finish upload

This commit is contained in:
vanilia
2025-11-12 10:01:18 +07:00
15 changed files with 140 additions and 89 deletions

No files matched your search

@@ -21,6 +21,7 @@ import (
"simrs-vx/internal/domain/main-entities/intern"
em "simrs-vx/internal/domain/main-entities/midwife"
en "simrs-vx/internal/domain/main-entities/nurse"
ep "simrs-vx/internal/domain/main-entities/pharmacist"
esp "simrs-vx/internal/domain/main-entities/specialist-position"
essp "simrs-vx/internal/domain/main-entities/subspecialist-position"
eup "simrs-vx/internal/domain/main-entities/unit-position"
@@ -70,7 +71,7 @@ func getDivisionPosition(employee_id uint, event *pl.Event) ([]string, error) {
if len(data) > 0 {
for _, dp := range data {
result = append(result, "div-"+*dp.Division_Code)
result = append(result, "div|"+*dp.Division_Code+"|"+dp.Code)
}
}
@@ -90,7 +91,7 @@ func getInstallationPosition(employeeId uint, event *pl.Event) ([]string, error)
if len(data) > 0 {
for _, dp := range data {
result = append(result, "inst-"+*dp.Installation_Code+"-"+dp.Code)
result = append(result, "inst|"+*dp.Installation_Code+"|"+dp.Code)
}
}
@@ -108,7 +109,7 @@ func getUnitPosition(employeeId uint, event *pl.Event) ([]string, error) {
if len(data) > 0 {
for _, dp := range data {
result = append(result, "unit-"+*dp.Unit_Code+"-"+dp.Code)
result = append(result, "unit|"+*dp.Unit_Code+"|"+dp.Code)
}
}
@@ -126,7 +127,7 @@ func getSpecialistPosition(employeeId uint, event *pl.Event) ([]string, error) {
if len(data) > 0 {
for _, dp := range data {
result = append(result, "spec-"+*dp.Specialist_Code+"-"+dp.Code)
result = append(result, "spec|"+*dp.Specialist_Code+"|"+dp.Code)
}
}
@@ -146,7 +147,7 @@ func getSubspecialistPosition(employeeId uint, event *pl.Event) ([]string, error
if len(data) > 0 {
for _, dp := range data {
result = append(result, "subspec-"+dp.Subspecialist.Code+"-"+dp.Code)
result = append(result, "subspec|"+dp.Subspecialist.Code+"|"+dp.Code)
}
}
@@ -209,7 +210,7 @@ func populateRoles(user *eu.User, input eu.LoginDto, atClaims jwt.MapClaims, out
}
atClaims["employee_id"] = employee.Id
outputData["employee_id"] = employee.Id
roles = append(roles, "emp-"+string(*employee.Position_Code))
roles = append(roles, "emp|"+string(*employee.Position_Code))
// employee position
if employee.Id > 0 && employee.Position_Code != nil {
@@ -249,6 +250,14 @@ func populateRoles(user *eu.User, input eu.LoginDto, atClaims jwt.MapClaims, out
}
atClaims["midwife_code"] = empData.Code
outputData["midwife_code"] = empData.Code
case erg.EPCPha:
empData := ep.Pharmacist{}
dg.I.Where("\"Employee_Id\" = ?", employee.Id).First(&empData)
if empData.Id == 0 {
return d.FieldErrors{"authentication": d.FieldError{Code: "auth-noPharmacist", Message: pl.GenMessage("auth-noPharmacist")}}
}
atClaims["pharmacist_code"] = empData.Code
outputData["pharmacist_code"] = empData.Code
}
errorGetPosition := d.FieldErrors{"authentication": d.FieldError{Code: "auth-getData-failed", Message: pl.GenMessage("auth-getData-failed")}}
@@ -3,6 +3,7 @@ package encounter
import (
"errors"
"fmt"
us "simrs-vx/internal/use-case/main-use-case/soapi"
"strconv"
"time"
@@ -489,6 +490,32 @@ func UpdateStatusCode(input e.UpdateStatusDto) (*d.Data, error) {
return pl.SetLogError(&event, input)
}
if input.StatusCode == erc.DSCCancel {
// TODO: Prevent cancellation if the billing has been verified
// TODO: Only "supervisi pendaftaran" could cancel encounter
// Prevent cancellation if soapi exist
encounterId := uint(input.Id)
dataSoapi, _, err := us.ReadListData(es.ReadListDto{
FilterDto: es.FilterDto{
Encounter_Id: &encounterId,
}}, &event, tx)
if err != nil {
return err
}
if len(dataSoapi) > 0 {
event.Status = "failed"
event.ErrInfo = pl.ErrorInfo{
Code: "cancel-not-allowed",
Detail: "encounter can't be cancelled because SOAPI already exists",
Raw: errors.New("encounter has SOAPI records"),
}
return pl.SetLogError(&event, input)
}
}
mwRunner := newMiddlewareRunner(&event, tx)
mwRunner.setMwType(pu.MWTPre)
// Run pre-middleware
@@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
}
func Update(input e.UpdateDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: input.Id}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.Installation
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: input.Id}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.Installation
var err error
@@ -17,7 +17,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Installation) {
inputSrc = &inputTemp.CreateDto
}
data.Code = inputSrc.Code
data.Code = *inputSrc.Code
data.Name = inputSrc.Name
data.EncounterClass_Code = inputSrc.EncounterClass_Code
}
@@ -81,9 +81,16 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if input.Code != nil {
tx = tx.Where("\"Code\" = ?", *input.Code)
}
if input.Id != nil {
tx = tx.Where("\"Id\" = ?", *input.Id)
}
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
First(&data).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -175,7 +175,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
}
func Update(input e.UpdateDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: input.Id}
rdDto := e.ReadDetailDto{Code: &input.Code}
var data *e.SpecialistPosition
var err error
@@ -235,7 +235,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
}
func Delete(input e.DeleteDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: input.Id}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.SpecialistPosition
var err error
@@ -86,7 +86,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
case input.Id != nil:
getData = tx.First(&data, input.Id)
case input.Code != nil && *input.Code != "":
getData = tx.Where("code = ?", *input.Code).First(&data)
getData = tx.Where("\"Code\" = ?", *input.Code).First(&data)
default:
event.Status = "failed"
event.ErrInfo = pl.ErrorInfo{
@@ -13,7 +13,7 @@ import (
"gorm.io/gorm"
)
const source = "specialist"
const source = "subspecialist"
func Create(input e.CreateDto) (*d.Data, error) {
data := e.Subspecialist{}
@@ -90,7 +90,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
if err := tx.
Scopes(gh.Preload(input.Includes)).
First(&data, input.Id).Error; err != nil {
First(&data).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -86,7 +86,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
case input.Id != nil:
getData = tx.First(&data, input.Id)
case input.Code != nil && *input.Code != "":
getData = tx.Where("code = ?", *input.Code).First(&data)
getData = tx.Where("\"Code\" = ?", *input.Code).First(&data)
default:
event.Status = "failed"
event.ErrInfo = pl.ErrorInfo{
@@ -107,16 +107,24 @@ func setPersonAttachment(input e.CreateDto, event *pl.Event, tx *gorm.DB) (*ep.P
var removeUrl string
switch input.Type_Code {
case eru.UCPRN:
removeUrl = *dataPerson.ResidentIdentityFileUrl
if dataPerson.ResidentIdentityFileUrl != nil {
removeUrl = *dataPerson.ResidentIdentityFileUrl
}
dataPerson.ResidentIdentityFileUrl = &input.FilePath
case eru.UCPDL:
removeUrl = *dataPerson.DrivingLicenseFileUrl
if dataPerson.DrivingLicenseFileUrl != nil {
removeUrl = *dataPerson.DrivingLicenseFileUrl
}
dataPerson.DrivingLicenseFileUrl = &input.FilePath
case eru.UCPP:
removeUrl = *dataPerson.PassportFileUrl
if dataPerson.PassportFileUrl != nil {
removeUrl = *dataPerson.PassportFileUrl
}
dataPerson.PassportFileUrl = &input.FilePath
case eru.UCPFC:
removeUrl = *dataPerson.FamilyIdentityFileUrl
if dataPerson.FamilyIdentityFileUrl != nil {
removeUrl = *dataPerson.FamilyIdentityFileUrl
}
dataPerson.FamilyIdentityFileUrl = &input.FilePath
}