use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7ConditionFHIRConversionTest method validateDiagnosis.
// --------------------- DIAGNOSIS UNIT TESTS (DG1) ---------------------
// Tests the DG1 segment (diagnosis) with all supported message types.
// This tests all the fields in the happy path.
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&|||||||ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r", // "MSH|^~\\&|||||||ADT^A04|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r",
"MSH|^~\\&|||||||ADT^A08|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r" // "MSH|^~\\&|||||||ADT^A28^ADT^A28|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r",
// "MSH|^~\\&|||||||ADT^A31|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r",
// "MSH|^~\\&|||||||ORM^O01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r"
// PPR_PC1, PPR_PC2, and PPR_PC3 create Conditions but they don't have a DG1 segment so they are tested in a different testcase.
})
void validateDiagnosis(String msh) {
String hl7message = msh + "PID||||||||||||||||||||||||||||||\r" + "PV1||I|||||||||||||||||1400|||||||||||||||||||||||||\r" + // DG1.20 to Identifier
"DG1|1||C56.9^Ovarian Cancer^I10||20210322154449|A|||||||||1|123^DOE^JOHN^A^|||20210322154326|V45|||||\r";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Verify no extraneous resources
// Expect encounter, patient, practitioner, condition
assertThat(e).hasSize(4);
// --- CONDITION TESTS ---
// Find the condition from the FHIR bundle.
List<Resource> conditionResource = ResourceUtils.getResourceList(e, ResourceType.Condition);
assertThat(conditionResource).hasSize(1);
Condition condition = (Condition) conditionResource.get(0);
// Verify we have 3 identifiers
// NOTE: The other identifiers, not related to condition, are tested deeply in the
// identifier suite of unit tests.
assertThat(condition.getIdentifier()).hasSize(3);
// First identifier is the Visit Number, and is a codeable concept
DatatypeUtils.checkCommonCodeableConceptAssertions(condition.getIdentifier().get(0).getType(), "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Second identifier
assertThat(condition.getIdentifier().get(1).getSystem()).isEqualTo("urn:id:extID");
assertThat(condition.getIdentifier().get(1).getValue()).isEqualTo("C56.9-I10");
// The 3rd identifier value should be from DG1.20
// DG1.20
assertThat(condition.getIdentifier().get(2).getValue()).isEqualTo("V45");
// Verify asserter reference to Practitioner exists
assertThat(condition.getAsserter().getReference().substring(0, 13)).isEqualTo("Practitioner/");
// Verify recorded date is set correctly.
// DG1.19
assertThat(condition.getRecordedDateElement().toString()).containsPattern("2021-03-22T15:43:26");
// Verify onset date time is set correctly.
// DG1.5
assertThat(condition.getOnset().toString()).containsPattern("2021-03-22T15:44:49");
// Verify code text and coding are set correctly.
DatatypeUtils.checkCommonCodeableConceptAssertions(condition.getCode(), "C56.9", "Ovarian Cancer", "http://hl7.org/fhir/sid/icd-10-cm", // DG1.3
"Ovarian Cancer");
// Verify encounter reference exists
assertThat(condition.getEncounter().getReference().substring(0, 10)).isEqualTo("Encounter/");
// Verify subject reference to Patient exists
assertThat(condition.getSubject().getReference().substring(0, 8)).isEqualTo("Patient/");
// Verify category text and coding are set correctly.
assertThat(condition.getCategory()).hasSize(1);
DatatypeUtils.checkCommonCodeableConceptAssertions(condition.getCategoryFirstRep(), "encounter-diagnosis", "Encounter Diagnosis", "http://terminology.hl7.org/CodeSystem/condition-category", // DG1.3
"Encounter Diagnosis");
// --- ENCOUNTER TESTS ---
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter encounter = (Encounter) encounterResource.get(0);
// Encounter should have a reference to the conditions (only 1 in this unit test)
assertThat(encounter.getReasonReference()).hasSize(1);
assertThat(encounter.getReasonReference().get(0).getReference().substring(0, 10)).isEqualTo("Condition/");
// Verify encounter diagnosis condition, use, and rank are set correctly
assertThat(encounter.getDiagnosis()).hasSize(1);
assertThat(encounter.getDiagnosisFirstRep().getCondition().getReference().substring(0, 10)).isEqualTo("Condition/");
DatatypeUtils.checkCommonCodeableConceptAssertions(encounter.getDiagnosisFirstRep().getUse(), "AD", "Admission diagnosis", "http://terminology.hl7.org/CodeSystem/diagnosis-role", // DG1.6
null);
// DG1.15
assertThat(encounter.getDiagnosisFirstRep().getRank()).isEqualTo(1);
// --- PRACTIONER TESTS ---
// Find the asserter (practitioner) resource from the FHIR bundle.
List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
assertThat(practitionerResource).hasSize(1);
Practitioner practitioner = (Practitioner) practitionerResource.get(0);
// Verify name text, family, and given are set correctly.
assertThat(practitioner.getName()).hasSize(1);
// DG1.16
assertThat(practitioner.getNameFirstRep().getText()).isEqualTo("JOHN A DOE");
// DG1.16.2
assertThat(practitioner.getNameFirstRep().getFamily()).isEqualTo("DOE");
// DG1.16.3
assertThat(practitioner.getNameFirstRep().getGivenAsSingleString()).isEqualTo("JOHN A");
// Verify asserter (practitioner) identifier is set correctly.
assertThat(practitioner.getIdentifier()).hasSize(1);
// DG1.16.1
assertThat(practitioner.getIdentifierFirstRep().getValue()).isEqualTo("123");
}
use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7MergeFHIRConversionTest method validateHappyPathADT_A34WithMRG.
// Test ADT_A34 with one MRG segment (the most it supports).
@Test
void validateHappyPathADT_A34WithMRG() {
String hl7message = "MSH|^~\\&|SENDING_APPLICATION|SENDING_FACILITY|RECEIVING_APPLICATION|RECEIVING_FACILITY|||ADT^A34||P|2.3||||\r" + "EVN|A40|20110613122406637||01\r" + // Identifier value 234 with no system and no identifier type
"PID|1||123^^^^MR||||||||||||||||||||||||||||||||||||\r" + // Identifier value 456 with no system and no identifier type
"MRG|456||||||\r";
// Convert hl7 message
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Find the patient resources in the FHIR bundle.
List<Resource> patientResources = ResourceUtils.getResourceList(e, ResourceType.Patient);
// There should be 2 - One for the PID segment and one for the MRG segment
assertThat(patientResources).hasSize(2);
// Get first patient and associated identifiers and id.
Patient patientOne = PatientUtils.getPatientFromResource(patientResources.get(0));
String patientOneId = patientOne.getId();
List<Identifier> patientOneIdentifierList = patientOne.getIdentifier();
// Get second patient and associated identifiers and id.
Patient patientTwo = PatientUtils.getPatientFromResource(patientResources.get(1));
String patientTwoId = patientTwo.getId();
List<Identifier> patientTwoIdentifierList = patientTwo.getIdentifier();
/*-----------Verify Patient One-----------*/
// Verify patient one's identifier is set correctly (this is the patient build
// from the PID segment)
//
// "identifier":[
// {
// "type":{
// "coding":[
// {
// "system":"http://terminology.hl7.org/CodeSystem/v2-0203",
// "code":"MR",
// "display":"Medical record number"
// }
// ]
// },
// "value":"123"
// },
// {
// "use":"old",
// "value":"456"
// }
// ]
// Verify the patient has two identifiers
assertThat(patientOneIdentifierList).hasSize(2);
// Verify the identifier values are correct.
assertThat(patientOneIdentifierList.get(0).getValue()).isEqualTo("123");
assertThat(patientOneIdentifierList.get(1).getValue()).isEqualTo("456");
// Verify the system values are not present
assertThat(patientOneIdentifierList.get(0).getSystem()).isNull();
assertThat(patientOneIdentifierList.get(1).getSystem()).isNull();
// Verify the first identifier has no use field.
assertThat(patientOneIdentifierList.get(0).getUse()).isNull();
// Verify the second identifier is marked as old
assertThat(patientOneIdentifierList.get(1).getUse()).isEqualTo(Identifier.IdentifierUse.OLD);
// Verify identifier type is set correctly for the first identifier
CodeableConcept patientOneIdentifierType = patientOneIdentifierList.get(0).getType();
assertThat(patientOneIdentifierType.getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
assertThat(patientOneIdentifierType.getCoding().get(0).getDisplay()).isEqualTo("Medical record number");
assertThat(patientOneIdentifierType.getCoding().get(0).getCode()).isEqualTo("MR");
// Verify the identifier type for the second identifier is not present.
assertThat(patientOneIdentifierList.get(1).getType().getCoding()).isEmpty();
// Verify first patient has these fields
//
// "active":true,
// "link":[
// {
// "other":{
// "reference":"Patient/expiringID-MRG"
// },
// "type":"replaces"
// }
// ]
// The first patient should be active.
assertThat(patientOne.getActive()).isTrue();
// Verify link.other.reference references the MRG (2nd) patient with of a type of 'replaces'
PatientLinkComponent linkOne = patientOne.getLink().get(0);
assertThat(linkOne.getType()).isEqualTo(Patient.LinkType.REPLACES);
assertThat(linkOne.getOther().getReference()).isEqualTo(patientTwoId);
/*-----------Verify Patient Two-----------*/
// Verify patient two's identifier is set correctly (this is the patient build
// from the MRG segment)
//
// "identifier":[
// {
// "use":"old",
// "value":"456"
// }
// ]
// Verify has only 1 identifier
assertThat(patientTwoIdentifierList).hasSize(1);
// Verify the identifier value is correct.
assertThat(patientTwoIdentifierList.get(0).getValue()).isEqualTo("456");
// Verify the system is not present
assertThat(patientTwoIdentifierList.get(0).getSystem()).isNull();
// Verify the identifier is marked as old
assertThat(patientTwoIdentifierList.get(0).getUse()).isEqualTo(Identifier.IdentifierUse.OLD);
// Verify identifier type is not present
assertThat(patientTwoIdentifierList.get(0).getType().getCoding()).isEmpty();
// Verify second patient has these fields.
// "active":false,
// "link":[
// {
// "other":{
// "reference":"Patient/survivingID"
// },
// "type":"replaced-by"
// }
// ]
// The second patient should NOT be active.
assertThat(patientTwo.getActive()).isFalse();
// We should have link.other.reference to the PID (1st) patient with a type of 'replaced-by'
PatientLinkComponent linkTwo = patientTwo.getLink().get(0);
assertThat(linkTwo.getType()).isEqualTo(Patient.LinkType.REPLACEDBY);
assertThat(linkTwo.getOther().getReference()).isEqualTo(patientOneId);
;
}
use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7FinancialInsuranceTest method testInsuranceCoverageByRelatedFields.
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@ParameterizedTest
// The breadth of this test is sufficent for multiple message type coverage, so other tests are not parameterized.
@ValueSource(strings = { "DFT^P03^DFT_P03", "VXU^V04^VXU_V04", "ADT^A01^ADT_A01", "ADT^A03^ADT_A03", // ADT^A04 uses structure ADT_A01
"ADT^A04^ADT_A01", // ADT^A08 uses structure ADT_A01
"ADT^A08^ADT_A01", // ADT^A28 uses structure ADT_A05
"ADT^A28^ADT_A05", // ADT^A31 uses structure ADT_A05
"ADT^A31^ADT_A05" })
// Also test IN2.2 Social Security number
void testInsuranceCoverageByRelatedFields(String messageType) throws IOException {
String hl7message = "MSH|^~\\&|||||20151008111200||" + messageType + "|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
"FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
"IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (See test testBasicInsuranceCoverageFields)
"|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.23 through IN1.35 NOT REFERENCED
"|DoeFake^Judy^^^Rev.|PAR|19780429|19 Rose St^^Faketown^CA^ZIP5||||||||||||||||" + // IN1.50 through IN1.53 NOT REFERENCED
"|MEMBER36|||||||F|||Value46|||J494949^^^Large HMO^XX||||\n" + // IN2.9 through IN2.60 not used
"IN2||777-88-9999||||MEDICARE06||MEDICAID08|| |||||||||| ||||||||||| |||||||||| |||||||||| ||||||||||" + // IN2.63.18 to Organization Contact telecom .rank
"MEMBER61||^^^^^555^7677777^^^^^^20201231145045^20211231145045^^^^1|";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
// From PV1
assertThat(encounters).hasSize(1);
List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
// From PID
assertThat(patients).hasSize(1);
Patient patient = (Patient) patients.get(0);
String patientId = patient.getId();
// From PID.3, IN1.49, IN2.6, IN2.8
assertThat(patient.getIdentifier()).hasSize(4);
Identifier patientIdentifier = patient.getIdentifier().get(0);
// PID.3.1
assertThat(patientIdentifier.getValue()).isEqualTo("MR1");
// PID.3.4
assertThat(patientIdentifier.getSystem()).isEqualTo("urn:id:XYZ");
DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MR", "Medical record number", "http://terminology.hl7.org/CodeSystem/v2-0203", // PID.3.5
null);
patientIdentifier = patient.getIdentifier().get(1);
// IN1.49.1
assertThat(patientIdentifier.getValue()).isEqualTo("J494949");
// IN1.49.4
assertThat(patientIdentifier.getSystem()).isEqualTo("urn:id:Large_HMO");
DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "XX", null, "http://terminology.hl7.org/CodeSystem/v2-0203", // IN1.49.5
null);
patientIdentifier = patient.getIdentifier().get(2);
// IN2.8
assertThat(patientIdentifier.getValue()).isEqualTo("MEDICAID08");
// No system for IN2.8
assertThat(patientIdentifier.hasSystem()).isFalse();
DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MA", "Patient Medicaid number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
patientIdentifier = patient.getIdentifier().get(3);
// IN2.6
assertThat(patientIdentifier.getValue()).isEqualTo("MEDICARE06");
// No system for IN2.6
assertThat(patientIdentifier.hasSystem()).isFalse();
DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MC", "Patient's Medicare number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
// From Payor created by IN1
assertThat(organizations).hasSize(1);
List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
// From IN1 segment
assertThat(coverages).hasSize(1);
Coverage coverage = (Coverage) coverages.get(0);
// Confirm Coverage Identifiers - Order matches order of identifier_X in Coverage.yml
// XV, XV, XV, MB, MA, MC, SN
assertThat(coverage.getIdentifier()).hasSize(7);
// IN1.2.1
assertThat(coverage.getIdentifier().get(0).getValue()).isEqualTo("Value1");
// IN1.2.3
assertThat(coverage.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:System3");
// No use, here
assertThat(coverage.getIdentifier().get(0).getUse()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(0).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN1.2.4
assertThat(coverage.getIdentifier().get(1).getValue()).isEqualTo("Value4");
// IN1.2.6
assertThat(coverage.getIdentifier().get(1).getSystem()).isEqualTo("urn:id:System6");
// No use, here
assertThat(coverage.getIdentifier().get(1).getUse()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(1).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN1.46
assertThat(coverage.getIdentifier().get(2).getValue()).isEqualTo("Value46");
// No system, here
assertThat(coverage.getIdentifier().get(2).getSystem()).isNull();
// Use is enumeration "old"
assertThat(coverage.getIdentifier().get(2).getUseElement().getCode()).hasToString("old");
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(2).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN2.61 takes priority over IN1.36
assertThat(coverage.getIdentifier().get(3).getValue()).isEqualTo("MEMBER61");
// No system, here
assertThat(coverage.getIdentifier().get(3).getSystem()).isNull();
// No use, here
assertThat(coverage.getIdentifier().get(3).getUse()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(3).getType(), "MB", "Member Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN2.8
assertThat(coverage.getIdentifier().get(4).getValue()).isEqualTo("MEDICAID08");
// No system, here
assertThat(coverage.getIdentifier().get(4).getSystem()).isNull();
// No use, here
assertThat(coverage.getIdentifier().get(4).getUse()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(4).getType(), "MA", "Patient Medicaid number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN2.6
assertThat(coverage.getIdentifier().get(5).getValue()).isEqualTo("MEDICARE06");
// No system, here
assertThat(coverage.getIdentifier().get(5).getSystem()).isNull();
// No use, here
assertThat(coverage.getIdentifier().get(5).getUse()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(5).getType(), "MC", "Patient's Medicare number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN1.36
assertThat(coverage.getIdentifier().get(6).getValue()).isEqualTo("MEMBER36");
// No system, here
assertThat(coverage.getIdentifier().get(6).getSystem()).isNull();
// No use, here
assertThat(coverage.getIdentifier().get(6).getUse()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(6).getType(), "SN", "Subscriber Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Confirm Coverage Beneficiary references to Patient, and Payor references to Organization
assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
assertThat(coverage.getPayorFirstRep().getReference()).isEqualTo(organizations.get(0).getId());
// Expect one RelatedPerson
List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
// From IN1.16 through IN1.19; IN1.43; INI.49
assertThat(relatedPersons).hasSize(1);
RelatedPerson related = (RelatedPerson) relatedPersons.get(0);
// Check RelatedPerson identifiers
assertThat(related.getIdentifier()).hasSize(2);
// IN1.49.1
assertThat(related.getIdentifier().get(0).getValue()).isEqualTo("J494949");
// IN1.49.4
assertThat(related.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:Large_HMO");
// IN1.49.5
DatatypeUtils.checkCommonCodeableConceptAssertions(// IN1.49.5
related.getIdentifier().get(0).getType(), // IN1.49.5
"XX", // Display value looked up from code 'XX'
"Organization identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// IN2.2
assertThat(related.getIdentifier().get(1).getValue()).isEqualTo("777-88-9999");
// No system to assign
assertThat(related.getIdentifier().get(1).hasSystem()).isFalse();
DatatypeUtils.checkCommonCodeableConceptAssertions(related.getIdentifier().get(1).getType(), "SS", "Social Security number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Check RelatedPerson name. IN1.16 name is standard XPN, tested exhaustively in other tests.
assertThat(related.getName()).hasSize(1);
HumanName relatedName = related.getName().get(0);
// IN1.16.1
assertThat(relatedName.getFamily()).isEqualTo("DoeFake");
// IN1.16.2
assertThat(relatedName.getGiven().get(0).getValueAsString()).isEqualTo("Judy");
// IN1.16.6
assertThat(relatedName.getPrefixAsSingleString()).hasToString("Rev.");
// from IN1.16 aggregate
assertThat(relatedName.getText()).isEqualTo("Rev. Judy DoeFake");
// Check RelatedPerson birth and gender
// IN1.18
assertThat(related.getBirthDateElement().toString()).containsPattern("1978-04-29");
Enumerations.AdministrativeGender gen = related.getGender();
// IN1.43
assertThat(gen).isNotNull().isEqualTo(Enumerations.AdministrativeGender.FEMALE);
// Check the RelatedPerson address. IN1.19 is a standard XAD address, which is tested exhaustively in other tests.
assertThat(related.getAddress()).hasSize(1);
assertThat(related.getAddress().get(0).getLine().get(0).getValueAsString()).isEqualTo(// IN1.19.1
"19 Rose St");
// IN1.19.3
assertThat(related.getAddress().get(0).getCity()).isEqualTo("Faketown");
// IN1.19.4
assertThat(related.getAddress().get(0).getState()).isEqualTo("CA");
// IN1.19.5
assertThat(related.getAddress().get(0).getPostalCode()).isEqualTo("ZIP5");
// Check RelatedPerson telecom. IN2.63 is standard XTN, tested exhaustively in other tests.
// telecom is type ContactPoint
ContactPoint contactPoint = related.getTelecomFirstRep();
// default type hardcoded.
assertThat(contactPoint.getSystemElement().getCode()).hasToString("phone");
// Hard-coded to home. IN2.63.2 is not mapped (ignored).
assertThat(contactPoint.getUseElement().getCode()).isEqualTo("home");
// Hard-coded to home. IN2.63.2 is not mapped (ignored).
;
// IN2.63.6, IN2.63.7 via getFormattedTelecomNumberValue
assertThat(contactPoint.getValue()).hasToString("(555) 767 7777");
// IN2.63.13
assertThat(contactPoint.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
// IN2.63.14
assertThat(contactPoint.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
// IN2.63.18
assertThat(contactPoint.getRank()).isEqualTo(1);
// Check coverage relationship
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "child", "Child", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN1.17
null);
// Check relatedPerson relationship
assertThat(related.getRelationship()).hasSize(1);
DatatypeUtils.checkCommonCodeableConceptAssertions(related.getRelationship().get(0), "PRN", "parent", "http://terminology.hl7.org/CodeSystem/v3-RoleCode", // IN1.17
null);
// Confirm the Coverage (subscriber) references the RelatedPerson
assertThat(coverage.getSubscriber().getReference()).isEqualTo(related.getId());
// Confirm the RelatedPerson references the Patient
assertThat(related.getPatient().getReference()).isEqualTo(patientId);
// Confirm coverage.Order
// IN1.1 backup for missing IN1.22
assertThat(coverage.getOrder()).isEqualTo(1);
// Confirm there are no unaccounted for resources
// Expected: Coverage, Organization, Patient, Encounter, RelatedPerson
assertThat(e).hasSize(5);
}
use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method encounterIdentifierVisitNumberFromMSH7.
@Test
void encounterIdentifierVisitNumberFromMSH7() {
// Test: Visit number from MSH-7
String encounterMsg = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN|A01|20130617154644||01\r" + "PID|||12345^^^^MR||smith^john\r" + "PV1||I||||||||SUR||||||||S||A\r";
Encounter encounter = ResourceUtils.getEncounter(ftv, encounterMsg);
// Expect a single identifier
assertThat(encounter.hasIdentifier()).isTrue();
assertThat(encounter.getIdentifier()).hasSize(1);
// Identifier 1: Visit number
Identifier identifier = encounter.getIdentifier().get(0);
String value = identifier.getValue();
String system = identifier.getSystem();
// MSH.7
assertThat(value).isEqualTo("20130531");
// PV1.19.4 and PID.18 is empty so system is null
assertThat(system).isNull();
CodeableConcept type = identifier.getType();
Coding coding = type.getCoding().get(0);
assertThat(type.getText()).isNull();
assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
assertThat(coding.getCode()).isEqualTo("VN");
assertThat(coding.getDisplay()).isEqualTo("Visit number");
}
use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method conditionDg1IdentifierTest2.
@Test
void conditionDg1IdentifierTest2() {
// Test PV1-19 for visit number; extID with DG1-3.1.
// Also test DG1-20 creates additional identifiers.
String withDG120 = "MSH|^~\\&|||||||ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r" + "PID|||10290^^^WEST^MR||||20040530|M||||||||||||||||||||||N\n" + "PV1||I||||||||SUR||||||||S|8846511^^^ACME|A|||||||||||||||||||SF|K||||20170215080000\n" + "DG1|1|ICD10|B45678|Broken Arm|20210322154449|A|E123|R45|Y|J76|C|15|1458.98||1|123^DOE^JOHN^A^|C|Y|20210322154326|one^https://terminology.hl7.org/CodeSystem/two^three^https://terminology.hl7.org/CodeSystem/four|S1234|Parent Diagnosis|Value345|Group567|DiagnosisG45|Y\r";
Condition condition = ResourceUtils.getCondition(ftv, withDG120);
// Expect 4 identifiers
assertThat(condition.hasIdentifier()).isTrue();
assertThat(condition.getIdentifier()).hasSize(4);
List<Identifier> identifiers = condition.getIdentifier();
// Match the id's to position; we can't depend on an order.
int posVN = getIdentifierPositionByValue("8846511", identifiers);
assertThat(posVN).isNotSameAs(-1);
int posExtId = getIdentifierPositionByValue("B45678", identifiers);
assertThat(posExtId).isNotSameAs(-1);
int posExtDG20a = getIdentifierPositionByValue("one", identifiers);
assertThat(posExtDG20a).isNotSameAs(-1);
int posExtDG20b = getIdentifierPositionByValue("three", identifiers);
assertThat(posExtDG20b).isNotSameAs(-1);
// Identifier 1: Visit number
Identifier identifier = condition.getIdentifier().get(posVN);
String value = identifier.getValue();
String system = identifier.getSystem();
// PV1.19.1
assertThat(value).isEqualTo("8846511");
// PV1.19.4
assertThat(system).isEqualTo("urn:id:ACME");
CodeableConcept type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Identifier 2: DG1.3.1
identifier = condition.getIdentifier().get(posExtId);
value = identifier.getValue();
system = identifier.getSystem();
// DG1.3.1
assertThat(value).isEqualTo("B45678");
assertThat(system).isEqualTo("urn:id:extID");
// Identifier 3: DG1.20.1 and DG1.20.2
identifier = condition.getIdentifier().get(posExtDG20a);
value = identifier.getValue();
system = identifier.getSystem();
// DG1.20.1
assertThat(value).isEqualTo("one");
// DG1.20.2
assertThat(system).isEqualTo("https://terminology.hl7.org/CodeSystem/two");
// Identifier 4: DG1.20.3 and DG1.20.4
identifier = condition.getIdentifier().get(posExtDG20b);
value = identifier.getValue();
system = identifier.getSystem();
// DG1.20.3
assertThat(value).isEqualTo("three");
// DG1.20.4
assertThat(system).isEqualTo("https://terminology.hl7.org/CodeSystem/four");
}
Aggregations