Skip to content

Commit 503d52e

Browse files
slubwamasolemabrothers
authored andcommitted
Adding counselling workflow
1 parent 7671565 commit 503d52e

File tree

8 files changed

+102
-6
lines changed

8 files changed

+102
-6
lines changed

api/src/main/java/org/openmrs/module/aijar/api/AijarService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515

1616
import org.openmrs.Patient;
1717
import org.openmrs.Person;
18+
import org.openmrs.annotation.Authorized;
1819
import org.openmrs.api.OpenmrsService;
20+
import org.openmrs.util.OpenmrsConstants;
21+
import org.openmrs.util.PrivilegeConstants;
1922
import org.springframework.transaction.annotation.Transactional;
2023

24+
import java.util.Date;
25+
2126

2227
/**
2328
* This service exposes module's core functionality. It is a Spring managed bean which is configured in moduleApplicationContext.xml.
@@ -59,4 +64,5 @@ public interface AijarService extends OpenmrsService {
5964
* This method when called generates and saves UIC (Unique Identifier Code) for all patients who dont have the UIC
6065
*/
6166
public void generateAndSaveUICForPatientsWithOut();
67+
6268
}

api/src/main/java/org/openmrs/module/aijar/api/deploy/bundle/CommonMetadataBundle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void install() throws Exception {
8181
install(Locations.PHARMACY);
8282
install(Locations.RECEPTION);
8383
install(Locations.TRIAGE);
84+
install(Locations.COUNSELING_CENTER);
8485

8586
// Install Encounter Role
8687
install(encounterRole(EncounterRoles.ASSISTANT_CIRCUMCISER_NAME,EncounterRoles.ASSISTANT_CIRCUMCISER_DESCRIPTION,EncounterRoles.ASSISTANT_CIRCUMCISER_UUID));

api/src/main/java/org/openmrs/module/aijar/api/impl/AijarServiceImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
import java.util.Date;
2020
import java.util.Calendar;
2121

22-
2322
import org.openmrs.Patient;
24-
import org.openmrs.PatientIdentifierType;
25-
import org.openmrs.PatientIdentifier;
2623
import org.openmrs.Person;
2724
import org.openmrs.Relationship;
2825
import org.openmrs.User;
2926
import org.openmrs.api.PatientService;
3027
import org.openmrs.api.PersonService;
28+
import org.openmrs.PatientIdentifierType;
29+
import org.openmrs.PatientIdentifier;
30+
import org.openmrs.api.VisitService;
3131
import org.openmrs.api.context.Context;
3232
import org.openmrs.api.impl.BaseOpenmrsService;
3333
import org.apache.commons.logging.Log;
@@ -37,6 +37,8 @@
3737
import org.openmrs.module.aijar.metadata.core.Locations;
3838
import org.openmrs.module.aijar.metadata.core.PatientIdentifierTypes;
3939
import org.openmrs.notification.Alert;
40+
import org.openmrs.util.OpenmrsConstants;
41+
import org.openmrs.util.OpenmrsUtil;
4042
import org.springframework.beans.factory.annotation.Autowired;
4143

4244

@@ -300,5 +302,4 @@ private String replaceLettersWithNumber(String letter) {
300302
}
301303
return numberToReturn;
302304
}
303-
304305
}

api/src/main/java/org/openmrs/module/aijar/metadata/core/Locations.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,38 @@ public List<LocationTagDescriptor> tags() {
233233

234234
};
235235

236+
public static LocationDescriptor COUNSELING_CENTER = new LocationDescriptor(){
237+
238+
@Override
239+
public String uuid() {
240+
return "7c231e1a-1db5-11ea-978f-2e728ce88125";
241+
}
242+
243+
@Override
244+
public String description() {
245+
return "A location where counseling and screening is done for a patient";
246+
}
247+
248+
@Override
249+
public String name() {
250+
return "Counseling Center";
251+
}
252+
253+
@Override
254+
public LocationDescriptor parent() {
255+
return PARENT;
256+
}
257+
258+
@Override
259+
public List<LocationTagDescriptor> tags() {
260+
261+
return Arrays.asList(
262+
LocationTags.LOGIN_LOCATION,
263+
LocationTags.VISIT_LOCATION
264+
);
265+
266+
}
267+
268+
};
269+
236270
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.openmrs.module.aijar.tasks;
2+
3+
import org.openmrs.Visit;
4+
import org.openmrs.api.VisitService;
5+
import org.openmrs.api.context.Context;
6+
import org.openmrs.scheduler.tasks.AbstractTask;
7+
import org.openmrs.util.OpenmrsUtil;
8+
9+
import java.util.List;
10+
11+
public class StopActiveFacilityVisitTask extends AbstractTask {
12+
@Override
13+
public void execute() {
14+
VisitService visitService = Context.getVisitService();
15+
List<Visit> visitList = visitService.getAllVisits();
16+
for (Visit visit : visitList) {
17+
if (visit.getStopDatetime() == null && visit.getVisitType()==visitService.getVisitTypeByUuid("7b0f5697-27e3-40c4-8bae-f4049abfb4ed")) {
18+
visitService.endVisit(visit, OpenmrsUtil.getLastMomentOfDay(visit.getStartDatetime()));
19+
}
20+
}
21+
}
22+
}

api/src/main/resources/liquibase.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,27 @@
260260
</insert>
261261

262262
</changeSet>
263+
264+
<changeSet id="ugandaemr-2019-16-16-1425" author="slubwama">
265+
<preConditions onFail="MARK_RAN">
266+
<sqlCheck expectedResult="0">
267+
SELECT COUNT(*) FROM scheduler_task_config
268+
WHERE schedulable_class = 'org.openmrs.module.aijar.tasks.StopActiveFacilityVisitTask'
269+
</sqlCheck>
270+
</preConditions>
271+
<comment>Close all active facility visits</comment>
272+
<insert tableName="scheduler_task_config">
273+
<column name="name" value="Close Active Facility Visits" />
274+
<column name="description" value="generates_uics into patient identifier table" />
275+
<column name="schedulable_class" value="org.openmrs.module.aijar.tasks.StopActiveFacilityVisitTask" />
276+
<column name="start_time_pattern" value="MM/dd/yyyy HH:mm:ss" />
277+
<column name="start_time" valueDate="2019-11-08T16:59:59" />
278+
<column name="repeat_interval" value="86400" />
279+
<column name="date_created" valueDate="CURRENT_TIMESTAMP" />
280+
<column name="created_by" value="1" />
281+
<column name="start_on_startup" value="1"/>
282+
<column name="started" value="1"/>
283+
<column name="uuid" value="1434dd72-1ff7-11ea-978f-2e728ce88125" />
284+
</insert>
285+
</changeSet>
263286
</databaseChangeLog>

api/src/main/resources/metadata/Role_Privilege.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<privilege privilege="App: ugandaemr.widget.eidSummary" description="Access eidSummary On Patient Dashboard" uuid="2dc27a93-a7d3-496e-b5ba-f8449ec90c12"/>
2323
<privilege privilege="App: ugandaemr.widget.mchSummary" description="Access MCH Summary on patient Dashboard" uuid="014fa1f5-7862-47d9-a977-a0b75bc33af9"/>
2424

25+
<!--Counseling Center-->
26+
<privilege privilege="App: ugandaemrpoc.counselingCenter" description="Access to the counseling center" uuid="b663fd6f-05fd-4553-be68-215464059977"/>
27+
2528
<!--* HOME PAGE *-->
2629
<privilege privilege="App: ugandaemr.report.cohortBuilder" description="Access Link to Manage cohort builder reports" uuid="515a0ce8-a4e5-4b7e-b210-3f64ad96302e"/>
2730
<privilege privilege="App: ugandaemr.backup.backupDatabase" description="Access App to the Backup" uuid="96c5dbe1-2c73-4f95-9b37-b24277617f6d"/>
@@ -120,6 +123,7 @@
120123
<role role="HTS Data Manager" description="This role enables a user access general reports and HTS Specific reports" uuid="1255d77e-6037-4774-a3df-6998b4fd9d11"/>
121124
<role role="General Data Manager" description="This is the over all data manager role. It enables one to access all reports in the system" uuid="c951823d-4798-4fc2-bf9d-91c311c50631"/>
122125
<role role="Organizational:Pharmacy" description="This is the over all data manager role. It enables one to access all reports in the system" uuid="cf349e5e-e59a-4019-a218-dd57935488da"/>
126+
<role role="Counselor" description="This role allows access to the counseling center" uuid="cab08bba-e2d9-4b32-83ec-ced29d69e283"/>
123127

124128

125129
<!-- ROLE PRIVILEGES -->
@@ -231,6 +235,12 @@
231235

232236

233237
<!--* COUNSELOR ROLE *-->
238+
<!--role-role-->
239+
<role_role parent_role="Base Role" child_role="Counselor"/>
240+
241+
<!-- role privilege -->
242+
<role_privilege role="Counselor" privilege="App: ugandaemrpoc.counselingCenter"/>
243+
<role_privilege role="Counselor" privilege="Task: HIV Clinic Access"/>
234244

235245

236246
<!--* LABORATORY ROLE *-->
@@ -270,7 +280,6 @@
270280
<role_privilege role="HIV Clinic" privilege="App: ugandaemr.widget.directionsToResidence"/>
271281
<role_privilege role="HIV Clinic" privilege="App: ugandaemrpoc.artclinic"/>
272282

273-
274283
<!--* OPD Clinic *-->
275284
<!--role-role-->
276285
<role_role parent_role="Base Role" child_role="OPD Clinic"/>

omod/src/main/webapp/resources/htmlforms/117-Viral-Load Non-SupressedRegister.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
formUILocation="patientDashboard.visitActions"
88
formOrder="3"
99
formIcon="icon-medkit"
10-
formShowIf="(visit.active || !visit.active) &amp;&amp; patient.person.dead==false &amp;&amp; sessionLocation.uuid=='86863db4-6101-4ecf-9a86-5e716d6504e4'"
10+
formShowIf="(visit.active || !visit.active) &amp;&amp; patient.person.dead==false &amp;&amp; (sessionLocation.uuid=='86863db4-6101-4ecf-9a86-5e716d6504e4' || sessionLocation.uuid=='7c231e1a-1db5-11ea-978f-2e728ce88125')"
1111
formDisplayStyle="Standard">
1212

1313
<ifMode mode="ENTER,EDIT" include="false">

0 commit comments

Comments
 (0)