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

Autoselected bottom locations available in custom report cards #1307

Closed
mahalakshme opened this issue Feb 18, 2024 · 6 comments
Closed

Autoselected bottom locations available in custom report cards #1307

mahalakshme opened this issue Feb 18, 2024 · 6 comments

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Feb 18, 2024

Make sure the necessary changes for this card are made as expected for custom report cards.

@mahalakshme mahalakshme converted this from a draft issue Feb 18, 2024
@mahalakshme mahalakshme moved this from In Analysis to QA Ready in Avni Product Feb 18, 2024
@Dinesh2019 Dinesh2019 moved this from QA Ready to In QA in Avni Product Feb 19, 2024
@Dinesh2019 Dinesh2019 moved this from In QA to QA Ready in Avni Product Feb 19, 2024
@himeshr himeshr moved this from QA Ready to In QA in Avni Product Feb 19, 2024
@Dinesh2019 Dinesh2019 moved this from In QA to Done in Avni Product Feb 19, 2024
@himeshr
Copy link
Contributor

himeshr commented Feb 19, 2024

Report card

**Name: Daily recording farmer and machine
Description: Count of work orders that whose endline recording form has not been filled out.
Query: **

'use strict';
({params, imports}) => {
  const individuals = params.db.objects('Individual');
  const workOrders = individuals.filtered('subjectType.name == "Work Order" && voided == false');
  let addressFilteredWorkOrders = workOrders;
  if (params.ruleInput) {
    const orQuery = (array) => {
      return array.length > 0 ? '( ' + array.join(' OR ') + ' )' : ''
    }
    const filterBasedOnAddress= (entitiesResult, addressFilter) => {
      if (!_.isNil(addressFilter) && !_.isNil(addressFilter.filterValue) && addressFilter.filterValue.length > 0) {
        const joinedQuery = addressFilter.filterValue.map((x) => `lowestAddressLevel.uuid = "${x.uuid}"`);
        return entitiesResult.filtered(orQuery(joinedQuery));
      }
      return entitiesResult;
    }
    let addressFilter = params.ruleInput.find(rule => rule.type === "Address");
    if(addressFilter) {
      addressFilteredWorkOrders = filterBasedOnAddress(workOrders, addressFilter);
    }
  }
  return addressFilteredWorkOrders.filter(ind => !ind.encounters.some(enc => enc.encounterType.name == "Work order endline"));
};

@himeshr himeshr moved this from Done to In QA in Avni Product Feb 19, 2024
@himeshr
Copy link
Contributor

himeshr commented Feb 19, 2024

AddressFilters work fine for

The addressLevel filter is created such that, based on lowestSelectAddressLevel's type, all of the children of the selected addressLevels at the lowestSelectAddressLevelType are passed in the filterValue.

This is then used by standard report cards to perform the filter by addressLevel operation.
It has to be manually coded in customQueryFilter to use that, as shown in the code snippet.

if (params.ruleInput) {
    const orQuery = (array) => {
      return array.length > 0 ? '( ' + array.join(' OR ') + ' )' : ''
    }
    const filterBasedOnAddress= (entitiesResult, addressFilter) => {
      if (!_.isNil(addressFilter) && !_.isNil(addressFilter.filterValue) && addressFilter.filterValue.length > 0) {
        const joinedQuery = addressFilter.filterValue.map((x) => `lowestAddressLevel.uuid = "${x.uuid}"`);
        return entitiesResult.filtered(orQuery(joinedQuery));
      }
      return entitiesResult;
    }
    let addressFilter = params.ruleInput.find(rule => rule.type === "Address");
    if(addressFilter) {
      addressFilteredWorkOrders = filterBasedOnAddress(workOrders, addressFilter);
    }
  }

@himeshr himeshr closed this as completed Feb 19, 2024
@github-project-automation github-project-automation bot moved this from In QA to Done in Avni Product Feb 19, 2024
@himeshr
Copy link
Contributor

himeshr commented Feb 19, 2024

@mahalakshme,
If we have applied filter at a higher level for an multiple addressLevels, but if we select only a few children from one of those higher addressLevel, then the filter now applies only for that selected children's all descendants.

Ex: Consider the below hierarchy:
Image

If we were to select => a,b,c,d,e, then the filter is effecively applied for all descendants of a->b->(d|e), but not for any descendant of a->c.

Is this behaviour acceptable.?

Screen.Recording.2024-02-05.at.10.57.03.AM.mov

@mahalakshme
Copy link
Contributor Author

@himeshr will check

@mahalakshme mahalakshme moved this from Done to In QA in Avni Product Feb 20, 2024
@mahalakshme
Copy link
Contributor Author

@AchalaBelokar can you verify the above scenario? descendants of a->c should get selected

@vinayvenu vinayvenu reopened this Feb 20, 2024
@github-project-automation github-project-automation bot moved this from In QA to Triaged in Avni Product Feb 20, 2024
@mahalakshme mahalakshme moved this from Triaged to In QA in Avni Product Feb 20, 2024
@mahalakshme
Copy link
Contributor Author

@AchalaBelokar since as discussed over the call the above functionality is inline with that of working of search filters, and also it seems to be intuitive with what the user would probably expect, we can move this to Done.

@mahalakshme mahalakshme moved this from In QA to Done in Avni Product Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants