feat (vclaim/bpjs/jkn): add several endpoint
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package controlplan
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/control-plan"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/control-plan"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
func GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
pValue1 := rw.ValidateString(w, "controlType", r.PathValue("controlType"))
|
||||
if pValue1 == "" {
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "controlType is required"}, nil)
|
||||
}
|
||||
pValue2 := rw.ValidateString(w, "polyCode", r.PathValue("polyCode"))
|
||||
if pValue2 == "" {
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "polyCode is required"}, nil)
|
||||
}
|
||||
pValue3 := rw.ValidateString(w, "date", r.PathValue("date"))
|
||||
if pValue3 == "" {
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "date is required"}, nil)
|
||||
}
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
dto.PathValue3 = pValue3
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -125,9 +125,11 @@ import (
|
||||
"simrs-vx/internal/interface/main-handler/home"
|
||||
|
||||
/******************** BPJS ********************/
|
||||
controlplan "simrs-vx/internal/interface/main-handler/control-plan"
|
||||
member "simrs-vx/internal/interface/main-handler/member"
|
||||
monitoring "simrs-vx/internal/interface/main-handler/monitoring"
|
||||
reference "simrs-vx/internal/interface/main-handler/reference"
|
||||
referral "simrs-vx/internal/interface/main-handler/referral"
|
||||
vclaimsep "simrs-vx/internal/interface/main-handler/vclaim-sep"
|
||||
vclaimsephist "simrs-vx/internal/interface/main-handler/vclaim-sep-hist"
|
||||
vclaimsepprint "simrs-vx/internal/interface/main-handler/vclaim-sep-print"
|
||||
@@ -382,9 +384,9 @@ func SetRoutes() http.Handler {
|
||||
|
||||
/******************** BPJS ********************/
|
||||
hk.GroupRoutes("/v1/vclaim-sep", r, hk.MapHandlerFunc{
|
||||
"POST /": vclaimsep.O.Create,
|
||||
"GET /{id}": vclaimsep.O.GetDetail,
|
||||
"DELETE /{id}": vclaimsep.O.Delete,
|
||||
"POST /": vclaimsep.O.Create,
|
||||
"GET /{number}": vclaimsep.O.GetDetail,
|
||||
"DELETE /{number}": vclaimsep.O.Delete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/vclaim-sep-hist", r, hk.MapHandlerFunc{
|
||||
@@ -417,6 +419,14 @@ func SetRoutes() http.Handler {
|
||||
"GET /hist/{cardNumber}/{startDate}/{endDate}": monitoring.GetListHist,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/control-plan", r, hk.MapHandlerFunc{
|
||||
"GET /{controlType}/{polyCode}/{date}": controlplan.GetList,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/referral", r, hk.MapHandlerFunc{
|
||||
"GET /{number}": referral.GetList,
|
||||
})
|
||||
|
||||
/////
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "sepDate is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTBpjs
|
||||
dto.PathValue1 = pValue1
|
||||
@@ -31,11 +31,11 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "sepDate is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTNik
|
||||
dto.PathValue1 = pValue1
|
||||
|
||||
@@ -14,11 +14,11 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "serviceType is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTVisit
|
||||
dto.PathValue1 = pValue1
|
||||
@@ -31,15 +31,15 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "endDate is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTHist
|
||||
dto.PathValue1 = pValue1
|
||||
|
||||
@@ -21,7 +21,7 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "provinceCode is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTCities
|
||||
dto.PathValue1 = pValue
|
||||
@@ -33,7 +33,7 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "regencyCode is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTDistrict
|
||||
dto.PathValue1 = pValue
|
||||
@@ -45,7 +45,7 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "keyword is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTDiagnose
|
||||
dto.PathValue1 = pValue
|
||||
@@ -64,7 +64,7 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "keyword is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTMedicinePrb
|
||||
dto.PathValue1 = pValue
|
||||
@@ -76,7 +76,7 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "unitCode is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTUnit
|
||||
dto.PathValue1 = pValue
|
||||
@@ -88,11 +88,11 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "healthcareType is required"}, nil)
|
||||
}
|
||||
dto.ReferenceType = e.RTHealthcare
|
||||
dto.PathValue1 = pValue1
|
||||
@@ -105,15 +105,15 @@ 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, 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)
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "specialistCode is required"}, nil)
|
||||
}
|
||||
dto.PathValue1 = pValue1
|
||||
dto.PathValue2 = pValue2
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package referral
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
e "simrs-vx/internal/domain/bpjs-entities/referral"
|
||||
u "simrs-vx/internal/use-case/bpjs-use-case/referral"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
func GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadDetailDto{}
|
||||
number := rw.ValidateString(w, "number", r.PathValue("number"))
|
||||
if number == "" {
|
||||
rw.WriteJSON(w, http.StatusBadRequest, d.IS{"message": "number is required"}, nil)
|
||||
}
|
||||
dto.Number = &number
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -30,12 +30,12 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
number := rw.ValidateString(w, "number", r.PathValue("number"))
|
||||
if number <= "" {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint(id)
|
||||
dto.Number = &number
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user