@icanbwell/bwell-sdk-ts 2.0.0-alpha.0-rc.1758728092 → 2.0.0-alpha.0-rc.1758914055

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.
Files changed (31) hide show
  1. package/dist/__version__.d.ts +1 -1
  2. package/dist/__version__.js +1 -1
  3. package/dist/api/base/health-data/health-manager.d.ts +24 -1
  4. package/dist/api/graphql-api/healthdata/get-encounters-request-factory.d.ts +7 -0
  5. package/dist/api/graphql-api/healthdata/get-encounters-request-factory.js +76 -0
  6. package/dist/api/graphql-api/healthdata/graphql-health-manager.d.ts +2 -1
  7. package/dist/api/graphql-api/healthdata/graphql-health-manager.js +24 -2
  8. package/dist/api/graphql-api/healthdata/health-data-request-factory.d.ts +7 -1
  9. package/dist/api/graphql-api/healthdata/health-data-request-factory.js +1 -1
  10. package/dist/graphql/operations/index.d.ts +32 -21
  11. package/dist/graphql/operations/index.js +385 -185
  12. package/dist/graphql/operations/types.d.ts +9623 -3851
  13. package/dist/graphql/schema.d.ts +28 -0
  14. package/dist/models/common/location.d.ts +2 -0
  15. package/dist/models/common/organization.d.ts +7 -1
  16. package/dist/models/common/practitioner-role.d.ts +1 -1
  17. package/dist/models/common/practitioner.d.ts +2 -0
  18. package/dist/models/health-data/condition.d.ts +3 -0
  19. package/dist/models/health-data/encounter.d.ts +79 -0
  20. package/dist/models/health-data/encounter.js +1 -0
  21. package/dist/models/health-data/immunization.d.ts +3 -1
  22. package/dist/models/health-data/index.d.ts +1 -0
  23. package/dist/models/health-data/observation.d.ts +3 -1
  24. package/dist/models/health-data/procedure.d.ts +3 -0
  25. package/dist/utils/index.d.ts +1 -0
  26. package/dist/utils/index.js +1 -0
  27. package/dist/utils/parsing-utils.d.ts +11 -1
  28. package/dist/utils/parsing-utils.js +33 -1
  29. package/dist/utils/search-token-utils.d.ts +8 -0
  30. package/dist/utils/search-token-utils.js +23 -0
  31. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * This file is automatically generated. Please do not edit this file directly.
3
3
  */
4
- export declare const VERSION = "2.0.0-alpha.0-rc.1758728092";
4
+ export declare const VERSION = "2.0.0-alpha.0-rc.1758914055";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * This file is automatically generated. Please do not edit this file directly.
3
3
  */
4
- export const VERSION = "2.0.0-alpha.0-rc.1758728092";
4
+ export const VERSION = "2.0.0-alpha.0-rc.1758914055";
@@ -1,4 +1,4 @@
1
- import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanBundle, CarePlanGroupBundle, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportLabGroupBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabGroupBundle, MedicationGroupBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
1
+ import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanBundle, CarePlanGroupBundle, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportLabGroupBundle, EncounterBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabGroupBundle, MedicationGroupBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
2
2
  import type { BWellQueryResult } from "../../../results/index.js";
3
3
  import type { BaseManagerError } from "../errors.js";
4
4
  import type { AllergyIntoleranceGroupsRequest, CarePlanGroupsRequest, ConditionGroupsRequest, DiagnosticReportLabGroupsRequest, EncounterGroupsRequest, HealthDataRequest, ImmunizationGroupsRequest, LabGroupsRequest, MedicationGroupsRequest, ProcedureGroupsRequest, VitalSignGroupsRequest } from "./health-data-request.js";
@@ -126,6 +126,29 @@ export interface HealthManager {
126
126
  * ```
127
127
  */
128
128
  getCarePlanGroups(request?: CarePlanGroupsRequest): Promise<BWellQueryResult<CarePlanGroupBundle, BaseManagerError>>;
129
+ /**
130
+ * Retrieves a list of encounter resources.
131
+ * Gets individual encounter records for the authenticated user.
132
+ *
133
+ * @param {HealthDataRequest} request - An optional request class for specifying the search criteria.
134
+ *
135
+ * @returns {Promise<BWellQueryResult<EncounterBundle>>} A promise resolving to an object representing the list of encounters retrieved.
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const encounters = await sdk.health.getEncounters();
140
+ * ```
141
+ *
142
+ * * @example
143
+ * ```typescript
144
+ * const encounters = await sdk.health.getEncounters(
145
+ * new HealthDataRequest({
146
+ * page: 0,
147
+ * pageSize: 20,
148
+ * );
149
+ *
150
+ */
151
+ getEncounters(request?: HealthDataRequest): Promise<BWellQueryResult<EncounterBundle, BaseManagerError>>;
129
152
  /**
130
153
  * Retrieves a list of encounter groups resources.
131
154
  *
@@ -0,0 +1,7 @@
1
+ import { GetEncountersQueryVariables } from "../../../graphql/operations/types.js";
2
+ import { RequestFactory } from "../../../requests/index.js";
3
+ import { HealthDataRequest } from "../../base/index.js";
4
+ export declare class GetEncountersRequestFactory implements RequestFactory<HealthDataRequest, GetEncountersQueryVariables> {
5
+ #private;
6
+ create(request: HealthDataRequest): GetEncountersQueryVariables;
7
+ }
@@ -0,0 +1,76 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _GetEncountersRequestFactory_instances, _GetEncountersRequestFactory_compileSearchValues;
7
+ import { BWellTransactionResult } from "../../../results/bwell-transaction-result.js";
8
+ import { base64Decode } from "../../../utils/base64.js";
9
+ import { getSearchTokenValues, parseJSONCodings, } from "../../../utils/index.js";
10
+ import { isNotNullOrUndefined, isNullOrUndefined, } from "../../../utils/type-utils.js";
11
+ import { toSortString } from "./health-data-request-factory.js";
12
+ export class GetEncountersRequestFactory {
13
+ constructor() {
14
+ _GetEncountersRequestFactory_instances.add(this);
15
+ }
16
+ create(request) {
17
+ var _a, _b, _c, _d, _e, _f;
18
+ const input = request.data();
19
+ let params = null;
20
+ if (!isNullOrUndefined(input.groupCode)) {
21
+ // Each groupcode search token value is a base64 encoded array
22
+ // of coding objects containing a class coding and type coding(s).
23
+ // Aggregate these into `class` and `type` FHIR search tokens.
24
+ const groupCodes = getSearchTokenValues(input.groupCode);
25
+ const compileResults = __classPrivateFieldGet(this, _GetEncountersRequestFactory_instances, "m", _GetEncountersRequestFactory_compileSearchValues).call(this, groupCodes);
26
+ params = compileResults.data();
27
+ }
28
+ return {
29
+ id: input.ids ? { values: input.ids } : null,
30
+ page: input.page,
31
+ pageSize: input.pageSize,
32
+ lastUpdated: (_a = input.lastUpdated) !== null && _a !== void 0 ? _a : null,
33
+ sort: (_c = (_b = input.sort) === null || _b === void 0 ? void 0 : _b.map((sort) => toSortString(sort))) !== null && _c !== void 0 ? _c : null,
34
+ status: (_d = input.status) !== null && _d !== void 0 ? _d : null,
35
+ class: (_e = params === null || params === void 0 ? void 0 : params.class) !== null && _e !== void 0 ? _e : null,
36
+ type: (_f = params === null || params === void 0 ? void 0 : params.type) !== null && _f !== void 0 ? _f : null,
37
+ total: "accurate",
38
+ };
39
+ }
40
+ }
41
+ _GetEncountersRequestFactory_instances = new WeakSet(), _GetEncountersRequestFactory_compileSearchValues = function _GetEncountersRequestFactory_compileSearchValues(groupCodes) {
42
+ var _a, _b;
43
+ const classes = [];
44
+ const types = [];
45
+ // Aggregate class and types from across all group code values.
46
+ for (const group of groupCodes) {
47
+ const decodeResult = parseJSONCodings(base64Decode(group));
48
+ if (decodeResult.failure()) {
49
+ return decodeResult.intoFailure();
50
+ }
51
+ const [classCoding, ...typeCodings] = decodeResult.data();
52
+ if (isNotNullOrUndefined(classCoding)) {
53
+ classes.push({
54
+ system: (_a = classCoding.system) !== null && _a !== void 0 ? _a : undefined,
55
+ code: (_b = classCoding.code) !== null && _b !== void 0 ? _b : undefined,
56
+ });
57
+ }
58
+ if (typeCodings.length > 0) {
59
+ types.push(...typeCodings.map((coding) => {
60
+ var _a, _b;
61
+ return ({
62
+ system: (_a = coding.system) !== null && _a !== void 0 ? _a : undefined,
63
+ code: (_b = coding.code) !== null && _b !== void 0 ? _b : undefined,
64
+ });
65
+ }));
66
+ }
67
+ }
68
+ return BWellTransactionResult.success({
69
+ class: {
70
+ values: classes,
71
+ },
72
+ type: {
73
+ values: types,
74
+ },
75
+ });
76
+ };
@@ -1,6 +1,6 @@
1
1
  import { ValidationError } from "../../../errors/index.js";
2
2
  import { LoggerProvider } from "../../../logger/index.js";
3
- import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanBundle, CarePlanGroupBundle, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportLabGroupBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabGroupBundle, MedicationGroupBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
3
+ import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanBundle, CarePlanGroupBundle, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportLabGroupBundle, EncounterBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabGroupBundle, MedicationGroupBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
4
4
  import { BWellQueryResult } from "../../../results/index.js";
5
5
  import { BaseManagerError } from "../../base/errors.js";
6
6
  import * as health from "../../base/health-data/index.js";
@@ -18,6 +18,7 @@ export declare class GraphQLHealthManager extends GraphQLManager implements Heal
18
18
  getLabGroups(request?: health.LabGroupsRequest): Promise<BWellQueryResult<LabGroupBundle, ValidationError | BaseManagerError>>;
19
19
  getCarePlans(request?: health.HealthDataRequest): Promise<BWellQueryResult<CarePlanBundle, BaseManagerError>>;
20
20
  getCarePlanGroups(request?: health.CarePlanGroupsRequest): Promise<BWellQueryResult<CarePlanGroupBundle, ValidationError | BaseManagerError>>;
21
+ getEncounters(request?: health.HealthDataRequest): Promise<BWellQueryResult<EncounterBundle, BaseManagerError>>;
21
22
  getEncounterGroups(request?: health.EncounterGroupsRequest): Promise<BWellQueryResult<EncounterGroupBundle, ValidationError | BaseManagerError>>;
22
23
  getImmunizations(request?: health.HealthDataRequest): Promise<BWellQueryResult<ImmunizationBundle, BaseManagerError>>;
23
24
  getImmunizationGroups(request?: health.ImmunizationGroupsRequest): Promise<BWellQueryResult<ImmunizationGroupBundle, ValidationError | BaseManagerError>>;
@@ -18,10 +18,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
18
18
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
19
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
20
  };
21
- var _GraphQLHealthManager_sdk, _GraphQLHealthManager_logger, _GraphQLHealthManager_healthDataRequestFactory;
21
+ var _GraphQLHealthManager_sdk, _GraphQLHealthManager_logger, _GraphQLHealthManager_healthDataRequestFactory, _GraphQLHealthManager_getEncountersRequestFactory;
22
22
  import { ConsoleLoggerProvider, } from "../../../logger/index.js";
23
23
  import { BWellQueryResult } from "../../../results/index.js";
24
24
  import { GraphQLManager } from "../graphql-manager/index.js";
25
+ import { GetEncountersRequestFactory } from "./get-encounters-request-factory.js";
25
26
  import { HealthDataRequestFactory, } from "./health-data-request-factory.js";
26
27
  export class GraphQLHealthManager extends GraphQLManager {
27
28
  constructor(sdk, loggerProvider = new ConsoleLoggerProvider()) {
@@ -29,6 +30,7 @@ export class GraphQLHealthManager extends GraphQLManager {
29
30
  _GraphQLHealthManager_sdk.set(this, void 0);
30
31
  _GraphQLHealthManager_logger.set(this, void 0);
31
32
  _GraphQLHealthManager_healthDataRequestFactory.set(this, new HealthDataRequestFactory());
33
+ _GraphQLHealthManager_getEncountersRequestFactory.set(this, new GetEncountersRequestFactory());
32
34
  __classPrivateFieldSet(this, _GraphQLHealthManager_sdk, sdk, "f");
33
35
  __classPrivateFieldSet(this, _GraphQLHealthManager_logger, loggerProvider.getLogger("GraphQLHealthManager"), "f");
34
36
  }
@@ -179,6 +181,26 @@ export class GraphQLHealthManager extends GraphQLManager {
179
181
  return new BWellQueryResult((_b = result.data) === null || _b === void 0 ? void 0 : _b.getCarePlanGroups, result.error);
180
182
  });
181
183
  }
184
+ getEncounters(request) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ var _a;
187
+ const validationResult = this.validateRequest(request);
188
+ if (validationResult.failure()) {
189
+ return validationResult.toQueryResult();
190
+ }
191
+ let gqlRequest;
192
+ if (request !== undefined) {
193
+ gqlRequest = __classPrivateFieldGet(this, _GraphQLHealthManager_getEncountersRequestFactory, "f").create(request);
194
+ }
195
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("calling getEncounters...");
196
+ const result = yield this.handleQuery(__classPrivateFieldGet(this, _GraphQLHealthManager_sdk, "f").getEncounters(gqlRequest));
197
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("getEncounters complete");
198
+ if (result.hasError()) {
199
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("getEncounters error", result.error);
200
+ }
201
+ return new BWellQueryResult((_a = result.data) === null || _a === void 0 ? void 0 : _a.encounters, result.error);
202
+ });
203
+ }
182
204
  getEncounterGroups(request) {
183
205
  return __awaiter(this, void 0, void 0, function* () {
184
206
  var _a, _b;
@@ -368,4 +390,4 @@ export class GraphQLHealthManager extends GraphQLManager {
368
390
  });
369
391
  }
370
392
  }
371
- _GraphQLHealthManager_sdk = new WeakMap(), _GraphQLHealthManager_logger = new WeakMap(), _GraphQLHealthManager_healthDataRequestFactory = new WeakMap();
393
+ _GraphQLHealthManager_sdk = new WeakMap(), _GraphQLHealthManager_logger = new WeakMap(), _GraphQLHealthManager_healthDataRequestFactory = new WeakMap(), _GraphQLHealthManager_getEncountersRequestFactory = new WeakMap();
@@ -1,12 +1,18 @@
1
1
  import { GetAllergyIntolerancesQueryVariables } from "../../../graphql/operations/types.js";
2
2
  import { RequestFactory } from "../../../requests/index.js";
3
- import { HealthDataRequest } from "../../base/index.js";
3
+ import { FieldSortOrder, HealthDataRequest } from "../../base/index.js";
4
4
  /**
5
5
  * @note All health data request queries (non group resource queries) should take
6
6
  * the same variables so this aliases GetAllergyIntolerancesQueryVariables as a
7
7
  * generic placeholder type
8
8
  */
9
9
  export type HealthDataRequestVariables = GetAllergyIntolerancesQueryVariables;
10
+ /**
11
+ * Converts a field sort order to a FHIR string representation.
12
+ * @param ordering The field sort order to convert.
13
+ * @returns The string representation of the field sort order.
14
+ */
15
+ export declare function toSortString(ordering: FieldSortOrder<string>): string;
10
16
  export declare class HealthDataRequestFactory implements RequestFactory<HealthDataRequest, HealthDataRequestVariables> {
11
17
  create(request: HealthDataRequest): HealthDataRequestVariables;
12
18
  }
@@ -3,7 +3,7 @@
3
3
  * @param ordering The field sort order to convert.
4
4
  * @returns The string representation of the field sort order.
5
5
  */
6
- function toSortString(ordering) {
6
+ export function toSortString(ordering) {
7
7
  const prefix = ordering.order === "asc" ? "+" : "-";
8
8
  return `${prefix}${ordering.field}`;
9
9
  }