mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-05-18 20:08:19 +00:00
fix: filter time slots by selected clinic/branch
Slots were fetched by doctor+date but not filtered by clinic. A doctor visiting multiple branches showed all slots regardless of selected branch. Now filters by clinicId when a clinic is selected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -108,13 +108,16 @@ export const AppointmentForm = ({
|
||||
apiClient.get<Array<{ time: string; label: string; clinicId: string; clinicName: string }>>(
|
||||
`/api/masterdata/slots?doctorId=${doctor}&date=${date}`,
|
||||
).then(slots => {
|
||||
setTimeSlotItems(slots.map(s => ({ id: s.time, label: s.label })));
|
||||
// Auto-select clinic from the slot's clinic
|
||||
if (slots.length > 0 && !clinic) {
|
||||
// Filter by selected clinic — doctor may visit multiple branches
|
||||
const filtered = clinic ? slots.filter(s => s.clinicId === clinic) : slots;
|
||||
setTimeSlotItems(filtered.map(s => ({ id: s.time, label: s.label })));
|
||||
// Auto-select clinic from the slot's clinic only if no clinic chosen
|
||||
if (filtered.length === 0 && slots.length > 0 && !clinic) {
|
||||
setClinic(slots[0].clinicId);
|
||||
setTimeSlotItems(slots.filter(s => s.clinicId === slots[0].clinicId).map(s => ({ id: s.time, label: s.label })));
|
||||
}
|
||||
}).catch(() => setTimeSlotItems([]));
|
||||
}, [doctor, date]);
|
||||
}, [doctor, date, clinic]);
|
||||
|
||||
// Availability state
|
||||
const [bookedSlots, setBookedSlots] = useState<string[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user