public static void main ( String [ ] args ) throws IOException { // Create a client factory FhirContext ctx = FhirContext . forDstu2 ( ) ; // Create the client String serverBase = "http://fhir.healthintersections.com.au/open" ; ClientInterface client = ctx . newRestfulClient ( ClientInterface . class , serverBase ) ; // Invoke the client to search for patient List < Patient > patients = client . findPatientsForMrn ( new IdentifierDt ( "urn:oid:1.2.36.146.595.217.0.1" , "12345" ) ) ; System . out . println ( "Found " + patients . size ( ) + " patients" ) ; // Print a value from the loaded resource Patient patient = patients . get ( 0 ) ; System . out . println ( "Patient Last Name: " + patient . getName ( ) . get ( 0 ) . getFamily ( ) . get ( 0 ) . getValue ( ) ) ; // Load a referenced resource ResourceReferenceDt managingRef = patient . getManagingOrganization ( ) ; Organization org = ( Organization ) managingRef . loadResource ( client ) ; // Print organization name System . out . println ( org . getName ( ) ) ; }
The main method here will directly call an open FHIR server and retrieve a list of resources matching a given criteria then load a linked resource .