Skip to content

Commit

Permalink
Merge pull request #156 from opensrp/reporting-issues
Browse files Browse the repository at this point in the history
Reporting issues
  • Loading branch information
hamza-vd authored Jun 28, 2021
2 parents 0955e4a + 182de78 commit 7191c57
Show file tree
Hide file tree
Showing 20 changed files with 195 additions and 138 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Decode google-services.json
env:
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
run: echo $FIREBASE_CONFIG > opensrp-path-zeir/google-services.json
- name: Run unit tests with Gradle
run: ./gradlew :opensrp-path-zeir:jacocoTestReport --stacktrace
- name: Generate Javadoc with Gradle
Expand Down
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ subprojects {
}
}

apply plugin: 'java'
apply plugin: 'build-dashboard'

buildDashboard {
reports.html.setDestination(file("build/"))
}

test.reports.html.enabled = false
test.reports.junitXml.enabled = false
}
1 change: 1 addition & 0 deletions opensrp-path-zeir/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
/release/
/preview/
google-services.json
45 changes: 30 additions & 15 deletions opensrp-path-zeir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ buildscript {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
Expand Down Expand Up @@ -74,18 +75,18 @@ android {
applicationVariants.all { variant ->
if (variant.name == "debug") {
variant.outputs.each { output ->
output.versionCodeOverride = 11
output.versionNameOverride = "0.0.11-debug"
output.versionCodeOverride = 15
output.versionNameOverride = "0.0.15-debug"
}
} else if (variant.name == "preview") {
variant.outputs.each { output ->
output.versionCodeOverride = 11
output.versionNameOverride = "0.0.11-preview"
output.versionCodeOverride = 15
output.versionNameOverride = "0.0.15-preview"
}
} else if (variant.name == "release") {
variant.outputs.each { output ->
output.versionCodeOverride = 16
output.versionNameOverride = "2.0.1-release"
output.versionCodeOverride = 17
output.versionNameOverride = "2.0.2-release"
}
}
}
Expand Down Expand Up @@ -123,7 +124,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '1'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand All @@ -148,7 +149,7 @@ android {
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand All @@ -173,11 +174,11 @@ android {
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rule.pro'
resValue "string", 'opensrp_url', '"https://path-zeir-preview.smartregister.org/opensrp/"'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '3'
buildConfigField "int", "VACCINE_SYNC_TIME", '0'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "DATABASE_VERSION", '16'
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "true"
buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15'
Expand Down Expand Up @@ -239,7 +240,7 @@ dependencies {
implementation fileTree(dir: "./build/libs", include: ['*.jar'])
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:27.1.0')
jarJar 'com.ibm.fhir:fhir-model:4.2.3'
jarJar 'com.ibm.fhir:fhir-model:4.7.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Expand Down Expand Up @@ -279,7 +280,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

implementation('org.smartregister:opensrp-client-core:4.3.3-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:4.3.7-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand All @@ -300,6 +301,7 @@ dependencies {
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'org.smartregister', module: 'opensrp-client-reporting'
exclude group: 'com.ibm.fhir', module: 'fhir-model'
}

implementation('org.smartregister:opensrp-client-reporting:0.0.22-SNAPSHOT@aar') {
Expand All @@ -310,19 +312,21 @@ dependencies {
exclude group: 'com.github.lecho', module: 'hellocharts-library'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.ibm.fhir', module: 'fhir-model'
}

implementation('org.smartregister:opensrp-client-stock:1.2.0-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-stock:1.2.4-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'com.android.support', module: 'design'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'org.smartregister', module: 'opensrp-client-reporting'
exclude group: 'com.ibm.fhir', module: 'fhir-model'
}

implementation('org.smartregister:opensrp-client-native-form:1.14.8.0-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-native-form:2.1.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand All @@ -332,6 +336,8 @@ dependencies {
exclude group: 'io.ona.rdt-capture', module: 'lib'
exclude group: 'com.google.android.gms', module: 'play-services-vision'
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.simprints', module: 'libsimprints'
exclude group: 'com.ibm.fhir', module: 'fhir-model'
}
implementation('com.google.android.material:material:1.2.1') {
exclude group: 'com.android.support', module: 'recyclerview-v7'
Expand Down Expand Up @@ -375,7 +381,7 @@ dependencies {
testImplementation "org.robolectric:shadows-supportv4:$robolectricVersion"
testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3'
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.0'
testImplementation 'com.ibm.fhir:fhir-model:4.2.3'
testImplementation 'com.ibm.fhir:fhir-model:4.7.0'
testImplementation 'junit:junit:4.13.1'
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.work:work-testing:2.5.0'
Expand Down Expand Up @@ -421,6 +427,15 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea
)
}

task javadoc(type: Javadoc) {
failOnError false
def mainSrc = "$project.projectDir/src/main/java"
def kotlinSrc = "$project.projectDir/src/main/kotlin"
source = files([mainSrc, kotlinSrc])
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}

coveralls {
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/merged.xml"
}
2 changes: 1 addition & 1 deletion opensrp-path-zeir/src/main/assets/stock_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
{
"quantity": "10",
"name": "M/MR",
"name": "MR",
"openmrs_parent_entity_id": "",
"openmrs_date_concept_id": "",
"openmrs_quantity_concept_id": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,13 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
String jsonString = data.getStringExtra(JsonFormConstants.JSON_FORM_KEY.JSON);
Timber.d(jsonString);
JSONObject form = new JSONObject(jsonString);
String encounterType = form.getString(ChildJsonFormUtils.ENCOUNTER_TYPE);
if (encounterType.equalsIgnoreCase(Constants.EventType.UPDATE_BITRH_REGISTRATION)) {
String jsonForm = AppUtils.validateChildZone(jsonString);
data.putExtra(JsonFormConstants.JSON_FORM_KEY.JSON, jsonForm);
if (jsonString != null) {
JSONObject form = new JSONObject(jsonString);
String encounterType = form.getString(ChildJsonFormUtils.ENCOUNTER_TYPE);
if (encounterType.equalsIgnoreCase(Constants.EventType.UPDATE_BITRH_REGISTRATION)) {
String jsonForm = AppUtils.validateChildZone(jsonString);
data.putExtra(JsonFormConstants.JSON_FORM_KEY.JSON, jsonForm);
}
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
package org.smartregister.path.fragment;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;

import com.rengwuxian.materialedittext.MaterialEditText;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.fragments.JsonFormFragment;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
import org.smartregister.child.fragment.ChildFormFragment;
import org.smartregister.child.presenter.ChildFormFragmentPresenter;
import org.smartregister.path.R;
import org.smartregister.path.activity.ChildFormActivity;
import org.smartregister.path.interactor.ChildFormInteractor;
import org.smartregister.path.presenter.AppChildFormFragmentPresenter;
import org.smartregister.path.util.AppConstants;

import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import static com.vijay.jsonwizard.constants.JsonFormConstants.STEP1;
import static org.smartregister.path.util.AppConstants.KeyConstants.OA_SERVICE_DATE;
import static org.smartregister.path.util.AppConstants.KeyConstants.OPENSRP_ID;

public class AppChildFormFragment extends ChildFormFragment {

private OnReactionVaccineSelected OnReactionVaccineSelected;
private ChildFormActivity childFormActivity;

public static AppChildFormFragment getFormFragment(String stepName) {
AppChildFormFragment jsonFormFragment = new AppChildFormFragment();
Expand Down Expand Up @@ -46,6 +63,12 @@ public interface OnReactionVaccineSelected {
void updateDatePicker(String date);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
childFormActivity = (ChildFormActivity) requireActivity();
}

@Override
public void onDestroy() {
setOnReactionVaccineSelected(null);
Expand All @@ -71,4 +94,57 @@ public void onDestroy() {
}
};
}

@Override
public void addFormElements(List<View> views) {
super.addFormElements(views);
JSONObject jsonObject = getJsonApi().getmJSONObject();
String encounterType = jsonObject.optString(JsonFormConstants.ENCOUNTER_TYPE, "");
if (AppConstants.EventTypeConstants.OUT_OF_CATCHMENT.equalsIgnoreCase(encounterType)) {
disableViews(Arrays.asList(STEP1 + ":" + OA_SERVICE_DATE, STEP1 + ":" + OPENSRP_ID));
}
}

public void disableViews(List<String> skippedViews) {
toggleReadOnly(false, skippedViews);
MaterialEditText serviceDateEditText = (MaterialEditText) childFormActivity.getFormDataView(
STEP1 + ":" + OA_SERVICE_DATE);
serviceDateEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
//Do nothing
}

@Override
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
//Do nothing
}

@Override
public void afterTextChanged(Editable editable) {
toggleReadOnly(StringUtils.isNotBlank(editable.toString()), skippedViews);
}
});
}

private void toggleReadOnly(boolean enabled, List<String> skippedViews) {
Collection<View> formDataViews = childFormActivity.getFormDataViews();
for (View formDataView : formDataViews) {
String address = (String) formDataView.getTag(R.id.address);
if (address != null && skippedViews.contains(address))
continue;
setViewAndChildrenEnabled(formDataView, enabled);
}
}

private static void setViewAndChildrenEnabled(View view, boolean enabled) {
view.setEnabled(enabled);
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
setViewAndChildrenEnabled(child, enabled);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ private Object[] getColumnValues(RemoteLocalCursor remoteLocalCursor) {
remoteLocalCursor.getLostToFollowUp()};
}

@Override
public String getCountQuery() {
return model.countSelect(getMainCondition());
}

@Override
public String getMainCondition() {
return "(ec_client.dod IS NULL AND ec_client.date_removed is null AND ec_client.is_closed IS NOT '1' AND ec_child_details.is_closed IS NOT '1')";
Expand Down
Loading

0 comments on commit 7191c57

Please sign in to comment.