test encounter
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"satusehat-rssa/internal/constant"
|
"satusehat-rssa/internal/constant"
|
||||||
"satusehat-rssa/internal/model"
|
"satusehat-rssa/internal/model"
|
||||||
"satusehat-rssa/pkg/httputil"
|
"satusehat-rssa/pkg/httputil"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EncounterInterface interface {
|
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 entries, ok := (encounter)["entry"].([]interface{}); ok && len(entries) > 0 {
|
||||||
if entryMap, ok := entries[0].(map[string]interface{}); ok {
|
if entryMap, ok := entries[0].(map[string]interface{}); ok {
|
||||||
if resource, ok := entryMap["resource"].(map[string]interface{}); ok {
|
if resource, ok := entryMap["resource"].(map[string]interface{}); ok {
|
||||||
if id, ok := resource["id"].(string); ok {
|
if period, ok := resource["period"].(map[string]interface{}); ok {
|
||||||
//fmt.Println("resource.id:", id)
|
if startStr, ok := period["start"].(string); ok {
|
||||||
return id, true, nil
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user