Registration Fee Sync with ERP - Interim Implementation

Though various ways including manual creation of billing entry at the end of the day, have been suggested to sync registration fee with ERP to meet the requirement of displaying registration fee in the billing automatically code changes are required.

A quick implementation ((that’s the subject: Interim Implementation) to meet this requirement, Java and Python code level changes have been done as explained below. Requires further discussions on this so that final code can be released on the community.

Here is Screen capture for registration fee syncing

Assumption -

  1. Once registration fee is charged, it will not get reversed though it is set to “No” on the second page of Patient Registration in Bahmni.

Pending -

  1. Like drug and radiology orders this code does not add any entries in openmrs (mysql) orders table. Requires further discussions on this as well.
  2. Order type “Registration Fee” has been hard coded in MapERPOrders class. To overcome this it can be set in order_type table and attached to the concept class “RegFee” (order_type_class_map) as mentioned here.

OpenMRS Settings -

  1. Create a new concept class name “RegFee”.
  2. Create concept name “Charge Registration” (or any name) of datatype Boolean, class “Radiology” and attach to “Fee Information”. Saving this should sync it with ERP. Once synced with ERP change the class to “RegFee”.

OpenERP Settings

  1. Order Type “Registration Fee” should be created in ERP and mapped to shop as mentioned here.
  2. Create a suitable product category for “Charge Registration”.
  3. Set the price and newly created product category for “Charge Registration”.

Following Code changes have been done -

openerp-atomfeed-service

  1. In org.bahmni.feed.openerp.domain.encounter added OpenMRSObservationGroupMember and OpenMRSObservationGroupMemberConcept classes to hold the respective data for the encounter event getting registered in event_records table.
  2. OpenMRSObservationGroupMember contains private OpenMRSObservationGroupMemberConcept concept;
  3. OpenMRSObservation contains a list of OpenMRSObservationGroupMember
  4. OpenMRSEncounter contains encounterType as string data member.
  5. MapERPOrders.getParameters checks if the encounter type is “Reg” then sets category parameter to “create.sale.regfeeorder” so that Python code can consume the same.
  6. MapERPOrders.mapOpenERPOrders checks if the encounter type is “Reg” and if the observation consists of a concept group member of class “RegFee” then adds OpenERPOrder with appropriate parameters same as radiology and drug order but with a new event type as “create.sale.regfeeorder”
  7. OpenMRSEncounter.shouldERPConsumeEvent checks if encounter type is “Reg” then returns true.

operp-modules\bahmni_atom_feed

  1. Added “event handler” for “create.sale.regfeeorder” to call self.pool.get(‘order.save.service’).create_orders(cr,uid,vals,context) in process_event in atom_feed_client.py
3 Likes

I understand that this is intended to be a quick/interim implementation, but I agree with @arjun’s comment: it would be a lot more useful to implement this in a generic way so that any sorts of obs (perhaps based on concept attributes) can be synched to ERP, instead of hardcoding to a specific RegFee concept class.

I would think it requires the same amount of code to do things in a more generic way, right?

Well, since this is a quick fix specifically for registration it doesn’t need lot of changes eg. we are not creating entry in openmrs order table.

And we agree and have been saying that all orders should get sync. To take it further when we create a new order type and set corresponding openmrs tables it throws exception. If you could look in to this and guide us further it will help

@ramashish I will try to look into the order issue.

Registration Fees would be an observation, not an order, right?

Thank you.

Yes, it’s an observation and in our code we are syncing all observations with ERP in res_person_attributes table. (It overwrites for the next visit).

A line item in quotation gets automatically generated for Registration Fee.

Assuming registration fee is to be charged one time, we are not maintaining “action” like other orders (NEW, DISCONTINUE etc.). That’s why I had put a question whether should it also be entered in orders table?

Hello @ramashish…Thanks for posting the interim implementation… Is it okay if u post the code you changed in the files mentioned above…so that we can also use your implementation since the workflow is not yet added into bahmni.

Hi Ramashish. Can you please elaborate where to find org.bahmni.feed.openerp.domain.encounter path.

Assuming you are looking for this

Being interim implementation and few members thought that it is more of hardcoded way, I have not given a pull request for this but if you need the Java side code then it’s here

Hello @ramashish… Using this interim implementation. I can sync the product id, product name and among others i can also sync the quantity as 1. My question is if its possible to sync a value entered by user as price of the product in OpenERP.

Is anyone aware of a generic way to achieve something like this, ie, syncing observations to OpenERP?

I am searching for a way to send a Service type of obs (recorded by a medical personnel in OpenMRS) - say a surgical procedure for instance, into the quotation opened in OpenERP (alongside any Drugs that may have been recorded too).

Using Concept Attribute as “Orderable” (boolean) can be used as discussed here to make it generic.

Think you for your idea can you explain to me this part please.?

Could you please let me know which particular point you got stuck at so it will be easier to explain?

we are facing the same problem in registration fee . we have followed the the documentation of attached link Registration Fee Sync with ERP - Interim Implementation but could not get through it. Can you please suggest us how to sync regfee to openerp. we also created concept as charge registration but is not synced on order type - shop mapping. Does any one has implemented

  1. In org.bahmni.feed.openerp.domain.encounter added OpenMRSObservationGroupMember and OpenMRSObservationGroupMemberConcept classes to hold the respective data for the encounter event getting registered in event_records table.
  2. OpenMRSObservationGroupMember contains private OpenMRSObservationGroupMemberConcept concept;
  3. OpenMRSObservation contains a list of OpenMRSObservationGroupMember
  4. OpenMRSEncounter contains encounterType as string data member.
  5. MapERPOrders.getParameters checks if the encounter type is “Reg” then sets category parameter to “create.sale.regfeeorder” so that Python code can consume the same.
  6. MapERPOrders.mapOpenERPOrders checks if the encounter type is “Reg” and if the observation consists of a concept group member of class “RegFee” then adds OpenERPOrder with appropriate parameters same as radiology and drug order but with a new event type as “create.sale.regfeeorder”
  7. OpenMRSEncounter.shouldERPConsumeEvent checks if encounter type is “Reg” then returns true.

operp-modules\bahmni_atom_feed

  1. Added “event handler” for “create.sale.regfeeorder” to call self.pool.get(‘order.save.service’).create_orders(cr,uid,vals,context) in process_event in atom_feed_client.py

if yes can you please guide us through it.

hi,@ramashish @darius this might be very trivial question… i generated the war file of the independent openerp-atomfeed-service and want to deploy it to the vagrant installation of my Bahmni. do i need to drop this war file to the certian path or how does the deployment of war file works in context of both bahmni vagrant installation as well as rpm based bahmni installation.

Can you please help? Much Appreciated

mvn clean install fails with test.

INFO] [INFO] — maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ openerp-atomfeed-service — [INFO] Compiling 19 source files to /home/atomfeedgit/openerp-atomfeed-service/openerp-atomfeed-service/target/test-classes [INFO] [INFO] — maven-surefire-plugin:2.5:test (default-test) @ openerp-atomfeed-service — [INFO] Surefire report directory: /home/atomfeedgit/openerp-atomfeed-service/openerp-atomfeed-service/target/surefire-reports OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0


T E S T S

Running org.bahmni.feed.openerp.event.OpenERPCustomerServiceEventWorkerTest log4j:ERROR No appender named [console] could be found. log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: /logs/openerp-feed-service.log (No such file or directory) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(FileOutputStream.java:270) at java.io.FileOutputStream.(FileOutputStream.java:213) at java.io.FileOutputStream.(FileOutputStream.java:133) at org.apache.log4j.FileAppender.setFile(FileAppender.java:294) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)

It says Build Failure [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 20.495 s [INFO] Finished at: 2019-03-31T13:26:16Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project openerp-atomfeed-service: There are test failures. [ERROR] [ERROR] Please refer to /home/atomfeedgit/openerp-atomfeed-service/openerp-atomfeed-service/target/surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR]

@roma87 you can try this one mvn clean install -DskipTests .

@ramashish can you please guide me through this . i did all the things. generated war , .class file replaced it on the required path. done every thing regarding concept on openmrs. Still the charge registration is not synced . i have bahmni-0.91 installed on both virtualbox and centos. did all the process on both . but could not get through it. please kindly guide through it.

Hi There,

Has the workaround worked for you? I haven’t been able to make it work yet from my end…

Thanks, Kika

Nope. This workaround does not generate any ‘order.sales.regFee’ type event in event_records table. I still see only two events ‘Patient’ and ‘Encounter’ being generated on my end. Also, this https://github.com/Pasayadaan/openerp-atomfeed-service code does not get build and deployed as it says.

I checked out the above openerp-atomfeed-service code. Installed maven and JDK. From the root folder tried to run “maven clean install -DskipTests” and it runs and builds fine. If you remove skip tests the test will fail. Also, ./scripts/vagrant-deploy.sh does not work as it fails with following error:

[INFO] — exec-maven-plugin:1.6.0:java (Deploy) @ openerp-atomfeed-service — [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for openerp-service 0.91-SNAPSHOT: [INFO] [INFO] openerp-service … SUCCESS [ 1.567 s] [INFO] openerp-client … SUCCESS [ 13.041 s] [INFO] openerp-atomfeed-service … FAILURE [ 27.268 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 43.568 s [INFO] Finished at: 2019-04-03T11:24:08Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (Deploy) on project openerp-atomfeed-service: The parameters ‘mainClass’ for goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java are missing or invalid -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :openerp-atomfeed-service ➜ openerp-atomfeed-service git:(master) ✗

Hi, I am able to sync Registration Fee with OpenERP. Please find below quick implementation.

Registration Fee Sync with OpenERP

OpenMRS Settings

Create a new concept class name "RegFee".

Create concept name “Charge Registration” (or any name) of datatype Boolean, class “Radiology” and attach to “Fee Information” concept. Saving this should sync concept got created as product in OpenERP. Once synced with ERP change the class to “RegFee”.

OpenERP Settings

Add order type “Registration Fee” in Sales- Configuration- Order Type - Shop Mapping section in OpenERP.

Create a suitable product category for “Charge Registration”.

Set the price and newly created product category for “Charge Registration”.

bahmni-erp-connect\openerp-atomfeed-service

Checkout java side code from

git clone https://github.com/Pasayadaan/openerp-atomfeed-service.git

Assign checked out folder read write access

eg: sudo chmod 777 -R foldername

Make sure maven is installed

Make sure java jdk is installed

Go to the folder where pom.xml file resides which is inside root folder and outside scripts folder.

Run mvn clean install -DskipTests

This will generate all classes and war file inside \target folder.

openerp-atomfeed-service\openerp-atomfeed-service\target\openerp-atomfeed-service.war

openerp-atomfeed-service\openerp-atomfeed-service\target\openerp-atomfeed-service\WEB-INF

Replace openerp-atomfeed-service.war file from /opt/bahmni-erp-connect/etc/

Replace WEB-INF folder from /opt/bahmni-erp-connect/bahmni-erp-connect/

bahmni-erp\openerp-modules\bahmni_atom_feed

Add "event handler" in process_event function inside /usr/lib/python2.6/site-packages/openerp-7.0_20130301_002301-py2.6.egg/openerp/addons/bahmni_atom_feed/atom_feed_client.py

if(category == "update.attributes"):

self.pool.get(‘order.save.service’).create_orders(cr,uid,vals,context)

Then restart openerp service

sudo service openerp restart

Logout and try creating patient from Bahmni

3 Likes