private void writeTagWithTextNode( XMLStreamWriter theEventWriter, String theElementName, StringDt theStringDt) throws XMLStreamException { theEventWriter.writeStartElement(theElementName); if (StringUtils.isNotBlank(theStringDt.getValue())) { theEventWriter.writeCharacters(theStringDt.getValue()); } theEventWriter.writeEndElement(); }
private void writeAtomLink(XMLStreamWriter theEventWriter, String theRel, StringDt theStringDt) throws XMLStreamException { if (StringUtils.isNotBlank(theStringDt.getValue())) { theEventWriter.writeStartElement("link"); theEventWriter.writeAttribute("rel", theRel); theEventWriter.writeAttribute("href", theStringDt.getValue()); theEventWriter.writeEndElement(); } }
private void writeBundleResourceLink( XMLStreamWriter theEventWriter, String theRel, StringDt theUrl) throws XMLStreamException { if (theUrl.isEmpty() == false) { theEventWriter.writeStartElement("link"); theEventWriter.writeStartElement("relation"); theEventWriter.writeAttribute("value", theRel); theEventWriter.writeEndElement(); theEventWriter.writeStartElement("url"); theEventWriter.writeAttribute("value", theUrl.getValue()); theEventWriter.writeEndElement(); theEventWriter.writeEndElement(); } }
@Search public List<Patient> findPatient( @RequiredParam(name = Patient.SP_NAME) StringDt theName, @IncludeParam(allow = {"foo", "bar"}) Set<Include> theIncludes) { ArrayList<Patient> retVal = new ArrayList<Patient>(); Patient p = new Patient(); p.addIdentifier().setSystem("foo").setValue("bar"); p.setId(theName.getValue()); if (theIncludes != null) { for (Include next : theIncludes) { p.addName().addFamily().setValue(next.getValue()); } } retVal.add(p); return retVal; }
@Override public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCode( UriDt theValueSetIdentifier, IIdType theId, CodeDt theCode, UriDt theSystem, StringDt theDisplay, CodingDt theCoding, CodeableConceptDt theCodeableConcept) { List<IIdType> valueSetIds; boolean haveCodeableConcept = theCodeableConcept != null && theCodeableConcept.getCoding().size() > 0; boolean haveCoding = theCoding != null && theCoding.isEmpty() == false; boolean haveCode = theCode != null && theCode.isEmpty() == false; if (!haveCodeableConcept && !haveCoding && !haveCode) { throw new InvalidRequestException("No code, coding, or codeableConcept provided to validate"); } if (!(haveCodeableConcept ^ haveCoding ^ haveCode)) { throw new InvalidRequestException( "$validate-code can only validate (system AND code) OR (coding) OR (codeableConcept)"); } boolean haveIdentifierParam = theValueSetIdentifier != null && theValueSetIdentifier.isEmpty() == false; if (theId != null) { valueSetIds = Collections.singletonList(theId); } else if (haveIdentifierParam) { Set<Long> ids = searchForIds( ValueSet.SP_IDENTIFIER, new TokenParam(null, theValueSetIdentifier.getValue())); valueSetIds = new ArrayList<IIdType>(); for (Long next : ids) { valueSetIds.add(new IdDt("ValueSet", next)); } } else { if (theCode == null || theCode.isEmpty()) { throw new InvalidRequestException( "Either ValueSet ID or ValueSet identifier or system and code must be provided. Unable to validate."); } Set<Long> ids = searchForIds( ValueSet.SP_CODE, new TokenParam(toStringOrNull(theSystem), theCode.getValue())); valueSetIds = new ArrayList<IIdType>(); for (Long next : ids) { valueSetIds.add(new IdDt("ValueSet", next)); } } for (IIdType nextId : valueSetIds) { ValueSet expansion = expand(nextId, null); List<ExpansionContains> contains = expansion.getExpansion().getContains(); ValidateCodeResult result = validateCodeIsInContains( contains, toStringOrNull(theSystem), toStringOrNull(theCode), theCoding, theCodeableConcept); if (result != null) { if (theDisplay != null && isNotBlank(theDisplay.getValue()) && isNotBlank(result.getDisplay())) { if (!theDisplay.getValue().equals(result.getDisplay())) { return new ValidateCodeResult( false, "Display for code does not match", result.getDisplay()); } } return result; } } return new ValidateCodeResult(false, "Code not found", null); }