Skip to content

Commit 271d8f4

Browse files
committed
WEB-4460 update modals
1 parent d7dbb9b commit 271d8f4

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

app/components/datasources/DataConnectionsModal.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const DataConnectionsModal = (props) => {
6060
const dispatch = useDispatch();
6161

6262
const fetchPatientDetails = useCallback(() => {
63-
dispatch(actions.async.fetchPatientFromClinic(api, selectedClinicId, patient.id));
64-
}, [dispatch, patient.id, selectedClinicId])
63+
dispatch(actions.async.fetchPatientFromClinic(api, selectedClinicId, patient?.id));
64+
}, [dispatch, patient?.id, selectedClinicId]);
6565

6666
// Pull the patient on load to ensure the most recent dexcom connection state is made available
6767
useEffect(() => {
@@ -136,6 +136,8 @@ export const DataConnectionsModal = (props) => {
136136
? t('Learn more.')
137137
: t('Learn more here.');
138138

139+
if (!patient) return null;
140+
139141
return (
140142
<>
141143
<Dialog

app/components/navpatientheader/EditPatientDialog.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { patientSchema as validationSchema } from '../../core/clinicUtils';
1616
import { DEFAULT_GLYCEMIC_RANGES } from '../../core/glycemicRangesUtils';
1717
import { useToasts } from '../../providers/ToastProvider';
1818
import * as actions from '../../redux/actions';
19+
import { trackMetric } from '../../core/metricUtils';
1920

2021
const useUpdatingClinicPatientWorkingState = ({ onUpdateSuccess = noop }) => {
2122
const { t } = useTranslation();
@@ -51,18 +52,18 @@ const PATIENT_FORM_SEARCH_DEBOUNCE_MS = 600;
5152

5253
const EditPatientDialog = ({
5354
api,
54-
trackMetric,
55+
clinicPatient,
5556
isOpen,
5657
onClose = noop,
58+
onEditSuccess = noop,
5759
}) => {
5860
const { t } = useTranslation();
5961
const dispatch = useDispatch();
6062

6163
const selectedClinicId = useSelector((state) => state.blip.selectedClinicId);
62-
const currentPatientInViewId = useSelector(state => state.blip.currentPatientInViewId);
63-
const clinicPatient = useSelector(state => selectClinicPatient(state));
6464
const clinic = useSelector(state => state.blip.clinics?.[selectedClinicId]);
6565
const isSmartOnFhir = useSelector(selectIsSmartOnFhirMode);
66+
const patientId = clinicPatient?.id;
6667

6768
const mrnSettings = useMemo(() => clinic?.mrnSettings ?? {}, [clinic?.mrnSettings]);
6869
const existingMRNs = useSelector(state => state.blip.clinicMRNsForPatientFormValidation)?.filter(mrn => mrn !== clinicPatient?.mrn) || [];
@@ -87,7 +88,8 @@ const EditPatientDialog = ({
8788
onClose();
8889

8990
if (shouldClearDataRef.current) {
90-
dispatch(actions.worker.dataWorkerRemoveDataRequest(null, currentPatientInViewId));
91+
onEditSuccess();
92+
dispatch(actions.worker.dataWorkerRemoveDataRequest(null, patientId));
9193
shouldClearDataRef.current = false;
9294
}
9395
};
@@ -112,7 +114,7 @@ const EditPatientDialog = ({
112114
setPatientFormContext({ ...formikContext });
113115
};
114116

115-
if (!currentPatientInViewId || !selectedClinicId) return null;
117+
if (!patientId || !selectedClinicId) return null;
116118

117119
return (
118120
<Dialog

0 commit comments

Comments
 (0)