Child pages
  • Concept Dataset Generation Maven Plugin
Skip to end of metadata
Go to start of metadata

Primary mentor

Rowan Seymour

Backup mentor

TBD

Assigned to

TBD

Background

It is challenge for developers, especially those working on large distributions, to maintain test data which is consistent with their production environments. For example, developers may want to write unit tests for an indicator report that includes most of the metadata and concepts used by the distribution. 

  • Metadata Deploy module addresses this challenge for a lot metadata types - but doesn't include concepts, as these don't lend themselves to being described in code. Also distributions commonly deploy concepts via a SQL dump (e.g. CIEL) 
  • PIH team have written code to generate a MariaDB copy of a production database but there's no easy way to specify what content should be included.

This project would seek to provide a mechanism by which developers can easily generate a test dataset file for use in unit tests, which includes a configurable subset of their entire concept dictionary. It's important that developers can configure what is included in the final dataset file so that they can keep it as small as possible to keep unit test times as fast as possible - it's obviously not feasible to load an entire dictionary like CIEL into memory for each unit test.

Project Champions

  • TBD

Skills Needed

  • Java coding proficiency
  • Basic SQL knowledge

Objectives

  • Produce a Maven plugin which can generate concept test data
  • Plugin should be configurable in terms of which locales to include, which reference term sources.
  • Plugin should be modular and support different sources of concept details (JDBC, OpenConceptLab API)

Extra Credit

  • [ Possibly ] work with OpenConceptLab to provide API support on their end

Contact

  • Leave a comment below

Design Proposal

It's common for an OpenMRS distribution to list the concepts it uses in classes of static constants, e.g.

Example dictionary class
public class Dictionary {
  public static final String ABACAVIR = "70056AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
  public static final String ADULT_INPATIENT_SERVICE = "160536AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
  public static final String ANTENATAL_CASE_NUMBER = "161655AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
  ...
}

Classes like this would be the inputs for the plugin. The plugin when invoked would:

  1. Parse out all of the constant fields of such classes
  2. Include dependent concepts (e.g. set members and answers)
  3. Connect to database and fetch data for all of those concepts
  4. Serialize to an XML dataset file

The output file would use the XML dataset format currently used to provide test data in uni tests, e.g.

Example output dataset file
<dataset>
  <concept concept_id="70056" retired="0" datatype_id="4" class_id="3" is_set="0" creator="1" date_created="2006-12-17 00:00:00.0" version="" changed_by="1" date_changed="2012-11-28 20:05:26.0" retired_by="1" uuid="70056AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"/>
  <concept_name concept_id="70056" name="Ziagen" locale="en" creator="1" date_created="2007-10-18 09:35:54.0" concept_name_id="100397" voided="0" voided_by="1" void_reason="" uuid="100397BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" locale_preferred="false"/>
  <concept_name concept_id="70056" name="ABACAVIR" locale="en" creator="1" date_created="2006-12-17 00:00:00.0" concept_name_id="3277" voided="0" voided_by="1" uuid="3277BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" concept_name_type="FULLY_SPECIFIED" locale_preferred="true"/>
  <concept_name concept_id="70056" name="ABC" locale="en" creator="1" date_created="2012-11-28 20:05:26.0" concept_name_id="110802" voided="0" voided_by="1" uuid="110802BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" concept_name_type="SHORT" locale_preferred="false"/>
  <concept_name concept_id="160536" name="Adult inpatient service" locale="en" creator="1" date_created="2012-06-12 02:19:56.0" concept_name_id="108856" voided="0" voided_by="1" uuid="108856BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" concept_name_type="FULLY_SPECIFIED" locale_preferred="true"/>
  <concept concept_id="161655" retired="0" datatype_id="1" class_id="7" is_set="0" creator="1" date_created="2013-04-26 14:32:16.0" version="" changed_by="1" retired_by="1" uuid="161655AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"/>
  <concept_numeric concept_id="161655" units="" precise="0"/>
  <concept_name concept_id="161655" name="ANC ID" locale="en" creator="1" date_created="2013-04-26 14:32:16.0" concept_name_id="123687" voided="0" voided_by="1" uuid="123687BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" concept_name_type="SHORT" locale_preferred="false"/>
  ...
</dataset>
	

The plugin itself could be configured in a project's POM something like this example:

Example plugin configuration
<plugin>
  <groupId>org.openmrs.contrib.maven</groupId>
  <artifactId>conceptdataset-maven-plugin</artifactId>
  <version>1.0</version>
  <configuration>
    <includeClasses>
      <includeClass>org.openmrs.module.kenyaemr.Dictionary</includeClass>
    </includeClasses>
    <connectionUrl>jdbc:mysql://localhost/openmrs</connectionUrl>
    <outputFile>${basedir}/src/test/resources/test-concepts.xml</outputDirectory>
  </configuration>
</plugin>

And when run would request database credentials, e.g.

mvn conceptdataset:generate
Enter database username: root
Enter database password: ********

 

 

  • No labels

10 Comments

  1. Hi Rowan,

    I'm Ujitha Iroshan ,third year undergraduate from Department of Computer Science and Engineering University of Moratuwa Sri Lanka.And currently doing my internship in WSO2 inc. I'm very interest in this project and I would like to join this project as my GSoC project 2014.  I have worked in several projects with Java,Mysql and Maven  so I think it would be an advantage for the project. I would like to know more details about this project and how can I contact you in order to discuss about the project?.

    Thank you

     

    1. Hi Ujitha, I can see your email address on the mailing list so I'll drop you an email...

  2. Thanks for the details Rowan 

  3. Hey!!

    Can you give me your email id?? I have loads of questions to ask.

     

    1. rowanseymour at gmail dot com

  4. Hi Rowan.

    I have been a very active member in the OPENMRS community during the past three months,I have fixed couple of bugs related to Hibernate and Liquibase issues and many other issues as well.I am pretty much interested in working on this project. Is there anything that I should read before submitting the proposal. Other than what is mentioned here. Thank you. Waiting for a quick reply. (smile)

  5. Rowan, please consider using https://github.com/openmrs/openmrs-module-dataexchange for this project.

    I've written this module to export concepts in the dbunit format, which can be easily imported in unit tests. We use this module in OpenMRS 2.x to export and import all concepts included in the reference application.

    See http://devtest02.openmrs.org:8080/openmrs/module/dataexchange/export.form and http://devtest02.openmrs.org:8080/openmrs/module/dataexchange/import.form

    The UI is pretty harsh, but Concepts exported from the export page are ready to install calling executeXmlDataSet in tests or can be imported into another instance of OpenMRS from the import page. There's also API you can use in some module's activator to import them automatically, see https://github.com/openmrs/openmrs-module-referencemetadata/blob/master/api/src/main/java/org/openmrs/module/referencemetadata/ReferenceMetadataActivator.java#L86

  6. Also, since the time of writing, I have extended the metadatadeploy module to also support creating concepts.

    But it's tedious to create these manually, so it would be great if that mechanism could read input that was exported from OCL.

  7. Rafal Korytkowski, Darius Jazayeri I'm not on that project anymore but the KenyaEMR guys might have a use for it. One of the last things I did was create Distro Tools Maven Plugin and the plan was that in conjunction with this project, a developer could just add a concept identifier to a file, run a maven task, and have it generate files for referencing that concept in code, forms and tests (by fetching data from OCL). That was the dream (wink)

  8. I would like to work on this project. Request for more information