feat (prescription): add approve + create medication

This commit is contained in:
dpurbosakti
2025-09-22 13:21:29 +07:00
parent 02c86a9ec0
commit 202bb32e9c
6 changed files with 196 additions and 59 deletions
@@ -116,7 +116,6 @@ func SetRoutes() http.Handler {
hc.RegCrud(r, "/v1/soapi", auth.GuardMW, soapi.O)
hc.RegCrud(r, "/v1/adime", auth.GuardMW, adime.O)
hc.RegCrud(r, "/v1/sbar", auth.GuardMW, sbar.O)
hc.RegCrud(r, "/v1/prescription", prescription.O)
hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O)
hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O)
hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O)
@@ -138,6 +137,14 @@ func SetRoutes() http.Handler {
"PATCH /{id}/complete": mcuorderitem.O.Complete,
"PATCH /{id}/set-schedule": mcuorderitem.O.SetSchedule,
})
hk.GroupRoutes("/v1/prescription", r, hk.MapHandlerFunc{
"GET /": prescription.O.GetList,
"GET /{id}": prescription.O.GetDetail,
"POST /": prescription.O.Create,
"PATCH /{id}": prescription.O.Update,
"DELETE /{id}": prescription.O.Delete,
"PATCH /{id}/approve": prescription.O.Approve,
})
hk.GroupRoutes("/v1/mcu-order-sub-item", r, hk.MapHandlerFunc{
"GET /": mcuordersubitem.O.GetList,
"GET /{id}": mcuordersubitem.O.GetDetail,
@@ -69,3 +69,15 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Approve(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
return
}
dto := e.ReadDetailDto{}
dto.Id = uint(id)
res, err := u.Approve(dto)
rw.DataResponse(w, res, err)
}