@oystehr/sdk 3.0.0 → 3.0.2

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 (68) hide show
  1. package/dist/cjs/client/client.d.ts +2 -2
  2. package/dist/cjs/index.cjs +50 -4
  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 +22 -33
  7. package/dist/cjs/resources/classes/fhir.d.ts +2 -0
  8. package/dist/cjs/resources/classes/index.d.ts +1 -0
  9. package/dist/cjs/resources/types/AccessPolicy.d.ts +1 -1
  10. package/dist/cjs/resources/types/ClaimCMS1500.d.ts +5 -5
  11. package/dist/cjs/resources/types/ConversationAddParticipantParams.d.ts +1 -1
  12. package/dist/cjs/resources/types/ErxMedicationSearchResponse.d.ts +3 -3
  13. package/dist/cjs/resources/types/Project.d.ts +1 -1
  14. package/dist/cjs/resources/types/VersionGetResponse.d.ts +2 -2
  15. package/dist/cjs/resources/types/Z3GetPresignedUrlParams.d.ts +1 -1
  16. package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +1 -1
  17. package/dist/cjs/resources/types/ZambdaFunction.d.ts +2 -2
  18. package/dist/cjs/resources/types/ZambdaUpdateParams.d.ts +2 -2
  19. package/dist/cjs/resources/types/fhir.d.ts +38 -2
  20. package/dist/esm/client/client.d.ts +2 -2
  21. package/dist/esm/client/client.js.map +1 -1
  22. package/dist/esm/index.min.js +1 -1
  23. package/dist/esm/index.min.js.map +1 -1
  24. package/dist/esm/resources/classes/fhir-ext.d.ts +22 -33
  25. package/dist/esm/resources/classes/fhir-ext.js +48 -5
  26. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  27. package/dist/esm/resources/classes/fhir.d.ts +2 -0
  28. package/dist/esm/resources/classes/fhir.js +3 -1
  29. package/dist/esm/resources/classes/fhir.js.map +1 -1
  30. package/dist/esm/resources/classes/index.d.ts +1 -0
  31. package/dist/esm/resources/classes/index.js +1 -0
  32. package/dist/esm/resources/classes/index.js.map +1 -1
  33. package/dist/esm/resources/types/AccessPolicy.d.ts +1 -1
  34. package/dist/esm/resources/types/ClaimCMS1500.d.ts +5 -5
  35. package/dist/esm/resources/types/ConversationAddParticipantParams.d.ts +1 -1
  36. package/dist/esm/resources/types/ErxMedicationSearchResponse.d.ts +3 -3
  37. package/dist/esm/resources/types/Project.d.ts +1 -1
  38. package/dist/esm/resources/types/VersionGetResponse.d.ts +2 -2
  39. package/dist/esm/resources/types/Z3GetPresignedUrlParams.d.ts +1 -1
  40. package/dist/esm/resources/types/ZambdaCreateParams.d.ts +1 -1
  41. package/dist/esm/resources/types/ZambdaFunction.d.ts +2 -2
  42. package/dist/esm/resources/types/ZambdaUpdateParams.d.ts +2 -2
  43. package/dist/esm/resources/types/fhir.d.ts +38 -2
  44. package/package.json +1 -1
  45. package/src/client/client.ts +2 -2
  46. package/src/resources/classes/fhir-ext.ts +97 -13
  47. package/src/resources/classes/fhir.ts +2 -0
  48. package/src/resources/classes/index.ts +2 -0
  49. package/src/resources/types/AccessPolicy.ts +1 -1
  50. package/src/resources/types/ClaimCMS1500.ts +12 -5
  51. package/src/resources/types/ConversationAddParticipantParams.ts +1 -1
  52. package/src/resources/types/ErxMedicationSearchResponse.ts +3 -3
  53. package/src/resources/types/Project.ts +1 -1
  54. package/src/resources/types/VersionGetResponse.ts +2 -2
  55. package/src/resources/types/Z3GetPresignedUrlParams.ts +1 -1
  56. package/src/resources/types/ZambdaCreateParams.ts +1 -1
  57. package/src/resources/types/ZambdaFunction.ts +2 -2
  58. package/src/resources/types/ZambdaUpdateParams.ts +2 -2
  59. package/src/resources/types/fhir.ts +56 -1
  60. package/dist/cjs/fhir/fhir-types.d.ts +0 -9
  61. package/dist/cjs/fhir/index.d.ts +0 -2
  62. package/dist/cjs/fhir/utils.d.ts +0 -14
  63. package/dist/esm/fhir/fhir-types.d.ts +0 -9
  64. package/dist/esm/fhir/index.d.ts +0 -2
  65. package/dist/esm/fhir/utils.d.ts +0 -14
  66. package/src/fhir/fhir-types.ts +0 -15
  67. package/src/fhir/index.ts +0 -2
  68. package/src/fhir/utils.ts +0 -68
@@ -1,5 +1,22 @@
1
- import { Operation } from 'fast-json-patch';
2
- import { BatchInput, BatchInputRequest, Binary, Bundle, BundleEntry, FhirBundle, FhirResource } from '../..';
1
+ import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';
2
+ import { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';
3
+ import {
4
+ BatchInput,
5
+ BatchInputRequest,
6
+ Binary,
7
+ Bundle,
8
+ BundleEntry,
9
+ FhirBundle,
10
+ FhirCreateParams,
11
+ FhirDeleteParams,
12
+ FhirGetParams,
13
+ FhirHistoryGetParams,
14
+ FhirHistorySearchParams,
15
+ FhirPatchParams,
16
+ FhirResource,
17
+ FhirSearchParams,
18
+ FhirUpdateParams,
19
+ } from '../..';
3
20
  import { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';
4
21
 
5
22
  /**
@@ -26,12 +43,13 @@ export interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {
26
43
  */
27
44
  export async function search<T extends FhirResource>(
28
45
  this: SDKResource,
29
- { resourceType, params }: { resourceType: string; params?: { name: string; value: string | number }[] },
46
+ params: FhirSearchParams,
30
47
  request?: OystehrClientRequest
31
48
  ): Promise<FhirFetcherResponse<Bundle<T>>> {
49
+ const { resourceType, params: searchParams } = params;
32
50
  let paramMap: Record<string, (string | number)[]> | undefined;
33
- if (params) {
34
- paramMap = Object.entries(params).reduce((acc, [_, param]) => {
51
+ if (searchParams) {
52
+ paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {
35
53
  if (!acc[param.name]) {
36
54
  acc[param.name] = [];
37
55
  }
@@ -45,7 +63,8 @@ export async function search<T extends FhirResource>(
45
63
  });
46
64
  const bundle: Bundle<T> = {
47
65
  ...requestBundle,
48
- unbundle: function (this: Bundle<T>) {
66
+ entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,
67
+ unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {
49
68
  return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];
50
69
  },
51
70
  };
@@ -54,7 +73,7 @@ export async function search<T extends FhirResource>(
54
73
 
55
74
  export async function create<T extends FhirResource>(
56
75
  this: SDKResource,
57
- params: T,
76
+ params: FhirCreateParams<T>,
58
77
  request?: OystehrClientRequest
59
78
  ): Promise<FhirFetcherResponse<T>> {
60
79
  const { resourceType } = params;
@@ -63,7 +82,7 @@ export async function create<T extends FhirResource>(
63
82
 
64
83
  export async function get<T extends FhirResource>(
65
84
  this: SDKResource,
66
- { resourceType, id }: { resourceType: string; id: string },
85
+ { resourceType, id }: FhirGetParams,
67
86
  request?: OystehrClientRequest
68
87
  ): Promise<FhirFetcherResponse<T>> {
69
88
  return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);
@@ -71,7 +90,7 @@ export async function get<T extends FhirResource>(
71
90
 
72
91
  export async function update<T extends FhirResource>(
73
92
  this: SDKResource,
74
- params: T,
93
+ params: FhirUpdateParams<T>,
75
94
  request?: OystehrFHIRUpdateClientRequest
76
95
  ): Promise<FhirFetcherResponse<T>> {
77
96
  const { id, resourceType } = params;
@@ -83,7 +102,7 @@ export async function update<T extends FhirResource>(
83
102
 
84
103
  export async function patch<T extends FhirResource>(
85
104
  this: SDKResource,
86
- { resourceType, id, operations }: { resourceType: string; id: string; operations: Operation[] },
105
+ { resourceType, id, operations }: FhirPatchParams,
87
106
  request?: OystehrFHIRUpdateClientRequest
88
107
  ): Promise<FhirFetcherResponse<T>> {
89
108
  return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {
@@ -95,7 +114,7 @@ export async function patch<T extends FhirResource>(
95
114
 
96
115
  async function del<T extends FhirResource>(
97
116
  this: SDKResource,
98
- { resourceType, id }: { resourceType: string; id: string },
117
+ { resourceType, id }: FhirDeleteParams,
99
118
  request?: OystehrClientRequest
100
119
  ): Promise<FhirFetcherResponse<T>> {
101
120
  return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);
@@ -104,12 +123,12 @@ export { del as delete };
104
123
 
105
124
  export async function history<T extends FhirResource>(
106
125
  this: SDKResource,
107
- { resourceType, id }: { resourceType: string; id: string },
126
+ { resourceType, id }: FhirHistorySearchParams,
108
127
  request?: OystehrClientRequest
109
128
  ): Promise<FhirFetcherResponse<Bundle<T>>>;
110
129
  export async function history<T extends FhirResource>(
111
130
  this: SDKResource,
112
- { resourceType, id, versionId }: { resourceType: string; id: string; versionId: string },
131
+ { resourceType, id, versionId }: FhirHistoryGetParams,
113
132
  request?: OystehrClientRequest
114
133
  ): Promise<FhirFetcherResponse<T>>;
115
134
  export async function history<T extends FhirResource>(
@@ -212,3 +231,68 @@ function bundleRequest(type: 'batch' | 'transaction') {
212
231
 
213
232
  export const batch = bundleRequest('batch');
214
233
  export const transaction = bundleRequest('transaction');
234
+
235
+ export function formatAddress(
236
+ address: AddressR4B | AddressR5,
237
+ options?: { all?: boolean; use?: boolean; lineSeparator?: string }
238
+ ): string {
239
+ const builder = [];
240
+
241
+ if (address.line) {
242
+ builder.push(...address.line);
243
+ }
244
+
245
+ if (address.city || address.state || address.postalCode) {
246
+ const cityStateZip = [];
247
+ if (address.city) {
248
+ cityStateZip.push(address.city);
249
+ }
250
+ if (address.state) {
251
+ cityStateZip.push(address.state);
252
+ }
253
+ if (address.postalCode) {
254
+ cityStateZip.push(address.postalCode);
255
+ }
256
+ builder.push(cityStateZip.join(', '));
257
+ }
258
+
259
+ if (address.use && (options?.all || options?.use)) {
260
+ builder.push('[' + address.use + ']');
261
+ }
262
+
263
+ return builder.join(options?.lineSeparator || ', ').trim();
264
+ }
265
+
266
+ export function formatHumanName(
267
+ name: HumanNameR4B | HumanNameR5,
268
+ options?: {
269
+ all?: boolean;
270
+ prefix?: boolean;
271
+ suffix?: boolean;
272
+ use?: boolean;
273
+ }
274
+ ): string {
275
+ const builder = [];
276
+
277
+ if (name.prefix && options?.prefix !== false) {
278
+ builder.push(...name.prefix);
279
+ }
280
+
281
+ if (name.given) {
282
+ builder.push(...name.given);
283
+ }
284
+
285
+ if (name.family) {
286
+ builder.push(name.family);
287
+ }
288
+
289
+ if (name.suffix && options?.suffix !== false) {
290
+ builder.push(...name.suffix);
291
+ }
292
+
293
+ if (name.use && (options?.all || options?.use)) {
294
+ builder.push('[' + name.use + ']');
295
+ }
296
+
297
+ return builder.join(' ').trim();
298
+ }
@@ -23,4 +23,6 @@ export class Fhir extends SDKResource {
23
23
  history = ext.history;
24
24
  batch = ext.batch;
25
25
  transaction = ext.transaction;
26
+ formatAddress = ext.formatAddress;
27
+ formatHumanName = ext.formatHumanName;
26
28
  }
@@ -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
  }
@@ -15,11 +15,11 @@ export interface ZambdaFunction {
15
15
  /**
16
16
  * The Zambda Function status provides information about the Functions state including whether it is ready to be invoked.
17
17
  */
18
- status: string;
18
+ status: 'Draft' | 'Pending' | 'Active' | 'Failed' | 'Inactive' | 'Validating';
19
19
  /**
20
20
  * 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.
21
21
  */
22
- triggerMethod: string;
22
+ triggerMethod: 'http_auth' | 'http_open' | 'subscription' | 'cron';
23
23
  schedule?: ZambdaSchedule;
24
24
  /**
25
25
  * Info about the zip file that was uploaded for the Zambda Function.
@@ -10,11 +10,11 @@ export interface ZambdaUpdateParams {
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
  /**
16
16
  * The runtime to use for the Zambda Function. This property is optional and defaults to "nodejs20.x".
17
17
  */
18
- runtime?: string;
18
+ runtime?: 'nodejs18.x' | 'nodejs20.x';
19
19
  id: string;
20
20
  }
@@ -15,12 +15,67 @@ import type {
15
15
  } from 'fhir/r5';
16
16
 
17
17
  export type FhirResource = FhirResourceR4B | FhirResourceR5;
18
+ // We're doing this "Omit dance" with the Bundle types because TypeScript
19
+ // produces incorrect BundleEntry<F> types when F is a union of multiple FHIR
20
+ // types. The guess is it's something about the conditional generic typing, but
21
+ // we haven't found a different way to resolve it.
22
+ //
23
+ // No "omit dance":
24
+ // entry: BundleEntry<Patient>[] | BundleEntry<Practitioner>[] | undefined
25
+ // With "omit dance":
26
+ // entry: (BundleEntry<Patient> | BundleEntry<Practitioner>)[] | undefined
27
+ //
28
+ // The latter can be used with array functions like `.find()`.
18
29
  export type FhirBundle<F extends FhirResource> = F extends FhirResourceR4B ? BundleR4B<F> : BundleR5<F>;
19
- export type Bundle<F extends FhirResource> = FhirBundle<F> & { unbundle: (this: Bundle<F>) => F[] };
30
+ export type EntrylessFhirBundle<F extends FhirResource> = F extends FhirResourceR4B
31
+ ? Omit<BundleR4B<F>, 'entry'>
32
+ : Omit<BundleR5<F>, 'entry'>;
33
+ export type Bundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
34
+ entry?: Array<BundleEntry<F>> | undefined;
35
+ unbundle: (this: { entry?: Array<BundleEntry<F>> }) => F[];
36
+ };
20
37
  export type BundleEntry<F extends FhirResource> = F extends FhirResourceR4B ? BundleEntryR4B<F> : BundleEntryR5<F>;
21
38
  export type Binary<F extends FhirResource> = F extends FhirResourceR4B ? BinaryR4B : BinaryR5;
22
39
  export type OperationOutcome = OperationOutcomeR4B | OperationOutcomeR5;
23
40
 
41
+ export type SearchParam = { name: string; value: string | number };
42
+
43
+ export interface FhirSearchParams {
44
+ resourceType: string;
45
+ params?: SearchParam[];
46
+ }
47
+
48
+ export interface FhirGetParams {
49
+ resourceType: string;
50
+ id: string;
51
+ }
52
+
53
+ export type FhirCreateParams<T extends FhirResource> = T;
54
+
55
+ export type FhirUpdateParams<T extends FhirResource> = T;
56
+
57
+ export interface FhirPatchParams {
58
+ resourceType: string;
59
+ id: string;
60
+ operations: Operation[];
61
+ }
62
+
63
+ export interface FhirDeleteParams {
64
+ resourceType: string;
65
+ id: string;
66
+ }
67
+
68
+ export interface FhirHistorySearchParams {
69
+ resourceType: string;
70
+ id: string;
71
+ }
72
+
73
+ export interface FhirHistoryGetParams {
74
+ resourceType: string;
75
+ id: string;
76
+ versionId: string;
77
+ }
78
+
24
79
  interface BatchInputBaseRequest {
25
80
  url: string;
26
81
  }
@@ -1,9 +0,0 @@
1
- import * as R4B from 'fhir/r4b';
2
- import * as R5 from 'fhir/r5';
3
- export type Binary = R4B.Binary | R5.Binary;
4
- export type FhirResource = R4B.FhirResource | R5.FhirResource;
5
- export type Resource = R4B.Resource | R5.Resource;
6
- export type Bundle<BundleContentType = FhirResource> = R4B.Bundle<BundleContentType> | R5.Bundle<BundleContentType>;
7
- export type BundleEntry<BundleContentType = FhirResource> = R4B.BundleEntry<BundleContentType> | R5.BundleEntry<BundleContentType>;
8
- export type Address = R4B.Address | R5.Address;
9
- export type HumanName = R4B.HumanName | R5.HumanName;
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- export * from './fhir-types';
@@ -1,14 +0,0 @@
1
- import { Address, HumanName } from './fhir-types';
2
- export interface AddressFormatOptions {
3
- all?: boolean;
4
- use?: boolean;
5
- lineSeparator?: string;
6
- }
7
- export interface HumanNameFormatOptions {
8
- all?: boolean;
9
- prefix?: boolean;
10
- suffix?: boolean;
11
- use?: boolean;
12
- }
13
- export declare function formatAddress(address: Address, options?: AddressFormatOptions): string;
14
- export declare function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string;
@@ -1,9 +0,0 @@
1
- import * as R4B from 'fhir/r4b';
2
- import * as R5 from 'fhir/r5';
3
- export type Binary = R4B.Binary | R5.Binary;
4
- export type FhirResource = R4B.FhirResource | R5.FhirResource;
5
- export type Resource = R4B.Resource | R5.Resource;
6
- export type Bundle<BundleContentType = FhirResource> = R4B.Bundle<BundleContentType> | R5.Bundle<BundleContentType>;
7
- export type BundleEntry<BundleContentType = FhirResource> = R4B.BundleEntry<BundleContentType> | R5.BundleEntry<BundleContentType>;
8
- export type Address = R4B.Address | R5.Address;
9
- export type HumanName = R4B.HumanName | R5.HumanName;
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- export * from './fhir-types';
@@ -1,14 +0,0 @@
1
- import { Address, HumanName } from './fhir-types';
2
- export interface AddressFormatOptions {
3
- all?: boolean;
4
- use?: boolean;
5
- lineSeparator?: string;
6
- }
7
- export interface HumanNameFormatOptions {
8
- all?: boolean;
9
- prefix?: boolean;
10
- suffix?: boolean;
11
- use?: boolean;
12
- }
13
- export declare function formatAddress(address: Address, options?: AddressFormatOptions): string;
14
- export declare function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string;
@@ -1,15 +0,0 @@
1
- import * as R4B from 'fhir/r4b';
2
- import * as R5 from 'fhir/r5';
3
-
4
- // Resources
5
- export type Binary = R4B.Binary | R5.Binary;
6
- export type FhirResource = R4B.FhirResource | R5.FhirResource;
7
- export type Resource = R4B.Resource | R5.Resource;
8
- export type Bundle<BundleContentType = FhirResource> = R4B.Bundle<BundleContentType> | R5.Bundle<BundleContentType>;
9
- export type BundleEntry<BundleContentType = FhirResource> =
10
- | R4B.BundleEntry<BundleContentType>
11
- | R5.BundleEntry<BundleContentType>;
12
-
13
- // DataTypes
14
- export type Address = R4B.Address | R5.Address;
15
- export type HumanName = R4B.HumanName | R5.HumanName;
package/src/fhir/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- export * from './fhir-types';
package/src/fhir/utils.ts DELETED
@@ -1,68 +0,0 @@
1
- import { Address, HumanName } from './fhir-types';
2
-
3
- export interface AddressFormatOptions {
4
- all?: boolean;
5
- use?: boolean;
6
- lineSeparator?: string;
7
- }
8
-
9
- export interface HumanNameFormatOptions {
10
- all?: boolean;
11
- prefix?: boolean;
12
- suffix?: boolean;
13
- use?: boolean;
14
- }
15
-
16
- export function formatAddress(address: Address, options?: AddressFormatOptions): string {
17
- const builder = [];
18
-
19
- if (address.line) {
20
- builder.push(...address.line);
21
- }
22
-
23
- if (address.city || address.state || address.postalCode) {
24
- const cityStateZip = [];
25
- if (address.city) {
26
- cityStateZip.push(address.city);
27
- }
28
- if (address.state) {
29
- cityStateZip.push(address.state);
30
- }
31
- if (address.postalCode) {
32
- cityStateZip.push(address.postalCode);
33
- }
34
- builder.push(cityStateZip.join(', '));
35
- }
36
-
37
- if (address.use && (options?.all || options?.use)) {
38
- builder.push('[' + address.use + ']');
39
- }
40
-
41
- return builder.join(options?.lineSeparator || ', ').trim();
42
- }
43
-
44
- export function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string {
45
- const builder = [];
46
-
47
- if (name.prefix && options?.prefix !== false) {
48
- builder.push(...name.prefix);
49
- }
50
-
51
- if (name.given) {
52
- builder.push(...name.given);
53
- }
54
-
55
- if (name.family) {
56
- builder.push(name.family);
57
- }
58
-
59
- if (name.suffix && options?.suffix !== false) {
60
- builder.push(...name.suffix);
61
- }
62
-
63
- if (name.use && (options?.all || options?.use)) {
64
- builder.push('[' + name.use + ']');
65
- }
66
-
67
- return builder.join(' ').trim();
68
- }