tango-app-api-trax 3.8.31 → 3.9.1
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 +2 -2
- package/src/controllers/download.controller.js +19 -19
- package/src/controllers/gallery.controller.js +31 -88
- package/src/controllers/handlebar-helper.js +1 -0
- package/src/controllers/internalTrax.controller.js +11 -11
- package/src/controllers/mobileTrax.controller.js +539 -33
- package/src/controllers/teaxFlag.controller.js +5 -5
- package/src/controllers/trax.controller.js +2 -2
- package/src/hbs/recurringFlag.hbs +250 -250
- package/src/hbs/weeklyWrap.hbs +218 -218
- package/src/routes/mobileTrax.routes.js +1 -0
- package/src/utils/visitChecklistPdf.utils.js +1 -1
|
@@ -118,7 +118,7 @@ export async function startChecklist( req, res ) {
|
|
|
118
118
|
$and: [
|
|
119
119
|
{ _id: new ObjectId( requestData.processedcheckListId ) },
|
|
120
120
|
{ userId: req.user._id },
|
|
121
|
-
{
|
|
121
|
+
{ date_string: requestData.date },
|
|
122
122
|
],
|
|
123
123
|
},
|
|
124
124
|
} );
|
|
@@ -1079,6 +1079,499 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
1079
1079
|
};
|
|
1080
1080
|
|
|
1081
1081
|
export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next ) {
|
|
1082
|
+
try {
|
|
1083
|
+
let requestData = req.body;
|
|
1084
|
+
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1085
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1086
|
+
let reqAnswers = requestData.questionAnswers;
|
|
1087
|
+
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1088
|
+
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1089
|
+
|
|
1090
|
+
if ( requestData.submittype == 'submit' ) {
|
|
1091
|
+
reqAnswers.forEach( ( reqA ) => {
|
|
1092
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA.answerType == 'dropDown' && !reqA.allowMultiple ) ) {
|
|
1093
|
+
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
1094
|
+
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
} );
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
if ( requestData?.editSubmit && requestData?.editSubmit == 'true' ) {
|
|
1101
|
+
let sampleData = reqAnswers[0];
|
|
1102
|
+
CLQAnswers.forEach( ( section ) => {
|
|
1103
|
+
let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
|
|
1104
|
+
if ( requestSection.length ) {
|
|
1105
|
+
requestSection.forEach( ( item ) => item.section_id = section.section_id );
|
|
1106
|
+
section.questions.forEach( ( question ) => {
|
|
1107
|
+
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
1108
|
+
if ( !sectionQuestion.length ) {
|
|
1109
|
+
let data = { ...requestSection[0] };
|
|
1110
|
+
data.answerType = question.answerType;
|
|
1111
|
+
data.qno = question.qno;
|
|
1112
|
+
data.uniqueqno = question.uniqueqno;
|
|
1113
|
+
data.uniqueqid = question.uniqueqid;
|
|
1114
|
+
data.qname = question.qname;
|
|
1115
|
+
data.oldQname = question?.oldQname || question.qname;
|
|
1116
|
+
data.answer = 'null';
|
|
1117
|
+
data.remarks = '';
|
|
1118
|
+
data.validationAnswer = '';
|
|
1119
|
+
data.Multianswer = [];
|
|
1120
|
+
data.linkType = question.linkType;
|
|
1121
|
+
data.linkquestionenabled = question.linkType;
|
|
1122
|
+
data.linkedQuestion = null;
|
|
1123
|
+
data.showLinked = null;
|
|
1124
|
+
data.parentanswer = '';
|
|
1125
|
+
data.dateRangeType = false;
|
|
1126
|
+
reqAnswers.push( data );
|
|
1127
|
+
}
|
|
1128
|
+
} );
|
|
1129
|
+
} else {
|
|
1130
|
+
section.questions.forEach( ( ele ) => {
|
|
1131
|
+
let data = { ...sampleData };
|
|
1132
|
+
data.section_id = section.section_id;
|
|
1133
|
+
data.sectionName = section.sectionName;
|
|
1134
|
+
data.answerType = ele.answerType;
|
|
1135
|
+
data.qno = ele.qno;
|
|
1136
|
+
data.uniqueqno = ele.uniqueqno;
|
|
1137
|
+
data.uniqueqid = ele.uniqueqid;
|
|
1138
|
+
data.qname = ele.qname;
|
|
1139
|
+
data.oldQname = ele?.oldQname || ele.qname;
|
|
1140
|
+
data.answer = 'null';
|
|
1141
|
+
data.remarks = '';
|
|
1142
|
+
data.validationAnswer = '';
|
|
1143
|
+
data.Multianswer = [];
|
|
1144
|
+
data.linkType = ele.linkType;
|
|
1145
|
+
data.linkquestionenabled = ele.linkType;
|
|
1146
|
+
data.linkedQuestion = null;
|
|
1147
|
+
data.showLinked = null;
|
|
1148
|
+
data.parentanswer = '';
|
|
1149
|
+
data.dateRangeType = false;
|
|
1150
|
+
reqAnswers.push( data );
|
|
1151
|
+
} );
|
|
1152
|
+
}
|
|
1153
|
+
} );
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
let sectionFormat = [];
|
|
1157
|
+
let uniqueSections = {};
|
|
1158
|
+
reqAnswers.forEach( ( item ) => {
|
|
1159
|
+
const key = `${item.section_id}-${item.sectionName}`;
|
|
1160
|
+
if ( !uniqueSections[key] ) {
|
|
1161
|
+
uniqueSections[key] = { id: item.section_id, name: item.sectionName };
|
|
1162
|
+
}
|
|
1163
|
+
} );
|
|
1164
|
+
const uniqueArray = Object.values( uniqueSections );
|
|
1165
|
+
for ( let section of uniqueArray ) {
|
|
1166
|
+
let CLQSection = CLQAnswers.find( ( item ) => item.section_id.toString() == section.id.toString() );
|
|
1167
|
+
if ( CLQSection ) {
|
|
1168
|
+
let newArray = [];
|
|
1169
|
+
let qaAnswers = CLQSection.questions;
|
|
1170
|
+
let requestSection = reqAnswers.filter( ( item ) => item.section_id == section.id );
|
|
1171
|
+
for ( let i = 0; i < requestSection.length; i++ ) {
|
|
1172
|
+
for ( let j = 0; j < qaAnswers.length; j++ ) {
|
|
1173
|
+
if ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) {
|
|
1174
|
+
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1175
|
+
let qaans = qaAnswers[j].answers;
|
|
1176
|
+
let yn = [];
|
|
1177
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1178
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1179
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1180
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1181
|
+
let validateAns = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1182
|
+
if ( validateAns.length ) {
|
|
1183
|
+
let splitImgUrl = validateAns.split( '/' );
|
|
1184
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1185
|
+
splitImgUrl.splice( 0, 3 );
|
|
1186
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
} else {
|
|
1191
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1192
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1193
|
+
}
|
|
1194
|
+
yn.push( qaans[k] );
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
let structure = {};
|
|
1198
|
+
structure.qno = qaAnswers[j].qno;
|
|
1199
|
+
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1200
|
+
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1201
|
+
structure.qname = qaAnswers[j].qname;
|
|
1202
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1203
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1204
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1205
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1206
|
+
structure.remarks = requestSection[i].remarks;
|
|
1207
|
+
structure.answers = qaAnswers[j].answers;
|
|
1208
|
+
structure.userAnswer = yn;
|
|
1209
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1210
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1211
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1212
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1213
|
+
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1214
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1215
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1216
|
+
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1217
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1218
|
+
if ( qaAnswers[j]?.taskId ) {
|
|
1219
|
+
structure.taskId = qaAnswers[j]?.taskId;
|
|
1220
|
+
structure.task = true;
|
|
1221
|
+
}
|
|
1222
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1223
|
+
structure.redo = false;
|
|
1224
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1225
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1226
|
+
}
|
|
1227
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1228
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1229
|
+
};
|
|
1230
|
+
newArray.push( structure );
|
|
1231
|
+
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' || ( qaAnswers[j].answerType == 'dropdown' && !qaAnswers[j].allowMultiple ) ) {
|
|
1232
|
+
let qaans = qaAnswers[j].answers;
|
|
1233
|
+
let ms = [];
|
|
1234
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1235
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1236
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1237
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1238
|
+
let validationAnswer = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1239
|
+
if ( validationAnswer.length ) {
|
|
1240
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1241
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1242
|
+
splitImgUrl.splice( 0, 3 );
|
|
1243
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
} else {
|
|
1248
|
+
if ( qaans[k].validationType == 'Capture Multiple Image with description' ) {
|
|
1249
|
+
qaans[k]['validationImage']=[];
|
|
1250
|
+
if ( requestSection[i].validationImage.length ) {
|
|
1251
|
+
for ( let image of requestSection[i].validationImage ) {
|
|
1252
|
+
let validationAnswer = decodeURIComponent( image.split( '?' )[0] );
|
|
1253
|
+
if ( validationAnswer.length ) {
|
|
1254
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1255
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1256
|
+
splitImgUrl.splice( 0, 3 );
|
|
1257
|
+
qaans[k].validationImage.push( splitImgUrl.join( '/' ) || '' );
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1264
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1265
|
+
}
|
|
1266
|
+
ms.push( qaans[k] );
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
let structure = {};
|
|
1270
|
+
structure.qno = qaAnswers[j].qno;
|
|
1271
|
+
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1272
|
+
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1273
|
+
structure.qname = qaAnswers[j].qname;
|
|
1274
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1275
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1276
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1277
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1278
|
+
structure.remarks = requestSection[i].remarks;
|
|
1279
|
+
structure.answers = qaAnswers[j].answers;
|
|
1280
|
+
structure.userAnswer = ms;
|
|
1281
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1282
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1283
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1284
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1285
|
+
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1286
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1287
|
+
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1288
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1289
|
+
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1290
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1291
|
+
if ( qaAnswers[j]?.taskId ) {
|
|
1292
|
+
structure.taskId = qaAnswers[j]?.taskId;
|
|
1293
|
+
structure.task = true;
|
|
1294
|
+
}
|
|
1295
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1296
|
+
structure.redo = false;
|
|
1297
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1298
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1299
|
+
}
|
|
1300
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1301
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1302
|
+
};
|
|
1303
|
+
newArray.push( structure );
|
|
1304
|
+
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' || ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) ) {
|
|
1305
|
+
let qaans = qaAnswers[j].answers;
|
|
1306
|
+
let mcmo = [];
|
|
1307
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1308
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1309
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1310
|
+
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1311
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1312
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1313
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1314
|
+
if ( validationAnswer.length ) {
|
|
1315
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1316
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1317
|
+
splitImgUrl.splice( 0, 3 );
|
|
1318
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
} else {
|
|
1323
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1324
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
mcmo.push( qaans[k] );
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
let structure = {};
|
|
1332
|
+
structure.qno = qaAnswers[j].qno;
|
|
1333
|
+
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1334
|
+
structure.qno = qaAnswers[j].qno;
|
|
1335
|
+
structure.qname = qaAnswers[j].qname;
|
|
1336
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1337
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1338
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1339
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1340
|
+
structure.remarks = requestSection[i].remarks;
|
|
1341
|
+
structure.answers = qaAnswers[j].answers;
|
|
1342
|
+
structure.userAnswer = mcmo;
|
|
1343
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1344
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1345
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1346
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1347
|
+
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1348
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1349
|
+
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1350
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1351
|
+
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1352
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1353
|
+
if ( qaAnswers[j]?.taskId ) {
|
|
1354
|
+
structure.taskId = qaAnswers[j]?.taskId;
|
|
1355
|
+
structure.task = true;
|
|
1356
|
+
}
|
|
1357
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1358
|
+
structure.redo = false;
|
|
1359
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1360
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1361
|
+
}
|
|
1362
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1363
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1364
|
+
};
|
|
1365
|
+
newArray.push( structure );
|
|
1366
|
+
} else if ( [ 'image/video', 'multipleImage' ].includes( qaAnswers[j].answerType ) ) {
|
|
1367
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1368
|
+
let mcmi = [];
|
|
1369
|
+
// for (let k = 0; k < qaans.length; k++) {
|
|
1370
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1371
|
+
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1372
|
+
let newAnswer = {};
|
|
1373
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1374
|
+
if ( validationAnswer.length ) {
|
|
1375
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1376
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1377
|
+
splitImgUrl.splice( 0, 3 );
|
|
1378
|
+
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
newAnswer.answeroptionNumber = 0;
|
|
1383
|
+
newAnswer.sopFlag = false;
|
|
1384
|
+
newAnswer.validation = false;
|
|
1385
|
+
newAnswer.validationType = '';
|
|
1386
|
+
newAnswer.referenceImage = '';
|
|
1387
|
+
newAnswer.allowUploadfromGallery = false;
|
|
1388
|
+
newAnswer.descriptivetype = '';
|
|
1389
|
+
newAnswer.showLinked = false;
|
|
1390
|
+
newAnswer.linkedQuestion = 0;
|
|
1391
|
+
newAnswer.nestedQuestion = [];
|
|
1392
|
+
newAnswer.index = s;
|
|
1393
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1394
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1395
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1396
|
+
if ( qaAnswers[j].answerType == 'image/video' ) {
|
|
1397
|
+
newAnswer.answerType = separatedArray[s].answerType;
|
|
1398
|
+
}
|
|
1399
|
+
mcmi.push( newAnswer );
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
// }
|
|
1403
|
+
let structure = {};
|
|
1404
|
+
structure.qno = qaAnswers[j].qno;
|
|
1405
|
+
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1406
|
+
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1407
|
+
structure.qname = qaAnswers[j].qname;
|
|
1408
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1409
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1410
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1411
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1412
|
+
structure.remarks = requestSection[i].remarks;
|
|
1413
|
+
structure.answers = qaAnswers[j].answers;
|
|
1414
|
+
structure.userAnswer = mcmi;
|
|
1415
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1416
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1417
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1418
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1419
|
+
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1420
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1421
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1422
|
+
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1423
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1424
|
+
if ( qaAnswers[j]?.taskId ) {
|
|
1425
|
+
structure.taskId = qaAnswers[j]?.taskId;
|
|
1426
|
+
structure.task = true;
|
|
1427
|
+
}
|
|
1428
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1429
|
+
structure.redo = false;
|
|
1430
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1431
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1432
|
+
}
|
|
1433
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1434
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1435
|
+
};
|
|
1436
|
+
newArray.push( structure );
|
|
1437
|
+
} else {
|
|
1438
|
+
let des = [];
|
|
1439
|
+
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1440
|
+
let validationAnswer = '';
|
|
1441
|
+
if ( requestSection[i].answer.split( '?' ).length > 1 || requestSection[i].answer.includes( 'https://' ) ) {
|
|
1442
|
+
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
1443
|
+
}
|
|
1444
|
+
if ( validationAnswer.length ) {
|
|
1445
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1446
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1447
|
+
splitImgUrl.splice( 0, 3 );
|
|
1448
|
+
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
let ansstructure = {
|
|
1452
|
+
answer: requestSection[i].answer,
|
|
1453
|
+
answeroptionNumber: 1,
|
|
1454
|
+
sopFlag: false,
|
|
1455
|
+
validation: false,
|
|
1456
|
+
validationType: '',
|
|
1457
|
+
validationAnswer: '',
|
|
1458
|
+
referenceImage: qaAnswers[j].answers[0].referenceImage || '',
|
|
1459
|
+
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1460
|
+
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1461
|
+
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1462
|
+
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1463
|
+
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1464
|
+
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1465
|
+
};
|
|
1466
|
+
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1467
|
+
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1468
|
+
if ( qaAnswers[j].compliance ) {
|
|
1469
|
+
if ( qaAnswers[j].compliance ) {
|
|
1470
|
+
let ansArray = requestSection[i].answer.split( ',' );
|
|
1471
|
+
if ( ansArray.includes( '-' ) ) {
|
|
1472
|
+
ansArray = requestSection[i].answer.split( '-' );
|
|
1473
|
+
}
|
|
1474
|
+
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 ) ) {
|
|
1475
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1476
|
+
} 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 ) ) {
|
|
1477
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1478
|
+
} 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]?.endDate ) {
|
|
1479
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1480
|
+
} else {
|
|
1481
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
if ( qaAnswers[j].answerType == 'linearscale' ) {
|
|
1487
|
+
if ( qaAnswers[j].compliance ) {
|
|
1488
|
+
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1489
|
+
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue && parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1490
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1491
|
+
} else {
|
|
1492
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
ansstructure.linearType = qaAnswers[j]?.answers[0]?.linearType;
|
|
1496
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1497
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1498
|
+
}
|
|
1499
|
+
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1500
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1501
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1502
|
+
}
|
|
1503
|
+
des.push( ansstructure );
|
|
1504
|
+
}
|
|
1505
|
+
let structure = {};
|
|
1506
|
+
structure.qno = qaAnswers[j].qno;
|
|
1507
|
+
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
1508
|
+
structure.uniqueqid = qaAnswers[j].uniqueqid;
|
|
1509
|
+
structure.qname = qaAnswers[j].qname;
|
|
1510
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1511
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1512
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1513
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1514
|
+
structure.remarks = requestSection[i].remarks;
|
|
1515
|
+
structure.answers = qaAnswers[j].answers;
|
|
1516
|
+
structure.userAnswer = des;
|
|
1517
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1518
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1519
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1520
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1521
|
+
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1522
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1523
|
+
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1524
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1525
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1526
|
+
if ( qaAnswers[j]?.taskId ) {
|
|
1527
|
+
structure.taskId = qaAnswers[j]?.taskId;
|
|
1528
|
+
structure.task = true;
|
|
1529
|
+
}
|
|
1530
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1531
|
+
structure.redo = false;
|
|
1532
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1533
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1534
|
+
}
|
|
1535
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1536
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1537
|
+
};
|
|
1538
|
+
newArray.push( structure );
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
let sectionData = {
|
|
1544
|
+
'section_id': section.id,
|
|
1545
|
+
'sectionName': section.name,
|
|
1546
|
+
'questions': newArray,
|
|
1547
|
+
};
|
|
1548
|
+
sectionFormat.push( sectionData );
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
requestData.questionAnswers = sectionFormat;
|
|
1554
|
+
logger.error( { message: requestData.questionAnswers, error: 'QuestionanswersPayload' } );
|
|
1555
|
+
|
|
1556
|
+
if ( requestData.submittype == 'submit' ) {
|
|
1557
|
+
for ( let section of sectionFormat ) {
|
|
1558
|
+
for ( let question of section.questions ) {
|
|
1559
|
+
let mustValidate = !question.linkType || ( question.linkType && question.linkquestionenabled );
|
|
1560
|
+
if ( mustValidate && ( !question.userAnswer || !question.userAnswer.length ) ) {
|
|
1561
|
+
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
next();
|
|
1568
|
+
} catch ( error ) {
|
|
1569
|
+
logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
|
|
1570
|
+
return res.sendError( error, 500 );
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
export async function sopMobilechecklistMultiSectionFormatterv2( req, res, next ) {
|
|
1082
1575
|
try {
|
|
1083
1576
|
let requestData = req.body;
|
|
1084
1577
|
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
@@ -1211,7 +1704,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1211
1704
|
structure.runAI = qaAnswers[j].runAI;
|
|
1212
1705
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1213
1706
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1214
|
-
|
|
1707
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1708
|
+
structure.remarks = requestSection[i].remarks;
|
|
1709
|
+
}
|
|
1215
1710
|
structure.answers = qaAnswers[j].answers;
|
|
1216
1711
|
structure.userAnswer = yn;
|
|
1217
1712
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1288,7 +1783,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1288
1783
|
structure.runAI = qaAnswers[j].runAI;
|
|
1289
1784
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1290
1785
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1291
|
-
|
|
1786
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1787
|
+
structure.remarks = requestSection[i].remarks;
|
|
1788
|
+
}
|
|
1292
1789
|
structure.answers = qaAnswers[j].answers;
|
|
1293
1790
|
structure.userAnswer = ms;
|
|
1294
1791
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1317,11 +1814,12 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1317
1814
|
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' || ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) ) {
|
|
1318
1815
|
let qaans = qaAnswers[j].answers;
|
|
1319
1816
|
let mcmo = [];
|
|
1320
|
-
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1817
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit || ( getChecklistQA?.redoEdit && qaAnswers[j].answers.some( ( ans ) => ans.redo ) ) ) {
|
|
1321
1818
|
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1322
1819
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1323
1820
|
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1324
1821
|
if ( ( separatedArray[s].answer == qaans[k].answer ) ) {
|
|
1822
|
+
console.log( qaans[k].redo, separatedArray[s].redo, qaans[k].redo == separatedArray[s].redo, qaans[k].answer );
|
|
1325
1823
|
if ( ( getChecklistQA?.redoEdit && qaans[k].redo == separatedArray[s].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1326
1824
|
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1327
1825
|
if ( separatedArray[s].validationAnswer ) {
|
|
@@ -1341,8 +1839,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1341
1839
|
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1342
1840
|
qaans[k].runAIData = separatedArray[s].runAIData;
|
|
1343
1841
|
}
|
|
1842
|
+
mcmo.push( qaans[k] );
|
|
1344
1843
|
}
|
|
1345
|
-
mcmo.push( qaans[k] );
|
|
1346
1844
|
}
|
|
1347
1845
|
}
|
|
1348
1846
|
}
|
|
@@ -1362,7 +1860,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1362
1860
|
structure.runAI = qaAnswers[j].runAI;
|
|
1363
1861
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1364
1862
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1365
|
-
|
|
1863
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1864
|
+
structure.remarks = requestSection[i].remarks;
|
|
1865
|
+
}
|
|
1366
1866
|
structure.answers = qaAnswers[j].answers;
|
|
1367
1867
|
structure.userAnswer = mcmo;
|
|
1368
1868
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1439,7 +1939,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1439
1939
|
structure.runAI = qaAnswers[j].runAI;
|
|
1440
1940
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1441
1941
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1442
|
-
|
|
1942
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1943
|
+
structure.remarks = requestSection[i].remarks;
|
|
1944
|
+
}
|
|
1443
1945
|
structure.answers = qaAnswers[j].answers;
|
|
1444
1946
|
structure.userAnswer = mcmi;
|
|
1445
1947
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1546,7 +2048,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1546
2048
|
structure.runAI = qaAnswers[j].runAI;
|
|
1547
2049
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1548
2050
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1549
|
-
|
|
2051
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
2052
|
+
structure.remarks = requestSection[i].remarks;
|
|
2053
|
+
}
|
|
1550
2054
|
structure.answers = qaAnswers[j].answers;
|
|
1551
2055
|
structure.userAnswer = des;
|
|
1552
2056
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1587,6 +2091,18 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1587
2091
|
|
|
1588
2092
|
requestData.questionAnswers = sectionFormat;
|
|
1589
2093
|
logger.error( { message: requestData.questionAnswers, error: 'QuestionanswersPayload' } );
|
|
2094
|
+
|
|
2095
|
+
if ( requestData.submittype == 'submit' ) {
|
|
2096
|
+
for ( let section of sectionFormat ) {
|
|
2097
|
+
for ( let question of section.questions ) {
|
|
2098
|
+
let mustValidate = !question.linkType || ( question.linkType && question.linkquestionenabled );
|
|
2099
|
+
if ( mustValidate && ( !question.userAnswer || !question.userAnswer.length ) ) {
|
|
2100
|
+
return res.sendError( 'Please Fill All Fields', 400 );
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
|
|
1590
2106
|
next();
|
|
1591
2107
|
} catch ( error ) {
|
|
1592
2108
|
logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
|
|
@@ -2207,7 +2723,6 @@ export async function submitChecklist( req, res ) {
|
|
|
2207
2723
|
let flagCount = QuestionFlag( req, res );
|
|
2208
2724
|
updateData.questionFlag = flagCount;
|
|
2209
2725
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2210
|
-
updateData.redoEdit = false;
|
|
2211
2726
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2212
2727
|
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2213
2728
|
}
|
|
@@ -2351,8 +2866,11 @@ export async function submitChecklist( req, res ) {
|
|
|
2351
2866
|
}
|
|
2352
2867
|
}
|
|
2353
2868
|
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2869
|
+
if ( getchecklist?.[0]?.redoEdit ) {
|
|
2870
|
+
return res.sendSuccess( 'New Questions Added So,Checklist moved back to In Progress. Please complete the updated checklist.' );
|
|
2871
|
+
} else {
|
|
2872
|
+
return res.sendSuccess( 'Checklist Updated Successfully' );
|
|
2873
|
+
}
|
|
2356
2874
|
} else {
|
|
2357
2875
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
2358
2876
|
}
|
|
@@ -2480,8 +2998,7 @@ export async function submitTask( req, res ) {
|
|
|
2480
2998
|
'storeResponseTime': currentDateTime.format( 'HH:mm:ss - MMM DD, YYYY' ),
|
|
2481
2999
|
'message_mode': 'retriggered',
|
|
2482
3000
|
};
|
|
2483
|
-
|
|
2484
|
-
console.log( sqsResponse );
|
|
3001
|
+
sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2485
3002
|
}
|
|
2486
3003
|
if ( !excludedChecklists.includes( checklist.checkListName ) ) {
|
|
2487
3004
|
const query1 = [
|
|
@@ -2986,9 +3503,6 @@ export async function dashboardv1( req, res ) {
|
|
|
2986
3503
|
// const { store_id, date } = req.query;
|
|
2987
3504
|
const { date } = req.query;
|
|
2988
3505
|
const userId = req.user._id;
|
|
2989
|
-
let fromDate = new Date( req.query.date );
|
|
2990
|
-
let toDate = new Date( req.query.date );
|
|
2991
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
2992
3506
|
|
|
2993
3507
|
// //Get User Based Checklist //
|
|
2994
3508
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -2999,7 +3513,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2999
3513
|
// eslint-disable-next-line camelcase
|
|
3000
3514
|
// store_id,
|
|
3001
3515
|
userId,
|
|
3002
|
-
|
|
3516
|
+
date_string: date,
|
|
3003
3517
|
timeFlagStatus: true,
|
|
3004
3518
|
...clientId,
|
|
3005
3519
|
...storeMatch,
|
|
@@ -3025,7 +3539,9 @@ export async function dashboardv1( req, res ) {
|
|
|
3025
3539
|
},
|
|
3026
3540
|
];
|
|
3027
3541
|
|
|
3028
|
-
|
|
3542
|
+
let fromDate = new Date( req.query.date );
|
|
3543
|
+
let toDate = new Date( req.query.date );
|
|
3544
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
3029
3545
|
const taskBaseMatch = {
|
|
3030
3546
|
// eslint-disable-next-line camelcase
|
|
3031
3547
|
// store_id,
|
|
@@ -3074,8 +3590,6 @@ export async function dashboardv1( req, res ) {
|
|
|
3074
3590
|
processedTask.aggregate( taskQuery ),
|
|
3075
3591
|
] );
|
|
3076
3592
|
|
|
3077
|
-
console.log( checklistResult );
|
|
3078
|
-
|
|
3079
3593
|
const checklistResultData =
|
|
3080
3594
|
checklistResult.status === 'fulfilled' ?
|
|
3081
3595
|
processResult( checklistResult.value ) :
|
|
@@ -3205,9 +3719,6 @@ export async function checklistv1( req, res ) {
|
|
|
3205
3719
|
// const { store_id, date, checklistStatus, searchValue } = req.query;
|
|
3206
3720
|
const { date, checklistStatus, searchValue } = req.query;
|
|
3207
3721
|
const userId = req.user._id;
|
|
3208
|
-
let fromDate = new Date( req.query.date );
|
|
3209
|
-
let toDate = new Date( req.query.date );
|
|
3210
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
3211
3722
|
|
|
3212
3723
|
// Get User Based Checklist //
|
|
3213
3724
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -3219,23 +3730,16 @@ export async function checklistv1( req, res ) {
|
|
|
3219
3730
|
// eslint-disable-next-line camelcase
|
|
3220
3731
|
// { store_id },
|
|
3221
3732
|
{ userId },
|
|
3222
|
-
|
|
3733
|
+
{ date_string: date },
|
|
3223
3734
|
{ timeFlagStatus: true },
|
|
3224
3735
|
...matchExtraConditions,
|
|
3225
3736
|
clientId,
|
|
3226
3737
|
storeMatch,
|
|
3227
3738
|
];
|
|
3228
|
-
if ( checklistStatus != 'submit' ) {
|
|
3229
|
-
matchConditions.push( { $or: [ { date_string: date }, { $and: [ { redoStatus: true }, { scheduleEndTime_iso: { $gte: fromDate } } ] } ] } );
|
|
3230
|
-
}
|
|
3231
|
-
if ( checklistStatus == 'submit' ) {
|
|
3232
|
-
matchConditions.push( { date_string: date } );
|
|
3233
|
-
}
|
|
3234
3739
|
if ( checklistStatus ) {
|
|
3235
3740
|
matchConditions.push( { checklistStatus } );
|
|
3236
3741
|
}
|
|
3237
3742
|
|
|
3238
|
-
|
|
3239
3743
|
const pipeline = [
|
|
3240
3744
|
{ $match: { $and: matchConditions } },
|
|
3241
3745
|
...( searchValue ?
|
|
@@ -3288,7 +3792,9 @@ export async function checklistv1( req, res ) {
|
|
|
3288
3792
|
return pipeline;
|
|
3289
3793
|
};
|
|
3290
3794
|
|
|
3291
|
-
|
|
3795
|
+
let fromDate = new Date( req.query.date );
|
|
3796
|
+
let toDate = new Date( req.query.date );
|
|
3797
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
3292
3798
|
const taskBuildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
|
|
3293
3799
|
const matchConditions = [
|
|
3294
3800
|
// eslint-disable-next-line camelcase
|
|
@@ -3668,7 +4174,7 @@ export async function questionList( req, res ) {
|
|
|
3668
4174
|
checkvalidation = answer.validationAnswer;
|
|
3669
4175
|
}
|
|
3670
4176
|
}
|
|
3671
|
-
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation
|
|
4177
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3672
4178
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
3673
4179
|
}
|
|
3674
4180
|
|