2024-10-05 23:10:41 +00:00
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
|
|
|
|
|
|
|
const departmentTypeMap = {
|
|
|
|
|
|
EMS: 'Medical Services',
|
|
|
|
|
|
Fire: 'Fire Department',
|
|
|
|
|
|
Rescue: 'Fire & EMS'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const accountDetails = {
|
|
|
|
|
|
"CallThemes" : {
|
|
|
|
|
|
"CriticalCallList": [
|
|
|
|
|
|
"CARDIAC ARREST|DEATH",
|
|
|
|
|
|
],
|
|
|
|
|
|
"HighCallList": [
|
2025-08-11 19:34:16 +00:00
|
|
|
|
"EMS ALS PRIORITY (ALS)",
|
|
|
|
|
|
"EMS Advanced Life Support life threatening response (ALS)",
|
|
|
|
|
|
"EMS ALS Intercept Required",
|
|
|
|
|
|
"EMS ALS Response – Cardiac Related",
|
|
|
|
|
|
"EMS ALS Response – Respiratory Distress",
|
|
|
|
|
|
"EMS ALS Response – Stroke Alert",
|
|
|
|
|
|
"EMS Basic Life Support with Paramedic Assist (BLS)",
|
|
|
|
|
|
"EMS ALS Tiered Response with Fire",
|
|
|
|
|
|
"EMS Response – Behavioral Emergency (ALS)",
|
|
|
|
|
|
"EMS Response – Obstetric Emergency (ALS)",
|
|
|
|
|
|
"EMS ALS Response – Overdose / Poisoning",
|
|
|
|
|
|
"EMS ALS Priority Interfacility Transfer",
|
|
|
|
|
|
"EMS Response – Unresponsive / Unconscious Patient (ALS)"
|
2024-10-05 23:10:41 +00:00
|
|
|
|
],
|
|
|
|
|
|
"MediumCallList": [
|
|
|
|
|
|
"ALS-STANDARD",
|
2025-08-11 19:34:16 +00:00
|
|
|
|
"BLS-PRIORITY",
|
|
|
|
|
|
"EMS BLS Priority Response",
|
|
|
|
|
|
"EMS BLS Response – Fall Injury"
|
2024-10-05 23:10:41 +00:00
|
|
|
|
],
|
|
|
|
|
|
"LowCallList": [
|
2025-08-11 19:34:16 +00:00
|
|
|
|
"EMS Standard Basic Life Support Response (BLS)",
|
|
|
|
|
|
"EMS BLS Non-Emergency Transport",
|
|
|
|
|
|
"EMS BLS Standby – Event Coverage",
|
|
|
|
|
|
"EMS Public Assist – Lift Only (BLS)",
|
|
|
|
|
|
"EMS BLS Scheduled Interfacility Transport"
|
2024-10-05 23:10:41 +00:00
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
"InitList": [
|
|
|
|
|
|
{
|
|
|
|
|
|
deptId: 0,
|
|
|
|
|
|
dept: 'Darien EMS',
|
|
|
|
|
|
addDepts: [
|
|
|
|
|
|
'Darien EMS Supv'
|
|
|
|
|
|
],
|
|
|
|
|
|
deptAbv: 'DEMS',
|
|
|
|
|
|
rank: 'Assistant Director',
|
|
|
|
|
|
rankAbv: 'Asst. Director',
|
|
|
|
|
|
type: 'EMS',
|
|
|
|
|
|
primary: true,
|
|
|
|
|
|
selected: true,
|
|
|
|
|
|
supervisor: true,
|
|
|
|
|
|
admin: true,
|
|
|
|
|
|
hasVolunteer: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
deptId: 1,
|
|
|
|
|
|
dept: 'Noroton Fire Department',
|
|
|
|
|
|
deptAbv: 'NFD',
|
|
|
|
|
|
rank: 'Lieutenant',
|
|
|
|
|
|
rankAbv: 'Lt.',
|
|
|
|
|
|
type: 'Fire',
|
|
|
|
|
|
primary: false,
|
|
|
|
|
|
selected: false,
|
|
|
|
|
|
supervisor: true,
|
|
|
|
|
|
admin: true,
|
|
|
|
|
|
hasVolunteer: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
deptId: 2,
|
|
|
|
|
|
dept: 'Stamford Fire Department',
|
|
|
|
|
|
deptAbv: 'SFD',
|
|
|
|
|
|
rank: 'Paramedic',
|
|
|
|
|
|
rankAbv: 'EMT-P',
|
|
|
|
|
|
type: 'Rescue',
|
|
|
|
|
|
primary: false,
|
|
|
|
|
|
selected: false,
|
|
|
|
|
|
supervisor: false,
|
|
|
|
|
|
admin: true,
|
|
|
|
|
|
hasVolunteer: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const useDepartments = () => {
|
|
|
|
|
|
const { InitList } = accountDetails;
|
|
|
|
|
|
const [deptList, setDeptList] = useState(InitList);
|
|
|
|
|
|
const [selectedDepartment, setSelectedDepartment] = useState(deptList?.find((dept) => {
|
|
|
|
|
|
return dept?.primary;
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
const updateSelectedDepartment = (currentSelectedId, newSelectedId) => {
|
|
|
|
|
|
if (currentSelectedId !== newSelectedId) {
|
|
|
|
|
|
setDeptList(deptList?.map((item) => {
|
|
|
|
|
|
if (item?.selected) {
|
|
|
|
|
|
item.selected = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item?.deptId === newSelectedId) {
|
|
|
|
|
|
item.selected = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return item;
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const selectedDepartmentColorPicker = (deptartmentType) => {
|
|
|
|
|
|
if (deptartmentType === 'Fire') {
|
|
|
|
|
|
return '#FF0000';
|
|
|
|
|
|
} else if (deptartmentType === 'EMS') {
|
|
|
|
|
|
return '#FF8C00';
|
|
|
|
|
|
} else if (deptartmentType === 'Rescue') {
|
|
|
|
|
|
return '#0000CD';
|
|
|
|
|
|
}
|
|
|
|
|
|
return 'grey';
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (deptList) {
|
|
|
|
|
|
setSelectedDepartment(deptList?.find((dept) => {
|
|
|
|
|
|
return dept?.selected;
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [deptList]);
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
departmentTypeMap,
|
|
|
|
|
|
accountDetails,
|
|
|
|
|
|
deptList,
|
|
|
|
|
|
setDeptList,
|
|
|
|
|
|
selectedDepartment,
|
|
|
|
|
|
setSelectedDepartment,
|
|
|
|
|
|
updateSelectedDepartment,
|
|
|
|
|
|
selectedDepartmentColorPicker
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|