Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Release 1.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
druchniewicz committed Apr 11, 2023
1 parent 4be7789 commit c8a7069
Show file tree
Hide file tree
Showing 38 changed files with 1,077 additions and 436 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>cflcore</artifactId>
<version>1.10.0</version>
<version>1.11.1</version>
</parent>

<artifactId>cflcore-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ public final class CFLConstants {

public static final String CALL_CHANNEL_TYPE = "Call";

public static final String WHATSAPP_CHANNEL_TYPE = "WhatsApp";

public static final String COMMA_SEPARATOR = ",";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

package org.openmrs.module.cflcore;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.PersonAttributeType;
Expand All @@ -36,10 +39,6 @@
import org.openmrs.module.metadatadeploy.api.MetadataDeployService;
import org.openmrs.module.metadatadeploy.bundle.MetadataBundle;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* This class contains the logic that is run every time this module is either started or shutdown
*/
Expand Down Expand Up @@ -155,6 +154,7 @@ private void createPersonAttributeTypeIfNotExists(PersonAttributeType attributeT
}
}

@SuppressWarnings("PMD.ExcessiveMethodLength")
private void createGlobalSettings() {
GlobalPropertyUtils.createGlobalSettingIfNotExists(
CFLConstants.PATIENT_DASHBOARD_REDIRECT_GLOBAL_PROPERTY_NAME,
Expand Down Expand Up @@ -251,6 +251,10 @@ private void createGlobalSettings() {
CFLConstants.SHOW_GENDER_PERSON_HEADER_KEY,
CFLConstants.SHOW_GENDER_PERSON_HEADER_DEFAULT_VALUE,
CFLConstants.SHOW_GENDER_PERSON_HEADER_DESCRIPTION);
GlobalPropertyUtils.createGlobalSettingIfNotExists(
GlobalPropertiesConstants.AD_HOC_SMS_MESSAGE_TEMPLATE);
GlobalPropertyUtils.createGlobalSettingIfNotExists(
GlobalPropertiesConstants.AD_HOC_WHATS_APP_MESSAGE_TEMPLATE);
}

private void createCountrySettings() {
Expand All @@ -272,11 +276,15 @@ private void createCountrySettings() {
CountryPropertyConstants.PERFORM_CALL_ON_PATIENT_REGISTRATION_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.SMS_CONFIG_PROP_NAME,
"defaultSmS",
"-",
CountryPropertyConstants.SMS_CONFIG_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.WHATSAPP_CONFIG_PROP_NAME,
"-",
CountryPropertyConstants.WHATSAPP_CONFIG_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.CALL_CONFIG_PROP_NAME,
"defaultCall",
"-",
CountryPropertyConstants.CALL_CONFIG_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.SEND_SMS_ON_PATIENT_REGISTRATION_PROP_NAME,
Expand All @@ -286,6 +294,14 @@ private void createCountrySettings() {
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_CALL_PROP_NAME,
Boolean.FALSE.toString(),
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_CALL_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.SEND_WHATSAPP_ON_PATIENT_REGISTRATION_PROP_NAME,
Boolean.FALSE.toString(),
CountryPropertyConstants.SEND_WHATSAPP_ON_PATIENT_REGISTRATION_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_WHATSAPP_PROP_NAME,
Boolean.FALSE.toString(),
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_WHATSAPP_PROP_DESC);
CountryPropertyUtils.createDefaultCountrySettingIfNotExists(
CountryPropertyConstants.SHOULD_CREATE_FIRST_VISIT_PROP_NAME,
Boolean.FALSE.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,80 @@

package org.openmrs.module.cflcore.api.constant;

/** The constants class with Country Properties. */
/**
* The constants class with Country Properties.
*/
public final class CountryPropertyConstants {

public static final String PATIENT_NOTIFICATION_TIME_WINDOW_FROM_PROP_NAME =
"messages.patientNotificationTimeWindowFrom";
"messages.patientNotificationTimeWindowFrom";
public static final String PATIENT_NOTIFICATION_TIME_WINDOW_FROM_PROP_DESC =
"The property configures the beginning of the time window during which system is allowed to send notifications to "
+ "patients.";
"The property configures the beginning of the time window during which system is allowed to send notifications to "
+ "patients.";

public static final String PATIENT_NOTIFICATION_TIME_WINDOW_TO_PROP_NAME =
"messages.patientNotificationTimeWindowTo";
"messages.patientNotificationTimeWindowTo";
public static final String PATIENT_NOTIFICATION_TIME_WINDOW_TO_PROP_DESC =
"The property configures the end of the time window during which system is allowed to send notifications to "
+ "patients.";
"The property configures the end of the time window during which system is allowed to send notifications to "
+ "patients.";

public static final String SHOULD_SEND_REMINDER_VIA_SMS_PROP_NAME =
"messages.shouldSendReminderViaSms";
"messages.shouldSendReminderViaSms";
public static final String SHOULD_SEND_REMINDER_VIA_SMS_PROP_DESC =
"The property configures whether the system should send Visit reminders via SMS. Value: true/false.";
"The property configures whether the system should send Visit reminders via SMS. Value: true/false.";

public static final String SHOULD_SEND_REMINDER_VIA_CALL_PROP_NAME =
"messages.shouldSendReminderViaCall";
"messages.shouldSendReminderViaCall";
public static final String SHOULD_SEND_REMINDER_VIA_CALL_PROP_DESC =
"The property configures whether the system should deliver Visit reminders via Call. Value: true/false.";
"The property configures whether the system should deliver Visit reminders via Call. Value: true/false.";

public static final String PERFORM_CALL_ON_PATIENT_REGISTRATION_PROP_NAME =
"messages.performCallOnPatientRegistration";
"messages.performCallOnPatientRegistration";
public static final String PERFORM_CALL_ON_PATIENT_REGISTRATION_PROP_DESC =
"The property configures whether new patients should receive Welcome Message via call after they are register in the"
+ " system. Value: true/false";
"The property configures whether new patients should receive Welcome Message via call after they are register in the"
+ " system. Value: true/false";

public static final String SMS_CONFIG_PROP_NAME = "messages.smsConfig";
public static final String SMS_CONFIG_PROP_DESC =
"The name of default SMS provider configuration.";
"The name of default SMS provider configuration.";

public static final String WHATSAPP_CONFIG_PROP_NAME = "messages.whatsAppConfig";

public static final String WHATSAPP_CONFIG_PROP_DESC = "The name of default WhatsApp provider configuration.";

public static final String CALL_CONFIG_PROP_NAME = "messages.callConfig";
public static final String CALL_CONFIG_PROP_DESC =
"The name of default Call provider configuration.";
"The name of default Call provider configuration.";

public static final String SEND_SMS_ON_PATIENT_REGISTRATION_PROP_NAME =
"messages.sendSmsOnPatientRegistration";
"messages.sendSmsOnPatientRegistration";
public static final String SEND_SMS_ON_PATIENT_REGISTRATION_PROP_DESC =
"The property configures whether new patients should receive Welcome Message via SMS after they are "
+ "register in the system. Value: true/false.";
"The property configures whether new patients should receive Welcome Message via SMS after they are "
+ "register in the system. Value: true/false.";

public static final String SEND_WHATSAPP_ON_PATIENT_REGISTRATION_PROP_NAME = "messages.sendWhatsAppOnPatientRegistration";

public static final String SEND_WHATSAPP_ON_PATIENT_REGISTRATION_PROP_DESC =
"The property configures whether new patients should receive Welcome Message via WhatsApp after they are "
+ "register in the system. Value: true/false.";

public static final String SHOULD_SEND_REMINDER_VIA_WHATSAPP_PROP_NAME = "messages.shouldSendReminderViaWhatsApp";

public static final String SHOULD_SEND_REMINDER_VIA_WHATSAPP_PROP_DESC =
"The property configures whether new patients should receive Welcome Message via WhatsApp after they are "
+ "register in the system. Value: true/false.";

public static final String SHOULD_CREATE_FIRST_VISIT_PROP_NAME = "visits.shouldCreateFirstVisit";
public static final String SHOULD_CREATE_FIRST_VISIT_PROP_DESC =
"The property configures whether the system should create first Visit for newly register patients automatically. "
+ "Value: true/false.";
"The property configures whether the system should create first Visit for newly register patients automatically. "
+ "Value: true/false.";

public static final String SHOULD_CREATE_FUTURE_VISIT_PROP_NAME =
"visits.shouldCreateFutureVisit";
"visits.shouldCreateFutureVisit";
public static final String SHOULD_CREATE_FUTURE_VISIT_PROP_DESC =
"The property configures whether the system should create a new future Visit after an existing Visit is marked as "
+ "OCCURRED. Value: true/false.";
"The property configures whether the system should create a new future Visit after an existing Visit is marked as "
+ "OCCURRED. Value: true/false.";

private CountryPropertyConstants() {}
private CountryPropertyConstants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

public class CountrySetting {
private String sms;
private String whatsApp;
private String call;
private boolean performCallOnPatientRegistration;
private boolean sendSmsOnPatientRegistration;
private boolean shouldSendReminderViaCall;
private boolean shouldSendReminderViaSms;
private boolean sendWhatsAppOnPatientRegistration;
private boolean shouldSendReminderViaWhatsApp;
private boolean shouldCreateFirstVisit;
private boolean shouldCreateFutureVisit;
private String patientNotificationTimeWindowFrom;
Expand All @@ -27,21 +30,27 @@ public CountrySetting() {}
@SuppressWarnings({"checkstyle:ParameterNumber", "PMD.ExcessiveParameterList"})
CountrySetting(
String sms,
String whatsApp,
String call,
boolean performCallOnPatientRegistration,
boolean sendSmsOnPatientRegistration,
boolean shouldSendReminderViaCall,
boolean shouldSendReminderViaSms,
boolean sendWhatsAppOnPatientRegistration,
boolean shouldSendReminderViaWhatsApp,
boolean shouldCreateFirstVisit,
boolean shouldCreateFutureVisit,
String patientNotificationTimeWindowFrom,
String patientNotificationTimeWindowTo) {
this.sms = sms;
this.whatsApp = whatsApp;
this.call = call;
this.performCallOnPatientRegistration = performCallOnPatientRegistration;
this.sendSmsOnPatientRegistration = sendSmsOnPatientRegistration;
this.shouldSendReminderViaCall = shouldSendReminderViaCall;
this.shouldSendReminderViaSms = shouldSendReminderViaSms;
this.sendWhatsAppOnPatientRegistration = sendWhatsAppOnPatientRegistration;
this.shouldSendReminderViaWhatsApp = shouldSendReminderViaWhatsApp;
this.shouldCreateFirstVisit = shouldCreateFirstVisit;
this.shouldCreateFutureVisit = shouldCreateFutureVisit;
this.patientNotificationTimeWindowFrom = patientNotificationTimeWindowFrom;
Expand All @@ -56,6 +65,14 @@ public void setSms(String sms) {
this.sms = sms;
}

public String getWhatsApp() {
return whatsApp;
}

public void setWhatsApp(String whatsApp) {
this.whatsApp = whatsApp;
}

public String getCall() {
return call;
}
Expand Down Expand Up @@ -96,6 +113,22 @@ public void setShouldSendReminderViaSms(boolean shouldSendReminderViaSms) {
this.shouldSendReminderViaSms = shouldSendReminderViaSms;
}

public boolean isSendWhatsAppOnPatientRegistration() {
return sendWhatsAppOnPatientRegistration;
}

public void setSendWhatsAppOnPatientRegistration(boolean sendWhatsAppOnPatientRegistration) {
this.sendWhatsAppOnPatientRegistration = sendWhatsAppOnPatientRegistration;
}

public boolean isShouldSendReminderViaWhatsApp() {
return shouldSendReminderViaWhatsApp;
}

public void setShouldSendReminderViaWhatsApp(boolean shouldSendReminderViaWhatsApp) {
this.shouldSendReminderViaWhatsApp = shouldSendReminderViaWhatsApp;
}

public boolean isShouldCreateFirstVisit() {
return shouldCreateFirstVisit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@

package org.openmrs.module.cflcore.api.contract;

import org.openmrs.module.cflcore.api.constant.CountryPropertyConstants;
import org.openmrs.module.messages.api.model.CountryProperty;
import static java.lang.Boolean.parseBoolean;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableSet;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

import static java.lang.Boolean.parseBoolean;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableSet;
import org.openmrs.module.cflcore.api.constant.CountryPropertyConstants;
import org.openmrs.module.messages.api.model.CountryProperty;

public class CountrySettingBuilder {
public static final Set<String> ALL_PROP_NAMES =
Expand All @@ -34,9 +33,12 @@ public class CountrySettingBuilder {
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_SMS_PROP_NAME,
CountryPropertyConstants.PERFORM_CALL_ON_PATIENT_REGISTRATION_PROP_NAME,
CountryPropertyConstants.SMS_CONFIG_PROP_NAME,
CountryPropertyConstants.WHATSAPP_CONFIG_PROP_NAME,
CountryPropertyConstants.CALL_CONFIG_PROP_NAME,
CountryPropertyConstants.SEND_SMS_ON_PATIENT_REGISTRATION_PROP_NAME,
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_CALL_PROP_NAME,
CountryPropertyConstants.SEND_WHATSAPP_ON_PATIENT_REGISTRATION_PROP_NAME,
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_WHATSAPP_PROP_NAME,
CountryPropertyConstants.SHOULD_CREATE_FIRST_VISIT_PROP_NAME,
CountryPropertyConstants.SHOULD_CREATE_FUTURE_VISIT_PROP_NAME)));

Expand All @@ -58,13 +60,20 @@ public class CountrySettingBuilder {
CountryPropertyConstants.PERFORM_CALL_ON_PATIENT_REGISTRATION_PROP_NAME,
CountrySettingBuilder::setPerformCallOnPatientRegistration);
tmp.put(CountryPropertyConstants.SMS_CONFIG_PROP_NAME, CountrySettingBuilder::setSms);
tmp.put(CountryPropertyConstants.WHATSAPP_CONFIG_PROP_NAME, CountrySettingBuilder::setWhatsApp);
tmp.put(CountryPropertyConstants.CALL_CONFIG_PROP_NAME, CountrySettingBuilder::setCall);
tmp.put(
CountryPropertyConstants.SEND_SMS_ON_PATIENT_REGISTRATION_PROP_NAME,
CountrySettingBuilder::setSendSmsOnPatientRegistration);
tmp.put(
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_CALL_PROP_NAME,
CountrySettingBuilder::setShouldSendReminderViaCall);
tmp.put(
CountryPropertyConstants.SEND_WHATSAPP_ON_PATIENT_REGISTRATION_PROP_NAME,
CountrySettingBuilder::setSendWhatsAppOnPatientRegistration);
tmp.put(
CountryPropertyConstants.SHOULD_SEND_REMINDER_VIA_WHATSAPP_PROP_NAME,
CountrySettingBuilder::setShouldSendReminderViaWhatsApp);
tmp.put(
CountryPropertyConstants.SHOULD_CREATE_FIRST_VISIT_PROP_NAME,
CountrySettingBuilder::setShouldCreateFirstVisit);
Expand All @@ -76,10 +85,13 @@ public class CountrySettingBuilder {

private String sms;
private String call;
private String whatsApp;
private boolean performCallOnPatientRegistration = false;
private boolean sendSmsOnPatientRegistration = false;
private boolean shouldSendReminderViaCall = false;
private boolean shouldSendReminderViaSms = false;
private boolean sendWhatsAppOnPatientRegistration = false;
private boolean shouldSendReminderViaWhatsApp = false;
private boolean shouldCreateFirstVisit = false;
private boolean shouldCreateFutureVisit = false;
private String patientNotificationTimeWindowFrom = "10:00";
Expand Down Expand Up @@ -107,11 +119,14 @@ public boolean addCountryProperty(CountryProperty countryProperty) {
public CountrySetting build() {
return new CountrySetting(
sms,
whatsApp,
call,
performCallOnPatientRegistration,
sendSmsOnPatientRegistration,
shouldSendReminderViaCall,
shouldSendReminderViaSms,
sendWhatsAppOnPatientRegistration,
shouldSendReminderViaWhatsApp,
shouldCreateFirstVisit,
shouldCreateFutureVisit,
patientNotificationTimeWindowFrom,
Expand All @@ -122,6 +137,10 @@ private void setSms(String sms) {
this.sms = sms;
}

private void setWhatsApp(String whatsApp) {
this.whatsApp = whatsApp;
}

private void setCall(String call) {
this.call = call;
}
Expand All @@ -142,6 +161,14 @@ private void setShouldSendReminderViaSms(String shouldSendReminderViaSms) {
this.shouldSendReminderViaSms = parseBoolean(shouldSendReminderViaSms);
}

private void setSendWhatsAppOnPatientRegistration(String sendWhatsAppOnPatientRegistration) {
this.sendWhatsAppOnPatientRegistration = parseBoolean(sendWhatsAppOnPatientRegistration);
}

private void setShouldSendReminderViaWhatsApp(String shouldSendReminderViaWhatsApp) {
this.shouldSendReminderViaWhatsApp = parseBoolean(shouldSendReminderViaWhatsApp);
}

private void setShouldCreateFirstVisit(String shouldCreateFirstVisit) {
this.shouldCreateFirstVisit = parseBoolean(shouldCreateFirstVisit);
}
Expand Down
Loading

0 comments on commit c8a7069

Please sign in to comment.