@rinse-dental/open-dental 4.0.2 → 4.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/README.md CHANGED
@@ -298,6 +298,36 @@ await benefits.deleteBenefit(benefitNum);
298
298
 
299
299
  ---
300
300
 
301
+ ## Date Utilities
302
+
303
+ Open Dental returns dates and datetimes **without timezone information** — they reflect the local clock of the Open Dental server. Use `toISO` to convert these to ISO 8601 UTC strings before storing or comparing them in your application.
304
+
305
+ ```ts
306
+ import { toISO } from '@rinse-dental/open-dental';
307
+
308
+ // Datetime string — "yyyy-MM-dd HH:mm:ss"
309
+ toISO("2021-08-05 02:00:00", "America/Los_Angeles");
310
+ // => "2021-08-05T09:00:00.000Z" (PDT, UTC-7)
311
+
312
+ // Date-only string — interpreted as midnight in the given timezone
313
+ toISO("2021-08-05", "America/Los_Angeles");
314
+ // => "2021-08-05T07:00:00.000Z" (PDT, UTC-7)
315
+ ```
316
+
317
+ Pass an [IANA timezone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) matching your Open Dental server's configured timezone. DST transitions are handled automatically. Strings that don't match either format are returned unchanged.
318
+
319
+ **Typical usage after an API call:**
320
+
321
+ ```ts
322
+ const appt = await OpenDental.Appointments().getAppointment(12345);
323
+ const TZ = "America/Los_Angeles";
324
+
325
+ const startISO = toISO(appt.AptDateTime, TZ);
326
+ const endISO = toISO(appt.AptDateTimeEnd, TZ);
327
+ ```
328
+
329
+ ---
330
+
301
331
  ## API Documentation (`Docs/`)
302
332
 
303
333
  This package includes the full Open Dental API reference documentation in the `Docs/` folder, enriched with database schema mappings and field-level notes for every endpoint. These markdown files are optimized for AI-assisted development.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { OpenDental } from "./openDental";
2
2
  export * as Transformers from './transformers';
3
+ export { toISO } from "./utils/dateUtils";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -33,7 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Transformers = exports.OpenDental = void 0;
36
+ exports.toISO = exports.Transformers = exports.OpenDental = void 0;
37
37
  var openDental_1 = require("./openDental");
38
38
  Object.defineProperty(exports, "OpenDental", { enumerable: true, get: function () { return openDental_1.OpenDental; } });
39
39
  exports.Transformers = __importStar(require("./transformers"));
40
+ var dateUtils_1 = require("./utils/dateUtils");
41
+ Object.defineProperty(exports, "toISO", { enumerable: true, get: function () { return dateUtils_1.toISO; } });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Converts an Open Dental date or datetime string to an ISO 8601 UTC string,
3
+ * interpreting the input as being in the given IANA timezone.
4
+ *
5
+ * Open Dental returns dates without timezone information. The server stores
6
+ * times in its local timezone (configured at the practice level). Pass that
7
+ * timezone here so the conversion to UTC is correct, including DST transitions.
8
+ *
9
+ * @param {string} value - A date string in "yyyy-MM-dd" or "yyyy-MM-dd HH:mm:ss" format.
10
+ * @param {string} timezone - IANA timezone name (e.g. "America/Los_Angeles").
11
+ * @returns {string} ISO 8601 UTC string (e.g. "2021-08-05T09:00:00.000Z"),
12
+ * or the original value unchanged if it does not match a recognised format.
13
+ *
14
+ * @example
15
+ * // Datetime (server in PST, offset -8 in winter / -7 in summer)
16
+ * toISO("2021-08-05 02:00:00", "America/Los_Angeles");
17
+ * // => "2021-08-05T09:00:00.000Z" (PDT, UTC-7)
18
+ *
19
+ * @example
20
+ * // Date-only — interpreted as midnight in the given timezone
21
+ * toISO("2021-08-05", "America/Los_Angeles");
22
+ * // => "2021-08-05T07:00:00.000Z" (PDT, UTC-7)
23
+ */
24
+ export declare function toISO(value: string, timezone: string): string;
25
+ //# sourceMappingURL=dateUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/utils/dateUtils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU7D"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.toISO = toISO;
7
+ const moment_timezone_1 = __importDefault(require("moment-timezone"));
8
+ /**
9
+ * Converts an Open Dental date or datetime string to an ISO 8601 UTC string,
10
+ * interpreting the input as being in the given IANA timezone.
11
+ *
12
+ * Open Dental returns dates without timezone information. The server stores
13
+ * times in its local timezone (configured at the practice level). Pass that
14
+ * timezone here so the conversion to UTC is correct, including DST transitions.
15
+ *
16
+ * @param {string} value - A date string in "yyyy-MM-dd" or "yyyy-MM-dd HH:mm:ss" format.
17
+ * @param {string} timezone - IANA timezone name (e.g. "America/Los_Angeles").
18
+ * @returns {string} ISO 8601 UTC string (e.g. "2021-08-05T09:00:00.000Z"),
19
+ * or the original value unchanged if it does not match a recognised format.
20
+ *
21
+ * @example
22
+ * // Datetime (server in PST, offset -8 in winter / -7 in summer)
23
+ * toISO("2021-08-05 02:00:00", "America/Los_Angeles");
24
+ * // => "2021-08-05T09:00:00.000Z" (PDT, UTC-7)
25
+ *
26
+ * @example
27
+ * // Date-only — interpreted as midnight in the given timezone
28
+ * toISO("2021-08-05", "America/Los_Angeles");
29
+ * // => "2021-08-05T07:00:00.000Z" (PDT, UTC-7)
30
+ */
31
+ function toISO(value, timezone) {
32
+ if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value)) {
33
+ return moment_timezone_1.default.tz(value, "YYYY-MM-DD HH:mm:ss", timezone).toISOString();
34
+ }
35
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
36
+ return moment_timezone_1.default.tz(value, "YYYY-MM-DD", timezone).startOf("day").toISOString();
37
+ }
38
+ return value;
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rinse-dental/open-dental",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
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",