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

Lmh Sprint 3 issue Fixes #1917

Open
wants to merge 13 commits into
base: lmh_issue_fixes_vts_2.0
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions opensrp-chw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ android {
applicationIdSuffix ".lmh"
versionCode 2
versionName "0.1.7"
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500'
buildConfigField "String", 'opensrp_url', '"https://lmh-liberia.smartregister.org/opensrp/"'
buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/lmh/"'
buildConfigField "String", 'opensrp_url_debug', '"https://lmh-stage.smartregister.org/opensrp/"'
Expand Down
15 changes: 11 additions & 4 deletions opensrp-chw/src/lmh/assets/json.form/child_enrollment.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,18 @@
"openmrs_entity_parent": "",
"openmrs_entity": "person",
"openmrs_entity_id": "gender",
"type": "spinner",
"type": "native_radio",
"label": "Sex",
"hint": "Sex",
"values": [
"Male",
"Female"
"options": [
{
"key": "Male",
"text": "Male"
},
{
"key": "Female",
"text": "Female"
}
],
"v_required": {
"value": "true",
Expand Down
15 changes: 11 additions & 4 deletions opensrp-chw/src/lmh/assets/json.form/family_member_register.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,18 @@
"openmrs_entity_parent": "",
"openmrs_entity": "person",
"openmrs_entity_id": "gender",
"type": "spinner",
"type": "native_radio",
"label": "Sex",
"hint": "Sex",
"values": [
"Male",
"Female"
"options": [
{
"key": "Male",
"text": "Male"
},
{
"key": "Female",
"text": "Female"
}
],
"v_required": {
"value": "true",
Expand Down
17 changes: 12 additions & 5 deletions opensrp-chw/src/lmh/assets/json.form/family_register.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,21 @@
"openmrs_entity_parent": "",
"openmrs_entity": "person",
"openmrs_entity_id": "gender",
"type": "spinner",
"type": "native_radio",
"label": "Sex",
"hint": "Sex",
"values": [
"Male",
"Female"
"options": [
{
"key": "Male",
"text": "Male"
},
{
"key": "Female",
"text": "Female"
}
],
"v_required": {
"value": "true",
"value": true,
"err": "Please enter the sex"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean showChildrenUnder5() {

@Override
public boolean launchChildClientsAtLogin() {
return true;
return false;
}

@Override
Expand Down Expand Up @@ -156,4 +156,19 @@ public boolean showChildrenAboveTwoDueStatus(){
public boolean showIconsForChildrenUnderTwoAndGirlsAgeNineToEleven(){
return true;
}

@Override
public boolean useAllChildrenTitle(){
return true;
}

@Override
public boolean showDueFilterToggle(){
return false;
}

@Override
public boolean hideCaregiverAndFamilyHeadWhenOnlyOneAdult(){
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import org.smartregister.chw.anc.domain.VisitDetail;
import org.smartregister.chw.anc.util.JsonFormUtils;
import org.smartregister.chw.anc.util.NCUtils;
import org.smartregister.immunization.domain.VaccineWrapper;
import org.smartregister.util.DatePickerUtils;

import java.util.List;
import java.util.Map;

public class BaseHomeVisitImmunizationFragmentFlv extends DefaultBaseHomeVisitImmunizationFragment {

private List<VaccineWrapper> vaccineWrappers;

public static BaseHomeVisitImmunizationFragmentFlv getInstance(final BaseAncHomeVisitContract.VisitView view, String baseEntityID, Map<String, List<VisitDetail>> details, List<VaccineDisplay> vaccineDisplays) {
return getInstance(view, baseEntityID, details, vaccineDisplays, true);
}
Expand Down Expand Up @@ -45,4 +48,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
DatePickerUtils.themeDatePicker(singleDatePicker, new char[]{'d', 'm', 'y'});
super.onViewCreated(view, savedInstanceState);
}

public void setVaccineWrappers(List<VaccineWrapper> vaccineWrappers) {
this.vaccineWrappers = vaccineWrappers;
}

public List<VaccineWrapper> getVaccineWrappers() {
return vaccineWrappers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public List<NavigationOption> getNavigationItems() {

if (navigationOptions.size() == 0) {
navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_families, R.mipmap.sidemenu_families_active, R.string.menu_all_families, Constants.DrawerMenu.ALL_FAMILIES, 0));
navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children_active, R.string.menu_child_clients, Constants.DrawerMenu.CHILD_CLIENTS, 0));
navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children_active, R.string.all_children_title, Constants.DrawerMenu.CHILD_CLIENTS, 0));
}

return navigationOptions;
Expand Down
2 changes: 2 additions & 0 deletions opensrp-chw/src/lmh/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@

<string name="remove_family_count">%s adults and %s U11 children</string>
<string name="any_changes_you_make">Are you sure you want to go back? All data you have entered in this form will be cleared.</string>
<string name="syncing_records">Syncing records...</string>
<string name="all_children_title">All Children</string>
</resources>
2 changes: 1 addition & 1 deletion opensrp-chw/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
android:theme="@style/ChwTheme.NoActionBar" />
<activity
android:name=".activity.PinLoginActivity"
android:theme="@style/ChwTheme.NoActionBar" />
android:theme="@style/ChwTheme.Login" />
<activity
android:name=".activity.AllClientsRegisterActivity"
android:theme="@style/ChwTheme.NoActionBar" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Context;

import androidx.core.util.Supplier;

import com.vijay.jsonwizard.constants.JsonFormConstants;

import org.joda.time.LocalDate;
Expand Down Expand Up @@ -37,18 +39,17 @@
public class ImmunizationActionHelper implements BaseAncHomeVisitAction.AncHomeVisitActionHelper {

private Context context;
private List<VaccineWrapper> wrappers;
private LocalDate dueDate;
private Supplier<List<VaccineWrapper>> vaccineSupplier;
private AlertStatus status;

private List<String> keys = new ArrayList<>();
private Map<String, List<String>> completedVaccines = new HashMap<>();
private List<String> notDoneVaccines = new ArrayList<>();
private Map<String, VaccineRepo.Vaccine> vaccineMap = new HashMap<>();

public ImmunizationActionHelper(Context context, List<VaccineWrapper> wrappers) {
public ImmunizationActionHelper(Context context, Supplier<List<VaccineWrapper>> vaccineSupplier) {
this.context = context;
this.wrappers = wrappers;
this.vaccineSupplier = vaccineSupplier;
List<String> serviceGroups = Arrays.asList(CoreConstants.SERVICE_GROUPS.CHILD, org.smartregister.chw.util.Constants.CHILD_OVER_5);
List<VaccineRepo.Vaccine> repo = new ArrayList<>();
for (String serviceGroup : serviceGroups) {
Expand All @@ -65,7 +66,7 @@ private void initialize() {
LocalDate dueDate = null;
AlertStatus myStatus = null;

for (VaccineWrapper vaccineWrapper : wrappers) {
for (VaccineWrapper vaccineWrapper : vaccineSupplier.get()) {
Alert alert = vaccineWrapper.getAlert();

if (myStatus == null || (alert != null && !alert.status().equals(AlertStatus.expired))) {
Expand All @@ -81,10 +82,29 @@ private void initialize() {
keys.add(NCUtils.removeSpaces(vaccineWrapper.getName()));
}

this.dueDate = new LocalDate(dueDate);
this.status = myStatus;
}

private LocalDate getDueDate(){
LocalDate dueDate = null;
AlertStatus myStatus = null;

for (VaccineWrapper vaccineWrapper : vaccineSupplier.get()) {
Alert alert = vaccineWrapper.getAlert();

if (myStatus == null || (alert != null && !alert.status().equals(AlertStatus.expired))) {
myStatus = alert.status();
} else if (alert != null && alert.status().equals(AlertStatus.urgent)) {
myStatus = alert.status();
}

if (dueDate == null) {
dueDate = new LocalDate(alert.startDate());
}
}
return dueDate == null ? LocalDate.now() : dueDate;
}

@Override
public void onJsonFormLoaded(String s, Context context, Map<String, List<VisitDetail>> map) {
this.context = context;
Expand Down Expand Up @@ -150,7 +170,7 @@ public String getPreProcessedSubTitle() {
due = context.getString(R.string.overdue);
}

return MessageFormat.format("{0} {1}", due, DateTimeFormat.forPattern("dd MMM yyyy").print(dueDate));
return MessageFormat.format("{0} {1}", due, DateTimeFormat.forPattern("dd MMM yyyy").print(getDueDate()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void onChanged(String s) {

List<VaccineWrapper> wrappers = VaccineScheduleUtil.recomputeSchedule(vaccineSchedules, anchorDate, vaccineGroup, allReceivedVaccines);
List<VaccineDisplay> displays = generateDisplaysFromWrappers(wrappers, anchorDate.toDate());
fragment.setVaccineWrappers(wrappers);

// update the vaccines
Map<String, VaccineDisplay> linkedHashMap = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import org.joda.time.DateTime;
import org.smartregister.chw.R;
import org.smartregister.chw.anc.activity.BaseAncMemberProfileActivity;
import org.smartregister.chw.anc.domain.MemberObject;
import org.smartregister.chw.application.ChwApplication;
Expand All @@ -25,6 +28,7 @@
import org.smartregister.chw.core.utils.CoreConstants;
import org.smartregister.chw.custom_view.ChwFamilyFloatingMenu;
import org.smartregister.chw.dao.ChwChildDao;
import org.smartregister.chw.dao.FamilyDao;
import org.smartregister.chw.fp.dao.FpDao;
import org.smartregister.chw.fragment.FamilyProfileActivityFragment;
import org.smartregister.chw.fragment.FamilyProfileDueFragment;
Expand Down Expand Up @@ -71,6 +75,27 @@ public void setupViews() {
);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
Integer noOfAdults = FamilyDao.countAdultsFamilyMembers(familyBaseEntityId);
MenuItem cannotChangeCaregiver = menu.findItem(R.id.action_not_able_to_change_caregiver);
MenuItem cannotChangeFamilyHead = menu.findItem(R.id.action_not_able_to_change_head);
MenuItem changeCaregiver = menu.findItem(R.id.action_change_care_giver);
MenuItem changeFamilyHead = menu.findItem(R.id.action_change_head);

if (ChwApplication.getApplicationFlavor().hideCaregiverAndFamilyHeadWhenOnlyOneAdult() && noOfAdults == 1) {
cannotChangeCaregiver.setVisible(true);
cannotChangeFamilyHead.setVisible(true);
}
if ((!ChwApplication.getApplicationFlavor().hideCaregiverAndFamilyHeadWhenOnlyOneAdult())
|| (ChwApplication.getApplicationFlavor().hideCaregiverAndFamilyHeadWhenOnlyOneAdult() && noOfAdults > 1)) {
changeCaregiver.setVisible(true);
changeFamilyHead.setVisible(true);
}
return true;
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand Down
Loading