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); }
@Create public MethodOutcome create(@ResourceParam T theResource) { long idPart = myNextId++; String idPartAsString = Long.toString(idPart); Long versionIdPart = 1L; IIdType id = store(theResource, idPartAsString, versionIdPart); myCreateCount.incrementAndGet(); return new MethodOutcome() .setCreated(true) .setId(id); }
@Delete public MethodOutcome delete(@IdParam IIdType theId) { TreeMap<Long, T> versions = myIdToVersionToResourceMap.get(theId.getIdPart()); if (versions == null || versions.isEmpty()) { throw new ResourceNotFoundException(theId); } long nextVersion = versions.lastEntry().getKey() + 1L; IIdType id = store(null, theId.getIdPart(), nextVersion); myDeleteCount.incrementAndGet(); return new MethodOutcome() .setId(id); }
/** * @param theConditional This is provided only so that subclasses can implement if they want */ @Update public MethodOutcome update( @ResourceParam T theResource, @ConditionalUrlParam String theConditional) { ValidateUtil.isTrueOrThrowInvalidRequest(isBlank(theConditional), "This server doesn't support conditional update"); String idPartAsString = theResource.getIdElement().getIdPart(); TreeMap<Long, T> versionToResource = getVersionToResource(idPartAsString); Long versionIdPart; boolean created; if (versionToResource.isEmpty()) { versionIdPart = 1L; created = true; } else { versionIdPart = versionToResource.lastKey() + 1L; created = false; } IIdType id = store(theResource, idPartAsString, versionIdPart); myUpdateCount.incrementAndGet(); return new MethodOutcome() .setCreated(created) .setId(id); }
@Update public MethodOutcome updatePatientPrefer( @ResourceParam Patient thePatient, @IdParam IdType theId) { // Save the patient to the database // Update the version and last updated time on the resource IdType updatedId = theId.withVersion("123"); thePatient.setId(updatedId); InstantType lastUpdated = InstantType.withCurrentTime(); thePatient.getMeta().setLastUpdatedElement(lastUpdated); // Add the resource to the outcome, so that it can be returned by the server // if the client requests it MethodOutcome outcome = new MethodOutcome(); outcome.setId(updatedId); outcome.setResource(thePatient); return outcome; } //END SNIPPET: updatePrefer
retVal.setId(new IdType("Patient", "3746", "1"));
retVal.setId(theId.withVersion(newVersion));
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); }
@Create public MethodOutcome create(@ResourceParam T theResource) { long idPart = myNextId++; String idPartAsString = Long.toString(idPart); Long versionIdPart = 1L; IIdType id = store(theResource, idPartAsString, versionIdPart); myCreateCount.incrementAndGet(); return new MethodOutcome() .setCreated(true) .setId(id); }
@Delete public MethodOutcome delete(@IdParam IIdType theId) { TreeMap<Long, T> versions = myIdToVersionToResourceMap.get(theId.getIdPart()); if (versions == null || versions.isEmpty()) { throw new ResourceNotFoundException(theId); } long nextVersion = versions.lastEntry().getKey() + 1L; IIdType id = store(null, theId.getIdPart(), nextVersion); myDeleteCount.incrementAndGet(); return new MethodOutcome() .setId(id); }
/** * @param theConditional This is provided only so that subclasses can implement if they want */ @Update public MethodOutcome update( @ResourceParam T theResource, @ConditionalUrlParam String theConditional) { ValidateUtil.isTrueOrThrowInvalidRequest(isBlank(theConditional), "This server doesn't support conditional update"); String idPartAsString = theResource.getIdElement().getIdPart(); TreeMap<Long, T> versionToResource = getVersionToResource(idPartAsString); Long versionIdPart; boolean created; if (versionToResource.isEmpty()) { versionIdPart = 1L; created = true; } else { versionIdPart = versionToResource.lastKey() + 1L; created = false; } IIdType id = store(theResource, idPartAsString, versionIdPart); myUpdateCount.incrementAndGet(); return new MethodOutcome() .setCreated(created) .setId(id); }