From 3dacdb5830334ef41f693275eb484ef26fdf7d5f Mon Sep 17 00:00:00 2001 From: Boban Ljuljdjurovic Date: Thu, 16 Jan 2025 09:39:47 -0500 Subject: [PATCH] remove data_source from core.sql --- containers/ecr-viewer/sql/core.sql | 1 - .../save-fhir-data/save-fhir-data-service.ts | 3 +- .../src/app/api/save-fhir-data/types.ts | 1 - .../src/app/services/listEcrDataService.ts | 2 -- .../src/app/tests/listEcrDataService.test.tsx | 4 --- .../app/tests/save-fhir-data-service.test.tsx | 33 +++---------------- 6 files changed, 5 insertions(+), 39 deletions(-) diff --git a/containers/ecr-viewer/sql/core.sql b/containers/ecr-viewer/sql/core.sql index c201bc35cc..49fb08fb3e 100644 --- a/containers/ecr-viewer/sql/core.sql +++ b/containers/ecr-viewer/sql/core.sql @@ -3,7 +3,6 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE ecr_data ( eICR_ID VARCHAR(200) PRIMARY KEY, set_id VARCHAR(255), - data_source VARCHAR(2), -- S3 or DB fhir_reference_link VARCHAR(500), -- Link to the ecr fhir bundle patient_name_first VARCHAR(100), patient_name_last VARCHAR(100), diff --git a/containers/ecr-viewer/src/app/api/save-fhir-data/save-fhir-data-service.ts b/containers/ecr-viewer/src/app/api/save-fhir-data/save-fhir-data-service.ts index 4d7a6e0f22..a3d7084134 100644 --- a/containers/ecr-viewer/src/app/api/save-fhir-data/save-fhir-data-service.ts +++ b/containers/ecr-viewer/src/app/api/save-fhir-data/save-fhir-data-service.ts @@ -451,13 +451,12 @@ export const saveMetadataToPostgres = async ( await database.tx(async (t) => { // Insert main ECR metadata const saveToEcrData = new PQ({ - text: "INSERT INTO ecr_data (eICR_ID, patient_name_last, patient_name_first, patient_birth_date, data_source, report_date, set_id) VALUES ($1, $2, $3, $4, $5, $6, $7)", + text: "INSERT INTO ecr_data (eICR_ID, patient_name_last, patient_name_first, patient_birth_date, report_date, set_id) VALUES ($1, $2, $3, $4, $5, $6)", values: [ ecrId, metadata.last_name, metadata.first_name, metadata.birth_date, - "DB", metadata.report_date, metadata.eicr_set_id, ], diff --git a/containers/ecr-viewer/src/app/api/save-fhir-data/types.ts b/containers/ecr-viewer/src/app/api/save-fhir-data/types.ts index c1b36cd6ee..6b89beab2f 100644 --- a/containers/ecr-viewer/src/app/api/save-fhir-data/types.ts +++ b/containers/ecr-viewer/src/app/api/save-fhir-data/types.ts @@ -83,7 +83,6 @@ export interface BundleMetadata { last_name: string; first_name: string; birth_date: string; - data_source: string; eicr_set_id: string | undefined; rr: RR[] | undefined; report_date: string; diff --git a/containers/ecr-viewer/src/app/services/listEcrDataService.ts b/containers/ecr-viewer/src/app/services/listEcrDataService.ts index bd3445a606..cbcf4d8791 100644 --- a/containers/ecr-viewer/src/app/services/listEcrDataService.ts +++ b/containers/ecr-viewer/src/app/services/listEcrDataService.ts @@ -5,7 +5,6 @@ import { DateRangePeriod } from "@/app/view-data/utils/date-utils"; export interface CoreMetadataModel { eicr_id: string; - data_source: "DB" | "S3"; data_link: string; patient_name_first: string; patient_name_last: string; @@ -18,7 +17,6 @@ export interface CoreMetadataModel { export interface ExtendedMetadataModel { eICR_ID: string; - data_source: "DB" | "S3"; data_link: string; first_name: string; last_name: string; diff --git a/containers/ecr-viewer/src/app/tests/listEcrDataService.test.tsx b/containers/ecr-viewer/src/app/tests/listEcrDataService.test.tsx index 89be4959bb..cba743da0f 100644 --- a/containers/ecr-viewer/src/app/tests/listEcrDataService.test.tsx +++ b/containers/ecr-viewer/src/app/tests/listEcrDataService.test.tsx @@ -49,7 +49,6 @@ describe("listEcrDataService", () => { report_date: date3, conditions: ["Long"], rule_summaries: ["Longer"], - data_source: "DB", data_link: "", }, { @@ -61,7 +60,6 @@ describe("listEcrDataService", () => { report_date: date3, conditions: ["Stuff"], rule_summaries: ["Other stuff", "Even more stuff"], - data_source: "DB", data_link: "", }, ]; @@ -144,7 +142,6 @@ describe("listEcrDataService", () => { conditions: ["super ebola", "double ebola"], rule_summaries: ["watch out for super ebola"], data_link: "", - data_source: "DB", }, ]), ); @@ -198,7 +195,6 @@ describe("listEcrDataService", () => { conditions: ["sick", "tired"], rule_summaries: ["stuff", "disease discovered"], data_link: "", - data_source: "DB", }, ]), ); diff --git a/containers/ecr-viewer/src/app/tests/save-fhir-data-service.test.tsx b/containers/ecr-viewer/src/app/tests/save-fhir-data-service.test.tsx index 2614b8d00f..5c508d5754 100644 --- a/containers/ecr-viewer/src/app/tests/save-fhir-data-service.test.tsx +++ b/containers/ecr-viewer/src/app/tests/save-fhir-data-service.test.tsx @@ -21,14 +21,13 @@ describe("saveMetadataToPostgres", () => { last_name: "lname", first_name: "fname", birth_date: "01/01/2000", - data_source: "s3", eicr_set_id: "1234", rr: [], report_date: "12/20/2024", }; const saveEcrDataQuery = - "INSERT INTO ecr_data (eICR_ID, patient_name_last, patient_name_first, patient_birth_date, data_source, report_date, set_id) VALUES ($1, $2, $3, $4, $5, $6, $7)"; + "INSERT INTO ecr_data (eICR_ID, patient_name_last, patient_name_first, patient_birth_date, report_date, set_id) VALUES ($1, $2, $3, $4, $5, $6)"; const saveRRConditionsQuery = "INSERT INTO ecr_rr_conditions (uuid, eICR_ID, condition) VALUES (uuid_generate_v4(), $1, $2) RETURNING uuid"; const saveRRSummaryQuery = @@ -66,15 +65,7 @@ describe("saveMetadataToPostgres", () => { expect(mockTransaction.one).not.toHaveBeenCalled(); expect(mockTransaction.none).toHaveBeenCalledExactlyOnceWith({ text: saveEcrDataQuery, - values: [ - "1-2-3-4", - "lname", - "fname", - "01/01/2000", - "DB", - "12/20/2024", - "1234", - ], + values: ["1-2-3-4", "lname", "fname", "01/01/2000", "12/20/2024", "1234"], }); }); @@ -101,15 +92,7 @@ describe("saveMetadataToPostgres", () => { }); expect(mockTransaction.none).toHaveBeenCalledExactlyOnceWith({ text: saveEcrDataQuery, - values: [ - "1-2-3-4", - "lname", - "fname", - "01/01/2000", - "DB", - "12/20/2024", - "1234", - ], + values: ["1-2-3-4", "lname", "fname", "01/01/2000", "12/20/2024", "1234"], }); }); @@ -137,15 +120,7 @@ describe("saveMetadataToPostgres", () => { expect(mockTransaction.none).toHaveBeenCalledTimes(3); expect(mockTransaction.none).toHaveBeenNthCalledWith(1, { text: saveEcrDataQuery, - values: [ - "1-2-3-4", - "lname", - "fname", - "01/01/2000", - "DB", - "12/20/2024", - "1234", - ], + values: ["1-2-3-4", "lname", "fname", "01/01/2000", "12/20/2024", "1234"], }); expect(mockTransaction.none).toHaveBeenNthCalledWith(2, {