Skip to content

Commit

Permalink
BAH-2962 | removed sms sending part from frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
atishbeehyv123 authored and rahu1ramesh committed Oct 19, 2023
1 parent 7e8383c commit c5a6f9f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 115 deletions.
21 changes: 0 additions & 21 deletions ui/react-components/api/smsService.js

This file was deleted.

15 changes: 2 additions & 13 deletions ui/react-components/components/AddAppointment/AddAppointment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
} from "../../services/AppointmentsService/AppointmentsService";
import Label from '../Label/Label.jsx';
import {getDateTime, isStartTimeBeforeEndTime} from '../../utils/DateUtil.js'
import {getAppointmentBookingMessage, getRecurringAppointmentBookingMessage, getPhoneNumber} from '../../utils/AppointmentSMS.js'
import TimeSelector from "../TimeSelector/TimeSelector.jsx";
import AppointmentNotes from "../AppointmentNotes/AppointmentNotes.jsx";
import AppointmentPlan from "../AppointmentPlan/AppointmentPlan.jsx";
Expand Down Expand Up @@ -65,11 +64,10 @@ import Conflicts from "../Conflicts/Conflicts.jsx";
import updateAppointmentStatusAndProviderResponse from "../../appointment-request/AppointmentRequest";
import * as patientApi from "../../api/patientApi";
import {mapOpenMRSPatient} from "../../mapper/patientMapper";
import {sendSMS} from "../../api/smsService";

const AddAppointment = props => {

const {appConfig, intl, appointmentParams, currentProvider, urlParams, isAppointmentSMSEnabled } = props;
const {appConfig, intl, appointmentParams, currentProvider, urlParams } = props;
const {setViewDate} = React.useContext(AppContext);
const errorTranslations = getErrorTranslations(intl);

Expand Down Expand Up @@ -279,10 +277,6 @@ const AddAppointment = props => {
setShowEmailWarning((isVirtual(response.data) && !checkPatientEmailAvailability(response.data)));
setShowEmailNotSentWarning((isVirtual(response.data) && !checkNotificationStatus(response.data)));
setViewDateAndShowSuccessPopup(response.data.startDateTime);
if (isAppointmentSMSEnabled) {
sendSMS(await getPhoneNumber(response.data.patient.uuid, appConfig.smsAttribute),
getAppointmentBookingMessage(response.data, appConfig, intl));
}
} else if (response.data && response.data.error) {
setConflicts(undefined);
setServiceErrorMessageFromResponse(response.data);
Expand Down Expand Up @@ -344,10 +338,6 @@ const AddAppointment = props => {
setServiceErrorMessage('');
const immediateAppointment = response.data[0];
setViewDateAndShowSuccessPopup(immediateAppointment.appointmentDefaultResponse.startDateTime);
if (isAppointmentSMSEnabled) {
sendSMS(await getPhoneNumber(immediateAppointment.appointmentDefaultResponse.patient.uuid, appConfig.smsAttribute),
getRecurringAppointmentBookingMessage(immediateAppointment, appConfig, intl));
}
} else if (status === 204) {
setServiceErrorMessage(errorTranslations.noContentErrorMessage);
resetServiceErrorMessage();
Expand Down Expand Up @@ -666,8 +656,7 @@ AddAppointment.propTypes = {
appConfig: PropTypes.object,
appointmentParams: PropTypes.object,
currentProvider: PropTypes.object,
urlParams: PropTypes.object,
isAppointmentSMSEnabled: PropTypes.bool
urlParams: PropTypes.object
};

export const isVirtual = (appt) => {
Expand Down
15 changes: 2 additions & 13 deletions ui/react-components/components/EditAppointment/EditAppointment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,17 @@ import {
updateRecurring
} from "../../services/AppointmentsService/AppointmentsService";
import {getDateTime, isStartTimeBeforeEndTime} from "../../utils/DateUtil";
import {getAppointmentBookingMessage, getRecurringAppointmentBookingMessage, getPhoneNumber} from '../../utils/AppointmentSMS.js'
import UpdateSuccessModal from "../SuccessModal/UpdateSuccessModal.jsx";
import UpdateConfirmationModal from "../UpdateConfirmationModal/UpdateConfirmationModal.jsx";
import {getComponentsDisableStatus} from "./ComponentsDisableStatus";
import ErrorMessage from "../ErrorMessage/ErrorMessage.jsx";
import {getErrorTranslations} from "../../utils/ErrorTranslationsUtil";
import {AppContext} from "../AppContext/AppContext";
import updateAppointmentStatusAndProviderResponse from "../../appointment-request/AppointmentRequest";
import {sendSMS} from "../../api/smsService";

const EditAppointment = props => {

const {appConfig, appointmentUuid, isRecurring, intl, currentProvider, isAppointmentSMSEnabled} = props;
const {appConfig, appointmentUuid, isRecurring, intl, currentProvider} = props;

const {setViewDate} = React.useContext(AppContext);

Expand Down Expand Up @@ -296,10 +294,6 @@ const EditAppointment = props => {
setConflicts(undefined);
setShowUpdateConfirmPopup(false);
setViewDateAndShowSuccessPopup(appointmentDetails.appointmentDate);
if (isAppointmentSMSEnabled) {
sendSMS(await getPhoneNumber(response.data.patient.uuid, appConfig.smsAttribute),
getAppointmentBookingMessage(response.data, appConfig, intl));
}
} else if (response.data && response.data.error) {
setConflicts(undefined);
setServiceErrorMessageFromResponse(response.data);
Expand All @@ -319,10 +313,6 @@ const EditAppointment = props => {
setConflicts(undefined);
setShowUpdateConfirmPopup(false);
setViewDateAndShowSuccessPopup(appointmentDetails.appointmentDate);
if (isAppointmentSMSEnabled) {
sendSMS(await getPhoneNumber(response.data[0].appointmentDefaultResponse.patient.uuid, appConfig.smsAttribute),
getRecurringAppointmentBookingMessage(response.data[0], appConfig, intl));
}
} else if (response.data && response.data.error) {
setConflicts(undefined);
setServiceErrorMessageFromResponse(response.data);
Expand Down Expand Up @@ -690,8 +680,7 @@ EditAppointment.propTypes = {
appConfig: PropTypes.object,
appointmentUuid: PropTypes.string.isRequired,
isRecurring: PropTypes.string.isRequired,
currentProvider: PropTypes.object,
isAppointmentSMSEnabled: PropTypes.bool
currentProvider: PropTypes.object
};

export default injectIntl(EditAppointment);
1 change: 0 additions & 1 deletion ui/react-components/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ export const appointmentEndTimeProps = endTime => {
};

export const helpDeskNumber = "clinic.helpDeskNumber";
export const appointmentSMSToggle = "sms.enableAppointmentBookingSMSAlert";
14 changes: 4 additions & 10 deletions ui/react-components/containers/AppointmentContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {getAppConfig, getMessages} from "../components/AppContext/AppService";
import EditAppointment from "../components/EditAppointment/EditAppointment.jsx";
import moment from "moment";
import {getFromGlobalProperty} from "../api/configApi";
import { appointmentSMSToggle, helpDeskNumber } from "../constants";

// TODO : need to add connection to redux

Expand All @@ -20,29 +19,24 @@ class AppointmentContainer extends Component {
this.state = {
locale: getLocale() === 'pt_BR' ? 'pt-BR': getLocale(),
messages: translations[props.locale],
appConfig: null,
isAppointmentSMSEnabled: false
appConfig: null
};
(async () => {
this.setState({messages: await getMessages(getLocale())});
this.setState({appConfig: await getAppConfig()});
this.setState({isAppointmentSMSEnabled: await getFromGlobalProperty(appointmentSMSToggle)});
if (this.state.isAppointmentSMSEnabled) {
localStorage.setItem(helpDeskNumber, await getFromGlobalProperty(helpDeskNumber));
}
})();
moment.locale(getLocale() === 'pt_BR' ? 'pt-BR': getLocale());
}

render() {
const {locale, messages, appConfig, isAppointmentSMSEnabled} = this.state;
const {locale, messages, appConfig} = this.state;
const {appointmentUuid,isRecurring, setViewDate, onBack, appointmentParams, currentProvider, urlParams} = this.props;
return (
<AppContext.Provider value={{onBack: onBack, setViewDate: setViewDate}}>
<IntlProvider defaultLocale='en' locale={locale} messages={messages}>
{appointmentUuid
? <EditAppointment appConfig={appConfig} appointmentUuid={appointmentUuid} isRecurring={isRecurring} currentProvider={currentProvider} isAppointmentSMSEnabled={isAppointmentSMSEnabled}/>
: <AddAppointment appConfig={appConfig} appointmentParams={appointmentParams} currentProvider={currentProvider} urlParams={urlParams} isAppointmentSMSEnabled={isAppointmentSMSEnabled}/>}
? <EditAppointment appConfig={appConfig} appointmentUuid={appointmentUuid} isRecurring={isRecurring} currentProvider={currentProvider} />
: <AddAppointment appConfig={appConfig} appointmentParams={appointmentParams} currentProvider={currentProvider} urlParams={urlParams} />}
</IntlProvider>
</AppContext.Provider>);
}
Expand Down
57 changes: 0 additions & 57 deletions ui/react-components/utils/AppointmentSMS.js

This file was deleted.

0 comments on commit c5a6f9f

Please sign in to comment.