Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UCSD ORU transformation to update MSH-6.1 with ORC-21.10 #1165

Merged
merged 7 commits into from
Jul 9, 2024
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 @@ -158,10 +158,21 @@ public static Identifier getMSH6_1Identifier(Bundle bundle) {
return getHD1Identifier(identifiers);
}

public static Identifier createMSH6_1Identifier() {
Identifier identifier = new Identifier();
setHD1Identifier(identifier);
return identifier;
}

public static void setMSH6_1Value(Bundle bundle, String value) {
Identifier identifier = getMSH6_1Identifier(bundle);
if (identifier == null) {
return;
identifier = createMSH6_1Identifier();
Organization receivingFacility = getMSH6Organization(bundle);
if (receivingFacility == null) {
return;
}
receivingFacility.addIdentifier(identifier);
}
identifier.setValue(value);
}
Expand Down Expand Up @@ -403,7 +414,7 @@ public static String getORC21Value(ServiceRequest serviceRequest) {
// OBR-4.1 - Identifier
public static String getOBR4_1Value(ServiceRequest serviceRequest) {
CodeableConcept cc = serviceRequest.getCode();
if (cc == null || cc.getCoding().isEmpty()) {
if (cc.getCoding().isEmpty()) {
return null;
}
return getCWE1Value(cc.getCoding().get(0));
Expand All @@ -419,6 +430,10 @@ public static Identifier getHD1Identifier(List<Identifier> identifiers) {
return hd1Identifiers.get(0);
}

public static void setHD1Identifier(Identifier identifier) {
setHl7FieldExtensionValue(identifier, EXTENSION_HD1_DATA_TYPE);
}

// CWE - Coded with Exceptions
public static String getCWE1Value(Coding coding) {
return coding.getCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gov.hhs.cdc.trustedintermediary.external.hapi

import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.Coding
import org.hl7.fhir.r4.model.DiagnosticReport
import org.hl7.fhir.r4.model.Extension
import org.hl7.fhir.r4.model.Identifier
import org.hl7.fhir.r4.model.MessageHeader
Expand Down Expand Up @@ -254,15 +253,30 @@ class HapiHelperTest extends Specification {
then:
HapiHelper.getMSH6Organization(bundle) == null

when:
HapiHelper.setMSH6_1Value(bundle, msh6_1)

then:
HapiHelper.getMSH6_1Identifier(bundle) == null

when:
def receivingFacility = HapiFhirHelper.createOrganization()
HapiFhirHelper.setMSH6Organization(bundle, receivingFacility)
HapiHelper.setMSH6_1Value(bundle, msh6_1)

then:
HapiHelper.getMSH6_1Identifier(bundle) != null
HapiFhirHelper.getMSH6_1Value(bundle) == msh6_1

when:
receivingFacility = HapiFhirHelper.createOrganization()
HapiFhirHelper.setMSH6Organization(bundle, receivingFacility)
HapiHelper.setMSH6_1Value(bundle, msh6_1)

then:
HapiHelper.getMSH6Organization(bundle).equalsDeep(receivingFacility)
HapiHelper.getMSH6_1Identifier(bundle) == null
HapiFhirHelper.getMSH6_1Value(bundle) != msh6_1
HapiHelper.getMSH6_1Identifier(bundle) != null
HapiFhirHelper.getMSH6_1Value(bundle) == msh6_1

when:
HapiFhirHelper.setMSH6_1Identifier(bundle, new Identifier())
Expand Down Expand Up @@ -502,6 +516,7 @@ class HapiHelperTest extends Specification {
def "orc-4.1 methods work as expected"() {
given:
def orc4_1 = "orc4_1"
def orc4_1b = "orc4_1b"
def bundle = new Bundle()
def dr = HapiFhirHelper.createDiagnosticReport(bundle)
def sr = HapiFhirHelper.createBasedOnServiceRequest(dr)
Expand All @@ -514,12 +529,19 @@ class HapiHelperTest extends Specification {

then:
HapiHelper.getORC4_1Value(sr) == orc4_1

when:
HapiHelper.setORC4_1Value(sr, orc4_1b)

then:
HapiHelper.getORC4_1Value(sr) == orc4_1b
}

// ORC-4.2 - Namespace ID
def "orc-4.2 methods work as expected"() {
given:
def orc4_2 = "orc4_2"
def orc4_2b = "orc4_2b"
def bundle = new Bundle()
def dr = HapiFhirHelper.createDiagnosticReport(bundle)
def sr = HapiFhirHelper.createBasedOnServiceRequest(dr)
Expand All @@ -532,6 +554,12 @@ class HapiHelperTest extends Specification {

then:
HapiHelper.getORC4_2Value(sr) == orc4_2

when:
HapiHelper.setORC4_2Value(sr, orc4_2b)

then:
HapiHelper.getORC4_2Value(sr) == orc4_2b
}

def "orc-21 methods work as expected"() {
Expand Down Expand Up @@ -589,6 +617,12 @@ class HapiHelperTest extends Specification {

then:
HapiHelper.getOBR4_1Value(sr) == expectedValue

when:
sr.setCode(null)

then:
HapiHelper.getOBR4_1Value(sr) == null
}

// HD - Hierarchic Designator
Expand Down