Merge branch 'dev' of https://github.com/dikstub-rssa/simrs-be into feat/chemo-plan
This commit is contained in:
@@ -338,3 +338,29 @@ func (obj myBase) CreateWithPatient(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := u.CreateWithPatient(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)
|
||||
}
|
||||
|
||||
@@ -71,3 +71,12 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateBulk(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateBulkDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateBulk(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -374,10 +374,31 @@ func SetRoutes() http.Handler {
|
||||
/******************** sources ********************/
|
||||
hc.RegCrudByCode(r, "/v1/division", division.O)
|
||||
hc.RegCrudByCode(r, "/v1/division-position", divisionposition.O)
|
||||
hc.RegCrudByCode(r, "/v1/installation", installation.O)
|
||||
hk.GroupRoutes("/v1/installation", r, hk.MapHandlerFunc{
|
||||
"GET /": installation.O.GetList,
|
||||
"GET /{id}": installation.O.GetDetail,
|
||||
"POST /": installation.O.Create,
|
||||
"PATCH /{id}": installation.O.Update,
|
||||
"DELETE /{id}": installation.O.Delete,
|
||||
"POST /bulk": installation.O.CreateBulk,
|
||||
})
|
||||
hc.RegCrudByCode(r, "/v1/installation-position", installationposition.O)
|
||||
hc.RegCrudByCode(r, "/v1/specialist", specialist.O)
|
||||
hc.RegCrudByCode(r, "/v1/subspecialist", subspecialist.O)
|
||||
hk.GroupRoutes("/v1/specialist", r, hk.MapHandlerFunc{
|
||||
"GET /": specialist.O.GetList,
|
||||
"GET /{id}": specialist.O.GetDetail,
|
||||
"POST /": specialist.O.Create,
|
||||
"PATCH /{id}": specialist.O.Update,
|
||||
"DELETE /{id}": specialist.O.Delete,
|
||||
"POST /bulk": specialist.O.CreateBulk,
|
||||
})
|
||||
hk.GroupRoutes("/v1/subspecialist", r, hk.MapHandlerFunc{
|
||||
"GET /": subspecialist.O.GetList,
|
||||
"GET /{id}": subspecialist.O.GetDetail,
|
||||
"POST /": subspecialist.O.Create,
|
||||
"PATCH /{id}": subspecialist.O.Update,
|
||||
"DELETE /{id}": subspecialist.O.Delete,
|
||||
"POST /bulk": subspecialist.O.CreateBulk,
|
||||
})
|
||||
hc.RegCrudByCode(r, "/v1/specialist-position", specialistposition.O)
|
||||
hc.RegCrudByCode(r, "/v1/subspecialist-position", subspecialistposition.O)
|
||||
hc.RegCrudByCode(r, "/v1/infra", infra.O)
|
||||
|
||||
@@ -71,3 +71,12 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateBulk(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateBulkDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateBulk(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -71,3 +71,12 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateBulk(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateBulkDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateBulk(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user