Help regarding module development

0 views
Skip to first unread message

Rakshit Wadhwa

unread,
May 24, 2014, 1:37:46 PM5/24/14
to d...@openmrs.org
Hi

I am new to OpenMRS development.

Can someone please suggest a sample or existing module that interact with more than one table within OpenMRS, like patients, provider, etc and do something over top of that.
I took a look at example modules, but looks like they are too old, I tried fixing and running (patient visit module) https://github.com/openmrs/openmrs-module-example-spring-mvc-annotation but looks like too many errors to resolve. I am searching something on similar lines.
It would be great if you can share some module's source code that is in working state, and interacts with some OpenMRS components.

I want to get started with my module that takes data directly from medical device(ECG, pulse-ox etc) and populate the custom tables and views, that we will be writing.
We are at a stage when we have to get started with the module as soon as possible.
Any help in this regard is highly appreciated.


Thanks and regards
Rakshit

Harsha Kumara

unread,
May 24, 2014, 1:58:33 PM5/24/14
to d...@openmrs.org
Hi Rakshit,

I will provide some module source codes which uses services from core. Please find [1],[2],[3] and [4] as useful resources.Wiki page in [5] gives details for generate openmrs module structure[5]. 
Please find openmrs developer guide in [6] which further describe the module creation.



Thanks,
Harsha


--
OpenMRS Developers: http://go.openmrs.org/dev
Post: d...@openmrs.org | Unsubscribe: dev+uns...@openmrs.org
Manage your OpenMRS subscriptions at https://id.openmrs.org/

To unsubscribe from this group and stop receiving emails from it, send an email to dev+uns...@openmrs.org.



--
Harsha Kumara
Software Engineer
WSO2 Inc.
Sri Lanka.

Rakshit Wadhwa

unread,
May 25, 2014, 7:04:19 AM5/25/14
to d...@openmrs.org
Thanks Harsha

I took a look into the modules you shared, however I could not find one that interacts with observations, concepts, encounter, make some table which is related to these tables and do something over it.

Any module working on similar lines will be a great help.
Also if you have a working version of https://github.com/openmrs/openmrs-module-example-spring-mvc-annotation or something like that will be a great help. I was trying to recreate a similar module myself, but having some issues
(for instance:  'Obs #1202' failed to validate with reason: concept: must have a datatype)  and many more.

Any help in such regards would really escalate our work.


Thanks and regards
Rakshit

Harsha Kumara

unread,
May 25, 2014, 7:10:45 AM5/25/14
to d...@openmrs.org
You can accesss those services as spring services from core. For example,if you need any information about patients, youncan access them via Context.getPaientService(). Likewise there are enounter service,provider service and etc for access those data. Creating table is with those data is easy. You will needs to specify hibernate mappings and liquibase.xml. Also look at patient narrative upload in openmrs github. 

Rakshit Wadhwa

unread,
May 26, 2014, 10:26:02 AM5/26/14
to d...@openmrs.org
Thanks Harsha

That was very useful. I created a sample module that takes patient, user, and allows setting appointment .
I have a small implementation doubt. I created a table, it got populated perfectly, and the module worked perfectly as expected.

However just to test things up, I tried creating another table by just renaming the name of table in sqldiff and in my hbm.xml. When I did so,I got the following error :

org.springframework.dao.InvalidDataAccessResourceUsageException
Could not execute JDBC batch update; SQL [insert into blah (start_datetime, end_datetime, patient_id, location_id, provider_id, id) values (?, ?, ?, ?, ?, ?)];
 nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
However if I rename the table name again to the original, it works fine.

My model class looks like: http://pastebin.com/h5DdNNsQ

I used table name as "appointment2" first time, and table got greated and populated, and module worked fine.
When I change the table  name in both hbm.xml and sqldiff.xml to something else, say "blah", I get the above mentioned error, and the even the table is not created.

I wanted to try on different tables for testing purpose.

Would be great if you can give some suggestion.

Thanks and regards
Rakshit

Rakshit Wadhwa

unread,
May 26, 2014, 11:02:14 AM5/26/14
to d...@openmrs.org
Changing the version helped to get this resolved.
However would love to know how does it maintain the version information of tables.

Thanks :)


Harsha Kumara

unread,
May 26, 2014, 1:06:42 PM5/26/14
to d...@openmrs.org
Now sqldiff.xml is obsolete. We are now using liquibase for database management. You can specify your tables in liquibase. Please refer [1].  I didn't get what you mean by version change? 

Reply all
Reply to author
Forward
0 new messages