@icanbwell/bwell-sdk-ts 2.0.0-alpha.0-rc.1760653171 → 2.0.0-alpha.0-rc.1760729227

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 (38) 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-data-response-factory.d.ts +26 -0
  4. package/dist/api/base/health-data/health-manager.d.ts +3 -3
  5. package/dist/api/base/health-data/index.d.ts +1 -0
  6. package/dist/api/graphql-api/healthdata/graphql-health-manager.d.ts +4 -3
  7. package/dist/api/graphql-api/healthdata/graphql-health-manager.js +19 -6
  8. package/dist/api/graphql-api/healthdata/health-data-response-factory.d.ts +7 -0
  9. package/dist/api/graphql-api/healthdata/health-data-response-factory.js +58 -0
  10. package/dist/graphql/operations/index.d.ts +2 -2
  11. package/dist/graphql/operations/index.js +3 -0
  12. package/dist/graphql/operations/types.d.ts +3 -0
  13. package/dist/graphql/schema.d.ts +12 -0
  14. package/dist/models/common/bundle.d.ts +38 -14
  15. package/dist/models/common/index.d.ts +1 -1
  16. package/dist/models/health-data/allergy-intolerance-bundle.d.ts +2 -2
  17. package/dist/models/health-data/care-plan-group.d.ts +9 -1
  18. package/dist/models/health-data/care-plan.d.ts +11 -11
  19. package/dist/models/health-data/care-team.d.ts +2 -10
  20. package/dist/models/health-data/condition.d.ts +2 -11
  21. package/dist/models/health-data/diagnostic-report.d.ts +2 -10
  22. package/dist/models/health-data/encounter.d.ts +2 -10
  23. package/dist/models/health-data/immunization.d.ts +2 -11
  24. package/dist/models/health-data/index.d.ts +2 -3
  25. package/dist/models/health-data/lab-bundle.d.ts +1 -1
  26. package/dist/models/health-data/medication-dispense.d.ts +2 -10
  27. package/dist/models/health-data/medication-request.d.ts +2 -10
  28. package/dist/models/health-data/medication-statement.d.ts +2 -10
  29. package/dist/models/health-data/procedure.d.ts +2 -10
  30. package/dist/models/health-data/vital-sign-bundle.d.ts +2 -10
  31. package/dist/models/health-space/appointment-bundle.d.ts +2 -2
  32. package/dist/models/health-space/index.d.ts +0 -1
  33. package/dist/models/user/consent.d.ts +2 -13
  34. package/package.json +1 -1
  35. package/dist/models/health-data/allergy-intolerance-entry.d.ts +0 -11
  36. package/dist/models/health-space/appointment-entry.d.ts +0 -11
  37. package/dist/models/health-space/appointment-entry.js +0 -1
  38. /package/dist/{models/health-data/allergy-intolerance-entry.js → api/base/health-data/health-data-response-factory.js} +0 -0
@@ -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.1760653171";
4
+ export declare const VERSION = "2.0.0-alpha.0-rc.1760729227";
@@ -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.1760653171";
4
+ export const VERSION = "2.0.0-alpha.0-rc.1760729227";
@@ -0,0 +1,26 @@
1
+ import { EntryBundle, GroupedHealthDataResponse, HealthDataResponse, ResourceBundle } from "../../../models/common/bundle.js";
2
+ import { HealthDataRequest } from "./health-data-request.js";
3
+ /**
4
+ * Interface for creating paginated responses for health queries.
5
+ *
6
+ * @category Health Data
7
+ * @title HealthDataResponseFactory
8
+ * @excerpt Interface for creating paginated response bundles from GraphQL responses
9
+ */
10
+ export interface HealthDataResponseFactory {
11
+ /**
12
+ * Creates a paginated SDK response from an raw FHIR bundle response.
13
+ *
14
+ * @param bundle - The raw GraphQL response data containing entries
15
+ * @param request - Optional request containing pagination parameters
16
+ * @returns Paginated bundle with type-safe data
17
+ */
18
+ transformHealthDataResult<T>(bundle: EntryBundle<T>, request?: HealthDataRequest): HealthDataResponse<T>;
19
+ /**
20
+ * Creates a paginated SDK response from a raw grouped health data response.
21
+ *
22
+ * @param bundle - The GraphQL response data containing resources and paging_info
23
+ * @returns Paginated bundle with type-safe data
24
+ */
25
+ transformGroupQueryResult<T>(bundle: ResourceBundle<T>): GroupedHealthDataResponse<T>;
26
+ }
@@ -1,4 +1,4 @@
1
- import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanBundle, CarePlanGroupBundle, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportBundle, DiagnosticReportLabGroupBundle, EncounterBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabBundle, LabGroupBundle, MedicationDispenseBundle, MedicationGroupBundle, MedicationRequestBundle, MedicationStatementBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
1
+ import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanGroupsResponse, CarePlanResponse, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportBundle, DiagnosticReportLabGroupBundle, EncounterBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabBundle, LabGroupBundle, MedicationDispenseBundle, MedicationGroupBundle, MedicationRequestBundle, MedicationStatementBundle, 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, MedicationDispenseRequest, MedicationGroupsRequest, ProcedureGroupsRequest, VitalSignGroupsRequest } from "./health-data-request.js";
@@ -112,7 +112,7 @@ export interface HealthManager {
112
112
  * const carePlans = await sdk.health.getCarePlans();
113
113
  * ```
114
114
  */
115
- getCarePlans(request?: HealthDataRequest): Promise<BWellQueryResult<CarePlanBundle, BaseManagerError>>;
115
+ getCarePlans(request?: HealthDataRequest): Promise<BWellQueryResult<CarePlanResponse, BaseManagerError>>;
116
116
  /**
117
117
  * Retrieves a list of care plan groups resources.
118
118
  *
@@ -125,7 +125,7 @@ export interface HealthManager {
125
125
  * const carePlanGroups = await sdk.health.getCarePlanGroups();
126
126
  * ```
127
127
  */
128
- getCarePlanGroups(request?: CarePlanGroupsRequest): Promise<BWellQueryResult<CarePlanGroupBundle, BaseManagerError>>;
128
+ getCarePlanGroups(request?: CarePlanGroupsRequest): Promise<BWellQueryResult<CarePlanGroupsResponse, BaseManagerError>>;
129
129
  /**
130
130
  * Retrieves a list of encounter resources.
131
131
  * Gets individual encounter records for the authenticated user.
@@ -3,3 +3,4 @@ export { MedicationPricingRequest, MedicationPricingRequestInput, } from "./medi
3
3
  export { MedicationKnowledgeRequest, MedicationKnowledgeRequestInput, } from "./medication-knowledge-request.js";
4
4
  export { LabKnowledgeRequest, LabKnowledgeRequestInput, } from "./lab-knowledge-request.js";
5
5
  export { HealthManager } from "./health-manager.js";
6
+ export { HealthDataResponseFactory } from "./health-data-response-factory.js";
@@ -1,6 +1,7 @@
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, DiagnosticReportBundle, DiagnosticReportLabGroupBundle, EncounterBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabBundle, LabGroupBundle, MedicationDispenseBundle, MedicationGroupBundle, MedicationRequestBundle, MedicationStatementBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
3
+ import { CarePlanResponse } from "../../../models/health-data/care-plan.js";
4
+ import type { AllergyIntoleranceBundle, AllergyIntoleranceGroupBundle, CarePlanGroupsResponse, CareTeamBundle, ConditionBundle, ConditionGroupBundle, DiagnosticReportBundle, DiagnosticReportLabGroupBundle, EncounterBundle, EncounterGroupBundle, HealthSummary, ImmunizationBundle, ImmunizationGroupBundle, LabBundle, LabGroupBundle, MedicationDispenseBundle, MedicationGroupBundle, MedicationRequestBundle, MedicationStatementBundle, ProcedureBundle, ProcedureGroupBundle, VitalSignBundle, VitalSignGroupBundle } from "../../../models/health-data/index.js";
4
5
  import { BWellQueryResult } from "../../../results/index.js";
5
6
  import { BaseManagerError } from "../../base/errors.js";
6
7
  import * as health from "../../base/health-data/index.js";
@@ -16,8 +17,8 @@ export declare class GraphQLHealthManager extends GraphQLManager implements Heal
16
17
  getAllergyIntoleranceGroups(request?: health.AllergyIntoleranceGroupsRequest): Promise<BWellQueryResult<AllergyIntoleranceGroupBundle, ValidationError | BaseManagerError>>;
17
18
  getConditionGroups(request?: health.ConditionGroupsRequest): Promise<BWellQueryResult<ConditionGroupBundle, ValidationError | BaseManagerError>>;
18
19
  getLabGroups(request?: health.LabGroupsRequest): Promise<BWellQueryResult<LabGroupBundle, ValidationError | BaseManagerError>>;
19
- getCarePlans(request?: health.HealthDataRequest): Promise<BWellQueryResult<CarePlanBundle, BaseManagerError>>;
20
- getCarePlanGroups(request?: health.CarePlanGroupsRequest): Promise<BWellQueryResult<CarePlanGroupBundle, ValidationError | BaseManagerError>>;
20
+ getCarePlans(request?: health.HealthDataRequest): Promise<BWellQueryResult<CarePlanResponse, BaseManagerError>>;
21
+ getCarePlanGroups(request?: health.CarePlanGroupsRequest): Promise<BWellQueryResult<CarePlanGroupsResponse, ValidationError | BaseManagerError>>;
21
22
  getEncounters(request?: health.HealthDataRequest): Promise<BWellQueryResult<EncounterBundle, BaseManagerError>>;
22
23
  getEncounterGroups(request?: health.EncounterGroupsRequest): Promise<BWellQueryResult<EncounterGroupBundle, ValidationError | BaseManagerError>>;
23
24
  getImmunizations(request?: health.HealthDataRequest): Promise<BWellQueryResult<ImmunizationBundle, BaseManagerError>>;
@@ -18,19 +18,22 @@ 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, _GraphQLHealthManager_getEncountersRequestFactory, _GraphQLHealthManager_getMedicationDispenseRequestFactory;
21
+ var _GraphQLHealthManager_sdk, _GraphQLHealthManager_logger, _GraphQLHealthManager_healthDataRequestFactory, _GraphQLHealthManager_healthDataResponseFactory, _GraphQLHealthManager_getEncountersRequestFactory, _GraphQLHealthManager_getMedicationDispenseRequestFactory;
22
22
  import { ConsoleLoggerProvider, } from "../../../logger/index.js";
23
23
  import { BWellQueryResult } from "../../../results/index.js";
24
+ import { isNullOrUndefined } from "../../../utils/type-utils.js";
24
25
  import { GraphQLManager } from "../graphql-manager/index.js";
25
26
  import { GetEncountersRequestFactory } from "./get-encounters-request-factory.js";
26
27
  import { GetMedicationDispensesRequestFactory } from "./get-medication-dispenses-request-factory.js";
27
28
  import { HealthDataRequestFactory, } from "./health-data-request-factory.js";
29
+ import { GraphQLHealthDataResponseFactory } from "./health-data-response-factory.js";
28
30
  export class GraphQLHealthManager extends GraphQLManager {
29
31
  constructor(sdk, loggerProvider = new ConsoleLoggerProvider()) {
30
32
  super();
31
33
  _GraphQLHealthManager_sdk.set(this, void 0);
32
34
  _GraphQLHealthManager_logger.set(this, void 0);
33
35
  _GraphQLHealthManager_healthDataRequestFactory.set(this, new HealthDataRequestFactory());
36
+ _GraphQLHealthManager_healthDataResponseFactory.set(this, new GraphQLHealthDataResponseFactory());
34
37
  _GraphQLHealthManager_getEncountersRequestFactory.set(this, new GetEncountersRequestFactory());
35
38
  _GraphQLHealthManager_getMedicationDispenseRequestFactory.set(this, new GetMedicationDispensesRequestFactory());
36
39
  __classPrivateFieldSet(this, _GraphQLHealthManager_sdk, sdk, "f");
@@ -147,7 +150,7 @@ export class GraphQLHealthManager extends GraphQLManager {
147
150
  }
148
151
  getCarePlans(request) {
149
152
  return __awaiter(this, void 0, void 0, function* () {
150
- var _a;
153
+ var _a, _b;
151
154
  const validationResult = this.validateRequest(request);
152
155
  if (validationResult.failure()) {
153
156
  return validationResult.toQueryResult();
@@ -162,12 +165,18 @@ export class GraphQLHealthManager extends GraphQLManager {
162
165
  if (result.hasError()) {
163
166
  __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("getCarePlans error", result.error);
164
167
  }
165
- return new BWellQueryResult((_a = result.data) === null || _a === void 0 ? void 0 : _a.carePlans, result.error);
168
+ if (isNullOrUndefined((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.carePlans)) {
169
+ return new BWellQueryResult({ id: null, entry: null, total: null, pagingInfo: null }, result.error);
170
+ }
171
+ // Compile time check verifies CarePlanBundle is a superset of the
172
+ // generated GraphQL response type.
173
+ const bundle = (_b = result.data) === null || _b === void 0 ? void 0 : _b.carePlans;
174
+ return new BWellQueryResult(__classPrivateFieldGet(this, _GraphQLHealthManager_healthDataResponseFactory, "f").transformHealthDataResult(bundle, request), result.error);
166
175
  });
167
176
  }
168
177
  getCarePlanGroups(request) {
169
178
  return __awaiter(this, void 0, void 0, function* () {
170
- var _a, _b;
179
+ var _a, _b, _c;
171
180
  const validationResult = this.validateRequest(request);
172
181
  if (validationResult.failure()) {
173
182
  return validationResult.toQueryResult();
@@ -180,7 +189,11 @@ export class GraphQLHealthManager extends GraphQLManager {
180
189
  if (result.hasError()) {
181
190
  __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("getCarePlanGroups errors", result.error);
182
191
  }
183
- return new BWellQueryResult((_b = result.data) === null || _b === void 0 ? void 0 : _b.getCarePlanGroups, result.error);
192
+ if (isNullOrUndefined((_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.getCarePlanGroups)) {
193
+ return new BWellQueryResult({ resources: [], pagingInfo: null }, result.error);
194
+ }
195
+ const bundle = (_c = result.data) === null || _c === void 0 ? void 0 : _c.getCarePlanGroups;
196
+ return new BWellQueryResult(__classPrivateFieldGet(this, _GraphQLHealthManager_healthDataResponseFactory, "f").transformGroupQueryResult(bundle), result.error);
184
197
  });
185
198
  }
186
199
  getEncounters(request) {
@@ -492,4 +505,4 @@ export class GraphQLHealthManager extends GraphQLManager {
492
505
  });
493
506
  }
494
507
  }
495
- _GraphQLHealthManager_sdk = new WeakMap(), _GraphQLHealthManager_logger = new WeakMap(), _GraphQLHealthManager_healthDataRequestFactory = new WeakMap(), _GraphQLHealthManager_getEncountersRequestFactory = new WeakMap(), _GraphQLHealthManager_getMedicationDispenseRequestFactory = new WeakMap();
508
+ _GraphQLHealthManager_sdk = new WeakMap(), _GraphQLHealthManager_logger = new WeakMap(), _GraphQLHealthManager_healthDataRequestFactory = new WeakMap(), _GraphQLHealthManager_healthDataResponseFactory = new WeakMap(), _GraphQLHealthManager_getEncountersRequestFactory = new WeakMap(), _GraphQLHealthManager_getMedicationDispenseRequestFactory = new WeakMap();
@@ -0,0 +1,7 @@
1
+ import { EntryBundle, GroupedHealthDataResponse, HealthDataResponse, ResourceBundle } from "../../../models/common/bundle.js";
2
+ import { HealthDataRequest, HealthDataResponseFactory } from "../../base/index.js";
3
+ export declare class GraphQLHealthDataResponseFactory implements HealthDataResponseFactory {
4
+ #private;
5
+ transformHealthDataResult<T>(bundle: EntryBundle<T>, request?: HealthDataRequest): HealthDataResponse<T>;
6
+ transformGroupQueryResult<T>(bundle: ResourceBundle<T>): GroupedHealthDataResponse<T>;
7
+ }
@@ -0,0 +1,58 @@
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 _GraphQLHealthDataResponseFactory_instances, _GraphQLHealthDataResponseFactory_getPagingInfo;
7
+ import { isNotNullOrUndefined, isNullOrUndefined, } from "../../../utils/type-utils.js";
8
+ export class GraphQLHealthDataResponseFactory {
9
+ constructor() {
10
+ _GraphQLHealthDataResponseFactory_instances.add(this);
11
+ }
12
+ transformHealthDataResult(bundle, request) {
13
+ return {
14
+ id: bundle.id,
15
+ entry: bundle.entry,
16
+ total: bundle.total,
17
+ pagingInfo: __classPrivateFieldGet(this, _GraphQLHealthDataResponseFactory_instances, "m", _GraphQLHealthDataResponseFactory_getPagingInfo).call(this, bundle, request),
18
+ };
19
+ }
20
+ transformGroupQueryResult(bundle) {
21
+ var _a, _b, _c, _d;
22
+ const { paging_info } = bundle;
23
+ return {
24
+ resources: bundle.resources,
25
+ pagingInfo: {
26
+ pageNumber: (_a = paging_info === null || paging_info === void 0 ? void 0 : paging_info.page_number) !== null && _a !== void 0 ? _a : null,
27
+ pageSize: (_b = paging_info === null || paging_info === void 0 ? void 0 : paging_info.page_size) !== null && _b !== void 0 ? _b : null,
28
+ totalItems: (_c = paging_info === null || paging_info === void 0 ? void 0 : paging_info.total_items) !== null && _c !== void 0 ? _c : null,
29
+ totalPages: (_d = paging_info === null || paging_info === void 0 ? void 0 : paging_info.total_pages) !== null && _d !== void 0 ? _d : null,
30
+ },
31
+ };
32
+ }
33
+ }
34
+ _GraphQLHealthDataResponseFactory_instances = new WeakSet(), _GraphQLHealthDataResponseFactory_getPagingInfo = function _GraphQLHealthDataResponseFactory_getPagingInfo(bundle, request) {
35
+ var _a;
36
+ const req = request === null || request === void 0 ? void 0 : request.data();
37
+ const total = bundle.total;
38
+ // Without a request, we can't det. what page size or item count
39
+ // was sent/retrieved by the server. Instead, return only what we
40
+ // know instead of using potentially inaccurate defaults.
41
+ if (isNullOrUndefined(req)) {
42
+ return {
43
+ pageNumber: 0,
44
+ pageSize: null,
45
+ totalItems: total !== null && total !== void 0 ? total : null,
46
+ totalPages: null,
47
+ };
48
+ }
49
+ // Else, use request data to calculate paging info:
50
+ return {
51
+ pageNumber: req.page,
52
+ pageSize: (_a = req.pageSize) !== null && _a !== void 0 ? _a : null,
53
+ totalItems: total !== null && total !== void 0 ? total : null,
54
+ totalPages: isNotNullOrUndefined(total) && req.pageSize > 0
55
+ ? Math.ceil(total / req.pageSize)
56
+ : null,
57
+ };
58
+ };