diff --git a/containers/ecr-viewer/src/app/services/formatService.tsx b/containers/ecr-viewer/src/app/services/formatService.tsx
index dabe0ddfab..fc7c6c9f24 100644
--- a/containers/ecr-viewer/src/app/services/formatService.tsx
+++ b/containers/ecr-viewer/src/app/services/formatService.tsx
@@ -415,25 +415,18 @@ export function getFirstNonCommentChild(
}
/**
- * Extracts the `data-id` value from the element or an HTML comment within the child nodes.
- * The `data-id` is either expected to be an attribute (`data-id="some-id"`) or in the format: ``.
+ * Extracts the `data-id` attribute from the element or its ID if there is no `data-id` attribute.
* @param elem - The element to search for the `data-id`.
* @returns - The extracted `data-id` value if found, otherwise `null`.
*/
export function getDataId(elem: HTMLLIElement | HTMLTableElement | Element) {
- if (elem.getAttribute("data-id")) return elem.getAttribute("data-id");
- for (let i = 0; i < elem.childNodes.length; i++) {
- const node = elem.childNodes[i];
- if (node.nodeType === Node.COMMENT_NODE) {
- // Extract the comment content and parse out the data-id
- const commentText = node.nodeValue?.trim() || "";
- const match = commentText.match(/data-id:\s*([^\s]+)/);
- if (match) {
- return match[1];
- }
- }
+ if (elem.getAttribute("data-id")) {
+ return elem.getAttribute("data-id");
+ } else if (elem.id) {
+ return elem.id;
+ } else {
+ return null; // Return null if no match is found
}
- return null; // Return null if no match is found
}
/**
diff --git a/containers/ecr-viewer/src/app/tests/assets/BundleLab.json b/containers/ecr-viewer/src/app/tests/assets/BundleLab.json
index b455b7c962..b18eb122c0 100644
--- a/containers/ecr-viewer/src/app/tests/assets/BundleLab.json
+++ b/containers/ecr-viewer/src/app/tests/assets/BundleLab.json
@@ -47,7 +47,7 @@
"title": "Results",
"text": {
"status": "generated",
- "div": "
- Stool Pathogens, NAAT, 12 to 25 Targets (09/28/2022 1:51 PM PDT)
Component | Value | Ref Range | Test Method | Analysis Time | Performed At | Pathologist Signature |
Campylobacter, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 1:59 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Plesiomonas shigelloides, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 1:59 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Specimen (Source) | Anatomical Location / Laterality | Collection Method / Volume | Collection Time | Received Time |
Stool | STOOL SPECIMEN / Unknown | | 09/28/2022 1:51 PM PDT | 09/28/2022 1:51 PM PDT |
Authorizing Provider | Result Type |
Ambhp1 Test MD | MICROBIOLOGY - GENERAL ORDERABLES |
Performing Organization | Address | City/State/ZIP Code | Phone Number |
PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | 501 S. Buena Vista Street | Burbank, CA 91505 | 818-847-6000 |
- (ABNORMAL) Stool Pathogens, NAAT, 12 to 25 Targets (09/28/2022 1:51 PM PDT)
Component | Value | Ref Range | Test Method | Analysis Time | Performed At | Pathologist Signature |
Campylobacter, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 2:00 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Plesiomonas shigelloides, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 2:00 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Specimen (Source) | Anatomical Location / Laterality | Collection Method / Volume | Collection Time | Received Time |
Stool | STOOL SPECIMEN / Unknown | | 09/28/2022 1:51 PM PDT | 09/28/2022 1:51 PM PDT |
Authorizing Provider | Result Type |
Ambhp1 Test MD | MICROBIOLOGY - GENERAL ORDERABLES |
Performing Organization | Address | City/State/ZIP Code | Phone Number |
PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | 501 S. Buena Vista Street | Burbank, CA 91505 | 818-847-6000 |
- Cytogenomic SNP microarray (04/04/2022 11:55 AM CDT)
Component | Value | Ref Range | Test Method | Analysis Time | Performed At | Pathologist Signature |
Organism ID | Acinetobacter baumannii | | | | VUMC CERNER LAB | |
Comment: Lab comment
|
Organism | Antibiotic | Method | Susceptibility |
Acinetobacter baumannii | Amikacin | MIC | 0.25: Susceptible |
Acinetobacter baumannii | Avycaz (Ceftazidime/Avibactam) | MIC | 0.05: Intermediate |
Acinetobacter baumannii | Levofloxacin | MIC | 0.75: Resistant |
Specimen (Source) | Anatomical Location / Laterality | Collection Method / Volume | Collection Time | Received Time |
Blood | | Collection / Unknown | 04/04/2022 11:55 AM CDT | 04/18/2022 2:46 PM CDT |
Narrative |
VUMC CERNER LAB - 04/18/2022 2:57 PM CDT MICROARRAY REPORT NARRATIVE |
Resulting Agency Comment |
testing comment |
Authorizing Provider | Result Type |
Carda Testprovqa MD | LAB GENETIC TESTING |
Performing Organization | Address | City/State/ZIP Code | Phone Number |
VUMC CERNER LAB | 4605 TVC VUMC 1301 Medical Center Drive | NASHVILLE, TN 37232-5310 | 615-875-5227 |
documented in this encounter"
+ "div": " - Stool Pathogens, NAAT, 12 to 25 Targets (09/28/2022 1:51 PM PDT)
Component | Value | Ref Range | Test Method | Analysis Time | Performed At | Pathologist Signature |
Campylobacter, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 1:59 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Plesiomonas shigelloides, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 1:59 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Specimen (Source) | Anatomical Location / Laterality | Collection Method / Volume | Collection Time | Received Time |
Stool | STOOL SPECIMEN / Unknown | | 09/28/2022 1:51 PM PDT | 09/28/2022 1:51 PM PDT |
Authorizing Provider | Result Type |
Ambhp1 Test MD | MICROBIOLOGY - GENERAL ORDERABLES |
Performing Organization | Address | City/State/ZIP Code | Phone Number |
PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | 501 S. Buena Vista Street | Burbank, CA 91505 | 818-847-6000 |
- (ABNORMAL) Stool Pathogens, NAAT, 12 to 25 Targets (09/28/2022 1:51 PM PDT)
Component | Value | Ref Range | Test Method | Analysis Time | Performed At | Pathologist Signature |
Campylobacter, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 2:00 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Plesiomonas shigelloides, NAAT | Not Detected | Not Detected | LAB DEVICE: BIOFIRE\u00ae FILMARRAY\u00ae 2.0 SYSTEM | 09/28/2022 2:00 PM PDT | PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | |
Specimen (Source) | Anatomical Location / Laterality | Collection Method / Volume | Collection Time | Received Time |
Stool | STOOL SPECIMEN / Unknown | | 09/28/2022 1:51 PM PDT | 09/28/2022 1:51 PM PDT |
Authorizing Provider | Result Type |
Ambhp1 Test MD | MICROBIOLOGY - GENERAL ORDERABLES |
Performing Organization | Address | City/State/ZIP Code | Phone Number |
PROVIDENCE ST. JOSEPH MEDICAL CENTER LABORATORY (CLIA 05D0672675) | 501 S. Buena Vista Street | Burbank, CA 91505 | 818-847-6000 |
- Cytogenomic SNP microarray (04/04/2022 11:55 AM CDT)
Component | Value | Ref Range | Test Method | Analysis Time | Performed At | Pathologist Signature |
Organism ID | Acinetobacter baumannii | | | | VUMC CERNER LAB | |
Comment: Lab comment
|
Organism | Antibiotic | Method | Susceptibility |
Acinetobacter baumannii | Amikacin | MIC | 0.25: Susceptible |
Acinetobacter baumannii | Avycaz (Ceftazidime/Avibactam) | MIC | 0.05: Intermediate |
Acinetobacter baumannii | Levofloxacin | MIC | 0.75: Resistant |
Specimen (Source) | Anatomical Location / Laterality | Collection Method / Volume | Collection Time | Received Time |
Blood | | Collection / Unknown | 04/04/2022 11:55 AM CDT | 04/18/2022 2:46 PM CDT |
Narrative |
VUMC CERNER LAB - 04/18/2022 2:57 PM CDT MICROARRAY REPORT NARRATIVE |
Resulting Agency Comment |
testing comment |
Authorizing Provider | Result Type |
Carda Testprovqa MD | LAB GENETIC TESTING |
Performing Organization | Address | City/State/ZIP Code | Phone Number |
VUMC CERNER LAB | 4605 TVC VUMC 1301 Medical Center Drive | NASHVILLE, TN 37232-5310 | 615-875-5227 |
documented in this encounter"
},
"code": {
"coding": [
diff --git a/containers/ecr-viewer/src/app/tests/services/formatService.test.tsx b/containers/ecr-viewer/src/app/tests/services/formatService.test.tsx
index d9121b91ee..013c15196a 100644
--- a/containers/ecr-viewer/src/app/tests/services/formatService.test.tsx
+++ b/containers/ecr-viewer/src/app/tests/services/formatService.test.tsx
@@ -158,9 +158,9 @@ describe("Format Date", () => {
describe("formatTablesToJSON", () => {
describe("return JSON object given an HTML string", () => {
- it("", () => {
+ it("", () => {
const htmlString =
- "Lab TestComponent | Analysis Time |
---|
Campylobacter, NAAT | 01/01/2024 1:00 PM PDT |
Salmonella, NAAT | 01/01/2024 1:00 PM PDT |
Specimen (Source) | Collection Time | Received Time |
---|
Stool | 01/01/2024 12:00 PM PDT | 01/01/2024 12:00 PM PDT |
";
+ "Lab TestComponent | Analysis Time |
---|
Campylobacter, NAAT | 01/01/2024 1:00 PM PDT |
Salmonella, NAAT | 01/01/2024 1:00 PM PDT |
Specimen (Source) | Collection Time | Received Time |
---|
Stool | 01/01/2024 12:00 PM PDT | 01/01/2024 12:00 PM PDT |
";
const expectedResult = [
{
resultId: "Result.12345",
@@ -219,9 +219,70 @@ describe("formatTablesToJSON", () => {
expect(result).toEqual(expectedResult);
});
- it(" ", () => {
+ it("", () => {
const htmlString =
- "- Lab Test
Component | Analysis Time |
---|
Campylobacter, NAAT | 01/01/2024 1:00 PM PDT |
Salmonella, NAAT | 01/01/2024 1:00 PM PDT |
Specimen (Source) | Collection Time | Received Time |
---|
Stool | 01/01/2024 12:00 PM PDT | 01/01/2024 12:00 PM PDT |
";
+ "Lab TestComponent | Analysis Time |
---|
Campylobacter, NAAT | 01/01/2024 1:00 PM PDT |
Salmonella, NAAT | 01/01/2024 1:00 PM PDT |
Specimen (Source) | Collection Time | Received Time |
---|
Stool | 01/01/2024 12:00 PM PDT | 01/01/2024 12:00 PM PDT |
";
+ const expectedResult = [
+ {
+ resultId: "Result.12345",
+ resultName: "Lab Test",
+ tables: [
+ [
+ {
+ Component: {
+ value: "Campylobacter, NAAT",
+ metadata: {
+ id: "Result.12345.Comp1Name",
+ },
+ },
+ "Analysis Time": {
+ value: "01/01/2024 1:00 PM PDT",
+ metadata: {},
+ },
+ },
+ {
+ Component: {
+ value: "Salmonella, NAAT",
+ metadata: {
+ id: "Result.12345.Comp2Name",
+ },
+ },
+ "Analysis Time": {
+ value: "01/01/2024 1:00 PM PDT",
+ metadata: {},
+ },
+ },
+ ],
+ [
+ {
+ "Specimen (Source)": {
+ value: "Stool",
+ metadata: {
+ id: "Result.12345.Specimen",
+ },
+ },
+ "Collection Time": {
+ value: "01/01/2024 12:00 PM PDT",
+ metadata: {},
+ },
+ "Received Time": {
+ value: "01/01/2024 12:00 PM PDT",
+ metadata: {},
+ },
+ },
+ ],
+ ],
+ },
+ ];
+
+ const result = formatTablesToJSON(htmlString);
+
+ expect(result).toEqual(expectedResult);
+ });
+
+ it(" ", () => {
+ const htmlString =
+ "- Lab Test
Component | Analysis Time |
---|
Campylobacter, NAAT | 01/01/2024 1:00 PM PDT |
Salmonella, NAAT | 01/01/2024 1:00 PM PDT |
Specimen (Source) | Collection Time | Received Time |
---|
Stool | 01/01/2024 12:00 PM PDT | 01/01/2024 12:00 PM PDT |
";
const expectedResult = [
{
resultId: "Result.12345",
@@ -280,6 +341,67 @@ describe("formatTablesToJSON", () => {
expect(result).toEqual(expectedResult);
});
+ it(" ", () => {
+ const htmlString =
+ "- Lab Test
Component | Analysis Time |
---|
Campylobacter, NAAT | 01/01/2024 1:00 PM PDT |
Salmonella, NAAT | 01/01/2024 1:00 PM PDT |
Specimen (Source) | Collection Time | Received Time |
---|
Stool | 01/01/2024 12:00 PM PDT | 01/01/2024 12:00 PM PDT |
";
+ const expectedResult = [
+ {
+ resultId: "Result.12345",
+ resultName: "Lab Test",
+ tables: [
+ [
+ {
+ Component: {
+ value: "Campylobacter, NAAT",
+ metadata: {
+ id: "Result.12345.Comp1Name",
+ },
+ },
+ "Analysis Time": {
+ value: "01/01/2024 1:00 PM PDT",
+ metadata: {},
+ },
+ },
+ {
+ Component: {
+ value: "Salmonella, NAAT",
+ metadata: {
+ id: "Result.12345.Comp2Name",
+ },
+ },
+ "Analysis Time": {
+ value: "01/01/2024 1:00 PM PDT",
+ metadata: {},
+ },
+ },
+ ],
+ [
+ {
+ "Specimen (Source)": {
+ value: "Stool",
+ metadata: {
+ id: "Result.12345.Specimen",
+ },
+ },
+ "Collection Time": {
+ value: "01/01/2024 12:00 PM PDT",
+ metadata: {},
+ },
+ "Received Time": {
+ value: "01/01/2024 12:00 PM PDT",
+ metadata: {},
+ },
+ },
+ ],
+ ],
+ },
+ ];
+
+ const result = formatTablesToJSON(htmlString);
+
+ expect(result).toEqual(expectedResult);
+ });
+
it("", () => {
const tableString =
"Scheduled OrdersName |
---|
test2 |
documented as of this encounter\n";
@@ -567,40 +689,22 @@ describe("getDataId", () => {
expect(result).toEqual("attribute123");
});
- it("should return the correct data-id from a comment node", () => {
- const li = document.createElement("li");
- li.appendChild(document.createComment("data-id: abc123-abc123"));
-
- const result = getDataId(li);
- expect(result).toEqual("abc123-abc123");
- });
-
- it("should return null if there is no data-id attribute or comment node", () => {
+ it("should return the id if there is one", () => {
const li = document.createElement("li");
- li.textContent = "No comment or data-id attribute here";
+ li.setAttribute("ID", "id123");
const result = getDataId(li);
- expect(result).toBeNull();
+ expect(result).toEqual("id123");
});
- it("should return null if the comment does not contain a valid data-id", () => {
+ it("should return null if there is no id or data-id attribute", () => {
const li = document.createElement("li");
- li.appendChild(document.createComment("some other comment"));
+ li.textContent = "No id or data-id attribute here";
const result = getDataId(li);
expect(result).toBeNull();
});
- it("should handle multiple child nodes and find the data-id in a comment", () => {
- const li = document.createElement("li");
- li.appendChild(document.createTextNode("Some text"));
- li.appendChild(document.createComment("data-id: abc123-abc123"));
- li.appendChild(document.createElement("span"));
-
- const result = getDataId(li);
- expect(result).toEqual("abc123-abc123");
- });
-
it("should return the correct data-id from a table element", () => {
const table = document.createElement("table");
table.setAttribute("data-id", "table123");
@@ -608,15 +712,6 @@ describe("getDataId", () => {
const result = getDataId(table);
expect(result).toEqual("table123");
});
-
- it("should prioritize the data-id attribute over a comment node", () => {
- const li = document.createElement("li");
- li.setAttribute("data-id", "attribute123");
- li.appendChild(document.createComment("data-id: abc123-abc123"));
-
- const result = getDataId(li);
- expect(result).toEqual("attribute123"); // Should return the attribute value
- });
});
describe("getFirstNonCommentChild", () => {