@imranq2/fhirpatientsummary 1.0.34 → 1.0.35

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 CHANGED
@@ -200,7 +200,8 @@ var IPSSectionSummaryCompositionFilter = {
200
200
  };
201
201
  var IPSSectionSummaryIPSCompositionFilter = {
202
202
  ["Patient" /* PATIENT */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_patient_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM)),
203
- ["VitalSignsSection" /* VITAL_SIGNS */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_vital_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM))
203
+ ["VitalSignsSection" /* VITAL_SIGNS */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_vital_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM)),
204
+ ["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_social_history_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM))
204
205
  };
205
206
  var IPSSectionResourceHelper = class {
206
207
  static getResourceFilterForSection(section) {
@@ -3670,6 +3671,61 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
3670
3671
  generateNarrative(resources, timezone) {
3671
3672
  return _SocialHistoryTemplate.generateStaticNarrative(resources, timezone);
3672
3673
  }
3674
+ /**
3675
+ * Generate HTML narrative for social history using summary
3676
+ * @param resources - FHIR Composition resources
3677
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
3678
+ * @returns HTML string for rendering
3679
+ */
3680
+ generateSummaryNarrative(resources, timezone) {
3681
+ const templateUtilities = new TemplateUtilities(resources);
3682
+ let isSummaryCreated = false;
3683
+ let html = `<p>This list includes all information about the patient's social history, sorted by effective date (most recent first).</p>
3684
+ `;
3685
+ html += `
3686
+ <div>
3687
+ <table>
3688
+ <thead>
3689
+ <tr>
3690
+ <th>Name</th>
3691
+ <th>Code (System)</th>
3692
+ <th>Result</th>
3693
+ <th>Date</th>
3694
+ <th>Comments</th>
3695
+ </tr>
3696
+ </thead>
3697
+ <tbody>`;
3698
+ for (const resourceItem of resources) {
3699
+ for (const rowData of resourceItem.section ?? []) {
3700
+ const sectionCodeableConcept = rowData.code;
3701
+ const data = {};
3702
+ data["codeSystem"] = templateUtilities.codeableConceptCoding(sectionCodeableConcept);
3703
+ for (const columnData of rowData.section ?? []) {
3704
+ const columnTitle = columnData.title;
3705
+ if (columnTitle) {
3706
+ data[columnTitle] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
3707
+ }
3708
+ }
3709
+ if (data["Social History Name"]?.toLowerCase() === "unknown") {
3710
+ continue;
3711
+ }
3712
+ isSummaryCreated = true;
3713
+ html += `
3714
+ <tr>
3715
+ <td>${templateUtilities.capitalizeFirstLetter(data["Social History Name"] ?? "")}</td>
3716
+ <td>${data["codeSystem"] ?? ""}</td>
3717
+ <td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
3718
+ <td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
3719
+ <td>${data["Notes"] ?? ""}</td>
3720
+ </tr>`;
3721
+ }
3722
+ }
3723
+ html += `
3724
+ </tbody>
3725
+ </table>
3726
+ </div>`;
3727
+ return isSummaryCreated ? html : void 0;
3728
+ }
3673
3729
  /**
3674
3730
  * Internal static implementation that actually generates the narrative
3675
3731
  * @param resources - FHIR Observation resources
package/dist/index.js CHANGED
@@ -172,7 +172,8 @@ var IPSSectionSummaryCompositionFilter = {
172
172
  };
173
173
  var IPSSectionSummaryIPSCompositionFilter = {
174
174
  ["Patient" /* PATIENT */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_patient_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM)),
175
- ["VitalSignsSection" /* VITAL_SIGNS */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_vital_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM))
175
+ ["VitalSignsSection" /* VITAL_SIGNS */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_vital_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM)),
176
+ ["SocialHistorySection" /* SOCIAL_HISTORY */]: (resource) => resource.resourceType === "Composition" && resource.type?.coding?.some((c) => codingMatches(c, "ips_social_history_summary_document", IPS_SUMMARY_COMPOSITION_TYPE_SYSTEM))
176
177
  };
177
178
  var IPSSectionResourceHelper = class {
178
179
  static getResourceFilterForSection(section) {
@@ -3642,6 +3643,61 @@ var SocialHistoryTemplate = class _SocialHistoryTemplate {
3642
3643
  generateNarrative(resources, timezone) {
3643
3644
  return _SocialHistoryTemplate.generateStaticNarrative(resources, timezone);
3644
3645
  }
3646
+ /**
3647
+ * Generate HTML narrative for social history using summary
3648
+ * @param resources - FHIR Composition resources
3649
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
3650
+ * @returns HTML string for rendering
3651
+ */
3652
+ generateSummaryNarrative(resources, timezone) {
3653
+ const templateUtilities = new TemplateUtilities(resources);
3654
+ let isSummaryCreated = false;
3655
+ let html = `<p>This list includes all information about the patient's social history, sorted by effective date (most recent first).</p>
3656
+ `;
3657
+ html += `
3658
+ <div>
3659
+ <table>
3660
+ <thead>
3661
+ <tr>
3662
+ <th>Name</th>
3663
+ <th>Code (System)</th>
3664
+ <th>Result</th>
3665
+ <th>Date</th>
3666
+ <th>Comments</th>
3667
+ </tr>
3668
+ </thead>
3669
+ <tbody>`;
3670
+ for (const resourceItem of resources) {
3671
+ for (const rowData of resourceItem.section ?? []) {
3672
+ const sectionCodeableConcept = rowData.code;
3673
+ const data = {};
3674
+ data["codeSystem"] = templateUtilities.codeableConceptCoding(sectionCodeableConcept);
3675
+ for (const columnData of rowData.section ?? []) {
3676
+ const columnTitle = columnData.title;
3677
+ if (columnTitle) {
3678
+ data[columnTitle] = templateUtilities.renderTextAsHtml(columnData.text?.div ?? "");
3679
+ }
3680
+ }
3681
+ if (data["Social History Name"]?.toLowerCase() === "unknown") {
3682
+ continue;
3683
+ }
3684
+ isSummaryCreated = true;
3685
+ html += `
3686
+ <tr>
3687
+ <td>${templateUtilities.capitalizeFirstLetter(data["Social History Name"] ?? "")}</td>
3688
+ <td>${data["codeSystem"] ?? ""}</td>
3689
+ <td>${templateUtilities.extractObservationSummaryValue(data, timezone) ?? ""}</td>
3690
+ <td>${templateUtilities.extractObservationSummaryEffectiveTime(data, timezone) ?? ""}</td>
3691
+ <td>${data["Notes"] ?? ""}</td>
3692
+ </tr>`;
3693
+ }
3694
+ }
3695
+ html += `
3696
+ </tbody>
3697
+ </table>
3698
+ </div>`;
3699
+ return isSummaryCreated ? html : void 0;
3700
+ }
3645
3701
  /**
3646
3702
  * Internal static implementation that actually generates the narrative
3647
3703
  * @param resources - FHIR Observation resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imranq2/fhirpatientsummary",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "A template for creating npm packages using TypeScript and VSCode",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",