tango-app-api-trax 3.7.70 → 3.7.71
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
|
@@ -714,10 +714,13 @@ export async function sopMobileTaskQuestionValidator( req, res, next ) {
|
|
|
714
714
|
section.questions.forEach( ( question ) => {
|
|
715
715
|
question.answers.forEach( ( answer ) => {
|
|
716
716
|
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qno == question.qno );
|
|
717
|
-
if (
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
717
|
+
if ( sectionQuestion[0] ) {
|
|
718
|
+
const multianswerEmpty = sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer?.length;
|
|
719
|
+
const answerEmpty = ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) );
|
|
720
|
+
const usesMultianswer = [ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( question.answerType ) || ( question.answerType == 'dropdown' && question.allowMultiple );
|
|
721
|
+
if ( usesMultianswer && multianswerEmpty ) {
|
|
722
|
+
validationCount++;
|
|
723
|
+
} else if ( !usesMultianswer && answerEmpty ) {
|
|
721
724
|
validationCount++;
|
|
722
725
|
}
|
|
723
726
|
}
|
|
@@ -1210,6 +1213,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1210
1213
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1211
1214
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1212
1215
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1216
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1213
1217
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1214
1218
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1215
1219
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1267,6 +1271,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1267
1271
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1268
1272
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1269
1273
|
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1274
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1270
1275
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1271
1276
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1272
1277
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1328,6 +1333,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1328
1333
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1329
1334
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1330
1335
|
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1336
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1331
1337
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1332
1338
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1333
1339
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1398,6 +1404,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1398
1404
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1399
1405
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1400
1406
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1407
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1401
1408
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1402
1409
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1403
1410
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1445,13 +1452,27 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1445
1452
|
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1446
1453
|
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1447
1454
|
if ( qaAnswers[j].compliance ) {
|
|
1448
|
-
|
|
1455
|
+
if ( qaAnswers[j].compliance ) {
|
|
1456
|
+
let ansArray = requestSection[i].answer.split( ',' );
|
|
1457
|
+
if ( ansArray.includes( '-' ) ) {
|
|
1458
|
+
ansArray = requestSection[i].answer.split( '-' );
|
|
1459
|
+
}
|
|
1460
|
+
if ( ansArray.length > 1 && ansArray.some( ( date ) => dayjs( date, 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate || dayjs( date, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1461
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1462
|
+
} else if ( ansArray.length > 1 && ( dayjs( ansArray?.[0], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate || dayjs( ansArray?.[1], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1463
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1464
|
+
} else if ( dayjs( requestSection[i].answer, 'DD MMM YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate || dayjs( requestSection[i].answer, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.startDate ) {
|
|
1465
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1466
|
+
} else {
|
|
1467
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1449
1470
|
}
|
|
1450
1471
|
}
|
|
1451
1472
|
if ( qaAnswers[j].answerType == 'linearscale' ) {
|
|
1452
|
-
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1453
1473
|
if ( qaAnswers[j].compliance ) {
|
|
1454
|
-
|
|
1474
|
+
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1475
|
+
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue || parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1455
1476
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1456
1477
|
} else {
|
|
1457
1478
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
@@ -1487,6 +1508,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1487
1508
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1488
1509
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1489
1510
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1511
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1490
1512
|
if ( qaAnswers[j]?.taskId ) {
|
|
1491
1513
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1492
1514
|
structure.task = true;
|
|
@@ -1533,7 +1555,7 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1533
1555
|
|
|
1534
1556
|
if ( requestData.submittype == 'submit' ) {
|
|
1535
1557
|
reqAnswers.forEach( ( reqA ) => {
|
|
1536
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( reqA?.answerType ) ) {
|
|
1558
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && !( reqA?.answerType == 'dropdown' && reqA?.allowMultiple ) ) {
|
|
1537
1559
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
1538
1560
|
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1539
1561
|
}
|
|
@@ -1714,8 +1736,64 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1714
1736
|
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1715
1737
|
};
|
|
1716
1738
|
newArray.push( structure );
|
|
1739
|
+
} else if ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) {
|
|
1740
|
+
let qaans = qaAnswers[j].answers;
|
|
1741
|
+
let mcmo = [];
|
|
1742
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1743
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1744
|
+
if ( separatedArray && separatedArray.length ) {
|
|
1745
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1746
|
+
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1747
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1748
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1749
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1750
|
+
if ( validationAnswer.length ) {
|
|
1751
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1752
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1753
|
+
splitImgUrl.splice( 0, 3 );
|
|
1754
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
} else {
|
|
1759
|
+
qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1760
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1761
|
+
}
|
|
1762
|
+
mcmo.push( qaans[k] );
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
let structure = {};
|
|
1768
|
+
structure.qno = qaAnswers[j].qno;
|
|
1769
|
+
structure.qname = qaAnswers[j].qname;
|
|
1770
|
+
if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
|
|
1771
|
+
structure.qcomment = qaAnswers[j].qcomment;
|
|
1772
|
+
}
|
|
1773
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1774
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1775
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1776
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1777
|
+
structure.remarks = requestSection[i].remarks;
|
|
1778
|
+
structure.answers = qaAnswers[j].answers;
|
|
1779
|
+
structure.userAnswer = mcmo;
|
|
1780
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1781
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1782
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1783
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1784
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1785
|
+
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1786
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1787
|
+
structure.redo = false;
|
|
1788
|
+
} else if ( requestData.submittype === 'draft' ) {
|
|
1789
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1790
|
+
}
|
|
1791
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1792
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1793
|
+
};
|
|
1794
|
+
newArray.push( structure );
|
|
1717
1795
|
} else if ( qaAnswers[j].answerType == 'multipleImage' ) {
|
|
1718
|
-
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1796
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : ( requestSection[i].Multianswer || [] );
|
|
1719
1797
|
let mcmi = [];
|
|
1720
1798
|
// for (let k = 0; k < qaans.length; k++) {
|
|
1721
1799
|
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
@@ -1773,6 +1851,69 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1773
1851
|
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1774
1852
|
};
|
|
1775
1853
|
newArray.push( structure );
|
|
1854
|
+
} else if ( qaAnswers[j].answerType == 'image/video' ) {
|
|
1855
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1856
|
+
let mcmi = [];
|
|
1857
|
+
if ( separatedArray && separatedArray.length ) {
|
|
1858
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1859
|
+
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1860
|
+
let newAnswer = {};
|
|
1861
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1862
|
+
if ( validationAnswer.length ) {
|
|
1863
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1864
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1865
|
+
splitImgUrl.splice( 0, 3 );
|
|
1866
|
+
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
newAnswer.answeroptionNumber = 0;
|
|
1870
|
+
newAnswer.sopFlag = false;
|
|
1871
|
+
newAnswer.validation = false;
|
|
1872
|
+
newAnswer.validationType = '';
|
|
1873
|
+
newAnswer.referenceImage = '';
|
|
1874
|
+
newAnswer.allowUploadfromGallery = false;
|
|
1875
|
+
newAnswer.descriptivetype = '';
|
|
1876
|
+
newAnswer.showLinked = false;
|
|
1877
|
+
newAnswer.linkedQuestion = 0;
|
|
1878
|
+
newAnswer.nestedQuestion = [];
|
|
1879
|
+
newAnswer.index = s;
|
|
1880
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1881
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1882
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1883
|
+
if ( separatedArray[s].answerType ) {
|
|
1884
|
+
newAnswer.answerType = separatedArray[s].answerType;
|
|
1885
|
+
}
|
|
1886
|
+
mcmi.push( newAnswer );
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
let structure = {};
|
|
1891
|
+
structure.qno = qaAnswers[j].qno;
|
|
1892
|
+
structure.qname = qaAnswers[j].qname;
|
|
1893
|
+
if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
|
|
1894
|
+
structure.qcomment = qaAnswers[j].qcomment;
|
|
1895
|
+
}
|
|
1896
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1897
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1898
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1899
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1900
|
+
structure.remarks = requestSection[i].remarks;
|
|
1901
|
+
structure.answers = qaAnswers[j].answers;
|
|
1902
|
+
structure.userAnswer = mcmi;
|
|
1903
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1904
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1905
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1906
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1907
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1908
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1909
|
+
structure.redo = false;
|
|
1910
|
+
} else if ( requestData.submittype === 'draft' ) {
|
|
1911
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1912
|
+
}
|
|
1913
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1914
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1915
|
+
};
|
|
1916
|
+
newArray.push( structure );
|
|
1776
1917
|
} else {
|
|
1777
1918
|
let des = [];
|
|
1778
1919
|
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|