From 6d49dca9253be238e0d9ccb21e7521573ab7b775 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 10 Nov 2025 13:25:00 +0700 Subject: [PATCH] remove several ids and fix constraint --- .../migrations/20251110062042.sql | 14 ++++ cmd/main-migration/migrations/atlas.sum | 49 ++++++------ .../domain/main-entities/consultation/dto.go | 46 +++++------ .../main-entities/consultation/entity.go | 6 +- .../main-entities/control-letter/dto.go | 76 +++++++++---------- .../main-entities/control-letter/entity.go | 12 +-- internal/domain/main-entities/doctor/dto.go | 7 +- .../domain/main-entities/encounter/dto.go | 76 +++++++++---------- .../domain/main-entities/encounter/entity.go | 14 ++-- .../main-entities/internal-reference/dto.go | 16 ++-- .../internal-reference/entity.go | 6 +- internal/domain/main-entities/nurse/dto.go | 7 +- .../main-entities/practice-schedule/dto.go | 40 +++++----- .../main-entities/practice-schedule/entity.go | 3 +- .../responsible-doctor-hist/dto.go | 8 +- .../responsible-doctor-hist/entity.go | 3 +- .../main-entities/therapy-protocol/dto.go | 10 +-- .../main-entities/therapy-protocol/entity.go | 3 +- .../interface/main-handler/doctor/handler.go | 18 ++--- .../encounter/request-validation.go | 12 +-- .../interface/main-handler/nurse/handler.go | 18 ++--- .../main-use-case/consultation/case.go | 11 +-- .../main-use-case/consultation/helper.go | 2 +- .../main-use-case/control-letter/helper.go | 8 +- .../use-case/main-use-case/doctor/case.go | 4 +- internal/use-case/main-use-case/doctor/lib.go | 2 +- .../use-case/main-use-case/encounter/case.go | 30 ++++---- .../main-use-case/encounter/helper.go | 64 ++++++++-------- .../use-case/main-use-case/encounter/lib.go | 8 +- .../internal-reference/helper.go | 8 +- internal/use-case/main-use-case/nurse/case.go | 4 +- internal/use-case/main-use-case/nurse/lib.go | 2 +- .../main-use-case/practice-schedule/helper.go | 2 +- .../responsible-doctor-hist/helper.go | 2 +- .../main-use-case/therapy-protocol/case.go | 6 +- .../main-use-case/therapy-protocol/helper.go | 2 +- 36 files changed, 294 insertions(+), 305 deletions(-) create mode 100644 cmd/main-migration/migrations/20251110062042.sql diff --git a/cmd/main-migration/migrations/20251110062042.sql b/cmd/main-migration/migrations/20251110062042.sql new file mode 100644 index 00000000..9ec62cf7 --- /dev/null +++ b/cmd/main-migration/migrations/20251110062042.sql @@ -0,0 +1,14 @@ +-- Modify "Consultation" table +ALTER TABLE "public"."Consultation" DROP CONSTRAINT "fk_Consultation_DstDoctor", DROP CONSTRAINT "fk_Consultation_DstUnit", DROP COLUMN "DstUnit_Id", DROP COLUMN "DstDoctor_Id", ALTER COLUMN "DstUnit_Code" TYPE character varying(10), ALTER COLUMN "DstDoctor_Code" TYPE character varying(20), ADD CONSTRAINT "fk_Consultation_DstDoctor" FOREIGN KEY ("DstDoctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Consultation_DstUnit" FOREIGN KEY ("DstUnit_Code") REFERENCES "public"."Unit" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "ControlLetter" table +ALTER TABLE "public"."ControlLetter" DROP CONSTRAINT "fk_ControlLetter_Doctor", DROP CONSTRAINT "fk_ControlLetter_Specialist", DROP CONSTRAINT "fk_ControlLetter_Subspecialist", DROP CONSTRAINT "fk_ControlLetter_Unit", DROP COLUMN "Unit_Id", DROP COLUMN "Specialist_Id", DROP COLUMN "Subspecialist_Id", DROP COLUMN "Doctor_Id", ALTER COLUMN "Unit_Code" TYPE character varying(10), ALTER COLUMN "Specialist_Code" TYPE character varying(10), ALTER COLUMN "Subspecialist_Code" TYPE character varying(10), ALTER COLUMN "Doctor_Code" TYPE character varying(20), ADD CONSTRAINT "fk_ControlLetter_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ControlLetter_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ControlLetter_Subspecialist" FOREIGN KEY ("Subspecialist_Code") REFERENCES "public"."Subspecialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ControlLetter_Unit" FOREIGN KEY ("Unit_Code") REFERENCES "public"."Unit" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "Encounter" table +ALTER TABLE "public"."Encounter" DROP CONSTRAINT "fk_Encounter_Appointment_Doctor", DROP CONSTRAINT "fk_Encounter_Responsible_Doctor", DROP CONSTRAINT "fk_Encounter_Specialist", DROP CONSTRAINT "fk_Encounter_Subspecialist", DROP COLUMN "Specialist_Id", DROP COLUMN "Subspecialist_Id", DROP COLUMN "Responsible_Doctor_Id", DROP COLUMN "Appointment_Doctor_Id", ALTER COLUMN "Specialist_Code" TYPE character varying(10), ALTER COLUMN "Subspecialist_Code" TYPE character varying(10), ALTER COLUMN "Appointment_Doctor_Code" TYPE character varying(20), ALTER COLUMN "Responsible_Doctor_Code" TYPE character varying(20), ADD COLUMN "Unit_Code" text NULL, ADD COLUMN "InsuranceCompany_Code" text NULL, ADD CONSTRAINT "fk_Encounter_Appointment_Doctor" FOREIGN KEY ("Appointment_Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Encounter_Responsible_Doctor" FOREIGN KEY ("Responsible_Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Encounter_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Encounter_Subspecialist" FOREIGN KEY ("Subspecialist_Code") REFERENCES "public"."Subspecialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "InternalReference" table +ALTER TABLE "public"."InternalReference" DROP CONSTRAINT "fk_InternalReference_Doctor", DROP CONSTRAINT "fk_InternalReference_Unit", DROP COLUMN "Unit_Id", DROP COLUMN "Doctor_Id", ALTER COLUMN "Unit_Code" TYPE character varying(10), ALTER COLUMN "Doctor_Code" TYPE character varying(20), ADD CONSTRAINT "fk_InternalReference_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_InternalReference_Unit" FOREIGN KEY ("Unit_Code") REFERENCES "public"."Unit" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "PracticeSchedule" table +ALTER TABLE "public"."PracticeSchedule" DROP CONSTRAINT "fk_PracticeSchedule_Doctor", DROP COLUMN "Doctor_Id", ALTER COLUMN "Doctor_Code" TYPE character varying(20), ADD CONSTRAINT "fk_PracticeSchedule_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "ResponsibleDoctorHist" table +ALTER TABLE "public"."ResponsibleDoctorHist" DROP CONSTRAINT "fk_ResponsibleDoctorHist_Doctor", DROP COLUMN "Doctor_Id", ALTER COLUMN "Doctor_Code" TYPE character varying(20), ADD CONSTRAINT "fk_ResponsibleDoctorHist_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "TherapyProtocol" table +ALTER TABLE "public"."TherapyProtocol" DROP CONSTRAINT "fk_TherapyProtocol_Doctor", DROP COLUMN "Doctor_Id", ALTER COLUMN "Doctor_Code" TYPE character varying(20), ADD CONSTRAINT "fk_TherapyProtocol_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") 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 3db34cf7..c64990da 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:hb81CPD5BxIB57EVCP5A2oI+LHYxKAQkq+Q7yeGhbiw= +h1:BX21/eygPEF+JaTDfxN/z3+7YAe6EYWa1EK9N2PKhAE= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,26 +75,27 @@ h1:hb81CPD5BxIB57EVCP5A2oI+LHYxKAQkq+Q7yeGhbiw= 20251106040137.sql h1:ppcqkVoT0o9jZcjI/TN7LuaPxXhJQhnIXEJtloP/46o= 20251106041333.sql h1:2JkxyelQ/EeB+boL5bfpnzefw32ttEGKvKchtQjWmAU= 20251106042006.sql h1:ruppYa1kAJQUU3ufQBbKGMcXrGbGJJiRPclT+dNc/YQ= -20251106050412.sql h1:MiEMJ1HCFYnalKuq3Z38xJeogfBAMqsTv2sG4EF8dDw= -20251106063418.sql h1:y3veDJPjKekOWLCZek/LgQwXPRhZtOppTfUXiqoL95s= -20251106071906.sql h1:/TUZA3XpMY23qEJXdkTwlzrNMvSSl6JJniPcgAttBaw= -20251106073157.sql h1:78txeibJ602DMD7huD618ZSMt6phSRzDNPTlo0PGyrc= -20251106074218.sql h1:8Xz7WywrtUnSxOHhlal53gG9rE7r86LFUt5zBFe/mIs= -20251106081846.sql h1:jp91Bf5bxGXMiUB1VIuN6y768vb2iWwow44WfCE5J5k= -20251106082844.sql h1:RHYzRO4G1fSWwf+xc/3QezZ/Iil67cZPIgNpNz3TNhQ= -20251106090021.sql h1:dFDk6mq+zjbYWmfWIrHf9DiKvvoXHjrr0++zssMTWP8= -20251106144745.sql h1:aHcr23iBFqCHer5D/SsPMXBCLjGqUYvWYfRU8jSJgIw= -20251107012049.sql h1:hu/7NHhnAkT4xK0RNtqmMDdH1Bo5EZbl7itDRjiCT+g= -20251107064812.sql h1:sfCXDQYnMf0ddrQ9oYljWJLLSt9NJjJV6o8VS3p7aZE= -20251107064937.sql h1:DlYGJ9LZFwZyR7jBP5zaGB128aIc4HAixBKPYCz9EkY= -20251107071420.sql h1:ynCdZAd2utLl+FhtWZwtahNXgIVOvuk3s/rOq7lfXA4= -20251107074318.sql h1:WE9cPhibWtZ0dbu1VEGirTeY6ijFYGMNhHdBtM32kOc= -20251107075050.sql h1:8tvneruqdynDOaJK1+0z4CH7YXZStZpGdqwIeOMLik4= -20251107080604.sql h1:8c4jd4Tql7tcdhbI9NS0tgvN+ADu9FnCf8wMUbmW7A0= -20251107081830.sql h1:SAAe3lmsm9vGXuSEsDdl7ad0EAxP5CMmFRDEgp9M7yY= -20251107091033.sql h1:JLdX/u7GUdBfjrPrMSNAqc8HtSoj0YA9iW9Vc6FJZdw= -20251107091209.sql h1:CzhYtwAwT+GHrbqcagnJE+v3mbl/rObf1IJaLCKlzrs= -20251107091541.sql h1:+3ZyWJTftDY2JeWThXuIxGWpUBnyMPyOyY4jBjdWYJI= -20251110012217.sql h1:f4Z8TuGc+XMSJ+Ekn4/PeHRE2FlHWkc5gKPJB0hAX7c= -20251110012306.sql h1:ENPyI6Kjdk6qKJQb0yJ6MCTDPAmO1WD/uhKuCSl+jYo= -20251110052049.sql h1:OrQ0acnyoQLKnTitZfnBcVr5jDslF59OFLaqT7SpdVs= +20251106050412.sql h1:1002KYtHd8AwrQTMewbs/PPHDylHDghigE/3S7PVdMA= +20251106063418.sql h1:jPW/gBnbFl4RO39lQ0ZMDtYA6xbhyD6CgQupT50HmaY= +20251106071906.sql h1:leYGKxR3EQn794aOehf0sd/ZPmOnvBMZPy5/anGmRB4= +20251106073157.sql h1:KASMzjjjk5UB7Zj8lCRtM1utc4ZnDjlnpZbtTe3vONE= +20251106074218.sql h1:Z5q5deOvLaZDPhiVTN9st3/s56RepBa2YOyrMXBdj4A= +20251106081846.sql h1:P+VsWwhGt60adDIZuE/Aa38JVp/yX1rnsdpXpxASodw= +20251106082844.sql h1:Dmi5A8i9frQZvdXYPwc7f8CisZtBH8liSXq1rI6z1iM= +20251106090021.sql h1:4JwdKgO8T46YhyWVJUxpRIwudBDlG8QN1brSOYmgQ20= +20251106144745.sql h1:nqnQCzGrVJaq8ilOEOGXeRUL1dolj+OPWKuP8A92FRA= +20251107012049.sql h1:Pff4UqltGS3clSlGr0qq8CQM56L29wyxY0FC/N/YAhU= +20251107064812.sql h1:GB9a0ZfMYTIoGNmKUG+XcYUsTnRMFfT4/dAD71uCPc4= +20251107064937.sql h1:IC5pw1Ifj30hiE6dr5NMHXaSHoQI+vRd40N5ABgBHRI= +20251107071420.sql h1:9NO3iyLEXEtWa2kSRjM/8LyzuVIk6pdFL2SuheWjB08= +20251107074318.sql h1:7fHbSRrdjOmHh/xwnjCLwoiB5cW5zeH+uxLV0vZbkIA= +20251107075050.sql h1:np+3uTOnU9QNtK7Knaw8eRMhkyB9AwrtSNHphOBxbHY= +20251107080604.sql h1:cXDBLPJDVWLTG6yEJqkJsOQ7p7VYxLM2SY+mwO8qSHo= +20251107081830.sql h1:/S7OQZo4ZnK80t28g/JyiOTZtmWG/dP5Wg2zXNMQ/iE= +20251107091033.sql h1:/cbkF1nO/IjNSIfDJJx456KJtQ9rWFXOBFAkR/M2xiE= +20251107091209.sql h1:jrLQOUeV8ji2fg0pnEcs1bw4ANUxzTSMXC/rrHLIY+M= +20251107091541.sql h1:6UqbhQQRmzA2+eKu5lIvkwOkk+lH70QLZC8Pjpjcq68= +20251110012217.sql h1:C9HpX0iyHzKjyNv/5DSAn2MCHj6MX4p5UQ/NrY7QD0w= +20251110012306.sql h1:J54yb27d30LBbYp9n1P66gFVRlxPguKu0kxmWIBBG8g= +20251110052049.sql h1:1LkEGCWPe04T3D8F3VMnBP8eJgskrvCggsybNxJ7GuU= +20251110062042.sql h1:yUUNX3EekfedaGTt5Q89a0bgZoCu/kfdXLU4iljN5Xw= diff --git a/internal/domain/main-entities/consultation/dto.go b/internal/domain/main-entities/consultation/dto.go index 33868dd0..1b83df77 100644 --- a/internal/domain/main-entities/consultation/dto.go +++ b/internal/domain/main-entities/consultation/dto.go @@ -20,7 +20,7 @@ type CreateDto struct { Encounter_Id *uint `json:"encounter_id"` Date *time.Time `json:"date"` Problem *string `json:"problem" validate:"maxLength=10240"` - DstUnit_Id *uint `json:"dstUnit_id"` + DstUnit_Code *string `json:"dstUnit_code"` } type ReadListDto struct { @@ -30,9 +30,9 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` - DstUnit_Id *uint `json:"dstUnit-id"` - DstDoctor_Id *uint `json:"dstDoctor-id"` + Encounter_Id *uint `json:"encounter-id"` + DstUnit_Code *string `json:"dstUnit-code"` + DstDoctor_Code *string `json:"dstDoctor-code"` } type ReadDetailDto struct { @@ -63,29 +63,29 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Encounter_Id *uint `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty"` - Date *time.Time `json:"date"` - Problem *string `json:"problem"` - Solution *string `json:"solution"` - DstUnit_Id *uint `json:"dstUnit_id"` - DstUnit *eu.Unit `json:"dstUnit,omitempty"` - DstDoctor_Id *uint `json:"dstDoctor_id"` - DstDoctor *ed.Doctor `json:"dstDoctor,omitempty"` - RepliedAt *time.Time `json:"repliedAt"` + Encounter_Id *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty"` + Date *time.Time `json:"date"` + Problem *string `json:"problem"` + Solution *string `json:"solution"` + DstUnit_Code *string `json:"dstUnit_code"` + DstUnit *eu.Unit `json:"dstUnit,omitempty"` + DstDoctor_Code *string `json:"dstDoctor_code"` + DstDoctor *ed.Doctor `json:"dstDoctor,omitempty"` + RepliedAt *time.Time `json:"repliedAt"` } func (d Consultation) ToResponse() ResponseDto { resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Encounter: d.Encounter, - Date: d.Date, - Problem: d.Problem, - Solution: d.Solution, - DstUnit_Id: d.DstUnit_Id, - DstUnit: d.DstUnit, - DstDoctor_Id: d.DstDoctor_Id, - DstDoctor: d.DstDoctor, + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Date: d.Date, + Problem: d.Problem, + Solution: d.Solution, + DstUnit_Code: d.DstUnit_Code, + DstUnit: d.DstUnit, + DstDoctor_Code: d.DstDoctor_Code, + DstDoctor: d.DstDoctor, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/consultation/entity.go b/internal/domain/main-entities/consultation/entity.go index 06a44d57..b8be3596 100644 --- a/internal/domain/main-entities/consultation/entity.go +++ b/internal/domain/main-entities/consultation/entity.go @@ -17,11 +17,9 @@ type Consultation struct { Problem *string `json:"case" gorm:"size:10240"` Solution *string `json:"solution" gorm:"size:10240"` - DstUnit_Id *uint `json:"dstUnit_id"` DstUnit_Code *string `json:"dstUnit_code"` - DstUnit *eu.Unit `json:"dstUnit" gorm:"foreignKey:DstUnit_Id;references:Id"` - DstDoctor_Id *uint `json:"dstDoctor_id"` + DstUnit *eu.Unit `json:"dstUnit" gorm:"foreignKey:DstUnit_Code;references:Code"` DstDoctor_Code *string `json:"dstDoctor_code"` - DstDoctor *ed.Doctor `json:"dstDoctor" gorm:"foreignKey:DstDoctor_Id;references:Id"` + DstDoctor *ed.Doctor `json:"dstDoctor" gorm:"foreignKey:DstDoctor_Code;references:Code"` RepliedAt *time.Time `json:"repliedAt"` } diff --git a/internal/domain/main-entities/control-letter/dto.go b/internal/domain/main-entities/control-letter/dto.go index c2bab776..87b82366 100644 --- a/internal/domain/main-entities/control-letter/dto.go +++ b/internal/domain/main-entities/control-letter/dto.go @@ -5,7 +5,6 @@ import ( "time" // internal - lib - pa "simrs-vx/internal/lib/auth" // internal - domain - base-entities ecore "simrs-vx/internal/domain/base-entities/core" @@ -20,12 +19,12 @@ import ( ) type CreateDto struct { - Encounter_Id *uint `json:"encounter_id"` - Unit_Id *uint `json:"unit_id"` - Specialist_Id *uint `json:"specialist_id"` - Subspecialist_Id *uint `json:"subspecialist_id"` - Doctor_Id *uint `json:"doctor_id"` - Date *time.Time `json:"date"` + Encounter_Id *uint `json:"encounter_id"` + Unit_Code *string `json:"unit_code"` + Specialist_Code *string `json:"specialist_code"` + Subspecialist_Code *string `json:"subspecialist_code"` + Doctor_Code *string `json:"doctor_code"` + Date *time.Time `json:"date"` } type ReadListDto struct { @@ -35,12 +34,12 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` - Unit_Id *uint `json:"unit-id"` - Specialist_Id *uint `json:"specialist-id"` - Subspecialist_Id *uint `json:"subspecialist-id"` - Doctor_Id *uint `json:"doctor-id"` - Date *time.Time `json:"date"` + Encounter_Id *uint `json:"encounter-id"` + Unit_Code *string `json:"unit-code"` + Specialist_Code *string `json:"specialist-code"` + Subspecialist_Code *string `json:"subspecialist-code"` + Doctor_Code *string `json:"doctor-code"` + Date *time.Time `json:"date"` } type ReadDetailDto struct { @@ -57,13 +56,6 @@ type DeleteDto struct { Id uint `json:"id"` } -type ReplyDto struct { - Id uint `json:"id"` - Solution *string `json:"solution"` - - pa.AuthInfo -} - type MetaDto struct { PageNumber int `json:"page_number"` PageSize int `json:"page_size"` @@ -72,32 +64,32 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Encounter_Id *uint `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty"` - Unit_Id *uint `json:"unit_id"` - Unit *eu.Unit `json:"unit,omitempty"` - Specialist_Id *uint `json:"specialist_id"` - Specialist *es.Specialist `json:"specialist,omitempty"` - Subspecialist_Id *uint `json:"subspecialist_id"` - Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"` - Doctor_Id *uint `json:"doctor_id"` - Doctor *ed.Doctor `json:"doctor,omitempty"` - Date *time.Time `json:"date"` + Encounter_Id *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty"` + Unit_Code *string `json:"unit_code"` + Unit *eu.Unit `json:"unit,omitempty"` + Specialist_Code *string `json:"specialist_code"` + Specialist *es.Specialist `json:"specialist,omitempty"` + Subspecialist_Code *string `json:"subspecialist_code"` + Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"` + Doctor_Code *string `json:"doctor_code"` + Doctor *ed.Doctor `json:"doctor,omitempty"` + Date *time.Time `json:"date"` } func (d ControlLetter) ToResponse() ResponseDto { resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Encounter: d.Encounter, - Unit_Id: d.Unit_Id, - Unit: d.Unit, - Specialist_Id: d.Specialist_Id, - Specialist: d.Specialist, - Subspecialist_Id: d.Subspecialist_Id, - Subspecialist: d.Subspecialist, - Doctor_Id: d.Doctor_Id, - Doctor: d.Doctor, - Date: d.Date, + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Unit_Code: d.Unit_Code, + Unit: d.Unit, + Specialist_Code: d.Specialist_Code, + Specialist: d.Specialist, + Subspecialist_Code: d.Subspecialist_Code, + Subspecialist: d.Subspecialist, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + Date: d.Date, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/control-letter/entity.go b/internal/domain/main-entities/control-letter/entity.go index d0bc0a45..2b8019b4 100644 --- a/internal/domain/main-entities/control-letter/entity.go +++ b/internal/domain/main-entities/control-letter/entity.go @@ -15,17 +15,13 @@ type ControlLetter struct { ecore.Main // adjust this according to the needs Encounter_Id *uint `json:"encounter_id"` Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"` - Unit_Id *uint `json:"unit_id"` Unit_Code *string `json:"unit_code"` - Unit *eu.Unit `json:"unit" gorm:"foreignKey:Unit_Id;references:Id"` - Specialist_Id *uint `json:"specialist_id"` + Unit *eu.Unit `json:"unit" gorm:"foreignKey:Unit_Code;references:Code"` Specialist_Code *string `json:"specialist_code"` - Specialist *es.Specialist `json:"specialist" gorm:"foreignKey:Specialist_Id;references:Id"` - Subspecialist_Id *uint `json:"subspecialist_id"` + Specialist *es.Specialist `json:"specialist" gorm:"foreignKey:Specialist_Code;references:Code"` Subspecialist_Code *string `json:"subspecialist_code"` - Subspecialist *ess.Subspecialist `json:"subspecialist" gorm:"foreignKey:Subspecialist_Id;references:Id"` - Doctor_Id *uint `json:"doctor_id"` + Subspecialist *ess.Subspecialist `json:"subspecialist" gorm:"foreignKey:Subspecialist_Code;references:Code"` Doctor_Code *string `json:"doctor_code"` - Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Code;references:Code"` Date *time.Time `json:"date"` } diff --git a/internal/domain/main-entities/doctor/dto.go b/internal/domain/main-entities/doctor/dto.go index 67290551..e3d1f3ee 100644 --- a/internal/domain/main-entities/doctor/dto.go +++ b/internal/domain/main-entities/doctor/dto.go @@ -38,7 +38,7 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` Code *string `json:"code"` Employee_Id *uint `json:"employee_id"` IHS_Number *string `json:"ihs_number"` @@ -46,12 +46,13 @@ type ReadDetailDto struct { } type UpdateDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id uint `json:"id"` + Code *string `json:"code"` } type MetaDto struct { diff --git a/internal/domain/main-entities/encounter/dto.go b/internal/domain/main-entities/encounter/dto.go index 966a53d3..7ac57b07 100644 --- a/internal/domain/main-entities/encounter/dto.go +++ b/internal/domain/main-entities/encounter/dto.go @@ -33,27 +33,27 @@ import ( ) type CreateDto struct { - Patient_Id *uint `json:"patient_id"` - RegisteredAt *time.Time `json:"registeredAt"` - Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"` - SubClass_Code *string `json:"subClass_code" validate:"maxLength=10"` // for sub - Infra_Id *uint16 `json:"infra_id"` // for inpatient - Unit_Id *uint `json:"unit_id"` - Specialist_Id *uint16 `json:"specialist_id"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` - VisitDate time.Time `json:"visitDate"` - PaymentMethod_Code erc.PaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"` - InsuranceCompany_Id *uint `json:"insuranceCompany_id"` - Member_Number *string `json:"member_number" validate:"maxLength=20"` - Ref_Number *string `json:"ref_number" validate:"maxLength=20"` - Trx_Number *string `json:"trx_number" validate:"maxLength=20"` - Appointment_Doctor_Id *uint `json:"appointment_doctor_id"` - Adm_Employee_Id *uint `json:"-"` - Responsible_Doctor_Id *uint `json:"responsible_doctor_id"` - RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"` - Appointment_Id *uint `json:"appointment_id"` - RefTypeCode ere.RefTypeCode `json:"refTypeCode"` - NewStatus bool `json:"newStatus"` + Patient_Id *uint `json:"patient_id"` + RegisteredAt *time.Time `json:"registeredAt"` + Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"` + SubClass_Code *string `json:"subClass_code" validate:"maxLength=10"` // for sub + Infra_Id *uint16 `json:"infra_id"` // for inpatient + Unit_Id *uint `json:"unit_id"` + Specialist_Code *string `json:"specialist_code"` + Subspecialist_Code *string `json:"subspecialist_code"` + VisitDate time.Time `json:"visitDate"` + PaymentMethod_Code erc.PaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"` + InsuranceCompany_Id *uint `json:"insuranceCompany_id"` + Member_Number *string `json:"member_number" validate:"maxLength=20"` + Ref_Number *string `json:"ref_number" validate:"maxLength=20"` + Trx_Number *string `json:"trx_number" validate:"maxLength=20"` + Appointment_Doctor_Code *string `json:"appointment_doctor_code"` + Adm_Employee_Id *uint `json:"-"` + Responsible_Doctor_Code *string `json:"responsible_doctor_code"` + RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"` + Appointment_Id *uint `json:"appointment_id"` + RefTypeCode ere.RefTypeCode `json:"refTypeCode"` + NewStatus bool `json:"newStatus"` Id uint `json:"-"` RecentEncounterAdm *Encounter `json:"-"` // if subClass_Code is rehab @@ -76,11 +76,11 @@ type FilterDto struct { RegisteredAt *time.Time `json:"registeredAt"` Class_Code ere.EncounterClassCode `json:"class-code" validate:"maxLength=10"` Unit_Id *uint `json:"unit-id"` - Specialist_Id *uint16 `json:"specialist-id"` - Subspecialist_Id *uint16 `json:"subspecialist-id"` + Specialist_Code *string `json:"specialist-code"` + Subspecialist_Code *string `json:"subspecialist-code"` VisitDate time.Time `json:"visitDate"` - Appoinment_Doctor_Id *uint `json:"appointment-doctor-id"` - Responsible_Doctor_Id *uint `json:"responsible-doctor-id"` + Appoinment_Doctor_Code *string `json:"appointment-doctor-code"` + Responsible_Doctor_Code *string `json:"responsible-doctor-code"` DischargeMethod_Code ere.DischargeMethodCode `json:"dischargeMethod-code" validate:"maxLength=10"` RefSource_Name *string `json:"refSource-name" validate:"maxLength=100"` Appointment_Id *uint `json:"appointment-id"` @@ -125,11 +125,11 @@ type DischargeDto struct { } type CheckinDto struct { - Id uint `json:"id"` - Responsible_Doctor_Id *uint `json:"responsible_doctor_id"` - Adm_Employee_Id *uint `json:"adm_employee_id"` - StartedAt *time.Time `json:"startedAt"` - FinishedAt *time.Time `json:"finishedAt"` + Id uint `json:"id"` + Responsible_Doctor_Code *string `json:"responsible_doctor_code"` + Adm_Employee_Id *uint `json:"adm_employee_id"` + StartedAt *time.Time `json:"startedAt"` + FinishedAt *time.Time `json:"finishedAt"` } type SwitchUnitDto struct { @@ -150,9 +150,9 @@ type ResponseDto struct { RegisteredAt *time.Time `json:"registeredAt"` Class_Code ere.EncounterClassCode `json:"class_code"` Unit_Id *uint `json:"unit_id"` - Specialist_Id *uint16 `json:"specialist_id"` + Specialist_Code *string `json:"specialist_code"` Specialist *es.Specialist `json:"specialist,omitempty"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` + Subspecialist_Code *string `json:"subspecialist_code"` Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"` Unit *eu.Unit `json:"unit,omitempty"` VisitDate time.Time `json:"visitDate"` @@ -161,9 +161,9 @@ type ResponseDto struct { Member_Number *string `json:"member_number"` Ref_Number *string `json:"ref_number"` Trx_Number *string `json:"trx_number"` - Appointment_Doctor_Id *uint `json:"appointment_doctor_id"` + Appointment_Doctor_Code *string `json:"appointment_doctor_code"` Appointment_Doctor *ed.Doctor `json:"appointment_doctor,omitempty"` - Responsible_Doctor_Id *uint `json:"responsible_doctor_id"` + Responsible_Doctor_Code *string `json:"responsible_doctor_code"` Responsible_Doctor *ed.Doctor `json:"responsible_doctor,omitempty"` Adm_Employee_Id *uint `json:"adm_employee_id"` Adm_Employee *ee.Employee `json:"adm_employee,omitempty"` @@ -198,9 +198,9 @@ func (d Encounter) ToResponse() ResponseDto { Class_Code: d.Class_Code, Unit_Id: d.Unit_Id, Unit: d.Unit, - Specialist_Id: d.Specialist_Id, + Specialist_Code: d.Specialist_Code, Specialist: d.Specialist, - Subspecialist_Id: d.Subspecialist_Id, + Subspecialist_Code: d.Subspecialist_Code, Subspecialist: d.Subspecialist, VisitDate: d.VisitDate, PaymentMethod_Code: d.PaymentMethod_Code, @@ -208,11 +208,11 @@ func (d Encounter) ToResponse() ResponseDto { Member_Number: d.Member_Number, Ref_Number: d.Ref_Number, Trx_Number: d.Trx_Number, - Appointment_Doctor_Id: d.Appointment_Doctor_Id, + Appointment_Doctor_Code: d.Appointment_Doctor_Code, Appointment_Doctor: d.Appointment_Doctor, Adm_Employee_Id: d.Adm_Employee_Id, Adm_Employee: d.Adm_Employee, - Responsible_Doctor_Id: d.Responsible_Doctor_Id, + Responsible_Doctor_Code: d.Responsible_Doctor_Code, Responsible_Doctor: d.Responsible_Doctor, Discharge_Method_Code: d.Discharge_Method_Code, RefSource_Name: d.RefSource_Name, diff --git a/internal/domain/main-entities/encounter/entity.go b/internal/domain/main-entities/encounter/entity.go index d3436c7a..e07b2263 100644 --- a/internal/domain/main-entities/encounter/entity.go +++ b/internal/domain/main-entities/encounter/entity.go @@ -30,31 +30,29 @@ type Encounter struct { RegisteredAt *time.Time `json:"registeredAt"` Class_Code ere.EncounterClassCode `json:"class_code" gorm:"not null;size:10"` Unit_Id *uint `json:"unit_id"` + Unit_Code *string `json:"unit_code"` Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"` - Specialist_Id *uint16 `json:"specialist_id"` Specialist_Code *string `json:"specialist_code"` - Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` - Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"` + Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Code;references:Code"` Subspecialist_Code *string `json:"subspecialist_code"` + Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Code;references:Code"` VisitDate time.Time `json:"visitDate"` StartedAt *time.Time `json:"startedAt"` FinishedAt *time.Time `json:"finishedAt"` PaymentMethod_Code erc.PaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"` InsuranceCompany_Id *uint `json:"insuranceCompany_id"` + InsuranceCompany_Code *string `json:"insuranceCompany_code"` InsuranceCompany *ei.InsuranceCompany `json:"insuranceCompany,omitempty" gorm:"foreignKey:InsuranceCompany_Id;references:Id"` Member_Number *string `json:"memberNumber" gorm:"unique;size:20"` RefType_Code *ere.RefTypeCode `json:"refType_code"` Ref_Number *string `json:"refNumber" gorm:"unique;size:20"` Trx_Number *string `json:"trxNumber" gorm:"unique;size:20"` - Appointment_Doctor_Id *uint `json:"appointment_doctor_id"` Appointment_Doctor_Code *string `json:"appointment_doctor_code"` - Appointment_Doctor *ed.Doctor `json:"appointment_doctor,omitempty" gorm:"foreignKey:Appointment_Doctor_Id;references:Id"` + Appointment_Doctor *ed.Doctor `json:"appointment_doctor,omitempty" gorm:"foreignKey:Appointment_Doctor_Code;references:Code"` Adm_Employee_Id *uint `json:"adm_employee_id"` Adm_Employee *ee.Employee `json:"adm_employee,omitempty" gorm:"foreignKey:Adm_Employee_Id;references:Id"` - Responsible_Doctor_Id *uint `json:"responsible_doctor_id"` Responsible_Doctor_Code *string `json:"responsible_doctor_code"` - Responsible_Doctor *ed.Doctor `json:"responsible_doctor,omitempty" gorm:"foreignKey:Responsible_Doctor_Id;references:Id"` + Responsible_Doctor *ed.Doctor `json:"responsible_doctor,omitempty" gorm:"foreignKey:Responsible_Doctor_Code;references:Code"` Discharge_Method_Code *ere.DischargeMethodCode `json:"discharge_method_code" gorm:"size:16"` RefSource_Name *string `json:"refSource_name" gorm:"size:100"` Appointment_Id *uint `json:"appointment_id"` diff --git a/internal/domain/main-entities/internal-reference/dto.go b/internal/domain/main-entities/internal-reference/dto.go index c957d60b..08eaaac2 100644 --- a/internal/domain/main-entities/internal-reference/dto.go +++ b/internal/domain/main-entities/internal-reference/dto.go @@ -10,8 +10,8 @@ import ( type CreateDto struct { Encounter_Id *uint `json:"-"` - Unit_Id *uint16 `json:"unit_id"` - Doctor_Id *uint `json:"doctor_Id"` + Unit_Code *string `json:"unit_code"` + Doctor_Code *string `json:"doctor_code"` Status_Code erc.DataApprovalCode `json:"status_code"` } @@ -23,8 +23,8 @@ type ReadListDto struct { type FilterDto struct { Encounter_Id *uint `json:"encounter-id"` - Unit_Id *uint `json:"unit-id"` - Doctor_Id *uint `json:"doctor-id"` + Unit_Code *uint `json:"unit-code"` + Doctor_Code *uint `json:"doctor-code"` Status_Code erc.DataApprovalCode `json:"status-code"` } @@ -51,9 +51,9 @@ type MetaDto struct { type ResponseDto struct { ecore.Main Encounter_Id *uint `json:"encounter_id"` - Unit_Id *uint16 `json:"unit_id"` + Unit_Code *string `json:"unit_id"` Unit *eu.Unit `json:"unit,omitempty"` - Doctor_Id *uint `json:"doctor_id"` + Doctor_Code *string `json:"doctor_id"` Doctor *ed.Doctor `json:"doctor,omitempty"` Status_Code *erc.DataApprovalCode `json:"status_code"` } @@ -61,9 +61,9 @@ type ResponseDto struct { func (d InternalReference) ToResponse() ResponseDto { resp := ResponseDto{ Encounter_Id: d.Encounter_Id, - Unit_Id: d.Unit_Id, + Unit_Code: d.Unit_Code, Unit: d.Unit, - Doctor_Id: d.Doctor_Id, + Doctor_Code: d.Doctor_Code, Doctor: d.Doctor, Status_Code: d.Status_Code, } diff --git a/internal/domain/main-entities/internal-reference/entity.go b/internal/domain/main-entities/internal-reference/entity.go index 71045b09..ae6307bb 100644 --- a/internal/domain/main-entities/internal-reference/entity.go +++ b/internal/domain/main-entities/internal-reference/entity.go @@ -11,11 +11,9 @@ import ( type InternalReference struct { ecore.Main Encounter_Id *uint `json:"encounter_id"` - Unit_Id *uint16 `json:"unit_id"` Unit_Code *string `json:"unit_code"` - Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"` - Doctor_Id *uint `json:"doctor_id"` + Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Code;references:Code"` Doctor_Code *string `json:"doctor_code"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` Status_Code *erc.DataApprovalCode `json:"status_code"` } diff --git a/internal/domain/main-entities/nurse/dto.go b/internal/domain/main-entities/nurse/dto.go index f48014dd..b0cd6104 100644 --- a/internal/domain/main-entities/nurse/dto.go +++ b/internal/domain/main-entities/nurse/dto.go @@ -29,19 +29,20 @@ type FilterDto struct { Infra_Code *string `json:"infra-code"` } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` Code *string `json:"code"` Employee_Id *uint `json:"employee_id"` IHS_Number *string `json:"ihs_number"` } type UpdateDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` + Code *string `json:"code"` } type MetaDto struct { diff --git a/internal/domain/main-entities/practice-schedule/dto.go b/internal/domain/main-entities/practice-schedule/dto.go index 00eea2ad..832bc29d 100644 --- a/internal/domain/main-entities/practice-schedule/dto.go +++ b/internal/domain/main-entities/practice-schedule/dto.go @@ -6,11 +6,11 @@ import ( ) type CreateDto struct { - Doctor_Id *uint `json:"doctor_id"` - Unit_Code *string `json:"unit_code"` - Day_Code *erc.DayCode `json:"day_code"` - StartTime *string `json:"startTime" validate:"maxLength=5"` - EndTime *string `json:"endTime" validate:"maxLength=5"` + Doctor_Code *string `json:"doctor_code"` + Unit_Code *string `json:"unit_code"` + Day_Code *erc.DayCode `json:"day_code"` + StartTime *string `json:"startTime" validate:"maxLength=5"` + EndTime *string `json:"endTime" validate:"maxLength=5"` } type ReadListDto struct { @@ -20,11 +20,11 @@ type ReadListDto struct { } type FilterDto struct { - Doctor_Id *uint `json:"doctor-id"` - Unit_Code *string `json:"unit-code"` - Day_Code *erc.DayCode `json:"day-code"` - StartTime *string `json:"startTime"` - EndTime *string `json:"endTime"` + Doctor_Code *string `json:"doctor-code"` + Unit_Code *string `json:"unit-code"` + Day_Code *erc.DayCode `json:"day-code"` + StartTime *string `json:"startTime"` + EndTime *string `json:"endTime"` } type ReadDetailDto struct { @@ -48,20 +48,20 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Doctor_Id *uint `json:"doctor_id"` - Unit_Code *string `json:"unit_code"` - Day_Code *erc.DayCode `json:"day_code"` - StartTime *string `json:"startTime"` - EndTime *string `json:"endTime"` + Doctor_Code *string `json:"doctor_code"` + Unit_Code *string `json:"unit_code"` + Day_Code *erc.DayCode `json:"day_code"` + StartTime *string `json:"startTime"` + EndTime *string `json:"endTime"` } func (d PracticeSchedule) ToResponse() ResponseDto { resp := ResponseDto{ - Doctor_Id: d.Doctor_Id, - Unit_Code: d.Unit_Code, - Day_Code: d.Day_Code, - StartTime: d.StartTime, - EndTime: d.EndTime, + Doctor_Code: d.Doctor_Code, + Unit_Code: d.Unit_Code, + Day_Code: d.Day_Code, + StartTime: d.StartTime, + EndTime: d.EndTime, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/practice-schedule/entity.go b/internal/domain/main-entities/practice-schedule/entity.go index 213d4495..84ea3296 100644 --- a/internal/domain/main-entities/practice-schedule/entity.go +++ b/internal/domain/main-entities/practice-schedule/entity.go @@ -9,9 +9,8 @@ import ( type PracticeSchedule struct { ecore.Main // adjust this according to the needs - Doctor_Id *uint `json:"doctor_id"` Doctor_Code *string `json:"doctor_code"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` Unit_Code *string `json:"unit_code"` Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Code;references:Code"` Day_Code *erc.DayCode `json:"day_code"` diff --git a/internal/domain/main-entities/responsible-doctor-hist/dto.go b/internal/domain/main-entities/responsible-doctor-hist/dto.go index 68c8dd21..c96c588c 100644 --- a/internal/domain/main-entities/responsible-doctor-hist/dto.go +++ b/internal/domain/main-entities/responsible-doctor-hist/dto.go @@ -8,7 +8,7 @@ import ( type CreateDto struct { Encounter_Id *uint `json:"encounter_id"` - Doctor_Id *uint `json:"doctor_id"` + Doctor_Code *string `json:"doctor_code"` StartedAt *time.Time `json:"startedAt"` FinishedAt *time.Time `json:"finishedAt"` } @@ -22,7 +22,7 @@ type ReadListDto struct { type FilterDto struct { Encounter_Id *uint `json:"encounter-id"` - Doctor_Id *uint `json:"doctor-id"` + Doctor_Code *string `json:"doctor-code"` StartedAt *time.Time `json:"startedAt"` FinishedAt *time.Time `json:"finishedAt"` } @@ -50,7 +50,7 @@ type MetaDto struct { type ResponseDto struct { ecore.Main // adjust this according to the needs Encounter_Id *uint `json:"encounter_id"` - Doctor_Id *uint `json:"doctor_id"` + Doctor_Code *string `json:"doctor_code"` Doctor *ed.Doctor `json:"doctor,omitempty"` StartedAt *time.Time `json:"startedAt"` FinishedAt *time.Time `json:"finishedAt"` @@ -59,7 +59,7 @@ type ResponseDto struct { func (d ResponsibleDoctorHist) ToResponse() ResponseDto { resp := ResponseDto{ Encounter_Id: d.Encounter_Id, - Doctor_Id: d.Doctor_Id, + Doctor_Code: d.Doctor_Code, Doctor: d.Doctor, StartedAt: d.StartedAt, FinishedAt: d.FinishedAt, diff --git a/internal/domain/main-entities/responsible-doctor-hist/entity.go b/internal/domain/main-entities/responsible-doctor-hist/entity.go index 75aa90f6..d9b4946c 100644 --- a/internal/domain/main-entities/responsible-doctor-hist/entity.go +++ b/internal/domain/main-entities/responsible-doctor-hist/entity.go @@ -9,9 +9,8 @@ import ( type ResponsibleDoctorHist struct { ecore.Main // adjust this according to the needs Encounter_Id *uint `json:"encounter_id"` - Doctor_Id *uint `json:"doctor_id"` Doctor_Code *string `json:"doctor_code"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` StartedAt *time.Time `json:"startedAt"` FinishedAt *time.Time `json:"finishedAt"` } diff --git a/internal/domain/main-entities/therapy-protocol/dto.go b/internal/domain/main-entities/therapy-protocol/dto.go index f7a5f2e4..40633b89 100644 --- a/internal/domain/main-entities/therapy-protocol/dto.go +++ b/internal/domain/main-entities/therapy-protocol/dto.go @@ -9,7 +9,7 @@ import ( type CreateDto struct { Encounter_Id *uint `json:"encounter_id"` - Doctor_Id *uint `json:"doctor_id"` + Doctor_Code *string `json:"doctor_code"` Anamnesis *string `json:"anamnesis" validate:"maxLength=2048"` MedicalDiagnoses *string `json:"medicalDiagnoses"` FunctionDiagnoses *string `json:"functionDiagnoses"` @@ -31,8 +31,8 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` - Doctor_Id *uint `json:"doctor-id"` + Encounter_Id *uint `json:"encounter-id"` + Doctor_Code *string `json:"doctor-code"` } type ReadDetailDto struct { @@ -59,7 +59,7 @@ type ResponseDto struct { ecore.Main Encounter_Id *uint `json:"encounter_id"` Encounter *ee.Encounter `json:"encounter,omitempty"` - Doctor_Id *uint `json:"doctor_id"` + Doctor_Code *string `json:"doctor_code"` Doctor *ed.Doctor `json:"doctor,omitempty"` Anamnesis *string `json:"anamnesis"` MedicalDiagnoses *string `json:"medicalDiagnoses"` @@ -79,7 +79,7 @@ func (d TherapyProtocol) ToResponse() ResponseDto { resp := ResponseDto{ Encounter_Id: d.Encounter_Id, Encounter: d.Encounter, - Doctor_Id: d.Doctor_Id, + Doctor_Code: d.Doctor_Code, Doctor: d.Doctor, Anamnesis: d.Anamnesis, MedicalDiagnoses: d.MedicalDiagnoses, diff --git a/internal/domain/main-entities/therapy-protocol/entity.go b/internal/domain/main-entities/therapy-protocol/entity.go index a91e18eb..7caaf0a6 100644 --- a/internal/domain/main-entities/therapy-protocol/entity.go +++ b/internal/domain/main-entities/therapy-protocol/entity.go @@ -13,9 +13,8 @@ type TherapyProtocol struct { Encounter_Id *uint `json:"encounter_id" gorm:"not null"` Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` - Doctor_Id *uint `json:"doctor_id"` Doctor_Code *string `json:"doctor_code"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` Anamnesis *string `json:"anamnesis" gorm:"size:2048"` MedicalDiagnoses *string `json:"medicalDiagnoses"` diff --git a/internal/interface/main-handler/doctor/handler.go b/internal/interface/main-handler/doctor/handler.go index ee1252ad..f62495d6 100644 --- a/internal/interface/main-handler/doctor/handler.go +++ b/internal/interface/main-handler/doctor/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "code", r.PathValue("code")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "code", r.PathValue("code")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint(id) + dto.Code = &code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "code", r.PathValue("code")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/interface/main-handler/encounter/request-validation.go b/internal/interface/main-handler/encounter/request-validation.go index be370074..79cc832c 100644 --- a/internal/interface/main-handler/encounter/request-validation.go +++ b/internal/interface/main-handler/encounter/request-validation.go @@ -47,10 +47,10 @@ func validateRequestCheckout(w http.ResponseWriter, i e.DischargeDto) (valid boo } func validateRequestCheckIn(w http.ResponseWriter, i e.CheckinDto) (valid bool) { - if i.Responsible_Doctor_Id == nil { + if i.Responsible_Doctor_Code == nil { rw.DataResponse(w, nil, d.FieldError{ Code: dataValidationFail, - Message: "responsible_doctor_id required", + Message: "responsible_doctor_code required", }) return } @@ -68,18 +68,18 @@ func validateRequestSwitchUnit(w http.ResponseWriter, i e.SwitchUnitDto) (valid } for _, v := range *i.InternalReferences { - if v.Unit_Id == nil { + if v.Unit_Code == nil { rw.DataResponse(w, nil, d.FieldError{ Code: dataValidationFail, - Message: "internalReferences.unit_id required", + Message: "internalReferences.unit_code required", }) return } - if v.Doctor_Id == nil { + if v.Doctor_Code == nil { rw.DataResponse(w, nil, d.FieldError{ Code: dataValidationFail, - Message: "internalReferences.doctor_id required", + Message: "internalReferences.doctor_code required", }) return } diff --git a/internal/interface/main-handler/nurse/handler.go b/internal/interface/main-handler/nurse/handler.go index 8817ae14..b8252892 100644 --- a/internal/interface/main-handler/nurse/handler.go +++ b/internal/interface/main-handler/nurse/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "code", r.PathValue("code")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "code", r.PathValue("code")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint(id) + dto.Code = &code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "code", r.PathValue("code")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/use-case/main-use-case/consultation/case.go b/internal/use-case/main-use-case/consultation/case.go index 3cda31d9..25306169 100644 --- a/internal/use-case/main-use-case/consultation/case.go +++ b/internal/use-case/main-use-case/consultation/case.go @@ -7,8 +7,6 @@ import ( e "simrs-vx/internal/domain/main-entities/consultation" ue "simrs-vx/internal/use-case/main-use-case/encounter" - ud "simrs-vx/internal/use-case/main-use-case/doctor" - dg "github.com/karincake/apem/db-gorm-pg" d "github.com/karincake/dodol" @@ -314,12 +312,7 @@ func Reply(input e.ReplyDto) (*d.Data, error) { return pl.SetLogError(&event, input) } - doctor_id, err := ud.GetIdByUserId(&input.AuthInfo.User_Id, &event, tx) - if err != nil { - return err - } - - if data.DstDoctor_Id != nil && data.DstDoctor_Id != doctor_id { + if data.DstDoctor_Code != nil && data.DstDoctor_Code != input.AuthInfo.Doctor_Code { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "data-handled-mismatch", @@ -329,7 +322,7 @@ func Reply(input e.ReplyDto) (*d.Data, error) { return pl.SetLogError(&event, input) } - data.DstDoctor_Id = doctor_id + data.DstDoctor_Code = input.AuthInfo.Doctor_Code data.Solution = input.Solution data.RepliedAt = pu.GetTimeNow() err = tx.Save(&data).Error diff --git a/internal/use-case/main-use-case/consultation/helper.go b/internal/use-case/main-use-case/consultation/helper.go index 519c3c91..3a518c77 100644 --- a/internal/use-case/main-use-case/consultation/helper.go +++ b/internal/use-case/main-use-case/consultation/helper.go @@ -20,5 +20,5 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Consultation) { data.Encounter_Id = inputSrc.Encounter_Id data.Date = inputSrc.Date data.Problem = inputSrc.Problem - data.DstUnit_Id = inputSrc.DstUnit_Id + data.DstUnit_Code = inputSrc.DstUnit_Code } diff --git a/internal/use-case/main-use-case/control-letter/helper.go b/internal/use-case/main-use-case/control-letter/helper.go index 5cc943c5..8ae71d3c 100644 --- a/internal/use-case/main-use-case/control-letter/helper.go +++ b/internal/use-case/main-use-case/control-letter/helper.go @@ -18,9 +18,9 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ControlLetter) { } data.Encounter_Id = inputSrc.Encounter_Id - data.Unit_Id = inputSrc.Unit_Id - data.Specialist_Id = inputSrc.Specialist_Id - data.Subspecialist_Id = inputSrc.Subspecialist_Id - data.Doctor_Id = inputSrc.Doctor_Id + data.Unit_Code = inputSrc.Unit_Code + data.Specialist_Code = inputSrc.Specialist_Code + data.Subspecialist_Code = inputSrc.Subspecialist_Code + data.Doctor_Code = inputSrc.Doctor_Code data.Date = inputSrc.Date } diff --git a/internal/use-case/main-use-case/doctor/case.go b/internal/use-case/main-use-case/doctor/case.go index 74337056..cab7facc 100644 --- a/internal/use-case/main-use-case/doctor/case.go +++ b/internal/use-case/main-use-case/doctor/case.go @@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Doctor var err error @@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Doctor var err error diff --git a/internal/use-case/main-use-case/doctor/lib.go b/internal/use-case/main-use-case/doctor/lib.go index 3355bb3c..12b62176 100644 --- a/internal/use-case/main-use-case/doctor/lib.go +++ b/internal/use-case/main-use-case/doctor/lib.go @@ -84,7 +84,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e if input.Employee_Id != nil { tx = tx.Where("\"Employee_Id\" = ?", *input.Employee_Id) } - if input.Id > 0 { + if input.Id != nil { tx = tx.Where("\"Id\" = ?", input.Id) } if err := tx.First(&data).Error; err != nil { diff --git a/internal/use-case/main-use-case/encounter/case.go b/internal/use-case/main-use-case/encounter/case.go index e1643d83..3a8c3b82 100644 --- a/internal/use-case/main-use-case/encounter/case.go +++ b/internal/use-case/main-use-case/encounter/case.go @@ -574,11 +574,11 @@ func CheckIn(input e.CheckinDto) (*d.Data, error) { } // Upsert responsible_doctor_hist if responsible_doctor_id has changed - if data.Responsible_Doctor_Id == nil || *input.Responsible_Doctor_Id != *data.Responsible_Doctor_Id { + if data.Responsible_Doctor_Code == nil || *input.Responsible_Doctor_Code != *data.Responsible_Doctor_Code { // upsert responsibleDoctorHist if err = upsertResponsibleDoctorHist(erdh.CreateDto{ Encounter_Id: &data.Id, - Doctor_Id: input.Responsible_Doctor_Id, + Doctor_Code: input.Responsible_Doctor_Code, StartedAt: input.StartedAt, }, &event, tx); err != nil { return err @@ -634,24 +634,24 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) { // Start log pl.SetLogInfo(&event, input, "started", "checkOut") - unitIDs := make(map[uint16]struct{}) - doctorIDs := make(map[uint]struct{}) + unitCodes := make(map[string]struct{}) + doctorCodes := make(map[string]struct{}) for _, ref := range *input.InternalReferences { - if ref.Unit_Id != nil { - unitIDs[*ref.Unit_Id] = struct{}{} + if ref.Unit_Code != nil { + unitCodes[*ref.Unit_Code] = struct{}{} } - if ref.Doctor_Id != nil { - doctorIDs[*ref.Doctor_Id] = struct{}{} + if ref.Doctor_Code != nil { + doctorCodes[*ref.Doctor_Code] = struct{}{} } } // validate unit - if err = validateUnitIds(unitIDs, &event); err != nil { + if err = validateUnitCodes(unitCodes, &event); err != nil { return nil, err } // validate doctor - if err = validateDoctorIds(doctorIDs, &event); err != nil { + if err = validateDoctorCodes(doctorCodes, &event); err != nil { return nil, err } @@ -773,8 +773,8 @@ func ApproveSwitchUnit(input e.ApproveUnitDto) (*d.Data, error) { Id: input.InternalReferences_Id, CreateDto: eir.CreateDto{ Encounter_Id: &input.Id, - Doctor_Id: irData.Doctor_Id, - Unit_Id: irData.Unit_Id, + Doctor_Code: irData.Doctor_Code, + Unit_Code: irData.Unit_Code, Status_Code: erc.DACApproved, }}, irData, &event, tx); err != nil { return err @@ -793,15 +793,15 @@ func ApproveSwitchUnit(input e.ApproveUnitDto) (*d.Data, error) { // create responsible doctor based on internal reference data if _, err = urdh.CreateData(erdh.CreateDto{ Encounter_Id: &input.Id, - Doctor_Id: irData.Doctor_Id, + Doctor_Code: irData.Doctor_Code, StartedAt: &now, }, &event, tx); err != nil { return err } // update data response - data.Responsible_Doctor_Id = irData.Doctor_Id - data.Unit = irData.Unit + data.Responsible_Doctor_Code = irData.Doctor_Code + data.Unit = irData.Unit // TODO: check if this is correct data.Specialist_Code = irData.Doctor.Specialist_Code data.Subspecialist_Code = irData.Doctor.Subspecialist_Code diff --git a/internal/use-case/main-use-case/encounter/helper.go b/internal/use-case/main-use-case/encounter/helper.go index 1d313d5f..793b5305 100644 --- a/internal/use-case/main-use-case/encounter/helper.go +++ b/internal/use-case/main-use-case/encounter/helper.go @@ -77,17 +77,17 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Encounter) { data.RegisteredAt = inputSrc.RegisteredAt data.Class_Code = inputSrc.Class_Code data.Unit_Id = inputSrc.Unit_Id - data.Specialist_Id = inputSrc.Specialist_Id - data.Subspecialist_Id = inputSrc.Subspecialist_Id + data.Specialist_Code = inputSrc.Specialist_Code + data.Subspecialist_Code = inputSrc.Subspecialist_Code data.VisitDate = inputSrc.VisitDate data.PaymentMethod_Code = inputSrc.PaymentMethod_Code data.InsuranceCompany_Id = inputSrc.InsuranceCompany_Id data.Member_Number = inputSrc.Member_Number data.Ref_Number = inputSrc.Ref_Number data.Trx_Number = inputSrc.Trx_Number - data.Appointment_Doctor_Id = inputSrc.Appointment_Doctor_Id + data.Appointment_Doctor_Code = inputSrc.Appointment_Doctor_Code data.Adm_Employee_Id = inputSrc.Adm_Employee_Id - data.Responsible_Doctor_Id = inputSrc.Responsible_Doctor_Id + data.Responsible_Doctor_Code = inputSrc.Responsible_Doctor_Code data.RefSource_Name = inputSrc.RefSource_Name data.Appointment_Id = inputSrc.Appointment_Id data.Status_Code = erc.DSCProcess @@ -96,11 +96,11 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Encounter) { } func setDataUpdate(src e.UpdateDto, dst *e.Encounter) { - dst.Appointment_Doctor_Id = src.Appointment_Doctor_Id - dst.Responsible_Doctor_Id = src.Responsible_Doctor_Id + dst.Appointment_Doctor_Code = src.Appointment_Doctor_Code + dst.Responsible_Doctor_Code = src.Responsible_Doctor_Code dst.Unit_Id = src.Unit_Id - dst.Specialist_Id = src.Specialist_Id - dst.Subspecialist_Id = src.Subspecialist_Id + dst.Specialist_Code = src.Specialist_Code + dst.Subspecialist_Code = src.Subspecialist_Code dst.VisitDate = src.VisitDate } @@ -126,7 +126,7 @@ func setDataCheckIn(src e.CheckinDto, dst *e.Encounter) { dst.Adm_Employee_Id = src.Adm_Employee_Id } - dst.Responsible_Doctor_Id = src.Responsible_Doctor_Id + dst.Responsible_Doctor_Code = src.Responsible_Doctor_Code dst.StartedAt = src.StartedAt } @@ -395,9 +395,9 @@ func upsertResponsibleDoctorHist(input erdh.CreateDto, event *pl.Event, dbx ...* default: // Update if err := tx.Model(&latest).Updates(map[string]interface{}{ - "Doctor_Id": input.Doctor_Id, - "StartedAt": input.StartedAt, - "UpdatedAt": time.Now(), + "Doctor_Code": input.Doctor_Code, + "StartedAt": input.StartedAt, + "UpdatedAt": time.Now(), }).Error; err != nil { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ @@ -904,8 +904,8 @@ func validateForeignKey(input e.CheckinDto) error { } // validate doctor_id - if input.Responsible_Doctor_Id != nil { - if _, err := ud.ReadDetail(ed.ReadDetailDto{Id: uint16(*input.Responsible_Doctor_Id)}); err != nil { + if input.Responsible_Doctor_Code != nil { + if _, err := ud.ReadDetail(ed.ReadDetailDto{Code: input.Responsible_Doctor_Code}); err != nil { return err } } @@ -932,10 +932,10 @@ func setDBError(event *pl.Event, err error, ctx any) error { return pl.SetLogError(event, ctx) } -func getUnits(unitIds []uint16, event *pl.Event) ([]eu.Unit, error) { +func getUnits(unitIds []string, event *pl.Event) ([]eu.Unit, error) { pl.SetLogInfo(event, nil, "started", "getUnits") var units []eu.Unit - err := dg.I.Where("\"Id\" IN ?", unitIds).Find(&units).Error + err := dg.I.Where("\"Code\" IN ?", unitIds).Find(&units).Error if err != nil { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ @@ -948,10 +948,10 @@ func getUnits(unitIds []uint16, event *pl.Event) ([]eu.Unit, error) { return units, nil } -func getDoctors(doctorIds []uint, event *pl.Event) ([]ed.Doctor, error) { +func getDoctors(doctorIds []string, event *pl.Event) ([]ed.Doctor, error) { pl.SetLogInfo(event, nil, "started", "getDoctors") var doctors []ed.Doctor - err := dg.I.Where("\"Id\" IN ?", doctorIds).Find(&doctors).Error + err := dg.I.Where("\"Id\" Code ?", doctorIds).Find(&doctors).Error if err != nil { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ @@ -964,18 +964,18 @@ func getDoctors(doctorIds []uint, event *pl.Event) ([]ed.Doctor, error) { return doctors, nil } -func validateUnitIds(unitIDs map[uint16]struct{}, event *pl.Event) error { - if len(unitIDs) > 0 { - var ids []uint16 - for id := range unitIDs { - ids = append(ids, id) +func validateUnitCodes(unitCodes map[string]struct{}, event *pl.Event) error { + if len(unitCodes) > 0 { + var codes []string + for code := range unitCodes { + codes = append(codes, code) } - units, err := getUnits(ids, event) + units, err := getUnits(codes, event) if err != nil { return fmt.Errorf("failed to fetch units: %w", err) } - if len(units) != len(ids) { + if len(units) != len(codes) { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "data-validation-fail", @@ -988,18 +988,18 @@ func validateUnitIds(unitIDs map[uint16]struct{}, event *pl.Event) error { return nil } -func validateDoctorIds(doctorIDs map[uint]struct{}, event *pl.Event) error { - if len(doctorIDs) > 0 { - var ids []uint - for id := range doctorIDs { - ids = append(ids, id) +func validateDoctorCodes(doctorCodes map[string]struct{}, event *pl.Event) error { + if len(doctorCodes) > 0 { + var codes []string + for code := range doctorCodes { + codes = append(codes, code) } - doctors, err := getDoctors(ids, event) + doctors, err := getDoctors(codes, event) if err != nil { return fmt.Errorf("failed to fetch doctors: %w", err) } - if len(doctors) != len(ids) { + if len(doctors) != len(codes) { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "data-validation-fail", diff --git a/internal/use-case/main-use-case/encounter/lib.go b/internal/use-case/main-use-case/encounter/lib.go index 8772a2f4..840fefac 100644 --- a/internal/use-case/main-use-case/encounter/lib.go +++ b/internal/use-case/main-use-case/encounter/lib.go @@ -332,10 +332,10 @@ func updateEncounterApproveSwitchUnit(input eir.InternalReference, event *pl.Eve if err := tx.Model(&e.Encounter{}). Where("\"Id\" = ?", input.Encounter_Id). Updates(map[string]interface{}{ - "Responsible_Doctor_Id": input.Doctor_Id, - "Unit_Id": input.Unit_Id, - "Specialist_Code": input.Doctor.Specialist_Code, - "Subspecialist_Code": input.Doctor.Subspecialist_Code, + "Responsible_Doctor_Code": input.Doctor_Code, + "Unit_Code": input.Unit_Code, + "Specialist_Code": input.Doctor.Specialist_Code, + "Subspecialist_Code": input.Doctor.Subspecialist_Code, }).Error; err != nil { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ diff --git a/internal/use-case/main-use-case/internal-reference/helper.go b/internal/use-case/main-use-case/internal-reference/helper.go index 36c28540..234eb770 100644 --- a/internal/use-case/main-use-case/internal-reference/helper.go +++ b/internal/use-case/main-use-case/internal-reference/helper.go @@ -19,8 +19,8 @@ func setData[T *ir.CreateDto | *ir.UpdateDto](input T, data *ir.InternalReferenc } data.Encounter_Id = inputSrc.Encounter_Id - data.Unit_Id = inputSrc.Unit_Id - data.Doctor_Id = inputSrc.Doctor_Id + data.Unit_Code = inputSrc.Unit_Code + data.Doctor_Code = inputSrc.Doctor_Code data.Status_Code = &inputSrc.Status_Code } @@ -31,8 +31,8 @@ func setBulkData(input []ir.CreateDto, encounterId uint) []ir.InternalReference statusCode := erc.DACNew data = append(data, ir.InternalReference{ Encounter_Id: &encounterId, - Unit_Id: v.Unit_Id, - Doctor_Id: v.Doctor_Id, + Unit_Code: v.Unit_Code, + Doctor_Code: v.Doctor_Code, Status_Code: &statusCode, }) } diff --git a/internal/use-case/main-use-case/nurse/case.go b/internal/use-case/main-use-case/nurse/case.go index 6201e15b..e7d0ce0c 100644 --- a/internal/use-case/main-use-case/nurse/case.go +++ b/internal/use-case/main-use-case/nurse/case.go @@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Nurse var err error @@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Nurse var err error diff --git a/internal/use-case/main-use-case/nurse/lib.go b/internal/use-case/main-use-case/nurse/lib.go index a59cc692..e0ce8ba6 100644 --- a/internal/use-case/main-use-case/nurse/lib.go +++ b/internal/use-case/main-use-case/nurse/lib.go @@ -84,7 +84,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e if input.Employee_Id != nil { tx = tx.Where("\"Employee_Id\" = ?", *input.Employee_Id) } - if input.Id > 0 { + if input.Id != nil { tx = tx.Where("\"Id\" = ?", input.Id) } if err := tx.First(&data).Error; err != nil { diff --git a/internal/use-case/main-use-case/practice-schedule/helper.go b/internal/use-case/main-use-case/practice-schedule/helper.go index 5c9f7815..ba61b691 100644 --- a/internal/use-case/main-use-case/practice-schedule/helper.go +++ b/internal/use-case/main-use-case/practice-schedule/helper.go @@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.PracticeSchedule) { inputSrc = &inputTemp.CreateDto } - data.Doctor_Id = inputSrc.Doctor_Id + data.Doctor_Code = inputSrc.Doctor_Code data.Unit_Code = inputSrc.Unit_Code data.Day_Code = inputSrc.Day_Code data.StartTime = inputSrc.StartTime diff --git a/internal/use-case/main-use-case/responsible-doctor-hist/helper.go b/internal/use-case/main-use-case/responsible-doctor-hist/helper.go index 6efd1097..33ee9da4 100644 --- a/internal/use-case/main-use-case/responsible-doctor-hist/helper.go +++ b/internal/use-case/main-use-case/responsible-doctor-hist/helper.go @@ -18,7 +18,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ResponsibleDoctorHi } data.Encounter_Id = inputSrc.Encounter_Id - data.Doctor_Id = inputSrc.Doctor_Id + data.Doctor_Code = inputSrc.Doctor_Code data.StartedAt = inputSrc.StartedAt data.FinishedAt = inputSrc.FinishedAt } diff --git a/internal/use-case/main-use-case/therapy-protocol/case.go b/internal/use-case/main-use-case/therapy-protocol/case.go index 93cf05a4..bc65325f 100644 --- a/internal/use-case/main-use-case/therapy-protocol/case.go +++ b/internal/use-case/main-use-case/therapy-protocol/case.go @@ -299,9 +299,9 @@ func validateForeignKey(input e.CreateDto) error { } } - // validate doctor_id - if input.Doctor_Id != nil { - if _, err := ud.ReadDetail(ed.ReadDetailDto{Id: uint16(*input.Doctor_Id)}); err != nil { + // validate doctor_code + if input.Doctor_Code != nil { + if _, err := ud.ReadDetail(ed.ReadDetailDto{Code: input.Doctor_Code}); err != nil { return err } } diff --git a/internal/use-case/main-use-case/therapy-protocol/helper.go b/internal/use-case/main-use-case/therapy-protocol/helper.go index 12e48747..021c89ed 100644 --- a/internal/use-case/main-use-case/therapy-protocol/helper.go +++ b/internal/use-case/main-use-case/therapy-protocol/helper.go @@ -18,7 +18,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.TherapyProtocol) { } data.Encounter_Id = inputSrc.Encounter_Id - data.Doctor_Id = inputSrc.Doctor_Id + data.Doctor_Code = inputSrc.Doctor_Code data.Anamnesis = inputSrc.Anamnesis data.MedicalDiagnoses = inputSrc.MedicalDiagnoses data.FunctionDiagnoses = inputSrc.FunctionDiagnoses