IBaseParameters triggerSubscription(List<UriParam> theResourceIds, List<StringParam> theSearchUrls, @IdParam IIdType theSubscriptionId); }
for (Annotation next : theMethod.getParameterAnnotations()[myIdParamIndex]) { if (next instanceof IdParam) { myCanOperateAtTypeLevel = ((IdParam) next).optional() == true;
for (Annotation next : theMethod.getParameterAnnotations()[myIdParamIndex]) { if (next instanceof IdParam) { myCanOperateAtTypeLevel = ((IdParam) next).optional() == true;
@Search(compartmentName="Condition") public List<IBaseResource> searchCompartment(@IdParam IdType thePatientId) { List<IBaseResource> retVal=new ArrayList<IBaseResource>(); // populate this with resources of any type that are a part of the // "Condition" compartment for the Patient with ID "thePatientId" return retVal; }
/** * The "@Read" annotation indicates that this method supports the * read operation. Read operations should return a single resource * instance. * * @param theId * The read operation takes one parameter, which must be of type * IdDt and must be annotated with the "@Read.IdParam" annotation. * @return * Returns a resource matching this identifier, or null if none exists. */ @Read() public Patient getResourceById(@IdParam IdDt theId);
/** Read a patient from a server by ID */ @Read Patient readPatient(@IdParam IdType theId);
/** Instance level (history of a specific resource instance by type and ID) */ @History(type=Patient.class) Bundle getHistoryPatientInstance(@IdParam IdType theId);
@Update public abstract MethodOutcome updateSomePatient(@IdParam IdType theId, @ResourceParam Patient thePatient); //END SNIPPET: updateClient
@Delete() public void deletePatientConditional(@IdParam IdType theId, @ConditionalUrlParam String theConditionalUrl) { // Only one of theId or theConditionalUrl will have a value depending // on whether the URL receieved was a logical ID, or a conditional // search string if (theId != null) { // do a normal delete } else { // do a conditional delete } // otherwise, delete was successful return; // can also return MethodOutcome } //END SNIPPET: deleteConditional
@History public List<T> historyInstance(@IdParam IIdType theId) { LinkedList<T> retVal = myIdToHistory.get(theId.getIdPart()); if (retVal == null) { throw new ResourceNotFoundException(theId); } return retVal; }
@Read public Patient find(@IdParam final IdType theId) { if (patients.containsKey(theId.getIdPart())) { return patients.get(theId.getIdPart()); } else { throw new ResourceNotFoundException(theId); } }
@Read(version=true) public Patient readOrVread(@IdParam IdType theId) { Patient retVal = new Patient(); if (theId.hasVersionIdPart()) { // this is a vread } else { // this is a read } // ...populate... return retVal; } //END SNIPPET: vread
@Delete() public void deletePatient(@IdParam IdType theId) { // .. Delete the patient .. if (couldntFindThisId) { throw new ResourceNotFoundException("Unknown version"); } if (conflictHappened) { throw new ResourceVersionConflictException("Couldn't delete because [foo]"); } // otherwise, delete was successful return; // can also return MethodOutcome } //END SNIPPET: delete
@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); }
@Read(type = OperationDefinition.class) public OperationDefinition readOperationDefinition(@IdParam IdType theId) { if (theId == null || theId.hasIdPart() == false) { throw new ResourceNotFoundException(theId); } List<OperationMethodBinding> operationBindings = myOperationNameToBindings.get(theId.getIdPart()); if (operationBindings != null && !operationBindings.isEmpty()) { return readOperationDefinitionForOperation(operationBindings); } List<SearchMethodBinding> searchBindings = mySearchNameToBindings.get(theId.getIdPart()); if (searchBindings != null && !searchBindings.isEmpty()) { return readOperationDefinitionForNamedSearch(searchBindings); } throw new ResourceNotFoundException(theId); }
@Operation(name="$everything", idempotent=true) public Bundle patientInstanceOperation( @IdParam IdDt thePatientId, @OperationParam(name="start") DateDt theStart, @OperationParam(name="end") DateDt theEnd) { Bundle retVal = new Bundle(); // Populate bundle with matching resources return retVal; } //END SNIPPET: patientInstanceOperation
@Read public Patient read(RequestDetails theRequestDetails, @IdParam IdType theId) { String tenantId = theRequestDetails.getTenantId(); String resourceId = theId.getIdPart(); // Use these two values to fetch the patient return new Patient(); } }
@Read(version = true) public IBaseResource read(@IdParam IIdType theId) { TreeMap<Long, T> versions = myIdToVersionToResourceMap.get(theId.getIdPart()); if (versions == null || versions.isEmpty()) { throw new ResourceNotFoundException(theId); } T retVal; if (theId.hasVersionIdPart()) { Long versionId = theId.getVersionIdPartAsLong(); if (!versions.containsKey(versionId)) { throw new ResourceNotFoundException(theId); } else { T resource = versions.get(versionId); if (resource == null) { throw new ResourceGoneException(theId); } retVal = resource; } } else { retVal = versions.lastEntry().getValue(); } myReadCount.incrementAndGet(); return retVal; }
@Read(version = true) public T read(HttpServletRequest theRequest, @IdParam IIdType theId, RequestDetails theRequestDetails) { startRequest(theRequest); try { return myDao.read(theId, theRequestDetails); } finally { endRequest(theRequest); } }
@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