Support syncing any and all saleable to ERP

Description

Context

When certain orders are placed in Bahmni EMR, they automatically get synchronised to ERP used for billing. This can be seen in this video here.
However this functionality currently has limitations because of hardcoding.
Currently Bahmni only synchronises certain types of orders. Specifically they are : Drug Orders, Lab Orders (Tests and Panels) and Radiology orders. However implementations need ability to sync other saleable to ERP. Examples of such saleable are Surgery orders, Dental procedures, Consultant Charges, Registration Fees. Unavailability of this feature leads to hacks like the one mentioned here.

We need to make this functionality generic and support the ability to synchronize any kind of saleable to the ERP, such that it can appear in a patient's bill.

This card is created as follow up from PAT 29-11-2017. See discussion at https://talk.openmrs.org/t/synchronizing-all-orders-to-openerp-needs-design/14064/7

Scope

Adding conceptattributes to atomfeed

Consuming concepattributes in erp-reader and creating line item in quotation

Providing built-in ConceptAttributeType in the bahmni-core module required for this functionality.

Out of scope: support for marking concepts as saleable when doing a CSV upload. (Because the UI supports this already.)

Acceptance Criteria

  1. As a Bahmni implementer when i create a concept with some concept-attribute values the atom feed should contain those concept attribute values

  2. As a Bahmni user when i create an order/obs for a concept which has concept-attribute values, the corresponding atom feed should contain those concept-attribute values

  3. As a Bahmni implementer, i should get some concept-attributes out of the box - saleable (true/false), saleable_type (product/service), category(string) which i can use to assign values to concepts.

  4. As a Bahmni implementer, when i create a concept with saleable=true, product_type = product, category = 'Surgical Tool', a product should get created in ERP under category = 'Surgical Tool'

  5. As a Bahmni implementer, when i create a concept with saleable=true, product_type = service, category = 'Surgeries', a service should get created in ERP under category = 'Surgeries'

  6. As a Bahmni user, when i place an order for an underlying concept having concept-attribute value saleable=true, product_type = product, a line item should get created in the quotation for the pre-synced product in ERP corresponding to this concept

  7. As a Bahmni user, when i create an obs with the underlying concept having concept-attribute values saleable=true, a line item should get created in the quotation for the pre-synced product/service in ERP corresponding to this concept

Note : The category used in AC is just an example and the functionality should work for any category.

Tech Notes

  • Synchronizing all saleable concepts to ERP as reference data is done via reader on ERP-connect side

    • The functionality currently exists but only for lab tests, panels, radiology orders and drugs. Need to make this generic.

  • Update the code that reads the encounter feed (and its orders) as necessary
    (and presumably more)

Tech Details

There are essentially 2 sides that need to be looked at - 1) Publishing Side 2) Consumer Side
Publishing Side
repo: bahmni-core
1) Start from ConceptServiceEventInterceptor.afterReturning()
2) Operation would need to be refactored.

  • You will find, there is a class level events variable which is a list of "ConceptServiceOperationEvent".
    Suggestions: Instead of LabTestEvent, PanelEvent, DrugEvent, RadiologyTestEvents - we should check whether they have attribute "saleable" as true. Note that we still need to push them to the right categories of the feed.

  • the package is wrongly named "org.bahmni.module.referencedata.labconcepts.model" - these are not just labconcepts - there are radiology, drug entities as well. Please adopt appropriate names.

Consumer Side
There are 2 subsystems that need to be worked at. 1) OpenELIS relevant 2) OpenERP relevant
1) OpenELIS - creating/updating the saleable tests/panels in OpenELIS
If the feeds are not changed, then it should just work without any changes. If not, you can follow code from the "LabFeedEventWorker"

2) OpenERP - creating/updating any saleable item (test/panel, drug, radiology tests, procedures, registration fee etc)

Suggestions: Instead of just handling specific types, we should refactor the code to handle any "saleable" item (concept). Note, the "openerp-atomfeed-service" is like an integrator service, which processes information from the feed and then makes XML RPC calls to OpenERP. Check here
These XML RPC calls to create/update products in ERP, are supported through some specific ERP custom modules - openerp-modules. These python codes would also need to be refactored. Note, its important that the right category needs to be assigned for the "products" (OpenMRS saleable concepts).

(The following cases are to be detailed)
Further, the consumer sides also need to refactored for
1) Handling "creation of the orders" - when an order is raised, we just check the encounter details. We need to ensure that we process the orders only for saleable products
2) A saleable concept can be turned off; example - a test that was done before is no longer done now. We need to handle such scenario as well.

Building the bahmni-erp-connect rpm
1. in "openerp-atomfeed-service": mvn clean install

  • this will generate "openerp-atomfeed-service.war" under "openerp-atomfeed-service/target/"

2. Copy the war file to "bahmni-package/bahmni-erp-connect/resources/"

  • cd /bahmni/bahmni-package/

  • ./gradlew bahmni-erp-connect:buildRpm (to build the rpm)

(NOTE: you might want to bump up the version of the rpm. To do so, you can change "bahmni-package/gradle.properties" => bahmniRelease)

3. Copy the rpm to target machine (Say /tmp/)

  • rpm -e bahmni-erp-connect (uninstall previous version)

  • install by command: rpm -Uvh <bahmni-erp-connect-0.92-1.noarch.rpm>

4. in this process, you might find that the JAVA path for the service is wrong. So you need to update
the "JAVA_HOME" to point to the right JRE root directory (e.g. /usr/java/jre1.8.0_131)
So, update in the conf below mentioned below

  • /opt/bahmni-erp-connect/etc/bahmni-erp-connect.conf

5. its useful to have more detailed log, so you would want to change the /opt/bahmni-erp-connect/bahmni-erp-connect/WEB-INF/classes/log4j.xml file

  • logs are kept in /var/log/bahmni-erp-connect/ and also /home/bahmni/nohup.out

  • change the log4j.xml file for the root priority level to "INFO" or "DEBUG"

Pull Requests

bahmni-core:
1. https://github.com/Bahmni/bahmni-core/pull/44
2. Commit: https://github.com/Bahmni/bahmni-core/commit/7ef9faf58e242c90f47b2dd1c34bc69b72a9439b
3. Commit: https://github.com/Bahmni/bahmni-core/commit/c49e5dcd11d42e00476a3b88ef7d7112cce434c6
openerp-atomfeed-service:
1. https://github.com/Bahmni/openerp-atomfeed-service/pull/5
2. ?
openerp-modules :
1. https://github.com/Bahmni/openerp-modules/pull/12

Activity

Show:
Angshuman Sarkar
September 17, 2019, 10:10 AM

PR for Odoo-modules:

Angshuman Sarkar
September 17, 2019, 1:40 PM

Updated above PRs for renaming “sellable” to “saleable”

new PR for bahmni-core:

Romain Buisson
September 18, 2019, 10:13 AM

, thanks for the PRs.

They are merged now.

Notes have been left in about know issue when saleable is set to false.

laxman manandhar
October 2, 2019, 5:35 AM

Hi , ,

I am reviewing the feature, I have setup my local machine with above changes

some observations :

  1. As per Acceptance criteria #3,”As a Bahmni implementer, i should get some concept-attributes out of the box - saleable (true/false), saleable_type (product/service), category(string) which i can use to assign values to concepts” But when i build changes such concept attirbutes were not created

  2. Then I created these attributes manually and created concept, but that does not not create any product/service in odoo.

Let me know if I am missing some configurations or anything else ?

 

 

 

laxman manandhar
October 2, 2019, 10:29 AM

Its working fine after replacing reference-data omod and restarting bahmni-erp-connect service
thanks.

Assignee

Ivange Larry

Reporter

Arjun

Labels

None

Units

None

PercentDone

None

DueTime

None

Clients

None

External issue ID

None

UAT Assignee

None

Reviewer

None

Sprint

Fix versions

Configure