oro-sdk 5.3.4 → 5.3.5

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.3.4",
2
+ "version": "5.3.5",
3
3
  "main": "dist/index.js",
4
4
  "typings": "dist/index.d.ts",
5
5
  "files": [
package/src/client.ts CHANGED
@@ -94,7 +94,7 @@ export class OroClient {
94
94
  public workflowClient: WorkflowService,
95
95
  public diagnosisClient: DiagnosisService,
96
96
  private authenticationCallback?: (err: Error) => void
97
- ) {}
97
+ ) { }
98
98
 
99
99
  /**
100
100
  * clears the vaultIndex and cached metadata grants
@@ -407,18 +407,18 @@ export class OroClient {
407
407
  }))
408
408
  .map(
409
409
  (e: IndexConsultLockbox) =>
410
- ({
411
- uuid: e.uuid,
412
- timestamp: e.timestamp,
413
- uniqueHash: e.uniqueHash,
414
- encryptedIndexEntry: CryptoRSA.jsonWithPubEncryptToBase64(
415
- {
416
- consultationId: e.consultationId,
417
- grant: e.grant,
418
- },
419
- rsaPub
420
- ),
421
- } as EncryptedIndexEntry)
410
+ ({
411
+ uuid: e.uuid,
412
+ timestamp: e.timestamp,
413
+ uniqueHash: e.uniqueHash,
414
+ encryptedIndexEntry: CryptoRSA.jsonWithPubEncryptToBase64(
415
+ {
416
+ consultationId: e.consultationId,
417
+ grant: e.grant,
418
+ },
419
+ rsaPub
420
+ ),
421
+ } as EncryptedIndexEntry)
422
422
  )
423
423
  break
424
424
  }
@@ -553,7 +553,7 @@ export class OroClient {
553
553
  documentType: DocumentType,
554
554
  lockboxOwnerUuid?: Uuid,
555
555
  previousDataUuid?: Uuid,
556
- withNotification: boolean = false
556
+ options: { withNotification?: boolean } = { withNotification: false }
557
557
  ): Promise<DataCreateResponse> {
558
558
  if (!this.rsa) throw IncompleteAuthentication
559
559
 
@@ -572,7 +572,7 @@ export class OroClient {
572
572
  },
573
573
  lockboxOwnerUuid,
574
574
  previousDataUuid,
575
- withNotification
575
+ options
576
576
  )
577
577
  }
578
578
 
@@ -585,7 +585,7 @@ export class OroClient {
585
585
  * @param privateMeta the metadata that will be secured in the vault
586
586
  * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
587
587
  * @param previousDataUuid if it's a revision of existing data, specify the previous data uuid
588
- * @param withNotification if the insertion of data requires notification
588
+ * @param options if the insertion of data requires email notification
589
589
  * @returns the data uuid
590
590
  */
591
591
  public async createJsonData<T extends Metadata>(
@@ -595,7 +595,7 @@ export class OroClient {
595
595
  privateMeta?: { [val: string]: any },
596
596
  lockboxOwnerUuid?: Uuid,
597
597
  previousDataUuid?: Uuid,
598
- withNotification: boolean = false
598
+ options: { withNotification?: boolean } = { withNotification: false }
599
599
  ): Promise<DataCreateResponse> {
600
600
  if (!this.rsa) throw IncompleteAuthentication
601
601
 
@@ -608,7 +608,7 @@ export class OroClient {
608
608
  publicMetadata: meta,
609
609
  privateMetadata: encryptedPrivateMeta,
610
610
  }
611
- if (withNotification)
611
+ if (options.withNotification)
612
612
  return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
613
613
  else return this.vaultClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
614
614
  }
@@ -620,7 +620,7 @@ export class OroClient {
620
620
  * @param publicMetadata the public Metadata
621
621
  * @param privateMetadata the private Metadata
622
622
  * @param forceReplace set true when the insertion of data requires to replace the data when it exists already
623
- * @param withNotification if the insertion of data requires notification
623
+ * @param options if the insertion of data requires email notification
624
624
  * @returns the data uuid
625
625
  */
626
626
  public async getOrInsertJsonData<M extends Metadata>(
@@ -628,11 +628,10 @@ export class OroClient {
628
628
  data: any,
629
629
  publicMetadata: M,
630
630
  privateMetadata: Metadata,
631
- forceReplace: boolean = false,
632
- withNotification: boolean = false
631
+ options: { withNotification?: boolean, forceReplace?: boolean } = { withNotification: false, forceReplace: false }
633
632
  ): Promise<Uuid> {
634
633
  let manifest = await this.vaultClient.lockboxManifestGet(lockboxUuid, publicMetadata)
635
- if (!forceReplace && manifest.length > 0) {
634
+ if (!options.forceReplace && manifest.length > 0) {
636
635
  console.log(`The data for ${JSON.stringify(publicMetadata)} already exist`)
637
636
  return manifest[0].dataUuid
638
637
  } else
@@ -643,8 +642,9 @@ export class OroClient {
643
642
  publicMetadata,
644
643
  privateMetadata,
645
644
  undefined,
646
- forceReplace && manifest.length > 0 ? manifest[0].dataUuid : undefined, // if forceReplace and data already exist, then replace data. Otherwise insert it
647
- withNotification
645
+ // if forceReplace and data already exist, then replace data. Otherwise insert it
646
+ options.forceReplace && manifest.length > 0 ? manifest[0].dataUuid : undefined,
647
+ { withNotification: options.withNotification }
648
648
  ).catch((err) => {
649
649
  console.error(`Error while upserting data ${JSON.stringify(publicMetadata)} data`, err)
650
650
  throw err
@@ -671,7 +671,7 @@ export class OroClient {
671
671
  privateMeta: { [val: string]: any },
672
672
  lockboxOwnerUuid?: Uuid,
673
673
  previousDataUuid?: Uuid,
674
- withNotification: boolean = false
674
+ options: { withNotification?: boolean } = { withNotification: false }
675
675
  ): Promise<DataCreateResponse> {
676
676
  if (!this.rsa) throw IncompleteAuthentication
677
677
  let symmetricEncryptor = await this.getCachedSecretCryptor(lockboxUuid, lockboxOwnerUuid)
@@ -683,7 +683,7 @@ export class OroClient {
683
683
  publicMetadata: meta,
684
684
  privateMetadata: encryptedPrivateMeta,
685
685
  }
686
- if (withNotification)
686
+ if (options.withNotification)
687
687
  return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
688
688
  else return this.vaultClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
689
689
  }
@@ -832,9 +832,9 @@ export class OroClient {
832
832
  public async getPersonalInformationsFromConsultId(
833
833
  consultationId: Uuid,
834
834
  category: MetadataCategory.Personal | MetadataCategory.ChildPersonal | MetadataCategory.OtherPersonal,
835
- forceRefresh = false
835
+ options: { forceRefresh: boolean } = { forceRefresh: false }
836
836
  ): Promise<LocalizedData<PopulatedWorkflowData>[]> {
837
- return this.getMetaCategoryFromConsultId(consultationId, category, forceRefresh)
837
+ return this.getMetaCategoryFromConsultId(consultationId, category, options)
838
838
  }
839
839
 
840
840
  /**
@@ -847,15 +847,15 @@ export class OroClient {
847
847
  */
848
848
  public async getMedicalDataFromConsultId(
849
849
  consultationId: Uuid,
850
- forceRefresh = false
850
+ options: { forceRefresh: boolean } = { forceRefresh: false }
851
851
  ): Promise<LocalizedData<PopulatedWorkflowData>[]> {
852
- return this.getMetaCategoryFromConsultId(consultationId, MetadataCategory.Medical, forceRefresh)
852
+ return this.getMetaCategoryFromConsultId(consultationId, MetadataCategory.Medical, options)
853
853
  }
854
854
 
855
855
  private async getMetaCategoryFromConsultId(
856
856
  consultationId: Uuid,
857
857
  category: MetadataCategory,
858
- forceRefresh = false
858
+ options: { forceRefresh: boolean } = { forceRefresh: false }
859
859
  ): Promise<LocalizedData<PopulatedWorkflowData>[]> {
860
860
  let grants = await this.getGrants({ consultationId })
861
861
  let workflowData: LocalizedData<PopulatedWorkflowData>[] = []
@@ -869,7 +869,7 @@ export class OroClient {
869
869
  },
870
870
  true,
871
871
  grant.lockboxOwnerUuid,
872
- forceRefresh
872
+ options
873
873
  )
874
874
 
875
875
  // TODO: find another solution for backwards compatibility (those without the metadata consultationIds)
@@ -884,7 +884,7 @@ export class OroClient {
884
884
  },
885
885
  true,
886
886
  grant.lockboxOwnerUuid,
887
- forceRefresh
887
+ options
888
888
  )
889
889
  ).filter((entry) => !entry.metadata.consultationIds) // Keep only entries without associated consultationIds
890
890
  }
@@ -987,7 +987,7 @@ export class OroClient {
987
987
  filter: Metadata,
988
988
  expandPrivateMetadata: boolean,
989
989
  lockboxOwnerUuid?: Uuid,
990
- forceRefresh: boolean = false
990
+ options: { forceRefresh: boolean } = { forceRefresh: false }
991
991
  ): Promise<LockboxManifest> {
992
992
  let manifestKey = JSON.stringify({
993
993
  lockboxUuid,
@@ -995,7 +995,7 @@ export class OroClient {
995
995
  expandPrivateMetadata,
996
996
  lockboxOwnerUuid,
997
997
  })
998
- if (!forceRefresh && this.cachedManifest[manifestKey]) return this.cachedManifest[manifestKey]
998
+ if (!options.forceRefresh && this.cachedManifest[manifestKey]) return this.cachedManifest[manifestKey]
999
999
 
1000
1000
  return this.vaultClient.lockboxManifestGet(lockboxUuid, filter, lockboxOwnerUuid).then((manifest) => {
1001
1001
  return Promise.all(
@@ -1096,11 +1096,10 @@ export class OroClient {
1096
1096
  const identificationDataUuid = (
1097
1097
  await this.getLockboxManifest(
1098
1098
  lockboxUuid,
1099
-
1100
1099
  filter,
1101
1100
  false,
1102
1101
  grant.lockboxOwnerUuid,
1103
- true
1102
+ { forceRefresh: true }
1104
1103
  )
1105
1104
  )[0].dataUuid
1106
1105
 
@@ -1253,7 +1252,7 @@ export class OroClient {
1253
1252
  */
1254
1253
  public async getPatientConsultationData(
1255
1254
  consultationId: Uuid,
1256
- forceRefresh: boolean = false
1255
+ options: { forceRefresh: boolean } = { forceRefresh: false }
1257
1256
  ): Promise<PopulatedWorkflowData[]> {
1258
1257
  //TODO: make use of getPatientDocumentsList instead of doing it manually here
1259
1258
  return Promise.all(
@@ -1268,7 +1267,7 @@ export class OroClient {
1268
1267
  },
1269
1268
  true,
1270
1269
  grant.lockboxOwnerUuid,
1271
- forceRefresh
1270
+ options
1272
1271
  ).then((manifest) =>
1273
1272
  Promise.all(
1274
1273
  manifest.map((e) =>
@@ -1373,7 +1372,7 @@ export class OroClient {
1373
1372
  { ...filters, consultationId },
1374
1373
  expandPrivateMetadata,
1375
1374
  grant.lockboxOwnerUuid,
1376
- true
1375
+ { forceRefresh: true }
1377
1376
  ).then((manifest) =>
1378
1377
  Promise.all(
1379
1378
  manifest.map(async (entry): Promise<Document> => {
@@ -1554,7 +1553,7 @@ export class OroClient {
1554
1553
  contentType: 'application/json',
1555
1554
  },
1556
1555
  {},
1557
- true
1556
+ { forceReplace: true }
1558
1557
  )
1559
1558
 
1560
1559
  return updatedIdentity
@@ -168,10 +168,10 @@ export async function registerPatient(
168
168
  oroClient,
169
169
  onProgress
170
170
  ? {
171
- onProgress,
172
- currentStep,
173
- stepsTotalNum,
174
- }
171
+ onProgress,
172
+ currentStep,
173
+ stepsTotalNum,
174
+ }
175
175
  : undefined
176
176
  ).catch((err) => {
177
177
  console.error('[SDK: registration] Some errors happened during image upload', err)
@@ -339,8 +339,8 @@ async function storePatientData(
339
339
  consultationId, // TODO: deprecated. Will finally only be in privateMetadata
340
340
  },
341
341
  { consultationId },
342
- false,
343
- true // the only data that needs to include an email notification
342
+ { withNotification: true },
343
+ // the only data that needs to include an email notification
344
344
  )
345
345
  ),
346
346
  getWorkflowDataByCategory(workflow, MetadataCategory.Medical).then((data) =>
@@ -439,11 +439,11 @@ async function storeImageAliases(
439
439
  Math.round(
440
440
  ((progress.currentStep + 1) / progress.stepsTotalNum -
441
441
  progress.currentStep / progress.stepsTotalNum) *
442
- 100
442
+ 100
443
443
  ) / 100
444
444
  progress.onProgress(
445
445
  progress.currentStep / progress.stepsTotalNum +
446
- progressStepValue * (storedImagesNum / totalImagesNum),
446
+ progressStepValue * (storedImagesNum / totalImagesNum),
447
447
  'store_images',
448
448
  {
449
449
  storedImagesNum,
@@ -43,84 +43,84 @@ export function getRefillAnswersAsWorkflow(
43
43
  if (pharmacy) selectedAnswers.push({ ['pharmacy']: JSON.stringify(pharmacy) })
44
44
 
45
45
  return {
46
- "id": "32573a20-6f1d-49be-9ad3-b87c58074979",
47
- "createdAt": "2022-10-03T00:00:00.000Z",
48
- "culDeSacs": [],
49
- "hidePlanRules": [],
50
- "pages": [
46
+ id: '32573a20-6f1d-49be-9ad3-b87c58074979',
47
+ createdAt: '2022-10-03T00:00:00.000Z',
48
+ culDeSacs: [],
49
+ hidePlanRules: [],
50
+ pages: [
51
51
  {
52
- "title": "Prescription Refill",
53
- "groups": [
52
+ title: 'Prescription Refill',
53
+ groups: [
54
54
  {
55
- "type": "field-group",
56
- "fieldsAndGroups": [
55
+ type: 'field-group',
56
+ fieldsAndGroups: [
57
57
  {
58
- "type": "field",
59
- "id": "isTreatmentWorking"
58
+ type: 'field',
59
+ id: 'isTreatmentWorking',
60
60
  },
61
61
  {
62
- "type": "field",
63
- "id": "hasSideEffects"
62
+ type: 'field',
63
+ id: 'hasSideEffects',
64
64
  },
65
65
  {
66
- "type": "field",
67
- "id": "youPharmacy"
66
+ type: 'field',
67
+ id: 'youPharmacy',
68
68
  },
69
69
  {
70
- "type": "field",
71
- "id": "youAddress"
72
- }
73
- ]
74
- }
70
+ type: 'field',
71
+ id: 'youAddress',
72
+ },
73
+ ],
74
+ },
75
75
  ],
76
- "questions": {
77
- "isTreatmentWorking": {
78
- "label": "Is the treatment working for you?",
79
- "kind": "radio",
80
- "inline": true,
81
- "inlineLabel": false,
82
- "metaCategory": MetadataCategory.Refill,
83
- "answers": {
84
- "73bec6eb-0310-4787-af3c-ac9c291737b2": {
85
- "text": "Yes"
76
+ questions: {
77
+ isTreatmentWorking: {
78
+ label: 'Is the treatment working for you?',
79
+ kind: 'radio',
80
+ inline: true,
81
+ inlineLabel: false,
82
+ metaCategory: MetadataCategory.Refill,
83
+ answers: {
84
+ '73bec6eb-0310-4787-af3c-ac9c291737b2': {
85
+ text: 'Yes',
86
+ },
87
+ 'e193951f-986f-4db3-bede-903045a1804a': {
88
+ text: 'No',
86
89
  },
87
- "e193951f-986f-4db3-bede-903045a1804a": {
88
- "text": "No"
89
- }
90
- }
90
+ },
91
91
  },
92
- "hasSideEffects": {
93
- "label": "Are there any side effects",
94
- "kind": "radio",
95
- "inline": true,
96
- "inlineLabel": false,
97
- "metaCategory": MetadataCategory.Refill,
98
- "answers": {
99
- "1b87ad22-d316-4fac-9c7f-8f4ccb841aed": {
100
- "text": "Yes"
92
+ hasSideEffects: {
93
+ label: 'Are there any side effects',
94
+ kind: 'radio',
95
+ inline: true,
96
+ inlineLabel: false,
97
+ metaCategory: MetadataCategory.Refill,
98
+ answers: {
99
+ '1b87ad22-d316-4fac-9c7f-8f4ccb841aed': {
100
+ text: 'Yes',
101
101
  },
102
- "ab7f5a41-c351-4f5d-a568-e38f9f200e9a": {
103
- "text": "No"
104
- }
105
- }
102
+ 'ab7f5a41-c351-4f5d-a568-e38f9f200e9a': {
103
+ text: 'No',
104
+ },
105
+ },
106
+ },
107
+ youPharmacy: {
108
+ kind: 'online-pharmacy-picker',
109
+ label: 'Which pharmacy do you want the prescription sent to?',
110
+ metaCategory: MetadataCategory.Refill,
111
+ minorLabel: ' (Optional)',
112
+ summaryLabel: 'Your pharmacy',
106
113
  },
107
- "youPharmacy": {
108
- "kind": "online-pharmacy-picker",
109
- "label": "Which pharmacy do you want the prescription sent to?",
110
- "metaCategory": MetadataCategory.Refill,
111
- "minorLabel": " (Optional)",
112
- "summaryLabel": "Your pharmacy"
114
+ youAddress: {
115
+ kind: 'place-address',
116
+ label: 'Address',
117
+ metaCategory: MetadataCategory.Refill,
113
118
  },
114
- "youAddress": {
115
- "kind": "place-address",
116
- "label": "Address",
117
- "metaCategory": MetadataCategory.Refill
118
- }
119
- }
120
- }
119
+ },
120
+ },
121
121
  ],
122
- "locale": "en",
123
- selectedAnswers
122
+ locale: 'en',
123
+ selectedAnswers,
124
124
  }
125
125
  }
126
126
 
@@ -156,7 +156,8 @@ export async function createRefill(
156
156
  documentType: DocumentType.PopulatedWorkflowData,
157
157
  consultationIds: [newConsult.uuid],
158
158
  },
159
- {}
159
+ {},
160
+ { withNotification: true }
160
161
  )
161
162
  .catch((err) => {
162
163
  console.error('[SDK: prescription refill] Some errors happened during refill data upload', err)