feat (encounter): create-with-patient wip

This commit is contained in:
dpurbosakti
2025-12-11 15:29:01 +07:00
parent 4172ecc427
commit 2e70cd727c
7 changed files with 218 additions and 10 deletions
@@ -312,3 +312,29 @@ func (obj myBase) CancelSwitchUnit(w http.ResponseWriter, r *http.Request) {
res, err := u.CancelSwitchUnit(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) CreateWithPatient(w http.ResponseWriter, r *http.Request) {
authInfo, err := pa.GetAuthInfo(r)
if err != nil {
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
}
dto := e.CreateWithPatientDto{}
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
// validate SubClass
if err := verifyClassCode(dto.Encounter); err != nil {
rw.DataResponse(w, nil, d.FieldError{
Code: dataValidationFail,
Message: err.Error(),
})
return
}
dto.Encounter.AuthInfo = *authInfo
dto.Patient.AuthInfo = *authInfo
res, err := u.CreateWithPatient(dto)
rw.DataResponse(w, res, err)
}