@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.
Files changed (3) hide show
  1. package/dist/index.cjs +287 -78
  2. package/dist/index.js +287 -78
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -110,6 +110,67 @@ var ESSENTIAL_LAB_PANELS = {
110
110
  "80235-8": "Cardiac Markers Panel",
111
111
  "69738-3": "CBC with Auto Differential"
112
112
  };
113
+ var FUNCTIONAL_STATUS_SNOMED_CODES = {
114
+ "118233009": "Core Functional Status",
115
+ "364644000": "Core Functional Status",
116
+ "160245001": "Core Functional Status",
117
+ "21134002": "Disability & Impairment",
118
+ "2655002": "Disability & Impairment",
119
+ "2219003": "Disability & Impairment",
120
+ "962000": "Disability & Impairment",
121
+ "3089009": "Disability & Impairment",
122
+ "4197006": "Disability & Impairment",
123
+ "284545001": "Activities of Daily Living",
124
+ "719930002": "Activities of Daily Living",
125
+ "301438001": "Activities of Daily Living",
126
+ "282145008": "Mobility & Movement",
127
+ "165245003": "Mobility & Movement",
128
+ "713458007": "Mobility & Movement"
129
+ };
130
+ var FUNCTIONAL_STATUS_ASSESSMENT_LOINC_CODES = {
131
+ "54522-8": "Functional Status Panel",
132
+ "54523-6": "ADL Assistance",
133
+ "45588-1": "Bed Mobility",
134
+ "45589-9": "Bed Mobility",
135
+ "45590-7": "Transfer",
136
+ "45591-5": "Transfer",
137
+ "45592-3": "Walk in room",
138
+ "45593-1": "Walk in room",
139
+ "45594-9": "Walk in corridor",
140
+ "45595-6": "Walk in corridor",
141
+ "45596-4": "Locomotion on unit",
142
+ "45597-2": "Locomotion on unit",
143
+ "45598-0": "Locomotion off unit",
144
+ "45599-8": "Locomotion off unit",
145
+ "45600-4": "Dressing",
146
+ "45601-2": "Dressing",
147
+ "45602-0": "Eating",
148
+ "45603-8": "Eating",
149
+ "45604-6": "Toilet use",
150
+ "45605-3": "Toilet use",
151
+ "45606-1": "Personal hygiene",
152
+ "45607-9": "Personal hygiene",
153
+ "46008-9": "Bathing",
154
+ "45608-7": "Bathing",
155
+ "45609-5": "Bathing",
156
+ "54524-4": "Balance during Transitions and Walking",
157
+ "54749-7": "Moving from Seated to Standing",
158
+ "54750-5": "Walking with Assistive Device",
159
+ "54751-3": "Turning Around While Walking",
160
+ "54753-9": "Surface-to-Surface Transfer",
161
+ "54525-1": "Functional Limitation in Range of Motion",
162
+ "54754-7": "Upper Extremity ROM",
163
+ "54755-4": "Lower Extremity ROM",
164
+ "54526-9": "Mobility Devices",
165
+ "54756-2": "Cane/Crutch",
166
+ "54757-0": "Walker",
167
+ "54758-8": "Wheelchair",
168
+ "54759-6": "Limb Prosthesis",
169
+ "54760-4": "No Mobility Devices",
170
+ "54527-7": "Functional Rehabilitation Potential",
171
+ "55123-4": "Resident Believes Capable of Increased Independence",
172
+ "45613-7": "Staff Believes Capable of Increased Independence"
173
+ };
113
174
 
114
175
  // src/structures/ips_section_constants.ts
115
176
  var VITAL_SIGNS_SUMMARY_COMPONENT_MAP = {
@@ -145,11 +206,9 @@ var IPSSectionResourceFilters = {
145
206
  ["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Observation" && codeableConceptMatches(resource.code, Object.keys(SOCIAL_HISTORY_LOINC_CODES), "http://loinc.org"),
146
207
  // Only include pregnancy history Observations or relevant Conditions
147
208
  ["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")),
148
- // Only include Observations with LOINC 47420-5, category 'functional-status', or category display containing 'functional', and completed ClinicalImpressions
149
- ["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: (resource) => resource.resourceType === "Observation" && (codeableConceptMatches(resource.code, "47420-5", "http://loinc.org") || resource.category?.some(
150
- (cat) => cat.coding?.some(
151
- (c) => c.code === "functional-status" && c.system === "http://terminology.hl7.org/CodeSystem/observation-category" || typeof c.display === "string" && c.display.toLowerCase().includes("functional")
152
- )
209
+ // Only include Condition with Functional Status LOINC and SNOMED codes, category code 'problem-list-item', and completed ClinicalImpressions
210
+ ["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(
211
+ (cat) => cat.coding?.some((c) => c.code === "problem-list-item")
153
212
  )) || resource.resourceType === "ClinicalImpression" && resource.status === "completed",
154
213
  // Only include resolved medical history Conditions
155
214
  ["HistoryOfPastIllnessSection" /* MEDICAL_HISTORY */]: (resource) => resource.resourceType === "Condition" && resource.clinicalStatus?.coding?.some((c) => ["inactive", "resolved"].includes(c.code)),
@@ -895,6 +954,18 @@ var TemplateUtilities = class {
895
954
  }
896
955
  return "";
897
956
  }
957
+ /**
958
+ * Returns the owner tag from the resource meta.security array.
959
+ * @param resource - FHIR resource with meta tag
960
+ * @returns The owner display or code if found, otherwise undefined
961
+ */
962
+ getOwnerTag(resource) {
963
+ if (!resource?.meta?.security) return "";
964
+ const ownerEntry = resource.meta.security.find(
965
+ (sec) => sec.system === "https://www.icanbwell.com/owner" && !!sec.code
966
+ );
967
+ return ownerEntry?.display || ownerEntry?.code;
968
+ }
898
969
  /**
899
970
  * Public method to render plain text as HTML, escaping special characters and replacing newlines with <br />.
900
971
  * This method should be used whenever displaying user-supplied or FHIR resource text in HTML to prevent XSS vulnerabilities
@@ -1830,6 +1901,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
1830
1901
  <th>Code (System)</th>
1831
1902
  <th>Criticality</th>
1832
1903
  <th>Recorded Date</th>
1904
+ <th>Source</th>
1833
1905
  </tr>
1834
1906
  </thead>
1835
1907
  <tbody>`;
@@ -1849,6 +1921,9 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
1849
1921
  case "Recorded Date":
1850
1922
  data["recordedDate"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
1851
1923
  break;
1924
+ case "Source":
1925
+ data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
1926
+ break;
1852
1927
  default:
1853
1928
  break;
1854
1929
  }
@@ -1863,6 +1938,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
1863
1938
  <td>${data["codeSystem"] ?? ""}</td>
1864
1939
  <td>${data["criticality"] ?? ""}</td>
1865
1940
  <td>${templateUtilities.renderTime(data["recordedDate"], timezone) ?? ""}</td>
1941
+ <td>${data["source"] ?? ""}</td>
1866
1942
  </tr>`;
1867
1943
  }
1868
1944
  }
@@ -1916,6 +1992,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
1916
1992
  <th>Reaction</th>
1917
1993
  <th>Onset Date</th>
1918
1994
  <th>Comments</th>
1995
+ <th>Source</th>
1919
1996
  </tr>
1920
1997
  </thead>
1921
1998
  <tbody>`;
@@ -1945,6 +2022,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
1945
2022
  <th>Onset Date</th>
1946
2023
  <th>Comments</th>
1947
2024
  <th>Resolved Date</th>
2025
+ <th>Source</th>
1948
2026
  </tr>
1949
2027
  </thead>
1950
2028
  <tbody>`;
@@ -1985,7 +2063,8 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
1985
2063
  <td class="Category">${templateUtilities.renderTextAsHtml(templateUtilities.safeConcat(allergy.category)) || ""}</td>
1986
2064
  <td class="Reaction">${templateUtilities.renderTextAsHtml(templateUtilities.concatReactionManifestation(allergy.reaction)) || ""}</td>
1987
2065
  <td class="OnsetDate">${templateUtilities.renderTextAsHtml(templateUtilities.renderTime(allergy.onsetDateTime, timezone)) || ""}</td>
1988
- <td class="Comments">${templateUtilities.renderNotes(allergy.note, timezone, { styled: true, warning: true })}</td>`;
2066
+ <td class="Comments">${templateUtilities.renderNotes(allergy.note, timezone, { styled: true, warning: true })}</td>
2067
+ <td class="Source">${templateUtilities.getOwnerTag(allergy)}</td>`;
1989
2068
  if (includeResolved) {
1990
2069
  let endDate = "";
1991
2070
  if (allergy.extension && Array.isArray(allergy.extension)) {
@@ -2041,6 +2120,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
2041
2120
  <th>Sig</th>
2042
2121
  <th>Days of Supply</th>
2043
2122
  <th>Start Date</th>
2123
+ <th>Source</th>
2044
2124
  </tr>
2045
2125
  </thead>
2046
2126
  <tbody>`;
@@ -2069,6 +2149,9 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
2069
2149
  case "Authored On Date":
2070
2150
  data["startDate"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
2071
2151
  break;
2152
+ case "Source":
2153
+ data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
2154
+ break;
2072
2155
  default:
2073
2156
  break;
2074
2157
  }
@@ -2096,6 +2179,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
2096
2179
  <td>${templateUtilities.renderTextAsHtml(data["sig-prescriber"] || data["sig-pharmacy"])}</td>
2097
2180
  <td>${templateUtilities.renderTextAsHtml(data["daysOfSupply"])}</td>
2098
2181
  <td>${templateUtilities.renderTime(data["startDate"], timezone)}</td>
2182
+ <td>${data["source"] ?? ""}</td>
2099
2183
  </tr>`;
2100
2184
  }
2101
2185
  }
@@ -2221,6 +2305,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
2221
2305
  <th>Sig</th>
2222
2306
  <th>Dispense Quantity</th>
2223
2307
  <th>Start Date</th>
2308
+ <th>Source</th>
2224
2309
  </tr>
2225
2310
  </thead>
2226
2311
  <tbody>`;
@@ -2279,6 +2364,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
2279
2364
  <td>${sig}</td>
2280
2365
  <td>${dispenseQuantity}</td>
2281
2366
  <td>${startDate}</td>
2367
+ <td>${templateUtilities.getOwnerTag(medication.resource)}</td>
2282
2368
  </tr>`;
2283
2369
  }
2284
2370
  html += `
@@ -2323,6 +2409,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
2323
2409
  <th>Code (System)</th>
2324
2410
  <th>Status</th>
2325
2411
  <th>Date</th>
2412
+ <th>Source</th>
2326
2413
  </tr>
2327
2414
  </thead>
2328
2415
  <tbody>`;
@@ -2342,6 +2429,9 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
2342
2429
  case "occurrenceDateTime":
2343
2430
  data["occurrenceDateTime"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
2344
2431
  break;
2432
+ case "Source":
2433
+ data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
2434
+ break;
2345
2435
  default:
2346
2436
  break;
2347
2437
  }
@@ -2357,6 +2447,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
2357
2447
  <td>${data["codeSystem"] ?? ""}</td>
2358
2448
  <td>${data["status"] ?? ""}</td>
2359
2449
  <td>${templateUtilities.renderTime(data["occurrenceDateTime"], timezone) ?? ""}</td>
2450
+ <td>${data["source"] ?? ""}</td>
2360
2451
  </tr>`;
2361
2452
  }
2362
2453
  }
@@ -2387,6 +2478,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
2387
2478
  <th>Lot Number</th>
2388
2479
  <th>Comments</th>
2389
2480
  <th>Date</th>
2481
+ <th>Source</th>
2390
2482
  </tr>
2391
2483
  </thead>
2392
2484
  <tbody>`;
@@ -2408,6 +2500,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
2408
2500
  <td>${imm.lotNumber || ""}</td>
2409
2501
  <td>${templateUtilities.renderNotes(imm.note, timezone)}</td>
2410
2502
  <td>${templateUtilities.renderTime(imm.occurrenceDateTime, timezone)}</td>
2503
+ <td>${templateUtilities.getOwnerTag(imm)}</td>
2411
2504
  </tr>`;
2412
2505
  }
2413
2506
  }
@@ -2448,6 +2541,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
2448
2541
  <th>Is Chronic</th>
2449
2542
  <th>Onset Date</th>
2450
2543
  <th>Last Confirmed Date</th>
2544
+ <th>Source</th>
2451
2545
  </tr>
2452
2546
  </thead>
2453
2547
  <tbody>`;
@@ -2472,6 +2566,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
2472
2566
  <td>${data["Is Chronic"] ?? ""}</td>
2473
2567
  <td>${templateUtilities.renderTime(data["Onset Date"], timezone) ?? ""}</td>
2474
2568
  <td>${templateUtilities.renderTime(data["Last Confirmed Date"], timezone) ?? ""}</td>
2569
+ <td>${data["Source"] ?? ""}</td>
2475
2570
  </tr>`;
2476
2571
  }
2477
2572
  }
@@ -2510,6 +2605,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
2510
2605
  <th>Code (System)</th>
2511
2606
  <th>Onset Date</th>
2512
2607
  <th>Recorded Date</th>
2608
+ <th>Source</th>
2513
2609
  </tr>
2514
2610
  </thead>
2515
2611
  <tbody>`;
@@ -2529,6 +2625,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
2529
2625
  <td class="CodeSystem">${codeAndSystem}</td>
2530
2626
  <td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
2531
2627
  <td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
2628
+ <td class="Source">${templateUtilities.getOwnerTag(cond)}</td>
2532
2629
  </tr>`;
2533
2630
  }
2534
2631
  html += `</tbody>
@@ -2568,6 +2665,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
2568
2665
  <th>Code (System)</th>
2569
2666
  <th>Result</th>
2570
2667
  <th>Date</th>
2668
+ <th>Source</th>
2571
2669
  </tr>
2572
2670
  </thead>
2573
2671
  <tbody>`;
@@ -2610,6 +2708,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
2610
2708
  <td>${data["codeSystem"] ?? ""}</td>
2611
2709
  <td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
2612
2710
  <td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
2711
+ <td>${data["Source"] ?? ""}</td>
2613
2712
  </tr>`;
2614
2713
  }
2615
2714
  }
@@ -2647,6 +2746,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
2647
2746
  <th>Component(s)</th>
2648
2747
  <th>Comments</th>
2649
2748
  <th>Date</th>
2749
+ <th>Source</th>
2650
2750
  </tr>
2651
2751
  </thead>
2652
2752
  <tbody>`;
@@ -2665,6 +2765,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
2665
2765
  <td>${templateUtilities.renderComponent(obs.component)}</td>
2666
2766
  <td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
2667
2767
  <td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
2768
+ <td>${templateUtilities.getOwnerTag(obs)}</td>
2668
2769
  </tr>`;
2669
2770
  }
2670
2771
  html += `
@@ -2701,6 +2802,7 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
2701
2802
  <th>Status</th>
2702
2803
  <th>Comments</th>
2703
2804
  <th>Date Recorded</th>
2805
+ <th>Source</th>
2704
2806
  </tr>
2705
2807
  </thead>
2706
2808
  <tbody>`;
@@ -2722,6 +2824,7 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
2722
2824
  <td>${templateUtilities.renderTextAsHtml(dus.status || "")}</td>
2723
2825
  <td>${templateUtilities.renderNotes(dus.note, timezone)}</td>
2724
2826
  <td>${templateUtilities.renderTextAsHtml(templateUtilities.renderRecorded(dus.recordedOn, timezone))}</td>
2827
+ <td>${templateUtilities.getOwnerTag(dus)}</td>
2725
2828
  </tr>`;
2726
2829
  }
2727
2830
  html += `
@@ -2874,6 +2977,9 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
2874
2977
  case "effectivePeriod.end":
2875
2978
  targetData["effectivePeriodEnd"] = templateUtilities.renderTextAsHtml(column.text?.div ?? "");
2876
2979
  break;
2980
+ case "Source":
2981
+ targetData["source"] = templateUtilities.renderTextAsHtml(column.text?.div ?? "");
2982
+ break;
2877
2983
  // valueQuantity
2878
2984
  case "valueQuantity.value":
2879
2985
  targetData["value"] = templateUtilities.renderTextAsHtml(column.text?.div ?? "");
@@ -3092,6 +3198,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3092
3198
  <th>Result</th>
3093
3199
  <th>Reference Range</th>
3094
3200
  <th>Date</th>
3201
+ <th>Source</th>
3095
3202
  </tr>
3096
3203
  </thead>
3097
3204
  <tbody>`;
@@ -3105,6 +3212,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3105
3212
  <th>Report</th>
3106
3213
  <th>Performer</th>
3107
3214
  <th>Issued</th>
3215
+ <th>Source</th>
3108
3216
  </tr>
3109
3217
  </thead>
3110
3218
  <tbody>`;
@@ -3151,6 +3259,8 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3151
3259
  case "Status":
3152
3260
  data["status"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
3153
3261
  break;
3262
+ case "Source":
3263
+ data["source"] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
3154
3264
  break;
3155
3265
  default:
3156
3266
  break;
@@ -3188,6 +3298,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3188
3298
  <td>${templateUtilities.renderTextAsHtml(component["formattedValue"]) ?? ""}</td>
3189
3299
  <td>${templateUtilities.renderTextAsHtml(component["referenceRange"])?.trim() ?? ""}</td>
3190
3300
  <td>${date ?? ""}</td>
3301
+ <td>${data["source"] ?? ""}</td>
3191
3302
  </tr>`;
3192
3303
  }
3193
3304
  }
@@ -3207,6 +3318,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3207
3318
  <td>${templateUtilities.renderTextAsHtml(data["formattedValue"]) ?? ""}</td>
3208
3319
  <td>${templateUtilities.renderTextAsHtml(data["referenceRange"])?.trim() ?? ""}</td>
3209
3320
  <td>${date ?? ""}</td>
3321
+ <td>${data["source"] ?? ""}</td>
3210
3322
  </tr>`;
3211
3323
  }
3212
3324
  }
@@ -3228,6 +3340,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3228
3340
  <td>${templateUtilities.capitalizeFirstLetter(data["report"] ?? "")}</td>
3229
3341
  <td>${data["performer"] ?? ""}</td>
3230
3342
  <td>${templateUtilities.renderTime(data["issued"], timezone) ?? ""}</td>
3343
+ <td>${data["source"] ?? ""}</td>
3231
3344
  </tr>`;
3232
3345
  }
3233
3346
  }
@@ -3412,6 +3525,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3412
3525
  <th>Result</th>
3413
3526
  <th>Reference Range</th>
3414
3527
  <th>Date</th>
3528
+ <th>Source</th>
3415
3529
  </tr>
3416
3530
  </thead>
3417
3531
  <tbody>`;
@@ -3432,6 +3546,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3432
3546
  <td>${templateUtilities.extractObservationValue(obs)}</td>
3433
3547
  <td>${templateUtilities.concatReferenceRange(obs.referenceRange)}</td>
3434
3548
  <td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
3549
+ <td>${templateUtilities.getOwnerTag(obs)}</td>
3435
3550
  </tr>`;
3436
3551
  }
3437
3552
  }
@@ -3458,6 +3573,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3458
3573
  <th>Category</th>
3459
3574
  <th>Result</th>
3460
3575
  <th>Issued</th>
3576
+ <th>Source</th>
3461
3577
  </tr>
3462
3578
  </thead>
3463
3579
  <tbody>`;
@@ -3482,6 +3598,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
3482
3598
  <td>${templateUtilities.firstFromCodeableConceptList(report.category)}</td>
3483
3599
  <td>${resultCount}</td>
3484
3600
  <td>${report.issued ? templateUtilities.renderTime(report.issued, timezone) : ""}</td>
3601
+ <td>${templateUtilities.getOwnerTag(report)}</td>
3485
3602
  </tr>`;
3486
3603
  }
3487
3604
  }
@@ -3548,6 +3665,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
3548
3665
  <th>Code (System)</th>
3549
3666
  <th>Performer</th>
3550
3667
  <th>Date</th>
3668
+ <th>Source</th>
3551
3669
  </tr>
3552
3670
  </thead>
3553
3671
  <tbody>`;
@@ -3567,6 +3685,8 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
3567
3685
  case "Performed Date":
3568
3686
  data["date"] = columnData.text?.div ?? "";
3569
3687
  break;
3688
+ case "Source":
3689
+ data["source"] = columnData.text?.div ?? "";
3570
3690
  break;
3571
3691
  default:
3572
3692
  break;
@@ -3582,6 +3702,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
3582
3702
  <td>${data["codeSystem"] ?? ""}</td>
3583
3703
  <td>${data["performer"] ?? ""}</td>
3584
3704
  <td>${templateUtilities.renderTime(data["date"], timezone) ?? ""}</td>
3705
+ <td>${data["source"] ?? ""}</td>
3585
3706
  </tr>`;
3586
3707
  }
3587
3708
  }
@@ -3609,6 +3730,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
3609
3730
  <th>Code (System)</th>
3610
3731
  <th>Comments</th>
3611
3732
  <th>Date</th>
3733
+ <th>Source</th>
3612
3734
  </tr>
3613
3735
  </thead>
3614
3736
  <tbody>`;
@@ -3624,6 +3746,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
3624
3746
  <td>${templateUtilities.codeableConceptCoding(proc.code)}</td>
3625
3747
  <td>${templateUtilities.renderNotes(proc.note, timezone)}</td>
3626
3748
  <td>${templateUtilities.renderTime(proc.performedDateTime || proc.performedPeriod?.start, timezone)}</td>
3749
+ <td>${templateUtilities.getOwnerTag(proc)}</td>
3627
3750
  </tr>`;
3628
3751
  }
3629
3752
  html += `
@@ -3665,6 +3788,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
3665
3788
  <th>Result</th>
3666
3789
  <th>Date</th>
3667
3790
  <th>Comments</th>
3791
+ <th>Source</th>
3668
3792
  </tr>
3669
3793
  </thead>
3670
3794
  <tbody>`;
@@ -3690,6 +3814,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
3690
3814
  <td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
3691
3815
  <td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
3692
3816
  <td>${data["Notes"] ?? ""}</td>
3817
+ <td>${data["Source"] ?? ""}</td>
3693
3818
  </tr>`;
3694
3819
  }
3695
3820
  }
@@ -3725,6 +3850,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
3725
3850
  <th>Unit</th>
3726
3851
  <th>Comments</th>
3727
3852
  <th>Date</th>
3853
+ <th>Source</th>
3728
3854
  </tr>
3729
3855
  </thead>
3730
3856
  <tbody>`;
@@ -3744,6 +3870,7 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
3744
3870
  <td>${templateUtilities.extractObservationValueUnit(obs)}</td>
3745
3871
  <td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
3746
3872
  <td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
3873
+ <td>${templateUtilities.getOwnerTag(obs)}</td>
3747
3874
  </tr>`;
3748
3875
  }
3749
3876
  }
@@ -3794,6 +3921,7 @@ var PastHistoryOfIllnessTemplate = class {
3794
3921
  <th>Onset Date</th>
3795
3922
  <th>Recorded Date</th>
3796
3923
  <th>Resolved Date</th>
3924
+ <th>Source</th>
3797
3925
  </tr>
3798
3926
  </thead>
3799
3927
  <tbody>`;
@@ -3811,6 +3939,7 @@ var PastHistoryOfIllnessTemplate = class {
3811
3939
  <td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
3812
3940
  <td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
3813
3941
  <td class="ResolvedDate">${templateUtilities.renderDate(cond.abatementDateTime)}</td>
3942
+ <td class="Source">${templateUtilities.getOwnerTag(cond)}</td>
3814
3943
  </tr>`;
3815
3944
  }
3816
3945
  }
@@ -3846,6 +3975,7 @@ var PastHistoryOfIllnessTemplate = class {
3846
3975
  <th>Onset Date</th>
3847
3976
  <th>Last Confirmed Date</th>
3848
3977
  <th>Resolved Date</th>
3978
+ <th>Source</th>
3849
3979
  </tr>
3850
3980
  </thead>
3851
3981
  <tbody>`;
@@ -3875,6 +4005,7 @@ var PastHistoryOfIllnessTemplate = class {
3875
4005
  <td>${templateUtilities.renderTime(data["Onset Date"], timezone) ?? ""}</td>
3876
4006
  <td>${templateUtilities.renderTime(data["Last Confirmed Date"], timezone) ?? ""}</td>
3877
4007
  <td>${templateUtilities.renderTime(data["Resolved Date"], timezone) ?? ""}</td>
4008
+ <td>${data["Source"] ?? ""}</td>
3878
4009
  </tr>`;
3879
4010
  }
3880
4011
  }
@@ -3918,6 +4049,7 @@ var PlanOfCareTemplate = class {
3918
4049
  <th>Comments</th>
3919
4050
  <th>Planned Start</th>
3920
4051
  <th>Planned End</th>
4052
+ <th>Source</th>
3921
4053
  </tr>
3922
4054
  </thead>
3923
4055
  <tbody>`;
@@ -3933,6 +4065,7 @@ var PlanOfCareTemplate = class {
3933
4065
  <td>${templateUtilities.concat(cp.note, "text")}</td>
3934
4066
  <td>${cp.period?.start ? templateUtilities.renderTime(cp.period?.start, timezone) : ""}</td>
3935
4067
  <td>${cp.period?.end ? templateUtilities.renderTime(cp.period?.end, timezone) : ""}</td>
4068
+ <td>${templateUtilities.getOwnerTag(cp)}</td>
3936
4069
  </tr>`;
3937
4070
  }
3938
4071
  html += `
@@ -3960,6 +4093,7 @@ var PlanOfCareTemplate = class {
3960
4093
  <th>Created</th>
3961
4094
  <th>Planned Start</th>
3962
4095
  <th>Planned End</th>
4096
+ <th>Source</th>
3963
4097
  </tr>
3964
4098
  </thead>
3965
4099
  <tbody>`;
@@ -3984,6 +4118,7 @@ var PlanOfCareTemplate = class {
3984
4118
  <td>${templateUtilities.renderTime(data["created"], timezone) ?? ""}</td>
3985
4119
  <td>${templateUtilities.renderTime(data["period.start"], timezone) ?? ""}</td>
3986
4120
  <td>${templateUtilities.renderTime(data["period.end"], timezone) ?? ""}</td>
4121
+ <td>${data["Source"] ?? ""}</td>
3987
4122
  </tr>`;
3988
4123
  }
3989
4124
  }
@@ -3999,7 +4134,7 @@ var PlanOfCareTemplate = class {
3999
4134
  var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
4000
4135
  /**
4001
4136
  * Generate HTML narrative for Functional Status
4002
- * @param resources - FHIR resources array containing Observation resources
4137
+ * @param resources - FHIR resources array containing Condition and ClinicalImpression resources
4003
4138
  * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
4004
4139
  * @returns HTML string for rendering
4005
4140
  */
@@ -4028,6 +4163,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
4028
4163
  <th>Code (System)</th>
4029
4164
  <th>Onset Date</th>
4030
4165
  <th>Recorded Date</th>
4166
+ <th>Source</th>
4031
4167
  </tr>
4032
4168
  </thead>
4033
4169
  <tbody>`;
@@ -4038,10 +4174,11 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
4038
4174
  <thead>
4039
4175
  <tr>
4040
4176
  <th>Name</th>
4041
- <th>Date</th>
4042
4177
  <th>Code (System)</th>
4178
+ <th>Date</th>
4043
4179
  <th>Description</th>
4044
4180
  <th>Summary</th>
4181
+ <th>Source</th>
4045
4182
  </tr>
4046
4183
  </thead>
4047
4184
  <tbody>`;
@@ -4081,6 +4218,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
4081
4218
  <td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
4082
4219
  <td>${date}</td>
4083
4220
  <td>${templateUtilities.renderTime(data["recordedDate"], timezone) ?? ""}</td>
4221
+ <td>${data["Source"] ?? ""}</td>
4084
4222
  </tr>`;
4085
4223
  }
4086
4224
  } else if (resourceItem.title === "Clinical Impression|Clinical Impression Summary") {
@@ -4103,10 +4241,11 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
4103
4241
  clinicalImpressionsHtml += `
4104
4242
  <tr>
4105
4243
  <td>${templateUtilities.capitalizeFirstLetter(name)}</td>
4106
- <td>${date ?? ""}</td>
4107
4244
  <td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
4245
+ <td>${date ?? ""}</td>
4108
4246
  <td>${data["Description"] ?? ""}</td>
4109
4247
  <td>${data["Summary"] ?? ""}</td>
4248
+ <td>${data["Source"] ?? ""}</td>
4110
4249
  </tr>`;
4111
4250
  }
4112
4251
  }
@@ -4132,90 +4271,156 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
4132
4271
  }
4133
4272
  /**
4134
4273
  * Internal static implementation that actually generates the narrative
4135
- * @param resources - FHIR resources array containing Observation resources
4274
+ * @param resources - FHIR resources array containing Condition and ClinicalImpression resources
4136
4275
  * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
4137
4276
  * @returns HTML string for rendering
4138
4277
  */
4139
4278
  static generateStaticNarrative(resources, timezone) {
4140
4279
  const templateUtilities = new TemplateUtilities(resources);
4141
- let html = `<p>This section summarizes key observations and assessments related to the person's functional status and ability to perform daily activities.</p>`;
4142
- let functionalObservations = resources.filter((r) => r.resourceType === "Observation").filter((r) => {
4143
- const hasFunctionalLoinc = r.code?.coding?.some(
4144
- (c) => c.system?.toLowerCase().includes("loinc") && c.code === "47420-5"
4145
- );
4146
- const hasFunctionalCategory = r.category?.some(
4147
- (cat) => cat.coding?.some(
4148
- (c) => c.code === "functional-status" || c.display?.toLowerCase().includes("functional")
4149
- )
4150
- );
4151
- return hasFunctionalLoinc || hasFunctionalCategory;
4152
- });
4153
- functionalObservations = functionalObservations.sort((a, b) => {
4154
- const getObsDate = (obs) => obs.effectiveDateTime ? new Date(obs.effectiveDateTime).getTime() : obs.issued ? new Date(obs.issued).getTime() : 0;
4155
- return getObsDate(b) - getObsDate(a);
4156
- });
4157
- let clinicalImpressions = resources.filter((r) => r.resourceType === "ClinicalImpression").filter((r) => r.status === "completed");
4158
- clinicalImpressions = clinicalImpressions.sort((a, b) => {
4159
- const getImpressionDate = (ci) => ci.effectiveDateTime ? new Date(ci.effectiveDateTime).getTime() : ci.effectivePeriod?.end ? new Date(ci.effectivePeriod.end).getTime() : ci.date ? new Date(ci.date).getTime() : 0;
4160
- return getImpressionDate(b) - getImpressionDate(a);
4280
+ let html = `<div>
4281
+ <p>This section summarizes key conditions and assessments related to the person's functional status and ability to perform daily activities.</p>`;
4282
+ let conditionHtml = `
4283
+ <div>
4284
+ <h3>Conditions</h3>
4285
+ <table>
4286
+ <thead>
4287
+ <tr>
4288
+ <th>Problem</th>
4289
+ <th>Code (System)</th>
4290
+ <th>Onset Date</th>
4291
+ <th>Recorded Date</th>
4292
+ <th>Source</th>
4293
+ </tr>
4294
+ </thead>
4295
+ <tbody>`;
4296
+ let clinicalImpressionsHtml = `
4297
+ <div>
4298
+ <h3>Clinical Impressions</h3>
4299
+ <table>
4300
+ <thead>
4301
+ <tr>
4302
+ <th>Name</th>
4303
+ <th>Code (System)</th>
4304
+ <th>Date</th>
4305
+ <th>Description</th>
4306
+ <th>Summary</th>
4307
+ <th>Source</th>
4308
+ </tr>
4309
+ </thead>
4310
+ <tbody>`;
4311
+ const conditions = resources.filter((entry) => entry.resourceType === "Condition").map((entry) => entry);
4312
+ conditions.sort((a, b) => {
4313
+ const dateA = a.recordedDate ? new Date(a.recordedDate).getTime() : 0;
4314
+ const dateB = b.recordedDate ? new Date(b.recordedDate).getTime() : 0;
4315
+ return dateB - dateA;
4161
4316
  });
4162
- if (functionalObservations.length > 0) {
4163
- html += `<table><thead><tr><th>Observation</th><th>Value</th><th>Date</th><th>Interpretation</th><th>Comments</th></tr></thead><tbody>`;
4164
- for (const obs of functionalObservations) {
4165
- const observation = obs;
4166
- const obsName = templateUtilities.codeableConceptDisplay(observation.code);
4167
- if (obsName?.toLowerCase() === "unknown") {
4168
- continue;
4317
+ const addedConditions = /* @__PURE__ */ new Set();
4318
+ for (const cond of conditions) {
4319
+ const functionalStatusName = this.getFunctionalStatusNameFromCode(cond.code);
4320
+ const problem = templateUtilities.codeableConceptDisplay(cond.code) || functionalStatusName;
4321
+ const codeAndSystem = templateUtilities.codeableConceptCoding(cond.code);
4322
+ if (!codeAndSystem || !problem || !functionalStatusName || addedConditions.has(functionalStatusName)) {
4323
+ continue;
4324
+ }
4325
+ if (problem?.toLowerCase() === "unknown") {
4326
+ continue;
4327
+ }
4328
+ addedConditions.add(functionalStatusName);
4329
+ let date = cond.onsetDateTime ? templateUtilities.renderTime(cond.onsetDateTime, timezone) : "";
4330
+ if (!date && cond.onsetPeriod?.start) {
4331
+ date = templateUtilities.renderTime(
4332
+ cond.onsetPeriod?.start,
4333
+ timezone
4334
+ );
4335
+ if (cond.onsetPeriod?.end) {
4336
+ date += " - " + templateUtilities.renderTime(cond.onsetPeriod?.end, timezone);
4169
4337
  }
4170
- const value = templateUtilities.extractObservationValue(observation);
4171
- const date = observation.effectiveDateTime ? templateUtilities.renderDate(observation.effectiveDateTime) : observation.issued ? templateUtilities.renderDate(observation.issued) : "";
4172
- const interpretation = observation.interpretation ? templateUtilities.codeableConceptDisplay(observation.interpretation[0]) : "";
4173
- const comments = observation.comment || observation.note?.map((n) => n.text).join("; ") || "";
4174
- html += `<tr>
4175
- <td>${templateUtilities.capitalizeFirstLetter(obsName)}</td>
4176
- <td>${value ?? ""}</td>
4338
+ }
4339
+ conditionHtml += `<tr>
4340
+ <td>${templateUtilities.capitalizeFirstLetter(problem)}</td>
4341
+ <td>${codeAndSystem}</td>
4177
4342
  <td>${date}</td>
4178
- <td>${interpretation}</td>
4179
- <td>${comments}</td>
4343
+ <td>${templateUtilities.renderTime(cond.recordedDate, timezone)}</td>
4344
+ <td>${templateUtilities.getOwnerTag(cond)}</td>
4180
4345
  </tr>`;
4346
+ }
4347
+ const clinicalImpressions = resources.filter((entry) => entry.resourceType === "ClinicalImpression").map((entry) => entry);
4348
+ clinicalImpressions.sort((a, b) => {
4349
+ const dateA = this.getClinicalImpressionEffectiveDate(a);
4350
+ const dateB = this.getClinicalImpressionEffectiveDate(b);
4351
+ return dateB && dateA ? dateB.getTime() - dateA.getTime() : 0;
4352
+ });
4353
+ const addedClinicalImpressions = /* @__PURE__ */ new Set();
4354
+ for (const impression of clinicalImpressions) {
4355
+ const name = templateUtilities.codeableConceptDisplay(impression.code);
4356
+ const codeAndSystem = templateUtilities.codeableConceptCoding(impression.code);
4357
+ if (!codeAndSystem || addedClinicalImpressions.has(name)) {
4358
+ continue;
4181
4359
  }
4182
- html += `</tbody></table>`;
4183
- }
4184
- if (clinicalImpressions.length > 0) {
4185
- html += `<table><thead><tr><th>Date</th><th>Status</th><th>Description</th><th>Summary</th><th>Findings</th></tr></thead><tbody>`;
4186
- for (const impression of clinicalImpressions) {
4187
- let formattedDate = "";
4188
- if (impression.effectiveDateTime) {
4189
- formattedDate = templateUtilities.renderTime(impression.effectiveDateTime, timezone);
4190
- } else if (impression.effectivePeriod) {
4191
- formattedDate = templateUtilities.renderPeriod(impression.effectivePeriod, timezone);
4192
- } else if (impression.date) {
4193
- formattedDate = templateUtilities.renderDate(impression.date);
4194
- }
4195
- let findingsHtml = "";
4196
- if (impression.finding && impression.finding.length > 0) {
4197
- findingsHtml = "<ul>";
4198
- for (const finding of impression.finding) {
4199
- const findingText = finding.itemCodeableConcept ? templateUtilities.codeableConceptDisplay(finding.itemCodeableConcept) : finding.itemReference ? templateUtilities.renderReference(finding.itemReference) : "";
4200
- const cause = finding.basis || "";
4201
- findingsHtml += `<li>${findingText}${cause ? ` - ${cause}` : ""}</li>`;
4202
- }
4203
- findingsHtml += "</ul>";
4360
+ if (!name || name?.toLowerCase() === "unknown") {
4361
+ continue;
4362
+ }
4363
+ addedClinicalImpressions.add(name);
4364
+ let date = impression.effectiveDateTime ? templateUtilities.renderTime(impression.effectiveDateTime, timezone) : "";
4365
+ if (!date && impression.effectivePeriod?.start) {
4366
+ date = templateUtilities.renderTime(
4367
+ impression.effectivePeriod?.start,
4368
+ timezone
4369
+ );
4370
+ if (impression.effectivePeriod?.end) {
4371
+ date += " - " + templateUtilities.renderTime(impression.effectivePeriod?.end, timezone);
4204
4372
  }
4205
- html += `<tr>
4206
- <td>${formattedDate}</td>
4207
- <td>${impression.status || ""}</td>
4373
+ }
4374
+ clinicalImpressionsHtml += `<tr>
4375
+ <td>${templateUtilities.capitalizeFirstLetter(name)}</td>
4376
+ <td>${codeAndSystem}</td>
4377
+ <td>${date}</td>
4208
4378
  <td>${impression.description || ""}</td>
4209
4379
  <td>${impression.summary || ""}</td>
4210
- <td>${findingsHtml}</td>
4380
+ <td>${templateUtilities.getOwnerTag(impression)}</td>
4211
4381
  </tr>`;
4382
+ }
4383
+ if (addedConditions.size > 0) {
4384
+ html += conditionHtml;
4385
+ html += `
4386
+ </tbody>
4387
+ </table>
4388
+ </div>`;
4389
+ }
4390
+ if (addedClinicalImpressions.size > 0) {
4391
+ html += clinicalImpressionsHtml;
4392
+ html += `
4393
+ </tbody>
4394
+ </table>
4395
+ </div>`;
4396
+ }
4397
+ html += `
4398
+ </div>`;
4399
+ return addedConditions.size > 0 || addedClinicalImpressions.size > 0 ? html : void 0;
4400
+ }
4401
+ static getFunctionalStatusNameFromCode(cc) {
4402
+ if (!cc) return "";
4403
+ for (const coding of cc.coding || []) {
4404
+ let functionalStatusName = FUNCTIONAL_STATUS_SNOMED_CODES[coding.code];
4405
+ if (functionalStatusName) {
4406
+ return functionalStatusName;
4407
+ }
4408
+ functionalStatusName = FUNCTIONAL_STATUS_ASSESSMENT_LOINC_CODES[coding.code];
4409
+ if (functionalStatusName) {
4410
+ return functionalStatusName;
4212
4411
  }
4213
- html += `</tbody></table>`;
4214
4412
  }
4215
- if (functionalObservations.length === 0 && clinicalImpressions.length === 0) {
4216
- html += `<p>No functional status information available.</p>`;
4413
+ }
4414
+ static getClinicalImpressionEffectiveDate(impression) {
4415
+ if (impression.effectiveDateTime) {
4416
+ return new Date(impression.effectiveDateTime);
4417
+ } else if (impression.effectivePeriod) {
4418
+ if (impression.effectivePeriod.start) {
4419
+ return new Date(impression.effectivePeriod.start);
4420
+ } else if (impression.effectivePeriod.end) {
4421
+ return new Date(impression.effectivePeriod.end);
4422
+ }
4217
4423
  }
4218
- return html;
4219
4424
  }
4220
4425
  };
4221
4426
 
@@ -4274,10 +4479,11 @@ var PregnancyTemplate = class _PregnancyTemplate {
4274
4479
  <th>Code (System)</th>
4275
4480
  <th>Comments</th>
4276
4481
  <th>Date</th>
4482
+ <th>Source</th>
4277
4483
  </tr>
4278
4484
  </thead>
4279
4485
  <tbody>`;
4280
- function renderRow({ result, comments, date, codeSystem }) {
4486
+ function renderRow({ result, comments, date, codeSystem, resource }) {
4281
4487
  if (result?.toLowerCase() === "unknown") {
4282
4488
  return;
4283
4489
  }
@@ -4287,6 +4493,7 @@ var PregnancyTemplate = class _PregnancyTemplate {
4287
4493
  <td class="CodeSystem">${codeSystem}</td>
4288
4494
  <td class="Comments">${comments}</td>
4289
4495
  <td class="Date">${date}</td>
4496
+ <td class="Source">${templateUtilities.getOwnerTag(resource)}</td>
4290
4497
  </tr>`;
4291
4498
  }
4292
4499
  const rowResources = [];
@@ -4340,7 +4547,7 @@ var PregnancyTemplate = class _PregnancyTemplate {
4340
4547
  const rowKey = `${result}|${codeSystem}`;
4341
4548
  if (!addedRows.has(rowKey)) {
4342
4549
  addedRows.add(rowKey);
4343
- renderRow({ result, comments, date: dateStr, codeSystem });
4550
+ renderRow({ result, comments, date: dateStr, codeSystem, resource });
4344
4551
  }
4345
4552
  }
4346
4553
  html += `
@@ -4384,6 +4591,7 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
4384
4591
  <th>Status</th>
4385
4592
  <th>Action Controlled</th>
4386
4593
  <th>Date</th>
4594
+ <th>Source</th>
4387
4595
  </tr>
4388
4596
  </thead>
4389
4597
  <tbody>`;
@@ -4401,6 +4609,7 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
4401
4609
  <td>${consent.status || ""}</td>
4402
4610
  <td>${consent.provision?.action ? templateUtilities.concatCodeableConcept(consent.provision.action) : ""}</td>
4403
4611
  <td>${consent.dateTime || ""}</td>
4612
+ <td>${templateUtilities.getOwnerTag(consent)}</td>
4404
4613
  </tr>`;
4405
4614
  }
4406
4615
  html += `