-1

I'm trying to access FHIR resources from a FHIR server. Everything works fine when accessing the FHIR resources via postman

This is my code:

String serverBase = https://<fhir-server-url>;

//Adding required headers here - removed as irrelevant for this question

IGenericClient client = ctx.newRestfulGenericClient(serverBase);
client.setEncoding(EncodingEnum.JSON);

Patient p = client.read(Patient.class, "jasdkfljasdklfjasldfkja");
String resPatient = p.getName().get(0).getGiven().toString();

PROBLEM: The conformance functionality is broken and I am not being able to proceed with doing any operations on resources because the IGenericClient gets the conformance when initiating by calling https://<fhir-server-url>/metadata.

It is going to take time for the conformance functionality to get fixed. Meanwhile, I was wondering if there is a way to bypass getting the conformance by setting a flag or something so that i can access the FHIR resources?

Viral Patel
  • 32,418
  • 18
  • 82
  • 110

1 Answers1

1

Figured out myself. Can be done as follows:

FhirContext fhirfctx = FhirContext.forDstu2();

// bypass conformance check  

fhirfctx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
Viral Patel
  • 32,418
  • 18
  • 82
  • 110