update All feture and service
This commit is contained in:
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package specimen
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
@@ -10,18 +9,13 @@ import (
|
||||
func MapRequestToFHIR(req SpecimenRequest) satusehat.FHIRPayload {
|
||||
payload := satusehat.NewFHIRPayload("Specimen")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
|
||||
if orgID != "" && req.SpecimenID != "" {
|
||||
if req.OrganizationID != "" && req.SpecimenID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
{
|
||||
"system": "http://sys-ids.kemkes.go.id/specimen/" + orgID,
|
||||
"system": "http://sys-ids.kemkes.go.id/specimen/" + req.OrganizationID,
|
||||
"value": req.SpecimenID,
|
||||
"assigner": map[string]interface{}{
|
||||
"reference": "Organization/" + orgID,
|
||||
"reference": "Organization/" + req.OrganizationID,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -31,136 +25,123 @@ func MapRequestToFHIR(req SpecimenRequest) satusehat.FHIRPayload {
|
||||
payload.Set("status", req.Status)
|
||||
}
|
||||
|
||||
if req.Type != nil {
|
||||
sys := req.Type.System
|
||||
if req.TypeCode != "" {
|
||||
sys := req.TypeSystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Type.Code}
|
||||
if req.Type.Display != "" {
|
||||
coding["display"] = req.Type.Display
|
||||
coding := map[string]interface{}{"system": sys, "code": req.TypeCode}
|
||||
if req.TypeDisplay != "" {
|
||||
coding["display"] = req.TypeDisplay
|
||||
}
|
||||
payload.Set("type", map[string]interface{}{"coding": []map[string]interface{}{coding}})
|
||||
}
|
||||
|
||||
if req.Collection != nil {
|
||||
coll := map[string]interface{}{}
|
||||
if req.Collection.Collector != nil {
|
||||
collector := map[string]interface{}{"reference": req.Collection.Collector.Reference}
|
||||
if req.Collection.Collector.Display != "" {
|
||||
collector["display"] = req.Collection.Collector.Display
|
||||
}
|
||||
coll["collector"] = collector
|
||||
}
|
||||
|
||||
if req.Collection.CollectedDateTime != nil && !req.Collection.CollectedDateTime.IsZero() {
|
||||
coll["collectedDateTime"] = req.Collection.CollectedDateTime.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
if req.Collection.Quantity != nil {
|
||||
sys := req.Collection.Quantity.System
|
||||
if sys == "" {
|
||||
sys = "http://unitsofmeasure.org"
|
||||
}
|
||||
coll["quantity"] = map[string]interface{}{
|
||||
"value": req.Collection.Quantity.Value,
|
||||
"unit": req.Collection.Quantity.Unit,
|
||||
"system": sys,
|
||||
"code": req.Collection.Quantity.Code,
|
||||
}
|
||||
}
|
||||
|
||||
if req.Collection.Method != nil {
|
||||
sys := req.Collection.Method.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Collection.Method.Code}
|
||||
if req.Collection.Method.Display != "" {
|
||||
coding["display"] = req.Collection.Method.Display
|
||||
}
|
||||
coll["method"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
|
||||
if req.Collection.BodySite != nil {
|
||||
sys := req.Collection.BodySite.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Collection.BodySite.Code}
|
||||
if req.Collection.BodySite.Display != "" {
|
||||
coding["display"] = req.Collection.BodySite.Display
|
||||
}
|
||||
coll["bodySite"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
|
||||
if req.Collection.FastingStatus != nil {
|
||||
sys := req.Collection.FastingStatus.System
|
||||
if sys == "" {
|
||||
sys = "http://terminology.hl7.org/CodeSystem/v2-0916"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.Collection.FastingStatus.Code}
|
||||
if req.Collection.FastingStatus.Display != "" {
|
||||
coding["display"] = req.Collection.FastingStatus.Display
|
||||
}
|
||||
coll["fastingStatusCodeableConcept"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
|
||||
if len(coll) > 0 {
|
||||
payload.Set("collection", coll)
|
||||
}
|
||||
}
|
||||
|
||||
if len(req.Processing) > 0 {
|
||||
var processings []map[string]interface{}
|
||||
for _, proc := range req.Processing {
|
||||
p := map[string]interface{}{}
|
||||
if proc.Procedure != nil {
|
||||
sys := proc.Procedure.System
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
p["procedure"] = map[string]interface{}{
|
||||
"coding": []map[string]interface{}{
|
||||
{"system": sys, "code": proc.Procedure.Code, "display": proc.Procedure.Display},
|
||||
},
|
||||
}
|
||||
}
|
||||
if proc.TimeDateTime != nil && !proc.TimeDateTime.IsZero() {
|
||||
p["timeDateTime"] = proc.TimeDateTime.Format(time.RFC3339)
|
||||
}
|
||||
processings = append(processings, p)
|
||||
}
|
||||
payload.Set("processing", processings)
|
||||
}
|
||||
|
||||
if len(req.Conditions) > 0 {
|
||||
var conditions []map[string]interface{}
|
||||
for _, c := range req.Conditions {
|
||||
conditions = append(conditions, map[string]interface{}{"text": c})
|
||||
}
|
||||
payload.Set("condition", conditions)
|
||||
}
|
||||
|
||||
if req.Subject != nil {
|
||||
subject := map[string]interface{}{"reference": req.Subject.Reference}
|
||||
if req.Subject.Display != "" {
|
||||
subject["display"] = req.Subject.Display
|
||||
if req.PatientID != "" {
|
||||
subject := map[string]interface{}{"reference": "Patient/" + req.PatientID}
|
||||
if req.PatientName != "" {
|
||||
subject["display"] = req.PatientName
|
||||
}
|
||||
payload.Set("subject", subject)
|
||||
}
|
||||
|
||||
if len(req.Request) > 0 {
|
||||
var requests []map[string]interface{}
|
||||
for _, r := range req.Request {
|
||||
requests = append(requests, map[string]interface{}{"reference": r.Reference})
|
||||
}
|
||||
payload.Set("request", requests)
|
||||
}
|
||||
|
||||
if req.ReceivedDateTime != nil && !req.ReceivedDateTime.IsZero() {
|
||||
payload.Set("receivedTime", req.ReceivedDateTime.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
coll := map[string]interface{}{}
|
||||
if req.CollectorID != "" {
|
||||
collector := map[string]interface{}{"reference": "Practitioner/" + req.CollectorID}
|
||||
if req.CollectorName != "" {
|
||||
collector["display"] = req.CollectorName
|
||||
}
|
||||
coll["collector"] = collector
|
||||
}
|
||||
if req.CollectedDateTime != nil && !req.CollectedDateTime.IsZero() {
|
||||
coll["collectedDateTime"] = req.CollectedDateTime.Format(time.RFC3339)
|
||||
}
|
||||
if req.CollectionQuantityValue != nil {
|
||||
sys := req.CollectionQuantitySystem
|
||||
if sys == "" {
|
||||
sys = "http://unitsofmeasure.org"
|
||||
}
|
||||
q := map[string]interface{}{"value": *req.CollectionQuantityValue, "system": sys}
|
||||
if req.CollectionQuantityUnit != "" {
|
||||
q["unit"] = req.CollectionQuantityUnit
|
||||
q["code"] = req.CollectionQuantityUnit
|
||||
}
|
||||
coll["quantity"] = q
|
||||
}
|
||||
if req.CollectionMethodCode != "" {
|
||||
sys := req.CollectionMethodSystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.CollectionMethodCode}
|
||||
if req.CollectionMethodDisplay != "" {
|
||||
coding["display"] = req.CollectionMethodDisplay
|
||||
}
|
||||
coll["method"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
if req.BodySiteCode != "" {
|
||||
sys := req.BodySiteSystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.BodySiteCode}
|
||||
if req.BodySiteDisplay != "" {
|
||||
coding["display"] = req.BodySiteDisplay
|
||||
}
|
||||
coll["bodySite"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
if req.FastingStatusCode != "" {
|
||||
sys := req.FastingStatusSystem
|
||||
if sys == "" {
|
||||
sys = "http://terminology.hl7.org/CodeSystem/v2-0916"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.FastingStatusCode}
|
||||
if req.FastingStatusDisplay != "" {
|
||||
coding["display"] = req.FastingStatusDisplay
|
||||
}
|
||||
coll["fastingStatusCodeableConcept"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
if len(coll) > 0 {
|
||||
payload.Set("collection", coll)
|
||||
}
|
||||
|
||||
if req.ProcessingProcedureCode != "" {
|
||||
sys := req.ProcessingProcedureSystem
|
||||
if sys == "" {
|
||||
sys = "http://snomed.info/sct"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.ProcessingProcedureCode}
|
||||
if req.ProcessingProcedureDisplay != "" {
|
||||
coding["display"] = req.ProcessingProcedureDisplay
|
||||
}
|
||||
p := map[string]interface{}{
|
||||
"procedure": map[string]interface{}{"coding": []map[string]interface{}{coding}},
|
||||
}
|
||||
if req.ProcessingTimeDateTime != nil && !req.ProcessingTimeDateTime.IsZero() {
|
||||
p["timeDateTime"] = req.ProcessingTimeDateTime.Format(time.RFC3339)
|
||||
}
|
||||
payload.Set("processing", []map[string]interface{}{p})
|
||||
}
|
||||
|
||||
if len(req.Conditions) > 0 {
|
||||
conditions := make([]map[string]interface{}, 0, len(req.Conditions))
|
||||
for _, c := range req.Conditions {
|
||||
conditions = append(conditions, map[string]interface{}{"text": c})
|
||||
}
|
||||
payload.Set("condition", conditions)
|
||||
}
|
||||
|
||||
if len(req.RequestServiceRequestIDs) > 0 {
|
||||
requests := make([]map[string]interface{}, 0, len(req.RequestServiceRequestIDs))
|
||||
for _, id := range req.RequestServiceRequestIDs {
|
||||
requests = append(requests, map[string]interface{}{"reference": "ServiceRequest/" + id})
|
||||
}
|
||||
payload.Set("request", requests)
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
Reference in New Issue
Block a user