Is it required to use EmrApiVisitAssignmentHandler while saving an encounter?

Hi,

I am trying to save a new encounter through my own module code. I want to simply use the core platform API in my module, but the module is deployed on the 2.2 release. I am getting the following exception:

org.openmrs.api.APIException: Failed to instantiate assignment handler object for class class: org.openmrs.module.emrapi.adt.EmrApiVisitAssignmentHandler
    at org.openmrs.api.impl.EncounterServiceImpl.getActiveEncounterVisitHandler(EncounterServiceImpl.java:707)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

Is it required to use EmrApiVisitAssignmentHandler while saving an encounter? Does my module need the refapp dependencies?

It’s a configuration problem, not a problem with your module.

The error message means that you have the “visits.assignmentHandler” global property configured to try to use “org.openmrs.module.emrapi.adt.EmrApiVisitAssignmentHandler”, but you said that you’re not running the emrapi module.

One way to fix this is to set the GP value back to its default, which is “org.openmrs.api.handler.ExistingVisitAssignmentHandler”.

You can see the code resulting in this error here at EncounterServiceImpl. getActiveEncounterVisitHandler(EncounterServiceImpl.java:707)

Thank you @darius for quick response. Does it mean that, if I make this change the reference application user interface will not work?

Probably not.

So, if you are trying to sometimes run the reference application, and sometimes run the legacy user interface, I suggest that you should have two different databases for this. E.g. the referenceapplication module will set a bunch of specific GP values that it expects, but which may not work if you stop all the reference application modules.