@Deprecated public synchronized IBaseResource toProfile() { validateSealed(); if (myProfileDef != null) { return myProfileDef; } IBaseResource retVal = myContext.getVersion().generateProfile(this, null); myProfileDef = retVal; return retVal; }
public IIdType getIdElement(FhirContext theContext) { IIdType retVal = null; if (isNotBlank(myIdElement)) { retVal = theContext.getVersion().newIdType().setValue(myIdElement); } return retVal; }
public BaseIgPackParser(FhirContext theCtx) { FhirVersionEnum expectedVersion = provideExpectedVersion(); Validate.isTrue(theCtx.getVersion().getVersion() == expectedVersion, "theCtx is not for the correct version, expecting " + expectedVersion); myCtx = theCtx; }
@Override public final void encodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theWriter, "theWriter can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } doEncodeResourceToWriter(theResource, theWriter); }
@Override public void encodeResourceToJsonLikeWriter(IBaseResource theResource, JsonLikeWriter theJsonLikeWriter) throws IOException, DataFormatException { Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theJsonLikeWriter, "theJsonLikeWriter can not be null"); if (theResource.getStructureFhirVersionEnum() != myContext.getVersion().getVersion()) { throw new IllegalArgumentException( "This parser is for FHIR version " + myContext.getVersion().getVersion() + " - Can not encode a structure for version " + theResource.getStructureFhirVersionEnum()); } doEncodeResourceToJsonLikeWriter(theResource, theJsonLikeWriter); }
private String getSubsettedCodeSystem() { if (myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.R4)) { return Constants.TAG_SUBSETTED_SYSTEM_R4; } else { return Constants.TAG_SUBSETTED_SYSTEM_DSTU3; } }
public IIdType getPayloadId(FhirContext theCtx) { IIdType retVal = null; if (myPayloadId != null) { retVal = theCtx.getVersion().newIdType().setValue(myPayloadId); } return retVal; }
static FhirContext getHl7OrgDstu2Ctx(FhirContext theCtx) { if (theCtx.getVersion().getVersion() == FhirVersionEnum.DSTU2_HL7ORG) { return theCtx; } FhirContext retVal = ourHl7OrgCtx; if (retVal == null) { retVal = FhirContext.forDstu2Hl7Org(); ourHl7OrgCtx = retVal; } return retVal; }
public synchronized IBaseResource toProfile(String theServerBase) { validateSealed(); if (myProfileDef != null) { return myProfileDef; } IBaseResource retVal = myContext.getVersion().generateProfile(this, theServerBase); myProfileDef = retVal; return retVal; }
public IIdType getId(FhirContext theCtx) { IIdType retVal = null; if (myId != null) { retVal = theCtx.getVersion().newIdType().setValue(myId); } return retVal; }
private static FhirContext massage(FhirContext theCtx) { if (theCtx.getVersion().getVersion() == FhirVersionEnum.DSTU2) { return FhirContext.forDstu2Hl7Org(); } else { return theCtx; } }
protected static void parseContentLocation(FhirContext theContext, MethodOutcome theOutcomeToPopulate, String theLocationHeader) { if (StringUtils.isBlank(theLocationHeader)) { return; } IIdType id = theContext.getVersion().newIdType(); id.setValue(theLocationHeader); theOutcomeToPopulate.setId(id); }
protected static void parseContentLocation(FhirContext theContext, MethodOutcome theOutcomeToPopulate, String theLocationHeader) { if (StringUtils.isBlank(theLocationHeader)) { return; } IIdType id = theContext.getVersion().newIdType(); id.setValue(theLocationHeader); theOutcomeToPopulate.setId(id); }
public CanonicalSubscription canonicalize(S theSubscription) { switch (myFhirContext.getVersion().getVersion()) { case DSTU2: return canonicalizeDstu2(theSubscription); case DSTU3: return canonicalizeDstu3(theSubscription); case R4: return canonicalizeR4(theSubscription); default: throw new ConfigurationException("Subscription not supported for version: " + myFhirContext.getVersion().getVersion()); } }
private IBaseBundle getBundleFromFile(Integer theLimit, File theSuppliedFile, FhirContext theCtx) throws ParseException, IOException { switch (theCtx.getVersion().getVersion()) { case DSTU2: return getBundleFromFileDstu2(theLimit, theSuppliedFile, theCtx); case DSTU3: return getBundleFromFileDstu3(theLimit, theSuppliedFile, theCtx); case R4: return getBundleFromFileR4(theLimit, theSuppliedFile, theCtx); default: throw new ParseException("Invalid spec version for this command: " + theCtx.getVersion().getVersion()); } }
public String getCriteria(IBaseResource theSubscription) { switch (myFhirContext.getVersion().getVersion()) { case DSTU2: return ((ca.uhn.fhir.model.dstu2.resource.Subscription)theSubscription).getCriteria(); case DSTU3: return ((org.hl7.fhir.dstu3.model.Subscription)theSubscription).getCriteria(); case R4: return ((org.hl7.fhir.r4.model.Subscription)theSubscription).getCriteria(); default: throw new ConfigurationException("Subscription not supported for version: " + myFhirContext.getVersion().getVersion()); } }
@Transactional(propagation = Propagation.REQUIRED) @Override public Resource lookup(Object theAppInfo, String theType, String theId) throws FHIRException { IIdType refId = getContext().getVersion().newIdType(); refId.setValue(theType + "/" + theId); IFhirResourceDao<? extends IBaseResource> dao = getDao(theType); BaseHasResource id = dao.readEntity(refId); return (Resource) toResource(id, false); }
public static IPrimitiveType<?> createString(FhirContext theContext, String theValue) { IPrimitiveType<?> value; if (theContext.getVersion().getVersion().isRi()) { value = (IPrimitiveType<?>) theContext.getElementDefinition("string").newInstance(theValue); } else { value = new StringDt(theValue); } return value; }
private String getContentType(EncodingEnum encoding) { if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { // application/xml+fhir return encoding.getResourceContentType(); } else { // application/fhir+xml return encoding.getResourceContentTypeNonLegacy(); } }
@Override public Response returnResponse(ParseAction<?> outcome, int operationStatus, boolean allowPrefer, MethodOutcome response, String resourceName) throws IOException { StringWriter writer = new StringWriter(); if (outcome != null) { FhirContext fhirContext = getRequestDetails().getServer().getFhirContext(); IParser parser = RestfulServerUtils.getNewParser(fhirContext, fhirContext.getVersion().getVersion(), getRequestDetails()); outcome.execute(parser, writer); } return sendWriterResponse(operationStatus, getParserType(), null, writer); }