Merge pull request #182 from dikstub-rssa/feat/sync-from-simgos-161

merge old-to-new/patient
This commit is contained in:
vaniliacahya
2025-12-03 13:27:23 +07:00
committed by GitHub
7 changed files with 595 additions and 2 deletions
@@ -0,0 +1,48 @@
package patient
import (
"net/http"
p "simrs-vx/internal/domain/simgos-entities/m-pasien"
uo "simrs-vx/internal/use-case/simgos-sync-use-case/old/patient"
rw "github.com/karincake/risoles"
)
type myBase struct{}
var O myBase
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
dto := p.MPasienDto{}
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
return
}
// mapping m_patient to patient
patient := dto.ToPatient()
res, err := uo.Create(patient)
rw.DataResponse(w, res, err)
}
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
dto := p.MPasienDto{}
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
return
}
patient := dto.ToPatient()
res, err := uo.Update(patient)
rw.DataResponse(w, res, err)
}
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
dto := p.MPasienDto{}
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
return
}
patient := dto.ToPatient()
res, err := uo.Delete(patient)
rw.DataResponse(w, res, err)
}
@@ -30,6 +30,8 @@ import (
"simrs-vx/internal/interface/simgos-sync-handler/new/subspecialist"
"simrs-vx/internal/interface/simgos-sync-handler/new/unit"
oldpatient "simrs-vx/internal/interface/simgos-sync-handler/old/patient"
oauth "simrs-vx/internal/interface/simgos-sync-handler/old/authentication" // just a reminder, an openauth
)
@@ -76,7 +78,10 @@ func SetRoutes() http.Handler {
/******************** SvcToNew ******************/
prefixold := "/old-to-new"
hk.GroupRoutes(prefixold+"/v1/patient", r, oauth.OldGuardMW, hk.MapHandlerFunc{}) // FINISH THIS
hk.GroupRoutes(prefixold+"/v1/patient", r, oauth.OldGuardMW, hk.MapHandlerFunc{
"POST /": oldpatient.O.Create,
"PATCH /{id}": oldpatient.O.Update,
"DELETE /{id}": oldpatient.O.Delete,
}) // FINISH THIS
return cmw.SetCors(handlerlogger.SetLog(r))
}