Move PreferReturnEnum back to original location to avoid regressions
This commit is contained in:
parent
6fde2879ef
commit
eddb98084d
|
@ -8,7 +8,7 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -246,7 +246,7 @@ public class GenericClientDstu3IT {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
assertNotNull(outcome.getResource());
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PreferHeader {
|
||||
|
||||
|
@ -27,35 +26,4 @@ public class PreferHeader {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents values for "return" value as provided in the the <a href="https://tools.ietf.org/html/rfc7240#section-4.2">HTTP Prefer header</a>.
|
||||
*/
|
||||
public enum PreferReturnEnum {
|
||||
|
||||
REPRESENTATION("representation"), MINIMAL("minimal"), OPERATION_OUTCOME("OperationOutcome");
|
||||
|
||||
private static HashMap<String, PreferReturnEnum> ourValues;
|
||||
private String myHeaderValue;
|
||||
|
||||
PreferReturnEnum(String theHeaderValue) {
|
||||
myHeaderValue = theHeaderValue;
|
||||
}
|
||||
|
||||
public String getHeaderValue() {
|
||||
return myHeaderValue;
|
||||
}
|
||||
|
||||
public static PreferReturnEnum fromHeaderValue(String theHeaderValue) {
|
||||
if (ourValues == null) {
|
||||
HashMap<String, PreferReturnEnum> values = new HashMap<>();
|
||||
for (PreferReturnEnum next : PreferReturnEnum.values()) {
|
||||
values.put(next.getHeaderValue(), next);
|
||||
}
|
||||
ourValues = values;
|
||||
}
|
||||
return ourValues.get(theHeaderValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Represents values for "return" value as provided in the the <a href="https://tools.ietf.org/html/rfc7240#section-4.2">HTTP Prefer header</a>.
|
||||
*/
|
||||
public enum PreferReturnEnum {
|
||||
|
||||
REPRESENTATION("representation"), MINIMAL("minimal"), OPERATION_OUTCOME("OperationOutcome");
|
||||
|
||||
private static HashMap<String, PreferReturnEnum> ourValues;
|
||||
private String myHeaderValue;
|
||||
|
||||
PreferReturnEnum(String theHeaderValue) {
|
||||
myHeaderValue = theHeaderValue;
|
||||
}
|
||||
|
||||
public String getHeaderValue() {
|
||||
return myHeaderValue;
|
||||
}
|
||||
|
||||
public static PreferReturnEnum fromHeaderValue(String theHeaderValue) {
|
||||
if (ourValues == null) {
|
||||
HashMap<String, PreferReturnEnum> values = new HashMap<>();
|
||||
for (PreferReturnEnum next : PreferReturnEnum.values()) {
|
||||
values.put(next.getHeaderValue(), next);
|
||||
}
|
||||
ourValues = values;
|
||||
}
|
||||
return ourValues.get(theHeaderValue);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
|
||||
public interface ICreateTyped extends IClientExecutable<ICreateTyped, MethodOutcome> {
|
||||
|
||||
|
@ -47,6 +47,6 @@ public interface ICreateTyped extends IClientExecutable<ICreateTyped, MethodOutc
|
|||
*
|
||||
* @since HAPI 1.1
|
||||
*/
|
||||
ICreateTyped prefer(PreferHeader.PreferReturnEnum theReturn);
|
||||
ICreateTyped prefer(PreferReturnEnum theReturn);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
|
||||
public interface IPatchExecutable extends IClientExecutable<IPatchExecutable, MethodOutcome>{
|
||||
|
||||
|
@ -32,6 +32,6 @@ public interface IPatchExecutable extends IClientExecutable<IPatchExecutable, Me
|
|||
*
|
||||
* @since HAPI 1.1
|
||||
*/
|
||||
IPatchExecutable prefer(PreferHeader.PreferReturnEnum theReturn);
|
||||
IPatchExecutable prefer(PreferReturnEnum theReturn);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
|
||||
public interface IUpdateExecutable extends IClientExecutable<IUpdateExecutable, MethodOutcome>{
|
||||
|
||||
|
@ -32,6 +32,6 @@ public interface IUpdateExecutable extends IClientExecutable<IUpdateExecutable,
|
|||
*
|
||||
* @since HAPI 1.1
|
||||
*/
|
||||
IUpdateExecutable prefer(PreferHeader.PreferReturnEnum theReturn);
|
||||
IUpdateExecutable prefer(PreferReturnEnum theReturn);
|
||||
|
||||
}
|
||||
|
|
|
@ -364,11 +364,11 @@ public class GenericOkHttpClientDstu2Test {
|
|||
Patient p = new Patient();
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
}
|
||||
|
@ -1745,11 +1745,11 @@ public class GenericOkHttpClientDstu2Test {
|
|||
p.setId(new IdDt("1"));
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
}
|
||||
|
|
|
@ -533,7 +533,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
private class CreateInternal extends BaseSearch<ICreateTyped, ICreateWithQueryTyped, MethodOutcome> implements ICreate, ICreateTyped, ICreateWithQuery, ICreateWithQueryTyped {
|
||||
|
||||
private boolean myConditional;
|
||||
private PreferHeader.PreferReturnEnum myPrefer;
|
||||
private PreferReturnEnum myPrefer;
|
||||
private IBaseResource myResource;
|
||||
private String myResourceBody;
|
||||
private String mySearchUrl;
|
||||
|
@ -580,7 +580,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ICreateTyped prefer(PreferHeader.PreferReturnEnum theReturn) {
|
||||
public ICreateTyped prefer(PreferReturnEnum theReturn) {
|
||||
myPrefer = theReturn;
|
||||
return this;
|
||||
}
|
||||
|
@ -1380,13 +1380,13 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
|
||||
private final class OutcomeResponseHandler implements IClientResponseHandler<MethodOutcome> {
|
||||
private PreferHeader.PreferReturnEnum myPrefer;
|
||||
private PreferReturnEnum myPrefer;
|
||||
|
||||
private OutcomeResponseHandler() {
|
||||
super();
|
||||
}
|
||||
|
||||
private OutcomeResponseHandler(PreferHeader.PreferReturnEnum thePrefer) {
|
||||
private OutcomeResponseHandler(PreferReturnEnum thePrefer) {
|
||||
this();
|
||||
myPrefer = thePrefer;
|
||||
}
|
||||
|
@ -1396,7 +1396,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
MethodOutcome response = MethodUtil.process2xxResponse(myContext, theResponseStatusCode, theResponseMimeType, theResponseInputStream, theHeaders);
|
||||
response.setCreatedUsingStatusCode(theResponseStatusCode);
|
||||
|
||||
if (myPrefer == PreferHeader.PreferReturnEnum.REPRESENTATION) {
|
||||
if (myPrefer == PreferReturnEnum.REPRESENTATION) {
|
||||
if (response.getResource() == null) {
|
||||
if (response.getId() != null && isNotBlank(response.getId().getValue()) && response.getId().hasBaseUrl()) {
|
||||
ourLog.info("Server did not return resource for Prefer-representation, going to fetch: {}", response.getId().getValue());
|
||||
|
@ -1418,7 +1418,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
private IIdType myId;
|
||||
private String myPatchBody;
|
||||
private PatchTypeEnum myPatchType;
|
||||
private PreferHeader.PreferReturnEnum myPrefer;
|
||||
private PreferReturnEnum myPrefer;
|
||||
private String myResourceType;
|
||||
private String mySearchUrl;
|
||||
|
||||
|
@ -1476,7 +1476,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IPatchExecutable prefer(PreferHeader.PreferReturnEnum theReturn) {
|
||||
public IPatchExecutable prefer(PreferReturnEnum theReturn) {
|
||||
myPrefer = theReturn;
|
||||
return this;
|
||||
}
|
||||
|
@ -2048,7 +2048,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
private boolean myConditional;
|
||||
private IIdType myId;
|
||||
private PreferHeader.PreferReturnEnum myPrefer;
|
||||
private PreferReturnEnum myPrefer;
|
||||
private IBaseResource myResource;
|
||||
private String myResourceBody;
|
||||
private String mySearchUrl;
|
||||
|
@ -2102,7 +2102,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IUpdateExecutable prefer(PreferHeader.PreferReturnEnum theReturn) {
|
||||
public IUpdateExecutable prefer(PreferReturnEnum theReturn) {
|
||||
myPrefer = theReturn;
|
||||
return this;
|
||||
}
|
||||
|
@ -2282,7 +2282,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
params.get(parameterName).add(parameterValue);
|
||||
}
|
||||
|
||||
private static void addPreferHeader(PreferHeader.PreferReturnEnum thePrefer, BaseHttpClientInvocation theInvocation) {
|
||||
private static void addPreferHeader(PreferReturnEnum thePrefer, BaseHttpClientInvocation theInvocation) {
|
||||
if (thePrefer != null) {
|
||||
theInvocation.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RETURN + '=' + thePrefer.getHeaderValue());
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ public abstract class AbstractJaxRsPageProvider extends AbstractJaxRsProvider im
|
|||
}
|
||||
|
||||
@Override
|
||||
public PreferHeader.PreferReturnEnum getDefaultPreferReturn() {
|
||||
return PreferHeader.PreferReturnEnum.REPRESENTATION;
|
||||
public PreferReturnEnum getDefaultPreferReturn() {
|
||||
return PreferReturnEnum.REPRESENTATION;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -370,8 +370,8 @@ implements IRestfulServer<JaxRsRequest>, IResourceProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PreferHeader.PreferReturnEnum getDefaultPreferReturn() {
|
||||
return PreferHeader.PreferReturnEnum.REPRESENTATION;
|
||||
public PreferReturnEnum getDefaultPreferReturn() {
|
||||
return PreferReturnEnum.REPRESENTATION;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -301,12 +301,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
Patient p = new Patient();
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
@ -1937,12 +1937,12 @@ public class GenericJaxRsClientDstu2Test {
|
|||
p.setId(new IdDt("1"));
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
|
|
@ -321,12 +321,12 @@ public class GenericJaxRsClientDstu3Test {
|
|||
Patient p = new Patient();
|
||||
p.addName().setFamily("FOOFAMILY");
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
@ -1990,12 +1990,12 @@ public class GenericJaxRsClientDstu3Test {
|
|||
p.setId(new IdType("1"));
|
||||
p.addName().setFamily("FOOFAMILY");
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue());
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
client.setEncoding(EncodingEnum.JSON);
|
||||
|
||||
MethodOutcome response = client.create().resource(toCreate).conditional()
|
||||
.where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
.where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals("myIdentifier", patientCaptor.getValue().getIdentifier().get(0).getValue());
|
||||
IBaseResource resource = response.getResource();
|
||||
|
@ -158,7 +158,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
|
||||
when(mock.create(patientCaptor.capture(), isNull(String.class))).thenReturn(outcome);
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.execute();
|
||||
IBaseResource resource = response.getResource();
|
||||
compareResultId(1, resource);
|
||||
|
|
|
@ -131,7 +131,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
client.setEncoding(EncodingEnum.JSON);
|
||||
|
||||
MethodOutcome response = client.create().resource(toCreate).conditional()
|
||||
.where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
.where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals("myIdentifier", patientCaptor.getValue().getIdentifierFirstRep().getValue());
|
||||
IResource resource = (IResource) response.getResource();
|
||||
|
@ -154,7 +154,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
|
||||
when(mock.create(patientCaptor.capture(), isNull(String.class))).thenReturn(outcome);
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.execute();
|
||||
IResource resource = (IResource) response.getResource();
|
||||
compareResultId(1, resource);
|
||||
|
|
|
@ -138,7 +138,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
existing.setId((IdType) null);
|
||||
existing.getName().add(new HumanName().setFamily("Created Patient 54"));
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
System.out.println(patient);
|
||||
|
@ -154,7 +154,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
existing.setId((IdType) null);
|
||||
existing.getName().add(new HumanName().setFamily("Created Patient 54"));
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
|
||||
|
@ -187,7 +187,7 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
public void testDeletePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.getName().add(new HumanName().setFamily("Created Patient XYZ"));
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
client.delete().resourceById(patient.getIdElement()).execute();
|
||||
|
|
|
@ -5,10 +5,7 @@ import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
|||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
|
@ -152,7 +149,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().setFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
System.out.println(patient);
|
||||
|
@ -167,7 +164,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().setFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
|
||||
|
@ -199,7 +196,7 @@ public class JaxRsPatientProviderR4Test {
|
|||
public void testDeletePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.getNameFirstRep().setFamily("Created Patient XYZ");
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
client.delete().resource(patient).execute();
|
||||
|
|
|
@ -149,7 +149,7 @@ public class JaxRsPatientProviderTest {
|
|||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().addFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
System.out.println(patient);
|
||||
|
@ -164,7 +164,7 @@ public class JaxRsPatientProviderTest {
|
|||
existing.setId((IdDt) null);
|
||||
existing.getNameFirstRep().addFamily("Created Patient 54");
|
||||
client.setEncoding(EncodingEnum.XML);
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class JaxRsPatientProviderTest {
|
|||
public void testDeletePatient() {
|
||||
final Patient existing = new Patient();
|
||||
existing.getNameFirstRep().addFamily("Created Patient XYZ");
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
System.out.println(results.getId());
|
||||
final Patient patient = (Patient) results.getResource();
|
||||
client.delete().resourceById(patient.getId()).execute();
|
||||
|
|
|
@ -64,7 +64,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
@ -185,9 +184,9 @@ public class TransactionProcessor<BUNDLE extends IBaseBundle, BUNDLEENTRY> {
|
|||
if (theRequestDetails != null) {
|
||||
if (outcome.getResource() != null) {
|
||||
String prefer = theRequestDetails.getHeader(Constants.HEADER_PREFER);
|
||||
PreferHeader.PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(null, prefer).getReturn();
|
||||
PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(null, prefer).getReturn();
|
||||
if (preferReturn != null) {
|
||||
if (preferReturn == PreferHeader.PreferReturnEnum.REPRESENTATION) {
|
||||
if (preferReturn == PreferReturnEnum.REPRESENTATION) {
|
||||
outcome.fireResourceViewCallbacks();
|
||||
myVersionAdapter.setResource(newEntry, outcome.getResource());
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import ca.uhn.fhir.jpa.config.BaseConfig;
|
|||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
|
@ -349,7 +349,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
|
|||
|
||||
Patient patient = new Patient();
|
||||
patient.setActive(true);
|
||||
IIdType id = ourClient.create().resource(patient).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute().getId().toUnqualifiedVersionless();
|
||||
IIdType id = ourClient.create().resource(patient).prefer(PreferReturnEnum.REPRESENTATION).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
DelegatingConsentService consentService = new DelegatingConsentService();
|
||||
myConsentInterceptor = new ConsentInterceptor(consentService, IConsentContextServices.NULL_IMPL);
|
||||
|
|
|
@ -683,7 +683,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.create()
|
||||
.resource(p)
|
||||
.conditionalByUrl("Patient?identifier=foo|bar")
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.execute();
|
||||
|
||||
assertEquals(id.getIdPart(), outcome.getId().getIdPart());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ca.uhn.fhir.rest.api.server;
|
||||
|
||||
import ca.uhn.fhir.context.api.BundleInclusionRule;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.server.IPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
||||
|
||||
|
@ -31,6 +31,6 @@ public interface IRestfulServer<T extends RequestDetails> extends IRestfulServer
|
|||
|
||||
BundleInclusionRule getBundleInclusionRule();
|
||||
|
||||
PreferHeader.PreferReturnEnum getDefaultPreferReturn();
|
||||
PreferReturnEnum getDefaultPreferReturn();
|
||||
|
||||
}
|
||||
|
|
|
@ -98,9 +98,9 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
*/
|
||||
public static final String SERVLET_CONTEXT_ATTRIBUTE = "ca.uhn.fhir.rest.server.RestfulServer.servlet_context";
|
||||
/**
|
||||
* Default value for {@link #setDefaultPreferReturn(PreferHeader.PreferReturnEnum)}
|
||||
* Default value for {@link #setDefaultPreferReturn(PreferReturnEnum)}
|
||||
*/
|
||||
public static final PreferHeader.PreferReturnEnum DEFAULT_PREFER_RETURN = PreferHeader.PreferReturnEnum.REPRESENTATION;
|
||||
public static final PreferReturnEnum DEFAULT_PREFER_RETURN = PreferReturnEnum.REPRESENTATION;
|
||||
private static final ExceptionHandlingInterceptor DEFAULT_EXCEPTION_HANDLER = new ExceptionHandlingInterceptor();
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(RestfulServer.class);
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -131,7 +131,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
private boolean myStarted;
|
||||
private boolean myUncompressIncomingContents = true;
|
||||
private ITenantIdentificationStrategy myTenantIdentificationStrategy;
|
||||
private PreferHeader.PreferReturnEnum myDefaultPreferReturn = DEFAULT_PREFER_RETURN;
|
||||
private PreferReturnEnum myDefaultPreferReturn = DEFAULT_PREFER_RETURN;
|
||||
private ElementsSupportEnum myElementsSupport = ElementsSupportEnum.EXTENDED;
|
||||
|
||||
/**
|
||||
|
@ -1770,13 +1770,13 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
* <code>Prefer</code> header.
|
||||
* <p>
|
||||
* This setting changes the default behaviour if no Prefer header is supplied by the client.
|
||||
* The default is {@link PreferHeader.PreferReturnEnum#REPRESENTATION}
|
||||
* The default is {@link PreferReturnEnum#REPRESENTATION}
|
||||
* </p>
|
||||
*
|
||||
* @see <a href="http://hl7.org/fhir/http.html#ops">HL7 FHIR Specification</a> section on the Prefer header
|
||||
*/
|
||||
@Override
|
||||
public PreferHeader.PreferReturnEnum getDefaultPreferReturn() {
|
||||
public PreferReturnEnum getDefaultPreferReturn() {
|
||||
return myDefaultPreferReturn;
|
||||
}
|
||||
|
||||
|
@ -1786,12 +1786,12 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
* <code>Prefer</code> header.
|
||||
* <p>
|
||||
* This setting changes the default behaviour if no Prefer header is supplied by the client.
|
||||
* The default is {@link PreferHeader.PreferReturnEnum#REPRESENTATION}
|
||||
* The default is {@link PreferReturnEnum#REPRESENTATION}
|
||||
* </p>
|
||||
*
|
||||
* @see <a href="http://hl7.org/fhir/http.html#ops">HL7 FHIR Specification</a> section on the Prefer header
|
||||
*/
|
||||
public void setDefaultPreferReturn(PreferHeader.PreferReturnEnum theDefaultPreferReturn) {
|
||||
public void setDefaultPreferReturn(PreferReturnEnum theDefaultPreferReturn) {
|
||||
Validate.notNull(theDefaultPreferReturn, "theDefaultPreferReturn must not be null");
|
||||
myDefaultPreferReturn = theDefaultPreferReturn;
|
||||
}
|
||||
|
|
|
@ -704,7 +704,7 @@ public class RestfulServerUtils {
|
|||
value = value.substring(1, value.length() - 1);
|
||||
}
|
||||
|
||||
retVal.setReturn(PreferHeader.PreferReturnEnum.fromHeaderValue(value));
|
||||
retVal.setReturn(PreferReturnEnum.fromHeaderValue(value));
|
||||
|
||||
} else if (key.equals(Constants.HEADER_PREFER_RESPOND_ASYNC)) {
|
||||
|
||||
|
|
|
@ -184,8 +184,8 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
|||
if (allowPrefer) {
|
||||
String prefer = theRequest.getHeader(Constants.HEADER_PREFER);
|
||||
PreferHeader preferReturn = RestfulServerUtils.parsePreferHeader(theServer, prefer);
|
||||
PreferHeader.PreferReturnEnum returnEnum = preferReturn.getReturn();
|
||||
returnEnum = defaultIfNull(returnEnum, PreferHeader.PreferReturnEnum.REPRESENTATION);
|
||||
PreferReturnEnum returnEnum = preferReturn.getReturn();
|
||||
returnEnum = defaultIfNull(returnEnum, PreferReturnEnum.REPRESENTATION);
|
||||
|
||||
switch (returnEnum) {
|
||||
case REPRESENTATION:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -10,14 +11,14 @@ public class RestfulServerUtilsTest{
|
|||
@Test
|
||||
public void testParsePreferReturn() {
|
||||
PreferHeader header = RestfulServerUtils.parsePreferHeader(null,"return=representation");
|
||||
assertEquals(PreferHeader.PreferReturnEnum.REPRESENTATION, header.getReturn());
|
||||
assertEquals(PreferReturnEnum.REPRESENTATION, header.getReturn());
|
||||
assertFalse(header.getRespondAsync());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsePreferReturnAndAsync() {
|
||||
PreferHeader header = RestfulServerUtils.parsePreferHeader(null,"return=OperationOutcome; respond-async");
|
||||
assertEquals(PreferHeader.PreferReturnEnum.OPERATION_OUTCOME, header.getReturn());
|
||||
assertEquals(PreferReturnEnum.OPERATION_OUTCOME, header.getReturn());
|
||||
assertTrue(header.getRespondAsync());
|
||||
}
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ public class GenericClientDstu2_1Test {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(2, myAnswerCount);
|
||||
assertNotNull(outcome.getOperationOutcome());
|
||||
|
@ -603,7 +603,7 @@ public class GenericClientDstu2_1Test {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(1, myAnswerCount);
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
|
@ -1029,7 +1029,7 @@ public class GenericClientDstu2_1Test {
|
|||
client
|
||||
.update()
|
||||
.resource(bundle)
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
|
||||
|
@ -1074,7 +1074,7 @@ public class GenericClientDstu2_1Test {
|
|||
client
|
||||
.update()
|
||||
.resource(bundle)
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.encodedXml()
|
||||
.execute();
|
||||
|
||||
|
@ -1713,7 +1713,7 @@ public class GenericClientDstu2_1Test {
|
|||
pt.setId("Patient/222");
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(2, myAnswerCount);
|
||||
assertNotNull(outcome.getOperationOutcome());
|
||||
|
@ -1758,7 +1758,7 @@ public class GenericClientDstu2_1Test {
|
|||
pt.setId("Patient/222");
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(1, myAnswerCount);
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
|
|
|
@ -416,12 +416,12 @@ public class GenericClientDstu2Test {
|
|||
Patient p = new Patient();
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER).length);
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER)[0].getValue());
|
||||
idx++;
|
||||
|
||||
client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.create().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER).length);
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER)[0].getValue());
|
||||
idx++;
|
||||
|
@ -2475,12 +2475,12 @@ public class GenericClientDstu2Test {
|
|||
p.setId(new IdDt("1"));
|
||||
p.addName().addFamily("FOOFAMILY");
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
|
||||
assertEquals(1, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER).length);
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER)[0].getValue());
|
||||
idx++;
|
||||
|
||||
client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
client.update().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
assertEquals(1, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER).length);
|
||||
assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_PREFER)[0].getValue());
|
||||
idx++;
|
||||
|
|
|
@ -544,7 +544,7 @@ public class GenericClientDstu3Test {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(2, myAnswerCount);
|
||||
assertNotNull(outcome.getOperationOutcome());
|
||||
|
@ -590,7 +590,7 @@ public class GenericClientDstu3Test {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(1, myAnswerCount);
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
|
@ -965,7 +965,7 @@ public class GenericClientDstu3Test {
|
|||
client
|
||||
.update()
|
||||
.resource(bundle)
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ public class GenericClientDstu3Test {
|
|||
client
|
||||
.update()
|
||||
.resource(bundle)
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.encodedXml()
|
||||
.execute();
|
||||
|
||||
|
@ -1679,7 +1679,7 @@ public class GenericClientDstu3Test {
|
|||
pt.setId("Patient/222");
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(2, myAnswerCount);
|
||||
assertNotNull(outcome.getOperationOutcome());
|
||||
|
@ -1724,7 +1724,7 @@ public class GenericClientDstu3Test {
|
|||
pt.setId("Patient/222");
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(1, myAnswerCount);
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
|
|
|
@ -342,7 +342,7 @@ public class GenericClientR4Test {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(2, myAnswerCount);
|
||||
assertNotNull(outcome.getOperationOutcome());
|
||||
|
@ -388,7 +388,7 @@ public class GenericClientR4Test {
|
|||
Patient pt = new Patient();
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(1, myAnswerCount);
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
|
@ -1296,7 +1296,7 @@ public class GenericClientR4Test {
|
|||
client
|
||||
.update()
|
||||
.resource(bundle)
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.encodedJson()
|
||||
.execute();
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ public class GenericClientR4Test {
|
|||
client
|
||||
.update()
|
||||
.resource(bundle)
|
||||
.prefer(PreferHeader.PreferReturnEnum.REPRESENTATION)
|
||||
.prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.encodedXml()
|
||||
.execute();
|
||||
|
||||
|
@ -2153,7 +2153,7 @@ public class GenericClientR4Test {
|
|||
pt.setId("Patient/222");
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(2, myAnswerCount);
|
||||
assertNotNull(outcome.getOperationOutcome());
|
||||
|
@ -2198,7 +2198,7 @@ public class GenericClientR4Test {
|
|||
pt.setId("Patient/222");
|
||||
pt.getText().setDivAsString("A PATIENT");
|
||||
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome outcome = client.update().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
|
||||
assertEquals(1, myAnswerCount);
|
||||
assertNull(outcome.getOperationOutcome());
|
||||
|
|
|
@ -4,7 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.client.MyPatientWithExtensions;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -268,7 +268,7 @@ public class CreateR4Test {
|
|||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
||||
httpPost.setEntity(new StringEntity(body, ContentType.parse("application/fhir+json; charset=utf-8")));
|
||||
ourServlet.setDefaultPreferReturn(PreferHeader.PreferReturnEnum.OPERATION_OUTCOME);
|
||||
ourServlet.setDefaultPreferReturn(PreferReturnEnum.OPERATION_OUTCOME);
|
||||
try (CloseableHttpResponse status = ourClient.execute(httpPost)) {
|
||||
|
||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||
|
@ -293,7 +293,7 @@ public class CreateR4Test {
|
|||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
||||
httpPost.setEntity(new StringEntity(body, ContentType.parse("application/fhir+json; charset=utf-8")));
|
||||
ourServlet.setDefaultPreferReturn(PreferHeader.PreferReturnEnum.MINIMAL);
|
||||
ourServlet.setDefaultPreferReturn(PreferReturnEnum.MINIMAL);
|
||||
try (CloseableHttpResponse status = ourClient.execute(httpPost)) {
|
||||
|
||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<div class="col-sm-3 form-group">
|
||||
<a type="button" id="fetch-conformance-btn"
|
||||
class="btn btn-primary btn-block">
|
||||
<span class="fa fa-dot-circle-o"></i>
|
||||
<i class="far fa-dot-circle"></i>
|
||||
Conformance
|
||||
</a>
|
||||
<script type="text/javascript">
|
||||
|
@ -97,7 +97,7 @@
|
|||
<div class="col-sm-3">
|
||||
<button type="button" id="server-history-btn"
|
||||
class="btn btn-primary btn-block">
|
||||
<span class="fa fa-calendar"></i>
|
||||
<i class="far fa-calendar-alt"></i>
|
||||
History
|
||||
</button>
|
||||
</div>
|
||||
|
@ -156,7 +156,7 @@
|
|||
<div class="row-fluid">
|
||||
<div class="col-sm-3">
|
||||
<button type="button" id="transaction-btn" class="btn btn-primary btn-block">
|
||||
<span class="fa fa-files-o"></i>
|
||||
<i class="fas fa-file-archive"></i>
|
||||
Transaction
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
<h4 class="panel-title">
|
||||
<th:block th:if="${#lists.isEmpty(bundle.entries)}">Bundle contains no entries</th:block>
|
||||
<a th:unless="${#lists.isEmpty(bundle.entries)}" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||
<i id="collapseOneIcon" class="fa fa-minus-square-o"></i>
|
||||
<i id="collapseOneIcon" class="far fa-minus-square"></i>
|
||||
<span th:if="${bundle.totalResults.empty}" th:text="'Bundle contains ' + ${#lists.size(bundle.entries)} + ' entries'"/>
|
||||
<span th:unless="${bundle.totalResults.empty}" th:text="'Bundle contains ' + ${#lists.size(bundle.entries)} + ' / ' + ${bundle.totalResults.value} + ' entries'"/>
|
||||
</a>
|
||||
|
@ -195,8 +195,8 @@
|
|||
<tr th:each="entry : ${bundle.entries}">
|
||||
<td style="white-space: nowrap;">
|
||||
<th:block th:if="${entry.resource} != null">
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.id.resourceType}" th:data2="${entry.resource.id.idPart}" th:data3="${#strings.defaultString(entry.resource.id.versionIdPart,'')}" onclick="readFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="read"><i class="fa fa-book"></i> Read</button>
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.id.resourceType}" th:data2="${entry.resource.id.idPart}" th:data3="${#strings.defaultString(entry.resource.id.versionIdPart,'')}" onclick="updateFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="home"><i class="fa fa-pencil"></i> Update</button>
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.id.resourceType}" th:data2="${entry.resource.id.idPart}" th:data3="${#strings.defaultString(entry.resource.id.versionIdPart,'')}" onclick="readFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="read"><i class="fas fa-book"></i> Read</button>
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.id.resourceType}" th:data2="${entry.resource.id.idPart}" th:data3="${#strings.defaultString(entry.resource.id.versionIdPart,'')}" onclick="updateFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="home"><i class="far fa-edit"></i> Update</button>
|
||||
</th:block>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -214,13 +214,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
$('#collapseOne').on('hidden.bs.collapse', function () {
|
||||
$("#collapseOneIcon").removeClass("fa-minus-square-o").addClass("fa-plus-square-o");
|
||||
$("#collapseOneIcon").removeClass("fa-minus-square").addClass("fa-plus-square");
|
||||
});
|
||||
|
||||
$('#collapseOne').on('shown.bs.collapse', function () {
|
||||
$("#collapseOneIcon").removeClass("fa-plus-square-o").addClass("fa-minus-square-o");
|
||||
$("#collapseOneIcon").removeClass("fa-plus-square").addClass("fa-minus-square");
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -240,7 +242,7 @@
|
|||
<h4 class="panel-title">
|
||||
<th:block th:if="${#lists.isEmpty(riBundle.entry)}">Bundle contains no entries</th:block>
|
||||
<a th:unless="${#lists.isEmpty(riBundle.entry)}" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||
<i id="collapseOneIcon" class="fa fa-minus-square-o"></i>
|
||||
<i id="collapseOneIcon" class="far fa-minus-square"></i>
|
||||
<span th:if="${riBundle.totalElement.empty}" th:text="'Bundle contains ' + ${#lists.size(riBundle.entry)} + ' entries'"/>
|
||||
<span th:unless="${riBundle.totalElement.empty}" th:text="'Bundle contains ' + ${#lists.size(riBundle.entry)} + ' / ' + ${riBundle.totalElement.value} + ' entries'"/>
|
||||
</a>
|
||||
|
@ -307,8 +309,8 @@
|
|||
<tr th:each="entry : ${riBundle.entry}">
|
||||
<td style="white-space: nowrap;">
|
||||
<th:block th:if="${entry.resource} != null">
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.idElement.resourceType}" th:data2="${entry.resource.idElement.idPart}" th:data3="${#strings.defaultString(entry.resource.idElement.versionIdPart,'')}" onclick="readFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="read"><i class="fa fa-book"></i> Read</button>
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.idElement.resourceType}" th:data2="${entry.resource.idElement.idPart}" th:data3="${#strings.defaultString(entry.resource.idElement.versionIdPart,'')}" onclick="updateFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="home"><i class="fa fa-pencil"></i> Update</button>
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.idElement.resourceType}" th:data2="${entry.resource.idElement.idPart}" th:data3="${#strings.defaultString(entry.resource.idElement.versionIdPart,'')}" onclick="readFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="read"><i class="fas fa-book"></i> Read</button>
|
||||
<button class="btn btn-primary btn-xs" th:data1="${entry.resource.idElement.resourceType}" th:data2="${entry.resource.idElement.idPart}" th:data3="${#strings.defaultString(entry.resource.idElement.versionIdPart,'')}" onclick="updateFromEntriesTable(this, this.getAttribute('data1'), this.getAttribute('data2'), this.getAttribute('data3'));" type="submit" name="action" value="home"><i class="far fa-edit"></i> Update</button>
|
||||
</th:block>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -328,13 +330,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
$('#collapseOne').on('hidden.bs.collapse', function () {
|
||||
$("#collapseOneIcon").removeClass("fa-minus-square-o").addClass("fa-plus-square-o");
|
||||
$("#collapseOneIcon").removeClass("fa-minus-square").addClass("fa-plus-square");
|
||||
});
|
||||
|
||||
$('#collapseOne').on('shown.bs.collapse', function () {
|
||||
$("#collapseOneIcon").removeClass("fa-plus-square-o").addClass("fa-minus-square-o");
|
||||
$("#collapseOneIcon").removeClass("fa-plus-square").addClass("fa-minus-square");
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<ul th:fragment="farright">
|
||||
<li><a href="https://github.com/jamesagnew/hapi-fhir"><span class="fa fa-book-open topbarIcon"></span> Source Code</a></li>
|
||||
<li><a href="https://github.com/jamesagnew/hapi-fhir"><i class="fab fa-github topbarIcon"></i></span> Source Code</a></li>
|
||||
<li><a href="about"><span class="fa fa-question-circle topbarIcon"></span> About This Server</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -26,6 +27,8 @@ import ca.uhn.fhir.rest.param.DateRangeParam;
|
|||
import ca.uhn.fhir.rest.param.TokenOrListParam;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class OverlayTestApp {
|
||||
|
||||
private static AnnotationConfigApplicationContext ourAppCtx;
|
||||
|
@ -156,14 +159,37 @@ public class OverlayTestApp {
|
|||
@Search
|
||||
public List<DiagnosticReport> findDiagnosticReportsByPatient(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_CODE) TokenOrListParam theNames,
|
||||
@OptionalParam(name = DiagnosticReport.SP_DATE) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set<Include> theIncludes) throws Exception {
|
||||
return null;
|
||||
return getDiagnosticReports();
|
||||
}
|
||||
|
||||
@Description(shortDefinition = "This is a query by issued.. blah blah foo bar blah blah")
|
||||
@Search
|
||||
public List<DiagnosticReport> findDiagnosticReportsByPatientIssued(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_CODE) TokenOrListParam theNames,
|
||||
@OptionalParam(name = DiagnosticReport.SP_ISSUED) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set<Include> theIncludes) throws Exception {
|
||||
return null;
|
||||
return getDiagnosticReports();
|
||||
}
|
||||
|
||||
@Description(shortDefinition = "This is a query by issued.. blah blah foo bar blah blah")
|
||||
@Search
|
||||
public List<DiagnosticReport> findDiagnosticReportsByPatientIssued() throws Exception {
|
||||
return getDiagnosticReports();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<DiagnosticReport> getDiagnosticReports() {
|
||||
ArrayList<DiagnosticReport> retVal = new ArrayList<>();
|
||||
|
||||
DiagnosticReport dr = new DiagnosticReport();
|
||||
dr.addResult().setReference("Observation/123");
|
||||
dr.setId("DiagnosticReport/1");
|
||||
retVal.add(dr);
|
||||
|
||||
dr = new DiagnosticReport();
|
||||
dr.addResult().setReference("Observation/123");
|
||||
dr.setId("DiagnosticReport/2");
|
||||
retVal.add(dr);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,7 @@ package ca.uhn.fhir.tests.integration.karaf.client;
|
|||
import java.io.IOException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferHeader;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.Ignore;
|
||||
|
@ -56,7 +56,7 @@ public class FhirClientTest {
|
|||
patient.setId("PATIENTID");
|
||||
patient.getMeta().addProfile("http://BAR");
|
||||
patient.addName().addGiven("GIVEN");
|
||||
MethodOutcome execute = client.create().resource(patient).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute();
|
||||
MethodOutcome execute = client.create().resource(patient).prefer(PreferReturnEnum.REPRESENTATION).execute();
|
||||
ourLog.info(execute.toString());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue