Skip to content

Commit

Permalink
Merge pull request #100 from OpenSRP/show-all-details
Browse files Browse the repository at this point in the history
Include empty labels in registration data
  • Loading branch information
hamza-vd authored Mar 24, 2021
2 parents 7c53661 + 5cff23c commit 3b1a443
Show file tree
Hide file tree
Showing 45 changed files with 505 additions and 365 deletions.
20 changes: 11 additions & 9 deletions opensrp-path-zeir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ android {
applicationId "org.smartregister.pathzeir"
minSdkVersion androidMinSdkVersion
targetSdkVersion androidTargetSdkVersion
versionCode 7
versionName "0.0.7"
multiDexEnabled true
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "false"
Expand Down Expand Up @@ -94,6 +92,8 @@ android {
buildTypes {

release {
defaultConfig.versionCode 1
defaultConfig.versionName "0.0.1"
minifyEnabled false
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro'
Expand Down Expand Up @@ -122,7 +122,8 @@ android {
}

debug {

defaultConfig.versionCode 8
defaultConfig.versionName "0.0.8"
versionNameSuffix "-debug"
resValue "string", 'opensrp_url', '"https://path-zeir-stage.smartregister.org/opensrp/"'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250'
Expand All @@ -149,12 +150,13 @@ android {
}

preview {
defaultConfig.versionCode 8
defaultConfig.versionName "0.0.8"
minifyEnabled false
zipAlignEnabled true
debuggable true
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro'

versionNameSuffix "-preview"
resValue "string", 'opensrp_url', '"https://path-zeir-preview.smartregister.org/opensrp/"'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10'
Expand All @@ -171,8 +173,8 @@ android {
buildConfigField "int", "VIEW_SYNC_CONFIGURATIONS_MINUTES", '15'
buildConfigField "int", "CLIENT_SETTINGS_SYNC_MINUTES", '15'
buildConfigField "int", "GROWTH_MONITORING_SYNC_TIME", '15'
buildConfigField "String[]", "LOCATION_LEVELS", '{"National", "Province", "District", "Health Facility"}'
buildConfigField "String[]", "HEALTH_FACILITY_LEVELS", '{"National", "Province", "District", "Health Facility"}'
buildConfigField "String[]", "LOCATION_LEVELS", '{"National", "Province", "District", "Health Facility", "Zone"}'
buildConfigField "String[]", "HEALTH_FACILITY_LEVELS", '{"National", "Province", "District", "Health Facility", "Zone"}'
buildConfigField "String[]", "ALLOWED_LEVELS", '{"Health Facility", "Zone"}'
buildConfigField "String", 'DEFAULT_LOCATION', '"Health Facility"'
buildConfigField "String", "OAUTH_CLIENT_ID", getLocalProperty("oauth.client.id.preview")
Expand Down Expand Up @@ -239,7 +241,7 @@ dependencies {
implementation "androidx.cardview:cardview:1.0.0"

// implementation(project(':opensrp-child')) {
implementation('org.smartregister:opensrp-client-child:0.6.10-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-child:0.6.12-ALPHA1-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'org.smartregister', module: 'opensrp-client-growth-monitoring'
Expand All @@ -260,7 +262,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

implementation('org.smartregister:opensrp-client-core:4.2.5-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:4.2.14-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down Expand Up @@ -333,7 +335,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
implementation 'com.evernote:android-job:1.2.6'
implementation 'com.github.lecho:hellocharts-android:v1.5.8'
implementation 'id.zelory:compressor:2.1.0'
implementation 'id.zelory:compressor:2.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
Expand Down
3 changes: 2 additions & 1 deletion opensrp-path-zeir/src/main/assets/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ show.out.of.catchment.recurring.services=true
home.alert.style.legacy=true
home.split.fully.immunized.status=true
home.zeir.id.column.enabled=true
show.booster.immunizations=true
show.booster.immunizations=true
notifications.weight.enabled=true

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions opensrp-path-zeir/src/main/assets/ec_client_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@
"field": "addresses.address2"
}
},
{
"column_name": "birth_facility_name_other",
"type": "Client",
"json_mapping": {
"field": "attributes.birth_facility_name_other"
}
},
{
"column_name": "residential_area",
"type": "Client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"err": "{{child_enrollment.step1.first_name.v_regex.err}}"
},
"v_required": {
"value": "true",
"value": "false",
"err": "{{child_enrollment.step1.first_name.v_required.err}}"
}
},
Expand Down Expand Up @@ -395,6 +395,26 @@
}
}
},
{
"key": "birth_facility_name_other",
"openmrs_entity_parent": "",
"openmrs_entity": "person_attribute",
"openmrs_entity_id": "birth_facility_name_other",
"type": "edit_text",
"hint": "{{child_enrollment.step1.birth_facility_name_other.hint}}",
"edit_type": "name",
"v_required": {
"value": "true",
"err": "{{child_enrollment.step1.birth_facility_name_other.v_required.err}}"
},
"relevance": {
"rules-engine": {
"ex-rules": {
"rules-file": "child_register_registration_relevance_rules.yml"
}
}
}
},
{
"key": "residential_area",
"openmrs_entity_parent": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@ name: step1_birth_facility_name
description: birth_facility_name
priority: 1
condition: "step1_place_of_birth == 'health_facility'"
actions:
- "isRelevant = true"
---
name: step1_birth_facility_name_other
description: birth_facility_name_other
priority: 1
condition: "step1_birth_facility_name == 'other'"
actions:
- "isRelevant = true"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.smartregister.SyncFilter;
import org.smartregister.pathzeir.BuildConfig;
import org.smartregister.pathzeir.activity.LoginActivity;
import org.smartregister.repository.AllSharedPreferences;
import org.smartregister.view.activity.BaseLoginActivity;

import java.util.ArrayList;
Expand All @@ -24,9 +23,7 @@ public SyncFilter getSyncFilterParam() {

@Override
public String getSyncFilterValue() {
AllSharedPreferences sharedPreferences = ZeirApplication.getInstance().context().userService()
.getAllSharedPreferences();
return sharedPreferences.fetchDefaultLocalityId(sharedPreferences.fetchRegisteredANM());
return ZeirApplication.getInstance().getSyncLocations();
}

@Override
Expand Down Expand Up @@ -83,5 +80,6 @@ public String getOauthClientSecret() {
public Class<? extends BaseLoginActivity> getAuthenticationActivity() {
return LoginActivity.class;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public void onCreate() {

SyncStatusBroadcastReceiver.init(this);
LocationHelper.init(new ArrayList<>(Arrays.asList(BuildConfig.ALLOWED_LEVELS)), BuildConfig.DEFAULT_LOCATION);

jsonSpecHelper = new JsonSpecHelper(this);

//init Job Manager
Expand Down Expand Up @@ -511,5 +512,10 @@ public CumulativeIndicatorRepository cumulativeIndicatorRepository() {
return cumulativeIndicatorRepository;
}

public String getSyncLocations() {
if (LocationHelper.getInstance() != null && LocationHelper.getInstance().locationIdsFromHierarchy() != null)
return LocationHelper.getInstance().locationIdsFromHierarchy();
return "";
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@

public class AppChildDao extends ChildDao {

public static boolean isPrematureBaby(String baseEntityID) {
String sql = String.format("SELECT count(*) count\n" +
"FROM ec_child_details\n" +
"WHERE base_entity_id = '%s'\n" +
" AND pcv4_required is '1'", baseEntityID);

DataMap<Integer> dataMap = cursor -> getCursorIntValue(cursor, "count");

List<Integer> result = readData(sql, dataMap);
if (result == null || result.size() != 1)
return false;

return result.get(0) > 0;
}

public static List<String> getChildrenAboveFiveYears() {
String sql = "SELECT ec_client.base_entity_id\n" +
"FROM ec_child_details\n" +
Expand Down Expand Up @@ -71,4 +56,19 @@ public static boolean clientNeedsCard(String baseEntityId) {

return result.get(0) > 0;
}

public static int getDueVaccineCount(String vaccine) {
String sql = "SELECT count(*) count\n" +
"FROM alerts\n" +
"WHERE scheduleName = '$s' COLLATE NOCASE\n" +
" AND startDate LIKE '%' || strftime('%Y-%m', date('now', 'start of month', '+1 month')) || '%'".replace("$s", vaccine);

DataMap<Integer> dataMap = cursor -> getCursorIntValue(cursor, "count");

List<Integer> result = readData(sql, dataMap);
if (result == null || result.size() != 1)
return result.get(0);

return 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
package org.smartregister.pathzeir.fragment;

import android.os.Bundle;
import android.text.TextUtils;

import com.vijay.jsonwizard.constants.JsonFormConstants;

import org.apache.commons.lang3.StringUtils;
import org.smartregister.child.adapter.ChildRegistrationDataAdapter;
import org.smartregister.child.domain.Field;
import org.smartregister.child.domain.KeyValueItem;
import org.smartregister.child.fragment.BaseChildRegistrationDataFragment;
import org.smartregister.child.util.ChildDbUtils;
import org.smartregister.child.util.Utils;
import org.smartregister.pathzeir.R;
import org.smartregister.pathzeir.util.AppConstants;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
Expand Down Expand Up @@ -48,4 +59,62 @@ protected Map<String, String> getDataRowLabelResourceIds() {
};
return super.getDataRowLabelResourceIds();
}

@Override
public void resetAdapterData(Map<String, String> detailsMap) {
// Add Birth weight to the details
if (detailsMap.get(AppConstants.KeyConstants.BIRTH_WEIGHT.toLowerCase()) == null) {
String caseId = detailsMap.get(AppConstants.KeyConstants.BASE_ENTITY_ID);
Utils.putAll(detailsMap, ChildDbUtils.fetchChildFirstGrowthAndMonitoring(caseId));
String weight = detailsMap.get(AppConstants.KeyConstants.BIRTH_WEIGHT.toLowerCase());
if (weight != null && !TextUtils.isEmpty(weight)) {
detailsMap.put(AppConstants.KeyConstants.BIRTH_WEIGHT.toLowerCase(), Utils.kgStringSuffix(weight));
}
}
List<KeyValueItem> detailsList = new ArrayList<>();
String key;
String value;

for (int i = 0; i < getFields().size(); i++) {
Field field = getFields().get(i);
key = field.getKey();

//Some fields have alias name on query
if (fieldNameAliasMap.containsKey(key)) {
String keyAlias = fieldNameAliasMap.get(key);
value = getFieldValue(detailsMap, field, keyAlias);
} else {
value = getFieldValue(detailsMap, field, key);
}

//TODO Temporary fix for spinner setting value as hint when nothing is selected
if (JsonFormConstants.SPINNER.equalsIgnoreCase(field.getType()) && value != null && value.equalsIgnoreCase(field.getHint())) {
value = null;
}

String label = getResourceLabel(key);

if (!TextUtils.isEmpty(label)) {
detailsList.add(new KeyValueItem(label, cleanValue(field, value)));
}
}
setmAdapter(new ChildRegistrationDataAdapter(detailsList));
}

protected String getFieldValue(Map<String, String> detailsMap, Field field, String key) {
String value;
value = detailsMap.get(field.getKey().toLowerCase(Locale.getDefault()));
value = !StringUtils.isBlank(value) ? value : detailsMap.get(getPrefix(field.getEntityId()) + key.toLowerCase(Locale.getDefault()));
value = !StringUtils.isBlank(value) ? value : detailsMap.get(getPrefix(field.getEntityId()) + cleanOpenMRSEntityId(field.getOpenmrsEntityId().toLowerCase(Locale.getDefault())));
value = !StringUtils.isBlank(value) ? value : detailsMap.get(key.toLowerCase(Locale.getDefault()));
return value;
}

@Override
public String cleanValue(Field field, String raw) {
if (raw == null) {
return "";
}
return super.cleanValue(field, raw);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.smartregister.pathzeir.helper;

import java.util.Set;

import org.smartregister.CoreLibrary;
import org.smartregister.domain.PhysicalLocation;
import org.smartregister.repository.LocationRepository;
import org.smartregister.sync.helper.ValidateAssignmentHelper;
import org.smartregister.util.SyncUtils;

import java.util.Set;
import java.util.stream.Collectors;

public class AppValidateAssignmentHelper extends ValidateAssignmentHelper {
Expand All @@ -19,7 +18,7 @@ public AppValidateAssignmentHelper(SyncUtils syncUtils) {
/**
* Validate Health Facility Level only
*
* @return
* @return existing jurisdictions set
*/
@Override
protected Set<String> getExistingJurisdictions() {
Expand All @@ -29,8 +28,9 @@ protected Set<String> getExistingJurisdictions() {
.map(PhysicalLocation::getId).collect(Collectors.toSet());
}


@Override
public void validateUserAssignment() {
// Do Nothing
// Do nothing
}
}
Loading

0 comments on commit 3b1a443

Please sign in to comment.