Write rule for data integrity module

Hi All,

I was exploring data integrity module and I used sample rule given in the github. I included it in the dataintegrity by inserting it into the dataintegrity_rules table but I’m not able to run it.

When I put it inside main directory (/api/src/main/java/org/openmrs/module/dataintegrity), I got groovy.lang.MissingMethodException: No signature of method .

Complete log file.

@ssmusoke fyi

@shivtej Can I see the code for the rule and the sample data that you entered?

  1. Example rules can be seen here https://github.com/METS-Programme/openmrs-module-aijar/tree/master/api/src/main/java/org/openmrs/module/aijar/dataintegrity

  2. The generated SQL for these rules is https://gist.github.com/ssmusoke/71214209f66e84a2d3c18de8ee441839

My recommendation for moving forward is as follows:

  1. Using SDK create a Reference Application 2.6-SNAPSHOT server and generate custom data using the reference demo data module - and add the latest version of the Data Integrity module

  2. Create a custom module based on the Reference Application archetype which will be used to host the rules

  3. This is also where the dashboard widget will be configured

Do let me know if you run into any problems doing this

thanks @ssmusoke .

I’m using SDK for the server and I used the sample rule given in the readme file of github repo of data integrity module. Also I have used the reference application demo data with the DINT omod which I complied from the fork of the module.

I’m getting this error when I’m running this command mvn clean install openmrs-sdk:run -DserverId=dint :

[INFO] Scanning for projects… [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] Basicexample [INFO] Basicexample API [INFO] Basicexample OMOD [WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available [WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failure to find org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in http://mavenrepo.openmrs.org/nexus/content/repositories/public was cached in the local repository, resolution will not be reattempted until the update interval of openmrs-repo has elapsed or updates are forced [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building Basicexample 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ basicexample — [INFO] [INFO] — buildnumber-maven-plugin:1.1:create (default) @ basicexample — [INFO] Checking for local modifications: skipped. [INFO] Updating project files from SCM: skipped. [INFO] ShortRevision tag detected. The value is ‘6’. [INFO] Executing: /bin/sh -c cd /home/shivang/basicexample && git rev-parse --verify --short=6 HEAD [INFO] Working directory: /home/shivang/basicexample [INFO] Storing buildNumber: 0 at timestamp: 1492709937788 [INFO] ShortRevision tag detected. The value is ‘6’. [INFO] Executing: /bin/sh -c cd /home/shivang/basicexample && git rev-parse --verify --short=6 HEAD [INFO] Working directory: /home/shivang/basicexample [INFO] Storing buildScmBranch: UNKNOWN_BRANCH [INFO] [INFO] — maven-java-formatter-plugin:0.4:format (default) @ basicexample — [INFO] Using ‘UTF-8’ encoding to format source files. [INFO] Number of files to be formatted: 0 [INFO] [INFO] — maven-install-plugin:2.4:install (default-install) @ basicexample — [INFO] Installing /home/shivang/basicexample/pom.xml to /home/shivang/.m2/repository/org/openmrs/module/basicexample/1.0.0-SNAPSHOT/basicexample-1.0.0-SNAPSHOT.pom [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building Basicexample API 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ basicexample-api — [INFO] Deleting /home/shivang/basicexample/api/target [INFO] [INFO] — buildnumber-maven-plugin:1.1:create (default) @ basicexample-api — [INFO] [INFO] — maven-java-formatter-plugin:0.4:format (default) @ basicexample-api — [INFO] Using ‘UTF-8’ encoding to format source files. [INFO] Number of files to be formatted: 12 [INFO] Successfully formatted: 0 file(s) [INFO] Fail to format : 0 file(s) [INFO] Skipped : 12 file(s) [INFO] Approximate time taken: 0s [INFO] [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ basicexample-api — [INFO] Using ‘UTF-8’ encoding to copy filtered resources. [INFO] Copying 5 resources [INFO] Copying 0 resource [INFO] skip non existing resourceDirectory /home/shivang/basicexample/api/src/main/webapp [INFO] skip non existing resourceDirectory /home/shivang/basicexample/api/src/main/webapp [INFO] [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ basicexample-api — [INFO] Changes detected - recompiling the module! [INFO] Compiling 10 source files to /home/shivang/basicexample/api/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/shivang/basicexample/api/src/main/java/org/openmrs/module/basicexample/dataintegrity/IncompleteExposedInfantInformation.java:[33,71] diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) [ERROR] /home/shivang/basicexample/api/src/main/java/org/openmrs/module/basicexample/dataintegrity/IncompleteARTInformation.java:[26,71] diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) [ERROR] /home/shivang/basicexample/api/src/main/java/org/openmrs/module/basicexample/dataintegrity/InvalidARTEncounters.java:[27,71] diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) [INFO] 3 errors [INFO] ------------------------------------------------------------- [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Skipping Basicexample [INFO] This project has been banned from the build due to previous failures. [INFO] ------------------------------------------------------------------------ [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Basicexample … SUCCESS [ 1.069 s] [INFO] Basicexample API … FAILURE [ 2.304 s] [INFO] Basicexample OMOD … SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.474 s [INFO] Finished at: 2017-04-20T23:09:00+05:30 [INFO] Final Memory: 30M/221M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project basicexample-api: Compilation failure: Compilation failure: [ERROR] /home/shivang/basicexample/api/src/main/java/org/openmrs/module/basicexample/dataintegrity/IncompleteExposedInfantInformation.java:[33,71] diamond operator is not supported in -source 1.6 [ERROR] (use -source 7 or higher to enable diamond operator) [ERROR] /home/shivang/basicexample/api/src/main/java/org/openmrs/module/basicexample/dataintegrity/IncompleteARTInformation.java:[26,71] diamond operator is not supported in -source 1.6 [ERROR] (use -source 7 or higher to enable diamond operator) [ERROR] /home/shivang/basicexample/api/src/main/java/org/openmrs/module/basicexample/dataintegrity/InvalidARTEncounters.java:[27,71] diamond operator is not supported in -source 1.6 [ERROR] (use -source 7 or higher to enable diamond operator) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :basicexample-api

@shivtej What JDK version are you using?

seems to point to 1.6, you need to upgrade to 1.7 as a minimum

@ssmusoke, I’m using 1.7 . And the $JAVA_HOME is point to a symoblic link file whose link I change whenever necessary from jdk 1.7 to jdk 1.8 and vice-versa. I don’t even have 1.6 on my system.

What version of the Reference application did you use for your servers? if you used 2.5 or 2.6-SNAPSHOT then you need to have Java 8.

I’m using 2.4 version of Reference Application. Does it work with jdk 1.7 ?

@shivtej see instructions that I provided above … this will help avoid further problems

@ssmusoke could you please explain more about this?

https://wiki.openmrs.org/display/docs/OpenMRS+SDK+3.1#OpenMRSSDK3.1-Creatingprojects

@ssmusoke, I did exactly what you’ve mentioned but I’m still getting the same error. Attaching some information: Maven

OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0 Apache Maven 3.3.9 (NON-CANONICAL_2015-11-23T13:17:27+03:00_root; 2015-11-23T15:47:27+05:30) Maven home: /opt/maven Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: “linux”, version: “4.10.6-1-arch”, arch: “amd64”, family: “unix”

Can you share your code via Github

Here is the repo link: https://github.com/shivtej1505/openmrs-module-maggi Rule are added here: https://github.com/shivtej1505/openmrs-module-maggi/tree/master/api/src/main/java/org/openmrs/module/maggi/dataintegrity

Thanks!

@ssmusoke, did you find the problem ?

  1. You need to add a dependency on the data integrity module in the pom.xml both for the project and the api sub-module like https://github.com/METS-Programme/openmrs-module-aijar/blob/4f4d8a79845754e442255a8840268f03be3c979c/pom.xml#L220-L225

  2. The rules from the UgandaEMR module may not work for you as the missing data may not be there in you rmodule.

  3. We can start with simple rules that can be built from the standard OpenMRS dataset for example making a patient below 5 years having a relationship parent.

Now I’m able to see the rules defined in 'data quality` section but I’m not able to run it due to some error. Here is the log . I added dataintegrity dependency in root and api’s pom.xml . I’ve also added the rule in ‘dataintegrity_rule’ table.

@ssmusoke, @maany, @dkayiwa could you please help me here ? Everything is working fine except I’m not able to run validation rule. Is it possible to proceed with this error ?

@shivtej You should delete the rule from the data_integrity rule table. Once you create the rule in your API, the data integrity module will load it on module startup with the correct metadata to enable it to run.

Also it is always good practice to setup unit tests to test your rule with data before you attempt to run it which means that it will work as expected. As you keep adding more functionality

@ssmusoke, I did delete the rule from the table but the data integrity module isn’t loading the rule. I also added various module related to metadata (metadatadeploy, metadatamapping and metadatasharing) on the pom.xml of api submodule but I’m not able to see the rule.

Kindly excuse me if I’m getting stuck at very basic things. I don’t have much experience with Maven, but I assure you that I will have grip over it very quickly.

Please also let me know how can I test the rule, I really don’t have any clue about it. Thanks a lot for your help.