Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
phommata opened this issue May 22, 2024 · 2 comments
Closed

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

phommata opened this issue May 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@phommata
Copy link

phommata commented May 22, 2024

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):

  • OS: MacOS
  • Java Distribution/Version Java 17
  • Connect Version 4.5.0

Workaround(s)
I can use Hapi FHIR 6.8.7.

Additional context
None

@phommata phommata added the bug Something isn't working label May 22, 2024
@is-simon
Copy link

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
Copy link
Collaborator

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

@pacmano1 pacmano1 converted this issue into discussion #6207 May 23, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants