Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@
<artifactId>patientflags-api-metadata</artifactId>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>registrationcore-api</artifactId>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>registrationapp-api</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.openmrs.module</groupId>-->
<!-- <artifactId>registrationcore-api</artifactId>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>org.openmrs.module</groupId>-->
<!-- <artifactId>registrationapp-api</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>org.openmrs.module</groupId>
Expand Down
8 changes: 4 additions & 4 deletions api/src/main/resources/openmrs-distro.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ omod.metadatadeploy=${metadatadeployVersion}
omod.reportingrest=${reportingRestVersion}
omod.serialization.xstream.type=omod
omod.serialization.xstream=${serializationxstreamVersion}
omod.registrationapp=${registrationappVersion}
#omod.registrationapp=${registrationappVersion}
omod.event.groupId=org.openmrs
omod.event=${eventVersion}
omod.uilibrary=${uilibraryVersion}
Expand All @@ -27,18 +27,18 @@ omod.referenceapplication=${referenceapplicationVersion}
omod.htmlformentry=${htmlformentryVersion}
omod.appframework=${appframeworkVersion}
omod.referencemetadata=${referencemetadataVersion}
omod.coreapps=${coreappsVersion}
#omod.coreapps=${coreappsVersion}
omod.reportingcompatibility=${reportingCompatibilityVersion}
omod.reporting=${reportingVersion}
omod.reportingui=${reportingUIVersion}
omod.adminui=${adminuiVersion}
omod.registrationcore=${registrationcoreVersion}
#omod.registrationcore=${registrationcoreVersion}
war.openmrs=${openMRSVersion}
omod.webservices.rest=${webservices.restModuleVersion}
omod.calculation=${calculationVersion}
version=${project.parent.version}
omod.uicommons=${uicommonsVersion}
omod.xforms=${xformsVersion}
#omod.xforms=${xformsVersion}
omod.uiframework=${uiframeworkVersion}
omod.metadatasharing=${metadatasharingVersion}
omod.dataintegrity=${dataintegrityVersion}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.openmrs.module.ugandaemr;

import org.junit.Test;

/**
* Test for generating the UIC task for patients without the UIC
*/
import java.util.Date;
import java.util.List;


import org.junit.Before;
import org.openmrs.*;
import org.openmrs.api.AdministrationService;
import org.openmrs.api.PatientService;
import org.openmrs.api.VisitService;
import org.openmrs.api.context.Context;
import org.openmrs.module.ugandaemr.api.UgandaEMRService;
import org.openmrs.test.BaseModuleContextSensitiveTest;


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;


public class UgandaEMRServiceTest extends BaseModuleContextSensitiveTest {

protected static final String UGANDAEMR_STANDARD_DATASET_XML = "org/openmrs/module/ugandaemr/include/standardTestDataset.xml";


protected UgandaEMRService ugandaemrService;
protected PatientService patientService;
protected VisitService visitService;
protected AdministrationService administrationService;

@Before
public void setup() throws Exception {
executeDataSet(UGANDAEMR_STANDARD_DATASET_XML);
ugandaemrService = Context.getService(UgandaEMRService.class);
patientService = Context.getPatientService();
visitService = Context.getVisitService();
administrationService = Context.getAdministrationService();
}

@Test
public void generateAndSaveUICForPatientsWithOut_shouldGenerateUICForPatientWithoutUIC() {

List listBeforeGeneration = administrationService.executeSQL("select * from patient inner join patient_identifier pi on (patient.patient_id = pi.patient_id) inner join patient_identifier_type pit on (pi.identifier_type = pit.patient_identifier_type_id) where pit.uuid='877169c4-92c6-4cc9-bf45-1ab95faea242'", true);

assertEquals(0, listBeforeGeneration.size());

ugandaemrService.generateAndSaveUICForPatientsWithOut();

List listAfterGeneration = administrationService.executeSQL("select * from patient inner join patient_identifier pi on (patient.patient_id = pi.patient_id) inner join patient_identifier_type pit on (pi.identifier_type = pit.patient_identifier_type_id) where pit.uuid='877169c4-92c6-4cc9-bf45-1ab95faea242'", true);

assertNotEquals(0, listAfterGeneration.size());
}

@Test
public void generatePatientUIC_shouldGenerateUIC() {
Patient patient = patientService.getPatient(10003);

String uniqueIdentifierCode = null;
uniqueIdentifierCode = ugandaemrService.generatePatientUIC(patient);

assertEquals("XX-0117-1-01140411011213", uniqueIdentifierCode);

}

@Test
public void stopActiveOutPatientVisits_shouldCompleteAllVisitOfSetTypeInGlobalProperty() {

assertTrue(visitService.getActiveVisitsByPatient(patientService.getPatient(10110)).size() > 0);

ugandaemrService.stopActiveOutPatientVisits();

assertTrue(visitService.getActiveVisitsByPatient(patientService.getPatient(10110)).size() == 0);

}

@Test
public void isTransferredIn_ShouldReturnFalseWhenPatientIsNotTransferIn() {
Patient patient = patientService.getPatient(10008);
assertFalse(ugandaemrService.isTransferredIn(patient, new Date()));

}

@Test
public void isTransferredOut_ShouldReturnFalseWhenPatientIsNotTransferredOut() {
Context.getPatientService();
Patient patient = patientService.getPatient(10008);
assertFalse(ugandaemrService.isTransferredIn(patient, new Date()));
}


}
27 changes: 27 additions & 0 deletions api/src/test/resources/TestingApplicationContext.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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>
</bean>

</beans>
21 changes: 21 additions & 0 deletions api/src/test/resources/test-hibernate.cfg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ This Source Code Form is subject to the terms of the Mozilla Public License,
~ v. 2.0. If a copy of the MPL was not distributed with this file, You can
~ obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
~ the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
~
~ Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
~ graphic logo is a trademark of OpenMRS Inc.
~
-->

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
</session-factory>
</hibernate-configuration>
16 changes: 8 additions & 8 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@
<artifactId>referenceapplication-omod</artifactId>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>registrationapp-api</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.openmrs.module</groupId>-->
<!-- <artifactId>registrationapp-api</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>org.openmrs.module</groupId>
Expand Down Expand Up @@ -231,10 +231,10 @@
<groupId>org.openmrs.module</groupId>
<artifactId>ugandaemrfingerprint-omod</artifactId>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>coreapps-omod</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.openmrs.module</groupId>-->
<!-- <artifactId>coreapps-omod</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>patientqueueing-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.openmrs.api.PatientService;
import org.openmrs.api.context.Context;
import org.openmrs.module.appui.UiSessionContext;
import org.openmrs.module.coreapps.fragment.controller.visit.QuickVisitFragmentController;
//import org.openmrs.module.coreapps.fragment.controller.visit.QuickVisitFragmentController;
import org.openmrs.module.emrapi.adt.AdtService;
import org.openmrs.module.patientqueueing.api.PatientQueueingService;
import org.openmrs.module.patientqueueing.model.PatientQueue;
Expand Down Expand Up @@ -74,7 +74,7 @@ public SimpleObject post(@SpringBean("patientService") PatientService patientSer
//patientQueue.setComment(visitComment);
}

createVisitForToday(patient, uiUtils, uiSessionContext, request);
// createVisitForToday(patient, uiUtils, uiSessionContext, request);

patientQueue.setLocationFrom(currentLocation);
patientQueue.setPatient(patient);
Expand All @@ -96,34 +96,34 @@ private VisitType getFacilityVisitType() {
return Context.getVisitService().getVisitTypeByUuid("7b0f5697-27e3-40c4-8bae-f4049abfb4ed");
}

private void createVisitForToday(Patient patient, UiUtils uiUtils, UiSessionContext uiSessionContext, HttpServletRequest request) {

List<Visit> visitList = Context.getVisitService().getActiveVisitsByPatient(patient);

if (visitList.isEmpty()) {
QuickVisitFragmentController quickVisitFragmentController = new QuickVisitFragmentController();
quickVisitFragmentController.create((AdtService) Context.getService(AdtService.class), Context.getVisitService(), patient, Context.getLocationService().getLocationByUuid("629d78e9-93e5-43b0-ad8a-48313fd99117"), uiUtils, getFacilityVisitType(), uiSessionContext, request);
} else {
Visit todayVisit = null;
for (Visit visit : visitList) {
Date largestEncounterDate = OpenmrsUtil.getLastMomentOfDay(visit.getStartDatetime());
for (Encounter encounter : visit.getEncounters()) {
if (encounter.getEncounterDatetime().after(largestEncounterDate)) {
largestEncounterDate = encounter.getEncounterDatetime();
}
}

if (!visit.getStartDatetime().after(OpenmrsUtil.firstSecondOfDay(new Date()))) {
Context.getVisitService().endVisit(visit, largestEncounterDate);
} else {
todayVisit = visit;
}
}

if (todayVisit == null) {
QuickVisitFragmentController quickVisitFragmentController = new QuickVisitFragmentController();
quickVisitFragmentController.create((AdtService) Context.getService(AdtService.class), Context.getVisitService(), patient, Context.getLocationService().getLocationByUuid("629d78e9-93e5-43b0-ad8a-48313fd99117"), uiUtils, getFacilityVisitType(), uiSessionContext, request);
}
}
}
// private void createVisitForToday(Patient patient, UiUtils uiUtils, UiSessionContext uiSessionContext, HttpServletRequest request) {
//
// List<Visit> visitList = Context.getVisitService().getActiveVisitsByPatient(patient);
//
// if (visitList.isEmpty()) {
// QuickVisitFragmentController quickVisitFragmentController = new QuickVisitFragmentController();
// quickVisitFragmentController.create((AdtService) Context.getService(AdtService.class), Context.getVisitService(), patient, Context.getLocationService().getLocationByUuid("629d78e9-93e5-43b0-ad8a-48313fd99117"), uiUtils, getFacilityVisitType(), uiSessionContext, request);
// } else {
// Visit todayVisit = null;
// for (Visit visit : visitList) {
// Date largestEncounterDate = OpenmrsUtil.getLastMomentOfDay(visit.getStartDatetime());
// for (Encounter encounter : visit.getEncounters()) {
// if (encounter.getEncounterDatetime().after(largestEncounterDate)) {
// largestEncounterDate = encounter.getEncounterDatetime();
// }
// }
//
// if (!visit.getStartDatetime().after(OpenmrsUtil.firstSecondOfDay(new Date()))) {
// Context.getVisitService().endVisit(visit, largestEncounterDate);
// } else {
// todayVisit = visit;
// }
// }
//
// if (todayVisit == null) {
// QuickVisitFragmentController quickVisitFragmentController = new QuickVisitFragmentController();
// quickVisitFragmentController.create((AdtService) Context.getService(AdtService.class), Context.getVisitService(), patient, Context.getLocationService().getLocationByUuid("629d78e9-93e5-43b0-ad8a-48313fd99117"), uiUtils, getFacilityVisitType(), uiSessionContext, request);
// }
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.openmrs.module.appframework.domain.Extension;
import org.openmrs.module.appframework.service.AppFrameworkService;
import org.openmrs.module.appui.UiSessionContext;
import org.openmrs.module.coreapps.CoreAppsConstants;
//import org.openmrs.module.coreapps.CoreAppsConstants;
import org.openmrs.module.emrapi.utils.GeneralUtils;
import org.openmrs.module.ugandaemrfingerprint.core.FingerPrintConstant;
import org.openmrs.module.ugandaemrfingerprint.remoteserver.FingerPrintGlobalProperties;
Expand Down Expand Up @@ -45,11 +45,11 @@ public void controller(FragmentModel model, UiSessionContext sessionContext,
model.addAttribute("minSearchCharacters",
administrationService.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "1"));

model.addAttribute("searchDelayShort",
administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_SHORT, "300"));

model.addAttribute("searchDelayLong",
administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_LONG, "1000"));
// model.addAttribute("searchDelayShort",
// administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_SHORT, "300"));
//
// model.addAttribute("searchDelayLong",
// administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_LONG, "1000"));

model.addAttribute("dateFormatJS", "DD MMM YYYY"); // TODO really should be driven by global property, but currently we only have a property for the java date format
model.addAttribute("locale", Context.getLocale().getLanguage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.openmrs.module.appframework.domain.Extension;
import org.openmrs.module.appframework.service.AppFrameworkService;
import org.openmrs.module.appui.UiSessionContext;
import org.openmrs.module.coreapps.CoreAppsConstants;
//import org.openmrs.module.coreapps.CoreAppsConstants;
import org.openmrs.module.emrapi.utils.GeneralUtils;
import org.openmrs.ui.framework.UiFrameworkConstants;
import org.openmrs.ui.framework.annotation.FragmentParam;
Expand Down Expand Up @@ -46,11 +46,11 @@ public void controller(FragmentModel model, UiSessionContext sessionContext, Htt
model.addAttribute("minSearchCharacters",
administrationService.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "1"));

model.addAttribute("searchDelayShort",
administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_SHORT, "300"));
model.addAttribute("searchDelayLong",
administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_LONG, "1000"));
// model.addAttribute("searchDelayShort",
// administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_SHORT, "300"));
//
// model.addAttribute("searchDelayLong",
// administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_LONG, "1000"));

model.addAttribute("dateFormatJS", "DD MMM YYYY"); // TODO really should be driven by global property, but currently we only have a property for the java date format
model.addAttribute("locale", Context.getLocale().getLanguage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.apache.commons.logging.LogFactory;
import org.openmrs.module.appframework.domain.AppDescriptor;
import org.openmrs.module.appui.UiSessionContext;
import org.openmrs.module.coreapps.helper.BreadcrumbHelper;
//import org.openmrs.module.coreapps.helper.BreadcrumbHelper;
import org.openmrs.module.ugandaemrfingerprint.core.FingerPrintConstant;
import org.openmrs.module.ugandaemrfingerprint.remoteserver.FingerPrintGlobalProperties;
import org.openmrs.ui.framework.UiUtils;
Expand Down Expand Up @@ -41,6 +41,6 @@ public void get(PageModel model, @RequestParam("app") AppDescriptor app, UiSessi
model.addAttribute("registrationAppLink", app.getConfig().get("registrationAppLink").getTextValue());
}
model.put("fingerSocketPrintIpAddress", fingerPrintGlobalProperties.getGlobalProperty(FingerPrintConstant.GP_DEVICE_SOCKET_IP));
BreadcrumbHelper.addBreadcrumbsIfDefinedInApp(app, model, ui);
// BreadcrumbHelper.addBreadcrumbsIfDefinedInApp(app, model, ui);
}
}
Loading