update All feture and service
This commit is contained in:
No files matched your search
@@ -1,22 +1,17 @@
|
||||
package careplan
|
||||
|
||||
import (
|
||||
"os"
|
||||
"service/internal/interfaces/satusehat"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
)
|
||||
|
||||
func MapRequestToFHIR(req CarePlanRequest) satusehat.FHIRPayload {
|
||||
payload := satusehat.NewFHIRPayload("CarePlan")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
|
||||
if orgID != "" && req.CarePlanID != "" {
|
||||
if req.OrganizationID != "" && req.CarePlanID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
{"system": "http://sys-ids.kemkes.go.id/careplan/" + orgID, "use": "official", "value": req.CarePlanID},
|
||||
{"system": "http://sys-ids.kemkes.go.id/careplan/" + req.OrganizationID, "use": "official", "value": req.CarePlanID},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -26,31 +21,28 @@ func MapRequestToFHIR(req CarePlanRequest) satusehat.FHIRPayload {
|
||||
if req.Intent != "" {
|
||||
payload.Set("intent", req.Intent)
|
||||
}
|
||||
if len(req.Category) > 0 {
|
||||
var categories []map[string]interface{}
|
||||
for _, cat := range req.Category {
|
||||
sys := cat.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct" // Default value jika kosong
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": cat.Code}
|
||||
if cat.Display != "" {
|
||||
coding["display"] = cat.Display
|
||||
}
|
||||
concept := map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
if cat.Text != "" {
|
||||
concept["text"] = cat.Text
|
||||
}
|
||||
categories = append(categories, concept)
|
||||
|
||||
if req.CategoryCode != "" {
|
||||
sys := req.CategorySystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
payload.Set("category", categories)
|
||||
coding := map[string]interface{}{"system": sys, "code": req.CategoryCode}
|
||||
if req.CategoryDisplay != "" {
|
||||
coding["display"] = req.CategoryDisplay
|
||||
}
|
||||
payload.Set("category", []map[string]interface{}{
|
||||
{"coding": []map[string]interface{}{coding}},
|
||||
})
|
||||
}
|
||||
|
||||
if req.Title != "" {
|
||||
payload.Set("title", req.Title)
|
||||
}
|
||||
if req.Description != "" {
|
||||
payload.Set("description", req.Description)
|
||||
}
|
||||
|
||||
if req.PatientID != "" {
|
||||
subject := map[string]interface{}{"reference": "Patient/" + req.PatientID}
|
||||
if req.PatientDisplay != "" {
|
||||
@@ -76,7 +68,7 @@ func MapRequestToFHIR(req CarePlanRequest) satusehat.FHIRPayload {
|
||||
payload.Set("created", req.CreatedDate.Format(time.RFC3339))
|
||||
}
|
||||
if len(req.GoalIDs) > 0 {
|
||||
var goals []map[string]interface{}
|
||||
goals := make([]map[string]interface{}, 0, len(req.GoalIDs))
|
||||
for _, id := range req.GoalIDs {
|
||||
goals = append(goals, map[string]interface{}{"reference": "Goal/" + id})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user