/** * Match the referenced resource if the resource has the given ID (this can be * the logical ID or the absolute URL of the resource) */ public ICriterion<ReferenceClientParam> hasId(String theId) { return new StringCriterion<>(getParamName(), theId); }
/** * Match the referenced resource if the resource has ANY of the given IDs * (this is an OR search, not an AND search), (this can be the logical ID or * the absolute URL of the resource). Note that to specify an AND search, * simply add a subsequent {@link IQuery#where(ICriterion) where} criteria * with the same parameter. */ public ICriterion<ReferenceClientParam> hasAnyOfIds(String... theIds) { Validate.notNull(theIds, "theIds must not be null"); return hasAnyOfIds(Arrays.asList(theIds)); }
protected ICriterion<?> manifestPatientReferenceParameter() { return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1"); }
/** * General purpose fluent find * * @param clazz Resource class to find * @param criterion Criterion to be applied to the query. Must include a patient matching criterion * @param <T> Resource * @return A list of resource matching the criterion */ public <T extends IBaseResource> Collection<T> find(Class<T> clazz, ICriterion<?>... criterion) { String patientId = session.getContext().getPatientResource().getId().getIdPart(); IQuery<Bundle> queryBuilder = session.search().forResource(clazz); // use reflection to match the getPatientContext criterion queryBuilder.where(findPatientReferenceOnResource(clazz).hasId(patientId)); for (ICriterion<?> theCriterion : criterion) { queryBuilder = queryBuilder.and(theCriterion); } Bundle results = queryBuilder.execute(); return asCollection(results); }
.forResource(Patient.class) .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) .execute();
protected ICriterion<?> referencePatientReferenceParameter() { return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1"); }
/** * General purpose find * * @param clazz Resource class to find * @param criterion Criterion to be applied to the query. Must include a patient matching criterion * @param <T> Resource * @return A list of resource matching the criterion */ public <T extends IBaseResource> Collection<T> find(Class<T> clazz, ICriterion<?>... criterion) { String patientId = session.getContextSTU3().getPatientResource().getIdElement().getIdPart(); IQuery<ca.uhn.fhir.model.api.Bundle> queryBuilder = session.search().forResource(clazz); // use reflection to match the getPatientContext criterion queryBuilder.where(findPatientReferenceOnResource(clazz).hasId(patientId)); for (ICriterion<?> theCriterion : criterion) { queryBuilder = queryBuilder.and(theCriterion); } IClientExecutable<IQuery<Bundle>, Bundle> results = queryBuilder.returnBundle(Bundle.class); return asCollection(results.execute()); }
protected ICriterion<?> manifestPatientReferenceParameter() { return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1"); }
/** * General purpose find * * @param clazz Resource class to find * @param criterion Criterion to be applied to the query. Must include a patient matching criterion * @param <T> Resource * @return A list of resource matching the criterion */ public <T extends IResource> Collection<T> find(Class<T> clazz, ICriterion<?>... criterion) { String patientId = session.getContextDSTU2().getPatientResource().getIdElement().getIdPart(); IQuery<ca.uhn.fhir.model.api.Bundle> queryBuilder = session.search().forResource(clazz); // use reflection to match the getPatientContext criterion queryBuilder.where(findPatientReferenceOnResource(clazz).hasId(patientId)); for (ICriterion<?> theCriterion : criterion) { queryBuilder = queryBuilder.and(theCriterion); } IClientExecutable<IQuery<Bundle>, Bundle> results = queryBuilder.returnBundle(Bundle.class); return asCollection(results.execute()); }
/** * Match the referenced resource if the resource has ANY of the given IDs * (this is an OR search, not an AND search), (this can be the logical ID or * the absolute URL of the resource). Note that to specify an AND search, * simply add a subsequent {@link IQuery#where(ICriterion) where} criteria * with the same parameter. */ public ICriterion<ReferenceClientParam> hasAnyOfIds(Collection<String> theIds) { return new StringCriterion<>(getParamName(), theIds); }
/** * Match the referenced resource if the resource has ANY of the given IDs * (this is an OR search, not an AND search), (this can be the logical ID or * the absolute URL of the resource). Note that to specify an AND search, * simply add a subsequent {@link IQuery#where(ICriterion) where} criteria * with the same parameter. */ public ICriterion<ReferenceClientParam> hasAnyOfIds(String... theIds) { Validate.notNull(theIds, "theIds must not be null"); return hasAnyOfIds(Arrays.asList(theIds)); }
protected ICriterion<?> referencePatientReferenceParameter() { return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1"); }
@Override public void buildQuery(EncounterSearchCriteria criteria, IQuery<Bundle> query) { super.buildQuery(criteria, query); if (criteria.getPatient() != null) { query.where(Encounter.PATIENT.hasId(criteria.getPatient().getId())); } if (criteria.getPeriod() != null) { Date start = criteria.getPeriod().getStart(); Date end = criteria.getPeriod().getEnd(); if (start != null) { if (end == null) { query.where(Encounter.LOCATION_PERIOD.exactly().day(start)); } else { query.where(Encounter.LOCATION_PERIOD.afterOrEquals().day(start)); query.where(Encounter.LOCATION_PERIOD.beforeOrEquals().day(end)); } } else if (end != null) { query.where(Encounter.LOCATION_PERIOD.exactly().day(end)); } } if (criteria.getType() != null) { query.where(Encounter.TYPE.exactly().code(criteria.getType())); } }
/** * Include a chained search. For example: * <pre> * Bundle resp = ourClient * .search() * .forResource(QuestionnaireResponse.class) * .where(QuestionnaireResponse.SUBJECT.hasChainedProperty(Patient.FAMILY.matches().value("SMITH"))) * .returnBundle(Bundle.class) * .execute(); * </pre> */ public ICriterion<ReferenceClientParam> hasChainedProperty(ICriterion<?> theCriterion) { return new ReferenceChainCriterion(getParamName(), theCriterion); }
ReferenceClientParam subject = new ReferenceClientParam(DocumentReference.SP_SUBJECT + ":Patient"); .where(subject.hasId(patient.getId().getIdPart()));
@Override public void buildQuery(EncounterSearchCriteria criteria, IQuery<?> query) { super.buildQuery(criteria, query); if (criteria.getPatient() != null) { query.where(Encounter.PATIENT.hasId(criteria.getPatient().getId())); } if (criteria.getPeriod() != null) { Date start = criteria.getPeriod().getStart(); Date end = criteria.getPeriod().getEnd(); if (start != null) { if (end == null) { query.where(Encounter.LOCATION_PERIOD.exactly().day(start)); } else { query.where(Encounter.LOCATION_PERIOD.afterOrEquals().day(start)); query.where(Encounter.LOCATION_PERIOD.beforeOrEquals().day(end)); } } else if (end != null) { query.where(Encounter.LOCATION_PERIOD.exactly().day(end)); } } if (criteria.getType() != null) { query.where(Encounter.TYPE.exactly().code(criteria.getType())); } }
/** * Include a chained search with a resource type. For example: * <pre> * Bundle resp = ourClient * .search() * .forResource(QuestionnaireResponse.class) * .where(QuestionnaireResponse.SUBJECT.hasChainedProperty("Patient", Patient.FAMILY.matches().value("SMITH"))) * .returnBundle(Bundle.class) * .execute(); * </pre> */ public ICriterion<ReferenceClientParam> hasChainedProperty(String theResourceType, ICriterion<?> theCriterion) { return new ReferenceChainCriterion(getParamName(), theResourceType, theCriterion); }
/** * Match the referenced resource if the resource has the given ID (this can be * the logical ID or the absolute URL of the resource) */ public ICriterion<ReferenceClientParam> hasId(IIdType theId) { return new StringCriterion<>(getParamName(), theId.getValue()); }
/** * Match the referenced resource if the resource has the given ID (this can be * the logical ID or the absolute URL of the resource) */ public ICriterion<ReferenceClientParam> hasId(String theId) { return new StringCriterion<>(getParamName(), theId); }
/** * Match the referenced resource if the resource has ANY of the given IDs * (this is an OR search, not an AND search), (this can be the logical ID or * the absolute URL of the resource). Note that to specify an AND search, * simply add a subsequent {@link IQuery#where(ICriterion) where} criteria * with the same parameter. */ public ICriterion<ReferenceClientParam> hasAnyOfIds(Collection<String> theIds) { return new StringCriterion<>(getParamName(), theIds); }