oro-sdk 6.0.2 → 6.1.0
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/dist/helpers/workflow.d.ts +8 -0
- package/dist/oro-sdk.cjs.development.js +81 -34
- package/dist/oro-sdk.cjs.development.js.map +1 -1
- package/dist/oro-sdk.cjs.production.min.js +1 -1
- package/dist/oro-sdk.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk.esm.js +81 -35
- package/dist/oro-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/patient-registration.ts +12 -8
- package/src/helpers/workflow.ts +48 -7
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "6.0
|
2
|
+
"version": "6.1.0",
|
3
3
|
"main": "dist/index.js",
|
4
4
|
"typings": "dist/index.d.ts",
|
5
5
|
"files": [
|
@@ -55,7 +55,7 @@
|
|
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": "~6.0
|
58
|
+
"oro-sdk-apis": "~6.1.0",
|
59
59
|
"oro-toolbox": "0.0.6",
|
60
60
|
"uuid": "^8.3.2"
|
61
61
|
}
|
@@ -21,6 +21,7 @@ import {
|
|
21
21
|
WorkflowData,
|
22
22
|
} from 'oro-sdk-apis'
|
23
23
|
import {
|
24
|
+
detectChangesInWorkflowAnswers,
|
24
25
|
filterTriggeredAnsweredWithKind,
|
25
26
|
getImagesFromIndexDb,
|
26
27
|
getWorkflowDataByCategory,
|
@@ -81,6 +82,9 @@ export async function registerPatient(
|
|
81
82
|
const stepsTotalNum = 9
|
82
83
|
let currentStep: number
|
83
84
|
|
85
|
+
// toggle all changed statuses if this workflow has previous/revision data
|
86
|
+
workflow = detectChangesInWorkflowAnswers(workflow)
|
87
|
+
|
84
88
|
for (; retry > 0; retry--) {
|
85
89
|
try {
|
86
90
|
currentStep = 0
|
@@ -168,10 +172,10 @@ export async function registerPatient(
|
|
168
172
|
oroClient,
|
169
173
|
onProgress
|
170
174
|
? {
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
+
onProgress,
|
176
|
+
currentStep,
|
177
|
+
stepsTotalNum,
|
178
|
+
}
|
175
179
|
: undefined
|
176
180
|
).catch((err) => {
|
177
181
|
console.error('[SDK: registration] Some errors happened during image upload', err)
|
@@ -246,9 +250,9 @@ export async function registerPatient(
|
|
246
250
|
|
247
251
|
if (errorsThrown.length > 0) throw errorsThrown
|
248
252
|
|
249
|
-
if(
|
253
|
+
if (consult.statusMedical === MedicalStatus.Assigning) {
|
250
254
|
//hopefully svelte query received all updates
|
251
|
-
console.warn(
|
255
|
+
console.warn('Consult assignation took too much time, moving to new anyway')
|
252
256
|
}
|
253
257
|
// Deem the consultation as ready
|
254
258
|
await oroClient.consultClient.updateConsultByUUID(consult.uuid, {
|
@@ -443,11 +447,11 @@ async function storeImageAliases(
|
|
443
447
|
Math.round(
|
444
448
|
((progress.currentStep + 1) / progress.stepsTotalNum -
|
445
449
|
progress.currentStep / progress.stepsTotalNum) *
|
446
|
-
|
450
|
+
100
|
447
451
|
) / 100
|
448
452
|
progress.onProgress(
|
449
453
|
progress.currentStep / progress.stepsTotalNum +
|
450
|
-
|
454
|
+
progressStepValue * (storedImagesNum / totalImagesNum),
|
451
455
|
'store_images',
|
452
456
|
{
|
453
457
|
storedImagesNum,
|
package/src/helpers/workflow.ts
CHANGED
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
MetadataCategory,
|
5
5
|
PopulatedWorkflowData,
|
6
6
|
PopulatedWorkflowField,
|
7
|
+
PreviousAnswerData,
|
7
8
|
QuestionData,
|
8
9
|
SelectedAnswerData,
|
9
10
|
SelectedAnswersData,
|
@@ -85,14 +86,31 @@ export async function getWorkflowDataByCategory(
|
|
85
86
|
|
86
87
|
const fields: Record<string, PopulatedWorkflowField> = {}
|
87
88
|
|
89
|
+
let answersPerPage = (workflowData.selectedAnswers ?? [])
|
90
|
+
.map((pageAnswers, _) =>
|
91
|
+
Object.entries(pageAnswers)
|
92
|
+
.map(([k, v]) => [k, v, undefined]) as [string, SelectedAnswerData, PreviousAnswerData | undefined][])
|
93
|
+
|
94
|
+
if (workflowData.previousAnswers) {
|
95
|
+
// Since the selectedAnswers and previousAnswers should be a 1-1, we can map them together
|
96
|
+
answersPerPage = answersPerPage
|
97
|
+
.map((pageAnswers, pageIndex) => pageAnswers
|
98
|
+
.map(([questionId, v]): [string, SelectedAnswerData, PreviousAnswerData | undefined] => {
|
99
|
+
let previousAnswer = undefined
|
100
|
+
if (workflowData.previousAnswers && workflowData.previousAnswers[pageIndex][questionId])
|
101
|
+
previousAnswer = workflowData.previousAnswers[pageIndex][questionId]
|
102
|
+
return [questionId, v, previousAnswer]
|
103
|
+
}
|
104
|
+
))
|
105
|
+
}
|
106
|
+
|
88
107
|
// Generates the answers of the specified category and adds the appropriate values if any are missing
|
89
108
|
return Promise.all(
|
90
|
-
|
91
|
-
.
|
92
|
-
.
|
93
|
-
.
|
94
|
-
|
95
|
-
return populateWorkflowField(triggeredQuestions[k], v).then((populatedValue) => {
|
109
|
+
answersPerPage
|
110
|
+
.flat(1) // remove the pages, we want the answers all together
|
111
|
+
.filter(([k]) => triggeredQuestions[k] && triggeredQuestions[k]['metaCategory'] === category)
|
112
|
+
.map(([k, v, p]) => {
|
113
|
+
return populateWorkflowField(triggeredQuestions[k], v, p).then((populatedValue) => {
|
96
114
|
fields[k] = populatedValue
|
97
115
|
})
|
98
116
|
})
|
@@ -127,7 +145,8 @@ export async function getImagesFromIndexDb(answer: SelectedAnswerData): Promise<
|
|
127
145
|
*/
|
128
146
|
async function populateWorkflowField(
|
129
147
|
question: QuestionData,
|
130
|
-
answerValue: SelectedAnswerData
|
148
|
+
answerValue: SelectedAnswerData,
|
149
|
+
previousAnswer?: PreviousAnswerData
|
131
150
|
): Promise<PopulatedWorkflowField> {
|
132
151
|
let answer: any
|
133
152
|
let displayedAnswer: string | string[] | undefined = undefined
|
@@ -175,6 +194,7 @@ async function populateWorkflowField(
|
|
175
194
|
return Promise.resolve({
|
176
195
|
answer,
|
177
196
|
displayedAnswer,
|
197
|
+
previousAnswer,
|
178
198
|
kind: question.kind,
|
179
199
|
})
|
180
200
|
}
|
@@ -297,3 +317,24 @@ export function fillWorkflowFromPopulatedWorkflow(workflow: WorkflowData, popula
|
|
297
317
|
|
298
318
|
return filledWorkflow
|
299
319
|
}
|
320
|
+
|
321
|
+
/**
|
322
|
+
* Checks and toggles the changed status for every answer in the workflow
|
323
|
+
* by comparing the previous answer with the selected answer of the same question
|
324
|
+
*
|
325
|
+
* @param workflow
|
326
|
+
* @returns the workflow with the updated `changed` statuses
|
327
|
+
*/
|
328
|
+
export function detectChangesInWorkflowAnswers(workflow: WorkflowData): WorkflowData {
|
329
|
+
return {
|
330
|
+
...workflow,
|
331
|
+
previousAnswers: workflow.previousAnswers ?
|
332
|
+
Object.fromEntries(workflow.previousAnswers
|
333
|
+
.map((pageAnswers, pageId) => Object.entries(pageAnswers).map(([question, answer]) => {
|
334
|
+
let selectedAnswer = undefined
|
335
|
+
if (workflow.selectedAnswers && workflow.selectedAnswers[pageId][question])
|
336
|
+
selectedAnswer = workflow.selectedAnswers[pageId][question]
|
337
|
+
return [question, { ...answer, changed: selectedAnswer === answer.previousAnswer }]
|
338
|
+
}))) : undefined
|
339
|
+
}
|
340
|
+
}
|