@icanbwell/bwell-sdk-ts 1.112.2 → 1.113.0-rc.1790784080

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 (27) 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 +35 -2
  4. package/dist/api/base/health-data/index.d.ts +3 -1
  5. package/dist/api/base/health-data/index.js +1 -0
  6. package/dist/api/base/health-data/upload-document-request.d.ts +36 -0
  7. package/dist/api/base/health-data/upload-document-request.js +37 -0
  8. package/dist/api/base/health-data/upload-document-result.d.ts +67 -0
  9. package/dist/api/base/health-data/upload-document-result.js +1 -0
  10. package/dist/api/base/support/upload-support-attachment-request.d.ts +0 -1
  11. package/dist/api/base/support/upload-support-attachment-request.js +5 -4
  12. package/dist/api/graphql-api/healthdata/graphql-health-manager.d.ts +5 -1
  13. package/dist/api/graphql-api/healthdata/graphql-health-manager.js +44 -4
  14. package/dist/api/graphql-api/healthdata/graphql-upload-document-request-factory.d.ts +6 -0
  15. package/dist/api/graphql-api/healthdata/graphql-upload-document-request-factory.js +37 -0
  16. package/dist/api/graphql-api/healthdata/graphql-upload-document-response-factory.d.ts +24 -0
  17. package/dist/api/graphql-api/healthdata/graphql-upload-document-response-factory.js +71 -0
  18. package/dist/api/graphql-api/user/graphql-user-manager.js +1 -1
  19. package/dist/graphql/operations/index.d.ts +20 -3
  20. package/dist/graphql/operations/index.js +100 -5
  21. package/dist/graphql/operations/types.d.ts +218 -5
  22. package/dist/graphql/schema.d.ts +44 -0
  23. package/dist/utils/data-uri-utils.d.ts +46 -0
  24. package/dist/utils/data-uri-utils.js +74 -0
  25. package/dist/utils/index.d.ts +1 -0
  26. package/dist/utils/index.js +1 -0
  27. 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 = "1.112.2";
4
+ export declare const VERSION = "1.113.0-rc.1790784080";
@@ -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 = "1.112.2";
4
+ export const VERSION = "1.113.0-rc.1790784080";
@@ -1,4 +1,5 @@
1
- import { GetAllergyIntoleranceGroupsQueryResults, GetAllergyIntolerancesQueryResults, GetBinaryQueryResults, GetBodySystemScoreQueryResults, GetCarePlanGroupsQueryResults, GetCarePlansQueryResults, GetCareTeamsQueryResults, GetConditionGroupsQueryResults, GetConditionsQueryResults, GetDeviceMetricsGroupsQueryResults, GetDiagnosticReportLabGroupsQueryResults, GetDiagnosticReportsQueryResults, GetDocumentReferencesQueryResults, GetEncounterQueryResults, GetEncountersGroupQueryResults, GetHealthScoreQueryResults, GetHealthSummaryQueryResults, GetImmunizationGroupsQueryResults, GetImmunizationsQueryResults, GetLabGroupsQueryResults, GetLabKnowledgeQueryResults, GetLabsQueryResults, GetMedicationGroupsQueryResults, GetMedicationKnowledgeQueryResults, GetMedicationPricingQueryResults, GetMedicationStatementsQueryResults, GetObservationsQueryResults, GetProcedureGroupsQueryResults, GetProceduresQueryResults, GetVitalSignGroupsQueryResults, UpdateMedicationStatementMutationResults } from "../../../graphql/operations/types.js";
1
+ import { ValidationError } from "../../../errors/index.js";
2
+ import { GetAllergyIntoleranceGroupsQueryResults, GetAllergyIntolerancesQueryResults, GetBinaryQueryResults, GetBodySystemScoreQueryResults, GetCarePlanGroupsQueryResults, GetCarePlansQueryResults, GetCareTeamsQueryResults, GetConditionGroupsQueryResults, GetConditionsQueryResults, GetDeviceMetricsGroupsQueryResults, GetDiagnosticReportLabGroupsQueryResults, GetDiagnosticReportsQueryResults, GetDocumentReferencesListQueryResults, GetDocumentReferencesQueryResults, GetEncounterQueryResults, GetEncountersGroupQueryResults, GetHealthScoreQueryResults, GetHealthSummaryQueryResults, GetImmunizationGroupsQueryResults, GetImmunizationsQueryResults, GetLabGroupsQueryResults, GetLabKnowledgeQueryResults, GetLabsQueryResults, GetMedicationGroupsQueryResults, GetMedicationKnowledgeQueryResults, GetMedicationPricingQueryResults, GetMedicationStatementsQueryResults, GetObservationsQueryResults, GetProcedureGroupsQueryResults, GetProceduresQueryResults, GetVitalSignGroupsQueryResults, UpdateMedicationStatementMutationResults } from "../../../graphql/operations/types.js";
2
3
  import { BWellQueryResult, BWellTransactionResult } from "../../../results/index.js";
3
4
  import { MedicationDispenseResultsType } from "../../graphql-api/healthdata/graphql-get-medication-dispense-bwell-response-factory.js";
4
5
  import { MedicationRequestResultsType } from "../../graphql-api/healthdata/graphql-get-medication-request-bwell-response-factory.js";
@@ -9,6 +10,8 @@ import { LabKnowledgeRequest } from "./lab-knowledge-request.js";
9
10
  import { MedicationKnowledgeRequest } from "./medication-knowledge-request.js";
10
11
  import { MedicationPricingRequest } from "./medication-pricing-request.js";
11
12
  import { UpdateMedicationStatementRequest } from "./medication-statement-request.js";
13
+ import { UploadDocumentRequest } from "./upload-document-request.js";
14
+ import { UploadDocumentResult } from "./upload-document-result.js";
12
15
  type HealthSummaryResultsType = GetHealthSummaryQueryResults["getHealthSummary"];
13
16
  export interface HealthSummaryResults extends HealthSummaryResultsType {
14
17
  }
@@ -24,6 +27,9 @@ export type DiagnosticReportsResults = DiagnosticReportsResultsType;
24
27
  type DocumentReferencesResultsType = GetDocumentReferencesQueryResults["getDocumentReferences"];
25
28
  export interface DocumentReferencesResults extends DocumentReferencesResultsType {
26
29
  }
30
+ type DocumentReferencesListResultsType = GetDocumentReferencesListQueryResults["getDocumentReferences"];
31
+ export interface DocumentReferencesListResults extends DocumentReferencesListResultsType {
32
+ }
27
33
  type BinaryResultsType = GetBinaryQueryResults["getBinary"];
28
34
  export interface BinaryResults extends BinaryResultsType {
29
35
  }
@@ -165,6 +171,20 @@ export interface HealthManager {
165
171
  * @returns {Promise<BWellQueryResult<DocumentReferencesResults>>} A promise resolving to an object representing the list of document references retrieved from the FHIR server.
166
172
  */
167
173
  getDocumentReferences(request?: DocumentReferencesRequest): Promise<BWellQueryResult<DocumentReferencesResults>>;
174
+ /**
175
+ * Retrieves a list of document references using the FHIR (Fast Healthcare Interoperability Resources) standard,
176
+ * for display in a list/browse view.
177
+ * Unlike {@link getDocumentReferences}, this omits `content.attachment.data` (the base64-encoded file bytes),
178
+ * since a list view only ever renders metadata and should not pull full file bytes per row.
179
+ * Callers that need the actual file content (e.g. a single-document viewer) should use
180
+ * {@link getDocumentReferences} instead.
181
+ * See also https://build.fhir.org/documentreference.html
182
+ *
183
+ * @param {DocumentReferencesRequest} request An optional request class for specifying the search criteria, for the retrieval of document reference resources.
184
+ *
185
+ * @returns {Promise<BWellQueryResult<DocumentReferencesListResults>>} A promise resolving to an object representing the list of document references retrieved from the FHIR server, without attachment file content.
186
+ */
187
+ getDocumentReferencesList(request?: DocumentReferencesRequest): Promise<BWellQueryResult<DocumentReferencesListResults>>;
168
188
  /**
169
189
  * Retrieves a list of Binary resources.
170
190
  * See also https://hl7.org/fhir/r4b/binary.html
@@ -336,7 +356,20 @@ export interface HealthManager {
336
356
  * @param {UpdateMedicationStatementRequest} request The request object specifying the medication statement to update and the fields to update.
337
357
  * @returns {Promise<BWellQueryResult<UpdateMedicationStatementResult>>} A promise resolving to the result of the update operation.
338
358
  */
339
- updateMedicationStatement(request: UpdateMedicationStatementRequest): Promise<BWellTransactionResult<UpdateMedicationStatementResult, BaseManagerError>>;
359
+ updateMedicationStatement(request: UpdateMedicationStatementRequest): Promise<BWellTransactionResult<UpdateMedicationStatementResult, ValidationError | BaseManagerError>>;
360
+ /**
361
+ * Uploads a document reference resource (e.g. a member-provided file).
362
+ *
363
+ * The server stamps `category = patient-uploaded` and derives `subject` from
364
+ * the caller's identity; neither can be set by the caller.
365
+ *
366
+ * @category Manager Methods
367
+ * @title uploadDocument
368
+ * @excerpt Upload a member-provided file as a new DocumentReference
369
+ * @param {UploadDocumentRequest} request The request object specifying the file content (as a data URI), title, and type coding.
370
+ * @returns {Promise<BWellTransactionResult<UploadDocumentResult>>} A promise resolving to the result of the upload operation.
371
+ */
372
+ uploadDocument(request: UploadDocumentRequest): Promise<BWellTransactionResult<UploadDocumentResult, ValidationError | BaseManagerError>>;
340
373
  /**
341
374
  * Retrieves a list of medication groups resources.
342
375
  *
@@ -4,4 +4,6 @@ export { BodySystemScoreRequest, BodySystemScoreRequestInput, } from "./body-sys
4
4
  export { MedicationKnowledgeRequest, MedicationKnowledgeRequestInput, } from "./medication-knowledge-request.js";
5
5
  export { LabKnowledgeRequest, LabKnowledgeRequestInput, } from "./lab-knowledge-request.js";
6
6
  export { UpdateMedicationStatementRequest, UpdateMedicationStatementInput, UpdateMedicationStatementStatus, } from "./medication-statement-request.js";
7
- export { HealthSummaryResults, HealthScoreResults, BodySystemScoreResults, AllergyIntolerancesResults, AllergyIntolerancesGroupsResults, BinaryResults, ConditionsResults, ConditionGroupsResults, DiagnosticReportsResults, DocumentReferencesResults, LabsResults, LabGroupsResults, CarePlansResults, CarePlanGroupsResults, CareTeamsResults, EncountersResults, EncounterGroupsResults, ImmunizationsResults, ImmunizationGroupsResults, ProceduresResults, ProcedureGroupsResults, VitalSignsResults, VitalSignGroupsResults, DeviceMetricsResults, DeviceMetricsGroupsResults, MedicationDispenseResults, MedicationRequestResults, MedicationStatementsResults, MedicationKnowledgeResults, MedicationGroupsResults, LabKnowledgeResults, HealthManager, MedicationPricingResults, DiagnosticReportLabGroupsResults, UpdateMedicationStatementResult, } from "./health-manager.js";
7
+ export { UploadDocumentRequest, UploadDocumentRequestInput, UploadDocumentTypeCoding, } from "./upload-document-request.js";
8
+ export { UploadDocumentAttachment, UploadDocumentCategory, UploadDocumentContent, UploadDocumentResult, UploadDocumentSubject, } from "./upload-document-result.js";
9
+ export { HealthSummaryResults, HealthScoreResults, BodySystemScoreResults, AllergyIntolerancesResults, AllergyIntolerancesGroupsResults, BinaryResults, ConditionsResults, ConditionGroupsResults, DiagnosticReportsResults, DocumentReferencesResults, DocumentReferencesListResults, LabsResults, LabGroupsResults, CarePlansResults, CarePlanGroupsResults, CareTeamsResults, EncountersResults, EncounterGroupsResults, ImmunizationsResults, ImmunizationGroupsResults, ProceduresResults, ProcedureGroupsResults, VitalSignsResults, VitalSignGroupsResults, DeviceMetricsResults, DeviceMetricsGroupsResults, MedicationDispenseResults, MedicationRequestResults, MedicationStatementsResults, MedicationKnowledgeResults, MedicationGroupsResults, LabKnowledgeResults, HealthManager, MedicationPricingResults, DiagnosticReportLabGroupsResults, UpdateMedicationStatementResult, } from "./health-manager.js";
@@ -4,3 +4,4 @@ export { BodySystemScoreRequest, } from "./body-system-score-request.js";
4
4
  export { MedicationKnowledgeRequest, } from "./medication-knowledge-request.js";
5
5
  export { LabKnowledgeRequest, } from "./lab-knowledge-request.js";
6
6
  export { UpdateMedicationStatementRequest, UpdateMedicationStatementStatus, } from "./medication-statement-request.js";
7
+ export { UploadDocumentRequest, } from "./upload-document-request.js";
@@ -0,0 +1,36 @@
1
+ import { Coding } from "../../../models/coding.js";
2
+ import { ErrorsCollector, ValidationRequest, Validator } from "../../../requests/index.js";
3
+ /**
4
+ * The code — e.g. LOINC — describing what kind of document this is.
5
+ */
6
+ export type UploadDocumentTypeCoding = Coding;
7
+ /**
8
+ * Input for uploading a document reference.
9
+ * @category Inputs
10
+ * @title UploadDocumentRequestInput
11
+ * @excerpt Input for uploading a member-provided file as a DocumentReference
12
+ */
13
+ export type UploadDocumentRequestInput = {
14
+ /**
15
+ * The file content as a data URI with base64 encoding and MIME type.
16
+ * Format: data:<MIME-type>;base64,<base64-encoded-data>
17
+ * Example: "data:application/pdf;base64,JVBERi0xLjQKJeLjz9MK..."
18
+ */
19
+ file: string;
20
+ title?: string;
21
+ typeCoding?: UploadDocumentTypeCoding;
22
+ };
23
+ declare class UploadDocumentRequestValidator implements Validator<UploadDocumentRequestInput> {
24
+ validate(data: UploadDocumentRequestInput, errors: ErrorsCollector): void;
25
+ }
26
+ /**
27
+ * Request class for uploading a document reference.
28
+ * Validates that the file is provided as a data URI with base64 encoding and a MIME type.
29
+ * @category Requests
30
+ * @title UploadDocumentRequest
31
+ * @excerpt Request object for uploading a document reference with validation
32
+ */
33
+ export declare class UploadDocumentRequest extends ValidationRequest<UploadDocumentRequestInput> {
34
+ protected validator: UploadDocumentRequestValidator;
35
+ }
36
+ export {};
@@ -0,0 +1,37 @@
1
+ import { ValidationRequest, } from "../../../requests/index.js";
2
+ import { isNullOrUndefinedOrEmptyString, MAX_DOCUMENT_DATA_LENGTH, MAX_DOCUMENT_FILE_BYTES, parseDataUri, } from "../../../utils/index.js";
3
+ class UploadDocumentRequestValidator {
4
+ validate(data, errors) {
5
+ if (isNullOrUndefinedOrEmptyString(data.file)) {
6
+ errors.add("File content is required");
7
+ return;
8
+ }
9
+ // Note: the bound is checked against the parsed base64 *payload*
10
+ // length, not `data.file.length` — the raw data URI string also
11
+ // includes the "data:<mime-type>;base64," prefix (and any RFC 2397
12
+ // params baked into the MIME type), whose length varies independently
13
+ // of the actual file content and would otherwise make the bound
14
+ // inconsistent for otherwise-identical file sizes.
15
+ const parsed = parseDataUri(data.file);
16
+ if (parsed === null) {
17
+ errors.add("File must be a valid data URI with base64 encoding (e.g., data:image/png;base64,...)");
18
+ return;
19
+ }
20
+ if (parsed.data.length > MAX_DOCUMENT_DATA_LENGTH) {
21
+ errors.add(`File content must not exceed ${MAX_DOCUMENT_FILE_BYTES / (1024 * 1024)} MB`);
22
+ }
23
+ }
24
+ }
25
+ /**
26
+ * Request class for uploading a document reference.
27
+ * Validates that the file is provided as a data URI with base64 encoding and a MIME type.
28
+ * @category Requests
29
+ * @title UploadDocumentRequest
30
+ * @excerpt Request object for uploading a document reference with validation
31
+ */
32
+ export class UploadDocumentRequest extends ValidationRequest {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.validator = new UploadDocumentRequestValidator();
36
+ }
37
+ }
@@ -0,0 +1,67 @@
1
+ import { Coding } from "../../../models/coding.js";
2
+ /**
3
+ * The coding/text describing what category the uploaded document falls
4
+ * under. The server always stamps `category = patient-uploaded`; callers
5
+ * cannot set this, but may read it back.
6
+ * @category Results
7
+ * @title UploadDocumentCategory
8
+ * @excerpt The server-stamped category on an uploaded document result
9
+ */
10
+ export type UploadDocumentCategory = {
11
+ coding?: Coding[];
12
+ text?: string;
13
+ };
14
+ /**
15
+ * The subject (patient) the uploaded document is attached to, as derived
16
+ * server-side from the caller's identity.
17
+ * @category Results
18
+ * @title UploadDocumentSubject
19
+ * @excerpt The server-derived patient subject on an uploaded document result
20
+ */
21
+ export type UploadDocumentSubject = {
22
+ reference?: string;
23
+ display?: string;
24
+ };
25
+ /**
26
+ * The attachment metadata for the uploaded document's content.
27
+ *
28
+ * NOTE: `data` (the base64 file bytes) is deliberately NOT included here —
29
+ * never echo a member's uploaded file bytes back through the SDK. If you're
30
+ * editing the `.graphql` selection set for `uploadDocument` to add fields,
31
+ * read this comment first before adding `data` back to the selection or to
32
+ * this type.
33
+ * @category Results
34
+ * @title UploadDocumentAttachment
35
+ * @excerpt The attachment metadata (no file bytes) on an uploaded document result
36
+ */
37
+ export type UploadDocumentAttachment = {
38
+ contentType?: string;
39
+ title?: string;
40
+ };
41
+ /**
42
+ * The content entry (attachment wrapper) for the uploaded document.
43
+ * @category Results
44
+ * @title UploadDocumentContent
45
+ * @excerpt The content entry wrapping an uploaded document's attachment
46
+ */
47
+ export type UploadDocumentContent = {
48
+ attachment?: UploadDocumentAttachment;
49
+ };
50
+ /**
51
+ * SDK-owned result shape for `uploadDocument`. Unlike most other result
52
+ * types in this SDK, this type is intentionally NOT derived from the
53
+ * generated GraphQL mutation result type (see `health-manager.ts` for the
54
+ * rationale) — it's hand-written so that codegen's `any`-typed scalars
55
+ * never leak through to SDK consumers.
56
+ * @category Results
57
+ * @title UploadDocumentResult
58
+ * @excerpt SDK-owned result shape for the uploadDocument mutation
59
+ */
60
+ export type UploadDocumentResult = {
61
+ id: string;
62
+ resourceType: string;
63
+ status?: string;
64
+ category?: UploadDocumentCategory[];
65
+ subject?: UploadDocumentSubject;
66
+ content?: UploadDocumentContent[];
67
+ };
@@ -12,7 +12,6 @@ export type UploadSupportAttachmentRequestInput = {
12
12
  fileName: string;
13
13
  };
14
14
  declare class UploadSupportAttachmentRequestValidator implements Validator<UploadSupportAttachmentRequestInput> {
15
- private readonly dataURIRegex;
16
15
  validate(data: UploadSupportAttachmentRequestInput, errors: ErrorsCollector): void;
17
16
  }
18
17
  /**
@@ -1,13 +1,14 @@
1
1
  import { ValidationRequest, } from "../../../requests/index.js";
2
+ import { isDataUri } from "../../../utils/index.js";
2
3
  class UploadSupportAttachmentRequestValidator {
3
- constructor() {
4
- this.dataURIRegex = /^data:[a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+;base64,([A-Za-z0-9+/]*={0,2})$/;
5
- }
6
4
  validate(data, errors) {
7
5
  if (!data.file.trim()) {
8
6
  errors.add("File content is required");
9
7
  }
10
- if (data.file.trim() && !this.dataURIRegex.test(data.file)) {
8
+ // No size bound here, deliberately: unlike UploadDocumentRequest, this
9
+ // request type's server-side cap is unrelated/unknown, so the payload
10
+ // length is left unbounded for support attachments.
11
+ if (data.file.trim() && !isDataUri(data.file)) {
11
12
  errors.add("File must be a valid data URI with base64 encoding (e.g., data:image/png;base64,...)");
12
13
  }
13
14
  if (!data.fileName.trim()) {
@@ -10,13 +10,15 @@ import { GraphQLGetDiagnosticReportRequestFactory } from "./graphql-diagnostic-r
10
10
  import { GraphQLGetMedicationDispenseBWellResponseFactory } from "./graphql-get-medication-dispense-bwell-response-factory.js";
11
11
  import { GraphQLGetMedicationRequestBWellResponseFactory } from "./graphql-get-medication-request-bwell-response-factory.js";
12
12
  import { GraphqlUpdateMedicationStatementRequestFactory } from "./graphql-update-medication-statement-request-factory.js";
13
+ import { GraphQLUploadDocumentRequestFactory } from "./graphql-upload-document-request-factory.js";
14
+ import { GraphQLUploadDocumentResponseFactory } from "./graphql-upload-document-response-factory.js";
13
15
  export type RenameKey<T, OldKey extends string, NewKey extends string> = T extends unknown[] ? RenameKeyInArray<T, OldKey, NewKey> : T extends object ? {
14
16
  [K in keyof T as K extends OldKey ? NewKey : K]: RenameKey<T[K], OldKey, NewKey>;
15
17
  } : T;
16
18
  export type RenameKeyInArray<T extends unknown[], OldKey extends string, NewKey extends string> = Array<RenameKey<T[number], OldKey, NewKey>>;
17
19
  export declare class GraphQLHealthManager extends GraphQLManager implements HealthManager {
18
20
  #private;
19
- constructor(sdk: GraphQLSdk, loggerProvider?: LoggerProvider, medicationRequestResponseFactory?: GraphQLGetMedicationRequestBWellResponseFactory, medicationDispenseResponseFactory?: GraphQLGetMedicationDispenseBWellResponseFactory, diagnosticReportRequestFactory?: GraphQLGetDiagnosticReportRequestFactory, updateMedicationStatementRequestFactory?: GraphqlUpdateMedicationStatementRequestFactory);
21
+ constructor(sdk: GraphQLSdk, loggerProvider?: LoggerProvider, medicationRequestResponseFactory?: GraphQLGetMedicationRequestBWellResponseFactory, medicationDispenseResponseFactory?: GraphQLGetMedicationDispenseBWellResponseFactory, diagnosticReportRequestFactory?: GraphQLGetDiagnosticReportRequestFactory, updateMedicationStatementRequestFactory?: GraphqlUpdateMedicationStatementRequestFactory, uploadDocumentRequestFactory?: GraphQLUploadDocumentRequestFactory, uploadDocumentResponseFactory?: GraphQLUploadDocumentResponseFactory);
20
22
  getHealthSummary(): Promise<BWellQueryResult<health.HealthSummaryResults, BaseManagerError>>;
21
23
  getAllergyIntolerances(request?: health.AllergyIntolerancesRequest): Promise<BWellQueryResult<health.AllergyIntolerancesResults, ValidationError | BaseManagerError>>;
22
24
  getAllergyIntoleranceGroups(request?: health.AllergyIntoleranceGroupsRequest): Promise<BWellQueryResult<health.AllergyIntolerancesGroupsResults, ValidationError | BaseManagerError>>;
@@ -24,6 +26,7 @@ export declare class GraphQLHealthManager extends GraphQLManager implements Heal
24
26
  getConditionGroups(request?: health.ConditionGroupsRequest): Promise<BWellQueryResult<health.ConditionGroupsResults, ValidationError | BaseManagerError>>;
25
27
  getDiagnosticReports(request?: health.DiagnosticReportsRequest): Promise<BWellQueryResult<health.DiagnosticReportsResults, ValidationError | BaseManagerError>>;
26
28
  getDocumentReferences(request?: health.DocumentReferencesRequest): Promise<BWellQueryResult<health.DocumentReferencesResults, ValidationError | BaseManagerError>>;
29
+ getDocumentReferencesList(request?: health.DocumentReferencesRequest): Promise<BWellQueryResult<health.DocumentReferencesListResults, ValidationError | BaseManagerError>>;
27
30
  getBinary(request: health.BinaryRequest): Promise<BWellQueryResult<health.BinaryResults, ValidationError | BaseManagerError>>;
28
31
  getLabs(request?: health.LabsRequest): Promise<BWellQueryResult<health.LabsResults, ValidationError | BaseManagerError>>;
29
32
  getLabGroups(request?: health.LabGroupsRequest): Promise<BWellQueryResult<health.LabGroupsResults, ValidationError | BaseManagerError>>;
@@ -44,6 +47,7 @@ export declare class GraphQLHealthManager extends GraphQLManager implements Heal
44
47
  getMedicationRequest(request?: health.MedicationRequestRequest): Promise<BWellQueryResult<health.MedicationRequestResults, ValidationError | BaseManagerError>>;
45
48
  getMedicationStatements(request?: health.MedicationStatementsRequest): Promise<BWellQueryResult<health.MedicationStatementsResults, ValidationError | BaseManagerError>>;
46
49
  updateMedicationStatement(request: health.UpdateMedicationStatementRequest): Promise<BWellTransactionResult<health.UpdateMedicationStatementResult, ValidationError | BaseManagerError>>;
50
+ uploadDocument(request: health.UploadDocumentRequest): Promise<BWellTransactionResult<health.UploadDocumentResult, ValidationError | BaseManagerError>>;
47
51
  getMedicationGroups(request?: health.MedicationGroupsRequest): Promise<BWellQueryResult<health.MedicationGroupsResults, ValidationError | BaseManagerError>>;
48
52
  getMedicationKnowledge(request: health.MedicationKnowledgeRequest): Promise<BWellQueryResult<health.MedicationKnowledgeResults, ValidationError | BaseManagerError>>;
49
53
  getLabKnowledge(request: health.LabKnowledgeRequest): Promise<BWellQueryResult<health.LabKnowledgeResults, ValidationError | BaseManagerError>>;
@@ -18,7 +18,7 @@ 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_medicationRequestResponseFactory, _GraphQLHealthManager_medicationDispenseResponseFactory, _GraphQLHealthManager_diagnosticReportRequestFactory, _GraphQLHealthManager_updateMedicationStatementRequestFactory;
21
+ var _GraphQLHealthManager_sdk, _GraphQLHealthManager_logger, _GraphQLHealthManager_medicationRequestResponseFactory, _GraphQLHealthManager_medicationDispenseResponseFactory, _GraphQLHealthManager_diagnosticReportRequestFactory, _GraphQLHealthManager_updateMedicationStatementRequestFactory, _GraphQLHealthManager_uploadDocumentRequestFactory, _GraphQLHealthManager_uploadDocumentResponseFactory;
22
22
  import { ObservationCategory } from "../../../graphql/schema.js";
23
23
  import { ConsoleLoggerProvider, } from "../../../logger/index.js";
24
24
  import { BWellQueryResult, BWellTransactionResult, } from "../../../results/index.js";
@@ -27,8 +27,10 @@ import { GraphQLGetDiagnosticReportRequestFactory } from "./graphql-diagnostic-r
27
27
  import { GraphQLGetMedicationDispenseBWellResponseFactory } from "./graphql-get-medication-dispense-bwell-response-factory.js";
28
28
  import { GraphQLGetMedicationRequestBWellResponseFactory } from "./graphql-get-medication-request-bwell-response-factory.js";
29
29
  import { GraphqlUpdateMedicationStatementRequestFactory } from "./graphql-update-medication-statement-request-factory.js";
30
+ import { GraphQLUploadDocumentRequestFactory } from "./graphql-upload-document-request-factory.js";
31
+ import { GraphQLUploadDocumentResponseFactory } from "./graphql-upload-document-response-factory.js";
30
32
  export class GraphQLHealthManager extends GraphQLManager {
31
- constructor(sdk, loggerProvider = new ConsoleLoggerProvider(), medicationRequestResponseFactory = new GraphQLGetMedicationRequestBWellResponseFactory(), medicationDispenseResponseFactory = new GraphQLGetMedicationDispenseBWellResponseFactory(), diagnosticReportRequestFactory = new GraphQLGetDiagnosticReportRequestFactory(), updateMedicationStatementRequestFactory = new GraphqlUpdateMedicationStatementRequestFactory()) {
33
+ constructor(sdk, loggerProvider = new ConsoleLoggerProvider(), medicationRequestResponseFactory = new GraphQLGetMedicationRequestBWellResponseFactory(), medicationDispenseResponseFactory = new GraphQLGetMedicationDispenseBWellResponseFactory(), diagnosticReportRequestFactory = new GraphQLGetDiagnosticReportRequestFactory(), updateMedicationStatementRequestFactory = new GraphqlUpdateMedicationStatementRequestFactory(), uploadDocumentRequestFactory = new GraphQLUploadDocumentRequestFactory(), uploadDocumentResponseFactory = new GraphQLUploadDocumentResponseFactory()) {
32
34
  super();
33
35
  _GraphQLHealthManager_sdk.set(this, void 0);
34
36
  _GraphQLHealthManager_logger.set(this, void 0);
@@ -36,12 +38,16 @@ export class GraphQLHealthManager extends GraphQLManager {
36
38
  _GraphQLHealthManager_medicationDispenseResponseFactory.set(this, void 0);
37
39
  _GraphQLHealthManager_diagnosticReportRequestFactory.set(this, void 0);
38
40
  _GraphQLHealthManager_updateMedicationStatementRequestFactory.set(this, void 0);
41
+ _GraphQLHealthManager_uploadDocumentRequestFactory.set(this, void 0);
42
+ _GraphQLHealthManager_uploadDocumentResponseFactory.set(this, void 0);
39
43
  __classPrivateFieldSet(this, _GraphQLHealthManager_sdk, sdk, "f");
40
44
  __classPrivateFieldSet(this, _GraphQLHealthManager_logger, loggerProvider.getLogger("GraphQLHealthManager"), "f");
41
45
  __classPrivateFieldSet(this, _GraphQLHealthManager_medicationRequestResponseFactory, medicationRequestResponseFactory, "f");
42
46
  __classPrivateFieldSet(this, _GraphQLHealthManager_medicationDispenseResponseFactory, medicationDispenseResponseFactory, "f");
43
47
  __classPrivateFieldSet(this, _GraphQLHealthManager_diagnosticReportRequestFactory, diagnosticReportRequestFactory, "f");
44
48
  __classPrivateFieldSet(this, _GraphQLHealthManager_updateMedicationStatementRequestFactory, updateMedicationStatementRequestFactory, "f");
49
+ __classPrivateFieldSet(this, _GraphQLHealthManager_uploadDocumentRequestFactory, uploadDocumentRequestFactory, "f");
50
+ __classPrivateFieldSet(this, _GraphQLHealthManager_uploadDocumentResponseFactory, uploadDocumentResponseFactory, "f");
45
51
  }
46
52
  getHealthSummary() {
47
53
  return __awaiter(this, void 0, void 0, function* () {
@@ -158,6 +164,24 @@ export class GraphQLHealthManager extends GraphQLManager {
158
164
  return new BWellQueryResult((_b = result.data) === null || _b === void 0 ? void 0 : _b.getDocumentReferences, result.error);
159
165
  });
160
166
  }
167
+ getDocumentReferencesList(request) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ var _a, _b;
170
+ const validationResult = this.validateRequest(request);
171
+ if (validationResult.failure()) {
172
+ return validationResult.toQueryResult();
173
+ }
174
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("calling getDocumentReferencesList...");
175
+ const result = yield this.handleQuery(__classPrivateFieldGet(this, _GraphQLHealthManager_sdk, "f").getDocumentReferencesList({
176
+ request: (_a = request === null || request === void 0 ? void 0 : request.data()) !== null && _a !== void 0 ? _a : null,
177
+ }));
178
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("getDocumentReferencesList complete");
179
+ if (result.hasError()) {
180
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("getDocumentReferencesList errors", result.error);
181
+ }
182
+ return new BWellQueryResult((_b = result.data) === null || _b === void 0 ? void 0 : _b.getDocumentReferences, result.error);
183
+ });
184
+ }
161
185
  getBinary(request) {
162
186
  return __awaiter(this, void 0, void 0, function* () {
163
187
  var _a;
@@ -510,12 +534,28 @@ export class GraphQLHealthManager extends GraphQLManager {
510
534
  const result = yield this.handleTransaction(__classPrivateFieldGet(this, _GraphQLHealthManager_sdk, "f").updateMedicationStatement(__classPrivateFieldGet(this, _GraphQLHealthManager_updateMedicationStatementRequestFactory, "f").create(request)));
511
535
  __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("updateMedicationStatement complete");
512
536
  if (result.failure()) {
513
- __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("updateMedicationStatement failed", result.error);
537
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("updateMedicationStatement failed", result.error());
514
538
  return result.intoFailure();
515
539
  }
516
540
  return BWellTransactionResult.success(result.data().updateMedicationStatement);
517
541
  });
518
542
  }
543
+ uploadDocument(request) {
544
+ return __awaiter(this, void 0, void 0, function* () {
545
+ const validationResult = this.validateRequest(request);
546
+ if (validationResult.failure()) {
547
+ return validationResult.intoFailure();
548
+ }
549
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("calling uploadDocument mutation...");
550
+ const result = yield this.handleTransaction(__classPrivateFieldGet(this, _GraphQLHealthManager_sdk, "f").UploadDocument(__classPrivateFieldGet(this, _GraphQLHealthManager_uploadDocumentRequestFactory, "f").create(request)));
551
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").verbose("uploadDocument mutation complete");
552
+ if (result.failure()) {
553
+ __classPrivateFieldGet(this, _GraphQLHealthManager_logger, "f").error("uploadDocument mutation failed", result.error());
554
+ return result.intoFailure();
555
+ }
556
+ return BWellTransactionResult.success(__classPrivateFieldGet(this, _GraphQLHealthManager_uploadDocumentResponseFactory, "f").create(result.data().uploadDocument));
557
+ });
558
+ }
519
559
  getMedicationGroups(request) {
520
560
  return __awaiter(this, void 0, void 0, function* () {
521
561
  var _a, _b;
@@ -635,4 +675,4 @@ export class GraphQLHealthManager extends GraphQLManager {
635
675
  });
636
676
  }
637
677
  }
638
- _GraphQLHealthManager_sdk = new WeakMap(), _GraphQLHealthManager_logger = new WeakMap(), _GraphQLHealthManager_medicationRequestResponseFactory = new WeakMap(), _GraphQLHealthManager_medicationDispenseResponseFactory = new WeakMap(), _GraphQLHealthManager_diagnosticReportRequestFactory = new WeakMap(), _GraphQLHealthManager_updateMedicationStatementRequestFactory = new WeakMap();
678
+ _GraphQLHealthManager_sdk = new WeakMap(), _GraphQLHealthManager_logger = new WeakMap(), _GraphQLHealthManager_medicationRequestResponseFactory = new WeakMap(), _GraphQLHealthManager_medicationDispenseResponseFactory = new WeakMap(), _GraphQLHealthManager_diagnosticReportRequestFactory = new WeakMap(), _GraphQLHealthManager_updateMedicationStatementRequestFactory = new WeakMap(), _GraphQLHealthManager_uploadDocumentRequestFactory = new WeakMap(), _GraphQLHealthManager_uploadDocumentResponseFactory = new WeakMap();
@@ -0,0 +1,6 @@
1
+ import { UploadDocumentMutationVariables } from "../../../graphql/operations/types.js";
2
+ import { RequestFactory } from "../../../requests/index.js";
3
+ import { UploadDocumentRequest } from "../../base/health-data/upload-document-request.js";
4
+ export declare class GraphQLUploadDocumentRequestFactory implements RequestFactory<UploadDocumentRequest, UploadDocumentMutationVariables> {
5
+ create(request: UploadDocumentRequest): UploadDocumentMutationVariables;
6
+ }
@@ -0,0 +1,37 @@
1
+ import { ValidationError } from "../../../errors/index.js";
2
+ import { parseDataUri } from "../../../utils/index.js";
3
+ export class GraphQLUploadDocumentRequestFactory {
4
+ create(request) {
5
+ const data = request.data();
6
+ const parsed = parseDataUri(data.file);
7
+ // The request validator (`UploadDocumentRequestValidator`) rejects a
8
+ // malformed `data.file` before a `BWellTransactionResult` is returned
9
+ // to the caller — but nothing stops a caller from constructing this
10
+ // factory directly against an unvalidated `UploadDocumentRequest`, or
11
+ // ignoring a failed `validate()` result. Falling back to empty strings
12
+ // here would silently send an empty/garbage payload to the server
13
+ // instead of failing loudly, so treat a `null` parse as an explicit
14
+ // error rather than a non-null assertion.
15
+ if (parsed === null) {
16
+ throw new ValidationError([
17
+ "File must be a valid data URI with base64 encoding (e.g., data:image/png;base64,...)",
18
+ ]);
19
+ }
20
+ const contentType = parsed.contentType;
21
+ const base64Data = parsed.data;
22
+ return {
23
+ input: {
24
+ data: base64Data,
25
+ contentType,
26
+ title: data.title,
27
+ typeCoding: data.typeCoding !== undefined
28
+ ? {
29
+ system: data.typeCoding.system,
30
+ code: data.typeCoding.code,
31
+ display: data.typeCoding.display,
32
+ }
33
+ : undefined,
34
+ },
35
+ };
36
+ }
37
+ }
@@ -0,0 +1,24 @@
1
+ import { UploadDocumentMutationResults } from "../../../graphql/operations/types.js";
2
+ import { UploadDocumentResult } from "../../base/health-data/upload-document-result.js";
3
+ /**
4
+ * Codegen's shape for the raw `uploadDocument` mutation result, i.e. the
5
+ * value of `result.data().uploadDocument` in `GraphQLHealthManager`.
6
+ */
7
+ export type UploadDocumentMutationResultsType = UploadDocumentMutationResults["uploadDocument"];
8
+ /**
9
+ * Factory to map the raw GraphQL `uploadDocument` mutation result into the
10
+ * SDK-owned `UploadDocumentResult` shape. Unlike the query-side response
11
+ * factories in this directory (e.g.
12
+ * `GraphQLGetMedicationDispenseBWellResponseFactory`), this factory doesn't
13
+ * wrap/unwrap a `BWellQueryResult` — `uploadDocument` is a transaction, so
14
+ * by the time this factory runs, `result.data().uploadDocument` is already
15
+ * the unwrapped mutation payload. Each field is mapped explicitly by name
16
+ * (no spread), so codegen's `any`-typed scalars never leak through to SDK
17
+ * consumers.
18
+ * @category Factories
19
+ * @title GraphQLUploadDocumentResponseFactory
20
+ * @excerpt Maps the raw uploadDocument mutation result into UploadDocumentResult
21
+ */
22
+ export declare class GraphQLUploadDocumentResponseFactory {
23
+ create(result: UploadDocumentMutationResultsType): UploadDocumentResult;
24
+ }
@@ -0,0 +1,71 @@
1
+ import { ValidationError } from "../../../errors/index.js";
2
+ /**
3
+ * Factory to map the raw GraphQL `uploadDocument` mutation result into the
4
+ * SDK-owned `UploadDocumentResult` shape. Unlike the query-side response
5
+ * factories in this directory (e.g.
6
+ * `GraphQLGetMedicationDispenseBWellResponseFactory`), this factory doesn't
7
+ * wrap/unwrap a `BWellQueryResult` — `uploadDocument` is a transaction, so
8
+ * by the time this factory runs, `result.data().uploadDocument` is already
9
+ * the unwrapped mutation payload. Each field is mapped explicitly by name
10
+ * (no spread), so codegen's `any`-typed scalars never leak through to SDK
11
+ * consumers.
12
+ * @category Factories
13
+ * @title GraphQLUploadDocumentResponseFactory
14
+ * @excerpt Maps the raw uploadDocument mutation result into UploadDocumentResult
15
+ */
16
+ export class GraphQLUploadDocumentResponseFactory {
17
+ create(result) {
18
+ var _a, _b, _c, _d, _e;
19
+ // `id` and `resourceType` are `required` on `UploadDocumentResult` — a
20
+ // persisted document always has both, so a `null`/`undefined` value
21
+ // here means the server response was malformed, not that the field is
22
+ // legitimately absent. Fail loudly instead of smuggling a `null` into a
23
+ // field the type promises is a `string`.
24
+ if (result.id === null || result.id === undefined) {
25
+ throw new ValidationError([
26
+ "uploadDocument response is missing required field: id",
27
+ ]);
28
+ }
29
+ if (result.resourceType === null || result.resourceType === undefined) {
30
+ throw new ValidationError([
31
+ "uploadDocument response is missing required field: resourceType",
32
+ ]);
33
+ }
34
+ return {
35
+ id: result.id,
36
+ resourceType: result.resourceType,
37
+ status: (_a = result.status) !== null && _a !== void 0 ? _a : undefined,
38
+ category: (_b = result.category) === null || _b === void 0 ? void 0 : _b.map((category) => {
39
+ var _a, _b;
40
+ return ({
41
+ coding: (_a = category === null || category === void 0 ? void 0 : category.coding) === null || _a === void 0 ? void 0 : _a.map((coding) => {
42
+ var _a;
43
+ return ({
44
+ system: coding === null || coding === void 0 ? void 0 : coding.system,
45
+ code: coding === null || coding === void 0 ? void 0 : coding.code,
46
+ display: (_a = coding === null || coding === void 0 ? void 0 : coding.display) !== null && _a !== void 0 ? _a : undefined,
47
+ });
48
+ }),
49
+ text: (_b = category === null || category === void 0 ? void 0 : category.text) !== null && _b !== void 0 ? _b : undefined,
50
+ });
51
+ }),
52
+ subject: result.subject
53
+ ? {
54
+ reference: (_c = result.subject.reference) !== null && _c !== void 0 ? _c : undefined,
55
+ display: (_d = result.subject.display) !== null && _d !== void 0 ? _d : undefined,
56
+ }
57
+ : undefined,
58
+ content: (_e = result.content) === null || _e === void 0 ? void 0 : _e.map((content) => {
59
+ var _a, _b;
60
+ return ({
61
+ attachment: (content === null || content === void 0 ? void 0 : content.attachment)
62
+ ? {
63
+ contentType: (_a = content.attachment.contentType) !== null && _a !== void 0 ? _a : undefined,
64
+ title: (_b = content.attachment.title) !== null && _b !== void 0 ? _b : undefined,
65
+ }
66
+ : undefined,
67
+ });
68
+ }),
69
+ };
70
+ }
71
+ }
@@ -76,7 +76,7 @@ export class GraphQLUserManager extends GraphQLManager {
76
76
  const result = yield this.handleTransaction(__classPrivateFieldGet(this, _GraphQLUserManager_sdk, "f").delete());
77
77
  __classPrivateFieldGet(this, _GraphQLUserManager_logger, "f").verbose("delete complete");
78
78
  if (result.failure()) {
79
- __classPrivateFieldGet(this, _GraphQLUserManager_logger, "f").error("delete failed", result.error);
79
+ __classPrivateFieldGet(this, _GraphQLUserManager_logger, "f").error("delete failed", result.error());
80
80
  return result.intoFailure();
81
81
  }
82
82
  __classPrivateFieldGet(this, _GraphQLUserManager_logger, "f").info("successfully called delete");