Merge branch 'dev' of https://github.com/dikstub-rssa/simrs-be into feat/encounter-adjustment
# Conflicts: # cmd/main-migration/migrations/atlas.sum
This commit is contained in:
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
-- Modify "McuOrder" table
|
||||||
|
ALTER TABLE "public"."McuOrder" ADD COLUMN "Scope_Code" character varying(10) NULL;
|
||||||
|
-- Create index "idx_McuOrder_Scope_Code" to table: "McuOrder"
|
||||||
|
CREATE INDEX "idx_McuOrder_Scope_Code" ON "public"."McuOrder" ("Scope_Code");
|
||||||
|
-- Create index "idx_McuSrcCategory_Scope_Code" to table: "McuSrcCategory"
|
||||||
|
CREATE INDEX "idx_McuSrcCategory_Scope_Code" ON "public"."McuSrcCategory" ("Scope_Code");
|
||||||
@@ -49,7 +49,8 @@ type FilterDto struct {
|
|||||||
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel-code"`
|
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel-code"`
|
||||||
}
|
}
|
||||||
type ReadDetailDto struct {
|
type ReadDetailDto struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
|
Includes string `json:"includes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateDto struct {
|
type UpdateDto struct {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
ercl "simrs-vx/internal/domain/references/clinical"
|
ercl "simrs-vx/internal/domain/references/clinical"
|
||||||
erc "simrs-vx/internal/domain/references/common"
|
erc "simrs-vx/internal/domain/references/common"
|
||||||
|
ere "simrs-vx/internal/domain/references/encounter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type McuOrder struct {
|
type McuOrder struct {
|
||||||
@@ -22,6 +23,7 @@ type McuOrder struct {
|
|||||||
Number uint8 `json:"number"`
|
Number uint8 `json:"number"`
|
||||||
Temperature float64 `json:"temperature"`
|
Temperature float64 `json:"temperature"`
|
||||||
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code" gorm:"not null;size:15"`
|
McuUrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"mcuUrgencyLevel_code" gorm:"not null;size:15"`
|
||||||
|
Scope_Code *ere.CheckupScopeCode `json:"scope_code" gorm:"index;size:10"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d McuOrder) IsCompleted() bool {
|
func (d McuOrder) IsCompleted() bool {
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ type McuSrcCategory struct {
|
|||||||
ecore.SmallMain // adjust this according to the needs
|
ecore.SmallMain // adjust this according to the needs
|
||||||
Code string `json:"code" gorm:"unique;size:20"`
|
Code string `json:"code" gorm:"unique;size:20"`
|
||||||
Name string `json:"name" gorm:"size:50"`
|
Name string `json:"name" gorm:"size:50"`
|
||||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code" gorm:"size:10"`
|
Scope_Code *ere.CheckupScopeCode `json:"scope_code" gorm:"index;size:10"`
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ type ReadListDto struct {
|
|||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
McuSrcCategory_Code *string `json:"mcuSrcCategory-code"`
|
McuSrcCategory_Code *string `json:"mcu-src-category-code"`
|
||||||
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ type FilterDto struct {
|
|||||||
Status_Code *erc.DataStatusCode `json:"status-code"`
|
Status_Code *erc.DataStatusCode `json:"status-code"`
|
||||||
}
|
}
|
||||||
type ReadDetailDto struct {
|
type ReadDetailDto struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Encounter_Id *uint `json:"encounter_id"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
|
Includes string `json:"includes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateDto struct {
|
type UpdateDto struct {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package subspecialist
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
|
es "simrs-vx/internal/domain/main-entities/specialist"
|
||||||
espb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
|
espb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -48,10 +49,11 @@ type MetaDto struct {
|
|||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
ecore.SmallMain
|
ecore.SmallMain
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Specialist_Id *uint16 `json:"specialist_id"`
|
Specialist_Id *uint16 `json:"specialist_id"`
|
||||||
Subspecialist []espb.Basic `json:"subspecialistPositions,omitempty"`
|
Specialist *es.Specialist `json:"specialist,omitempty"`
|
||||||
|
Subspecialist []espb.Basic `json:"subspecialistPositions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Subspecialist) ToResponse() ResponseDto {
|
func (d Subspecialist) ToResponse() ResponseDto {
|
||||||
@@ -59,6 +61,7 @@ func (d Subspecialist) ToResponse() ResponseDto {
|
|||||||
Code: d.Code,
|
Code: d.Code,
|
||||||
Name: d.Name,
|
Name: d.Name,
|
||||||
Specialist_Id: d.Specialist_Id,
|
Specialist_Id: d.Specialist_Id,
|
||||||
|
Specialist: d.Specialist,
|
||||||
Subspecialist: d.SubspecialistPositions,
|
Subspecialist: d.SubspecialistPositions,
|
||||||
}
|
}
|
||||||
resp.SmallMain = d.SmallMain
|
resp.SmallMain = d.SmallMain
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dto := e.ReadDetailDto{}
|
dto := e.ReadDetailDto{}
|
||||||
|
sf.UrlQueryParam(&dto, *r.URL)
|
||||||
dto.Id = uint(id)
|
dto.Id = uint(id)
|
||||||
res, err := u.ReadDetail(dto)
|
res, err := u.ReadDetail(dto)
|
||||||
rw.DataResponse(w, res, err)
|
rw.DataResponse(w, res, err)
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
e "simrs-vx/internal/domain/main-entities/adime"
|
e "simrs-vx/internal/domain/main-entities/adime"
|
||||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
|
||||||
|
|
||||||
ue "simrs-vx/internal/use-case/main-use-case/employee"
|
|
||||||
|
|
||||||
dg "github.com/karincake/apem/db-gorm-pg"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
d "github.com/karincake/dodol"
|
d "github.com/karincake/dodol"
|
||||||
@@ -49,11 +46,13 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
|||||||
return pl.SetLogError(&event, input)
|
return pl.SetLogError(&event, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
employee, err := ue.ReadDetailData(ee.ReadDetailDto{User_Id: &input.AuthInfo.User_Id}, &event, tx)
|
if input.AuthInfo.Employee_Id != nil {
|
||||||
if err != nil {
|
v := uint(*input.AuthInfo.Employee_Id)
|
||||||
return err
|
input.Employee_Id = &v
|
||||||
|
} else {
|
||||||
|
input.Employee_Id = nil
|
||||||
}
|
}
|
||||||
input.Employee_Id = &employee.Id
|
|
||||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ func GenToken(input eu.LoginDto) (*d.Data, error) {
|
|||||||
|
|
||||||
// employee position
|
// employee position
|
||||||
if employee.Id > 0 && employee.Position_Code != nil {
|
if employee.Id > 0 && employee.Position_Code != nil {
|
||||||
|
atClaims["employee_position_code"] = *employee.Position_Code
|
||||||
switch *employee.Position_Code {
|
switch *employee.Position_Code {
|
||||||
case erg.EPCDoc:
|
case erg.EPCDoc:
|
||||||
doctor := ed.Doctor{}
|
doctor := ed.Doctor{}
|
||||||
@@ -314,6 +315,7 @@ func ExtractToken(r *http.Request, tokenType TokenType) (data *pa.AuthInfo, err
|
|||||||
data.Laborant_Id = checkIntPtrClaims(claims, "laborant_id")
|
data.Laborant_Id = checkIntPtrClaims(claims, "laborant_id")
|
||||||
data.Pharmachist_Id = checkIntPtrClaims(claims, "pharmachist_id")
|
data.Pharmachist_Id = checkIntPtrClaims(claims, "pharmachist_id")
|
||||||
data.Intern_Position_Code = checkStrPtrClaims(claims, "intern_position_code")
|
data.Intern_Position_Code = checkStrPtrClaims(claims, "intern_position_code")
|
||||||
|
data.Employee_Id = checkIntPtrClaims(claims, "employee_id")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return nil, d.FieldError{Code: "token", Message: "token-invalid"}
|
return nil, d.FieldError{Code: "token", Message: "token-invalid"}
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import (
|
|||||||
func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.McuOrderItem, error) {
|
func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.McuOrderItem, error) {
|
||||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||||
|
|
||||||
data := e.McuOrderItem{}
|
|
||||||
setData(&input, &data)
|
|
||||||
|
|
||||||
var tx *gorm.DB
|
var tx *gorm.DB
|
||||||
if len(dbx) > 0 {
|
if len(dbx) > 0 {
|
||||||
tx = dbx[0]
|
tx = dbx[0]
|
||||||
@@ -25,6 +22,20 @@ func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.McuOrde
|
|||||||
tx = dg.I
|
tx = dg.I
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletedData := e.McuOrderItem{}
|
||||||
|
tx.Unscoped().
|
||||||
|
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 {
|
||||||
|
return nil, plh.HandleCreateError(input, event, err)
|
||||||
|
}
|
||||||
|
return &deletedData, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
data := e.McuOrderItem{}
|
||||||
|
setData(&input, &data)
|
||||||
|
|
||||||
if err := tx.Create(&data).Error; err != nil {
|
if err := tx.Create(&data).Error; err != nil {
|
||||||
return nil, plh.HandleCreateError(input, event, err)
|
return nil, plh.HandleCreateError(input, event, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
|||||||
tx = dg.I
|
tx = dg.I
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tx.First(&data, input.Id).Error; err != nil {
|
if err := tx.Scopes(gh.Preload(input.Includes)).First(&data, input.Id).Error; err != nil {
|
||||||
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
|
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
|
||||||
return nil, processedErr
|
return nil, processedErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
|||||||
tx = tx.Where("\"Id\" = ?", input.Id)
|
tx = tx.Where("\"Id\" = ?", input.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tx.First(&data).Error; err != nil {
|
if err := tx.Scopes(gh.Preload(input.Includes)).First(&data).Error; err != nil {
|
||||||
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
|
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
|
||||||
return nil, processedErr
|
return nil, processedErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
|
||||||
e "simrs-vx/internal/domain/main-entities/sbar"
|
e "simrs-vx/internal/domain/main-entities/sbar"
|
||||||
|
|
||||||
ue "simrs-vx/internal/use-case/main-use-case/employee"
|
|
||||||
|
|
||||||
dg "github.com/karincake/apem/db-gorm-pg"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
d "github.com/karincake/dodol"
|
d "github.com/karincake/dodol"
|
||||||
|
|
||||||
@@ -49,11 +46,13 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
|||||||
return pl.SetLogError(&event, input)
|
return pl.SetLogError(&event, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
employee, err := ue.ReadDetailData(ee.ReadDetailDto{User_Id: &input.AuthInfo.User_Id}, &event, tx)
|
if input.AuthInfo.Employee_Id != nil {
|
||||||
if err != nil {
|
v := uint(*input.AuthInfo.Employee_Id)
|
||||||
return err
|
input.Employee_Id = &v
|
||||||
|
} else {
|
||||||
|
input.Employee_Id = nil
|
||||||
}
|
}
|
||||||
input.Employee_Id = &employee.Id
|
|
||||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
|
||||||
e "simrs-vx/internal/domain/main-entities/soapi"
|
e "simrs-vx/internal/domain/main-entities/soapi"
|
||||||
|
|
||||||
ue "simrs-vx/internal/use-case/main-use-case/employee"
|
|
||||||
|
|
||||||
dg "github.com/karincake/apem/db-gorm-pg"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
d "github.com/karincake/dodol"
|
d "github.com/karincake/dodol"
|
||||||
|
|
||||||
@@ -49,11 +46,13 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
|||||||
return pl.SetLogError(&event, input)
|
return pl.SetLogError(&event, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
employee, err := ue.ReadDetailData(ee.ReadDetailDto{User_Id: &input.AuthInfo.User_Id}, &event, tx)
|
if input.AuthInfo.Employee_Id != nil {
|
||||||
if err != nil {
|
v := uint(*input.AuthInfo.Employee_Id)
|
||||||
return err
|
input.Employee_Id = &v
|
||||||
|
} else {
|
||||||
|
input.Employee_Id = nil
|
||||||
}
|
}
|
||||||
input.Employee_Id = &employee.Id
|
|
||||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user