@oystehr/sdk 3.0.0 → 3.0.1

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 (54) hide show
  1. package/dist/cjs/client/client.d.ts +2 -2
  2. package/dist/cjs/index.cjs +5 -3
  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/fhir-ext.d.ts +9 -33
  7. package/dist/cjs/resources/classes/index.d.ts +1 -0
  8. package/dist/cjs/resources/types/AccessPolicy.d.ts +1 -1
  9. package/dist/cjs/resources/types/ClaimCMS1500.d.ts +5 -5
  10. package/dist/cjs/resources/types/ConversationAddParticipantParams.d.ts +1 -1
  11. package/dist/cjs/resources/types/ErxMedicationSearchResponse.d.ts +3 -3
  12. package/dist/cjs/resources/types/Project.d.ts +1 -1
  13. package/dist/cjs/resources/types/VersionGetResponse.d.ts +2 -2
  14. package/dist/cjs/resources/types/Z3GetPresignedUrlParams.d.ts +1 -1
  15. package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +1 -1
  16. package/dist/cjs/resources/types/ZambdaFunction.d.ts +2 -2
  17. package/dist/cjs/resources/types/ZambdaUpdateParams.d.ts +2 -2
  18. package/dist/cjs/resources/types/fhir.d.ts +34 -1
  19. package/dist/esm/client/client.d.ts +2 -2
  20. package/dist/esm/client/client.js.map +1 -1
  21. package/dist/esm/index.min.js +1 -1
  22. package/dist/esm/index.min.js.map +1 -1
  23. package/dist/esm/resources/classes/fhir-ext.d.ts +9 -33
  24. package/dist/esm/resources/classes/fhir-ext.js +4 -3
  25. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  26. package/dist/esm/resources/classes/index.d.ts +1 -0
  27. package/dist/esm/resources/classes/index.js +1 -0
  28. package/dist/esm/resources/classes/index.js.map +1 -1
  29. package/dist/esm/resources/types/AccessPolicy.d.ts +1 -1
  30. package/dist/esm/resources/types/ClaimCMS1500.d.ts +5 -5
  31. package/dist/esm/resources/types/ConversationAddParticipantParams.d.ts +1 -1
  32. package/dist/esm/resources/types/ErxMedicationSearchResponse.d.ts +3 -3
  33. package/dist/esm/resources/types/Project.d.ts +1 -1
  34. package/dist/esm/resources/types/VersionGetResponse.d.ts +2 -2
  35. package/dist/esm/resources/types/Z3GetPresignedUrlParams.d.ts +1 -1
  36. package/dist/esm/resources/types/ZambdaCreateParams.d.ts +1 -1
  37. package/dist/esm/resources/types/ZambdaFunction.d.ts +2 -2
  38. package/dist/esm/resources/types/ZambdaUpdateParams.d.ts +2 -2
  39. package/dist/esm/resources/types/fhir.d.ts +34 -1
  40. package/package.json +1 -1
  41. package/src/client/client.ts +2 -2
  42. package/src/resources/classes/fhir-ext.ts +28 -12
  43. package/src/resources/classes/index.ts +2 -0
  44. package/src/resources/types/AccessPolicy.ts +1 -1
  45. package/src/resources/types/ClaimCMS1500.ts +12 -5
  46. package/src/resources/types/ConversationAddParticipantParams.ts +1 -1
  47. package/src/resources/types/ErxMedicationSearchResponse.ts +3 -3
  48. package/src/resources/types/Project.ts +1 -1
  49. package/src/resources/types/VersionGetResponse.ts +2 -2
  50. package/src/resources/types/Z3GetPresignedUrlParams.ts +1 -1
  51. package/src/resources/types/ZambdaCreateParams.ts +1 -1
  52. package/src/resources/types/ZambdaFunction.ts +2 -2
  53. package/src/resources/types/ZambdaUpdateParams.ts +2 -2
  54. package/src/resources/types/fhir.ts +56 -2
@@ -1,5 +1,4 @@
1
- import { Operation } from 'fast-json-patch';
2
- import { BatchInput, Bundle, FhirResource } from '../..';
1
+ import { BatchInput, Bundle, FhirCreateParams, FhirDeleteParams, FhirGetParams, FhirHistoryGetParams, FhirHistorySearchParams, FhirPatchParams, FhirResource, FhirSearchParams, FhirUpdateParams } from '../..';
3
2
  import { FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';
4
3
  /**
5
4
  * Optional parameter that can be passed to the client methods. It allows
@@ -22,37 +21,14 @@ export interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {
22
21
  * @param request optional OystehrClientRequest object
23
22
  * @returns FHIR Bundle resource
24
23
  */
25
- export declare function search<T extends FhirResource>(this: SDKResource, { resourceType, params }: {
26
- resourceType: string;
27
- params?: {
28
- name: string;
29
- value: string | number;
30
- }[];
31
- }, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
32
- export declare function create<T extends FhirResource>(this: SDKResource, params: T, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
33
- export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: {
34
- resourceType: string;
35
- id: string;
36
- }, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
37
- export declare function update<T extends FhirResource>(this: SDKResource, params: T, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<T>>;
38
- export declare function patch<T extends FhirResource>(this: SDKResource, { resourceType, id, operations }: {
39
- resourceType: string;
40
- id: string;
41
- operations: Operation[];
42
- }, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<T>>;
43
- declare function del<T extends FhirResource>(this: SDKResource, { resourceType, id }: {
44
- resourceType: string;
45
- id: string;
46
- }, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
24
+ export declare function search<T extends FhirResource>(this: SDKResource, params: FhirSearchParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
25
+ export declare function create<T extends FhirResource>(this: SDKResource, params: FhirCreateParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
26
+ export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirGetParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
27
+ export declare function update<T extends FhirResource>(this: SDKResource, params: FhirUpdateParams<T>, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<T>>;
28
+ export declare function patch<T extends FhirResource>(this: SDKResource, { resourceType, id, operations }: FhirPatchParams, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<T>>;
29
+ declare function del<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirDeleteParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
47
30
  export { del as delete };
48
- export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id }: {
49
- resourceType: string;
50
- id: string;
51
- }, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
52
- export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, versionId }: {
53
- resourceType: string;
54
- id: string;
55
- versionId: string;
56
- }, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
31
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirHistorySearchParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
32
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, versionId }: FhirHistoryGetParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
57
33
  export declare const batch: <BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest) => Promise<Bundle<BundleContentType>>;
58
34
  export declare const transaction: <BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest) => Promise<Bundle<BundleContentType>>;
@@ -8,11 +8,12 @@ import { addParamsToSearch } from '../../client/client.js';
8
8
  * @param request optional OystehrClientRequest object
9
9
  * @returns FHIR Bundle resource
10
10
  */
11
- function search({ resourceType, params }, request) {
11
+ function search(params, request) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
+ const { resourceType, params: searchParams } = params;
13
14
  let paramMap;
14
- if (params) {
15
- paramMap = Object.entries(params).reduce((acc, [_, param]) => {
15
+ if (searchParams) {
16
+ paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {
16
17
  if (!acc[param.name]) {
17
18
  acc[param.name] = [];
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import { Operation } from 'fast-json-patch';\nimport { BatchInput, BatchInputRequest, Binary, Bundle, BundleEntry, FhirBundle, FhirResource } from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n { resourceType, params }: { resourceType: string; params?: { name: string; value: string | number }[] },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (params) {\n paramMap = Object.entries(params).reduce((acc, [_, param]) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n unbundle: function (this: Bundle<T>) {\n return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: T,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { resourceType } = params;\n return this.fhirRequest(`/${resourceType}`, 'POST')(params as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: { resourceType: string; id: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: T,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { id, resourceType } = params;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(params as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: { resourceType: string; id: string; operations: Operation[] },\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: { resourceType: string; id: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: { resourceType: string; id: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: { resourceType: string; id: string; versionId: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: { resourceType: string; id: string; versionId?: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}/_history${versionId ? `/${versionId}` : ''}`, 'GET')({}, request);\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>\n): BundleEntry<T | Binary<T>> {\n const { method, url } = request;\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n acc[name] = value;\n return acc;\n }, {} as Record<string, string>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const { resource } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n return {\n ...baseRequest,\n resource: request.resource,\n } as BundleEntry<Binary<T>>;\n }\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data: Buffer.from(JSON.stringify(request.operations), 'utf8').toString('base64'),\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST creates require a full resource\n if (method === 'POST') {\n const { resource, fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n throw new Error('Unrecognized method');\n}\n\nfunction bundleRequest(type: 'batch' | 'transaction') {\n return async function <BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n ): Promise<FhirFetcherResponse<Bundle<BundleContentType>>> {\n return this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type,\n entry: input.requests.map(batchInputRequestToBundleEntryItem),\n },\n request\n );\n };\n}\n\nexport const batch = bundleRequest('batch');\nexport const transaction = bundleRequest('transaction');\n"],"names":[],"mappings":";;;AAmBA;;;;;;AAMG;AACG,SAAgB,MAAM,CAE1B,EAAE,YAAY,EAAE,MAAM,EAAiF,EACvG,OAA8B,EAAA;;AAE9B,QAAA,IAAI,QAAyD,CAAC;AAC9D,QAAA,IAAI,MAAM,EAAE;AACV,YAAA,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,KAAI;AAC3D,gBAAA,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AACpB,oBAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AACtB,iBAAA;AACD,gBAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClC,gBAAA,OAAO,GAAG,CAAC;aACZ,EAAE,EAAyC,CAAC,CAAC;AAC/C,SAAA;QACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,WAAW,CAAgB,CAAI,CAAA,EAAA,YAAY,CAAU,QAAA,CAAA,EAAE,MAAM,CAAC,CAAC,QAAQ,EACnG,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,KACV,WAAW,EAAE,mCAAmC,EAAA,CAAA,CAChD,CAAC;AACH,QAAA,MAAM,MAAM,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACP,aAAa,CAAA,EAAA,EAChB,QAAQ,EAAE,YAAA;;AACR,gBAAA,OAAO,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,IAAI,CAAC,KAAK,MAAA,IAAA,IAAA,E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C,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAClC;AACE,gBAAA,YAAY,EAAE,QAAQ;gBACtB,IAAI;gBACJ,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,kCAAkC,CAAC;aAC9D,EACD,OAAO,CACR,CAAC;SACH,CAAA,CAAA;KAAA,CAAC;AACJ,CAAC;MAEY,KAAK,GAAG,aAAa,CAAC,OAAO,EAAE;MAC/B,WAAW,GAAG,aAAa,CAAC,aAAa;;;;"}
1
+ {"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import {\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirSearchParams,\n FhirUpdateParams,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n const { resourceType, params: searchParams } = params;\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (searchParams) {\n paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n unbundle: function (this: Bundle<T>) {\n return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { resourceType } = params;\n return this.fhirRequest(`/${resourceType}`, 'POST')(params as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n const { id, resourceType } = params;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(params as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: { resourceType: string; id: string; versionId?: string },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n return this.fhirRequest(`/${resourceType}/${id}/_history${versionId ? `/${versionId}` : ''}`, 'GET')({}, request);\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>\n): BundleEntry<T | Binary<T>> {\n const { method, url } = request;\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n acc[name] = value;\n return acc;\n }, {} as Record<string, string>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const { resource } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n return {\n ...baseRequest,\n resource: request.resource,\n } as BundleEntry<Binary<T>>;\n }\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data: Buffer.from(JSON.stringify(request.operations), 'utf8').toString('base64'),\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST creates require a full resource\n if (method === 'POST') {\n const { resource, fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n throw new Error('Unrecognized method');\n}\n\nfunction bundleRequest(type: 'batch' | 'transaction') {\n return async function <BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n ): Promise<FhirFetcherResponse<Bundle<BundleContentType>>> {\n return this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type,\n entry: input.requests.map(batchInputRequestToBundleEntryItem),\n },\n request\n );\n };\n}\n\nexport const batch = bundleRequest('batch');\nexport const transaction = bundleRequest('transaction');\n"],"names":[],"mappings":";;;AAkCA;;;;;;AAMG;AACmB,SAAA,MAAM,CAE1B,MAAwB,EACxB,OAA8B,EAAA;;QAE9B,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;AACtD,QAAA,IAAI,QAAyD,CAAC;AAC9D,QAAA,IAAI,YAAY,EAAE;AAChB,YAAA,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,KAAI;AACjE,gBAAA,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AACpB,oBAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AACtB,iBAAA;AACD,gBAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClC,gBAAA,OAAO,GAAG,CAAC;aACZ,EAAE,EAAyC,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,QAAQ,CAAC,QAAQ,CAAC;AACjF,aAAA,EAAA,CACwB,CAAC;AAC7B,KAAA;;IAGD,IAAI,MAAM,KAAK,MAAM,EAAE;AACrB,QAAA,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QACtC,OAAO,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACF,WAAW,CACd,EAAA,EAAA,QAAQ,EAAE,QAAa,EACvB,OAAO,EAAA,CACU,CAAC;AACrB,KAAA;AACD,IAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,aAAa,CAAC,IAA6B,EAAA;IAClD,OAAO,UAEL,KAAoC,EACpC,OAA8B,EAAA;;YAE9B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAClC;AACE,gBAAA,YAAY,EAAE,QAAQ;gBACtB,IAAI;gBACJ,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,kCAAkC,CAAC;aAC9D,EACD,OAAO,CACR,CAAC;SACH,CAAA,CAAA;KAAA,CAAC;AACJ,CAAC;MAEY,KAAK,GAAG,aAAa,CAAC,OAAO,EAAE;MAC/B,WAAW,GAAG,aAAa,CAAC,aAAa;;;;"}
@@ -20,6 +20,7 @@ import { Z3 } from './z3';
20
20
  import { Zambda } from './zambda';
21
21
  import { ZambdaLogStream } from './zambdaLogStream';
22
22
  export declare class Oystehr {
23
+ readonly config: OystehrConfig;
23
24
  readonly application: Application;
24
25
  readonly developer: Developer;
25
26
  readonly m2m: M2m;
@@ -22,6 +22,7 @@ import { ZambdaLogStream } from './zambdaLogStream.js';
22
22
  // AUTOGENERATED -- DO NOT EDIT
23
23
  let Oystehr$1 = class Oystehr {
24
24
  constructor(config) {
25
+ this.config = config;
25
26
  this.application = new Application(config);
26
27
  this.developer = new Developer(config);
27
28
  this.m2m = new M2m(config);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/resources/classes/index.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { OystehrConfig } from '../../config';\nimport { Application } from './application';\nimport { Charge } from './charge';\nimport { Conversation } from './conversation';\nimport { Developer } from './developer';\nimport { Erx } from './erx';\nimport { Fhir } from './fhir';\nimport { M2m } from './m2m';\nimport { Messaging } from './messaging';\nimport { PaymentMethod } from './paymentMethod';\nimport { Project } from './project';\nimport { Rcm } from './rcm';\nimport { Role } from './role';\nimport { Secret } from './secret';\nimport { Telemed } from './telemed';\nimport { TransactionalSMS } from './transactionalSMS';\nimport { User } from './user';\nimport { Version } from './version';\nimport { Z3 } from './z3';\nimport { Zambda } from './zambda';\nimport { ZambdaLogStream } from './zambdaLogStream';\n\nexport class Oystehr {\n readonly application: Application;\n readonly developer: Developer;\n readonly m2m: M2m;\n readonly messaging: Messaging;\n readonly conversation: Conversation;\n readonly transactionalSMS: TransactionalSMS;\n readonly paymentMethod: PaymentMethod;\n readonly charge: Charge;\n readonly project: Project;\n readonly rcm: Rcm;\n readonly erx: Erx;\n readonly role: Role;\n readonly secret: Secret;\n readonly telemed: Telemed;\n readonly user: User;\n readonly version: Version;\n readonly z3: Z3;\n readonly zambda: Zambda;\n readonly zambdaLogStream: ZambdaLogStream;\n readonly fhir: Fhir;\n constructor(config: OystehrConfig) {\n this.application = new Application(config);\n this.developer = new Developer(config);\n this.m2m = new M2m(config);\n this.messaging = new Messaging(config);\n this.conversation = new Conversation(config);\n this.transactionalSMS = new TransactionalSMS(config);\n this.paymentMethod = new PaymentMethod(config);\n this.charge = new Charge(config);\n this.project = new Project(config);\n this.rcm = new Rcm(config);\n this.erx = new Erx(config);\n this.role = new Role(config);\n this.secret = new Secret(config);\n this.telemed = new Telemed(config);\n this.user = new User(config);\n this.version = new Version(config);\n this.z3 = new Z3(config);\n this.zambda = new Zambda(config);\n this.zambdaLogStream = new ZambdaLogStream(config);\n this.fhir = new Fhir(config);\n }\n}\n"],"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AAC,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;KAC9B;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/resources/classes/index.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { OystehrConfig } from '../../config';\nimport { Application } from './application';\nimport { Charge } from './charge';\nimport { Conversation } from './conversation';\nimport { Developer } from './developer';\nimport { Erx } from './erx';\nimport { Fhir } from './fhir';\nimport { M2m } from './m2m';\nimport { Messaging } from './messaging';\nimport { PaymentMethod } from './paymentMethod';\nimport { Project } from './project';\nimport { Rcm } from './rcm';\nimport { Role } from './role';\nimport { Secret } from './secret';\nimport { Telemed } from './telemed';\nimport { TransactionalSMS } from './transactionalSMS';\nimport { User } from './user';\nimport { Version } from './version';\nimport { Z3 } from './z3';\nimport { Zambda } from './zambda';\nimport { ZambdaLogStream } from './zambdaLogStream';\n\nexport class Oystehr {\n readonly config: OystehrConfig;\n readonly application: Application;\n readonly developer: Developer;\n readonly m2m: M2m;\n readonly messaging: Messaging;\n readonly conversation: Conversation;\n readonly transactionalSMS: TransactionalSMS;\n readonly paymentMethod: PaymentMethod;\n readonly charge: Charge;\n readonly project: Project;\n readonly rcm: Rcm;\n readonly erx: Erx;\n readonly role: Role;\n readonly secret: Secret;\n readonly telemed: Telemed;\n readonly user: User;\n readonly version: Version;\n readonly z3: Z3;\n readonly zambda: Zambda;\n readonly zambdaLogStream: ZambdaLogStream;\n readonly fhir: Fhir;\n constructor(config: OystehrConfig) {\n this.config = config;\n this.application = new Application(config);\n this.developer = new Developer(config);\n this.m2m = new M2m(config);\n this.messaging = new Messaging(config);\n this.conversation = new Conversation(config);\n this.transactionalSMS = new TransactionalSMS(config);\n this.paymentMethod = new PaymentMethod(config);\n this.charge = new Charge(config);\n this.project = new Project(config);\n this.rcm = new Rcm(config);\n this.erx = new Erx(config);\n this.role = new Role(config);\n this.secret = new Secret(config);\n this.telemed = new Telemed(config);\n this.user = new User(config);\n this.version = new Version(config);\n this.z3 = new Z3(config);\n this.zambda = new Zambda(config);\n this.zambdaLogStream = new ZambdaLogStream(config);\n this.fhir = new Fhir(config);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;sBAwBa,OAAO,CAAA;AAsBlB,IAAA,WAAA,CAAY,MAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;KAC9B;AACF;;;;"}
@@ -2,6 +2,6 @@ export interface AccessPolicy {
2
2
  rule: {
3
3
  resource?: string[];
4
4
  action?: string[];
5
- effect?: string;
5
+ effect?: 'Allow' | 'Deny';
6
6
  }[];
7
7
  }
@@ -5,14 +5,14 @@ import { ClaimDateWithQualifier } from './ClaimDateWithQualifier';
5
5
  import { ClaimId } from './ClaimId';
6
6
  import { ClaimName } from './ClaimName';
7
7
  export interface ClaimCMS1500 {
8
- _1_insuranceProgram: string;
8
+ _1_insuranceProgram: 'MEDICARE' | 'MEDICAID' | 'TRICARE' | 'CHAMPVA' | 'GROUP_HEALTH_PLAN' | 'FECA_BLK_LUNG' | 'OTHER';
9
9
  _1a_insuredIdNumber: string;
10
10
  _2_patientName: ClaimName;
11
11
  _3_patientBirthDate: ClaimDate;
12
- _3_patientSex: string;
12
+ _3_patientSex: 'M' | 'F';
13
13
  _4_insuredName?: ClaimName;
14
14
  _5_patientAddress: ClaimAddress;
15
- _6_patientRelationshipToInsured?: string;
15
+ _6_patientRelationshipToInsured?: 'Self' | 'Spouse' | 'Child' | 'Other';
16
16
  _7_insuredAddress?: ClaimAddress;
17
17
  _9_otherInsuredName?: ClaimName;
18
18
  _9a_otherInsuredPolicyOrGroupNumber?: string;
@@ -26,7 +26,7 @@ export interface ClaimCMS1500 {
26
26
  _10d_claimCodes?: string[];
27
27
  _11_insuredPolicyGroupOrFecaNumber?: string;
28
28
  _11a_insuredDateOfBirth?: ClaimDate;
29
- _11a_insuredSex?: string;
29
+ _11a_insuredSex?: 'M' | 'F';
30
30
  _11b_otherClaimId?: string;
31
31
  _11c_insurancePlanNameOrProgramName?: string;
32
32
  _11d_anotherHealthBenefitPlan: boolean;
@@ -78,7 +78,7 @@ export interface ClaimCMS1500 {
78
78
  }[];
79
79
  _25_federalTaxIdNumber: {
80
80
  value: string;
81
- type: string;
81
+ type: 'SSN' | 'EIN';
82
82
  };
83
83
  _26_patientAccountNumber?: string;
84
84
  _27_acceptAssignment?: boolean;
@@ -11,7 +11,7 @@ export interface ConversationAddParticipantParams {
11
11
  /**
12
12
  * The channel to use to communicate with the participant. The `chat` channel allows the Developer or User whose `profile` resource is in `participantReference` to join the Conversation via the Twilio Conversations SDK which enables web and native mobile chat. If channel is `sms` then `phoneNumber` must be supplied. The participant's phone number, specified in the `phoneNumber`, is added to the Conversation. They will receive SMS messages from the Conversation, and replies to the phone number from which they receive the messages will be sent to the Conversation.
13
13
  */
14
- channel: string;
14
+ channel: 'sms' | 'chat';
15
15
  /**
16
16
  * The phone number of the participant. Required if `channel` is `sms`.
17
17
  */
@@ -24,9 +24,9 @@ export interface ErxMedicationSearchResponse {
24
24
  /**
25
25
  * Null implies a medication can not be prescribed
26
26
  */
27
- type?: string | null;
28
- concept: string;
29
- schedule?: string | null;
27
+ type?: ('RX' | 'OTC') | null;
28
+ concept: 'DRUG' | 'PRODUCT' | 'PACKAGE';
29
+ schedule?: ('I' | 'II' | 'III' | 'IV' | 'V') | null;
30
30
  controlled: boolean;
31
31
  brandName?: string | null;
32
32
  genericName?: string | null;
@@ -13,5 +13,5 @@ export interface Project {
13
13
  sandbox: boolean;
14
14
  defaultPatientRole?: RoleStub;
15
15
  defaultSSOUserRole?: RoleStub;
16
- fhirVersion: string;
16
+ fhirVersion: 'r4' | 'r5';
17
17
  }
@@ -5,7 +5,7 @@ export interface VersionGetResponse {
5
5
  /**
6
6
  * Always "project"
7
7
  */
8
- api: string;
8
+ api: 'project';
9
9
  /**
10
10
  * The project API version
11
11
  */
@@ -13,5 +13,5 @@ export interface VersionGetResponse {
13
13
  /**
14
14
  * Always "production"
15
15
  */
16
- environment: string;
16
+ environment: 'production';
17
17
  }
@@ -1,5 +1,5 @@
1
1
  export interface Z3GetPresignedUrlParams {
2
- action: string;
2
+ action: 'upload' | 'download';
3
3
  /**
4
4
  * An optional parameter that determines which type of S3 object should be created.
5
5
  */
@@ -7,6 +7,6 @@ export interface ZambdaCreateParams {
7
7
  /**
8
8
  * The trigger method for the Zambda Function determines how the Function is invoked. Learn more about the different types here, https://docs.oystehr.com/services/zambda/#types-of-zambdas.
9
9
  */
10
- triggerMethod: string;
10
+ triggerMethod: 'http_auth' | 'http_open' | 'subscription' | 'cron';
11
11
  schedule?: ZambdaSchedule;
12
12
  }
@@ -12,11 +12,11 @@ export interface ZambdaFunction {
12
12
  /**
13
13
  * The Zambda Function status provides information about the Functions state including whether it is ready to be invoked.
14
14
  */
15
- status: string;
15
+ status: 'Draft' | 'Pending' | 'Active' | 'Failed' | 'Inactive' | 'Validating';
16
16
  /**
17
17
  * The trigger method for the Zambda Function determines how the Function is invoked. Learn more about the different types here, https://docs.oystehr.com/services/zambda/#types-of-zambdas.
18
18
  */
19
- triggerMethod: string;
19
+ triggerMethod: 'http_auth' | 'http_open' | 'subscription' | 'cron';
20
20
  schedule?: ZambdaSchedule;
21
21
  /**
22
22
  * Info about the zip file that was uploaded for the Zambda Function.
@@ -7,11 +7,11 @@ export interface ZambdaUpdateParams {
7
7
  /**
8
8
  * The trigger method for the Zambda Function determines how the Function is invoked. Learn more about the different types here, https://docs.oystehr.com/services/zambda/#types-of-zambdas.
9
9
  */
10
- triggerMethod?: string;
10
+ triggerMethod?: 'http_auth' | 'http_open' | 'subscription' | 'cron';
11
11
  schedule?: ZambdaSchedule;
12
12
  /**
13
13
  * The runtime to use for the Zambda Function. This property is optional and defaults to "nodejs20.x".
14
14
  */
15
- runtime?: string;
15
+ runtime?: 'nodejs18.x' | 'nodejs20.x';
16
16
  id: string;
17
17
  }
@@ -2,13 +2,46 @@ import type { Operation } from 'fast-json-patch';
2
2
  import type { Binary as BinaryR4B, Bundle as BundleR4B, BundleEntry as BundleEntryR4B, FhirResource as FhirResourceR4B, OperationOutcome as OperationOutcomeR4B } from 'fhir/r4b';
3
3
  import type { Binary as BinaryR5, Bundle as BundleR5, BundleEntry as BundleEntryR5, FhirResource as FhirResourceR5, OperationOutcome as OperationOutcomeR5 } from 'fhir/r5';
4
4
  export type FhirResource = FhirResourceR4B | FhirResourceR5;
5
- export type FhirBundle<F extends FhirResource> = F extends FhirResourceR4B ? BundleR4B<F> : BundleR5<F>;
5
+ export type FhirBundle<F extends FhirResource> = F extends FhirResourceR4B ? Omit<BundleR4B<F>, 'entry'> : Omit<BundleR5<F>, 'entry'>;
6
6
  export type Bundle<F extends FhirResource> = FhirBundle<F> & {
7
+ entry?: Array<BundleEntry<F>> | undefined;
7
8
  unbundle: (this: Bundle<F>) => F[];
8
9
  };
9
10
  export type BundleEntry<F extends FhirResource> = F extends FhirResourceR4B ? BundleEntryR4B<F> : BundleEntryR5<F>;
10
11
  export type Binary<F extends FhirResource> = F extends FhirResourceR4B ? BinaryR4B : BinaryR5;
11
12
  export type OperationOutcome = OperationOutcomeR4B | OperationOutcomeR5;
13
+ export type SearchParam = {
14
+ name: string;
15
+ value: string | number;
16
+ };
17
+ export interface FhirSearchParams {
18
+ resourceType: string;
19
+ params?: SearchParam[];
20
+ }
21
+ export interface FhirGetParams {
22
+ resourceType: string;
23
+ id: string;
24
+ }
25
+ export type FhirCreateParams<T extends FhirResource> = T;
26
+ export type FhirUpdateParams<T extends FhirResource> = T;
27
+ export interface FhirPatchParams {
28
+ resourceType: string;
29
+ id: string;
30
+ operations: Operation[];
31
+ }
32
+ export interface FhirDeleteParams {
33
+ resourceType: string;
34
+ id: string;
35
+ }
36
+ export interface FhirHistorySearchParams {
37
+ resourceType: string;
38
+ id: string;
39
+ }
40
+ export interface FhirHistoryGetParams {
41
+ resourceType: string;
42
+ id: string;
43
+ versionId: string;
44
+ }
12
45
  interface BatchInputBaseRequest {
13
46
  url: string;
14
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oystehr/sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Oystehr SDK",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -55,7 +55,7 @@ export class SDKResource {
55
55
  this.config = config;
56
56
  }
57
57
 
58
- request(path: string, method: string): FetcherFunction {
58
+ protected request(path: string, method: string): FetcherFunction {
59
59
  return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {
60
60
  const baseUrlThunk = (): string => this.config.projectApiUrl ?? defaultProjectApiUrl;
61
61
  const configThunk = (): OystehrConfig => this.config;
@@ -68,7 +68,7 @@ export class SDKResource {
68
68
  };
69
69
  }
70
70
 
71
- fhirRequest<T extends FhirResource = any>(path: string, method: string) {
71
+ protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {
72
72
  return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {
73
73
  try {
74
74
  const baseUrlThunk = (): string => this.config.fhirApiUrl ?? defaultFhirApiUrl;
@@ -1,5 +1,20 @@
1
- import { Operation } from 'fast-json-patch';
2
- import { BatchInput, BatchInputRequest, Binary, Bundle, BundleEntry, FhirBundle, FhirResource } from '../..';
1
+ import {
2
+ BatchInput,
3
+ BatchInputRequest,
4
+ Binary,
5
+ Bundle,
6
+ BundleEntry,
7
+ FhirBundle,
8
+ FhirCreateParams,
9
+ FhirDeleteParams,
10
+ FhirGetParams,
11
+ FhirHistoryGetParams,
12
+ FhirHistorySearchParams,
13
+ FhirPatchParams,
14
+ FhirResource,
15
+ FhirSearchParams,
16
+ FhirUpdateParams,
17
+ } from '../..';
3
18
  import { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';
4
19
 
5
20
  /**
@@ -26,12 +41,13 @@ export interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {
26
41
  */
27
42
  export async function search<T extends FhirResource>(
28
43
  this: SDKResource,
29
- { resourceType, params }: { resourceType: string; params?: { name: string; value: string | number }[] },
44
+ params: FhirSearchParams,
30
45
  request?: OystehrClientRequest
31
46
  ): Promise<FhirFetcherResponse<Bundle<T>>> {
47
+ const { resourceType, params: searchParams } = params;
32
48
  let paramMap: Record<string, (string | number)[]> | undefined;
33
- if (params) {
34
- paramMap = Object.entries(params).reduce((acc, [_, param]) => {
49
+ if (searchParams) {
50
+ paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {
35
51
  if (!acc[param.name]) {
36
52
  acc[param.name] = [];
37
53
  }
@@ -54,7 +70,7 @@ export async function search<T extends FhirResource>(
54
70
 
55
71
  export async function create<T extends FhirResource>(
56
72
  this: SDKResource,
57
- params: T,
73
+ params: FhirCreateParams<T>,
58
74
  request?: OystehrClientRequest
59
75
  ): Promise<FhirFetcherResponse<T>> {
60
76
  const { resourceType } = params;
@@ -63,7 +79,7 @@ export async function create<T extends FhirResource>(
63
79
 
64
80
  export async function get<T extends FhirResource>(
65
81
  this: SDKResource,
66
- { resourceType, id }: { resourceType: string; id: string },
82
+ { resourceType, id }: FhirGetParams,
67
83
  request?: OystehrClientRequest
68
84
  ): Promise<FhirFetcherResponse<T>> {
69
85
  return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);
@@ -71,7 +87,7 @@ export async function get<T extends FhirResource>(
71
87
 
72
88
  export async function update<T extends FhirResource>(
73
89
  this: SDKResource,
74
- params: T,
90
+ params: FhirUpdateParams<T>,
75
91
  request?: OystehrFHIRUpdateClientRequest
76
92
  ): Promise<FhirFetcherResponse<T>> {
77
93
  const { id, resourceType } = params;
@@ -83,7 +99,7 @@ export async function update<T extends FhirResource>(
83
99
 
84
100
  export async function patch<T extends FhirResource>(
85
101
  this: SDKResource,
86
- { resourceType, id, operations }: { resourceType: string; id: string; operations: Operation[] },
102
+ { resourceType, id, operations }: FhirPatchParams,
87
103
  request?: OystehrFHIRUpdateClientRequest
88
104
  ): Promise<FhirFetcherResponse<T>> {
89
105
  return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {
@@ -95,7 +111,7 @@ export async function patch<T extends FhirResource>(
95
111
 
96
112
  async function del<T extends FhirResource>(
97
113
  this: SDKResource,
98
- { resourceType, id }: { resourceType: string; id: string },
114
+ { resourceType, id }: FhirDeleteParams,
99
115
  request?: OystehrClientRequest
100
116
  ): Promise<FhirFetcherResponse<T>> {
101
117
  return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);
@@ -104,12 +120,12 @@ export { del as delete };
104
120
 
105
121
  export async function history<T extends FhirResource>(
106
122
  this: SDKResource,
107
- { resourceType, id }: { resourceType: string; id: string },
123
+ { resourceType, id }: FhirHistorySearchParams,
108
124
  request?: OystehrClientRequest
109
125
  ): Promise<FhirFetcherResponse<Bundle<T>>>;
110
126
  export async function history<T extends FhirResource>(
111
127
  this: SDKResource,
112
- { resourceType, id, versionId }: { resourceType: string; id: string; versionId: string },
128
+ { resourceType, id, versionId }: FhirHistoryGetParams,
113
129
  request?: OystehrClientRequest
114
130
  ): Promise<FhirFetcherResponse<T>>;
115
131
  export async function history<T extends FhirResource>(
@@ -23,6 +23,7 @@ import { Zambda } from './zambda';
23
23
  import { ZambdaLogStream } from './zambdaLogStream';
24
24
 
25
25
  export class Oystehr {
26
+ readonly config: OystehrConfig;
26
27
  readonly application: Application;
27
28
  readonly developer: Developer;
28
29
  readonly m2m: M2m;
@@ -44,6 +45,7 @@ export class Oystehr {
44
45
  readonly zambdaLogStream: ZambdaLogStream;
45
46
  readonly fhir: Fhir;
46
47
  constructor(config: OystehrConfig) {
48
+ this.config = config;
47
49
  this.application = new Application(config);
48
50
  this.developer = new Developer(config);
49
51
  this.m2m = new M2m(config);
@@ -4,6 +4,6 @@ export interface AccessPolicy {
4
4
  rule: {
5
5
  resource?: string[];
6
6
  action?: string[];
7
- effect?: string;
7
+ effect?: 'Allow' | 'Deny';
8
8
  }[];
9
9
  }
@@ -8,14 +8,21 @@ import { ClaimId } from './ClaimId';
8
8
  import { ClaimName } from './ClaimName';
9
9
 
10
10
  export interface ClaimCMS1500 {
11
- _1_insuranceProgram: string;
11
+ _1_insuranceProgram:
12
+ | 'MEDICARE'
13
+ | 'MEDICAID'
14
+ | 'TRICARE'
15
+ | 'CHAMPVA'
16
+ | 'GROUP_HEALTH_PLAN'
17
+ | 'FECA_BLK_LUNG'
18
+ | 'OTHER';
12
19
  _1a_insuredIdNumber: string;
13
20
  _2_patientName: ClaimName;
14
21
  _3_patientBirthDate: ClaimDate;
15
- _3_patientSex: string;
22
+ _3_patientSex: 'M' | 'F';
16
23
  _4_insuredName?: ClaimName;
17
24
  _5_patientAddress: ClaimAddress;
18
- _6_patientRelationshipToInsured?: string;
25
+ _6_patientRelationshipToInsured?: 'Self' | 'Spouse' | 'Child' | 'Other';
19
26
  _7_insuredAddress?: ClaimAddress;
20
27
  _9_otherInsuredName?: ClaimName;
21
28
  _9a_otherInsuredPolicyOrGroupNumber?: string;
@@ -29,7 +36,7 @@ export interface ClaimCMS1500 {
29
36
  _10d_claimCodes?: string[];
30
37
  _11_insuredPolicyGroupOrFecaNumber?: string;
31
38
  _11a_insuredDateOfBirth?: ClaimDate;
32
- _11a_insuredSex?: string;
39
+ _11a_insuredSex?: 'M' | 'F';
33
40
  _11b_otherClaimId?: string;
34
41
  _11c_insurancePlanNameOrProgramName?: string;
35
42
  _11d_anotherHealthBenefitPlan: boolean;
@@ -81,7 +88,7 @@ export interface ClaimCMS1500 {
81
88
  }[];
82
89
  _25_federalTaxIdNumber: {
83
90
  value: string;
84
- type: string;
91
+ type: 'SSN' | 'EIN';
85
92
  };
86
93
  _26_patientAccountNumber?: string;
87
94
  _27_acceptAssignment?: boolean;
@@ -13,7 +13,7 @@ export interface ConversationAddParticipantParams {
13
13
  /**
14
14
  * The channel to use to communicate with the participant. The `chat` channel allows the Developer or User whose `profile` resource is in `participantReference` to join the Conversation via the Twilio Conversations SDK which enables web and native mobile chat. If channel is `sms` then `phoneNumber` must be supplied. The participant's phone number, specified in the `phoneNumber`, is added to the Conversation. They will receive SMS messages from the Conversation, and replies to the phone number from which they receive the messages will be sent to the Conversation.
15
15
  */
16
- channel: string;
16
+ channel: 'sms' | 'chat';
17
17
  /**
18
18
  * The phone number of the participant. Required if `channel` is `sms`.
19
19
  */
@@ -26,9 +26,9 @@ export interface ErxMedicationSearchResponse {
26
26
  /**
27
27
  * Null implies a medication can not be prescribed
28
28
  */
29
- type?: string | null;
30
- concept: string;
31
- schedule?: string | null;
29
+ type?: ('RX' | 'OTC') | null;
30
+ concept: 'DRUG' | 'PRODUCT' | 'PACKAGE';
31
+ schedule?: ('I' | 'II' | 'III' | 'IV' | 'V') | null;
32
32
  controlled: boolean;
33
33
  brandName?: string | null;
34
34
  genericName?: string | null;
@@ -16,5 +16,5 @@ export interface Project {
16
16
  sandbox: boolean;
17
17
  defaultPatientRole?: RoleStub;
18
18
  defaultSSOUserRole?: RoleStub;
19
- fhirVersion: string;
19
+ fhirVersion: 'r4' | 'r5';
20
20
  }
@@ -7,7 +7,7 @@ export interface VersionGetResponse {
7
7
  /**
8
8
  * Always "project"
9
9
  */
10
- api: string;
10
+ api: 'project';
11
11
  /**
12
12
  * The project API version
13
13
  */
@@ -15,5 +15,5 @@ export interface VersionGetResponse {
15
15
  /**
16
16
  * Always "production"
17
17
  */
18
- environment: string;
18
+ environment: 'production';
19
19
  }
@@ -1,7 +1,7 @@
1
1
  // AUTOGENERATED -- DO NOT EDIT
2
2
 
3
3
  export interface Z3GetPresignedUrlParams {
4
- action: string;
4
+ action: 'upload' | 'download';
5
5
  /**
6
6
  * An optional parameter that determines which type of S3 object should be created.
7
7
  */
@@ -10,6 +10,6 @@ export interface ZambdaCreateParams {
10
10
  /**
11
11
  * The trigger method for the Zambda Function determines how the Function is invoked. Learn more about the different types here, https://docs.oystehr.com/services/zambda/#types-of-zambdas.
12
12
  */
13
- triggerMethod: string;
13
+ triggerMethod: 'http_auth' | 'http_open' | 'subscription' | 'cron';
14
14
  schedule?: ZambdaSchedule;
15
15
  }