diff --git a/cmd/main-migration/migrations/20251205073858.sql b/cmd/main-migration/migrations/20251205073858.sql new file mode 100644 index 00000000..96f9200a --- /dev/null +++ b/cmd/main-migration/migrations/20251205073858.sql @@ -0,0 +1,23 @@ +-- Modify "Chemo" table +ALTER TABLE "public"."Chemo" ADD COLUMN "Doctor_Code" character varying(20) NULL, ADD COLUMN "NextChemoDate" timestamptz NULL, ADD CONSTRAINT "fk_Chemo_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Rename a column from "Encounter_Id" to "Chemo_Id" +ALTER TABLE "public"."ChemoProtocol" RENAME COLUMN "Encounter_Id" TO "Chemo_Id"; +-- Modify "ChemoProtocol" table +ALTER TABLE "public"."ChemoProtocol" DROP CONSTRAINT "fk_ChemoProtocol_Encounter", ALTER COLUMN "DurationUnit_Code" TYPE text, ADD COLUMN "Interval" bigint NULL, ADD COLUMN "Cycle" bigint NULL, ADD COLUMN "Series" integer NULL, ADD COLUMN "Status_Code" text NULL, ADD CONSTRAINT "fk_ChemoProtocol_Chemo" FOREIGN KEY ("Chemo_Id") REFERENCES "public"."Chemo" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Create "ChemoPlan" table +CREATE TABLE "public"."ChemoPlan" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Parent_Id" bigint NULL, + "Protocol_Id" bigint NULL, + "SeriesNumber" integer NULL, + "CycleNumber" bigint NULL, + "PlanDate" timestamptz NULL, + "RealizationDate" timestamptz NULL, + "Notes" text NULL, + "Status" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_ChemoPlan_Protocol" FOREIGN KEY ("Protocol_Id") REFERENCES "public"."ChemoProtocol" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 341a35d3..9b12364f 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:DgMML95zGYI7JMvZaIb/gySCvncMu62CANOIXNX0A6w= +h1:2pGamYMy0LEZE7Du/0SEb8z5LrkmpNk199Yw0CJri+M= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -144,3 +144,4 @@ h1:DgMML95zGYI7JMvZaIb/gySCvncMu62CANOIXNX0A6w= 20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= +20251205073858.sql h1:GD692c2jC2mFr6esv3eQmxEpWOeIA860TGctwHAldfM= diff --git a/internal/domain/main-entities/chemo-plan/dto.go b/internal/domain/main-entities/chemo-plan/dto.go new file mode 100644 index 00000000..b3e89d80 --- /dev/null +++ b/internal/domain/main-entities/chemo-plan/dto.go @@ -0,0 +1,90 @@ +package chemo_plan + +import ( + ecp "simrs-vx/internal/domain/main-entities/chemo-protocol" + ere "simrs-vx/internal/domain/references/encounter" + // std + "time" + + // internal - domain - main-entities + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type CreateDto struct { + Parent_Id *uint `json:"parent_id"` + Protocol_Id *uint `json:"protocol_id"` + SeriesNumber *uint16 `json:"seriesNumber"` + CycleNumber *uint `json:"cycleNumber"` + PlanDate *time.Time `json:"planDate"` + RealizationDate *time.Time `json:"realizationDate"` + Notes *string `json:"notes"` + Status ere.StatusProtocolChemo `json:"status"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Parent_Id *uint `json:"parent-id"` + Protocol_Id *uint `json:"protocol-id"` +} + +type ReadDetailDto struct { + Id uint16 `json:"id"` + Includes string `json:"includes"` +} + +type UpdateDto struct { + Id uint16 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint16 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.Main + Parent_Id *uint `json:"parent_id"` // chemo.Id + Protocol_Id *uint `json:"protocol_id"` + Protocol ecp.ChemoProtocol `json:"protocol,omitempty"` + SeriesNumber *uint16 `json:"seriesNumber"` // series ke - + CycleNumber *uint `json:"cycleNumber"` // cycle ke - + PlanDate *time.Time `json:"planDate"` + RealizationDate *time.Time `json:"realizationDate"` + Notes *string `json:"notes"` + Status ere.StatusProtocolChemo `json:"status"` +} + +func (d ChemoPlan) ToResponse() ResponseDto { + resp := ResponseDto{ + Parent_Id: d.Parent_Id, + Protocol_Id: d.Protocol_Id, + Protocol: d.Protocol, + SeriesNumber: d.SeriesNumber, + CycleNumber: d.CycleNumber, + PlanDate: d.PlanDate, + RealizationDate: d.RealizationDate, + Notes: d.Notes, + Status: d.Status, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []ChemoPlan) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/chemo-plan/entity.go b/internal/domain/main-entities/chemo-plan/entity.go new file mode 100644 index 00000000..08ac905d --- /dev/null +++ b/internal/domain/main-entities/chemo-plan/entity.go @@ -0,0 +1,24 @@ +package chemo_plan + +import ( + "time" + + ecore "simrs-vx/internal/domain/base-entities/core" + + ere "simrs-vx/internal/domain/references/encounter" + + ecp "simrs-vx/internal/domain/main-entities/chemo-protocol" +) + +type ChemoPlan struct { + ecore.Main + Parent_Id *uint `json:"parent_id"` // chemo.Id + Protocol_Id *uint `json:"protocol_id"` + Protocol ecp.ChemoProtocol `json:"protocol,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"` + SeriesNumber *uint16 `json:"seriesNumber"` // series ke - + CycleNumber *uint `json:"cycleNumber"` // cycle ke - + PlanDate *time.Time `json:"planDate"` + RealizationDate *time.Time `json:"realizationDate"` + Notes *string `json:"notes"` + Status ere.StatusProtocolChemo `json:"status"` +} diff --git a/internal/domain/main-entities/chemo-protocol/dto.go b/internal/domain/main-entities/chemo-protocol/dto.go index 04ea0023..03ad0c10 100644 --- a/internal/domain/main-entities/chemo-protocol/dto.go +++ b/internal/domain/main-entities/chemo-protocol/dto.go @@ -9,18 +9,21 @@ import ( // internal - domain - main-entities ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/encounter" + + ec "simrs-vx/internal/domain/main-entities/chemo" ) type CreateDto struct { - Encounter_Id *uint `json:"encounter_id"` - Patient_Weight *float32 `json:"patient_weight"` - Patient_Height *float32 `json:"patient_height"` - Diagnoses *string `json:"diagnoses"` - Duration *uint `json:"duration"` - DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"` - StartDate *time.Time `json:"startDate"` - EndDate *time.Time `json:"endDate"` + Chemo_Id *uint `json:"chemo_id"` + Patient_Weight *float32 `json:"patient_weight"` + Patient_Height *float32 `json:"patient_height"` + Diagnoses *string `json:"diagnoses"` + Interval *uint `json:"interval"` + Cycle *uint `json:"cycle"` + Series *uint16 `json:"series"` + StartDate *time.Time `json:"startDate"` + EndDate *time.Time `json:"endDate"` + Status_Code erc.DataVerifiedCode `json:"-"` } type ReadListDto struct { @@ -30,7 +33,7 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` + Chemo_Id *uint `json:"chemo-id"` } type ReadDetailDto struct { @@ -55,28 +58,32 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Encounter_Id *uint `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty"` - Patient_Weight *float32 `json:"patient_weight"` - Patient_Height *float32 `json:"patient_height"` - Diagnoses *string `json:"diagnoses"` - Duration *uint `json:"duration"` - DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"` - StartDate *time.Time `json:"startDate"` - EndDate *time.Time `json:"endDate"` + Chemo_Id *uint `json:"chemo_id"` + Chemo *ec.Chemo `json:"chemo,omitempty"` + Patient_Weight *float32 `json:"patient_weight"` + Patient_Height *float32 `json:"patient_height"` + Diagnoses *string `json:"diagnoses"` + Interval *uint `json:"interval"` + Cycle *uint `json:"cycle"` + Series *uint16 `json:"series"` + StartDate *time.Time `json:"startDate"` + EndDate *time.Time `json:"endDate"` + Status_Code erc.DataVerifiedCode `json:"status_code"` } func (d ChemoProtocol) ToResponse() ResponseDto { resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Encounter: d.Encounter, - Patient_Weight: d.Patient_Weight, - Patient_Height: d.Patient_Height, - Diagnoses: d.Diagnoses, - Duration: d.Duration, - DurationUnit_Code: d.DurationUnit_Code, - StartDate: d.StartDate, - EndDate: d.EndDate, + Chemo_Id: d.Chemo_Id, + Chemo: d.Chemo, + Patient_Weight: d.Patient_Weight, + Patient_Height: d.Patient_Height, + Diagnoses: d.Diagnoses, + Interval: d.Interval, + Cycle: d.Cycle, + Series: d.Series, + StartDate: d.StartDate, + EndDate: d.EndDate, + Status_Code: d.Status_Code, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/chemo-protocol/entity.go b/internal/domain/main-entities/chemo-protocol/entity.go index e1508e91..e20f3592 100644 --- a/internal/domain/main-entities/chemo-protocol/entity.go +++ b/internal/domain/main-entities/chemo-protocol/entity.go @@ -1,21 +1,27 @@ package chemo_protocol import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/encounter" - "simrs-vx/internal/domain/references/common" "time" + + ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" + + ec "simrs-vx/internal/domain/main-entities/chemo" ) type ChemoProtocol struct { ecore.Main - Encounter_Id *uint `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Chemo_Id *uint `json:"chemo_id"` + Chemo *ec.Chemo `json:"chemo,omitempty" gorm:"foreignKey:Chemo_Id;references:Id"` Patient_Weight *float32 `json:"patient_weight"` Patient_Height *float32 `json:"patient_height"` Diagnoses *string `json:"diagnoses"` - Duration *uint `json:"duration"` - DurationUnit_Code *common.TimeUnitCode `json:"durationUnit_code" gorm:"size:10"` + Duration *uint `json:"duration"` // not used + DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"` // not used + Interval *uint `json:"interval"` + Cycle *uint `json:"cycle"` // total cycle + Series *uint16 `json:"series"` // total series StartDate *time.Time `json:"startDate"` EndDate *time.Time `json:"endDate"` + Status_Code erc.DataVerifiedCode `json:"status_code"` } diff --git a/internal/domain/main-entities/chemo/dto.go b/internal/domain/main-entities/chemo/dto.go index 5d8b9501..461203d2 100644 --- a/internal/domain/main-entities/chemo/dto.go +++ b/internal/domain/main-entities/chemo/dto.go @@ -1,6 +1,7 @@ package chemo import ( + ed "simrs-vx/internal/domain/main-entities/doctor" // std "time" @@ -50,10 +51,12 @@ type DeleteDto struct { } type VerifyDto struct { - Id uint16 `json:"id"` - Status_Code erc.DataVerifiedCode `json:"status_code"` - Bed *string `json:"bed" validate:"required"` - Needs *string `json:"needs" validate:"required"` + Id uint16 `json:"id"` + Status_Code erc.DataVerifiedCode `json:"status_code"` + Bed *string `json:"bed"` + Needs *string `json:"needs"` + Doctor_Code *string `json:"doctor_code" validate:"required"` + NextChemoDate *time.Time `json:"nextChemoDate"` pa.AuthInfo } @@ -74,6 +77,9 @@ type ResponseDto struct { VerifiedBy *eus.User `json:"verifiedBy,omitempty"` SrcUnit_Code *string `json:"srcUnit_code"` SrcUnit *eun.Unit `json:"srcUnit,omitempty"` + Doctor_Code *string `json:"doctor_code"` + Doctor *ed.Doctor `json:"doctor,omitempty"` + NextChemoDate *time.Time `json:"nextChemoDate"` } func (d Chemo) ToResponse() ResponseDto { @@ -86,6 +92,9 @@ func (d Chemo) ToResponse() ResponseDto { VerifiedBy: d.VerifiedBy, SrcUnit_Code: d.SrcUnit_Code, SrcUnit: d.SrcUnit, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + NextChemoDate: d.NextChemoDate, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/chemo/entity.go b/internal/domain/main-entities/chemo/entity.go index 6f5180aa..682333ed 100644 --- a/internal/domain/main-entities/chemo/entity.go +++ b/internal/domain/main-entities/chemo/entity.go @@ -4,11 +4,12 @@ import ( "time" ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" + + ed "simrs-vx/internal/domain/main-entities/doctor" ee "simrs-vx/internal/domain/main-entities/encounter" eun "simrs-vx/internal/domain/main-entities/unit" eus "simrs-vx/internal/domain/main-entities/user" - - erc "simrs-vx/internal/domain/references/common" ) type Chemo struct { @@ -19,8 +20,11 @@ type Chemo struct { VerifiedAt *time.Time `json:"verifiedAt"` VerifiedBy_User_Id *uint `json:"verifiedBy_user_id"` VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"` - SrcUnit_Code *string `json:"src_unit_code"` + SrcUnit_Code *string `json:"src_unit_code"` // klinik asal SrcUnit *eun.Unit `json:"src_unit,omitempty" gorm:"foreignKey:SrcUnit_Code;references:Code"` Bed *string `json:"bed" gorm:"size:1024"` Needs *string `json:"needs" gorm:"size:2048"` + Doctor_Code *string `json:"doctor_code"` + Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Code;references:Code"` + NextChemoDate *time.Time `json:"nextChemoDate"` } diff --git a/internal/domain/references/encounter/encounter.go b/internal/domain/references/encounter/encounter.go index ad6abe05..83ef759b 100644 --- a/internal/domain/references/encounter/encounter.go +++ b/internal/domain/references/encounter/encounter.go @@ -22,6 +22,7 @@ type ( PolySwitchCode string DocTypeCode string EntityTypeCode string + StatusProtocolChemo string ) const ( @@ -128,6 +129,10 @@ const ( ETCPerson EntityTypeCode = "person" ETCEncounter EntityTypeCode = "encounter" ETCMCU EntityTypeCode = "mcu" + + SPCComplete StatusProtocolChemo = "complete" + SPCPlanned StatusProtocolChemo = "planned" + SPCSchedule StatusProtocolChemo = "schedule" ) func (ec EncounterClassCode) Code() string { diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 34530d78..4c182d22 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -11,6 +11,7 @@ import ( appointment "simrs-vx/internal/domain/main-entities/appointment" authpartner "simrs-vx/internal/domain/main-entities/auth-partner" chemo "simrs-vx/internal/domain/main-entities/chemo" + chemoplan "simrs-vx/internal/domain/main-entities/chemo-plan" chemoprotocol "simrs-vx/internal/domain/main-entities/chemo-protocol" consultation "simrs-vx/internal/domain/main-entities/consultation" controlletter "simrs-vx/internal/domain/main-entities/control-letter" @@ -235,5 +236,6 @@ func getMainEntities() []any { &vclaimreference.VclaimReference{}, &screening.Screening{}, &actionreport.ActionReport{}, + &chemoplan.ChemoPlan{}, } }