-4

API content https://i.stack.imgur.com/Tew1u.jpg

I am new to using API's. The only thing I can currently do is search for a diagnostic report via ID by using the code:

DiagnosticReport dR = client.read().resource(DiagnosticReport.class).withId("3281").execute();

But how can I search to see if a subject with reference: "Patient/3250" exists, and if it exists, how can I return the string "Encounter/3267" from:

"context": { "reference": "Encounter/3267"

J_D
  • 740
  • 8
  • 17

2 Answers2

0

You can try this with JSON :-

JSONObject jsonObject = new JSONObject(JSON);
JSONObject getFirst = jsonObject.getJSONObject("Context");
Object level2 = getFirst.get("reference");
if(level2.equals("Patient/3250")){
    System.out.println("True");
    }
else{
    System.out.println("False");
    }
Amol Gharpure
  • 129
  • 1
  • 7
0

you can do the first part with a query. I'm not sure about the HAPI syntax for it, so I'll show it in a URL. Your query is

GET [base]/DiagnosticReport/3281

The query you want for searching to see if a subject with reference "Patient/3250" exists would be

GET [base]/DiagnosticReport?subject:Patient.id=3250
Grahame Grieve
  • 3,538
  • 3
  • 15
  • 17