Skip to content

Commit 1e9b17a

Browse files
committed
U4X-1035: Upgrade Sync Module Dependencies to use latest openmrs core
1 parent c45aff3 commit 1e9b17a

File tree

52 files changed

+4317
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4317
-29
lines changed

api/pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openmrs.module</groupId>
66
<artifactId>ugandaemrsync</artifactId>
7-
<version>2.0.0-SNAPSHOT</version>
7+
<version>1.3.15-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>ugandaemrsync-api</artifactId>
@@ -94,6 +94,11 @@
9494
<artifactId>openmrs-web</artifactId>
9595
<scope>test</scope>
9696
</dependency>
97+
98+
<dependency>
99+
<groupId>org.openmrs.module</groupId>
100+
<artifactId>uiframework-api</artifactId>
101+
</dependency>
97102
<dependency>
98103
<groupId>org.openmrs.module</groupId>
99104
<artifactId>fhir2-api</artifactId>
@@ -103,14 +108,17 @@
103108
<groupId>org.openmrs.module</groupId>
104109
<artifactId>fhir2-api-2.5</artifactId>
105110
</dependency>
111+
106112
<dependency>
107113
<groupId>org.openmrs.module</groupId>
108114
<artifactId>fhir2-api-2.6</artifactId>
109115
</dependency>
116+
110117
<dependency>
111118
<groupId>org.openmrs.module</groupId>
112119
<artifactId>fhir2-api-2.7</artifactId>
113120
</dependency>
121+
114122
<dependency>
115123
<groupId>org.apache.ibatis</groupId>
116124
<artifactId>ibatis-core</artifactId>

api/src/main/java/org/openmrs/module/ugandaemrsync/tasks/CrossBorderIntegrationSyncTask.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.openmrs.module.ugandaemrsync.model.SyncFhirProfile;
1212
import org.openmrs.module.ugandaemrsync.server.SyncFHIRRecord;
1313
import org.openmrs.scheduler.tasks.AbstractTask;
14+
import org.openmrs.ui.framework.SimpleObject;
1415

1516

1617
import static org.openmrs.module.ugandaemrsync.UgandaEMRSyncConfig.PATIENT_ID_TYPE_CROSS_BORDER_UUID;
@@ -34,7 +35,7 @@ public void execute() {
3435

3536
}
3637

37-
public void updatePatientWithCBI(String patientDataObject) throws Exception {
38+
public SimpleObject updatePatientWithCBI(String patientDataObject) throws Exception {
3839
ObjectMapper objectMapper = new ObjectMapper();
3940
try {
4041
UgandaEMRSyncService ugandaEMRSyncService = Context.getService(UgandaEMRSyncService.class);
@@ -47,11 +48,14 @@ public void updatePatientWithCBI(String patientDataObject) throws Exception {
4748
}
4849
if (patient != null) {
4950
log.info("Patient " + patient.getNames() + "Successfully Updated");
51+
return SimpleObject.create("status", objectMapper.writeValueAsString("Patient Successfully Updated "));
5052
}
5153
}
5254

5355
} catch (Exception e) {
54-
log.error("There was a problem updating in patient cross boarder ID",e);
56+
return SimpleObject.create("status",
57+
objectMapper.writeValueAsString("There was a problem updating in patient cross boarder ID"));
5558
}
59+
return null;
5660
}
5761
}

api/src/main/java/org/openmrs/module/ugandaemrsync/tasks/SendDHIS2DataToCentralServerTask.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.openmrs.module.ugandaemrsync.server.SyncGlobalProperties;
1111
import org.openmrs.module.ugandaemrsync.api.UgandaEMRHttpURLConnection;
1212
import org.openmrs.scheduler.tasks.AbstractTask;
13+
import org.openmrs.ui.framework.SimpleObject;
1314
import org.springframework.stereotype.Component;
1415
import java.io.IOException;
1516
import java.io.InputStream;
@@ -32,14 +33,19 @@ public class SendDHIS2DataToCentralServerTask extends AbstractTask {
3233
protected Log log = LogFactory.getLog(getClass());
3334
SyncGlobalProperties syncGlobalProperties = new SyncGlobalProperties();
3435
protected byte[] data ;
36+
SimpleObject serverResponseObject;
3537

38+
public SimpleObject getServerResponseObject(){
39+
return serverResponseObject;
40+
}
3641
UgandaEMRHttpURLConnection ugandaEMRHttpURLConnection = new UgandaEMRHttpURLConnection();
3742

3843

3944
public SendDHIS2DataToCentralServerTask() {}
4045

41-
public SendDHIS2DataToCentralServerTask(byte[] data) {
46+
public SendDHIS2DataToCentralServerTask(byte[] data, SimpleObject simpleObject) {
4247
this.data = data;
48+
this.serverResponseObject= simpleObject;
4349
}
4450

4551

@@ -50,6 +56,14 @@ public void execute() {
5056
String baseUrl = ugandaEMRHttpURLConnection.getBaseURL(syncGlobalProperties.getGlobalProperty(GP_DHIS2_SERVER_URL));
5157
if (isBlank(syncGlobalProperties.getGlobalProperty(GP_DHIS2_SERVER_URL))) {
5258
log.error("DHIS 2 server URL is not set");
59+
60+
try {
61+
map.put("responseCode", responseCode);
62+
map.put("responseMessage", "DHIS 2 server URL is not set");
63+
serverResponseObject = SimpleObject.create("message", objectMapper.writeValueAsString(map));
64+
} catch (IOException e) {
65+
log.error("error creating message to interface", e);
66+
}
5367
log.error("DHIS 2 server URL is not set");
5468
return;
5569
}
@@ -58,7 +72,11 @@ public void execute() {
5872
if (!ugandaEMRHttpURLConnection.isConnectionAvailable()) {
5973
map.put("responseCode", responseCode);
6074
map.put("responseMessage", "Failed to connect to the internet. Check connection");
61-
75+
try {
76+
serverResponseObject = SimpleObject.create("message", objectMapper.writeValueAsString(map));
77+
} catch (IOException e) {
78+
e.printStackTrace();
79+
}
6280
return;
6381
}
6482

@@ -67,6 +85,11 @@ public void execute() {
6785
map.put("responseCode", responseCode);
6886
map.put("responseMessage", "Server Not Available");
6987

88+
try {
89+
serverResponseObject = SimpleObject.create("message", objectMapper.writeValueAsString(map));
90+
} catch (IOException e) {
91+
e.printStackTrace();
92+
}
7093
return;
7194
}
7295

@@ -88,6 +111,13 @@ public void execute() {
88111
log.error(e);
89112
}
90113

114+
115+
try {
116+
serverResponseObject = SimpleObject.create("message", objectMapper.writeValueAsString(map));
117+
serverResponseObject.put("responseCode", responseCode);
118+
} catch (IOException e) {
119+
e.printStackTrace();
120+
}
91121
}
92122

93123
public Map getMapOfResults(InputStream inputStreamReader, int responseCode) throws IOException {

api/src/main/java/org/openmrs/module/ugandaemrsync/tasks/SendPatientsToFacilitySHRTask.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.openmrs.module.ugandaemrsync.model.SyncFhirProfile;
1111
import org.openmrs.module.ugandaemrsync.server.SyncFHIRRecord;
1212
import org.openmrs.scheduler.tasks.AbstractTask;
13+
import org.openmrs.ui.framework.SimpleObject;
1314

1415
public class SendPatientsToFacilitySHRTask extends AbstractTask {
1516
protected final Log log = LogFactory.getLog(SendPatientsToFacilitySHRTask.class);
@@ -30,7 +31,7 @@ public void execute() {
3031

3132
}
3233

33-
public void transferIn(String patientDataObject) throws Exception {
34+
public SimpleObject transferIn(String patientDataObject) throws Exception {
3435
ObjectMapper objectMapper = new ObjectMapper();
3536
try {
3637
UgandaEMRSyncService ugandaEMRSyncService = Context.getService(UgandaEMRSyncService.class);
@@ -44,11 +45,14 @@ public void transferIn(String patientDataObject) throws Exception {
4445
}
4546
if (patient != null) {
4647
log.info("Patient " + patient.getNames() + "Successfully Created");
48+
return SimpleObject.create("status", objectMapper.writeValueAsString("Patient Successfully Created "));
4749
}
4850
}
4951

5052
} catch (Exception e) {
51-
log.info(e);
53+
return SimpleObject.create("status",
54+
objectMapper.writeValueAsString("There was a problem transferring in patient"));
5255
}
56+
return null;
5357
}
5458
}

api/src/main/java/org/openmrs/module/ugandaemrsync/tasks/SendReportsTask.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.openmrs.module.ugandaemrsync.model.SyncTaskType;
1010
import org.openmrs.module.ugandaemrsync.server.SyncGlobalProperties;
1111
import org.openmrs.scheduler.tasks.AbstractTask;
12+
import org.openmrs.ui.framework.SimpleObject;
1213
import org.springframework.stereotype.Component;
1314

1415
import static org.apache.commons.lang.StringUtils.isBlank;
@@ -29,6 +30,8 @@ public class SendReportsTask extends AbstractTask {
2930

3031
SyncTaskType syncTaskType;
3132

33+
SimpleObject response;
34+
3235
public SendReportsTask() {
3336
super();
3437
}

api/src/test/java/org/openmrs/module/ugandaemrsync/server/SyncFHIRRecordTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import org.junit.Assert;
1111
import org.junit.Before;
1212
import org.junit.Test;
13+
import org.mockito.MockedStatic;
14+
import org.openmrs.Patient;
15+
import org.openmrs.api.PatientService;
1316
import org.openmrs.api.context.Context;
1417
import org.openmrs.module.ugandaemrsync.api.UgandaEMRSyncService;
1518
import org.openmrs.module.ugandaemrsync.model.SyncFhirProfile;
@@ -18,8 +21,11 @@
1821
import org.openmrs.test.BaseModuleContextSensitiveTest;
1922
import org.springframework.context.annotation.ComponentScan;
2023

24+
import java.text.SimpleDateFormat;
2125
import java.util.*;
2226

27+
import static org.mockito.Mockito.*;
28+
2329
@ComponentScan(basePackages = {"org.openmrs.module.fhir2"})
2430
public class SyncFHIRRecordTest extends BaseModuleContextSensitiveTest {
2531

omod/pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.openmrs.module</groupId>
55
<artifactId>ugandaemrsync</artifactId>
6-
<version>2.0.0-SNAPSHOT</version>
6+
<version>1.3.15-SNAPSHOT</version>
77
</parent>
88

99
<artifactId>ugandaemrsync-omod</artifactId>
@@ -56,6 +56,18 @@
5656
<artifactId>idgen-api</artifactId>
5757
</dependency>
5858

59+
<dependency>
60+
<groupId>org.openmrs.module</groupId>
61+
<artifactId>uiframework-omod</artifactId>
62+
<scope>provided</scope>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>org.openmrs.module</groupId>
67+
<artifactId>appui-omod</artifactId>
68+
<scope>provided</scope>
69+
</dependency>
70+
5971
<dependency>
6072
<groupId>org.openmrs.module</groupId>
6173
<artifactId>calculation-api</artifactId>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5+
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6+
* <p>
7+
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8+
* graphic logo is a trademark of OpenMRS Inc.
9+
*/
10+
package org.openmrs.module.ugandaemrsync.fragment.controller;
11+
12+
import org.openmrs.api.context.Context;
13+
import org.openmrs.module.appui.UiSessionContext;
14+
import org.openmrs.module.ugandaemrsync.server.SyncDataRecord;
15+
import org.openmrs.ui.framework.annotation.SpringBean;
16+
import org.openmrs.ui.framework.fragment.FragmentModel;
17+
import org.openmrs.ui.framework.page.PageModel;
18+
19+
import java.util.List;
20+
21+
/**
22+
*  * Controller for a fragment that shows all users  
23+
*/
24+
public class GenerateInitialDataFragmentController {
25+
26+
27+
public void controller(UiSessionContext sessionContext, FragmentModel model) {
28+
}
29+
30+
public void get(@SpringBean PageModel pageModel) throws Exception {
31+
SyncDataRecord syncDataRecord = new SyncDataRecord();
32+
List totals = syncDataRecord.syncData();
33+
pageModel.put("persons", totals);
34+
35+
36+
}
37+
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5+
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6+
* <p>
7+
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8+
* graphic logo is a trademark of OpenMRS Inc.
9+
*/
10+
package org.openmrs.module.ugandaemrsync.fragment.controller;
11+
12+
import org.openmrs.module.appui.UiSessionContext;
13+
import org.openmrs.module.ugandaemrsync.server.SyncDataRecord;
14+
import org.openmrs.module.ugandaemrsync.server.SyncFHIRRecord;
15+
import org.openmrs.ui.framework.annotation.SpringBean;
16+
import org.openmrs.ui.framework.fragment.FragmentModel;
17+
import org.openmrs.ui.framework.page.PageModel;
18+
19+
import java.util.List;
20+
21+
/**
22+
*  * Controller for a fragment that shows all users  
23+
*/
24+
public class GenerateInitialFHIRDataFragmentController {
25+
26+
SyncDataRecord syncDataRecord = new SyncDataRecord();
27+
28+
public void controller(UiSessionContext sessionContext, FragmentModel model) {
29+
}
30+
31+
public void get(@SpringBean PageModel pageModel) throws Exception {
32+
SyncFHIRRecord syncFHIRRecord = new SyncFHIRRecord();
33+
List totals = syncFHIRRecord.syncFHIRData();
34+
pageModel.put("persons", totals);
35+
36+
37+
}
38+
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5+
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6+
* <p>
7+
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8+
* graphic logo is a trademark of OpenMRS Inc.
9+
*/
10+
package org.openmrs.module.ugandaemrsync.fragment.controller;
11+
12+
import org.openmrs.module.appui.UiSessionContext;
13+
import org.openmrs.module.ugandaemrsync.api.UgandaEMRHttpURLConnection;
14+
import org.openmrs.ui.framework.annotation.SpringBean;
15+
import org.openmrs.ui.framework.fragment.FragmentModel;
16+
import org.openmrs.ui.framework.page.PageModel;
17+
18+
/**
19+
*  * Controller for a fragment that shows all users  
20+
*/
21+
public class GetFacilityIdFragmentController {
22+
23+
public void controller(UiSessionContext sessionContext, FragmentModel model) {
24+
}
25+
26+
public void get(@SpringBean PageModel pageModel) throws Exception {
27+
UgandaEMRHttpURLConnection ugandaEMRHttpURLConnection = new UgandaEMRHttpURLConnection();
28+
29+
pageModel.put("message", ugandaEMRHttpURLConnection.requestFacilityId());
30+
}
31+
32+
}

0 commit comments

Comments
 (0)