feat (vaccine-data): add migration and fix entity
This commit is contained in:
No files matched your search
@@ -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=
|
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||||
@@ -163,3 +163,4 @@ h1:bNByj2VsHOaJEMfbX3xRNdLNTeYIVgInihZwRFfBUpc=
|
|||||||
20251210145148.sql h1:rejGrnTpaygxPv06v0vxMytF4rk1OJBXaw3ttSmidgc=
|
20251210145148.sql h1:rejGrnTpaygxPv06v0vxMytF4rk1OJBXaw3ttSmidgc=
|
||||||
20251211101547.sql h1:+jT5yRCEsSRExzoawrqymS/I7lVfwUQQSgSzbxCxgRk=
|
20251211101547.sql h1:+jT5yRCEsSRExzoawrqymS/I7lVfwUQQSgSzbxCxgRk=
|
||||||
20251211113942.sql h1:hRwiVZnXGzgUbqOk5TZ6ZHzGs1GebIFeIKkJNb+6+f0=
|
20251211113942.sql h1:hRwiVZnXGzgUbqOk5TZ6ZHzGs1GebIFeIKkJNb+6+f0=
|
||||||
|
20251216074834.sql h1:OJkATzCGB8NQlhaNblRMRhBLuT5XV1YSUWhtYjJzxl0=
|
||||||
@@ -30,6 +30,7 @@ import (
|
|||||||
er "simrs-vx/internal/domain/main-entities/rehab/base"
|
er "simrs-vx/internal/domain/main-entities/rehab/base"
|
||||||
es "simrs-vx/internal/domain/main-entities/specialist"
|
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||||
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||||
|
evd "simrs-vx/internal/domain/main-entities/vaccine-data"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
@@ -234,6 +235,7 @@ type ResponseDto struct {
|
|||||||
EncounterDocuments *[]eed.EncounterDocument `json:"encounterDocuments,omitempty"`
|
EncounterDocuments *[]eed.EncounterDocument `json:"encounterDocuments,omitempty"`
|
||||||
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
||||||
Responsible_Nurse *en.Nurse `json:"responsible_nurse,omitempty"`
|
Responsible_Nurse *en.Nurse `json:"responsible_nurse,omitempty"`
|
||||||
|
Vaccines *evd.VaccineData `json:"vaccines,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Encounter) ToResponse() ResponseDto {
|
func (d Encounter) ToResponse() ResponseDto {
|
||||||
@@ -281,6 +283,7 @@ func (d Encounter) ToResponse() ResponseDto {
|
|||||||
EncounterDocuments: d.EncounterDocuments,
|
EncounterDocuments: d.EncounterDocuments,
|
||||||
Responsible_Nurse_Code: d.Responsible_Nurse_Code,
|
Responsible_Nurse_Code: d.Responsible_Nurse_Code,
|
||||||
Responsible_Nurse: d.Responsible_Nurse,
|
Responsible_Nurse: d.Responsible_Nurse,
|
||||||
|
Vaccines: d.Vaccines,
|
||||||
}
|
}
|
||||||
resp.Main = d.Main
|
resp.Main = d.Main
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
er "simrs-vx/internal/domain/main-entities/rehab/base"
|
er "simrs-vx/internal/domain/main-entities/rehab/base"
|
||||||
es "simrs-vx/internal/domain/main-entities/specialist"
|
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||||
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||||
|
evd "simrs-vx/internal/domain/main-entities/vaccine-data"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Encounter struct {
|
type Encounter struct {
|
||||||
@@ -77,6 +78,7 @@ type Encounter struct {
|
|||||||
VclaimReference *evr.VclaimReference `json:"vclaimReference,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
VclaimReference *evr.VclaimReference `json:"vclaimReference,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||||
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
||||||
Responsible_Nurse *en.Nurse `json:"responsible_nurse,omitempty" gorm:"foreignKey:Responsible_Nurse_Code;references: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 {
|
func (d Encounter) IsDone() bool {
|
||||||
|
|||||||
@@ -5,24 +5,22 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
// internal - lib
|
// internal - lib
|
||||||
|
erc "simrs-vx/internal/domain/references/clinical"
|
||||||
|
|
||||||
// internal - domain - base-entities
|
// internal - domain - base-entities
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
|
|
||||||
// internal - domain - main-entities
|
// internal - domain - main-entities
|
||||||
|
|
||||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateDto struct {
|
type CreateDto struct {
|
||||||
Vaccine_type_Code *string `json:"vaccine_type_code"`
|
Type *erc.VaccineTypeCode `json:"type"`
|
||||||
Encounter_Id *uint `json:"encounter_id"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
BatchNumber *string `json:"batchNumber"`
|
||||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
Dose *float64 `json:"dose"`
|
||||||
Dose_order *uint `json:"dose_order"`
|
DoseOrder *uint `json:"doseOrder"`
|
||||||
Injection_location *string `json:"injection_location"`
|
InjectionLocation *string `json:"injectionLocation"`
|
||||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
GivenDate *time.Time `json:"givenDate"`
|
||||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
ExpirationDate *time.Time `json:"expirationDate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadListDto struct {
|
type ReadListDto struct {
|
||||||
@@ -32,15 +30,14 @@ type ReadListDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
Encounter_Id *uint `json:"encounter-id"`
|
Type *erc.VaccineTypeCode `json:"type"`
|
||||||
Date *time.Time `json:"date"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
Vaccine_type_Code *string `json:"vaccine-type-code"`
|
BatchNumber *string `json:"batchNumber"`
|
||||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
Dose *float64 `json:"dose"`
|
||||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
DoseOrder *uint `json:"doseOrder"`
|
||||||
Dose_order *uint `json:"dose_order"`
|
InjectionLocation *string `json:"injectionLocation"`
|
||||||
Injection_location *string `json:"injection_location"`
|
GivenDate *time.Time `json:"givenDate"`
|
||||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
ExpirationDate *time.Time `json:"expirationDate"`
|
||||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadDetailDto struct {
|
type ReadDetailDto struct {
|
||||||
@@ -65,28 +62,26 @@ type MetaDto struct {
|
|||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
ecore.Main
|
ecore.Main
|
||||||
Vaccine_type_Code *string `json:"vaccine_type_code"`
|
Type *erc.VaccineTypeCode `json:"type"`
|
||||||
Encounter_Id *uint `json:"encounter_id"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"`
|
BatchNumber *string `json:"batchNumber"`
|
||||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
Dose *float64 `json:"dose"`
|
||||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
DoseOrder *uint `json:"doseOrder"`
|
||||||
Dose_order *uint `json:"dose_order"`
|
InjectionLocation *string `json:"injectionLocation"`
|
||||||
Injection_location *string `json:"injection_location"`
|
GivenDate *time.Time `json:"givenDate"`
|
||||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
ExpirationDate *time.Time `json:"expirationDate"`
|
||||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d VaccineData) ToResponse() ResponseDto {
|
func (d VaccineData) ToResponse() ResponseDto {
|
||||||
resp := ResponseDto{
|
resp := ResponseDto{
|
||||||
Encounter_Id: d.Encounter_Id,
|
Type: d.Type,
|
||||||
Encounter: d.Encounter,
|
Encounter_Id: d.Encounter_Id,
|
||||||
Vaccine_type_Code: d.Vaccine_type_Code,
|
BatchNumber: d.BatchNumber,
|
||||||
Vaccine_batch_number: d.Vaccine_batch_number,
|
Dose: d.Dose,
|
||||||
Vaccine_dose: d.Vaccine_dose,
|
DoseOrder: d.DoseOrder,
|
||||||
Dose_order: d.Dose_order,
|
InjectionLocation: d.InjectionLocation,
|
||||||
Injection_location: d.Injection_location,
|
GivenDate: d.GivenDate,
|
||||||
Vaccination_datetime: d.Vaccination_datetime,
|
ExpirationDate: d.ExpirationDate,
|
||||||
Vaccine_expiration_date: d.Vaccine_expiration_date,
|
|
||||||
}
|
}
|
||||||
resp.Main = d.Main
|
resp.Main = d.Main
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
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 {
|
type VaccineData struct {
|
||||||
ecore.Main // adjust this according to the needs
|
ecore.Main // adjust this according to the needs
|
||||||
Vaccine_type_Code *string `json:"vaccine_type_code"`
|
Type *erc.VaccineTypeCode `json:"type" gorm:"size:25"`
|
||||||
Encounter_Id *uint `json:"encounter_id"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"`
|
BatchNumber *string `json:"batchNumber"`
|
||||||
Vaccine_batch_number *uint `json:"vaccine_batch_number"`
|
Dose *float64 `json:"dose"`
|
||||||
Vaccine_dose *uint `json:"vaccine_dose"`
|
DoseOrder *uint `json:"doseOrder"`
|
||||||
Dose_order *uint `json:"dose_order"`
|
InjectionLocation *string `json:"injectionLocation"`
|
||||||
Injection_location *string `json:"injection_location"`
|
GivenDate *time.Time `json:"givenDate"`
|
||||||
Vaccination_datetime *time.Time `json:"vaccination_datetime"`
|
ExpirationDate *time.Time `json:"expirationDate"`
|
||||||
Vaccine_expiration_date *time.Time `json:"vaccine_expiration_date"`
|
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ type (
|
|||||||
BornLocationCode string
|
BornLocationCode string
|
||||||
SpecimentDestCode string
|
SpecimentDestCode string
|
||||||
ProcedureReportType string
|
ProcedureReportType string
|
||||||
|
VaccineTypeCode string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -243,6 +244,21 @@ const (
|
|||||||
|
|
||||||
PRTProcedure ProcedureReportType = "procedure"
|
PRTProcedure ProcedureReportType = "procedure"
|
||||||
PRTSurgery ProcedureReportType = "surgery"
|
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 {
|
type Soapi struct {
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if pu.IsDateBeforeNow(input.Vaccination_datetime) {
|
if pu.IsDateBeforeNow(input.GivenDate) {
|
||||||
return errors.New("vaccination date is in the past")
|
return errors.New("given 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")
|
return errors.New("expiration date is in the past")
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if encounter is done
|
// check if encounter is done
|
||||||
@@ -206,10 +206,10 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if pu.IsDateBeforeNow(input.Vaccination_datetime) {
|
if pu.IsDateBeforeNow(input.GivenDate) {
|
||||||
return errors.New("vaccination date is in the past")
|
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")
|
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
|
inputSrc = &inputTemp.CreateDto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.Type = inputSrc.Type
|
||||||
data.Encounter_Id = inputSrc.Encounter_Id
|
data.Encounter_Id = inputSrc.Encounter_Id
|
||||||
data.Vaccine_type_Code = inputSrc.Vaccine_type_Code
|
data.BatchNumber = inputSrc.BatchNumber
|
||||||
data.Vaccine_batch_number = inputSrc.Vaccine_batch_number
|
data.Dose = inputSrc.Dose
|
||||||
data.Vaccine_dose = inputSrc.Vaccine_dose
|
data.DoseOrder = inputSrc.DoseOrder
|
||||||
data.Dose_order = inputSrc.Dose_order
|
data.InjectionLocation = inputSrc.InjectionLocation
|
||||||
data.Injection_location = inputSrc.Injection_location
|
data.GivenDate = inputSrc.GivenDate
|
||||||
data.Vaccination_datetime = inputSrc.Vaccination_datetime
|
data.ExpirationDate = inputSrc.ExpirationDate
|
||||||
data.Vaccine_expiration_date = inputSrc.Vaccine_expiration_date
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user