@rinse-dental/open-dental 2.0.1 → 2.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.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Represents a Disease (Problem) that is assigned to a patient in the Open Dental system.
3
+ * @see https://www.opendental.com/site/apidiseases.html
4
+ */
5
+ export interface Disease {
6
+ DiseaseNum?: number;
7
+ PatNum?: number;
8
+ DiseaseDefNum?: number;
9
+ diseaseDefName?: string;
10
+ PatNote?: string;
11
+ ProbStatus?: 'Active' | 'Resolved' | 'Inactive';
12
+ DateStart?: string;
13
+ DateStop?: string;
14
+ }
15
+ /**
16
+ * Parameters for GET diseases attached to one or more patients.
17
+ * @see https://www.opendental.com/site/apidiseases.html
18
+ */
19
+ export interface GetDiseasesParams {
20
+ PatNum?: number;
21
+ Offset?: number;
22
+ }
23
+ /**
24
+ * Parameters for attaching a diseaseDef (Problem) to a patient.
25
+ * @see https://www.opendental.com/site/apidiseases.html
26
+ */
27
+ export interface AddDiseaseParams {
28
+ PatNum: number;
29
+ DiseaseDefNum?: number;
30
+ diseaseDefName?: string;
31
+ PatNote?: string;
32
+ ProbStatus?: 'Active' | 'Resolved' | 'Inactive';
33
+ DateStart?: string;
34
+ DateStop?: string;
35
+ }
36
+ /**
37
+ * Parameters for updating a diseaseDef (Problem) attached to a patient.
38
+ * @see https://www.opendental.com/site/apidiseases.html
39
+ */
40
+ export interface UpdateDiseaseParams {
41
+ DiseaseNum: number;
42
+ PatNote?: string;
43
+ ProbStatus?: 'Active' | 'Resolved' | 'Inactive';
44
+ DateStart?: string;
45
+ DateStop?: string;
46
+ }
47
+ //# sourceMappingURL=diseaseTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diseaseTypes.d.ts","sourceRoot":"","sources":["../../src/types/diseaseTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,OAAO;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Represents an Medication that is assigned to a patient in the Open Dental system.
3
+ * @see https://www.opendental.com/site/apimedicationpats.html
4
+ */
5
+ export interface MedicationPat {
6
+ MedicationPatNum?: number;
7
+ PatNum?: number;
8
+ medName?: string;
9
+ MedicationNum?: number;
10
+ PatNote?: string;
11
+ DateStart?: string;
12
+ DateStop?: string;
13
+ ProvNum?: number;
14
+ }
15
+ /**
16
+ * Parameters for GET medications attached to a patient.
17
+ * @see https://www.opendental.com/site/apimedicationpats.html
18
+ */
19
+ export interface GetMedicationPatsParams {
20
+ PatNum: number;
21
+ Offset?: number;
22
+ }
23
+ /**
24
+ * Parameters for attaching a medication to a patient.
25
+ * @see https://www.opendental.com/site/apimedicationpats.html
26
+ */
27
+ export interface AddMedicationPatParams {
28
+ PatNum: number;
29
+ medName?: string;
30
+ MedicationNum?: number;
31
+ PatNote?: string;
32
+ DateStart?: string;
33
+ DateStop?: string;
34
+ ProvNum?: number;
35
+ }
36
+ /**
37
+ * Parameters for updating a medication attached to a patient.
38
+ * @see https://www.opendental.com/site/apimedicationpats.html
39
+ */
40
+ export interface UpdateMedicationPatParams {
41
+ MedicationPatNum: number;
42
+ PatNote?: string;
43
+ DateStart?: string;
44
+ DateStop?: string;
45
+ ProvNum?: number;
46
+ }
47
+ //# sourceMappingURL=medicationPatTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"medicationPatTypes.d.ts","sourceRoot":"","sources":["../../src/types/medicationPatTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rinse-dental/open-dental",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "A TypeScript library for easily accessing Open Dental APIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/release.sh CHANGED
@@ -45,4 +45,4 @@ gh release create "$NEW_TAG" --title "Release $NEW_TAG" --notes "$COMMIT_MSG"
45
45
  #example ./release.sh "Some commit message" major
46
46
  #npm token: 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
47
47
 
48
- #./release.sh "corrected appointment endpoints" minor
48
+ #./release.sh "addition of Fees, treatmentPlanAttaches, and DiscountPlans API" major
@@ -0,0 +1,114 @@
1
+ import HttpClient from "../utils/httpClient";
2
+ import {
3
+ Allergy,
4
+ GetAllergiesParams,
5
+ AddAllergyParams,
6
+ UpdateAllergyParams,
7
+ } from "../types/allergyTypes";
8
+
9
+ export default class Allergies {
10
+ private httpClient: HttpClient;
11
+
12
+ constructor(httpClient: HttpClient) {
13
+ this.httpClient = httpClient;
14
+ }
15
+
16
+ /**
17
+ * Fetch patient's allergies with optional pagination.
18
+ * @param {Object} params - The parameters for filtering and pagination.
19
+ * @param {number} params.PatNum - Required. Filter by patient.
20
+ * @param {number} [params.Offset] - pagination.
21
+ * @returns {Promise<Allergy>} - A list of a patient's allergies.
22
+ */
23
+ public async getAllergies({
24
+ PatNum,
25
+ Offset,
26
+ }: GetAllergiesParams): Promise<Allergy[]> {
27
+ if (!PatNum || typeof PatNum !== "number") {
28
+ throw new Error("PatNum is required to fetch allergies.");
29
+ }
30
+
31
+ return this.httpClient.get<Allergy[]>("/allergies", {
32
+ params: {
33
+ PatNum,
34
+ Offset,
35
+ },
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Add an allergy to a patient.
41
+ * @param {Object} data - The details of allergy to add.
42
+ * @param {number} data.PatNum - Required: FK to patient.
43
+ * @param {number} [data.AllergyDefNum] - Rarely used. Just use defDescription instead, which handles insertion of AllergyDef automatically.
44
+ * @param {string} [data.defDescription] - Required unless you choose to use AllergyDefNum.
45
+ * @param {string} [data.Reaction] - Optional. String describing the adverse reaction.
46
+ * @param {string} [data.DateAdverseReaction] - Optional. String in "yyyy-MM-dd" format. Default "0001-01-01".
47
+ * @param {'true' | 'false'} [data.StatusIsActive] - Optional. Either "true" or "false". Default "true".
48
+ * @returns {Promise<Allergy>} - The attached allergy.
49
+ * @throws {Error} - If required fields are missing or the API returns an error.
50
+ */
51
+ public async addAllergy({
52
+ PatNum,
53
+ AllergyDefNum,
54
+ defDescription,
55
+ Reaction,
56
+ DateAdverseReaction,
57
+ StatusIsActive,
58
+ } : AddAllergyParams): Promise<Allergy> {
59
+ if (!PatNum || (!AllergyDefNum && !defDescription)) {
60
+ throw new Error("Invalid data: PatNum and either AllergyDefNum or defDescription are required.");
61
+ }
62
+
63
+ return this.httpClient.post<Allergy>("/allergies", {
64
+ PatNum,
65
+ AllergyDefNum,
66
+ defDescription,
67
+ Reaction,
68
+ DateAdverseReaction,
69
+ StatusIsActive,
70
+ });
71
+ }
72
+
73
+ /**
74
+ * update an allergy attached to a patient.
75
+ * @param {Object} data - The details of allergy to update.
76
+ * @param {number} data.AllergyNum - Required: PK
77
+ * @param {string} [data.Reaction] - Optional. String describing the adverse reaction.
78
+ * @param {string} [data.DateAdverseReaction] - Optional. String in "yyyy-MM-dd" format.
79
+ * @param {'true' | 'false'} [data.StatusIsActive] - Optional. Either "true" or "false".
80
+ * @returns {Promise<Allergy>} - The updated allergy.
81
+ * @throws {Error} - If required fields are missing or the API returns an error.
82
+ */
83
+ public async updateAllergy({
84
+ AllergyNum,
85
+ Reaction,
86
+ DateAdverseReaction,
87
+ StatusIsActive,
88
+ }: UpdateAllergyParams): Promise<Allergy> {
89
+ if (!AllergyNum || typeof AllergyNum !== "number") {
90
+ throw new Error("Invalid data: AllergyNum is required.");
91
+ }
92
+
93
+ return this.httpClient.put<Allergy>(`/allergies/${AllergyNum}`, {
94
+ AllergyNum,
95
+ Reaction,
96
+ DateAdverseReaction,
97
+ StatusIsActive,
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Deletes an allergy for a patient.
103
+ * @param {number} AllergyNum - Required: The unique identifier of the patient allergy to delete.
104
+ * @returns {Promise<void>} - Resolves when the Allergy is deleted.
105
+ * @throws {Error} - If `AllergyNum` is not valid or the API returns an error.
106
+ */
107
+ public async deleteAllergy(AllergyNum: number): Promise<void> {
108
+ if (!AllergyNum || typeof AllergyNum !== "number") {
109
+ throw new Error("Invalid parameter: AllergyNum must be a valid number.");
110
+ }
111
+
112
+ return this.httpClient.delete<void>(`/allergies/${AllergyNum}`);
113
+ }
114
+ }
@@ -0,0 +1,130 @@
1
+ import HttpClient from "../utils/httpClient";
2
+ import {
3
+ Disease,
4
+ GetDiseasesParams,
5
+ AddDiseaseParams,
6
+ UpdateDiseaseParams,
7
+ } from "../types/diseaseTypes";
8
+
9
+ export default class Diseases {
10
+ private httpClient: HttpClient;
11
+
12
+ constructor(httpClient: HttpClient) {
13
+ this.httpClient = httpClient;
14
+ }
15
+
16
+ /**
17
+ * Fetch a a single disease (Problem) assigned to a patient.
18
+ * @param {number} DiseaseNum - The ID of the Disease.
19
+ * @returns {Promise<Disease>} - The Disease data.
20
+ * @throws {Error} - If `DiseaseNum` is not valid or the API returns an error.
21
+ */
22
+ public async getDisease(DiseaseNum: number): Promise<Disease> {
23
+ if (!DiseaseNum || typeof DiseaseNum !== "number") {
24
+ throw new Error("Invalid parameter: DiseaseNum must be a valid number.");
25
+ }
26
+
27
+ return await this.httpClient.get<Disease>(`/diseases/${DiseaseNum}`);
28
+ }
29
+
30
+ /**
31
+ * Fetch patient's diseases with optional filtering and pagination.
32
+ * @param {Object} params - The parameters for filtering and pagination.
33
+ * @param {number} [params.PatNum] - Filter by patient.
34
+ * @param {number} [params.Offset] - pagination.
35
+ * @returns {Promise<Disease>} - A list of patient diseases.
36
+ */
37
+ public async getDiseases({
38
+ PatNum,
39
+ Offset,
40
+ }: GetDiseasesParams = {}): Promise<Disease> {
41
+ const params = {
42
+ PatNum,
43
+ Offset,
44
+ };
45
+
46
+ return this.httpClient.get<Disease>("/diseases", params);
47
+ }
48
+
49
+ /**
50
+ * Add a diseaseDef (Problem) to a patient.
51
+ * @param {Object} data - The details of disease to add.
52
+ * @param {number} data.PatNum - Required: FK to patient.
53
+ * @param {number} [data.DiseaseDefNum] - Rarely used. Just use diseaseDefName instead, which handles insertion of DiseaseDef automatically.
54
+ * @param {string} [data.diseaseDefName] - Required unless you choose to use DiseaseDefNum.
55
+ * @param {string} [data.DateStart] - Optional. String in "yyyy-MM-dd" format. Default "0001-01-01".
56
+ * @param {string} [data.DateStop] - Optional. String in "yyyy-MM-dd" format. Default "0001-01-01".
57
+ * @param {"Active" | "Resolved" | "Inactive"} [data.ProbStatus] - Optional. Either "Active", "Resolved" or "Inactive". Default "Active".
58
+ * @param {string} [data.PatNote] - Optional.
59
+ * @returns {Promise<Disease>} - The attached disease.
60
+ * @throws {Error} - If required fields are missing or the API returns an error.
61
+ */
62
+ public async addDisease({
63
+ PatNum,
64
+ DiseaseDefNum,
65
+ diseaseDefName,
66
+ DateStart,
67
+ DateStop,
68
+ ProbStatus,
69
+ PatNote,
70
+ } : AddDiseaseParams): Promise<Disease> {
71
+ if (!PatNum || (!DiseaseDefNum && !diseaseDefName)) {
72
+ throw new Error("Invalid data: PatNum and either DiseaseDefNum or diseaseDefName are required.");
73
+ }
74
+
75
+ return this.httpClient.post<Disease>("/diseases", {
76
+ PatNum,
77
+ DiseaseDefNum,
78
+ diseaseDefName,
79
+ DateStart,
80
+ DateStop,
81
+ ProbStatus,
82
+ PatNote,
83
+ });
84
+ }
85
+
86
+ /**
87
+ * update a diseaseDef (Problem) attached to a patient.
88
+ * @param {Object} data - The details of disease to update.
89
+ * @param {number} data.DiseaseNum - Required.
90
+ * @param {string} [data.DateStart] - Optional. String in "yyyy-MM-dd" format.
91
+ * @param {string} [data.DateStop] - Optional. String in "yyyy-MM-dd" format.
92
+ * @param {"Active" | "Resolved" | "Inactive"} [data.ProbStatus] - Optional. Either "Active", "Resolved" or "Inactive".
93
+ * @param {string} [data.PatNote] - Optional. Will overwrite existing note.
94
+ * @returns {Promise<Disease>} - The updated disease.
95
+ * @throws {Error} - If required fields are missing or the API returns an error.
96
+ */
97
+ public async updateDisease({
98
+ DiseaseNum,
99
+ DateStart,
100
+ DateStop,
101
+ ProbStatus,
102
+ PatNote,
103
+ }: UpdateDiseaseParams): Promise<Disease> {
104
+ if (!DiseaseNum || typeof DiseaseNum !== "number") {
105
+ throw new Error("Invalid data: DiseaseNum is required.");
106
+ }
107
+
108
+ return this.httpClient.put<Disease>(`/diseases/${DiseaseNum}`, {
109
+ DiseaseNum,
110
+ DateStart,
111
+ DateStop,
112
+ ProbStatus,
113
+ PatNote,
114
+ });
115
+ }
116
+
117
+ /**
118
+ * Deletes a disease (Problem) for a patient.
119
+ * @param {number} DiseaseNum - Required: The unique identifier of the patient disease to delete.
120
+ * @returns {Promise<void>} - Resolves when the Disease is deleted.
121
+ * @throws {Error} - If `DiseaseNum` is not valid or the API returns an error.
122
+ */
123
+ public async deleteDiscountPlanSub(DiseaseNum: number): Promise<void> {
124
+ if (!DiseaseNum || typeof DiseaseNum !== "number") {
125
+ throw new Error("Invalid parameter: DiseaseNum must be a valid number.");
126
+ }
127
+
128
+ return this.httpClient.delete<void>(`/diseases/${DiseaseNum}`);
129
+ }
130
+ }
package/src/api/index.ts CHANGED
@@ -15,4 +15,7 @@ export { default as Definitions } from "./definitions";
15
15
  export { default as DiscountPlanSubs } from "./discountPlanSubs";
16
16
  export { default as DiscountPlans } from "./discountPlans";
17
17
  export { default as Fees } from "./fees";
18
+ export { default as Diseases } from "./diseases";
19
+ export { default as Allergies } from "./allergies";
20
+ export { default as MedicationPats } from "./medicationPats";
18
21
  // Add other APIs as needed
@@ -0,0 +1,119 @@
1
+ import HttpClient from "../utils/httpClient";
2
+ import {
3
+ MedicationPat,
4
+ GetMedicationPatsParams,
5
+ AddMedicationPatParams,
6
+ UpdateMedicationPatParams,
7
+ } from "../types/medicationPatTypes";
8
+
9
+ export default class MedicationPats {
10
+ private httpClient: HttpClient;
11
+
12
+ constructor(httpClient: HttpClient) {
13
+ this.httpClient = httpClient;
14
+ }
15
+
16
+ /**
17
+ * Fetch patient's medications with optional pagination.
18
+ * @param {Object} params - The parameters for filtering and pagination.
19
+ * @param {number} params.PatNum - Required. Filter by patient.
20
+ * @param {number} [params.Offset] - pagination.
21
+ * @returns {Promise<MedicationPat>} - A list of a patient's medications.
22
+ */
23
+ public async getMedicationPats({
24
+ PatNum,
25
+ Offset,
26
+ }: GetMedicationPatsParams): Promise<MedicationPat[]> {
27
+ if (!PatNum || typeof PatNum !== "number") {
28
+ throw new Error("PatNum is required to fetch medicationpats.");
29
+ }
30
+
31
+ return this.httpClient.get<MedicationPat[]>("/medicationpats", {
32
+ params: {
33
+ PatNum,
34
+ Offset,
35
+ },
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Add a medication to a patient.
41
+ * @param {Object} data - The details of MedicationPat to add.
42
+ * @param {number} data.PatNum - Required: FK to patient.
43
+ * @param {string} [data.medName] - Required unless MedicationNum is used. Tries to match to an existing medication. If a new medication must be created, it will be assumed to be generic rather than brand. For more control, use medication POST.
44
+ * @param {number} [data.MedicationNum] - Rarely used. Just use medName instead, which handles insertion of a Medication automatically. If MedicationNum is used, then medName is not required.
45
+ * @param {string} [data.PatNote] - Optional. String for notes specific to this patient's medication.
46
+ * @param {string} [data.DateStart] - Optional. String in "yyyy-MM-dd" format. Default "0001-01-01".
47
+ * @param {string} [data.DateStop] - Optional. String in "yyyy-MM-dd" format. Default "0001-01-01".
48
+ * @param {number} [data.ProvNum] - Optional. Default is 0.
49
+ * @returns {Promise<MedicationPat>} - The attached medicationPat.
50
+ * @throws {Error} - If required fields are missing or the API returns an error.
51
+ */
52
+ public async addMedicationPat({
53
+ PatNum,
54
+ medName,
55
+ MedicationNum,
56
+ PatNote,
57
+ DateStart,
58
+ DateStop,
59
+ ProvNum,
60
+ } : AddMedicationPatParams): Promise<MedicationPat> {
61
+ if (!PatNum || (!medName && !MedicationNum)) {
62
+ throw new Error("Invalid data: PatNum and either medName or MedicationNum are required.");
63
+ }
64
+
65
+ return this.httpClient.post<MedicationPat>("/medicationpats", {
66
+ PatNum,
67
+ medName,
68
+ MedicationNum,
69
+ PatNote,
70
+ DateStart,
71
+ DateStop,
72
+ ProvNum,
73
+ });
74
+ }
75
+
76
+ /**
77
+ * update an medication attached to a patient.
78
+ * @param {number} data.MedicationPatNum - Required.
79
+ * @param {string} [data.PatNote] - Optional. String for notes specific to this patient's medication.
80
+ * @param {string} [data.DateStart] - Optional. String in "yyyy-MM-dd" format.
81
+ * @param {string} [data.DateStop] - Optional. String in "yyyy-MM-dd" format.
82
+ * @param {number} [data.ProvNum] - Optional.
83
+ * @returns {Promise<MedicationPat>} - The attached medicationPat.
84
+ * @throws {Error} - If required fields are missing or the API returns an error.
85
+ */
86
+ public async updateMedicationPat({
87
+ MedicationPatNum,
88
+ PatNote,
89
+ DateStart,
90
+ DateStop,
91
+ ProvNum,
92
+ }: UpdateMedicationPatParams): Promise<MedicationPat> {
93
+ if (!MedicationPatNum || typeof MedicationPatNum !== "number") {
94
+ throw new Error("Invalid data: MedicationPatNum is required.");
95
+ }
96
+
97
+ return this.httpClient.put<MedicationPat>(`/medicationpats/${MedicationPatNum}`, {
98
+ MedicationPatNum,
99
+ PatNote,
100
+ DateStart,
101
+ DateStop,
102
+ ProvNum,
103
+ });
104
+ }
105
+
106
+ /**
107
+ * Deletes an MedicationPat for a patient.
108
+ * @param {number} MedicationPatNum - Required: The unique identifier of the patient MedicationPat to delete.
109
+ * @returns {Promise<void>} - Resolves when the MedicationPat is deleted.
110
+ * @throws {Error} - If `MedicationPatNum` is not valid or the API returns an error.
111
+ */
112
+ public async deleteMedicationPat(MedicationPatNum: number): Promise<void> {
113
+ if (!MedicationPatNum || typeof MedicationPatNum !== "number") {
114
+ throw new Error("Invalid parameter: MedicationPatNum must be a valid number.");
115
+ }
116
+
117
+ return this.httpClient.delete<void>(`/medicationpats/${MedicationPatNum}`);
118
+ }
119
+ }
package/src/openDental.ts CHANGED
@@ -28,6 +28,9 @@ import ClaimProcs from "./api/claimProcs";
28
28
  import Adjustments from "./api/adjustments";
29
29
  import ProcedureCodes from "./api/procedureCodes";
30
30
  import Fees from "./api/fees";
31
+ import Diseases from "./api/diseases";
32
+ import Allergies from "./api/allergies";
33
+ import MedicationPats from "./api/medicationPats";
31
34
 
32
35
  class OpenDental {
33
36
  private static httpClient: HttpClient;
@@ -140,42 +143,42 @@ class OpenDental {
140
143
  /**
141
144
  * Create a new instance of the Schedules API.
142
145
  */
143
- public static Schedules() {
144
- if (!this.httpClient) {
145
- throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
146
- }
147
- return new Schedules(this.httpClient);
146
+ public static Schedules() {
147
+ if (!this.httpClient) {
148
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
148
149
  }
150
+ return new Schedules(this.httpClient);
151
+ }
149
152
 
150
153
  /**
151
154
  * Create a new instance of the Providers API.
152
155
  */
153
- public static Providers() {
154
- if (!this.httpClient) {
155
- throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
156
- }
157
- return new Providers(this.httpClient);
156
+ public static Providers() {
157
+ if (!this.httpClient) {
158
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
158
159
  }
160
+ return new Providers(this.httpClient);
161
+ }
159
162
 
160
163
  /**
161
164
  * Create a new instance of the Operatories API.
162
165
  */
163
- public static Operatories() {
164
- if (!this.httpClient) {
165
- throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
166
- }
167
- return new Operatories(this.httpClient);
166
+ public static Operatories() {
167
+ if (!this.httpClient) {
168
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
168
169
  }
170
+ return new Operatories(this.httpClient);
171
+ }
169
172
 
170
173
  /**
171
174
  * Create a new instance of the Payments API.
172
175
  */
173
- public static Payments() {
174
- if (!this.httpClient) {
175
- throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
176
- }
177
- return new Payments(this.httpClient);
176
+ public static Payments() {
177
+ if (!this.httpClient) {
178
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
178
179
  }
180
+ return new Payments(this.httpClient);
181
+ }
179
182
 
180
183
  /**
181
184
  * Create a new instance of the Definitions API.
@@ -337,6 +340,36 @@ class OpenDental {
337
340
  return new Fees(this.httpClient);
338
341
  }
339
342
 
343
+ /**
344
+ * Create a new instance of the Diseases API.
345
+ */
346
+ public static Diseases() {
347
+ if (!this.httpClient) {
348
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
349
+ }
350
+ return new Diseases(this.httpClient);
351
+ }
352
+
353
+ /**
354
+ * Create a new instance of the Allergies API.
355
+ */
356
+ public static Allergies() {
357
+ if (!this.httpClient) {
358
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
359
+ }
360
+ return new Allergies(this.httpClient);
361
+ }
362
+
363
+ /**
364
+ * Create a new instance of the MedicationPats API.
365
+ */
366
+ public static MedicationPats() {
367
+ if (!this.httpClient) {
368
+ throw new Error("OpenDental not initialized. Call OpenDental.initialize() first.");
369
+ }
370
+ return new MedicationPats(this.httpClient);
371
+ }
372
+
340
373
  }
341
374
 
342
375
  export { OpenDental };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Represents an Allergy that is assigned to a patient in the Open Dental system.
3
+ * @see https://www.opendental.com/site/apiallergies.html
4
+ */
5
+ export interface Allergy {
6
+ AllergyNum?: number; //PK
7
+ AllergyDefNum?: number; // FK to AllergyDef
8
+ PatNum?: number; // FK to patient
9
+ defDescription?: string; //
10
+ defSnomedType?: string; //
11
+ Reaction?: string; //
12
+ StatusIsActive?: 'true' | 'false'; // Either "true" or "false". Default "true".
13
+ DateAdverseReaction?: string; // String in "yyyy-MM-dd" format.
14
+ }
15
+
16
+ /**
17
+ * Parameters for GET allergies attached to a patient.
18
+ * @see https://www.opendental.com/site/apiallergies.html
19
+ */
20
+ export interface GetAllergiesParams {
21
+ PatNum: number; // Required. FK to patient.PatNum. Gets all allergies for a specified patient.
22
+ Offset?: number; // Optional. Pagination.
23
+ }
24
+
25
+ /**
26
+ * Parameters for attaching an allergy to a patient.
27
+ * @see https://www.opendental.com/site/apiallergies.html
28
+ */
29
+ export interface AddAllergyParams {
30
+ PatNum: number; // Required. FK to patient
31
+ AllergyDefNum?: number; // Rarely used. Just use defDescription instead, which handles insertion of AllergyDef automatically.
32
+ defDescription?: string; // Required unless you choose to use AllergyDefNum.
33
+ Reaction?: string; // Optional. String describing the adverse reaction.
34
+ StatusIsActive?: 'true' | 'false'; // Either "true" or "false". Default "true".
35
+ DateAdverseReaction?: string; // Optional. String in "yyyy-MM-dd" format. Default "0001-01-01".
36
+ }
37
+
38
+ /**
39
+ * Parameters for updating an allergy attached to a patient.
40
+ * @see https://www.opendental.com/site/apiallergies.html
41
+ */
42
+ export interface UpdateAllergyParams {
43
+ AllergyNum: number; // Required.
44
+ Reaction?: string; // Optional. String describing the adverse reaction.
45
+ StatusIsActive?: 'true' | 'false'; // Either "true" or "false".
46
+ DateAdverseReaction?: string; // Optional. String in "yyyy-MM-dd" format.
47
+ }
48
+