i
merge branch 'migration into feat/vehicle-src-75 .
This commit is contained in:
@@ -4,22 +4,27 @@ import (
|
||||
"net/http"
|
||||
|
||||
/******************** main / transaction ********************/
|
||||
member "simrs-vx/internal/interface/bpjs-handler/member"
|
||||
monitoring "simrs-vx/internal/interface/bpjs-handler/monitoring"
|
||||
reference "simrs-vx/internal/interface/bpjs-handler/reference"
|
||||
vclaimsep "simrs-vx/internal/interface/bpjs-handler/vclaim-sep"
|
||||
vclaimsephist "simrs-vx/internal/interface/bpjs-handler/vclaim-sep-hist"
|
||||
vclaimsepprint "simrs-vx/internal/interface/bpjs-handler/vclaim-sep-print"
|
||||
|
||||
/******************** actor ********************/
|
||||
|
||||
/******************** external ********************/
|
||||
a "github.com/karincake/apem"
|
||||
hk "github.com/karincake/hongkue"
|
||||
|
||||
/******************** infra ********************/
|
||||
ibpjs "simrs-vx/internal/infra/bpjs"
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
minio "simrs-vx/internal/infra/minio"
|
||||
ssdb "simrs-vx/internal/infra/ss-db"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
lh "simrs-vx/pkg/lang-helper"
|
||||
handlerlogger "simrs-vx/pkg/middleware/handler-logger"
|
||||
mh "simrs-vx/pkg/minio-helper"
|
||||
zlc "simrs-vx/pkg/zerolog-ctx"
|
||||
|
||||
/******************** sources ********************/
|
||||
@@ -33,10 +38,8 @@ func SetRoutes() http.Handler {
|
||||
/////
|
||||
a.RegisterExtCall(gs.Adjust)
|
||||
a.RegisterExtCall(zlc.Adjust)
|
||||
a.RegisterExtCall(ssdb.SetInstance)
|
||||
a.RegisterExtCall(lh.Populate)
|
||||
a.RegisterExtCall(minio.Connect)
|
||||
a.RegisterExtCall(mh.I.SetClient)
|
||||
a.RegisterExtCall(ibpjs.SetConfig)
|
||||
a.RegisterExtCall(validation.RegisterValidation)
|
||||
|
||||
r := http.NewServeMux()
|
||||
@@ -44,6 +47,42 @@ func SetRoutes() http.Handler {
|
||||
/******************** Main ********************/
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
hk.GroupRoutes("/v1/vclaim-sep", r, hk.MapHandlerFunc{
|
||||
"POST /": vclaimsep.O.Create,
|
||||
"PATCH /{id}": vclaimsep.O.Update,
|
||||
"DELETE /{id}": vclaimsep.O.Delete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/vclaim-sep-hist", r, hk.MapHandlerFunc{
|
||||
"GET /": vclaimsephist.O.GetList,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/vclaim-sep-print", r, hk.MapHandlerFunc{
|
||||
"POST /": vclaimsepprint.O.Create,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/reference", r, hk.MapHandlerFunc{
|
||||
"GET /province": reference.GetListProvince,
|
||||
"GET /regency/{provinceCode}": reference.GetListCities,
|
||||
"GET /district/{regencyCode}": reference.GetListDistrict,
|
||||
"GET /diagnose/{keyword}": reference.GetListDiagnose,
|
||||
"GET /diagnose-prb": reference.GetListDiagnosePrb,
|
||||
"GET /medicine-prb/{keyword}": reference.GetListMedicinePrb,
|
||||
"GET /unit/{unitCode}": reference.GetListUnit,
|
||||
"GET /healthcare/{healthcare}/{healthcareType}": reference.GetListHealthcare,
|
||||
"GET /responsible-doctor/{serviceType}/{serviceDate}/{specialistCode}": reference.GetListDoctor,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/member", r, hk.MapHandlerFunc{
|
||||
"GET /bpjs/{cardNumber}/{sepDate}": member.GetListByBpjsNumber,
|
||||
"GET /nik/{nik}/{sepDate}": member.GetListByNik,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/monitoring", r, hk.MapHandlerFunc{
|
||||
"GET /visit/{date}/{serviceType}": monitoring.GetListVisit,
|
||||
"GET /hist/{cardNumber}/{startDate}/{endDate}": monitoring.GetListHist,
|
||||
})
|
||||
|
||||
/******************** actor ********************/
|
||||
|
||||
/******************** sources ********************/
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package member
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/member"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/member"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
func GetListByBpjsNumber(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "cardNumber", r.PathValue("cardNumber"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "cardNumber is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "sepDate", r.PathValue("sepDate"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "sepDate is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTBpjs
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListByNik(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "nik", r.PathValue("nik"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "nik is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "sepDate", r.PathValue("sepDate"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "sepDate is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTNik
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package monitoring
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/monitoring"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/monitoring"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
func GetListVisit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "date", r.PathValue("date"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "date is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "serviceType", r.PathValue("serviceType"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "serviceType is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTVisit
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListHist(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "cardNumber", r.PathValue("cardNumber"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "cardNumber is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "startDate", r.PathValue("startDate"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "startDate is required"}, nil)
|
||||
}
|
||||
pValue3 := rw.ValidateString(w, "endDate", r.PathValue("endDate"))
|
||||
if pValue3 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "endDate is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTHist
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
dto.PathValue3 = pValue3
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package reference
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/reference"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/reference"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
func GetListProvince(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
dto.ReferenceType = e.RTProvince
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListCities(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue := rw.ValidateString(w, "provinceCode", r.PathValue("provinceCode"))
|
||||
if pValue == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "provinceCode is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTCities
|
||||
dto.PathValue1 = pValue
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListDistrict(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue := rw.ValidateString(w, "regencyCode", r.PathValue("regencyCode"))
|
||||
if pValue == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "regencyCode is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTDistrict
|
||||
dto.PathValue1 = pValue
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListDiagnose(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue := rw.ValidateString(w, "keyword", r.PathValue("keyword"))
|
||||
if pValue == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "keyword is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTDiagnose
|
||||
dto.PathValue1 = pValue
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListDiagnosePrb(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
dto.ReferenceType = e.RTDiagnosePrb
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListMedicinePrb(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue := rw.ValidateString(w, "keyword", r.PathValue("keyword"))
|
||||
if pValue == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "keyword is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTMedicinePrb
|
||||
dto.PathValue1 = pValue
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListUnit(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue := rw.ValidateString(w, "unitCode", r.PathValue("unitCode"))
|
||||
if pValue == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "unitCode is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTUnit
|
||||
dto.PathValue1 = pValue
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListHealthcare(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "healthcare", r.PathValue("healthcare"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "healthcare is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "healthcareType", r.PathValue("healthcareType"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "healthcareType is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTHealthcare
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func GetListDoctor(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "serviceType", r.PathValue("serviceType"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "serviceType is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "serviceDate", r.PathValue("serviceDate"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "serviceDate is required"}, nil)
|
||||
}
|
||||
pValue3 := rw.ValidateString(w, "specialistCode", r.PathValue("specialistCode"))
|
||||
if pValue3 == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "specialistCode is required"}, nil)
|
||||
}
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
dto.PathValue3 = pValue3
|
||||
dto.ReferenceType = e.RTDoctor
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package vclaimsephist
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/vclaim-sep-hist"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/vclaim-sep-hist"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vclaimsepprint
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/vclaim-sep-print"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/vclaim-sep-print"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package vclaimsep
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/vclaim-sep"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/vclaim-sep"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, "failed to read body", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
dto.RequestPayload = body
|
||||
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) {
|
||||
// id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
// if id <= 0 {
|
||||
// return
|
||||
// }
|
||||
// dto := e.ReadDetailDto{}
|
||||
// dto.Id = uint(id)
|
||||
// res, err := u.ReadDetail(dto)
|
||||
// rw.DataResponse(w, res, err)
|
||||
// }
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
number := rw.ValidateString(w, "number", r.PathValue("number"))
|
||||
if number != "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Number = &number
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
number := rw.ValidateString(w, "number", r.PathValue("number"))
|
||||
if number != "" {
|
||||
return
|
||||
}
|
||||
dto := e.DeleteDto{}
|
||||
dto.Number = &number
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -12,6 +12,10 @@ import (
|
||||
u "simrs-vx/internal/use-case/main-use-case/encounter"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
pa "simrs-vx/pkg/auth-helper"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -19,10 +23,15 @@ type myBase struct{}
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(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.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -40,6 +49,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
person "simrs-vx/internal/interface/main-handler/person"
|
||||
personaddress "simrs-vx/internal/interface/main-handler/person-address"
|
||||
personcontact "simrs-vx/internal/interface/main-handler/person-contact"
|
||||
personinsurance "simrs-vx/internal/interface/main-handler/person-insurance"
|
||||
pharmacist "simrs-vx/internal/interface/main-handler/pharmacist"
|
||||
user "simrs-vx/internal/interface/main-handler/user"
|
||||
|
||||
@@ -116,7 +117,6 @@ func SetRoutes() http.Handler {
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
r.HandleFunc("POST /v1/authentication/login", auth.Login)
|
||||
// r.HandleFunc("POST /v1/authentication/logout", auth.Logout)
|
||||
hk.Route("POST /v1/authentication/logout", r, auth.GuardMW, auth.Logout)
|
||||
hc.RegCrud(r, "/v1/practice-schedule", practiceschedule.O)
|
||||
hc.RegCrud(r, "/v1/counter", counter.O)
|
||||
@@ -162,7 +162,7 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": mcuordersubitem.O.Delete,
|
||||
"PATCH /{id}/complete": mcuordersubitem.O.Complete,
|
||||
})
|
||||
hk.GroupRoutes("/v1/encounter", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": encounter.O.GetList,
|
||||
"GET /{id}": encounter.O.GetDetail,
|
||||
"POST /": encounter.O.Create,
|
||||
@@ -244,6 +244,7 @@ func SetRoutes() http.Handler {
|
||||
hc.RegCrud(r, "/v1/person", person.O)
|
||||
hc.RegCrud(r, "/v1/person-address", personaddress.O)
|
||||
hc.RegCrud(r, "/v1/person-contact", personcontact.O)
|
||||
hc.RegCrud(r, "/v1/person-insurance", personinsurance.O)
|
||||
hc.RegCrud(r, "/v1/employee", employee.O)
|
||||
hc.RegCrud(r, "/v1/doctor", doctor.O)
|
||||
hc.RegCrud(r, "/v1/nurse", nurse.O)
|
||||
@@ -259,13 +260,14 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/active": user.O.Active,
|
||||
})
|
||||
hk.GroupRoutes("/v1/patient", r, hk.MapHandlerFunc{
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
"POST /": patient.O.Create,
|
||||
"PATCH /{id}": patient.O.Update,
|
||||
"DELETE /{id}": patient.O.Delete,
|
||||
"GET /by-identifier": patient.O.Search,
|
||||
"POST /{id}/upload": patient.O.Upload,
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
"POST /": patient.O.Create,
|
||||
"PATCH /{id}": patient.O.Update,
|
||||
"DELETE /{id}": patient.O.Delete,
|
||||
"GET /search/{keyword}": patient.O.Search,
|
||||
"GET /by-resident-identity": patient.O.SearchByResidentIdentity,
|
||||
"POST /{id}/upload": patient.O.Upload,
|
||||
})
|
||||
|
||||
/******************** sources ********************/
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
u "simrs-vx/internal/use-case/main-use-case/patient"
|
||||
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -73,8 +75,21 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) Search(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.SearchDto{}
|
||||
keyword := rw.ValidateString(w, "keyword", r.PathValue("keyword"))
|
||||
if keyword == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "keyword is required"}, nil)
|
||||
}
|
||||
dto.Mode = e.SMIdent
|
||||
dto.Search = keyword
|
||||
res, err := u.Search(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) SearchByResidentIdentity(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.SearchDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Mode = e.SMNik
|
||||
res, err := u.Search(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package personinsurance
|
||||
|
||||
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/person-insurance"
|
||||
u "simrs-vx/internal/use-case/main-use-case/person-insurance"
|
||||
)
|
||||
|
||||
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) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
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)
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
inpatient "simrs-vx/internal/domain/main-entities/inpatient"
|
||||
installation "simrs-vx/internal/domain/main-entities/installation"
|
||||
insurancecompany "simrs-vx/internal/domain/main-entities/insurance-company"
|
||||
intern "simrs-vx/internal/domain/main-entities/intern"
|
||||
internalreference "simrs-vx/internal/domain/main-entities/internal-reference"
|
||||
item "simrs-vx/internal/domain/main-entities/item"
|
||||
itemprice "simrs-vx/internal/domain/main-entities/item-price"
|
||||
@@ -105,6 +106,7 @@ func getMainEntities() []any {
|
||||
&diagnosesrc.DiagnoseSrc{},
|
||||
&proceduresrc.ProcedureSrc{},
|
||||
&employee.Employee{},
|
||||
&intern.Intern{},
|
||||
&doctor.Doctor{},
|
||||
&nurse.Nurse{},
|
||||
&nutritionist.Nutritionist{},
|
||||
|
||||
Reference in New Issue
Block a user