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.StatusBadRequest, d.IS{"message": "date is required"}, nil)
	}
	pValue2 := rw.ValidateString(w, "serviceType", r.PathValue("serviceType"))
	if pValue2 == "" {
		rw.WriteJSON(w, http.StatusBadRequest, 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.StatusBadRequest, d.IS{"message": "cardNumber is required"}, nil)
	}
	pValue2 := rw.ValidateString(w, "startDate", r.PathValue("startDate"))
	if pValue2 == "" {
		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.StatusBadRequest, 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)
}
