add adjustment checkout
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package encounter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
@@ -84,6 +85,8 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) CheckOut(w http.ResponseWriter, r *http.Request) {
|
||||
const dataValidationVail = "data-validation-fail"
|
||||
|
||||
dto := e.DischargeDto{}
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
@@ -95,7 +98,44 @@ func (obj myBase) CheckOut(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// validate request body
|
||||
if dto.DischargeMethod_Code == ere.
|
||||
{
|
||||
switch *dto.Discharge_Method_Code {
|
||||
case ere.DMCDeath:
|
||||
if dto.DeathCause == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationVail,
|
||||
Message: "deathCause required if discharge_method_code is death",
|
||||
})
|
||||
return
|
||||
}
|
||||
case ere.DMCConsulPoly, ere.DMCConsulExecutive:
|
||||
if dto.InternalReferences == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationVail,
|
||||
Message: fmt.Sprintf("internalReferences required if discharge_method_code is %s", *dto.Discharge_Method_Code),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range *dto.InternalReferences {
|
||||
if v.Unit_Id == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationVail,
|
||||
Message: "internalReferences.unit_id required",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if v.Doctor_Id == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationVail,
|
||||
Message: "internalReferences.doctor_id required",
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
res, err := u.CheckOut(dto)
|
||||
|
||||
Reference in New Issue
Block a user