Hibernate mapping in Patient Matching Module

Hi everyone,

I am currently working on the task PTM-88. For that it is required to create a database table to hold true matches & non matches.

The problem is, there is no hibernate xml configuration file in the Patient Matching Module. I looked at the hibernate.cfg.xml file in the openmrs-core but even I couldn’t find the mapping for tables which are related to Patient Matching Module. (for example there is no mapping for tables like patientmatching_report, patientmatching_configuration, patientmatching_matching_attribute, patientmatching_matchingset )

So can anyone help me to figure it out how the hibernate mapping for the existing patient matching tables has been done and how should I do it for the PTM-88 task?

1 Like

@lahiruj, the Platform does not create any tables for modules. All the tables listed in the core hibernate.cfg.xml are core tables that are part of the core API.

Modules are responsible for adding their own tables. The convention is that modules use their module ID as a prefix (as a way of namespacing to avoid conflicts between tables). So, ideally, any table created by the patientmatching module would begin with “patientmatching_”. If you look at the hibernate config in the patient matching module PatientMatchingReportMetadata.hbm.xml, you will notice that it does not properly follow this convention, using the table name metadata_report instead of patientmatching_metadata_report as would be expected. <aside>While it doesn’t fall in the scope of your GSoC project, if there isn’t a Patient Matching JIRA issue for changing that table name to patientmatching_metadata_report, please make one.</aside>.

Are there tables other than metadata_report being created by the patientmatching module?

Yes @burke there are set of tables and you can find them here. Those tables are being used for the patientmatching process.

The problem is @burke I created a table according to the convention ( patientmatching_[name] ) but I really have no idea how to map the newly created table with the java class since there is no hibernate.cfg.xml file in the patientmatching module. In the resource directories of both api & omod, there is no file with the .cfg.xml extension. ( But anyway some of already existing java classes are mapped with the patientmatching_ tables. I couldn’t figure out how it was done. )

Note : Hibernate mapping has not been done using annotations.

sure I will do it.

@lahiruj, in the OMOD resources folder that you shared there are a whole bunch of files with an hbm.xml extension. These map from hibernate to a specific Java class. No module has a hibernate.cfg.xml. I think normally you also have to list the hbm.xml files in your config.xml, but this module does something unusual there.

Incidentally there is also one hbm.xml file in the API folder. The correct place for these is API, not OMOD (but back when we first started using maven we were incorrectly putting these in OMOD instead of API. Anyway, you may not want to take on modernizing everything.