tango-app-api-trax 3.9.54 → 3.9.56
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
|
@@ -2150,14 +2150,6 @@ export async function sopMobilechecklistMultiSectionFormatterv2( req, res, next
|
|
|
2150
2150
|
if ( question.compliance ) {
|
|
2151
2151
|
const scores = ( question.userAnswer || [] ).map( ( ua ) => ua?.complianceScore ?? 0 );
|
|
2152
2152
|
let score = scores.length ? Math.max( ...scores ) : 0;
|
|
2153
|
-
// Single-choice questions answered 'NA' / 'N/A' (case-insensitive) score 0,
|
|
2154
|
-
// matching the visit-checklist PDF and dashboard compliance calculation.
|
|
2155
|
-
if ( question.answerType === 'multiplechoicesingle' ) {
|
|
2156
|
-
const naAnswer = ( question.userAnswer?.[0]?.answer || '' ).toString().trim().toLowerCase();
|
|
2157
|
-
if ( naAnswer === 'na' || naAnswer === 'n/a' ) {
|
|
2158
|
-
score = 0;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
2153
|
requestData.userComplianceCount += score;
|
|
2162
2154
|
}
|
|
2163
2155
|
}
|
|
@@ -326,83 +326,6 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
326
326
|
// },
|
|
327
327
|
// } );
|
|
328
328
|
|
|
329
|
-
// Recompute compliance per submission straight from questionAnswers so the
|
|
330
|
-
// dashboard % matches the visit-checklist PDF: a 'multiplechoicesingle'
|
|
331
|
-
// question answered 'NA'/'N/A' (case-insensitive) is excluded from BOTH the
|
|
332
|
-
// score (numerator) and the max (denominator). Non-compliance questions and
|
|
333
|
-
// non-NA questions keep the existing max/score formula.
|
|
334
|
-
findQuery.push( {
|
|
335
|
-
$addFields: {
|
|
336
|
-
naAwareCompliance: {
|
|
337
|
-
$reduce: {
|
|
338
|
-
input: { $ifNull: [ '$questionAnswers', [] ] },
|
|
339
|
-
initialValue: { score: 0, max: 0 },
|
|
340
|
-
in: {
|
|
341
|
-
$reduce: {
|
|
342
|
-
input: { $ifNull: [ '$$this.questions', [] ] },
|
|
343
|
-
initialValue: '$$value',
|
|
344
|
-
in: {
|
|
345
|
-
$let: {
|
|
346
|
-
vars: {
|
|
347
|
-
// Count this question's score/max unless it is a single-choice
|
|
348
|
-
// question answered NA/N/A, or a non-compliance question.
|
|
349
|
-
countIt: {
|
|
350
|
-
$and: [
|
|
351
|
-
{ $toBool: { $ifNull: [ '$$this.compliance', false ] } },
|
|
352
|
-
{ $not: [ {
|
|
353
|
-
$and: [
|
|
354
|
-
{ $eq: [ '$$this.answerType', 'multiplechoicesingle' ] },
|
|
355
|
-
{ $in: [
|
|
356
|
-
{ $toLower: { $trim: { input: { $convert: {
|
|
357
|
-
input: { $arrayElemAt: [ { $ifNull: [ '$$this.userAnswer.answer', [] ] }, 0 ] },
|
|
358
|
-
to: 'string', onError: '', onNull: '',
|
|
359
|
-
} } } } },
|
|
360
|
-
[ 'na', 'n/a' ],
|
|
361
|
-
] },
|
|
362
|
-
],
|
|
363
|
-
} ] },
|
|
364
|
-
],
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
in: {
|
|
368
|
-
score: {
|
|
369
|
-
$add: [
|
|
370
|
-
'$$value.score',
|
|
371
|
-
{ $cond: [
|
|
372
|
-
'$$countIt',
|
|
373
|
-
{ $ifNull: [ { $max: { $map: {
|
|
374
|
-
input: { $ifNull: [ '$$this.userAnswer', [] ] },
|
|
375
|
-
as: 'u',
|
|
376
|
-
in: { $ifNull: [ '$$u.complianceScore', 0 ] },
|
|
377
|
-
} } }, 0 ] },
|
|
378
|
-
0,
|
|
379
|
-
] },
|
|
380
|
-
],
|
|
381
|
-
},
|
|
382
|
-
max: {
|
|
383
|
-
$add: [
|
|
384
|
-
'$$value.max',
|
|
385
|
-
{ $cond: [
|
|
386
|
-
'$$countIt',
|
|
387
|
-
{ $ifNull: [ { $max: { $map: {
|
|
388
|
-
input: { $ifNull: [ '$$this.answers', [] ] },
|
|
389
|
-
as: 'o',
|
|
390
|
-
in: { $ifNull: [ '$$o.complianceScore', { $max: [ { $ifNull: [ '$$o.matchedCount', 0 ] }, { $ifNull: [ '$$o.notMatchedCount', 0 ] } ] } ] },
|
|
391
|
-
} } }, 0 ] },
|
|
392
|
-
0,
|
|
393
|
-
] },
|
|
394
|
-
],
|
|
395
|
-
},
|
|
396
|
-
},
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
},
|
|
401
|
-
},
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
} );
|
|
405
|
-
|
|
406
329
|
findQuery.push( {
|
|
407
330
|
$group: {
|
|
408
331
|
_id: '$sourceCheckList_id',
|
|
@@ -421,24 +344,16 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
421
344
|
timeFlag: { $sum: '$timeFlag' },
|
|
422
345
|
questionFlagCount: { $sum: '$questionFlag' },
|
|
423
346
|
runAIFlagCount: { $sum: '$runAIFlag' },
|
|
424
|
-
|
|
347
|
+
userComplianceCountTotal: {
|
|
425
348
|
$sum: {
|
|
426
349
|
$cond: [
|
|
427
350
|
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
428
|
-
{ $ifNull: [ '$
|
|
429
|
-
0,
|
|
430
|
-
],
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
complianceMaxTotal: {
|
|
434
|
-
$sum: {
|
|
435
|
-
$cond: [
|
|
436
|
-
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
437
|
-
{ $ifNull: [ '$naAwareCompliance.max', 0 ] },
|
|
351
|
+
{ $ifNull: [ '$userComplianceCount', 0 ] },
|
|
438
352
|
0,
|
|
439
353
|
],
|
|
440
354
|
},
|
|
441
355
|
},
|
|
356
|
+
complianceCount: { $first: '$complianceCount' },
|
|
442
357
|
checkListType: { $last: '$checkListType' },
|
|
443
358
|
redo: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
|
|
444
359
|
task: {
|
|
@@ -499,26 +414,34 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
499
414
|
redo: 1,
|
|
500
415
|
task: 1,
|
|
501
416
|
questionCompliance: {
|
|
502
|
-
$
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
417
|
+
$let: {
|
|
418
|
+
vars: {
|
|
419
|
+
divisor: {
|
|
420
|
+
$cond: [
|
|
421
|
+
{ $gt: [ '$submittedChecklist', 1 ] },
|
|
422
|
+
{ $multiply: [ { $ifNull: [ '$complianceCount', 0 ] }, '$submittedChecklist' ] },
|
|
423
|
+
{ $ifNull: [ '$complianceCount', 0 ] },
|
|
424
|
+
],
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
in: {
|
|
428
|
+
$cond: [
|
|
429
|
+
{ $gt: [ '$$divisor', 0 ] },
|
|
507
430
|
{
|
|
508
431
|
$round: [
|
|
509
432
|
{
|
|
510
433
|
$multiply: [
|
|
511
|
-
{ $divide: [ '$
|
|
434
|
+
{ $divide: [ '$userComplianceCountTotal', '$$divisor' ] },
|
|
512
435
|
100,
|
|
513
436
|
],
|
|
514
437
|
},
|
|
515
438
|
0,
|
|
516
439
|
],
|
|
517
440
|
},
|
|
441
|
+
0,
|
|
518
442
|
],
|
|
519
443
|
},
|
|
520
|
-
|
|
521
|
-
],
|
|
444
|
+
},
|
|
522
445
|
},
|
|
523
446
|
},
|
|
524
447
|
} );
|
|
@@ -540,7 +463,7 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
540
463
|
},
|
|
541
464
|
} );
|
|
542
465
|
let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
|
|
543
|
-
if ( !getChecklistPerformanceData
|
|
466
|
+
if ( !getChecklistPerformanceData[0].data.length ) {
|
|
544
467
|
return res.sendError( 'no data found', 204 );
|
|
545
468
|
}
|
|
546
469
|
|