Cleanup $everything for Patient and Encounter in JPA
This commit is contained in:
parent
d5b99c2c10
commit
75e9b711a5
|
@ -24,6 +24,8 @@ import java.util.Date;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sourceforge.cobertura.CoverageIgnore;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -48,6 +50,7 @@ public abstract class BaseJpaResourceProvider<T extends IResource> extends BaseJ
|
|||
// nothing
|
||||
}
|
||||
|
||||
@CoverageIgnore
|
||||
public BaseJpaResourceProvider(IFhirResourceDao<T> theDao) {
|
||||
myDao = theDao;
|
||||
}
|
||||
|
|
|
@ -22,18 +22,43 @@ package ca.uhn.fhir.jpa.provider;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Encounter;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
|
||||
public class BaseJpaResourceProviderEncounterDstu2 extends JpaResourceProviderDstu2<Encounter> {
|
||||
|
||||
|
||||
@Operation(name="everything", idempotent=true)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider everything(
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
@IdParam ca.uhn.fhir.model.primitive.IdDt theId,
|
||||
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name="_count") ca.uhn.fhir.model.primitive.UnsignedIntDt theCount
|
||||
){
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
}
|
||||
|
||||
paramMap.setRevIncludes(Collections.singleton(new Include("*")));
|
||||
paramMap.setIncludes(Collections.singleton(new Include("*")));
|
||||
paramMap.add("_id", new StringParam(theId.getIdPart()));
|
||||
ca.uhn.fhir.rest.server.IBundleProvider retVal = getDao().search(paramMap);
|
||||
return retVal;
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,24 +22,32 @@ package ca.uhn.fhir.jpa.provider;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
|
||||
public class BaseJpaResourceProviderPatientDstu2 extends JpaResourceProviderDstu2<Patient> {
|
||||
|
||||
@Operation(name="$everything", idempotent=true)
|
||||
public IBundleProvider everything(HttpServletRequest theServletRequest, @IdParam IdDt theId) {
|
||||
@Operation(name = "everything", idempotent = true)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider everything(
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
@IdParam ca.uhn.fhir.model.primitive.IdDt theId,
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name = "_count")
|
||||
ca.uhn.fhir.model.primitive.UnsignedIntDt theCount) {
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
}
|
||||
|
||||
paramMap.setRevIncludes(Collections.singleton(new Include("*")));
|
||||
paramMap.setIncludes(Collections.singleton(new Include("*")));
|
||||
paramMap.add("_id", new StringParam(theId.getIdPart()));
|
||||
|
@ -48,6 +56,7 @@ public class BaseJpaResourceProviderPatientDstu2 extends JpaResourceProviderDstu
|
|||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,13 @@ import ca.uhn.fhir.model.dstu.resource.Binary;
|
|||
// import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
// import ca.uhn.fhir.model.api.Bundle;
|
||||
|
||||
public class ${className}ResourceProvider extends JpaResourceProvider${versionCapitalized}<${className}> {
|
||||
public class ${className}ResourceProvider extends
|
||||
#if ( $version != 'dstu' && (${className} == 'Patient' || ${className} == 'Encounter') )
|
||||
BaseJpaResourceProvider${className}${versionCapitalized}<${className}>
|
||||
#else
|
||||
JpaResourceProvider${versionCapitalized}<${className}>
|
||||
#end
|
||||
{
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
|
@ -121,35 +127,4 @@ public class ${className}ResourceProvider extends JpaResourceProvider${versionCa
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if ( $version != 'dstu' && (${className} == 'Patient' || ${className} == 'Encounter') )
|
||||
@Operation(name="everything", idempotent=true)
|
||||
public ca.uhn.fhir.rest.server.IBundleProvider everything(
|
||||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
@IdParam ca.uhn.fhir.model.primitive.IdDt theId,
|
||||
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name="_count") ca.uhn.fhir.model.primitive.UnsignedIntDt theCount
|
||||
){
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
}
|
||||
|
||||
paramMap.setRevIncludes(Collections.singleton(new Include("*")));
|
||||
paramMap.setIncludes(Collections.singleton(new Include("*")));
|
||||
paramMap.add("_id", new StringParam(theId.getIdPart()));
|
||||
ca.uhn.fhir.rest.server.IBundleProvider retVal = getDao().search(paramMap);
|
||||
return retVal;
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue