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;
}
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());
}
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());
}
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());
}
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());
}
Aggregations