Creates a new appointment record.
This method validates the provided appointment data and sends a POST request to create an appointment.
The appointment data to be created. Fields include:
A promise resolving to the appointment creation response object. The response includes:
// Input:
const appointment = {
patientReference: "a8654878-4202-4b47-bcc4-868060a75254",
practitionerReference: "3c7271bb-4212-4291-9f75-64d886d69893",
appointmentStartDate: "2025-02-28T09:00:00Z",
appointmentEndDate: "2025-02-28T10:00:00Z",
appointmentPriority: "Emergency",
organizationId: "org123",
appointmentSlot: "slot123",
reference: "ref123"
};
const result = await appointment.create(appointment);
console.log(result);
// Expected Output:
{
message: 'Successfully created the Appointment profile',
type: 'Appointment',
resourceId: '2d9f1cfb-3ab0-4697-907a-78431678df1e',
validationErrors: [],
fhirProfileId: '',
resource: {
reference: '2d9f1cfb-3ab0-4697-907a-78431678df1e',
practitionerReference: '3c7271bb-4212-4291-9f75-64d886d69893',
patientReference: 'a8654878-4202-4b47-bcc4-868060a75254',
priority: 'Emergency',
slot: '02:30 PM - 03:30 PM',
start: '2025-02-28T09:00:00Z',
end: '2025-02-28T10:00:00Z',
organizationId: 'ACHALA_HEALTH_01'
}
}
Delete a Appointment
Appointment's unique identifier
Checks whether a appointment exists in the system using their unique identifier.
Unique identifier (Resource ID) of the appointment to check - mandatory
A promise that resolves to:
true
if the appointment existsRetrieves a paginated list of all Appointments.
Optional
pageSize: numberNumber of appointments to fetch in a single page - optional (Only effective in the first request. Default is 10 if not provided)
Optional
nextPage: stringCursor to fetch the next set appointments - optional
(Use the value from the previous response's nextPage
for pagination)
Promise
// Input:
const appointments = await appointment.findAll(20);
const moreAppointments = await appointment.findAll(undefined, appointments.nextPage);
// Expected Output:
{
data: {
Entry: [
{
reference: '277eec90-04d4-4291-b578-a21c9f0563ba',
practitionerReference: 'bb847118-135e-4c08-92a4-27506a3e807e',
patientReference: '9a3ca20a-1bde-4e1f-b1cc-01fcd698aa42',
priority: 'Emergency',
slot: '03:30 PM - 02:15 PM',
// ... other fields
},
{
reference: '77907eec90-04d4-4291-b578-a21c9f0563ba',
practitionerReference: 'bb9896578-135e-4c08-92a4-27506a3e807e',
patientReference: '9a3ca20a-1bde-4e1f-b1cc-01fcd698aa42',
priority: 'Emergency',
// ... other fields
}
// ... more entries
],
link: {
nextPage: 'X2NvdW50PTEwJl9zb3J0PS1fb'
},
total: 900
}
}
Fetches a list of appointments based on specified filters.
Validates and applies filters to retrieve appointment records. Useful for paginated search with filtering criteria.
Filters to apply (used primarily on the first page of results):
Optional
nextPage: stringToken or URL for fetching the next set of results (used for pagination).
A promise that resolves with:
// Input:
const filters = {
appointmentDate: "2025-02-28",
pageSize: 10,
organizationId: "IN3610001039"
};
const appointments = await appointment.findByFilters(filters);
console.log(appointments);
// Expected Output:
{
entry: [
{
reference: '332ca988-1e72-4a75-a252-5fc252460057',
practitionerReference: '51a3e368-09a4-4398-bc19-405a6bfce0f2',
patientReference: '4d92e619-6495-418f-9985-edd692e03436',
priority: 'Emergency',
slot: '02:30 PM - 03:30 PM',
start: '2025-02-28T09:00:00Z',
end: '2025-02-28T10:00:00Z',
organizationId: 'IN3610001039'
},
{
reference: 'f4ae6784-9469-4b8c-a487-9f9eec3b88e3',
practitionerReference: '2cb4bb5d-8657-4c95-b547-579ee7b17f89',
patientReference: '5e73f8d3-798d-4dd4-9989-a733e32be02d',
priority: 'Routine',
slot: '03:30 PM - 04:00 PM',
start: '2025-02-28T10:30:00Z',
end: '2025-02-28T11:00:00Z',
organizationId: 'IN3610001039'
}
],
link: {
nextPage: 'X2NvdW50PTEwJl9zb3J0PS1fb'
},
total: 25
}
Fetches the details of an appointment using its unique identifier.
Unique identifier (Resource ID) of the appointment to fetch (mandatory).
Returns an object containing:
// Input:
const appointment = await appointment.findById("d7d79e4c-a3db-4505-877d-f853610b7c4a");
console.log(appointment);
// Expected Output:
{
type: 'Appointment',
message: 'Appointment Found !!!',
requestResource: {
reference: 'd7d79e4c-a3db-4505-877d-f853610b7c4a',
practitionerReference: '3c7271bb-4212-4291-9f75-64d886d69893',
patientReference: 'a8654878-4202-4b47-bcc4-868060a75254',
priority: 'Emergency',
slot: '02:30 PM - 03:30 PM',
start: '2025-02-28T09:00:00Z',
end: '2025-02-28T10:00:00Z',
organizationId: 'ACHALA_HEALTH_01'
},
totalNumberOfRecords: 1
}
Updates an existing appointment record.
Validates and sends the updated appointment data to the backend API.
The updated appointment data. Fields include:
A promise that resolves with:
const updateData = {
appointmentStartDate: "2025-08-01T11:00:00Z",
appointmentEndDate: "2025-08-01T11:30:00Z",
appointmentPriority: "ROUTINE",
appointmentSlot: "slot-456",
reference: "updated-ref-001"
};
const updatedappointment = await appointment.update(updateData);
console.log(updatedappointment)
Service for handling appointment-related operations.
This class provides a comprehensive set of methods for managing appointments within the EHR system. It implements standardized CRUD (Create, Read, Update, Delete) and search functionalities for appointments.
All operations are designed to be asynchronous and non-blocking, typically returning Promises (or reactive types like Mono in Java).
Core Features:
This service ensures scalability by supporting non-blocking data operations.