-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EA-184 - Move reporting module to an aware_of dependency #229
Changes from 11 commits
cf7c477
94482cf
00bfd8d
417d1a6
db67858
03d6b78
4addd76
7786eeb
5ab37a0
79fc27d
cf56de4
0bccb57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>emrapi</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>emrapi-api-reporting</artifactId> | ||
<packaging>jar</packaging> | ||
<name>EMR API Reporting API</name> | ||
|
||
<properties> | ||
<reportingVersion>1.25.0</reportingVersion> | ||
<serialization.xstreamVersion>0.2.16</serialization.xstreamVersion> | ||
<calculationVersion>1.3.0</calculationVersion> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-api</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
<type>test-jar</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>reporting-api</artifactId> | ||
<version>${reportingVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>reporting-api-1.10</artifactId> | ||
<version>${reportingVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>reporting-api-2.0</artifactId> | ||
<version>${reportingVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>reporting-api-2.2</artifactId> | ||
<version>${reportingVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>serialization.xstream-api</artifactId> | ||
<version>${serialization.xstreamVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>serialization.xstream-api-1.10</artifactId> | ||
<version>${serialization.xstreamVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>serialization.xstream-api-2.0</artifactId> | ||
<version>${serialization.xstreamVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>calculation-api</artifactId> | ||
<version>${calculationVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test/resources</directory> | ||
<includes> | ||
<include>**/*.properties</include> | ||
<include>**/*.xml</include> | ||
</includes> | ||
<filtering>true</filtering> | ||
</testResource> | ||
<testResource> | ||
<directory>src/test/resources</directory> | ||
<excludes> | ||
<exclude>**/*.properties</exclude> | ||
<exclude>**/*.xml</exclude> | ||
</excludes> | ||
<filtering>false</filtering> | ||
</testResource> | ||
</testResources> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.openmrs.module.emrapi.adt.reporting.evaluator; | ||
|
||
import org.openmrs.Location; | ||
import org.openmrs.Visit; | ||
import org.openmrs.annotation.Handler; | ||
import org.openmrs.annotation.OpenmrsProfile; | ||
import org.openmrs.module.emrapi.adt.AdtService; | ||
import org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery; | ||
import org.openmrs.module.reporting.evaluation.EvaluationContext; | ||
import org.openmrs.module.reporting.evaluation.EvaluationException; | ||
import org.openmrs.module.reporting.evaluation.context.VisitEvaluationContext; | ||
import org.openmrs.module.reporting.query.visit.VisitQueryResult; | ||
import org.openmrs.module.reporting.query.visit.definition.VisitQuery; | ||
import org.openmrs.module.reporting.query.visit.evaluator.VisitQueryEvaluator; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
@Handler(supports = AwaitingAdmissionVisitQuery.class) | ||
@OpenmrsProfile(modules = { "reporting:*" }) | ||
public class AwaitingAdmissionVisitQueryEvaluator implements VisitQueryEvaluator { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for retrieving visits awaiting admission was moved into the AdtService so that it can be used without relying on the reporting module. Then, the reporting module evaluator below was updated to call the implementation in the AdtService. None of the unit tests were changed, and all continue to pass. |
||
@Autowired | ||
AdtService adtService; | ||
|
||
@Override | ||
public VisitQueryResult evaluate(VisitQuery visitQuery, EvaluationContext evaluationContext) throws EvaluationException { | ||
AwaitingAdmissionVisitQuery eq = (AwaitingAdmissionVisitQuery) visitQuery; | ||
Location location = eq.getLocation(); | ||
Collection<Integer> patientIds = null; | ||
Collection<Integer> visitIds = null; | ||
if (evaluationContext.getBaseCohort() != null) { | ||
patientIds = evaluationContext.getBaseCohort().getMemberIds(); | ||
} | ||
if (evaluationContext instanceof VisitEvaluationContext) { | ||
VisitEvaluationContext visitEvaluationContext = (VisitEvaluationContext) evaluationContext; | ||
if (visitEvaluationContext.getBaseVisits() != null) { | ||
visitIds = visitEvaluationContext.getBaseVisits().getMemberIds(); | ||
} | ||
} | ||
List<Visit> results = adtService.getVisitsAwaitingAdmission(location, patientIds, visitIds); | ||
VisitQueryResult result = new VisitQueryResult(visitQuery, evaluationContext); | ||
for (Visit v : results) { | ||
result.add(v.getVisitId()); | ||
} | ||
return result; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.openmrs.module.emrapi; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.openmrs.module.Module; | ||
import org.openmrs.module.ModuleFactory; | ||
import org.openmrs.test.BaseModuleContextSensitiveTest; | ||
|
||
import java.io.File; | ||
|
||
public abstract class BaseReportingTest extends BaseModuleContextSensitiveTest { | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
Module mod = new Module("", "reporting", "", "", "", "1.25.0"); | ||
mod.setFile(new File("")); | ||
ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() { | ||
ModuleFactory.getStartedModulesMap().remove("reporting"); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> | ||
|
||
<!-- | ||
From applicationContext-service.xml in openmrs-api | ||
Needed to override and add hibernate mappings to the classpath since omod is not packaged yet | ||
--> | ||
<bean id="sessionFactory" class="org.openmrs.api.db.hibernate.HibernateSessionFactoryBean"> | ||
<property name="configLocations"> | ||
<list> | ||
<value>classpath:hibernate.cfg.xml</value> | ||
<value>classpath:test-hibernate.cfg.xml</value> | ||
</list> | ||
</property> | ||
<property name="mappingJarLocations"> | ||
<ref bean="mappingJarResources"/> | ||
</property> | ||
<property name="packagesToScan"> | ||
<list> | ||
<value>org.openmrs</value> | ||
</list> | ||
</property> | ||
<!-- default properties must be set in the hibernate.default.properties --> | ||
</bean> | ||
</beans> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE hibernate-configuration PUBLIC | ||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" | ||
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> | ||
|
||
<hibernate-configuration> | ||
<session-factory> | ||
<mapping resource="Provider.hbm.xml"/> | ||
<mapping resource="ProviderRole.hbm.xml"/> | ||
<mapping resource="ExportedPackage.hbm.xml" /> | ||
<mapping resource="ImportedPackage.hbm.xml" /> | ||
<mapping resource="ImportedItem.hbm.xml" /> | ||
<mapping resource="ReportDesign.hbm.xml" /> | ||
<mapping resource="MetadataSource.hbm.xml"/> | ||
<mapping resource="MetadataTermMapping.hbm.xml"/> | ||
<mapping resource="MetadataSet.hbm.xml"/> | ||
<mapping resource="MetadataSetMember.hbm.xml"/> | ||
</session-factory> | ||
</hibernate-configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I create a new maven sub-module, which will result in a jar that can be conditionally loaded. All of the reporting-related dependencies are able to be moved in here.