tango-app-api-audit 3.6.41 → 3.6.42-eyetest.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.6.41",
3
+ "version": "3.6.42-eyetest.0",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -847,7 +847,7 @@ export async function save( req, res ) {
847
847
 
848
848
  const getEyetestConfig = await findOneEyeTestConfig( { clientId: req?.user.userType == 'tango'? inputData?.clientId : req.user.clientId, configureType: 'email' }, { complianceThreshold: 1 } );
849
849
 
850
- if ( getEyetestConfig &&( inputData.auditStatus == 'Audited' ||inputData.auditStatus == 'Re-Audited' ) && inputUpdatedData && inputData.type === 'physical' && inputData?.isReSend !== false ) {
850
+ if ( getEyetestConfig &&( inputData.auditStatus == 'Audited' ||inputData.auditStatus == 'Re-Audited' ) && inputUpdatedData && inputData?.isReSend !== false ) {
851
851
  const value = Number( getEyetestConfig?.complianceThreshold?.value?.split( '%' )[0] );
852
852
  const condition = getEyetestConfig?.complianceThreshold?.condition;
853
853
  const id= inputData?.isReSend === true ?`${inputData.id}_${inputUpdatedData?._source?.optumId}_${inputData?.fileId}_${Date.now()}` : `${inputData.id}_${inputUpdatedData?._source?.optumId}_${inputData?.fileId}`;
@@ -911,8 +911,8 @@ export async function save( req, res ) {
911
911
  RMEmail: inputData.RMEmail,
912
912
  RMName: rmName.toString(),
913
913
  cluster: inputData.cluster,
914
- optumId: inputUpdatedData?._source?.optumId,
915
- optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
914
+ optumId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
915
+ optomEmailId: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
916
916
  storeName: inputUpdatedData?._source?.storeName,
917
917
  complianceScore: inputUpdatedData?._source?.ComplianceScore,
918
918
  humanScore: humanScore,
@@ -920,27 +920,30 @@ export async function save( req, res ) {
920
920
  trustScore: inputUpdatedData?._source?.trustScore,
921
921
  auditedId: inputUpdatedData?._id,
922
922
  queueId: inputUpdatedData?._source?.queueId,
923
+ engagementId: inputUpdatedData?._source?.type === 'physical'? '' : inputUpdatedData?._source?.engagementId,
924
+ eyetestType: inputUpdatedData?._source?.type,
923
925
  createdAt: new Date(),
924
926
  updatedAt: new Date(),
925
927
 
928
+
926
929
  };
927
930
  const reference1 ={
928
931
  storeCode: inputUpdatedData?._source?.storeName,
929
- OptomId: inputUpdatedData?._source?.optumId,
932
+ OptomId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
930
933
  feedBackIssuedBy: req?.user?.email,
931
- RMName: inputData.RMEmail,
932
- clusterName: inputData.cluster,
934
+ RMName: inputData?.RMEmail,
935
+ clusterName: inputData?.cluster,
933
936
  };
934
937
  await insertWithId( openSearch.eyeTestEmailAlert, id, record1 );
935
938
  sendComplianceEmail( {
936
- toEmail: inputUpdatedData?._source?.salesmanEmailId,
939
+ toEmail: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
937
940
  fromEmail: ses.eyeTestAlertEmail,
938
941
  userName: 'Optom',
939
942
  storeName: inputUpdatedData?._source?.storeName,
940
- startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source.testEndTime}`,
943
+ startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source?.testEndTime}`,
941
944
  compliancePercentage: humanScore,
942
945
  steps: steps,
943
- videoUrl: `${url.physical}${inputUpdatedData?._source?.filePath}`,
946
+ videoUrl: `${inputUpdatedData?._source?.type === 'physical'?url.physical:url.remote}${inputUpdatedData?._source?.filePath}`,
944
947
  ref: reference1,
945
948
  } );
946
949
  }
@@ -950,8 +953,8 @@ export async function save( req, res ) {
950
953
  RMEmail: inputData.RMEmail,
951
954
  RMName: rmName.toString(),
952
955
  cluster: inputData.cluster,
953
- optumId: inputUpdatedData?._source?.optumId,
954
- optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
956
+ optumId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
957
+ optomEmailId: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
955
958
  storeName: inputUpdatedData?._source?.storeName,
956
959
  complianceScore: inputUpdatedData?._source?.ComplianceScore,
957
960
  humanScore: humanScore,
@@ -959,27 +962,28 @@ export async function save( req, res ) {
959
962
  trustScore: inputUpdatedData?._source?.trustScore,
960
963
  auditedId: inputUpdatedData?._id,
961
964
  queueId: inputUpdatedData?._source?.queueId,
965
+ engagementId: inputUpdatedData?._source?.type === 'physical'? '' : inputUpdatedData?._source?.engagementId,
962
966
  createdAt: new Date(),
963
967
  updatedAt: new Date(),
964
968
 
965
969
  };
966
970
  const reference2 ={
967
971
  storeCode: inputUpdatedData?._source?.storeName,
968
- OptomId: inputUpdatedData?._source?.optumId,
972
+ OptomId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
969
973
  feedBackIssuedBy: req?.user?.email,
970
974
  RMName: inputData.RMEmail,
971
975
  clusterName: inputData.cluster,
972
976
  };
973
977
  await insertWithId( openSearch.eyeTestEmailAlert, id, record2 );
974
978
  sendComplianceEmail( {
975
- toEmail: inputUpdatedData?._source?.salesmanEmailId,
979
+ toEmail: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
976
980
  fromEmail: ses.eyeTestAlertEmail,
977
981
  userName: 'Optom',
978
982
  storeName: inputUpdatedData?._source?.storeName,
979
983
  startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source.testEndTime}`,
980
984
  compliancePercentage: humanScore,
981
985
  steps: steps,
982
- videoUrl: `${url.physical}${inputUpdatedData?._source?.filePath}`,
986
+ videoUrl: `${inputUpdatedData?._source?.type === 'physical'?url.physical:url.remote}${inputUpdatedData?._source?.filePath}`,
983
987
  ref: reference2,
984
988
  } );
985
989
  };
@@ -989,8 +993,10 @@ export async function save( req, res ) {
989
993
  RMEmail: inputData.RMEmail,
990
994
  RMName: rmName.toString(),
991
995
  cluster: inputData.cluster,
992
- optumId: inputUpdatedData?._source?.optumId,
993
- optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
996
+ optumId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
997
+
998
+ optomEmailId: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
999
+
994
1000
  storeName: inputUpdatedData?._source?.storeName,
995
1001
  complianceScore: inputUpdatedData?._source?.ComplianceScore,
996
1002
  humanScore: humanScore,
@@ -998,27 +1004,32 @@ export async function save( req, res ) {
998
1004
  trustScore: inputUpdatedData?._source?.trustScore,
999
1005
  auditedId: inputUpdatedData?._id,
1000
1006
  queueId: inputUpdatedData?._source?.queueId,
1007
+ engagementId: inputUpdatedData?._source?.type === 'physical'? '' : inputUpdatedData?._source?.engagementId,
1008
+
1001
1009
  createdAt: new Date(),
1002
1010
  updatedAt: new Date(),
1003
1011
 
1004
1012
  };
1005
1013
  const reference3 ={
1006
1014
  storeCode: inputUpdatedData?._source?.storeName,
1007
- OptomId: inputUpdatedData?._source?.optumId,
1015
+ OptomId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1016
+
1008
1017
  feedBackIssuedBy: req?.user?.email,
1009
1018
  RMName: inputData.RMEmail,
1010
1019
  clusterName: inputData.cluster,
1011
1020
  };
1012
1021
  await insertWithId( openSearch.eyeTestEmailAlert, id, record3 );
1013
1022
  sendComplianceEmail( {
1014
- toEmail: inputUpdatedData?._source?.salesmanEmailId,
1023
+ toEmail: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1024
+
1015
1025
  fromEmail: ses.eyeTestAlertEmail,
1016
1026
  userName: 'Optom',
1017
1027
  storeName: inputUpdatedData?._source?.storeName,
1018
1028
  startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source.testEndTime}`,
1019
1029
  compliancePercentage: humanScore,
1020
1030
  steps: steps,
1021
- videoUrl: `${url.physical}${inputUpdatedData?._source?.filePath}`,
1031
+ videoUrl: `${inputUpdatedData?._source?.type === 'physical'?url.physical:url.remote}${inputUpdatedData?._source?.filePath}`,
1032
+
1022
1033
  ref: reference3,
1023
1034
  } );
1024
1035
  }
@@ -1028,8 +1039,10 @@ export async function save( req, res ) {
1028
1039
  RMEmail: inputData.RMEmail,
1029
1040
  RMName: rmName.toString(),
1030
1041
  cluster: inputData.cluster,
1031
- optumId: inputUpdatedData?._source?.optumId,
1032
- optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
1042
+ optumId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1043
+ optomEmailId: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1044
+
1045
+
1033
1046
  storeName: inputUpdatedData?._source?.storeName,
1034
1047
  complianceScore: inputUpdatedData?._source?.ComplianceScore,
1035
1048
  humanScore: humanScore,
@@ -1037,27 +1050,29 @@ export async function save( req, res ) {
1037
1050
  trustScore: inputUpdatedData?._source?.trustScore,
1038
1051
  auditedId: inputUpdatedData?._id,
1039
1052
  queueId: inputUpdatedData?._source?.queueId,
1053
+ engagementId: inputUpdatedData?._source?.type === 'physical'? '' : inputUpdatedData?._source?.engagementId,
1054
+
1040
1055
  createdAt: new Date(),
1041
1056
  updatedAt: new Date(),
1042
1057
 
1043
1058
  };
1044
1059
  const reference4 ={
1045
1060
  storeCode: inputUpdatedData?._source?.storeName,
1046
- OptomId: inputUpdatedData?._source?.optumId,
1061
+ OptomId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1047
1062
  feedBackIssuedBy: req?.user?.email,
1048
1063
  RMName: inputData.RMEmail,
1049
1064
  clusterName: inputData.cluster,
1050
1065
  };
1051
1066
  await insertWithId( openSearch.eyeTestEmailAlert, id, record4 );
1052
1067
  sendComplianceEmail( {
1053
- toEmail: inputUpdatedData?._source?.salesmanEmailId,
1068
+ toEmail: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1054
1069
  fromEmail: ses.eyeTestAlertEmail,
1055
1070
  userName: 'Optom',
1056
1071
  storeName: inputUpdatedData?._source?.storeName,
1057
1072
  startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source.testEndTime}`,
1058
1073
  compliancePercentage: humanScore,
1059
1074
  steps: steps,
1060
- videoUrl: `${url.physical}${inputUpdatedData?._source?.filePath}`,
1075
+ videoUrl: `${inputUpdatedData?._source?.type === 'physical'?url.physical:url.remote}${inputUpdatedData?._source?.filePath}`,
1061
1076
  ref: reference4,
1062
1077
  } );
1063
1078
  }
@@ -1068,8 +1083,8 @@ export async function save( req, res ) {
1068
1083
  RMEmail: inputData.RMEmail,
1069
1084
  RMName: rmName.toString(),
1070
1085
  cluster: inputData.cluster,
1071
- optumId: inputUpdatedData?._source?.optumId,
1072
- optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
1086
+ optumId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1087
+ optomEmailId: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1073
1088
  storeName: inputUpdatedData?._source?.storeName,
1074
1089
  complianceScore: inputUpdatedData?._source?.ComplianceScore,
1075
1090
  humanScore: humanScore,
@@ -1077,27 +1092,28 @@ export async function save( req, res ) {
1077
1092
  trustScore: inputUpdatedData?._source?.trustScore,
1078
1093
  auditedId: inputUpdatedData?._id,
1079
1094
  queueId: inputUpdatedData?._source?.queueId,
1095
+ engagementId: inputUpdatedData?._source?.type === 'physical'? '' : inputUpdatedData?._source?.engagementId,
1080
1096
  createdAt: new Date(),
1081
1097
  updatedAt: new Date(),
1082
1098
 
1083
1099
  };
1084
1100
  const reference5 ={
1085
1101
  storeCode: inputUpdatedData?._source?.storeName,
1086
- OptomId: inputUpdatedData?._source?.optumId,
1102
+ OptomId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1087
1103
  feedBackIssuedBy: req?.user?.email,
1088
1104
  RMName: inputData.RMEmail,
1089
1105
  clusterName: inputData.cluster,
1090
1106
  };
1091
1107
  await insertWithId( openSearch.eyeTestEmailAlert, id, record5 );
1092
1108
  sendComplianceEmail( {
1093
- toEmail: inputUpdatedData?._source?.salesmanEmailId,
1109
+ toEmail: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1094
1110
  fromEmail: ses.eyeTestAlertEmail,
1095
1111
  userName: 'Optom',
1096
1112
  storeName: inputUpdatedData?._source?.storeName,
1097
1113
  startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source.testEndTime}`,
1098
1114
  compliancePercentage: humanScore,
1099
1115
  steps: steps,
1100
- videoUrl: `${url.physical}${inputUpdatedData?._source?.filePath}`,
1116
+ videoUrl: `${inputUpdatedData?._source?.type === 'physical'?url.physical:url.remote}${inputUpdatedData?._source?.filePath}`,
1101
1117
  ref: reference5,
1102
1118
  } );
1103
1119
  }
@@ -1107,8 +1123,8 @@ export async function save( req, res ) {
1107
1123
  RMEmail: inputData.RMEmail,
1108
1124
  RMName: rmName.toString(),
1109
1125
  cluster: inputData.cluster,
1110
- optumId: inputUpdatedData?._source?.optumId,
1111
- optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
1126
+ optumId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1127
+ optomEmailId: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1112
1128
  storeName: inputUpdatedData?._source?.storeName,
1113
1129
  complianceScore: inputUpdatedData?._source?.ComplianceScore,
1114
1130
  humanScore: humanScore,
@@ -1116,26 +1132,27 @@ export async function save( req, res ) {
1116
1132
  trustScore: inputUpdatedData?._source?.trustScore,
1117
1133
  auditedId: inputUpdatedData?._id,
1118
1134
  queueId: inputUpdatedData?._source?.queueId,
1135
+ engagementId: inputUpdatedData?._source?.type === 'physical'? '' : inputUpdatedData?._source?.engagementId,
1119
1136
  createdAt: new Date(),
1120
1137
  updatedAt: new Date(),
1121
1138
  };
1122
1139
  const reference6 ={
1123
1140
  storeCode: inputUpdatedData?._source?.storeName,
1124
- OptomId: inputUpdatedData?._source?.optumId,
1141
+ OptomId: inputUpdatedData?._source?.type === 'physical'?inputUpdatedData?._source?.optumId:inputUpdatedData?._source?.optm_userId,
1125
1142
  feedBackIssuedBy: req?.user?.email,
1126
1143
  RMName: inputData.RMEmail,
1127
1144
  clusterName: inputData.cluster,
1128
1145
  };
1129
1146
  await insertWithId( openSearch.eyeTestEmailAlert, id, record6 );
1130
1147
  sendComplianceEmail( {
1131
- toEmail: inputUpdatedData?._source?.salesmanEmailId,
1148
+ toEmail: inputUpdatedData?._source?.type === 'physical'? inputUpdatedData?._source?.salesmanEmailId:inputUpdatedData?._source?.userEmail,
1132
1149
  fromEmail: ses.eyeTestAlertEmail,
1133
1150
  userName: 'Optom',
1134
1151
  storeName: inputUpdatedData?._source?.storeName,
1135
1152
  startTime: `${inputUpdatedData?._source?.fileDate}T${inputUpdatedData?._source.testEndTime}`,
1136
1153
  compliancePercentage: humanScore,
1137
1154
  steps: steps,
1138
- videoUrl: `${url.physical}${inputUpdatedData?._source?.filePath}`,
1155
+ videoUrl: `${inputUpdatedData?._source?.type === 'physical'?url.physical:url.remote}${inputUpdatedData?._source?.filePath}`,
1139
1156
  ref: reference6,
1140
1157
  } );
1141
1158
  }
@@ -44,9 +44,9 @@ export async function sendAlert( req, res, next ) {
44
44
  try {
45
45
  const inputData = req.body;
46
46
  const openSearch = JSON.parse( process.env.OPENSEARCH );
47
- if ( inputData.auditStatus == 'Re-Audited' && inputData.type == 'physical' && inputData?.isReSend == undefined ) {
47
+ if ( inputData.auditStatus == 'Re-Audited' && inputData?.isReSend == undefined ) {
48
48
  const getOne = await getOpenSearchById( openSearch.EyeTestInput, inputData.id );
49
- const id = `${inputData.id}_${getOne?.body?._source?.optumId}_${inputData.fileId}`;
49
+ const id = `${inputData.id}_${getOne?.body?._source?.type === 'physical' ? getOne?.body?._source?.optumId : getOne?.body?._source?.optm_userId}_${inputData.fileId}`;
50
50
  const getId = await getOpenSearchById( openSearch.eyeTestEmailAlert, id );
51
51
  logger.info( { getId: getId, id: id } );
52
52
  const inputUpdatedData = getId?.body;