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

parent targets fix #1361

Merged
Changes from all 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
33 changes: 17 additions & 16 deletions health-services/project-factory/src/server/utils/campaignUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,15 +1696,15 @@ function mapBoundariesParent(boundaryResponse: any, request: any, parent: any) {
function mapTargets(boundaryResponses: any, codesTargetMapping: any) {
if (!boundaryResponses || !codesTargetMapping) return;

// Helper function to map individual boundaries
const mapBoundary = (boundary: any) => {
if (!boundary.children || boundary.children.length === 0) {
// If no children, simply return the target value object or default to empty object
const targetValue = codesTargetMapping[boundary.code];
return targetValue || {};
}
// Helper function to map individual boundaries
const mapBoundary = (boundary: any) => {
if (!boundary.children || boundary.children.length === 0) {
// If no children, simply return the target value object or default to empty object
const targetValue = codesTargetMapping[boundary.code];
return targetValue || {};
}

// Initialize a new object to accumulate total target values from children
// Initialize a new object to accumulate total target values from children
let totalTargetValue: any = {};

// Iterate through each child and accumulate their target values
Expand All @@ -1718,19 +1718,20 @@ function mapTargets(boundaryResponses: any, codesTargetMapping: any) {
totalTargetValue[key] = (totalTargetValue[key] || 0) + childTargetValue[key];
}
}
}

// Store the accumulated total target value for the current boundary
codesTargetMapping[boundary.code] = totalTargetValue;
return totalTargetValue;
};
// Map each boundary response
for (const boundaryResponse of boundaryResponses) {
// Store the accumulated total target value for the current boundary
codesTargetMapping[boundary.code] = totalTargetValue;
return totalTargetValue;
};

// Map each boundary response
for (const boundaryResponse of boundaryResponses) {
mapBoundary(boundaryResponse);
}
}
}


async function processBoundary(
boundaryResponse: any,
boundaries: any,
Expand Down
Loading