Search in sources :

Example 96 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project summary-care-record-api by NHSDigital.

the class GetScrService method getScrId.

@LogExecutionTime
public Bundle getScrId(String nhsNumber, String nhsdAsid, String clientIp) {
    Document scrIdXml = getScrIdRawXml(nhsNumber, nhsdAsid, clientIp);
    checkDetectedIssues(scrIdXml);
    EventListQueryResponse response = eventListQueryResponseParser.parseXml(scrIdXml);
    Bundle bundle = buildBundle();
    if (StringUtils.isNotEmpty(response.getLatestScrId())) {
        bundle.setTotal(1);
        Patient patient = buildPatientResource(nhsNumber);
        DocumentReference documentReference = buildDocumentReference(nhsNumber, response, patient);
        bundle.addEntry(new BundleEntryComponent().setFullUrl(getScrUrl() + "/DocumentReference/" + documentReference.getId()).setResource(documentReference).setSearch(new Bundle.BundleEntrySearchComponent().setMode(MATCH)));
        bundle.addEntry(new BundleEntryComponent().setFullUrl(patient.getId()).setResource(patient));
    } else {
        bundle.setTotal(0);
    }
    return bundle;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) EventListQueryResponse(uk.nhs.adaptors.scr.models.EventListQueryResponse) Patient(org.hl7.fhir.r4.model.Patient) Document(org.w3c.dom.Document) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) LogExecutionTime(uk.nhs.adaptors.scr.logging.LogExecutionTime)

Example 97 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project elexis-server by elexis.

the class ConditionTest method getCondition.

@Test
public void getCondition() {
    Patient readPatient = client.read().resource(Patient.class).withId(AllTests.getTestDatabaseInitializer().getPatient().getId()).execute();
    // search by patient
    Bundle results = client.search().forResource(Condition.class).where(Condition.SUBJECT.hasId(readPatient.getId())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    Condition condition = (Condition) entries.get(0).getResource();
    // read with by id
    Condition readCondition = client.read().resource(Condition.class).withId(condition.getId()).execute();
    assertNotNull(readCondition);
    assertEquals(condition.getId(), readCondition.getId());
    // search by patient and category
    results = client.search().forResource(Condition.class).where(Condition.SUBJECT.hasId(readPatient.getId())).and(Condition.CATEGORY.exactly().code("problem-list-item")).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    entries = results.getEntry();
    assertFalse(entries.isEmpty());
    results = client.search().forResource(Condition.class).where(Condition.SUBJECT.hasId(readPatient.getId())).and(Condition.CATEGORY.exactly().code("abc")).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    entries = results.getEntry();
    assertTrue(entries.isEmpty());
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.Test)

Example 98 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project elexis-server by elexis.

the class CoverageTest method getCoverage.

@Test
public void getCoverage() {
    Patient readPatient = client.read().resource(Patient.class).withId(AllTests.getTestDatabaseInitializer().getPatient().getId()).execute();
    // search by BENEFICIARY
    Bundle results = client.search().forResource(Coverage.class).where(Coverage.BENEFICIARY.hasId(readPatient.getId())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    Coverage coverage = (Coverage) entries.get(0).getResource();
    // read with by id
    Coverage readCoverage = client.read().resource(Coverage.class).withId(coverage.getId()).execute();
    assertNotNull(readCoverage);
    assertEquals(coverage.getId(), readCoverage.getId());
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) ICoverage(ch.elexis.core.model.ICoverage) Test(org.junit.Test)

Example 99 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project elexis-server by elexis.

the class EncounterTest method getEncounter.

@Test
public void getEncounter() {
    Patient readPatient = client.read().resource(Patient.class).withId(AllTests.getTestDatabaseInitializer().getPatient().getId()).execute();
    // search by patient
    Bundle results = client.search().forResource(Encounter.class).where(Encounter.PATIENT.hasId(readPatient.getId())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    Encounter encounter = (Encounter) entries.get(0).getResource();
    System.out.println("LOOK " + TestDatabaseInitializer.getBehandlung().getId());
    // search by elexis behandlung id
    results = client.search().forResource(Encounter.class).where(Encounter.IDENTIFIER.exactly().systemAndIdentifier("www.elexis.info/consultationid", TestDatabaseInitializer.getBehandlung().getId())).returnBundle(Bundle.class).execute();
    entries = results.getEntry();
    assertFalse(entries.isEmpty());
    // read with by id
    Encounter readEncounter = client.read().resource(Encounter.class).withId(encounter.getId()).execute();
    assertNotNull(readEncounter);
    assertEquals(encounter.getId(), readEncounter.getId());
    // search by patient and date
    results = client.search().forResource(Encounter.class).where(Encounter.PATIENT.hasId(readPatient.getId())).and(Encounter.DATE.afterOrEquals().day("2016-09-01")).and(Encounter.DATE.beforeOrEquals().day("2016-10-01")).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    entries = results.getEntry();
    assertFalse(entries.isEmpty());
    // search by patient and date not found
    results = client.search().forResource(Encounter.class).where(Encounter.PATIENT.hasId(readPatient.getId())).and(Encounter.DATE.afterOrEquals().day("2016-10-01")).and(Encounter.DATE.beforeOrEquals().day("2016-11-01")).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    entries = results.getEntry();
    assertTrue(entries.isEmpty());
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.Test)

Example 100 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project elexis-server by elexis.

the class FamilyMemberHistoryTest method testFamilyMemberHistory.

@Test
public void testFamilyMemberHistory() {
    // search for encounter
    Bundle results = client.search().forResource(FamilyMemberHistory.class).where(FamilyMemberHistory.PATIENT.hasId(AllTests.getTestDatabaseInitializer().getPatient().getId())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
}
Also used : FamilyMemberHistory(org.hl7.fhir.r4.model.FamilyMemberHistory) IFamilyMemberHistory(ch.elexis.core.findings.IFamilyMemberHistory) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) Test(org.junit.Test)

Aggregations

BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)265 Resource (org.hl7.fhir.r4.model.Resource)167 Test (org.junit.jupiter.api.Test)126 Bundle (org.hl7.fhir.r4.model.Bundle)116 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)96 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)88 ArrayList (java.util.ArrayList)67 Date (java.util.Date)52 Reference (org.hl7.fhir.r4.model.Reference)52 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)51 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Patient (org.hl7.fhir.r4.model.Patient)37 IOException (java.io.IOException)36 Observation (org.hl7.fhir.r4.model.Observation)36 Test (org.junit.Test)35 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)34 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)33 Condition (org.hl7.fhir.r4.model.Condition)32 HashMap (java.util.HashMap)31 Encounter (org.hl7.fhir.r4.model.Encounter)31