Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ 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],
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,
Expand All @@ -114,23 +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.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],
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 ('CP')
AND tl.phone_nbr_txt IS NOT NULL ) t
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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment thread
mehansen marked this conversation as resolved.
email_work varchar(50) null,
Comment thread
ericnagel marked this conversation as resolved.
phone_cell varchar(50) null,
entry_method varchar(50) null,
add_user_id bigint null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,10 +37,23 @@ public <T extends PersonExtendedProps> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -118,45 +119,24 @@ public <T extends PersonExtendedProps> 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<Predicate<? super Phone>, T> personPhoneFn =
Consumer<Predicate<? super Phone>> 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 <T extends PersonExtendedProps> void processPersonEntityData(String entityData, T pf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -221,6 +231,8 @@
"phone_work": "2323252423",
"phone_ext_work": "",
"phone_comments": "work phone office comment",
"phone_work_phone": "2323222422",
"phone_ext_work_phone": "232",
"phone_cell": "2823252423",
"email_work": "someone2@email.com",
"quick_code": "12314286",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
Loading