39 lines
957 B
Go
39 lines
957 B
Go
package composition
|
|
|
|
import (
|
|
"time"
|
|
|
|
"service/internal/interfaces/satusehat"
|
|
)
|
|
|
|
func MapRequestToFHIR(req CompositionRequest) satusehat.FHIRPayload {
|
|
payload := satusehat.NewFHIRPayload("Composition").
|
|
Set("status", req.Status).
|
|
Set("type", map[string]interface{}{
|
|
"coding": []map[string]interface{}{
|
|
{
|
|
"system": "http://loinc.org",
|
|
"code": "11503-0", // Example: Medical records
|
|
"display": "Medical records",
|
|
},
|
|
},
|
|
}).
|
|
Set("subject", map[string]interface{}{
|
|
"reference": "Patient/" + req.PatientID,
|
|
"display": req.PatientName,
|
|
}).
|
|
Set("encounter", map[string]interface{}{
|
|
"reference": "Encounter/" + req.EncounterID,
|
|
}).
|
|
Set("date", req.Date.Format(time.RFC3339)).
|
|
Set("title", req.Title)
|
|
|
|
if req.PractitionerID != "" {
|
|
payload.Append("author", map[string]interface{}{
|
|
"reference": "Practitioner/" + req.PractitionerID,
|
|
"display": req.PractitionerName,
|
|
})
|
|
}
|
|
return payload
|
|
}
|