Search in sources :

Example 96 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageFromIN2.

@Test
// Tests empty IN2.63 missing telecom.
void testInsuranceCoverageFromIN2() throws IOException {
    String hl7message = "MSH|^~\\&|||||20151008111200||ADT^A01^ADT_A01|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.18 through IN1.35 NOT REFERENCED
    "|DoeFake^Judy^^^Rev.|||||||||||||||||||" + // IN1.37 through IN1.53 NOT REFERENCED
    "|MEMBER36|||||||||||||||||\n" + // IN2.63 purposely empty to ensure an empty telecom is not created.
    "IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" + // IN2.72 to Coverage.relationship and RelatedPerson.relationship.  (Backup for IN1.17) Codes from table 0344
    "04|\n";
    // 04 = Natural child
    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();
    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
    // XV, XV, MB, SN
    assertThat(coverage.getIdentifier()).hasSize(4);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // 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 IN2.72
    assertThat(relatedPersons).hasSize(1);
    RelatedPerson related = (RelatedPerson) relatedPersons.get(0);
    // Because IN2.63 is empty
    assertThat(related.hasTelecom()).isFalse();
    assertThat(related.getName()).hasSize(1);
    HumanName relatedName = related.getName().get(0);
    // Simplified name test.  Deeper tests in other tests.
    // from IN1.16 aggregate
    assertThat(relatedName.getText()).isEqualTo("Rev. Judy DoeFake");
    // Check coverage relationship
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "child", "Child", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN2.72 (04 = Natural child)
    null);
    // Check relatedPerson relationship
    assertThat(related.getRelationship()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(related.getRelationship().get(0), "PRN", "parent", "http://terminology.hl7.org/CodeSystem/v3-RoleCode", // IN2.72 (04 = Natural child)
    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 there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter, RelatedPerson
    assertThat(e).hasSize(5);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7AddressFHIRConversionTest method patient_address_date_ranges_test.

@Test
void patient_address_date_ranges_test() {
    String patientAddress = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|111 1st Street^Suite #1^Minneapolis^MN^11111^USA^H^^AdrC^^^20010101&20081231^^^^Y^Z^V^c/o Pluto19|PatC|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|||USA||||\n";
    String patientAddressExplicitEffectiveExpirationDates = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|111 1st Street^Suite #1^Minneapolis^MN^11111^USA^H^^AdrC^^^20010101&20081231^19920101^19981231^^Y^Z^V^c/o Pluto19|PatC|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|||USA||||\n";
    // If address county, ignore patient county
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientAddress);
    assertThat(patient.hasAddress()).isTrue();
    List<Address> addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    Address address = addresses.get(0);
    // Test date range
    Period period = address.getPeriod();
    assertThat(period.hasStart()).isTrue();
    assertThat(period.hasEnd()).isTrue();
    Date startDate = period.getStart();
    Calendar startCalendar = Calendar.getInstance();
    startCalendar.setTime(startDate);
    assertThat(startCalendar.get(Calendar.YEAR)).isEqualTo(2001);
    // Zero based; January is 0
    assertThat(startCalendar.get(Calendar.MONTH)).isZero();
    assertThat(startCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(1);
    Date endDate = period.getEnd();
    Calendar endCalendar = Calendar.getInstance();
    endCalendar.setTime(endDate);
    assertThat(endCalendar.get(Calendar.YEAR)).isEqualTo(2008);
    // Zero based; December is 11
    assertThat(endCalendar.get(Calendar.MONTH)).isEqualTo(11);
    assertThat(endCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(31);
    // Test explicit date start (effective) and end (expiration)
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientAddressExplicitEffectiveExpirationDates);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    address = addresses.get(0);
    period = address.getPeriod();
    assertThat(period.hasStart()).isTrue();
    assertThat(period.hasEnd()).isTrue();
    startDate = period.getStart();
    startCalendar = Calendar.getInstance();
    startCalendar.setTime(startDate);
    assertThat(startCalendar.get(Calendar.YEAR)).isEqualTo(1992);
    // Zero based; January is 0
    assertThat(startCalendar.get(Calendar.MONTH)).isZero();
    assertThat(startCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(1);
    endDate = period.getEnd();
    endCalendar = Calendar.getInstance();
    endCalendar.setTime(endDate);
    assertThat(endCalendar.get(Calendar.YEAR)).isEqualTo(1998);
    // Zero based; December is 11
    assertThat(endCalendar.get(Calendar.MONTH)).isEqualTo(11);
    assertThat(endCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(31);
}
Also used : Address(org.hl7.fhir.r4.model.Address) Calendar(java.util.Calendar) Patient(org.hl7.fhir.r4.model.Patient) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 98 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_subject_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_subject_test(String segment) {
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, documentReferenceMessage);
    List<Resource> documentReferenceList = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
    String s = context.getParser().encodeResourceToString(documentReferenceList.get(0));
    Class<? extends IBaseResource> klass = DocumentReference.class;
    DocumentReference documentReference = (DocumentReference) context.getParser().parseResource(klass, s);
    assertThat(documentReference.hasSubject()).isTrue();
    assertThat(documentReference.getSubject().getReference()).startsWith("Patient");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 99 with Patient

use of org.hl7.fhir.r4.model.Patient 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");
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 100 with Patient

use of org.hl7.fhir.r4.model.Patient 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);
    ;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) PatientLinkComponent(org.hl7.fhir.r4.model.Patient.PatientLinkComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.Test)576 Test (org.junit.jupiter.api.Test)410 Patient (org.hl7.fhir.r4.model.Patient)368 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)246 Patient (org.hl7.fhir.dstu3.model.Patient)230 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)227 Bundle (org.hl7.fhir.r4.model.Bundle)191 ArrayList (java.util.ArrayList)144 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)140 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)138 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)136 Date (java.util.Date)136 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)127 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)127 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)125 Bundle (org.hl7.fhir.dstu3.model.Bundle)110 List (java.util.List)108 Reference (org.hl7.fhir.r4.model.Reference)106 Resource (org.hl7.fhir.r4.model.Resource)103 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)94