/** * 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);
@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
@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); }
@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); } }
@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 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
@Read public Patient read(@IdParam IdDt theId) { if (databaseIsDown) { OperationOutcome oo = new OperationOutcome(); oo.addIssue().setSeverity(IssueSeverityEnum.FATAL).setDetails("Database is down"); throw new InternalErrorException("Database is down", oo); } Patient patient = new Patient(); // populate this return patient; } //END SNIPPET: returnOO
/** * 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) { Patient patient = new Patient(); patient.addIdentifier(); patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns")); patient.getIdentifier().get(0).setValue("00002"); patient.addName().addFamily("Test"); patient.getName().get(0).addGiven("PatientOne"); patient.setGender(AdministrativeGenderEnum.FEMALE); return patient; }
/** * The "@Read" annotation indicates that this method supports the * read operation. It takes one argument, the Resource type being returned. * * @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) { Patient patient = new Patient(); patient.addIdentifier(); patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns")); patient.getIdentifier().get(0).setValue("00002"); patient.addName().addFamily("Test"); patient.getName().get(0).addGiven("PatientOne"); patient.setGender(AdministrativeGenderEnum.FEMALE); return patient; }
@Read() public Patient getResourceById(@IdParam IdType theId) { Patient retVal = new Patient(); // ...populate... retVal.addIdentifier().setSystem("urn:mrns").setValue("12345"); retVal.addName().setFamily("Smith").addGiven("Tester").addGiven("Q"); // ...etc... // if you know the version ID of the resource, you should set it and HAPI will // include it in a Content-Location header retVal.setId(new IdType("Patient", "123", "2")); return retVal; } //END SNIPPET: read
@Read(type = OperationDefinition.class) public OperationDefinition readOperationDefinition(@IdParam IdType theId) { if (theId == null || theId.hasIdPart() == false) {
@Read(type = OperationDefinition.class) public OperationDefinition readOperationDefinition(@IdParam IdType theId) { if (theId == null || theId.hasIdPart() == false) {
@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 IdDt theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; } String serverBase = getServerBase(theRequest); return (StructureDefinition) retVal.toProfile(serverBase); }