update All feture and service
This commit is contained in:
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package immunization
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
@@ -10,15 +9,10 @@ import (
|
||||
func MapRequestToFHIR(req ImmunizationRequest) satusehat.FHIRPayload {
|
||||
payload := satusehat.NewFHIRPayload("Immunization")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
|
||||
if orgID != "" && req.ImmunizationID != "" {
|
||||
if req.OrganizationID != "" && req.ImmunizationID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
{
|
||||
"system": "http://sys-ids.kemkes.go.id/immunization/" + orgID,
|
||||
"system": "http://sys-ids.kemkes.go.id/immunization/" + req.OrganizationID,
|
||||
"use": "official",
|
||||
"value": req.ImmunizationID,
|
||||
},
|
||||
@@ -29,20 +23,18 @@ func MapRequestToFHIR(req ImmunizationRequest) satusehat.FHIRPayload {
|
||||
payload.Set("status", req.Status)
|
||||
}
|
||||
|
||||
if req.VaccineCode != nil {
|
||||
sys := req.VaccineCode.System
|
||||
if req.VaccineCode != "" {
|
||||
sys := req.VaccineCodeSystem
|
||||
if sys == "" {
|
||||
sys = "http://sys-ids.kemkes.go.id/kfa"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.VaccineCode.Code}
|
||||
if req.VaccineCode.Display != "" {
|
||||
coding["display"] = req.VaccineCode.Display
|
||||
coding := map[string]interface{}{"system": sys, "code": req.VaccineCode}
|
||||
if req.VaccineCodeDisplay != "" {
|
||||
coding["display"] = req.VaccineCodeDisplay
|
||||
}
|
||||
vaccineConcept := map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
if req.VaccineCode.Text != "" {
|
||||
vaccineConcept["text"] = req.VaccineCode.Text
|
||||
}
|
||||
payload.Set("vaccineCode", vaccineConcept)
|
||||
payload.Set("vaccineCode", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{coding},
|
||||
})
|
||||
}
|
||||
|
||||
if req.PatientID != "" {
|
||||
@@ -69,10 +61,10 @@ func MapRequestToFHIR(req ImmunizationRequest) satusehat.FHIRPayload {
|
||||
payload.Set("primarySource", *req.PrimarySource)
|
||||
}
|
||||
|
||||
if req.Location != nil {
|
||||
loc := map[string]interface{}{"reference": req.Location.Reference}
|
||||
if req.Location.Display != "" {
|
||||
loc["display"] = req.Location.Display
|
||||
if req.LocationID != "" {
|
||||
loc := map[string]interface{}{"reference": "Location/" + req.LocationID}
|
||||
if req.LocationName != "" {
|
||||
loc["display"] = req.LocationName
|
||||
}
|
||||
payload.Set("location", loc)
|
||||
}
|
||||
@@ -81,45 +73,46 @@ func MapRequestToFHIR(req ImmunizationRequest) satusehat.FHIRPayload {
|
||||
payload.Set("lotNumber", req.LotNumber)
|
||||
}
|
||||
|
||||
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 req.DoseQuantity != nil {
|
||||
sys := req.DoseQuantity.System
|
||||
if req.DoseQuantityValue != 0 || req.DoseQuantityUnit != "" {
|
||||
sys := req.DoseQuantitySystem
|
||||
if sys == "" {
|
||||
sys = "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm"
|
||||
sys = "http://unitsofmeasure.org"
|
||||
}
|
||||
payload.Set("doseQuantity", map[string]interface{}{
|
||||
"value": req.DoseQuantity.Value,
|
||||
"unit": req.DoseQuantity.Unit,
|
||||
q := map[string]interface{}{
|
||||
"value": req.DoseQuantityValue,
|
||||
"system": sys,
|
||||
"code": req.DoseQuantity.Code,
|
||||
})
|
||||
}
|
||||
if req.DoseQuantityUnit != "" {
|
||||
q["unit"] = req.DoseQuantityUnit
|
||||
}
|
||||
if req.DoseQuantityCode != "" {
|
||||
q["code"] = req.DoseQuantityCode
|
||||
} else if req.DoseQuantityUnit != "" {
|
||||
q["code"] = req.DoseQuantityUnit
|
||||
}
|
||||
payload.Set("doseQuantity", q)
|
||||
}
|
||||
|
||||
if req.Route != nil {
|
||||
sys := req.Route.System
|
||||
if req.RouteCode != "" {
|
||||
sys := req.RouteSystem
|
||||
if sys == "" {
|
||||
sys = "http://www.whocc.no/atc"
|
||||
sys = "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministration"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Route.Code}
|
||||
if req.Route.Display != "" {
|
||||
coding["display"] = req.Route.Display
|
||||
coding := map[string]interface{}{"system": sys, "code": req.RouteCode}
|
||||
if req.RouteDisplay != "" {
|
||||
coding["display"] = req.RouteDisplay
|
||||
}
|
||||
routeConcept := map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
if req.Route.Text != "" {
|
||||
routeConcept["text"] = req.Route.Text
|
||||
}
|
||||
payload.Set("route", routeConcept)
|
||||
payload.Set("route", map[string]interface{}{
|
||||
"coding": []map[string]interface{}{coding},
|
||||
})
|
||||
}
|
||||
|
||||
return payload
|
||||
|
||||
Reference in New Issue
Block a user