{
id: 'services-last-month',
translation_key: 'targets.all_services.title',
subtitle_translation_key: 'targets.last_month.subtitle',
type: 'count',
icon: 'icon-people-person-visits',
goal: -1,
appliesTo: 'reports',
context: 'user.parent.type === "health_center"',
idType: 'report',
appliesIf: function (c, r) {
return (extras.isShortModule(r) || extras.isLongModule(r)) && extras.hasConsentbeenGiven(r) && extras.isInLastMonth(r.reported_date);
},
visible: false,
date: 'now',
aggregate: false, // for the moment set to false until we decide how to use the aggregate functionality,
},
date: "now" is used for counting continuous (all-time) targets, not monthly targets, so I see where this can yield incorrect results. I see that you added extras.isInLastMonth(r.reported_date);, but that will be dependent on when the calculation is executed, and targets are not calculated all the time.
For a correct monthly target, remove the extras.isInLastMonth(r.reported_date) condition and change the date to use reported.
Can you please try enabling these changes and sharing the new target count?
Hi @diana, thanks for spotting this! Just to add, in our contact-summary, we are using the last month’s target doc count to compute and show last month’s chw pyment on the chw profile. Please see this function:
Hence, will your suggested change affect this logic?
isCHWPayforPerformanceLastmonth(targetDoc, contact) {
if (
contact.type === "person" && (contact.role === "chw" || contact.role === "chv") &&
!!targetDoc
) {
//console.log("TargetDoc:", targetDoc); // Debugging line to check targetDoc
const target_in_array = targetDoc.targets;
let payforservices = 0;
let payformeetings = 0;
// Services: Find the number of short services
const short_services_details = target_in_array.find(
(u) => u.id === "short-services-last-month"
);
if (short_services_details !== undefined) {
const short_services_number = short_services_details.value.pass;
payforservices += short_services_number*CHW_P4P.shortService;
}
// Services: Find the number of long services
const long_services_details = target_in_array.find(
(u) => u.id === "long-services-last-month"
);
if (long_services_details !== undefined) {
const long_services_number = long_services_details.value.pass;
payforservices += long_services_number*CHW_P4P.longService;
}
// Meetings: Check whether CHW attended Supervisor meeting
const supervisory_meeting_details = target_in_array.find(
(u) => u.id === "supervisory-meeting-last-month"
);
if (supervisory_meeting_details !== undefined) {
const supervisory_meeting_number = supervisory_meeting_details.value.pass;
if(supervisory_meeting_number > 0){
payformeetings += CHW_P4P.supervisorMeeting
}
}
// Meetings: Check whether CHW organised community outreach meetings/services
const community_meeting_details = target_in_array.find(
(u) => u.id === "community-meeting-last-month"
);
if (community_meeting_details !== undefined) {
const community_meeting_number = community_meeting_details.value.pass;
if(community_meeting_number > 0){
payformeetings += CHW_P4P.communityOutreachMeeting
}
}
return [
payforservices,
payformeetings,
];
}
return [0, 0]; // Return 0 for both values if conditions are not met},
I;m not sure I understand the question @iesmail . the changes should guarantee that the correct reports are counted towards your target, regardless of when the target is calculated.