@Update public MethodOutcome update(@IdParam IdType theId, @ResourceParam Patient thePatient) { String resourceId = theId.getIdPart(); String versionId = theId.getVersionIdPart(); // this will contain the ETag String currentVersion = "1"; // populate this with the current version if (!versionId.equals(currentVersion)) { throw new ResourceVersionConflictException("Expected version " + currentVersion); } // ... perform the update ... return new MethodOutcome(); } //END SNIPPET: updateEtag
@Override protected void createOrUpdateValueSet(org.hl7.fhir.r4.model.ValueSet theValueSet) { ValueSet valueSetDstu3; try { valueSetDstu3 = VersionConvertor_30_40.convertValueSet(theValueSet); } catch (FHIRException e) { throw new InternalErrorException(e); } if (isBlank(valueSetDstu3.getIdElement().getIdPart())) { String matchUrl = "ValueSet?url=" + UrlUtil.escapeUrlParam(theValueSet.getUrl()); myValueSetResourceDao.update(valueSetDstu3, matchUrl); } else { myValueSetResourceDao.update(valueSetDstu3); } }
@Override protected void createOrUpdateConceptMap(org.hl7.fhir.r4.model.ConceptMap theConceptMap) { ConceptMap resourceToStore; try { resourceToStore = VersionConvertor_30_40.convertConceptMap(theConceptMap); } catch (FHIRException e) { throw new InternalErrorException(e); } if (isBlank(resourceToStore.getIdElement().getIdPart())) { String matchUrl = "ConceptMap?url=" + UrlUtil.escapeUrlParam(theConceptMap.getUrl()); myConceptMapResourceDao.update(resourceToStore, matchUrl); } else { myConceptMapResourceDao.update(resourceToStore); } }
@Override protected IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource) { CodeSystem resourceToStore; try { resourceToStore = VersionConvertor_30_40.convertCodeSystem(theCodeSystemResource); } catch (FHIRException e) { throw new InternalErrorException(e); } if (isBlank(resourceToStore.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(resourceToStore, matchUrl).getId(); } else { return myCodeSystemResourceDao.update(resourceToStore).getId(); } }
iterator.remove(); } else { IdDt resourceId = new IdDt(next.getResource().getResourceType() + "/EX" + next.getResource().getIdElement().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); for (Iterator<BundleEntryComponent> iterator = bundle.getEntry().iterator(); iterator.hasNext(); ) { BundleEntryComponent next = iterator.next(); if (next.getResource().getIdElement().getIdPart() != null) { String nextId = next.getResource().getIdElement().getValue(); next.getRequest().setMethod(HTTPVerb.PUT);
private static void copy(FhirContext theCtx, IGenericClient theTarget, String theResType, List<IBaseResource> theQueued, Set<String> theSent, Bundle theReceived) { for (Bundle.BundleEntryComponent nextEntry : theReceived.getEntry()) { Resource nextResource = nextEntry.getResource(); nextResource.setId(theResType + "/" + "CR-" + nextResource.getIdElement().getIdPart()); boolean haveUnsentReference = false; for (ResourceReferenceInfo nextRefInfo : theCtx.newTerser().getAllResourceReferences(nextResource)) { IIdType nextRef = nextRefInfo.getResourceReference().getReferenceElement(); if (nextRef.hasIdPart()) { String newRef = nextRef.getResourceType() + "/" + "CR-" + nextRef.getIdPart(); ourLog.info("Changing reference {} to {}", nextRef.getValue(), newRef); nextRefInfo.getResourceReference().setReference(newRef); if (!theSent.contains(newRef)) { haveUnsentReference = true; } } } if (haveUnsentReference) { ourLog.info("Queueing {} for delivery after", nextResource.getId()); theQueued.add(nextResource); continue; } IIdType newId = theTarget .update() .resource(nextResource) .execute() .getId(); ourLog.info("Copied resource {} and got ID {}", nextResource.getId(), newId); theSent.add(nextResource.getIdElement().toUnqualifiedVersionless().getValue()); } }
org.hl7.fhir.dstu3.model.Resource next = i.getResource(); if (next.getIdElement().isIdPartValidLong()) { next.setIdElement(new IdType("v2-" + next.getIdElement().getIdPart()));
@Override public boolean hasIdPart() { return isNotBlank(getIdPart()); }
SearchParameterMap params = new SearchParameterMap(); params.setLoadSynchronousUpTo(1); params.add(IAnyResource.SP_RES_ID, new StringParam(id.getIdPart())); search = myQuestionnaireDao.search(params); } else if ("CodeSystem".equals(resourceName)) {
protected void createSubscription(Class<? extends IBaseResource> clazz) { String resourceName = clazz.getSimpleName(); String id = patient.getIdElement().getIdPart(); String criteria = resourceName + "?subject=" + id; SubscriptionWrapper wrapper = subscriptionManager.subscribe(criteria, subscriptionListener); if (wrapper != null) { subscriptions.add(wrapper); } }
/** * Sets the default location to the specified value. This value is stored in the * LOCATION.DEFAULT property. * * @param location The location. */ public static void setDefaultLocation(Location location) { PropertyUtil.saveValue(PROPERTY_DEFAULT_LOCATION, null, false, location.getIdElement().getIdPart()); }
public static SpecialElement fromProperty(Property property) { if (property.getStructure().getIdElement().getIdPart().equals("Parameters")) return PARAMETER; if (property.getStructure().getIdElement().getIdPart().equals("Bundle") && property.getName().equals("resource")) return BUNDLE_ENTRY; if (property.getStructure().getIdElement().getIdPart().equals("Bundle") && property.getName().equals("outcome")) return BUNDLE_OUTCOME; if (property.getName().equals("contained")) return CONTAINED; throw new Error("Unknown resource containing a native resource: "+property.getDefinition().getId()); } }
@Read() public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; } String serverBase = getServerBase(theRequest); return (StructureDefinition) retVal.toProfile(serverBase); }
@Override public IdType withResourceType(String theResourceName) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theResourceName, getIdPart(), getVersionIdPart()); }
@Override public IdType toUnqualifiedVersionless() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart()); }
/** * Returns a new IdType containing this IdType's values but with no server * base URL if one is present in this IdType. For example, if this IdType * contains the ID "http://foo/Patient/1", this method will return a new * IdType containing ID "Patient/1". */ @Override public IdType toUnqualified() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart(), getVersionIdPart()); }
@Override public IdType toVersionless() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getBaseUrl(), getResourceType(), getIdPart(), null); }
@Test public void testSendIti66WithPatientReference() { Bundle result = sendManually(manifestPatientReferenceParameter()); assertEquals(Bundle.BundleType.SEARCHSET, result.getType()); assertEquals(ResourceType.Bundle, result.getResourceType()); assertEquals(1, result.getTotal()); DocumentManifest p = (DocumentManifest) result.getEntry().get(0).getResource(); assertEquals("9bc72458-49b0-11e6-8a1c-3c1620524153", p.getIdElement().getIdPart()); }
@Test public void testSendIti67WithPatientReference() { Bundle result = sendManually(referencePatientReferenceParameter()); assertEquals(Bundle.BundleType.SEARCHSET, result.getType()); assertEquals(ResourceType.Bundle, result.getResourceType()); assertEquals(1, result.getTotal()); DocumentReference p = (DocumentReference) result.getEntry().get(0).getResource(); assertEquals("63ab1c29-4225-11e6-9b33-0050569b0094", p.getIdElement().getIdPart()); }