feat (vaccine-data): add migration and fix entity
This commit is contained in:
17
cmd/main-migration/migrations/20251216074834.sql
Normal file
17
cmd/main-migration/migrations/20251216074834.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Create "VaccineData" table
|
||||
CREATE TABLE "public"."VaccineData" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Type" character varying(25) NULL,
|
||||
"Encounter_Id" bigint NULL,
|
||||
"BatchNumber" text NULL,
|
||||
"Dose" numeric NULL,
|
||||
"DoseOrder" bigint NULL,
|
||||
"InjectionLocation" text NULL,
|
||||
"GivenDate" timestamptz NULL,
|
||||
"ExpirationDate" timestamptz NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_Encounter_Vaccines" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -1,4 +1,4 @@
|
||||
h1:bNByj2VsHOaJEMfbX3xRNdLNTeYIVgInihZwRFfBUpc=
|
||||
h1:hG7tbR8A3hp2zgbUt9pwONdJrHiSfrgcVBWoRB8Cx9k=
|
||||
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||
@@ -163,3 +163,4 @@ h1:bNByj2VsHOaJEMfbX3xRNdLNTeYIVgInihZwRFfBUpc=
|
||||
20251210145148.sql h1:rejGrnTpaygxPv06v0vxMytF4rk1OJBXaw3ttSmidgc=
|
||||
20251211101547.sql h1:+jT5yRCEsSRExzoawrqymS/I7lVfwUQQSgSzbxCxgRk=
|
||||
20251211113942.sql h1:hRwiVZnXGzgUbqOk5TZ6ZHzGs1GebIFeIKkJNb+6+f0=
|
||||
20251216074834.sql h1:OJkATzCGB8NQlhaNblRMRhBLuT5XV1YSUWhtYjJzxl0=
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
er "simrs-vx/internal/domain/main-entities/rehab/base"
|
||||
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
evd "simrs-vx/internal/domain/main-entities/vaccine-data"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
@@ -234,6 +235,7 @@ type ResponseDto struct {
|
||||
EncounterDocuments *[]eed.EncounterDocument `json:"encounterDocuments,omitempty"`
|
||||
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
||||
Responsible_Nurse *en.Nurse `json:"responsible_nurse,omitempty"`
|
||||
Vaccines *evd.VaccineData `json:"vaccines,omitempty"`
|
||||
}
|
||||
|
||||
func (d Encounter) ToResponse() ResponseDto {
|
||||
@@ -281,6 +283,7 @@ func (d Encounter) ToResponse() ResponseDto {
|
||||
EncounterDocuments: d.EncounterDocuments,
|
||||
Responsible_Nurse_Code: d.Responsible_Nurse_Code,
|
||||
Responsible_Nurse: d.Responsible_Nurse,
|
||||
Vaccines: d.Vaccines,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
er "simrs-vx/internal/domain/main-entities/rehab/base"
|
||||
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
evd "simrs-vx/internal/domain/main-entities/vaccine-data"
|
||||
)
|
||||
|
||||
type Encounter struct {
|
||||
@@ -77,6 +78,7 @@ type Encounter struct {
|
||||
VclaimReference *evr.VclaimReference `json:"vclaimReference,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
||||
Responsible_Nurse *en.Nurse `json:"responsible_nurse,omitempty" gorm:"foreignKey:Responsible_Nurse_Code;references:Code"`
|
||||
Vaccines *evd.VaccineData `json:"vaccines,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Encounter) IsDone() bool {
|
||||
|
||||
@@ -5,24 +5,22 @@ import (
|
||||
"time"
|
||||
|
||||
// internal - lib
|
||||
erc "simrs-vx/internal/domain/references/clinical"
|
||||
|
||||
// internal - domain - base-entities
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
|
||||
// internal - domain - main-entities
|
||||
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Vaccine_type_Code *string `json:"vaccine_type_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
||||
Dose_order *uint `json:"dose_order"`
|
||||
Injection_location *string `json:"injection_location"`
|
||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
||||
Type *erc.VaccineTypeCode `json:"type"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
BatchNumber *string `json:"batchNumber"`
|
||||
Dose *float64 `json:"dose"`
|
||||
DoseOrder *uint `json:"doseOrder"`
|
||||
InjectionLocation *string `json:"injectionLocation"`
|
||||
GivenDate *time.Time `json:"givenDate"`
|
||||
ExpirationDate *time.Time `json:"expirationDate"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -32,15 +30,14 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Date *time.Time `json:"date"`
|
||||
Vaccine_type_Code *string `json:"vaccine-type-code"`
|
||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
||||
Dose_order *uint `json:"dose_order"`
|
||||
Injection_location *string `json:"injection_location"`
|
||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
||||
Type *erc.VaccineTypeCode `json:"type"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
BatchNumber *string `json:"batchNumber"`
|
||||
Dose *float64 `json:"dose"`
|
||||
DoseOrder *uint `json:"doseOrder"`
|
||||
InjectionLocation *string `json:"injectionLocation"`
|
||||
GivenDate *time.Time `json:"givenDate"`
|
||||
ExpirationDate *time.Time `json:"expirationDate"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
@@ -65,28 +62,26 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Vaccine_type_Code *string `json:"vaccine_type_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
||||
Dose_order *uint `json:"dose_order"`
|
||||
Injection_location *string `json:"injection_location"`
|
||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
||||
Type *erc.VaccineTypeCode `json:"type"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
BatchNumber *string `json:"batchNumber"`
|
||||
Dose *float64 `json:"dose"`
|
||||
DoseOrder *uint `json:"doseOrder"`
|
||||
InjectionLocation *string `json:"injectionLocation"`
|
||||
GivenDate *time.Time `json:"givenDate"`
|
||||
ExpirationDate *time.Time `json:"expirationDate"`
|
||||
}
|
||||
|
||||
func (d VaccineData) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Vaccine_type_Code: d.Vaccine_type_Code,
|
||||
Vaccine_batch_number: d.Vaccine_batch_number,
|
||||
Vaccine_dose: d.Vaccine_dose,
|
||||
Dose_order: d.Dose_order,
|
||||
Injection_location: d.Injection_location,
|
||||
Vaccination_datetime: d.Vaccination_datetime,
|
||||
Vaccine_expiration_date: d.Vaccine_expiration_date,
|
||||
Type: d.Type,
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
BatchNumber: d.BatchNumber,
|
||||
Dose: d.Dose,
|
||||
DoseOrder: d.DoseOrder,
|
||||
InjectionLocation: d.InjectionLocation,
|
||||
GivenDate: d.GivenDate,
|
||||
ExpirationDate: d.ExpirationDate,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -4,18 +4,18 @@ import (
|
||||
"time"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/clinical"
|
||||
)
|
||||
|
||||
type VaccineData struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Vaccine_type_Code *string `json:"vaccine_type_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
||||
Dose_order *uint `json:"dose_order"`
|
||||
Injection_location *string `json:"injection_location"`
|
||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Type *erc.VaccineTypeCode `json:"type" gorm:"size:25"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
BatchNumber *string `json:"batchNumber"`
|
||||
Dose *float64 `json:"dose"`
|
||||
DoseOrder *uint `json:"doseOrder"`
|
||||
InjectionLocation *string `json:"injectionLocation"`
|
||||
GivenDate *time.Time `json:"givenDate"`
|
||||
ExpirationDate *time.Time `json:"expirationDate"`
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ type (
|
||||
BornLocationCode string
|
||||
SpecimentDestCode string
|
||||
ProcedureReportType string
|
||||
VaccineTypeCode string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -243,6 +244,21 @@ const (
|
||||
|
||||
PRTProcedure ProcedureReportType = "procedure"
|
||||
PRTSurgery ProcedureReportType = "surgery"
|
||||
|
||||
VaccineBCG VaccineTypeCode = "BCG" // BCG
|
||||
VaccineIPV VaccineTypeCode = "IPV" // IPV
|
||||
VaccineTD VaccineTypeCode = "TD" // TD
|
||||
VaccinePCVPneumoni VaccineTypeCode = "PCVPneumoni" // PCV pneumoni
|
||||
VaccineRotavirus VaccineTypeCode = "ROTAVIRUS" // ROTAVIRUS
|
||||
VaccineDT VaccineTypeCode = "DT" // DT
|
||||
VaccineTT VaccineTypeCode = "TT" // TT
|
||||
VaccineMRCampak VaccineTypeCode = "MRCampak" // MR / Campak
|
||||
VaccineHB VaccineTypeCode = "HB" // HB
|
||||
VaccineHIV VaccineTypeCode = "HIV" // HIV
|
||||
VaccineDPT VaccineTypeCode = "DPT" // DPT
|
||||
VaccineInfluenzaBType VaccineTypeCode = "INFLUENZABType" // INFLUENSA tipe B
|
||||
VaccinePolioOPV VaccineTypeCode = "PolioOPV" // Polio OPV
|
||||
VaccinePolioDrops VaccineTypeCode = "PolioDrops" // Polio Tetes
|
||||
)
|
||||
|
||||
type Soapi struct {
|
||||
|
||||
@@ -37,11 +37,11 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if pu.IsDateBeforeNow(input.Vaccination_datetime) {
|
||||
return errors.New("vaccination date is in the past")
|
||||
if pu.IsDateBeforeNow(input.GivenDate) {
|
||||
return errors.New("given date is in the past")
|
||||
}
|
||||
if pu.IsDateBeforeNow(input.Vaccine_expiration_date) {
|
||||
return errors.New("vaccine expiration date is in the past")
|
||||
if pu.IsDateBeforeNow(input.ExpirationDate) {
|
||||
return errors.New("expiration date is in the past")
|
||||
}
|
||||
|
||||
// check if encounter is done
|
||||
@@ -206,10 +206,10 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if pu.IsDateBeforeNow(input.Vaccination_datetime) {
|
||||
if pu.IsDateBeforeNow(input.GivenDate) {
|
||||
return errors.New("vaccination date is in the past")
|
||||
}
|
||||
if pu.IsDateBeforeNow(input.Vaccine_expiration_date) {
|
||||
if pu.IsDateBeforeNow(input.ExpirationDate) {
|
||||
return errors.New("vaccine expiration date is in the past")
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.VaccineData) {
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Type = inputSrc.Type
|
||||
data.Encounter_Id = inputSrc.Encounter_Id
|
||||
data.Vaccine_type_Code = inputSrc.Vaccine_type_Code
|
||||
data.Vaccine_batch_number = inputSrc.Vaccine_batch_number
|
||||
data.Vaccine_dose = inputSrc.Vaccine_dose
|
||||
data.Dose_order = inputSrc.Dose_order
|
||||
data.Injection_location = inputSrc.Injection_location
|
||||
data.Vaccination_datetime = inputSrc.Vaccination_datetime
|
||||
data.Vaccine_expiration_date = inputSrc.Vaccine_expiration_date
|
||||
data.BatchNumber = inputSrc.BatchNumber
|
||||
data.Dose = inputSrc.Dose
|
||||
data.DoseOrder = inputSrc.DoseOrder
|
||||
data.InjectionLocation = inputSrc.InjectionLocation
|
||||
data.GivenDate = inputSrc.GivenDate
|
||||
data.ExpirationDate = inputSrc.ExpirationDate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user