@imranq2/fhirpatientsummary 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +287 -78
- package/dist/index.js +287 -78
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -138,6 +138,67 @@ var ESSENTIAL_LAB_PANELS = {
|
|
|
138
138
|
"80235-8": "Cardiac Markers Panel",
|
|
139
139
|
"69738-3": "CBC with Auto Differential"
|
|
140
140
|
};
|
|
141
|
+
var FUNCTIONAL_STATUS_SNOMED_CODES = {
|
|
142
|
+
"118233009": "Core Functional Status",
|
|
143
|
+
"364644000": "Core Functional Status",
|
|
144
|
+
"160245001": "Core Functional Status",
|
|
145
|
+
"21134002": "Disability & Impairment",
|
|
146
|
+
"2655002": "Disability & Impairment",
|
|
147
|
+
"2219003": "Disability & Impairment",
|
|
148
|
+
"962000": "Disability & Impairment",
|
|
149
|
+
"3089009": "Disability & Impairment",
|
|
150
|
+
"4197006": "Disability & Impairment",
|
|
151
|
+
"284545001": "Activities of Daily Living",
|
|
152
|
+
"719930002": "Activities of Daily Living",
|
|
153
|
+
"301438001": "Activities of Daily Living",
|
|
154
|
+
"282145008": "Mobility & Movement",
|
|
155
|
+
"165245003": "Mobility & Movement",
|
|
156
|
+
"713458007": "Mobility & Movement"
|
|
157
|
+
};
|
|
158
|
+
var FUNCTIONAL_STATUS_ASSESSMENT_LOINC_CODES = {
|
|
159
|
+
"54522-8": "Functional Status Panel",
|
|
160
|
+
"54523-6": "ADL Assistance",
|
|
161
|
+
"45588-1": "Bed Mobility",
|
|
162
|
+
"45589-9": "Bed Mobility",
|
|
163
|
+
"45590-7": "Transfer",
|
|
164
|
+
"45591-5": "Transfer",
|
|
165
|
+
"45592-3": "Walk in room",
|
|
166
|
+
"45593-1": "Walk in room",
|
|
167
|
+
"45594-9": "Walk in corridor",
|
|
168
|
+
"45595-6": "Walk in corridor",
|
|
169
|
+
"45596-4": "Locomotion on unit",
|
|
170
|
+
"45597-2": "Locomotion on unit",
|
|
171
|
+
"45598-0": "Locomotion off unit",
|
|
172
|
+
"45599-8": "Locomotion off unit",
|
|
173
|
+
"45600-4": "Dressing",
|
|
174
|
+
"45601-2": "Dressing",
|
|
175
|
+
"45602-0": "Eating",
|
|
176
|
+
"45603-8": "Eating",
|
|
177
|
+
"45604-6": "Toilet use",
|
|
178
|
+
"45605-3": "Toilet use",
|
|
179
|
+
"45606-1": "Personal hygiene",
|
|
180
|
+
"45607-9": "Personal hygiene",
|
|
181
|
+
"46008-9": "Bathing",
|
|
182
|
+
"45608-7": "Bathing",
|
|
183
|
+
"45609-5": "Bathing",
|
|
184
|
+
"54524-4": "Balance during Transitions and Walking",
|
|
185
|
+
"54749-7": "Moving from Seated to Standing",
|
|
186
|
+
"54750-5": "Walking with Assistive Device",
|
|
187
|
+
"54751-3": "Turning Around While Walking",
|
|
188
|
+
"54753-9": "Surface-to-Surface Transfer",
|
|
189
|
+
"54525-1": "Functional Limitation in Range of Motion",
|
|
190
|
+
"54754-7": "Upper Extremity ROM",
|
|
191
|
+
"54755-4": "Lower Extremity ROM",
|
|
192
|
+
"54526-9": "Mobility Devices",
|
|
193
|
+
"54756-2": "Cane/Crutch",
|
|
194
|
+
"54757-0": "Walker",
|
|
195
|
+
"54758-8": "Wheelchair",
|
|
196
|
+
"54759-6": "Limb Prosthesis",
|
|
197
|
+
"54760-4": "No Mobility Devices",
|
|
198
|
+
"54527-7": "Functional Rehabilitation Potential",
|
|
199
|
+
"55123-4": "Resident Believes Capable of Increased Independence",
|
|
200
|
+
"45613-7": "Staff Believes Capable of Increased Independence"
|
|
201
|
+
};
|
|
141
202
|
|
|
142
203
|
// src/structures/ips_section_constants.ts
|
|
143
204
|
var VITAL_SIGNS_SUMMARY_COMPONENT_MAP = {
|
|
@@ -173,11 +234,9 @@ var IPSSectionResourceFilters = {
|
|
|
173
234
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Observation" && codeableConceptMatches(resource.code, Object.keys(SOCIAL_HISTORY_LOINC_CODES), "http://loinc.org"),
|
|
174
235
|
// Only include pregnancy history Observations or relevant Conditions
|
|
175
236
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: (resource) => resource.resourceType === "Observation" && (codeableConceptMatches(resource.code, Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_STATUS), "http://loinc.org") || codeableConceptMatches(resource.valueCodeableConcept, Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME), "http://loinc.org") || codingMatches(resource.code?.coding?.[0], PREGNANCY_SNOMED_CODES, "http://snomed.info/sct") || codingMatches(resource.valueCodeableConcept?.coding?.[0], PREGNANCY_SNOMED_CODES, "http://snomed.info/sct")) || resource.resourceType === "Condition" && (codeableConceptMatches(resource.code, Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_STATUS), "http://loinc.org") || codeableConceptMatches(resource.code, Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME), "http://loinc.org") || codingMatches(resource.code?.coding?.[0], PREGNANCY_SNOMED_CODES, "http://snomed.info/sct")),
|
|
176
|
-
// Only include
|
|
177
|
-
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: (resource) => resource.resourceType === "
|
|
178
|
-
(cat) => cat.coding?.some(
|
|
179
|
-
(c) => c.code === "functional-status" && c.system === "http://terminology.hl7.org/CodeSystem/observation-category" || typeof c.display === "string" && c.display.toLowerCase().includes("functional")
|
|
180
|
-
)
|
|
237
|
+
// Only include Condition with Functional Status LOINC and SNOMED codes, category code 'problem-list-item', and completed ClinicalImpressions
|
|
238
|
+
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: (resource) => resource.resourceType === "Condition" && ((codeableConceptMatches(resource.code, Object.keys(FUNCTIONAL_STATUS_ASSESSMENT_LOINC_CODES), "http://loinc.org") || codeableConceptMatches(resource.code, Object.keys(FUNCTIONAL_STATUS_SNOMED_CODES), "http://snomed.info/sct")) && resource.clinicalStatus?.coding?.some((c) => c.code === "active") && resource.category?.some(
|
|
239
|
+
(cat) => cat.coding?.some((c) => c.code === "problem-list-item")
|
|
181
240
|
)) || resource.resourceType === "ClinicalImpression" && resource.status === "completed",
|
|
182
241
|
// Only include resolved medical history Conditions
|
|
183
242
|
["HistoryOfPastIllnessSection" /* MEDICAL_HISTORY */]: (resource) => resource.resourceType === "Condition" && resource.clinicalStatus?.coding?.some((c) => ["inactive", "resolved"].includes(c.code)),
|
|
@@ -923,6 +982,18 @@ var TemplateUtilities = class {
|
|
|
923
982
|
}
|
|
924
983
|
return "";
|
|
925
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* Returns the owner tag from the resource meta.security array.
|
|
987
|
+
* @param resource - FHIR resource with meta tag
|
|
988
|
+
* @returns The owner display or code if found, otherwise undefined
|
|
989
|
+
*/
|
|
990
|
+
getOwnerTag(resource) {
|
|
991
|
+
if (!resource?.meta?.security) return "";
|
|
992
|
+
const ownerEntry = resource.meta.security.find(
|
|
993
|
+
(sec) => sec.system === "https://www.icanbwell.com/owner" && !!sec.code
|
|
994
|
+
);
|
|
995
|
+
return ownerEntry?.display || ownerEntry?.code;
|
|
996
|
+
}
|
|
926
997
|
/**
|
|
927
998
|
* Public method to render plain text as HTML, escaping special characters and replacing newlines with <br />.
|
|
928
999
|
* This method should be used whenever displaying user-supplied or FHIR resource text in HTML to prevent XSS vulnerabilities
|
|
@@ -1858,6 +1929,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1858
1929
|
<th>Code (System)</th>
|
|
1859
1930
|
<th>Criticality</th>
|
|
1860
1931
|
<th>Recorded Date</th>
|
|
1932
|
+
<th>Source</th>
|
|
1861
1933
|
</tr>
|
|
1862
1934
|
</thead>
|
|
1863
1935
|
<tbody>`;
|
|
@@ -1877,6 +1949,9 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1877
1949
|
case "Recorded Date":
|
|
1878
1950
|
data["recordedDate"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
1879
1951
|
break;
|
|
1952
|
+
case "Source":
|
|
1953
|
+
data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
1954
|
+
break;
|
|
1880
1955
|
default:
|
|
1881
1956
|
break;
|
|
1882
1957
|
}
|
|
@@ -1891,6 +1966,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1891
1966
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
1892
1967
|
<td>${data["criticality"] ?? ""}</td>
|
|
1893
1968
|
<td>${templateUtilities.renderTime(data["recordedDate"], timezone) ?? ""}</td>
|
|
1969
|
+
<td>${data["source"] ?? ""}</td>
|
|
1894
1970
|
</tr>`;
|
|
1895
1971
|
}
|
|
1896
1972
|
}
|
|
@@ -1944,6 +2020,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1944
2020
|
<th>Reaction</th>
|
|
1945
2021
|
<th>Onset Date</th>
|
|
1946
2022
|
<th>Comments</th>
|
|
2023
|
+
<th>Source</th>
|
|
1947
2024
|
</tr>
|
|
1948
2025
|
</thead>
|
|
1949
2026
|
<tbody>`;
|
|
@@ -1973,6 +2050,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1973
2050
|
<th>Onset Date</th>
|
|
1974
2051
|
<th>Comments</th>
|
|
1975
2052
|
<th>Resolved Date</th>
|
|
2053
|
+
<th>Source</th>
|
|
1976
2054
|
</tr>
|
|
1977
2055
|
</thead>
|
|
1978
2056
|
<tbody>`;
|
|
@@ -2013,7 +2091,8 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
2013
2091
|
<td class="Category">${templateUtilities.renderTextAsHtml(templateUtilities.safeConcat(allergy.category)) || ""}</td>
|
|
2014
2092
|
<td class="Reaction">${templateUtilities.renderTextAsHtml(templateUtilities.concatReactionManifestation(allergy.reaction)) || ""}</td>
|
|
2015
2093
|
<td class="OnsetDate">${templateUtilities.renderTextAsHtml(templateUtilities.renderTime(allergy.onsetDateTime, timezone)) || ""}</td>
|
|
2016
|
-
<td class="Comments">${templateUtilities.renderNotes(allergy.note, timezone, { styled: true, warning: true })}</td
|
|
2094
|
+
<td class="Comments">${templateUtilities.renderNotes(allergy.note, timezone, { styled: true, warning: true })}</td>
|
|
2095
|
+
<td class="Source">${templateUtilities.getOwnerTag(allergy)}</td>`;
|
|
2017
2096
|
if (includeResolved) {
|
|
2018
2097
|
let endDate = "";
|
|
2019
2098
|
if (allergy.extension && Array.isArray(allergy.extension)) {
|
|
@@ -2069,6 +2148,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2069
2148
|
<th>Sig</th>
|
|
2070
2149
|
<th>Days of Supply</th>
|
|
2071
2150
|
<th>Start Date</th>
|
|
2151
|
+
<th>Source</th>
|
|
2072
2152
|
</tr>
|
|
2073
2153
|
</thead>
|
|
2074
2154
|
<tbody>`;
|
|
@@ -2097,6 +2177,9 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2097
2177
|
case "Authored On Date":
|
|
2098
2178
|
data["startDate"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
2099
2179
|
break;
|
|
2180
|
+
case "Source":
|
|
2181
|
+
data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
2182
|
+
break;
|
|
2100
2183
|
default:
|
|
2101
2184
|
break;
|
|
2102
2185
|
}
|
|
@@ -2124,6 +2207,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2124
2207
|
<td>${templateUtilities.renderTextAsHtml(data["sig-prescriber"] || data["sig-pharmacy"])}</td>
|
|
2125
2208
|
<td>${templateUtilities.renderTextAsHtml(data["daysOfSupply"])}</td>
|
|
2126
2209
|
<td>${templateUtilities.renderTime(data["startDate"], timezone)}</td>
|
|
2210
|
+
<td>${data["source"] ?? ""}</td>
|
|
2127
2211
|
</tr>`;
|
|
2128
2212
|
}
|
|
2129
2213
|
}
|
|
@@ -2249,6 +2333,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2249
2333
|
<th>Sig</th>
|
|
2250
2334
|
<th>Dispense Quantity</th>
|
|
2251
2335
|
<th>Start Date</th>
|
|
2336
|
+
<th>Source</th>
|
|
2252
2337
|
</tr>
|
|
2253
2338
|
</thead>
|
|
2254
2339
|
<tbody>`;
|
|
@@ -2307,6 +2392,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2307
2392
|
<td>${sig}</td>
|
|
2308
2393
|
<td>${dispenseQuantity}</td>
|
|
2309
2394
|
<td>${startDate}</td>
|
|
2395
|
+
<td>${templateUtilities.getOwnerTag(medication.resource)}</td>
|
|
2310
2396
|
</tr>`;
|
|
2311
2397
|
}
|
|
2312
2398
|
html += `
|
|
@@ -2351,6 +2437,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2351
2437
|
<th>Code (System)</th>
|
|
2352
2438
|
<th>Status</th>
|
|
2353
2439
|
<th>Date</th>
|
|
2440
|
+
<th>Source</th>
|
|
2354
2441
|
</tr>
|
|
2355
2442
|
</thead>
|
|
2356
2443
|
<tbody>`;
|
|
@@ -2370,6 +2457,9 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2370
2457
|
case "occurrenceDateTime":
|
|
2371
2458
|
data["occurrenceDateTime"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
2372
2459
|
break;
|
|
2460
|
+
case "Source":
|
|
2461
|
+
data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
2462
|
+
break;
|
|
2373
2463
|
default:
|
|
2374
2464
|
break;
|
|
2375
2465
|
}
|
|
@@ -2385,6 +2475,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2385
2475
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
2386
2476
|
<td>${data["status"] ?? ""}</td>
|
|
2387
2477
|
<td>${templateUtilities.renderTime(data["occurrenceDateTime"], timezone) ?? ""}</td>
|
|
2478
|
+
<td>${data["source"] ?? ""}</td>
|
|
2388
2479
|
</tr>`;
|
|
2389
2480
|
}
|
|
2390
2481
|
}
|
|
@@ -2415,6 +2506,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2415
2506
|
<th>Lot Number</th>
|
|
2416
2507
|
<th>Comments</th>
|
|
2417
2508
|
<th>Date</th>
|
|
2509
|
+
<th>Source</th>
|
|
2418
2510
|
</tr>
|
|
2419
2511
|
</thead>
|
|
2420
2512
|
<tbody>`;
|
|
@@ -2436,6 +2528,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2436
2528
|
<td>${imm.lotNumber || ""}</td>
|
|
2437
2529
|
<td>${templateUtilities.renderNotes(imm.note, timezone)}</td>
|
|
2438
2530
|
<td>${templateUtilities.renderTime(imm.occurrenceDateTime, timezone)}</td>
|
|
2531
|
+
<td>${templateUtilities.getOwnerTag(imm)}</td>
|
|
2439
2532
|
</tr>`;
|
|
2440
2533
|
}
|
|
2441
2534
|
}
|
|
@@ -2476,6 +2569,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
|
|
|
2476
2569
|
<th>Is Chronic</th>
|
|
2477
2570
|
<th>Onset Date</th>
|
|
2478
2571
|
<th>Last Confirmed Date</th>
|
|
2572
|
+
<th>Source</th>
|
|
2479
2573
|
</tr>
|
|
2480
2574
|
</thead>
|
|
2481
2575
|
<tbody>`;
|
|
@@ -2500,6 +2594,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
|
|
|
2500
2594
|
<td>${data["Is Chronic"] ?? ""}</td>
|
|
2501
2595
|
<td>${templateUtilities.renderTime(data["Onset Date"], timezone) ?? ""}</td>
|
|
2502
2596
|
<td>${templateUtilities.renderTime(data["Last Confirmed Date"], timezone) ?? ""}</td>
|
|
2597
|
+
<td>${data["Source"] ?? ""}</td>
|
|
2503
2598
|
</tr>`;
|
|
2504
2599
|
}
|
|
2505
2600
|
}
|
|
@@ -2538,6 +2633,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
|
|
|
2538
2633
|
<th>Code (System)</th>
|
|
2539
2634
|
<th>Onset Date</th>
|
|
2540
2635
|
<th>Recorded Date</th>
|
|
2636
|
+
<th>Source</th>
|
|
2541
2637
|
</tr>
|
|
2542
2638
|
</thead>
|
|
2543
2639
|
<tbody>`;
|
|
@@ -2557,6 +2653,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
|
|
|
2557
2653
|
<td class="CodeSystem">${codeAndSystem}</td>
|
|
2558
2654
|
<td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
|
|
2559
2655
|
<td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
|
|
2656
|
+
<td class="Source">${templateUtilities.getOwnerTag(cond)}</td>
|
|
2560
2657
|
</tr>`;
|
|
2561
2658
|
}
|
|
2562
2659
|
html += `</tbody>
|
|
@@ -2596,6 +2693,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2596
2693
|
<th>Code (System)</th>
|
|
2597
2694
|
<th>Result</th>
|
|
2598
2695
|
<th>Date</th>
|
|
2696
|
+
<th>Source</th>
|
|
2599
2697
|
</tr>
|
|
2600
2698
|
</thead>
|
|
2601
2699
|
<tbody>`;
|
|
@@ -2638,6 +2736,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2638
2736
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
2639
2737
|
<td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
|
|
2640
2738
|
<td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
|
|
2739
|
+
<td>${data["Source"] ?? ""}</td>
|
|
2641
2740
|
</tr>`;
|
|
2642
2741
|
}
|
|
2643
2742
|
}
|
|
@@ -2675,6 +2774,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2675
2774
|
<th>Component(s)</th>
|
|
2676
2775
|
<th>Comments</th>
|
|
2677
2776
|
<th>Date</th>
|
|
2777
|
+
<th>Source</th>
|
|
2678
2778
|
</tr>
|
|
2679
2779
|
</thead>
|
|
2680
2780
|
<tbody>`;
|
|
@@ -2693,6 +2793,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2693
2793
|
<td>${templateUtilities.renderComponent(obs.component)}</td>
|
|
2694
2794
|
<td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
|
|
2695
2795
|
<td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
|
|
2796
|
+
<td>${templateUtilities.getOwnerTag(obs)}</td>
|
|
2696
2797
|
</tr>`;
|
|
2697
2798
|
}
|
|
2698
2799
|
html += `
|
|
@@ -2729,6 +2830,7 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
|
|
|
2729
2830
|
<th>Status</th>
|
|
2730
2831
|
<th>Comments</th>
|
|
2731
2832
|
<th>Date Recorded</th>
|
|
2833
|
+
<th>Source</th>
|
|
2732
2834
|
</tr>
|
|
2733
2835
|
</thead>
|
|
2734
2836
|
<tbody>`;
|
|
@@ -2750,6 +2852,7 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
|
|
|
2750
2852
|
<td>${templateUtilities.renderTextAsHtml(dus.status || "")}</td>
|
|
2751
2853
|
<td>${templateUtilities.renderNotes(dus.note, timezone)}</td>
|
|
2752
2854
|
<td>${templateUtilities.renderTextAsHtml(templateUtilities.renderRecorded(dus.recordedOn, timezone))}</td>
|
|
2855
|
+
<td>${templateUtilities.getOwnerTag(dus)}</td>
|
|
2753
2856
|
</tr>`;
|
|
2754
2857
|
}
|
|
2755
2858
|
html += `
|
|
@@ -2902,6 +3005,9 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
2902
3005
|
case "effectivePeriod.end":
|
|
2903
3006
|
targetData["effectivePeriodEnd"] = templateUtilities.renderTextAsHtml(column.text?.div ?? "");
|
|
2904
3007
|
break;
|
|
3008
|
+
case "Source":
|
|
3009
|
+
targetData["source"] = templateUtilities.renderTextAsHtml(column.text?.div ?? "");
|
|
3010
|
+
break;
|
|
2905
3011
|
// valueQuantity
|
|
2906
3012
|
case "valueQuantity.value":
|
|
2907
3013
|
targetData["value"] = templateUtilities.renderTextAsHtml(column.text?.div ?? "");
|
|
@@ -3120,6 +3226,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3120
3226
|
<th>Result</th>
|
|
3121
3227
|
<th>Reference Range</th>
|
|
3122
3228
|
<th>Date</th>
|
|
3229
|
+
<th>Source</th>
|
|
3123
3230
|
</tr>
|
|
3124
3231
|
</thead>
|
|
3125
3232
|
<tbody>`;
|
|
@@ -3133,6 +3240,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3133
3240
|
<th>Report</th>
|
|
3134
3241
|
<th>Performer</th>
|
|
3135
3242
|
<th>Issued</th>
|
|
3243
|
+
<th>Source</th>
|
|
3136
3244
|
</tr>
|
|
3137
3245
|
</thead>
|
|
3138
3246
|
<tbody>`;
|
|
@@ -3179,6 +3287,8 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3179
3287
|
case "Status":
|
|
3180
3288
|
data["status"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
3181
3289
|
break;
|
|
3290
|
+
case "Source":
|
|
3291
|
+
data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
|
|
3182
3292
|
break;
|
|
3183
3293
|
default:
|
|
3184
3294
|
break;
|
|
@@ -3216,6 +3326,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3216
3326
|
<td>${templateUtilities.renderTextAsHtml(component["formattedValue"]) ?? ""}</td>
|
|
3217
3327
|
<td>${templateUtilities.renderTextAsHtml(component["referenceRange"])?.trim() ?? ""}</td>
|
|
3218
3328
|
<td>${date ?? ""}</td>
|
|
3329
|
+
<td>${data["source"] ?? ""}</td>
|
|
3219
3330
|
</tr>`;
|
|
3220
3331
|
}
|
|
3221
3332
|
}
|
|
@@ -3235,6 +3346,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3235
3346
|
<td>${templateUtilities.renderTextAsHtml(data["formattedValue"]) ?? ""}</td>
|
|
3236
3347
|
<td>${templateUtilities.renderTextAsHtml(data["referenceRange"])?.trim() ?? ""}</td>
|
|
3237
3348
|
<td>${date ?? ""}</td>
|
|
3349
|
+
<td>${data["source"] ?? ""}</td>
|
|
3238
3350
|
</tr>`;
|
|
3239
3351
|
}
|
|
3240
3352
|
}
|
|
@@ -3256,6 +3368,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3256
3368
|
<td>${templateUtilities.capitalizeFirstLetter(data["report"] ?? "")}</td>
|
|
3257
3369
|
<td>${data["performer"] ?? ""}</td>
|
|
3258
3370
|
<td>${templateUtilities.renderTime(data["issued"], timezone) ?? ""}</td>
|
|
3371
|
+
<td>${data["source"] ?? ""}</td>
|
|
3259
3372
|
</tr>`;
|
|
3260
3373
|
}
|
|
3261
3374
|
}
|
|
@@ -3440,6 +3553,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3440
3553
|
<th>Result</th>
|
|
3441
3554
|
<th>Reference Range</th>
|
|
3442
3555
|
<th>Date</th>
|
|
3556
|
+
<th>Source</th>
|
|
3443
3557
|
</tr>
|
|
3444
3558
|
</thead>
|
|
3445
3559
|
<tbody>`;
|
|
@@ -3460,6 +3574,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3460
3574
|
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
3461
3575
|
<td>${templateUtilities.concatReferenceRange(obs.referenceRange)}</td>
|
|
3462
3576
|
<td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
|
|
3577
|
+
<td>${templateUtilities.getOwnerTag(obs)}</td>
|
|
3463
3578
|
</tr>`;
|
|
3464
3579
|
}
|
|
3465
3580
|
}
|
|
@@ -3486,6 +3601,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3486
3601
|
<th>Category</th>
|
|
3487
3602
|
<th>Result</th>
|
|
3488
3603
|
<th>Issued</th>
|
|
3604
|
+
<th>Source</th>
|
|
3489
3605
|
</tr>
|
|
3490
3606
|
</thead>
|
|
3491
3607
|
<tbody>`;
|
|
@@ -3510,6 +3626,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3510
3626
|
<td>${templateUtilities.firstFromCodeableConceptList(report.category)}</td>
|
|
3511
3627
|
<td>${resultCount}</td>
|
|
3512
3628
|
<td>${report.issued ? templateUtilities.renderTime(report.issued, timezone) : ""}</td>
|
|
3629
|
+
<td>${templateUtilities.getOwnerTag(report)}</td>
|
|
3513
3630
|
</tr>`;
|
|
3514
3631
|
}
|
|
3515
3632
|
}
|
|
@@ -3576,6 +3693,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3576
3693
|
<th>Code (System)</th>
|
|
3577
3694
|
<th>Performer</th>
|
|
3578
3695
|
<th>Date</th>
|
|
3696
|
+
<th>Source</th>
|
|
3579
3697
|
</tr>
|
|
3580
3698
|
</thead>
|
|
3581
3699
|
<tbody>`;
|
|
@@ -3595,6 +3713,8 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3595
3713
|
case "Performed Date":
|
|
3596
3714
|
data["date"] = columnData.text?.div ?? "";
|
|
3597
3715
|
break;
|
|
3716
|
+
case "Source":
|
|
3717
|
+
data["source"] = columnData.text?.div ?? "";
|
|
3598
3718
|
break;
|
|
3599
3719
|
default:
|
|
3600
3720
|
break;
|
|
@@ -3610,6 +3730,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3610
3730
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
3611
3731
|
<td>${data["performer"] ?? ""}</td>
|
|
3612
3732
|
<td>${templateUtilities.renderTime(data["date"], timezone) ?? ""}</td>
|
|
3733
|
+
<td>${data["source"] ?? ""}</td>
|
|
3613
3734
|
</tr>`;
|
|
3614
3735
|
}
|
|
3615
3736
|
}
|
|
@@ -3637,6 +3758,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3637
3758
|
<th>Code (System)</th>
|
|
3638
3759
|
<th>Comments</th>
|
|
3639
3760
|
<th>Date</th>
|
|
3761
|
+
<th>Source</th>
|
|
3640
3762
|
</tr>
|
|
3641
3763
|
</thead>
|
|
3642
3764
|
<tbody>`;
|
|
@@ -3652,6 +3774,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3652
3774
|
<td>${templateUtilities.codeableConceptCoding(proc.code)}</td>
|
|
3653
3775
|
<td>${templateUtilities.renderNotes(proc.note, timezone)}</td>
|
|
3654
3776
|
<td>${templateUtilities.renderTime(proc.performedDateTime || proc.performedPeriod?.start, timezone)}</td>
|
|
3777
|
+
<td>${templateUtilities.getOwnerTag(proc)}</td>
|
|
3655
3778
|
</tr>`;
|
|
3656
3779
|
}
|
|
3657
3780
|
html += `
|
|
@@ -3693,6 +3816,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
|
|
|
3693
3816
|
<th>Result</th>
|
|
3694
3817
|
<th>Date</th>
|
|
3695
3818
|
<th>Comments</th>
|
|
3819
|
+
<th>Source</th>
|
|
3696
3820
|
</tr>
|
|
3697
3821
|
</thead>
|
|
3698
3822
|
<tbody>`;
|
|
@@ -3718,6 +3842,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
|
|
|
3718
3842
|
<td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
|
|
3719
3843
|
<td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
|
|
3720
3844
|
<td>${data["Notes"] ?? ""}</td>
|
|
3845
|
+
<td>${data["Source"] ?? ""}</td>
|
|
3721
3846
|
</tr>`;
|
|
3722
3847
|
}
|
|
3723
3848
|
}
|
|
@@ -3753,6 +3878,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
|
|
|
3753
3878
|
<th>Unit</th>
|
|
3754
3879
|
<th>Comments</th>
|
|
3755
3880
|
<th>Date</th>
|
|
3881
|
+
<th>Source</th>
|
|
3756
3882
|
</tr>
|
|
3757
3883
|
</thead>
|
|
3758
3884
|
<tbody>`;
|
|
@@ -3772,6 +3898,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
|
|
|
3772
3898
|
<td>${templateUtilities.extractObservationValueUnit(obs)}</td>
|
|
3773
3899
|
<td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
|
|
3774
3900
|
<td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
|
|
3901
|
+
<td>${templateUtilities.getOwnerTag(obs)}</td>
|
|
3775
3902
|
</tr>`;
|
|
3776
3903
|
}
|
|
3777
3904
|
}
|
|
@@ -3822,6 +3949,7 @@ var PastHistoryOfIllnessTemplate = class {
|
|
|
3822
3949
|
<th>Onset Date</th>
|
|
3823
3950
|
<th>Recorded Date</th>
|
|
3824
3951
|
<th>Resolved Date</th>
|
|
3952
|
+
<th>Source</th>
|
|
3825
3953
|
</tr>
|
|
3826
3954
|
</thead>
|
|
3827
3955
|
<tbody>`;
|
|
@@ -3839,6 +3967,7 @@ var PastHistoryOfIllnessTemplate = class {
|
|
|
3839
3967
|
<td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
|
|
3840
3968
|
<td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
|
|
3841
3969
|
<td class="ResolvedDate">${templateUtilities.renderDate(cond.abatementDateTime)}</td>
|
|
3970
|
+
<td class="Source">${templateUtilities.getOwnerTag(cond)}</td>
|
|
3842
3971
|
</tr>`;
|
|
3843
3972
|
}
|
|
3844
3973
|
}
|
|
@@ -3874,6 +4003,7 @@ var PastHistoryOfIllnessTemplate = class {
|
|
|
3874
4003
|
<th>Onset Date</th>
|
|
3875
4004
|
<th>Last Confirmed Date</th>
|
|
3876
4005
|
<th>Resolved Date</th>
|
|
4006
|
+
<th>Source</th>
|
|
3877
4007
|
</tr>
|
|
3878
4008
|
</thead>
|
|
3879
4009
|
<tbody>`;
|
|
@@ -3903,6 +4033,7 @@ var PastHistoryOfIllnessTemplate = class {
|
|
|
3903
4033
|
<td>${templateUtilities.renderTime(data["Onset Date"], timezone) ?? ""}</td>
|
|
3904
4034
|
<td>${templateUtilities.renderTime(data["Last Confirmed Date"], timezone) ?? ""}</td>
|
|
3905
4035
|
<td>${templateUtilities.renderTime(data["Resolved Date"], timezone) ?? ""}</td>
|
|
4036
|
+
<td>${data["Source"] ?? ""}</td>
|
|
3906
4037
|
</tr>`;
|
|
3907
4038
|
}
|
|
3908
4039
|
}
|
|
@@ -3946,6 +4077,7 @@ var PlanOfCareTemplate = class {
|
|
|
3946
4077
|
<th>Comments</th>
|
|
3947
4078
|
<th>Planned Start</th>
|
|
3948
4079
|
<th>Planned End</th>
|
|
4080
|
+
<th>Source</th>
|
|
3949
4081
|
</tr>
|
|
3950
4082
|
</thead>
|
|
3951
4083
|
<tbody>`;
|
|
@@ -3961,6 +4093,7 @@ var PlanOfCareTemplate = class {
|
|
|
3961
4093
|
<td>${templateUtilities.concat(cp.note, "text")}</td>
|
|
3962
4094
|
<td>${cp.period?.start ? templateUtilities.renderTime(cp.period?.start, timezone) : ""}</td>
|
|
3963
4095
|
<td>${cp.period?.end ? templateUtilities.renderTime(cp.period?.end, timezone) : ""}</td>
|
|
4096
|
+
<td>${templateUtilities.getOwnerTag(cp)}</td>
|
|
3964
4097
|
</tr>`;
|
|
3965
4098
|
}
|
|
3966
4099
|
html += `
|
|
@@ -3988,6 +4121,7 @@ var PlanOfCareTemplate = class {
|
|
|
3988
4121
|
<th>Created</th>
|
|
3989
4122
|
<th>Planned Start</th>
|
|
3990
4123
|
<th>Planned End</th>
|
|
4124
|
+
<th>Source</th>
|
|
3991
4125
|
</tr>
|
|
3992
4126
|
</thead>
|
|
3993
4127
|
<tbody>`;
|
|
@@ -4012,6 +4146,7 @@ var PlanOfCareTemplate = class {
|
|
|
4012
4146
|
<td>${templateUtilities.renderTime(data["created"], timezone) ?? ""}</td>
|
|
4013
4147
|
<td>${templateUtilities.renderTime(data["period.start"], timezone) ?? ""}</td>
|
|
4014
4148
|
<td>${templateUtilities.renderTime(data["period.end"], timezone) ?? ""}</td>
|
|
4149
|
+
<td>${data["Source"] ?? ""}</td>
|
|
4015
4150
|
</tr>`;
|
|
4016
4151
|
}
|
|
4017
4152
|
}
|
|
@@ -4027,7 +4162,7 @@ var PlanOfCareTemplate = class {
|
|
|
4027
4162
|
var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
4028
4163
|
/**
|
|
4029
4164
|
* Generate HTML narrative for Functional Status
|
|
4030
|
-
* @param resources - FHIR resources array containing
|
|
4165
|
+
* @param resources - FHIR resources array containing Condition and ClinicalImpression resources
|
|
4031
4166
|
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
4032
4167
|
* @returns HTML string for rendering
|
|
4033
4168
|
*/
|
|
@@ -4056,6 +4191,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
4056
4191
|
<th>Code (System)</th>
|
|
4057
4192
|
<th>Onset Date</th>
|
|
4058
4193
|
<th>Recorded Date</th>
|
|
4194
|
+
<th>Source</th>
|
|
4059
4195
|
</tr>
|
|
4060
4196
|
</thead>
|
|
4061
4197
|
<tbody>`;
|
|
@@ -4066,10 +4202,11 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
4066
4202
|
<thead>
|
|
4067
4203
|
<tr>
|
|
4068
4204
|
<th>Name</th>
|
|
4069
|
-
<th>Date</th>
|
|
4070
4205
|
<th>Code (System)</th>
|
|
4206
|
+
<th>Date</th>
|
|
4071
4207
|
<th>Description</th>
|
|
4072
4208
|
<th>Summary</th>
|
|
4209
|
+
<th>Source</th>
|
|
4073
4210
|
</tr>
|
|
4074
4211
|
</thead>
|
|
4075
4212
|
<tbody>`;
|
|
@@ -4109,6 +4246,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
4109
4246
|
<td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
|
|
4110
4247
|
<td>${date}</td>
|
|
4111
4248
|
<td>${templateUtilities.renderTime(data["recordedDate"], timezone) ?? ""}</td>
|
|
4249
|
+
<td>${data["Source"] ?? ""}</td>
|
|
4112
4250
|
</tr>`;
|
|
4113
4251
|
}
|
|
4114
4252
|
} else if (resourceItem.title === "Clinical Impression|Clinical Impression Summary") {
|
|
@@ -4131,10 +4269,11 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
4131
4269
|
clinicalImpressionsHtml += `
|
|
4132
4270
|
<tr>
|
|
4133
4271
|
<td>${templateUtilities.capitalizeFirstLetter(name)}</td>
|
|
4134
|
-
<td>${date ?? ""}</td>
|
|
4135
4272
|
<td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
|
|
4273
|
+
<td>${date ?? ""}</td>
|
|
4136
4274
|
<td>${data["Description"] ?? ""}</td>
|
|
4137
4275
|
<td>${data["Summary"] ?? ""}</td>
|
|
4276
|
+
<td>${data["Source"] ?? ""}</td>
|
|
4138
4277
|
</tr>`;
|
|
4139
4278
|
}
|
|
4140
4279
|
}
|
|
@@ -4160,90 +4299,156 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
4160
4299
|
}
|
|
4161
4300
|
/**
|
|
4162
4301
|
* Internal static implementation that actually generates the narrative
|
|
4163
|
-
* @param resources - FHIR resources array containing
|
|
4302
|
+
* @param resources - FHIR resources array containing Condition and ClinicalImpression resources
|
|
4164
4303
|
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
4165
4304
|
* @returns HTML string for rendering
|
|
4166
4305
|
*/
|
|
4167
4306
|
static generateStaticNarrative(resources, timezone) {
|
|
4168
4307
|
const templateUtilities = new TemplateUtilities(resources);
|
|
4169
|
-
let html = `<
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
let
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4308
|
+
let html = `<div>
|
|
4309
|
+
<p>This section summarizes key conditions and assessments related to the person's functional status and ability to perform daily activities.</p>`;
|
|
4310
|
+
let conditionHtml = `
|
|
4311
|
+
<div>
|
|
4312
|
+
<h3>Conditions</h3>
|
|
4313
|
+
<table>
|
|
4314
|
+
<thead>
|
|
4315
|
+
<tr>
|
|
4316
|
+
<th>Problem</th>
|
|
4317
|
+
<th>Code (System)</th>
|
|
4318
|
+
<th>Onset Date</th>
|
|
4319
|
+
<th>Recorded Date</th>
|
|
4320
|
+
<th>Source</th>
|
|
4321
|
+
</tr>
|
|
4322
|
+
</thead>
|
|
4323
|
+
<tbody>`;
|
|
4324
|
+
let clinicalImpressionsHtml = `
|
|
4325
|
+
<div>
|
|
4326
|
+
<h3>Clinical Impressions</h3>
|
|
4327
|
+
<table>
|
|
4328
|
+
<thead>
|
|
4329
|
+
<tr>
|
|
4330
|
+
<th>Name</th>
|
|
4331
|
+
<th>Code (System)</th>
|
|
4332
|
+
<th>Date</th>
|
|
4333
|
+
<th>Description</th>
|
|
4334
|
+
<th>Summary</th>
|
|
4335
|
+
<th>Source</th>
|
|
4336
|
+
</tr>
|
|
4337
|
+
</thead>
|
|
4338
|
+
<tbody>`;
|
|
4339
|
+
const conditions = resources.filter((entry) => entry.resourceType === "Condition").map((entry) => entry);
|
|
4340
|
+
conditions.sort((a, b) => {
|
|
4341
|
+
const dateA = a.recordedDate ? new Date(a.recordedDate).getTime() : 0;
|
|
4342
|
+
const dateB = b.recordedDate ? new Date(b.recordedDate).getTime() : 0;
|
|
4343
|
+
return dateB - dateA;
|
|
4189
4344
|
});
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4345
|
+
const addedConditions = /* @__PURE__ */ new Set();
|
|
4346
|
+
for (const cond of conditions) {
|
|
4347
|
+
const functionalStatusName = this.getFunctionalStatusNameFromCode(cond.code);
|
|
4348
|
+
const problem = templateUtilities.codeableConceptDisplay(cond.code) || functionalStatusName;
|
|
4349
|
+
const codeAndSystem = templateUtilities.codeableConceptCoding(cond.code);
|
|
4350
|
+
if (!codeAndSystem || !problem || !functionalStatusName || addedConditions.has(functionalStatusName)) {
|
|
4351
|
+
continue;
|
|
4352
|
+
}
|
|
4353
|
+
if (problem?.toLowerCase() === "unknown") {
|
|
4354
|
+
continue;
|
|
4355
|
+
}
|
|
4356
|
+
addedConditions.add(functionalStatusName);
|
|
4357
|
+
let date = cond.onsetDateTime ? templateUtilities.renderTime(cond.onsetDateTime, timezone) : "";
|
|
4358
|
+
if (!date && cond.onsetPeriod?.start) {
|
|
4359
|
+
date = templateUtilities.renderTime(
|
|
4360
|
+
cond.onsetPeriod?.start,
|
|
4361
|
+
timezone
|
|
4362
|
+
);
|
|
4363
|
+
if (cond.onsetPeriod?.end) {
|
|
4364
|
+
date += " - " + templateUtilities.renderTime(cond.onsetPeriod?.end, timezone);
|
|
4197
4365
|
}
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
html += `<tr>
|
|
4203
|
-
<td>${templateUtilities.capitalizeFirstLetter(obsName)}</td>
|
|
4204
|
-
<td>${value ?? ""}</td>
|
|
4366
|
+
}
|
|
4367
|
+
conditionHtml += `<tr>
|
|
4368
|
+
<td>${templateUtilities.capitalizeFirstLetter(problem)}</td>
|
|
4369
|
+
<td>${codeAndSystem}</td>
|
|
4205
4370
|
<td>${date}</td>
|
|
4206
|
-
<td>${
|
|
4207
|
-
<td>${
|
|
4371
|
+
<td>${templateUtilities.renderTime(cond.recordedDate, timezone)}</td>
|
|
4372
|
+
<td>${templateUtilities.getOwnerTag(cond)}</td>
|
|
4208
4373
|
</tr>`;
|
|
4374
|
+
}
|
|
4375
|
+
const clinicalImpressions = resources.filter((entry) => entry.resourceType === "ClinicalImpression").map((entry) => entry);
|
|
4376
|
+
clinicalImpressions.sort((a, b) => {
|
|
4377
|
+
const dateA = this.getClinicalImpressionEffectiveDate(a);
|
|
4378
|
+
const dateB = this.getClinicalImpressionEffectiveDate(b);
|
|
4379
|
+
return dateB && dateA ? dateB.getTime() - dateA.getTime() : 0;
|
|
4380
|
+
});
|
|
4381
|
+
const addedClinicalImpressions = /* @__PURE__ */ new Set();
|
|
4382
|
+
for (const impression of clinicalImpressions) {
|
|
4383
|
+
const name = templateUtilities.codeableConceptDisplay(impression.code);
|
|
4384
|
+
const codeAndSystem = templateUtilities.codeableConceptCoding(impression.code);
|
|
4385
|
+
if (!codeAndSystem || addedClinicalImpressions.has(name)) {
|
|
4386
|
+
continue;
|
|
4209
4387
|
}
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
}
|
|
4223
|
-
let findingsHtml = "";
|
|
4224
|
-
if (impression.finding && impression.finding.length > 0) {
|
|
4225
|
-
findingsHtml = "<ul>";
|
|
4226
|
-
for (const finding of impression.finding) {
|
|
4227
|
-
const findingText = finding.itemCodeableConcept ? templateUtilities.codeableConceptDisplay(finding.itemCodeableConcept) : finding.itemReference ? templateUtilities.renderReference(finding.itemReference) : "";
|
|
4228
|
-
const cause = finding.basis || "";
|
|
4229
|
-
findingsHtml += `<li>${findingText}${cause ? ` - ${cause}` : ""}</li>`;
|
|
4230
|
-
}
|
|
4231
|
-
findingsHtml += "</ul>";
|
|
4388
|
+
if (!name || name?.toLowerCase() === "unknown") {
|
|
4389
|
+
continue;
|
|
4390
|
+
}
|
|
4391
|
+
addedClinicalImpressions.add(name);
|
|
4392
|
+
let date = impression.effectiveDateTime ? templateUtilities.renderTime(impression.effectiveDateTime, timezone) : "";
|
|
4393
|
+
if (!date && impression.effectivePeriod?.start) {
|
|
4394
|
+
date = templateUtilities.renderTime(
|
|
4395
|
+
impression.effectivePeriod?.start,
|
|
4396
|
+
timezone
|
|
4397
|
+
);
|
|
4398
|
+
if (impression.effectivePeriod?.end) {
|
|
4399
|
+
date += " - " + templateUtilities.renderTime(impression.effectivePeriod?.end, timezone);
|
|
4232
4400
|
}
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
<td>${
|
|
4401
|
+
}
|
|
4402
|
+
clinicalImpressionsHtml += `<tr>
|
|
4403
|
+
<td>${templateUtilities.capitalizeFirstLetter(name)}</td>
|
|
4404
|
+
<td>${codeAndSystem}</td>
|
|
4405
|
+
<td>${date}</td>
|
|
4236
4406
|
<td>${impression.description || ""}</td>
|
|
4237
4407
|
<td>${impression.summary || ""}</td>
|
|
4238
|
-
<td>${
|
|
4408
|
+
<td>${templateUtilities.getOwnerTag(impression)}</td>
|
|
4239
4409
|
</tr>`;
|
|
4410
|
+
}
|
|
4411
|
+
if (addedConditions.size > 0) {
|
|
4412
|
+
html += conditionHtml;
|
|
4413
|
+
html += `
|
|
4414
|
+
</tbody>
|
|
4415
|
+
</table>
|
|
4416
|
+
</div>`;
|
|
4417
|
+
}
|
|
4418
|
+
if (addedClinicalImpressions.size > 0) {
|
|
4419
|
+
html += clinicalImpressionsHtml;
|
|
4420
|
+
html += `
|
|
4421
|
+
</tbody>
|
|
4422
|
+
</table>
|
|
4423
|
+
</div>`;
|
|
4424
|
+
}
|
|
4425
|
+
html += `
|
|
4426
|
+
</div>`;
|
|
4427
|
+
return addedConditions.size > 0 || addedClinicalImpressions.size > 0 ? html : void 0;
|
|
4428
|
+
}
|
|
4429
|
+
static getFunctionalStatusNameFromCode(cc) {
|
|
4430
|
+
if (!cc) return "";
|
|
4431
|
+
for (const coding of cc.coding || []) {
|
|
4432
|
+
let functionalStatusName = FUNCTIONAL_STATUS_SNOMED_CODES[coding.code];
|
|
4433
|
+
if (functionalStatusName) {
|
|
4434
|
+
return functionalStatusName;
|
|
4435
|
+
}
|
|
4436
|
+
functionalStatusName = FUNCTIONAL_STATUS_ASSESSMENT_LOINC_CODES[coding.code];
|
|
4437
|
+
if (functionalStatusName) {
|
|
4438
|
+
return functionalStatusName;
|
|
4240
4439
|
}
|
|
4241
|
-
html += `</tbody></table>`;
|
|
4242
4440
|
}
|
|
4243
|
-
|
|
4244
|
-
|
|
4441
|
+
}
|
|
4442
|
+
static getClinicalImpressionEffectiveDate(impression) {
|
|
4443
|
+
if (impression.effectiveDateTime) {
|
|
4444
|
+
return new Date(impression.effectiveDateTime);
|
|
4445
|
+
} else if (impression.effectivePeriod) {
|
|
4446
|
+
if (impression.effectivePeriod.start) {
|
|
4447
|
+
return new Date(impression.effectivePeriod.start);
|
|
4448
|
+
} else if (impression.effectivePeriod.end) {
|
|
4449
|
+
return new Date(impression.effectivePeriod.end);
|
|
4450
|
+
}
|
|
4245
4451
|
}
|
|
4246
|
-
return html;
|
|
4247
4452
|
}
|
|
4248
4453
|
};
|
|
4249
4454
|
|
|
@@ -4302,10 +4507,11 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
4302
4507
|
<th>Code (System)</th>
|
|
4303
4508
|
<th>Comments</th>
|
|
4304
4509
|
<th>Date</th>
|
|
4510
|
+
<th>Source</th>
|
|
4305
4511
|
</tr>
|
|
4306
4512
|
</thead>
|
|
4307
4513
|
<tbody>`;
|
|
4308
|
-
function renderRow({ result, comments, date, codeSystem }) {
|
|
4514
|
+
function renderRow({ result, comments, date, codeSystem, resource }) {
|
|
4309
4515
|
if (result?.toLowerCase() === "unknown") {
|
|
4310
4516
|
return;
|
|
4311
4517
|
}
|
|
@@ -4315,6 +4521,7 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
4315
4521
|
<td class="CodeSystem">${codeSystem}</td>
|
|
4316
4522
|
<td class="Comments">${comments}</td>
|
|
4317
4523
|
<td class="Date">${date}</td>
|
|
4524
|
+
<td class="Source">${templateUtilities.getOwnerTag(resource)}</td>
|
|
4318
4525
|
</tr>`;
|
|
4319
4526
|
}
|
|
4320
4527
|
const rowResources = [];
|
|
@@ -4368,7 +4575,7 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
4368
4575
|
const rowKey = `${result}|${codeSystem}`;
|
|
4369
4576
|
if (!addedRows.has(rowKey)) {
|
|
4370
4577
|
addedRows.add(rowKey);
|
|
4371
|
-
renderRow({ result, comments, date: dateStr, codeSystem });
|
|
4578
|
+
renderRow({ result, comments, date: dateStr, codeSystem, resource });
|
|
4372
4579
|
}
|
|
4373
4580
|
}
|
|
4374
4581
|
html += `
|
|
@@ -4412,6 +4619,7 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
|
|
|
4412
4619
|
<th>Status</th>
|
|
4413
4620
|
<th>Action Controlled</th>
|
|
4414
4621
|
<th>Date</th>
|
|
4622
|
+
<th>Source</th>
|
|
4415
4623
|
</tr>
|
|
4416
4624
|
</thead>
|
|
4417
4625
|
<tbody>`;
|
|
@@ -4429,6 +4637,7 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
|
|
|
4429
4637
|
<td>${consent.status || ""}</td>
|
|
4430
4638
|
<td>${consent.provision?.action ? templateUtilities.concatCodeableConcept(consent.provision.action) : ""}</td>
|
|
4431
4639
|
<td>${consent.dateTime || ""}</td>
|
|
4640
|
+
<td>${templateUtilities.getOwnerTag(consent)}</td>
|
|
4432
4641
|
</tr>`;
|
|
4433
4642
|
}
|
|
4434
4643
|
html += `
|