-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestList.java
47 lines (36 loc) · 1.61 KB
/
TestList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.ArrayList;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.DomainResource;
import org.hl7.fhir.dstu3.model.IdType;
import org.hl7.fhir.dstu3.model.OperationOutcome;
import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.Practitioner;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
public class TestList {
static FhirContext ctx = FhirContext.forDstu3();
static IGenericClient client = ctx.newRestfulGenericClient("http://114.142.160.89:8080/hapi-fhir-jpaserver/fhir/");
//static ArrayList<Patient> listPatients = new ArrayList<Patient>();
static String street;
static OperationOutcome oo = new OperationOutcome();
public static void main(String[] args) {
try{
Patient response = client.read()
.resource(Patient.class)
.withId("")
.execute();
System.out.println(ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response));
}catch (ResourceNotFoundException e) {
System.out.println("An issue "+ e.getMessage());
//System.out.println("An issue "+oo.getIssue().get(0).getDiagnostics().toString());
}catch (ResourceGoneException e) {
System.out.println("An issue "+ e.getMessage());
}catch (IllegalArgumentException e ) {
System.out.println("An issue "+ e.getMessage());
}
}
}