usePatientInfo
The usePatientInfo
hook provides access to basic patient demographic information from the active display sets and also detects when display sets from multiple patients are loaded simultaneously.
Overviewβ
This hook retrieves patient information from the first instance of the first display set added to the viewer. It monitors when new display sets are added and updates the patient information accordingly. It also checks if any of the active display sets are from different patients and provides this information through the isMixedPatients
flag.
Importβ
import { usePatientInfo } from '@ohif/extension-default';
Usageβ
function PatientBanner() {
const { patientInfo, isMixedPatients } = usePatientInfo();
return (
<div className="patient-banner">
{isMixedPatients && (
<div className="warning">Multiple patients loaded</div>
)}
<div className="patient-name">{patientInfo.PatientName}</div>
<div className="patient-details">
<span>ID: {patientInfo.PatientID}</span>
<span>Sex: {patientInfo.PatientSex}</span>
<span>DOB: {patientInfo.PatientDOB}</span>
</div>
</div>
);
}
Parametersβ
This hook doesn't take any parameters.
Returnsβ
An object containing:
patientInfo
: Object with the following properties:PatientName
: Formatted patient namePatientID
: Patient identifierPatientSex
: Patient sexPatientDOB
: Formatted patient date of birth
isMixedPatients
: Boolean indicating whether multiple patients are loaded in the viewer
Eventsβ
The hook subscribes to the following display set service events:
DISPLAY_SETS_ADDED
: Updates patient information when new display sets are added to the viewer
Implementation Detailsβ
- Patient name and date of birth are formatted using OHIF utility functions.
- The hook checks all active display sets to determine if they belong to different patients.
- Patient information is initialized with empty strings and updated when display sets are added.
- When no instances are available in a display set, the hook attempts to get information from the
instance
property as a fallback.