From 77548a350e6713288b8d72309b0f4820f978ee43 Mon Sep 17 00:00:00 2001 From: mehansen Date: Wed, 29 Apr 2026 12:13:05 -0700 Subject: [PATCH 01/11] remove unused join --- .../routines/003-sp_nrt_provider_postprocessing-001.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql index 92c6ff9cd..25a72710c 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql @@ -97,7 +97,6 @@ BEGIN last_chg_user_name as PROVIDER_LAST_UPDATED_BY, last_chg_time as PROVIDER_LAST_CHANGE_TIME from dbo.nrt_provider nrt with (nolock) - left join dbo.d_provider p with (nolock) on p.provider_uid = nrt.provider_uid where nrt.provider_uid in (SELECT value FROM STRING_SPLIT(@id_list, ',')) ) select From a29eabe5b29cf6d2f2ccfa5815f302676d20b754 Mon Sep 17 00:00:00 2001 From: mehansen Date: Thu, 30 Apr 2026 08:58:49 -0700 Subject: [PATCH 02/11] Revert "remove unused join" This reverts commit a2fd3e38dd603ec484fc4e5b1b2293e3fb66f753. --- .../routines/003-sp_nrt_provider_postprocessing-001.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql index 25a72710c..92c6ff9cd 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/003-sp_nrt_provider_postprocessing-001.sql @@ -97,6 +97,7 @@ BEGIN last_chg_user_name as PROVIDER_LAST_UPDATED_BY, last_chg_time as PROVIDER_LAST_CHANGE_TIME from dbo.nrt_provider nrt with (nolock) + left join dbo.d_provider p with (nolock) on p.provider_uid = nrt.provider_uid where nrt.provider_uid in (SELECT value FROM STRING_SPLIT(@id_list, ',')) ) select From 98af8ca9f440a72d75f86fb6126116943bf54dc7 Mon Sep 17 00:00:00 2001 From: mehansen Date: Thu, 30 Apr 2026 09:25:07 -0700 Subject: [PATCH 03/11] add new phone columns to nrt_provider table --- .../330-sp_covid_lab_datamart_postprocessing-001.sql | 4 ++-- .../005-rdb_modern/tables/003-create_nrt_provider-001.sql | 4 +++- .../person/model/dto/provider/ProviderReporting.java | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql index 3bbe48160..c2e163995 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql @@ -379,8 +379,8 @@ BEGIN COALESCE(d_provider_order.PROVIDER_STATE_CODE,provider_order.state_code) AS Ordering_Provider_State_Cd, COALESCE(dim_state_provider_order.state_NM, nrt_state_provider_order.state_NM) AS Ordering_Provider_State, COALESCE(d_provider_order.PROVIDER_ZIP,provider_order.zip) AS Ordering_Provider_Zip_Cd, - COALESCE(d_provider_order.PROVIDER_PHONE_WORK,provider_order.phone_work) AS Ordering_Provider_Phone_Nbr, - COALESCE(COALESCE(d_provider_order.PROVIDER_PHONE_EXT_WORK,provider_order.phone_ext_work), '') AS Ordering_Provider_Phone_Ext, + provider_order.phone_work_phone AS Ordering_Provider_Phone_Nbr, + COALESCE(provider_order.phone_ext_work_phone, '') AS Ordering_Provider_Phone_Ext, provider_order.provider_npi AS ORDERING_PROVIDER_ID INTO #COVID_LAB_ENTITIES_DATA FROM #COVID_LAB_CORE_DATA o diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/tables/003-create_nrt_provider-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/tables/003-create_nrt_provider-001.sql index c0ec9d653..215aac51f 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/tables/003-create_nrt_provider-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/tables/003-create_nrt_provider-001.sql @@ -28,8 +28,10 @@ CREATE TABLE dbo.nrt_provider address_comments varchar(2000) null, phone_work varchar(50) null, phone_ext_work varchar(50) null, - email_work varchar(50) null, phone_comments varchar(2000) null, + phone_work_phone varchar(50) null, + phone_ext_work_phone varchar(50) null, + email_work varchar(50) null, phone_cell varchar(50) null, entry_method varchar(50) null, add_user_id bigint null, diff --git a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/provider/ProviderReporting.java b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/provider/ProviderReporting.java index 91d9d3e44..dc3398194 100644 --- a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/provider/ProviderReporting.java +++ b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/provider/ProviderReporting.java @@ -66,10 +66,16 @@ public class ProviderReporting implements PersonExtendedProps { private String countryCode; private String addressComments; - // Phone + // Telephone - Primary Workplace Office type private String phoneWork; private String phoneExtWork; private String phoneComments; + + // Telephone - Primary Workplace Phone type + private String phoneWorkPhone; + private String phoneExtWorkPhone; + + // Telephone - Cellular phone type private String phoneCell; // Email From d504df153cedfacd81e2468f87f2309ea0faa719 Mon Sep 17 00:00:00 2001 From: mehansen Date: Thu, 30 Apr 2026 15:42:16 -0700 Subject: [PATCH 04/11] populate nrt table phone numbers matching masteretl logic --- .../routines/052-sp_provider_event-001.sql | 28 ++++------- .../person/model/dto/PersonExtendedProps.java | 4 ++ .../person/model/dto/persondetail/Phone.java | 23 ++++++++-- .../person/transformer/DataPostProcessor.java | 46 ++++++------------- 4 files changed, 46 insertions(+), 55 deletions(-) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql index 4979cac37..c0a6fa542 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql @@ -102,22 +102,6 @@ BEGIN FOR json path, INCLUDE_NULL_VALUES) AS address) AS address, -- person phone (SELECT ( - SELECT ph_tl_uid, ph_elp_cd, ph_elp_use_cd, telephoneNbr, extensionTxt, phone_comments - FROM (SELECT tl.tele_locator_uid AS [ph_tl_uid], - elp.cd AS [ph_elp_cd], - elp.use_cd AS [ph_elp_use_cd], - REPLACE(tl.phone_nbr_txt, ' ', '') telephoneNbr, - tl.extension_txt extensionTxt, - elp.locator_desc_txt phone_comments - FROM nbs_odse.dbo.Entity_locator_participation elp WITH (NOLOCK) - JOIN nbs_odse.dbo.Tele_locator tl WITH (NOLOCK) - ON elp.locator_uid = tl.tele_locator_uid - WHERE elp.entity_uid = p.person_uid - AND elp.CLASS_CD = 'TELE' - AND elp.CD IN ('O') - AND elp.RECORD_STATUS_CD = 'ACTIVE' - AND tl.phone_nbr_txt IS NOT NULL - UNION ALL SELECT tl.tele_locator_uid AS [ph_tl_uid], elp.cd AS [ph_elp_cd], elp.use_cd AS [ph_elp_use_cd], @@ -129,8 +113,16 @@ BEGIN ON elp.locator_uid = tl.tele_locator_uid WHERE elp.entity_uid = p.person_uid AND elp.CLASS_CD = 'TELE' - AND elp.CD IN ('CP') - AND tl.phone_nbr_txt IS NOT NULL ) t + AND tl.phone_nbr_txt IS NOT NULL + AND ( + (elp.USE_CD = 'WP' AND elp.CD = 'O' AND elp.RECORD_STATUS_CD = 'ACTIVE') -- provider office phone + OR + (elp.USE_CD = 'WP' AND elp.CD = 'PH' AND elp.STATUS_CD = 'A') -- provider workplace phone + OR + (elp.CD = 'CP') -- provider cell phone + -- todo: should we really be including deleted cell numbers? + -- todo: let service do filtering by cd and use_cd for readability/findability? + ) FOR json path, INCLUDE_NULL_VALUES) AS phone) AS phone, -- person email (SELECT (SELECT tl.tele_locator_uid AS [email_tl_uid], diff --git a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/PersonExtendedProps.java b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/PersonExtendedProps.java index ccd341c24..79cfea2b3 100644 --- a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/PersonExtendedProps.java +++ b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/PersonExtendedProps.java @@ -71,6 +71,10 @@ default void setPhoneExtHome(String phoneExtHome) {} default void setPhoneCell(String phoneCell) {} + default void setPhoneWorkPhone(String phoneWorkPhone) {} + + default void setPhoneExtWorkPhone(String phoneExtWorkPhone) {} + default void setPhElpCd(String phElpCd) {} default void setPhElpUseCd(String phElpUseCd) {} diff --git a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/persondetail/Phone.java b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/persondetail/Phone.java index b23840973..7013d8fdf 100644 --- a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/persondetail/Phone.java +++ b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/model/dto/persondetail/Phone.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import gov.cdc.nbs.report.pipeline.person.model.dto.PersonExtendedProps; +import gov.cdc.nbs.report.pipeline.person.model.dto.provider.ProviderElasticSearch; +import gov.cdc.nbs.report.pipeline.person.model.dto.provider.ProviderReporting; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -35,10 +37,23 @@ public T updatePerson(T personFull) { personFull.setPhTlUid(teleLocatorUid); if (useCd.equalsIgnoreCase("WP")) { - personFull.setPhoneWork(telephoneNbr); - personFull.setPhoneExtWork(extensionTxt); - personFull.setPhoneComments(phoneComments); - } else if (useCd.equalsIgnoreCase("H")) { + // work phone fields applied differently for providers and patients + if (personFull instanceof ProviderReporting || personFull instanceof ProviderElasticSearch) { + if (cd.equalsIgnoreCase("PH")) { + personFull.setPhoneWorkPhone(telephoneNbr); + personFull.setPhoneExtWorkPhone(extensionTxt); + } else if (cd.equalsIgnoreCase("O")) { + personFull.setPhoneWork(telephoneNbr); + personFull.setPhoneExtWork(extensionTxt); + personFull.setPhoneComments(phoneComments); + } + } else { + if (cd.equalsIgnoreCase("PH")) { + personFull.setPhoneWork(telephoneNbr); + personFull.setPhoneExtWork(extensionTxt); + } + } + } else if (useCd.equalsIgnoreCase("H") && cd.equalsIgnoreCase("PH")) { personFull.setPhoneHome(telephoneNbr); personFull.setPhoneExtHome(extensionTxt); } diff --git a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/transformer/DataPostProcessor.java b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/transformer/DataPostProcessor.java index f940180b5..151d655e4 100644 --- a/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/transformer/DataPostProcessor.java +++ b/reporting-pipeline-service/src/main/java/gov/cdc/nbs/report/pipeline/person/transformer/DataPostProcessor.java @@ -12,6 +12,7 @@ import gov.cdc.nbs.report.pipeline.person.model.dto.provider.ProviderElasticSearch; import gov.cdc.nbs.report.pipeline.person.model.dto.provider.ProviderReporting; import java.util.*; +import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import lombok.NoArgsConstructor; @@ -118,45 +119,24 @@ public void processPersonTelephone(String teleph // Deserialize once Phone[] allData = requireNonNull(deserializePayload(telephone, Phone[].class)); - // --- Special work phone logic for ProviderReporting / ProviderElasticSearch --- - if (pf instanceof ProviderReporting || pf instanceof ProviderElasticSearch) { - Phone workPhone = - Arrays.stream(allData) - .filter(p -> "WP".equalsIgnoreCase(p.getUseCd()) && "O".equalsIgnoreCase(p.getCd())) - .max(Comparator.comparing(Phone::getTeleLocatorUid)) - .orElse(null); - - if (workPhone == null) { - workPhone = - Arrays.stream(allData) - .filter(p -> "WP".equalsIgnoreCase(p.getUseCd())) - .max(Comparator.comparing(Phone::getTeleLocatorUid)) - .orElse(null); - } - - if (workPhone != null) { - workPhone.updatePerson(pf); // delegate update - } - } else { - Arrays.stream(allData) - .filter(p -> "WP".equalsIgnoreCase(p.getUseCd())) - .max(Comparator.comparing(Phone::getTeleLocatorUid)) - .ifPresent(p -> p.updatePerson(pf)); // delegate update - } - - Function, T> personPhoneFn = + Consumer> maxPhoneFn = p -> Arrays.stream(allData) .filter(p) .max(Comparator.comparing(Phone::getTeleLocatorUid)) - .map(n -> n.updatePerson(pf)) - .orElse(null); + .ifPresent(n -> n.updatePerson(pf)); + + // Work place phone + maxPhoneFn.accept(p -> "WP".equalsIgnoreCase(p.getUseCd()) && "PH".equalsIgnoreCase(p.getCd())); + + // Work place office phone + maxPhoneFn.accept(p -> "WP".equalsIgnoreCase(p.getUseCd()) && "O".equalsIgnoreCase(p.getCd())); - // --- Home phone --- - personPhoneFn.apply(p -> "H".equalsIgnoreCase(p.getUseCd())); + // Home phone + maxPhoneFn.accept(p -> "H".equalsIgnoreCase(p.getUseCd()) && "PH".equalsIgnoreCase(p.getCd())); - // --- Cell phone --- - personPhoneFn.apply(p -> "CP".equalsIgnoreCase(p.getCd())); + // Cell phone + maxPhoneFn.accept(p -> "CP".equalsIgnoreCase(p.getCd())); } public void processPersonEntityData(String entityData, T pf) { From df47d79725cbaa3de5e1714afc085cedab149658 Mon Sep 17 00:00:00 2001 From: mehansen Date: Wed, 6 May 2026 09:45:54 -0700 Subject: [PATCH 05/11] fix blanks in phone ext --- .../db/005-rdb_modern/routines/052-sp_provider_event-001.sql | 1 - .../routines/330-sp_covid_lab_datamart_postprocessing-001.sql | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql index c0a6fa542..fc6e05345 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql @@ -120,7 +120,6 @@ BEGIN (elp.USE_CD = 'WP' AND elp.CD = 'PH' AND elp.STATUS_CD = 'A') -- provider workplace phone OR (elp.CD = 'CP') -- provider cell phone - -- todo: should we really be including deleted cell numbers? -- todo: let service do filtering by cd and use_cd for readability/findability? ) FOR json path, INCLUDE_NULL_VALUES) AS phone) AS phone, diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql index c2e163995..4f6672428 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/330-sp_covid_lab_datamart_postprocessing-001.sql @@ -380,7 +380,7 @@ BEGIN COALESCE(dim_state_provider_order.state_NM, nrt_state_provider_order.state_NM) AS Ordering_Provider_State, COALESCE(d_provider_order.PROVIDER_ZIP,provider_order.zip) AS Ordering_Provider_Zip_Cd, provider_order.phone_work_phone AS Ordering_Provider_Phone_Nbr, - COALESCE(provider_order.phone_ext_work_phone, '') AS Ordering_Provider_Phone_Ext, + provider_order.phone_ext_work_phone AS Ordering_Provider_Phone_Ext, provider_order.provider_npi AS ORDERING_PROVIDER_ID INTO #COVID_LAB_ENTITIES_DATA FROM #COVID_LAB_CORE_DATA o From fe4fa1d79cc68069f75344fa8e5462fecc11ec7e Mon Sep 17 00:00:00 2001 From: mehansen Date: Thu, 7 May 2026 14:19:34 -0700 Subject: [PATCH 06/11] clean up todo --- .../db/005-rdb_modern/routines/052-sp_provider_event-001.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql index fc6e05345..6864bae30 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql @@ -120,7 +120,6 @@ BEGIN (elp.USE_CD = 'WP' AND elp.CD = 'PH' AND elp.STATUS_CD = 'A') -- provider workplace phone OR (elp.CD = 'CP') -- provider cell phone - -- todo: let service do filtering by cd and use_cd for readability/findability? ) FOR json path, INCLUDE_NULL_VALUES) AS phone) AS phone, -- person email From 11f25800cf02baeb2abbc695a806e18e87a51277 Mon Sep 17 00:00:00 2001 From: mehansen Date: Mon, 18 May 2026 12:01:42 -0700 Subject: [PATCH 07/11] exclude deleted provider cell phones from D_Provider --- .../routines/052-sp_provider_event-001.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql index 6864bae30..62bc7defd 100644 --- a/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql +++ b/liquibase-service/src/main/resources/db/005-rdb_modern/routines/052-sp_provider_event-001.sql @@ -113,14 +113,9 @@ BEGIN ON elp.locator_uid = tl.tele_locator_uid WHERE elp.entity_uid = p.person_uid AND elp.CLASS_CD = 'TELE' + AND elp.RECORD_STATUS_CD = 'ACTIVE' AND tl.phone_nbr_txt IS NOT NULL - AND ( - (elp.USE_CD = 'WP' AND elp.CD = 'O' AND elp.RECORD_STATUS_CD = 'ACTIVE') -- provider office phone - OR - (elp.USE_CD = 'WP' AND elp.CD = 'PH' AND elp.STATUS_CD = 'A') -- provider workplace phone - OR - (elp.CD = 'CP') -- provider cell phone - ) + AND (elp.USE_CD = 'WP' OR elp.CD = 'CP') FOR json path, INCLUDE_NULL_VALUES) AS phone) AS phone, -- person email (SELECT (SELECT tl.tele_locator_uid AS [email_tl_uid], From 23591f6c2f63ccdd67e653d302d0e7e8eff4ea7a Mon Sep 17 00:00:00 2001 From: mehansen Date: Mon, 18 May 2026 21:18:36 -0700 Subject: [PATCH 08/11] add happy path unit test for case_lab_datamart sp --- .../unit/covidLabDatamart/expected.json | 109 +++++++++++++ .../testData/unit/covidLabDatamart/query.sql | 120 ++++++++++++++ .../testData/unit/covidLabDatamart/setup.sql | 149 ++++++++++++++++++ 3 files changed, 378 insertions(+) create mode 100644 reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/expected.json create mode 100644 reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/query.sql create mode 100644 reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/setup.sql diff --git a/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/expected.json b/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/expected.json new file mode 100644 index 000000000..fe918be65 --- /dev/null +++ b/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/expected.json @@ -0,0 +1,109 @@ +{ + "0": [ + { + "Observation_UID": 90006001, + "Lab_Local_ID": "LAB-TEST-90006001", + "Ordered_Test_Cd": "94500-6", + "Ordered_Test_Desc": "SARS-CoV-2 RNA panel", + "Ordered_Test_Code_System": "LN", + "Electronic_Ind": "Y", + "Program_Area_Cd": "STD", + "Jurisdiction_Cd": "130001", + "Jurisdiction_Nm": "Fulton County", + "Specimen_Cd": "NP", + "Specimen_Desc": "Nasopharyngeal Swab", + "Specimen_type_free_text": "Combined Naso/Oropharyngeal Swab", + "Specimen_Id": "ACC-2021-001", + "Testing_Lab_Accession_Number": "ACC-2021-001", + "SPECIMEN_SOURCE_SITE_CD": "NP", + "SPECIMEN_SOURCE_SITE_DESC": "Nasopharynx", + "Lab_Report_Dt": "2021-01-10 12:00:00", + "Lab_Rpt_Received_By_PH_Dt": "2021-01-10 14:00:00", + "ORDER_TEST_DATE": "2021-01-09 09:00:00", + "Specimen_Coll_Dt": "2021-01-09 09:00:00", + "Lab_Added_Dt": "2021-01-10 08:00:00", + "Lab_Update_Dt": "2021-01-10 15:00:00", + "Order_result_status": "Final", + "Test_result_status": "Final", + "COVID_LAB_DATAMART_KEY": 90006002, + "Resulted_Test_Cd": "94309-2", + "Resulted_Test_Desc": "SARS-CoV-2 RNA Ql NAA+probe", + "Resulted_Test_Code_System": "LN", + "DEVICE_INSTANCE_ID_1": "DEVICE-SERIAL-001", + "DEVICE_INSTANCE_ID_2": null, + "Device_Type_Id_1": "EUA001", + "Device_Type_Id_2": null, + "Test_Method_Desc": "RT-PCR", + "Result_Cd": "260373001", + "Result_Cd_Sys": "SCT", + "Result_Desc": "Detected", + "Text_Result_Desc": "SARS-CoV-2 RNA Detected", + "Result_Comments": "Specimen received in good condition.", + "Result": "Detected SARS-CoV-2 RNA Detected Specimen received in good condition.", + "Result_Category": "Positive", + "Numeric_Comparator_Cd": null, + "Numeric_Value_1": null, + "Numeric_Value_2": null, + "Numeric_Unit_Cd": null, + "Numeric_Low_Range": null, + "Numeric_High_Range": null, + "Numeric_Separator_Cd": null, + "Interpretation_Cd": "POS", + "Interpretation_Desc": "Positive", + "Last_Name": "Smith", + "Middle_Name": "A", + "First_Name": "John", + "Patient_Local_ID": "PSN-TEST-90001001", + "Current_Sex_Cd": "M", + "Age_Reported": "45", + "Age_Unit_Cd": "a", + "Birth_Dt": "1979-03-15 00:00:00", + "Phone_Number": "4045550100", + "Address_One": "123 Main St", + "City": "Atlanta", + "State_Cd": "13", + "State": "GA", + "Zip_Code": "30301", + "County_Cd": "063", + "County_Desc": "Fulton", + "PATIENT_RACE_CALC": "White", + "PATIENT_ETHNICITY": "N", + "Perform_Facility_Name": "State Reference Lab", + "Testing_lab_Address_One": "456 Lab Blvd", + "Testing_lab_City": "Atlanta", + "Testing_lab_State_Cd": "13", + "Testing_lab_State": "GA", + "Testing_lab_Zip_Cd": "30302", + "Testing_lab_county": "063", + "Testing_lab_county_Desc": "Fulton", + "Testing_lab_Country": "US", + "Reporting_Facility_Name": "Emory University Hospital", + "Reporting_Facility_Address_One": "789 Clifton Rd", + "Reporting_Facility_City": "Atlanta", + "Reporting_Facility_State_Cd": "13", + "Reporting_Facility_State": "GA", + "Reporting_Facility_Zip_Cd": "30322", + "Reporting_Facility_Clia": "10D0123456", + "Reporting_Facility_Phone_Nbr": "4045550300", + "Reporting_Facility_Phone_Ext": "", + "Ordering_Facility_Name": "Peachtree Urgent Care", + "Ordering_Facility_Address_One": "321 Peachtree St", + "Ordering_Facility_City": "Atlanta", + "Ordering_Facility_State_Cd": "13", + "Ordering_Facility_State": "GA", + "Ordering_Facility_Zip_Cd": "30303", + "Ordering_Facility_Phone_Nbr": "4045550400", + "Ordering_Facility_Phone_Ext": "", + "Ordering_Provider_First_Name": "Jane", + "Ordering_Provider_Last_Name": "Doe", + "Ordering_Provider_Address_One": "555 Provider Ave", + "Ordering_Provider_City": "Atlanta", + "Ordering_Provider_State_Cd": "13", + "Ordering_Provider_State": "GA", + "Ordering_Provider_Zip_Cd": "30308", + "Ordering_Provider_Phone_Nbr": "4045550500", + "ORDERING_PROVIDER_ID": "1234567890", + "Associated_Case_ID": "CAS-TEST-90005001" + } + ] +} \ No newline at end of file diff --git a/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/query.sql b/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/query.sql new file mode 100644 index 000000000..66022bfad --- /dev/null +++ b/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/query.sql @@ -0,0 +1,120 @@ +SELECT + -- Core lab identifiers + Observation_UID, + Lab_Local_ID, + Ordered_Test_Cd, + Ordered_Test_Desc, + Ordered_Test_Code_System, + Electronic_Ind, + Program_Area_Cd, + Jurisdiction_Cd, + Jurisdiction_Nm, + -- Specimen + Specimen_Cd, + Specimen_Desc, + Specimen_type_free_text, + Specimen_Id, + Testing_Lab_Accession_Number, + SPECIMEN_SOURCE_SITE_CD, + SPECIMEN_SOURCE_SITE_DESC, + -- Dates + Lab_Report_Dt, + Lab_Rpt_Received_By_PH_Dt, + ORDER_TEST_DATE, + Specimen_Coll_Dt, + Lab_Added_Dt, + Lab_Update_Dt, + -- Status + Order_result_status, + Test_result_status, + -- Result observation + COVID_LAB_DATAMART_KEY, + Resulted_Test_Cd, + Resulted_Test_Desc, + Resulted_Test_Code_System, + DEVICE_INSTANCE_ID_1, + DEVICE_INSTANCE_ID_2, + Device_Type_Id_1, + Device_Type_Id_2, + Test_Method_Desc, + -- Coded result + Result_Cd, + Result_Cd_Sys, + Result_Desc, + Text_Result_Desc, + Result_Comments, + Result, + Result_Category, + -- Numeric result + Numeric_Comparator_Cd, + Numeric_Value_1, + Numeric_Value_2, + Numeric_Unit_Cd, + Numeric_Low_Range, + Numeric_High_Range, + Numeric_Separator_Cd, + Interpretation_Cd, + Interpretation_Desc, + -- Patient + Last_Name, + Middle_Name, + First_Name, + Patient_Local_ID, + Current_Sex_Cd, + Age_Reported, + Age_Unit_Cd, + Birth_Dt, + Phone_Number, + Address_One, + City, + State_Cd, + State, + Zip_Code, + County_Cd, + County_Desc, + PATIENT_RACE_CALC, + PATIENT_ETHNICITY, + -- Testing lab + Perform_Facility_Name, + Testing_lab_Address_One, + Testing_lab_City, + Testing_lab_State_Cd, + Testing_lab_State, + Testing_lab_Zip_Cd, + Testing_lab_county, + Testing_lab_county_Desc, + Testing_lab_Country, + -- Reporting facility + Reporting_Facility_Name, + Reporting_Facility_Address_One, + Reporting_Facility_City, + Reporting_Facility_State_Cd, + Reporting_Facility_State, + Reporting_Facility_Zip_Cd, + Reporting_Facility_Clia, + Reporting_Facility_Phone_Nbr, + Reporting_Facility_Phone_Ext, + -- Ordering facility + Ordering_Facility_Name, + Ordering_Facility_Address_One, + Ordering_Facility_City, + Ordering_Facility_State_Cd, + Ordering_Facility_State, + Ordering_Facility_Zip_Cd, + Ordering_Facility_Phone_Nbr, + Ordering_Facility_Phone_Ext, + -- Ordering provider + Ordering_Provider_First_Name, + Ordering_Provider_Last_Name, + Ordering_Provider_Address_One, + Ordering_Provider_City, + Ordering_Provider_State_Cd, + Ordering_Provider_State, + Ordering_Provider_Zip_Cd, + Ordering_Provider_Phone_Nbr, + ORDERING_PROVIDER_ID, + -- Associated investigation + Associated_Case_ID +FROM dbo.COVID_LAB_DATAMART +WHERE Observation_UID = 90006001 +ORDER BY Observation_UID; \ No newline at end of file diff --git a/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/setup.sql b/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/setup.sql new file mode 100644 index 000000000..76b4f5957 --- /dev/null +++ b/reporting-pipeline-service/src/test/resources/testData/unit/covidLabDatamart/setup.sql @@ -0,0 +1,149 @@ +-- ============================================================ +-- COVID_LAB_DATAMART Post-Processing Stored Procedure +-- Happy path unit test for sp_covid_lab_datamart_postprocessing +-- - assumes all entities are present in nrt tables +-- - skips code branch to populate AOE columns +-- ============================================================ + +USE [RDB_Modern]; + +-- ------------------------------------------------------------ +-- UIDs +-- ------------------------------------------------------------ +DECLARE @patient_uid BIGINT = 90001001; +DECLARE @org_uid_perform BIGINT = 90002001; -- Testing lab +DECLARE @org_uid_author BIGINT = 90002002; -- Reporting facility +DECLARE @org_uid_order BIGINT = 90002003; -- Ordering facility +DECLARE @provider_uid BIGINT = 90003001; +DECLARE @material_id BIGINT = 90004001; +DECLARE @phc_uid BIGINT = 90005001; +DECLARE @obs_uid_order BIGINT = 90006001; +DECLARE @obs_uid_result BIGINT = 90006002; + +-- ------------------------------------------------------------ +-- Reference / SRTE tables +-- ------------------------------------------------------------ + +-- Add condition mapping for Covid LOINCs +INSERT INTO dbo.nrt_srte_Loinc_condition (loinc_cd, condition_cd) +SELECT '94500-6', '11065' + WHERE NOT EXISTS (SELECT 1 FROM dbo.nrt_srte_Loinc_condition WHERE loinc_cd = '94500-6' AND condition_cd = '11065'); + +INSERT INTO dbo.nrt_srte_Loinc_condition (loinc_cd, condition_cd) +SELECT '94309-2', '11065' + WHERE NOT EXISTS (SELECT 1 FROM dbo.nrt_srte_Loinc_condition WHERE loinc_cd = '94309-2' AND condition_cd = '11065'); + +-- Ensure our LOINC values don't have invalid details +DELETE FROM dbo.nrt_srte_Loinc_code +WHERE loinc_cd IN ('94500-6', '94309-2') AND time_aspect = 'Pt' AND system_cd = '^Patient'; + +-- ------------------------------------------------------------ +-- Patient +-- ------------------------------------------------------------ +INSERT INTO dbo.nrt_patient +(patient_uid, local_id, last_name, middle_name, first_name, curr_sex_cd, + age_reported, age_reported_unit_cd, dob, phone_home, + street_address_1, city, state_code, zip, county_code, county, + race_calculated, ethnic_group_ind) +VALUES + (@patient_uid, 'PSN-TEST-' + CAST(@patient_uid AS VARCHAR), 'Smith', 'A', 'John', 'M', + '45', 'a', '1979-03-15', '4045550100', + '123 Main St', 'Atlanta', '13', '30301', '063', 'Fulton', + 'White', 'N'); + +INSERT INTO dbo.nrt_patient_key (patient_uid) +VALUES (@patient_uid); + +-- ------------------------------------------------------------ +-- Organizations +-- ------------------------------------------------------------ +INSERT INTO dbo.nrt_organization +(organization_uid, organization_name, street_address_1, city, state_code, state, zip, county_code, county, country_code, facility_id, phone_work, phone_ext_work) +VALUES + (@org_uid_perform, 'State Reference Lab', '456 Lab Blvd', 'Atlanta', '13', 'Georgia', '30302', '063', 'Fulton', 'US', '10D2289533', '4045550200', ''), + (@org_uid_author, 'Emory University Hospital', '789 Clifton Rd', 'Atlanta', '13', 'Georgia', '30322', '063', 'Fulton', 'US', '10D0123456', '4045550300', ''), + (@org_uid_order, 'Peachtree Urgent Care', '321 Peachtree St', 'Atlanta', '13', 'Georgia', '30303', '063', 'Fulton', 'US', '10D9876543', '4045550400', ''); + +-- ------------------------------------------------------------ +-- Provider +-- ------------------------------------------------------------ +INSERT INTO dbo.nrt_provider +(provider_uid, first_name, last_name, street_address_1, city, state_code, zip, county_code, county, country_code, phone_work_phone, phone_ext_work_phone, provider_npi) +VALUES + (@provider_uid, 'Jane', 'Doe', '555 Provider Ave', 'Atlanta', '13', '30308', '063', 'Fulton', 'US', '4045550500', '', '1234567890'); + +-- ------------------------------------------------------------ +-- Observation material (specimen) +-- ------------------------------------------------------------ +INSERT INTO dbo.nrt_observation_material (act_uid, material_id, material_cd, material_desc, material_details) +VALUES (@obs_uid_order, @material_id, 'NP', 'Nasopharyngeal Swab', 'Combined Naso/Oropharyngeal Swab'); + +-- ------------------------------------------------------------ +-- Investigation +-- ------------------------------------------------------------ +INSERT INTO dbo.nrt_investigation (public_health_case_uid, local_id) +VALUES (@phc_uid, 'CAS-TEST-' + CAST(@phc_uid AS VARCHAR)); + +-- ------------------------------------------------------------ +-- Observations (order and result) +-- ------------------------------------------------------------ +INSERT INTO dbo.nrt_observation +(observation_uid, local_id, record_status_cd, cd, cd_desc_txt, cd_system_cd, + electronic_ind, version_ctrl_nbr, prog_area_cd, jurisdiction_cd, + activity_to_time, rpt_to_state_time, activity_from_time, effective_from_time, + target_site_cd, target_site_desc_txt, status_cd, + accession_number, add_time, last_chg_time, + result_observation_uid, obs_domain_cd_st_1, + material_id, patient_id, + performing_organization_id, author_organization_id, ordering_organization_id, + ordering_person_id, associated_phc_uids, batch_id, + method_cd, method_desc_txt, device_instance_id_1, device_instance_id_2, + interpretation_cd, interpretation_desc_txt) +VALUES + -- ORDER row + (@obs_uid_order, 'LAB-TEST-' + CAST(@obs_uid_order AS VARCHAR), 'ACTIVE', '94500-6', 'SARS-CoV-2 RNA panel', 'LN', + 'Y', 1, 'STD', '130001', + '2021-01-10 12:00:00', '2021-01-10 14:00:00', '2021-01-09 09:00:00', '2021-01-09 09:00:00', + 'NP', 'Nasopharynx', 'D', + 'ACC-2021-001', '2021-01-10 08:00:00', '2021-01-10 15:00:00', + CAST(@obs_uid_result AS NVARCHAR(MAX)), 'Order', + @material_id, @patient_uid, + @org_uid_perform, @org_uid_author, @org_uid_order, + CAST(@provider_uid AS NVARCHAR(MAX)), CAST(@phc_uid AS NVARCHAR(MAX)), 1, + NULL, NULL, NULL, NULL, NULL, NULL), + + -- RESULT row + (@obs_uid_result, 'LAB-TEST-' + CAST(@obs_uid_result AS VARCHAR), 'ACTIVE', '94309-2', 'SARS-CoV-2 RNA Ql NAA+probe', 'LN', + 'Y', 1, 'STD', 'GA', + '2021-01-10 12:00:00', NULL, NULL, NULL, + NULL, NULL, 'D', + NULL, '2021-01-10 08:00:00', '2021-01-10 15:00:00', + NULL, 'Result', + NULL, @patient_uid, + @org_uid_perform, @org_uid_author, @org_uid_order, + CAST(@provider_uid AS NVARCHAR(MAX)), CAST(@phc_uid AS NVARCHAR(MAX)), 1, + 'EUA001', 'RT-PCR', 'DEVICE-SERIAL-001', NULL, + 'POS', 'Positive'); + +-- ------------------------------------------------------------ +-- Observation results +-- ------------------------------------------------------------ + +-- Coded result — "Detected" +INSERT INTO dbo.nrt_observation_coded (observation_uid, ovc_code, ovc_code_system_cd, ovc_display_name) +VALUES (@obs_uid_result, '260373001', 'SCT', 'Detected'); + +-- Text result (type 'O') and comment (type 'N') +INSERT INTO dbo.nrt_observation_txt (observation_uid, ovt_seq, ovt_txt_type_cd, ovt_value_txt) +VALUES + (@obs_uid_result, 1, 'O', 'SARS-CoV-2 RNA Detected'), + (@obs_uid_result, 2, 'N', 'Specimen received in good condition.'); + +-- ------------------------------------------------------------ +-- Execute the stored procedure +-- ------------------------------------------------------------ +DECLARE @obs_id_list NVARCHAR(MAX) = CAST(@obs_uid_order AS NVARCHAR(MAX)); + +EXEC dbo.sp_covid_lab_datamart_postprocessing + @observation_id_list = @obs_id_list, + @debug = 'false'; \ No newline at end of file From 95511d2fad44c09dbd8ca33714e7e571b74bd356 Mon Sep 17 00:00:00 2001 From: mehansen Date: Tue, 19 May 2026 11:23:22 -0700 Subject: [PATCH 09/11] update junit tests for work phone logic --- .../test/resources/rawDataFiles/patient/PatientReporting.json | 4 ++-- .../resources/rawDataFiles/provider/ProviderReporting.json | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/patient/PatientReporting.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/patient/PatientReporting.json index 204c8fc91..84ea9f682 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/patient/PatientReporting.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/patient/PatientReporting.json @@ -508,8 +508,8 @@ "within_city_limits": "Y", "birth_country": "Canada", "census_tract": "3389.45", - "phone_work": "2323252423", - "phone_ext_work": "", + "phone_work": "2323222422", + "phone_ext_work": "232", "phone_home": "4562323222", "phone_ext_home": "211", "phone_cell": "2823252423", diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json index 46d600064..821168f08 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json @@ -220,6 +220,8 @@ "address_comments": "", "phone_work": "2323252423", "phone_ext_work": "", + "phone_work_phone": "2323222422", + "phone_ext_work_phone": "232", "phone_comments": "work phone office comment", "phone_cell": "2823252423", "email_work": "someone2@email.com", From 43f058a05f482bb05343a6ff5ac189682bf0ce17 Mon Sep 17 00:00:00 2001 From: mehansen Date: Tue, 19 May 2026 12:13:36 -0700 Subject: [PATCH 10/11] add unit tests for provider event sp --- .../testData/unit/providerEvent/expected.json | 64 +++++++++ .../testData/unit/providerEvent/query.sql | 1 + .../testData/unit/providerEvent/setup.sql | 133 ++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/expected.json create mode 100644 reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/query.sql create mode 100644 reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/setup.sql diff --git a/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/expected.json b/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/expected.json new file mode 100644 index 000000000..cbb7ee0dd --- /dev/null +++ b/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/expected.json @@ -0,0 +1,64 @@ +{ + "0": [ + { + "person_uid": 90010001, + "person_parent_uid": 90010001, + "description": null, + "add_time": "2024-01-15 09:00:00", + "first_nm": "Jane", + "middle_nm": "A", + "last_nm": "Doe", + "nm_suffix": null, + "cd": "PRV", + "electronic_ind": "Y", + "last_chg_time": "2024-01-15 10:00:00", + "record_status_cd": "ACTIVE", + "record_status_time": "2024-01-15 09:00:00", + "status_cd": "A", + "status_time": "2024-01-15 09:00:00", + "local_id": "PRV-TEST-90010001", + "version_ctrl_nbr": 1, + "edx_ind": null, + "dedup_match_ind": null, + "add_user_id": 10009282, + "add_user_name": "Kent, Ariella", + "last_chg_user_id": 10009282, + "last_chg_user_name": "Kent, Ariella", + "provider_name": "[{\"pn_person_uid\":90010001,\"lastNm\":\"Doe\",\"lastNmSndx\":\"D000\",\"middleNm\":\"A\",\"firstNm\":\"Jane\",\"firstNmSndx\":\"J500\",\"nm_use_cd\":\"L\",\"nmSuffix\":\"MD\",\"name_suffix\":null,\"nmPrefix\":\"Dr\",\"name_prefix\":\"Doctor\\/Dr.\",\"nmDegree\":\"MD\",\"pn_person_name_seq\":1,\"pn_last_chg_time\":\"2024-01-15T09:00:00\"}]", + "provider_address": "[{\"addr_elp_cd\":\"O\",\"addr_elp_use_cd\":\"WP\",\"addr_pl_uid\":90011001,\"street_addr1\":\"555 Provider Ave\",\"street_addr2\":\"Suite 100\",\"city\":\"Atlanta\",\"zip\":\"30308\",\"cntyCd\":\"13121\",\"state\":\"13\",\"cntryCd\":\"840\",\"state_desc\":\"Georgia\",\"county\":\"Fulton County\",\"within_city_limits_ind\":null,\"country\":\"United States\",\"address_comments\":null}]", + "provider_telephone": "[{\"ph_tl_uid\":90011002,\"ph_elp_cd\":\"PH\",\"ph_elp_use_cd\":\"WP\",\"telephoneNbr\":\"4045550500\",\"extensionTxt\":\"123\",\"phone_comments\":null}]", + "provider_email": "[{\"email_tl_uid\":90011003,\"email_elp_cd\":\"O\",\"email_elp_use_cd\":\"WP\",\"emailAddress\":\"jane.doe@statelab.org\"}]", + "provider_entity": "[{\"entity_uid\":90010001,\"typeCd\":\"NPI\",\"recordStatusCd\":\"ACTIVE\",\"rootExtensionTxt\":\"1234567890\",\"entity_id_seq\":1,\"assigning_authority_cd\":\"CMS\"}]" + }, + { + "person_uid": 90010002, + "person_parent_uid": 90010002, + "description": null, + "add_time": "2024-02-01 09:00:00", + "first_nm": "James", + "middle_nm": "B", + "last_nm": "Smith", + "nm_suffix": null, + "cd": "PRV", + "electronic_ind": "Y", + "last_chg_time": "2024-02-01 10:00:00", + "record_status_cd": "ACTIVE", + "record_status_time": "2024-02-01 09:00:00", + "status_cd": "A", + "status_time": "2024-02-01 09:00:00", + "local_id": "PRV-TEST-90010002", + "version_ctrl_nbr": 1, + "edx_ind": null, + "dedup_match_ind": null, + "add_user_id": 10009282, + "add_user_name": "Kent, Ariella", + "last_chg_user_id": 10009282, + "last_chg_user_name": "Kent, Ariella", + "provider_name": "[{\"pn_person_uid\":90010002,\"lastNm\":\"Smith\",\"lastNmSndx\":\"S530\",\"middleNm\":\"B\",\"firstNm\":\"James\",\"firstNmSndx\":\"J520\",\"nm_use_cd\":\"L\",\"nmSuffix\":null,\"name_suffix\":null,\"nmPrefix\":null,\"name_prefix\":null,\"nmDegree\":\"MD\",\"pn_person_name_seq\":1,\"pn_last_chg_time\":\"2024-02-01T09:00:00\"}]", + "provider_address": "[{\"addr_elp_cd\":\"O\",\"addr_elp_use_cd\":\"WP\",\"addr_pl_uid\":90011004,\"street_addr1\":\"100 Test Blvd\",\"street_addr2\":null,\"city\":\"Atlanta\",\"zip\":\"30301\",\"cntyCd\":\"13121\",\"state\":\"13\",\"cntryCd\":\"840\",\"state_desc\":\"Georgia\",\"county\":\"Fulton County\",\"within_city_limits_ind\":null,\"country\":\"United States\",\"address_comments\":null}]", + "provider_telephone": "[{\"ph_tl_uid\":90011005,\"ph_elp_cd\":\"PH\",\"ph_elp_use_cd\":\"WP\",\"telephoneNbr\":\"4045550600\",\"extensionTxt\":null,\"phone_comments\":null},{\"ph_tl_uid\":90011006,\"ph_elp_cd\":\"CP\",\"ph_elp_use_cd\":\"MC\",\"telephoneNbr\":\"4045550601\",\"extensionTxt\":null,\"phone_comments\":null}]", + "provider_email": "[{\"email_tl_uid\":90011008,\"email_elp_cd\":\"O\",\"email_elp_use_cd\":\"WP\",\"emailAddress\":\"james.smith@statelab.org\"}]", + "provider_entity": "[{\"entity_uid\":90010002,\"typeCd\":\"NPI\",\"recordStatusCd\":\"ACTIVE\",\"rootExtensionTxt\":\"0987654321\",\"entity_id_seq\":1,\"assigning_authority_cd\":\"CMS\"}]" + } + ] +} \ No newline at end of file diff --git a/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/query.sql b/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/query.sql new file mode 100644 index 000000000..b7f886eb4 --- /dev/null +++ b/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/query.sql @@ -0,0 +1 @@ +EXEC RDB_Modern.dbo.sp_provider_event @user_id_list = '90010001,90010002'; \ No newline at end of file diff --git a/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/setup.sql b/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/setup.sql new file mode 100644 index 000000000..d6baae767 --- /dev/null +++ b/reporting-pipeline-service/src/test/resources/testData/unit/providerEvent/setup.sql @@ -0,0 +1,133 @@ +-- ============================================================ +-- Provider_Event Stored Procedure +-- Unit tests for sp_provider_event +-- Provider 1: baseline happy path +-- Provider 2: inactive cell phone filtered out +-- ============================================================ + +USE [NBS_ODSE]; + +-- ------------------------------------------------------------ +-- UIDs +-- ------------------------------------------------------------ +DECLARE @entity_id_seq SMALLINT = 1; +DECLARE @add_user_id BIGINT = 10009282; -- superuser + +-- Provider 1 +DECLARE @person_uid BIGINT = 90010001; +DECLARE @postal_locator_uid BIGINT = 90011001; +DECLARE @tele_locator_uid_ph BIGINT = 90011002; -- work phone +DECLARE @tele_locator_uid_em BIGINT = 90011003; -- email + +-- Provider 2 +DECLARE @person_uid_2 BIGINT = 90010002; +DECLARE @postal_locator_uid_2 BIGINT = 90011004; +DECLARE @tele_locator_uid_ph_2 BIGINT = 90011005; -- work phone +DECLARE @tele_locator_uid_cp_2 BIGINT = 90011006; -- active cell phone +DECLARE @tele_locator_uid_cp_3 BIGINT = 90011007; -- inactive cell phone +DECLARE @tele_locator_uid_em_2 BIGINT = 90011008; -- email + +-- ------------------------------------------------------------ +-- Entity +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Entity (entity_uid, class_cd) +VALUES + (@person_uid, 'PSN'), + (@person_uid_2, 'PSN'); + +-- ------------------------------------------------------------ +-- Person +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Person +(person_uid, add_time, add_user_id, last_chg_time, last_chg_user_id, + cd, cd_desc_txt, first_nm, last_nm, middle_nm, + record_status_cd, record_status_time, + status_cd, status_time, + local_id, version_ctrl_nbr, electronic_ind, + person_parent_uid) +VALUES + (@person_uid, '2024-01-15 09:00:00', @add_user_id, '2024-01-15 10:00:00', @add_user_id, + 'PRV', 'Provider', 'Jane', 'Doe', 'A', + 'ACTIVE', '2024-01-15 09:00:00', + 'A', '2024-01-15 09:00:00', + 'PRV-TEST-' + CAST(@person_uid AS VARCHAR), 1, 'Y', + @person_uid), + (@person_uid_2, '2024-02-01 09:00:00', @add_user_id, '2024-02-01 10:00:00', @add_user_id, + 'PRV', 'Provider', 'James', 'Smith', 'B', + 'ACTIVE', '2024-02-01 09:00:00', + 'A', '2024-02-01 09:00:00', + 'PRV-TEST-' + CAST(@person_uid_2 AS VARCHAR), 1, 'Y', + @person_uid_2); + +-- ------------------------------------------------------------ +-- Person name +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Person_name +(person_uid, person_name_seq, first_nm, last_nm, middle_nm, + nm_use_cd, nm_prefix, nm_suffix, nm_degree, + record_status_cd, record_status_time, + status_cd, status_time, last_chg_time) +VALUES + (@person_uid, 1, 'Jane', 'Doe', 'A', 'L', 'Dr', 'MD', 'MD', + 'ACTIVE', '2024-01-15 09:00:00', 'A', '2024-01-15 09:00:00', '2024-01-15 09:00:00'), + (@person_uid_2, 1, 'James', 'Smith', 'B', 'L', NULL, NULL, 'MD', + 'ACTIVE', '2024-02-01 09:00:00', 'A', '2024-02-01 09:00:00', '2024-02-01 09:00:00'); + +-- ------------------------------------------------------------ +-- Postal locator +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Postal_locator +(postal_locator_uid, street_addr1, street_addr2, city_desc_txt, + state_cd, zip_cd, cnty_cd, cntry_cd, + record_status_cd, record_status_time) +VALUES + (@postal_locator_uid, '555 Provider Ave', 'Suite 100', 'Atlanta', '13', '30308', '13121', '840', + 'ACTIVE', '2024-01-15 09:00:00'), + (@postal_locator_uid_2, '100 Test Blvd', NULL, 'Atlanta', '13', '30301', '13121', '840', + 'ACTIVE', '2024-02-01 09:00:00'); + +-- ------------------------------------------------------------ +-- Tele locator +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Tele_locator +(tele_locator_uid, phone_nbr_txt, extension_txt, record_status_cd, record_status_time) +VALUES + (@tele_locator_uid_ph, '4045550500', '123', 'ACTIVE', '2024-01-15 09:00:00'), -- P1 work phone + (@tele_locator_uid_ph_2,'4045550600', NULL, 'ACTIVE', '2024-02-01 09:00:00'), -- P2 work phone + (@tele_locator_uid_cp_2,'4045550601', NULL, 'ACTIVE', '2024-02-01 09:00:00'), -- P2 active cell + (@tele_locator_uid_cp_3,'4045550602', NULL, 'ACTIVE', '2024-02-01 09:00:00'); -- P2 inactive cell (ELP inactive) + +INSERT INTO nbs_odse.dbo.Tele_locator +(tele_locator_uid, email_address, record_status_cd, record_status_time) +VALUES + (@tele_locator_uid_em, 'jane.doe@statelab.org', 'ACTIVE', '2024-01-15 09:00:00'), + (@tele_locator_uid_em_2, 'james.smith@statelab.org','ACTIVE', '2024-02-01 09:00:00'); + +-- ------------------------------------------------------------ +-- Entity locator participation +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Entity_locator_participation +(entity_uid, locator_uid, class_cd, cd, use_cd, + record_status_cd, record_status_time, status_cd, version_ctrl_nbr) +VALUES + -- Provider 1 + (@person_uid, @postal_locator_uid, 'PST', 'O', 'WP', 'ACTIVE', '2024-01-15 09:00:00', 'A', 1), + (@person_uid, @tele_locator_uid_ph, 'TELE', 'PH', 'WP', 'ACTIVE', '2024-01-15 09:00:00', 'A', 1), + (@person_uid, @tele_locator_uid_em, 'TELE', 'O', 'WP', 'ACTIVE', '2024-01-15 09:00:00', 'A', 1), + -- Provider 2 + (@person_uid_2, @postal_locator_uid_2, 'PST', 'O', 'WP', 'ACTIVE', '2024-02-01 09:00:00', 'A', 1), + (@person_uid_2, @tele_locator_uid_ph_2, 'TELE', 'PH', 'WP', 'ACTIVE', '2024-02-01 09:00:00', 'A', 1), + (@person_uid_2, @tele_locator_uid_cp_2, 'TELE', 'CP', 'MC', 'ACTIVE', '2024-02-01 09:00:00', 'A', 1), + (@person_uid_2, @tele_locator_uid_cp_3, 'TELE', 'CP', 'MC', 'INACTIVE', '2024-02-01 09:00:00', 'I', 1), + (@person_uid_2, @tele_locator_uid_em_2, 'TELE', 'O', 'WP', 'ACTIVE', '2024-02-01 09:00:00', 'A', 1); + +-- ------------------------------------------------------------ +-- Entity ID +-- ------------------------------------------------------------ +INSERT INTO nbs_odse.dbo.Entity_id +(entity_uid, entity_id_seq, type_cd, root_extension_txt, + assigning_authority_cd, record_status_cd, record_status_time, + status_cd, add_time) +VALUES + (@person_uid, 1, 'NPI', '1234567890', 'CMS', 'ACTIVE', '2024-01-15 09:00:00', 'A', '2024-01-15 09:00:00'), + (@person_uid_2, 1, 'NPI', '0987654321', 'CMS', 'ACTIVE', '2024-02-01 09:00:00', 'A', '2024-02-01 09:00:00'); \ No newline at end of file From 1dd14906401b32d12da0d7cd1db7d0bc0f75b218 Mon Sep 17 00:00:00 2001 From: mehansen Date: Wed, 20 May 2026 11:20:31 -0700 Subject: [PATCH 11/11] update junit tests with new phone logic --- .../rawDataFiles/person/PersonTelephone2.json | 8 -------- .../rawDataFiles/person/PersonTelephone3.json | 2 +- .../rawDataFiles/provider/ProviderReporting.json | 12 +++++++++++- .../provider/ProviderReporting2.json | 12 ++++++++++++ .../provider/ProviderReporting3.json | 16 ++++++++++++++-- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone2.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone2.json index c2e138b93..86f71e95b 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone2.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone2.json @@ -19,14 +19,6 @@ "ph_elp_use_cd": "WP", "ph_elp_cd": "PH", "ph_tl_uid": 10000011, - "phone_comments": "work phone comment ignored" - }, - { - "telephoneNbr": "2323222422", - "extensionTxt": "232", - "ph_elp_use_cd": "WP", - "ph_elp_cd": "PH", - "ph_tl_uid": 10000012, "phone_comments": "work phone comment" }, { diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone3.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone3.json index 0c377f541..9097f3b9d 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone3.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/person/PersonTelephone3.json @@ -42,7 +42,7 @@ "ph_elp_use_cd": "WP", "ph_elp_cd": "CP", "ph_tl_uid": 10000016, - "phone_comments": "work phone office comment" + "phone_comments": "work phone cell comment" }, { "telephoneNbr": "2223335555", diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json index 821168f08..66fc9dfea 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting.json @@ -157,6 +157,16 @@ "optional": true, "field": "phone_comments" }, + { + "type": "string", + "optional": true, + "field": "phone_work_phone" + }, + { + "type": "string", + "optional": true, + "field": "phone_ext_work_phone" + }, { "type": "string", "optional": true, @@ -220,9 +230,9 @@ "address_comments": "", "phone_work": "2323252423", "phone_ext_work": "", + "phone_comments": "work phone office comment", "phone_work_phone": "2323222422", "phone_ext_work_phone": "232", - "phone_comments": "work phone office comment", "phone_cell": "2823252423", "email_work": "someone2@email.com", "quick_code": "12314286", diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting2.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting2.json index 9d11e52cb..955cd1feb 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting2.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting2.json @@ -157,6 +157,16 @@ "optional": true, "field": "phone_comments" }, + { + "type": "string", + "optional": true, + "field": "phone_work_phone" + }, + { + "type": "string", + "optional": true, + "field": "phone_ext_work_phone" + }, { "type": "string", "optional": true, @@ -221,6 +231,8 @@ "phone_work": "2223334455", "phone_ext_work": "", "phone_comments": "work phone office 2 comment", + "phone_work_phone": "2323222222", + "phone_ext_work_phone": "231", "phone_cell": "2823252423", "email_work": "someone2@email.com", "quick_code": "12314286", diff --git a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting3.json b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting3.json index 586b8d39c..537236d9d 100644 --- a/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting3.json +++ b/reporting-pipeline-service/src/test/resources/rawDataFiles/provider/ProviderReporting3.json @@ -157,6 +157,16 @@ "optional": true, "field": "phone_comments" }, + { + "type": "string", + "optional": true, + "field": "phone_work_phone" + }, + { + "type": "string", + "optional": true, + "field": "phone_ext_work_phone" + }, { "type": "string", "optional": true, @@ -218,9 +228,11 @@ "country": "United States", "country_code": "840", "address_comments": "", - "phone_work": "2223335555", - "phone_ext_work": "", + "phone_work": null, + "phone_ext_work": null, "phone_comments": null, + "phone_work_phone": "2323222422", + "phone_ext_work_phone": "232", "phone_cell": "2823252423", "email_work": "someone2@email.com", "quick_code": "12314286",