public static void simpleExample() { // START SNIPPET: simple // We're connecting to a DSTU1 compliant server in this example FhirContext ctx = FhirContext.forDstu2(); String serverBase = "http://fhirtest.uhn.ca/baseDstu2"; IGenericClient client = ctx.newRestfulGenericClient(serverBase); // Perform a search Bundle results = client .search() .forResource(Patient.class) .where(Patient.FAMILY.matches().value("duck")) .returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class) .execute(); System.out.println("Found " + results.getEntry().size() + " patients named 'duck'"); // END SNIPPET: simple }
.search() .forResource(org.hl7.fhir.dstu3.model.ConceptMap.class) .where(org.hl7.fhir.dstu3.model.ConceptMap.URL.matches().value(conceptMapUrl)) .returnBundle(org.hl7.fhir.dstu3.model.Bundle.class) .execute(); .search() .forResource(ConceptMap.class) .where(ConceptMap.URL.matches().value(conceptMapUrl)) .returnBundle(Bundle.class) .execute();
private static void paging() { { // START SNIPPET: searchPaging FhirContext ctx = FhirContext.forDstu2(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); // Perform a search Bundle resultBundle = client.search() .forResource(Patient.class) .where(Patient.NAME.matches().value("Smith")) .returnBundle(Bundle.class) .execute(); if (resultBundle.getLink(Bundle.LINK_NEXT) != null) { // load next page Bundle nextPage = client.loadPage().next(resultBundle).execute(); } // END SNIPPET: searchPaging } }
.where(Patient.BIRTHDATE.beforeOrEquals().day("2011-01-01")) .and(Patient.CAREPROVIDER.hasChainedProperty(Organization.NAME.matches().value("Health"))) .returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class) .where(Patient.FAMILY.matches().values("Smith", "Smyth")) .returnBundle(Bundle.class) .execute(); .where(Patient.ADDRESS.matches().values("Toronto")) .and(Patient.ADDRESS.matches().values("Ontario")) .and(Patient.ADDRESS.matches().values("Canada")) .forResource(Patient.class) .withIdAndCompartment("123", "condition") .where(Patient.ADDRESS.matches().values("Toronto")) .returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class) .execute(); .where(Patient.ADDRESS.matches().values("Toronto")) .returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class) .summaryMode(SummaryEnum.TRUE) .where(Patient.ADDRESS.matches().values("Toronto")) .returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class) .elementsSubset("identifier", "name") // only include the identifier and name .forResource(Patient.class) .encodedJson() .where(Patient.BIRTHDATE.beforeOrEquals().day("2012-01-22"))
@Override public void buildQuery(LocationSearchCriteria criteria, IQuery<Bundle> query) { super.buildQuery(criteria, query); if (criteria.getType() != null) { query.where(Location.TYPE.exactly().code(criteria.getType().getCode())); } if (criteria.getStatus() != null) { query.where(Location.STATUS.exactly().code(criteria.getStatus().getCode())); } if (criteria.getName() != null) { query.where(Location.NAME.matches().value(criteria.getName())); } }
public Collection<String> getTypes() { TreeSet<String> results = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); try { Bundle bundle = ClientUtil.getFhirClient().search().forResource(ValueSet.class) .where(ValueSet.NAME.matchesExactly().value("DocumentType")).execute(); for (ValueSet vs : FhirUtil.getEntries(bundle, ValueSet.class)) { for (ValueSet.DefineConcept concept : vs.getDefine().getConcept()) { results.add(concept.getDisplay().toString()); } } } catch (Exception e) {} return results; } }
@Override public void buildQuery(LocationSearchCriteria criteria, IQuery<?> query) { super.buildQuery(criteria, query); if (criteria.getType() != null) { query.where(Location.TYPE.exactly().code(criteria.getType())); } if (criteria.getStatus() != null) { query.where(Location.STATUS.exactly().code(criteria.getStatus().toCode())); } if (criteria.getName() != null) { query.where(Location.NAME.matches().value(criteria.getName())); } }
/** * Fetch multiple instances of the domain class from the data store. */ @Override public <T extends BaseResource> List<T> fetchObjects(Class<T> clazz, String[] ids) { if (ids == null || ids.length == 0) { return Collections.emptyList(); } StringClientParam param = new StringClientParam(BaseResource.SP_RES_ID); Bundle results = fhirClient.search().forResource(clazz).where(param.matches().values(ids)).execute(); return FhirUtil.getEntries(results, clazz); }
/** * Fetch multiple instances of the domain class from the data store. */ @Override public <T extends BaseResource> List<T> fetchObjects(Class<T> clazz, String[] ids) { if (ids == null || ids.length == 0) { return Collections.emptyList(); } StringClientParam param = new StringClientParam(BaseResource.SP_RES_ID); Bundle results = fhirClient.search().forResource(clazz).where(param.matches().values(ids)).returnBundle(Bundle.class) .execute(); return FhirUtil.getEntries(results, clazz); }
protected Bundle sendManually(ICriterion<?> requestData) { return client.search() .forResource(PdqPatient.class) .where(requestData) .returnBundle(Bundle.class) .execute(); }
protected Bundle sendManually(ICriterion<?> requestData) { return client.search() .forResource(DocumentManifest.class) .where(requestData) .returnBundle(Bundle.class) .execute(); }
protected Bundle sendManually(ICriterion<?> requestData) { return client.search() .forResource(DocumentReference.class) .where(requestData) .returnBundle(Bundle.class) .execute(); }
protected Bundle sendManually(ICriterion<?> requestData) { return client.search() .forResource(DocumentReference.class) .where(requestData) .returnBundle(Bundle.class) .execute(); }
protected Bundle sendManually(ICriterion<?> requestData) { return client.search() .forResource(PdqPatient.class) .where(requestData) .returnBundle(Bundle.class) .execute(); }
protected Bundle sendManually(ICriterion<?> requestData) { return client.search() .forResource(DocumentManifest.class) .where(requestData) .returnBundle(Bundle.class) .execute(); }
/** * Validates the criteria settings and then transfers them to the query object. This method * transfers the base criteria only. Override to transfer additional criteria that are specific * to the resource type. * * @param criteria Research search criteria. * @param query The query object. */ protected void buildQuery(C criteria, IQuery<Bundle> query) { criteria.validate(); if (criteria.getMaximum() > 0) { query.limitTo(criteria.getMaximum()); } if (criteria.getId() != null) { query.where(new StringClientParam(BaseResource.SP_RES_ID).matches().value(criteria.getId())); } }
/** * Validates the criteria settings and then transfers them to the query object. This method * transfers the base criteria only. Override to transfer additional criteria that are specific * to the resource type. * * @param criteria Research search criteria. * @param query The query object. */ protected void buildQuery(C criteria, IQuery<?> query) { criteria.validate(); if (criteria.getMaximum() > 0) { query.count(criteria.getMaximum()); } if (criteria.getId() != null) { query.where(new StringClientParam(BaseResource.SP_RES_ID).matches().value(criteria.getId())); } }
protected Bundle sendManuallyWithCount(ICriterion<?> requestData, int count) { return client.search() .forResource(PdqPatient.class) .where(requestData) .count(count) .returnBundle(Bundle.class) .execute(); }
protected Bundle sendManuallyWithCount(ICriterion<?> requestData, int count) { return client.search() .forResource(PdqPatient.class) .where(requestData) .count(count) .returnBundle(Bundle.class) .execute(); }
@Test public void testSendManualPdqmWithBirthdayRange() { Bundle result = client.search() .forResource(PdqPatient.class) .where(PdqPatient.BIRTHDATE.exactly().day("2011-12-31")) .and(PdqPatient.FAMILY.matches().value("Miller")) .returnBundle(Bundle.class) .execute(); assertEquals(Bundle.BundleType.SEARCHSET, result.getType()); assertEquals(ResourceType.Bundle, result.getResourceType()); assertTrue(result.hasEntry()); }