/
LocationBasedAccessActivator.java
79 lines (67 loc) · 2.75 KB
/
LocationBasedAccessActivator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* 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.
*/
package org.openmrs.module.locationbasedaccess;
import org.openmrs.PersonAttributeType;
import org.openmrs.api.context.Context;
import org.openmrs.module.locationbasedaccess.common.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.module.BaseModuleActivator;
import org.openmrs.module.ModuleActivator;
public class LocationBasedAccessActivator extends BaseModuleActivator {
protected Logger log = LoggerFactory.getLogger(getClass());
/**
* @see ModuleActivator#willRefreshContext()
*/
public void willRefreshContext() {
log.info("Refreshing Location Based Access Control Module");
}
/**
* @see ModuleActivator#contextRefreshed()
*/
public void contextRefreshed() {
log.info("Location Based Access Control Module refreshed");
}
/**
* @see ModuleActivator#willStart()
*/
public void willStart() {
log.info("Starting Location Based Access Control Module");
}
/**
* @see ModuleActivator#started()
*/
public void started() {
if (Context.getPersonService().getPersonAttributeTypeByName(Constants.ACCESS_LOCATION_PERSON_ATTRIBUTE_TYPE_NAME) == null) {
PersonAttributeType personAttributeType = new PersonAttributeType();
personAttributeType.setUuid("8b5c95ef-103c-41bc-9f24-368b8f77e070");
personAttributeType.setName(Constants.ACCESS_LOCATION_PERSON_ATTRIBUTE_TYPE_NAME);
personAttributeType.setFormat("java.lang.String");
personAttributeType.setDescription("Given Access location for the person");
Context.getPersonService().savePersonAttributeType(personAttributeType);
}
if(Context.getAdministrationService().getGlobalProperty(Constants.SHOW_PATIENTS_WHO_WITHOUT_ACCESS_LOCATION) == null) {
Context.getAdministrationService().setGlobalProperty(Constants.SHOW_PATIENTS_WHO_WITHOUT_ACCESS_LOCATION,"true");
}
log.info("Location Based Access Control Module started");
}
/**
* @see ModuleActivator#willStop()
*/
public void willStop() {
log.info("Stopping Location Based Access Control Module");
}
/**
* @see ModuleActivator#stopped()
*/
public void stopped() {
log.info("Location Based Access Control Module stopped");
}
}