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

Sowmya | A-1205219676877884 | [Cure Bug] Search by patient id is flaky in add new appointment #308

Merged
merged 1 commit into from
Oct 18, 2023
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
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
Loading