List<Observation> observations = new ArrayList<Observation>(); String chain = subject.getChain(); if (Patient.SP_IDENTIFIER.equals(chain)) { TokenParam tokenSubject = subject.toTokenParam(myContext); String system = tokenSubject.getSystem(); String identifier = tokenSubject.getValue(); DateParam dateSubject = subject.toDateParam(myContext); DateTimeType birthDate = new DateTimeType(dateSubject.getValueAsString()); String resourceId = subject.getValue();
@CoverageIgnore @Override ReferenceParam newInstance() { return new ReferenceParam(); }
@Override String doGetValueAsQueryToken(FhirContext theContext) { if (isBlank(myId.getResourceType())) { return myId.getValue(); // e.g. urn:asdjd or 123 or cid:wieiuru or #1 } else { if (isBlank(getChain())) { return getResourceType() + "/" + myId.getIdPart(); } return myId.getIdPart(); } }
/** * Constructor */ public ReferenceParam(String theChain, String theValue) { setValueAsQueryToken(null, null, null, theValue); setChain(theChain); }
@Search public List<DiagnosticReport> findReportsWithChain( @RequiredParam(name=DiagnosticReport.SP_SUBJECT, chainWhitelist= {Patient.SP_FAMILY, Patient.SP_GENDER}) ReferenceParam theSubject ) { List<DiagnosticReport> retVal=new ArrayList<DiagnosticReport>(); String chain = theSubject.getChain(); if (Patient.SP_FAMILY.equals(chain)) { String familyName = theSubject.getValue(); // .. populate with reports matching subject family name .. } if (Patient.SP_GENDER.equals(chain)) { String gender = theSubject.getValue(); // .. populate with reports matching subject gender .. } return retVal; } //END SNIPPET: referenceWithChain
.build(); String chain = patient.getChain(); if (Patient.SP_IDENTIFIER.equals(chain)) { parameters.setPatientIdentifier(patient.toTokenParam(getFhirContext())); } else if (chain == null || chain.isEmpty()) { parameters.setPatientReference(patient);
ReferenceParam ref = (ReferenceParam) nextOr; if (isBlank(ref.getChain())) { IIdType dt = new IdDt(ref.getBaseUrl(), ref.getResourceType(), ref.getIdPart(), null); if (!ref.getValue().matches("[a-zA-Z]+/.*")) { resourceId = ref.getValue(); RuntimeResourceDefinition resDef = myContext.getResourceDefinition(ref.getResourceType()); resourceTypes = new ArrayList<>(1); resourceTypes.add(resDef.getImplementingClass()); resourceId = ref.getIdPart(); } catch (DataFormatException e) { throw new InvalidRequestException("Invalid resource type: " + ref.getResourceType()); String chain = ref.getChain(); String remainingChain = null; int chainDotIndex = chain.indexOf('.'); throw new InvalidRequestException(myContext.getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "invalidParameterChain", theParamName + '.' + ref.getChain()));
public Iti66SearchParameters setAuthor(ReferenceAndListParam author) { if (author != null) { author.getValuesAsQueryTokens().forEach(param -> { ReferenceParam ref = param.getValuesAsQueryTokens().get(0); String authorChain = ref.getChain(); if (Practitioner.SP_FAMILY.equals(authorChain)) { setAuthorFamilyName(ref.toStringParam(getFhirContext())); } else if (Practitioner.SP_GIVEN.equals(authorChain)) { setAuthorGivenName(ref.toStringParam(getFhirContext())); } }); } return this; } }
@Override public List<TokenParam> getPatientIdParam() { if (_id != null) return Collections.singletonList(_id); return Collections.singletonList(patientReference.toTokenParam(fhirContext)); } }
private boolean hasChain(List<List<? extends IQueryParameterType>> theAndOrParams) { return theAndOrParams.stream().flatMap(List::stream).anyMatch(param -> param instanceof ReferenceParam && ((ReferenceParam)param).getChain() != null); }
private IQueryParameterType mapReferenceChainToRawParamType(String remainingChain, RuntimeSearchParam param, String theParamName, String qualifier, Class<? extends IBaseResource> nextType, String chain, boolean isMeta, String resourceId) { IQueryParameterType chainValue; if (remainingChain != null) { if (param == null || param.getParamType() != RestSearchParameterTypeEnum.REFERENCE) { ourLog.debug("Type {} parameter {} is not a reference, can not chain {}", nextType.getSimpleName(), chain, remainingChain); return null; } chainValue = new ReferenceParam(); chainValue.setValueAsQueryToken(myContext, theParamName, qualifier, resourceId); ((ReferenceParam) chainValue).setChain(remainingChain); } else if (isMeta) { IQueryParameterType type = myMatchUrlService.newInstanceType(chain); type.setValueAsQueryToken(myContext, theParamName, qualifier, resourceId); chainValue = type; } else { chainValue = toParameterType(param, qualifier, resourceId); } return chainValue; }
@Search public List<DiagnosticReport> findDiagnosticReportsWithSubjet( @OptionalParam(name=DiagnosticReport.SP_SUBJECT) ReferenceParam theSubject ) { List<DiagnosticReport> retVal=new ArrayList<DiagnosticReport>(); // If the parameter passed in includes a resource type (e.g. ?subject:Patient=123) // that resource type is available. Here we just check that it is either not provided // or set to "Patient" if (theSubject.hasResourceType()) { String resourceType = theSubject.getResourceType(); if ("Patient".equals(resourceType) == false) { throw new InvalidRequestException("Invalid resource type for parameter 'subject': " + resourceType); } } if (theSubject != null) { // ReferenceParam extends IdType so all of the resource ID methods are available String subjectId = theSubject.getIdPart(); // .. populate retVal with DiagnosticReport resources having // subject with id "subjectId" .. } return retVal; } //END SNIPPET: referenceSimple
public Class<? extends IBaseResource> getResourceType(FhirContext theCtx) { if (isBlank(getResourceType())) { return null; } return theCtx.getResourceDefinition(getResourceType()).getImplementingClass(); }
private boolean resourceIdMatches(ResourceLink theResourceLink, ReferenceParam theReference) { ResourceTable target = theResourceLink.getTargetResource(); IdDt idDt = target.getIdDt(); if (idDt.isIdPartValidLong()) { return theReference.getIdPartAsLong() == idDt.getIdPartAsLong(); } else { ForcedId forcedId = target.getForcedId(); if (forcedId != null) { return forcedId.getForcedId().equals(theReference.getValue()); } else { return false; } } }
@Override public String toString() { ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); if (isNotBlank(myChain)) { b.append("chain", myChain); } b.append("value", getValue()); return b.build(); }
setValue(theValue); if (isNotBlank(resourceType) && isBlank(getResourceType())) { setValue(resourceType + '/' + theValue);
.build(); String chain = patient.getChain(); if (Patient.SP_IDENTIFIER.equals(chain)) { parameters.setPatientIdentifier(patient.toTokenParam(getFhirContext())); } else if (chain == null || chain.isEmpty()) { parameters.setPatientReference(patient);
ReferenceParam ref = (ReferenceParam) nextOr; if (isBlank(ref.getChain())) { IIdType dt = new IdDt(ref.getBaseUrl(), ref.getResourceType(), ref.getIdPart(), null); if (!ref.getValue().matches("[a-zA-Z]+/.*")) { resourceId = ref.getValue(); RuntimeResourceDefinition resDef = myContext.getResourceDefinition(ref.getResourceType()); resourceTypes = new ArrayList<>(1); resourceTypes.add(resDef.getImplementingClass()); resourceId = ref.getIdPart(); } catch (DataFormatException e) { throw new InvalidRequestException("Invalid resource type: " + ref.getResourceType()); String chain = ref.getChain(); String remainingChain = null; int chainDotIndex = chain.indexOf('.'); throw new InvalidRequestException(myContext.getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "invalidParameterChain", theParamName + '.' + ref.getChain()));
public Iti67SearchParameters setAuthor(ReferenceAndListParam author) { if (author != null) { author.getValuesAsQueryTokens().forEach(param -> { ReferenceParam ref = param.getValuesAsQueryTokens().get(0); String authorChain = ref.getChain(); if (Practitioner.SP_FAMILY.equals(authorChain)) { setAuthorFamilyName(ref.toStringParam(getFhirContext())); } else if (Practitioner.SP_GIVEN.equals(authorChain)) { setAuthorGivenName(ref.toStringParam(getFhirContext())); } }); } return this; } }