@oystehr/sdk 3.0.2 → 3.0.4

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 (46) hide show
  1. package/dist/cjs/client/client.d.ts +2 -1
  2. package/dist/cjs/index.cjs +70 -2
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.min.cjs +1 -1
  5. package/dist/cjs/index.min.cjs.map +1 -1
  6. package/dist/cjs/resources/classes/erx.d.ts +5 -1
  7. package/dist/cjs/resources/classes/z3-ext.d.ts +22 -0
  8. package/dist/cjs/resources/classes/z3.d.ts +15 -0
  9. package/dist/cjs/resources/types/ErxMedicationSearchV2Params.d.ts +4 -0
  10. package/dist/cjs/resources/types/ErxMedicationSearchV2Response.d.ts +38 -0
  11. package/dist/cjs/resources/types/Z3ListObjectsParams.d.ts +1 -0
  12. package/dist/cjs/resources/types/index.d.ts +2 -0
  13. package/dist/cjs/tests/setup/constants.d.ts +1 -1
  14. package/dist/esm/client/client.d.ts +2 -1
  15. package/dist/esm/client/client.js +1 -1
  16. package/dist/esm/client/client.js.map +1 -1
  17. package/dist/esm/index.min.js +1 -1
  18. package/dist/esm/index.min.js.map +1 -1
  19. package/dist/esm/node_modules/tslib/tslib.es6.js +1 -1
  20. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
  21. package/dist/esm/resources/classes/erx.d.ts +5 -1
  22. package/dist/esm/resources/classes/erx.js +4 -0
  23. package/dist/esm/resources/classes/erx.js.map +1 -1
  24. package/dist/esm/resources/classes/fhir-ext.js +4 -1
  25. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  26. package/dist/esm/resources/classes/z3-ext.d.ts +22 -0
  27. package/dist/esm/resources/classes/z3-ext.js +49 -1
  28. package/dist/esm/resources/classes/z3-ext.js.map +1 -1
  29. package/dist/esm/resources/classes/z3.d.ts +15 -0
  30. package/dist/esm/resources/classes/z3.js +16 -1
  31. package/dist/esm/resources/classes/z3.js.map +1 -1
  32. package/dist/esm/resources/types/ErxMedicationSearchV2Params.d.ts +4 -0
  33. package/dist/esm/resources/types/ErxMedicationSearchV2Response.d.ts +38 -0
  34. package/dist/esm/resources/types/Z3ListObjectsParams.d.ts +1 -0
  35. package/dist/esm/resources/types/index.d.ts +2 -0
  36. package/dist/esm/tests/setup/constants.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/src/client/client.ts +2 -2
  39. package/src/resources/classes/erx.ts +9 -0
  40. package/src/resources/classes/fhir-ext.ts +5 -2
  41. package/src/resources/classes/z3-ext.ts +48 -1
  42. package/src/resources/classes/z3.ts +15 -0
  43. package/src/resources/types/ErxMedicationSearchV2Params.ts +6 -0
  44. package/src/resources/types/ErxMedicationSearchV2Response.ts +40 -0
  45. package/src/resources/types/Z3ListObjectsParams.ts +1 -0
  46. package/src/resources/types/index.ts +2 -0
@@ -1,5 +1,12 @@
1
- import { SDKResource } from '../../client/client';
1
+ import { defaultProjectApiUrl, SDKResource } from '../../client/client';
2
+ import { OystehrSdkError } from '../../errors';
3
+ import { Z3GetPresignedUrlParams, Z3GetPresignedUrlResponse } from '../types';
2
4
 
5
+ /**
6
+ * Uploads a file to the bucket and key. Files should be Blobs.
7
+ *
8
+ * @param params upload file params
9
+ */
3
10
  export async function uploadFile(
4
11
  this: SDKResource,
5
12
  {
@@ -26,6 +33,11 @@ export async function uploadFile(
26
33
  });
27
34
  }
28
35
 
36
+ /**
37
+ * Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
38
+ *
39
+ * @param params download file params
40
+ */
29
41
  export async function downloadFile(
30
42
  this: SDKResource,
31
43
  {
@@ -52,3 +64,38 @@ export async function downloadFile(
52
64
  }
53
65
  return resp.arrayBuffer();
54
66
  }
67
+
68
+ /**
69
+ * This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
70
+ * `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
71
+ * instead of the standard SDK `Z3GetPresignedUrlParams`.
72
+ *
73
+ * @param params url and action
74
+ */
75
+ export async function getPresignedUrlForZ3Url(
76
+ this: SDKResource,
77
+ params: { url: string; action: Z3GetPresignedUrlParams['action'] }
78
+ ): Promise<Z3GetPresignedUrlResponse> {
79
+ let bucket: string;
80
+ let key: string;
81
+ const url = new URL(params.url);
82
+ if (url.protocol === 'z3:') {
83
+ // remove leading forward slash
84
+ const z3PathParts = url.pathname.split('/').slice(1);
85
+ bucket = url.hostname;
86
+ key = z3PathParts.join('/');
87
+ } else if (url.href.startsWith(this.config.projectApiUrl ?? defaultProjectApiUrl)) {
88
+ // remove leading `/v1/z3`
89
+ const httpsPathParts = url.pathname.split('/').slice(3);
90
+ bucket = httpsPathParts[0];
91
+ key = httpsPathParts.slice(1).join('/');
92
+ } else {
93
+ throw new OystehrSdkError({ message: 'Invalid Z3 URL', code: 400 });
94
+ }
95
+ const requestParams: Z3GetPresignedUrlParams = {
96
+ action: 'upload',
97
+ bucketName: bucket,
98
+ 'objectPath+': key,
99
+ };
100
+ return this.request('/z3/{bucketName}/{objectPath+}', 'post')(requestParams);
101
+ }
@@ -20,8 +20,23 @@ export class Z3 extends SDKResource {
20
20
  constructor(config: OystehrConfig) {
21
21
  super(config);
22
22
  }
23
+ /**
24
+ * Uploads a file to the bucket and key. Files should be Blobs.
25
+ * @param params upload file params
26
+ */
23
27
  uploadFile = ext.uploadFile;
28
+ /**
29
+ * Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
30
+ * @param params download file params
31
+ */
24
32
  downloadFile = ext.downloadFile;
33
+ /**
34
+ * This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
35
+ * `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
36
+ * instead of the standard SDK `Z3GetPresignedUrlParams`.
37
+ * @param params url and action
38
+ */
39
+ getPresignedUrlForZ3Url = ext.getPresignedUrlForZ3Url;
25
40
  /**
26
41
  * List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
27
42
  *
@@ -0,0 +1,6 @@
1
+ // AUTOGENERATED -- DO NOT EDIT
2
+
3
+ export interface ErxMedicationSearchV2Params {
4
+ name?: string;
5
+ code?: string;
6
+ }
@@ -0,0 +1,40 @@
1
+ // AUTOGENERATED -- DO NOT EDIT
2
+
3
+ /**
4
+ * Medications
5
+ */
6
+ export interface ErxMedicationSearchV2Response {
7
+ medications?: {
8
+ /**
9
+ * Internal identifier for the medication.
10
+ */
11
+ id: string;
12
+ /**
13
+ * Human readible name of medication.
14
+ */
15
+ name: string;
16
+ codes: {
17
+ /**
18
+ * RxNorm Concept Unique (RxCUI) identifier of medication.
19
+ */
20
+ rxcui?: string | null;
21
+ productNDC?: string | null;
22
+ packageNDC?: string | null;
23
+ SKU?: string | null;
24
+ HCPCS?: string | null;
25
+ };
26
+ /**
27
+ * Null implies a medication can not be prescribed
28
+ */
29
+ type?: ('RX' | 'OTC') | null;
30
+ concept?: ('DRUG' | 'PRODUCT' | 'PACKAGE') | null;
31
+ schedule?: ('I' | 'II' | 'III' | 'IV' | 'V') | null;
32
+ controlled?: boolean | null;
33
+ brandName?: string | null;
34
+ genericName?: string | null;
35
+ strength?: string | null;
36
+ form?: string | null;
37
+ manufacturer?: string | null;
38
+ description?: string | null;
39
+ }[];
40
+ }
@@ -3,4 +3,5 @@
3
3
  export interface Z3ListObjectsParams {
4
4
  bucketName: string;
5
5
  'objectPath+': string;
6
+ direct?: boolean;
6
7
  }
@@ -99,6 +99,8 @@ export * from './ErxAllergySearchParams';
99
99
  export * from './ErxAllergySearchResponse';
100
100
  export * from './ErxMedicationSearchParams';
101
101
  export * from './ErxMedicationSearchResponse';
102
+ export * from './ErxMedicationSearchV2Params';
103
+ export * from './ErxMedicationSearchV2Response';
102
104
  export * from './RoleListResponse';
103
105
  export * from './RoleCreateParams';
104
106
  export * from './RoleCreateResponse';