diff --git a/backend/pkg/utils/ips/render.go b/backend/pkg/utils/ips/render.go index fb1d855c..add170b8 100644 --- a/backend/pkg/utils/ips/render.go +++ b/backend/pkg/utils/ips/render.go @@ -55,7 +55,12 @@ func NewNarrative() (*Narrative, error) { } return template.HTML(*s) }, - "parseList": func(data datatypes.JSON) []map[string]interface{} { + "parseStringList": func(data datatypes.JSON) []string { + var parsed []string + _ = json.Unmarshal(data, &parsed) + return parsed + }, + "parseMapList": func(data datatypes.JSON) []map[string]interface{} { var parsed []map[string]interface{} _ = json.Unmarshal(data, &parsed) return parsed diff --git a/backend/pkg/utils/ips/templates/allergies_intolerances.gohtml b/backend/pkg/utils/ips/templates/allergies_intolerances.gohtml index 9f2d7b43..1c2625ee 100644 --- a/backend/pkg/utils/ips/templates/allergies_intolerances.gohtml +++ b/backend/pkg/utils/ips/templates/allergies_intolerances.gohtml @@ -26,11 +26,11 @@ Comments: AllergyIntolerance.note[x].text (separated by
) {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .AllergyIntolerance }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Allergen */}} - {{pluckList "code" ($entry.ClinicalStatus | parseList) | uniq | join "," }} {{/* Status */}} - {{pluckList "code" ($entry.Category | parseList) | uniq | join "," }} {{/* Category */}} - {{pluckList "text" ($entry.Manifestation | parseList) | uniq | join "," }} {{/* Reaction */}} - {{pluckList "code" ($entry.Criticality | parseList) | uniq | join ","}} {{/* Severity */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Allergen */}} + {{pluckList "code" ($entry.ClinicalStatus | parseMapList) | uniq | join "," }} {{/* Status */}} + {{pluckList "code" ($entry.Category | parseMapList) | uniq | join "," }} {{/* Category */}} + {{pluckList "text" ($entry.Manifestation | parseMapList) | uniq | join "," }} {{/* Reaction */}} + {{pluckList "code" ($entry.Criticality | parseMapList) | uniq | join ","}} {{/* Severity */}} Comments {{/* Comments - TODO: use FHIRPath */}} {{default "unknown" $entry.Onset }} {{/* Onset */}} diff --git a/backend/pkg/utils/ips/templates/history_of_illness.gohtml b/backend/pkg/utils/ips/templates/history_of_illness.gohtml index ec96b346..4e83b465 100644 --- a/backend/pkg/utils/ips/templates/history_of_illness.gohtml +++ b/backend/pkg/utils/ips/templates/history_of_illness.gohtml @@ -20,8 +20,8 @@ Onset Date: Condition.onsetDateTime || Condition.onsetPeriod.start && “-“ && {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Condition }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Medical Problem */}} - {{pluckList "code" ($entry.ClinicalStatus | parseList) | uniq | join "," }} {{/* Status */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Medical Problem */}} + {{pluckList "code" ($entry.ClinicalStatus | parseMapList) | uniq | join "," }} {{/* Status */}} Comments {{/* Comments - TODO: use FHIRPath */}} {{$entry.OnsetDate | date "2006-01-02"}} {{/* Onset */}} diff --git a/backend/pkg/utils/ips/templates/history_of_procedures.gohtml b/backend/pkg/utils/ips/templates/history_of_procedures.gohtml index 29eadf36..e985b792 100644 --- a/backend/pkg/utils/ips/templates/history_of_procedures.gohtml +++ b/backend/pkg/utils/ips/templates/history_of_procedures.gohtml @@ -19,7 +19,7 @@ Date: Procedure.performedDateTime || Procedure.performedPeriod.start && “-“ {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Procedure }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Procedure */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Procedure */}} Comments {{/* Comments - TODO: use FHIRPath */}} {{$entry.Date | date "2006-01-02"}} {{/* Performed Date */}} diff --git a/backend/pkg/utils/ips/templates/immunizations.gohtml b/backend/pkg/utils/ips/templates/immunizations.gohtml index 748ad730..e782ce87 100644 --- a/backend/pkg/utils/ips/templates/immunizations.gohtml +++ b/backend/pkg/utils/ips/templates/immunizations.gohtml @@ -27,10 +27,10 @@ Date: Immunization.occurrenceDateTime || Immunization.occurrenceString {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Immunization }} - {{pluckList "text" ($entry.VaccineCode | parseList) | uniq | join "," }} {{/* Immunization */}} - {{pluckList "code" ($entry.Status | parseList) | uniq | join "," }} {{/* Status */}} + {{pluckList "text" ($entry.VaccineCode | parseMapList) | uniq | join "," }} {{/* Immunization */}} + {{pluckList "code" ($entry.Status | parseMapList) | uniq | join "," }} {{/* Status */}} Dose Number {{/* Comments - TODO: use FHIRPath */}} - {{pluckList "display" ($entry.Manufacturer | parseList) | uniq | join "," }} {{/* Manufacturer */}} + {{pluckList "display" ($entry.Manufacturer | parseMapList) | uniq | join "," }} {{/* Manufacturer */}} {{$entry.LotNumber}} {{/* Lot Number */}} Comments {{$entry.Date | date "2006-01-02"}} {{/* Performed Date */}} diff --git a/backend/pkg/utils/ips/templates/includes/observation-unit.gohtml b/backend/pkg/utils/ips/templates/includes/observation-unit.gohtml index 10a0de7c..b4040903 100644 --- a/backend/pkg/utils/ips/templates/includes/observation-unit.gohtml +++ b/backend/pkg/utils/ips/templates/includes/observation-unit.gohtml @@ -1,11 +1,11 @@ -{{if not (empty .ValueString) }} +{{if not (empty (.ValueString | parseMapList)) }} {{.ValueString}} -{{else if not (empty (.ValueQuantity | parseList)) }} - {{.ValueQuantity | parseList | pluckList "unit" | join "," }} +{{else if not (empty (.ValueQuantity | parseMapList)) }} + {{.ValueQuantity | parseMapList | pluckList "unit" | join "," }} {{else if not (empty .ValueDate) }} {{.ValueDate | date "2006-01-02" }} -{{else if not (empty (.ValueConcept | parseList)) }} +{{else if not (empty (.ValueConcept | parseMapList)) }} {{.ValueConcept}} -{{else if not (empty (.ComponentValueQuantity | parseList)) }} - {{.ComponentValueQuantity | parseList | pluckList "unit" | join "," }} +{{else if not (empty (.ComponentValueQuantity | parseMapList)) }} + {{.ComponentValueQuantity | parseMapList | pluckList "unit" | join "," }} {{end}} diff --git a/backend/pkg/utils/ips/templates/includes/observation-value.gohtml b/backend/pkg/utils/ips/templates/includes/observation-value.gohtml index c57d17bb..c92aa81f 100644 --- a/backend/pkg/utils/ips/templates/includes/observation-value.gohtml +++ b/backend/pkg/utils/ips/templates/includes/observation-value.gohtml @@ -1,23 +1,27 @@ -{{if not (empty .entry.ValueString) }} - {{.ValueString}} -{{else if not (empty (.entry.ValueQuantity | parseList)) }} - {{.entry.ValueQuantity | parseList | pluckList "value" | roundList 2 | join "," }} +{{if not (empty (.entry.ValueString | parseMapList)) }} + {{.entry.ValueString | parseStringList | join ","}} +{{else if not (empty (.entry.ValueQuantity | parseMapList)) }} + {{.entry.ValueQuantity | parseMapList | pluckList "value" | roundList 2 | join "," }} {{if (get . "include_unit")}} - {{.entry.ValueQuantity | parseList | pluckList "unit" | join "," }} + {{.entry.ValueQuantity | parseMapList | pluckList "unit" | join "," }} {{end}} {{else if not (empty .entry.ValueDate) }} {{.entry.ValueDate | date "2006-01-02" }} -{{else if not (empty (.entry.ValueConcept | parseList)) }} +{{else if not (empty (.entry.ValueConcept | parseMapList)) }} {{.entry.ValueConcept}} -{{else if not (empty (.entry.ComponentValueQuantity | parseList)) }} - {{$componentCodeText := $.entry.ComponentCode | parseList | pluckList "text" }} - {{$componentValueQuantity := $.entry.ComponentValueQuantity | parseList | pluckList "value" | roundList 2 }} +{{else if not (empty (.entry.ComponentValueQuantity | parseMapList)) }} + {{$componentCodeText := .entry.ComponentCode | parseMapList | pluckList "text" }} + {{$componentValueQuantity := .entry.ComponentValueQuantity | parseMapList | pluckList "value" | roundList 2 }} + {{$componentValueQuantityUnit := .entry.ComponentValueQuantity | parseMapList | pluckList "unit" }} + {{range $index, $text := $componentCodeText }} {{$text}} - {{index $componentValueQuantity $index}} + {{if (get $ "include_unit")}} + {{index $componentValueQuantityUnit $index}} + {{end}} +
{{end}} - {{if (get . "include_unit")}} - {{.ComponentValueQuantity | parseList | pluckList "unit" | join "," }} - {{end}} + {{end}} diff --git a/backend/pkg/utils/ips/templates/medical_devices.gohtml b/backend/pkg/utils/ips/templates/medical_devices.gohtml index d237d73e..86421f7e 100644 --- a/backend/pkg/utils/ips/templates/medical_devices.gohtml +++ b/backend/pkg/utils/ips/templates/medical_devices.gohtml @@ -20,8 +20,8 @@ Date Recorded: DeviceUseStatement.recordedDateTime {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Device }} - {{pluckList "text" ($entry.Type | parseList) | uniq | join "," }} {{/* Device */}} - {{pluckList "code" ($entry.Status | parseList) | uniq | join "," }} {{/* Status */}} + {{pluckList "text" ($entry.Type | parseMapList) | uniq | join "," }} {{/* Device */}} + {{pluckList "code" ($entry.Status | parseMapList) | uniq | join "," }} {{/* Status */}} Comments {{/* Date Recorded */}} diff --git a/backend/pkg/utils/ips/templates/plan_of_care.gohtml b/backend/pkg/utils/ips/templates/plan_of_care.gohtml index 8acc170a..a88e45d3 100644 --- a/backend/pkg/utils/ips/templates/plan_of_care.gohtml +++ b/backend/pkg/utils/ips/templates/plan_of_care.gohtml @@ -23,7 +23,7 @@ Planned End: CarePlan.period.end {{range $index, $entry := .CarePlan }} Activity - {{pluckList "code" ($entry.Intent | parseList) | uniq | join "," }} {{/* Intent */}} + {{pluckList "code" ($entry.Intent | parseMapList) | uniq | join "," }} {{/* Intent */}} Comments {{$entry.Date}}{{/* Planned Start */}} Planned End diff --git a/backend/pkg/utils/ips/templates/pregnancy.gohtml b/backend/pkg/utils/ips/templates/pregnancy.gohtml index 8e9dd53a..01cc7fd6 100644 --- a/backend/pkg/utils/ips/templates/pregnancy.gohtml +++ b/backend/pkg/utils/ips/templates/pregnancy.gohtml @@ -20,7 +20,7 @@ Date: Observation.effectiveDateTime || Observation.effectivePeriod.start {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Observation }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Code */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Code */}} {{template "observation-value.gohtml" (dict "entry" $entry "include_unit" true)}} {{/* Result */}} Comments {{$entry.Date | date "2006-01-02"}} {{/* Date */}} diff --git a/backend/pkg/utils/ips/templates/problem_list.gohtml b/backend/pkg/utils/ips/templates/problem_list.gohtml index 8abae809..42f5055e 100644 --- a/backend/pkg/utils/ips/templates/problem_list.gohtml +++ b/backend/pkg/utils/ips/templates/problem_list.gohtml @@ -20,8 +20,8 @@ Onset Date: Condition.onsetDateTime || Condition.onsetPeriod.start && “-“ && {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Condition }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Medical Problems */}} - {{pluckList "code" ($entry.ClinicalStatus | parseList) | uniq | join "," }} {{/* Status */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Medical Problems */}} + {{pluckList "code" ($entry.ClinicalStatus | parseMapList) | uniq | join "," }} {{/* Status */}} Comments {{$entry.OnsetDate | date "2006-01-02"}} {{/* Onset */}} diff --git a/backend/pkg/utils/ips/templates/social_history.gohtml b/backend/pkg/utils/ips/templates/social_history.gohtml index 842806f9..a7c482c7 100644 --- a/backend/pkg/utils/ips/templates/social_history.gohtml +++ b/backend/pkg/utils/ips/templates/social_history.gohtml @@ -22,7 +22,7 @@ Date: Observation.effectiveDateTime || Observation.effectivePeriod.start {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Observation }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Code */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Code */}} {{template "observation-value.gohtml" (dict "entry" $entry "include_unit" false)}} {{/* Result */}} Unit Comments diff --git a/backend/pkg/utils/ips/templates/vital_signs.gohtml b/backend/pkg/utils/ips/templates/vital_signs.gohtml index 3176f280..7870aca8 100644 --- a/backend/pkg/utils/ips/templates/vital_signs.gohtml +++ b/backend/pkg/utils/ips/templates/vital_signs.gohtml @@ -25,7 +25,7 @@ Date: Observation.effectiveDateTime || Observation.effectivePeriod.start {{- /*gotype: github.com/fastenhealth/fasten-onprem/backend/pkg/utils/ips.NarrativeTemplateData*/ -}} {{range $index, $entry := .Observation }} - {{pluckList "text" ($entry.Code | parseList) | uniq | join "," }} {{/* Code */}} + {{pluckList "text" ($entry.Code | parseMapList) | uniq | join "," }} {{/* Code */}} {{template "observation-value.gohtml" (dict "entry" $entry "include_unit" false)}} {{/* Result */}} {{template "observation-unit.gohtml" $entry}} Interpretation