nextgenhealthcare / connect

The swiss army knife of healthcare integration.
Other
914 stars 275 forks source link

[BUG] JSON parse FHIR resources error using Hapi FHIR #6206

Closed phommata closed 4 months ago

phommata commented 4 months ago

Describe the bug

Hapi FHIR JSON parse fails on the Appointment resource with ca.uhn.fhir.context.ConfigurationException: HAPI-1716: Resource class[org.hl7.fhir.r4.model.Appointment] does not contain any valid HAPI-FHIR annotations . I can successfully JSON parse the Patient resource example in the Hapi FHIR docs. The JSON parse of resources works in plain old Java. I expect an Appointment object to be returned when the JSON Appointment resource is parsed. I can successfully JSON parse a Patient resource. This also fails for the Encounter resource.

To Reproduce Setup steps

  1. Run JDK 17
  2. Run Mirth Connect 4.5.0
  3. Download Hapi FHIR 7.2.0 to custom-libs from GitHub releases

Steps to reproduce the behavior:

  1. Run code below in a JavaScript destination connector
  2. See error
// Create a HAPI FHIR context for FHIR
var context = new Packages.ca.uhn.fhir.context.FhirContext.forR4();

// Instantiate a new parser
var parser = ctx.newJsonParser();

var input = {
{
  "resourceType" : "Appointment",
  "status" : "booked"
};

// Parse it
var appointment = parser.parseResource(Packages.org.hl7.fhir.r4.model.Appointment, JSON.stringify(input));

Expected behavior I expect the JSON parser to successfully parse the Appointment resource JSON string returning an Appointment object.

Actual behavior Appointment resource JSON parsing error DETAILS: Wrapped ca.uhn.fhir.context.ConfigurationException: HAPI-1716: Resource class[org.hl7.fhir.r4.model.Appointment] does not contain any valid HAPI-FHIR annotations at 580496cb-4e73-4584-b43b-2d157216edf7_JavaScript_Writer_9:494 (doScript) at 580496cb-4e73-4584-b43b-2d157216edf7_JavaScript_Writer_9:519 at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1899) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:226) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1692) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1013) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578) ~[rhino-1.7.13.jar:1.7.13] at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:121) ~[rhino-1.7.13.jar:1.7.13] at com.mirth.connect.server.util.javascript.JavaScriptTask.executeScript(JavaScriptTask.java:151) ~[mirth-server.jar:?] at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:261) ~[js-server.jar:?] at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:221) ~[js-server.jar:?] at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:114) ~[mirth-server.jar:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:842) ~[?:?] Caused by: ca.uhn.fhir.context.ConfigurationException: HAPI-1716: Resource class[org.hl7.fhir.r4.model.Appointment] does not contain any valid HAPI-FHIR annotations at ca.uhn.fhir.context.ModelScanner.scan(ModelScanner.java:232) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.context.ModelScanner.init(ModelScanner.java:141) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.context.ModelScanner.<init>(ModelScanner.java:98) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.context.FhirContext.scanResourceTypes(FhirContext.java:1064) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.context.FhirContext.scanResourceType(FhirContext.java:1041) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.context.FhirContext.getResourceDefinition(FhirContext.java:500) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:679) ~[hapi-fhir-base-7.2.0.jar:?] at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:738) ~[hapi-fhir-base-7.2.0.jar:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138) ~[rhino-1.7.13.jar:1.7.13] ... 15 more

Screenshots None

Environment (please complete the following information):

Workaround(s) I can use Hapi FHIR 6.8.7.

Additional context None

is-simon commented 4 months ago

What did you put exactly in your custom-libs directory. The HAPI-FHIR distribution is pretty big! Maybe list the jars you put in there or a screenshot of your custom-libs directory. It will be easier then to help. I don't think this is a Mirth Connect bug, probably just a missing library

pacmano1 commented 4 months ago

@phommata please don't post in the issues section things you are trying to troubleshoot.