test encounter

This commit is contained in:
2025-12-17 12:51:13 +07:00
parent 1d23464aba
commit b43d0f438d

View File

@@ -10,6 +10,7 @@ import (
"satusehat-rssa/internal/constant"
"satusehat-rssa/internal/model"
"satusehat-rssa/pkg/httputil"
"time"
)
type EncounterInterface interface {
@@ -36,9 +37,20 @@ func (e *EncounterRepository) HandleCheckEncounter(patientID string) (string, bo
if entries, ok := (encounter)["entry"].([]interface{}); ok && len(entries) > 0 {
if entryMap, ok := entries[0].(map[string]interface{}); ok {
if resource, ok := entryMap["resource"].(map[string]interface{}); ok {
if id, ok := resource["id"].(string); ok {
//fmt.Println("resource.id:", id)
return id, true, nil
if period, ok := resource["period"].(map[string]interface{}); ok {
if startStr, ok := period["start"].(string); ok {
if startTime, err := time.Parse(time.RFC3339, startStr); err == nil {
now := time.Now()
if startTime.Year() == now.Year() &&
startTime.Month() == now.Month() &&
startTime.Day() == now.Day() {
if id, ok := resource["id"].(string); ok {
return id, true, nil
}
}
}
}
}
}
}