Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ private HL7Constants() {

public static final String SIMPLE_REPORT_NAME = "SimpleReport";

/** Note: this is the CDC OID for now until we get a SimpleReport OID registered */
public static final String SIMPLE_REPORT_ORG_OID = "2.16.840.1.114222.4";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion]: Now that we're no longer using this old CDC OID, could this PR remove the old comment in HL7Properties.java?

Do you think we should update the name of sendingApplicationNamespace and sendingApplicationOID to something else now that it is used beyond just MSH-3 Sending Application? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about simpleReportNamespace and simpleReportOID?


public static final String APHL_ORG_OID = "2.16.840.1.113883.3.8589";
public static final String HL7_VERSION_ID = "2.5.1";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static gov.cdc.usds.simplereport.api.converter.HL7Constants.SENDING_FACILITY_FAKE_AGGREGATE_CLIA;
import static gov.cdc.usds.simplereport.api.converter.HL7Constants.SENDING_FACILITY_NAMESPACE;
import static gov.cdc.usds.simplereport.api.converter.HL7Constants.SIMPLE_REPORT_NAME;
import static gov.cdc.usds.simplereport.api.converter.HL7Constants.SIMPLE_REPORT_ORG_OID;
import static gov.cdc.usds.simplereport.utils.DateTimeUtils.formatToHL7DateTime;
import static gov.cdc.usds.simplereport.utils.MultiplexUtils.inferMultiplexDeviceTypeDisease;

Expand Down Expand Up @@ -187,7 +186,10 @@ public ORU_R01 createLabReportMessage(

PID patientIdentificationSegment = message.getPATIENT_RESULT().getPATIENT().getPID();
populatePatientIdentification(
patientIdentificationSegment, patientInput, performingFacility.getClia());
patientIdentificationSegment,
patientInput,
performingFacility.getName(),
performingFacility.getClia());

String specimenId = String.valueOf(uuidGenerator.randomUUID());

Expand Down Expand Up @@ -302,10 +304,10 @@ void populateMessageHeader(MSH msh, String processingId, Date messageTimestamp)
// Sending application is different between prod and lower environments
msh.getMsh3_SendingApplication()
.getHd1_NamespaceID()
.setValue(hl7Properties.getSendingApplicationNamespace());
.setValue(hl7Properties.getSimpleReportNamespace());
msh.getMsh3_SendingApplication()
.getHd2_UniversalID()
.setValue(hl7Properties.getSendingApplicationOID());
.setValue(hl7Properties.getSimpleReportOid());
msh.getMsh3_SendingApplication().getHd3_UniversalIDType().setValue("ISO");

// Sending facility is the same for ALL environments including local.
Expand Down Expand Up @@ -392,13 +394,18 @@ void populateSoftwareSegment(SFT sft, GitProperties gitProperties) throws DataTy
*
* @param pid the PID object from the message's PATIENT_RESULT.PATIENT group
* @param patientInput the input containing the form values for patient
* @param performingFacilityClia used to populate namespace ID for the assigning authority on a
* @param performingFacilityName used to populate namespace ID for the assigning authority on a
* patient external id if present
* @param performingFacilityClia used to populate universal ID for the assigning authority on a
* patient external id if present
* @throws DataTypeException if the HAPI package encounters a problem with the validity of a
* primitive data type
*/
void populatePatientIdentification(
PID pid, PatientReportInput patientInput, String performingFacilityClia)
PID pid,
PatientReportInput patientInput,
String performingFacilityName,
String performingFacilityClia)
throws DataTypeException {
// PID Sequence 1 is "Set ID - PID" which is used to identify repetitions.
// Since the ORU^R01 message only allows one Patient per message, the HL7 IG says this must be
Expand All @@ -414,15 +421,26 @@ void populatePatientIdentification(
: uuidGenerator.randomUUID().toString();
CX patientInternalIdEntry = pid.getPid3_PatientIdentifierList(0);
// PI is the value for Patient internal identifier on HL7 table 0203 Identifier type
populatePatientIdentifierEntry(patientInternalIdEntry, internalId, "PI", null);
populatePatientIdentifierEntry(
patientInternalIdEntry,
internalId,
"PI",
hl7Properties.getSimpleReportNamespace(),
hl7Properties.getSimpleReportOid(),
"ISO");

// ID used by the facility, such as a medical record number
String externalId = patientInput.getPatientExternalId();
if (StringUtils.isNotBlank(externalId)) {
CX patientExternalIdEntry = pid.getPid3_PatientIdentifierList(1);
// PT is the value for Patient external identifier on HL7 table 0203 Identifier type
populatePatientIdentifierEntry(
patientExternalIdEntry, externalId, "PT", performingFacilityClia);
patientExternalIdEntry,
externalId,
"PT",
performingFacilityName,
performingFacilityClia,
"CLIA");
}

populateName(
Expand Down Expand Up @@ -471,19 +489,23 @@ void populatePatientIdentification(
}

void populatePatientIdentifierEntry(
CX identifierEntry, String id, String identifierTypeCode, String namespaceId)
CX identifierEntry,
String id,
String identifierTypeCode,
String namespaceId,
String universalId,
String idType)
throws DataTypeException {
identifierEntry.getCx1_IDNumber().setValue(id);
identifierEntry
.getCx4_AssigningAuthority()
.getHd2_UniversalID()
.setValue(SIMPLE_REPORT_ORG_OID);
identifierEntry.getCx4_AssigningAuthority().getHd3_UniversalIDType().setValue("ISO");

identifierEntry.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue(namespaceId);
identifierEntry.getCx4_AssigningAuthority().getHd2_UniversalID().setValue(universalId);
identifierEntry.getCx4_AssigningAuthority().getHd3_UniversalIDType().setValue(idType);

identifierEntry.getCx5_IdentifierTypeCode().setValue(identifierTypeCode);

if (StringUtils.isNotBlank(namespaceId)) {
identifierEntry.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue(namespaceId);
}
identifierEntry.getCx6_AssigningFacility().getHd1_NamespaceID().setValue(namespaceId);
identifierEntry.getCx6_AssigningFacility().getHd2_UniversalID().setValue(universalId);
}

/** Populates the Extended Person Name (XPN) object */
Expand Down Expand Up @@ -750,9 +772,10 @@ void populateCommonOrderSegment(
*/
void populateEntityIdentifierOID(EI entityIdentifier, String id) throws DataTypeException {
entityIdentifier.getEi1_EntityIdentifier().setValue(id);
entityIdentifier.getEi2_NamespaceID().setValue(hl7Properties.getSimpleReportNamespace());
// EI-3 contains the universal ID for the assigning authority,
// not the universal ID for the entity itself
entityIdentifier.getEi3_UniversalID().setValue(SIMPLE_REPORT_ORG_OID);
entityIdentifier.getEi3_UniversalID().setValue(hl7Properties.getSimpleReportOid());
entityIdentifier.getEi4_UniversalIDType().setValue("ISO");
}

Expand Down Expand Up @@ -1234,8 +1257,8 @@ public String createBatchFileString(
generateHeaderSegment(
new HeaderSegmentFields(
"FHS",
hl7Properties.getSendingApplicationNamespace(),
hl7Properties.getSendingApplicationOID(),
hl7Properties.getSimpleReportNamespace(),
hl7Properties.getSimpleReportOid(),
"ISO",
SENDING_FACILITY_NAMESPACE,
SENDING_FACILITY_FAKE_AGGREGATE_CLIA,
Expand All @@ -1253,8 +1276,8 @@ public String createBatchFileString(
generateHeaderSegment(
new HeaderSegmentFields(
"BHS",
hl7Properties.getSendingApplicationNamespace(),
hl7Properties.getSendingApplicationOID(),
hl7Properties.getSimpleReportNamespace(),
hl7Properties.getSimpleReportOid(),
"ISO",
SENDING_FACILITY_NAMESPACE,
SENDING_FACILITY_FAKE_AGGREGATE_CLIA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
* These values were assigned from APHL for use in MSH-3 Sending Application. <br>
* <br>
* As of 11/4/2025, APHL stated we should continue to use the existing CDC OID for other HL7 fields
* like ORC-3.3 where SimpleReport is identified as the assigning authority.
*
* @see gov.cdc.usds.simplereport.api.converter.HL7Constants
* These values were assigned from APHL for use in numerous places where we need SimpleReport's
* namespace and OID.
*/
@ConfigurationProperties(prefix = "simple-report.hl7")
@Getter
@RequiredArgsConstructor
@Slf4j
public final class HL7Properties {
private final String sendingApplicationNamespace;
private final String sendingApplicationOID;
private final String simpleReportNamespace;
private final String simpleReportOid;
}
4 changes: 2 additions & 2 deletions backend/src/main/resources/application-azure-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ simple-report:
device-sync-enabled: false
aims-processing-mode-code: P
hl7:
sending-application-namespace: "SIMPLEREPORT.PROD"
sending-application-oid: "2.16.840.1.113883.3.8589.4.2.134.1"
simple-report-namespace: "SIMPLEREPORT.PROD"
simple-report-oid: "2.16.840.1.113883.3.8589.4.2.134.1"
twilio:
enabled: true
from-number: "+14045312484"
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ simple-report:
devices-token: ${SR_PROD_DEVICES_TOKEN:sr-prod-devices-fake-token}
device-sync-enabled: true
hl7:
sending-application-namespace: "SIMPLEREPORT.STAG"
sending-application-oid: "2.16.840.1.113883.3.8589.4.2.134.2"
simple-report-namespace: "SIMPLEREPORT.STAG"
simple-report-oid: "2.16.840.1.113883.3.8589.4.2.134.2"
twilio:
messaging-service-sid: ${TWILIO_MESSAGING_SID}
logging:
Expand Down
Loading
Loading