penambahan All case Satu sehat
This commit is contained in:
@@ -1,50 +1,91 @@
|
||||
package condition
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
)
|
||||
|
||||
func MapRequestToFHIR(req ConditionRequest) satusehat.FHIRPayload {
|
||||
payload := satusehat.NewFHIRPayload("Condition").
|
||||
Set("clinicalStatus", map[string]interface{}{
|
||||
payload := satusehat.NewFHIRPayload("Condition")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
|
||||
if orgID != "" && req.ConditionID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
{"system": "http://sys-ids.kemkes.go.id/condition/" + orgID, "use": "official", "value": req.ConditionID},
|
||||
})
|
||||
}
|
||||
|
||||
if req.ClinicalStatus != "" {
|
||||
payload.Set("clinicalStatus", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{
|
||||
{
|
||||
"system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
|
||||
"code": req.ClinicalStatus,
|
||||
},
|
||||
{"system": "http://terminology.hl7.org/CodeSystem/condition-clinical", "code": req.ClinicalStatus},
|
||||
},
|
||||
}).
|
||||
Set("category", []map[string]interface{}{
|
||||
})
|
||||
}
|
||||
if req.Category != nil {
|
||||
sys := req.Category.System
|
||||
if sys == "" {
|
||||
sys = "http://terminology.hl7.org/CodeSystem/condition-category"
|
||||
}
|
||||
coding := map[string]interface{}{
|
||||
"system": sys,
|
||||
"code": req.Category.Code,
|
||||
}
|
||||
if req.Category.Display != "" {
|
||||
coding["display"] = req.Category.Display
|
||||
}
|
||||
payload.Set("category", []map[string]interface{}{
|
||||
{
|
||||
"coding": []map[string]interface{}{
|
||||
{
|
||||
"system": "http://terminology.hl7.org/CodeSystem/condition-category",
|
||||
"code": req.CategoryCode,
|
||||
"display": req.CategoryDisplay,
|
||||
},
|
||||
coding,
|
||||
},
|
||||
},
|
||||
}).
|
||||
Set("code", map[string]interface{}{
|
||||
})
|
||||
}
|
||||
if req.Code != nil {
|
||||
sys := req.Code.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct" // Default value jika tidak diset
|
||||
}
|
||||
coding := map[string]interface{}{
|
||||
"system": sys,
|
||||
"code": req.Code.Code,
|
||||
}
|
||||
if req.Code.Display != "" {
|
||||
coding["display"] = req.Code.Display
|
||||
}
|
||||
codeConcept := map[string]interface{}{
|
||||
"coding": []map[string]interface{}{
|
||||
{
|
||||
"system": "http://snomed.info/sct",
|
||||
"code": req.Code,
|
||||
"display": req.Display,
|
||||
},
|
||||
coding,
|
||||
},
|
||||
}).
|
||||
Set("subject", map[string]interface{}{
|
||||
"reference": "Patient/" + req.PatientID,
|
||||
"display": req.PatientName,
|
||||
}).
|
||||
Set("encounter", map[string]interface{}{
|
||||
"reference": "Encounter/" + req.EncounterID,
|
||||
}).
|
||||
Set("onsetDateTime", req.OnsetDateTime.Format(time.RFC3339)).
|
||||
Set("recordedDate", req.RecordedDate.Format(time.RFC3339))
|
||||
}
|
||||
if req.Code.Text != "" {
|
||||
codeConcept["text"] = req.Code.Text
|
||||
}
|
||||
payload.Set("code", codeConcept)
|
||||
}
|
||||
if req.PatientID != "" {
|
||||
subject := map[string]interface{}{"reference": "Patient/" + req.PatientID}
|
||||
if req.PatientName != "" {
|
||||
subject["display"] = req.PatientName
|
||||
}
|
||||
payload.Set("subject", subject)
|
||||
}
|
||||
if req.EncounterID != "" {
|
||||
payload.Set("encounter", map[string]interface{}{"reference": "Encounter/" + req.EncounterID})
|
||||
}
|
||||
if req.OnsetDateTime != nil && !req.OnsetDateTime.IsZero() {
|
||||
payload.Set("onsetDateTime", req.OnsetDateTime.Format(time.RFC3339))
|
||||
}
|
||||
if req.RecordedDate != nil && !req.RecordedDate.IsZero() {
|
||||
payload.Set("recordedDate", req.RecordedDate.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
Reference in New Issue
Block a user