@imranq2/fhirpatientsummary 1.0.31 → 1.0.32
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 +70 -81
- package/dist/index.js +70 -81
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -938,6 +938,12 @@ var TemplateUtilities = class {
|
|
|
938
938
|
const escapedText = text.replace(/</g, "<").replace(/>/g, ">");
|
|
939
939
|
return escapedText.replace(/\n/g, "<br />");
|
|
940
940
|
}
|
|
941
|
+
capitalizeFirstLetter(text) {
|
|
942
|
+
if (!text || text.length === 0) {
|
|
943
|
+
return "";
|
|
944
|
+
}
|
|
945
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
946
|
+
}
|
|
941
947
|
/**
|
|
942
948
|
* Renders note elements from a FHIR resource in a standardized format
|
|
943
949
|
* Can render as simple comma-separated text or as styled HTML with timestamps
|
|
@@ -1814,7 +1820,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1814
1820
|
isSummaryCreated = true;
|
|
1815
1821
|
html += `
|
|
1816
1822
|
<tr>
|
|
1817
|
-
<td>${data["allergen"] ?? ""}</td>
|
|
1823
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["allergen"] ?? "")}</td>
|
|
1818
1824
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
1819
1825
|
<td>${data["criticality"] ?? ""}</td>
|
|
1820
1826
|
<td>${templateUtilities.renderTime(data["recordedDate"], timezone) ?? ""}</td>
|
|
@@ -1932,8 +1938,8 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1932
1938
|
let html = "";
|
|
1933
1939
|
for (const allergy of allergies) {
|
|
1934
1940
|
html += `
|
|
1935
|
-
<tr
|
|
1936
|
-
<td class="Name"><span class="AllergenName">${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(allergy.code))}</span></td>
|
|
1941
|
+
<tr>
|
|
1942
|
+
<td class="Name"><span class="AllergenName">${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(allergy.code)))}</span></td>
|
|
1937
1943
|
<td class="Status">${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(allergy.clinicalStatus)) || ""}</td>
|
|
1938
1944
|
<td class="CodeSystem">${templateUtilities.codeableConceptCoding(allergy.code)}</td>
|
|
1939
1945
|
<td class="Category">${templateUtilities.renderTextAsHtml(templateUtilities.safeConcat(allergy.category)) || ""}</td>
|
|
@@ -2050,7 +2056,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2050
2056
|
isSummaryCreated = true;
|
|
2051
2057
|
html += `
|
|
2052
2058
|
<tr>
|
|
2053
|
-
<td>${templateUtilities.renderTextAsHtml(data["medication"])}</td>
|
|
2059
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(data["medication"]))}</td>
|
|
2054
2060
|
<td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
|
|
2055
2061
|
<td>${templateUtilities.renderTextAsHtml(data["status"])}</td>
|
|
2056
2062
|
<td>${templateUtilities.renderTextAsHtml(data["sig-prescriber"] || data["sig-pharmacy"])}</td>
|
|
@@ -2097,8 +2103,8 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2097
2103
|
static generateStaticNarrative(resources, timezone, now) {
|
|
2098
2104
|
const templateUtilities = new TemplateUtilities(resources);
|
|
2099
2105
|
let html = "";
|
|
2100
|
-
const medicationRequests =
|
|
2101
|
-
const medicationStatements =
|
|
2106
|
+
const medicationRequests = resources.filter((entry) => entry.resourceType === "MedicationRequest");
|
|
2107
|
+
const medicationStatements = resources.filter((entry) => entry.resourceType === "MedicationStatement");
|
|
2102
2108
|
const allActiveMedications = [];
|
|
2103
2109
|
const currentDate = now || /* @__PURE__ */ new Date();
|
|
2104
2110
|
const twoYearsAgo = new Date(currentDate);
|
|
@@ -2106,10 +2112,10 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2106
2112
|
let skippedMedications = 0;
|
|
2107
2113
|
const allMedications = [];
|
|
2108
2114
|
medicationRequests.forEach((mr) => {
|
|
2109
|
-
allMedications.push({ type: "request", resource: mr
|
|
2115
|
+
allMedications.push({ type: "request", resource: mr });
|
|
2110
2116
|
});
|
|
2111
2117
|
medicationStatements.forEach((ms) => {
|
|
2112
|
-
allMedications.push({ type: "statement", resource: ms
|
|
2118
|
+
allMedications.push({ type: "statement", resource: ms });
|
|
2113
2119
|
});
|
|
2114
2120
|
for (const med of allMedications) {
|
|
2115
2121
|
let dateString;
|
|
@@ -2166,36 +2172,6 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2166
2172
|
}
|
|
2167
2173
|
return "";
|
|
2168
2174
|
}
|
|
2169
|
-
/**
|
|
2170
|
-
* Extract MedicationRequest resources
|
|
2171
|
-
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
2172
|
-
* @param resources - FHIR Medication resources
|
|
2173
|
-
* @returns Array of MedicationRequest resources
|
|
2174
|
-
*/
|
|
2175
|
-
static getMedicationRequests(templateUtilities, resources) {
|
|
2176
|
-
if (resources.length === 0) {
|
|
2177
|
-
return [];
|
|
2178
|
-
}
|
|
2179
|
-
return resources.filter((entry) => entry.resourceType === "MedicationRequest").map((entry) => ({
|
|
2180
|
-
resource: entry,
|
|
2181
|
-
extension: templateUtilities.narrativeLinkExtension(entry)
|
|
2182
|
-
}));
|
|
2183
|
-
}
|
|
2184
|
-
/**
|
|
2185
|
-
* Extract MedicationStatement resources
|
|
2186
|
-
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
2187
|
-
* @param resources - FHIR Medication resources
|
|
2188
|
-
* @returns Array of MedicationStatement resources
|
|
2189
|
-
*/
|
|
2190
|
-
static getMedicationStatements(templateUtilities, resources) {
|
|
2191
|
-
if (resources.length === 0) {
|
|
2192
|
-
return [];
|
|
2193
|
-
}
|
|
2194
|
-
return resources.filter((entry) => entry.resourceType === "MedicationStatement").map((entry) => ({
|
|
2195
|
-
resource: entry,
|
|
2196
|
-
extension: templateUtilities.narrativeLinkExtension(entry)
|
|
2197
|
-
}));
|
|
2198
|
-
}
|
|
2199
2175
|
/**
|
|
2200
2176
|
* Render HTML table for combined MedicationRequest and MedicationStatement resources
|
|
2201
2177
|
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
@@ -2219,7 +2195,6 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2219
2195
|
</thead>
|
|
2220
2196
|
<tbody>`;
|
|
2221
2197
|
for (const medication of medications) {
|
|
2222
|
-
const narrativeLinkId = templateUtilities.narrativeLinkId(medication.extension);
|
|
2223
2198
|
let type;
|
|
2224
2199
|
let medicationName;
|
|
2225
2200
|
let sig;
|
|
@@ -2266,9 +2241,9 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2266
2241
|
}
|
|
2267
2242
|
}
|
|
2268
2243
|
html += `
|
|
2269
|
-
<tr
|
|
2244
|
+
<tr>
|
|
2270
2245
|
<td>${type}</td>
|
|
2271
|
-
<td>${medicationName}
|
|
2246
|
+
<td>${templateUtilities.capitalizeFirstLetter(medicationName)}</td>
|
|
2272
2247
|
<td>${codeSystemDisplay}</td>
|
|
2273
2248
|
<td>${sig}</td>
|
|
2274
2249
|
<td>${dispenseQuantity}</td>
|
|
@@ -2350,7 +2325,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2350
2325
|
isSummaryCreated = true;
|
|
2351
2326
|
html += `
|
|
2352
2327
|
<tr>
|
|
2353
|
-
<td>${data["immunization"] ?? ""}</td>
|
|
2328
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["immunization"] ?? "")}</td>
|
|
2354
2329
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
2355
2330
|
<td>${data["status"] ?? ""}</td>
|
|
2356
2331
|
<td>${templateUtilities.renderTime(data["occurrenceDateTime"], timezone) ?? ""}</td>
|
|
@@ -2395,7 +2370,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2395
2370
|
const imm = resourceItem;
|
|
2396
2371
|
html += `
|
|
2397
2372
|
<tr>
|
|
2398
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(imm.vaccineCode))}</td>
|
|
2373
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(imm.vaccineCode)))}</td>
|
|
2399
2374
|
<td>${templateUtilities.codeableConceptCoding(imm.vaccineCode)}</td>
|
|
2400
2375
|
<td>${imm.status || ""}</td>
|
|
2401
2376
|
<td>${templateUtilities.concatDoseNumber(imm.protocolApplied)}</td>
|
|
@@ -2466,7 +2441,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
|
|
|
2466
2441
|
}
|
|
2467
2442
|
seenCodeAndSystems.add(codeAndSystem);
|
|
2468
2443
|
html += `<tr>
|
|
2469
|
-
<td class="Name">${conditionDisplay}</td>
|
|
2444
|
+
<td class="Name">${templateUtilities.capitalizeFirstLetter(conditionDisplay)}</td>
|
|
2470
2445
|
<td class="CodeSystem">${codeAndSystem}</td>
|
|
2471
2446
|
<td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
|
|
2472
2447
|
<td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
|
|
@@ -2546,7 +2521,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2546
2521
|
isSummaryCreated = true;
|
|
2547
2522
|
html += `
|
|
2548
2523
|
<tr>
|
|
2549
|
-
<td>${data["Vital Name"] ?? ""}</td>
|
|
2524
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["Vital Name"] ?? "")}</td>
|
|
2550
2525
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
2551
2526
|
<td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
|
|
2552
2527
|
<td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
|
|
@@ -2595,7 +2570,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2595
2570
|
for (const obs of observations) {
|
|
2596
2571
|
html += `
|
|
2597
2572
|
<tr>
|
|
2598
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(obs.code, "display"))}</td>
|
|
2573
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(obs.code, "display")))}</td>
|
|
2599
2574
|
<td>${templateUtilities.codeableConceptCoding(obs.code)}</td>
|
|
2600
2575
|
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
2601
2576
|
<td>${templateUtilities.extractObservationValueUnit(obs)}</td>
|
|
@@ -2648,10 +2623,12 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
|
|
|
2648
2623
|
const dateB = b.recordedOn;
|
|
2649
2624
|
return typeof dateA === "string" && typeof dateB === "string" ? new Date(dateB).getTime() - new Date(dateA).getTime() : 0;
|
|
2650
2625
|
});
|
|
2626
|
+
let isDeviceAdded = false;
|
|
2651
2627
|
for (const dus of deviceStatements) {
|
|
2628
|
+
isDeviceAdded = true;
|
|
2652
2629
|
html += `
|
|
2653
2630
|
<tr>
|
|
2654
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.renderDevice(dus.device))}</td>
|
|
2631
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.renderDevice(dus.device)))}</td>
|
|
2655
2632
|
<td>${templateUtilities.renderTextAsHtml(dus.status || "")}</td>
|
|
2656
2633
|
<td>${templateUtilities.renderNotes(dus.note, timezone)}</td>
|
|
2657
2634
|
<td>${templateUtilities.renderTextAsHtml(templateUtilities.renderRecorded(dus.recordedOn, timezone))}</td>
|
|
@@ -2660,7 +2637,7 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
|
|
|
2660
2637
|
html += `
|
|
2661
2638
|
</tbody>
|
|
2662
2639
|
</table>`;
|
|
2663
|
-
return html;
|
|
2640
|
+
return isDeviceAdded ? html : void 0;
|
|
2664
2641
|
}
|
|
2665
2642
|
};
|
|
2666
2643
|
|
|
@@ -3117,7 +3094,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3117
3094
|
this.formatSummaryObservationData(component);
|
|
3118
3095
|
observationhtml += `
|
|
3119
3096
|
<tr>
|
|
3120
|
-
<td>${componentCode}</td>
|
|
3097
|
+
<td>${templateUtilities.capitalizeFirstLetter(componentCode)}</td>
|
|
3121
3098
|
<td></td>
|
|
3122
3099
|
<td>${templateUtilities.renderTextAsHtml(component["formattedValue"]) ?? ""}</td>
|
|
3123
3100
|
<td>${templateUtilities.renderTextAsHtml(component["referenceRange"])?.trim() ?? ""}</td>
|
|
@@ -3134,7 +3111,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3134
3111
|
this.formatSummaryObservationData(data);
|
|
3135
3112
|
observationhtml += `
|
|
3136
3113
|
<tr>
|
|
3137
|
-
<td>${data["code"] ?? ""}</td>
|
|
3114
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["code"] ?? "")}</td>
|
|
3138
3115
|
<td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
|
|
3139
3116
|
<td>${templateUtilities.renderTextAsHtml(data["formattedValue"]) ?? ""}</td>
|
|
3140
3117
|
<td>${templateUtilities.renderTextAsHtml(data["referenceRange"])?.trim() ?? ""}</td>
|
|
@@ -3155,7 +3132,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3155
3132
|
diagnosticReportAdded.add(reportName);
|
|
3156
3133
|
diagnosticReporthtml += `
|
|
3157
3134
|
<tr>
|
|
3158
|
-
<td>${data["report"] ?? ""}</td>
|
|
3135
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["report"] ?? "")}</td>
|
|
3159
3136
|
<td>${data["performer"] ?? ""}</td>
|
|
3160
3137
|
<td>${templateUtilities.renderTime(data["issued"], timezone) ?? ""}</td>
|
|
3161
3138
|
<td>${data["source"] ?? ""}</td>
|
|
@@ -3355,8 +3332,8 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3355
3332
|
observationAdded.add(obsCodeDisplay);
|
|
3356
3333
|
observationAdded.add(obsCodeAndSystem);
|
|
3357
3334
|
html += `
|
|
3358
|
-
<tr
|
|
3359
|
-
<td>${obsCodeDisplay}</td>
|
|
3335
|
+
<tr>
|
|
3336
|
+
<td>${templateUtilities.capitalizeFirstLetter(obsCodeDisplay)}</td>
|
|
3360
3337
|
<td>${templateUtilities.codeableConceptCoding(obs.code)}</td>
|
|
3361
3338
|
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
3362
3339
|
<td>${templateUtilities.concatReferenceRange(obs.referenceRange)}</td>
|
|
@@ -3404,8 +3381,8 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3404
3381
|
resultCount = `${report.result.length} result${report.result.length !== 1 ? "s" : ""}`;
|
|
3405
3382
|
}
|
|
3406
3383
|
html += `
|
|
3407
|
-
<tr
|
|
3408
|
-
<td>${reportName}</td>
|
|
3384
|
+
<tr>
|
|
3385
|
+
<td>${templateUtilities.capitalizeFirstLetter(reportName)}</td>
|
|
3409
3386
|
<td>${codeAndSystem}</td>
|
|
3410
3387
|
<td>${templateUtilities.firstFromCodeableConceptList(report.category)}</td>
|
|
3411
3388
|
<td>${resultCount}</td>
|
|
@@ -3507,7 +3484,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3507
3484
|
isSummaryCreated = true;
|
|
3508
3485
|
html += `
|
|
3509
3486
|
<tr>
|
|
3510
|
-
<td>${data["procedure"] ?? ""}</td>
|
|
3487
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["procedure"] ?? "")}</td>
|
|
3511
3488
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
3512
3489
|
<td>${data["performer"] ?? ""}</td>
|
|
3513
3490
|
<td>${templateUtilities.renderTime(data["date"], timezone) ?? ""}</td>
|
|
@@ -3547,7 +3524,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3547
3524
|
const proc = resourceItem;
|
|
3548
3525
|
html += `
|
|
3549
3526
|
<tr>
|
|
3550
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(proc.code, "display"))}</td>
|
|
3527
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(proc.code, "display")))}</td>
|
|
3551
3528
|
<td>${templateUtilities.codeableConceptCoding(proc.code)}</td>
|
|
3552
3529
|
<td>${templateUtilities.renderNotes(proc.note, timezone)}</td>
|
|
3553
3530
|
<td>${templateUtilities.renderTime(proc.performedDateTime || proc.performedPeriod?.start, timezone)}</td>
|
|
@@ -3602,17 +3579,22 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
|
|
|
3602
3579
|
</tr>
|
|
3603
3580
|
</thead>
|
|
3604
3581
|
<tbody>`;
|
|
3582
|
+
const addedObservations = /* @__PURE__ */ new Set();
|
|
3605
3583
|
for (const obs of observations) {
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
<
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3584
|
+
const obsName = templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(obs.code));
|
|
3585
|
+
if (!addedObservations.has(obsName)) {
|
|
3586
|
+
addedObservations.add(obsName);
|
|
3587
|
+
html += `
|
|
3588
|
+
<tr>
|
|
3589
|
+
<td>${templateUtilities.capitalizeFirstLetter(obsName)}</td>
|
|
3590
|
+
<td>${templateUtilities.codeableConceptCoding(obs.code)}</td>
|
|
3591
|
+
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
3592
|
+
<td>${templateUtilities.extractObservationValueUnit(obs)}</td>
|
|
3593
|
+
<td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
|
|
3594
|
+
<td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
|
|
3595
|
+
<td>${templateUtilities.getOwnerTag(obs)}</td>
|
|
3596
|
+
</tr>`;
|
|
3597
|
+
}
|
|
3616
3598
|
}
|
|
3617
3599
|
html += `
|
|
3618
3600
|
</tbody>
|
|
@@ -3671,7 +3653,7 @@ var PastHistoryOfIllnessTemplate = class {
|
|
|
3671
3653
|
if (!addedConditionCodes.has(conditionCode)) {
|
|
3672
3654
|
addedConditionCodes.add(conditionCode);
|
|
3673
3655
|
html += `<tr>
|
|
3674
|
-
<td class="Name">${conditionCode}</td>
|
|
3656
|
+
<td class="Name">${templateUtilities.capitalizeFirstLetter(conditionCode)}</td>
|
|
3675
3657
|
<td class="CodeSystem">${templateUtilities.codeableConceptCoding(cond.code)}</td>
|
|
3676
3658
|
<td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
|
|
3677
3659
|
<td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
|
|
@@ -3723,8 +3705,8 @@ var PlanOfCareTemplate = class {
|
|
|
3723
3705
|
<tbody>`;
|
|
3724
3706
|
for (const cp of carePlans) {
|
|
3725
3707
|
html += `
|
|
3726
|
-
<tr
|
|
3727
|
-
<td>${cp.description || cp.title || ""}</td>
|
|
3708
|
+
<tr>
|
|
3709
|
+
<td>${templateUtilities.capitalizeFirstLetter(cp.description || cp.title || "")}</td>
|
|
3728
3710
|
<td>${cp.intent || ""}</td>
|
|
3729
3711
|
<td>${templateUtilities.concat(cp.note, "text")}</td>
|
|
3730
3712
|
<td>${cp.period?.start ? templateUtilities.renderTime(cp.period?.start, timezone) : ""}</td>
|
|
@@ -3775,7 +3757,7 @@ var PlanOfCareTemplate = class {
|
|
|
3775
3757
|
isSummaryCreated = true;
|
|
3776
3758
|
html += `
|
|
3777
3759
|
<tr>
|
|
3778
|
-
<td>${data["CarePlan Name"] ?? ""}</td>
|
|
3760
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["CarePlan Name"] ?? "")}</td>
|
|
3779
3761
|
<td>${templateUtilities.renderTime(data["created"], timezone) ?? ""}</td>
|
|
3780
3762
|
<td>${templateUtilities.renderTime(data["period.start"], timezone) ?? ""}</td>
|
|
3781
3763
|
<td>${templateUtilities.renderTime(data["period.end"], timezone) ?? ""}</td>
|
|
@@ -3840,8 +3822,8 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
3840
3822
|
const date = observation.effectiveDateTime ? templateUtilities.renderDate(observation.effectiveDateTime) : observation.issued ? templateUtilities.renderDate(observation.issued) : "";
|
|
3841
3823
|
const interpretation = observation.interpretation ? templateUtilities.codeableConceptDisplay(observation.interpretation[0]) : "";
|
|
3842
3824
|
const comments = observation.comment || observation.note?.map((n) => n.text).join("; ") || "";
|
|
3843
|
-
html += `<tr
|
|
3844
|
-
<td>${obsName}</td>
|
|
3825
|
+
html += `<tr>
|
|
3826
|
+
<td>${templateUtilities.capitalizeFirstLetter(obsName)}</td>
|
|
3845
3827
|
<td>${value ?? ""}</td>
|
|
3846
3828
|
<td>${date}</td>
|
|
3847
3829
|
<td>${interpretation}</td>
|
|
@@ -3871,7 +3853,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
3871
3853
|
}
|
|
3872
3854
|
findingsHtml += "</ul>";
|
|
3873
3855
|
}
|
|
3874
|
-
html += `<tr
|
|
3856
|
+
html += `<tr>
|
|
3875
3857
|
<td>${formattedDate}</td>
|
|
3876
3858
|
<td>${impression.status || ""}</td>
|
|
3877
3859
|
<td>${impression.description || ""}</td>
|
|
@@ -3947,10 +3929,10 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
3947
3929
|
</tr>
|
|
3948
3930
|
</thead>
|
|
3949
3931
|
<tbody>`;
|
|
3950
|
-
function renderRow({
|
|
3932
|
+
function renderRow({ result, comments, date, codeSystem, owner }) {
|
|
3951
3933
|
html += `
|
|
3952
|
-
<tr
|
|
3953
|
-
<td class="Result">${result}</td>
|
|
3934
|
+
<tr>
|
|
3935
|
+
<td class="Result">${templateUtilities.capitalizeFirstLetter(result)}</td>
|
|
3954
3936
|
<td class="CodeSystem">${codeSystem}</td>
|
|
3955
3937
|
<td class="Comments">${comments}</td>
|
|
3956
3938
|
<td class="Date">${date}</td>
|
|
@@ -3981,9 +3963,9 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
3981
3963
|
if (!b.date) return -1;
|
|
3982
3964
|
return new Date(b.date).getTime() - new Date(a.date).getTime();
|
|
3983
3965
|
});
|
|
3966
|
+
const addedRows = /* @__PURE__ */ new Set();
|
|
3984
3967
|
for (const { resource, date, type } of rowResources) {
|
|
3985
3968
|
let result = "", comments = "", dateStr = "", codeSystem = "";
|
|
3986
|
-
const id = templateUtilities.narrativeLinkId(resource);
|
|
3987
3969
|
if (type === "status") {
|
|
3988
3970
|
result = templateUtilities.renderTextAsHtml(templateUtilities.extractPregnancyStatus(resource));
|
|
3989
3971
|
comments = templateUtilities.renderNotes(resource.note, timezone);
|
|
@@ -4005,8 +3987,12 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
4005
3987
|
dateStr = date ? templateUtilities.renderTextAsHtml(templateUtilities.renderTime(date, timezone)) : "";
|
|
4006
3988
|
codeSystem = templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptCoding(resource.code));
|
|
4007
3989
|
}
|
|
4008
|
-
const
|
|
4009
|
-
|
|
3990
|
+
const rowKey = `${result}|${codeSystem}`;
|
|
3991
|
+
if (!addedRows.has(rowKey)) {
|
|
3992
|
+
addedRows.add(rowKey);
|
|
3993
|
+
const owner = templateUtilities.getOwnerTag(resource);
|
|
3994
|
+
renderRow({ result, comments, date: dateStr, codeSystem, owner });
|
|
3995
|
+
}
|
|
4010
3996
|
}
|
|
4011
3997
|
html += `
|
|
4012
3998
|
</tbody>
|
|
@@ -4056,7 +4042,7 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
|
|
|
4056
4042
|
const consent = resourceItem;
|
|
4057
4043
|
html += `
|
|
4058
4044
|
<tr>
|
|
4059
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(consent.scope, "display"))}</td>
|
|
4045
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(consent.scope, "display")))}</td>
|
|
4060
4046
|
<td>${consent.status || ""}</td>
|
|
4061
4047
|
<td>${consent.provision?.action ? templateUtilities.concatCodeableConcept(consent.provision.action) : ""}</td>
|
|
4062
4048
|
<td>${consent.dateTime || ""}</td>
|
|
@@ -4371,14 +4357,17 @@ var ComprehensiveIPSCompositionBuilder = class {
|
|
|
4371
4357
|
const summaryIPSCompositionFilter = useSummaryCompositions ? IPSSectionResourceHelper.getSummaryIPSCompositionFilterForSection(sectionType) : void 0;
|
|
4372
4358
|
const sectionIPSSummary = summaryIPSCompositionFilter ? resources.filter((resource) => summaryIPSCompositionFilter(resource)) : [];
|
|
4373
4359
|
if (sectionIPSSummary.length > 0) {
|
|
4360
|
+
console.log(`Using IPS summary composition for section: ${sectionType}`);
|
|
4374
4361
|
await this.makeSectionFromSummaryAsync(sectionType, sectionIPSSummary, resources, timezone);
|
|
4375
4362
|
continue;
|
|
4376
4363
|
}
|
|
4377
4364
|
const summaryCompositionFilter = useSummaryCompositions ? IPSSectionResourceHelper.getSummaryCompositionFilterForSection(sectionType) : void 0;
|
|
4378
4365
|
const sectionSummary = summaryCompositionFilter ? resources.filter((resource) => summaryCompositionFilter(resource)) : [];
|
|
4379
4366
|
if (sectionSummary.length > 0) {
|
|
4367
|
+
console.log(`Using summary composition for section: ${sectionType}`);
|
|
4380
4368
|
await this.makeSectionFromSummaryAsync(sectionType, sectionSummary, resources, timezone);
|
|
4381
4369
|
} else {
|
|
4370
|
+
console.log(`Using individual resources for section: ${sectionType}`);
|
|
4382
4371
|
const sectionFilter = IPSSectionResourceHelper.getResourceFilterForSection(sectionType);
|
|
4383
4372
|
const sectionResources = resources.filter((resource) => sectionFilter(resource));
|
|
4384
4373
|
await this.makeSectionAsync(sectionType, sectionResources, timezone);
|
package/dist/index.js
CHANGED
|
@@ -910,6 +910,12 @@ var TemplateUtilities = class {
|
|
|
910
910
|
const escapedText = text.replace(/</g, "<").replace(/>/g, ">");
|
|
911
911
|
return escapedText.replace(/\n/g, "<br />");
|
|
912
912
|
}
|
|
913
|
+
capitalizeFirstLetter(text) {
|
|
914
|
+
if (!text || text.length === 0) {
|
|
915
|
+
return "";
|
|
916
|
+
}
|
|
917
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
918
|
+
}
|
|
913
919
|
/**
|
|
914
920
|
* Renders note elements from a FHIR resource in a standardized format
|
|
915
921
|
* Can render as simple comma-separated text or as styled HTML with timestamps
|
|
@@ -1786,7 +1792,7 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1786
1792
|
isSummaryCreated = true;
|
|
1787
1793
|
html += `
|
|
1788
1794
|
<tr>
|
|
1789
|
-
<td>${data["allergen"] ?? ""}</td>
|
|
1795
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["allergen"] ?? "")}</td>
|
|
1790
1796
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
1791
1797
|
<td>${data["criticality"] ?? ""}</td>
|
|
1792
1798
|
<td>${templateUtilities.renderTime(data["recordedDate"], timezone) ?? ""}</td>
|
|
@@ -1904,8 +1910,8 @@ var AllergyIntoleranceTemplate = class _AllergyIntoleranceTemplate {
|
|
|
1904
1910
|
let html = "";
|
|
1905
1911
|
for (const allergy of allergies) {
|
|
1906
1912
|
html += `
|
|
1907
|
-
<tr
|
|
1908
|
-
<td class="Name"><span class="AllergenName">${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(allergy.code))}</span></td>
|
|
1913
|
+
<tr>
|
|
1914
|
+
<td class="Name"><span class="AllergenName">${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(allergy.code)))}</span></td>
|
|
1909
1915
|
<td class="Status">${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(allergy.clinicalStatus)) || ""}</td>
|
|
1910
1916
|
<td class="CodeSystem">${templateUtilities.codeableConceptCoding(allergy.code)}</td>
|
|
1911
1917
|
<td class="Category">${templateUtilities.renderTextAsHtml(templateUtilities.safeConcat(allergy.category)) || ""}</td>
|
|
@@ -2022,7 +2028,7 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2022
2028
|
isSummaryCreated = true;
|
|
2023
2029
|
html += `
|
|
2024
2030
|
<tr>
|
|
2025
|
-
<td>${templateUtilities.renderTextAsHtml(data["medication"])}</td>
|
|
2031
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(data["medication"]))}</td>
|
|
2026
2032
|
<td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
|
|
2027
2033
|
<td>${templateUtilities.renderTextAsHtml(data["status"])}</td>
|
|
2028
2034
|
<td>${templateUtilities.renderTextAsHtml(data["sig-prescriber"] || data["sig-pharmacy"])}</td>
|
|
@@ -2069,8 +2075,8 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2069
2075
|
static generateStaticNarrative(resources, timezone, now) {
|
|
2070
2076
|
const templateUtilities = new TemplateUtilities(resources);
|
|
2071
2077
|
let html = "";
|
|
2072
|
-
const medicationRequests =
|
|
2073
|
-
const medicationStatements =
|
|
2078
|
+
const medicationRequests = resources.filter((entry) => entry.resourceType === "MedicationRequest");
|
|
2079
|
+
const medicationStatements = resources.filter((entry) => entry.resourceType === "MedicationStatement");
|
|
2074
2080
|
const allActiveMedications = [];
|
|
2075
2081
|
const currentDate = now || /* @__PURE__ */ new Date();
|
|
2076
2082
|
const twoYearsAgo = new Date(currentDate);
|
|
@@ -2078,10 +2084,10 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2078
2084
|
let skippedMedications = 0;
|
|
2079
2085
|
const allMedications = [];
|
|
2080
2086
|
medicationRequests.forEach((mr) => {
|
|
2081
|
-
allMedications.push({ type: "request", resource: mr
|
|
2087
|
+
allMedications.push({ type: "request", resource: mr });
|
|
2082
2088
|
});
|
|
2083
2089
|
medicationStatements.forEach((ms) => {
|
|
2084
|
-
allMedications.push({ type: "statement", resource: ms
|
|
2090
|
+
allMedications.push({ type: "statement", resource: ms });
|
|
2085
2091
|
});
|
|
2086
2092
|
for (const med of allMedications) {
|
|
2087
2093
|
let dateString;
|
|
@@ -2138,36 +2144,6 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2138
2144
|
}
|
|
2139
2145
|
return "";
|
|
2140
2146
|
}
|
|
2141
|
-
/**
|
|
2142
|
-
* Extract MedicationRequest resources
|
|
2143
|
-
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
2144
|
-
* @param resources - FHIR Medication resources
|
|
2145
|
-
* @returns Array of MedicationRequest resources
|
|
2146
|
-
*/
|
|
2147
|
-
static getMedicationRequests(templateUtilities, resources) {
|
|
2148
|
-
if (resources.length === 0) {
|
|
2149
|
-
return [];
|
|
2150
|
-
}
|
|
2151
|
-
return resources.filter((entry) => entry.resourceType === "MedicationRequest").map((entry) => ({
|
|
2152
|
-
resource: entry,
|
|
2153
|
-
extension: templateUtilities.narrativeLinkExtension(entry)
|
|
2154
|
-
}));
|
|
2155
|
-
}
|
|
2156
|
-
/**
|
|
2157
|
-
* Extract MedicationStatement resources
|
|
2158
|
-
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
2159
|
-
* @param resources - FHIR Medication resources
|
|
2160
|
-
* @returns Array of MedicationStatement resources
|
|
2161
|
-
*/
|
|
2162
|
-
static getMedicationStatements(templateUtilities, resources) {
|
|
2163
|
-
if (resources.length === 0) {
|
|
2164
|
-
return [];
|
|
2165
|
-
}
|
|
2166
|
-
return resources.filter((entry) => entry.resourceType === "MedicationStatement").map((entry) => ({
|
|
2167
|
-
resource: entry,
|
|
2168
|
-
extension: templateUtilities.narrativeLinkExtension(entry)
|
|
2169
|
-
}));
|
|
2170
|
-
}
|
|
2171
2147
|
/**
|
|
2172
2148
|
* Render HTML table for combined MedicationRequest and MedicationStatement resources
|
|
2173
2149
|
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
@@ -2191,7 +2167,6 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2191
2167
|
</thead>
|
|
2192
2168
|
<tbody>`;
|
|
2193
2169
|
for (const medication of medications) {
|
|
2194
|
-
const narrativeLinkId = templateUtilities.narrativeLinkId(medication.extension);
|
|
2195
2170
|
let type;
|
|
2196
2171
|
let medicationName;
|
|
2197
2172
|
let sig;
|
|
@@ -2238,9 +2213,9 @@ var MedicationSummaryTemplate = class _MedicationSummaryTemplate {
|
|
|
2238
2213
|
}
|
|
2239
2214
|
}
|
|
2240
2215
|
html += `
|
|
2241
|
-
<tr
|
|
2216
|
+
<tr>
|
|
2242
2217
|
<td>${type}</td>
|
|
2243
|
-
<td>${medicationName}
|
|
2218
|
+
<td>${templateUtilities.capitalizeFirstLetter(medicationName)}</td>
|
|
2244
2219
|
<td>${codeSystemDisplay}</td>
|
|
2245
2220
|
<td>${sig}</td>
|
|
2246
2221
|
<td>${dispenseQuantity}</td>
|
|
@@ -2322,7 +2297,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2322
2297
|
isSummaryCreated = true;
|
|
2323
2298
|
html += `
|
|
2324
2299
|
<tr>
|
|
2325
|
-
<td>${data["immunization"] ?? ""}</td>
|
|
2300
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["immunization"] ?? "")}</td>
|
|
2326
2301
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
2327
2302
|
<td>${data["status"] ?? ""}</td>
|
|
2328
2303
|
<td>${templateUtilities.renderTime(data["occurrenceDateTime"], timezone) ?? ""}</td>
|
|
@@ -2367,7 +2342,7 @@ var ImmunizationsTemplate = class _ImmunizationsTemplate {
|
|
|
2367
2342
|
const imm = resourceItem;
|
|
2368
2343
|
html += `
|
|
2369
2344
|
<tr>
|
|
2370
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(imm.vaccineCode))}</td>
|
|
2345
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(imm.vaccineCode)))}</td>
|
|
2371
2346
|
<td>${templateUtilities.codeableConceptCoding(imm.vaccineCode)}</td>
|
|
2372
2347
|
<td>${imm.status || ""}</td>
|
|
2373
2348
|
<td>${templateUtilities.concatDoseNumber(imm.protocolApplied)}</td>
|
|
@@ -2438,7 +2413,7 @@ var ProblemListTemplate = class _ProblemListTemplate {
|
|
|
2438
2413
|
}
|
|
2439
2414
|
seenCodeAndSystems.add(codeAndSystem);
|
|
2440
2415
|
html += `<tr>
|
|
2441
|
-
<td class="Name">${conditionDisplay}</td>
|
|
2416
|
+
<td class="Name">${templateUtilities.capitalizeFirstLetter(conditionDisplay)}</td>
|
|
2442
2417
|
<td class="CodeSystem">${codeAndSystem}</td>
|
|
2443
2418
|
<td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
|
|
2444
2419
|
<td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
|
|
@@ -2518,7 +2493,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2518
2493
|
isSummaryCreated = true;
|
|
2519
2494
|
html += `
|
|
2520
2495
|
<tr>
|
|
2521
|
-
<td>${data["Vital Name"] ?? ""}</td>
|
|
2496
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["Vital Name"] ?? "")}</td>
|
|
2522
2497
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
2523
2498
|
<td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
|
|
2524
2499
|
<td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
|
|
@@ -2567,7 +2542,7 @@ var VitalSignsTemplate = class _VitalSignsTemplate {
|
|
|
2567
2542
|
for (const obs of observations) {
|
|
2568
2543
|
html += `
|
|
2569
2544
|
<tr>
|
|
2570
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(obs.code, "display"))}</td>
|
|
2545
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(obs.code, "display")))}</td>
|
|
2571
2546
|
<td>${templateUtilities.codeableConceptCoding(obs.code)}</td>
|
|
2572
2547
|
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
2573
2548
|
<td>${templateUtilities.extractObservationValueUnit(obs)}</td>
|
|
@@ -2620,10 +2595,12 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
|
|
|
2620
2595
|
const dateB = b.recordedOn;
|
|
2621
2596
|
return typeof dateA === "string" && typeof dateB === "string" ? new Date(dateB).getTime() - new Date(dateA).getTime() : 0;
|
|
2622
2597
|
});
|
|
2598
|
+
let isDeviceAdded = false;
|
|
2623
2599
|
for (const dus of deviceStatements) {
|
|
2600
|
+
isDeviceAdded = true;
|
|
2624
2601
|
html += `
|
|
2625
2602
|
<tr>
|
|
2626
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.renderDevice(dus.device))}</td>
|
|
2603
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.renderDevice(dus.device)))}</td>
|
|
2627
2604
|
<td>${templateUtilities.renderTextAsHtml(dus.status || "")}</td>
|
|
2628
2605
|
<td>${templateUtilities.renderNotes(dus.note, timezone)}</td>
|
|
2629
2606
|
<td>${templateUtilities.renderTextAsHtml(templateUtilities.renderRecorded(dus.recordedOn, timezone))}</td>
|
|
@@ -2632,7 +2609,7 @@ var MedicalDevicesTemplate = class _MedicalDevicesTemplate {
|
|
|
2632
2609
|
html += `
|
|
2633
2610
|
</tbody>
|
|
2634
2611
|
</table>`;
|
|
2635
|
-
return html;
|
|
2612
|
+
return isDeviceAdded ? html : void 0;
|
|
2636
2613
|
}
|
|
2637
2614
|
};
|
|
2638
2615
|
|
|
@@ -3089,7 +3066,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3089
3066
|
this.formatSummaryObservationData(component);
|
|
3090
3067
|
observationhtml += `
|
|
3091
3068
|
<tr>
|
|
3092
|
-
<td>${componentCode}</td>
|
|
3069
|
+
<td>${templateUtilities.capitalizeFirstLetter(componentCode)}</td>
|
|
3093
3070
|
<td></td>
|
|
3094
3071
|
<td>${templateUtilities.renderTextAsHtml(component["formattedValue"]) ?? ""}</td>
|
|
3095
3072
|
<td>${templateUtilities.renderTextAsHtml(component["referenceRange"])?.trim() ?? ""}</td>
|
|
@@ -3106,7 +3083,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3106
3083
|
this.formatSummaryObservationData(data);
|
|
3107
3084
|
observationhtml += `
|
|
3108
3085
|
<tr>
|
|
3109
|
-
<td>${data["code"] ?? ""}</td>
|
|
3086
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["code"] ?? "")}</td>
|
|
3110
3087
|
<td>${templateUtilities.codeableConceptCoding(sectionCodeableConcept)}</td>
|
|
3111
3088
|
<td>${templateUtilities.renderTextAsHtml(data["formattedValue"]) ?? ""}</td>
|
|
3112
3089
|
<td>${templateUtilities.renderTextAsHtml(data["referenceRange"])?.trim() ?? ""}</td>
|
|
@@ -3127,7 +3104,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3127
3104
|
diagnosticReportAdded.add(reportName);
|
|
3128
3105
|
diagnosticReporthtml += `
|
|
3129
3106
|
<tr>
|
|
3130
|
-
<td>${data["report"] ?? ""}</td>
|
|
3107
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["report"] ?? "")}</td>
|
|
3131
3108
|
<td>${data["performer"] ?? ""}</td>
|
|
3132
3109
|
<td>${templateUtilities.renderTime(data["issued"], timezone) ?? ""}</td>
|
|
3133
3110
|
<td>${data["source"] ?? ""}</td>
|
|
@@ -3327,8 +3304,8 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3327
3304
|
observationAdded.add(obsCodeDisplay);
|
|
3328
3305
|
observationAdded.add(obsCodeAndSystem);
|
|
3329
3306
|
html += `
|
|
3330
|
-
<tr
|
|
3331
|
-
<td>${obsCodeDisplay}</td>
|
|
3307
|
+
<tr>
|
|
3308
|
+
<td>${templateUtilities.capitalizeFirstLetter(obsCodeDisplay)}</td>
|
|
3332
3309
|
<td>${templateUtilities.codeableConceptCoding(obs.code)}</td>
|
|
3333
3310
|
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
3334
3311
|
<td>${templateUtilities.concatReferenceRange(obs.referenceRange)}</td>
|
|
@@ -3376,8 +3353,8 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
|
|
|
3376
3353
|
resultCount = `${report.result.length} result${report.result.length !== 1 ? "s" : ""}`;
|
|
3377
3354
|
}
|
|
3378
3355
|
html += `
|
|
3379
|
-
<tr
|
|
3380
|
-
<td>${reportName}</td>
|
|
3356
|
+
<tr>
|
|
3357
|
+
<td>${templateUtilities.capitalizeFirstLetter(reportName)}</td>
|
|
3381
3358
|
<td>${codeAndSystem}</td>
|
|
3382
3359
|
<td>${templateUtilities.firstFromCodeableConceptList(report.category)}</td>
|
|
3383
3360
|
<td>${resultCount}</td>
|
|
@@ -3479,7 +3456,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3479
3456
|
isSummaryCreated = true;
|
|
3480
3457
|
html += `
|
|
3481
3458
|
<tr>
|
|
3482
|
-
<td>${data["procedure"] ?? ""}</td>
|
|
3459
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["procedure"] ?? "")}</td>
|
|
3483
3460
|
<td>${data["codeSystem"] ?? ""}</td>
|
|
3484
3461
|
<td>${data["performer"] ?? ""}</td>
|
|
3485
3462
|
<td>${templateUtilities.renderTime(data["date"], timezone) ?? ""}</td>
|
|
@@ -3519,7 +3496,7 @@ var HistoryOfProceduresTemplate = class _HistoryOfProceduresTemplate {
|
|
|
3519
3496
|
const proc = resourceItem;
|
|
3520
3497
|
html += `
|
|
3521
3498
|
<tr>
|
|
3522
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(proc.code, "display"))}</td>
|
|
3499
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(proc.code, "display")))}</td>
|
|
3523
3500
|
<td>${templateUtilities.codeableConceptCoding(proc.code)}</td>
|
|
3524
3501
|
<td>${templateUtilities.renderNotes(proc.note, timezone)}</td>
|
|
3525
3502
|
<td>${templateUtilities.renderTime(proc.performedDateTime || proc.performedPeriod?.start, timezone)}</td>
|
|
@@ -3574,17 +3551,22 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
|
|
|
3574
3551
|
</tr>
|
|
3575
3552
|
</thead>
|
|
3576
3553
|
<tbody>`;
|
|
3554
|
+
const addedObservations = /* @__PURE__ */ new Set();
|
|
3577
3555
|
for (const obs of observations) {
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
<
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3556
|
+
const obsName = templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(obs.code));
|
|
3557
|
+
if (!addedObservations.has(obsName)) {
|
|
3558
|
+
addedObservations.add(obsName);
|
|
3559
|
+
html += `
|
|
3560
|
+
<tr>
|
|
3561
|
+
<td>${templateUtilities.capitalizeFirstLetter(obsName)}</td>
|
|
3562
|
+
<td>${templateUtilities.codeableConceptCoding(obs.code)}</td>
|
|
3563
|
+
<td>${templateUtilities.extractObservationValue(obs)}</td>
|
|
3564
|
+
<td>${templateUtilities.extractObservationValueUnit(obs)}</td>
|
|
3565
|
+
<td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
|
|
3566
|
+
<td>${obs.effectiveDateTime ? templateUtilities.renderTime(obs.effectiveDateTime, timezone) : obs.effectivePeriod ? templateUtilities.renderPeriod(obs.effectivePeriod, timezone) : ""}</td>
|
|
3567
|
+
<td>${templateUtilities.getOwnerTag(obs)}</td>
|
|
3568
|
+
</tr>`;
|
|
3569
|
+
}
|
|
3588
3570
|
}
|
|
3589
3571
|
html += `
|
|
3590
3572
|
</tbody>
|
|
@@ -3643,7 +3625,7 @@ var PastHistoryOfIllnessTemplate = class {
|
|
|
3643
3625
|
if (!addedConditionCodes.has(conditionCode)) {
|
|
3644
3626
|
addedConditionCodes.add(conditionCode);
|
|
3645
3627
|
html += `<tr>
|
|
3646
|
-
<td class="Name">${conditionCode}</td>
|
|
3628
|
+
<td class="Name">${templateUtilities.capitalizeFirstLetter(conditionCode)}</td>
|
|
3647
3629
|
<td class="CodeSystem">${templateUtilities.codeableConceptCoding(cond.code)}</td>
|
|
3648
3630
|
<td class="OnsetDate">${templateUtilities.renderDate(cond.onsetDateTime)}</td>
|
|
3649
3631
|
<td class="RecordedDate">${templateUtilities.renderDate(cond.recordedDate)}</td>
|
|
@@ -3695,8 +3677,8 @@ var PlanOfCareTemplate = class {
|
|
|
3695
3677
|
<tbody>`;
|
|
3696
3678
|
for (const cp of carePlans) {
|
|
3697
3679
|
html += `
|
|
3698
|
-
<tr
|
|
3699
|
-
<td>${cp.description || cp.title || ""}</td>
|
|
3680
|
+
<tr>
|
|
3681
|
+
<td>${templateUtilities.capitalizeFirstLetter(cp.description || cp.title || "")}</td>
|
|
3700
3682
|
<td>${cp.intent || ""}</td>
|
|
3701
3683
|
<td>${templateUtilities.concat(cp.note, "text")}</td>
|
|
3702
3684
|
<td>${cp.period?.start ? templateUtilities.renderTime(cp.period?.start, timezone) : ""}</td>
|
|
@@ -3747,7 +3729,7 @@ var PlanOfCareTemplate = class {
|
|
|
3747
3729
|
isSummaryCreated = true;
|
|
3748
3730
|
html += `
|
|
3749
3731
|
<tr>
|
|
3750
|
-
<td>${data["CarePlan Name"] ?? ""}</td>
|
|
3732
|
+
<td>${templateUtilities.capitalizeFirstLetter(data["CarePlan Name"] ?? "")}</td>
|
|
3751
3733
|
<td>${templateUtilities.renderTime(data["created"], timezone) ?? ""}</td>
|
|
3752
3734
|
<td>${templateUtilities.renderTime(data["period.start"], timezone) ?? ""}</td>
|
|
3753
3735
|
<td>${templateUtilities.renderTime(data["period.end"], timezone) ?? ""}</td>
|
|
@@ -3812,8 +3794,8 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
3812
3794
|
const date = observation.effectiveDateTime ? templateUtilities.renderDate(observation.effectiveDateTime) : observation.issued ? templateUtilities.renderDate(observation.issued) : "";
|
|
3813
3795
|
const interpretation = observation.interpretation ? templateUtilities.codeableConceptDisplay(observation.interpretation[0]) : "";
|
|
3814
3796
|
const comments = observation.comment || observation.note?.map((n) => n.text).join("; ") || "";
|
|
3815
|
-
html += `<tr
|
|
3816
|
-
<td>${obsName}</td>
|
|
3797
|
+
html += `<tr>
|
|
3798
|
+
<td>${templateUtilities.capitalizeFirstLetter(obsName)}</td>
|
|
3817
3799
|
<td>${value ?? ""}</td>
|
|
3818
3800
|
<td>${date}</td>
|
|
3819
3801
|
<td>${interpretation}</td>
|
|
@@ -3843,7 +3825,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
3843
3825
|
}
|
|
3844
3826
|
findingsHtml += "</ul>";
|
|
3845
3827
|
}
|
|
3846
|
-
html += `<tr
|
|
3828
|
+
html += `<tr>
|
|
3847
3829
|
<td>${formattedDate}</td>
|
|
3848
3830
|
<td>${impression.status || ""}</td>
|
|
3849
3831
|
<td>${impression.description || ""}</td>
|
|
@@ -3919,10 +3901,10 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
3919
3901
|
</tr>
|
|
3920
3902
|
</thead>
|
|
3921
3903
|
<tbody>`;
|
|
3922
|
-
function renderRow({
|
|
3904
|
+
function renderRow({ result, comments, date, codeSystem, owner }) {
|
|
3923
3905
|
html += `
|
|
3924
|
-
<tr
|
|
3925
|
-
<td class="Result">${result}</td>
|
|
3906
|
+
<tr>
|
|
3907
|
+
<td class="Result">${templateUtilities.capitalizeFirstLetter(result)}</td>
|
|
3926
3908
|
<td class="CodeSystem">${codeSystem}</td>
|
|
3927
3909
|
<td class="Comments">${comments}</td>
|
|
3928
3910
|
<td class="Date">${date}</td>
|
|
@@ -3953,9 +3935,9 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
3953
3935
|
if (!b.date) return -1;
|
|
3954
3936
|
return new Date(b.date).getTime() - new Date(a.date).getTime();
|
|
3955
3937
|
});
|
|
3938
|
+
const addedRows = /* @__PURE__ */ new Set();
|
|
3956
3939
|
for (const { resource, date, type } of rowResources) {
|
|
3957
3940
|
let result = "", comments = "", dateStr = "", codeSystem = "";
|
|
3958
|
-
const id = templateUtilities.narrativeLinkId(resource);
|
|
3959
3941
|
if (type === "status") {
|
|
3960
3942
|
result = templateUtilities.renderTextAsHtml(templateUtilities.extractPregnancyStatus(resource));
|
|
3961
3943
|
comments = templateUtilities.renderNotes(resource.note, timezone);
|
|
@@ -3977,8 +3959,12 @@ var PregnancyTemplate = class _PregnancyTemplate {
|
|
|
3977
3959
|
dateStr = date ? templateUtilities.renderTextAsHtml(templateUtilities.renderTime(date, timezone)) : "";
|
|
3978
3960
|
codeSystem = templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptCoding(resource.code));
|
|
3979
3961
|
}
|
|
3980
|
-
const
|
|
3981
|
-
|
|
3962
|
+
const rowKey = `${result}|${codeSystem}`;
|
|
3963
|
+
if (!addedRows.has(rowKey)) {
|
|
3964
|
+
addedRows.add(rowKey);
|
|
3965
|
+
const owner = templateUtilities.getOwnerTag(resource);
|
|
3966
|
+
renderRow({ result, comments, date: dateStr, codeSystem, owner });
|
|
3967
|
+
}
|
|
3982
3968
|
}
|
|
3983
3969
|
html += `
|
|
3984
3970
|
</tbody>
|
|
@@ -4028,7 +4014,7 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
|
|
|
4028
4014
|
const consent = resourceItem;
|
|
4029
4015
|
html += `
|
|
4030
4016
|
<tr>
|
|
4031
|
-
<td>${templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(consent.scope, "display"))}</td>
|
|
4017
|
+
<td>${templateUtilities.capitalizeFirstLetter(templateUtilities.renderTextAsHtml(templateUtilities.codeableConceptDisplay(consent.scope, "display")))}</td>
|
|
4032
4018
|
<td>${consent.status || ""}</td>
|
|
4033
4019
|
<td>${consent.provision?.action ? templateUtilities.concatCodeableConcept(consent.provision.action) : ""}</td>
|
|
4034
4020
|
<td>${consent.dateTime || ""}</td>
|
|
@@ -4343,14 +4329,17 @@ var ComprehensiveIPSCompositionBuilder = class {
|
|
|
4343
4329
|
const summaryIPSCompositionFilter = useSummaryCompositions ? IPSSectionResourceHelper.getSummaryIPSCompositionFilterForSection(sectionType) : void 0;
|
|
4344
4330
|
const sectionIPSSummary = summaryIPSCompositionFilter ? resources.filter((resource) => summaryIPSCompositionFilter(resource)) : [];
|
|
4345
4331
|
if (sectionIPSSummary.length > 0) {
|
|
4332
|
+
console.log(`Using IPS summary composition for section: ${sectionType}`);
|
|
4346
4333
|
await this.makeSectionFromSummaryAsync(sectionType, sectionIPSSummary, resources, timezone);
|
|
4347
4334
|
continue;
|
|
4348
4335
|
}
|
|
4349
4336
|
const summaryCompositionFilter = useSummaryCompositions ? IPSSectionResourceHelper.getSummaryCompositionFilterForSection(sectionType) : void 0;
|
|
4350
4337
|
const sectionSummary = summaryCompositionFilter ? resources.filter((resource) => summaryCompositionFilter(resource)) : [];
|
|
4351
4338
|
if (sectionSummary.length > 0) {
|
|
4339
|
+
console.log(`Using summary composition for section: ${sectionType}`);
|
|
4352
4340
|
await this.makeSectionFromSummaryAsync(sectionType, sectionSummary, resources, timezone);
|
|
4353
4341
|
} else {
|
|
4342
|
+
console.log(`Using individual resources for section: ${sectionType}`);
|
|
4354
4343
|
const sectionFilter = IPSSectionResourceHelper.getResourceFilterForSection(sectionType);
|
|
4355
4344
|
const sectionResources = resources.filter((resource) => sectionFilter(resource));
|
|
4356
4345
|
await this.makeSectionAsync(sectionType, sectionResources, timezone);
|