oro-sdk 5.5.1 → 5.6.1-dev1.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.5.1",
2
+ "version": "5.6.1-dev1.0",
3
3
  "main": "dist/index.js",
4
4
  "typings": "dist/index.d.ts",
5
5
  "files": [
@@ -55,8 +55,8 @@
55
55
  "form-data": "^4.0.0",
56
56
  "formdata-node": "^4.3.1",
57
57
  "idb-keyval": "^5.0.6",
58
- "oro-sdk-apis": "3.3.1",
58
+ "oro-sdk-apis": "3.7.0-dev1.0 ",
59
59
  "oro-toolbox": "0.0.6",
60
60
  "uuid": "^8.3.2"
61
61
  }
62
- }
62
+ }
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
@@ -412,18 +412,18 @@ export class OroClient {
412
412
  }))
413
413
  .map(
414
414
  (e: IndexConsultLockbox) =>
415
- ({
416
- uuid: e.uuid,
417
- timestamp: e.timestamp,
418
- uniqueHash: e.uniqueHash,
419
- encryptedIndexEntry: CryptoRSA.jsonWithPubEncryptToBase64(
420
- {
421
- consultationId: e.consultationId,
422
- grant: e.grant,
423
- },
424
- rsaPub
425
- ),
426
- } as EncryptedIndexEntry)
415
+ ({
416
+ uuid: e.uuid,
417
+ timestamp: e.timestamp,
418
+ uniqueHash: e.uniqueHash,
419
+ encryptedIndexEntry: CryptoRSA.jsonWithPubEncryptToBase64(
420
+ {
421
+ consultationId: e.consultationId,
422
+ grant: e.grant,
423
+ },
424
+ rsaPub
425
+ ),
426
+ } as EncryptedIndexEntry)
427
427
  )
428
428
  break
429
429
  }
@@ -468,7 +468,8 @@ export class OroClient {
468
468
  message: string,
469
469
  consultationId: string,
470
470
  lockboxOwnerUuid?: Uuid,
471
- previousDataUuid?: Uuid
471
+ previousDataUuid?: Uuid,
472
+ options: { updateMedicalStatus: boolean } = { updateMedicalStatus: true }
472
473
  ): Promise<DataCreateResponse> {
473
474
  if (!this.rsa) throw IncompleteAuthentication
474
475
 
@@ -492,7 +493,7 @@ export class OroClient {
492
493
  privateMetadata: encryptedPrivateMeta,
493
494
  }
494
495
 
495
- return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
496
+ return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid, options)
496
497
  }
497
498
 
498
499
  /**
@@ -510,7 +511,8 @@ export class OroClient {
510
511
  data: File,
511
512
  consultationId: string,
512
513
  lockboxOwnerUuid?: Uuid,
513
- previousDataUuid?: Uuid
514
+ previousDataUuid?: Uuid,
515
+ options: { updateMedicalStatus: boolean } = { updateMedicalStatus: true }
514
516
  ): Promise<DataCreateResponse> {
515
517
  if (!this.rsa) throw IncompleteAuthentication
516
518
 
@@ -536,7 +538,7 @@ export class OroClient {
536
538
  privateMetadata: encryptedPrivateMeta,
537
539
  }
538
540
 
539
- return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
541
+ return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid, options)
540
542
  }
541
543
 
542
544
  /**
@@ -558,7 +560,10 @@ export class OroClient {
558
560
  documentType: DocumentType,
559
561
  lockboxOwnerUuid?: Uuid,
560
562
  previousDataUuid?: Uuid,
561
- options: { withNotification?: boolean } = { withNotification: false }
563
+ options: { withNotification: boolean; updateMedicalStatus: boolean } = {
564
+ withNotification: false,
565
+ updateMedicalStatus: false,
566
+ }
562
567
  ): Promise<DataCreateResponse> {
563
568
  if (!this.rsa) throw IncompleteAuthentication
564
569
 
@@ -600,7 +605,10 @@ export class OroClient {
600
605
  privateMeta?: { [val: string]: any },
601
606
  lockboxOwnerUuid?: Uuid,
602
607
  previousDataUuid?: Uuid,
603
- options: { withNotification?: boolean } = { withNotification: false }
608
+ options: { withNotification: boolean; updateMedicalStatus: boolean } = {
609
+ withNotification: false,
610
+ updateMedicalStatus: false,
611
+ }
604
612
  ): Promise<DataCreateResponse> {
605
613
  if (!this.rsa) throw IncompleteAuthentication
606
614
 
@@ -614,7 +622,7 @@ export class OroClient {
614
622
  privateMetadata: encryptedPrivateMeta,
615
623
  }
616
624
  if (options.withNotification)
617
- return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
625
+ return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid, options)
618
626
  else return this.vaultClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
619
627
  }
620
628
 
@@ -633,7 +641,11 @@ export class OroClient {
633
641
  data: any,
634
642
  publicMetadata: M,
635
643
  privateMetadata: Metadata,
636
- options: { withNotification?: boolean, forceReplace?: boolean } = { withNotification: false, forceReplace: false }
644
+ options: { withNotification: boolean; forceReplace: boolean; updateMedicalStatus: boolean } = {
645
+ withNotification: false,
646
+ forceReplace: false,
647
+ updateMedicalStatus: false,
648
+ }
637
649
  ): Promise<Uuid> {
638
650
  let manifest = await this.vaultClient.lockboxManifestGet(lockboxUuid, publicMetadata)
639
651
  if (!options.forceReplace && manifest.length > 0) {
@@ -649,7 +661,7 @@ export class OroClient {
649
661
  undefined,
650
662
  // if forceReplace and data already exist, then replace data. Otherwise insert it
651
663
  options.forceReplace && manifest.length > 0 ? manifest[0].dataUuid : undefined,
652
- { withNotification: options.withNotification }
664
+ options
653
665
  ).catch((err) => {
654
666
  console.error(`Error while upserting data ${JSON.stringify(publicMetadata)} data`, err)
655
667
  throw err
@@ -676,7 +688,10 @@ export class OroClient {
676
688
  privateMeta: { [val: string]: any },
677
689
  lockboxOwnerUuid?: Uuid,
678
690
  previousDataUuid?: Uuid,
679
- options: { withNotification?: boolean } = { withNotification: false }
691
+ options: { withNotification: boolean; updateMedicalStatus: boolean } = {
692
+ withNotification: false,
693
+ updateMedicalStatus: false,
694
+ }
680
695
  ): Promise<DataCreateResponse> {
681
696
  if (!this.rsa) throw IncompleteAuthentication
682
697
  let symmetricEncryptor = await this.getCachedSecretCryptor(lockboxUuid, lockboxOwnerUuid)
@@ -689,7 +704,7 @@ export class OroClient {
689
704
  privateMetadata: encryptedPrivateMeta,
690
705
  }
691
706
  if (options.withNotification)
692
- return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
707
+ return this.tellerClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid, options)
693
708
  else return this.vaultClient.lockboxDataStore(lockboxUuid, request, lockboxOwnerUuid, previousDataUuid)
694
709
  }
695
710
 
@@ -1099,13 +1114,7 @@ export class OroClient {
1099
1114
  if (!lockboxUuid) throw MissingLockbox
1100
1115
  if (!lockboxOwnerUuid) throw MissingLockboxOwner
1101
1116
  const identificationDataUuid = (
1102
- await this.getLockboxManifest(
1103
- lockboxUuid,
1104
- filter,
1105
- false,
1106
- grant.lockboxOwnerUuid,
1107
- { forceRefresh: true }
1108
- )
1117
+ await this.getLockboxManifest(lockboxUuid, filter, false, grant.lockboxOwnerUuid, { forceRefresh: true })
1109
1118
  )[0].dataUuid
1110
1119
 
1111
1120
  return {
@@ -1558,7 +1567,7 @@ export class OroClient {
1558
1567
  contentType: 'application/json',
1559
1568
  },
1560
1569
  {},
1561
- { forceReplace: true }
1570
+ { forceReplace: true, withNotification: false, updateMedicalStatus: false }
1562
1571
  )
1563
1572
 
1564
1573
  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,7 +339,7 @@ async function storePatientData(
339
339
  consultationId, // TODO: deprecated. Will finally only be in privateMetadata
340
340
  },
341
341
  { consultationId },
342
- { withNotification: true },
342
+ { withNotification: true, forceReplace: false, updateMedicalStatus: false }
343
343
  // the only data that needs to include an email notification
344
344
  )
345
345
  ),
@@ -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,
@@ -17,9 +17,9 @@ const MAX_RETRIES = 15
17
17
  * Placeholder while the workflow interpreter for the refill flows is complete
18
18
  *
19
19
  * Creates a fake workflow in which the workflow data will reside
20
- *
20
+ *
21
21
  * @todo deprecate this function when using workflows and populating them from the app
22
- *
22
+ *
23
23
  * @param isTreatmentWorking the value from the `is treatment working` question
24
24
  * @param hasSideEffects the value from the `does the treatment have side effects` question
25
25
  * @param deliveryAddress the provided delivery address
@@ -30,7 +30,7 @@ export function getRefillAnswersAsWorkflow(
30
30
  isTreatmentWorking: string,
31
31
  hasSideEffects: string,
32
32
  deliveryAddress?: string,
33
- pharmacy?: PlaceData,
33
+ pharmacy?: PlaceData
34
34
  ): WorkflowData {
35
35
  let selectedAnswers: SelectedAnswersData = [
36
36
  {
@@ -167,24 +167,34 @@ export async function createRefill(
167
167
  lockboxUuid!,
168
168
  populatedRefillWorkflow,
169
169
  {
170
- category: MetadataCategory.Refill,
170
+ category: MetadataCategory.Consultation,
171
171
  documentType: DocumentType.PopulatedWorkflowData,
172
- consultationIds: [newConsult.uuid],
172
+ consultationId: newConsult.uuid,
173
173
  },
174
174
  {},
175
- { withNotification: true }
175
+ { withNotification: true, forceReplace: false, updateMedicalStatus: true }
176
176
  )
177
177
  .catch((err) => {
178
- console.error('[SDK: prescription refill request] Some errors happened during refill data upload', err)
178
+ console.error(
179
+ '[SDK: prescription refill request] Some errors happened during refill data upload',
180
+ err
181
+ )
179
182
  errorsThrown.push(err)
180
183
  })
181
184
 
182
185
  if (indexSearch) {
183
186
  if (onProgress) onProgress(currentStep++ / stepsTotalNum, 'fetching_parent_workflow_data')
184
187
  // raw workflow from parent consultation (contains first and last name of patient)
185
- let rawConsultationManifest = await oroClient.getLockboxManifest(lockboxUuid!, { category: MetadataCategory.Raw, consultationId: consultRequest.uuidParent }, false)
188
+ let rawConsultationManifest = await oroClient.getLockboxManifest(
189
+ lockboxUuid!,
190
+ { category: MetadataCategory.Raw, consultationId: consultRequest.uuidParent },
191
+ false
192
+ )
186
193
  if (rawConsultationManifest && rawConsultationManifest.length > 0) {
187
- let rawConsultation = await oroClient.getJsonData<WorkflowData>(lockboxUuid!, rawConsultationManifest[0].dataUuid)
194
+ let rawConsultation = await oroClient.getJsonData<WorkflowData>(
195
+ lockboxUuid!,
196
+ rawConsultationManifest[0].dataUuid
197
+ )
188
198
  if (onProgress) onProgress(currentStep++ / stepsTotalNum, 'search_indexing')
189
199
  await buildConsultSearchIndex(newConsult, rawConsultation, oroClient).catch((err) => {
190
200
  console.error(
@@ -195,9 +205,7 @@ export async function createRefill(
195
205
  errorsThrown.push(err)
196
206
  })
197
207
  } else {
198
- console.error(
199
- '[SDK: prescription refill request] parent consultation\'s raw data not found',
200
- )
208
+ console.error("[SDK: prescription refill request] parent consultation's raw data not found")
201
209
  errorsThrown.push(Error('RawData Not Found'))
202
210
  }
203
211
  }
@@ -214,9 +222,10 @@ export async function createRefill(
214
222
 
215
223
  await oroClient.cleanIndex()
216
224
  break
217
-
218
225
  } catch (err) {
219
- console.error(`[SDK] Error occured during prescription refill request: ${err}, retrying... Retries remaining: ${retry}`)
226
+ console.error(
227
+ `[SDK] Error occured during prescription refill request: ${err}, retrying... Retries remaining: ${retry}`
228
+ )
220
229
  errorsThrown = []
221
230
  continue
222
231
  }