penambahan All case Satu sehat
This commit is contained in:
No files matched your search
@@ -1,42 +1,115 @@
|
||||
package allergyintolerance
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
)
|
||||
|
||||
var verificationStatusDisplayMap = map[string]string{
|
||||
"unconfirmed": "Unconfirmed",
|
||||
"presumed": "Presumed",
|
||||
"confirmed": "Confirmed",
|
||||
"refuted": "Refuted",
|
||||
"entered-in-error": "Entered in Error",
|
||||
}
|
||||
|
||||
func MapRequestToFHIR(req AllergyIntoleranceRequest) satusehat.FHIRPayload {
|
||||
return satusehat.NewFHIRPayload("AllergyIntolerance").
|
||||
Set("clinicalStatus", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{
|
||||
{
|
||||
"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
|
||||
"code": req.ClinicalStatus,
|
||||
},
|
||||
payload := satusehat.NewFHIRPayload("AllergyIntolerance")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
|
||||
if orgID != "" && req.AllergyID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
{
|
||||
"system": "http://sys-ids.kemkes.go.id/allergy/" + orgID,
|
||||
"use": "official",
|
||||
"value": req.AllergyID,
|
||||
},
|
||||
}).
|
||||
Set("verificationStatus", map[string]interface{}{
|
||||
})
|
||||
}
|
||||
|
||||
if req.ClinicalStatus != "" {
|
||||
payload.Set("clinicalStatus", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{
|
||||
{
|
||||
"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification",
|
||||
"code": req.VerificationStatus,
|
||||
"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
|
||||
"code": req.ClinicalStatus,
|
||||
"display": strings.ToUpper(req.ClinicalStatus[:1]) + req.ClinicalStatus[1:],
|
||||
},
|
||||
},
|
||||
}).
|
||||
Set("category", []string{req.Category}).
|
||||
Set("code", map[string]interface{}{
|
||||
})
|
||||
}
|
||||
|
||||
if req.VerificationStatus != "" {
|
||||
display, ok := verificationStatusDisplayMap[req.VerificationStatus]
|
||||
if !ok {
|
||||
display = strings.ToUpper(req.VerificationStatus[:1]) + req.VerificationStatus[1:]
|
||||
}
|
||||
payload.Set("verificationStatus", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{
|
||||
{
|
||||
"system": "http://snomed.info/sct",
|
||||
"code": req.Code,
|
||||
"display": req.Display,
|
||||
},
|
||||
{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "code": req.VerificationStatus, "display": display},
|
||||
},
|
||||
}).
|
||||
Set("patient", map[string]interface{}{
|
||||
"reference": "Patient/" + req.PatientID,
|
||||
"display": req.PatientName,
|
||||
}).
|
||||
Set("recordedDate", req.RecordedDate.Format(time.RFC3339))
|
||||
})
|
||||
}
|
||||
|
||||
if len(req.Category) > 0 {
|
||||
payload.Set("category", req.Category)
|
||||
}
|
||||
|
||||
if req.Code != nil {
|
||||
sys := req.Code.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct" // Default to SNOMED
|
||||
}
|
||||
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{}{coding},
|
||||
}
|
||||
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("patient", subject)
|
||||
}
|
||||
|
||||
if req.EncounterID != "" {
|
||||
encounter := map[string]interface{}{"reference": "Encounter/" + req.EncounterID}
|
||||
if req.EncounterDisplay != "" {
|
||||
encounter["display"] = req.EncounterDisplay
|
||||
}
|
||||
payload.Set("encounter", encounter)
|
||||
}
|
||||
|
||||
if req.RecordedDate != nil && !req.RecordedDate.IsZero() {
|
||||
payload.Set("recordedDate", req.RecordedDate.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
if req.RecorderID != "" {
|
||||
recorder := map[string]interface{}{"reference": "Practitioner/" + req.RecorderID}
|
||||
if req.RecorderDisplay != "" {
|
||||
recorder["display"] = req.RecorderDisplay
|
||||
}
|
||||
payload.Set("recorder", recorder)
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
Reference in New Issue
Block a user