@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 +44 -17
- package/dist/index.js +44 -17
- package/package.json +1 -1
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
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
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
|
|
878
|
+
* Renders patient telecom information grouped by system
|
|
875
879
|
* @param patient - Patient resource
|
|
876
|
-
* @returns HTML string
|
|
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
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
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
|
-
|
|
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
|
-
|
|
901
|
-
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
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
|
|
850
|
+
* Renders patient telecom information grouped by system
|
|
847
851
|
* @param patient - Patient resource
|
|
848
|
-
* @returns HTML string
|
|
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
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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
|
-
|
|
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
|
-
|
|
873
|
-
|
|
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
|
-
<
|
|
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
|
-
<
|
|
1684
|
+
<h3>Diagnostic Reports</h3>
|
|
1658
1685
|
<table>
|
|
1659
1686
|
<thead>
|
|
1660
1687
|
<tr>
|