finish upload
This commit is contained in:
No files matched your search
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code" validate:"maxLength=10"`
|
||||
Code *string `json:"code" validate:"maxLength=10"`
|
||||
Name string `json:"name" validate:"maxLength=50"`
|
||||
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" validate:"maxLength=10"`
|
||||
}
|
||||
@@ -21,25 +21,26 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Code *string `json:"code"`
|
||||
Name *string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass-code"`
|
||||
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
|
||||
@@ -11,21 +11,21 @@ type (
|
||||
)
|
||||
|
||||
const (
|
||||
CSCSys ContractPositionCode = "system" // System
|
||||
CSCEmp ContractPositionCode = "employee" // Pegawai
|
||||
CSCInt ContractPositionCode = "intern" // PPDS
|
||||
CSCSys ContractPositionCode = "sys" // System
|
||||
CSCEmp ContractPositionCode = "emp" // Pegawai
|
||||
CSCInt ContractPositionCode = "int" // PPDS
|
||||
|
||||
EPCReg EmployeePositionCode = "registration" // Admisi/Pendaftaran
|
||||
EPCNur EmployeePositionCode = "nurse" // Perawat
|
||||
EPCDoc EmployeePositionCode = "doctor" // Dokter
|
||||
EPCNut EmployeePositionCode = "nutritionist" // Ahli gizi
|
||||
EPCMwi EmployeePositionCode = "mid-wife" // Bidan
|
||||
EPCLab EmployeePositionCode = "laborant" // Laboran
|
||||
EPCPha EmployeePositionCode = "pharmacy" // Farmasi
|
||||
EPCPay EmployeePositionCode = "payment" // Pembayaran
|
||||
EPCHur EmployeePositionCode = "human-resource" // Sumber Daya Manusia
|
||||
EPCGea EmployeePositionCode = "general-affair" // Bagian Umum
|
||||
EPCMan EmployeePositionCode = "management" // Manajemen
|
||||
EPCReg EmployeePositionCode = "reg" // Admisi/Pendaftaran
|
||||
EPCNur EmployeePositionCode = "nur" // Perawat
|
||||
EPCDoc EmployeePositionCode = "doc" // Dokter
|
||||
EPCNut EmployeePositionCode = "nut" // Ahli gizi
|
||||
EPCMwi EmployeePositionCode = "miw" // Bidan
|
||||
EPCLab EmployeePositionCode = "lab" // Laboran
|
||||
EPCPha EmployeePositionCode = "pha" // Farmasi
|
||||
EPCPay EmployeePositionCode = "pay" // Pembayaran
|
||||
EPCHur EmployeePositionCode = "hue" // Sumber Daya Manusia
|
||||
EPCGea EmployeePositionCode = "gea" // Bagian Umum
|
||||
EPCMan EmployeePositionCode = "man" // Manajemen
|
||||
|
||||
IPCSpecialist = "specialist-intern"
|
||||
IPCNurse = "nurse-intern"
|
||||
|
||||
@@ -33,21 +33,21 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
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, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,19 +55,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint16(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, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.Code = &code
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user