monitoring done

This commit is contained in:
dpurbosakti
2025-10-16 11:26:09 +07:00
parent c009a34f5e
commit 2fb47d0d48
11 changed files with 292 additions and 0 deletions

No files matched your search

@@ -0,0 +1,18 @@
package monitoring
import (
"fmt"
e "simrs-vx/internal/domain/bpjs-entities/monitoring"
ibpjs "simrs-vx/internal/infra/bpjs"
)
func endpointMapper(input *e.ReadListDto) string {
switch input.ReferenceType {
case e.RTHist:
return fmt.Sprintf("%smonitoring/history/%s?tglawal=%s&tglakhir=%s", ibpjs.O.BaseUrl, input.PathValue1, input.PathValue2, input.PathValue3)
case e.RTVisit:
return fmt.Sprintf("%smonitoring/kunjungan?tglpelayanan=%s&jnspelayanan=%s", ibpjs.O.BaseUrl, input.PathValue1, input.PathValue2)
default:
return ""
}
}
@@ -0,0 +1,37 @@
package monitoring
import (
"encoding/json"
"fmt"
"io"
"net/http"
e "simrs-vx/internal/domain/bpjs-entities/monitoring"
"gorm.io/gorm"
)
func ReadList(input *e.ReadListDto, data *e.Response, tx *gorm.DB) error {
endpoint := endpointMapper(input)
req, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if err := json.Unmarshal(body, &data); err != nil {
return fmt.Errorf("failed to parse response JSON: %w", err)
}
return nil
}