@imranq2/fhirpatientsummary 1.0.12 → 1.0.13
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 +20 -100
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +20 -100
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,6 @@ var IPSSections = /* @__PURE__ */ ((IPSSections2) => {
|
|
|
43
43
|
IPSSections2["MEDICAL_HISTORY"] = "HistoryOfPastIllnessSection";
|
|
44
44
|
IPSSections2["SOCIAL_HISTORY"] = "SocialHistorySection";
|
|
45
45
|
IPSSections2["VITAL_SIGNS"] = "VitalSignsSection";
|
|
46
|
-
IPSSections2["FAMILY_HISTORY"] = "FamilyHistorySection";
|
|
47
46
|
return IPSSections2;
|
|
48
47
|
})(IPSSections || {});
|
|
49
48
|
|
|
@@ -58,7 +57,6 @@ var IPS_SECTION_LOINC_CODES = {
|
|
|
58
57
|
["MedicalDeviceSection" /* MEDICAL_DEVICES */]: "46264-8",
|
|
59
58
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: "30954-2",
|
|
60
59
|
["HistoryOfProceduresSection" /* PROCEDURES */]: "47519-4",
|
|
61
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: "10157-6",
|
|
62
60
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: "29762-2",
|
|
63
61
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: "10162-6",
|
|
64
62
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: "47420-5",
|
|
@@ -81,10 +79,9 @@ var IPS_SECTION_DISPLAY_NAMES = {
|
|
|
81
79
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: "History of Pregnancies",
|
|
82
80
|
["PlanOfCareSection" /* CARE_PLAN */]: "Plan of Care",
|
|
83
81
|
["HistoryOfPastIllnessSection" /* MEDICAL_HISTORY */]: "History of Past Illness",
|
|
84
|
-
["SocialHistorySection" /* SOCIAL_HISTORY */]: "Social History"
|
|
85
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: "History of Family Member Diseases"
|
|
82
|
+
["SocialHistorySection" /* SOCIAL_HISTORY */]: "Social History"
|
|
86
83
|
};
|
|
87
|
-
var
|
|
84
|
+
var PREGNANCY_LOINC_CODES = {
|
|
88
85
|
PREGNANCY_STATUS: {
|
|
89
86
|
"LA15173-0": "Pregnant",
|
|
90
87
|
"LA26683-5": "Not pregnant",
|
|
@@ -102,7 +99,7 @@ var PREGNANCY_LONIC_CODES = {
|
|
|
102
99
|
"33065-4": "Ectopic Pregnancy"
|
|
103
100
|
}
|
|
104
101
|
};
|
|
105
|
-
var
|
|
102
|
+
var SOCIAL_HISTORY_LOINC_CODES = {
|
|
106
103
|
"72166-2": "Tobacco Use",
|
|
107
104
|
"74013-4": "Alcohol Use"
|
|
108
105
|
};
|
|
@@ -121,7 +118,6 @@ var IPSSectionResourceMap = {
|
|
|
121
118
|
// Device resource is used for medical devices name
|
|
122
119
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: ["DiagnosticReport", "Observation"],
|
|
123
120
|
["HistoryOfProceduresSection" /* PROCEDURES */]: ["Procedure"],
|
|
124
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: ["FamilyMemberHistory"],
|
|
125
121
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: ["Observation"],
|
|
126
122
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: ["Observation"],
|
|
127
123
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: ["Condition", "ClinicalImpression"],
|
|
@@ -142,12 +138,10 @@ var IPSSectionResourceFilters = {
|
|
|
142
138
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: (resource) => ["DiagnosticReport", "Observation"].includes(resource.resourceType) && resource.status === "final",
|
|
143
139
|
// Only include completed procedures
|
|
144
140
|
["HistoryOfProceduresSection" /* PROCEDURES */]: (resource) => resource.resourceType === "Procedure" && resource.status === "completed",
|
|
145
|
-
// Only include family history resources
|
|
146
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: (resource) => resource.resourceType === "FamilyMemberHistory",
|
|
147
141
|
// Only include social history Observations (category.coding contains 'social-history')
|
|
148
|
-
["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Observation" && resource.code?.coding?.some((c) => Object.keys(
|
|
142
|
+
["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Observation" && resource.code?.coding?.some((c) => Object.keys(SOCIAL_HISTORY_LOINC_CODES).includes(c.code)),
|
|
149
143
|
// Only include pregnancy history Observations (category.coding contains 'pregnancy')
|
|
150
|
-
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: (resource) => resource.resourceType === "Observation" && (resource.code?.coding?.some((c) => Object.keys(
|
|
144
|
+
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: (resource) => resource.resourceType === "Observation" && (resource.code?.coding?.some((c) => Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_STATUS).includes(c.code)) || resource.valueCodeableConcept?.coding?.some((c) => Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME).includes(c.code))),
|
|
151
145
|
// Only include active functional status Conditions or ClinicalImpressions
|
|
152
146
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: (resource) => resource.resourceType === "Condition" && resource.clinicalStatus?.coding?.some((c) => typeof c.code === "string") || resource.resourceType === "ClinicalImpression" && resource.status === "completed",
|
|
153
147
|
// Only include resolved medical history Conditions
|
|
@@ -577,17 +571,17 @@ var TemplateUtilities = class {
|
|
|
577
571
|
extractPregnancyStatus(observation) {
|
|
578
572
|
let status = "";
|
|
579
573
|
observation.code?.coding?.forEach((c) => {
|
|
580
|
-
if (c.code && Object.keys(
|
|
581
|
-
status =
|
|
574
|
+
if (c.code && Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_STATUS).includes(c.code)) {
|
|
575
|
+
status = PREGNANCY_LOINC_CODES.PREGNANCY_STATUS[c.code];
|
|
582
576
|
}
|
|
583
577
|
});
|
|
584
578
|
if (observation.valueCodeableConcept) {
|
|
585
579
|
observation.valueCodeableConcept.coding?.forEach((c) => {
|
|
586
|
-
if (c.code && Object.keys(
|
|
580
|
+
if (c.code && Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME).includes(c.code)) {
|
|
587
581
|
if (status) {
|
|
588
582
|
status += " - ";
|
|
589
583
|
}
|
|
590
|
-
status +=
|
|
584
|
+
status += PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME[c.code];
|
|
591
585
|
}
|
|
592
586
|
});
|
|
593
587
|
}
|
|
@@ -1988,8 +1982,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
1988
1982
|
</tr>`;
|
|
1989
1983
|
}
|
|
1990
1984
|
html += `</tbody>
|
|
1991
|
-
</table
|
|
1992
|
-
</div>`;
|
|
1985
|
+
</table>`;
|
|
1993
1986
|
}
|
|
1994
1987
|
if (clinicalImpressions.length > 0) {
|
|
1995
1988
|
html += `<h3>Clinical Impressions</h3>
|
|
@@ -2041,6 +2034,8 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
2041
2034
|
<td>${notes}</td>
|
|
2042
2035
|
</tr>`;
|
|
2043
2036
|
}
|
|
2037
|
+
html += `</tbody>
|
|
2038
|
+
</table>`;
|
|
2044
2039
|
}
|
|
2045
2040
|
return html;
|
|
2046
2041
|
}
|
|
@@ -2154,87 +2149,6 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
|
|
|
2154
2149
|
}
|
|
2155
2150
|
};
|
|
2156
2151
|
|
|
2157
|
-
// src/narratives/templates/typescript/FamilyHistoryTemplate.ts
|
|
2158
|
-
var FamilyHistoryTemplate = class {
|
|
2159
|
-
/**
|
|
2160
|
-
* Generate HTML narrative for Family History
|
|
2161
|
-
* @param resource - FHIR Bundle containing FamilyMemberHistory resources
|
|
2162
|
-
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
2163
|
-
* @returns HTML string for rendering
|
|
2164
|
-
*/
|
|
2165
|
-
generateNarrative(resource, timezone) {
|
|
2166
|
-
const templateUtilities = new TemplateUtilities(resource);
|
|
2167
|
-
let html = `
|
|
2168
|
-
<h5>Family History</h5>
|
|
2169
|
-
<table>
|
|
2170
|
-
<thead>
|
|
2171
|
-
<tr>
|
|
2172
|
-
<th>Relationship</th>
|
|
2173
|
-
<th>Condition</th>
|
|
2174
|
-
<th>Status</th>
|
|
2175
|
-
<th>Onset</th>
|
|
2176
|
-
<th>Notes</th>
|
|
2177
|
-
</tr>
|
|
2178
|
-
</thead>
|
|
2179
|
-
<tbody>`;
|
|
2180
|
-
if (resource.entry && Array.isArray(resource.entry)) {
|
|
2181
|
-
let hasFamilyHistory = false;
|
|
2182
|
-
for (const entry of resource.entry) {
|
|
2183
|
-
const familyHistory = entry.resource;
|
|
2184
|
-
if (!familyHistory || familyHistory.resourceType !== "FamilyMemberHistory") {
|
|
2185
|
-
continue;
|
|
2186
|
-
}
|
|
2187
|
-
hasFamilyHistory = true;
|
|
2188
|
-
const fmh = familyHistory;
|
|
2189
|
-
const relationship = templateUtilities.codeableConcept(fmh.relationship, "display");
|
|
2190
|
-
if (fmh.condition && Array.isArray(fmh.condition)) {
|
|
2191
|
-
for (const condition of fmh.condition) {
|
|
2192
|
-
const conditionCode = templateUtilities.codeableConcept(condition.code, "display");
|
|
2193
|
-
const status = fmh.status || "";
|
|
2194
|
-
let onset = "";
|
|
2195
|
-
if (condition.onsetAge) {
|
|
2196
|
-
onset = templateUtilities.renderOnset(condition.onsetAge, timezone);
|
|
2197
|
-
}
|
|
2198
|
-
const notes = condition.note ? templateUtilities.renderNotes(condition.note, timezone) : templateUtilities.renderNotes(fmh.note, timezone);
|
|
2199
|
-
html += `
|
|
2200
|
-
<tr id="${templateUtilities.narrativeLinkId(fmh)}">
|
|
2201
|
-
<td>${relationship}</td>
|
|
2202
|
-
<td>${conditionCode}</td>
|
|
2203
|
-
<td>${status}</td>
|
|
2204
|
-
<td>${onset}</td>
|
|
2205
|
-
<td>${notes}</td>
|
|
2206
|
-
</tr>`;
|
|
2207
|
-
}
|
|
2208
|
-
} else {
|
|
2209
|
-
html += `
|
|
2210
|
-
<tr id="${templateUtilities.narrativeLinkId(fmh)}">
|
|
2211
|
-
<td>${relationship}</td>
|
|
2212
|
-
<td>Not specified</td>
|
|
2213
|
-
<td>${fmh.status || ""}</td>
|
|
2214
|
-
<td></td>
|
|
2215
|
-
<td>${templateUtilities.renderNotes(fmh.note, timezone)}</td>
|
|
2216
|
-
</tr>`;
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
if (!hasFamilyHistory) {
|
|
2220
|
-
html += `
|
|
2221
|
-
<tr>
|
|
2222
|
-
<td colspan="5">No family history recorded</td>
|
|
2223
|
-
</tr>`;
|
|
2224
|
-
}
|
|
2225
|
-
} else {
|
|
2226
|
-
html += `
|
|
2227
|
-
<tr>
|
|
2228
|
-
<td colspan="5">No family history recorded</td>
|
|
2229
|
-
</tr>`;
|
|
2230
|
-
}
|
|
2231
|
-
html += `
|
|
2232
|
-
</tbody>
|
|
2233
|
-
</table>`;
|
|
2234
|
-
return html;
|
|
2235
|
-
}
|
|
2236
|
-
};
|
|
2237
|
-
|
|
2238
2152
|
// src/narratives/templates/typescript/TypeScriptTemplateMapper.ts
|
|
2239
2153
|
var TypeScriptTemplateMapper = class {
|
|
2240
2154
|
/**
|
|
@@ -2264,7 +2178,6 @@ TypeScriptTemplateMapper.sectionToTemplate = {
|
|
|
2264
2178
|
["MedicalDeviceSection" /* MEDICAL_DEVICES */]: new MedicalDevicesTemplate(),
|
|
2265
2179
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: new DiagnosticResultsTemplate(),
|
|
2266
2180
|
["HistoryOfProceduresSection" /* PROCEDURES */]: new HistoryOfProceduresTemplate(),
|
|
2267
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: new FamilyHistoryTemplate(),
|
|
2268
2181
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: new SocialHistoryTemplate(),
|
|
2269
2182
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: new PregnancyTemplate(),
|
|
2270
2183
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: new FunctionalStatusTemplate(),
|
|
@@ -2528,7 +2441,7 @@ var ComprehensiveIPSCompositionBuilder = class {
|
|
|
2528
2441
|
"Patient" /* PATIENT */,
|
|
2529
2442
|
[this.patient],
|
|
2530
2443
|
timezone,
|
|
2531
|
-
|
|
2444
|
+
true
|
|
2532
2445
|
)
|
|
2533
2446
|
};
|
|
2534
2447
|
const bundle = {
|
|
@@ -2569,6 +2482,13 @@ var ComprehensiveIPSCompositionBuilder = class {
|
|
|
2569
2482
|
});
|
|
2570
2483
|
return bundle;
|
|
2571
2484
|
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Returns the Composition sections without creating a full bundle.
|
|
2487
|
+
* @returns Array of TCompositionSection
|
|
2488
|
+
*/
|
|
2489
|
+
getSections() {
|
|
2490
|
+
return this.sections;
|
|
2491
|
+
}
|
|
2572
2492
|
};
|
|
2573
2493
|
|
|
2574
2494
|
// src/index.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -518,6 +518,22 @@ type TPatient = {
|
|
|
518
518
|
link?: TPatientLink[];
|
|
519
519
|
};
|
|
520
520
|
|
|
521
|
+
type TCompositionSection = {
|
|
522
|
+
id?: string;
|
|
523
|
+
extension?: TExtension[];
|
|
524
|
+
modifierExtension?: TExtension[];
|
|
525
|
+
title?: string;
|
|
526
|
+
code?: TCodeableConcept;
|
|
527
|
+
author?: TReference[];
|
|
528
|
+
focus?: TReference;
|
|
529
|
+
text?: TNarrative;
|
|
530
|
+
mode?: string;
|
|
531
|
+
orderedBy?: TCodeableConcept;
|
|
532
|
+
entry?: TReference[];
|
|
533
|
+
emptyReason?: TCodeableConcept;
|
|
534
|
+
section?: TCompositionSection[];
|
|
535
|
+
};
|
|
536
|
+
|
|
521
537
|
type TDomainResource = {
|
|
522
538
|
resourceType?: string;
|
|
523
539
|
id?: string;
|
|
@@ -545,8 +561,7 @@ declare enum IPSSections {
|
|
|
545
561
|
CARE_PLAN = "PlanOfCareSection",
|
|
546
562
|
MEDICAL_HISTORY = "HistoryOfPastIllnessSection",
|
|
547
563
|
SOCIAL_HISTORY = "SocialHistorySection",
|
|
548
|
-
VITAL_SIGNS = "VitalSignsSection"
|
|
549
|
-
FAMILY_HISTORY = "FamilyHistorySection"
|
|
564
|
+
VITAL_SIGNS = "VitalSignsSection"
|
|
550
565
|
}
|
|
551
566
|
|
|
552
567
|
type TBundleLink = {
|
|
@@ -646,6 +661,11 @@ declare class ComprehensiveIPSCompositionBuilder {
|
|
|
646
661
|
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
647
662
|
*/
|
|
648
663
|
buildBundleAsync(authorOrganizationId: string, authorOrganizationName: string, baseUrl: string, timezone: string | undefined): Promise<TBundle>;
|
|
664
|
+
/**
|
|
665
|
+
* Returns the Composition sections without creating a full bundle.
|
|
666
|
+
* @returns Array of TCompositionSection
|
|
667
|
+
*/
|
|
668
|
+
getSections(): TCompositionSection[];
|
|
649
669
|
}
|
|
650
670
|
|
|
651
671
|
interface Narrative {
|
package/dist/index.d.ts
CHANGED
|
@@ -518,6 +518,22 @@ type TPatient = {
|
|
|
518
518
|
link?: TPatientLink[];
|
|
519
519
|
};
|
|
520
520
|
|
|
521
|
+
type TCompositionSection = {
|
|
522
|
+
id?: string;
|
|
523
|
+
extension?: TExtension[];
|
|
524
|
+
modifierExtension?: TExtension[];
|
|
525
|
+
title?: string;
|
|
526
|
+
code?: TCodeableConcept;
|
|
527
|
+
author?: TReference[];
|
|
528
|
+
focus?: TReference;
|
|
529
|
+
text?: TNarrative;
|
|
530
|
+
mode?: string;
|
|
531
|
+
orderedBy?: TCodeableConcept;
|
|
532
|
+
entry?: TReference[];
|
|
533
|
+
emptyReason?: TCodeableConcept;
|
|
534
|
+
section?: TCompositionSection[];
|
|
535
|
+
};
|
|
536
|
+
|
|
521
537
|
type TDomainResource = {
|
|
522
538
|
resourceType?: string;
|
|
523
539
|
id?: string;
|
|
@@ -545,8 +561,7 @@ declare enum IPSSections {
|
|
|
545
561
|
CARE_PLAN = "PlanOfCareSection",
|
|
546
562
|
MEDICAL_HISTORY = "HistoryOfPastIllnessSection",
|
|
547
563
|
SOCIAL_HISTORY = "SocialHistorySection",
|
|
548
|
-
VITAL_SIGNS = "VitalSignsSection"
|
|
549
|
-
FAMILY_HISTORY = "FamilyHistorySection"
|
|
564
|
+
VITAL_SIGNS = "VitalSignsSection"
|
|
550
565
|
}
|
|
551
566
|
|
|
552
567
|
type TBundleLink = {
|
|
@@ -646,6 +661,11 @@ declare class ComprehensiveIPSCompositionBuilder {
|
|
|
646
661
|
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
647
662
|
*/
|
|
648
663
|
buildBundleAsync(authorOrganizationId: string, authorOrganizationName: string, baseUrl: string, timezone: string | undefined): Promise<TBundle>;
|
|
664
|
+
/**
|
|
665
|
+
* Returns the Composition sections without creating a full bundle.
|
|
666
|
+
* @returns Array of TCompositionSection
|
|
667
|
+
*/
|
|
668
|
+
getSections(): TCompositionSection[];
|
|
649
669
|
}
|
|
650
670
|
|
|
651
671
|
interface Narrative {
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var IPSSections = /* @__PURE__ */ ((IPSSections2) => {
|
|
|
15
15
|
IPSSections2["MEDICAL_HISTORY"] = "HistoryOfPastIllnessSection";
|
|
16
16
|
IPSSections2["SOCIAL_HISTORY"] = "SocialHistorySection";
|
|
17
17
|
IPSSections2["VITAL_SIGNS"] = "VitalSignsSection";
|
|
18
|
-
IPSSections2["FAMILY_HISTORY"] = "FamilyHistorySection";
|
|
19
18
|
return IPSSections2;
|
|
20
19
|
})(IPSSections || {});
|
|
21
20
|
|
|
@@ -30,7 +29,6 @@ var IPS_SECTION_LOINC_CODES = {
|
|
|
30
29
|
["MedicalDeviceSection" /* MEDICAL_DEVICES */]: "46264-8",
|
|
31
30
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: "30954-2",
|
|
32
31
|
["HistoryOfProceduresSection" /* PROCEDURES */]: "47519-4",
|
|
33
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: "10157-6",
|
|
34
32
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: "29762-2",
|
|
35
33
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: "10162-6",
|
|
36
34
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: "47420-5",
|
|
@@ -53,10 +51,9 @@ var IPS_SECTION_DISPLAY_NAMES = {
|
|
|
53
51
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: "History of Pregnancies",
|
|
54
52
|
["PlanOfCareSection" /* CARE_PLAN */]: "Plan of Care",
|
|
55
53
|
["HistoryOfPastIllnessSection" /* MEDICAL_HISTORY */]: "History of Past Illness",
|
|
56
|
-
["SocialHistorySection" /* SOCIAL_HISTORY */]: "Social History"
|
|
57
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: "History of Family Member Diseases"
|
|
54
|
+
["SocialHistorySection" /* SOCIAL_HISTORY */]: "Social History"
|
|
58
55
|
};
|
|
59
|
-
var
|
|
56
|
+
var PREGNANCY_LOINC_CODES = {
|
|
60
57
|
PREGNANCY_STATUS: {
|
|
61
58
|
"LA15173-0": "Pregnant",
|
|
62
59
|
"LA26683-5": "Not pregnant",
|
|
@@ -74,7 +71,7 @@ var PREGNANCY_LONIC_CODES = {
|
|
|
74
71
|
"33065-4": "Ectopic Pregnancy"
|
|
75
72
|
}
|
|
76
73
|
};
|
|
77
|
-
var
|
|
74
|
+
var SOCIAL_HISTORY_LOINC_CODES = {
|
|
78
75
|
"72166-2": "Tobacco Use",
|
|
79
76
|
"74013-4": "Alcohol Use"
|
|
80
77
|
};
|
|
@@ -93,7 +90,6 @@ var IPSSectionResourceMap = {
|
|
|
93
90
|
// Device resource is used for medical devices name
|
|
94
91
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: ["DiagnosticReport", "Observation"],
|
|
95
92
|
["HistoryOfProceduresSection" /* PROCEDURES */]: ["Procedure"],
|
|
96
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: ["FamilyMemberHistory"],
|
|
97
93
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: ["Observation"],
|
|
98
94
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: ["Observation"],
|
|
99
95
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: ["Condition", "ClinicalImpression"],
|
|
@@ -114,12 +110,10 @@ var IPSSectionResourceFilters = {
|
|
|
114
110
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: (resource) => ["DiagnosticReport", "Observation"].includes(resource.resourceType) && resource.status === "final",
|
|
115
111
|
// Only include completed procedures
|
|
116
112
|
["HistoryOfProceduresSection" /* PROCEDURES */]: (resource) => resource.resourceType === "Procedure" && resource.status === "completed",
|
|
117
|
-
// Only include family history resources
|
|
118
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: (resource) => resource.resourceType === "FamilyMemberHistory",
|
|
119
113
|
// Only include social history Observations (category.coding contains 'social-history')
|
|
120
|
-
["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Observation" && resource.code?.coding?.some((c) => Object.keys(
|
|
114
|
+
["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Observation" && resource.code?.coding?.some((c) => Object.keys(SOCIAL_HISTORY_LOINC_CODES).includes(c.code)),
|
|
121
115
|
// Only include pregnancy history Observations (category.coding contains 'pregnancy')
|
|
122
|
-
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: (resource) => resource.resourceType === "Observation" && (resource.code?.coding?.some((c) => Object.keys(
|
|
116
|
+
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: (resource) => resource.resourceType === "Observation" && (resource.code?.coding?.some((c) => Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_STATUS).includes(c.code)) || resource.valueCodeableConcept?.coding?.some((c) => Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME).includes(c.code))),
|
|
123
117
|
// Only include active functional status Conditions or ClinicalImpressions
|
|
124
118
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: (resource) => resource.resourceType === "Condition" && resource.clinicalStatus?.coding?.some((c) => typeof c.code === "string") || resource.resourceType === "ClinicalImpression" && resource.status === "completed",
|
|
125
119
|
// Only include resolved medical history Conditions
|
|
@@ -549,17 +543,17 @@ var TemplateUtilities = class {
|
|
|
549
543
|
extractPregnancyStatus(observation) {
|
|
550
544
|
let status = "";
|
|
551
545
|
observation.code?.coding?.forEach((c) => {
|
|
552
|
-
if (c.code && Object.keys(
|
|
553
|
-
status =
|
|
546
|
+
if (c.code && Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_STATUS).includes(c.code)) {
|
|
547
|
+
status = PREGNANCY_LOINC_CODES.PREGNANCY_STATUS[c.code];
|
|
554
548
|
}
|
|
555
549
|
});
|
|
556
550
|
if (observation.valueCodeableConcept) {
|
|
557
551
|
observation.valueCodeableConcept.coding?.forEach((c) => {
|
|
558
|
-
if (c.code && Object.keys(
|
|
552
|
+
if (c.code && Object.keys(PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME).includes(c.code)) {
|
|
559
553
|
if (status) {
|
|
560
554
|
status += " - ";
|
|
561
555
|
}
|
|
562
|
-
status +=
|
|
556
|
+
status += PREGNANCY_LOINC_CODES.PREGNANCY_OUTCOME[c.code];
|
|
563
557
|
}
|
|
564
558
|
});
|
|
565
559
|
}
|
|
@@ -1960,8 +1954,7 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
1960
1954
|
</tr>`;
|
|
1961
1955
|
}
|
|
1962
1956
|
html += `</tbody>
|
|
1963
|
-
</table
|
|
1964
|
-
</div>`;
|
|
1957
|
+
</table>`;
|
|
1965
1958
|
}
|
|
1966
1959
|
if (clinicalImpressions.length > 0) {
|
|
1967
1960
|
html += `<h3>Clinical Impressions</h3>
|
|
@@ -2013,6 +2006,8 @@ var FunctionalStatusTemplate = class _FunctionalStatusTemplate {
|
|
|
2013
2006
|
<td>${notes}</td>
|
|
2014
2007
|
</tr>`;
|
|
2015
2008
|
}
|
|
2009
|
+
html += `</tbody>
|
|
2010
|
+
</table>`;
|
|
2016
2011
|
}
|
|
2017
2012
|
return html;
|
|
2018
2013
|
}
|
|
@@ -2126,87 +2121,6 @@ var AdvanceDirectivesTemplate = class _AdvanceDirectivesTemplate {
|
|
|
2126
2121
|
}
|
|
2127
2122
|
};
|
|
2128
2123
|
|
|
2129
|
-
// src/narratives/templates/typescript/FamilyHistoryTemplate.ts
|
|
2130
|
-
var FamilyHistoryTemplate = class {
|
|
2131
|
-
/**
|
|
2132
|
-
* Generate HTML narrative for Family History
|
|
2133
|
-
* @param resource - FHIR Bundle containing FamilyMemberHistory resources
|
|
2134
|
-
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
2135
|
-
* @returns HTML string for rendering
|
|
2136
|
-
*/
|
|
2137
|
-
generateNarrative(resource, timezone) {
|
|
2138
|
-
const templateUtilities = new TemplateUtilities(resource);
|
|
2139
|
-
let html = `
|
|
2140
|
-
<h5>Family History</h5>
|
|
2141
|
-
<table>
|
|
2142
|
-
<thead>
|
|
2143
|
-
<tr>
|
|
2144
|
-
<th>Relationship</th>
|
|
2145
|
-
<th>Condition</th>
|
|
2146
|
-
<th>Status</th>
|
|
2147
|
-
<th>Onset</th>
|
|
2148
|
-
<th>Notes</th>
|
|
2149
|
-
</tr>
|
|
2150
|
-
</thead>
|
|
2151
|
-
<tbody>`;
|
|
2152
|
-
if (resource.entry && Array.isArray(resource.entry)) {
|
|
2153
|
-
let hasFamilyHistory = false;
|
|
2154
|
-
for (const entry of resource.entry) {
|
|
2155
|
-
const familyHistory = entry.resource;
|
|
2156
|
-
if (!familyHistory || familyHistory.resourceType !== "FamilyMemberHistory") {
|
|
2157
|
-
continue;
|
|
2158
|
-
}
|
|
2159
|
-
hasFamilyHistory = true;
|
|
2160
|
-
const fmh = familyHistory;
|
|
2161
|
-
const relationship = templateUtilities.codeableConcept(fmh.relationship, "display");
|
|
2162
|
-
if (fmh.condition && Array.isArray(fmh.condition)) {
|
|
2163
|
-
for (const condition of fmh.condition) {
|
|
2164
|
-
const conditionCode = templateUtilities.codeableConcept(condition.code, "display");
|
|
2165
|
-
const status = fmh.status || "";
|
|
2166
|
-
let onset = "";
|
|
2167
|
-
if (condition.onsetAge) {
|
|
2168
|
-
onset = templateUtilities.renderOnset(condition.onsetAge, timezone);
|
|
2169
|
-
}
|
|
2170
|
-
const notes = condition.note ? templateUtilities.renderNotes(condition.note, timezone) : templateUtilities.renderNotes(fmh.note, timezone);
|
|
2171
|
-
html += `
|
|
2172
|
-
<tr id="${templateUtilities.narrativeLinkId(fmh)}">
|
|
2173
|
-
<td>${relationship}</td>
|
|
2174
|
-
<td>${conditionCode}</td>
|
|
2175
|
-
<td>${status}</td>
|
|
2176
|
-
<td>${onset}</td>
|
|
2177
|
-
<td>${notes}</td>
|
|
2178
|
-
</tr>`;
|
|
2179
|
-
}
|
|
2180
|
-
} else {
|
|
2181
|
-
html += `
|
|
2182
|
-
<tr id="${templateUtilities.narrativeLinkId(fmh)}">
|
|
2183
|
-
<td>${relationship}</td>
|
|
2184
|
-
<td>Not specified</td>
|
|
2185
|
-
<td>${fmh.status || ""}</td>
|
|
2186
|
-
<td></td>
|
|
2187
|
-
<td>${templateUtilities.renderNotes(fmh.note, timezone)}</td>
|
|
2188
|
-
</tr>`;
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
if (!hasFamilyHistory) {
|
|
2192
|
-
html += `
|
|
2193
|
-
<tr>
|
|
2194
|
-
<td colspan="5">No family history recorded</td>
|
|
2195
|
-
</tr>`;
|
|
2196
|
-
}
|
|
2197
|
-
} else {
|
|
2198
|
-
html += `
|
|
2199
|
-
<tr>
|
|
2200
|
-
<td colspan="5">No family history recorded</td>
|
|
2201
|
-
</tr>`;
|
|
2202
|
-
}
|
|
2203
|
-
html += `
|
|
2204
|
-
</tbody>
|
|
2205
|
-
</table>`;
|
|
2206
|
-
return html;
|
|
2207
|
-
}
|
|
2208
|
-
};
|
|
2209
|
-
|
|
2210
2124
|
// src/narratives/templates/typescript/TypeScriptTemplateMapper.ts
|
|
2211
2125
|
var TypeScriptTemplateMapper = class {
|
|
2212
2126
|
/**
|
|
@@ -2236,7 +2150,6 @@ TypeScriptTemplateMapper.sectionToTemplate = {
|
|
|
2236
2150
|
["MedicalDeviceSection" /* MEDICAL_DEVICES */]: new MedicalDevicesTemplate(),
|
|
2237
2151
|
["ResultsSection" /* DIAGNOSTIC_REPORTS */]: new DiagnosticResultsTemplate(),
|
|
2238
2152
|
["HistoryOfProceduresSection" /* PROCEDURES */]: new HistoryOfProceduresTemplate(),
|
|
2239
|
-
["FamilyHistorySection" /* FAMILY_HISTORY */]: new FamilyHistoryTemplate(),
|
|
2240
2153
|
["SocialHistorySection" /* SOCIAL_HISTORY */]: new SocialHistoryTemplate(),
|
|
2241
2154
|
["HistoryOfPregnancySection" /* PREGNANCY_HISTORY */]: new PregnancyTemplate(),
|
|
2242
2155
|
["FunctionalStatusSection" /* FUNCTIONAL_STATUS */]: new FunctionalStatusTemplate(),
|
|
@@ -2500,7 +2413,7 @@ var ComprehensiveIPSCompositionBuilder = class {
|
|
|
2500
2413
|
"Patient" /* PATIENT */,
|
|
2501
2414
|
[this.patient],
|
|
2502
2415
|
timezone,
|
|
2503
|
-
|
|
2416
|
+
true
|
|
2504
2417
|
)
|
|
2505
2418
|
};
|
|
2506
2419
|
const bundle = {
|
|
@@ -2541,6 +2454,13 @@ var ComprehensiveIPSCompositionBuilder = class {
|
|
|
2541
2454
|
});
|
|
2542
2455
|
return bundle;
|
|
2543
2456
|
}
|
|
2457
|
+
/**
|
|
2458
|
+
* Returns the Composition sections without creating a full bundle.
|
|
2459
|
+
* @returns Array of TCompositionSection
|
|
2460
|
+
*/
|
|
2461
|
+
getSections() {
|
|
2462
|
+
return this.sections;
|
|
2463
|
+
}
|
|
2544
2464
|
};
|
|
2545
2465
|
|
|
2546
2466
|
// src/index.ts
|