Merge branch 'migration' of github.com:dikstub-rssa/simrs-be into feat/be-upload-berkas-pasien-32

This commit is contained in:
dpurbosakti
2025-09-24 12:14:48 +07:00
8 changed files with 205 additions and 60 deletions
@@ -0,0 +1,17 @@
-- Create "Consultation" table
CREATE TABLE "public"."Consultation" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Encounter_Id" bigint NULL,
"Case" character varying(2048) NULL,
"Solution" character varying(2048) NULL,
"Unit_Id" bigint NULL,
"Doctor_Id" bigint NULL,
"RepliedAt" timestamptz NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_Consultation_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_Consultation_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_Consultation_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
@@ -0,0 +1,2 @@
-- Modify "Person" table
ALTER TABLE "public"."Person" ADD COLUMN "ResidentIdentityFileUrl" character varying(1024) NULL, ADD COLUMN "PassportFileUrl" character varying(1024) NULL, ADD COLUMN "DrivingLicenseFileUrl" character varying(1024) NULL, ADD COLUMN "FamilyIdentityFileUrl" character varying(1024) NULL;
+3 -1
View File
@@ -1,4 +1,4 @@
h1:ZD6tpr1oc81DWrZLIE3ZVmvnBpU7r6Nlet5N489jJVk=
h1:n2YbCQPYchOWsVSLUNPCl29Xx3RMTi7vdulwPRHXL4E=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -15,3 +15,5 @@ h1:ZD6tpr1oc81DWrZLIE3ZVmvnBpU7r6Nlet5N489jJVk=
20250918073552.sql h1:RJ1SvMzP6aeWnoPVD3eVAmIQOkcp6Php8z3QRri6v4g=
20250918073742.sql h1:+cEsnJTJFybe2fR69ZoOiX2R6c6iITl4m6WTZ1hjyzY=
20250918074745.sql h1:2hNVQCXF/dVYXAh+T/7oBFgERGWxzVb2FXJjwkFWGCI=
20250923025134.sql h1:Ykz/qpHiGDXPsCsWTjydQFVSibZP2D+h2fIeb2h2JGA=
20250924051317.sql h1:vbbuylW434V23raIl6Y6Ima6aZVItLrdIpk+xehVsJc=
@@ -0,0 +1,87 @@
package consultation
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
eu "simrs-vx/internal/domain/main-entities/unit"
"time"
)
type CreateDto struct {
Encounter_Id *uint `json:"encounter_id"`
Case *string `json:"case" validate:"maxLength=2048"`
Unit_Id *uint `json:"unit_id"`
}
type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Encounter_Id *uint `json:"encounter_id"`
Unit_Id *uint `json:"unit_id"`
Doctor_Id *uint `json:"doctor_id"`
Page int `json:"page"`
PageSize int `json:"page_size"`
NoPagination int `json:"no_pagination"`
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
}
type UpdateDto struct {
Id uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
}
type MetaDto struct {
PageNumber int `json:"page_number"`
PageSize int `json:"page_size"`
Count int `json:"count"`
}
type ResponseDto struct {
ecore.Main
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty"`
Case *string `json:"case"`
Solution *string `json:"solution"`
Unit_Id *uint `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty"`
Doctor_Id *uint `json:"doctor_id"`
Doctor *ed.Doctor `json:"doctor,omitempty"`
RepliedAt *time.Time `json:"repliedAt"`
}
func (d Consultation) ToResponse() ResponseDto {
resp := ResponseDto{
Encounter_Id: d.Encounter_Id,
Encounter: d.Encounter,
Case: d.Case,
Solution: d.Solution,
Unit_Id: d.Unit_Id,
Unit: d.Unit,
Doctor_Id: d.Doctor_Id,
Doctor: d.Doctor,
RepliedAt: d.RepliedAt,
}
resp.Main = d.Main
return resp
}
func ToResponseList(data []Consultation) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,23 @@
package consultation
import (
"time"
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
eu "simrs-vx/internal/domain/main-entities/unit"
)
type Consultation 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"`
Case *string `json:"case" gorm:"size:2048"`
Solution *string `json:"solution" gorm:"size:2048"`
Unit_Id *uint `json:"unit_id"`
Unit *eu.Unit `json:"unit" gorm:"foreignKey:Unit_Id;references:Id"`
Doctor_Id *uint `json:"doctor_id"`
Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Id;references:Id"`
RepliedAt *time.Time `json:"repliedAt"`
}
+46 -38
View File
@@ -81,48 +81,56 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
Name string `json:"name"`
FrontTitle *string `json:"frontTitle"`
EndTitle *string `json:"endTitle"`
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code"`
Gender_Code *erp.GenderCode `json:"gender_code"`
ResidentIdentityNumber *string `json:"residentIdentityNumber"`
PassportNumber *string `json:"passportNumber"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber"`
Religion_Code *erp.ReligionCode `json:"religion_code"`
Education_Code *erp.EducationCode `json:"education_code"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code"`
Ocupation_Name *string `json:"occupation_name"`
Ethnic_Code *string `json:"ethnic_code"`
Ethnic *ee.Ethnic `json:"ethnic,omitempty"`
Addresses *[]epa.PersonAddress `json:"addresses,omitempty"`
Contacts *[]epc.PersonContact `json:"contacts,omitempty"`
Relatives *[]epr.PersonRelative `json:"relatives,omitempty"`
Language_Code *string `json:"language_code"`
Name string `json:"name"`
FrontTitle *string `json:"frontTitle"`
EndTitle *string `json:"endTitle"`
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code"`
Gender_Code *erp.GenderCode `json:"gender_code"`
ResidentIdentityNumber *string `json:"residentIdentityNumber"`
PassportNumber *string `json:"passportNumber"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber"`
Religion_Code *erp.ReligionCode `json:"religion_code"`
Education_Code *erp.EducationCode `json:"education_code"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code"`
Ocupation_Name *string `json:"occupation_name"`
Ethnic_Code *string `json:"ethnic_code"`
Ethnic *ee.Ethnic `json:"ethnic,omitempty"`
Addresses *[]epa.PersonAddress `json:"addresses,omitempty"`
Contacts *[]epc.PersonContact `json:"contacts,omitempty"`
Relatives *[]epr.PersonRelative `json:"relatives,omitempty"`
Language_Code *string `json:"language_code"`
ResidentIdentityFileUrl *string `json:"residentIdentityFileUrl"`
PassportFileUrl *string `json:"passportFileUrl"`
DrivingLicenseFileUrl *string `json:"drivingLicenseFileUrl"`
FamilyIdentityFileUrl *string `json:"familyIdentityFileUrl"`
}
func (d *Person) ToResponse() ResponseDto {
resp := ResponseDto{
Name: d.Name,
FrontTitle: d.FrontTitle,
EndTitle: d.EndTitle,
BirthDate: d.BirthDate,
BirthRegency_Code: d.BirthRegency_Code,
Gender_Code: d.Gender_Code,
ResidentIdentityNumber: d.ResidentIdentityNumber,
PassportNumber: d.PassportNumber,
DrivingLicenseNumber: d.DrivingLicenseNumber,
Religion_Code: d.Religion_Code,
Education_Code: d.Education_Code,
Ocupation_Code: d.Ocupation_Code,
Ocupation_Name: d.Ocupation_Name,
Ethnic_Code: d.Ethnic_Code,
Ethnic: d.Ethnic,
Addresses: d.Addresses,
Contacts: d.Contacts,
Relatives: d.Relatives,
Language_Code: d.Language_Code,
Name: d.Name,
FrontTitle: d.FrontTitle,
EndTitle: d.EndTitle,
BirthDate: d.BirthDate,
BirthRegency_Code: d.BirthRegency_Code,
Gender_Code: d.Gender_Code,
ResidentIdentityNumber: d.ResidentIdentityNumber,
PassportNumber: d.PassportNumber,
DrivingLicenseNumber: d.DrivingLicenseNumber,
Religion_Code: d.Religion_Code,
Education_Code: d.Education_Code,
Ocupation_Code: d.Ocupation_Code,
Ocupation_Name: d.Ocupation_Name,
Ethnic_Code: d.Ethnic_Code,
Ethnic: d.Ethnic,
Addresses: d.Addresses,
Contacts: d.Contacts,
Relatives: d.Relatives,
Language_Code: d.Language_Code,
ResidentIdentityFileUrl: d.ResidentIdentityFileUrl,
PassportFileUrl: d.PassportFileUrl,
DrivingLicenseFileUrl: d.DrivingLicenseFileUrl,
FamilyIdentityFileUrl: d.FamilyIdentityFileUrl,
}
resp.Main = d.Main
return resp
+25 -21
View File
@@ -13,27 +13,31 @@ import (
)
type Person struct {
ecore.Main // adjust this according to the needs
Name string `json:"name" gorm:"not null;size:150"`
FrontTitle *string `json:"frontTitle" gorm:"size:50"`
EndTitle *string `json:"endTitle" gorm:"size:50"`
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"`
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"unique;size:16"`
PassportNumber *string `json:"passportNumber" gorm:"unique;size:20"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"unique;size:20"`
Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"`
Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"`
Ocupation_Name *string `json:"occupation_name" gorm:"size:50"`
Ethnic_Code *string `json:"ethnic_code" gorm:"size:20"`
Ethnic *ee.Ethnic `json:"ethnic,omitempty" gorm:"foreignKey:Ethnic_Code;references:Code"`
Addresses *[]epa.PersonAddress `json:"addresses" gorm:"foreignKey:Person_Id"`
Contacts *[]epc.PersonContact `json:"contacts" gorm:"foreignKey:Person_Id"`
Relatives *[]epr.PersonRelative `json:"relatives" gorm:"foreignKey:Person_Id"`
Language_Code *string `json:"language_code" gorm:"size:10"`
Language *el.Language `json:"language,omitempty" gorm:"foreignKey:Language_Code;references:Code"`
ecore.Main // adjust this according to the needs
Name string `json:"name" gorm:"not null;size:150"`
FrontTitle *string `json:"frontTitle" gorm:"size:50"`
EndTitle *string `json:"endTitle" gorm:"size:50"`
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"`
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"unique;size:16"`
PassportNumber *string `json:"passportNumber" gorm:"unique;size:20"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"unique;size:20"`
Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"`
Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"`
Ocupation_Name *string `json:"occupation_name" gorm:"size:50"`
Ethnic_Code *string `json:"ethnic_code" gorm:"size:20"`
Ethnic *ee.Ethnic `json:"ethnic,omitempty" gorm:"foreignKey:Ethnic_Code;references:Code"`
Addresses *[]epa.PersonAddress `json:"addresses" gorm:"foreignKey:Person_Id"`
Contacts *[]epc.PersonContact `json:"contacts" gorm:"foreignKey:Person_Id"`
Relatives *[]epr.PersonRelative `json:"relatives" gorm:"foreignKey:Person_Id"`
Language_Code *string `json:"language_code" gorm:"size:10"`
Language *el.Language `json:"language,omitempty" gorm:"foreignKey:Language_Code;references:Code"`
ResidentIdentityFileUrl *string `json:"residentIdentityFileUrl" gorm:"size:1024"`
PassportFileUrl *string `json:"passportFileUrl" gorm:"size:1024"`
DrivingLicenseFileUrl *string `json:"drivingLicenseFileUrl" gorm:"size:1024"`
FamilyIdentityFileUrl *string `json:"familyIdentityFileUrl" gorm:"size:1024"`
}
func (d Person) IsSameResidentIdentityNumber(input *string) bool {
@@ -4,6 +4,7 @@ import (
adime "simrs-vx/internal/domain/main-entities/adime"
ambulatory "simrs-vx/internal/domain/main-entities/ambulatory"
appointment "simrs-vx/internal/domain/main-entities/appointment"
consultation "simrs-vx/internal/domain/main-entities/consultation"
counter "simrs-vx/internal/domain/main-entities/counter"
device "simrs-vx/internal/domain/main-entities/device"
deviceorder "simrs-vx/internal/domain/main-entities/device-order"
@@ -143,5 +144,6 @@ func getMainEntities() []any {
&mcuorderitem.McuOrderItem{},
&mcusubsrc.McuSubSrc{},
&mcuordersubitem.McuOrderSubItem{},
&consultation.Consultation{},
}
}