Refine search
public IBaseResource getPayload(FhirContext theCtx) { IBaseResource retVal = myPayload; if (retVal == null && isNotBlank(myPayloadString)) { retVal = theCtx.newJsonParser().parseResource(myPayloadString); myPayload = retVal; } return retVal; }
@Override public IParser newParser(FhirContext theContext) { return theContext.newXmlParser(); } };
private void processUrl() { String resourceType = myId.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, myId)); } myType = myContext.getResourceDefinition(resourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, myId)); } }
@SuppressWarnings("unused") public void getResourceTags() { // START SNIPPET: context // Create a DSTU2 context, which will use DSTU2 semantics FhirContext ctx = FhirContext.forDstu2(); // This parser supports DSTU2 IParser parser = ctx.newJsonParser(); // This client supports DSTU2 IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); // END SNIPPET: context }
public static void deferModelScanning() { // START SNIPPET: deferModelScanning // Create a context and configure it for deferred child scanning FhirContext ctx = FhirContext.forDstu2(); ctx.setPerformanceOptions(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING); // Now create a client and use it String serverBase = "http://fhirtest.uhn.ca/baseDstu2"; IGenericClient client = ctx.newRestfulGenericClient(serverBase); // END SNIPPET: deferModelScanning }
public void upgrade() { // START SNIPPET: client FhirContext ctxDstu2 = FhirContext.forDstu2(); IGenericClient clientDstu2 = ctxDstu2.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); // END SNIPPET: client }
private static boolean payloadContainsNoPlaceholderReferences(FhirContext theCtx, IBaseResource theNewPayload) { List<ResourceReferenceInfo> refs = theCtx.newTerser().getAllResourceReferences(theNewPayload); for (ResourceReferenceInfo next : refs) { String ref = next.getResourceReference().getReferenceElement().getValue(); if (isBlank(ref)) { IBaseResource resource = next.getResourceReference().getResource(); if (resource != null) { ref = resource.getIdElement().getValue(); } } if (isNotBlank(ref)) { if (ref.startsWith("#")) { continue; } if (ref.startsWith("urn:uuid:")) { throw new AssertionError("Reference at " + next.getName() + " is invalid: " + ref); } } } return true; }
private void populateBundleEntryFullUrl(IResource next, Entry entry) { if (next.getId().hasBaseUrl()) { entry.setFullUrl(next.getId().toVersionless().getValue()); } else { if (isNotBlank(myBase) && next.getId().hasIdPart()) { IdDt id = next.getId().toVersionless(); id = id.withServerBase(myBase, myContext.getResourceDefinition(next).getName()); entry.setFullUrl(id.getValue()); } } }
public static HttpPutClientInvocation createUpdateInvocation(FhirContext theContext, IBaseResource theResource, String theResourceBody, Map<String, List<String>> theMatchParams) { String resourceType = theContext.getResourceDefinition(theResource).getName(); StringBuilder b = createUrl(resourceType, theMatchParams); HttpPutClientInvocation retVal; if (StringUtils.isBlank(theResourceBody)) { retVal = new HttpPutClientInvocation(theContext, theResource, b.toString()); } else { retVal = new HttpPutClientInvocation(theContext, theResourceBody, false, b.toString()); } return retVal; }
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); }
FhirValidator validator = getContext().newValidator(); Class<? extends IBaseResource> type = getContext().getResourceDefinition(theId.getResourceType()).getImplementingClass(); IFhirResourceDao<? extends IBaseResource> dao = getDao(type); resourceToValidateById = dao.read(theId, theRequestDetails); result = validator.validateWithResult(resourceToValidateById); } else { String msg = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "cantValidateWithNoResource"); throw new InvalidRequestException(msg); } else if (isNotBlank(theRawResource)) { result = validator.validateWithResult(theRawResource); } else {
public static String parseContentTextIntoWords(FhirContext theContext, IBaseResource theResource) { StringBuilder retVal = new StringBuilder(); @SuppressWarnings("rawtypes") List<IPrimitiveType> childElements = theContext.newTerser().getAllPopulatedChildElementsOfType(theResource, IPrimitiveType.class); for (@SuppressWarnings("rawtypes") IPrimitiveType nextType : childElements) { if (nextType instanceof StringDt || nextType.getClass().getSimpleName().equals("StringType")) { String nextValue = nextType.getValueAsString(); if (isNotBlank(nextValue)) { retVal.append(nextValue.replace("\n", " ").replace("\r", " ")); retVal.append("\n"); } } } return retVal.toString(); }
public IIdType getIdElement(FhirContext theContext) { IIdType retVal = null; if (isNotBlank(myIdElement)) { retVal = theContext.getVersion().newIdType().setValue(myIdElement); } return retVal; }
FhirContext ctx = FhirContext.forDstu3(); IParser xmlParser = ctx.newXmlParser(); IParser jsonParser = ctx.newJsonParser(); if (isNotBlank(res.getUrl())) { structureDefinitions.put(res.getUrl(), res); if (isNotBlank(res.getUrl())) { valueSets.put(res.getUrl(), res); if (isNotBlank(res.getUrl())) { codeSystems.put(res.getUrl(), res); FhirValidator val = ctx.newValidator(); val.registerValidatorModule(instanceValidator);
private String determineSystemIfMissing(String theParamName, String code, String theSystem) { String retVal = theSystem; if (retVal == null) { RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(myResourceName); RuntimeSearchParam param = mySearchParamRegistry.getSearchParamByName(resourceDef, theParamName); if (param != null) { Set<String> valueSetUris = Sets.newHashSet(); for (String nextPath : param.getPathsSplit()) { BaseRuntimeChildDefinition def = myContext.newTerser().getDefinition(myResourceType, nextPath); if (def instanceof BaseRuntimeDeclaredChildDefinition) { String valueSet = ((BaseRuntimeDeclaredChildDefinition) def).getBindingValueSet(); if (isNotBlank(valueSet)) { valueSetUris.add(valueSet); } } } if (valueSetUris.size() == 1) { String valueSet = valueSetUris.iterator().next(); List<VersionIndependentConcept> candidateCodes = myTerminologySvc.expandValueSet(valueSet); for (VersionIndependentConcept nextCandidate : candidateCodes) { if (nextCandidate.getCode().equals(code)) { retVal = nextCandidate.getSystem(); break; } } } } } return retVal; }
public static void main(String[] args) { FhirContext ctx = FhirContext.forDstu3(); IGenericClient source = ctx.newRestfulGenericClient("http://localhost:8080/baseDstu3"); IGenericClient target = ctx.newRestfulGenericClient("https://try.smilecdr.com:8000"); for (ResourceReferenceInfo nextRefInfo : ctx.newTerser().getAllResourceReferences(nextQueued)) { String nextRef = nextRefInfo.getResourceReference().getReferenceElement().getValue(); if (isNotBlank(nextRef) && !sent.contains(nextRef)) { missingRef = nextRef;
FhirValidator validator = getContext().newValidator(); if (isNotBlank(theRawResource)) { result = validator.validateWithResult(theRawResource); } else if (theResource != null) { result = validator.validateWithResult(theResource); } else { String msg = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "cantValidateWithNoResource"); throw new InvalidRequestException(msg);
@SuppressWarnings({"unchecked"}) @Override public IOperationUntypedWithInputAndPartialOutput withParameters(IBaseParameters theParameters) { Validate.notNull(theParameters, "theParameters can not be null"); myParameters = theParameters; myParametersDef = myContext.getResourceDefinition(theParameters.getClass()); return this; }
@SuppressWarnings("unchecked") @Override public <T extends IBaseParameters> IOperationUntypedWithInputAndPartialOutput<T> withSearchParameter(Class<T> theParameterType, String theName, IQueryParameterType theValue) { Validate.notNull(theParameterType, "theParameterType must not be null"); Validate.notEmpty(theName, "theName must not be null"); Validate.notNull(theValue, "theValue must not be null"); myParametersDef = myContext.getResourceDefinition(theParameterType); myParameters = (IBaseParameters) myParametersDef.newInstance(); addParam(theName, theValue); return this; }
@Override public <T extends IBaseResource> IReadTyped<T> resource(Class<T> theResourceType) { Validate.notNull(theResourceType, "theResourceType must not be null"); myType = myContext.getResourceDefinition(theResourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theResourceType)); } return this; }