Merge branch 'migration' of github.com:dikstub-rssa/simrs-be into feat/control-letter-121
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- Rename a column from "McuUrgencyLevel_Code" to "UrgencyLevel_Code"
|
||||
ALTER TABLE "public"."McuOrder" RENAME COLUMN "McuUrgencyLevel_Code" TO "UrgencyLevel_Code";
|
||||
@@ -0,0 +1,17 @@
|
||||
-- Create "ControlLetter" table
|
||||
CREATE TABLE "public"."ControlLetter" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Encounter_Id" bigint NULL,
|
||||
"Unit_Id" bigint NULL,
|
||||
"Specialist_Id" bigint NULL,
|
||||
"Subspecialist_Id" bigint NULL,
|
||||
"Date" timestamptz NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_ControlLetter_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_ControlLetter_Specialist" FOREIGN KEY ("Specialist_Id") REFERENCES "public"."Specialist" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_ControlLetter_Subspecialist" FOREIGN KEY ("Subspecialist_Id") REFERENCES "public"."Subspecialist" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_ControlLetter_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -1,4 +1,4 @@
|
||||
h1:ewCVlZr73Pj7qD/A+J5/yF94CncwZCb6s8VSHl0Hawo=
|
||||
h1:zJVjtCkiWEF41JV7lzbRtI5mPZGz5bC8FaVruh3fmkY=
|
||||
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||
@@ -62,4 +62,6 @@ h1:ewCVlZr73Pj7qD/A+J5/yF94CncwZCb6s8VSHl0Hawo=
|
||||
20251025013609.sql h1:evPJaTD8WxYRMOJZHkSr7ONLx9PYxT+ankzQt9c/sJ0=
|
||||
20251027075128.sql h1:/iFQBM1sytjqpyQSOx61q33gnorMgxTiFVSuL6bQqsM=
|
||||
20251027091406.sql h1:eCZGtUkxAzEAqpC9UsGpP8Df9mS0DEOqSl885LgqpvM=
|
||||
20251102002037.sql h1:FTJ9KdTOhso+wNbDoEtvj3D8XkgT6blu79JucGQoprg=
|
||||
20251102002037.sql h1:lFJbuoZ2LMQnUNGdcwHVY3Xlfslgzu9t2WByT8yfOZI=
|
||||
20251102091932.sql h1:rmdhb5m+P+fU8jROBZNyeYgZKuQvucsuljXv4ZVzvks=
|
||||
20251103081637.sql h1:jqpMnygFceOJn0rI30GYWI2CKbOu6RzVqw2/Pji2Ka8=
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package controlletter
|
||||
|
||||
import (
|
||||
// std
|
||||
"time"
|
||||
|
||||
// internal - lib
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
|
||||
// internal - domain - base-entities
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
|
||||
// internal - domain - main-entities
|
||||
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
eu "simrs-vx/internal/domain/main-entities/unit"
|
||||
)
|
||||
|
||||
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"`
|
||||
Date *time.Time `json:"date"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
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"`
|
||||
Date *time.Time `json:"date"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
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"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Unit_Id *uint `json:"unit_id"`
|
||||
Unit *eu.Unit `json:"unit" gorm:"foreignKey:Unit_Id;references:Id"`
|
||||
Specialist_Id *uint `json:"specialist_id"`
|
||||
Specialist *es.Specialist `json:"specialist" gorm:"foreignKey:Specialist_Id;references:Id"`
|
||||
Subspecialist_Id *uint `json:"subspecialist_id"`
|
||||
Subspecialist *ess.Subspecialist `json:"subspecialist" gorm:"foreignKey:Subspecialist_Id;references:Id"`
|
||||
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,
|
||||
Date: d.Date,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []ControlLetter) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package controlletter
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||
ess "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
eu "simrs-vx/internal/domain/main-entities/unit"
|
||||
)
|
||||
|
||||
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 *eu.Unit `json:"unit" gorm:"foreignKey:Unit_Id;references:Id"`
|
||||
Specialist_Id *uint `json:"specialist_id"`
|
||||
Specialist *es.Specialist `json:"specialist" gorm:"foreignKey:Specialist_Id;references:Id"`
|
||||
Subspecialist_Id *uint `json:"subspecialist_id"`
|
||||
Subspecialist *ess.Subspecialist `json:"subspecialist" gorm:"foreignKey:Subspecialist_Id;references:Id"`
|
||||
Date *time.Time `json:"date"`
|
||||
}
|
||||
@@ -23,8 +23,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
McuOrder_Id *uint `json:"mcuOrder-id"`
|
||||
McuSrc_Id *uint `json:"mcuSrc-id"`
|
||||
McuOrder_Id *uint `json:"mcu-order-id"`
|
||||
McuSrc_Id *uint `json:"mcu-src-id"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status-code"`
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code"`
|
||||
|
||||
pa.AuthInfo
|
||||
}
|
||||
@@ -39,14 +39,15 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Status_Code erc.DataStatusCode `json:"status-code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor-id"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel-code"`
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Status_Code erc.DataStatusCode `json:"status-code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor-id"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgency-level-code"`
|
||||
Scope_Code ercl.McuUrgencyLevelCode `json:"scope-code"`
|
||||
}
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
@@ -74,30 +75,30 @@ type MetaDto struct {
|
||||
}
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code""`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code""`
|
||||
}
|
||||
|
||||
func (d McuOrder) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Status_Code: d.Status_Code,
|
||||
Doctor_Id: d.Doctor_Id,
|
||||
Doctor: d.Doctor,
|
||||
SpecimenPickTime: d.SpecimenPickTime,
|
||||
ExaminationDate: d.ExaminationDate,
|
||||
Number: d.Number,
|
||||
Temperature: d.Temperature,
|
||||
McuUrgencyLevel_Code: d.McuUrgencyLevel_Code,
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Status_Code: d.Status_Code,
|
||||
Doctor_Id: d.Doctor_Id,
|
||||
Doctor: d.Doctor,
|
||||
SpecimenPickTime: d.SpecimenPickTime,
|
||||
ExaminationDate: d.ExaminationDate,
|
||||
Number: d.Number,
|
||||
Temperature: d.Temperature,
|
||||
UrgencyLevel_Code: d.UrgencyLevel_Code,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -12,18 +12,18 @@ import (
|
||||
)
|
||||
|
||||
type McuOrder struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code" gorm:"not null;size:15"`
|
||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code" gorm:"index;size:10"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
|
||||
SpecimenPickTime *time.Time `json:"specimenPickTime"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
Number uint8 `json:"number"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code" gorm:"not null;size:15"`
|
||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code" gorm:"index;size:10"`
|
||||
}
|
||||
|
||||
func (d McuOrder) IsCompleted() bool {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
appointment "simrs-vx/internal/domain/main-entities/appointment"
|
||||
chemo "simrs-vx/internal/domain/main-entities/chemo"
|
||||
consultation "simrs-vx/internal/domain/main-entities/consultation"
|
||||
controlletter "simrs-vx/internal/domain/main-entities/control-letter"
|
||||
counter "simrs-vx/internal/domain/main-entities/counter"
|
||||
deathcause "simrs-vx/internal/domain/main-entities/death-cause"
|
||||
device "simrs-vx/internal/domain/main-entities/device"
|
||||
@@ -193,5 +194,6 @@ func getMainEntities() []any {
|
||||
&responsibledoctorhist.ResponsibleDoctorHist{},
|
||||
&admemployeehist.AdmEmployeeHist{},
|
||||
&vclaimmember.VclaimMember{},
|
||||
&controlletter.ControlLetter{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.McuOrde
|
||||
|
||||
deletedData := e.McuOrderItem{}
|
||||
tx.Unscoped().
|
||||
Where("\"McuOrder_Id\" = ? AND \"McuSrc_Id\" = ?", input.McuOrder_Id, input.McuSrc_Id).
|
||||
Where("\"McuOrder_Id\" = ? AND \"McuSrc_Id\" = ?", *input.McuOrder_Id, input.McuSrc_Id).
|
||||
First(&deletedData)
|
||||
if deletedData.Id != 0 {
|
||||
if err := tx.Model(e.McuOrderItem{}).Where("Id = ?", deletedData.Id).Update("DeletedAt", nil).Error; err != nil {
|
||||
if err := tx.Unscoped().Model(e.McuOrderItem{}).Where("\"Id\" = ?", deletedData.Id).Update("\"DeletedAt\"", nil).Error; err != nil {
|
||||
return nil, plh.HandleCreateError(input, event, err)
|
||||
}
|
||||
return &deletedData, nil
|
||||
|
||||
@@ -26,6 +26,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.McuOrder) {
|
||||
data.ExaminationDate = inputSrc.ExaminationDate
|
||||
data.Number = inputSrc.Number
|
||||
data.Temperature = inputSrc.Temperature
|
||||
data.McuUrgencyLevel_Code = inputSrc.McuUrgencyLevel_Code
|
||||
data.UrgencyLevel_Code = inputSrc.UrgencyLevel_Code
|
||||
data.Doctor_Id = inputSrc.Doctor_Id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user