@@ -16,6 +16,7 @@ import { patientSchema as validationSchema } from '../../core/clinicUtils';
1616import { DEFAULT_GLYCEMIC_RANGES } from '../../core/glycemicRangesUtils' ;
1717import { useToasts } from '../../providers/ToastProvider' ;
1818import * as actions from '../../redux/actions' ;
19+ import { trackMetric } from '../../core/metricUtils' ;
1920
2021const useUpdatingClinicPatientWorkingState = ( { onUpdateSuccess = noop } ) => {
2122 const { t } = useTranslation ( ) ;
@@ -51,18 +52,18 @@ const PATIENT_FORM_SEARCH_DEBOUNCE_MS = 600;
5152
5253const 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