# Is it required to use EmrApiVisitAssignmentHandler while saving an encounter?

**URL:** <https://talk.openmrs.org/t/is-it-required-to-use-emrapivisitassignmenthandler-while-saving-an-encounter/2630>\
**Category:** Development\
**Created:** [July 30, 2015, 12:53am UTC](https://talk.openmrs.org/t/is-it-required-to-use-emrapivisitassignmenthandler-while-saving-an-encounter/2630 "2015-07-30T00:53:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![n\_nehete](https://talk.openmrs.org/user_avatar/talk.openmrs.org/n_nehete/32/618_2.png) [@n\_nehete](https://talk.openmrs.org/u/n_nehete)\
**Post date:** [July 30, 2015, 12:53am UTC](https://talk.openmrs.org/t/is-it-required-to-use-emrapivisitassignmenthandler-while-saving-an-encounter/2630/1 "2015-07-30T00:53:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [July 30, 2015, 1:16am UTC](https://talk.openmrs.org/t/is-it-required-to-use-emrapivisitassignmenthandler-while-saving-an-encounter/2630/2 "2015-07-30T01:16:53Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![n\_nehete](https://talk.openmrs.org/user_avatar/talk.openmrs.org/n_nehete/32/618_2.png) [@n\_nehete](https://talk.openmrs.org/u/n_nehete)\
**Post date:** [July 30, 2015, 1:44am UTC](https://talk.openmrs.org/t/is-it-required-to-use-emrapivisitassignmenthandler-while-saving-an-encounter/2630/3 "2015-07-30T01:44:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [July 30, 2015, 1:56am UTC](https://talk.openmrs.org/t/is-it-required-to-use-emrapivisitassignmenthandler-while-saving-an-encounter/2630/4 "2015-07-30T01:56:29Z")

</div>

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.
