@@ -282,8 +282,7 @@ export const PatientDetailView = ({
282282 return < LoadingContainer />
283283 }
284284
285- const patient = patientData ?. patient
286- const patientName = patient ? `${ patient . firstname } ${ patient . lastname } ` : ''
285+ const patientName = patientData ?. patient ? `${ patientData . patient . firstname } ${ patientData . patient . lastname } ` : ''
287286 const patientLocation = selectedLocations . length > 0 ? selectedLocations . map ( loc => formatLocationPath ( loc ) ) . join ( ' ▸ ' ) : ''
288287
289288 const handleToggleDone = ( taskId : string , done : boolean ) => {
@@ -300,8 +299,8 @@ export const PatientDetailView = ({
300299 < div className = "px-1 py-3 mb-4" >
301300 < div className = "flex items-center justify-between" >
302301 < div className = "font-semibold text-lg" > { patientName } </ div >
303- { patient ?. state && (
304- < PatientStateChip state = { patient . state } />
302+ { patientData ?. patient ?. state && (
303+ < PatientStateChip state = { patientData . patient . state } />
305304 ) }
306305 </ div >
307306 { patientLocation && (
@@ -464,39 +463,42 @@ export const PatientDetailView = ({
464463 </ FormElementWrapper >
465464 ) }
466465
467- { isEditMode && patientId && patient && (
468- < FormElementWrapper label = { translation ( 'patientActions' ) } >
469- { ( ) => (
470- < div className = "flex gap-2 flex-wrap" >
471- { patient . state !== PatientState . Admitted && (
472- < Button
473- onClick = { ( ) => admitPatient ( { id : patientId } ) }
474- color = "positive"
475- >
476- { translation ( 'admitPatient' ) }
477- </ Button >
478- ) }
479- { patient . state !== PatientState . Discharged && (
480- < Button
481- onClick = { ( ) => dischargePatient ( { id : patientId } ) }
482- color = "neutral"
483- coloringStyle = "outline"
484- >
485- { translation ( 'dischargePatient' ) }
486- </ Button >
487- ) }
488- { patient . state !== PatientState . Wait && (
489- < Button
490- onClick = { ( ) => waitPatient ( { id : patientId } ) }
491- color = "warning"
492- >
493- { translation ( 'waitPatient' ) }
494- </ Button >
495- ) }
496- </ div >
497- ) }
498- </ FormElementWrapper >
499- ) }
466+ { isEditMode && patientId && patientData ?. patient && ( ( ) => {
467+ const patient = patientData . patient
468+ return (
469+ < FormElementWrapper label = { translation ( 'patientActions' ) } >
470+ { ( ) => (
471+ < div className = "flex gap-2 flex-wrap" >
472+ { patient . state !== PatientState . Admitted && (
473+ < Button
474+ onClick = { ( ) => admitPatient ( { id : patientId } ) }
475+ color = "positive"
476+ >
477+ { translation ( 'admitPatient' ) }
478+ </ Button >
479+ ) }
480+ { patient . state !== PatientState . Discharged && (
481+ < Button
482+ onClick = { ( ) => dischargePatient ( { id : patientId } ) }
483+ color = "neutral"
484+ coloringStyle = "outline"
485+ >
486+ { translation ( 'dischargePatient' ) }
487+ </ Button >
488+ ) }
489+ { patient . state !== PatientState . Wait && (
490+ < Button
491+ onClick = { ( ) => waitPatient ( { id : patientId } ) }
492+ color = "warning"
493+ >
494+ { translation ( 'waitPatient' ) }
495+ </ Button >
496+ ) }
497+ </ div >
498+ ) }
499+ </ FormElementWrapper >
500+ )
501+ } ) ( ) }
500502
501503 < FormElementWrapper label = { translation ( 'assignedLocation' ) } >
502504 { ( { isShowingError : _ , setIsShowingError : _2 , ...bag } ) => (
@@ -571,7 +573,7 @@ export const PatientDetailView = ({
571573 </ div >
572574 ) }
573575
574- { isEditMode && patientId && patient && patient . state !== PatientState . Dead && (
576+ { isEditMode && patientId && patientData ?. patient && patientData . patient . state !== PatientState . Dead && (
575577 < div className = "flex-none pt-4 mt-auto border-t border-divider flex justify-end gap-2" >
576578 < Button
577579 onClick = { ( ) => markPatientDead ( { id : patientId } ) }
0 commit comments