@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; }
@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 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); }
@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 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
@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); }
@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); }
@Read() public Patient readPatient(@IdParam IdType theId) { Patient retVal = new Patient(); // ..populate demographics, contact, or anything else you usually would.. // Populate some tags retVal.getMeta().addTag("http://animals", "Dog", "Canine Patient"); // TODO: more realistic example retVal.getMeta().addTag("http://personality", "Friendly", "Friendly"); // TODO: more realistic example return retVal; } //END SNIPPET: readTags
@Operation(name = JpaConstants.OPERATION_EXPUNGE, idempotent = false, returnParameters = { @OperationParam(name = JpaConstants.OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT, type = IntegerDt.class) }) public Parameters expunge( @IdParam IIdType theIdParam, @OperationParam(name = JpaConstants.OPERATION_EXPUNGE_PARAM_LIMIT) IntegerDt theLimit, @OperationParam(name = JpaConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_DELETED_RESOURCES) BooleanDt theExpungeDeletedResources, @OperationParam(name = JpaConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_PREVIOUS_VERSIONS) BooleanDt theExpungeOldVersions ) { org.hl7.fhir.r4.model.Parameters retVal = super.doExpunge(theIdParam, theLimit, theExpungeDeletedResources, theExpungeOldVersions, null); return JpaSystemProviderDstu2.toExpungeResponse(retVal); }
@Operation(name = OPERATION_META, idempotent = true, returnParameters = { @OperationParam(name = "return", type = MetaDt.class) }) public Parameters meta(@IdParam IdDt theId, RequestDetails theRequestDetails) { Parameters parameters = new Parameters(); MetaDt metaGetOperation = getDao().metaGetOperation(MetaDt.class, theId, theRequestDetails); parameters.addParameter().setName("return").setValue(metaGetOperation); return parameters; }
@Validate public MethodOutcome validate(@ResourceParam T theResource, @IdParam IdType theId, @ResourceParam String theRawResource, @ResourceParam EncodingEnum theEncoding, @Validate.Mode ValidationModeEnum theMode, @Validate.Profile String theProfile, RequestDetails theRequestDetails) { return getDao().validate(theResource, theId, theRawResource, theEncoding, theMode, theProfile, theRequestDetails); }
@Operation(name = OPERATION_META, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters meta(@IdParam IdType theId, RequestDetails theRequestDetails) { Parameters parameters = new Parameters(); Meta metaGetOperation = getDao().metaGetOperation(Meta.class, theId, theRequestDetails); parameters.addParameter().setName("return").setValue(metaGetOperation); return parameters; }
@Operation(name = JpaConstants.OPERATION_TRIGGER_SUBSCRIPTION) public IBaseParameters triggerSubscription( @IdParam IIdType theSubscriptionId, @OperationParam(name = RESOURCE_ID, min = 0, max = OperationParam.MAX_UNLIMITED) List<UriParam> theResourceIds, @OperationParam(name = SEARCH_URL, min = 0, max = OperationParam.MAX_UNLIMITED) List<StringParam> theSearchUrls ) { return mySubscriptionTriggeringSvc.triggerSubscription(theResourceIds, theSearchUrls, theSubscriptionId); }
@Operation(name = "someCustomOperation", idempotent = true, returnParameters = { @OperationParam(name = "return", type = StringDt.class) }) public Parameters someCustomOperation(@IdParam IdDt myId, @OperationParam(name = "dummy") StringDt dummyInput) { Parameters parameters = new Parameters(); parameters.addParameter().setName("return").setValue(new StringDt("My Dummy Result")); return parameters; } // END SNIPPET: jax-rs-provider-operation
@Operation(name = OPERATION_META_ADD, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters metaAdd(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); Meta metaAddOperation = getDao().metaAddOperation(theId, theMeta, theRequestDetails); parameters.addParameter().setName("return").setValue(metaAddOperation); return parameters; }
@Operation(name = OPERATION_META_ADD, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters metaAdd(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); Meta metaAddOperation = getDao().metaAddOperation(theId, theMeta, theRequestDetails); parameters.addParameter().setName("return").setValue(metaAddOperation); return parameters; }