Skip to content

Commit

Permalink
MSHR-75: Resolved upgrade issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kaweesi committed Mar 18, 2016
1 parent ace4960 commit 73b9b1c
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 99 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.project
.settings/
.svn/
api/.classpath
api/.gitignore
api/.project
api/.settings/
omod/.classpath
omod/.gitignore
omod/.project
omod/.settings/
28 changes: 20 additions & 8 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
<description>API project for MOH-TRAC : PMTCT</description>

<dependencies>
<!--
Add other dependencies from lib:
<dependency>
<groupId>org.other.library</groupId>
<artifactId>library-name</artifactId>
</dependency>
-->

<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
Expand All @@ -30,6 +22,26 @@
<artifactId>openmrs-web</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openMRSVersion}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openmrs.test</groupId>
<artifactId>openmrs-test</artifactId>
<version>${openMRSVersion}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>mohtracportal-api</artifactId>
<scope>provided</scope>
<version>${mohtracPortalVersion}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static String getEncounterTypeNameById(String encounterTypeId) {
return "";
EncounterType enctype = null;
try {
enctype = Context.getEncounterService().getEncounterType(Integer.parseInt(encounterTypeId));
enctype = encounterTypeId != null && !encounterTypeId.equals("null") ? Context.getEncounterService().getEncounterType(Integer.parseInt(encounterTypeId)) : null;
}
catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ public void exportDrugToCSVFile(HttpServletRequest request, HttpServletResponse
for (DrugOrder drugOrder : drugOrderList) {
count += 1;
outputStream.println(count + ", " + drugOrder.getDrug().getName() + ", " + drugOrder.getDose() + " "
+ drugOrder.getUnits() + ", " + drugOrder.getFrequency() + ", " + drugOrder.getInstructions() + ", "
+ sdf.format(drugOrder.getStartDate()) + ", " + sdf.format(drugOrder.getDiscontinuedDate()));
+ drugOrder.getDoseUnits().getName().getName() + ", " + drugOrder.getFrequency() + ", " + drugOrder.getInstructions() + ", "
+ sdf.format(drugOrder.getEffectiveStartDate()) + ", " + sdf.format(drugOrder.getEffectiveStopDate()));
}

outputStream.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static boolean isMohTracPortalConfigured() throws Exception {
public static boolean isConfigured() throws Exception {
GlobalProperty gp = Context.getAdministrationService()
.getGlobalPropertyObject("pmtct.configured");
return (gp != null) ? ((gp.getPropertyValue().compareToIgnoreCase(
return (gp != null && gp.getPropertyValue() != null) ? ((gp.getPropertyValue().compareToIgnoreCase(
"true") == 0) ? true : false) : true;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public static int getLocalHealthCenterIdentifierTypeId() throws Exception {
*/
public static int getCPNEncounterTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.encounterType.anc");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -136,7 +136,7 @@ public static int getCPNEncounterTypeId() throws Exception {
*/
public static int getMaternityEncounterTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.encounterType.maternity");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -149,7 +149,7 @@ public static int getMaternityEncounterTypeId() throws Exception {
*/
public static int getMotherFollowUpEncounterTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.encounterType.motherfollowup");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -161,7 +161,7 @@ public static int getMotherFollowUpEncounterTypeId() throws Exception {
*/
public static int getPCRTestEncounterTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.encounterType.pcr");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -174,7 +174,7 @@ public static int getPCRTestEncounterTypeId() throws Exception {
*/
public static int getSerology9MonthEncounterTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.encounterType.serology9month");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -188,7 +188,7 @@ public static int getSerology9MonthEncounterTypeId() throws Exception {
public static int getSerology18MonthEncounterTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService()
.getGlobalPropertyObject("pmtct.encounterType.serology18month");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -209,79 +209,79 @@ public static List<GlobalProperty> getNeededEncounterType() {
*/
public static int getBornAliveConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.concept.bornalive");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getBornDeadConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.concept.borndead");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getBornStatusConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.concept.bornstatus");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getHivTestInDeliveryRoomConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService()
.getGlobalPropertyObject("pmtct.concept.hivtestindeliveryroom");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getPatientArrivedWithPartnerConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(
"pmtct.concept.patientarrivedwithpartner");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getPartnerTestedSeparatelyConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(
"pmtct.concept.partnertestedseparately");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getHivTestDateForPartnerConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.concept.hivtestdateofpartner");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getResultHivTestReceptionDateConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(
"pmtct.concept.resulthivtestreceptiondate");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getSyphilisTestDateConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.concept.syphilistestdate");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getResultSyphilisTestReceptionDateConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(
"pmtct.concept.resultsyphilistestreceptiondate");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getReceptionDateCD4CountConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService()
.getGlobalPropertyObject("pmtct.concept.receptiondatecd4count");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

public static int getReceptionDateBedNetConceptId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.concept.receptiondatebednet");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -304,7 +304,7 @@ public static List<GlobalProperty> getNeededConcept() {
*/
public static Integer getDrugOrderTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.ordertype");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -317,7 +317,7 @@ public static Integer getDrugOrderTypeId() throws Exception {
*/
public static Integer getCPNIdentifierTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.identifiertype.anc");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}

Expand All @@ -330,7 +330,7 @@ public static Integer getCPNIdentifierTypeId() throws Exception {
*/
public static Integer getRelationshipTypeId() throws Exception {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject("pmtct.relationshiptype.motherchild");
return (gp != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
return (gp != null && gp.getPropertyValue() != null && gp.getPropertyValue().trim().compareTo("") != 0) ? Integer.parseInt(gp.getPropertyValue())
: null;
}
}
46 changes: 46 additions & 0 deletions api/src/main/resources/moduleApplicationContext.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">

<!-- ========================= Services ========================= -->

<bean parent="serviceContext">
<property name="moduleService">
<list>
<value>org.openmrs.module.pmtct.db.PmtctService</value>
<bean
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<bean
class="org.openmrs.module.pmtct.db.hibernate.HibernatePmtctDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</property>
<property name="preInterceptors">
<list>
<ref bean="authorizationInterceptor" />
</list>
</property>
<property name="transactionAttributeSource">
<bean
class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
</property>
</bean>
</list>
</property>

</bean>
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.openmrs.module.pmtct.service;
import org.junit.Assert;
import org.junit.Test;
import org.openmrs.api.context.Context;
import org.openmrs.module.pmtct.db.PmtctService;
import org.openmrs.test.BaseModuleContextSensitiveTest;

public class PmtctServiceTest extends BaseModuleContextSensitiveTest{

@Test
public void testIsServiceAccessible() {
Assert.assertNotNull(Context.getService(PmtctService.class));
}
}
29 changes: 19 additions & 10 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@
<artifactId>openmrs-web</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.openmrs.test</groupId>
<artifactId>openmrs-test</artifactId>
<version>${openMRSVersion}</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>mohorderentrybridge-api</artifactId>
<version>${mohorderentrybridgeVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>mohtracportal-api</artifactId>
<scope>provided</scope>
<version>${mohtracPortalVersion}</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -72,16 +91,6 @@
</excludes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.openmrs.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.openmrs.api.ConceptService;
import org.openmrs.api.EncounterService;
import org.openmrs.api.context.Context;
import org.openmrs.module.mohorderentrybridge.api.MoHOrderEntryBridgeService;
import org.openmrs.module.pmtct.PMTCTConfiguration;
import org.openmrs.module.pmtct.PmtctChildInformation;
import org.openmrs.module.pmtct.util.PMTCTConfigurationUtils;
Expand Down Expand Up @@ -126,7 +127,7 @@ protected Map<String, Object> referenceData(HttpServletRequest request, Object c

map.put("patient", pmtctChildTest.getPatient());

drugOrdersTmp = Context.getOrderService().getDrugOrdersByPatient(
drugOrdersTmp = Context.getService(MoHOrderEntryBridgeService.class).getDrugOrdersByPatient(
Context.getPatientService().getPatient(Integer.parseInt(request.getParameter("patientId"))));
for (DrugOrder d : drugOrdersTmp) {
if (d.getConcept().getConceptId() == PMTCTConstants.PMTCT_DRUG_ORDER_CONCEPT_RELATED_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpSer
// pmtctConfig.put("existingAttributeTypes", Context.getPersonService().getAllPersonAttributeTypes());
pmtctConfig.put("existingEncTypes", Context.getEncounterService().getAllEncounterTypes());
pmtctConfig.put("existingIdentifierTypes", Context.getPatientService().getAllPatientIdentifierTypes());
pmtctConfig.put("existingDrugOrderTypes", Context.getOrderService().getAllOrderTypes());
pmtctConfig.put("existingDrugOrderTypes", Context.getOrderService().getOrderTypes(false));
pmtctConfig.put("existingRelationshipTypes", Context.getPersonService().getAllRelationshipTypes());

mav.addObject("pmtctConfigured", Context.getAdministrationService().getGlobalPropertyObject("pmtct.configured"));
Expand Down
Loading

0 comments on commit 73b9b1c

Please sign in to comment.