Stream: implementers
Topic: client classpath error
Ma Sk (Aug 14 2019 at 16:21):
Hi guys, i have a problem with my hapi fhir client.
I get the error message:
Exception in thread "main" ca.uhn.fhir.context.ConfigurationException: hapi-fhir-client does not appear to be on the classpath
at ca.uhn.fhir.context.FhirContext.getRestfulClientFactory(FhirContext.java:528)
at ca.uhn.fhir.context.FhirContext.newRestfulGenericClient(FhirContext.java:665)
//////////////
at this line:
IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://hapi.fhir.org/baseDstu3");
Does anybody know whats wrong with that?
This line worked with Dstu2. Now i switched to Dstu3 and it doesn´t work anymore.
I switched to the correct libraries of course.
Thanks in advance
Ma Sk (Aug 14 2019 at 17:05):
More of my code, if neccessary
FhirContext ctx = FhirContext.forDstu3();
Patient patient = new Patient();
//Add an MRN (a patient identifier)
Identifier id = patient.addIdentifier();
id.setSystem("http://TestEmail");
id.setValue("MRN001");
patient.addName().addGiven("John").setFamily("Smith");
patient.getBirthDateElement().setValueAsString("1998-02-22");
patient.setGender(AdministrativeGender.MALE);
patient.setId(IdDt.newRandomUuid());
.....
Bundle bundle = new Bundle();
bundle.setType(BundleType.TRANSACTION);
bundle.addEntry()
.setFullUrl(patient.getId())
.setResource(patient)
.getRequest()
.setUrl("Patient")
.setIfNoneExist("identifier=http://acme.org/mrns|1234588")
.setMethod(HTTPVerb.POST);
bundle.addEntry()
.setResource(observation)
.getRequest()
.setUrl("Observation")
.setMethod(HTTPVerb.POST);
System.out.println(ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle));
IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://hapi.fhir.org/baseDstu3");
Bundle resp = client.transaction().withBundle(bundle).execute();
Grahame Grieve (Aug 15 2019 at 02:34):
perhaps you could ask on the #hapi stream
Last updated: Apr 12 2022 at 19:14 UTC