Merge branch 'migration' of https://github.com/dikstub-rssa/simrs-be into migration-vanilia
# Conflicts: # cmd/main-migration/migrations/atlas.sum
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package encounter_document
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/encounter-document"
|
||||
u "simrs-vx/internal/use-case/main-use-case/encounter-document"
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
if dto.Encounter_Id == nil {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: "data-validation-fail",
|
||||
Message: "filter encounter-id required",
|
||||
})
|
||||
return
|
||||
}
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.ReadDetail(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
|
||||
}
|
||||
dto.Id = uint16(id)
|
||||
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{}
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -89,9 +89,14 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -159,11 +164,17 @@ func (obj myBase) Cancel(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
dto := e.UpdateStatusDto{
|
||||
Id: uint16(id),
|
||||
StatusCode: erc.DSCCancel,
|
||||
}
|
||||
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.UpdateStatusCode(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
deviceorder "simrs-vx/internal/interface/main-handler/device-order"
|
||||
deviceorderitem "simrs-vx/internal/interface/main-handler/device-order-item"
|
||||
encounter "simrs-vx/internal/interface/main-handler/encounter"
|
||||
encounterdocument "simrs-vx/internal/interface/main-handler/encounter-document"
|
||||
internalreference "simrs-vx/internal/interface/main-handler/internal-reference"
|
||||
materialorder "simrs-vx/internal/interface/main-handler/material-order"
|
||||
materialorderitem "simrs-vx/internal/interface/main-handler/material-order-item"
|
||||
@@ -36,7 +37,6 @@ import (
|
||||
upload "simrs-vx/internal/interface/main-handler/upload"
|
||||
|
||||
/******************** actor ********************/
|
||||
|
||||
authpartner "simrs-vx/internal/interface/main-handler/auth-partner"
|
||||
doctor "simrs-vx/internal/interface/main-handler/doctor"
|
||||
employee "simrs-vx/internal/interface/main-handler/employee"
|
||||
@@ -60,6 +60,7 @@ import (
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
minio "simrs-vx/internal/infra/minio"
|
||||
ssdb "simrs-vx/internal/infra/ss-db"
|
||||
simgossync "simrs-vx/internal/infra/sync-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
@@ -129,6 +130,7 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(mh.I.SetClient)
|
||||
a.RegisterExtCall(ibpjs.SetConfig)
|
||||
a.RegisterExtCall(validation.RegisterValidation)
|
||||
a.RegisterExtCall(simgossync.SetConfig)
|
||||
|
||||
r := http.NewServeMux()
|
||||
|
||||
@@ -150,7 +152,6 @@ func SetRoutes() http.Handler {
|
||||
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)
|
||||
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": encounter.O.GetList,
|
||||
"GET /{id}": encounter.O.GetDetail,
|
||||
@@ -209,7 +210,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": medication.O.Delete,
|
||||
"PATCH /{id}/complete": medication.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/medication-item", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": medicationitem.O.GetList,
|
||||
"GET /{id}": medicationitem.O.GetDetail,
|
||||
@@ -218,7 +218,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": medicationitem.O.Delete,
|
||||
"PATCH /{id}/redeem": medicationitem.O.Redeem,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/medication-item-dist", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": medicationitemdist.O.GetList,
|
||||
"GET /{id}": medicationitemdist.O.GetDetail,
|
||||
@@ -227,7 +226,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": medicationitemdist.O.Delete,
|
||||
"PATCH /{id}/consume": medicationitemdist.O.Consume,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/device-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": deviceorder.O.GetList,
|
||||
"GET /{id}": deviceorder.O.GetDetail,
|
||||
@@ -236,7 +234,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": deviceorder.O.Delete,
|
||||
"PATCH /{id}/complete": deviceorder.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/material-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": materialorder.O.GetList,
|
||||
"GET /{id}": materialorder.O.GetDetail,
|
||||
@@ -245,7 +242,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": materialorder.O.Delete,
|
||||
"PATCH /{id}/complete": materialorder.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/consultation", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": consultation.O.GetList,
|
||||
"GET /{id}": consultation.O.GetDetail,
|
||||
@@ -254,7 +250,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": consultation.O.Delete,
|
||||
"PATCH /{id}/reply": consultation.O.Reply,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/chemo", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": chemo.O.GetList,
|
||||
"GET /{id}": chemo.O.GetDetail,
|
||||
@@ -264,15 +259,23 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/verify": chemo.O.Verify,
|
||||
"PATCH /{id}/reject": chemo.O.Reject,
|
||||
})
|
||||
|
||||
hc.RegCrud(r, "/v1/control-letter", controlletter.O)
|
||||
hc.RegCrud(r, "/v1/internal-reference", internalreference.O)
|
||||
hc.RegCrud(r, "/v1/ambulance-transport-req", ambulancetransportrequest.O)
|
||||
hc.RegCrud(r, "/v1/responsible-doctor-hist", responsibledoctorhist.O)
|
||||
hc.RegCrud(r, "/v1/adm-employee-hist", admemployeehist.O)
|
||||
hc.RegCrud(r, "/v1/therapy-protocol", therapyprotocol.O)
|
||||
hk.GroupRoutes("/v1/therapy-protocol", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": therapyprotocol.O.GetList,
|
||||
"GET /{id}": therapyprotocol.O.GetDetail,
|
||||
"POST /": therapyprotocol.O.Create,
|
||||
"PATCH /{id}": therapyprotocol.O.Update,
|
||||
"DELETE /{id}": therapyprotocol.O.Delete,
|
||||
"PATCH /{id}/verify": therapyprotocol.O.Verify,
|
||||
"PATCH /{id}/reject": therapyprotocol.O.Reject,
|
||||
})
|
||||
hc.RegCrud(r, "/v1/chemo-protocol", chemoprotocol.O)
|
||||
hc.RegCrud(r, "/v1/upload", upload.O)
|
||||
hc.RegCrud(r, "/v1/encounter-document", encounterdocument.O)
|
||||
|
||||
/******************** actor ********************/
|
||||
hc.RegCrud(r, "/v1/person", person.O)
|
||||
@@ -294,7 +297,6 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/active": user.O.Active,
|
||||
})
|
||||
hc.RegCrud(r, "/v1/user-fes", userfes.O)
|
||||
|
||||
hk.GroupRoutes("/v1/patient", r, hk.MapHandlerFunc{
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
|
||||
@@ -46,6 +46,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Id = uint(id)
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
|
||||
@@ -9,7 +9,12 @@ import (
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/therapy-protocol"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
u "simrs-vx/internal/use-case/main-use-case/therapy-protocol"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -71,3 +76,44 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Verify(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.VerifyDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Status_Code = erc.DVCVerified
|
||||
res, err := u.Verify(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Reject(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.VerifyDto{}
|
||||
dto.Id = uint(id)
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Status_Code = erc.DVCRejected
|
||||
res, err := u.Verify(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -4,13 +4,12 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/upload"
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/upload"
|
||||
u "simrs-vx/internal/use-case/main-use-case/upload"
|
||||
)
|
||||
|
||||
@@ -86,4 +85,5 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package mainsynchandler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
/******************** infra ********************/
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
synccfg "simrs-vx/internal/infra/sync-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
lh "simrs-vx/pkg/lang-helper"
|
||||
handlerlogger "simrs-vx/pkg/middleware/handler-logger"
|
||||
zlc "simrs-vx/pkg/zerolog-ctx"
|
||||
|
||||
/******************** external ********************/
|
||||
a "github.com/karincake/apem"
|
||||
|
||||
/******************** internal ********************/
|
||||
"simrs-vx/internal/interface/main-handler/home"
|
||||
)
|
||||
|
||||
func SetRoutes() http.Handler {
|
||||
///
|
||||
a.RegisterExtCall(gs.Adjust)
|
||||
a.RegisterExtCall(zlc.Adjust)
|
||||
a.RegisterExtCall(lh.Populate)
|
||||
a.RegisterExtCall(synccfg.SetConfig)
|
||||
|
||||
r := http.NewServeMux()
|
||||
|
||||
/******************** Main ********************/
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package installation
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/installation"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/installation"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -5,8 +5,7 @@ import (
|
||||
|
||||
/******************** infra ********************/
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
synccfg "simrs-vx/internal/infra/sync-cfg"
|
||||
|
||||
simgosdb "simrs-vx/internal/infra/simgos-db"
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
lh "simrs-vx/pkg/lang-helper"
|
||||
@@ -15,9 +14,11 @@ import (
|
||||
|
||||
/******************** external ********************/
|
||||
a "github.com/karincake/apem"
|
||||
hk "github.com/karincake/hongkue"
|
||||
|
||||
/******************** internal ********************/
|
||||
"simrs-vx/internal/interface/main-handler/home"
|
||||
installation "simrs-vx/internal/interface/simgos-sync-handler/installation"
|
||||
)
|
||||
|
||||
func SetRoutes() http.Handler {
|
||||
@@ -25,12 +26,21 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(gs.Adjust)
|
||||
a.RegisterExtCall(zlc.Adjust)
|
||||
a.RegisterExtCall(lh.Populate)
|
||||
a.RegisterExtCall(synccfg.SetConfig)
|
||||
a.RegisterExtCall(simgosdb.SetInstance)
|
||||
|
||||
r := http.NewServeMux()
|
||||
|
||||
/******************** Main ********************/
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
/******************** Source ******************/
|
||||
prefix := "/new-to-old"
|
||||
hk.GroupRoutes(prefix+"/v1/installation", r, hk.MapHandlerFunc{
|
||||
"POST /": installation.O.Create,
|
||||
"POST /log": installation.O.CreateLog,
|
||||
"PATCH /{id}": installation.O.Update,
|
||||
"DELETE /{id}": installation.O.Delete,
|
||||
})
|
||||
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user