protected String getPreferredId(IBaseResource theResource, String theId) { if (isNotBlank(theId)) { return theId; } return theResource.getIdElement().getIdPart(); }
private void handleUserOperation(RequestDetails theRequest, IBaseResource theResource, RestOperationTypeEnum operation) { applyRulesAndFailIfDeny(operation, theRequest, theResource, theResource.getIdElement(), null); }
public boolean unregisterSubscriptionIfRegistered(IBaseResource theSubscription, String theStatusString) { if (hasSubscription(theSubscription.getIdElement()).isPresent()) { ourLog.info("Removing {} subscription {}", theStatusString, theSubscription.getIdElement().toUnqualified().getValue()); unregisterSubscription(theSubscription.getIdElement()); return true; } return false; }
private boolean matchIdsOr(List<? extends IQueryParameterType> theOrParams, IBaseResource theResource) { if (theResource == null) { return true; } return theOrParams.stream().anyMatch(param -> param instanceof StringParam && matchId(((StringParam)param).getValue(), theResource.getIdElement())); }
public void addContained(IBaseResource theResource) { if (getResourceToIdMap().containsKey(theResource)) { return; } IIdType newId; if (theResource.getIdElement().isLocal()) { newId = theResource.getIdElement(); } else { newId = null; } getResourceToIdMap().put(theResource, newId); getResourceList().add(theResource); }
@Override public IDeleteTyped resource(IBaseResource theResource) { Validate.notNull(theResource, "theResource can not be null"); IIdType id = theResource.getIdElement(); Validate.notNull(id, "theResource.getIdElement() can not be null"); if (id.hasResourceType() == false || id.hasIdPart() == false) { throw new IllegalArgumentException("theResource.getId() must contain a resource type and logical ID at a minimum (e.g. Patient/1234), found: " + id.getValue()); } myId = id; return this; }
/** * Retrieves the ID from the given resource instance */ public static IdType of(IBaseResource theResouce) { if (theResouce == null) { throw new NullPointerException("theResource can not be null"); } else { IIdType retVal = theResouce.getIdElement(); if (retVal == null) { return null; } else if (retVal instanceof IdType) { return (IdType) retVal; } else { return new IdType(retVal.getValue()); } } }
public ActionRequestDetails(RequestDetails theRequestDetails, FhirContext theContext, IBaseResource theResource) { this(theRequestDetails, theContext, theContext.getResourceDefinition(theResource).getName(), theResource.getIdElement()); myResource = theResource; }
private void filterBundle(org.hl7.fhir.dstu3.model.Bundle theBundle) { for (Iterator<BundleEntryComponent> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
private void populateBundleEntryFullUrl(IBaseResource next, BundleEntryComponent entry) { if (next.getIdElement().hasBaseUrl()) { entry.setFullUrl(next.getIdElement().toVersionless().getValue()); } else { if (isNotBlank(myBase) && next.getIdElement().hasIdPart()) { IIdType id = next.getIdElement().toVersionless(); id = id.withServerBase(myBase, myContext.getResourceDefinition(next).getName()); entry.setFullUrl(id.getValue()); } } }
private void filterBundle(ca.uhn.fhir.model.dstu2.resource.Bundle theBundle) { for (Iterator<Entry> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
private void filterBundle(org.hl7.fhir.r4.model.Bundle theBundle) { for (Iterator<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
private IIdType populateBundleEntryFullUrl(IBaseResource next, BundleEntryComponent entry) { IIdType idElement = null; if (next.getIdElement().hasBaseUrl()) { idElement = next.getIdElement(); entry.setFullUrl(idElement.toVersionless().getValue()); } else { if (isNotBlank(myBase) && next.getIdElement().hasIdPart()) { idElement = next.getIdElement(); idElement = idElement.withServerBase(myBase, myContext.getResourceDefinition(next).getName()); entry.setFullUrl(idElement.toVersionless().getValue()); } } return idElement; }
private IIdType populateBundleEntryFullUrl(IBaseResource next, BundleEntryComponent entry) { IIdType idElement = null; if (next.getIdElement().hasBaseUrl()) { idElement = next.getIdElement(); entry.setFullUrl(idElement.toVersionless().getValue()); } else { if (isNotBlank(myBase) && next.getIdElement().hasIdPart()) { idElement = next.getIdElement(); idElement = idElement.withServerBase(myBase, myContext.getResourceDefinition(next).getName()); entry.setFullUrl(idElement.toVersionless().getValue()); } } return idElement; }
public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) { this(); setId(theResource.getIdElement()); setOperationType(theOperationType); if (theOperationType != OperationTypeEnum.DELETE) { setNewPayload(theFhirContext, theResource); } }
public void setPayload(FhirContext theCtx, IBaseResource thePayload) { myPayload = thePayload; myPayloadString = theCtx.newJsonParser().encodeResourceToString(thePayload); myPayloadId = thePayload.getIdElement().toUnqualified().getValue(); }
public ActionRequestDetails(RequestDetails theRequestDetails, IBaseResource theResource) { this(theRequestDetails, theRequestDetails.getServer().getFhirContext().getResourceDefinition(theResource).getName(), theResource.getIdElement()); myResource = theResource; }
void incrementId(T theResource, ResourceTable theSavedEntity, IIdType theResourceId) { String newVersion; long newVersionLong; if (theResourceId == null || theResourceId.getVersionIdPart() == null) { newVersion = "1"; newVersionLong = 1; } else { newVersionLong = theResourceId.getVersionIdPartAsLong() + 1; newVersion = Long.toString(newVersionLong); } IIdType newId = theResourceId.withVersion(newVersion); theResource.getIdElement().setValue(newId.getValue()); theSavedEntity.setVersion(newVersionLong); }
@Override public DaoMethodOutcome create(T theResource, String theIfNoneExist, boolean thePerformIndexing, Date theUpdateTimestamp, RequestDetails theRequestDetails) { if (isNotBlank(theResource.getIdElement().getIdPart())) { if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getIdElement().getIdPart()); throw new InvalidRequestException(message, createErrorOperationOutcome(message, "processing")); } else { // As of DSTU3, ID and version in the body should be ignored for a create/update theResource.setId(""); } } if (myDaoConfig.getResourceServerIdStrategy() == DaoConfig.IdStrategyEnum.UUID) { theResource.setId(UUID.randomUUID().toString()); } return doCreate(theResource, theIfNoneExist, thePerformIndexing, theUpdateTimestamp, theRequestDetails); }
public static BaseHttpClientInvocation createValidateInvocation(FhirContext theContext, IBaseResource theResource) { IBaseParameters parameters = (IBaseParameters) theContext.getResourceDefinition("Parameters").newInstance(); ParametersUtil.addParameterToParameters(theContext, parameters, "resource", theResource); String resourceName = theContext.getResourceDefinition(theResource).getName(); String resourceId = theResource.getIdElement().getIdPart(); BaseHttpClientInvocation retVal = createOperationInvocation(theContext, resourceName, resourceId, null,Constants.EXTOP_VALIDATE, parameters, false); return retVal; }