Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microplan check #1

Open
wants to merge 6 commits into
base: console
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions health-services/project-factory/src/server/api/campaignApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
getBoundaryOnWhichWeSplit,
getLocalizedName,
reorderBoundariesOfDataAndValidate,
checkIfSourceIsMicroplan,
createIdRequests,
createUniqueUserNameViaIdGen,
boundaryGeometryManagement,
Expand All @@ -48,6 +47,7 @@ import { checkAndGiveIfParentCampaignAvailable } from "../utils/onGoingCampaignU
import { validateMicroplanFacility } from "../validators/microplanValidators";
import {
createPlanFacilityForMicroplan,
isMicroplanCampaignId,
updateFacilityDetailsForMicroplan,
} from "../utils/microplanUtils";
import { getTransformedLocale } from "../utils/localisationUtils";
Expand Down Expand Up @@ -240,7 +240,7 @@ function changeBodyViaElements(elements: any, requestBody: any) {
// }
// }

function updateErrorsForUser(
async function updateErrorsForUser(
request: any,
newCreatedData: any[],
newSearchedData: any[],
Expand All @@ -249,7 +249,7 @@ function updateErrorsForUser(
userNameAndPassword: any[]
) {
const isSourceMicroplan =
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan";
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider caching the result of isMicroplanCampaignId.

The function isMicroplanCampaignId is called and awaited multiple times with the same campaignId. Since the campaignId does not change during the request processing, consider caching the result to reduce unnecessary asynchronous calls and improve performance.

Apply this diff to cache the result:

+ const isMicroplanCampaign = await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);

- const isSourceMicroplan =
-   await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
+ const isSourceMicroplan = isMicroplanCampaign;

...

- if (
-   await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId) &&
-   request.body.ResourceDetails.type == "facility"
- ) {
+ if (isMicroplanCampaign && request.body.ResourceDetails.type == "facility") {

...

// Repeat similar replacements for other occurrences

Also applies to: 861-862, 890-890, 1017-1017, 1033-1033, 1504-1504, 1575-1575, 1644-1644, 2979-2980, 3442-3442

newCreatedData.forEach((createdElement: any) => {
let foundMatch = false;
for (const searchedElement of newSearchedData) {
Expand Down Expand Up @@ -340,7 +340,7 @@ function updateErrors(
});
}

function matchCreatedAndSearchedData(
async function matchCreatedAndSearchedData(
createdData: any[],
searchedData: any[],
request: any,
Expand Down Expand Up @@ -369,7 +369,7 @@ function matchCreatedAndSearchedData(
updateFacilityDetailsForMicroplan(request, newCreatedData);
} else {
var userNameAndPassword: any = [];
updateErrorsForUser(
await updateErrorsForUser(
request,
newCreatedData,
newSearchedData,
Expand Down Expand Up @@ -584,7 +584,7 @@ async function matchUserValidation(createdData: any[], request: any) {
? [...request?.body?.sheetErrorDetails, ...errors]
: errors;
}
function matchViaUserIdAndCreationTime(
async function matchViaUserIdAndCreationTime(
createdData: any[],
searchedData: any[],
request: any,
Expand Down Expand Up @@ -612,7 +612,7 @@ function matchViaUserIdAndCreationTime(
if (count < createdData.length) {
request.body.ResourceDetails.status = "PERSISTER_ERROR";
}
matchCreatedAndSearchedData(
await matchCreatedAndSearchedData(
createdData,
matchingSearchData,
request,
Expand Down Expand Up @@ -828,7 +828,7 @@ async function confirmCreation(
request,
params
);
matchViaUserIdAndCreationTime(
await matchViaUserIdAndCreationTime(
dataToCreate,
arraysToMatch,
request,
Expand All @@ -838,7 +838,7 @@ async function confirmCreation(
);
} else {
const arraysToMatch = await getEmployeesBasedOnUuids(dataToCreate, request);
matchViaUserIdAndCreationTime(
await matchViaUserIdAndCreationTime(
dataToCreate,
arraysToMatch,
request,
Expand All @@ -858,9 +858,8 @@ async function processValidateAfterSchema(
try {
validateEmptyActive(dataFromSheet, request?.body?.ResourceDetails?.type, localizationMap);
if (
request?.body?.ResourceDetails?.additionalDetails?.source ==
"microplan" &&
request?.body?.ResourceDetails?.type == "facility"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId) &&
request.body.ResourceDetails.type == "facility"
) {
validateMicroplanFacility(request, dataFromSheet, localizationMap);
}
Expand Down Expand Up @@ -888,7 +887,7 @@ export async function processValidateAfterSchemaSheetWise(
localizationMap?: { [key: string]: string }
) {
if (
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan" &&
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId) &&
request.body.ResourceDetails.type == "user"
) {
await generateProcessedFileAndPersist(request, localizationMap);
Expand Down Expand Up @@ -1015,7 +1014,7 @@ async function processValidate(
if (type == "facility" || type == "user") {
const isUpdate = request?.body?.parentCampaignObject ? true : false;
if (
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
) {
schema = await callMdmsTypeSchema(
request,
Expand All @@ -1031,7 +1030,7 @@ async function processValidate(
const translatedSchema = await translateSchema(schema, localizationMap);
if (Array.isArray(dataFromSheet)) {
if (
request?.body?.ResourceDetails?.additionalDetails?.source != "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
) {
await validateSheetData(
dataFromSheet,
Expand Down Expand Up @@ -1502,8 +1501,7 @@ async function processAfterValidation(
try {
validateEmptyActive(dataFromSheet, request?.body?.ResourceDetails?.type, localizationMap);
if (
request?.body?.ResourceDetails?.additionalDetails?.source ==
"microplan" &&
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId) &&
request.body.ResourceDetails.type == "user"
) {
await processSearchAndValidation(request);
Expand Down Expand Up @@ -1574,7 +1572,7 @@ async function processCreate(request: any, localizationMap?: any) {
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const campaignType =
responseFromCampaignSearch?.CampaignDetails[0]?.projectType;
if (checkIfSourceIsMicroplan(request?.body?.ResourceDetails)) {
if (await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)) {
logger.info(`Data create Source is MICROPLAN`);
if (createAndSearchConfig?.parseArrayConfig?.parseLogic) {
createAndSearchConfig.parseArrayConfig.parseLogic =
Expand Down Expand Up @@ -1643,7 +1641,7 @@ async function getSchema(
"Fetching schema to validate the created data for type: " + type
);
if (
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
) {
const mdmsResponse = await callMdmsTypeSchema(
request,
Expand Down
55 changes: 24 additions & 31 deletions health-services/project-factory/src/server/utils/campaignUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import {
modifyNewSheetData,
unhideColumnsOfProcessedFile,
} from "./onGoingCampaignUpdateUtils";
import { changeCreateDataForMicroplan, lockSheet } from "./microplanUtils";
import { changeCreateDataForMicroplan, isMicroplanRequest, isMicroplanCampaignId, lockSheet } from "./microplanUtils";
const _ = require("lodash");
import { searchDataService } from "../service/dataManageService";
import { searchMDMSDataViaV2Api } from "../api/coreApis";
Expand Down Expand Up @@ -305,15 +305,15 @@ function enrichActiveAndUUidColumn(
}
}

function deterMineLastColumnAndEnrichUserDetails(
async function deterMineLastColumnAndEnrichUserDetails(
ashish-egov marked this conversation as resolved.
Show resolved Hide resolved
worksheet: any,
errorDetailsColumn: number,
userNameAndPassword:
| { rowNumber: number; userName: string; password: string }[]
| undefined,
request: any,
createAndSearchConfig: { uniqueIdentifierColumn?: number }
): string {
){
// Determine the last column
let lastColumn: any = errorDetailsColumn;
if (createAndSearchConfig?.uniqueIdentifierColumn !== undefined) {
Expand All @@ -329,7 +329,7 @@ function deterMineLastColumnAndEnrichUserDetails(

// Update columns if the request indicates a different source
if (
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
) {
usernameColumn = "F";
passwordColumn = "G";
Expand Down Expand Up @@ -387,7 +387,7 @@ function adjustRef(worksheet: any, lastColumn: any) {
};
}

function processErrorData(
async function processErrorData(
request: any,
createAndSearchConfig: any,
workbook: any,
Expand Down Expand Up @@ -418,7 +418,7 @@ function processErrorData(
: additionalDetailsErrors;

// Determine the last column to set the worksheet ref
const lastColumn = deterMineLastColumnAndEnrichUserDetails(
const lastColumn = await deterMineLastColumnAndEnrichUserDetails(
worksheet,
errorDetailsColumn,
userNameAndPassword,
Expand Down Expand Up @@ -535,7 +535,7 @@ async function updateStatusFile(
"get"
);
const isLockSheetNeeded =
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? true
: false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplify boolean assignment by removing unnecessary ternary operator.

The ternary operator is redundant since await isMicroplanCampaignId(...) already returns a boolean.

Apply this diff:

- const isLockSheetNeeded =
-   await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
-     ? true
-     : false;
+ const isLockSheetNeeded = await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? true
: false;
const isLockSheetNeeded = await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
🧰 Tools
🪛 Biome (1.9.4)

[error] 538-540: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


Expand All @@ -554,7 +554,7 @@ async function updateStatusFile(
const columnsToUnhide = ["G", "H", "J", "K"];
unhideColumnsOfProcessedFile(worksheet, columnsToUnhide);
}
processErrorData(
await processErrorData(
request,
createAndSearchConfig,
workbook,
Expand Down Expand Up @@ -595,7 +595,7 @@ async function updateStatusFileForEachSheets(
"get"
);
const isLockSheetNeeded =
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? true
: false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplify boolean assignment by removing unnecessary ternary operator.

Similar to the previous instance, remove the redundant ternary operator.

Apply this diff:

- const isLockSheetNeeded =
-   await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
-     ? true
-     : false;
+ const isLockSheetNeeded = await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? true
: false;
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
🧰 Tools
🪛 Biome (1.9.4)

[error] 598-600: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


Expand Down Expand Up @@ -702,7 +702,7 @@ async function processData(
const requiresToSearchFromSheet =
createAndSearchConfig?.requiresToSearchFromSheet;
const isSourceMicroplan =
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan";
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
var createData = [],
searchData = [];
for (const data of dataFromSheet) {
Expand Down Expand Up @@ -810,7 +810,7 @@ async function generateProcessedFileAndPersist(
) {
if (
request.body.ResourceDetails.type == "boundaryWithTarget" ||
(request?.body?.ResourceDetails?.additionalDetails?.source == "microplan" &&
(await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId) &&
request.body.ResourceDetails.type == "user")
) {
await updateStatusFileForEachSheets(request, localizationMap);
Expand Down Expand Up @@ -838,7 +838,7 @@ async function generateProcessedFileAndPersist(
...request?.body?.ResourceDetails?.additionalDetails,
sheetErrors: request?.body?.additionalDetailsErrors,
source:
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? "microplan"
: null,
},
Expand Down Expand Up @@ -881,7 +881,7 @@ async function generateProcessedFileAndPersist(
if (request?.body?.ResourceDetails?.action == "create") {
persistMessage.ResourceDetails.additionalDetails = {
source:
request?.body?.ResourceDetails?.additionalDetails?.source == "microplan"
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? "microplan"
: null,
fileName:
Expand Down Expand Up @@ -2484,7 +2484,6 @@ async function appendSheetsToWorkbook(
);
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const campaignObject = responseFromCampaignSearch?.CampaignDetails?.[0];
// const isSourceMicroplan = checkIfSourceIsMicroplan(campaignObject);
const mainSheet = workbook.addWorksheet(
getLocalizedName(getBoundaryTabName(), localizationMap)
);
Expand Down Expand Up @@ -2973,16 +2972,15 @@ async function updateAndPersistResourceDetails(
lastModifiedTime: Date.now(),
},
additionalDetails:
{
...request?.body?.ResourceDetails?.additionalDetails,
sheetErrors: request?.body?.additionalDetailsErrors,
source:
request?.body?.ResourceDetails?.additionalDetails?.source ==
"microplan"
? "microplan"
: null,
[name]: [fileStoreId],
},
{
...request?.body?.ResourceDetails?.additionalDetails,
sheetErrors: request?.body?.additionalDetailsErrors,
source:
await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId)
? "microplan"
: null,
[name]: [fileStoreId],
} ,
};
} else {
request.body.ResourceDetails = {
Expand Down Expand Up @@ -3441,7 +3439,7 @@ const getConfigurableColumnHeadersBasedOnCampaignType = async (
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const campaignObject = responseFromCampaignSearch?.CampaignDetails?.[0];
let campaignType = campaignObject?.projectType;
const isSourceMicroplan = checkIfSourceIsMicroplan(campaignObject);
const isSourceMicroplan = await isMicroplanRequest(request);
campaignType = isSourceMicroplan
? `${config?.prefixForMicroplanCampaigns}-${campaignType}`
: campaignType;
Expand Down Expand Up @@ -3523,7 +3521,7 @@ async function getFinalValidHeadersForTargetSheetAsPerCampaignType(
);
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const campaignObject = responseFromCampaignSearch?.CampaignDetails?.[0];
const isSourceMicroplan = checkIfSourceIsMicroplan(campaignObject);
const isSourceMicroplan = await isMicroplanRequest(request);
var expectedHeadersForTargetSheetUptoHierarchy: any;
if (isSourceMicroplan) {
expectedHeadersForTargetSheetUptoHierarchy = localizedHierarchy;
Expand Down Expand Up @@ -3630,10 +3628,6 @@ async function getBoundaryOnWhichWeSplit(request: any, tenantId: any) {
return mdmsResponse?.mdms?.[0]?.data?.splitBoundariesOn;
}

function checkIfSourceIsMicroplan(objectWithAdditionalDetails: any): boolean {
return objectWithAdditionalDetails?.additionalDetails?.source === "microplan";
}

function createIdRequests(employees: any[]): any[] {
if (employees && Array.isArray(employees) && employees.length > 0) {
const { tenantId } = employees[0]; // Assuming all employees have the same tenantId
Expand Down Expand Up @@ -3782,7 +3776,6 @@ export {
getConfigurableColumnHeadersBasedOnCampaignType,
getFinalValidHeadersForTargetSheetAsPerCampaignType,
getDifferentTabGeneratedBasedOnConfig,
checkIfSourceIsMicroplan,
getBoundaryOnWhichWeSplit,
createIdRequests,
createUniqueUserNameViaIdGen,
Expand Down
12 changes: 6 additions & 6 deletions health-services/project-factory/src/server/utils/genericUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { produceModifiedMessages } from "../kafka/Producer";
import { generateHierarchyList, getAllFacilities, getCampaignSearchResponse, getHierarchy } from "../api/campaignApis";
import { getBoundarySheetData, getSheetData, createAndUploadFile, createExcelSheet, getTargetSheetData, callMdmsData, callMdmsTypeSchema, getConfigurableColumnHeadersBasedOnCampaignTypeForBoundaryManagement } from "../api/genericApis";
import { logger } from "./logger";
import { checkIfSourceIsMicroplan, getConfigurableColumnHeadersBasedOnCampaignType, getDifferentTabGeneratedBasedOnConfig, getLocalizedName } from "./campaignUtils";
import { getConfigurableColumnHeadersBasedOnCampaignType, getDifferentTabGeneratedBasedOnConfig, getLocalizedName } from "./campaignUtils";
import Localisation from "../controllers/localisationController/localisation.controller";
import { executeQuery } from "./db";
import { generatedResourceTransformer } from "./transforms/searchResponseConstructor";
Expand All @@ -18,7 +18,7 @@ import { addDataToSheet, formatWorksheet, getNewExcelWorkbook, updateFontNameToR
import createAndSearch from "../config/createAndSearch";
import { generateDynamicTargetHeaders } from "./targetUtils";
import { buildSearchCriteria, checkAndGiveIfParentCampaignAvailable, fetchFileUrls, getCreatedResourceIds, modifyProcessedSheetData } from "./onGoingCampaignUpdateUtils";
import { getReadMeConfigForMicroplan, getRolesForMicroplan, getUserDataFromMicroplanSheet, isMicroplanRequest, modifyBoundaryIfSourceMicroplan } from "./microplanUtils";
import { getReadMeConfigForMicroplan, getRolesForMicroplan, getUserDataFromMicroplanSheet, isMicroplanRequest, isMicroplanCampaignId, modifyBoundaryIfSourceMicroplan } from "./microplanUtils";
const NodeCache = require("node-cache");

const updateGeneratedResourceTopic = config?.kafka?.KAFKA_UPDATE_GENERATED_RESOURCE_DETAILS_TOPIC;
Expand Down Expand Up @@ -544,7 +544,7 @@ async function getSchemaBasedOnSource(request: any, isSourceMicroplan: boolean,

async function createFacilitySheet(request: any, allFacilities: any[], localizationMap?: { [key: string]: string }) {
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const isSourceMicroplan = checkIfSourceIsMicroplan(responseFromCampaignSearch?.CampaignDetails?.[0]);
const isSourceMicroplan = await isMicroplanCampaignId(request?.query?.campaignId);
request.body.isSourceMicroplan = isSourceMicroplan;
let schema: any = await getSchemaBasedOnSource(request, isSourceMicroplan, responseFromCampaignSearch?.CampaignDetails?.[0]?.additionalDetails?.resourceDistributionStrategy);
Comment on lines +547 to 549
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider adding error handling for microplan campaign ID check

While the implementation is correct, consider adding try-catch block to handle potential errors during the microplan campaign ID check.

-  const isSourceMicroplan = await isMicroplanCampaignId(request?.query?.campaignId);
+  let isSourceMicroplan = false;
+  try {
+    isSourceMicroplan = await isMicroplanCampaignId(request?.query?.campaignId);
+  } catch (error) {
+    logger.error(`Error checking microplan campaign ID: ${error}`);
+    throw error;
+  }

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 549-549: This let declares a variable that is only assigned once.

'schema' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

const keys = schema?.columns;
Expand Down Expand Up @@ -1232,7 +1232,7 @@ async function getDataFromSheetFromNormalCampaign(type: any, fileStoreId: any, t


async function getDataFromSheet(request: any, fileStoreId: any, tenantId: any, createAndSearchConfig: any, optionalSheetName?: any, localizationMap?: { [key: string]: string }) {
const isSourceMicroplan = request?.body?.ResourceDetails?.additionalDetails?.source == "microplan";
const isSourceMicroplan = await isMicroplanCampaignId(request?.body?.ResourceDetails?.campaignId);
const type = request?.body?.ResourceDetails?.type;
if (isSourceMicroplan) {
if (type == 'user') {
Expand Down Expand Up @@ -1431,7 +1431,7 @@ function getDifferentDistrictTabs(boundaryData: any, differentTabsBasedOnLevel:
async function getConfigurableColumnHeadersFromSchemaForTargetSheet(request: any, hierarchy: any, boundaryData: any, differentTabsBasedOnLevel: any, campaignObject: any, localizationMap?: any) {
const districtIndex = hierarchy.indexOf(differentTabsBasedOnLevel);
let headers: any;
const isSourceMicroplan = checkIfSourceIsMicroplan(campaignObject);
const isSourceMicroplan = await isMicroplanRequest(request);
if (isSourceMicroplan) {
logger.info(`Source is Microplan.`);
headers = getLocalizedHeaders(hierarchy, localizationMap);
Expand All @@ -1450,7 +1450,7 @@ async function getMdmsDataBasedOnCampaignType(request: any, localizationMap?: an
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const campaignObject = responseFromCampaignSearch?.CampaignDetails?.[0];
let campaignType = campaignObject.projectType;
const isSourceMicroplan = checkIfSourceIsMicroplan(campaignObject);
const isSourceMicroplan = await isMicroplanRequest(request);
campaignType = (isSourceMicroplan) ? `${config?.prefixForMicroplanCampaigns}-${campaignType}` : campaignType;
const mdmsResponse = await callMdmsTypeSchema(request, request?.query?.tenantId || request?.body?.ResourceDetails?.tenantId, false, request?.query?.type || request?.body?.ResourceDetails?.type, campaignType)
ashish-egov marked this conversation as resolved.
Show resolved Hide resolved
return mdmsResponse;
Expand Down
Loading