-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1377 from OpenSRP/lmh_child_visits
Adds lmh-home-visit rule file
- Loading branch information
Showing
9 changed files
with
226 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
package org.smartregister.chw.custom_view; | ||
|
||
public class NavigationMenuFlv extends DefaultNavigationMenuFlv { | ||
@Override | ||
public boolean hasCommunityResponders() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String childNavigationMenuCountString() { | ||
return "Select count(*)\n" + | ||
" FROM ec_child\n" + | ||
" LEFT JOIN ec_family ON ec_child.relational_id = ec_family.id COLLATE NOCASE \n" + | ||
" LEFT JOIN ec_family_member ON ec_family_member.base_entity_id = ec_family.primary_caregiver COLLATE NOCASE \n" + | ||
" LEFT JOIN (select base_entity_id , max(visit_date) visit_date from visits GROUP by base_entity_id) VISIT_SUMMARY ON VISIT_SUMMARY.base_entity_id = ec_child.base_entity_id \n" + | ||
" WHERE ec_child.date_removed is null\n" + | ||
" AND (( ifnull(ec_child.entry_point,'') <> 'PNC' ) or (ifnull(ec_child.entry_point,'') = 'PNC' and ( date(ec_child.dob, '+28 days') <= date() \n" + | ||
" and ((SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 0))) \n" + | ||
" or (ifnull(ec_child.entry_point,'') = 'PNC' \n" + | ||
" and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 1)) \n" + | ||
" and CASE WHEN ec_child.gender = 'Male' \n" + | ||
" THEN (\n" + | ||
" ((( julianday('now') - julianday(ec_child.dob))/365.25) < +1.8) OR ( (((( julianday('now') - julianday(ec_child.dob))/365.25) >= +1.8) AND ((( julianday('now') - julianday(ec_child.dob))/365.25) <= +2)) AND\n" + | ||
" ((SELECT count(*) FROM alerts WHERE alerts.caseID = ec_child.base_entity_id and alerts.status in ('normal','urgent', 'upcoming')) > 0))\n" + | ||
" )\n" + | ||
" WHEN ec_child.gender = 'Female' \n" + | ||
" THEN (\n" + | ||
" ((( julianday('now') - julianday(ec_child.dob))/365.25) < +1.8) OR ( (((( julianday('now') - julianday(ec_child.dob))/365.25) >= +1.8) AND ((( julianday('now') - julianday(ec_child.dob))/365.25) <= +2)) AND\n" + | ||
" ((SELECT count(*) FROM alerts WHERE alerts.caseID = ec_child.base_entity_id and alerts.status in ('normal','urgent', 'upcoming')) > 0)) OR (((julianday('now') - julianday(ec_child.dob))/365.25) BETWEEN 9 AND 11)\n" + | ||
" ) END"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
opensrp-chw/src/test/java/org/smartregister/chw/fragment/FpRegisterFragmentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
package org.smartregister.chw.fragment; | ||
|
||
import android.text.TextWatcher; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
import android.widget.ImageView; | ||
import android.widget.ProgressBar; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.fragment.app.FragmentActivity; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.junit.MockitoJUnit; | ||
import org.mockito.junit.MockitoRule; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.android.controller.ActivityController; | ||
import org.robolectric.util.ReflectionHelpers; | ||
import org.smartregister.Context; | ||
import org.smartregister.CoreLibrary; | ||
import org.smartregister.chw.BaseUnitTest; | ||
import org.smartregister.chw.fp.contract.BaseFpRegisterFragmentContract; | ||
import org.smartregister.commonregistry.CommonPersonObjectClient; | ||
import org.smartregister.commonregistry.CommonRepository; | ||
import org.smartregister.receiver.SyncStatusBroadcastReceiver; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class FpRegisterFragmentTest extends BaseUnitTest { | ||
@Rule | ||
public MockitoRule rule = MockitoJUnit.rule(); | ||
@Mock | ||
private Context context; | ||
@Mock | ||
private FpRegisterFragment fpRegisterFragment; | ||
|
||
@Mock | ||
private CommonRepository commonRepository; | ||
|
||
@Mock | ||
private View view; | ||
|
||
private FragmentActivity activity; | ||
private ActivityController<AppCompatActivity> activityController; | ||
|
||
@Mock | ||
private ImageView imageView; | ||
|
||
@Mock | ||
private ProgressBar clientsProgressView; | ||
|
||
@Mock | ||
private TextView textView; | ||
|
||
@Mock | ||
private RelativeLayout relativeLayout; | ||
|
||
@Mock | ||
private EditText editText; | ||
|
||
@Mock | ||
private TextWatcher textWatcher; | ||
|
||
@Mock | ||
private View.OnKeyListener hideKeyboard; | ||
|
||
@Mock | ||
private ProgressBar syncProgressBar; | ||
|
||
@Mock | ||
private BaseFpRegisterFragmentContract.Presenter presenter; | ||
|
||
@Mock | ||
private CommonPersonObjectClient commonPersonObjectClient; | ||
|
||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
fpRegisterFragment = Mockito.mock(FpRegisterFragment.class, Mockito.CALLS_REAL_METHODS); | ||
ReflectionHelpers.setField(fpRegisterFragment, "presenter", presenter); | ||
ReflectionHelpers.setField(fpRegisterFragment, "view", view); | ||
ReflectionHelpers.setField(fpRegisterFragment, "dueOnlyLayout", view); | ||
ReflectionHelpers.setField(fpRegisterFragment, "clientsProgressView", clientsProgressView); | ||
ReflectionHelpers.setField(fpRegisterFragment, "dueFilterActive", true); | ||
ReflectionHelpers.setField(fpRegisterFragment, "qrCodeScanImageView", imageView); | ||
ReflectionHelpers.setField(fpRegisterFragment, "headerTextDisplay", textView); | ||
ReflectionHelpers.setField(fpRegisterFragment, "filterStatus", textView); | ||
ReflectionHelpers.setField(fpRegisterFragment, "filterRelativeLayout", relativeLayout); | ||
ReflectionHelpers.setField(fpRegisterFragment, "searchView", editText); | ||
ReflectionHelpers.setField(fpRegisterFragment, "textWatcher", textWatcher); | ||
ReflectionHelpers.setField(fpRegisterFragment, "hideKeyboard", hideKeyboard); | ||
ReflectionHelpers.setField(fpRegisterFragment, "syncProgressBar", syncProgressBar); | ||
ReflectionHelpers.setField(fpRegisterFragment, "syncButton", imageView); | ||
ReflectionHelpers.setField(fpRegisterFragment, "globalQrSearch", false); | ||
|
||
CoreLibrary.init(context); | ||
when(context.commonrepository(anyString())).thenReturn(commonRepository); | ||
activityController = Robolectric.buildActivity(AppCompatActivity.class).create().resume(); | ||
activity = activityController.get(); | ||
Context.bindtypes = new ArrayList<>(); | ||
SyncStatusBroadcastReceiver.init(activity); | ||
} | ||
|
||
@Test | ||
public void testSetupViews() { | ||
when(fpRegisterFragment.getActivity()).thenReturn(activity); | ||
when(fpRegisterFragment.getContext()).thenReturn(activity); | ||
View view = LayoutInflater.from(activity).inflate(org.smartregister.chw.core.R.layout.fragment_base_register, null); | ||
fpRegisterFragment.setupViews(view); | ||
|
||
View dueOnlyLayout = view.findViewById(org.smartregister.chw.core.R.id.due_only_layout); | ||
dueOnlyLayout.setVisibility(View.VISIBLE); | ||
View searchBarLayout = view.findViewById(org.smartregister.R.id.search_bar_layout); | ||
searchBarLayout.setBackgroundResource(org.smartregister.chw.core.R.color.customAppThemeBlue); | ||
assertEquals(View.VISIBLE, dueOnlyLayout.getVisibility()); | ||
} | ||
|
||
@Test | ||
public void testInitializePresenterActivityIsNull() { | ||
fpRegisterFragment.initializePresenter(); | ||
TestCase.assertNotNull(fpRegisterFragment.presenter()); | ||
} | ||
|
||
@Test | ||
public void testInitializePresenter() { | ||
Mockito.doReturn(activity).when(fpRegisterFragment).getActivity(); | ||
|
||
fpRegisterFragment.initializePresenter(); | ||
TestCase.assertNotNull(fpRegisterFragment.presenter()); | ||
} | ||
|
||
@Test | ||
public void testOpenProfile() { | ||
when(fpRegisterFragment.getActivity()).thenReturn(activity); | ||
fpRegisterFragment.openProfile(commonPersonObjectClient); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
try { | ||
activityController.pause().stop().destroy(); | ||
activity.finish(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |