Skip to content

Commit

Permalink
Sowmya | A-1205219676877884 | [Cure Bug] Search by patient id is flak…
Browse files Browse the repository at this point in the history
…y in add new appointment - adds configurable debounce logic delay (#308)
  • Loading branch information
sowmya-AS authored and Phanindra-tw committed Mar 4, 2024
1 parent 0dd6e03 commit 4ea7daf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/controllers/manage/appointmentsCreateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ angular.module('bahmni.appointments')
var patientSearchURL = appService.getAppDescriptor().getConfigValue('patientSearchUrl');
var loginLocationUuid = sessionService.getLoginLocationUuid();
$scope.minCharLengthToTriggerPatientSearch = appService.getAppDescriptor().getConfigValue('minCharLengthToTriggerPatientSearch') || 3;
$scope.debouncePatientSearchDelayInMilliseconds = appService.getAppDescriptor().getConfigValue('debouncePatientSearchDelayInMilliseconds') || 3000;

$scope.maxAppointmentProviders = appService.getAppDescriptor().getConfigValue("maxAppointmentProviders") || 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const AppointmentEditorCommonFieldsWrapper = props => {
<PatientSearch
value={appointmentDetails.patient}
minCharLengthToTriggerPatientSearch={appConfig && appConfig.minCharLengthToTriggerPatientSearch}
debouncePatientSearchDelayInMilliseconds={appConfig && appConfig.debouncePatientSearchDelayInMilliseconds}
onChange={(optionSelected) => {
const newValue = optionSelected ? optionSelected : null;
updateAppointmentDetails({patient: newValue});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {getPatientsByLocation} from '../../api/patientApi';
import {currentLocation} from '../../utils/CookieUtil';
import { injectIntl } from 'react-intl';
import PropTypes from 'prop-types';
import {MINIMUM_CHAR_LENGTH_FOR_PATIENT_SEARCH} from "../../constants";
import {MINIMUM_CHAR_LENGTH_FOR_PATIENT_SEARCH,DEBOUNCE_PATIENT_SEARCH_DELAY_IN_MILLISECONDS} from "../../constants";
import {Search, ClickableTile, Tile} from "carbon-components-react";

const styles = {
Expand All @@ -26,11 +26,12 @@ const styles = {
}
const PatientSearch = (props) => {

const {intl, onChange, value, isDisabled, minCharLengthToTriggerPatientSearch, autoFocus} = props;
const {intl, onChange, value, isDisabled, minCharLengthToTriggerPatientSearch,debouncePatientSearchDelayInMilliseconds, autoFocus} = props;
const [userInput, setUserInput] = useState('')
const [patients, setPatients] = useState([])
const [selectedPatient, setSelectedPatient] = useState(value)
const [isCalled, setIsCalled] = useState(false)
const debouncePatientSearchDelay = debouncePatientSearchDelayInMilliseconds || DEBOUNCE_PATIENT_SEARCH_DELAY_IN_MILLISECONDS;
const createDropdownOptions = (patients) => {
return patients.map(patient => getPatientForDropdown(patient));
};
Expand All @@ -48,7 +49,7 @@ const PatientSearch = (props) => {
};

const debouncedLoadPatients = useCallback(
debounce(loadPatients, 3000, {
debounce(loadPatients, debouncePatientSearchDelay, {
leading: true,
}),
[],
Expand Down Expand Up @@ -127,6 +128,7 @@ PatientSearch.propTypes = {
value: PropTypes.object,
isDisabled: PropTypes.bool,
minCharLengthToTriggerPatientSearch: PropTypes.number,
debouncePatientSearchDelayInMilliseconds: PropTypes.number,
autoFocus: PropTypes.bool
};

Expand Down
1 change: 1 addition & 0 deletions ui/react-components/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const appName = 'appointments';
export const availableForAppointments = "Available for appointments";
export const minDurationForAppointment = 30;
export const MINIMUM_CHAR_LENGTH_FOR_PATIENT_SEARCH = 3;
export const DEBOUNCE_PATIENT_SEARCH_DELAY_IN_MILLISECONDS = 3000;
export const DEFAULT_MAX_APPOINTMENT_PROVIDERS = 1;
export const PROVIDER_ERROR_MESSAGE_TIME_OUT_INTERVAL = 5000;
export const SERVICE_ERROR_MESSAGE_TIME_OUT_INTERVAL = 5000;
Expand Down

0 comments on commit 4ea7daf

Please sign in to comment.