@imranq2/fhirpatientsummary 1.0.13 → 1.0.14

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
@@ -830,7 +830,7 @@ var PatientTemplate = class _PatientTemplate {
830
830
  <li><strong>Gender:</strong>${patient.gender ? this.capitalize(patient.gender) : ""}</li>
831
831
  <li><strong>Date of Birth:</strong>${patient.birthDate || ""}</li>
832
832
  <li><strong>Identifier(s):</strong>${this.renderIdentifiers(patient)}</li>
833
- <li><strong>Telecom:</strong>${this.renderTelecom(patient)}</li>
833
+ <li><strong>Telecom:</strong><ul>${this.renderTelecom(patient)}</ul></li>
834
834
  <li><strong>Address(es):</strong>${this.renderAddresses(patient)}</li>
835
835
  <li><strong>Marital Status:</strong> ${patient.maritalStatus?.text || ""}</li>
836
836
  <li><strong>Deceased:</strong>${this.renderDeceased(patient)}</li>
@@ -850,10 +850,14 @@ var PatientTemplate = class _PatientTemplate {
850
850
  if (!patient.name || patient.name.length === 0) {
851
851
  return "";
852
852
  }
853
- return patient.name.map((name) => {
854
- const nameText = name.text || ((name.given || []).join(" ") + " " + (name.family || "")).trim();
855
- return `<ul><li>${nameText}</li></ul>`;
856
- }).join("");
853
+ const uniqueNames = /* @__PURE__ */ new Set();
854
+ patient.name.forEach((name) => {
855
+ if (name.use !== "old") {
856
+ const nameText = name.text || ((name.given || []).join(" ") + " " + (name.family || "")).trim();
857
+ uniqueNames.add(nameText);
858
+ }
859
+ });
860
+ return Array.from(uniqueNames).map((nameText) => `<ul><li>${nameText}</li></ul>`).join("");
857
861
  }
858
862
  /**
859
863
  * Renders patient identifiers as HTML list items
@@ -871,19 +875,38 @@ var PatientTemplate = class _PatientTemplate {
871
875
  }).join("");
872
876
  }
873
877
  /**
874
- * Renders patient telecom information as HTML list items
878
+ * Renders patient telecom information grouped by system
875
879
  * @param patient - Patient resource
876
- * @returns HTML string of list items
880
+ * @returns HTML string grouped by system
877
881
  */
878
882
  static renderTelecom(patient) {
879
883
  if (!patient.telecom || patient.telecom.length === 0) {
880
884
  return "";
881
885
  }
882
- return patient.telecom.map((telecom) => {
883
- const system = telecom.system ? this.capitalize(telecom.system) : "";
884
- const value = telecom.value || "";
885
- const use = telecom.use ? ` (${telecom.use})` : "";
886
- return `<ul><li>${system}: ${value}${use}</li></ul>`;
886
+ const systemPriority = ["email", "phone", "pager", "sms", "fax", "url", "other"];
887
+ const telecomBySystem = /* @__PURE__ */ new Map();
888
+ patient.telecom.forEach((telecom) => {
889
+ if (telecom.system && telecom.value) {
890
+ const system = telecom.system.toLowerCase();
891
+ if (!telecomBySystem.has(system)) {
892
+ telecomBySystem.set(system, /* @__PURE__ */ new Set());
893
+ }
894
+ telecomBySystem.get(system).add(telecom.value);
895
+ }
896
+ });
897
+ return Array.from(telecomBySystem.entries()).sort(([systemA], [systemB]) => {
898
+ const priorityA = systemPriority.indexOf(systemA);
899
+ const priorityB = systemPriority.indexOf(systemB);
900
+ if (priorityA !== -1 && priorityB !== -1) {
901
+ return priorityA - priorityB;
902
+ }
903
+ if (priorityA !== -1) return -1;
904
+ if (priorityB !== -1) return 1;
905
+ return systemA.localeCompare(systemB);
906
+ }).map(([system, values]) => {
907
+ const systemLabel = this.capitalize(system);
908
+ const valueList = Array.from(values).map((value) => `<li>${value}</li>`).join("");
909
+ return `<li><strong>${systemLabel}:</strong><ul>${valueList}</ul></li>`;
887
910
  }).join("");
888
911
  }
889
912
  /**
@@ -895,10 +918,14 @@ var PatientTemplate = class _PatientTemplate {
895
918
  if (!patient.address || patient.address.length === 0) {
896
919
  return "";
897
920
  }
898
- return patient.address.map((address) => {
921
+ const uniqueAddresses = /* @__PURE__ */ new Set();
922
+ patient.address.forEach((address) => {
899
923
  const addressText = address.text || ((address.line || []).join(", ") + ", " + (address.city || "") + ", " + (address.country || "")).trim();
900
- return `<ul><li>${addressText}</li></ul>`;
901
- }).join("");
924
+ if (addressText) {
925
+ uniqueAddresses.add(addressText);
926
+ }
927
+ });
928
+ return Array.from(uniqueAddresses).map((addressText) => `<ul><li>${addressText}</li></ul>`).join("");
902
929
  }
903
930
  /**
904
931
  * Renders patient deceased status
@@ -1642,7 +1669,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
1642
1669
  */
1643
1670
  static renderObservations(templateUtilities, observations, timezone) {
1644
1671
  let html = `
1645
- <h5>Observations</h5>
1672
+ <h3>Observations</h3>
1646
1673
  <table>
1647
1674
  <thead>
1648
1675
  <tr>
@@ -1682,7 +1709,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
1682
1709
  */
1683
1710
  static renderDiagnosticReports(templateUtilities, reports, timezone) {
1684
1711
  let html = `
1685
- <h5>Diagnostic Reports</h5>
1712
+ <h3>Diagnostic Reports</h3>
1686
1713
  <table>
1687
1714
  <thead>
1688
1715
  <tr>
package/dist/index.js CHANGED
@@ -802,7 +802,7 @@ var PatientTemplate = class _PatientTemplate {
802
802
  <li><strong>Gender:</strong>${patient.gender ? this.capitalize(patient.gender) : ""}</li>
803
803
  <li><strong>Date of Birth:</strong>${patient.birthDate || ""}</li>
804
804
  <li><strong>Identifier(s):</strong>${this.renderIdentifiers(patient)}</li>
805
- <li><strong>Telecom:</strong>${this.renderTelecom(patient)}</li>
805
+ <li><strong>Telecom:</strong><ul>${this.renderTelecom(patient)}</ul></li>
806
806
  <li><strong>Address(es):</strong>${this.renderAddresses(patient)}</li>
807
807
  <li><strong>Marital Status:</strong> ${patient.maritalStatus?.text || ""}</li>
808
808
  <li><strong>Deceased:</strong>${this.renderDeceased(patient)}</li>
@@ -822,10 +822,14 @@ var PatientTemplate = class _PatientTemplate {
822
822
  if (!patient.name || patient.name.length === 0) {
823
823
  return "";
824
824
  }
825
- return patient.name.map((name) => {
826
- const nameText = name.text || ((name.given || []).join(" ") + " " + (name.family || "")).trim();
827
- return `<ul><li>${nameText}</li></ul>`;
828
- }).join("");
825
+ const uniqueNames = /* @__PURE__ */ new Set();
826
+ patient.name.forEach((name) => {
827
+ if (name.use !== "old") {
828
+ const nameText = name.text || ((name.given || []).join(" ") + " " + (name.family || "")).trim();
829
+ uniqueNames.add(nameText);
830
+ }
831
+ });
832
+ return Array.from(uniqueNames).map((nameText) => `<ul><li>${nameText}</li></ul>`).join("");
829
833
  }
830
834
  /**
831
835
  * Renders patient identifiers as HTML list items
@@ -843,19 +847,38 @@ var PatientTemplate = class _PatientTemplate {
843
847
  }).join("");
844
848
  }
845
849
  /**
846
- * Renders patient telecom information as HTML list items
850
+ * Renders patient telecom information grouped by system
847
851
  * @param patient - Patient resource
848
- * @returns HTML string of list items
852
+ * @returns HTML string grouped by system
849
853
  */
850
854
  static renderTelecom(patient) {
851
855
  if (!patient.telecom || patient.telecom.length === 0) {
852
856
  return "";
853
857
  }
854
- return patient.telecom.map((telecom) => {
855
- const system = telecom.system ? this.capitalize(telecom.system) : "";
856
- const value = telecom.value || "";
857
- const use = telecom.use ? ` (${telecom.use})` : "";
858
- return `<ul><li>${system}: ${value}${use}</li></ul>`;
858
+ const systemPriority = ["email", "phone", "pager", "sms", "fax", "url", "other"];
859
+ const telecomBySystem = /* @__PURE__ */ new Map();
860
+ patient.telecom.forEach((telecom) => {
861
+ if (telecom.system && telecom.value) {
862
+ const system = telecom.system.toLowerCase();
863
+ if (!telecomBySystem.has(system)) {
864
+ telecomBySystem.set(system, /* @__PURE__ */ new Set());
865
+ }
866
+ telecomBySystem.get(system).add(telecom.value);
867
+ }
868
+ });
869
+ return Array.from(telecomBySystem.entries()).sort(([systemA], [systemB]) => {
870
+ const priorityA = systemPriority.indexOf(systemA);
871
+ const priorityB = systemPriority.indexOf(systemB);
872
+ if (priorityA !== -1 && priorityB !== -1) {
873
+ return priorityA - priorityB;
874
+ }
875
+ if (priorityA !== -1) return -1;
876
+ if (priorityB !== -1) return 1;
877
+ return systemA.localeCompare(systemB);
878
+ }).map(([system, values]) => {
879
+ const systemLabel = this.capitalize(system);
880
+ const valueList = Array.from(values).map((value) => `<li>${value}</li>`).join("");
881
+ return `<li><strong>${systemLabel}:</strong><ul>${valueList}</ul></li>`;
859
882
  }).join("");
860
883
  }
861
884
  /**
@@ -867,10 +890,14 @@ var PatientTemplate = class _PatientTemplate {
867
890
  if (!patient.address || patient.address.length === 0) {
868
891
  return "";
869
892
  }
870
- return patient.address.map((address) => {
893
+ const uniqueAddresses = /* @__PURE__ */ new Set();
894
+ patient.address.forEach((address) => {
871
895
  const addressText = address.text || ((address.line || []).join(", ") + ", " + (address.city || "") + ", " + (address.country || "")).trim();
872
- return `<ul><li>${addressText}</li></ul>`;
873
- }).join("");
896
+ if (addressText) {
897
+ uniqueAddresses.add(addressText);
898
+ }
899
+ });
900
+ return Array.from(uniqueAddresses).map((addressText) => `<ul><li>${addressText}</li></ul>`).join("");
874
901
  }
875
902
  /**
876
903
  * Renders patient deceased status
@@ -1614,7 +1641,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
1614
1641
  */
1615
1642
  static renderObservations(templateUtilities, observations, timezone) {
1616
1643
  let html = `
1617
- <h5>Observations</h5>
1644
+ <h3>Observations</h3>
1618
1645
  <table>
1619
1646
  <thead>
1620
1647
  <tr>
@@ -1654,7 +1681,7 @@ var DiagnosticResultsTemplate = class _DiagnosticResultsTemplate {
1654
1681
  */
1655
1682
  static renderDiagnosticReports(templateUtilities, reports, timezone) {
1656
1683
  let html = `
1657
- <h5>Diagnostic Reports</h5>
1684
+ <h3>Diagnostic Reports</h3>
1658
1685
  <table>
1659
1686
  <thead>
1660
1687
  <tr>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imranq2/fhirpatientsummary",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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",