update All feture and service
This commit is contained in:
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package episodeofcare
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"service/internal/interfaces/satusehat"
|
||||
@@ -10,10 +9,7 @@ import (
|
||||
func MapRequestToFHIR(req EpisodeOfCareRequest) satusehat.FHIRPayload {
|
||||
payload := satusehat.NewFHIRPayload("EpisodeOfCare")
|
||||
|
||||
orgID := os.Getenv("SATUSEHAT_ORG_ID")
|
||||
if orgID == "" {
|
||||
orgID = req.OrganizationID
|
||||
}
|
||||
orgID := req.OrganizationID
|
||||
|
||||
if orgID != "" && req.EpisodeOfCareID != "" {
|
||||
payload.Set("identifier", []map[string]interface{}{
|
||||
@@ -28,79 +24,39 @@ func MapRequestToFHIR(req EpisodeOfCareRequest) satusehat.FHIRPayload {
|
||||
payload.Set("status", req.Status)
|
||||
}
|
||||
|
||||
if len(req.StatusHistory) > 0 {
|
||||
var statusHistory []map[string]interface{}
|
||||
for _, sh := range req.StatusHistory {
|
||||
historyItem := map[string]interface{}{"status": sh.Status}
|
||||
period := map[string]interface{}{}
|
||||
if sh.PeriodStart != nil && !sh.PeriodStart.IsZero() {
|
||||
period["start"] = sh.PeriodStart.Format(time.RFC3339)
|
||||
}
|
||||
if sh.PeriodEnd != nil && !sh.PeriodEnd.IsZero() {
|
||||
period["end"] = sh.PeriodEnd.Format(time.RFC3339)
|
||||
}
|
||||
if len(period) > 0 {
|
||||
historyItem["period"] = period
|
||||
}
|
||||
statusHistory = append(statusHistory, historyItem)
|
||||
if req.TypeCode != "" {
|
||||
sys := req.TypeSystem
|
||||
if sys == "" {
|
||||
sys = "http://terminology.kemkes.go.id/CodeSystem/episodeofcare-type"
|
||||
}
|
||||
payload.Set("statusHistory", statusHistory)
|
||||
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 len(req.Type) > 0 {
|
||||
var types []map[string]interface{}
|
||||
for _, t := range req.Type {
|
||||
if t != nil {
|
||||
sys := t.System
|
||||
if sys == "" {
|
||||
sys = "http://terminology.kemkes.go.id/CodeSystem/episodeofcare-type"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": t.Code}
|
||||
if t.Display != "" {
|
||||
coding["display"] = t.Display
|
||||
}
|
||||
typeConcept := map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
if t.Text != "" {
|
||||
typeConcept["text"] = t.Text
|
||||
}
|
||||
types = append(types, typeConcept)
|
||||
}
|
||||
if req.DiagnosisConditionID != "" {
|
||||
diag := map[string]interface{}{
|
||||
"condition": map[string]interface{}{"reference": "Condition/" + req.DiagnosisConditionID},
|
||||
}
|
||||
payload.Set("type", types)
|
||||
}
|
||||
|
||||
if len(req.Diagnosis) > 0 {
|
||||
var diagnoses []map[string]interface{}
|
||||
for _, d := range req.Diagnosis {
|
||||
diagnosisItem := map[string]interface{}{}
|
||||
|
||||
if d.Condition != nil {
|
||||
condition := map[string]interface{}{"reference": d.Condition.Reference}
|
||||
if d.Condition.Display != "" {
|
||||
condition["display"] = d.Condition.Display
|
||||
}
|
||||
diagnosisItem["condition"] = condition
|
||||
if req.DiagnosisRoleCode != "" {
|
||||
sys := req.DiagnosisRoleSystem
|
||||
if sys == "" {
|
||||
sys = "http://terminology.hl7.org/CodeSystem/diagnosis-role"
|
||||
}
|
||||
|
||||
if d.Role != nil {
|
||||
sys := d.Role.System
|
||||
if sys == "" {
|
||||
sys = "http://terminology.hl7.org/CodeSystem/diagnosis-role"
|
||||
}
|
||||
coding := map[string]interface{}{"system": sys, "code": d.Role.Code}
|
||||
if d.Role.Display != "" {
|
||||
coding["display"] = d.Role.Display
|
||||
}
|
||||
diagnosisItem["role"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
coding := map[string]interface{}{"system": sys, "code": req.DiagnosisRoleCode}
|
||||
if req.DiagnosisRoleDisplay != "" {
|
||||
coding["display"] = req.DiagnosisRoleDisplay
|
||||
}
|
||||
|
||||
if d.Rank > 0 {
|
||||
diagnosisItem["rank"] = d.Rank
|
||||
}
|
||||
|
||||
diagnoses = append(diagnoses, diagnosisItem)
|
||||
diag["role"] = map[string]interface{}{"coding": []map[string]interface{}{coding}}
|
||||
}
|
||||
payload.Set("diagnosis", diagnoses)
|
||||
if req.DiagnosisRank > 0 {
|
||||
diag["rank"] = req.DiagnosisRank
|
||||
}
|
||||
payload.Set("diagnosis", []map[string]interface{}{diag})
|
||||
}
|
||||
|
||||
if req.PatientID != "" {
|
||||
@@ -112,8 +68,8 @@ func MapRequestToFHIR(req EpisodeOfCareRequest) satusehat.FHIRPayload {
|
||||
}
|
||||
|
||||
manageOrg := orgID
|
||||
if req.ManagingOrganization != "" {
|
||||
manageOrg = req.ManagingOrganization
|
||||
if req.ManagingOrganizationID != "" {
|
||||
manageOrg = req.ManagingOrganizationID
|
||||
}
|
||||
if manageOrg != "" {
|
||||
payload.Set("managingOrganization", map[string]interface{}{
|
||||
@@ -129,10 +85,10 @@ func MapRequestToFHIR(req EpisodeOfCareRequest) satusehat.FHIRPayload {
|
||||
payload.Set("period", period)
|
||||
}
|
||||
|
||||
if req.CareManager != nil {
|
||||
cm := map[string]interface{}{"reference": req.CareManager.Reference}
|
||||
if req.CareManager.Display != "" {
|
||||
cm["display"] = req.CareManager.Display
|
||||
if req.CareManagerID != "" {
|
||||
cm := map[string]interface{}{"reference": "Practitioner/" + req.CareManagerID}
|
||||
if req.CareManagerName != "" {
|
||||
cm["display"] = req.CareManagerName
|
||||
}
|
||||
payload.Set("careManager", cm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user