From 1d64332c4128d4fe8f507ddc6022a78be60df668 Mon Sep 17 00:00:00 2001 From: issyzac Date: Wed, 27 Sep 2023 12:36:53 +0300 Subject: [PATCH 01/19] :recycle: translations --- opensrp-chw/src/kk/res/values-sw/strings.xml | 1 + opensrp-chw/src/kk/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/opensrp-chw/src/kk/res/values-sw/strings.xml b/opensrp-chw/src/kk/res/values-sw/strings.xml index 01ffb508f..b34b69f5c 100644 --- a/opensrp-chw/src/kk/res/values-sw/strings.xml +++ b/opensrp-chw/src/kk/res/values-sw/strings.xml @@ -154,6 +154,7 @@ Taarifa za mahudhurio ya mtoto Je mtoto amekuja na mlezi wake %s? Je mtoto aliwekwa kwenye grupu gani? + Mtu gani ambae alikuja kwa niaba ya mlezi wa mtoto? Ukiachana na mama mzazi wa mtoto, ni walezi gani wengine ambao walihudhuria? Watu gani wengine ambao walikuja kwa niaba ya mlezi wa mtoto? Chagua Mtoto Aliyehudhuria diff --git a/opensrp-chw/src/kk/res/values/strings.xml b/opensrp-chw/src/kk/res/values/strings.xml index ce2b381fb..765d65697 100644 --- a/opensrp-chw/src/kk/res/values/strings.xml +++ b/opensrp-chw/src/kk/res/values/strings.xml @@ -174,6 +174,7 @@ Did the child come with their caregiver %s? Select the group Which other people were present beyond the caregiver? + What is the child\' relationship to the adult that came on behalf of primary caregiver What is the child\' relationship to the adult that came on behalf of primary caregiver Select Child Present Did you divide children into different age groups? From f00262b7932eda1a755b9d4641a5f92c7ae1da84 Mon Sep 17 00:00:00 2001 From: issyzac Date: Wed, 27 Sep 2023 12:37:25 +0300 Subject: [PATCH 02/19] :zap: caregiver representative questions added --- .../layout/dialog_fragment_childselection.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml index 823b3faaf..13bbfce42 100644 --- a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml +++ b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml @@ -98,6 +98,25 @@ android:choiceMode="singleChoice" android:divider="@color/transparent" /> + + + + + Date: Wed, 27 Sep 2023 12:37:58 +0300 Subject: [PATCH 03/19] :zap: caregiver rep ux --- ...ectChildForGroupSessionDialogFragment.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 1498fee2a..8e6711ebb 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -1,5 +1,6 @@ package org.smartregister.chw.fragment; +import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; import android.os.Bundle; @@ -29,10 +30,16 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private RecyclerView who_came_with_the_child_lv; + private RecyclerView came_with_pc_lv; + private RecyclerView lv_caregiver_representative; private TextView who_came_with_child_tv; + private TextView tv_caregiver_representative; + private KKCustomAdapter came_with_pc_lv_adapter; private KKCustomAdapter selected_group_lv_adapter; + private KKCustomAdapter cg_rep_lv_adapter; + private int selectedPosition1 = -1; private int selectedPosition2 = -1; private int selectedPosition3 = -1; @@ -58,12 +65,20 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity()); LayoutInflater inflater = requireActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_fragment_childselection, null); + TextView came_with_pc_tv = view.findViewById(R.id.came_with_pc); came_with_pc_tv.setText(String.format(getString(R.string.primary_care_give_dialog_gs), primaryCareGiverName)); builder.setView(view); - RecyclerView came_with_pc_lv = view.findViewById(R.id.came_with_pc_lv); + came_with_pc_lv = view.findViewById(R.id.came_with_pc_lv); who_came_with_the_child_lv = view.findViewById(R.id.who_came_with_the_child_lv); + + lv_caregiver_representative = view.findViewById(R.id.cg_rep_lv); + lv_caregiver_representative.setVisibility(View.GONE); + lv_caregiver_representative.setScrollContainer(false); + tv_caregiver_representative = view.findViewById(R.id.cg_rep_tv); + tv_caregiver_representative.setVisibility(View.GONE); + TextView selected_group = view.findViewById(R.id.selected_group); RecyclerView selected_group_lv = view.findViewById(R.id.selected_group_lv); selected_group_lv.setScrollContainer(false); @@ -87,11 +102,15 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { String[] groupItems = getResources().getStringArray(R.array.group_session_groups); selected_group_lv_adapter = new KKCustomAdapter(groupItems, requireContext()); - came_with_pc_lv.setAdapter(came_with_pc_lv_adapter); who_came_with_the_child_lv.setAdapter(who_came_with_the_child_lv_adapter); selected_group_lv.setAdapter(selected_group_lv_adapter); + String[] representativesList = getResources().getStringArray(R.array.multi_select_accompany_child_option); + cg_rep_lv_adapter = new KKCustomAdapter(representativesList, requireContext()); + lv_caregiver_representative.setAdapter(cg_rep_lv_adapter); + lv_caregiver_representative.setLayoutManager(new LinearLayoutManager(requireContext())); + came_with_pc_lv.setLayoutManager(new LinearLayoutManager(requireContext())); who_came_with_the_child_lv.setLayoutManager(new LinearLayoutManager(requireContext())); selected_group_lv.setLayoutManager(new LinearLayoutManager(requireContext())); @@ -163,8 +182,14 @@ public void onAttach(@NonNull Context context) { private void modifyChildCameWith(boolean hide) { if (hide) { + //Child came with the care giver + tv_caregiver_representative.setVisibility(View.GONE); + lv_caregiver_representative.setVisibility(View.GONE); who_came_with_child_tv.setText(R.string.who_came_with_the_child_yes); } else { + //Child did not come with the caregiver + tv_caregiver_representative.setVisibility(View.VISIBLE); + lv_caregiver_representative.setVisibility(View.VISIBLE); who_came_with_child_tv.setText(R.string.who_came_with_the_child_no); } } From 8b3ee8166e152f821d25c2c8fa1a02088a41bec1 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 3 Oct 2023 12:42:11 +0300 Subject: [PATCH 04/19] use checkbox for selecting caregiver representatives --- ...ectChildForGroupSessionDialogFragment.java | 20 ++++++++++++------- opensrp-chw/src/kk/res/values-sw/strings.xml | 2 +- opensrp-chw/src/kk/res/values/strings.xml | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 8e6711ebb..c7058827e 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -38,7 +38,7 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private KKCustomAdapter came_with_pc_lv_adapter; private KKCustomAdapter selected_group_lv_adapter; - private KKCustomAdapter cg_rep_lv_adapter; + private KKCustomAdapterMultiSelectList cg_rep_lv_adapter; private int selectedPosition1 = -1; private int selectedPosition2 = -1; @@ -50,6 +50,8 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private final boolean childrenDividedIntoGroups; + private final ArrayList multiSelectListItems = new ArrayList<>(); + SelectChildForGroupSessionRegisterFragment.DialogDismissListener dialogDismissListener; public SelectChildForGroupSessionDialogFragment(String selectedChildBaseEntityId, String primaryCareGiverName, boolean childrenDividedIntoGroups, SelectChildForGroupSessionRegisterFragment.DialogDismissListener listener) { @@ -94,10 +96,9 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { who_came_with_child_tv = view.findViewById(R.id.who_came_with_child_tv); came_with_pc_lv_adapter = new KKCustomAdapter(getResources().getStringArray(R.array.select_child_option), requireContext()); - ArrayList multiSelectListItems = new ArrayList<>(); - for(String item : getResources().getStringArray(R.array.multi_select_accompany_child_option)){ - multiSelectListItems.add(new MultiSelectListItemModel(item, false)); - } + + setMultiSelectListItems(); + KKCustomAdapterMultiSelectList who_came_with_the_child_lv_adapter = new KKCustomAdapterMultiSelectList(multiSelectListItems, requireContext()); String[] groupItems = getResources().getStringArray(R.array.group_session_groups); @@ -106,8 +107,7 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { who_came_with_the_child_lv.setAdapter(who_came_with_the_child_lv_adapter); selected_group_lv.setAdapter(selected_group_lv_adapter); - String[] representativesList = getResources().getStringArray(R.array.multi_select_accompany_child_option); - cg_rep_lv_adapter = new KKCustomAdapter(representativesList, requireContext()); + cg_rep_lv_adapter = new KKCustomAdapterMultiSelectList(multiSelectListItems, requireContext()); lv_caregiver_representative.setAdapter(cg_rep_lv_adapter); lv_caregiver_representative.setLayoutManager(new LinearLayoutManager(requireContext())); @@ -201,4 +201,10 @@ void onSelectComeWithPrimaryCareGiver( String selectedGroup); } + private void setMultiSelectListItems(){ + for(String item : getResources().getStringArray(R.array.multi_select_accompany_child_option)){ + multiSelectListItems.add(new MultiSelectListItemModel(item, false)); + } + } + } diff --git a/opensrp-chw/src/kk/res/values-sw/strings.xml b/opensrp-chw/src/kk/res/values-sw/strings.xml index b34b69f5c..40fe3ce11 100644 --- a/opensrp-chw/src/kk/res/values-sw/strings.xml +++ b/opensrp-chw/src/kk/res/values-sw/strings.xml @@ -156,7 +156,7 @@ Je mtoto aliwekwa kwenye grupu gani? Mtu gani ambae alikuja kwa niaba ya mlezi wa mtoto? Ukiachana na mama mzazi wa mtoto, ni walezi gani wengine ambao walihudhuria? - Watu gani wengine ambao walikuja kwa niaba ya mlezi wa mtoto? + Ukiachana na mlezi ambaye alikuja kwa niaba ya mzazi wa mtoto, ni walezi gani wengine ambao walihudhuria? Chagua Mtoto Aliyehudhuria Je uliwatenganisha watoto kwenye makundi tofauti? Tarehe ya kipindi diff --git a/opensrp-chw/src/kk/res/values/strings.xml b/opensrp-chw/src/kk/res/values/strings.xml index 765d65697..f1bd35134 100644 --- a/opensrp-chw/src/kk/res/values/strings.xml +++ b/opensrp-chw/src/kk/res/values/strings.xml @@ -174,8 +174,8 @@ Did the child come with their caregiver %s? Select the group Which other people were present beyond the caregiver? - What is the child\' relationship to the adult that came on behalf of primary caregiver - What is the child\' relationship to the adult that came on behalf of primary caregiver + What is the child\'s relationship to the adult that came on behalf of primary caregiver + Which other people were present beyond the person who came on behalf of the Primary Care giver? Select Child Present Did you divide children into different age groups? Select session date From 40a524ae32f0ac25de74fbec4756ca2343985c2e Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 3 Oct 2023 12:43:34 +0300 Subject: [PATCH 05/19] disable recycleview scrolling --- .../layout/dialog_fragment_childselection.xml | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml index 13bbfce42..3710ac43e 100644 --- a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml +++ b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml @@ -115,7 +115,17 @@ android:layout_height="wrap_content" android:layout_marginTop="4dp" android:choiceMode="singleChoice" - android:isScrollContainer="false" /> + android:isScrollContainer="false" + android:overScrollMode="never"/> + + - - + android:layout_height="wrap_content"> + + + + Date: Tue, 3 Oct 2023 16:41:05 +0300 Subject: [PATCH 06/19] refactor --- ...ectChildForGroupSessionDialogFragment.java | 43 ++++++++++++++++--- opensrp-chw/src/kk/res/values-sw/strings.xml | 2 + opensrp-chw/src/kk/res/values/strings.xml | 2 + 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index c7058827e..0644a2496 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; @@ -52,6 +53,8 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private final ArrayList multiSelectListItems = new ArrayList<>(); + private EditText cg_rep_lv_other; + SelectChildForGroupSessionRegisterFragment.DialogDismissListener dialogDismissListener; public SelectChildForGroupSessionDialogFragment(String selectedChildBaseEntityId, String primaryCareGiverName, boolean childrenDividedIntoGroups, SelectChildForGroupSessionRegisterFragment.DialogDismissListener listener) { @@ -85,6 +88,9 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { RecyclerView selected_group_lv = view.findViewById(R.id.selected_group_lv); selected_group_lv.setScrollContainer(false); + cg_rep_lv_other = view.findViewById(R.id.cg_rep_lv_other); + cg_rep_lv_other.setVisibility(View.GONE); + if (childrenDividedIntoGroups) { selected_group_lv.setVisibility(View.VISIBLE); selected_group.setVisibility(View.VISIBLE); @@ -96,10 +102,8 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { who_came_with_child_tv = view.findViewById(R.id.who_came_with_child_tv); came_with_pc_lv_adapter = new KKCustomAdapter(getResources().getStringArray(R.array.select_child_option), requireContext()); - - setMultiSelectListItems(); - - KKCustomAdapterMultiSelectList who_came_with_the_child_lv_adapter = new KKCustomAdapterMultiSelectList(multiSelectListItems, requireContext()); + ArrayList multiSelectListItems = new ArrayList<>(); + KKCustomAdapterMultiSelectList who_came_with_the_child_lv_adapter = new KKCustomAdapterMultiSelectList(setMultiSelectListItems(multiSelectListItems), requireContext()); String[] groupItems = getResources().getStringArray(R.array.group_session_groups); selected_group_lv_adapter = new KKCustomAdapter(groupItems, requireContext()); @@ -107,7 +111,8 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { who_came_with_the_child_lv.setAdapter(who_came_with_the_child_lv_adapter); selected_group_lv.setAdapter(selected_group_lv_adapter); - cg_rep_lv_adapter = new KKCustomAdapterMultiSelectList(multiSelectListItems, requireContext()); + ArrayList multiSelectListItems1 = new ArrayList<>(); + cg_rep_lv_adapter = new KKCustomAdapterMultiSelectList(setMultiSelectListItems(multiSelectListItems1), requireContext()); lv_caregiver_representative.setAdapter(cg_rep_lv_adapter); lv_caregiver_representative.setLayoutManager(new LinearLayoutManager(requireContext())); @@ -126,6 +131,11 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { who_came_with_the_child_lv_adapter.setSelectedPosition(position); }); + cg_rep_lv_adapter.setOnItemSelectedListener(position -> { + cg_rep_lv_adapter.setSelectedPosition(position); + checkForOtherSelectedItem(); + }); + selected_group_lv_adapter.setOnItemSelectedListener(position -> { selectedPosition2 = position; selected_group_lv_adapter.setSelectedPosition(position); @@ -186,11 +196,13 @@ private void modifyChildCameWith(boolean hide) { tv_caregiver_representative.setVisibility(View.GONE); lv_caregiver_representative.setVisibility(View.GONE); who_came_with_child_tv.setText(R.string.who_came_with_the_child_yes); + cg_rep_lv_other.setVisibility(View.GONE); } else { //Child did not come with the caregiver tv_caregiver_representative.setVisibility(View.VISIBLE); lv_caregiver_representative.setVisibility(View.VISIBLE); who_came_with_child_tv.setText(R.string.who_came_with_the_child_no); + checkForOtherSelectedItem(); } } @@ -201,10 +213,29 @@ void onSelectComeWithPrimaryCareGiver( String selectedGroup); } - private void setMultiSelectListItems(){ + private ArrayList setMultiSelectListItems(ArrayList multiSelectListItems){ for(String item : getResources().getStringArray(R.array.multi_select_accompany_child_option)){ multiSelectListItems.add(new MultiSelectListItemModel(item, false)); } + return multiSelectListItems; + } + + public boolean isOtherItemSelected() { + for (MultiSelectListItemModel item : cg_rep_lv_adapter.getSelectedItems()) { + if (item.getName().equals(getString(R.string.cg_rep_lv_other)) && item.isSelected()) { + return true; + } + } + return false; + } + + private void checkForOtherSelectedItem(){ + if(isOtherItemSelected()){ + cg_rep_lv_other.setVisibility(View.VISIBLE); + }else{ + cg_rep_lv_other.setVisibility(View.GONE); + cg_rep_lv_other.getText().clear(); + } } } diff --git a/opensrp-chw/src/kk/res/values-sw/strings.xml b/opensrp-chw/src/kk/res/values-sw/strings.xml index 40fe3ce11..f1aae35c2 100644 --- a/opensrp-chw/src/kk/res/values-sw/strings.xml +++ b/opensrp-chw/src/kk/res/values-sw/strings.xml @@ -205,5 +205,7 @@ Tafadhali chagua kama watoto waligawanywa kwenye makundi au la Tafadhali chagua sababu za kipindi kutokutokea Muda wa kipingi kwenye saa na dakika + Mwingine + Mlezi mwingine \ No newline at end of file diff --git a/opensrp-chw/src/kk/res/values/strings.xml b/opensrp-chw/src/kk/res/values/strings.xml index f1bd35134..68907b259 100644 --- a/opensrp-chw/src/kk/res/values/strings.xml +++ b/opensrp-chw/src/kk/res/values/strings.xml @@ -224,5 +224,7 @@ Please indicate the reason for the session to not take place Please indicate whether children were divided into groups or not Session Duration in Hours and Minutes + Other + Other caregiver \ No newline at end of file From cbaa5f89dbad2e3ed26b1f1ecd41b2b66e758680 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 3 Oct 2023 16:45:22 +0300 Subject: [PATCH 07/19] display the textfield hint --- .../src/kk/res/layout/dialog_fragment_childselection.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml index 3710ac43e..6e4b1b101 100644 --- a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml +++ b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml @@ -124,7 +124,7 @@ android:layout_height="wrap_content" android:inputType = "text" android:textSize="14sp" - android:hint="Other relationship" + android:hint="@string/cg_rep_lv_other_hint" android:layout_marginVertical="8dp"/> Date: Sat, 7 Oct 2023 14:44:03 +0300 Subject: [PATCH 08/19] refactor --- .../chw/fragment/SelectChildForGroupSessionDialogFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 0644a2496..52961ba3d 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -51,8 +51,6 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private final boolean childrenDividedIntoGroups; - private final ArrayList multiSelectListItems = new ArrayList<>(); - private EditText cg_rep_lv_other; SelectChildForGroupSessionRegisterFragment.DialogDismissListener dialogDismissListener; From f1045fc1301972b5b3e2d9505c6581a472a4a2bd Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Mon, 16 Oct 2023 12:56:29 +0300 Subject: [PATCH 09/19] validate the form fields before submit --- ...ectChildForGroupSessionDialogFragment.java | 77 ++++++++++++++----- ...tChildForGroupSessionRegisterFragment.java | 5 ++ 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 52961ba3d..0824acc13 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -3,6 +3,7 @@ import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -40,6 +41,7 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private KKCustomAdapter came_with_pc_lv_adapter; private KKCustomAdapter selected_group_lv_adapter; private KKCustomAdapterMultiSelectList cg_rep_lv_adapter; + private KKCustomAdapterMultiSelectList who_came_with_the_child_lv_adapter; private int selectedPosition1 = -1; private int selectedPosition2 = -1; @@ -55,6 +57,8 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { SelectChildForGroupSessionRegisterFragment.DialogDismissListener dialogDismissListener; + String[] groupItems; + public SelectChildForGroupSessionDialogFragment(String selectedChildBaseEntityId, String primaryCareGiverName, boolean childrenDividedIntoGroups, SelectChildForGroupSessionRegisterFragment.DialogDismissListener listener) { this.selectedChildBaseEntityId = selectedChildBaseEntityId; this.primaryCareGiverName = primaryCareGiverName; @@ -101,9 +105,9 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { came_with_pc_lv_adapter = new KKCustomAdapter(getResources().getStringArray(R.array.select_child_option), requireContext()); ArrayList multiSelectListItems = new ArrayList<>(); - KKCustomAdapterMultiSelectList who_came_with_the_child_lv_adapter = new KKCustomAdapterMultiSelectList(setMultiSelectListItems(multiSelectListItems), requireContext()); + who_came_with_the_child_lv_adapter = new KKCustomAdapterMultiSelectList(setMultiSelectListItems(multiSelectListItems), requireContext()); - String[] groupItems = getResources().getStringArray(R.array.group_session_groups); + groupItems = getResources().getStringArray(R.array.group_session_groups); selected_group_lv_adapter = new KKCustomAdapter(groupItems, requireContext()); came_with_pc_lv.setAdapter(came_with_pc_lv_adapter); who_came_with_the_child_lv.setAdapter(who_came_with_the_child_lv_adapter); @@ -144,37 +148,64 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { Toast.makeText(requireContext(), "Caregiver information missing", Toast.LENGTH_SHORT).show(); dialogDismissListener.onFailure(); dialog.dismiss(); - } - - if (selectedPosition2 == -1 && childrenDividedIntoGroups) { + }else if (selectedPosition2 == -1 && childrenDividedIntoGroups) { Toast.makeText(requireContext(), "Child missing the group", Toast.LENGTH_SHORT).show(); dialogDismissListener.onFailure(); dialog.dismiss(); + }else { + handleSuccess(dialog); } + }); - if (dialogListener != null && (selectedPosition2 != -1 || !childrenDividedIntoGroups) && selectedPosition1 != -1) { + builder.setNegativeButton(R.string.cancel, (dialog, which) -> { + dialogDismissListener.onFailure(); + dialog.dismiss(); + }); + + return builder.create(); + } + + void handleSuccess(DialogInterface dialogInterface){ + if(selectedPosition1 == 0){ + if(who_came_with_the_child_lv_adapter.getSelectedItems().size() > 0){ dialogListener.onSelectComeWithPrimaryCareGiver( - selectedPosition1 == 0, + true, selectedChildBaseEntityId, who_came_with_the_child_lv_adapter.getSelectedItems(), - !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2] + groupItems[selectedPosition2] ); - dialogDismissListener.onSuccess(); - dialog.dismiss(); + dialogValidationSuccess(dialogInterface); }else{ - Toast.makeText(requireContext(), "Missing information for the child", Toast.LENGTH_SHORT).show(); - dialogDismissListener.onFailure(); - dialog.dismiss(); + dialogValidationFail(dialogInterface,"The companions of caregiver missing"); } + }else if(selectedPosition1 == 1){ + if(cg_rep_lv_adapter.getSelectedItems().size() > 0){ + if(who_came_with_the_child_lv_adapter.getSelectedItems().size() > 0){ + dialogListener.onSelectComeWithoutPrimaryCareGiver( + false, + selectedChildBaseEntityId, + cg_rep_lv_adapter.getSelectedItems(), + who_came_with_the_child_lv_adapter.getSelectedItems(), + groupItems[selectedPosition2]); + dialogValidationSuccess(dialogInterface); + }else{ + dialogValidationFail(dialogInterface,"The companions of caregiver representative missing"); + } + }else{ + dialogValidationFail(dialogInterface,"Caregiver representatives missing"); + } + } + } - }); - - builder.setNegativeButton(R.string.cancel, (dialog, which) -> { - dialogDismissListener.onFailure(); - dialog.dismiss(); - }); + void dialogValidationFail(DialogInterface dialogInterface,String message){ + Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show(); + dialogDismissListener.onFailure(); + dialogInterface.dismiss(); + } - return builder.create(); + void dialogValidationSuccess(DialogInterface dialogInterface){ + dialogDismissListener.onSuccess(); + dialogInterface.dismiss(); } @Override @@ -209,6 +240,12 @@ void onSelectComeWithPrimaryCareGiver( boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedAccompanyingCaregivers, String selectedGroup); + + void onSelectComeWithoutPrimaryCareGiver( + boolean isComeWithPrimaryCareGiver, + String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, + List selectedAccompanyingCaregiverRepresentatives, + String selectedGroup); } private ArrayList setMultiSelectListItems(ArrayList multiSelectListItems){ diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java index ea520fb55..587b9c1c6 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java @@ -119,6 +119,11 @@ public void onSelectComeWithPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced)); } + @Override + public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String selectedGroup) { + + } + private String getTranslatedAccompanyingRelatives(String name) { switch (name) { From 25b3d91801e18e6a6ca0cc349c86da23ee8c484c Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Mon, 16 Oct 2023 16:04:24 +0300 Subject: [PATCH 10/19] add caregiver representaives to the selected child model --- ...lectChildForGroupSessionRegisterFragment.java | 16 ++++++++++++++-- .../smartregister/chw/model/SelectedChildGS.java | 9 +++++++++ ...lectChildForGroupSessionFragmentProvider.java | 10 ++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java index 587b9c1c6..337ad6582 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java @@ -120,8 +120,20 @@ public void onSelectComeWithPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, } @Override - public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String selectedGroup) { - + public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { + List listOfAccompanyingRelatives = new ArrayList<>(); + List listOfCaregiverRepresentatives = new ArrayList<>(); + for (MultiSelectListItemModel multiSelectListItemModel : selectedAccompanyingCaregiverRepresentatives) { + listOfAccompanyingRelatives.add(getTranslatedAccompanyingRelatives(multiSelectListItemModel.getName())); + } + for (MultiSelectListItemModel multiSelectListItemModel : selectedCaregiverRepresentatives) { + listOfCaregiverRepresentatives.add(getTranslatedAccompanyingRelatives(multiSelectListItemModel.getName())); + } + childRegisterProvider.updateStatusOfChildWithoutCareGiver(selectedChildBaseEntityId, + isComeWithPrimaryCareGiver, + listOfCaregiverRepresentatives, + listOfAccompanyingRelatives, + GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced)); } private String getTranslatedAccompanyingRelatives(String name) { diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java index 63d08545b..fca4125fa 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java @@ -14,6 +14,8 @@ public class SelectedChildGS { private List accompanyingRelatives = null; + private List careGiverRepresentatives; + public SelectedChildGS(String childBaseEntityId, ChildStatus childSelectionStatus, boolean cameWithPrimaryCareGiver, String groupPlaced) { this.childBaseEntityId = childBaseEntityId; this.childSelectionStatus = childSelectionStatus; @@ -61,6 +63,13 @@ public void setAccompanyingRelatives(List accompanyingRelatives) { this.accompanyingRelatives = accompanyingRelatives; } + public List getCareGiverRepresentatives() { + return accompanyingRelatives; + } + + public void setCareGiverRepresentatives(List careGiverRepresentatives) { + this.careGiverRepresentatives = careGiverRepresentatives; + } public enum ChildStatus { SELECTED, diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java index 4a5a5bb8c..788fa7bcf 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java @@ -19,6 +19,7 @@ import org.smartregister.chw.core.holders.RegisterViewHolder; import org.smartregister.chw.core.utils.ChildDBConstants; import org.smartregister.chw.holders.SelectChildGSViewHolder; +import org.smartregister.chw.model.MultiSelectListItemModel; import org.smartregister.chw.model.SelectedChildGS; import org.smartregister.commonregistry.CommonPersonObjectClient; import org.smartregister.commonregistry.CommonRepository; @@ -78,6 +79,15 @@ public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCare } } + public void updateStatusOfChildWithoutCareGiver(String baseEntityId, boolean cameWithCareGiver, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { + if (childList.containsKey(baseEntityId)) { + Objects.requireNonNull(childList.get(baseEntityId)).setCameWithPrimaryCareGiver(cameWithCareGiver); + Objects.requireNonNull(childList.get(baseEntityId)).setGroupPlaced(groupPlaced); + Objects.requireNonNull(childList.get(baseEntityId)).setAccompanyingRelatives(selectedAccompanyingCaregiverRepresentatives); + Objects.requireNonNull(childList.get(baseEntityId)).setCareGiverRepresentatives(selectedCaregiverRepresentatives); + } + } + protected void populatePatientColumn(CommonPersonObjectClient pc, SmartRegisterClient client, SelectChildGSViewHolder viewHolder) { String parentFirstName = Utils.getValue(pc.getColumnmaps(), ChildDBConstants.KEY.FAMILY_FIRST_NAME, true); String parentLastName = Utils.getValue(pc.getColumnmaps(), ChildDBConstants.KEY.FAMILY_LAST_NAME, true); From ae3972362d0f255b2881d6a64b8cffb79ac2493f Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 11:16:55 +0300 Subject: [PATCH 11/19] add caregiver representatives to the child events --- .../src/kk/assets/json.form/group_session_child_form.json | 7 +++++++ .../fragment/SelectChildForGroupSessionDialogFragment.java | 4 ++-- .../java/org/smartregister/chw/model/SelectedChildGS.java | 2 +- .../kk/java/org/smartregister/chw/util/KkConstants.java | 2 +- .../chw/application/ChwSyncConfiguration.java | 2 +- .../chw/interactor/GroupSessionInteractor.java | 3 +++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json b/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json index 9cf349a13..483f817ae 100644 --- a/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json +++ b/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json @@ -83,6 +83,13 @@ "openmrs_entity": "concept", "openmrs_entity_id": "other_people_present", "type": "hidden" + }, + { + "key": "care_giver_representatives", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "care_giver_representatives", + "type": "hidden" } ] }, diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 0824acc13..ca84866cc 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -172,7 +172,7 @@ void handleSuccess(DialogInterface dialogInterface){ true, selectedChildBaseEntityId, who_came_with_the_child_lv_adapter.getSelectedItems(), - groupItems[selectedPosition2] + !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2] ); dialogValidationSuccess(dialogInterface); }else{ @@ -186,7 +186,7 @@ void handleSuccess(DialogInterface dialogInterface){ selectedChildBaseEntityId, cg_rep_lv_adapter.getSelectedItems(), who_came_with_the_child_lv_adapter.getSelectedItems(), - groupItems[selectedPosition2]); + !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2]); dialogValidationSuccess(dialogInterface); }else{ dialogValidationFail(dialogInterface,"The companions of caregiver representative missing"); diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java index fca4125fa..b022cbfa4 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java @@ -64,7 +64,7 @@ public void setAccompanyingRelatives(List accompanyingRelatives) { } public List getCareGiverRepresentatives() { - return accompanyingRelatives; + return careGiverRepresentatives; } public void setCareGiverRepresentatives(List careGiverRepresentatives) { diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java b/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java index 956154567..5daa7d418 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java @@ -176,7 +176,7 @@ public static class GCJsonKeys { public static final String GC_ALL_CAREGIVERS_PRESENT = "all_caregivers_present"; public static final String GC_CHILD_GROUP_PLACED = "child_group_placed"; public static final String GC_CHILD_CAME_WITH_OTHER_PEOPLE = "other_people_present"; - + public static final String GC_CAREGIVER_REPRESENTATIVES = "care_giver_representatives"; } } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java index 510adb4f8..ce2cb9125 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java @@ -59,7 +59,7 @@ public boolean isSyncSettings() { @Override public SyncFilter getEncryptionParam() { - return isProductionEnvironment() ? SyncFilter.PROVIDER : SyncFilter.LOCATION; + return SyncFilter.TEAM_ID; } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java index af0e4b7d2..5fa9b6a57 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java @@ -304,6 +304,9 @@ private void processChildPopulatableFields(JSONObject field, GroupSessionModel s case KkConstants.GCJsonKeys.GC_CHILD_CAME_WITH_OTHER_PEOPLE: field.put(org.smartregister.chw.util.JsonFormUtils.VALUE, selectedChildGS.getAccompanyingRelatives()); break; + case KkConstants.GCJsonKeys.GC_CAREGIVER_REPRESENTATIVES: + field.put(org.smartregister.chw.util.JsonFormUtils.VALUE, selectedChildGS.getCareGiverRepresentatives()); + break; default: break; } From 0d140a6c70cb623b6155849fbff0bfee4b47ae47 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 11:46:25 +0300 Subject: [PATCH 12/19] refactor --- ...tChildForGroupSessionRegisterFragment.java | 33 +++++++++---------- ...tChildForGroupSessionFragmentProvider.java | 10 +----- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java index 337ad6582..98f7768e8 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java @@ -108,32 +108,31 @@ private String getClientCareGiverName(CommonPersonObjectClient client) { @Override public void onSelectComeWithPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedAccompanyingCaregivers, String groupPlaced) { Timber.d("The Child with id %s Come with Primary Care Giver: %s", selectedChildBaseEntityId, isComeWithPrimaryCareGiver); - List listOfAccompanyingRelatives = new ArrayList<>(); - for (MultiSelectListItemModel multiSelectListItemModel : selectedAccompanyingCaregivers) { - listOfAccompanyingRelatives.add(getTranslatedAccompanyingRelatives(multiSelectListItemModel.getName())); - } - + List listOfAccompanyingRelatives = getTranslatedNames(selectedAccompanyingCaregivers); childRegisterProvider.updateChildSelectionStatus(selectedChildBaseEntityId, isComeWithPrimaryCareGiver, listOfAccompanyingRelatives, - GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced)); + GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced), + null); } @Override public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { - List listOfAccompanyingRelatives = new ArrayList<>(); - List listOfCaregiverRepresentatives = new ArrayList<>(); - for (MultiSelectListItemModel multiSelectListItemModel : selectedAccompanyingCaregiverRepresentatives) { - listOfAccompanyingRelatives.add(getTranslatedAccompanyingRelatives(multiSelectListItemModel.getName())); - } - for (MultiSelectListItemModel multiSelectListItemModel : selectedCaregiverRepresentatives) { - listOfCaregiverRepresentatives.add(getTranslatedAccompanyingRelatives(multiSelectListItemModel.getName())); - } - childRegisterProvider.updateStatusOfChildWithoutCareGiver(selectedChildBaseEntityId, + List listOfAccompanyingRelatives = getTranslatedNames(selectedAccompanyingCaregiverRepresentatives);; + List listOfCaregiverRepresentatives = getTranslatedNames(selectedCaregiverRepresentatives); + childRegisterProvider.updateChildSelectionStatus(selectedChildBaseEntityId, isComeWithPrimaryCareGiver, - listOfCaregiverRepresentatives, listOfAccompanyingRelatives, - GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced)); + GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced), + listOfCaregiverRepresentatives); + } + + private List getTranslatedNames(List items) { + List translatedNames = new ArrayList<>(); + for (MultiSelectListItemModel item : items) { + translatedNames.add(getTranslatedAccompanyingRelatives(item.getName())); + } + return translatedNames; } private String getTranslatedAccompanyingRelatives(String name) { diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java index 788fa7bcf..2361f19cb 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java @@ -71,19 +71,11 @@ public HashMap getSelectedChildList() { return childList; } - public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCareGiver, List accompanyingRelatives, String groupPlaced) { + public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCareGiver, List accompanyingRelatives, String groupPlaced, List selectedCaregiverRepresentatives) { if (childList.containsKey(baseEntityId)) { Objects.requireNonNull(childList.get(baseEntityId)).setCameWithPrimaryCareGiver(cameWithCareGiver); Objects.requireNonNull(childList.get(baseEntityId)).setGroupPlaced(groupPlaced); Objects.requireNonNull(childList.get(baseEntityId)).setAccompanyingRelatives(accompanyingRelatives); - } - } - - public void updateStatusOfChildWithoutCareGiver(String baseEntityId, boolean cameWithCareGiver, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { - if (childList.containsKey(baseEntityId)) { - Objects.requireNonNull(childList.get(baseEntityId)).setCameWithPrimaryCareGiver(cameWithCareGiver); - Objects.requireNonNull(childList.get(baseEntityId)).setGroupPlaced(groupPlaced); - Objects.requireNonNull(childList.get(baseEntityId)).setAccompanyingRelatives(selectedAccompanyingCaregiverRepresentatives); Objects.requireNonNull(childList.get(baseEntityId)).setCareGiverRepresentatives(selectedCaregiverRepresentatives); } } From 8bb1ce358377ac0f6d276d1c0aaca9a441651e9d Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 11:56:35 +0300 Subject: [PATCH 13/19] make companions field optional --- ...electChildForGroupSessionDialogFragment.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index ca84866cc..c45d6ab5e 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -180,17 +180,12 @@ void handleSuccess(DialogInterface dialogInterface){ } }else if(selectedPosition1 == 1){ if(cg_rep_lv_adapter.getSelectedItems().size() > 0){ - if(who_came_with_the_child_lv_adapter.getSelectedItems().size() > 0){ - dialogListener.onSelectComeWithoutPrimaryCareGiver( - false, - selectedChildBaseEntityId, - cg_rep_lv_adapter.getSelectedItems(), - who_came_with_the_child_lv_adapter.getSelectedItems(), - !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2]); - dialogValidationSuccess(dialogInterface); - }else{ - dialogValidationFail(dialogInterface,"The companions of caregiver representative missing"); - } + dialogListener.onSelectComeWithoutPrimaryCareGiver( + false, + selectedChildBaseEntityId, + cg_rep_lv_adapter.getSelectedItems(), + who_came_with_the_child_lv_adapter.getSelectedItems(), + !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2]); }else{ dialogValidationFail(dialogInterface,"Caregiver representatives missing"); } From 478fe3df78a75cc5f8169f46aeac96f03c5fe251 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 14:18:04 +0300 Subject: [PATCH 14/19] capture other caregiver representative info --- .../json.form/group_session_child_form.json | 7 ++++++ ...ectChildForGroupSessionDialogFragment.java | 24 ++++++++++++------- ...tChildForGroupSessionRegisterFragment.java | 7 +++--- .../chw/model/SelectedChildGS.java | 10 ++++++++ ...tChildForGroupSessionFragmentProvider.java | 3 ++- .../smartregister/chw/util/KkConstants.java | 1 + .../interactor/GroupSessionInteractor.java | 3 +++ 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json b/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json index 483f817ae..47efd0578 100644 --- a/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json +++ b/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json @@ -90,6 +90,13 @@ "openmrs_entity": "concept", "openmrs_entity_id": "care_giver_representatives", "type": "hidden" + }, + { + "key": "care_giver_representatives_other", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "care_giver_representatives_other", + "type": "hidden" } ] }, diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index c45d6ab5e..c47fa3ee3 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -167,7 +167,9 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { void handleSuccess(DialogInterface dialogInterface){ if(selectedPosition1 == 0){ - if(who_came_with_the_child_lv_adapter.getSelectedItems().size() > 0){ + if(who_came_with_the_child_lv_adapter.getSelectedItems().isEmpty()){ + dialogValidationFail(dialogInterface,"The companions of caregiver missing"); + }else{ dialogListener.onSelectComeWithPrimaryCareGiver( true, selectedChildBaseEntityId, @@ -175,19 +177,22 @@ void handleSuccess(DialogInterface dialogInterface){ !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2] ); dialogValidationSuccess(dialogInterface); - }else{ - dialogValidationFail(dialogInterface,"The companions of caregiver missing"); } }else if(selectedPosition1 == 1){ - if(cg_rep_lv_adapter.getSelectedItems().size() > 0){ + String otherCaregiverRepresentative = cg_rep_lv_other.getText().toString(); + if(cg_rep_lv_adapter.getSelectedItems().isEmpty()){ + dialogValidationFail(dialogInterface,"Caregiver representatives missing"); + }else if(isOtherItemSelected() && otherCaregiverRepresentative.isEmpty()){ + dialogValidationFail(dialogInterface,"Other caregiver representative missing"); + }else{ dialogListener.onSelectComeWithoutPrimaryCareGiver( false, selectedChildBaseEntityId, cg_rep_lv_adapter.getSelectedItems(), + otherCaregiverRepresentative.isEmpty() ? null : otherCaregiverRepresentative, who_came_with_the_child_lv_adapter.getSelectedItems(), !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2]); - }else{ - dialogValidationFail(dialogInterface,"Caregiver representatives missing"); + dialogValidationSuccess(dialogInterface); } } } @@ -233,12 +238,15 @@ private void modifyChildCameWith(boolean hide) { public interface DialogListener { void onSelectComeWithPrimaryCareGiver( boolean isComeWithPrimaryCareGiver, - String selectedChildBaseEntityId, List selectedAccompanyingCaregivers, + String selectedChildBaseEntityId, + List selectedAccompanyingCaregivers, String selectedGroup); void onSelectComeWithoutPrimaryCareGiver( boolean isComeWithPrimaryCareGiver, - String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, + String selectedChildBaseEntityId, + List selectedCaregiverRepresentatives, + String otherCaregiverRepresentative, List selectedAccompanyingCaregiverRepresentatives, String selectedGroup); } diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java index 98f7768e8..6b45fd35e 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java @@ -113,18 +113,19 @@ public void onSelectComeWithPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, isComeWithPrimaryCareGiver, listOfAccompanyingRelatives, GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced), - null); + null,null); } @Override - public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { + public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, String otherCaregiverRepresentative, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { List listOfAccompanyingRelatives = getTranslatedNames(selectedAccompanyingCaregiverRepresentatives);; List listOfCaregiverRepresentatives = getTranslatedNames(selectedCaregiverRepresentatives); childRegisterProvider.updateChildSelectionStatus(selectedChildBaseEntityId, isComeWithPrimaryCareGiver, listOfAccompanyingRelatives, GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced), - listOfCaregiverRepresentatives); + listOfCaregiverRepresentatives, + otherCaregiverRepresentative); } private List getTranslatedNames(List items) { diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java index b022cbfa4..68bdd8238 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java @@ -16,6 +16,8 @@ public class SelectedChildGS { private List careGiverRepresentatives; + private String otherCaregiverRepresentative; + public SelectedChildGS(String childBaseEntityId, ChildStatus childSelectionStatus, boolean cameWithPrimaryCareGiver, String groupPlaced) { this.childBaseEntityId = childBaseEntityId; this.childSelectionStatus = childSelectionStatus; @@ -71,6 +73,14 @@ public void setCareGiverRepresentatives(List careGiverRepresentatives) { this.careGiverRepresentatives = careGiverRepresentatives; } + public String getOtherCaregiverRepresentative() { + return otherCaregiverRepresentative; + } + + public void setOtherCaregiverRepresentative(String otherCaregiverRepresentative) { + this.otherCaregiverRepresentative = otherCaregiverRepresentative; + } + public enum ChildStatus { SELECTED, UNSELECTED diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java index 2361f19cb..53f4b90f8 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java @@ -71,12 +71,13 @@ public HashMap getSelectedChildList() { return childList; } - public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCareGiver, List accompanyingRelatives, String groupPlaced, List selectedCaregiverRepresentatives) { + public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCareGiver, List accompanyingRelatives, String groupPlaced, List selectedCaregiverRepresentatives, String otherCaregiverRepresentative) { if (childList.containsKey(baseEntityId)) { Objects.requireNonNull(childList.get(baseEntityId)).setCameWithPrimaryCareGiver(cameWithCareGiver); Objects.requireNonNull(childList.get(baseEntityId)).setGroupPlaced(groupPlaced); Objects.requireNonNull(childList.get(baseEntityId)).setAccompanyingRelatives(accompanyingRelatives); Objects.requireNonNull(childList.get(baseEntityId)).setCareGiverRepresentatives(selectedCaregiverRepresentatives); + Objects.requireNonNull(childList.get(baseEntityId)).setOtherCaregiverRepresentative(otherCaregiverRepresentative); } } diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java b/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java index 5daa7d418..08c2e2e21 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java @@ -177,6 +177,7 @@ public static class GCJsonKeys { public static final String GC_CHILD_GROUP_PLACED = "child_group_placed"; public static final String GC_CHILD_CAME_WITH_OTHER_PEOPLE = "other_people_present"; public static final String GC_CAREGIVER_REPRESENTATIVES = "care_giver_representatives"; + public static final String GC_CAREGIVER_REPRESENTATIVES_OTHER = "care_giver_representatives_other"; } } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java index 5fa9b6a57..dfc903d67 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java @@ -307,6 +307,9 @@ private void processChildPopulatableFields(JSONObject field, GroupSessionModel s case KkConstants.GCJsonKeys.GC_CAREGIVER_REPRESENTATIVES: field.put(org.smartregister.chw.util.JsonFormUtils.VALUE, selectedChildGS.getCareGiverRepresentatives()); break; + case KkConstants.GCJsonKeys.GC_CAREGIVER_REPRESENTATIVES_OTHER: + field.put(org.smartregister.chw.util.JsonFormUtils.VALUE, selectedChildGS.getOtherCaregiverRepresentative()); + break; default: break; } From b61a067a46c32212eaa423b7cca4d3b63006f727 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 15:20:19 +0300 Subject: [PATCH 15/19] validate other companion form field --- ...ectChildForGroupSessionDialogFragment.java | 36 ++++++++++++------- .../layout/dialog_fragment_childselection.xml | 9 +++++ opensrp-chw/src/kk/res/values-sw/strings.xml | 2 +- opensrp-chw/src/kk/res/values/strings.xml | 2 +- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index c47fa3ee3..9dad01293 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -1,6 +1,5 @@ package org.smartregister.chw.fragment; -import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; @@ -55,6 +54,8 @@ public class SelectChildForGroupSessionDialogFragment extends DialogFragment { private EditText cg_rep_lv_other; + private EditText who_came_with_the_child_lv_other; + SelectChildForGroupSessionRegisterFragment.DialogDismissListener dialogDismissListener; String[] groupItems; @@ -93,6 +94,9 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { cg_rep_lv_other = view.findViewById(R.id.cg_rep_lv_other); cg_rep_lv_other.setVisibility(View.GONE); + who_came_with_the_child_lv_other = view.findViewById(R.id.who_came_with_the_child_lv_other); + who_came_with_the_child_lv_other.setVisibility(View.GONE); + if (childrenDividedIntoGroups) { selected_group_lv.setVisibility(View.VISIBLE); selected_group.setVisibility(View.VISIBLE); @@ -131,11 +135,12 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { who_came_with_the_child_lv_adapter.setOnItemSelectedListener(position -> { selectedPosition3 = position; who_came_with_the_child_lv_adapter.setSelectedPosition(position); + checkForOtherItemSelected(isOtherItemSelected(who_came_with_the_child_lv_adapter.getSelectedItems()), who_came_with_the_child_lv_other); }); cg_rep_lv_adapter.setOnItemSelectedListener(position -> { cg_rep_lv_adapter.setSelectedPosition(position); - checkForOtherSelectedItem(); + checkForOtherItemSelected(isOtherItemSelected(cg_rep_lv_adapter.getSelectedItems()), cg_rep_lv_other); }); selected_group_lv_adapter.setOnItemSelectedListener(position -> { @@ -166,9 +171,12 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { } void handleSuccess(DialogInterface dialogInterface){ + String otherCompanion = who_came_with_the_child_lv_other.getText().toString(); if(selectedPosition1 == 0){ if(who_came_with_the_child_lv_adapter.getSelectedItems().isEmpty()){ dialogValidationFail(dialogInterface,"The companions of caregiver missing"); + }else if(isOtherItemSelected(who_came_with_the_child_lv_adapter.getSelectedItems()) && otherCompanion.isEmpty()){ + dialogValidationFail(dialogInterface,"Other companion missing"); }else{ dialogListener.onSelectComeWithPrimaryCareGiver( true, @@ -182,8 +190,10 @@ void handleSuccess(DialogInterface dialogInterface){ String otherCaregiverRepresentative = cg_rep_lv_other.getText().toString(); if(cg_rep_lv_adapter.getSelectedItems().isEmpty()){ dialogValidationFail(dialogInterface,"Caregiver representatives missing"); - }else if(isOtherItemSelected() && otherCaregiverRepresentative.isEmpty()){ + }else if(isOtherItemSelected(cg_rep_lv_adapter.getSelectedItems()) && otherCaregiverRepresentative.isEmpty()){ dialogValidationFail(dialogInterface,"Other caregiver representative missing"); + }else if(isOtherItemSelected(who_came_with_the_child_lv_adapter.getSelectedItems()) && otherCompanion.isEmpty()){ + dialogValidationFail(dialogInterface,"Other companion missing"); }else{ dialogListener.onSelectComeWithoutPrimaryCareGiver( false, @@ -231,7 +241,7 @@ private void modifyChildCameWith(boolean hide) { tv_caregiver_representative.setVisibility(View.VISIBLE); lv_caregiver_representative.setVisibility(View.VISIBLE); who_came_with_child_tv.setText(R.string.who_came_with_the_child_no); - checkForOtherSelectedItem(); + checkForOtherItemSelected(isOtherItemSelected(cg_rep_lv_adapter.getSelectedItems()), cg_rep_lv_other); } } @@ -258,8 +268,8 @@ private ArrayList setMultiSelectListItems(ArrayList list) { + for (MultiSelectListItemModel item : list) { if (item.getName().equals(getString(R.string.cg_rep_lv_other)) && item.isSelected()) { return true; } @@ -267,13 +277,13 @@ public boolean isOtherItemSelected() { return false; } - private void checkForOtherSelectedItem(){ - if(isOtherItemSelected()){ - cg_rep_lv_other.setVisibility(View.VISIBLE); - }else{ - cg_rep_lv_other.setVisibility(View.GONE); - cg_rep_lv_other.getText().clear(); - } + private void checkForOtherItemSelected(boolean isOtherItemSelected, EditText editText){ + if(isOtherItemSelected){ + editText.setVisibility(View.VISIBLE); + }else{ + editText.setVisibility(View.GONE); + editText.getText().clear(); + } } } diff --git a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml index 6e4b1b101..d9df29b72 100644 --- a/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml +++ b/opensrp-chw/src/kk/res/layout/dialog_fragment_childselection.xml @@ -152,6 +152,15 @@ + + Muda wa kipingi kwenye saa na dakika Mwingine Mlezi mwingine - + Mtu mwingine \ No newline at end of file diff --git a/opensrp-chw/src/kk/res/values/strings.xml b/opensrp-chw/src/kk/res/values/strings.xml index 68907b259..dbb4e3eb0 100644 --- a/opensrp-chw/src/kk/res/values/strings.xml +++ b/opensrp-chw/src/kk/res/values/strings.xml @@ -226,5 +226,5 @@ Session Duration in Hours and Minutes Other Other caregiver - + Other companion \ No newline at end of file From 020bd93953c6c38c807683b97c81ec983a207a42 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 15:51:54 +0300 Subject: [PATCH 16/19] capture other companion to the child event --- .../kk/assets/json.form/group_session_child_form.json | 7 +++++++ .../SelectChildForGroupSessionDialogFragment.java | 4 ++++ .../SelectChildForGroupSessionRegisterFragment.java | 6 ++++-- .../org/smartregister/chw/model/SelectedChildGS.java | 10 ++++++++++ .../SelectChildForGroupSessionFragmentProvider.java | 3 ++- .../java/org/smartregister/chw/util/KkConstants.java | 1 + .../chw/interactor/GroupSessionInteractor.java | 3 +++ 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json b/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json index 47efd0578..047372761 100644 --- a/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json +++ b/opensrp-chw/src/kk/assets/json.form/group_session_child_form.json @@ -84,6 +84,13 @@ "openmrs_entity_id": "other_people_present", "type": "hidden" }, + { + "key": "other_people_present_other", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "other_people_present_other", + "type": "hidden" + }, { "key": "care_giver_representatives", "openmrs_entity_parent": "", diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 9dad01293..7852b800c 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -182,6 +182,7 @@ void handleSuccess(DialogInterface dialogInterface){ true, selectedChildBaseEntityId, who_came_with_the_child_lv_adapter.getSelectedItems(), + otherCompanion.isEmpty() ? null : otherCompanion, !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2] ); dialogValidationSuccess(dialogInterface); @@ -201,6 +202,7 @@ void handleSuccess(DialogInterface dialogInterface){ cg_rep_lv_adapter.getSelectedItems(), otherCaregiverRepresentative.isEmpty() ? null : otherCaregiverRepresentative, who_came_with_the_child_lv_adapter.getSelectedItems(), + otherCompanion.isEmpty() ? null : otherCompanion, !childrenDividedIntoGroups ? "Not in groups" : groupItems[selectedPosition2]); dialogValidationSuccess(dialogInterface); } @@ -250,6 +252,7 @@ void onSelectComeWithPrimaryCareGiver( boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedAccompanyingCaregivers, + String otherCompanion, String selectedGroup); void onSelectComeWithoutPrimaryCareGiver( @@ -258,6 +261,7 @@ void onSelectComeWithoutPrimaryCareGiver( List selectedCaregiverRepresentatives, String otherCaregiverRepresentative, List selectedAccompanyingCaregiverRepresentatives, + String otherCompanion, String selectedGroup); } diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java index 6b45fd35e..7f373d22a 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionRegisterFragment.java @@ -106,23 +106,25 @@ private String getClientCareGiverName(CommonPersonObjectClient client) { @Override - public void onSelectComeWithPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedAccompanyingCaregivers, String groupPlaced) { + public void onSelectComeWithPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedAccompanyingCaregivers, String otherCompanion, String groupPlaced) { Timber.d("The Child with id %s Come with Primary Care Giver: %s", selectedChildBaseEntityId, isComeWithPrimaryCareGiver); List listOfAccompanyingRelatives = getTranslatedNames(selectedAccompanyingCaregivers); childRegisterProvider.updateChildSelectionStatus(selectedChildBaseEntityId, isComeWithPrimaryCareGiver, listOfAccompanyingRelatives, + otherCompanion, GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced), null,null); } @Override - public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, String otherCaregiverRepresentative, List selectedAccompanyingCaregiverRepresentatives, String groupPlaced) { + public void onSelectComeWithoutPrimaryCareGiver(boolean isComeWithPrimaryCareGiver, String selectedChildBaseEntityId, List selectedCaregiverRepresentatives, String otherCaregiverRepresentative, List selectedAccompanyingCaregiverRepresentatives, String otherCompanion, String groupPlaced) { List listOfAccompanyingRelatives = getTranslatedNames(selectedAccompanyingCaregiverRepresentatives);; List listOfCaregiverRepresentatives = getTranslatedNames(selectedCaregiverRepresentatives); childRegisterProvider.updateChildSelectionStatus(selectedChildBaseEntityId, isComeWithPrimaryCareGiver, listOfAccompanyingRelatives, + otherCompanion, GroupSessionTranslationsUtils.getTranslatedGroupPlaced(groupPlaced), listOfCaregiverRepresentatives, otherCaregiverRepresentative); diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java index 68bdd8238..8a99b3adb 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/model/SelectedChildGS.java @@ -18,6 +18,8 @@ public class SelectedChildGS { private String otherCaregiverRepresentative; + private String otherCompanion; + public SelectedChildGS(String childBaseEntityId, ChildStatus childSelectionStatus, boolean cameWithPrimaryCareGiver, String groupPlaced) { this.childBaseEntityId = childBaseEntityId; this.childSelectionStatus = childSelectionStatus; @@ -81,6 +83,14 @@ public void setOtherCaregiverRepresentative(String otherCaregiverRepresentative) this.otherCaregiverRepresentative = otherCaregiverRepresentative; } + public String getOtherCompanion() { + return otherCompanion; + } + + public void setOtherCompanion(String otherCompanion) { + this.otherCompanion = otherCompanion; + } + public enum ChildStatus { SELECTED, UNSELECTED diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java index 53f4b90f8..9dd580687 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/provider/SelectChildForGroupSessionFragmentProvider.java @@ -71,11 +71,12 @@ public HashMap getSelectedChildList() { return childList; } - public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCareGiver, List accompanyingRelatives, String groupPlaced, List selectedCaregiverRepresentatives, String otherCaregiverRepresentative) { + public void updateChildSelectionStatus(String baseEntityId, boolean cameWithCareGiver, List accompanyingRelatives, String otherCompanion, String groupPlaced, List selectedCaregiverRepresentatives, String otherCaregiverRepresentative) { if (childList.containsKey(baseEntityId)) { Objects.requireNonNull(childList.get(baseEntityId)).setCameWithPrimaryCareGiver(cameWithCareGiver); Objects.requireNonNull(childList.get(baseEntityId)).setGroupPlaced(groupPlaced); Objects.requireNonNull(childList.get(baseEntityId)).setAccompanyingRelatives(accompanyingRelatives); + Objects.requireNonNull(childList.get(baseEntityId)).setOtherCompanion(otherCompanion); Objects.requireNonNull(childList.get(baseEntityId)).setCareGiverRepresentatives(selectedCaregiverRepresentatives); Objects.requireNonNull(childList.get(baseEntityId)).setOtherCaregiverRepresentative(otherCaregiverRepresentative); } diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java b/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java index 08c2e2e21..ef028da7c 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/util/KkConstants.java @@ -176,6 +176,7 @@ public static class GCJsonKeys { public static final String GC_ALL_CAREGIVERS_PRESENT = "all_caregivers_present"; public static final String GC_CHILD_GROUP_PLACED = "child_group_placed"; public static final String GC_CHILD_CAME_WITH_OTHER_PEOPLE = "other_people_present"; + public static final String GC_CHILD_CAME_WITH_OTHER_PEOPLE_OTHER = "other_people_present_other"; public static final String GC_CAREGIVER_REPRESENTATIVES = "care_giver_representatives"; public static final String GC_CAREGIVER_REPRESENTATIVES_OTHER = "care_giver_representatives_other"; } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java index dfc903d67..0bc300627 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/GroupSessionInteractor.java @@ -310,6 +310,9 @@ private void processChildPopulatableFields(JSONObject field, GroupSessionModel s case KkConstants.GCJsonKeys.GC_CAREGIVER_REPRESENTATIVES_OTHER: field.put(org.smartregister.chw.util.JsonFormUtils.VALUE, selectedChildGS.getOtherCaregiverRepresentative()); break; + case KkConstants.GCJsonKeys.GC_CHILD_CAME_WITH_OTHER_PEOPLE_OTHER: + field.put(org.smartregister.chw.util.JsonFormUtils.VALUE, selectedChildGS.getOtherCompanion()); + break; default: break; } From 5f6b22c045fb0781b5c9cef89488689e2853b296 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 16:37:09 +0300 Subject: [PATCH 17/19] translate the error messages --- .../SelectChildForGroupSessionDialogFragment.java | 10 +++++----- opensrp-chw/src/kk/res/values-sw/strings.xml | 4 ++++ opensrp-chw/src/kk/res/values/strings.xml | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 7852b800c..9d1462b5f 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -174,9 +174,9 @@ void handleSuccess(DialogInterface dialogInterface){ String otherCompanion = who_came_with_the_child_lv_other.getText().toString(); if(selectedPosition1 == 0){ if(who_came_with_the_child_lv_adapter.getSelectedItems().isEmpty()){ - dialogValidationFail(dialogInterface,"The companions of caregiver missing"); + dialogValidationFail(dialogInterface, getString(R.string.who_came_with_the_child_lv_error)); }else if(isOtherItemSelected(who_came_with_the_child_lv_adapter.getSelectedItems()) && otherCompanion.isEmpty()){ - dialogValidationFail(dialogInterface,"Other companion missing"); + dialogValidationFail(dialogInterface, getString(R.string.who_came_with_the_child_lv_other_error)); }else{ dialogListener.onSelectComeWithPrimaryCareGiver( true, @@ -190,11 +190,11 @@ void handleSuccess(DialogInterface dialogInterface){ }else if(selectedPosition1 == 1){ String otherCaregiverRepresentative = cg_rep_lv_other.getText().toString(); if(cg_rep_lv_adapter.getSelectedItems().isEmpty()){ - dialogValidationFail(dialogInterface,"Caregiver representatives missing"); + dialogValidationFail(dialogInterface, getString(R.string.cg_rep_lv_error)); }else if(isOtherItemSelected(cg_rep_lv_adapter.getSelectedItems()) && otherCaregiverRepresentative.isEmpty()){ - dialogValidationFail(dialogInterface,"Other caregiver representative missing"); + dialogValidationFail(dialogInterface,getString(R.string.cg_rep_lv_other_error)); }else if(isOtherItemSelected(who_came_with_the_child_lv_adapter.getSelectedItems()) && otherCompanion.isEmpty()){ - dialogValidationFail(dialogInterface,"Other companion missing"); + dialogValidationFail(dialogInterface, getString(R.string.who_came_with_the_child_lv_other_error)); }else{ dialogListener.onSelectComeWithoutPrimaryCareGiver( false, diff --git a/opensrp-chw/src/kk/res/values-sw/strings.xml b/opensrp-chw/src/kk/res/values-sw/strings.xml index 4c3b81e0c..794943ae3 100644 --- a/opensrp-chw/src/kk/res/values-sw/strings.xml +++ b/opensrp-chw/src/kk/res/values-sw/strings.xml @@ -208,4 +208,8 @@ Mwingine Mlezi mwingine Mtu mwingine + Tafadhari chagua mtu ambae alikuja kwa niaba ya mlezi wa mtoto + Tafadhari jaza mtu mwingine ambae alikuja kwa niaba ya mlezi wa mtoto + Tafadhari chagua walezi/watu wengine waliohudhuria + Tafadhari jaza mlezi/mtu mwingine aliyehudhuria \ No newline at end of file diff --git a/opensrp-chw/src/kk/res/values/strings.xml b/opensrp-chw/src/kk/res/values/strings.xml index dbb4e3eb0..ba08c1e64 100644 --- a/opensrp-chw/src/kk/res/values/strings.xml +++ b/opensrp-chw/src/kk/res/values/strings.xml @@ -227,4 +227,8 @@ Other Other caregiver Other companion + Caregiver representatives missing + Other caregiver representative missing + The companions of caregiver missing + Other companion of caregiver missing \ No newline at end of file From 297060403c00bc0e45b895b3dd637b36bf584530 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Tue, 17 Oct 2023 16:48:12 +0300 Subject: [PATCH 18/19] restore the encryption parameter --- .../org/smartregister/chw/application/ChwSyncConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java index ce2cb9125..510adb4f8 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java @@ -59,7 +59,7 @@ public boolean isSyncSettings() { @Override public SyncFilter getEncryptionParam() { - return SyncFilter.TEAM_ID; + return isProductionEnvironment() ? SyncFilter.PROVIDER : SyncFilter.LOCATION; } From e152b50cd5738538187047b8c142061403c3baf4 Mon Sep 17 00:00:00 2001 From: maulidkategile Date: Thu, 19 Oct 2023 13:28:15 +0300 Subject: [PATCH 19/19] make a dialog not dismissable if form errors available for improved ux --- ...ectChildForGroupSessionDialogFragment.java | 36 +++++++++++-------- opensrp-chw/src/kk/res/values-sw/strings.xml | 2 ++ opensrp-chw/src/kk/res/values/strings.xml | 2 ++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java index 9d1462b5f..59636e793 100644 --- a/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java +++ b/opensrp-chw/src/kk/java/org/smartregister/chw/fragment/SelectChildForGroupSessionDialogFragment.java @@ -148,19 +148,7 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { selected_group_lv_adapter.setSelectedPosition(position); }); - builder.setPositiveButton(R.string.ok, (dialog, which) -> { - if (selectedPosition1 == -1) { - Toast.makeText(requireContext(), "Caregiver information missing", Toast.LENGTH_SHORT).show(); - dialogDismissListener.onFailure(); - dialog.dismiss(); - }else if (selectedPosition2 == -1 && childrenDividedIntoGroups) { - Toast.makeText(requireContext(), "Child missing the group", Toast.LENGTH_SHORT).show(); - dialogDismissListener.onFailure(); - dialog.dismiss(); - }else { - handleSuccess(dialog); - } - }); + builder.setPositiveButton(R.string.ok, null); builder.setNegativeButton(R.string.cancel, (dialog, which) -> { dialogDismissListener.onFailure(); @@ -170,6 +158,27 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { return builder.create(); } + @Override + public void onResume() { + AlertDialog dialog = (AlertDialog) getDialog(); + assert dialog != null; + dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() + { + @Override + public void onClick(View v) + { + if (selectedPosition1 == -1) { + dialogValidationFail(dialog, getString(R.string.came_with_pc_lv)); + }else if (selectedPosition2 == -1 && childrenDividedIntoGroups) { + dialogValidationFail(dialog, getString(R.string.selected_group_lv)); + }else { + handleSuccess(dialog); + } + } + }); + super.onResume(); + } + void handleSuccess(DialogInterface dialogInterface){ String otherCompanion = who_came_with_the_child_lv_other.getText().toString(); if(selectedPosition1 == 0){ @@ -212,7 +221,6 @@ void handleSuccess(DialogInterface dialogInterface){ void dialogValidationFail(DialogInterface dialogInterface,String message){ Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show(); dialogDismissListener.onFailure(); - dialogInterface.dismiss(); } void dialogValidationSuccess(DialogInterface dialogInterface){ diff --git a/opensrp-chw/src/kk/res/values-sw/strings.xml b/opensrp-chw/src/kk/res/values-sw/strings.xml index 794943ae3..e27fcaeb2 100644 --- a/opensrp-chw/src/kk/res/values-sw/strings.xml +++ b/opensrp-chw/src/kk/res/values-sw/strings.xml @@ -212,4 +212,6 @@ Tafadhari jaza mtu mwingine ambae alikuja kwa niaba ya mlezi wa mtoto Tafadhari chagua walezi/watu wengine waliohudhuria Tafadhari jaza mlezi/mtu mwingine aliyehudhuria + Tafadhari bainisha kama mtoto amekuja na mlezi wake + Tafadhari chagua kundi la mototo \ No newline at end of file diff --git a/opensrp-chw/src/kk/res/values/strings.xml b/opensrp-chw/src/kk/res/values/strings.xml index ba08c1e64..f928c8263 100644 --- a/opensrp-chw/src/kk/res/values/strings.xml +++ b/opensrp-chw/src/kk/res/values/strings.xml @@ -231,4 +231,6 @@ Other caregiver representative missing The companions of caregiver missing Other companion of caregiver missing + Caregiver information missing + Child missing the group \ No newline at end of file