Registration Fee Sync with ERP - Interim Implementation


(Ramashish Joshi) #1

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

OpenERP features required from the product
Registration fee functionality and transfer to quotation in erp
Registration fee bug
(Darius Jazayeri) #2

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?


(Ramashish Joshi) #3

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


(Darius Jazayeri) #4

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

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


(Ramashish Joshi) #5

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?


(Nahabwe Brian) #6

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.


(Aniket Jagadale) #7

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


(Ramashish Joshi) #8

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


(Nahabwe Brian) #9

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.


(Romain Buisson) #10

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


(Ramashish Joshi) #11

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


(camara Oumarc77) #12

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


(Ramashish Joshi) #13

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