Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exemption list for forms in 3.x #1872

Merged
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
21 changes: 21 additions & 0 deletions api/src/main/java/org/openmrs/module/kenyaemr/util/EmrUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.openmrs.Encounter;
import org.openmrs.EncounterType;
import org.openmrs.Form;
import org.openmrs.GlobalProperty;
import org.openmrs.Obs;
import org.openmrs.Order;
import org.openmrs.OrderType;
Expand Down Expand Up @@ -54,6 +55,7 @@
*/
public class EmrUtils {
protected static final Log log = LogFactory.getLog(EmrUtils.class);
public static String GP_2X_FORMS_WHITELIST = "kenyaemr.2.x.forms.whitelist";

/**
* Checks whether a date has any time value
Expand Down Expand Up @@ -316,5 +318,24 @@ public static List<Person> getPersonChildren(Patient patient) {
return people;
}

/**
* A temporary solution for whitelisting forms to show in 2.x
* TODO: retire this once all forms are fully moved to o3
* @return
*/
public static List<String> getFormsToShowInLegacyUI() {
GlobalProperty gpFormsWhitelist = Context.getAdministrationService().getGlobalPropertyObject(GP_2X_FORMS_WHITELIST);

String formsWhiteList = "";
List<String> formsList = new ArrayList<String>();
if (gpFormsWhitelist != null) {
formsWhiteList = gpFormsWhitelist.getPropertyValue();
if (StringUtils.isNotBlank(formsWhiteList)) {
formsList = Arrays.asList(formsWhiteList.split(","));
}
}
return formsList;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openmrs.module.appframework.domain.AppDescriptor;
import org.openmrs.module.kenyacore.form.FormDescriptor;
import org.openmrs.module.kenyacore.form.FormManager;
import org.openmrs.module.kenyaemr.util.EmrUtils;
import org.openmrs.module.kenyaui.KenyaUiUtils;
import org.openmrs.ui.framework.SimpleObject;
import org.openmrs.ui.framework.UiUtils;
Expand Down Expand Up @@ -45,9 +46,16 @@ public void controller(FragmentModel model,

List<SimpleObject> availableForms = new ArrayList<SimpleObject>();

List<String> formsList = EmrUtils.getFormsToShowInLegacyUI();

for (FormDescriptor descriptor : formManager.getAllUncompletedFormsForVisit(currentApp, visit)) {
//Display only active forms
if(!descriptor.getTarget().isRetired()) {
/**
* Display only active forms
* we filter forms based on the configured whitelist. The idea is to temporarily take care of any partner forms in the add-on modules
* We block everything if no configuration exists i.e. default to an empty whitelist
*/

if(!descriptor.getTarget().isRetired() && formsList.contains(descriptor.getTarget().getUuid())) {
availableForms.add(ui.simplifyObject(descriptor.getTarget()));
}
continue;
Expand Down
8 changes: 8 additions & 0 deletions omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,12 @@
</description>
</globalProperty>

<globalProperty>
<property>kenyaemr.2.x.forms.whitelist</property>
<defaultValue></defaultValue>
<description>
Configures a comma separated list of forms to avail in 2.x KenyaEMR user interface
</description>
</globalProperty>

</module>