-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathappointment.ts
23 lines (20 loc) · 947 Bytes
/
appointment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { parseReference } from '@medplum/core';
import { Appointment, Patient, Practitioner, Reference } from '@medplum/fhirtypes';
export function getAppointmentParticipant(
appointment: Appointment,
resourceType: string
): Reference<Patient | Practitioner> | undefined {
return appointment.participant.find((p) => {
if (!p?.actor) {
return false;
}
const [participantType] = parseReference(p?.actor);
return participantType === resourceType;
})?.actor as Reference<Patient | Practitioner> | undefined;
}
export function getAppointmentPatient(appointment: Appointment): Reference<Patient> | undefined {
return getAppointmentParticipant(appointment, 'Patient') as Reference<Patient> | undefined;
}
export function getAppointmentPractitioner(appointment: Appointment): Reference<Practitioner> | undefined {
return getAppointmentParticipant(appointment, 'Practitioner') as Reference<Practitioner> | undefined;
}