Skip to content

Instantly share code, notes, and snippets.

@KevinMayfield
Created June 18, 2017 07:40
Show Gist options
  • Save KevinMayfield/b71d1318d5fddf5012b334c74d25f561 to your computer and use it in GitHub Desktop.
Save KevinMayfield/b71d1318d5fddf5012b334c74d25f561 to your computer and use it in GitHub Desktop.
Patient Search gist
// Create a FHIR Context
FhirContext ctx = FhirContext.forDstu2();
IParser parser = ctx.newXmlParser();
// Create a client and post the transaction to the server
IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:8181/Dstu2/");
System.out.println("GET http://127.0.0.1:8181/Dstu2/Patient?birthdate=1998-03-19&given=bernie&family=kanfeld");
Bundle results = client
.search()
.forResource(Patient.class)
.where(Patient.FAMILY.matches().value("kanfeld"))
.and(Patient.GIVEN.matches().value("bernie"))
.and(Patient.BIRTHDATE.exactly().day("1998-03-19"))
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
.execute();
System.out.println(parser.setPrettyPrint(true).encodeResourceToString(results));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment