update All feture and service
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package procedure
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
@@ -10,15 +9,10 @@ import (
|
||||
func MapRequestToFHIR(req ProcedureRequest) satusehat.FHIRPayload {
|
||||
payload := satusehat.NewFHIRPayload("Procedure")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
|
||||
if orgID != "" && req.ProcedureID != "" {
|
||||
if req.OrganizationID != "" && req.ProcedureID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
{
|
||||
"system": "http://sys-ids.kemkes.go.id/procedure/" + orgID,
|
||||
"system": "http://sys-ids.kemkes.go.id/procedure/" + req.OrganizationID,
|
||||
"value": req.ProcedureID,
|
||||
},
|
||||
})
|
||||
@@ -28,50 +22,46 @@ func MapRequestToFHIR(req ProcedureRequest) satusehat.FHIRPayload {
|
||||
payload.Set("status", req.Status)
|
||||
}
|
||||
|
||||
if len(req.Category) > 0 && req.Category[0] != nil {
|
||||
sys := req.Category[0].System
|
||||
if req.CategoryCode != "" {
|
||||
sys := req.CategorySystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Category[0].Code}
|
||||
if req.Category[0].Display != "" {
|
||||
coding["display"] = req.Category[0].Display
|
||||
coding := map[string]interface{}{"system": sys, "code": req.CategoryCode}
|
||||
if req.CategoryDisplay != "" {
|
||||
coding["display"] = req.CategoryDisplay
|
||||
}
|
||||
catObj := map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
if req.Category[0].Text != "" {
|
||||
catObj["text"] = req.Category[0].Text
|
||||
}
|
||||
payload.Set("category", catObj)
|
||||
payload.Set("category", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{coding},
|
||||
})
|
||||
}
|
||||
|
||||
if req.Code != nil {
|
||||
sys := req.Code.System
|
||||
if req.Code != "" {
|
||||
sys := req.CodeSystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
sys = "http://hl7.org/fhir/sid/icd-9-cm"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Code.Code}
|
||||
if req.Code.Display != "" {
|
||||
coding["display"] = req.Code.Display
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Code}
|
||||
if req.CodeDisplay != "" {
|
||||
coding["display"] = req.CodeDisplay
|
||||
}
|
||||
codeObj := map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
if req.Code.Text != "" {
|
||||
codeObj["text"] = req.Code.Text
|
||||
}
|
||||
payload.Set("code", codeObj)
|
||||
payload.Set("code", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{coding},
|
||||
})
|
||||
}
|
||||
|
||||
if req.Subject != nil {
|
||||
subj := map[string]interface{}{"reference": req.Subject.Reference}
|
||||
if req.Subject.Display != "" {
|
||||
subj["display"] = req.Subject.Display
|
||||
if req.PatientID != "" {
|
||||
subj := map[string]interface{}{"reference": "Patient/" + req.PatientID}
|
||||
if req.PatientName != "" {
|
||||
subj["display"] = req.PatientName
|
||||
}
|
||||
payload.Set("subject", subj)
|
||||
}
|
||||
|
||||
if req.Encounter != nil {
|
||||
enc := map[string]interface{}{"reference": req.Encounter.Reference}
|
||||
if req.Encounter.Display != "" {
|
||||
enc["display"] = req.Encounter.Display
|
||||
if req.EncounterID != "" {
|
||||
enc := map[string]interface{}{"reference": "Encounter/" + req.EncounterID}
|
||||
if req.EncounterDisplay != "" {
|
||||
enc["display"] = req.EncounterDisplay
|
||||
}
|
||||
payload.Set("encounter", enc)
|
||||
}
|
||||
@@ -86,60 +76,44 @@ func MapRequestToFHIR(req ProcedureRequest) satusehat.FHIRPayload {
|
||||
payload.Set("performedDateTime", req.PerformedDateTime.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
if len(req.Performer) > 0 {
|
||||
var performers []map[string]interface{}
|
||||
for _, p := range req.Performer {
|
||||
actor := map[string]interface{}{"reference": p.Reference}
|
||||
if p.Display != "" {
|
||||
actor["display"] = p.Display
|
||||
}
|
||||
performers = append(performers, map[string]interface{}{"actor": actor})
|
||||
if req.PerformerID != "" {
|
||||
actor := map[string]interface{}{"reference": "Practitioner/" + req.PerformerID}
|
||||
if req.PerformerName != "" {
|
||||
actor["display"] = req.PerformerName
|
||||
}
|
||||
payload.Set("performer", performers)
|
||||
payload.Set("performer", []map[string]interface{}{{"actor": actor}})
|
||||
}
|
||||
|
||||
if len(req.ReasonCode) > 0 {
|
||||
var reasons []map[string]interface{}
|
||||
for _, r := range req.ReasonCode {
|
||||
if r != nil {
|
||||
sys := r.System
|
||||
if sys == "" {
|
||||
sys = "http://hl7.org/fhir/sid/icd-10"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": r.Code}
|
||||
if r.Display != "" {
|
||||
coding["display"] = r.Display
|
||||
}
|
||||
reasons = append(reasons, map[string]interface{}{"coding": []map[string]interface{}{coding}})
|
||||
}
|
||||
if req.ReasonCode != "" {
|
||||
sys := req.ReasonSystem
|
||||
if sys == "" {
|
||||
sys = "http://hl7.org/fhir/sid/icd-10"
|
||||
}
|
||||
payload.Set("reasonCode", reasons)
|
||||
coding := map[string]interface{}{"system": sys, "code": req.ReasonCode}
|
||||
if req.ReasonDisplay != "" {
|
||||
coding["display"] = req.ReasonDisplay
|
||||
}
|
||||
payload.Set("reasonCode", []map[string]interface{}{
|
||||
{"coding": []map[string]interface{}{coding}},
|
||||
})
|
||||
}
|
||||
|
||||
if len(req.BodySite) > 0 {
|
||||
var bodySites []map[string]interface{}
|
||||
for _, b := range req.BodySite {
|
||||
if b != nil {
|
||||
sys := b.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": b.Code}
|
||||
if b.Display != "" {
|
||||
coding["display"] = b.Display
|
||||
}
|
||||
bodySites = append(bodySites, map[string]interface{}{"coding": []map[string]interface{}{coding}})
|
||||
}
|
||||
if req.BodySiteCode != "" {
|
||||
sys := req.BodySiteSystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
payload.Set("bodySite", bodySites)
|
||||
coding := map[string]interface{}{"system": sys, "code": req.BodySiteCode}
|
||||
if req.BodySiteDisplay != "" {
|
||||
coding["display"] = req.BodySiteDisplay
|
||||
}
|
||||
payload.Set("bodySite", []map[string]interface{}{
|
||||
{"coding": []map[string]interface{}{coding}},
|
||||
})
|
||||
}
|
||||
|
||||
if len(req.Note) > 0 {
|
||||
var notes []map[string]interface{}
|
||||
for _, text := range req.Note {
|
||||
notes = append(notes, map[string]interface{}{"text": text})
|
||||
}
|
||||
payload.Set("note", notes)
|
||||
if req.Note != "" {
|
||||
payload.Set("note", []map[string]interface{}{{"text": req.Note}})
|
||||
}
|
||||
|
||||
return payload
|
||||
|
||||
Reference in New Issue
Block a user