@rinse-dental/open-dental 0.0.6 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/appointments.d.ts +196 -0
- package/dist/api/appointments.d.ts.map +1 -0
- package/dist/api/appointments.js +253 -8
- package/dist/api/commlogs.d.ts +28 -0
- package/dist/api/commlogs.d.ts.map +1 -0
- package/dist/api/commlogs.js +48 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/patients.d.ts +113 -0
- package/dist/api/patients.d.ts.map +1 -0
- package/dist/api/patients.js +149 -6
- package/dist/api/procedureLog.d.ts +117 -0
- package/dist/api/procedureLog.d.ts.map +1 -0
- package/dist/api/procedureLog.js +177 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/openDental.d.ts +19 -0
- package/dist/openDental.d.ts.map +1 -0
- package/dist/types/appointmentType.d.ts +226 -0
- package/dist/types/appointmentType.d.ts.map +1 -0
- package/dist/types/commlogType.d.ts +28 -0
- package/dist/types/commlogType.d.ts.map +1 -0
- package/dist/types/commlogType.js +2 -0
- package/dist/types/patientTypes.d.ts +205 -0
- package/dist/types/patientTypes.d.ts.map +1 -0
- package/dist/types/patientTypes.js +2 -0
- package/dist/types/procedurelogTypes.d.ts +108 -0
- package/dist/types/procedurelogTypes.d.ts.map +1 -0
- package/dist/types/procedurelogTypes.js +3 -0
- package/dist/utils/errorHandler.d.ts +1 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/httpClient.d.ts +46 -0
- package/dist/utils/httpClient.d.ts.map +1 -0
- package/dist/utils/httpClient.js +25 -33
- package/package.json +1 -1
- package/src/api/appointments.ts +323 -26
- package/src/api/commlogs.ts +63 -0
- package/src/api/patients.ts +192 -13
- package/src/api/procedureLog.ts +230 -0
- package/src/openDental.ts +4 -4
- package/src/types/appointmentType.ts +249 -0
- package/src/types/commlogType.ts +28 -0
- package/src/types/patientTypes.ts +209 -0
- package/src/types/procedurelogTypes.ts +119 -0
- package/src/utils/httpClient.ts +27 -31
- package/tsconfig.json +4 -1
- package/src/utils/types.ts +0 -134
- /package/dist/{utils/types.js → types/appointmentType.js} +0 -0
package/dist/utils/httpClient.js
CHANGED
|
@@ -18,17 +18,11 @@ class HttpClient {
|
|
|
18
18
|
/**
|
|
19
19
|
* GET request
|
|
20
20
|
* @param {string} url - The endpoint URL
|
|
21
|
-
* @param {object} params - Optional query parameters
|
|
21
|
+
* @param {object} [params] - Optional query parameters
|
|
22
22
|
* @returns {Promise<T>} - The API response
|
|
23
23
|
*/
|
|
24
24
|
async get(url, params) {
|
|
25
|
-
|
|
26
|
-
const response = await this.client.get(url, { params });
|
|
27
|
-
return response.data;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
this.handleError(error);
|
|
31
|
-
}
|
|
25
|
+
return this.handleRequest(() => this.client.get(url, { params }));
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
34
28
|
* POST request
|
|
@@ -37,13 +31,7 @@ class HttpClient {
|
|
|
37
31
|
* @returns {Promise<T>} - The API response
|
|
38
32
|
*/
|
|
39
33
|
async post(url, data) {
|
|
40
|
-
|
|
41
|
-
const response = await this.client.post(url, data);
|
|
42
|
-
return response.data;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
this.handleError(error);
|
|
46
|
-
}
|
|
34
|
+
return this.handleRequest(() => this.client.post(url, data));
|
|
47
35
|
}
|
|
48
36
|
/**
|
|
49
37
|
* PUT request
|
|
@@ -52,13 +40,7 @@ class HttpClient {
|
|
|
52
40
|
* @returns {Promise<T>} - The API response
|
|
53
41
|
*/
|
|
54
42
|
async put(url, data) {
|
|
55
|
-
|
|
56
|
-
const response = await this.client.put(url, data);
|
|
57
|
-
return response.data;
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
this.handleError(error);
|
|
61
|
-
}
|
|
43
|
+
return this.handleRequest(() => this.client.put(url, data));
|
|
62
44
|
}
|
|
63
45
|
/**
|
|
64
46
|
* DELETE request
|
|
@@ -66,8 +48,17 @@ class HttpClient {
|
|
|
66
48
|
* @returns {Promise<T>} - The API response
|
|
67
49
|
*/
|
|
68
50
|
async delete(url) {
|
|
51
|
+
return this.handleRequest(() => this.client.delete(url));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Handles requests and errors consistently across methods.
|
|
55
|
+
* @param {Function} requestFn - The Axios request function to execute.
|
|
56
|
+
* @returns {Promise<T>} - The API response or an error message.
|
|
57
|
+
* @throws {Error} - Throws an error with a formatted message.
|
|
58
|
+
*/
|
|
59
|
+
async handleRequest(requestFn) {
|
|
69
60
|
try {
|
|
70
|
-
const response = await
|
|
61
|
+
const response = await requestFn();
|
|
71
62
|
return response.data;
|
|
72
63
|
}
|
|
73
64
|
catch (error) {
|
|
@@ -75,34 +66,35 @@ class HttpClient {
|
|
|
75
66
|
}
|
|
76
67
|
}
|
|
77
68
|
/**
|
|
78
|
-
* Error handler to provide detailed error information
|
|
79
|
-
* @param {
|
|
69
|
+
* Error handler to provide detailed error information.
|
|
70
|
+
* @param {unknown} error - The error object from Axios or another source.
|
|
71
|
+
* @throws {Error} - A formatted error with API details or a general message.
|
|
80
72
|
*/
|
|
81
73
|
handleError(error) {
|
|
82
74
|
if (axios_1.default.isAxiosError(error)) {
|
|
83
|
-
// Handle Axios-specific error
|
|
84
75
|
if (error.response) {
|
|
85
|
-
// The
|
|
76
|
+
// The server responded with a status code outside 2xx
|
|
77
|
+
const { status, data } = error.response;
|
|
86
78
|
console.error("API Response Error:", {
|
|
87
|
-
status
|
|
88
|
-
data
|
|
79
|
+
status,
|
|
80
|
+
data,
|
|
89
81
|
headers: error.response.headers,
|
|
90
82
|
});
|
|
91
|
-
throw new Error(`
|
|
83
|
+
throw new Error(`API Error (Status ${status}): ${data?.message || JSON.stringify(data)}`);
|
|
92
84
|
}
|
|
93
85
|
else if (error.request) {
|
|
94
|
-
// The request was made, but no response
|
|
86
|
+
// The request was made, but no response received
|
|
95
87
|
console.error("No Response Error:", error.request);
|
|
96
88
|
throw new Error("No response received from the server.");
|
|
97
89
|
}
|
|
98
90
|
else {
|
|
99
|
-
// Something
|
|
91
|
+
// Something went wrong in setting up the request
|
|
100
92
|
console.error("Request Setup Error:", error.message);
|
|
101
93
|
throw new Error(`Request setup failed: ${error.message}`);
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
96
|
else {
|
|
105
|
-
// Handle non-Axios errors
|
|
97
|
+
// Handle non-Axios-specific errors
|
|
106
98
|
console.error("Unexpected Error:", error);
|
|
107
99
|
throw new Error("An unexpected error occurred.");
|
|
108
100
|
}
|
package/package.json
CHANGED
package/src/api/appointments.ts
CHANGED
|
@@ -1,40 +1,337 @@
|
|
|
1
1
|
import HttpClient from "../utils/httpClient";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Appointment,
|
|
4
|
+
AppointmentSlot,
|
|
5
|
+
GetAppointmentParams,
|
|
6
|
+
GetASAPParams,
|
|
7
|
+
GetSlotsParams,
|
|
8
|
+
GetSlotsWebSchedParams,
|
|
9
|
+
GetWebSchedAppointmentsParams,
|
|
10
|
+
CreateNewAppointmentParams,
|
|
11
|
+
CreatePlannedAppointmentParams,
|
|
12
|
+
SchedulePlannedAppointmentParams,
|
|
13
|
+
ScheduleWebSchedAppointmentParams,
|
|
14
|
+
UpdateAppointmentParams,
|
|
15
|
+
BreakAppointmentParams,
|
|
16
|
+
ConfirmAppointmentParams,
|
|
17
|
+
} from "../types/appointmentType";
|
|
3
18
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
getAppointments(params?: object): Promise<Appointment[]>;
|
|
7
|
-
createAppointment(data: Partial<Appointment>): Promise<Appointment>;
|
|
8
|
-
}
|
|
19
|
+
export default class Appointments {
|
|
20
|
+
private httpClient: HttpClient;
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
constructor(httpClient: HttpClient) {
|
|
23
|
+
this.httpClient = httpClient;
|
|
24
|
+
}
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Fetch a single appointment by its ID.
|
|
28
|
+
* @param {number} AptNum - The unique identifier for the appointment.
|
|
29
|
+
* @returns {Promise<Appointment>} - The appointment object.
|
|
30
|
+
* @throws {Error} - If `AptNum` is not provided.
|
|
31
|
+
*/
|
|
32
|
+
public async getAppointment(AptNum: number): Promise<Appointment> {
|
|
33
|
+
if (!AptNum) {
|
|
34
|
+
throw new Error("AptNum is required.");
|
|
15
35
|
}
|
|
36
|
+
return this.httpClient.get<Appointment>(`/appointments/${AptNum}`);
|
|
37
|
+
}
|
|
16
38
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Fetch multiple appointments with optional filtering and pagination.
|
|
41
|
+
* @param {Object} params - The parameters for filtering and pagination.
|
|
42
|
+
* @param {number} [params.PatNum] - Filter by patient number.
|
|
43
|
+
* @param {"Scheduled" | "Complete" | "UnschedList" | "ASAP" | "Broken" | "Planned" | "PtNote" | "PtNoteCompleted"} [params.AptStatus] - Filter by appointment status.
|
|
44
|
+
* @param {number} [params.Op] - Filter by operatory number.
|
|
45
|
+
* @param {string} [params.date] - Search for a specific day in "yyyy-MM-dd" format.
|
|
46
|
+
* @param {string} [params.dateStart] - Start date for date range in "yyyy-MM-dd" format.
|
|
47
|
+
* @param {string} [params.dateEnd] - End date for date range in "yyyy-MM-dd" format.
|
|
48
|
+
* @param {number} [params.ClinicNum] - Filter by clinic number.
|
|
49
|
+
* @param {string} [params.DateTStamp] - Return only appointments updated after this timestamp.
|
|
50
|
+
* @param {number} [params.Offset] - Pagination offset for results.
|
|
51
|
+
* @returns {Promise<Appointment[]>} - A list of appointments.
|
|
52
|
+
*/
|
|
53
|
+
public async getAppointments({
|
|
54
|
+
PatNum,
|
|
55
|
+
AptStatus,
|
|
56
|
+
Op,
|
|
57
|
+
date,
|
|
58
|
+
dateStart,
|
|
59
|
+
dateEnd,
|
|
60
|
+
ClinicNum,
|
|
61
|
+
DateTStamp,
|
|
62
|
+
Offset,
|
|
63
|
+
}: GetAppointmentParams = {}): Promise<Appointment[]> {
|
|
64
|
+
const params = {
|
|
65
|
+
PatNum,
|
|
66
|
+
AptStatus,
|
|
67
|
+
Op,
|
|
68
|
+
date,
|
|
69
|
+
dateStart,
|
|
70
|
+
dateEnd,
|
|
71
|
+
ClinicNum,
|
|
72
|
+
DateTStamp,
|
|
73
|
+
Offset,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return this.httpClient.get<Appointment[]>("/appointments", params);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Fetch ASAP appointments.
|
|
81
|
+
* @param {Object} params - Parameters for fetching ASAP appointments.
|
|
82
|
+
* @param {number} params.ClinicNum - Required: Clinic number. Use 0 for appointments not attached to clinics.
|
|
83
|
+
* @param {number} [params.ProvNum] - Optional: Provider number.
|
|
84
|
+
* @returns {Promise<Appointment[]>} - A list of ASAP appointments.
|
|
85
|
+
* @throws {Error} - If `ClinicNum` is not provided.
|
|
86
|
+
*/
|
|
87
|
+
public async getASAPappointments(params: GetASAPParams): Promise<Appointment[]> {
|
|
88
|
+
if (!params.ClinicNum) {
|
|
89
|
+
throw new Error("ClinicNum is required when Clinics are enabled.");
|
|
28
90
|
}
|
|
91
|
+
return this.httpClient.get<Appointment[]>("/appointments/asap", params);
|
|
92
|
+
}
|
|
29
93
|
|
|
30
|
-
|
|
31
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Fetch available appointment slots.
|
|
96
|
+
* @param {Object} params - Parameters for filtering slots.
|
|
97
|
+
* @param {string} [params.date] - Search for a specific day in "yyyy-MM-dd" format.
|
|
98
|
+
* @param {string} [params.dateStart] - Start date for date range in "yyyy-MM-dd" format.
|
|
99
|
+
* @param {string} [params.dateEnd] - End date for date range in "yyyy-MM-dd" format.
|
|
100
|
+
* @param {number} [params.lengthMinutes] - Ignore slots shorter than this length.
|
|
101
|
+
* @param {number} [params.ProvNum] - Provider number.
|
|
102
|
+
* @param {number} [params.OpNum] - Operatory number.
|
|
103
|
+
* @returns {Promise<AppointmentSlot[]>} - A list of available slots.
|
|
104
|
+
*/
|
|
105
|
+
public async getSlots(params?: GetSlotsParams): Promise<AppointmentSlot[]> {
|
|
106
|
+
return this.httpClient.get<AppointmentSlot[]>("/appointments/slots", params);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fetch WebSched appointment slots.
|
|
111
|
+
* @param {Object} params - Parameters for filtering WebSched slots.
|
|
112
|
+
* @param {string} [params.date] - Search for a specific day in "yyyy-MM-dd" format.
|
|
113
|
+
* @param {string} [params.dateStart] - Start date for date range in "yyyy-MM-dd" format.
|
|
114
|
+
* @param {string} [params.dateEnd] - End date for date range in "yyyy-MM-dd" format.
|
|
115
|
+
* @param {number} params.ClinicNum - Required: Clinic number.
|
|
116
|
+
* @param {number} [params.defNumApptType] - Appointment type definition number.
|
|
117
|
+
* @param {"true" | "false"} [params.isNewPatient] - Indicates if the slot is for a new patient.
|
|
118
|
+
* @returns {Promise<AppointmentSlot[]>} - A list of WebSched slots.
|
|
119
|
+
* @throws {Error} - If `ClinicNum` is not provided.
|
|
120
|
+
*/
|
|
121
|
+
public async getSlotsWebSched(params: GetSlotsWebSchedParams): Promise<AppointmentSlot[]> {
|
|
122
|
+
if (!params.ClinicNum) {
|
|
123
|
+
throw new Error("ClinicNum is required when Clinics are enabled.");
|
|
32
124
|
}
|
|
125
|
+
return this.httpClient.get<AppointmentSlot[]>("/appointments/slotswebsched", params);
|
|
126
|
+
}
|
|
33
127
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Fetch WebSched appointments.
|
|
130
|
+
* @param {Object} params - Parameters for fetching WebSched appointments.
|
|
131
|
+
* @param {string} [params.date] - Search for a specific day in "yyyy-MM-dd" format.
|
|
132
|
+
* @param {string} [params.dateStart] - Start date for date range in "yyyy-MM-dd" format.
|
|
133
|
+
* @param {string} [params.dateEnd] - End date for date range in "yyyy-MM-dd" format.
|
|
134
|
+
* @param {string} [params.DateTStamp] - Return only appointments updated after this timestamp.
|
|
135
|
+
* @param {number} [params.ClinicNum] - Clinic number.
|
|
136
|
+
* @returns {Promise<Appointment[]>} - A list of WebSched appointments.
|
|
137
|
+
*/
|
|
138
|
+
public async getWebSchedAppointments(
|
|
139
|
+
params?: GetWebSchedAppointmentsParams
|
|
140
|
+
): Promise<Appointment[]> {
|
|
141
|
+
return this.httpClient.get<Appointment[]>("/appointments/websched", params);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Create a new appointment.
|
|
146
|
+
* @param {Object} data - Data for the new appointment.
|
|
147
|
+
* @param {number} data.PatNum - Required: Patient number.
|
|
148
|
+
* @param {number} data.Op - Required: Operatory number.
|
|
149
|
+
* @param {string} data.AptDateTime - Required: Appointment start time in "yyyy-MM-dd HH:mm:ss" format.
|
|
150
|
+
* @param {"Scheduled" | "Complete" | "UnschedList" | "PtNote" | "PtNoteCompleted"} [data.AptStatus="Scheduled"] - Optional: Appointment status. Default is "Scheduled".
|
|
151
|
+
* @param {string} [data.Pattern="/XX/"] - Optional: Time pattern in 5-minute increments. Default is "/XX/" (20 minutes).
|
|
152
|
+
* @param {number} [data.Confirmed] - Optional: Confirmation status definition number.
|
|
153
|
+
* @param {string} [data.Note] - Optional: Appointment notes.
|
|
154
|
+
* @param {number} [data.ProvNum] - Optional: Provider number.
|
|
155
|
+
* @param {number} [data.ProvHyg=0] - Optional: Hygienist provider number. Default is 0.
|
|
156
|
+
* @param {number} [data.ClinicNum] - Optional: Clinic number.
|
|
157
|
+
* @param {"true" | "false"} [data.IsHygiene="false"] - Optional: Indicates if the appointment is for hygiene. Default is "false".
|
|
158
|
+
* @param {"true" | "false"} [data.IsNewPatient="false"] - Optional: Indicates if the patient is new. Default is "false".
|
|
159
|
+
* @param {"Normal" | "ASAP"} [data.Priority="Normal"] - Optional: Appointment priority. Default is "Normal".
|
|
160
|
+
* @param {number} [data.AppointmentTypeNum=0] - Optional: Appointment type number. Default is 0.
|
|
161
|
+
* @param {string} [data.colorOverride] - Optional: Custom color in "R,G,B" format.
|
|
162
|
+
* @param {string} [data.PatternSecondary] - Optional: Secondary time pattern.
|
|
163
|
+
* @returns {Promise<Appointment>} - The created appointment.
|
|
164
|
+
* @throws {Error} - If required fields are missing.
|
|
165
|
+
*/
|
|
166
|
+
public async createNewAppointment(data: CreateNewAppointmentParams): Promise<Appointment> {
|
|
167
|
+
if (!data.PatNum || !data.Op || !data.AptDateTime) {
|
|
168
|
+
throw new Error("PatNum, Op, and AptDateTime are required.");
|
|
37
169
|
}
|
|
170
|
+
|
|
38
171
|
return this.httpClient.post<Appointment>("/appointments", data);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Create a planned appointment.
|
|
177
|
+
* @param {Object} data - Data for the planned appointment.
|
|
178
|
+
* @param {number} data.PatNum - Required: Patient number.
|
|
179
|
+
* @param {number} [data.AppointmentTypeNum] - Optional: Appointment type number.
|
|
180
|
+
* @param {number[]} [data.procNums] - Optional: Array of procedure numbers. At least one of `AppointmentTypeNum` or `procNums` is required.
|
|
181
|
+
* @param {string} [data.Pattern="/XX/"] - Optional: Time pattern in 5-minute increments. Default is "/XX/" (20 minutes).
|
|
182
|
+
* @param {number} [data.Confirmed] - Optional: Confirmation status definition number.
|
|
183
|
+
* @param {string} [data.Note] - Optional: Appointment notes.
|
|
184
|
+
* @param {number} [data.ProvNum] - Optional: Provider number.
|
|
185
|
+
* @param {number} [data.ProvHyg=0] - Optional: Hygienist provider number. Default is 0.
|
|
186
|
+
* @param {number} [data.ClinicNum] - Optional: Clinic number.
|
|
187
|
+
* @param {"true" | "false"} [data.IsHygiene="false"] - Optional: Indicates if the appointment is for hygiene. Default is "false".
|
|
188
|
+
* @param {"true" | "false"} [data.IsNewPatient="false"] - Optional: Indicates if the patient is new. Default is "false".
|
|
189
|
+
* @param {"Normal" | "ASAP"} [data.Priority="Normal"] - Optional: Appointment priority. Default is "Normal".
|
|
190
|
+
* @param {string} [data.PatternSecondary] - Optional: Secondary time pattern.
|
|
191
|
+
* @returns {Promise<Appointment>} - The created planned appointment.
|
|
192
|
+
* @throws {Error} - If required fields are missing.
|
|
193
|
+
*/
|
|
194
|
+
public async createPlannedAppointment(data: CreatePlannedAppointmentParams): Promise<Appointment> {
|
|
195
|
+
if (!data.PatNum || (!data.AppointmentTypeNum && (!data.procNums || data.procNums.length === 0))) {
|
|
196
|
+
throw new Error("PatNum and either AppointmentTypeNum or procNums are required.");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return this.httpClient.post<Appointment>("/appointments/planned", data);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Schedule a planned appointment.
|
|
205
|
+
* @param {Object} data - Data for scheduling the planned appointment.
|
|
206
|
+
* @param {number} data.AptNum - Required: The appointment number with Planned status.
|
|
207
|
+
* @param {string} data.AptDateTime - Required: Start time for the appointment in "yyyy-MM-dd HH:mm:ss" format.
|
|
208
|
+
* @param {number} data.ProvNum - Required: The provider number for the appointment.
|
|
209
|
+
* @param {number} data.Op - Required: The operatory number for the appointment.
|
|
210
|
+
* @param {number} [data.Confirmed] - Optional: Confirmation status definition number.
|
|
211
|
+
* @param {string} [data.Note] - Optional: Notes for the appointment. Will overwrite any existing note.
|
|
212
|
+
* @returns {Promise<Appointment>} - The scheduled appointment.
|
|
213
|
+
* @throws {Error} - If required fields are missing.
|
|
214
|
+
*/
|
|
215
|
+
public async schedulePlannedAppointment(
|
|
216
|
+
data: SchedulePlannedAppointmentParams
|
|
217
|
+
): Promise<Appointment> {
|
|
218
|
+
if (!data.AptNum || !data.AptDateTime || !data.ProvNum || !data.Op) {
|
|
219
|
+
throw new Error("AptNum, AptDateTime, ProvNum, and Op are required.");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return this.httpClient.post<Appointment>("/appointments/scheduleplanned", data);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Schedule a WebSched appointment.
|
|
227
|
+
* @param {Object} data - Data for scheduling the WebSched appointment.
|
|
228
|
+
* @param {number} data.PatNum - Required: Patient number.
|
|
229
|
+
* @param {string} data.DateTimeStart - Required: The start time of the appointment in "yyyy-MM-dd HH:mm:ss" format.
|
|
230
|
+
* @param {string} data.DateTimeEnd - Required: The end time of the appointment in "yyyy-MM-dd HH:mm:ss" format.
|
|
231
|
+
* @param {number} data.ProvNum - Required: Provider number associated with the appointment slot.
|
|
232
|
+
* @param {number} data.OpNum - Required: Operatory number associated with the appointment slot.
|
|
233
|
+
* @param {number} data.defNumApptType - Required: Appointment type definition number.
|
|
234
|
+
* @returns {Promise<Appointment>} - The scheduled WebSched appointment.
|
|
235
|
+
* @throws {Error} - If required fields are missing.
|
|
236
|
+
*/
|
|
237
|
+
public async scheduleWebSchedAppointment(
|
|
238
|
+
data: ScheduleWebSchedAppointmentParams
|
|
239
|
+
): Promise<Appointment> {
|
|
240
|
+
if (
|
|
241
|
+
!data.PatNum ||
|
|
242
|
+
!data.DateTimeStart ||
|
|
243
|
+
!data.DateTimeEnd ||
|
|
244
|
+
!data.ProvNum ||
|
|
245
|
+
!data.OpNum ||
|
|
246
|
+
!data.defNumApptType
|
|
247
|
+
) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
"PatNum, DateTimeStart, DateTimeEnd, ProvNum, OpNum, and defNumApptType are required."
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return this.httpClient.post<Appointment>("/appointments/websched", data);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Update an existing appointment.
|
|
258
|
+
* @param {Object} data - Data for updating the appointment.
|
|
259
|
+
* @param {number} data.AptNum - Required: The unique identifier of the appointment to update.
|
|
260
|
+
* @param {"Scheduled" | "Complete" | "UnschedList" | "Broken" | "Planned" | "PtNote" | "PtNoteCompleted"} [data.AptStatus] - Optional: Updated status of the appointment.
|
|
261
|
+
* @param {string} [data.Pattern] - Optional: Updated time pattern in 5-minute increments.
|
|
262
|
+
* @param {number} [data.Confirmed] - Optional: Updated confirmation status definition number.
|
|
263
|
+
* @param {number} [data.Op] - Optional: Updated operatory number.
|
|
264
|
+
* @param {string} [data.Note] - Optional: Updated notes for the appointment. Will overwrite existing notes.
|
|
265
|
+
* @param {number} [data.ProvNum] - Optional: Updated provider number.
|
|
266
|
+
* @param {number} [data.ProvHyg] - Optional: Updated hygienist provider number.
|
|
267
|
+
* @param {string} [data.AptDateTime] - Optional: Updated appointment start time in "yyyy-MM-dd HH:mm:ss" format.
|
|
268
|
+
* @param {number} [data.ClinicNum] - Optional: Updated clinic number.
|
|
269
|
+
* @param {"true" | "false"} [data.IsHygiene] - Optional: Indicates if the appointment is for hygiene.
|
|
270
|
+
* @param {"true" | "false"} [data.IsNewPatient] - Optional: Indicates if the appointment is for a new patient.
|
|
271
|
+
* @param {"Normal" | "ASAP"} [data.Priority] - Optional: Updated priority of the appointment.
|
|
272
|
+
* @param {number} [data.AppointmentTypeNum] - Optional: Updated appointment type number.
|
|
273
|
+
* @param {number} [data.UnschedStatus] - Optional: Updated unscheduled status definition number.
|
|
274
|
+
* @param {string} [data.colorOverride] - Optional: Updated custom color in "R,G,B" format.
|
|
275
|
+
* @param {string} [data.PatternSecondary] - Optional: Updated secondary time pattern.
|
|
276
|
+
* @returns {Promise<Appointment>} - The updated appointment.
|
|
277
|
+
* @throws {Error} - If `AptNum` is missing.
|
|
278
|
+
*/
|
|
279
|
+
public async updateAppointment(data: UpdateAppointmentParams): Promise<Appointment> {
|
|
280
|
+
if (!data.AptNum) {
|
|
281
|
+
throw new Error("AptNum is required.");
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return this.httpClient.put<Appointment>(`/appointments/${data.AptNum}`, data);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Break an existing appointment.
|
|
289
|
+
* Only appointments with an AptStatus of "Scheduled" can be broken.
|
|
290
|
+
* @param {Object} data - Data for breaking the appointment.
|
|
291
|
+
* @param {number} data.AptNum - Required: The unique identifier of the appointment to break.
|
|
292
|
+
* @param {"true" | "false"} data.sendToUnscheduledList - Required: Indicates if the appointment should be added to the Unscheduled List.
|
|
293
|
+
* @param {"Missed" | "Cancelled"} [data.breakType] - Optional: Reason for breaking the appointment.
|
|
294
|
+
* @returns {Promise<void>} - Resolves when the appointment is successfully broken.
|
|
295
|
+
* @throws {Error} - If required fields are missing.
|
|
296
|
+
*/
|
|
297
|
+
public async breakAppointment(data: BreakAppointmentParams): Promise<void> {
|
|
298
|
+
if (!data.AptNum || !data.sendToUnscheduledList) {
|
|
299
|
+
throw new Error("AptNum and sendToUnscheduledList are required.");
|
|
39
300
|
}
|
|
301
|
+
|
|
302
|
+
return this.httpClient.put<void>(`/appointments/${data.AptNum}/break`, data);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Update the note for an existing appointment.
|
|
307
|
+
* @param {number} AptNum - Required: The unique identifier of the appointment to update.
|
|
308
|
+
* @param {string} Note - Required: The new note content for the appointment.
|
|
309
|
+
* @returns {Promise<void>} - Resolves when the note is successfully updated.
|
|
310
|
+
* @throws {Error} - If required fields are missing.
|
|
311
|
+
*/
|
|
312
|
+
public async updateAppointmentNote(AptNum: number, Note: string): Promise<void> {
|
|
313
|
+
if (!AptNum || !Note) {
|
|
314
|
+
throw new Error("AptNum and Note are required.");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return this.httpClient.put<void>(`/appointments/${AptNum}/note`, { Note });
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Confirm an existing appointment.
|
|
322
|
+
* @param {Object} data - Data for confirming the appointment.
|
|
323
|
+
* @param {number} data.AptNum - Required: The unique identifier of the appointment to confirm.
|
|
324
|
+
* @param {string} [data.confirmVal] - Optional: Confirmation value, e.g., "Sent", "Confirmed".
|
|
325
|
+
* @param {number} [data.defNum] - Optional: Confirmation definition number.
|
|
326
|
+
* @returns {Promise<void>} - Resolves when the appointment is successfully confirmed.
|
|
327
|
+
* @throws {Error} - If required fields are missing.
|
|
328
|
+
*/
|
|
329
|
+
public async confirmAppointment(data: ConfirmAppointmentParams): Promise<void> {
|
|
330
|
+
if (!data.AptNum || (!data.confirmVal && !data.defNum)) {
|
|
331
|
+
throw new Error("AptNum and either confirmVal or defNum are required.");
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return this.httpClient.put<void>(`/appointments/${data.AptNum}/confirm`, data);
|
|
335
|
+
}
|
|
336
|
+
|
|
40
337
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import HttpClient from "../utils/httpClient";
|
|
2
|
+
import { CommLog, CreateCommLogParams } from "../types/commlogType";
|
|
3
|
+
|
|
4
|
+
export default class CommLogs {
|
|
5
|
+
private httpClient: HttpClient;
|
|
6
|
+
|
|
7
|
+
constructor(httpClient: HttpClient) {
|
|
8
|
+
this.httpClient = httpClient;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Fetch communication logs for a specific patient.
|
|
13
|
+
* @param {number} PatNum - Required: The unique identifier for the patient.
|
|
14
|
+
* @returns {Promise<CommLog[]>} - A list of communication logs for the patient.
|
|
15
|
+
* @throws {Error} - If `PatNum` is not provided or the API returns an error.
|
|
16
|
+
*/
|
|
17
|
+
public async getCommLogs(PatNum: number): Promise<CommLog[]> {
|
|
18
|
+
if (!PatNum || typeof PatNum !== "number") {
|
|
19
|
+
throw new Error("Invalid parameter: PatNum must be a valid number.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return this.httpClient.get<CommLog[]>("/commlogs", { PatNum });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a new communication log.
|
|
27
|
+
* @param {CreateCommLogParams} params - The details of the communication log to create.
|
|
28
|
+
* @param {number} params.PatNum - Required: The unique identifier for the patient.
|
|
29
|
+
* @param {string} params.CommDateTime - Required: Date and time of the communication in "yyyy-MM-dd HH:mm:ss" format.
|
|
30
|
+
* @param {"None" | "Email" | "Mail" | "Phone" | "In Person" | "Text" | "Email and Text" | "Phone and Text"} params.Mode_ - Required: Mode of communication.
|
|
31
|
+
* @param {string} params.Note - Required: Detailed note about the communication.
|
|
32
|
+
* @param {number} [params.CommType] - Optional: Type of communication: definition.DefNum where definition.Category=25.
|
|
33
|
+
* @param {string} [params.commType] - Optional: Human-readable description of the communication type.
|
|
34
|
+
* @param {"Sent" | "Received" | "Neither"} [params.SentOrReceived] - Optional: Direction of communication.
|
|
35
|
+
* @returns {Promise<CommLog>} - The created communication log.
|
|
36
|
+
* @throws {Error} - If required fields are missing or the API returns an error.
|
|
37
|
+
*/
|
|
38
|
+
public async createCommLog({
|
|
39
|
+
PatNum,
|
|
40
|
+
CommDateTime,
|
|
41
|
+
Mode_,
|
|
42
|
+
Note,
|
|
43
|
+
CommType,
|
|
44
|
+
commType,
|
|
45
|
+
SentOrReceived,
|
|
46
|
+
}: CreateCommLogParams): Promise<CommLog> {
|
|
47
|
+
if (!PatNum || !CommDateTime || !Mode_ || !Note) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"Invalid data: PatNum, CommDateTime, Mode_, and Note are required."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return this.httpClient.post<CommLog>("/commlogs", {
|
|
54
|
+
PatNum,
|
|
55
|
+
CommDateTime,
|
|
56
|
+
Mode_,
|
|
57
|
+
Note,
|
|
58
|
+
CommType,
|
|
59
|
+
commType,
|
|
60
|
+
SentOrReceived,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|