From b0a69f5f7d39d9c1c0f0350af2a16d6eae309e45 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 6 Mar 2020 19:36:21 +0300 Subject: [PATCH 01/21] :construction: Add support for Weight for height z-score calculations --- .../GrowthMonitoringLibrary.java | 9 ++ .../domain/WeightForHeightZscore.java | 34 ++++++++ .../repository/WeightForHeightRepository.java | 85 +++++++++++++++++++ .../intent/WeightForHeightIntentService.java | 66 ++++++++++++++ .../util/GrowthMonitoringConstants.java | 1 + 5 files changed, 195 insertions(+) create mode 100644 opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java create mode 100644 opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java create mode 100644 opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringLibrary.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringLibrary.java index a06a197..5b9bb23 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringLibrary.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringLibrary.java @@ -5,6 +5,7 @@ import org.smartregister.Context; import org.smartregister.growthmonitoring.repository.HeightRepository; import org.smartregister.growthmonitoring.repository.HeightZScoreRepository; +import org.smartregister.growthmonitoring.repository.WeightForHeightRepository; import org.smartregister.growthmonitoring.repository.WeightRepository; import org.smartregister.growthmonitoring.repository.WeightZScoreRepository; import org.smartregister.growthmonitoring.util.AppProperties; @@ -27,6 +28,7 @@ public class GrowthMonitoringLibrary { private HeightRepository heightRepository; private WeightZScoreRepository weightZScoreRepository; private HeightZScoreRepository heightZScoreRepository; + private WeightForHeightRepository weightForHeightRepository; private EventClientRepository eventClientRepository; private int applicationVersion; private int databaseVersion; @@ -100,6 +102,13 @@ public HeightZScoreRepository heightZScoreRepository() { return heightZScoreRepository; } + public WeightForHeightRepository weightForHeightRepository() { + if (weightForHeightRepository == null) { + weightForHeightRepository = new WeightForHeightRepository(); + } + return weightForHeightRepository; + } + public EventClientRepository eventClientRepository() { if (eventClientRepository == null) { eventClientRepository = new EventClientRepository(); diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java new file mode 100644 index 0000000..d05324a --- /dev/null +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java @@ -0,0 +1,34 @@ +package org.smartregister.growthmonitoring.domain; + +import org.smartregister.growthmonitoring.GrowthMonitoringLibrary; + +import timber.log.Timber; + +public class WeightForHeightZscore extends ZScore { + + public static Double calculate(String gender, double weight, double height) { + try { + ZScore zScore = GrowthMonitoringLibrary.getInstance().weightForHeightRepository().findZScoreVariables(gender, height).get(0); + if (zScore != null) { + return zScore.getZ(weight); + } + } catch (Exception ex) { + Timber.e(ex); + return null; + } + return 0.0; + } + + /** + * This method calculates Z (The z-score) using the formulae provided here https://www.cdc + * .gov/growthcharts/percentile_data_files.htm + * + * @param x The weight to use + * @return The Z-Score value + */ + @Override + public double getZ(double x) { + return super.getZ(x); + } + +} diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java new file mode 100644 index 0000000..58d7416 --- /dev/null +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java @@ -0,0 +1,85 @@ +package org.smartregister.growthmonitoring.repository; + +import android.database.Cursor; + +import net.sqlcipher.database.SQLiteDatabase; + +import org.opensrp.api.constants.Gender; +import org.smartregister.growthmonitoring.domain.ZScore; +import org.smartregister.growthmonitoring.util.GrowthMonitoringConstants; +import org.smartregister.repository.BaseRepository; + +import java.util.ArrayList; +import java.util.List; + +import timber.log.Timber; + +/** + * Stores Weight-For-Height z-score computation chart values + * for male and female + */ +public class WeightForHeightRepository extends BaseRepository { + public static final String TABLE_NAME = "weight_for_height_z_values"; + private static final String CREATE_TABLE_QUERY = "CREATE TABLE " + TABLE_NAME + " (_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " VARCHAR NOT NULL," + + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " REAL NOT NULL, " + + GrowthMonitoringConstants.ColumnHeaders.COLUMN_L + " REAL NOT NULL, " + + GrowthMonitoringConstants.ColumnHeaders.COLUMN_M + " REAL NOT NULL, " + + GrowthMonitoringConstants.ColumnHeaders.COLUMN_S + " REAL NOT NULL, " + "UNIQUE(" + + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + ", " + + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + ") ON CONFLICT REPLACE)"; + private static final String CREATE_INDEX_SEX_QUERY = "CREATE INDEX " + TABLE_NAME + "_" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + "_index ON " + + TABLE_NAME + "(" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " COLLATE NOCASE);"; + private static final String CREATE_INDEX_HEIGHT_QUERY = "CREATE INDEX " + TABLE_NAME + "_" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_MONTH + "_index ON " + + TABLE_NAME + "(" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_MONTH + " COLLATE NOCASE);"; + + public static void createTable(SQLiteDatabase database) { + database.execSQL(CREATE_TABLE_QUERY); + database.execSQL(CREATE_INDEX_SEX_QUERY); + database.execSQL(CREATE_INDEX_HEIGHT_QUERY); + } + + /** + * Get values for z-score computation + * + * @param gender Gender value by which to filter + * @param height Gender value by which to filter + * @return A list of z-score variables for use in the computation + */ + public List findZScoreVariables(String gender, double height) { + Cursor cursor = null; + List zScoreVariables = new ArrayList<>(); + try { + SQLiteDatabase database = getReadableDatabase(); + + String selection = GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? "; + String[] selectionArgs = new String[]{gender, String.valueOf(height)}; + + cursor = database.query(TABLE_NAME, null, + selection + COLLATE_NOCASE, selectionArgs, null, null, null, null); + + if (cursor != null && cursor.moveToFirst()) { + while (!cursor.isAfterLast()) { + zScoreVariables.add(getZScoreValuesFromCursor(cursor)); + cursor.moveToNext(); + } + } + } catch (Exception ex) { + Timber.e(ex); + } finally { + if (cursor != null) cursor.close(); + } + return zScoreVariables; + } + + private ZScore getZScoreValuesFromCursor(Cursor cursor) { + ZScore zScoreValues = new ZScore(); + int gender = Integer.parseInt(cursor.getString(cursor.getColumnIndex(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX))); + zScoreValues.setGender(gender == 1 ? Gender.MALE : Gender.FEMALE); + zScoreValues.setL(cursor.getDouble(cursor.getColumnIndex(GrowthMonitoringConstants.ColumnHeaders.COLUMN_L))); + zScoreValues.setM(cursor.getDouble(cursor.getColumnIndex(GrowthMonitoringConstants.ColumnHeaders.COLUMN_M))); + zScoreValues.setS(cursor.getDouble(cursor.getColumnIndex(GrowthMonitoringConstants.ColumnHeaders.COLUMN_S))); + + return zScoreValues; + } +} diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java new file mode 100644 index 0000000..e1db7eb --- /dev/null +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java @@ -0,0 +1,66 @@ +package org.smartregister.growthmonitoring.service.intent; + +import android.app.IntentService; +import android.content.Intent; +import android.content.Context; + +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVParser; +import org.apache.commons.csv.CSVRecord; +import org.apache.commons.lang3.StringUtils; +import org.smartregister.util.Utils; + +/** + * An {@link IntentService} subclass for handling asynchronous task requests in + * a service on a separate handler thread. + *

+ * helper methods. + */ +public class WeightForHeightIntentService extends IntentService { + + private static final String ACTION_PARSE_WFH_CSV = "org.smartregister.growthmonitoring.service.intent.action.parse"; + + public WeightForHeightIntentService() { + super("WeightForHeightIntentService"); + } + + /** + * Starts this service to perform action Foo with the given parameters. If + * the service is already performing a task this action will be queued. + * + * @see IntentService + */ + public static void startActionFoo(Context context) { + Intent intent = new Intent(context, WeightForHeightIntentService.class); + intent.setAction(ACTION_PARSE_WFH_CSV); + context.startService(intent); + } + + @Override + protected void onHandleIntent(Intent intent) { + if (intent != null) { + final String action = intent.getAction(); + if (ACTION_PARSE_WFH_CSV.equals(action)) { + parseWFHCSV(); + } + } + } + + /** + * Handle parsing the WFH CSV chart in the provided background thread + */ + private void parseWFHCSV() { + + try { + String fileName = null; + if (StringUtils.isNotBlank(fileName)) { + CSVParser csvParser = CSVParser.parse(Utils.readAssetContents(this, fileName), CSVFormat.newFormat('\t')); + for (CSVRecord record : csvParser) { + + } + } + } catch (Exception ex) { + + } + } +} diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringConstants.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringConstants.java index 922090f..a5e843d 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringConstants.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringConstants.java @@ -33,6 +33,7 @@ public static final class JsonForm { public static final class ColumnHeaders { public static final String COLUMN_SEX = "sex"; public static final String COLUMN_MONTH = "month"; + public static final String HEIGHT = "height"; public static final String COLUMN_L = "l"; public static final String COLUMN_M = "m"; public static final String COLUMN_S = "s"; From 0bbaaa2b571bcc9b049ad2fa5620e0724d5da21f Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 6 Mar 2020 19:37:07 +0300 Subject: [PATCH 02/21] :arrow_up: Increase snapshot version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8df1059..d579662 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.1.19-SNAPSHOT +VERSION_NAME=1.1.20-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Growth Monitoring Application From df87c6229f68bf54e6808ec3bc35b548fcfc6604 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 6 Mar 2020 19:37:34 +0300 Subject: [PATCH 03/21] :fire: Refactor and move z-score main calculation to Zscore parent class --- .../src/main/AndroidManifest.xml | 6 ++++-- .../growthmonitoring/domain/HeightZScore.java | 9 +++------ .../growthmonitoring/domain/WeightZScore.java | 8 +++----- .../growthmonitoring/domain/ZScore.java | 16 ++++++++++++++++ .../repository/HeightZScoreRepository.java | 7 ++++--- .../repository/WeightZScoreRepository.java | 6 ++++-- .../intent/ZScoreRefreshIntentService.java | 2 +- 7 files changed, 35 insertions(+), 19 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/AndroidManifest.xml b/opensrp-growth-monitoring/src/main/AndroidManifest.xml index 2d5622a..5ca3c89 100644 --- a/opensrp-growth-monitoring/src/main/AndroidManifest.xml +++ b/opensrp-growth-monitoring/src/main/AndroidManifest.xml @@ -6,7 +6,9 @@ android:allowBackup="true" android:label="@string/app_name" android:supportsRtl="true"> - + - + \ No newline at end of file diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java index cd66476..0ad9e14 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java @@ -56,7 +56,7 @@ public static Double calculate(Gender gender, Date dateOfBirth, Date heightDate, return 0.0; } catch (Exception e) { - Timber.e(e.getMessage()); + Timber.e(e); return null; } } @@ -115,12 +115,9 @@ public static Double reverse(Gender gender, double ageInMonthsDouble, Double z) * * @return */ + @Override public double getZ(double x) { - if (getL() != 0) { - return (Math.pow((x / getM()), getL()) - 1) / (getL() * getS()); - } else { - return Math.log(x / getM()) / getS(); - } + return super.getZ(x); } /** diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java index 54ab1bf..256966e 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java @@ -120,12 +120,10 @@ public static Double reverse(Gender gender, double ageInMonthsDouble, Double z) * * @return */ + + @Override public double getZ(double x) { - if (getL() != 0) { - return (Math.pow((x / getM()), getL()) - 1) / (getL() * getS()); - } else { - return Math.log(x / getM()) / getS(); - } + return super.getZ(x); } /** diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/ZScore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/ZScore.java index 7e99ec6..00bd031 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/ZScore.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/ZScore.java @@ -114,4 +114,20 @@ public double getSd3() { public void setSd3(double sd3) { this.sd3 = sd3; } + + /** + * This method calculates Z (The z-score) using the formulae provided here https://www.cdc + * .gov/growthcharts/percentile_data_files.htm + * + * @param x The height/weight to use + * + * @return + */ + public double getZ(double x) { + if (getL() != 0) { + return (Math.pow((x / getM()), getL()) - 1) / (getL() * getS()); + } else { + return Math.log(x / getM()) / getS(); + } + } } diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java index 41ed34d..e761d10 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java @@ -1,7 +1,6 @@ package org.smartregister.growthmonitoring.repository; import android.database.Cursor; -import android.util.Log; import net.sqlcipher.database.SQLiteDatabase; @@ -13,6 +12,8 @@ import java.util.ArrayList; import java.util.List; +import timber.log.Timber; + /** * Stores child z-scores obtained from: - http://www.who.int/childgrowth/standards/wfa_boys_0_5_zscores.txt - * http://www.who.int/childgrowth/standards/wfa_girls_0_5_zscores.txt @@ -64,7 +65,7 @@ public boolean runRawQuery(String query) { getWritableDatabase().execSQL(query); return true; } catch (Exception e) { - Log.e(TAG, Log.getStackTraceString(e)); + Timber.e(e, TAG); } return false; @@ -86,7 +87,7 @@ public List findByGender(Gender gender) { } } } catch (Exception e) { - Log.e(TAG, Log.getStackTraceString(e)); + Timber.e(e, TAG); } finally { if (cursor != null) cursor.close(); } diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightZScoreRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightZScoreRepository.java index 0732062..98fb302 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightZScoreRepository.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightZScoreRepository.java @@ -13,6 +13,8 @@ import java.util.ArrayList; import java.util.List; +import timber.log.Timber; + /** * Stores child z-scores obtained from: - http://www.who.int/childgrowth/standards/wfa_boys_0_5_zscores.txt - * http://www.who.int/childgrowth/standards/wfa_girls_0_5_zscores.txt @@ -62,7 +64,7 @@ public boolean runRawQuery(String query) { getWritableDatabase().execSQL(query); return true; } catch (Exception e) { - Log.e(TAG, Log.getStackTraceString(e)); + Timber.e(e); } return false; @@ -84,7 +86,7 @@ public List findByGender(Gender gender) { } } } catch (Exception e) { - Log.e(TAG, Log.getStackTraceString(e)); + Timber.e(e); } finally { if (cursor != null) cursor.close(); } diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java index cd8fe31..73a1259 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java @@ -106,7 +106,7 @@ protected void onHandleIntent(Intent intent) { * @param force */ private void dumpWeightCsv(Gender gender, boolean force) { - try { + try { List existingScores = GrowthMonitoringLibrary.getInstance().weightZScoreRepository().findByGender(gender); if (force || existingScores.size() == 0) { From 1e1b5bb5b5794e735950cc70d141095687e6b6ca Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 9 Mar 2020 11:39:48 +0300 Subject: [PATCH 04/21] :Recycle: Refactor and move CSV dump query builder functionaliy to a Util class for reuse --- .../intent/ZScoreRefreshIntentService.java | 81 +++---------------- .../util/GrowthMonitoringUtils.java | 59 ++++++++++++++ 2 files changed, 69 insertions(+), 71 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java index 73a1259..4d238a1 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java @@ -5,9 +5,6 @@ import android.text.TextUtils; import android.util.Log; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; import org.joda.time.DateTime; import org.opensrp.api.constants.Gender; import org.smartregister.commonregistry.CommonPersonObject; @@ -20,6 +17,7 @@ import org.smartregister.growthmonitoring.repository.HeightZScoreRepository; import org.smartregister.growthmonitoring.repository.WeightZScoreRepository; import org.smartregister.growthmonitoring.util.GrowthMonitoringConstants; +import org.smartregister.growthmonitoring.util.GrowthMonitoringUtils; import org.smartregister.util.FileUtilities; import org.smartregister.util.Utils; @@ -106,7 +104,7 @@ protected void onHandleIntent(Intent intent) { * @param force */ private void dumpWeightCsv(Gender gender, boolean force) { - try { + try { List existingScores = GrowthMonitoringLibrary.getInstance().weightZScoreRepository().findByGender(gender); if (force || existingScores.size() == 0) { @@ -116,41 +114,12 @@ private void dumpWeightCsv(Gender gender, boolean force) { } else if (gender.equals(Gender.MALE)) { filename = GrowthMonitoringLibrary.getInstance().getConfig().getMaleWeightZScoreFile(); } - if (filename != null) { - CSVParser csvParser = - CSVParser.parse(Utils.readAssetContents(this, filename), CSVFormat.newFormat('\t')); - - HashMap columnStatus = new HashMap<>(); - String query = - "INSERT INTO `" + WeightZScoreRepository.TABLE_NAME + "` ( `" + ColumnHeaders.COLUMN_SEX + "`"; - for (CSVRecord record : csvParser) { - if (csvParser.getCurrentLineNumber() == 2) {// The second line - query = query + ")\n VALUES (\"" + gender.name() + "\""; - } else if (csvParser.getCurrentLineNumber() > 2) { - query = query + "),\n (\"" + gender.name() + "\""; - } - - for (int columnIndex = 0; columnIndex < record.size(); columnIndex++) { - String curColumn = record.get(columnIndex); - if (csvParser.getCurrentLineNumber() == 1) { - if (CSV_HEADING_SQL_COLUMN_MAP.containsKey(curColumn)) { - columnStatus.put(columnIndex, true); - query = query + ", `" + CSV_HEADING_SQL_COLUMN_MAP.get(curColumn) + "`"; - } else { - columnStatus.put(columnIndex, false); - } - } else { - if (columnStatus.get(columnIndex)) { - query = query + ", \"" + curColumn + "\""; - } - } - } + String query = GrowthMonitoringUtils.dumpCsvQueryBuilder(gender, this, filename, WeightZScoreRepository.TABLE_NAME, CSV_HEADING_SQL_COLUMN_MAP); + if (query != null) { + boolean result = GrowthMonitoringLibrary.getInstance().weightZScoreRepository().runRawQuery(query); + Timber.d("ZScoreRefreshIntentService --> dumpWeightCsv --> Result%s", result); } - query = query + ");"; - - boolean result = GrowthMonitoringLibrary.getInstance().weightZScoreRepository().runRawQuery(query); - Timber.d("ZScoreRefreshIntentService --> dumpWeightCsv --> Result%s", result); } } } catch (Exception e) { @@ -175,42 +144,12 @@ private void dumpHeightCsv(Gender gender, boolean force) { } else if (gender.equals(Gender.MALE)) { filename = GrowthMonitoringLibrary.getInstance().getConfig().getMaleHeightZScoreFile(); } - if (filename != null) { - CSVParser csvParser = - CSVParser.parse(Utils.readAssetContents(this, filename), CSVFormat.newFormat('\t')); - - HashMap columnStatus = new HashMap<>(); - String query = - "INSERT INTO `" + HeightZScoreRepository.TABLE_NAME + "` ( `" + ColumnHeaders.COLUMN_SEX + "`"; - for (CSVRecord record : csvParser) { - if (csvParser.getCurrentLineNumber() == 2) {// The second line - query = query + ")\n VALUES (\"" + gender.name() + "\""; - } else if (csvParser.getCurrentLineNumber() > 2) { - query = query + "),\n (\"" + gender.name() + "\""; - } - - for (int columnIndex = 0; columnIndex < record.size(); columnIndex++) { - String curColumn = record.get(columnIndex); - if (csvParser.getCurrentLineNumber() == 1) { - if (HEIGHT_CSV_HEADING_SQL_COLUMN_MAP.containsKey(curColumn)) { - columnStatus.put(columnIndex, true); - query = query + ", `" + HEIGHT_CSV_HEADING_SQL_COLUMN_MAP.get(curColumn) + "`"; - } else { - columnStatus.put(columnIndex, false); - } - } else { - if (columnStatus.get(columnIndex)) { - query = query + ", \"" + curColumn + "\""; - } - } - } + String query = GrowthMonitoringUtils.dumpCsvQueryBuilder(gender, this, filename, HeightZScoreRepository.TABLE_NAME, HEIGHT_CSV_HEADING_SQL_COLUMN_MAP); + if (query != null) { + boolean result = GrowthMonitoringLibrary.getInstance().heightZScoreRepository().runRawQuery(query); + Timber.d("ZScoreRefreshIntentService --> dumpHeightCsv --> Result%s", result); } - query = query + ");"; - - boolean result = GrowthMonitoringLibrary.getInstance().heightZScoreRepository().runRawQuery(query); - Timber.d("ZScoreRefreshIntentService --> dumpHeightCsv --> Result%s", result); - } } } catch (Exception e) { diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java index 9644b5c..f420486 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java @@ -1,15 +1,23 @@ package org.smartregister.growthmonitoring.util; +import android.content.Context; import android.content.res.AssetManager; import android.view.View; import android.view.ViewTreeObserver; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVParser; +import org.apache.commons.csv.CSVRecord; +import org.opensrp.api.constants.Gender; import org.smartregister.growthmonitoring.domain.WeightZScore; import org.smartregister.growthmonitoring.listener.ViewMeasureListener; +import org.smartregister.util.Utils; import java.io.InputStream; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import timber.log.Timber; @@ -103,4 +111,55 @@ public static AppProperties getProperties(android.content.Context context) { return properties; } + + /** + * Parse CSV file and build query String for persisting values in the DB + * @param gender Gender for which the chart values belong to + * @param context + * @param filename CSV file name + * @param tableName Table where values will be stored + * @param csvHeadingColumnMap CSV Headings map + * @return Query String + */ + public static String dumpCsvQueryBuilder(Gender gender, Context context, String filename, String tableName, Map csvHeadingColumnMap) { + StringBuilder queryString; + try { + if (filename != null) { + CSVParser csvParser = + CSVParser.parse(Utils.readAssetContents(context, filename), CSVFormat.newFormat('\t')); + + HashMap columnStatus = new HashMap<>(); + + queryString = new StringBuilder("INSERT INTO `" + tableName + "` ( `" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + "`"); + for (CSVRecord record : csvParser) { + if (csvParser.getCurrentLineNumber() == 2) {// The second line + queryString.append(")\n VALUES (\"").append(gender.name()).append("\""); + } else if (csvParser.getCurrentLineNumber() > 2) { + queryString.append("),\n (\"").append(gender.name()).append("\""); + } + + for (int columnIndex = 0; columnIndex < record.size(); columnIndex++) { + String curColumn = record.get(columnIndex); + if (csvParser.getCurrentLineNumber() == 1) { + if (csvHeadingColumnMap.containsKey(curColumn)) { + columnStatus.put(columnIndex, true); + queryString.append(", `").append(csvHeadingColumnMap.get(curColumn)).append("`"); + } else { + columnStatus.put(columnIndex, false); + } + } else { + if (columnStatus.get(columnIndex)) { + queryString.append(", \"").append(curColumn).append("\""); + } + } + } + } + queryString.append(");"); + return queryString.toString(); + } + } catch (Exception e) { + Timber.e(e, "GrowthMonitoringUtils --> Dump CSV"); + } + return null; + } } From b2e65ebb40caaaf55084e4b1ceb3998f3085d5e8 Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 9 Mar 2020 16:59:25 +0300 Subject: [PATCH 05/21] :arrow_up: Update client core and native forms dependency versions --- opensrp-growth-monitoring/build.gradle | 4 ++-- sample/build.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/opensrp-growth-monitoring/build.gradle b/opensrp-growth-monitoring/build.gradle index 74948a0..df1242c 100644 --- a/opensrp-growth-monitoring/build.gradle +++ b/opensrp-growth-monitoring/build.gradle @@ -87,12 +87,12 @@ allprojects { } dependencies { - implementation('org.smartregister:opensrp-client-core:1.8.26-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-core:1.9.2-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' } - implementation('org.smartregister:opensrp-client-native-form:1.7.18-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-native-form:1.7.23-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'recyclerview-v7' } diff --git a/sample/build.gradle b/sample/build.gradle index 694aa4d..1ed0d2b 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -79,12 +79,12 @@ android { } dependencies { - implementation('org.smartregister:opensrp-client-core:1.8.26-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-core:1.9.2-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' } - implementation('org.smartregister:opensrp-client-native-form:1.7.18-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-native-form:1.7.23-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'recyclerview-v7' } From e239a931858ab5cdf9acbab277c73f4969f6a054 Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 9 Mar 2020 17:07:41 +0300 Subject: [PATCH 06/21] :boom: Add and get CSV file --- .../src/main/assets/weight_for_height.csv | 1103 +++++++++++++++++ .../GrowthMonitoringConfig.java | 9 + 2 files changed, 1112 insertions(+) create mode 100644 opensrp-growth-monitoring/src/main/assets/weight_for_height.csv diff --git a/opensrp-growth-monitoring/src/main/assets/weight_for_height.csv b/opensrp-growth-monitoring/src/main/assets/weight_for_height.csv new file mode 100644 index 0000000..2efe8d2 --- /dev/null +++ b/opensrp-growth-monitoring/src/main/assets/weight_for_height.csv @@ -0,0 +1,1103 @@ +sex height l m s lorh +1 65 -0.3521 7.4327 0.08217 H +1 65.1 -0.3521 7.4563 0.08216 H +1 65.2 -0.3521 7.4799 0.08216 H +1 65.3 -0.3521 7.5034 0.08215 H +1 65.4 -0.3521 7.5269 0.08214 H +1 65.5 -0.3521 7.5504 0.08214 H +1 65.6 -0.3521 7.5738 0.08214 H +1 65.7 -0.3521 7.5973 0.08213 H +1 65.8 -0.3521 7.6206 0.08213 H +1 65.9 -0.3521 7.644 0.08213 H +1 66 -0.3521 7.6673 0.08212 H +1 66.1 -0.3521 7.6906 0.08212 H +1 66.2 -0.3521 7.7138 0.08212 H +1 66.3 -0.3521 7.737 0.08212 H +1 66.4 -0.3521 7.7602 0.08212 H +1 66.5 -0.3521 7.7834 0.08212 H +1 66.6 -0.3521 7.8065 0.08212 H +1 66.7 -0.3521 7.8296 0.08212 H +1 66.8 -0.3521 7.8526 0.08212 H +1 66.9 -0.3521 7.8757 0.08212 H +1 67 -0.3521 7.8986 0.08213 H +1 67.1 -0.3521 7.9216 0.08213 H +1 67.2 -0.3521 7.9445 0.08213 H +1 67.3 -0.3521 7.9674 0.08214 H +1 67.4 -0.3521 7.9903 0.08214 H +1 67.5 -0.3521 8.0132 0.08214 H +1 67.6 -0.3521 8.036 0.08215 H +1 67.7 -0.3521 8.0588 0.08215 H +1 67.8 -0.3521 8.0816 0.08216 H +1 67.9 -0.3521 8.1044 0.08217 H +1 68 -0.3521 8.1272 0.08217 H +1 68.1 -0.3521 8.15 0.08218 H +1 68.2 -0.3521 8.1727 0.08219 H +1 68.3 -0.3521 8.1955 0.08219 H +1 68.4 -0.3521 8.2183 0.0822 H +1 68.5 -0.3521 8.241 0.08221 H +1 68.6 -0.3521 8.2638 0.08222 H +1 68.7 -0.3521 8.2865 0.08223 H +1 68.8 -0.3521 8.3092 0.08224 H +1 68.9 -0.3521 8.332 0.08225 H +1 69 -0.3521 8.3547 0.08226 H +1 69.1 -0.3521 8.3774 0.08227 H +1 69.2 -0.3521 8.4001 0.08228 H +1 69.3 -0.3521 8.4227 0.08229 H +1 69.4 -0.3521 8.4454 0.0823 H +1 69.5 -0.3521 8.468 0.08231 H +1 69.6 -0.3521 8.4906 0.08232 H +1 69.7 -0.3521 8.5132 0.08233 H +1 69.8 -0.3521 8.5358 0.08235 H +1 69.9 -0.3521 8.5583 0.08236 H +1 70 -0.3521 8.5808 0.08237 H +1 70.1 -0.3521 8.6032 0.08238 H +1 70.2 -0.3521 8.6257 0.0824 H +1 70.3 -0.3521 8.648 0.08241 H +1 70.4 -0.3521 8.6704 0.08242 H +1 70.5 -0.3521 8.6927 0.08243 H +1 70.6 -0.3521 8.715 0.08245 H +1 70.7 -0.3521 8.7372 0.08246 H +1 70.8 -0.3521 8.7594 0.08248 H +1 70.9 -0.3521 8.7815 0.08249 H +1 71 -0.3521 8.8036 0.0825 H +1 71.1 -0.3521 8.8257 0.08252 H +1 71.2 -0.3521 8.8477 0.08253 H +1 71.3 -0.3521 8.8697 0.08254 H +1 71.4 -0.3521 8.8916 0.08256 H +1 71.5 -0.3521 8.9135 0.08257 H +1 71.6 -0.3521 8.9353 0.08259 H +1 71.7 -0.3521 8.9571 0.0826 H +1 71.8 -0.3521 8.9788 0.08262 H +1 71.9 -0.3521 9.0005 0.08263 H +1 72 -0.3521 9.0221 0.08264 H +1 72.1 -0.3521 9.0436 0.08266 H +1 72.2 -0.3521 9.0651 0.08267 H +1 72.3 -0.3521 9.0865 0.08269 H +1 72.4 -0.3521 9.1079 0.0827 H +1 72.5 -0.3521 9.1292 0.08272 H +1 72.6 -0.3521 9.1504 0.08273 H +1 72.7 -0.3521 9.1716 0.08274 H +1 72.8 -0.3521 9.1927 0.08276 H +1 72.9 -0.3521 9.2137 0.08277 H +1 73 -0.3521 9.2347 0.08278 H +1 73.1 -0.3521 9.2557 0.0828 H +1 73.2 -0.3521 9.2766 0.08281 H +1 73.3 -0.3521 9.2974 0.08283 H +1 73.4 -0.3521 9.3182 0.08284 H +1 73.5 -0.3521 9.339 0.08285 H +1 73.6 -0.3521 9.3597 0.08287 H +1 73.7 -0.3521 9.3803 0.08288 H +1 73.8 -0.3521 9.401 0.08289 H +1 73.9 -0.3521 9.4215 0.0829 H +1 74 -0.3521 9.442 0.08292 H +1 74.1 -0.3521 9.4625 0.08293 H +1 74.2 -0.3521 9.4829 0.08294 H +1 74.3 -0.3521 9.5032 0.08295 H +1 74.4 -0.3521 9.5235 0.08297 H +1 74.5 -0.3521 9.5438 0.08298 H +1 74.6 -0.3521 9.5639 0.08299 H +1 74.7 -0.3521 9.5841 0.083 H +1 74.8 -0.3521 9.6041 0.08301 H +1 74.9 -0.3521 9.6241 0.08302 H +1 75 -0.3521 9.644 0.08303 H +1 75.1 -0.3521 9.6639 0.08305 H +1 75.2 -0.3521 9.6836 0.08306 H +1 75.3 -0.3521 9.7033 0.08307 H +1 75.4 -0.3521 9.723 0.08307 H +1 75.5 -0.3521 9.7425 0.08308 H +1 75.6 -0.3521 9.762 0.08309 H +1 75.7 -0.3521 9.7814 0.0831 H +1 75.8 -0.3521 9.8007 0.08311 H +1 75.9 -0.3521 9.82 0.08312 H +1 76 -0.3521 9.8392 0.08312 H +1 76.1 -0.3521 9.8583 0.08313 H +1 76.2 -0.3521 9.8773 0.08314 H +1 76.3 -0.3521 9.8963 0.08314 H +1 76.4 -0.3521 9.9152 0.08315 H +1 76.5 -0.3521 9.9341 0.08315 H +1 76.6 -0.3521 9.9528 0.08316 H +1 76.7 -0.3521 9.9716 0.08316 H +1 76.8 -0.3521 9.9902 0.08317 H +1 76.9 -0.3521 10.0088 0.08317 H +1 77 -0.3521 10.0274 0.08317 H +1 77.1 -0.3521 10.0459 0.08318 H +1 77.2 -0.3521 10.0643 0.08318 H +1 77.3 -0.3521 10.0827 0.08318 H +1 77.4 -0.3521 10.1011 0.08318 H +1 77.5 -0.3521 10.1194 0.08318 H +1 77.6 -0.3521 10.1377 0.08318 H +1 77.7 -0.3521 10.1559 0.08318 H +1 77.8 -0.3521 10.1741 0.08318 H +1 77.9 -0.3521 10.1923 0.08317 H +1 78 -0.3521 10.2105 0.08317 H +1 78.1 -0.3521 10.2286 0.08317 H +1 78.2 -0.3521 10.2468 0.08316 H +1 78.3 -0.3521 10.2649 0.08316 H +1 78.4 -0.3521 10.2831 0.08315 H +1 78.5 -0.3521 10.3012 0.08315 H +1 78.6 -0.3521 10.3194 0.08314 H +1 78.7 -0.3521 10.3376 0.08313 H +1 78.8 -0.3521 10.3558 0.08313 H +1 78.9 -0.3521 10.3741 0.08312 H +1 79 -0.3521 10.3923 0.08311 H +1 79.1 -0.3521 10.4107 0.0831 H +1 79.2 -0.3521 10.4291 0.08309 H +1 79.3 -0.3521 10.4475 0.08308 H +1 79.4 -0.3521 10.466 0.08307 H +1 79.5 -0.3521 10.4845 0.08305 H +1 79.6 -0.3521 10.5031 0.08304 H +1 79.7 -0.3521 10.5217 0.08303 H +1 79.8 -0.3521 10.5405 0.08301 H +1 79.9 -0.3521 10.5592 0.083 H +1 80 -0.3521 10.5781 0.08298 H +1 80.1 -0.3521 10.597 0.08297 H +1 80.2 -0.3521 10.6161 0.08295 H +1 80.3 -0.3521 10.6352 0.08293 H +1 80.4 -0.3521 10.6544 0.08291 H +1 80.5 -0.3521 10.6737 0.0829 H +1 80.6 -0.3521 10.6931 0.08288 H +1 80.7 -0.3521 10.7126 0.08286 H +1 80.8 -0.3521 10.7322 0.08284 H +1 80.9 -0.3521 10.752 0.08282 H +1 81 -0.3521 10.7718 0.08279 H +1 81.1 -0.3521 10.7918 0.08277 H +1 81.2 -0.3521 10.8119 0.08275 H +1 81.3 -0.3521 10.8321 0.08273 H +1 81.4 -0.3521 10.8524 0.0827 H +1 81.5 -0.3521 10.8728 0.08268 H +1 81.6 -0.3521 10.8934 0.08265 H +1 81.7 -0.3521 10.9142 0.08263 H +1 81.8 -0.3521 10.935 0.0826 H +1 81.9 -0.3521 10.956 0.08258 H +1 82 -0.3521 10.9772 0.08255 H +1 82.1 -0.3521 10.9985 0.08252 H +1 82.2 -0.3521 11.0199 0.08249 H +1 82.3 -0.3521 11.0415 0.08246 H +1 82.4 -0.3521 11.0632 0.08244 H +1 82.5 -0.3521 11.0851 0.08241 H +1 82.6 -0.3521 11.1071 0.08238 H +1 82.7 -0.3521 11.1293 0.08235 H +1 82.8 -0.3521 11.1516 0.08231 H +1 82.9 -0.3521 11.174 0.08228 H +1 83 -0.3521 11.1966 0.08225 H +1 83.1 -0.3521 11.2193 0.08222 H +1 83.2 -0.3521 11.2422 0.08219 H +1 83.3 -0.3521 11.2651 0.08215 H +1 83.4 -0.3521 11.2882 0.08212 H +1 83.5 -0.3521 11.3114 0.08209 H +1 83.6 -0.3521 11.3347 0.08205 H +1 83.7 -0.3521 11.3581 0.08202 H +1 83.8 -0.3521 11.3817 0.08198 H +1 83.9 -0.3521 11.4053 0.08195 H +1 84 -0.3521 11.429 0.08191 H +1 84.1 -0.3521 11.4529 0.08188 H +1 84.2 -0.3521 11.4768 0.08184 H +1 84.3 -0.3521 11.5007 0.08181 H +1 84.4 -0.3521 11.5248 0.08177 H +1 84.5 -0.3521 11.549 0.08174 H +1 84.6 -0.3521 11.5732 0.0817 H +1 84.7 -0.3521 11.5975 0.08166 H +1 84.8 -0.3521 11.6218 0.08163 H +1 84.9 -0.3521 11.6462 0.08159 H +1 85 -0.3521 11.6707 0.08156 H +1 85.1 -0.3521 11.6952 0.08152 H +1 85.2 -0.3521 11.7198 0.08148 H +1 85.3 -0.3521 11.7444 0.08145 H +1 85.4 -0.3521 11.769 0.08141 H +1 85.5 -0.3521 11.7937 0.08138 H +1 85.6 -0.3521 11.8184 0.08134 H +1 85.7 -0.3521 11.8431 0.08131 H +1 85.8 -0.3521 11.8678 0.08128 H +1 85.9 -0.3521 11.8926 0.08124 H +1 86 -0.3521 11.9173 0.08121 H +1 86.1 -0.3521 11.9421 0.08118 H +1 86.2 -0.3521 11.9668 0.08114 H +1 86.3 -0.3521 11.9916 0.08111 H +1 86.4 -0.3521 12.0163 0.08108 H +1 86.5 -0.3521 12.0411 0.08105 H +1 86.6 -0.3521 12.0658 0.08102 H +1 86.7 -0.3521 12.0905 0.08099 H +1 86.8 -0.3521 12.1152 0.08096 H +1 86.9 -0.3521 12.1398 0.08093 H +1 87 -0.3521 12.1645 0.0809 H +1 87.1 -0.3521 12.1891 0.08087 H +1 87.2 -0.3521 12.2136 0.08084 H +1 87.3 -0.3521 12.2382 0.08082 H +1 87.4 -0.3521 12.2627 0.08079 H +1 87.5 -0.3521 12.2871 0.08076 H +1 87.6 -0.3521 12.3116 0.08074 H +1 87.7 -0.3521 12.336 0.08071 H +1 87.8 -0.3521 12.3603 0.08069 H +1 87.9 -0.3521 12.3846 0.08067 H +1 88 -0.3521 12.4089 0.08064 H +1 88.1 -0.3521 12.4332 0.08062 H +1 88.2 -0.3521 12.4574 0.0806 H +1 88.3 -0.3521 12.4815 0.08058 H +1 88.4 -0.3521 12.5057 0.08056 H +1 88.5 -0.3521 12.5298 0.08054 H +1 88.6 -0.3521 12.5538 0.08052 H +1 88.7 -0.3521 12.5778 0.0805 H +1 88.8 -0.3521 12.6017 0.08048 H +1 88.9 -0.3521 12.6257 0.08047 H +1 89 -0.3521 12.6495 0.08045 H +1 89.1 -0.3521 12.6734 0.08044 H +1 89.2 -0.3521 12.6972 0.08042 H +1 89.3 -0.3521 12.7209 0.08041 H +1 89.4 -0.3521 12.7446 0.08039 H +1 89.5 -0.3521 12.7683 0.08038 H +1 89.6 -0.3521 12.792 0.08037 H +1 89.7 -0.3521 12.8156 0.08035 H +1 89.8 -0.3521 12.8392 0.08034 H +1 89.9 -0.3521 12.8628 0.08033 H +1 90 -0.3521 12.8864 0.08032 H +1 90.1 -0.3521 12.9099 0.08031 H +1 90.2 -0.3521 12.9334 0.0803 H +1 90.3 -0.3521 12.9569 0.0803 H +1 90.4 -0.3521 12.9804 0.08029 H +1 90.5 -0.3521 13.0038 0.08028 H +1 90.6 -0.3521 13.0273 0.08027 H +1 90.7 -0.3521 13.0507 0.08027 H +1 90.8 -0.3521 13.0742 0.08026 H +1 90.9 -0.3521 13.0976 0.08026 H +1 91 -0.3521 13.1209 0.08025 H +1 91.1 -0.3521 13.1443 0.08025 H +1 91.2 -0.3521 13.1677 0.08025 H +1 91.3 -0.3521 13.191 0.08025 H +1 91.4 -0.3521 13.2143 0.08025 H +1 91.5 -0.3521 13.2376 0.08024 H +1 91.6 -0.3521 13.2609 0.08024 H +1 91.7 -0.3521 13.2842 0.08024 H +1 91.8 -0.3521 13.3075 0.08025 H +1 91.9 -0.3521 13.3308 0.08025 H +1 92 -0.3521 13.3541 0.08025 H +1 92.1 -0.3521 13.3773 0.08025 H +1 92.2 -0.3521 13.4006 0.08026 H +1 92.3 -0.3521 13.4239 0.08026 H +1 92.4 -0.3521 13.4472 0.08027 H +1 92.5 -0.3521 13.4705 0.08027 H +1 92.6 -0.3521 13.4937 0.08028 H +1 92.7 -0.3521 13.5171 0.08028 H +1 92.8 -0.3521 13.5404 0.08029 H +1 92.9 -0.3521 13.5637 0.0803 H +1 93 -0.3521 13.587 0.08031 H +1 93.1 -0.3521 13.6104 0.08032 H +1 93.2 -0.3521 13.6338 0.08033 H +1 93.3 -0.3521 13.6572 0.08034 H +1 93.4 -0.3521 13.6806 0.08035 H +1 93.5 -0.3521 13.7041 0.08036 H +1 93.6 -0.3521 13.7275 0.08037 H +1 93.7 -0.3521 13.751 0.08038 H +1 93.8 -0.3521 13.7746 0.0804 H +1 93.9 -0.3521 13.7981 0.08041 H +1 94 -0.3521 13.8217 0.08043 H +1 94.1 -0.3521 13.8454 0.08044 H +1 94.2 -0.3521 13.8691 0.08046 H +1 94.3 -0.3521 13.8928 0.08047 H +1 94.4 -0.3521 13.9165 0.08049 H +1 94.5 -0.3521 13.9403 0.08051 H +1 94.6 -0.3521 13.9642 0.08052 H +1 94.7 -0.3521 13.9881 0.08054 H +1 94.8 -0.3521 14.012 0.08056 H +1 94.9 -0.3521 14.036 0.08058 H +1 95 -0.3521 14.06 0.0806 H +1 95.1 -0.3521 14.0841 0.08062 H +1 95.2 -0.3521 14.1083 0.08064 H +1 95.3 -0.3521 14.1325 0.08067 H +1 95.4 -0.3521 14.1567 0.08069 H +1 95.5 -0.3521 14.1811 0.08071 H +1 95.6 -0.3521 14.2055 0.08073 H +1 95.7 -0.3521 14.2299 0.08076 H +1 95.8 -0.3521 14.2544 0.08078 H +1 95.9 -0.3521 14.279 0.08081 H +1 96 -0.3521 14.3037 0.08083 H +1 96.1 -0.3521 14.3284 0.08086 H +1 96.2 -0.3521 14.3533 0.08089 H +1 96.3 -0.3521 14.3782 0.08092 H +1 96.4 -0.3521 14.4031 0.08094 H +1 96.5 -0.3521 14.4282 0.08097 H +1 96.6 -0.3521 14.4533 0.081 H +1 96.7 -0.3521 14.4785 0.08103 H +1 96.8 -0.3521 14.5038 0.08106 H +1 96.9 -0.3521 14.5292 0.08109 H +1 97 -0.3521 14.5547 0.08112 H +1 97.1 -0.3521 14.5802 0.08116 H +1 97.2 -0.3521 14.6058 0.08119 H +1 97.3 -0.3521 14.6316 0.08122 H +1 97.4 -0.3521 14.6574 0.08125 H +1 97.5 -0.3521 14.6832 0.08129 H +1 97.6 -0.3521 14.7092 0.08132 H +1 97.7 -0.3521 14.7353 0.08136 H +1 97.8 -0.3521 14.7614 0.08139 H +1 97.9 -0.3521 14.7877 0.08143 H +1 98 -0.3521 14.814 0.08146 H +1 98.1 -0.3521 14.8404 0.0815 H +1 98.2 -0.3521 14.8669 0.08154 H +1 98.3 -0.3521 14.8934 0.08157 H +1 98.4 -0.3521 14.9201 0.08161 H +1 98.5 -0.3521 14.9468 0.08165 H +1 98.6 -0.3521 14.9736 0.08169 H +1 98.7 -0.3521 15.0005 0.08173 H +1 98.8 -0.3521 15.0275 0.08177 H +1 98.9 -0.3521 15.0546 0.08181 H +1 99 -0.3521 15.0818 0.08185 H +1 99.1 -0.3521 15.109 0.08189 H +1 99.2 -0.3521 15.1363 0.08194 H +1 99.3 -0.3521 15.1637 0.08198 H +1 99.4 -0.3521 15.1912 0.08202 H +1 99.5 -0.3521 15.2187 0.08206 H +1 99.6 -0.3521 15.2463 0.08211 H +1 99.7 -0.3521 15.274 0.08215 H +1 99.8 -0.3521 15.3018 0.0822 H +1 99.9 -0.3521 15.3297 0.08224 H +1 100 -0.3521 15.3576 0.08229 H +1 100.1 -0.3521 15.3856 0.08233 H +1 100.2 -0.3521 15.4137 0.08238 H +1 100.3 -0.3521 15.4419 0.08243 H +1 100.4 -0.3521 15.4701 0.08247 H +1 100.5 -0.3521 15.4985 0.08252 H +1 100.6 -0.3521 15.5268 0.08257 H +1 100.7 -0.3521 15.5553 0.08262 H +1 100.8 -0.3521 15.5838 0.08267 H +1 100.9 -0.3521 15.6125 0.08272 H +1 101 -0.3521 15.6412 0.08277 H +1 101.1 -0.3521 15.6699 0.08281 H +1 101.2 -0.3521 15.6987 0.08287 H +1 101.3 -0.3521 15.7276 0.08292 H +1 101.4 -0.3521 15.7566 0.08297 H +1 101.5 -0.3521 15.7857 0.08302 H +1 101.6 -0.3521 15.8148 0.08307 H +1 101.7 -0.3521 15.844 0.08312 H +1 101.8 -0.3521 15.8732 0.08317 H +1 101.9 -0.3521 15.9026 0.08322 H +1 102 -0.3521 15.932 0.08328 H +1 102.1 -0.3521 15.9615 0.08333 H +1 102.2 -0.3521 15.991 0.08338 H +1 102.3 -0.3521 16.0206 0.08343 H +1 102.4 -0.3521 16.0503 0.08349 H +1 102.5 -0.3521 16.0801 0.08354 H +1 102.6 -0.3521 16.1099 0.08359 H +1 102.7 -0.3521 16.1398 0.08365 H +1 102.8 -0.3521 16.1697 0.0837 H +1 102.9 -0.3521 16.1997 0.08376 H +1 103 -0.3521 16.2298 0.08381 H +1 103.1 -0.3521 16.26 0.08386 H +1 103.2 -0.3521 16.2902 0.08392 H +1 103.3 -0.3521 16.3204 0.08397 H +1 103.4 -0.3521 16.3508 0.08403 H +1 103.5 -0.3521 16.3812 0.08408 H +1 103.6 -0.3521 16.4117 0.08414 H +1 103.7 -0.3521 16.4422 0.08419 H +1 103.8 -0.3521 16.4728 0.08425 H +1 103.9 -0.3521 16.5035 0.08431 H +1 104 -0.3521 16.5342 0.08436 H +1 104.1 -0.3521 16.565 0.08442 H +1 104.2 -0.3521 16.5959 0.08447 H +1 104.3 -0.3521 16.6268 0.08453 H +1 104.4 -0.3521 16.6579 0.08458 H +1 104.5 -0.3521 16.6889 0.08464 H +1 104.6 -0.3521 16.7201 0.0847 H +1 104.7 -0.3521 16.7513 0.08475 H +1 104.8 -0.3521 16.7826 0.08481 H +1 104.9 -0.3521 16.8139 0.08487 H +1 105 -0.3521 16.8454 0.08493 H +1 105.1 -0.3521 16.8769 0.08498 H +1 105.2 -0.3521 16.9084 0.08504 H +1 105.3 -0.3521 16.9401 0.0851 H +1 105.4 -0.3521 16.9718 0.08516 H +1 105.5 -0.3521 17.0036 0.08521 H +1 105.6 -0.3521 17.0355 0.08527 H +1 105.7 -0.3521 17.0674 0.08533 H +1 105.8 -0.3521 17.0995 0.08539 H +1 105.9 -0.3521 17.1316 0.08545 H +1 106 -0.3521 17.1637 0.08551 H +1 106.1 -0.3521 17.196 0.08557 H +1 106.2 -0.3521 17.2283 0.08562 H +1 106.3 -0.3521 17.2607 0.08568 H +1 106.4 -0.3521 17.2931 0.08574 H +1 106.5 -0.3521 17.3256 0.0858 H +1 106.6 -0.3521 17.3582 0.08586 H +1 106.7 -0.3521 17.3909 0.08592 H +1 106.8 -0.3521 17.4237 0.08599 H +1 106.9 -0.3521 17.4565 0.08605 H +1 107 -0.3521 17.4894 0.08611 H +1 107.1 -0.3521 17.5224 0.08617 H +1 107.2 -0.3521 17.5554 0.08623 H +1 107.3 -0.3521 17.5885 0.08629 H +1 107.4 -0.3521 17.6217 0.08635 H +1 107.5 -0.3521 17.655 0.08641 H +1 107.6 -0.3521 17.6884 0.08648 H +1 107.7 -0.3521 17.7218 0.08654 H +1 107.8 -0.3521 17.7553 0.0866 H +1 107.9 -0.3521 17.7889 0.08666 H +1 108 -0.3521 17.8226 0.08673 H +1 108.1 -0.3521 17.8564 0.08679 H +1 108.2 -0.3521 17.8903 0.08685 H +1 108.3 -0.3521 17.9242 0.08691 H +1 108.4 -0.3521 17.9583 0.08698 H +1 108.5 -0.3521 17.9924 0.08704 H +1 108.6 -0.3521 18.0267 0.0871 H +1 108.7 -0.3521 18.061 0.08717 H +1 108.8 -0.3521 18.0954 0.08723 H +1 108.9 -0.3521 18.1299 0.0873 H +1 109 -0.3521 18.1645 0.08736 H +1 109.1 -0.3521 18.1992 0.08742 H +1 109.2 -0.3521 18.234 0.08749 H +1 109.3 -0.3521 18.2689 0.08755 H +1 109.4 -0.3521 18.3039 0.08762 H +1 109.5 -0.3521 18.339 0.08768 H +1 109.6 -0.3521 18.3742 0.08774 H +1 109.7 -0.3521 18.4094 0.08781 H +1 109.8 -0.3521 18.4448 0.08787 H +1 109.9 -0.3521 18.4802 0.08794 H +1 110 -0.3521 18.5158 0.088 H +1 110.1 -0.3521 18.5514 0.08806 H +1 110.2 -0.3521 18.5871 0.08813 H +1 110.3 -0.3521 18.6229 0.08819 H +1 110.4 -0.3521 18.6588 0.08826 H +1 110.5 -0.3521 18.6948 0.08832 H +1 110.6 -0.3521 18.7308 0.08838 H +1 110.7 -0.3521 18.767 0.08845 H +1 110.8 -0.3521 18.8032 0.08851 H +1 110.9 -0.3521 18.8395 0.08858 H +1 111 -0.3521 18.8759 0.08864 H +1 111.1 -0.3521 18.9123 0.08871 H +1 111.2 -0.3521 18.9489 0.08877 H +1 111.3 -0.3521 18.9855 0.08883 H +1 111.4 -0.3521 19.0222 0.0889 H +1 111.5 -0.3521 19.059 0.08896 H +1 111.6 -0.3521 19.0958 0.08903 H +1 111.7 -0.3521 19.1327 0.08909 H +1 111.8 -0.3521 19.1697 0.08915 H +1 111.9 -0.3521 19.2067 0.08922 H +1 112 -0.3521 19.2439 0.08928 H +1 112.1 -0.3521 19.281 0.08934 H +1 112.2 -0.3521 19.3183 0.08941 H +1 112.3 -0.3521 19.3556 0.08947 H +1 112.4 -0.3521 19.393 0.08953 H +1 112.5 -0.3521 19.4304 0.0896 H +1 112.6 -0.3521 19.4679 0.08966 H +1 112.7 -0.3521 19.5055 0.08972 H +1 112.8 -0.3521 19.5431 0.08979 H +1 112.9 -0.3521 19.5807 0.08985 H +1 113 -0.3521 19.6185 0.08991 H +1 113.1 -0.3521 19.6563 0.08997 H +1 113.2 -0.3521 19.6941 0.09004 H +1 113.3 -0.3521 19.7321 0.0901 H +1 113.4 -0.3521 19.77 0.09016 H +1 113.5 -0.3521 19.8081 0.09022 H +1 113.6 -0.3521 19.8461 0.09029 H +1 113.7 -0.3521 19.8843 0.09035 H +1 113.8 -0.3521 19.9225 0.09041 H +1 113.9 -0.3521 19.9607 0.09047 H +1 114 -0.3521 19.999 0.09054 H +1 114.1 -0.3521 20.0373 0.0906 H +1 114.2 -0.3521 20.0757 0.09066 H +1 114.3 -0.3521 20.1142 0.09072 H +1 114.4 -0.3521 20.1527 0.09079 H +1 114.5 -0.3521 20.1912 0.09085 H +1 114.6 -0.3521 20.2298 0.09091 H +1 114.7 -0.3521 20.2684 0.09097 H +1 114.8 -0.3521 20.3071 0.09103 H +1 114.9 -0.3521 20.3458 0.0911 H +1 115 -0.3521 20.3846 0.09116 H +1 115.1 -0.3521 20.4233 0.09122 H +1 115.2 -0.3521 20.4622 0.09128 H +1 115.3 -0.3521 20.501 0.09134 H +1 115.4 -0.3521 20.54 0.0914 H +1 115.5 -0.3521 20.5789 0.09147 H +1 115.6 -0.3521 20.6179 0.09153 H +1 115.7 -0.3521 20.6569 0.09159 H +1 115.8 -0.3521 20.6959 0.09165 H +1 115.9 -0.3521 20.735 0.09171 H +1 116 -0.3521 20.7741 0.09177 H +1 116.1 -0.3521 20.8132 0.09183 H +1 116.2 -0.3521 20.8524 0.0919 H +1 116.3 -0.3521 20.8916 0.09196 H +1 116.4 -0.3521 20.9308 0.09202 H +1 116.5 -0.3521 20.97 0.09208 H +1 116.6 -0.3521 21.0093 0.09214 H +1 116.7 -0.3521 21.0486 0.0922 H +1 116.8 -0.3521 21.0879 0.09227 H +1 116.9 -0.3521 21.1272 0.09233 H +1 117 -0.3521 21.1666 0.09239 H +1 117.1 -0.3521 21.2059 0.09245 H +1 117.2 -0.3521 21.2453 0.09251 H +1 117.3 -0.3521 21.2847 0.09257 H +1 117.4 -0.3521 21.3242 0.09263 H +1 117.5 -0.3521 21.3636 0.0927 H +1 117.6 -0.3521 21.4031 0.09276 H +1 117.7 -0.3521 21.4426 0.09282 H +1 117.8 -0.3521 21.482 0.09288 H +1 117.9 -0.3521 21.5215 0.09294 H +1 118 -0.3521 21.5611 0.093 H +1 118.1 -0.3521 21.6006 0.09307 H +1 118.2 -0.3521 21.6401 0.09313 H +1 118.3 -0.3521 21.6797 0.09319 H +1 118.4 -0.3521 21.7193 0.09325 H +1 118.5 -0.3521 21.7588 0.09331 H +1 118.6 -0.3521 21.7984 0.09338 H +1 118.7 -0.3521 21.838 0.09344 H +1 118.8 -0.3521 21.8776 0.0935 H +1 118.9 -0.3521 21.9172 0.09356 H +1 119 -0.3521 21.9568 0.09362 H +1 119.1 -0.3521 21.9964 0.09368 H +1 119.2 -0.3521 22.036 0.09375 H +1 119.3 -0.3521 22.0757 0.09381 H +1 119.4 -0.3521 22.1153 0.09387 H +1 119.5 -0.3521 22.1549 0.09393 H +1 119.6 -0.3521 22.1945 0.09399 H +1 119.7 -0.3521 22.2341 0.09406 H +1 119.8 -0.3521 22.2738 0.09412 H +1 119.9 -0.3521 22.3134 0.09418 H +1 120 -0.3521 22.353 0.09424 H +2 65 -0.3833 7.2402 0.09113 H +2 65.1 -0.3833 7.2627 0.09112 H +2 65.2 -0.3833 7.2852 0.09111 H +2 65.3 -0.3833 7.3076 0.0911 H +2 65.4 -0.3833 7.33 0.09109 H +2 65.5 -0.3833 7.3523 0.09109 H +2 65.6 -0.3833 7.3745 0.09108 H +2 65.7 -0.3833 7.3967 0.09107 H +2 65.8 -0.3833 7.4189 0.09106 H +2 65.9 -0.3833 7.441 0.09105 H +2 66 -0.3833 7.463 0.09104 H +2 66.1 -0.3833 7.485 0.09103 H +2 66.2 -0.3833 7.5069 0.09102 H +2 66.3 -0.3833 7.5288 0.09101 H +2 66.4 -0.3833 7.5507 0.091 H +2 66.5 -0.3833 7.5724 0.09099 H +2 66.6 -0.3833 7.5942 0.09098 H +2 66.7 -0.3833 7.6158 0.09097 H +2 66.8 -0.3833 7.6375 0.09096 H +2 66.9 -0.3833 7.659 0.09095 H +2 67 -0.3833 7.6806 0.09094 H +2 67.1 -0.3833 7.702 0.09093 H +2 67.2 -0.3833 7.7234 0.09091 H +2 67.3 -0.3833 7.7448 0.0909 H +2 67.4 -0.3833 7.7661 0.09089 H +2 67.5 -0.3833 7.7874 0.09088 H +2 67.6 -0.3833 7.8086 0.09087 H +2 67.7 -0.3833 7.8298 0.09086 H +2 67.8 -0.3833 7.8509 0.09085 H +2 67.9 -0.3833 7.872 0.09084 H +2 68 -0.3833 7.893 0.09083 H +2 68.1 -0.3833 7.914 0.09082 H +2 68.2 -0.3833 7.935 0.0908 H +2 68.3 -0.3833 7.9559 0.09079 H +2 68.4 -0.3833 7.9768 0.09078 H +2 68.5 -0.3833 7.9976 0.09077 H +2 68.6 -0.3833 8.0184 0.09076 H +2 68.7 -0.3833 8.0392 0.09075 H +2 68.8 -0.3833 8.0599 0.09074 H +2 68.9 -0.3833 8.0806 0.09072 H +2 69 -0.3833 8.1012 0.09071 H +2 69.1 -0.3833 8.1218 0.0907 H +2 69.2 -0.3833 8.1424 0.09069 H +2 69.3 -0.3833 8.163 0.09068 H +2 69.4 -0.3833 8.1835 0.09067 H +2 69.5 -0.3833 8.2039 0.09065 H +2 69.6 -0.3833 8.2244 0.09064 H +2 69.7 -0.3833 8.2448 0.09063 H +2 69.8 -0.3833 8.2651 0.09062 H +2 69.9 -0.3833 8.2855 0.09061 H +2 70 -0.3833 8.3058 0.09059 H +2 70.1 -0.3833 8.3261 0.09058 H +2 70.2 -0.3833 8.3464 0.09057 H +2 70.3 -0.3833 8.3666 0.09056 H +2 70.4 -0.3833 8.3869 0.09055 H +2 70.5 -0.3833 8.4071 0.09053 H +2 70.6 -0.3833 8.4273 0.09052 H +2 70.7 -0.3833 8.4474 0.09051 H +2 70.8 -0.3833 8.4676 0.0905 H +2 70.9 -0.3833 8.4877 0.09048 H +2 71 -0.3833 8.5078 0.09047 H +2 71.1 -0.3833 8.5278 0.09046 H +2 71.2 -0.3833 8.5479 0.09045 H +2 71.3 -0.3833 8.5679 0.09043 H +2 71.4 -0.3833 8.5879 0.09042 H +2 71.5 -0.3833 8.6078 0.09041 H +2 71.6 -0.3833 8.6277 0.0904 H +2 71.7 -0.3833 8.6476 0.09039 H +2 71.8 -0.3833 8.6674 0.09037 H +2 71.9 -0.3833 8.6872 0.09036 H +2 72 -0.3833 8.707 0.09035 H +2 72.1 -0.3833 8.7267 0.09034 H +2 72.2 -0.3833 8.7464 0.09032 H +2 72.3 -0.3833 8.7661 0.09031 H +2 72.4 -0.3833 8.7857 0.0903 H +2 72.5 -0.3833 8.8053 0.09028 H +2 72.6 -0.3833 8.8248 0.09027 H +2 72.7 -0.3833 8.8443 0.09026 H +2 72.8 -0.3833 8.8638 0.09025 H +2 72.9 -0.3833 8.8831 0.09023 H +2 73 -0.3833 8.9025 0.09022 H +2 73.1 -0.3833 8.9217 0.09021 H +2 73.2 -0.3833 8.941 0.0902 H +2 73.3 -0.3833 8.9601 0.09018 H +2 73.4 -0.3833 8.9792 0.09017 H +2 73.5 -0.3833 8.9983 0.09016 H +2 73.6 -0.3833 9.0173 0.09014 H +2 73.7 -0.3833 9.0363 0.09013 H +2 73.8 -0.3833 9.0552 0.09012 H +2 73.9 -0.3833 9.074 0.09011 H +2 74 -0.3833 9.0928 0.09009 H +2 74.1 -0.3833 9.1116 0.09008 H +2 74.2 -0.3833 9.1303 0.09007 H +2 74.3 -0.3833 9.149 0.09005 H +2 74.4 -0.3833 9.1676 0.09004 H +2 74.5 -0.3833 9.1862 0.09003 H +2 74.6 -0.3833 9.2048 0.09001 H +2 74.7 -0.3833 9.2233 0.09 H +2 74.8 -0.3833 9.2418 0.08999 H +2 74.9 -0.3833 9.2602 0.08997 H +2 75 -0.3833 9.2786 0.08996 H +2 75.1 -0.3833 9.297 0.08995 H +2 75.2 -0.3833 9.3154 0.08993 H +2 75.3 -0.3833 9.3337 0.08992 H +2 75.4 -0.3833 9.352 0.08991 H +2 75.5 -0.3833 9.3703 0.08989 H +2 75.6 -0.3833 9.3886 0.08988 H +2 75.7 -0.3833 9.4069 0.08987 H +2 75.8 -0.3833 9.4252 0.08985 H +2 75.9 -0.3833 9.4435 0.08984 H +2 76 -0.3833 9.4617 0.08983 H +2 76.1 -0.3833 9.48 0.08981 H +2 76.2 -0.3833 9.4983 0.0898 H +2 76.3 -0.3833 9.5166 0.08979 H +2 76.4 -0.3833 9.535 0.08977 H +2 76.5 -0.3833 9.5533 0.08976 H +2 76.6 -0.3833 9.5717 0.08975 H +2 76.7 -0.3833 9.5901 0.08973 H +2 76.8 -0.3833 9.6086 0.08972 H +2 76.9 -0.3833 9.6271 0.08971 H +2 77 -0.3833 9.6456 0.08969 H +2 77.1 -0.3833 9.6642 0.08968 H +2 77.2 -0.3833 9.6828 0.08966 H +2 77.3 -0.3833 9.7015 0.08965 H +2 77.4 -0.3833 9.7202 0.08964 H +2 77.5 -0.3833 9.739 0.08963 H +2 77.6 -0.3833 9.7578 0.08961 H +2 77.7 -0.3833 9.7767 0.0896 H +2 77.8 -0.3833 9.7957 0.08959 H +2 77.9 -0.3833 9.8147 0.08957 H +2 78 -0.3833 9.8338 0.08956 H +2 78.1 -0.3833 9.853 0.08955 H +2 78.2 -0.3833 9.8722 0.08953 H +2 78.3 -0.3833 9.8915 0.08952 H +2 78.4 -0.3833 9.9109 0.08951 H +2 78.5 -0.3833 9.9303 0.0895 H +2 78.6 -0.3833 9.9499 0.08948 H +2 78.7 -0.3833 9.9695 0.08947 H +2 78.8 -0.3833 9.9892 0.08946 H +2 78.9 -0.3833 10.009 0.08945 H +2 79 -0.3833 10.0289 0.08943 H +2 79.1 -0.3833 10.0489 0.08942 H +2 79.2 -0.3833 10.069 0.08941 H +2 79.3 -0.3833 10.0891 0.0894 H +2 79.4 -0.3833 10.1094 0.08939 H +2 79.5 -0.3833 10.1298 0.08937 H +2 79.6 -0.3833 10.1503 0.08936 H +2 79.7 -0.3833 10.1709 0.08935 H +2 79.8 -0.3833 10.1916 0.08934 H +2 79.9 -0.3833 10.2123 0.08933 H +2 80 -0.3833 10.2332 0.08932 H +2 80.1 -0.3833 10.2542 0.0893 H +2 80.2 -0.3833 10.2753 0.08929 H +2 80.3 -0.3833 10.2965 0.08928 H +2 80.4 -0.3833 10.3178 0.08927 H +2 80.5 -0.3833 10.3393 0.08926 H +2 80.6 -0.3833 10.3608 0.08925 H +2 80.7 -0.3833 10.3824 0.08924 H +2 80.8 -0.3833 10.4041 0.08923 H +2 80.9 -0.3833 10.4258 0.08922 H +2 81 -0.3833 10.4477 0.08921 H +2 81.1 -0.3833 10.4697 0.0892 H +2 81.2 -0.3833 10.4918 0.08919 H +2 81.3 -0.3833 10.514 0.08918 H +2 81.4 -0.3833 10.5363 0.08917 H +2 81.5 -0.3833 10.5586 0.08916 H +2 81.6 -0.3833 10.5811 0.08915 H +2 81.7 -0.3833 10.6037 0.08915 H +2 81.8 -0.3833 10.6263 0.08914 H +2 81.9 -0.3833 10.6491 0.08913 H +2 82 -0.3833 10.6719 0.08912 H +2 82.1 -0.3833 10.6948 0.08911 H +2 82.2 -0.3833 10.7178 0.0891 H +2 82.3 -0.3833 10.741 0.0891 H +2 82.4 -0.3833 10.7641 0.08909 H +2 82.5 -0.3833 10.7874 0.08908 H +2 82.6 -0.3833 10.8108 0.08907 H +2 82.7 -0.3833 10.8343 0.08907 H +2 82.8 -0.3833 10.8578 0.08906 H +2 82.9 -0.3833 10.8814 0.08905 H +2 83 -0.3833 10.9051 0.08905 H +2 83.1 -0.3833 10.9289 0.08904 H +2 83.2 -0.3833 10.9527 0.08903 H +2 83.3 -0.3833 10.9767 0.08903 H +2 83.4 -0.3833 11.0007 0.08902 H +2 83.5 -0.3833 11.0248 0.08902 H +2 83.6 -0.3833 11.0489 0.08901 H +2 83.7 -0.3833 11.0731 0.08901 H +2 83.8 -0.3833 11.0974 0.089 H +2 83.9 -0.3833 11.1218 0.089 H +2 84 -0.3833 11.1462 0.08899 H +2 84.1 -0.3833 11.1707 0.08899 H +2 84.2 -0.3833 11.1952 0.08899 H +2 84.3 -0.3833 11.2198 0.08898 H +2 84.4 -0.3833 11.2444 0.08898 H +2 84.5 -0.3833 11.2691 0.08897 H +2 84.6 -0.3833 11.2939 0.08897 H +2 84.7 -0.3833 11.3187 0.08897 H +2 84.8 -0.3833 11.3435 0.08897 H +2 84.9 -0.3833 11.3684 0.08896 H +2 85 -0.3833 11.3934 0.08896 H +2 85.1 -0.3833 11.4183 0.08896 H +2 85.2 -0.3833 11.4434 0.08896 H +2 85.3 -0.3833 11.4684 0.08895 H +2 85.4 -0.3833 11.4935 0.08895 H +2 85.5 -0.3833 11.5186 0.08895 H +2 85.6 -0.3833 11.5437 0.08895 H +2 85.7 -0.3833 11.5689 0.08895 H +2 85.8 -0.3833 11.594 0.08895 H +2 85.9 -0.3833 11.6192 0.08895 H +2 86 -0.3833 11.6444 0.08895 H +2 86.1 -0.3833 11.6696 0.08895 H +2 86.2 -0.3833 11.6948 0.08895 H +2 86.3 -0.3833 11.7201 0.08895 H +2 86.4 -0.3833 11.7453 0.08895 H +2 86.5 -0.3833 11.7705 0.08895 H +2 86.6 -0.3833 11.7957 0.08895 H +2 86.7 -0.3833 11.8209 0.08895 H +2 86.8 -0.3833 11.8461 0.08895 H +2 86.9 -0.3833 11.8713 0.08896 H +2 87 -0.3833 11.8965 0.08896 H +2 87.1 -0.3833 11.9217 0.08896 H +2 87.2 -0.3833 11.9468 0.08896 H +2 87.3 -0.3833 11.972 0.08896 H +2 87.4 -0.3833 11.9971 0.08897 H +2 87.5 -0.3833 12.0223 0.08897 H +2 87.6 -0.3833 12.0474 0.08897 H +2 87.7 -0.3833 12.0725 0.08898 H +2 87.8 -0.3833 12.0976 0.08898 H +2 87.9 -0.3833 12.1227 0.08898 H +2 88 -0.3833 12.1478 0.08899 H +2 88.1 -0.3833 12.1728 0.08899 H +2 88.2 -0.3833 12.1978 0.089 H +2 88.3 -0.3833 12.2229 0.089 H +2 88.4 -0.3833 12.2479 0.08901 H +2 88.5 -0.3833 12.2729 0.08901 H +2 88.6 -0.3833 12.2978 0.08902 H +2 88.7 -0.3833 12.3228 0.08902 H +2 88.8 -0.3833 12.3477 0.08903 H +2 88.9 -0.3833 12.3727 0.08903 H +2 89 -0.3833 12.3976 0.08904 H +2 89.1 -0.3833 12.4225 0.08904 H +2 89.2 -0.3833 12.4474 0.08905 H +2 89.3 -0.3833 12.4723 0.08906 H +2 89.4 -0.3833 12.4971 0.08906 H +2 89.5 -0.3833 12.522 0.08907 H +2 89.6 -0.3833 12.5468 0.08908 H +2 89.7 -0.3833 12.5717 0.08909 H +2 89.8 -0.3833 12.5965 0.08909 H +2 89.9 -0.3833 12.6213 0.0891 H +2 90 -0.3833 12.6461 0.08911 H +2 90.1 -0.3833 12.6709 0.08912 H +2 90.2 -0.3833 12.6957 0.08912 H +2 90.3 -0.3833 12.7205 0.08913 H +2 90.4 -0.3833 12.7453 0.08914 H +2 90.5 -0.3833 12.77 0.08915 H +2 90.6 -0.3833 12.7948 0.08916 H +2 90.7 -0.3833 12.8196 0.08917 H +2 90.8 -0.3833 12.8443 0.08918 H +2 90.9 -0.3833 12.8691 0.08919 H +2 91 -0.3833 12.8939 0.0892 H +2 91.1 -0.3833 12.9186 0.08921 H +2 91.2 -0.3833 12.9434 0.08922 H +2 91.3 -0.3833 12.9681 0.08923 H +2 91.4 -0.3833 12.9929 0.08924 H +2 91.5 -0.3833 13.0177 0.08925 H +2 91.6 -0.3833 13.0424 0.08926 H +2 91.7 -0.3833 13.0672 0.08927 H +2 91.8 -0.3833 13.092 0.08928 H +2 91.9 -0.3833 13.1167 0.0893 H +2 92 -0.3833 13.1415 0.08931 H +2 92.1 -0.3833 13.1663 0.08932 H +2 92.2 -0.3833 13.1911 0.08933 H +2 92.3 -0.3833 13.2158 0.08934 H +2 92.4 -0.3833 13.2406 0.08936 H +2 92.5 -0.3833 13.2654 0.08937 H +2 92.6 -0.3833 13.2902 0.08938 H +2 92.7 -0.3833 13.3151 0.0894 H +2 92.8 -0.3833 13.3399 0.08941 H +2 92.9 -0.3833 13.3647 0.08942 H +2 93 -0.3833 13.3896 0.08944 H +2 93.1 -0.3833 13.4145 0.08945 H +2 93.2 -0.3833 13.4394 0.08947 H +2 93.3 -0.3833 13.4643 0.08948 H +2 93.4 -0.3833 13.4892 0.08949 H +2 93.5 -0.3833 13.5142 0.08951 H +2 93.6 -0.3833 13.5391 0.08952 H +2 93.7 -0.3833 13.5641 0.08954 H +2 93.8 -0.3833 13.5892 0.08955 H +2 93.9 -0.3833 13.6142 0.08957 H +2 94 -0.3833 13.6393 0.08959 H +2 94.1 -0.3833 13.6644 0.0896 H +2 94.2 -0.3833 13.6895 0.08962 H +2 94.3 -0.3833 13.7146 0.08963 H +2 94.4 -0.3833 13.7398 0.08965 H +2 94.5 -0.3833 13.765 0.08967 H +2 94.6 -0.3833 13.7902 0.08968 H +2 94.7 -0.3833 13.8155 0.0897 H +2 94.8 -0.3833 13.8408 0.08972 H +2 94.9 -0.3833 13.8661 0.08974 H +2 95 -0.3833 13.8914 0.08975 H +2 95.1 -0.3833 13.9168 0.08977 H +2 95.2 -0.3833 13.9422 0.08979 H +2 95.3 -0.3833 13.9676 0.08981 H +2 95.4 -0.3833 13.9931 0.08983 H +2 95.5 -0.3833 14.0186 0.08984 H +2 95.6 -0.3833 14.0441 0.08986 H +2 95.7 -0.3833 14.0697 0.08988 H +2 95.8 -0.3833 14.0953 0.0899 H +2 95.9 -0.3833 14.1209 0.08992 H +2 96 -0.3833 14.1466 0.08994 H +2 96.1 -0.3833 14.1724 0.08996 H +2 96.2 -0.3833 14.1981 0.08998 H +2 96.3 -0.3833 14.2239 0.09 H +2 96.4 -0.3833 14.2498 0.09002 H +2 96.5 -0.3833 14.2757 0.09004 H +2 96.6 -0.3833 14.3016 0.09006 H +2 96.7 -0.3833 14.3276 0.09008 H +2 96.8 -0.3833 14.3537 0.0901 H +2 96.9 -0.3833 14.3798 0.09012 H +2 97 -0.3833 14.4059 0.09015 H +2 97.1 -0.3833 14.4321 0.09017 H +2 97.2 -0.3833 14.4584 0.09019 H +2 97.3 -0.3833 14.4848 0.09021 H +2 97.4 -0.3833 14.5112 0.09023 H +2 97.5 -0.3833 14.5376 0.09026 H +2 97.6 -0.3833 14.5642 0.09028 H +2 97.7 -0.3833 14.5908 0.0903 H +2 97.8 -0.3833 14.6174 0.09033 H +2 97.9 -0.3833 14.6442 0.09035 H +2 98 -0.3833 14.671 0.09037 H +2 98.1 -0.3833 14.6979 0.0904 H +2 98.2 -0.3833 14.7248 0.09042 H +2 98.3 -0.3833 14.7519 0.09044 H +2 98.4 -0.3833 14.779 0.09047 H +2 98.5 -0.3833 14.8062 0.09049 H +2 98.6 -0.3833 14.8334 0.09052 H +2 98.7 -0.3833 14.8608 0.09054 H +2 98.8 -0.3833 14.8882 0.09057 H +2 98.9 -0.3833 14.9157 0.09059 H +2 99 -0.3833 14.9434 0.09062 H +2 99.1 -0.3833 14.9711 0.09064 H +2 99.2 -0.3833 14.9989 0.09067 H +2 99.3 -0.3833 15.0267 0.09069 H +2 99.4 -0.3833 15.0547 0.09072 H +2 99.5 -0.3833 15.0828 0.09075 H +2 99.6 -0.3833 15.1109 0.09077 H +2 99.7 -0.3833 15.1392 0.0908 H +2 99.8 -0.3833 15.1676 0.09083 H +2 99.9 -0.3833 15.196 0.09085 H +2 100 -0.3833 15.2246 0.09088 H +2 100.1 -0.3833 15.2532 0.09091 H +2 100.2 -0.3833 15.2819 0.09093 H +2 100.3 -0.3833 15.3108 0.09096 H +2 100.4 -0.3833 15.3397 0.09099 H +2 100.5 -0.3833 15.3687 0.09102 H +2 100.6 -0.3833 15.3979 0.09105 H +2 100.7 -0.3833 15.4271 0.09107 H +2 100.8 -0.3833 15.4564 0.0911 H +2 100.9 -0.3833 15.4858 0.09113 H +2 101 -0.3833 15.5154 0.09116 H +2 101.1 -0.3833 15.545 0.09119 H +2 101.2 -0.3833 15.5747 0.09122 H +2 101.3 -0.3833 15.6046 0.09125 H +2 101.4 -0.3833 15.6345 0.09128 H +2 101.5 -0.3833 15.6646 0.09131 H +2 101.6 -0.3833 15.6947 0.09133 H +2 101.7 -0.3833 15.725 0.09136 H +2 101.8 -0.3833 15.7553 0.09139 H +2 101.9 -0.3833 15.7858 0.09142 H +2 102 -0.3833 15.8164 0.09146 H +2 102.1 -0.3833 15.847 0.09149 H +2 102.2 -0.3833 15.8778 0.09152 H +2 102.3 -0.3833 15.9087 0.09155 H +2 102.4 -0.3833 15.9396 0.09158 H +2 102.5 -0.3833 15.9707 0.09161 H +2 102.6 -0.3833 16.0019 0.09164 H +2 102.7 -0.3833 16.0332 0.09167 H +2 102.8 -0.3833 16.0645 0.0917 H +2 102.9 -0.3833 16.096 0.09173 H +2 103 -0.3833 16.1276 0.09177 H +2 103.1 -0.3833 16.1593 0.0918 H +2 103.2 -0.3833 16.191 0.09183 H +2 103.3 -0.3833 16.2229 0.09186 H +2 103.4 -0.3833 16.2549 0.0919 H +2 103.5 -0.3833 16.287 0.09193 H +2 103.6 -0.3833 16.3191 0.09196 H +2 103.7 -0.3833 16.3514 0.09199 H +2 103.8 -0.3833 16.3837 0.09203 H +2 103.9 -0.3833 16.4162 0.09206 H +2 104 -0.3833 16.4488 0.09209 H +2 104.1 -0.3833 16.4814 0.09213 H +2 104.2 -0.3833 16.5142 0.09216 H +2 104.3 -0.3833 16.547 0.09219 H +2 104.4 -0.3833 16.58 0.09223 H +2 104.5 -0.3833 16.6131 0.09226 H +2 104.6 -0.3833 16.6462 0.09229 H +2 104.7 -0.3833 16.6795 0.09233 H +2 104.8 -0.3833 16.7129 0.09236 H +2 104.9 -0.3833 16.7464 0.0924 H +2 105 -0.3833 16.78 0.09243 H +2 105.1 -0.3833 16.8137 0.09247 H +2 105.2 -0.3833 16.8475 0.0925 H +2 105.3 -0.3833 16.8814 0.09254 H +2 105.4 -0.3833 16.9154 0.09257 H +2 105.5 -0.3833 16.9496 0.09261 H +2 105.6 -0.3833 16.9838 0.09264 H +2 105.7 -0.3833 17.0182 0.09268 H +2 105.8 -0.3833 17.0527 0.09271 H +2 105.9 -0.3833 17.0873 0.09275 H +2 106 -0.3833 17.122 0.09278 H +2 106.1 -0.3833 17.1569 0.09282 H +2 106.2 -0.3833 17.1918 0.09286 H +2 106.3 -0.3833 17.2269 0.09289 H +2 106.4 -0.3833 17.262 0.09293 H +2 106.5 -0.3833 17.2973 0.09296 H +2 106.6 -0.3833 17.3327 0.093 H +2 106.7 -0.3833 17.3683 0.09304 H +2 106.8 -0.3833 17.4039 0.09307 H +2 106.9 -0.3833 17.4397 0.09311 H +2 107 -0.3833 17.4755 0.09315 H +2 107.1 -0.3833 17.5115 0.09318 H +2 107.2 -0.3833 17.5476 0.09322 H +2 107.3 -0.3833 17.5839 0.09326 H +2 107.4 -0.3833 17.6202 0.09329 H +2 107.5 -0.3833 17.6567 0.09333 H +2 107.6 -0.3833 17.6932 0.09337 H +2 107.7 -0.3833 17.7299 0.09341 H +2 107.8 -0.3833 17.7668 0.09344 H +2 107.9 -0.3833 17.8037 0.09348 H +2 108 -0.3833 17.8407 0.09352 H +2 108.1 -0.3833 17.8779 0.09356 H +2 108.2 -0.3833 17.9152 0.09359 H +2 108.3 -0.3833 17.9526 0.09363 H +2 108.4 -0.3833 17.9901 0.09367 H +2 108.5 -0.3833 18.0277 0.09371 H +2 108.6 -0.3833 18.0654 0.09375 H +2 108.7 -0.3833 18.1033 0.09378 H +2 108.8 -0.3833 18.1412 0.09382 H +2 108.9 -0.3833 18.1792 0.09386 H +2 109 -0.3833 18.2174 0.0939 H +2 109.1 -0.3833 18.2556 0.09394 H +2 109.2 -0.3833 18.294 0.09397 H +2 109.3 -0.3833 18.3324 0.09401 H +2 109.4 -0.3833 18.371 0.09405 H +2 109.5 -0.3833 18.4096 0.09409 H +2 109.6 -0.3833 18.4484 0.09413 H +2 109.7 -0.3833 18.4872 0.09417 H +2 109.8 -0.3833 18.5262 0.09421 H +2 109.9 -0.3833 18.5652 0.09424 H +2 110 -0.3833 18.6043 0.09428 H +2 110.1 -0.3833 18.6436 0.09432 H +2 110.2 -0.3833 18.6829 0.09436 H +2 110.3 -0.3833 18.7223 0.0944 H +2 110.4 -0.3833 18.7618 0.09444 H +2 110.5 -0.3833 18.8015 0.09448 H +2 110.6 -0.3833 18.8412 0.09452 H +2 110.7 -0.3833 18.8809 0.09456 H +2 110.8 -0.3833 18.9208 0.0946 H +2 110.9 -0.3833 18.9608 0.09464 H +2 111 -0.3833 19.0009 0.09467 H +2 111.1 -0.3833 19.041 0.09471 H +2 111.2 -0.3833 19.0812 0.09475 H +2 111.3 -0.3833 19.1215 0.09479 H +2 111.4 -0.3833 19.1619 0.09483 H +2 111.5 -0.3833 19.2024 0.09487 H +2 111.6 -0.3833 19.243 0.09491 H +2 111.7 -0.3833 19.2836 0.09495 H +2 111.8 -0.3833 19.3243 0.09499 H +2 111.9 -0.3833 19.3651 0.09503 H +2 112 -0.3833 19.406 0.09507 H +2 112.1 -0.3833 19.447 0.09511 H +2 112.2 -0.3833 19.488 0.09515 H +2 112.3 -0.3833 19.5291 0.09519 H +2 112.4 -0.3833 19.5703 0.09523 H +2 112.5 -0.3833 19.6116 0.09527 H +2 112.6 -0.3833 19.6529 0.09531 H +2 112.7 -0.3833 19.6943 0.09534 H +2 112.8 -0.3833 19.7358 0.09538 H +2 112.9 -0.3833 19.7774 0.09542 H +2 113 -0.3833 19.819 0.09546 H +2 113.1 -0.3833 19.8607 0.0955 H +2 113.2 -0.3833 19.9024 0.09554 H +2 113.3 -0.3833 19.9442 0.09558 H +2 113.4 -0.3833 19.9861 0.09562 H +2 113.5 -0.3833 20.028 0.09566 H +2 113.6 -0.3833 20.07 0.0957 H +2 113.7 -0.3833 20.112 0.09574 H +2 113.8 -0.3833 20.1541 0.09578 H +2 113.9 -0.3833 20.1963 0.09582 H +2 114 -0.3833 20.2385 0.09586 H +2 114.1 -0.3833 20.2807 0.0959 H +2 114.2 -0.3833 20.323 0.09594 H +2 114.3 -0.3833 20.3653 0.09598 H +2 114.4 -0.3833 20.4077 0.09602 H +2 114.5 -0.3833 20.4502 0.09606 H +2 114.6 -0.3833 20.4926 0.0961 H +2 114.7 -0.3833 20.5351 0.09614 H +2 114.8 -0.3833 20.5777 0.09618 H +2 114.9 -0.3833 20.6203 0.09622 H +2 115 -0.3833 20.6629 0.09626 H +2 115.1 -0.3833 20.7056 0.0963 H +2 115.2 -0.3833 20.7483 0.09634 H +2 115.3 -0.3833 20.791 0.09638 H +2 115.4 -0.3833 20.8338 0.09642 H +2 115.5 -0.3833 20.8766 0.09646 H +2 115.6 -0.3833 20.9194 0.0965 H +2 115.7 -0.3833 20.9622 0.09654 H +2 115.8 -0.3833 21.0051 0.09658 H +2 115.9 -0.3833 21.048 0.09662 H +2 116 -0.3833 21.0909 0.09666 H +2 116.1 -0.3833 21.1339 0.0967 H +2 116.2 -0.3833 21.1769 0.09674 H +2 116.3 -0.3833 21.2199 0.09678 H +2 116.4 -0.3833 21.2629 0.09682 H +2 116.5 -0.3833 21.3059 0.09686 H +2 116.6 -0.3833 21.3489 0.09691 H +2 116.7 -0.3833 21.392 0.09695 H +2 116.8 -0.3833 21.4351 0.09699 H +2 116.9 -0.3833 21.4782 0.09703 H +2 117 -0.3833 21.5213 0.09707 H +2 117.1 -0.3833 21.5644 0.09711 H +2 117.2 -0.3833 21.6075 0.09715 H +2 117.3 -0.3833 21.6507 0.09719 H +2 117.4 -0.3833 21.6938 0.09723 H +2 117.5 -0.3833 21.737 0.09727 H +2 117.6 -0.3833 21.7802 0.09731 H +2 117.7 -0.3833 21.8233 0.09735 H +2 117.8 -0.3833 21.8665 0.09739 H +2 117.9 -0.3833 21.9097 0.09743 H +2 118 -0.3833 21.9529 0.09747 H +2 118.1 -0.3833 21.9961 0.09751 H +2 118.2 -0.3833 22.0393 0.09755 H +2 118.3 -0.3833 22.0825 0.09759 H +2 118.4 -0.3833 22.1258 0.09763 H +2 118.5 -0.3833 22.169 0.09767 H +2 118.6 -0.3833 22.2122 0.09771 H +2 118.7 -0.3833 22.2554 0.09775 H +2 118.8 -0.3833 22.2986 0.0978 H +2 118.9 -0.3833 22.3419 0.09784 H +2 119 -0.3833 22.3851 0.09788 H +2 119.1 -0.3833 22.4283 0.09792 H +2 119.2 -0.3833 22.4715 0.09796 H +2 119.3 -0.3833 22.5148 0.098 H +2 119.4 -0.3833 22.558 0.09804 H +2 119.5 -0.3833 22.6012 0.09808 H +2 119.6 -0.3833 22.6444 0.09812 H +2 119.7 -0.3833 22.6877 0.09816 H +2 119.8 -0.3833 22.7309 0.0982 H +2 119.9 -0.3833 22.7741 0.09824 H +2 120 -0.3833 22.8173 0.09828 H diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringConfig.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringConfig.java index 80aaad2..c7705ee 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringConfig.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/GrowthMonitoringConfig.java @@ -12,6 +12,7 @@ public class GrowthMonitoringConfig { private String femaleWeightZScoreFile; private String femaleHeightZScoreFile; private String genderNeutralZScoreFile; + private String weightForHeightZScoreFile; private String childTable; public GrowthMonitoringConfig() { @@ -62,6 +63,14 @@ public String getFemaleHeightZScoreFile() { } } + public void setWeightForHeightZScoreFile(String weightForHeightZScoreFile) { + this.weightForHeightZScoreFile = weightForHeightZScoreFile; + } + + public String getWeightForHeightZScoreFile() { + return this.weightForHeightZScoreFile; + } + public void setFemaleHeightZScoreFile(String femaleHeightZScoreFile) { this.femaleHeightZScoreFile = femaleHeightZScoreFile; } From 0aede0973542eacde55223589ab750cd0d4ae8b0 Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 9 Mar 2020 17:09:48 +0300 Subject: [PATCH 07/21] :boom: Parse & save WFH Z-Score chart values in IntentService --- .../repository/WeightForHeightRepository.java | 51 ++++++++++++-- .../intent/WeightForHeightIntentService.java | 68 ++++++++++++++++--- sample/src/main/AndroidManifest.xml | 2 + 3 files changed, 108 insertions(+), 13 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java index 58d7416..2c12c1b 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java @@ -30,8 +30,10 @@ public class WeightForHeightRepository extends BaseRepository { GrowthMonitoringConstants.ColumnHeaders.HEIGHT + ") ON CONFLICT REPLACE)"; private static final String CREATE_INDEX_SEX_QUERY = "CREATE INDEX " + TABLE_NAME + "_" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + "_index ON " + TABLE_NAME + "(" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " COLLATE NOCASE);"; - private static final String CREATE_INDEX_HEIGHT_QUERY = "CREATE INDEX " + TABLE_NAME + "_" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_MONTH + "_index ON " + - TABLE_NAME + "(" + GrowthMonitoringConstants.ColumnHeaders.COLUMN_MONTH + " COLLATE NOCASE);"; + private static final String CREATE_INDEX_HEIGHT_QUERY = "CREATE INDEX " + TABLE_NAME + "_" + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + "_index ON " + + TABLE_NAME + "(" + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " COLLATE NOCASE);"; + + public static final double NO_HEIGHT_DEFAULT = 0.0; public static void createTable(SQLiteDatabase database) { database.execSQL(CREATE_TABLE_QUERY); @@ -51,9 +53,16 @@ public List findZScoreVariables(String gender, double height) { List zScoreVariables = new ArrayList<>(); try { SQLiteDatabase database = getReadableDatabase(); - - String selection = GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? "; - String[] selectionArgs = new String[]{gender, String.valueOf(height)}; + String selection; + String[] selectionArgs; + + if (height == NO_HEIGHT_DEFAULT) { + selection = GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? "; + selectionArgs = new String[]{gender, String.valueOf(height)}; + } else { + selection = GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? "; + selectionArgs = new String[]{gender}; + } cursor = database.query(TABLE_NAME, null, selection + COLLATE_NOCASE, selectionArgs, null, null, null, null); @@ -72,6 +81,38 @@ public List findZScoreVariables(String gender, double height) { return zScoreVariables; } + public boolean isTableEmpty(String tableName) { + Cursor cursor = null; + String query = "SELECT count(1) WHERE NOT EXISTS (SELECT * FROM " + tableName + ");"; + int result = 1; + try { + SQLiteDatabase database = getReadableDatabase(); + cursor = database.rawQuery(query, null); + if (cursor != null && cursor.moveToFirst()) { + while (!cursor.isAfterLast()) { + result = cursor.getInt(cursor.getColumnIndex("count(1)")); + cursor.moveToNext(); + } + } + } catch (Exception ex) { + Timber.e(ex); + } finally { + if (cursor != null) cursor.close(); + } + return result == 1; + } + + public boolean runRawQuery(String query) { + try { + getWritableDatabase().execSQL(query); + return true; + } catch (Exception e) { + Timber.e(e); + } + + return false; + } + private ZScore getZScoreValuesFromCursor(Cursor cursor) { ZScore zScoreValues = new ZScore(); int gender = Integer.parseInt(cursor.getString(cursor.getColumnIndex(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX))); diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java index e1db7eb..7551907 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/WeightForHeightIntentService.java @@ -8,8 +8,16 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.apache.commons.lang3.StringUtils; +import org.smartregister.growthmonitoring.GrowthMonitoringLibrary; +import org.smartregister.growthmonitoring.repository.WeightForHeightRepository; +import org.smartregister.growthmonitoring.util.GrowthMonitoringConstants; import org.smartregister.util.Utils; +import java.util.HashMap; +import java.util.Map; + +import timber.log.Timber; + /** * An {@link IntentService} subclass for handling asynchronous task requests in * a service on a separate handler thread. @@ -19,6 +27,16 @@ public class WeightForHeightIntentService extends IntentService { private static final String ACTION_PARSE_WFH_CSV = "org.smartregister.growthmonitoring.service.intent.action.parse"; + private static final Map CSV_HEADING_COLUMN_MAP; + + static { + CSV_HEADING_COLUMN_MAP = new HashMap<>(); + CSV_HEADING_COLUMN_MAP.put("sex", GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX); + CSV_HEADING_COLUMN_MAP.put("height", GrowthMonitoringConstants.ColumnHeaders.HEIGHT); + CSV_HEADING_COLUMN_MAP.put("l", GrowthMonitoringConstants.ColumnHeaders.COLUMN_L); + CSV_HEADING_COLUMN_MAP.put("m", GrowthMonitoringConstants.ColumnHeaders.COLUMN_M); + CSV_HEADING_COLUMN_MAP.put("s", GrowthMonitoringConstants.ColumnHeaders.COLUMN_S); + } public WeightForHeightIntentService() { super("WeightForHeightIntentService"); @@ -30,7 +48,7 @@ public WeightForHeightIntentService() { * * @see IntentService */ - public static void startActionFoo(Context context) { + public static void startParseWFHZScores(Context context) { Intent intent = new Intent(context, WeightForHeightIntentService.class); intent.setAction(ACTION_PARSE_WFH_CSV); context.startService(intent); @@ -41,7 +59,7 @@ protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); if (ACTION_PARSE_WFH_CSV.equals(action)) { - parseWFHCSV(); + parseWFHCSV(GrowthMonitoringLibrary.getInstance().getConfig().getWeightForHeightZScoreFile()); } } } @@ -49,18 +67,52 @@ protected void onHandleIntent(Intent intent) { /** * Handle parsing the WFH CSV chart in the provided background thread */ - private void parseWFHCSV() { - + private void parseWFHCSV(String fileName) { + StringBuilder queryString; try { - String fileName = null; if (StringUtils.isNotBlank(fileName)) { - CSVParser csvParser = CSVParser.parse(Utils.readAssetContents(this, fileName), CSVFormat.newFormat('\t')); - for (CSVRecord record : csvParser) { + boolean isTableEmpty = GrowthMonitoringLibrary.getInstance().weightForHeightRepository().isTableEmpty(WeightForHeightRepository.TABLE_NAME); + if (isTableEmpty) { + CSVParser csvParser = CSVParser.parse(Utils.readAssetContents(this, fileName), CSVFormat.newFormat('\t')); + HashMap columnStatus = new HashMap<>(); + + queryString = new StringBuilder("INSERT INTO `" + WeightForHeightRepository.TABLE_NAME + "` ( `"); + for (CSVRecord record : csvParser) { + if (csvParser.getCurrentLineNumber() == 2) {// The second line + queryString.append(")\n VALUES (\""); + } else if (csvParser.getCurrentLineNumber() > 2) { + queryString.append("),\n (\""); + } + for (int columnIndex = 0; columnIndex < record.size(); columnIndex++) { + String curColumn = record.get(columnIndex); + if (csvParser.getCurrentLineNumber() == 1) { + if (CSV_HEADING_COLUMN_MAP.containsKey(curColumn)) { + columnStatus.put(columnIndex, true); + if (columnIndex > 0) { + queryString.append(", `"); + } + queryString.append(CSV_HEADING_COLUMN_MAP.get(curColumn)).append("`"); + } else { + columnStatus.put(columnIndex, false); + } + } else { + if (columnStatus.get(columnIndex)) { + if (columnIndex > 0) { + queryString.append(", \""); + } + queryString.append(curColumn).append("\""); + } + } + } + } + queryString.append(");"); + boolean result = GrowthMonitoringLibrary.getInstance().weightForHeightRepository().runRawQuery(queryString.toString()); + Timber.d("WeightForHeightIntentService --> parseWFHCSV --> Result :: %s", result); } } } catch (Exception ex) { - + Timber.e(ex, "WeightForHeightIntentService --> parseWFHCSV"); } } } diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 95dbe11..570f52c 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -26,6 +26,8 @@ + + From c4f8d64200cb6eca096bd07ff708d975cf88e1ef Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 9 Mar 2020 17:20:53 +0300 Subject: [PATCH 08/21] :fire: Initialize WFH Z-Score file and start WeightForHeight IntentService in Sample Application --- .../sample/application/SampleApplication.java | 10 +++++++--- .../sample/repository/SampleRepository.java | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sample/src/main/java/org/smartregister/growthmonitoring/sample/application/SampleApplication.java b/sample/src/main/java/org/smartregister/growthmonitoring/sample/application/SampleApplication.java index eebdb6d..2e139ad 100644 --- a/sample/src/main/java/org/smartregister/growthmonitoring/sample/application/SampleApplication.java +++ b/sample/src/main/java/org/smartregister/growthmonitoring/sample/application/SampleApplication.java @@ -8,6 +8,7 @@ import org.smartregister.growthmonitoring.GrowthMonitoringLibrary; import org.smartregister.growthmonitoring.sample.BuildConfig; import org.smartregister.growthmonitoring.sample.repository.SampleRepository; +import org.smartregister.growthmonitoring.service.intent.WeightForHeightIntentService; import org.smartregister.growthmonitoring.service.intent.ZScoreRefreshIntentService; import org.smartregister.location.helper.LocationHelper; import org.smartregister.repository.Repository; @@ -41,7 +42,6 @@ public void onCreate() { context.updateApplicationContext(getApplicationContext()); - //Initialize Modules CoreLibrary.init(context); @@ -49,12 +49,12 @@ public void onCreate() { GrowthMonitoringConfig config = new GrowthMonitoringConfig(); config.setFemaleWeightZScoreFile("zscores/custom_female_zscore_file.txt"); + config.setWeightForHeightZScoreFile("weight_for_height.csv"); GrowthMonitoringLibrary .init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION, config); - + startWeightForHeightIntentService(); startZscoreRefreshService(); - } @Override @@ -80,6 +80,10 @@ public void startZscoreRefreshService() { this.getApplicationContext().startService(intent); } + public void startWeightForHeightIntentService() { + WeightForHeightIntentService.startParseWFHZScores(this); + } + public static synchronized SampleApplication getInstance() { return (SampleApplication) mInstance; } diff --git a/sample/src/main/java/org/smartregister/growthmonitoring/sample/repository/SampleRepository.java b/sample/src/main/java/org/smartregister/growthmonitoring/sample/repository/SampleRepository.java index e682cea..bb97c69 100644 --- a/sample/src/main/java/org/smartregister/growthmonitoring/sample/repository/SampleRepository.java +++ b/sample/src/main/java/org/smartregister/growthmonitoring/sample/repository/SampleRepository.java @@ -9,10 +9,11 @@ import org.smartregister.domain.db.Column; import org.smartregister.growthmonitoring.repository.HeightRepository; import org.smartregister.growthmonitoring.repository.HeightZScoreRepository; +import org.smartregister.growthmonitoring.repository.WeightForHeightRepository; import org.smartregister.growthmonitoring.repository.WeightRepository; import org.smartregister.growthmonitoring.repository.WeightZScoreRepository; -import org.smartregister.growthmonitoring.sample.BuildConfig; import org.smartregister.repository.EventClientRepository; +import org.smartregister.growthmonitoring.sample.BuildConfig; import org.smartregister.repository.Repository; /** @@ -55,6 +56,8 @@ public void onCreate(SQLiteDatabase database) { database.execSQL(HeightRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL); database.execSQL(HeightRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL_INDEX); + WeightForHeightRepository.createTable(database); + onUpgrade(database, 1, BuildConfig.DATABASE_VERSION); } From 67473bbb117e40c81da56961cbd42aa9c07508dc Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 9 Mar 2020 19:48:52 +0300 Subject: [PATCH 09/21] :recycle: Rename package name to correct spelling mistake --- .../growthmonitoring/{domian => domain}/HeightZScoreTests.java | 0 .../growthmonitoring/{domian => domain}/WeightZScoreTests.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/{domian => domain}/HeightZScoreTests.java (100%) rename opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/{domian => domain}/WeightZScoreTests.java (100%) diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domian/HeightZScoreTests.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domain/HeightZScoreTests.java similarity index 100% rename from opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domian/HeightZScoreTests.java rename to opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domain/HeightZScoreTests.java diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domian/WeightZScoreTests.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domain/WeightZScoreTests.java similarity index 100% rename from opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domian/WeightZScoreTests.java rename to opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/domain/WeightZScoreTests.java From bee77ef6fc5d4d559ef56bdaea75dbbba165a8dd Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 10 Mar 2020 10:01:00 +0300 Subject: [PATCH 10/21] :recycle: Fix getting wfh z score chart values and rename parse CSV utility function --- .../repository/WeightForHeightRepository.java | 2 +- .../service/intent/ZScoreRefreshIntentService.java | 4 ++-- .../growthmonitoring/util/GrowthMonitoringUtils.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java index 2c12c1b..f0042eb 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java @@ -56,7 +56,7 @@ public List findZScoreVariables(String gender, double height) { String selection; String[] selectionArgs; - if (height == NO_HEIGHT_DEFAULT) { + if (height != NO_HEIGHT_DEFAULT) { selection = GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? "; selectionArgs = new String[]{gender, String.valueOf(height)}; } else { diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java index 4d238a1..d0ae1e0 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/service/intent/ZScoreRefreshIntentService.java @@ -115,7 +115,7 @@ private void dumpWeightCsv(Gender gender, boolean force) { filename = GrowthMonitoringLibrary.getInstance().getConfig().getMaleWeightZScoreFile(); } if (filename != null) { - String query = GrowthMonitoringUtils.dumpCsvQueryBuilder(gender, this, filename, WeightZScoreRepository.TABLE_NAME, CSV_HEADING_SQL_COLUMN_MAP); + String query = GrowthMonitoringUtils.getDumpCsvQuery(gender, this, filename, WeightZScoreRepository.TABLE_NAME, CSV_HEADING_SQL_COLUMN_MAP); if (query != null) { boolean result = GrowthMonitoringLibrary.getInstance().weightZScoreRepository().runRawQuery(query); Timber.d("ZScoreRefreshIntentService --> dumpWeightCsv --> Result%s", result); @@ -145,7 +145,7 @@ private void dumpHeightCsv(Gender gender, boolean force) { filename = GrowthMonitoringLibrary.getInstance().getConfig().getMaleHeightZScoreFile(); } if (filename != null) { - String query = GrowthMonitoringUtils.dumpCsvQueryBuilder(gender, this, filename, HeightZScoreRepository.TABLE_NAME, HEIGHT_CSV_HEADING_SQL_COLUMN_MAP); + String query = GrowthMonitoringUtils.getDumpCsvQuery(gender, this, filename, HeightZScoreRepository.TABLE_NAME, HEIGHT_CSV_HEADING_SQL_COLUMN_MAP); if (query != null) { boolean result = GrowthMonitoringLibrary.getInstance().heightZScoreRepository().runRawQuery(query); Timber.d("ZScoreRefreshIntentService --> dumpHeightCsv --> Result%s", result); diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java index f420486..88c6d1a 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/GrowthMonitoringUtils.java @@ -121,7 +121,7 @@ public static AppProperties getProperties(android.content.Context context) { * @param csvHeadingColumnMap CSV Headings map * @return Query String */ - public static String dumpCsvQueryBuilder(Gender gender, Context context, String filename, String tableName, Map csvHeadingColumnMap) { + public static String getDumpCsvQuery(Gender gender, Context context, String filename, String tableName, Map csvHeadingColumnMap) { StringBuilder queryString; try { if (filename != null) { From 56ebc1b5117432cb62c6d4a1ad6a7609b6a61324 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 10 Mar 2020 10:02:11 +0300 Subject: [PATCH 11/21] :white_check_mark: Add WFH Calculations tests --- .../GrowthMonitoringConfigTest.java | 9 +++ .../WeightForHeightRepositoryTest.java | 79 +++++++++++++++++++ .../utils/GrowthMonitoringUtilsTest.java | 47 ++++++----- 3 files changed, 117 insertions(+), 18 deletions(-) create mode 100644 opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/GrowthMonitoringConfigTest.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/GrowthMonitoringConfigTest.java index 06619bb..1b1be3f 100644 --- a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/GrowthMonitoringConfigTest.java +++ b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/GrowthMonitoringConfigTest.java @@ -13,6 +13,7 @@ public class GrowthMonitoringConfigTest { private static final String BOYCHILD_WEIGHT_ZSCORE_FILE = "weight_z_scores_male.csv"; private static final String FEMALE_HEIGHT_ZSCORE_FILE = "height_z_scores_female.csv"; private static final String BOYCHILD_HEIGHT_ZSCORE_FILE = "height_z_scores_male.csv"; + private static final String WEIGHT_FOR_HEIGHT_Z_SCORE_FILE = "weight_for_height.csv"; @Test public void testGrowthMonitoringConfigInstantiatesCorrectly() { @@ -44,4 +45,12 @@ public void testGrowthMonitoringConfigInstantiatesCorrectly() { config.setGenderNeutralZScoreFile(CUSTOM_ZSCORE_FILE); Assert.assertEquals(CUSTOM_ZSCORE_FILE, config.getGenderNeutralZScoreFile()); } + + @Test + public void weightForHeightConfigInstantiatesCorrectly() { + GrowthMonitoringConfig growthMonitoringConfig = new GrowthMonitoringConfig(); + growthMonitoringConfig.setWeightForHeightZScoreFile(WEIGHT_FOR_HEIGHT_Z_SCORE_FILE); + + Assert.assertEquals(WEIGHT_FOR_HEIGHT_Z_SCORE_FILE, growthMonitoringConfig.getWeightForHeightZScoreFile()); + } } diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java new file mode 100644 index 0000000..aea4d8d --- /dev/null +++ b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java @@ -0,0 +1,79 @@ +package org.smartregister.growthmonitoring.repository; + +import net.sqlcipher.MatrixCursor; +import net.sqlcipher.database.SQLiteDatabase; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.opensrp.api.constants.Gender; +import org.smartregister.growthmonitoring.BaseUnitTest; +import org.smartregister.growthmonitoring.domain.ZScore; +import org.smartregister.growthmonitoring.util.GrowthMonitoringConstants; + +import java.util.List; + +import static org.smartregister.repository.BaseRepository.COLLATE_NOCASE; + +public class WeightForHeightRepositoryTest extends BaseUnitTest { + + @Mock + private SQLiteDatabase sqliteDatabase; + + private WeightForHeightRepository weightForHeightRepository; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + weightForHeightRepository = Mockito.spy(new WeightForHeightRepository()); + } + + @Test + public void execSQLIsInvokedCorrectlyWhenCreatingWFHTable() { + WeightForHeightRepository.createTable(sqliteDatabase); + Mockito.verify(sqliteDatabase, Mockito.times(3)).execSQL(ArgumentMatchers.anyString()); + } + + @Test + public void getWFHZScoreValuesInvokesDatabaseQueryCorrectly() { + Mockito.doReturn(sqliteDatabase).when(weightForHeightRepository).getReadableDatabase(); + weightForHeightRepository.findZScoreVariables("1", 60); + Mockito.verify(sqliteDatabase, Mockito.times(1)).query( + ArgumentMatchers.eq(WeightForHeightRepository.TABLE_NAME), + ArgumentMatchers.isNull(String[].class), + ArgumentMatchers.eq(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? " + COLLATE_NOCASE), + ArgumentMatchers.eq(new String[]{"1", "60.0"}), + ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class)); + } + + @Test + public void getWFHZScoreValuesReturnsCorrectZValues() { + Mockito.doReturn(sqliteDatabase).when(weightForHeightRepository).getReadableDatabase(); + String[] columns = new String[]{ + GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX, + GrowthMonitoringConstants.ColumnHeaders.HEIGHT, + GrowthMonitoringConstants.ColumnHeaders.COLUMN_L, + GrowthMonitoringConstants.ColumnHeaders.COLUMN_M, + GrowthMonitoringConstants.ColumnHeaders.COLUMN_S + }; + MatrixCursor matrixCursor = new MatrixCursor(columns); + String gender = "1", height = "60.0", l = "-0.3521", m = "2.441", s = "0.09182"; + matrixCursor.addRow(new Object[]{gender, height, l, m, s}); + + Mockito.doReturn(matrixCursor).when(sqliteDatabase).query( + ArgumentMatchers.eq(WeightForHeightRepository.TABLE_NAME), + ArgumentMatchers.isNull(String[].class), + ArgumentMatchers.eq(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? " + COLLATE_NOCASE), + ArgumentMatchers.eq(new String[]{"1", "60.0"}), + ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class) + ); + + List zScoreValues = weightForHeightRepository.findZScoreVariables("1", 60); + Assert.assertEquals(Gender.MALE, zScoreValues.get(0).getGender()); + Assert.assertEquals(Double.parseDouble(l), zScoreValues.get(0).getL(), 0.0); + } +} diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java index 19a529c..759ca53 100644 --- a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java +++ b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java @@ -1,27 +1,29 @@ package org.smartregister.growthmonitoring.utils; +import android.os.Build; + import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.mockito.Mock; +import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.smartregister.growthmonitoring.BaseUnitTest; -import org.smartregister.growthmonitoring.domain.WeightZScore; +import org.opensrp.api.constants.Gender; + +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.smartregister.growthmonitoring.BuildConfig; +import org.smartregister.growthmonitoring.util.GrowthMonitoringConstants; import org.smartregister.growthmonitoring.util.GrowthMonitoringUtils; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; +import java.util.Map; -public class GrowthMonitoringUtilsTest extends BaseUnitTest { - @Rule - public PowerMockRule rule = new PowerMockRule(); - - @Mock - private Calendar calendar; +@RunWith(RobolectricTestRunner.class) +@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.O_MR1) +public class GrowthMonitoringUtilsTest { @Before public void setUp() { @@ -29,13 +31,22 @@ public void setUp() { } @Test - @PrepareForTest({Calendar.class, WeightZScore.class}) public void getMinAndMaxRecordingDatesTest() { - PowerMockito.mockStatic(Calendar.class); - PowerMockito.mockStatic(WeightZScore.class); - PowerMockito.when(Calendar.getInstance()).thenReturn(calendar); - Calendar[] calendar = GrowthMonitoringUtils.getMinAndMaxRecordingDates(new Date(1500208620000L)); Assert.assertEquals(2, calendar.length); } + + @Test + public void getDumpCsvQueryReturnsCorrectQueryString() { + Map CSV_HEADING_COLUMN_MAP = new HashMap<>(); + CSV_HEADING_COLUMN_MAP.put("sex", GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX); + CSV_HEADING_COLUMN_MAP.put("height", GrowthMonitoringConstants.ColumnHeaders.HEIGHT); + CSV_HEADING_COLUMN_MAP.put("l", GrowthMonitoringConstants.ColumnHeaders.COLUMN_L); + CSV_HEADING_COLUMN_MAP.put("m", GrowthMonitoringConstants.ColumnHeaders.COLUMN_M); + String queryStringStart = "INSERT INTO `test_table` ( `sex`, `sex`, `height`, `l`, `m`)\n" + + " VALUES (\"MALE\", \"1\", \"65\", \"-0.3521\", \"7.4327\"),"; + + String sqlQueryString = GrowthMonitoringUtils.getDumpCsvQuery(Gender.MALE, RuntimeEnvironment.application.getApplicationContext(), "weight_for_height.csv", "test_table", CSV_HEADING_COLUMN_MAP); + Assert.assertTrue(sqlQueryString.startsWith(queryStringStart)); + } } From 6eaec578d4418711de63313484653aaa08e00eec Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 01:17:06 +0300 Subject: [PATCH 12/21] :arrow_up: Update Native Forms dependency --- opensrp-growth-monitoring/build.gradle | 2 +- sample/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-growth-monitoring/build.gradle b/opensrp-growth-monitoring/build.gradle index df1242c..3a7202e 100644 --- a/opensrp-growth-monitoring/build.gradle +++ b/opensrp-growth-monitoring/build.gradle @@ -92,7 +92,7 @@ dependencies { exclude group: 'com.github.bmelnychuk', module: 'atv' } - implementation('org.smartregister:opensrp-client-native-form:1.7.23-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-native-form:1.7.27-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'recyclerview-v7' } diff --git a/sample/build.gradle b/sample/build.gradle index 1ed0d2b..845871b 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -84,7 +84,7 @@ dependencies { exclude group: 'com.github.bmelnychuk', module: 'atv' } - implementation('org.smartregister:opensrp-client-native-form:1.7.23-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-native-form:1.7.27-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'recyclerview-v7' } From 5327485a029ca2af3d97704d31a7d0cd41c9c297 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 12:56:50 +0300 Subject: [PATCH 13/21] :recycle: Remove calculate z-score overrides --- .../growthmonitoring/domain/HeightZScore.java | 15 --------------- .../domain/WeightForHeightZscore.java | 12 ------------ .../growthmonitoring/domain/WeightZScore.java | 16 ---------------- 3 files changed, 43 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java index 0ad9e14..66d57ee 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/HeightZScore.java @@ -84,7 +84,6 @@ public static double getAgeInMonths(Date dateOfBirth, Date heightDate) { * @param gender * @param ageInMonthsDouble * @param z - * * @return */ public static Double reverse(Gender gender, double ageInMonthsDouble, Double z) { @@ -107,24 +106,10 @@ public static Double reverse(Gender gender, double ageInMonthsDouble, Double z) return null; } - /** - * This method calculates Z (The z-score) using the formulae provided here https://www.cdc - * .gov/growthcharts/percentile_data_files.htm - * - * @param x The height to use - * - * @return - */ - @Override - public double getZ(double x) { - return super.getZ(x); - } - /** * This method calculates X (height) given the Z-Score * * @param z The z-score to use to calculate X - * * @return */ public double getX(double z) { diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java index d05324a..b07a567 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightForHeightZscore.java @@ -19,16 +19,4 @@ public static Double calculate(String gender, double weight, double height) { return 0.0; } - /** - * This method calculates Z (The z-score) using the formulae provided here https://www.cdc - * .gov/growthcharts/percentile_data_files.htm - * - * @param x The weight to use - * @return The Z-Score value - */ - @Override - public double getZ(double x) { - return super.getZ(x); - } - } diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java index 256966e..15c8de5 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/domain/WeightZScore.java @@ -89,7 +89,6 @@ private static void standardiseCalendarDate(Calendar calendarDate) { * @param gender * @param ageInMonthsDouble * @param z - * * @return */ public static Double reverse(Gender gender, double ageInMonthsDouble, Double z) { @@ -112,25 +111,10 @@ public static Double reverse(Gender gender, double ageInMonthsDouble, Double z) return null; } - /** - * This method calculates Z (The z-score) using the formulae provided here https://www.cdc - * .gov/growthcharts/percentile_data_files.htm - * - * @param x The weight to use - * - * @return - */ - - @Override - public double getZ(double x) { - return super.getZ(x); - } - /** * This method calculates X (weight) given the Z-Score * * @param z The z-score to use to calculate X - * * @return */ public double getX(double z) { From eda30f434f75df2958ca0b07d3270eaed3c5a254 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 15:39:34 +0300 Subject: [PATCH 14/21] :recycle: Remove collation in retrieve z-score values query --- .../growthmonitoring/repository/HeightZScoreRepository.java | 2 +- .../growthmonitoring/repository/WeightForHeightRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java index e761d10..bc72f43 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/HeightZScoreRepository.java @@ -87,7 +87,7 @@ public List findByGender(Gender gender) { } } } catch (Exception e) { - Timber.e(e, TAG); + Timber.e(e); } finally { if (cursor != null) cursor.close(); } diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java index f0042eb..2a64ee5 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepository.java @@ -65,7 +65,7 @@ public List findZScoreVariables(String gender, double height) { } cursor = database.query(TABLE_NAME, null, - selection + COLLATE_NOCASE, selectionArgs, null, null, null, null); + selection, selectionArgs, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { while (!cursor.isAfterLast()) { From f0ad8d996854f5de7db28fe2fba6c0187a89af72 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 16:11:43 +0300 Subject: [PATCH 15/21] :white_check_mark: Fix test --- .../utils/GrowthMonitoringUtilsTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java index 759ca53..e1a8d8a 100644 --- a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java +++ b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/utils/GrowthMonitoringUtilsTest.java @@ -39,14 +39,14 @@ public void getMinAndMaxRecordingDatesTest() { @Test public void getDumpCsvQueryReturnsCorrectQueryString() { Map CSV_HEADING_COLUMN_MAP = new HashMap<>(); - CSV_HEADING_COLUMN_MAP.put("sex", GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX); - CSV_HEADING_COLUMN_MAP.put("height", GrowthMonitoringConstants.ColumnHeaders.HEIGHT); - CSV_HEADING_COLUMN_MAP.put("l", GrowthMonitoringConstants.ColumnHeaders.COLUMN_L); - CSV_HEADING_COLUMN_MAP.put("m", GrowthMonitoringConstants.ColumnHeaders.COLUMN_M); - String queryStringStart = "INSERT INTO `test_table` ( `sex`, `sex`, `height`, `l`, `m`)\n" + - " VALUES (\"MALE\", \"1\", \"65\", \"-0.3521\", \"7.4327\"),"; - - String sqlQueryString = GrowthMonitoringUtils.getDumpCsvQuery(Gender.MALE, RuntimeEnvironment.application.getApplicationContext(), "weight_for_height.csv", "test_table", CSV_HEADING_COLUMN_MAP); + CSV_HEADING_COLUMN_MAP.put("Month", GrowthMonitoringConstants.ColumnHeaders.COLUMN_MONTH); + CSV_HEADING_COLUMN_MAP.put("L", GrowthMonitoringConstants.ColumnHeaders.COLUMN_L); + CSV_HEADING_COLUMN_MAP.put("M", GrowthMonitoringConstants.ColumnHeaders.COLUMN_M); + CSV_HEADING_COLUMN_MAP.put("S", GrowthMonitoringConstants.ColumnHeaders.COLUMN_S); + String queryStringStart = "INSERT INTO `test_table` ( `sex`, `month`, `l`, `m`, `s`)\n" + + " VALUES (\"MALE\", \"0\", \"0.3487\", \"3.3464\", \"0.14602\"),"; + + String sqlQueryString = GrowthMonitoringUtils.getDumpCsvQuery(Gender.MALE, RuntimeEnvironment.application.getApplicationContext(), "weight_z_scores_male.csv", "test_table", CSV_HEADING_COLUMN_MAP); Assert.assertTrue(sqlQueryString.startsWith(queryStringStart)); } } From 7a83ed7e506255b9a4f315ee3cab647042050c51 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 17:13:16 +0300 Subject: [PATCH 16/21] :recycle: Remove unnecessary WFH Calculation Service declaration in manifest --- opensrp-growth-monitoring/src/main/AndroidManifest.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/opensrp-growth-monitoring/src/main/AndroidManifest.xml b/opensrp-growth-monitoring/src/main/AndroidManifest.xml index 5ca3c89..0bc96fd 100644 --- a/opensrp-growth-monitoring/src/main/AndroidManifest.xml +++ b/opensrp-growth-monitoring/src/main/AndroidManifest.xml @@ -5,10 +5,6 @@ - - + android:supportsRtl="true"> \ No newline at end of file From 65df87a1fbfc275eafb3e54af05c407d6a7ff229 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 17:19:41 +0300 Subject: [PATCH 17/21] :wrench: Update Travis build dist --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4a2b456..67701a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: android # Setting sudo to required prevents Travis from testing the project in a Docker container. sudo: required jdk: oraclejdk8 -dist: precise +dist: trusty before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From 29e860989ac407297a82b0bf42648612d6fbbd0c Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 18:13:18 +0300 Subject: [PATCH 18/21] :recycle: Trigger build From 3138253c6ae2612642036dd3b14a16234ffa60f7 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 18:30:21 +0300 Subject: [PATCH 19/21] :white_check_mark: Fix failing test --- .../repository/WeightForHeightRepositoryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java index aea4d8d..de521c4 100644 --- a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java +++ b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java @@ -67,7 +67,7 @@ public void getWFHZScoreValuesReturnsCorrectZValues() { Mockito.doReturn(matrixCursor).when(sqliteDatabase).query( ArgumentMatchers.eq(WeightForHeightRepository.TABLE_NAME), ArgumentMatchers.isNull(String[].class), - ArgumentMatchers.eq(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? " + COLLATE_NOCASE), + ArgumentMatchers.eq(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? "), ArgumentMatchers.eq(new String[]{"1", "60.0"}), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class) ); From b629f383560c3f5de2a8c108856a5e5b7f1681f9 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 18:43:56 +0300 Subject: [PATCH 20/21] :white_check_mark: Fix failing test --- .../repository/WeightForHeightRepositoryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java index de521c4..6b75ffb 100644 --- a/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java +++ b/opensrp-growth-monitoring/src/test/java/org/smartregister/growthmonitoring/repository/WeightForHeightRepositoryTest.java @@ -45,7 +45,7 @@ public void getWFHZScoreValuesInvokesDatabaseQueryCorrectly() { Mockito.verify(sqliteDatabase, Mockito.times(1)).query( ArgumentMatchers.eq(WeightForHeightRepository.TABLE_NAME), ArgumentMatchers.isNull(String[].class), - ArgumentMatchers.eq(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? " + COLLATE_NOCASE), + ArgumentMatchers.eq(GrowthMonitoringConstants.ColumnHeaders.COLUMN_SEX + " = ? AND " + GrowthMonitoringConstants.ColumnHeaders.HEIGHT + " = ? "), ArgumentMatchers.eq(new String[]{"1", "60.0"}), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class), ArgumentMatchers.isNull(String.class)); } From 85df6044a4e01b4ad0ac8d5348c90ee7bc956fde Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Mar 2020 18:46:19 +0300 Subject: [PATCH 21/21] :wrench: Update build config --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 67701a8..6f71bc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,8 +40,10 @@ script: - ls -la # Enable the line below once we get all the test passing, currently most of the tests are failing # so we'll just if the project compiles + - travis_wait ./gradlew clean --stacktrace #Run All tests Unit and Instrumentation - - travis_wait ./gradlew :opensrp-growth-monitoring:jacocoTestReport coveralls --stacktrace + - travis_wait ./gradlew :opensrp-growth-monitoring:jacocoTestReport --stacktrace + - travis_wait ./gradlew :opensrp-growth-monitoring:coveralls --stacktrace after_failure: - pandoc opensrp-growth-monitoring/build/reports/tests/index.html -t plain