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

[IHMP] House number question to be added in Individual registration form #73

Closed
12 tasks done
salilsamanvay opened this issue Oct 3, 2023 · 16 comments
Closed
12 tasks done
Assignees
Labels

Comments

@salilsamanvay
Copy link

salilsamanvay commented Oct 3, 2023

Support ticket - https://avni.freshdesk.com/a/tickets/3064

New question has to be added and make it visible on search list.

  • Add Question: "Household number" in the Individual registration form:
    Note: this should be a mandatory question.

  • Auto populate the Household Number from Household Registration. Once house number field is available in the individual registration form it should be configured as Search Result field for Individual subject.

  • For the already registered individuals, add the value from their respective households via script

  • Update all the line-lists should have the "Household number" column in metabase

Note: the main purpose of adding this question is to make the field user locate the subject by house number.


Tech Approach and tasks -

  • Get the latest IHMP repo to your local
  • Add this already existing concept "Household number" in individual registration form json file as mandatory field
  • Write a rule "Household number" in individual registration handler file to auto populate the value from respective Household registration form.
  • Push only the changes via CLI command to staging
  • Write a script to add the "Household number" value for already exiting individual from their respective Household registration form
  • From App Designer, under Search Results field, add "Household number" under individual subject type.
  • Once QA is done on staging
  • Push the same changes to Production and configure the search results as well

Reference code

We have done auto populating of values in one individual registration from another member's registration in Add member flow.
Impl - Sakhi App
concept - Caste, Religion

Following the same approach Household number can be picked from hh observations.

@nupoorkhandelwal
Copy link

Estimates - 2 hrs

@nupoorkhandelwal nupoorkhandelwal changed the title House number question to be added in Individual registration form [IHMP] House number question to be added in Individual registration form Oct 9, 2023
@arjunk
Copy link
Contributor

arjunk commented Nov 23, 2023

@nupoorkhandelwal @salilsamanvay i am not clear why are we agreeing to do this. the card does not clearly describe it. Household number is a household field. There is a household subject type. why should we add this field to the Individual and why should the users again capture it?

@BEULAHEVANJALIN
Copy link

BEULAHEVANJALIN commented Nov 28, 2023

What if someone first registers an individual who hasn't been added to a household yet? In this case, the householdNumber wouldn't exist, right? This situation creates a problem because we can't fill in a mandatory field with information that isn't available yet.

What should we do in that case?

@WithStatusBuilder
    householdNumber([individual], statusBuilder) {
        const groups = individual.getGroups();
        if (groups && groups.length > 0) {
            const householdNumber = groups[0].groupSubject.getObservationReadableValue('24dabc3a-6562-4521-bd42-5fff11ea5c46');
            statusBuilder.value(householdNumber);
        } else {
            statusBuilder.value(null); // need clarity
        }
    }

The above concern about the householdNumber field is undefined at the time of individual registration is resolved. Since their workflow involves registering a household first and then adding individuals to that household, the issue of the householdNumber being unavailable at the time of an individual's registration won't happen.

@adamsanadi6 adamsanadi6 self-assigned this Nov 28, 2023
@BEULAHEVANJALIN
Copy link

BEULAHEVANJALIN commented Nov 28, 2023

select i.observations -> '24dabc3a-6562-4521-bd42-5fff11ea5c46',
       h.observations -> '24dabc3a-6562-4521-bd42-5fff11ea5c46'
from public.individual i
         join group_subject gs on i.id = gs.member_subject_id
         join public.individual h on h.id = gs.group_subject_id and h.subject_type_id = 129
where i.subject_type_id = 1;
update public.individual i
set observations = i.observations ||
                   JSONB_SET(i.observations, '{"24dabc3a-6562-4521-bd42-5fff11ea5c46"}',
                             h.observations -> '24dabc3a-6562-4521-bd42-5fff11ea5c46'),
last_modified_date_time=current_timestamp + ((id % 4000) * interval '1 millisecond'),
manual_update_history = i.manual_update_history || 'Adding household numbers in individuals registration'
from group_subject gs
         join public.individual h on h.id = gs.group_subject_id and h.subject_type_id = 129
where i.id = gs.member_subject_id
gs.is_voided = false
  and i.subject_type_id = 1;

@Dinesh2019
Copy link

Need a clarity on Analysis to handle the scenarios :

1.If the household is voided , what information should be present in the household number for the individual?
2.If an individual is included in two households, which household number should be assigned to them?
3.If an individual is registered and added, the household number cannot be automatically populated.
4.We unable to register the individual without the household number and that doesn’t allow the duplicate values
5.if register the individual without adding into the household - Invalid scenario
6.If we register the individual and add in the household the household number should be updated - Invalid scenario
7.If I register the individual and added in the household and if I remove the individual what we have to update in the household number

@vinayvenu
Copy link
Member

@salilsamanvay @nupoorkhandelwal can you please provide exactly what needs to be done as part of this card?

@vedfordev vedfordev self-assigned this Dec 18, 2023
@vedfordev
Copy link
Contributor

entityContext is not available in old style rule. Moving card to product dependent

@nupoorkhandelwal
Copy link

@mahalakshme
Copy link

@nupoorkhandelwal fix made in product and ll be released towards the end of this year. But to avoid blocking the issue, the specific rule alone can be added in new rule style.

@vedfordev
Copy link
Contributor

backup :

    @WithStatusBuilder
    householdNumber([individual], statusBuilder) {
        const groups = individual.groupSubjects;
        console.log("========================================>groups",individual.groups.length);
        console.log("========================================>groupSubjects",individual.groupSubjects.length);
        console.log("========================================>uuid",individual);
        if (groups && groups.length > 0) {
            const householdNumber = groups[0].groupSubject.getObservationReadableValue('24dabc3a-6562-4521-bd42-5fff11ea5c46');
            statusBuilder.value(householdNumber);
        }
    }

@mahalakshme
Copy link

@nupoorkhandelwal like mentioned above by me in the comment, was the rule tried in new style rule and is it working? Fixing it in product is requiring more effort and delaying the release. If it works in new style, it would be easier for the implementation team as well. cc: @salilsamanvay

@vedfordev vedfordev removed their assignment Jan 12, 2024
@sachsk
Copy link
Member

sachsk commented Jan 12, 2024

Rule for the HH number :

({params, imports}) => {
 const individual = params.entity;
 const moment = imports.moment;
 const formElement = params.formElement;
 const _ = imports.lodash;
 let visibility = true;
 let value = null;
 let answersToSkip = [];
 let validationErrors = [];
 
 const groupSubject = params.entityContext.group;

 if(groupSubject !== undefined){
    const id = groupSubject.getObservationReadableValue('Household number');
    value = id; 
  }
 return new imports.rulesConfig.FormElementStatus(formElement.uuid, visibility, value, answersToSkip, validationErrors);
}; 

@nupoorkhandelwal
Copy link

@Gojo-Taqi the actual uuid for Household number that is supposed to be used is 24dabc3a-6562-4521-bd42-5fff11ea5c46, checked on prod.

@pkundu pkundu added the Support label Jan 23, 2024
@nupoorkhandelwal
Copy link

@Gojo-Taqi App related changes are moved to IHMP prod, you just need to write script to add HH number for ind with missing value for hh number.

@Dinesh2019 Dinesh2019 self-assigned this Jan 23, 2024
@Gojo-Taqi
Copy link
Contributor

  • Added "Household number" in all the reports coming under the folder "MPR needs assessment line lists"
  • Added "Household number" in "List of neonatal children" in the folder "Reports with new tables".

@Dinesh2019
Copy link

  1. We have data loss so those individuals don't have the household number
  2. kulkarnig@ihmp updated the household number form element as non-mandatory and disabled ready only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests