Merge branch 'migration-vanilia' of https://github.com/dikstub-rssa/simrs-be into feat/sync-seeder
# Conflicts: # internal/interface/main-handler/main-handler.go
This commit is contained in:
@@ -240,8 +240,8 @@ func (obj myBase) Skip(w http.ResponseWriter, r *http.Request) {
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.SwitchUnitDto{}
|
||||
func (obj myBase) RequestSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.SwitchSpecialistDto{}
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
@@ -252,7 +252,7 @@ func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// validate request body
|
||||
if valid := validateRequestSwitchUnit(w, dto); !valid {
|
||||
if valid := validateRequestSwitchSpecialist(w, dto); !valid {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -263,12 +263,12 @@ func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Id = uint(id)
|
||||
res, err := u.RequestSwitchUnit(dto)
|
||||
res, err := u.RequestSwitchSpecialist(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) ApproveSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelUnitDto{}
|
||||
func (obj myBase) ApproveSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelSpecialistDto{}
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
@@ -286,12 +286,12 @@ func (obj myBase) ApproveSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Id = uint(id)
|
||||
|
||||
res, err := u.ApproveSwitchUnit(dto)
|
||||
res, err := u.ApproveSwitchSpecialist(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CancelSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelUnitDto{}
|
||||
func (obj myBase) CancelSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelSpecialistDto{}
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
@@ -309,6 +309,32 @@ func (obj myBase) CancelSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Id = uint(id)
|
||||
|
||||
res, err := u.CancelSwitchUnit(dto)
|
||||
res, err := u.CancelSwitchSpecialist(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)
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func validateRequestCheckIn(w http.ResponseWriter, i e.CheckinDto) (valid bool)
|
||||
return true
|
||||
}
|
||||
|
||||
func validateRequestSwitchUnit(w http.ResponseWriter, i e.SwitchUnitDto) (valid bool) {
|
||||
func validateRequestSwitchSpecialist(w http.ResponseWriter, i e.SwitchSpecialistDto) (valid bool) {
|
||||
// validate poly-switch-code
|
||||
if i.PolySwitchCode == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
@@ -84,7 +84,7 @@ func validateRequestSwitchUnit(w http.ResponseWriter, i e.SwitchUnitDto) (valid
|
||||
}
|
||||
|
||||
for _, v := range *i.InternalReferences {
|
||||
if v.Unit_Code == nil {
|
||||
if v.Specialist_Code == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: dataValidationFail,
|
||||
Message: "internalReferences.unit_code required",
|
||||
|
||||
@@ -115,8 +115,6 @@ import (
|
||||
subspecialist "simrs-vx/internal/interface/main-handler/subspecialist"
|
||||
subspecialistposition "simrs-vx/internal/interface/main-handler/subspecialist-position"
|
||||
therapyprotocol "simrs-vx/internal/interface/main-handler/therapy-protocol"
|
||||
unit "simrs-vx/internal/interface/main-handler/unit"
|
||||
unitposition "simrs-vx/internal/interface/main-handler/unit-position"
|
||||
uom "simrs-vx/internal/interface/main-handler/uom"
|
||||
vehicle "simrs-vx/internal/interface/main-handler/vehicle"
|
||||
vehiclehist "simrs-vx/internal/interface/main-handler/vehicle-hist"
|
||||
@@ -194,9 +192,10 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/cancel": encounter.O.Cancel,
|
||||
"PATCH /{id}/reject": encounter.O.Reject,
|
||||
"PATCH /{id}/skip": encounter.O.Skip,
|
||||
"PATCH /{id}/req-switch-unit": encounter.O.RequestSwitchUnit,
|
||||
"PATCH /{id}/approve-switch-unit": encounter.O.ApproveSwitchUnit,
|
||||
"PATCH /{id}/cancel-switch-unit": encounter.O.CancelSwitchUnit,
|
||||
"PATCH /{id}/req-switch-unit": encounter.O.RequestSwitchSpecialist,
|
||||
"PATCH /{id}/approve-switch-unit": encounter.O.ApproveSwitchSpecialist,
|
||||
"PATCH /{id}/cancel-switch-unit": encounter.O.CancelSwitchSpecialist,
|
||||
"POST /create-with-patient": encounter.O.CreateWithPatient,
|
||||
})
|
||||
hk.GroupRoutes("/v1/mcu-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": mcuorder.O.GetList,
|
||||
@@ -375,9 +374,7 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": installation.O.Delete,
|
||||
"POST /bulk": installation.O.CreateBulk,
|
||||
})
|
||||
hc.RegCrudByCode(r, "/v1/unit", unit.O)
|
||||
hc.RegCrudByCode(r, "/v1/installation-position", installationposition.O)
|
||||
hc.RegCrudByCode(r, "/v1/unit-position", unitposition.O)
|
||||
hk.GroupRoutes("/v1/specialist", r, hk.MapHandlerFunc{
|
||||
"GET /": specialist.O.GetList,
|
||||
"GET /{id}": specialist.O.GetDetail,
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package unit_position
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/unit-position"
|
||||
u "simrs-vx/internal/use-case/main-use-case/unit-position"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Code = &code
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Code = code
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Code = &code
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/unit"
|
||||
u "simrs-vx/internal/use-case/main-use-case/unit"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Code = &code
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Code = code
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Code = &code
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -109,8 +109,6 @@ import (
|
||||
subspecialist "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
subspecialistposition "simrs-vx/internal/domain/main-entities/subspecialist-position"
|
||||
therapyprotocol "simrs-vx/internal/domain/main-entities/therapy-protocol"
|
||||
unit "simrs-vx/internal/domain/main-entities/unit"
|
||||
unitposition "simrs-vx/internal/domain/main-entities/unit-position"
|
||||
uom "simrs-vx/internal/domain/main-entities/uom"
|
||||
user "simrs-vx/internal/domain/main-entities/user"
|
||||
userfes "simrs-vx/internal/domain/main-entities/user-fes"
|
||||
@@ -135,7 +133,6 @@ func getMainEntities() []any {
|
||||
&division.Division{},
|
||||
&divisionposition.DivisionPosition{},
|
||||
&installation.Installation{},
|
||||
&unit.Unit{},
|
||||
&village.Village{},
|
||||
&district.District{},
|
||||
®ency.Regency{},
|
||||
@@ -237,7 +234,6 @@ func getMainEntities() []any {
|
||||
&generalconsent.GeneralConsent{},
|
||||
&deathcause.DeathCause{},
|
||||
&installationposition.InstallationPosition{},
|
||||
&unitposition.UnitPosition{},
|
||||
&specialistposition.SpecialistPosition{},
|
||||
&subspecialistposition.SubspecialistPosition{},
|
||||
&responsibledoctorhist.ResponsibleDoctorHist{},
|
||||
|
||||
@@ -87,32 +87,32 @@ func (obj myBase) UpdateStatus(w http.ResponseWriter, r *http.Request) {
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) RequestSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
func (obj myBase) RequestSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Encounter{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.RequestSwitchUnit(dto)
|
||||
res, err := u.RequestSwitchSpecialist(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) ApproveSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelUnitDto{}
|
||||
func (obj myBase) ApproveSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelSpecialistDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.ApproveSwitchUnit(dto)
|
||||
res, err := u.ApproveSwitchSpecialist(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CancelSwitchUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelUnitDto{}
|
||||
func (obj myBase) CancelSwitchSpecialist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ApproveCancelSpecialistDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.CancelSwitchUnit(dto)
|
||||
res, err := u.CancelSwitchSpecialist(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/unit"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/unit"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/soapi"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/specialist"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/subspecialist"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/unit"
|
||||
|
||||
sd "simrs-vx/internal/interface/simgos-sync-handler/seeder"
|
||||
|
||||
@@ -55,7 +54,6 @@ func SetRoutes() http.Handler {
|
||||
/******************** SvcToOld ******************/
|
||||
prefixnew := "/new-to-old"
|
||||
hc.SyncCrud(r, prefixnew+"/v1/installation", installation.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/unit", unit.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/division", division.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/specialist", specialist.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/subspecialist", subspecialist.O)
|
||||
@@ -74,9 +72,9 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/checkin": encounter.O.Checkin,
|
||||
"PATCH /{id}/checkout": encounter.O.Checkout,
|
||||
"PATCH /{id}/update-status": encounter.O.UpdateStatus,
|
||||
"PATCH /{id}/req-switch-unit": encounter.O.RequestSwitchUnit,
|
||||
"PATCH /{id}/approve-switch-unit": encounter.O.ApproveSwitchUnit,
|
||||
"PATCH /{id}/cancel-switch-unit": encounter.O.CancelSwitchUnit,
|
||||
"PATCH /{id}/req-switch-unit": encounter.O.RequestSwitchSpecialist,
|
||||
"PATCH /{id}/approve-switch-unit": encounter.O.ApproveSwitchSpecialist,
|
||||
"PATCH /{id}/cancel-switch-unit": encounter.O.CancelSwitchSpecialist,
|
||||
})
|
||||
hc.SyncCrud(r, prefixnew+"/v1/soapi", soapi.O)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user