I am very new to the HAPI FHIR client, and have been endlessly browsing tutorials and documentation to try and assist me with my program that I am trying to develop, but I am now stuck when it comes to querying a server to search for a list of Patients that are all being treated by the same practitioner. In other words, I want a user to enter a Practitioner ID number and for the system to return a list of patients with their details. I was able to query the server to get all the Encounters when entering the ID number of the Practitioner, which were all placed into a Bundle, but I have no idea where to go from there. I have placed the line of code I used to get the Bundle and can verify that it works, because when couting the number of resources in the bundle, I get the correct number. pracID is the user-entered integer.
Bundle response = client.search().forResource(Encounter.class).where(Encounter.PRACTITIONER.hasId(Integer.toString(pracID))).returnBundle(Bundle.class).execute();
I am also coding this in Java on IntelliJ, using the R4 version of the Context client. I will highly appreciate any help. Thanks in advance