@rinse-dental/open-dental 0.0.6 → 0.1.0
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 +195 -0
- package/dist/api/appointments.js +253 -8
- package/dist/api/index.d.ts +2 -0
- package/dist/api/patients.d.ts +112 -0
- package/dist/api/patients.js +149 -6
- package/dist/api/procedureLog.d.ts +116 -0
- package/dist/api/procedureLog.js +177 -0
- package/dist/index.d.ts +1 -0
- package/dist/openDental.d.ts +18 -0
- package/dist/types/appointmentType.d.ts +225 -0
- package/dist/types/appointmentType.js +2 -0
- package/dist/types/patientTypes.d.ts +204 -0
- package/dist/types/patientTypes.js +2 -0
- package/dist/types/procedurelogTypes.d.ts +107 -0
- package/dist/types/procedurelogTypes.js +3 -0
- package/dist/utils/errorHandler.d.ts +0 -0
- package/dist/utils/httpClient.d.ts +45 -0
- package/dist/utils/httpClient.js +25 -33
- package/package.json +1 -1
- package/src/api/appointments.ts +323 -26
- 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/patientTypes.ts +209 -0
- package/src/types/procedurelogTypes.ts +119 -0
- package/src/utils/httpClient.ts +27 -31
- package/tsconfig.json +2 -1
- package/src/utils/types.ts +0 -134
package/src/utils/httpClient.ts
CHANGED
|
@@ -16,16 +16,11 @@ class HttpClient {
|
|
|
16
16
|
/**
|
|
17
17
|
* GET request
|
|
18
18
|
* @param {string} url - The endpoint URL
|
|
19
|
-
* @param {object} params - Optional query parameters
|
|
19
|
+
* @param {object} [params] - Optional query parameters
|
|
20
20
|
* @returns {Promise<T>} - The API response
|
|
21
21
|
*/
|
|
22
22
|
public async get<T>(url: string, params?: object): Promise<T> {
|
|
23
|
-
|
|
24
|
-
const response: AxiosResponse<T> = await this.client.get<T>(url, { params });
|
|
25
|
-
return response.data;
|
|
26
|
-
} catch (error) {
|
|
27
|
-
this.handleError(error);
|
|
28
|
-
}
|
|
23
|
+
return this.handleRequest<T>(() => this.client.get<T>(url, { params }));
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
/**
|
|
@@ -35,12 +30,7 @@ class HttpClient {
|
|
|
35
30
|
* @returns {Promise<T>} - The API response
|
|
36
31
|
*/
|
|
37
32
|
public async post<T>(url: string, data: object): Promise<T> {
|
|
38
|
-
|
|
39
|
-
const response: AxiosResponse<T> = await this.client.post<T>(url, data);
|
|
40
|
-
return response.data;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
this.handleError(error);
|
|
43
|
-
}
|
|
33
|
+
return this.handleRequest<T>(() => this.client.post<T>(url, data));
|
|
44
34
|
}
|
|
45
35
|
|
|
46
36
|
/**
|
|
@@ -50,12 +40,7 @@ class HttpClient {
|
|
|
50
40
|
* @returns {Promise<T>} - The API response
|
|
51
41
|
*/
|
|
52
42
|
public async put<T>(url: string, data: object): Promise<T> {
|
|
53
|
-
|
|
54
|
-
const response: AxiosResponse<T> = await this.client.put<T>(url, data);
|
|
55
|
-
return response.data;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
this.handleError(error);
|
|
58
|
-
}
|
|
43
|
+
return this.handleRequest<T>(() => this.client.put<T>(url, data));
|
|
59
44
|
}
|
|
60
45
|
|
|
61
46
|
/**
|
|
@@ -64,8 +49,18 @@ class HttpClient {
|
|
|
64
49
|
* @returns {Promise<T>} - The API response
|
|
65
50
|
*/
|
|
66
51
|
public async delete<T>(url: string): Promise<T> {
|
|
52
|
+
return this.handleRequest<T>(() => this.client.delete<T>(url));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Handles requests and errors consistently across methods.
|
|
57
|
+
* @param {Function} requestFn - The Axios request function to execute.
|
|
58
|
+
* @returns {Promise<T>} - The API response or an error message.
|
|
59
|
+
* @throws {Error} - Throws an error with a formatted message.
|
|
60
|
+
*/
|
|
61
|
+
private async handleRequest<T>(requestFn: () => Promise<AxiosResponse<T>>): Promise<T> {
|
|
67
62
|
try {
|
|
68
|
-
const response
|
|
63
|
+
const response = await requestFn();
|
|
69
64
|
return response.data;
|
|
70
65
|
} catch (error) {
|
|
71
66
|
this.handleError(error);
|
|
@@ -73,37 +68,38 @@ class HttpClient {
|
|
|
73
68
|
}
|
|
74
69
|
|
|
75
70
|
/**
|
|
76
|
-
* Error handler to provide detailed error information
|
|
77
|
-
* @param {
|
|
71
|
+
* Error handler to provide detailed error information.
|
|
72
|
+
* @param {unknown} error - The error object from Axios or another source.
|
|
73
|
+
* @throws {Error} - A formatted error with API details or a general message.
|
|
78
74
|
*/
|
|
79
75
|
private handleError(error: unknown): never {
|
|
80
76
|
if (axios.isAxiosError(error)) {
|
|
81
|
-
// Handle Axios-specific error
|
|
82
77
|
if (error.response) {
|
|
83
|
-
// The
|
|
78
|
+
// The server responded with a status code outside 2xx
|
|
79
|
+
const { status, data } = error.response;
|
|
84
80
|
console.error("API Response Error:", {
|
|
85
|
-
status
|
|
86
|
-
data
|
|
81
|
+
status,
|
|
82
|
+
data,
|
|
87
83
|
headers: error.response.headers,
|
|
88
84
|
});
|
|
89
85
|
throw new Error(
|
|
90
|
-
`
|
|
86
|
+
`API Error (Status ${status}): ${data?.message || JSON.stringify(data)}`
|
|
91
87
|
);
|
|
92
88
|
} else if (error.request) {
|
|
93
|
-
// The request was made, but no response
|
|
89
|
+
// The request was made, but no response received
|
|
94
90
|
console.error("No Response Error:", error.request);
|
|
95
91
|
throw new Error("No response received from the server.");
|
|
96
92
|
} else {
|
|
97
|
-
// Something
|
|
93
|
+
// Something went wrong in setting up the request
|
|
98
94
|
console.error("Request Setup Error:", error.message);
|
|
99
95
|
throw new Error(`Request setup failed: ${error.message}`);
|
|
100
96
|
}
|
|
101
97
|
} else {
|
|
102
|
-
// Handle non-Axios errors
|
|
98
|
+
// Handle non-Axios-specific errors
|
|
103
99
|
console.error("Unexpected Error:", error);
|
|
104
100
|
throw new Error("An unexpected error occurred.");
|
|
105
101
|
}
|
|
106
102
|
}
|
|
107
|
-
}
|
|
103
|
+
}
|
|
108
104
|
|
|
109
105
|
export default HttpClient;
|
package/tsconfig.json
CHANGED
package/src/utils/types.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a patient in the Open Dental system.
|
|
3
|
-
* @see https://www.opendental.com/site/apipatients.html
|
|
4
|
-
*/
|
|
5
|
-
export interface Patient {
|
|
6
|
-
PatNum: number; // Unique patient identifier
|
|
7
|
-
LName: string; // Last name
|
|
8
|
-
FName: string; // First name
|
|
9
|
-
MiddleI?: string; // Middle initial
|
|
10
|
-
Preferred?: string; // Preferred name
|
|
11
|
-
PatStatus: 'Patient' | 'NonPatient' | 'Inactive' | 'Archived' | 'Deceased' | 'Prospective'; // Patient status
|
|
12
|
-
Gender: 'Male' | 'Female' | 'Unknown' | 'Other'; // Gender
|
|
13
|
-
Position: 'Single' | 'Married' | 'Child' | 'Widowed' | 'Divorced'; // Marital status
|
|
14
|
-
Birthdate: string; // Date of birth in 'yyyy-MM-dd' format
|
|
15
|
-
SSN?: string; // Social Security Number
|
|
16
|
-
Address?: string; // Primary address
|
|
17
|
-
Address2?: string; // Secondary address
|
|
18
|
-
City?: string; // City
|
|
19
|
-
State?: string; // State
|
|
20
|
-
Zip?: string; // ZIP code
|
|
21
|
-
HmPhone?: string; // Home phone number
|
|
22
|
-
WkPhone?: string; // Work phone number
|
|
23
|
-
WirelessPhone?: string; // Mobile phone number
|
|
24
|
-
Guarantor: number; // Guarantor's PatNum
|
|
25
|
-
Email?: string; // Email address
|
|
26
|
-
EstBalance: number; // Estimated balance
|
|
27
|
-
PriProv: number; // Primary provider number
|
|
28
|
-
priProvAbbr?: string; // Primary provider abbreviation
|
|
29
|
-
SecProv?: number; // Secondary provider number
|
|
30
|
-
secProvAbbr?: string; // Secondary provider abbreviation
|
|
31
|
-
BillingType?: string; // Billing type description
|
|
32
|
-
ImageFolder?: string; // Image folder name
|
|
33
|
-
FamFinUrgNote?: string; // Family financial urgent note
|
|
34
|
-
ChartNumber?: string; // Chart number
|
|
35
|
-
MedicaidID?: string; // Medicaid ID
|
|
36
|
-
BalTotal: number; // Total balance
|
|
37
|
-
DateFirstVisit?: string; // Date of first visit in 'yyyy-MM-dd' format
|
|
38
|
-
ClinicNum?: number; // Clinic number
|
|
39
|
-
clinicAbbr?: string; // Clinic abbreviation
|
|
40
|
-
Ward?: string; // Ward
|
|
41
|
-
PreferConfirmMethod?: 'None' | 'Email' | 'TextMessage' | 'PhoneCall'; // Preferred confirmation method
|
|
42
|
-
PreferContactMethod?: 'None' | 'Email' | 'TextMessage' | 'PhoneCall' | 'Mail'; // Preferred contact method
|
|
43
|
-
PreferRecallMethod?: 'None' | 'Email' | 'TextMessage' | 'PhoneCall' | 'Mail'; // Preferred recall method
|
|
44
|
-
Language?: string; // Language code (ISO 639-2 format)
|
|
45
|
-
AdmitDate?: string; // Admission date in 'yyyy-MM-dd' format
|
|
46
|
-
siteDesc?: string; // Site description
|
|
47
|
-
DateTStamp: string; // Timestamp of the last update in 'yyyy-MM-dd HH:mm:ss' format
|
|
48
|
-
SuperFamily?: number; // Super family number
|
|
49
|
-
TxtMsgOk?: 'Unknown' | 'Yes' | 'No'; // Text message consent
|
|
50
|
-
SecDateEntry?: string; // Secondary date entry in 'yyyy-MM-dd' format
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Represents an appointment in the Open Dental system.
|
|
55
|
-
* @see https://www.opendental.com/site/apiappointments.html
|
|
56
|
-
*/
|
|
57
|
-
export interface Appointment {
|
|
58
|
-
AptNum: number; // Unique appointment identifier
|
|
59
|
-
PatNum: number; // Patient's PatNum
|
|
60
|
-
AptStatus: 'Scheduled' | 'Complete' | 'UnschedList' | 'ASAP' | 'Broken' | 'Planned' | 'PtNote' | 'PtNoteCompleted'; // Appointment status
|
|
61
|
-
Pattern: string; // Time pattern
|
|
62
|
-
Confirmed: number; // Confirmation status code
|
|
63
|
-
confirmed?: string; // Confirmation status description
|
|
64
|
-
TimeLocked: boolean; // Indicates if the time is locked
|
|
65
|
-
Op: number; // Operatory number
|
|
66
|
-
Note?: string; // Appointment note
|
|
67
|
-
ProvNum: number; // Provider number
|
|
68
|
-
provAbbr?: string; // Provider abbreviation
|
|
69
|
-
ProvHyg?: number; // Hygienist provider number
|
|
70
|
-
AptDateTime: string; // Appointment date and time in 'yyyy-MM-dd HH:mm:ss' format
|
|
71
|
-
NextAptNum?: number; // Next appointment number
|
|
72
|
-
UnschedStatus?: number; // Unscheduled status code
|
|
73
|
-
unschedStatus?: string; // Unscheduled status description
|
|
74
|
-
IsNewPatient: boolean; // Indicates if the patient is new
|
|
75
|
-
ProcDescript?: string; // Procedure description
|
|
76
|
-
ClinicNum?: number; // Clinic number
|
|
77
|
-
IsHygiene: boolean; // Indicates if it's a hygiene appointment
|
|
78
|
-
DateTStamp: string; // Timestamp of the last update in 'yyyy-MM-dd HH:mm:ss' format
|
|
79
|
-
DateTimeArrived?: string; // Arrival time in 'yyyy-MM-dd HH:mm:ss' format
|
|
80
|
-
DateTimeSeated?: string; // Seated time in 'yyyy-MM-dd HH:mm:ss' format
|
|
81
|
-
DateTimeDismissed?: string; // Dismissed time in 'yyyy-MM-dd HH:mm:ss' format
|
|
82
|
-
InsPlan1?: number; // Primary insurance plan number
|
|
83
|
-
InsPlan2?: number; // Secondary insurance plan number
|
|
84
|
-
DateTimeAskedToArrive?: string; // Requested arrival time in 'yyyy-MM-dd HH:mm:ss' format
|
|
85
|
-
colorOverride?: string; // Color override in 'R,G,B' format
|
|
86
|
-
AppointmentTypeNum?: number; // Appointment type number
|
|
87
|
-
SecDateTEntry?: string; // Secondary date entry in 'yyyy-MM-dd' format
|
|
88
|
-
Priority?: 'Normal' | 'ASAP'; // Appointment priority
|
|
89
|
-
PatternSecondary?: string; // Secondary time pattern
|
|
90
|
-
ItemOrderPlanned?: number; // Planned item order
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Represents a procedure log entry in the Open Dental system.
|
|
95
|
-
* @see https://www.opendental.com/site/apiprocedurelogs.html
|
|
96
|
-
*/
|
|
97
|
-
export interface ProcedureLog {
|
|
98
|
-
ProcNum: number; // Unique procedure identifier
|
|
99
|
-
PatNum: number; // Patient's PatNum
|
|
100
|
-
AptNum?: number; // Associated appointment number
|
|
101
|
-
ProcDate: string; // Procedure date in 'yyyy-MM-dd' format
|
|
102
|
-
ProcFee: number; // Procedure fee
|
|
103
|
-
Surf?: string; // Tooth surface
|
|
104
|
-
ToothNum?: string; // Tooth number
|
|
105
|
-
ToothRange?: string; // Tooth range
|
|
106
|
-
Priority?: number; // Priority code
|
|
107
|
-
priority?: string; // Priority description
|
|
108
|
-
ProcStatus: 'TP' | 'C' | 'EO' | 'R' | 'D' | 'E'; // Procedure status: Treatment Planned (TP), Complete (C), Existing Other Provider (EO), Referred (R), Deleted (D), or Existing Current Provider (E)
|
|
109
|
-
ProvNum: number; // Provider number
|
|
110
|
-
provAbbr?: string; // Provider abbreviation
|
|
111
|
-
Dx?: string; // Diagnosis code
|
|
112
|
-
dxName?: string; // Diagnosis name
|
|
113
|
-
PlannedAptNum?: number; // Planned appointment number
|
|
114
|
-
DateEntryC?: string; // Date the procedure was created in 'yyyy-MM-dd HH:mm:ss' format
|
|
115
|
-
ClinicNum?: number; // Clinic number
|
|
116
|
-
MedicalCode?: string; // Medical procedure code
|
|
117
|
-
DiagnosticCode?: string; // Diagnostic code
|
|
118
|
-
CodeNum: number; // Procedure code number
|
|
119
|
-
codeText?: string; // Procedure code description
|
|
120
|
-
ProcNote?: string; // Procedure note
|
|
121
|
-
ToothColor?: string; // Tooth color (if applicable)
|
|
122
|
-
LabFee?: number; // Lab fee
|
|
123
|
-
IsProsth?: boolean; // Indicates if it's a prosthodontic procedure
|
|
124
|
-
ProcTime?: string; // Time taken for the procedure
|
|
125
|
-
PriorityNum?: number; // Priority number
|
|
126
|
-
Prosthesis?: 'None' | 'Crown' | 'Denture' | 'Bridge'; // Type of prosthesis
|
|
127
|
-
ProsthesisDate?: string; // Prosthesis delivery date in 'yyyy-MM-dd' format
|
|
128
|
-
UnitQty?: number; // Quantity of units
|
|
129
|
-
DateTStamp: string; // Timestamp of the last update in 'yyyy-MM-dd HH:mm:ss' format
|
|
130
|
-
SecDateTEntry?: string; // Secondary date entry in 'yyyy-MM-dd HH:mm:ss' format
|
|
131
|
-
MedicalOrderNum?: number; // Medical order number
|
|
132
|
-
PlaceService?: 'Office' | 'InpatientHospital' | 'OutpatientHospital'; // Place of service
|
|
133
|
-
}
|
|
134
|
-
|