diff --git a/build.gradle b/build.gradle
index ab318eb..ff89848 100755
--- a/build.gradle
+++ b/build.gradle
@@ -5,28 +5,34 @@ buildscript {
repositories {
google()
jcenter()
-// maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
+ maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
-// dependencies {
-// classpath 'com.android.tools.build:gradle:4.0.1'
-// classpath 'org.smartregister:gradle-jarjar-plugin:1.0.0-SNAPSHOT'
-// }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:4.0.1'
+ classpath 'org.smartregister:gradle-jarjar-plugin:1.0.0-SNAPSHOT'
+ }
}
allprojects {
repositories {
- maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
+ google()
+ jcenter()
mavenLocal()
mavenCentral()
+ maven { url 'https://maven.google.com' }
+ maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://jitpack.io' }
maven { url "https://acra.googlecode.com/svn/repository/releases" }
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "https://cloudant.github.io/cloudant-sync-eap/repository" }
+ maven { url 'https://maven.fabric.io/public' }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
- google()
- jcenter()
+ //aven { url "https://dl.bintray.com/ona/rdt-capture" }
+ //maven { url "http://dl.bintray.com/ona/kujaku" }
+ //maven { url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases' }
+ maven { url 'https://repo1.maven.org/maven2/com/ibm/fhir' }
}
}
@@ -38,7 +44,7 @@ subprojects {
ext.androidToolsBuildGradle = '4.0.1'
ext.androidBuildToolsVersion = '29.0.3'
- ext.androidMinSdkVersion = 18
+ ext.androidMinSdkVersion = 27
ext.androidCompileSdkVersion = 29
ext.androidTargetSdkVersion = 29
diff --git a/local.properties b/local.properties
index 1d80b10..42e653c 100644
--- a/local.properties
+++ b/local.properties
@@ -6,3 +6,5 @@
# header note.
#Tue Jun 08 19:44:42 EAT 2021
sdk.dir=/home/stephen/Android/Sdk
+oauth.client.id="opensrp-trusted-client"
+oauth.client.secret="O@aTHS#cr3t"
\ No newline at end of file
diff --git a/opensrp-kip/build.gradle b/opensrp-kip/build.gradle
index cc43f67..230df7c 100755
--- a/opensrp-kip/build.gradle
+++ b/opensrp-kip/build.gradle
@@ -44,6 +44,34 @@ android {
buildConfigField "long", "EVENT_VERSION", System.currentTimeMillis() + "L"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
+ if (project.rootProject.file("local.properties").exists()) {
+
+ Properties properties = new Properties()
+ properties.load(project.rootProject.file("local.properties").newDataInputStream())
+
+ if (properties != null && properties.containsKey("oauth.client.id")) {
+
+ buildConfigField "String", "OAUTH_CLIENT_ID", properties["oauth.client.id"]
+
+ } else {
+ project.logger.error("oauth.client.id variable is not set in your local.properties")
+ buildConfigField "String", "OAUTH_CLIENT_ID", "\"sample_client_id\""
+ }
+
+
+ if (properties != null && properties.containsKey("oauth.client.secret")) {
+
+ buildConfigField "String", "OAUTH_CLIENT_SECRET", properties["oauth.client.secret"]
+
+ } else {
+ project.logger.error("oauth.client.secret variable is not set in your local.properties")
+ buildConfigField "String", "OAUTH_CLIENT_SECRET", "\"sample_client_secret\""
+ }
+ } else {
+ buildConfigField "String", "OAUTH_CLIENT_ID", '""'
+ buildConfigField "String", "OAUTH_CLIENT_SECRET", '""'
+ }
+
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
@@ -112,18 +140,21 @@ android {
}
packagingOptions {
- exclude 'META-INF/DEPENDENCIES.txt'
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/LICENSE'
+ //exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/notice.txt'
- exclude 'META-INF/license.txt'
- exclude 'META-INF/dependencies.txt'
- exclude 'META-INF/LGPL2.1'
- exclude 'LICENSE.txt'
-
+ //exclude 'META-INF/LICENSE.txt'
+ //exclude 'META-INF/NOTICE.txt'
+ //exclude 'META-INF/NOTICE'
+ exclude 'META-INF/NOTICE.md'
+ //exclude 'META-INF/LICENSE'
+ exclude 'META-INF/LICENSE.md'
+ exclude 'META-INF/INDEX.LIST'
+ //exclude 'META-INF/DEPENDENCIES'
+ //exclude 'META-INF/notice.txt'
+ //exclude 'META-INF/license.txt'
+ //exclude 'META-INF/dependencies.txt'
+ //exclude 'META-INF/LGPL2.1'
+ //exclude 'LICENSE.txt'
}
testOptions {
@@ -145,7 +176,7 @@ dependencies {
implementation 'com.evrencoskun.library:tableview:0.8.8'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
- implementation('org.smartregister:opensrp-client-opd:0.0.16-SNAPSHOT@aar') {
+ implementation('org.smartregister:opensrp-client-opd:0.0.18-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
@@ -153,7 +184,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
- implementation('org.smartregister:opensrp-client-child:0.3.4-00-SNAPSHOT@aar') {
+ implementation('org.smartregister:opensrp-client-child:0.5.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'org.smartregister', module: 'opensrp-client-core'
@@ -164,7 +195,7 @@ dependencies {
}
- api('org.smartregister:opensrp-client-core:1.12.0-SNAPSHOT@aar') {
+ api('org.smartregister:opensrp-client-core:3.3.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'com.github.bmelnychuk', module: 'atv'
@@ -176,9 +207,10 @@ dependencies {
exclude group: 'com.android.support', module: 'cardview-v7'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
+ exclude group: 'com.ibm.fhir', module: 'fhir-model'
}
- api('org.smartregister:opensrp-client-native-form:2.0.2-SNAPSHOT@aar') {
+ api('org.smartregister:opensrp-client-native-form:1.14.5.3-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'com.android.support', module: 'recyclerview-v7'
@@ -276,7 +308,9 @@ dependencies {
transitive = true
}
implementation group: 'io.fabric.sdk.android', name: 'fabric', version: '1.4.8'
-
+ implementation 'org.apache.poi:poi:3.17'
+ implementation "com.ibm.fhir:fhir-model:4.7.1"
+ implementation "com.ibm.fhir:fhir-path:4.7.1"
def robolectricVersion = '4.1'
testImplementation("org.robolectric:robolectric:$robolectricVersion") {
diff --git a/opensrp-kip/src/main/AndroidManifest.xml b/opensrp-kip/src/main/AndroidManifest.xml
index 77dae7c..48caa95 100755
--- a/opensrp-kip/src/main/AndroidManifest.xml
+++ b/opensrp-kip/src/main/AndroidManifest.xml
@@ -117,6 +117,11 @@
android:screenOrientation="fullSensor"
android:theme="@style/ChildTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
+
",
- "read_only": true,
- "hint_on_text": true,
"text_color": "#000000",
"text_size": "14sp",
- "openmrs_entity_parent": "",
- "openmrs_entity": "",
- "openmrs_entity_id": ""
+ "hint_on_text": true
},
{
"key": "Vials_Issued_Count",
@@ -83,9 +82,9 @@
"openmrs_entity": "",
"openmrs_entity_id": "",
"text": "Estimated vials issued on this date: ",
- "hint_on_text": true,
"text_color": "#000000",
- "text_size": "14sp"
+ "text_size": "14sp",
+ "hint_on_text": true
},
{
"key": "divider1",
@@ -106,7 +105,7 @@
"hint": "Actual number of [vaccine] vials issued",
"v_min": {
"value": "1",
- "err": "Issued vials must be greater than 0"
+ "err": "issued vials must be greater than 0"
},
"v_numeric_integer": {
"value": "true",
@@ -170,7 +169,7 @@
"hint": "Number of wasted vials (e.g. damaged vials)",
"v_min": {
"value": "0",
- "err": "Value cannot be less than zero"
+ "err": "value cannot be less than zero"
},
"v_numeric_integer": {
"value": "true",
@@ -193,9 +192,9 @@
"read_only": true,
"has_bg": true,
"top_padding": "10dp",
+ "left_padding": "20dp",
"right_padding": "20dp",
"bottom_padding": "10dp",
- "left_padding": "20dp",
"text_size": "14sp",
"openmrs_entity_parent": "",
"openmrs_entity": "",
@@ -215,9 +214,9 @@
"text_size": "10sp",
"text_color": "#737373",
"top_padding": "10dp",
+ "left_padding": "20dp",
"right_padding": "20dp",
"bottom_padding": "10dp",
- "left_padding": "20dp",
"openmrs_entity_parent": "",
"openmrs_entity": "",
"openmrs_entity_id": "",
@@ -234,9 +233,9 @@
"text": "Total wasted doses: 0 doses",
"has_bg": true,
"top_padding": "10dp",
+ "left_padding": "20dp",
"right_padding": "20dp",
"bottom_padding": "10dp",
- "left_padding": "20dp",
"text_size": "14sp",
"text_color": "#000000",
"openmrs_entity_parent": "",
@@ -256,13 +255,12 @@
"has_bg": true,
"text_size": "10sp",
"text_color": "#737373",
- "top_padding": "10dp",
- "right_padding": "20dp",
"bottom_padding": "10dp",
+ "top_padding": "10dp",
"left_padding": "20dp",
- "bottom_margin": "20dp",
- "read_only": true,
+ "right_padding": "20dp",
"openmrs_entity_parent": "",
+ "read_only": true,
"openmrs_entity": "",
"openmrs_entity_id": "",
"relevance": {
diff --git a/opensrp-kip/src/main/assets/json.form/stock_received_form.json b/opensrp-kip/src/main/assets/json.form/stock_received_form.json
index 194b20c..001e22f 100644
--- a/opensrp-kip/src/main/assets/json.form/stock_received_form.json
+++ b/opensrp-kip/src/main/assets/json.form/stock_received_form.json
@@ -125,7 +125,7 @@
"hint": "Vials [vaccine] received",
"v_min": {
"value": "1",
- "err": "Received vials must be greater than 0"
+ "err": "issued vials must be greater than 0"
},
"v_numeric_integer": {
"value": "true",
@@ -155,9 +155,9 @@
"text": "",
"has_bg": true,
"top_padding": "10dp",
+ "left_padding": "20dp",
"right_padding": "20dp",
"bottom_padding": "10dp",
- "left_padding": "20dp",
"text_size": "14sp",
"text_color": "#000000",
"relevance": {
@@ -175,9 +175,9 @@
"text_size": "10sp",
"text_color": "#737373",
"top_padding": "10dp",
+ "left_padding": "20dp",
"right_padding": "20dp",
"bottom_padding": "10dp",
- "left_padding": "20dp",
"openmrs_entity_parent": "",
"openmrs_entity": "",
"openmrs_entity_id": "",
diff --git a/opensrp-kip/src/main/assets/rule/opd/opd_covid19_vaccine_record_relevance.yml b/opensrp-kip/src/main/assets/rule/opd/opd_covid19_vaccine_record_relevance.yml
index 84d4376..65b42ec 100644
--- a/opensrp-kip/src/main/assets/rule/opd/opd_covid19_vaccine_record_relevance.yml
+++ b/opensrp-kip/src/main/assets/rule/opd/opd_covid19_vaccine_record_relevance.yml
@@ -2,14 +2,14 @@
name: step1_re_order_alert
description: re_order_alert
priority: 1
-condition: "((step1_az_oxford_vials_amount != '' && step1_az_oxford_vials_amount > 5 && step1_az_oxford_vials_amount < 10) || (step1_sinopharm != '' && step1_sinopharm > 5 && step1_sinopharm < 10) || (step1_sinovac != '' && step1_sinovac > 5 && step1_sinovac < 10))"
+condition: "((step1_az_oxford_vials_amount != '' && step1_az_oxford_vials_amount > 5 && step1_az_oxford_vials_amount < 10) || (step1_sinopharm != '' && step1_sinopharm > 5 && step1_sinopharm < 10) || (step1_sinovac != '' && step1_sinovac > 5 && step1_sinovac < 10) || (step1_johnson_johnson != '' && step1_johnson_johnson > 5 && step1_johnson_johnson < 10))"
actions:
- "isRelevant = true"
---
name: step1_must_re_order_alert
description: must_re_order_alert
priority: 1
-condition: "((step1_az_oxford_vials_amount != '' && step1_az_oxford_vials_amount < 5) || (step1_sinopharm != '' && step1_sinopharm < 5) || (step1_sinovac != '' && step1_sinovac < 5))"
+condition: "((step1_az_oxford_vials_amount != '' && step1_az_oxford_vials_amount < 5) || (step1_sinopharm != '' && step1_sinopharm < 5) || (step1_sinovac != '' && step1_sinovac < 5)|| (step1_johnson_johnson != '' && step1_johnson_johnson < 5))"
actions:
- "isRelevant = true"
---
diff --git a/opensrp-kip/src/main/assets/stock_type.json b/opensrp-kip/src/main/assets/stock_type.json
index 1469ff7..a8fbd95 100755
--- a/opensrp-kip/src/main/assets/stock_type.json
+++ b/opensrp-kip/src/main/assets/stock_type.json
@@ -14,14 +14,14 @@
"openmrs_quantity_concept_id": ""
},
{
- "quantity": "1",
+ "quantity": "10",
"name": "Penta",
"openmrs_parent_entity_id": "",
"openmrs_date_concept_id": "",
"openmrs_quantity_concept_id": ""
},
{
- "quantity": "2",
+ "quantity": "4",
"name": "PCV",
"openmrs_parent_entity_id": "",
"openmrs_date_concept_id": "",
@@ -42,14 +42,14 @@
"openmrs_quantity_concept_id": ""
},
{
- "quantity": "10",
+ "quantity": "2",
"name": "MV",
"openmrs_parent_entity_id": "",
"openmrs_date_concept_id": "",
"openmrs_quantity_concept_id": ""
},
{
- "quantity": "20",
+ "quantity": "5",
"name": "IPV",
"openmrs_parent_entity_id": "",
"openmrs_date_concept_id": "",
diff --git a/opensrp-kip/src/main/assets/template/covid19_vaccine_stock.json b/opensrp-kip/src/main/assets/template/covid19_vaccine_stock.json
index e597ff6..b460a76 100644
--- a/opensrp-kip/src/main/assets/template/covid19_vaccine_stock.json
+++ b/opensrp-kip/src/main/assets/template/covid19_vaccine_stock.json
@@ -20,16 +20,22 @@
"key": "sinovac_vials_amount"
},
{
- "description": "978676-001:2022-02-01",
+ "description": "978677-001:2022-02-01",
"label": "Moderna Stock Details",
"type": "SettingConfiguration",
"key": "moderna_vials_amount"
},
{
- "description": "978676-001:2022-02-01",
+ "description": "978679-001:2022-02-01",
"label": "Pfizer Stock Details",
"type": "SettingConfiguration",
"key": "pfizer_vials_amount"
+ },
+ {
+ "description": "978678-001:2022-02-01",
+ "label": "Johnson and Johnson Stock Details",
+ "type": "SettingConfiguration",
+ "key": "johnson_and_johnson_vials_amount"
}
],
"type": "SettingConfiguration"
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildDetailTabbedActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildDetailTabbedActivity.java
index 8eb7e46..56101b7 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildDetailTabbedActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildDetailTabbedActivity.java
@@ -59,7 +59,7 @@ protected void attachBaseContext(android.content.Context base) {
}
@Override
- public void onUniqueIdFetched(Triple triple, String s) {
+ public void onUniqueIdFetched(Triple, String> triple, String s) {
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildImmunizationActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildImmunizationActivity.java
index d565cdc..13315fe 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildImmunizationActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildImmunizationActivity.java
@@ -134,7 +134,7 @@ public void onClick(View view) {
}
@Override
- public void onUniqueIdFetched(Triple triple, String s) {
+ public void onUniqueIdFetched(Triple, String> triple, String s) {
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildRegisterActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildRegisterActivity.java
index f50c828..996b3fd 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildRegisterActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ChildRegisterActivity.java
@@ -27,7 +27,7 @@
import org.smartregister.child.model.BaseChildRegisterModel;
import org.smartregister.child.presenter.BaseChildRegisterPresenter;
import org.smartregister.child.util.Constants;
-import org.smartregister.child.util.JsonFormUtils;
+import org.smartregister.child.util.ChildJsonFormUtils;
import org.smartregister.child.util.Utils;
import org.smartregister.helper.BottomNavigationHelper;
import org.smartregister.kip.R;
@@ -225,7 +225,7 @@ public void startFormActivity(JSONObject jsonForm) {
}
intent.putExtra(Constants.INTENT_KEY.JSON, jsonForm.toString());
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getForm());
- startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON);
+ startActivityForResult(intent, ChildJsonFormUtils.REQUEST_CODE_GET_JSON);
}
public void finishActivity() {
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdProfileActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdProfileActivity.java
index 18c1873..456a17e 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdProfileActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdProfileActivity.java
@@ -181,6 +181,9 @@ private void updateSettings(String jsonForm) {
} else if (value.toLowerCase().equalsIgnoreCase("moderna") && settingsKey.equalsIgnoreCase(KipConstants.MODERNA_VIALS_AMOUNT)) {
setValues(metadata);
break;
+ } else if (value.toLowerCase().equalsIgnoreCase("johnson_and_johnson") && settingsKey.equalsIgnoreCase(KipConstants.JOHNSON_AND_JOHNSON_VIALS_AMOUNT)) {
+ setValues(metadata);
+ break;
}
}
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdRegisterActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdRegisterActivity.java
index a130fc7..965e461 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdRegisterActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/KipOpdRegisterActivity.java
@@ -41,6 +41,7 @@
import org.smartregister.view.fragment.BaseRegisterFragment;
import java.util.HashMap;
+import java.util.Map;
import timber.log.Timber;
@@ -112,6 +113,11 @@ protected void onResumption() {
createDrawer();
}
+ @Override
+ public void startFormActivity(String s, String s1, Map map) {
+
+ }
+
@Override
public void finishActivity() {
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/LoginActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/LoginActivity.java
index 56cb9d6..249d6cb 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/LoginActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/LoginActivity.java
@@ -67,7 +67,11 @@ private void gotToHomeRegister(boolean remote) {
finish();
}
-
+// private void goToCovid19VaccineStockSettings(boolean remote) {
+// Intent intent = new Intent(this, Covid19VaccineStockSettingsEnterActivity.class);
+// intent.putExtra(KipConstants.IntentKeyUtils.IS_REMOTE_LOGIN, remote);
+// startActivity(intent);
+// }
@Override
protected void attachBaseContext(Context base) {
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/Moh510ReportActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/Moh510ReportActivity.java
new file mode 100644
index 0000000..c6d60ef
--- /dev/null
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/Moh510ReportActivity.java
@@ -0,0 +1,347 @@
+package org.smartregister.kip.activity;
+
+import android.Manifest;
+import android.app.DatePickerDialog;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.Environment;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+import android.widget.ImageButton;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+
+import net.sqlcipher.Cursor;
+import net.sqlcipher.database.SQLiteDatabase;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFCreationHelper;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.smartregister.child.util.Utils;
+import org.smartregister.kip.R;
+import org.smartregister.kip.application.KipApplication;
+import org.smartregister.kip.pojo.Moh510SummaryReport;
+import org.smartregister.kip.repository.Moh510SummaryReportRepository;
+import org.smartregister.kip.util.KipChildUtils;
+import org.smartregister.location.helper.LocationHelper;
+import org.smartregister.opd.utils.OpdUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import timber.log.Timber;
+
+
+public class Moh510ReportActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, View.OnClickListener {
+
+ Moh510SummaryReportRepository summaryReportRepository = KipApplication.getInstance().moh510SummaryReportRepository();
+ private File filePath = new File(
+ Environment.getExternalStorageDirectory()+"/"+ LocationHelper.getInstance().getOpenMrsReadableName(KipChildUtils.getCurrentLocality())+"moh510Report.xls");
+ private int mYear, mMonth, mDay, mHour, mMinute;
+ ImageButton closeReport;
+ EditText endTextDate, startEditTextDate;
+ Button cancel, endDateBtn,startDateBtn, customDateRangeBtn, ok;
+ FrameLayout frameLayout, download;
+
+ private String[] columnsVariable = {"KIP ID", "CHILD'S NAME", "SEX", "DATE OF BIRTH (DD/MM/YYYY)",
+ "DATE FIRST SEEN", "FATHER'S FULL NAME", "MOTHER'S FULL NAME", "MOTHER'S PHONE NUMBER","VILLAGE/ESTATE/LANDMARK",
+ "TELEPHONE NUMBER", "BCG", "POLIO BIRTH DOSE", "OPV1", "OPV2", "OPV3","IPV", "DPT/HEP.B/HIB.1","DPT/HEP.B/HIB.2",
+ "DPT/HEP.B/HIB.3", "PCV 10 (PNEUMOCOCCAL) 1","PCV 10 (PNEUMOCOCCAL) 2","PCV 10 (PNEUMOCOCCAL) 3", "ROTA 1",
+ "ROTA 2", "VITAMIN A","MEASLES 1","YELLOW FEVER","Malaria 1","Malaria 2", "Malaria 3", "FULLY IMMUNIZED", "MEASLES 2 (MR 2)", "Malaria 4", "REMARKS"};
+
+ private List mohIndicators = Arrays.asList(columnsVariable);
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_moh510_report);
+ closeReport = findViewById(R.id.close_moh_510_report);
+
+ ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE}, PackageManager.PERMISSION_GRANTED);
+ endTextDate = findViewById(R.id.end_date);
+ startEditTextDate = findViewById(R.id.start_date);
+ startDateBtn = findViewById(R.id.start_date_button);
+ endDateBtn = findViewById(R.id.end_date_button);
+ customDateRangeBtn = findViewById(R.id.custom_date_button);
+ frameLayout = findViewById(R.id.custom_date);
+ download = findViewById(R.id.download);
+ ok = findViewById(R.id.ok);
+
+ cancel = findViewById(R.id.cancel);
+ cancel.setOnClickListener(this);
+ startDateBtn.setOnClickListener(this);
+ endDateBtn.setOnClickListener(this);
+ customDateRangeBtn.setOnClickListener(this);
+ closeReport.setOnClickListener(this);
+ ok.setOnClickListener(this);
+
+ if (startEditTextDate.getText().toString() == null){
+ startEditTextDate.setVisibility(View.GONE);
+ }
+ if (endTextDate.getText().toString()==null){
+ endTextDate.setVisibility(View.GONE);
+ }
+
+ }
+
+
+ @Override
+ public void onClick(View v) {
+
+ if (v == closeReport) {
+ Intent intent = new Intent(v.getContext(), ChildRegisterActivity.class);
+ startActivityForResult(intent, 0);
+ finish();
+ } else if (v == startDateBtn){
+
+ // Get Current Date
+ final Calendar c = Calendar.getInstance();
+ mYear = c.get(Calendar.YEAR);
+ mMonth = c.get(Calendar.MONTH);
+ mDay = c.get(Calendar.DAY_OF_MONTH);
+ DatePickerDialog datePickerDialog = new DatePickerDialog(this,
+ new DatePickerDialog.OnDateSetListener() {
+ @Override
+ public void onDateSet(android.widget.DatePicker view, int year, int month, int dayOfMonth) {
+ startEditTextDate.setText(dayOfMonth + "-" + "0"+(month + 1) + "-" + year);
+ }
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+
+
+ if (v == startDateBtn){
+ startEditTextDate.setVisibility(View.VISIBLE);
+ startDateBtn.setVisibility(View.GONE);
+ }if (v==endDateBtn){
+ endTextDate.setVisibility(View.VISIBLE);
+ endDateBtn.setVisibility(View.GONE);
+ }
+ } else if(v==cancel){
+ startEditTextDate.setText("");
+ endTextDate.setText("");
+ endDateBtn.setVisibility(View.VISIBLE);
+ startDateBtn.setVisibility(View.VISIBLE);
+ } else if (v == endDateBtn){
+
+ // Get Current Date
+ final Calendar c = Calendar.getInstance();
+ mYear = c.get(Calendar.YEAR);
+ mMonth = c.get(Calendar.MONTH);
+ mDay = c.get(Calendar.DAY_OF_MONTH);
+ DatePickerDialog datePickerDialog = new DatePickerDialog(this,
+ new DatePickerDialog.OnDateSetListener() {
+ @Override
+ public void onDateSet(android.widget.DatePicker view, int year, int month, int dayOfMonth) {
+
+ endTextDate.setText(dayOfMonth + "-" + "0"+(month + 1) + "-" + year);
+ }
+ }, mYear, mMonth, mDay);
+ datePickerDialog.show();
+
+
+ if (v == startDateBtn){
+ startEditTextDate.setVisibility(View.VISIBLE);
+ startDateBtn.setVisibility(View.GONE);
+ }if (v==endDateBtn){
+ endTextDate.setVisibility(View.VISIBLE);
+ endDateBtn.setVisibility(View.GONE);
+ }
+ } else if (v== customDateRangeBtn){
+ frameLayout.setVisibility(View.VISIBLE);
+ download.setVisibility(View.GONE);
+ } else if (v == ok){
+ buttonWriteToExcel(v);
+ Intent intent = new Intent(v.getContext(), ChildRegisterActivity.class);
+ startActivityForResult(intent, 0);
+ finish();
+ }
+
+ }
+
+ private String dateConverter(String date) {
+ if (date != null) {
+ Date dateParser = new Date(Long.parseLong(date));
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ return dateFormat.format(dateParser);
+ }
+ return null;
+ }
+
+ Map reportInfo =
+ new TreeMap();
+
+ public void buttonWriteToExcel(View view){
+ int i = 0;
+ for (Moh510SummaryReport report:getIndicatorValues()){
+ reportInfo.put(i++,new Object[]{report.getKipId(), getFullName(report.getChildFirstName(),report.getChildLastName()),report.getSex(),
+ report.getDob(), report.getDateFirstSeen(), getFullName(report.getFatherFirstName(), report.getFatherLastName()),getFullName(report.getMotherFirstName(),report.getMotherLastName()),
+ report.getMotherPhoneNumber(), report.getVillage(),report.getTelephone(), dateConverter(report.getBcg()),
+ dateConverter(report.getPolioBirthDose()), dateConverter(report.getOpv1()), dateConverter(report.getOpv2()),dateConverter(report.getOpv3()), dateConverter(report.getIpv()),
+ dateConverter(report.getDpt1()),dateConverter(report.getDpt2()),dateConverter(report.getDpt3()), dateConverter(report.getPcv1()), dateConverter(report.getPcv2()),dateConverter(report.getPcv3()), dateConverter(report.getRota1()),dateConverter(report.getRota2()),
+ dateConverter(report.getVitaminA()),dateConverter(report.getMeasles1()),dateConverter(report.getYellowFever()), dateConverter(report.getMalaria1()),dateConverter(report.getMalaria2()),dateConverter(report.getMalaria3()),dateConverter(report.getFullyImmunized()),dateConverter(report.getMeasles2()),dateConverter(report.getMalaria4())});
+ }
+
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+
+ HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
+ HSSFSheet sheets = hssfWorkbook.createSheet("ImmunizationRegister");
+ sheets.addMergedRegion(CellRangeAddress.valueOf("A1:E1"));
+ sheets.addMergedRegion(CellRangeAddress.valueOf("A2:E2"));
+
+ HSSFRow tittle = sheets.createRow(0);
+ HSSFRow facility = sheets.createRow(1);
+ HSSFRow year = sheets.createRow(2);
+ HSSFRow dateRange = sheets.createRow(3);
+ HSSFRow columnName = sheets.createRow(4);
+
+ HSSFCell tittleCell = tittle.createCell(0);
+
+ HSSFCell facilityCell = facility.createCell(0);
+ HSSFCell yearCell = year.createCell(0);
+ HSSFCell strStart = dateRange.createCell(0);
+ HSSFCell startDate = dateRange.createCell(1);
+ HSSFCell strEnd = dateRange.createCell(2);
+ HSSFCell endDate = dateRange.createCell(3);
+ tittleCell.setCellValue("Permanent Immunization Register(MOH 510)");
+ facilityCell.setCellValue("Health Facility: "+ LocationHelper.getInstance().getOpenMrsReadableName(KipChildUtils.getCurrentLocality()));
+ yearCell.setCellValue("Year of Enrollment: ");
+
+ strStart.setCellValue("Start Date");
+ strEnd.setCellValue("End Date");
+ endDate.setCellValue(endTextDate.getText().toString());
+ startDate.setCellValue(startEditTextDate.getText().toString());
+
+
+// Column names
+ for (int cell = 0; cell keyId = reportInfo.keySet();
+ for (Integer key: keyId){
+ queryRow = sheets.createRow(columnNumber++);
+ Object [] objectArr = reportInfo.get(key);
+ int cellId = 0;
+ for (Object obj:objectArr){
+ HSSFCell queryDataCell = queryRow.createCell(cellId++);
+ queryDataCell.setCellValue((String)obj);
+ }
+
+ }
+
+// for (int col = 0;col getIndicatorValues(){
+ List reportList = getMoh510SummaryReport();
+ return reportList;
+ }
+
+ @Override
+ public void onDateSet(android.widget.DatePicker view, int year, int month, int dayOfMonth) {
+ Calendar mCalender = Calendar.getInstance();
+ mCalender.set(Calendar.YEAR, year);
+ mCalender.set(Calendar.MONTH, month);
+ mCalender.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ String selectedDate = DateFormat.getDateInstance(DateFormat.FULL).format(mCalender.getTime());
+// endDate.setText(selectedDate);
+// startDate.setText(selectedDate);
+ }
+
+ private String dateFormat(String date){
+ String datFt = "";
+ try {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.US);
+ Date formDate = dateFormat.parse(date);
+
+ datFt = OpdUtils.convertDate(formDate,"yyyy-MM-dd'T'HH:mm:ss.SSS'+03:00'");
+ } catch (Exception e){
+ Timber.d("--->dateFormat %s",e.getMessage());
+ }
+
+ return datFt;
+ }
+
+ private List getMoh510SummaryReport(){
+ List moh510SummaryReports = new ArrayList<>();
+ SQLiteDatabase db = summaryReportRepository.getReadable();
+ Cursor sCursor = null;
+
+ String startDate = startEditTextDate.getText().toString();
+ String endDate = endTextDate.getText().toString();
+
+
+ try {
+ if ((startDate == null || startDate.isEmpty()) && (endDate == null || endDate.isEmpty())){
+ sCursor = db.rawQuery(summaryReportRepository.sql(),null);}
+ else {
+ sCursor = db.rawQuery(summaryReportRepository.sqlDateRange( dateFormat(startDate), dateFormat(endDate)),null);
+ }
+ moh510SummaryReports = summaryReportRepository.readAll(sCursor);
+ Timber.i("--->getMoh510SummaryReport: %s",sCursor);
+
+ } catch (Exception e){
+ Timber.d("-->getMoh510SummaryReport" + e.getMessage());
+ } finally {
+ if (sCursor !=null){
+ sCursor.close();
+ }
+ }
+ return moh510SummaryReports;
+ }
+
+ private String getFullName(String firstName, String lastName){
+ return firstName + " " + lastName;
+ }
+}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportRegisterActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportRegisterActivity.java
index 358979f..d3cd328 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportRegisterActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportRegisterActivity.java
@@ -97,7 +97,7 @@ public void onClickReport(View view) {
}
@Override
- public void onUniqueIdFetched(Triple triple, String s) {
+ public void onUniqueIdFetched(Triple, String> triple, String s) {
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportSummaryActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportSummaryActivity.java
index 9195c6d..38e4f82 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportSummaryActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/ReportSummaryActivity.java
@@ -26,6 +26,7 @@
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedHashMap;
+import java.util.Map;
/**
* Created by Ephraim Kigamba - ekigamba@ona.io on 2019-07-11
@@ -189,7 +190,7 @@ private void refreshIndicatorViews() {
}
@Override
- public void onUniqueIdFetched(Triple triple, String s) {
+ public void onUniqueIdFetched(Triple, String> triple, String s) {
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/activity/SmsActivity.java b/opensrp-kip/src/main/java/org/smartregister/kip/activity/SmsActivity.java
index 6fba8bf..6963044 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/activity/SmsActivity.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/activity/SmsActivity.java
@@ -20,7 +20,7 @@
import org.smartregister.kip.adapter.SmsEnrollmentAdapter;
import org.smartregister.kip.application.KipApplication;
import org.smartregister.kip.model.SmsEnrollementModel;
-import org.smartregister.kip.pojo.SmsErolledClient;
+import org.smartregister.kip.pojo.SmsEnrolledClient;
import org.smartregister.kip.repository.SmsEnrolledClientRepository;
import java.util.ArrayList;
@@ -157,11 +157,11 @@ private ArrayList getModel(boolean isSelected){
private List getFullName(){
List list = new ArrayList<>();
- SmsEnrolledClientRepository smsErolledClient = KipApplication.getInstance().smsEnrolledClientRepository();
- List enrolledClients = smsErolledClient.getEnrolledClients();
+ SmsEnrolledClientRepository smsEnrolledClient = KipApplication.getInstance().smsEnrolledClientRepository();
+ List enrolledClients = smsEnrolledClient.getEnrolledClients();
if (enrolledClients !=null){
- for (SmsErolledClient erolledClient : enrolledClients){
- list.add(erolledClient.getFirstName() + " " + erolledClient.getLastName() );
+ for (SmsEnrolledClient enrolledClient : enrolledClients){
+ list.add(enrolledClient.getFirstName() + " " + enrolledClient.getLastName() );
}
}
return list;
@@ -169,11 +169,11 @@ private List getFullName(){
public List getPhoneNumber(){
List list = new ArrayList<>();
- SmsEnrolledClientRepository smsErolledClient = KipApplication.getInstance().smsEnrolledClientRepository();
- List enrolledClients = smsErolledClient.getEnrolledClients();
+ SmsEnrolledClientRepository smsEnrolledClient = KipApplication.getInstance().smsEnrolledClientRepository();
+ List enrolledClients = smsEnrolledClient.getEnrolledClients();
if (enrolledClients !=null){
- for (SmsErolledClient erolledClient : enrolledClients){
- list.add(erolledClient.getPhoneNumber());
+ for (SmsEnrolledClient enrolledClient : enrolledClients){
+ list.add(enrolledClient.getPhoneNumber());
}
}
return list;
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/application/KipApplication.java b/opensrp-kip/src/main/java/org/smartregister/kip/application/KipApplication.java
index 9a6b5da..796e88e 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/application/KipApplication.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/application/KipApplication.java
@@ -67,6 +67,7 @@
import org.smartregister.kip.repository.KipLocationRepository;
import org.smartregister.kip.repository.KipOpdVisitSummaryRepository;
import org.smartregister.kip.repository.KipRepository;
+import org.smartregister.kip.repository.Moh510SummaryReportRepository;
import org.smartregister.kip.repository.MonthlyTalliesRepository;
import org.smartregister.kip.repository.OpdCovid19CalculateRiskRepository;
import org.smartregister.kip.repository.OpdCovid19VaccinationEligibilityRepository;
@@ -140,6 +141,7 @@ public class KipApplication extends DrishtiApplication implements TimeChangedBro
private OpdMedicalCheckFormRepository opdMedicalCheckAndVaccinateFormRepository;
private OpdInfluenzaVaccineAdministrationFormRepository opdInfluenzaVaccineAdministrationFormRepository;
private SmsEnrolledClientRepository smsEnrolledClientRepository;
+ private Moh510SummaryReportRepository moh510SummaryReportRepository;
public static JsonSpecHelper getJsonSpecHelper() {
@@ -369,13 +371,13 @@ public Repository getRepository() {
return repository;
}
- public String getPassword() {
- if (password == null) {
- String username = getContext().userService().getAllSharedPreferences().fetchRegisteredANM();
- password = getContext().userService().getGroupId(username);
- }
- return password;
- }
+// public String getPassword() {
+// if (password == null) {
+// String username = getContext().userService().getAllSharedPreferences().fetchRegisteredANM();
+// password = getContext().userService().getGroupId(username);
+// }
+// return password;
+// }
public Context getContext() {
return context;
@@ -464,13 +466,15 @@ public HeightZScoreRepository heightZScoreRepository() {
@Override
public void onTimeChanged() {
- context.userService().forceRemoteLogin();
+ String username = getContext().userService().getAllSharedPreferences().fetchRegisteredANM();
+ context.userService().forceRemoteLogin(username);
logoutCurrentUser();
}
@Override
public void onTimeZoneChanged() {
- context.userService().forceRemoteLogin();
+ String username = getContext().userService().getAllSharedPreferences().fetchRegisteredANM();
+ context.userService().forceRemoteLogin(username);
logoutCurrentUser();
}
@@ -624,6 +628,13 @@ public SmsEnrolledClientRepository smsEnrolledClientRepository(){
return smsEnrolledClientRepository;
}
+ public Moh510SummaryReportRepository moh510SummaryReportRepository(){
+ if (moh510SummaryReportRepository == null){
+ moh510SummaryReportRepository = new Moh510SummaryReportRepository();
+ }
+ return moh510SummaryReportRepository;
+ }
+
public void populateGlobalSettings() {
Setting setting = getSettings(KipConstants.Settings.VACCINE_STOCK_IDENTIFIER);
populateGlobalSettingsCore(setting);
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/application/KipSyncConfiguration.java b/opensrp-kip/src/main/java/org/smartregister/kip/application/KipSyncConfiguration.java
index 2620dd3..2ecee51 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/application/KipSyncConfiguration.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/application/KipSyncConfiguration.java
@@ -67,5 +67,20 @@ public String getTopAllowedLocationLevel() {
return null;
}
+ @Override
+ public String getOauthClientId() {
+ return BuildConfig.OAUTH_CLIENT_ID;
+ }
+
+ @Override
+ public String getOauthClientSecret() {
+ return BuildConfig.OAUTH_CLIENT_SECRET;
+ }
+
+ @Override
+ public Class extends BaseLoginActivity> getAuthenticationActivity() {
+ return null;
+ }
+
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/contract/KipOpdProfileVisitsFragmentContract.java b/opensrp-kip/src/main/java/org/smartregister/kip/contract/KipOpdProfileVisitsFragmentContract.java
index 962712c..07a211a 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/contract/KipOpdProfileVisitsFragmentContract.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/contract/KipOpdProfileVisitsFragmentContract.java
@@ -3,7 +3,6 @@
import androidx.annotation.NonNull;
import androidx.core.util.Pair;
-
import org.jeasy.rules.api.Facts;
import org.smartregister.kip.pojo.KipOpdVisitSummary;
import org.smartregister.opd.contract.OpdProfileVisitsFragmentContract;
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/cursor/CreateRemoteLocalCursor.java b/opensrp-kip/src/main/java/org/smartregister/kip/cursor/CreateRemoteLocalCursor.java
index 4143fba..00518c8 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/cursor/CreateRemoteLocalCursor.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/cursor/CreateRemoteLocalCursor.java
@@ -2,31 +2,40 @@
import android.database.Cursor;
-import org.smartregister.kip.util.KipConstants;
-
+import org.smartregister.child.util.DBConstants;
public class CreateRemoteLocalCursor {
private String id;
private String relationalId;
private String firstName;
private String lastName;
+ private String gender;
private String dob;
private String openSrpId;
+ private String motherFirstName;
+ private String motherLastName;
+ private String inactive;
+ private String lostToFollowUp;
private String phoneNumber;
private String altName;
public CreateRemoteLocalCursor(Cursor cursor, boolean isRemote) {
if (isRemote) {
- id = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.ID_LOWER_CASE));
+ id = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.ID_LOWER_CASE));
} else {
- id = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.BASE_ENTITY_ID));
+ id = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.BASE_ENTITY_ID));
}
- relationalId = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.RELATIONALID));
- firstName = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.FIRST_NAME));
- lastName = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.LAST_NAME));
- dob = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.DOB));
- openSrpId = cursor.getString(cursor.getColumnIndex(KipConstants.KEY.OPENMRS_ID));
+ relationalId = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.RELATIONALID));
+ firstName = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.FIRST_NAME));
+ lastName = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.LAST_NAME));
+ dob = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.DOB));
+ openSrpId = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.ZEIR_ID));
+ gender = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.GENDER));
+ motherFirstName = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.MOTHER_FIRST_NAME));
+ motherLastName = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.MOTHER_LAST_NAME));
+ inactive = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.INACTIVE));
+ lostToFollowUp = cursor.getString(cursor.getColumnIndex(DBConstants.KEY.LOST_TO_FOLLOW_UP));
}
public String getId() {
@@ -45,6 +54,10 @@ public String getLastName() {
return lastName;
}
+ public String getGender() {
+ return gender;
+ }
+
public String getDob() {
return dob;
}
@@ -61,7 +74,27 @@ public String getOpenSrpId() {
return openSrpId;
}
- public void setOpenSrpId(String openSrpId) {
- this.openSrpId = openSrpId;
+ public String getMotherFirstName() {
+ return motherFirstName;
+ }
+
+ public String getMotherLastName() {
+ return motherLastName;
+ }
+
+ public String getInactive() {
+ return inactive;
+ }
+
+ public void setInactive(String inactive) {
+ this.inactive = inactive;
+ }
+
+ public String getLostToFollowUp() {
+ return lostToFollowUp;
+ }
+
+ public void setLostToFollowUp(String lostToFollowUp) {
+ this.lostToFollowUp = lostToFollowUp;
}
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/dao/KipChildDao.java b/opensrp-kip/src/main/java/org/smartregister/kip/dao/KipChildDao.java
index 320c78d..0f7936a 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/dao/KipChildDao.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/dao/KipChildDao.java
@@ -1,75 +1,75 @@
-//package org.smartregister.kip.dao;
-//
-//import org.smartregister.child.domain.;
-//import org.smartregister.dao.AbstractDao;
-//
-//import java.util.ArrayList;
-//import java.util.List;
-//
-//public class KipChildDao extends ChildDao {
-//
-// public static List getChildrenAboveFiveYears() {
-// String sql = "SELECT ec_client.base_entity_id\n" +
-// "FROM ec_child_details\n" +
-// " JOIN ec_client ON ec_client.base_entity_id = ec_child_details.base_entity_id\n" +
-// "WHERE (julianday(strftime('%Y-%m-%d', 'now')) - julianday(strftime('%Y-%m-%d', ec_client.dob))) / 365 >= 5\n" +
-// " AND ec_client.is_closed = '0'\n" +
-// " AND ec_client.date_removed is null\n" +
-// " AND ec_child_details.is_closed = '0'";
-//
-// AbstractDao.DataMap dataMap = cursor -> getCursorValue(cursor, "base_entity_id");
-//
-// List result = readData(sql, dataMap);
-// if (result == null) return new ArrayList<>();
-// return result;
-// }
-//
-// public static String getBaseEntityIdByOpenSRPId(String openSRPId) {
-// String sql = String.format("SELECT base_entity_id\n" +
-// "FROM ec_client\n" +
-// "WHERE opensrp_id = '%s'\n" +
-// " AND ec_client.date_removed is null\n" +
-// " AND ec_client.dod is null\n" +
-// " AND ec_client.is_closed IS NOT '1';", openSRPId);
-//
-// AbstractDao.DataMap dataMap = cursor -> getCursorValue(cursor, "base_entity_id");
-//
-// List result = readData(sql, dataMap);
-// if (result == null || result.size() != 1)
-// return null;
-//
-// return result.get(0);
-// }
-//
-// public static boolean clientNeedsCard(String baseEntityId) {
-// String sql = String.format("SELECT count(*) as count\n" +
-// "FROM ec_child_details\n" +
-// "WHERE ec_child_details.card_status = 'needs_card' COLLATE NOCASE\n" +
-// " AND ec_child_details.date_removed is null\n" +
-// " AND ec_child_details.is_closed IS NOT '1'\n" +
-// " AND ec_child_details.base_entity_id = '%s' COLLATE NOCASE;", baseEntityId);
-//
-// AbstractDao.DataMap dataMap = cursor -> getCursorIntValue(cursor, "count");
-//
-// List result = readData(sql, dataMap);
-// if (result == null || result.size() != 1)
-// return false;
-//
-// return result.get(0) > 0;
-// }
-//
-// public static int getDueVaccineCount(String vaccine) {
-// String sql = "SELECT count(*) count\n" +
-// "FROM alerts\n" +
-// "WHERE scheduleName = '$s' COLLATE NOCASE\n" +
-// " AND startDate LIKE '%' || strftime('%Y-%m', date('now', 'start of month', '+1 month')) || '%'".replace("$s", vaccine);
-//
-// AbstractDao.DataMap dataMap = cursor -> getCursorIntValue(cursor, "count");
-//
-// List result = readData(sql, dataMap);
-// if (result == null || result.size() != 1)
-// return result.get(0);
-//
-// return 0;
-// }
-//}
+package org.smartregister.kip.dao;
+
+import org.smartregister.child.dao.ChildDao;
+import org.smartregister.dao.AbstractDao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class KipChildDao extends ChildDao {
+
+ public static List getChildrenAboveFiveYears() {
+ String sql = "SELECT ec_client.base_entity_id\n" +
+ "FROM ec_child_details\n" +
+ " JOIN ec_client ON ec_client.base_entity_id = ec_child_details.base_entity_id\n" +
+ "WHERE (julianday(strftime('%Y-%m-%d', 'now')) - julianday(strftime('%Y-%m-%d', ec_client.dob))) / 365 >= 5\n" +
+ " AND ec_client.is_closed = '0'\n" +
+ " AND ec_client.date_removed is null\n" +
+ " AND ec_child_details.is_closed = '0'";
+
+ AbstractDao.DataMap dataMap = cursor -> getCursorValue(cursor, "base_entity_id");
+
+ List result = readData(sql, dataMap);
+ if (result == null) return new ArrayList<>();
+ return result;
+ }
+
+ public static String getBaseEntityIdByOpenSRPId(String openSRPId) {
+ String sql = String.format("SELECT base_entity_id\n" +
+ "FROM ec_client\n" +
+ "WHERE opensrp_id = '%s'\n" +
+ " AND ec_client.date_removed is null\n" +
+ " AND ec_client.dod is null\n" +
+ " AND ec_client.is_closed IS NOT '1';", openSRPId);
+
+ AbstractDao.DataMap dataMap = cursor -> getCursorValue(cursor, "base_entity_id");
+
+ List result = readData(sql, dataMap);
+ if (result == null || result.size() != 1)
+ return null;
+
+ return result.get(0);
+ }
+
+ public static boolean clientNeedsCard(String baseEntityId) {
+ String sql = String.format("SELECT count(*) as count\n" +
+ "FROM ec_child_details\n" +
+ "WHERE ec_child_details.card_status = 'needs_card' COLLATE NOCASE\n" +
+ " AND ec_child_details.date_removed is null\n" +
+ " AND ec_child_details.is_closed IS NOT '1'\n" +
+ " AND ec_child_details.base_entity_id = '%s' COLLATE NOCASE;", baseEntityId);
+
+ AbstractDao.DataMap dataMap = cursor -> getCursorIntValue(cursor, "count");
+
+ List result = readData(sql, dataMap);
+ if (result == null || result.size() != 1)
+ return false;
+
+ return result.get(0) > 0;
+ }
+
+ public static int getDueVaccineCount(String vaccine) {
+ String sql = "SELECT count(*) count\n" +
+ "FROM alerts\n" +
+ "WHERE scheduleName = '$s' COLLATE NOCASE\n" +
+ " AND startDate LIKE '%' || strftime('%Y-%m', date('now', 'start of month', '+1 month')) || '%'".replace("$s", vaccine);
+
+ AbstractDao.DataMap dataMap = cursor -> getCursorIntValue(cursor, "count");
+
+ List result = readData(sql, dataMap);
+ if (result == null || result.size() != 1)
+ return result.get(0);
+
+ return 0;
+ }
+}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/fragment/CustomDateRangeDialogFragment.java b/opensrp-kip/src/main/java/org/smartregister/kip/fragment/CustomDateRangeDialogFragment.java
index 0c7c541..e48d6ec 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/fragment/CustomDateRangeDialogFragment.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/fragment/CustomDateRangeDialogFragment.java
@@ -55,7 +55,7 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
- ViewGroup dialogView = (ViewGroup) inflater.inflate(R.layout.custom_date_range_dialog_view, container, false);
+ ViewGroup dialogView = (ViewGroup) inflater.inflate(R.layout.moh510_content_view, container, false);
final EditText startDateView = (EditText) dialogView.findViewById(R.id.start_date);
final EditText endDateView = (EditText) dialogView.findViewById(R.id.end_date);
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/fragment/KipOpdProfileOverviewFragment.java b/opensrp-kip/src/main/java/org/smartregister/kip/fragment/KipOpdProfileOverviewFragment.java
index 85a6b93..e0f602e 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/fragment/KipOpdProfileOverviewFragment.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/fragment/KipOpdProfileOverviewFragment.java
@@ -2,12 +2,6 @@
import android.os.Bundle;
import androidx.annotation.NonNull;
-import androidx.appcompat.app.AlertDialog;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.fragment.app.FragmentActivity;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,6 +9,12 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.appcompat.app.AlertDialog;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.fragment.app.FragmentActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.smartregister.commonregistry.CommonPersonObjectClient;
@@ -180,7 +180,7 @@ protected void onResumption() {
opdCheckedInTv.setText(R.string.opd_checked_in);
showDiagnoseAndTreatBtn();
- showInfluenzaMedicalConditionBtn();
+ showInfluenzaMedicalConditionBtn();
if (StringUtils.isNotEmpty(((KipOpdProfileActivity) activity).getOpdMedicalCheck())) {
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/interactor/KipOpdProfileVisitsFragmentInteractor.java b/opensrp-kip/src/main/java/org/smartregister/kip/interactor/KipOpdProfileVisitsFragmentInteractor.java
index baed90d..7483aa0 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/interactor/KipOpdProfileVisitsFragmentInteractor.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/interactor/KipOpdProfileVisitsFragmentInteractor.java
@@ -5,7 +5,10 @@
import org.smartregister.kip.application.KipApplication;
import org.smartregister.kip.contract.KipOpdProfileVisitsFragmentContract;
import org.smartregister.kip.pojo.KipOpdVisitSummary;
+import org.smartregister.opd.OpdLibrary;
+import org.smartregister.opd.contract.OpdProfileVisitsFragmentContract;
import org.smartregister.opd.interactor.OpdProfileVisitsFragmentInteractor;
+import org.smartregister.opd.pojo.OpdVisitSummary;
import org.smartregister.opd.utils.AppExecutors;
import java.util.List;
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/interactor/SettingsInteractor.java b/opensrp-kip/src/main/java/org/smartregister/kip/interactor/SettingsInteractor.java
index 2f410e2..b1efd6d 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/interactor/SettingsInteractor.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/interactor/SettingsInteractor.java
@@ -49,6 +49,7 @@ public void saveCovid19VaccineStockSettings(Map covid19VaccineSt
settingObject = new JSONObject(covid19VaccineStockSettings.getValue());
}
localSettings = settingObject.has(AllConstants.SETTINGS) ? settingObject.getJSONArray(AllConstants.SETTINGS) : null;
+
if (localSettings != null) {
for (int i = 0; i < localSettings.length(); i++) {
JSONObject localSetting = localSettings.getJSONObject(i);
@@ -60,8 +61,10 @@ public void saveCovid19VaccineStockSettings(Map covid19VaccineSt
updateSettings(covid19VaccineStockSettingsMap, localSetting, KipConstants.SINOVAC_VIALS_AMOUNT);
} else if (localSetting.getString(KipConstants.KeyUtils.KEY).equalsIgnoreCase(KipConstants.PFIZER_VIALS_AMOUNT)) {
updateSettings(covid19VaccineStockSettingsMap, localSetting, KipConstants.PFIZER_VIALS_AMOUNT);
- } else {
+ } else if (localSetting.getString(KipConstants.KeyUtils.KEY).equalsIgnoreCase(KipConstants.MODERNA_VIALS_AMOUNT)){
updateSettings(covid19VaccineStockSettingsMap, localSetting, KipConstants.MODERNA_VIALS_AMOUNT);
+ } else{
+ updateSettings(covid19VaccineStockSettingsMap, localSetting, KipConstants.JOHNSON_AND_JOHNSON_VIALS_AMOUNT);
}
}
}
@@ -84,7 +87,7 @@ protected AllSettings getAllSettingsRepo() {
}
private Boolean getPropertyForInitialSaveAction(Context context) {
- String value = Utils.getProperties(context).getProperty(KipConstants.Properties.CAN_SAVE_SITE_INITIAL_SETTING, "false");
+ String value = Utils.getProperties(context).getProperty(KipConstants.Properties.CAN_SAVE_SITE_INITIAL_SETTING, "true");
return Boolean.valueOf(value);
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/listener/DatePicker.java b/opensrp-kip/src/main/java/org/smartregister/kip/listener/DatePicker.java
new file mode 100644
index 0000000..af1e540
--- /dev/null
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/listener/DatePicker.java
@@ -0,0 +1,25 @@
+package org.smartregister.kip.listener;
+
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+
+import java.util.Calendar;
+
+public class DatePicker extends DialogFragment {
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
+ Calendar mCalender = Calendar.getInstance();
+ int year = mCalender.get(Calendar.YEAR);
+ int month = mCalender.get(Calendar.MONTH);
+ int dayOfMonth = mCalender.get(Calendar.DAY_OF_MONTH);
+ return new DatePickerDialog(getActivity(), (DatePickerDialog.OnDateSetListener)
+ getActivity(), year, month, dayOfMonth);
+ }
+}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/listener/DateRangeActionListener.java b/opensrp-kip/src/main/java/org/smartregister/kip/listener/DateRangeActionListener.java
old mode 100755
new mode 100644
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/pojo/Moh510SummaryReport.java b/opensrp-kip/src/main/java/org/smartregister/kip/pojo/Moh510SummaryReport.java
new file mode 100644
index 0000000..b62492c
--- /dev/null
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/pojo/Moh510SummaryReport.java
@@ -0,0 +1,381 @@
+package org.smartregister.kip.pojo;
+
+public class Moh510SummaryReport {
+ private String kipId;
+ private String childFirstName;
+ private String childLastName;
+ private String sex;
+ private String dob;
+ private String dateFirstSeen;
+ private String fatherFirstName;
+ private String motherFirstName;
+ private String fatherLastName;
+ private String motherLastName;
+ private String motherPhoneNumber;
+ private String village;
+ private String telephone;
+ private String bcg;
+ private String polioBirthDose;
+ private String opv1;
+ private String opv2;
+ private String opv3;
+ private String ipv;
+ private String dpt1;
+ private String dpt2;
+ private String dpt3;
+ private String pcv1;
+ private String pcv2;
+ private String pcv3;
+ private String rota1;
+ private String rota2;
+ private String vitaminA;
+ private String measles1;
+ private String yellowFever;
+ private String malaria1;
+ private String malaria2;
+ private String malaria3;
+ private String fullyImmunized;
+ private String measles2;
+ private String malaria4;
+ private String remarks;
+
+
+ public String getKipId() {
+ return kipId;
+ }
+
+ public void setKipId(String kipId) {
+ this.kipId = kipId;
+ }
+
+ public String getChildFirstName() {
+ return childFirstName;
+ }
+
+ public String getChildLastName() {
+ return childLastName;
+ }
+
+ public void setChildLastName(String childLastName) {
+ this.childLastName = childLastName;
+ }
+
+ public String getFatherLastName() {
+ return fatherLastName;
+ }
+
+ public void setFatherLastName(String fatherLastName) {
+ this.fatherLastName = fatherLastName;
+ }
+
+ public String getMotherLastName() {
+ return motherLastName;
+ }
+
+ public void setMotherLastName(String motherLastName) {
+ this.motherLastName = motherLastName;
+ }
+
+ public void setChildFirstName(String childFirstName) {
+ this.childFirstName = childFirstName;
+ }
+
+ public String getSex() {
+ return sex;
+ }
+
+ public void setSex(String sex) {
+ this.sex = sex;
+ }
+
+ public String getDob() {
+ return dob;
+ }
+
+ public void setDob(String dob) {
+ this.dob = dob;
+ }
+
+ public String getDateFirstSeen() {
+ return dateFirstSeen;
+ }
+
+ public void setDateFirstSeen(String dateFirstSeen) {
+ this.dateFirstSeen = dateFirstSeen;
+ }
+
+ public String getFatherFirstName() {
+ return fatherFirstName;
+ }
+
+ public void setFatherFirstName(String fatherFirstName) {
+ this.fatherFirstName = fatherFirstName;
+ }
+
+ public String getMotherFirstName() {
+ return motherFirstName;
+ }
+
+ public void setMotherFirstName(String motherFirstName) {
+ this.motherFirstName = motherFirstName;
+ }
+
+ public String getMotherPhoneNumber() {
+ return motherPhoneNumber;
+ }
+
+ public void setMotherPhoneNumber(String motherPhoneNumber) {
+ this.motherPhoneNumber = motherPhoneNumber;
+ }
+
+ public String getVillage() {
+ return village;
+ }
+
+ public void setVillage(String village) {
+ this.village = village;
+ }
+
+ public String getTelephone() {
+ return telephone;
+ }
+
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+ public String getBcg() {
+ return bcg;
+ }
+
+ public void setBcg(String bcg) {
+ this.bcg = bcg;
+ }
+
+ public String getPolioBirthDose() {
+ return polioBirthDose;
+ }
+
+ public void setPolioBirthDose(String polioBirthDose) {
+ this.polioBirthDose = polioBirthDose;
+ }
+
+ public String getOpv1() {
+ return opv1;
+ }
+
+ public void setOpv1(String opv1) {
+ this.opv1 = opv1;
+ }
+
+ public String getOpv2() {
+ return opv2;
+ }
+
+ public void setOpv2(String opv2) {
+ this.opv2 = opv2;
+ }
+
+ public String getOpv3() {
+ return opv3;
+ }
+
+ public void setOpv3(String opv3) {
+ this.opv3 = opv3;
+ }
+
+ public String getIpv() {
+ return ipv;
+ }
+
+ public void setIpv(String ipv) {
+ this.ipv = ipv;
+ }
+
+ public String getDpt1() {
+ return dpt1;
+ }
+
+ public void setDpt1(String dpt1) {
+ this.dpt1 = dpt1;
+ }
+
+ public String getDpt2() {
+ return dpt2;
+ }
+
+ public void setDpt2(String dpt2) {
+ this.dpt2 = dpt2;
+ }
+
+ public String getDpt3() {
+ return dpt3;
+ }
+
+ public void setDpt3(String dpt3) {
+ this.dpt3 = dpt3;
+ }
+
+ public String getPcv1() {
+ return pcv1;
+ }
+
+ public void setPcv1(String pcv1) {
+ this.pcv1 = pcv1;
+ }
+
+ public String getPcv2() {
+ return pcv2;
+ }
+
+ public void setPcv2(String pcv2) {
+ this.pcv2 = pcv2;
+ }
+
+ public String getPcv3() {
+ return pcv3;
+ }
+
+ public void setPcv3(String pcv3) {
+ this.pcv3 = pcv3;
+ }
+
+ public String getRota1() {
+ return rota1;
+ }
+
+ public void setRota1(String rota1) {
+ this.rota1 = rota1;
+ }
+
+ public String getRota2() {
+ return rota2;
+ }
+
+ public void setRota2(String rota2) {
+ this.rota2 = rota2;
+ }
+
+ public String getVitaminA() {
+ return vitaminA;
+ }
+
+ public void setVitaminA(String vitaminA) {
+ this.vitaminA = vitaminA;
+ }
+
+ public String getMeasles1() {
+ return measles1;
+ }
+
+ public void setMeasles1(String measles1) {
+ this.measles1 = measles1;
+ }
+
+ public String getYellowFever() {
+ return yellowFever;
+ }
+
+ public void setYellowFever(String yellowFever) {
+ this.yellowFever = yellowFever;
+ }
+
+ public String getFullyImmunized() {
+ return fullyImmunized;
+ }
+
+ public void setFullyImmunized(String fullyImmunized) {
+ this.fullyImmunized = fullyImmunized;
+ }
+
+ public String getMeasles2() {
+ return measles2;
+ }
+
+ public void setMeasles2(String measles2) {
+ this.measles2 = measles2;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public String getMalaria1() {
+ return malaria1;
+ }
+
+ public void setMalaria1(String malaria1) {
+ this.malaria1 = malaria1;
+ }
+
+ public String getMalaria2() {
+ return malaria2;
+ }
+
+ public void setMalaria2(String malaria2) {
+ this.malaria2 = malaria2;
+ }
+
+ public String getMalaria3() {
+ return malaria3;
+ }
+
+ public void setMalaria3(String malaria3) {
+ this.malaria3 = malaria3;
+ }
+
+ public String getMalaria4() {
+ return malaria4;
+ }
+
+ public void setMalaria4(String malaria4) {
+ this.malaria4 = malaria4;
+ }
+
+ @Override
+ public String toString() {
+ return "Moh510SummaryReport{" +
+ "kipId='" + kipId + '\'' +
+ ", childFirstName='" + childFirstName + '\'' +
+ ", childLastName='" + childLastName + '\'' +
+ ", sex='" + sex + '\'' +
+ ", dob='" + dob + '\'' +
+ ", dateFirstSeen='" + dateFirstSeen + '\'' +
+ ", fatherFirstName='" + fatherFirstName + '\'' +
+ ", motherFirstName='" + motherFirstName + '\'' +
+ ", fatherLastName='" + fatherLastName + '\'' +
+ ", motherLastName='" + motherLastName + '\'' +
+ ", motherPhoneNumber='" + motherPhoneNumber + '\'' +
+ ", village='" + village + '\'' +
+ ", telephone='" + telephone + '\'' +
+ ", bcg='" + bcg + '\'' +
+ ", polioBirthDose='" + polioBirthDose + '\'' +
+ ", opv1='" + opv1 + '\'' +
+ ", opv2='" + opv2 + '\'' +
+ ", opv3='" + opv3 + '\'' +
+ ", ipv='" + ipv + '\'' +
+ ", dpt1='" + dpt1 + '\'' +
+ ", dpt2='" + dpt2 + '\'' +
+ ", dpt3='" + dpt3 + '\'' +
+ ", pcv1='" + pcv1 + '\'' +
+ ", pcv2='" + pcv2 + '\'' +
+ ", pcv3='" + pcv3 + '\'' +
+ ", rota1='" + rota1 + '\'' +
+ ", rota2='" + rota2 + '\'' +
+ ", vitaminA='" + vitaminA + '\'' +
+ ", measles1='" + measles1 + '\'' +
+ ", yellowFever='" + yellowFever + '\'' +
+ ", malaria1='" + malaria1 + '\'' +
+ ", malaria2='" + malaria2 + '\'' +
+ ", malaria3='" + malaria3 + '\'' +
+ ", fullyImmunized='" + fullyImmunized + '\'' +
+ ", measles2='" + measles2 + '\'' +
+ ", malaria4='" + malaria4 + '\'' +
+ ", remarks='" + remarks + '\'' +
+ '}';
+ }
+}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/pojo/SmsErolledClient.java b/opensrp-kip/src/main/java/org/smartregister/kip/pojo/SmsEnrolledClient.java
similarity index 96%
rename from opensrp-kip/src/main/java/org/smartregister/kip/pojo/SmsErolledClient.java
rename to opensrp-kip/src/main/java/org/smartregister/kip/pojo/SmsEnrolledClient.java
index 3276a97..2c878c5 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/pojo/SmsErolledClient.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/pojo/SmsEnrolledClient.java
@@ -1,6 +1,6 @@
package org.smartregister.kip.pojo;
-public class SmsErolledClient {
+public class SmsEnrolledClient {
private String phoneNumber;
private String firstName;
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/processor/KipProcessorForJava.java b/opensrp-kip/src/main/java/org/smartregister/kip/processor/KipProcessorForJava.java
index 1bcb91d..c0be1c3 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/processor/KipProcessorForJava.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/processor/KipProcessorForJava.java
@@ -21,7 +21,7 @@
import org.json.JSONObject;
import org.smartregister.CoreLibrary;
import org.smartregister.child.util.ChildDbUtils;
-import org.smartregister.child.util.JsonFormUtils;
+import org.smartregister.child.util.ChildJsonFormUtils;
import org.smartregister.child.util.Constants;
import org.smartregister.child.util.MoveToMyCatchmentUtils;
import org.smartregister.child.util.Utils;
@@ -29,10 +29,10 @@
import org.smartregister.commonregistry.AllCommonsRepository;
import org.smartregister.commonregistry.CommonFtsObject;
import org.smartregister.commonregistry.CommonRepository;
-import org.smartregister.domain.db.Client;
-import org.smartregister.domain.db.Event;
+import org.smartregister.domain.Client;
+import org.smartregister.domain.Event;
import org.smartregister.domain.db.EventClient;
-import org.smartregister.domain.db.Obs;
+import org.smartregister.domain.Obs;
import org.smartregister.domain.jsonmapping.ClientClassification;
import org.smartregister.domain.jsonmapping.ClientField;
import org.smartregister.domain.jsonmapping.Column;
@@ -94,7 +94,7 @@
import timber.log.Timber;
-public class KipProcessorForJava extends ClientProcessorForJava implements MiniClientProcessorForJava {
+public class KipProcessorForJava extends OpdMiniClientProcessorForJava implements MiniClientProcessorForJava {
private static KipProcessorForJava instance;
@@ -169,7 +169,7 @@ public synchronized void processClient(List eventClients) throws Ex
continue;
}
processService(eventClient, serviceTable);
- } else if (eventType.equals(JsonFormUtils.BCG_SCAR_EVENT)) {
+ } else if (eventType.equals(ChildJsonFormUtils.BCG_SCAR_EVENT)) {
processBCGScarEvent(eventClient);
} else if (eventType.equals(MoveToMyCatchmentUtils.MOVE_TO_CATCHMENT_EVENT)) {
unsyncEvents.add(event);
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/repository/KipRepository.java b/opensrp-kip/src/main/java/org/smartregister/kip/repository/KipRepository.java
index 67ed40e..9b88b07 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/repository/KipRepository.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/repository/KipRepository.java
@@ -184,8 +184,8 @@ private void upgradeToVersion11CreateHia2IndicatorsRepository(SQLiteDatabase db)
@Override
public SQLiteDatabase getReadableDatabase() {
- String pass = KipApplication.getInstance().getPassword();
- if (StringUtils.isNotBlank(pass)) {
+ byte[] pass = KipApplication.getInstance().getPassword();
+ if (pass != null && pass.length > 0) {
return getReadableDatabase(pass);
} else {
throw new IllegalStateException("Password is blank");
@@ -194,14 +194,15 @@ public SQLiteDatabase getReadableDatabase() {
@Override
public SQLiteDatabase getWritableDatabase() {
- String pass = KipApplication.getInstance().getPassword();
- if (StringUtils.isNotBlank(pass)) {
- return getReadableDatabase(pass);
+ byte[] pass = KipApplication.getInstance().getPassword();
+ if (pass != null && pass.length > 0) {
+ return getWritableDatabase(pass);
} else {
throw new IllegalStateException("Password is blank");
}
}
+
@Override
public synchronized SQLiteDatabase getWritableDatabase(String password) {
if (writableDatabase == null || !writableDatabase.isOpen()) {
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/repository/Moh510SummaryReportRepository.java b/opensrp-kip/src/main/java/org/smartregister/kip/repository/Moh510SummaryReportRepository.java
new file mode 100644
index 0000000..1923f1b
--- /dev/null
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/repository/Moh510SummaryReportRepository.java
@@ -0,0 +1,148 @@
+package org.smartregister.kip.repository;
+
+import net.sqlcipher.Cursor;
+import net.sqlcipher.database.SQLiteDatabase;
+
+import org.smartregister.kip.pojo.Moh510SummaryReport;
+import org.smartregister.repository.BaseRepository;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Moh510SummaryReportRepository extends BaseRepository {
+
+ public String sql(){
+ String sql = "SELECT client.opensrp_id AS kip_id, child_details.first_name AS child_first_name , child_details.last_name AS child_last_name,\n" +
+ " client.gender As sex, strftime('%d/%m/%Y',child_details.dob) AS dob, strftime('%d/%m/%Y',client.date) AS date_first_seen, father_details.first_name AS father_first_name, father_details.last_name AS father_last_name,\n" +
+ " mother_details.first_name AS mother_first_name, mother_details.last_name AS mother_last_name,\n" +
+ " mother_details.phone_number AS mother_phone, client.village, mother_details.phone_number AS telephone_number,\n" +
+ " SUM(CASE WHEN vaccines.name = 'bcg' THEN vaccines.date ELSE Null END) \"bcg\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_0' THEN vaccines.date ELSE Null END) \"polio_birth_dose\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_1' THEN vaccines.date ELSE Null END) \"opv1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_2' THEN vaccines.date ELSE Null END) \"opv2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_3' THEN vaccines.date ELSE Null END) \"opv3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'ipv' THEN vaccines.date ELSE Null END) \"ipv\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'penta_1' THEN vaccines.date ELSE Null END) \"penta1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'penta_2' THEN vaccines.date ELSE Null END) \"penta2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'penta_3' THEN vaccines.date ELSE Null END) \"penta3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'pcv_1' THEN vaccines.date ELSE Null END) \"pcv1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'pcv_2' THEN vaccines.date ELSE Null END) \"pcv2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'pcv_3' THEN vaccines.date ELSE Null END) \"pcv3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'rota_1' THEN vaccines.date ELSE Null END) \"rota1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'rota_2' THEN vaccines.date ELSE Null END) \"rota2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mr_1' THEN vaccines.date ELSE Null END) \"mr1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'vitamin_a' THEN vaccines.date ELSE Null END) \"vitamin_a\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'yellow_fever' THEN vaccines.date ELSE Null END) \"yellow_fever\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_1' THEN vaccines.date ELSE Null END) \"mv1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_2' THEN vaccines.date ELSE Null END) \"mv2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_3' THEN vaccines.date ELSE Null END) \"mv3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mr_1' THEN vaccines.date ELSE Null END) \"fully_immunized\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mr_2' THEN vaccines.date ELSE Null END) \"mr2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_4' THEN vaccines.date ELSE Null END) \"mv4\"\n" +
+ "FROM ec_child_details child_details\n" +
+ "LEFT OUTER JOIN ec_mother_details mother_details ON child_details.relational_id = mother_details.base_entity_id\n" +
+ "LEFT JOIN ec_father_details father_details ON child_details.father_relational_id = father_details.base_entity_id\n" +
+ "LEFT JOIN ec_client client ON child_details.base_entity_id = client.base_entity_id\n" +
+ "LEFT JOIN vaccines ON vaccines.base_entity_id = child_details.base_entity_id\n" +
+ "GROUP BY kip_id;";
+
+ return sql;
+ }
+
+ public String sqlDateRange( String startDate, String endDate){
+ String sql = "SELECT client.opensrp_id AS kip_id, child_details.first_name AS child_first_name , child_details.last_name AS child_last_name,\n" +
+ " client.gender As sex, strftime('%d/%m/%Y',child_details.dob) AS dob, strftime('%d/%m/%Y',client.date) AS date_first_seen, father_details.first_name AS father_first_name, father_details.last_name AS father_last_name,\n" +
+ " mother_details.first_name AS mother_first_name, mother_details.last_name AS mother_last_name,\n" +
+ " mother_details.phone_number AS mother_phone, client.village, mother_details.phone_number AS telephone_number,\n" +
+ " SUM(CASE WHEN vaccines.name = 'bcg' THEN vaccines.date ELSE Null END) \"bcg\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_0' THEN vaccines.date ELSE Null END) \"polio_birth_dose\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_1' THEN vaccines.date ELSE Null END) \"opv1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_2' THEN vaccines.date ELSE Null END) \"opv2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'opv_3' THEN vaccines.date ELSE Null END) \"opv3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'ipv' THEN vaccines.date ELSE Null END) \"ipv\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'penta_1' THEN vaccines.date ELSE Null END) \"penta1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'penta_2' THEN vaccines.date ELSE Null END) \"penta2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'penta_3' THEN vaccines.date ELSE Null END) \"penta3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'pcv_1' THEN vaccines.date ELSE Null END) \"pcv1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'pcv_2' THEN vaccines.date ELSE Null END) \"pcv2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'pcv_3' THEN vaccines.date ELSE Null END) \"pcv3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'rota_1' THEN vaccines.date ELSE Null END) \"rota1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'rota_2' THEN vaccines.date ELSE Null END) \"rota2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mr_1' THEN vaccines.date ELSE Null END) \"mr1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'vitamin_a' THEN vaccines.date ELSE Null END) \"vitamin_a\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'yellow_fever' THEN vaccines.date ELSE Null END) \"yellow_fever\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_1' THEN vaccines.date ELSE Null END) \"mv1\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_2' THEN vaccines.date ELSE Null END) \"mv2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_3' THEN vaccines.date ELSE Null END) \"mv3\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mr_1' THEN vaccines.date ELSE Null END) \"fully_immunized\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mr_2' THEN vaccines.date ELSE Null END) \"mr2\",\n" +
+ " SUM(CASE WHEN vaccines.name = 'mv_4' THEN vaccines.date ELSE Null END) \"mv4\"\n" +
+ "FROM ec_child_details child_details\n" +
+ "LEFT OUTER JOIN ec_mother_details mother_details ON child_details.relational_id = mother_details.base_entity_id\n" +
+ "LEFT JOIN ec_father_details father_details ON child_details.father_relational_id = father_details.base_entity_id\n" +
+ "LEFT JOIN ec_client client ON child_details.base_entity_id = client.base_entity_id\n" +
+ "LEFT JOIN vaccines ON vaccines.base_entity_id = child_details.base_entity_id\n" +
+ "WHERE client.date BETWEEN '"+startDate+"' AND '"+endDate+"'\n" +
+ "GROUP BY kip_id;";
+
+ return sql;
+ }
+
+ public SQLiteDatabase getReadable(){
+ return getReadableDatabase();
+ }
+
+ public Moh510SummaryReport getMoh510SummaryReport(Cursor cursor){
+ Moh510SummaryReport moh510SummaryReport = new Moh510SummaryReport();
+ moh510SummaryReport.setKipId(cursor.getString(cursor.getColumnIndex("kip_id")));
+ moh510SummaryReport.setChildFirstName(cursor.getString(cursor.getColumnIndex("child_first_name")));
+ moh510SummaryReport.setChildLastName(cursor.getString(cursor.getColumnIndex("child_last_name")));
+ moh510SummaryReport.setSex(cursor.getString(cursor.getColumnIndex("sex")));
+ moh510SummaryReport.setDob(cursor.getString(cursor.getColumnIndex("dob")));
+ moh510SummaryReport.setDateFirstSeen(cursor.getString(cursor.getColumnIndex("date_first_seen")));
+ moh510SummaryReport.setFatherFirstName(cursor.getString(cursor.getColumnIndex("father_first_name")));
+ moh510SummaryReport.setFatherLastName(cursor.getString(cursor.getColumnIndex("father_last_name")));
+ moh510SummaryReport.setMotherFirstName(cursor.getString(cursor.getColumnIndex("mother_first_name")));
+ moh510SummaryReport.setMotherLastName(cursor.getString(cursor.getColumnIndex("mother_last_name")));
+ moh510SummaryReport.setMotherPhoneNumber(cursor.getString(cursor.getColumnIndex("mother_phone")));
+ moh510SummaryReport.setVillage(cursor.getString(cursor.getColumnIndex("village")));
+ moh510SummaryReport.setTelephone(cursor.getString(cursor.getColumnIndex("telephone_number")));
+ moh510SummaryReport.setBcg(cursor.getString(cursor.getColumnIndex("bcg")));
+ moh510SummaryReport.setPolioBirthDose(cursor.getString(cursor.getColumnIndex("polio_birth_dose")));
+ moh510SummaryReport.setOpv1(cursor.getString(cursor.getColumnIndex("opv1")));
+ moh510SummaryReport.setOpv2(cursor.getString(cursor.getColumnIndex("opv2")));
+ moh510SummaryReport.setOpv3(cursor.getString(cursor.getColumnIndex("opv3")));
+ moh510SummaryReport.setIpv(cursor.getString(cursor.getColumnIndex("ipv")));
+ moh510SummaryReport.setDpt1(cursor.getString(cursor.getColumnIndex("penta1")));
+ moh510SummaryReport.setDpt2(cursor.getString(cursor.getColumnIndex("penta2")));
+ moh510SummaryReport.setDpt3(cursor.getString(cursor.getColumnIndex("penta3")));
+ moh510SummaryReport.setPcv1(cursor.getString(cursor.getColumnIndex("pcv1")));
+ moh510SummaryReport.setPcv2(cursor.getString(cursor.getColumnIndex("pcv2")));
+ moh510SummaryReport.setPcv3(cursor.getString(cursor.getColumnIndex("pcv3")));
+ moh510SummaryReport.setRota1(cursor.getString(cursor.getColumnIndex("rota1")));
+ moh510SummaryReport.setRota2(cursor.getString(cursor.getColumnIndex("rota2")));
+ moh510SummaryReport.setVitaminA(cursor.getString(cursor.getColumnIndex("vitamin_a")));
+ moh510SummaryReport.setMeasles1(cursor.getString(cursor.getColumnIndex("mr1")));
+ moh510SummaryReport.setYellowFever(cursor.getString(cursor.getColumnIndex("yellow_fever")));
+ moh510SummaryReport.setMalaria1(cursor.getString(cursor.getColumnIndex("mv1")));
+ moh510SummaryReport.setMalaria2(cursor.getString(cursor.getColumnIndex("mv2")));
+ moh510SummaryReport.setMalaria3(cursor.getString(cursor.getColumnIndex("mv3")));
+ moh510SummaryReport.setFullyImmunized(cursor.getString(cursor.getColumnIndex("fully_immunized")));
+ moh510SummaryReport.setMeasles2(cursor.getString(cursor.getColumnIndex("mr2")));
+ moh510SummaryReport.setMalaria4(cursor.getString(cursor.getColumnIndex("mv4")));
+ moh510SummaryReport.setRemarks(cursor.getString(cursor.getColumnIndex("mv1")));
+ return moh510SummaryReport;
+ }
+
+ public List readAll(Cursor cursor){
+ List moh510SummaryReports = new ArrayList<>();
+ if (cursor !=null && cursor.getCount() > 0 && cursor.moveToNext()){
+ cursor.moveToFirst();
+ while (cursor.getCount() > 0 && !cursor.isAfterLast()){
+ moh510SummaryReports.add(getMoh510SummaryReport(cursor));
+ cursor.moveToNext();
+ }
+ }
+ return moh510SummaryReports;
+ }
+}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/repository/SmsEnrolledClientRepository.java b/opensrp-kip/src/main/java/org/smartregister/kip/repository/SmsEnrolledClientRepository.java
index bd2f5d5..292931e 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/repository/SmsEnrolledClientRepository.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/repository/SmsEnrolledClientRepository.java
@@ -4,7 +4,7 @@
import net.sqlcipher.Cursor;
import net.sqlcipher.database.SQLiteDatabase;
-import org.smartregister.kip.pojo.SmsErolledClient;
+import org.smartregister.kip.pojo.SmsEnrolledClient;
import org.smartregister.repository.BaseRepository;
import java.util.ArrayList;
@@ -14,8 +14,8 @@
public class SmsEnrolledClientRepository extends BaseRepository {
- public List getEnrolledClients(){
- List smsErolledClient = new ArrayList<>();
+ public List getEnrolledClients(){
+ List smsEnrolledClient = new ArrayList<>();
SQLiteDatabase db = getReadableDatabase();
Cursor sCursor = null;
@@ -24,7 +24,7 @@ public List getEnrolledClients(){
try {
sCursor = db.rawQuery(sql,null);
- smsErolledClient = readAll(sCursor);
+ smsEnrolledClient = readAll(sCursor);
} catch (Exception e){
Timber.d("-->getEnrolledClients" + e.getMessage());
@@ -33,26 +33,26 @@ public List getEnrolledClients(){
sCursor.close();
}
}
- return smsErolledClient;
+ return smsEnrolledClient;
}
- public SmsErolledClient getEnrolledClients(Cursor cursor){
- SmsErolledClient smsErolledClient = new SmsErolledClient();
- smsErolledClient.setFirstName(cursor.getString(cursor.getColumnIndex("first_name")));
- smsErolledClient.setLastName(cursor.getString(cursor.getColumnIndex("last_name")));
- smsErolledClient.setPhoneNumber(cursor.getString(cursor.getColumnIndex("phone_number")));
- return smsErolledClient;
+ public SmsEnrolledClient getEnrolledClients(Cursor cursor){
+ SmsEnrolledClient smsEnrolledClient = new SmsEnrolledClient();
+ smsEnrolledClient.setFirstName(cursor.getString(cursor.getColumnIndex("first_name")));
+ smsEnrolledClient.setLastName(cursor.getString(cursor.getColumnIndex("last_name")));
+ smsEnrolledClient.setPhoneNumber(cursor.getString(cursor.getColumnIndex("phone_number")));
+ return smsEnrolledClient;
}
- private List readAll(Cursor cursor){
- List smsErolledClients = new ArrayList<>();
+ private List readAll(Cursor cursor){
+ List smsEnrolledClients = new ArrayList<>();
if (cursor !=null && cursor.getCount() > 0 && cursor.moveToNext()){
cursor.moveToFirst();
while (cursor.getCount() > 0 && !cursor.isAfterLast()){
- smsErolledClients.add(getEnrolledClients(cursor));
+ smsEnrolledClients.add(getEnrolledClients(cursor));
cursor.moveToNext();
}
}
- return smsErolledClients;
+ return smsEnrolledClients;
}
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/repository/StockHelperRepository.java b/opensrp-kip/src/main/java/org/smartregister/kip/repository/StockHelperRepository.java
index 0b0bcac..d3c74bc 100644
--- a/opensrp-kip/src/main/java/org/smartregister/kip/repository/StockHelperRepository.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/repository/StockHelperRepository.java
@@ -10,6 +10,7 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.kip.application.KipApplication;
+import org.smartregister.kip.dao.KipChildDao;
import org.smartregister.repository.Repository;
import org.smartregister.stock.StockLibrary;
import org.smartregister.stock.domain.ActiveChildrenStats;
@@ -129,12 +130,11 @@ public ActiveChildrenStats getActiveChildrenStat() {
@Override
public int getVaccinesDueBasedOnSchedule(JSONObject vaccineObject) {
-// try {
-// return KipChildDao.getDueVaccineCount(vaccineObject.getString("name"));
-// } catch (JSONException e) {
-// Timber.e(e);
-// return 0;
-// }
- return 10;
+ try {
+ return KipChildDao.getDueVaccineCount(vaccineObject.getString("name"));
+ } catch (JSONException e) {
+ Timber.e(e);
+ return 0;
+ }
}
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipChildUtils.java b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipChildUtils.java
index abb81fc..efbbf0c 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipChildUtils.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipChildUtils.java
@@ -29,10 +29,10 @@
import org.smartregister.child.util.Constants;
import org.smartregister.child.util.Utils;
import org.smartregister.commonregistry.AllCommonsRepository;
-import org.smartregister.domain.db.Client;
-import org.smartregister.domain.db.Event;
+import org.smartregister.domain.Client;
+import org.smartregister.domain.Event;
import org.smartregister.domain.db.EventClient;
-import org.smartregister.domain.db.Obs;
+import org.smartregister.domain.Obs;
import org.smartregister.domain.form.FormLocation;
import org.smartregister.kip.BuildConfig;
import org.smartregister.kip.application.KipApplication;
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipConstants.java b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipConstants.java
index b3c3e20..d311bf1 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipConstants.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipConstants.java
@@ -25,6 +25,7 @@ public class KipConstants {
public static final String PFIZER_VIALS_AMOUNT = "pfizer_vials_amount";
public static final String MODERNA_VIALS_AMOUNT = "moderna_vials_amount";
public static final String PHONE_NUMBER = "phone_number";
+ public static final String JOHNSON_AND_JOHNSON_VIALS_AMOUNT = "johnson_and_johnson_vials_amount";
public interface DateFormat {
String HH_MM_AMPM = "h:mm a";
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipJsonFormUtils.java b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipJsonFormUtils.java
index e50803c..0d05fc0 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipJsonFormUtils.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipJsonFormUtils.java
@@ -18,7 +18,7 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.child.ChildLibrary;
-import org.smartregister.child.util.JsonFormUtils;
+import org.smartregister.child.util.ChildJsonFormUtils;
import org.smartregister.child.util.Constants;
import org.smartregister.child.util.Utils;
import org.smartregister.clientandeventmodel.Event;
@@ -41,7 +41,7 @@
import static org.smartregister.login.task.RemoteLoginTask.getOpenSRPContext;
-public class KipJsonFormUtils extends JsonFormUtils {
+public class KipJsonFormUtils extends ChildJsonFormUtils {
public static final String CONCEPT = "concept";
public static final String VALUE = "value";
public static final String VALUES = "values";
@@ -52,8 +52,7 @@ public class KipJsonFormUtils extends JsonFormUtils {
public static final String SECTIONS = "sections";
public static final String attributes = "attributes";
public static final String ENCOUNTER = "encounter";
- public static final String
- AZ_OXFORD_VIALS_AMOUNT = "az_oxford_vials_amount";
+ public static final String AZ_OXFORD_VIALS_AMOUNT = "az_oxford_vials_amount";
public static final String AZ_OXFORD_VIALS_LOT_NUMBER = "az_oxford_vials_lot_number";
public static final String AZ_OXFORD_VIALS_EXPIRY = "az_oxford_vials_expiry";
public static final String SINOPHARM_VIALS_AMOUNT = "sinopharm_vials_amount";
@@ -63,6 +62,10 @@ public class KipJsonFormUtils extends JsonFormUtils {
public static final String SINOVAC_VIALS_LOT_NUMBER = "sinovac_vials_lot_number";
public static final String SINOVAC_VIALS_EXPIRY = "sinovac_vials_expiry";
+ public static final String JOHNSON_AND_JOHNSON_VIALS_AMOUNT = "johnson_and_johnson_vials_amount";
+ public static final String JOHNSON_AND_JOHNSON_VIALS_EXPIRY = "johnson_and_johnson_vials_expiry";
+ public static final String JOHNSON_AND_JOHNSON_VIALS_LOT_NUMBER = "johnson_and_johnson_vials_lot_number";
+
public static final String MODERNA_VIALS_AMOUNT = "moderna_vials_amount";
public static final String MODERNA_VIALS_LOT_NUMBER = "moderna_vials_lot_number";
public static final String MODERNA_VIALS_EXPIRY = "moderna_vials_expiry";
@@ -79,26 +82,26 @@ public static String getMetadataForEditForm(Context context, Map
JSONObject birthRegistrationForm = FormUtils.getInstance(context)
.getFormJson(Utils.metadata().childRegister.formName);
updateRegistrationEventType(birthRegistrationForm, childDetails);
- JsonFormUtils.addChildRegLocHierarchyQuestions(birthRegistrationForm);
+ ChildJsonFormUtils.addRegistrationFormLocationHierarchyQuestions(birthRegistrationForm);
KipLocationUtility.addChildRegLocHierarchyQuestions(birthRegistrationForm, getOpenSRPContext());
KipJsonFormUtils.addRelationshipTypesQuestions(birthRegistrationForm);
if (birthRegistrationForm != null) {
- birthRegistrationForm.put(JsonFormUtils.ENTITY_ID, childDetails.get(Constants.KEY.BASE_ENTITY_ID));
- birthRegistrationForm.put(JsonFormUtils.ENCOUNTER_TYPE, Utils.metadata().childRegister.updateEventType);
- birthRegistrationForm.put(JsonFormUtils.RELATIONAL_ID, childDetails.get(RELATIONAL_ID));
+ birthRegistrationForm.put(ChildJsonFormUtils.ENTITY_ID, childDetails.get(Constants.KEY.BASE_ENTITY_ID));
+ birthRegistrationForm.put(ChildJsonFormUtils.ENCOUNTER_TYPE, Utils.metadata().childRegister.updateEventType);
+ birthRegistrationForm.put(ChildJsonFormUtils.RELATIONAL_ID, childDetails.get(RELATIONAL_ID));
birthRegistrationForm.put(KipConstants.KEY.FATHER_RELATIONAL_ID, childDetails.get(KipConstants.KEY.FATHER_RELATIONAL_ID));
- birthRegistrationForm.put(JsonFormUtils.CURRENT_ZEIR_ID, Utils.getValue(childDetails, KipConstants.KEY.MALAWI_ID, true).replace("-", ""));
- birthRegistrationForm.put(JsonFormUtils.CURRENT_OPENSRP_ID,
+ birthRegistrationForm.put(ChildJsonFormUtils.CURRENT_ZEIR_ID, Utils.getValue(childDetails, KipConstants.KEY.MALAWI_ID, true).replace("-", ""));
+ birthRegistrationForm.put(ChildJsonFormUtils.CURRENT_OPENSRP_ID,
Utils.getValue(childDetails, Constants.JSON_FORM_KEY.UNIQUE_ID, false));
- JSONObject metadata = birthRegistrationForm.getJSONObject(JsonFormUtils.METADATA);
- metadata.put(JsonFormUtils.ENCOUNTER_LOCATION,
+ JSONObject metadata = birthRegistrationForm.getJSONObject(ChildJsonFormUtils.METADATA);
+ metadata.put(ChildJsonFormUtils.ENCOUNTER_LOCATION,
ChildLibrary.getInstance().getLocationPickerView(context).getSelectedItem());
//inject zeir id into the birthRegistrationForm
- JSONObject stepOne = birthRegistrationForm.getJSONObject(JsonFormUtils.STEP1);
- JSONArray jsonArray = stepOne.getJSONArray(JsonFormUtils.FIELDS);
+ JSONObject stepOne = birthRegistrationForm.getJSONObject(ChildJsonFormUtils.STEP1);
+ JSONArray jsonArray = stepOne.getJSONArray(ChildJsonFormUtils.FIELDS);
updateFormDetailsForEdit(childDetails, jsonArray, nonEditableFields);
return birthRegistrationForm.toString();
}
@@ -116,77 +119,77 @@ private static void updateFormDetailsForEdit(Map childDetails, J
JSONObject jsonObject = jsonArray.getJSONObject(i);
prefix = getPrefix(jsonObject);
- if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(Constants.KEY.PHOTO)) {
+ if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(Constants.KEY.PHOTO)) {
processPhoto(childDetails.get(Constants.KEY.BASE_ENTITY_ID), jsonObject);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("dob_unknown")) {
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("dob_unknown")) {
getDobUnknown(childDetails, jsonObject);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(Constants.JSON_FORM_KEY.AGE)) {
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(Constants.JSON_FORM_KEY.AGE)) {
processAge(Utils.getValue(childDetails, Constants.KEY.DOB, false), jsonObject);
} else if (jsonObject.getString(JsonFormConstants.TYPE).equalsIgnoreCase(JsonFormConstants.DATE_PICKER)) {
processDate(childDetails, prefix, jsonObject);
- } else if (jsonObject.getString(JsonFormUtils.OPENMRS_ENTITY).equalsIgnoreCase(JsonFormUtils.PERSON_INDENTIFIER)) {
- jsonObject.put(JsonFormUtils.VALUE, Utils.getValue(childDetails,
- jsonObject.getString(JsonFormUtils.OPENMRS_ENTITY_ID).toLowerCase(), true).replace("-", ""));
- } else if (jsonObject.getString(JsonFormUtils.OPENMRS_ENTITY).equalsIgnoreCase(JsonFormUtils.CONCEPT)) {
- jsonObject.put(JsonFormUtils.VALUE,
- getMappedValue(jsonObject.getString(JsonFormUtils.KEY), childDetails));
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.MIDDLE_NAME)) {
+ } else if (jsonObject.getString(ChildJsonFormUtils.OPENMRS_ENTITY).equalsIgnoreCase(ChildJsonFormUtils.PERSON_INDENTIFIER)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, Utils.getValue(childDetails,
+ jsonObject.getString(ChildJsonFormUtils.OPENMRS_ENTITY_ID).toLowerCase(), true).replace("-", ""));
+ } else if (jsonObject.getString(ChildJsonFormUtils.OPENMRS_ENTITY).equalsIgnoreCase(ChildJsonFormUtils.CONCEPT)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE,
+ getMappedValue(jsonObject.getString(ChildJsonFormUtils.KEY), childDetails));
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.MIDDLE_NAME)) {
String middleName = Utils.getValue(childDetails, KipConstants.KEY.MIDDLE_NAME, true);
- jsonObject.put(JsonFormUtils.VALUE, middleName);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.FATHER_FIRST_NAME)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, middleName);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.FATHER_FIRST_NAME)) {
String fatherFirstName = Utils.getValue(childDetails, KipConstants.KEY.FATHER_FIRST_NAME, true);
- jsonObject.put(JsonFormUtils.VALUE, fatherFirstName);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.FATHER_LAST_NAME)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, fatherFirstName);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.FATHER_LAST_NAME)) {
String fatherLastName = Utils.getValue(childDetails, KipConstants.KEY.FATHER_LAST_NAME, true);
- jsonObject.put(JsonFormUtils.VALUE, fatherLastName);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.FATHER_PHONE)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, fatherLastName);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.FATHER_PHONE)) {
String fatherPhoneNumber = Utils.getValue(childDetails, "father_phone_number", true);
- jsonObject.put(JsonFormUtils.VALUE, fatherPhoneNumber);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.MOTHER_NRC_NUMBER)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, fatherPhoneNumber);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.MOTHER_NRC_NUMBER)) {
String nidNumber = Utils.getValue(childDetails, KipConstants.KEY.MOTHER_NRC_NUMBER, true);
- jsonObject.put(JsonFormUtils.VALUE, nidNumber);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.MOTHER_SECOND_PHONE_NUMBER)) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, nidNumber);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.MOTHER_SECOND_PHONE_NUMBER)) {
String secondaryNumber = Utils.getValue(childDetails, KipConstants.KEY.MOTHER_SECOND_PHONE_NUMBER, true);
- jsonObject.put(JsonFormUtils.VALUE, secondaryNumber);
+ jsonObject.put(ChildJsonFormUtils.VALUE, secondaryNumber);
} else if (jsonObject.has(JsonFormConstants.TREE)) {
processLocationTree(childDetails, jsonObject);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("mother_guardian_first_name")) {
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("mother_guardian_first_name")) {
String secondaryNumber = Utils.getValue(childDetails, KipConstants.KEY.MOTHER_FIRST_NAME, true);
- jsonObject.put(JsonFormUtils.VALUE, secondaryNumber);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("mother_guardian_last_name")) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, secondaryNumber);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("mother_guardian_last_name")) {
String secondaryNumber = Utils.getValue(childDetails, KipConstants.KEY.MOTHER_LAST_NAME, true);
- jsonObject.put(JsonFormUtils.VALUE, secondaryNumber);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("Sex")) {
- jsonObject.put(JsonFormUtils.VALUE,
- childDetails.get(JsonFormUtils.GENDER));
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("Ce_County")) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, secondaryNumber);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("Sex")) {
+ jsonObject.put(ChildJsonFormUtils.VALUE,
+ childDetails.get(ChildJsonFormUtils.GENDER));
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("Ce_County")) {
String county = Utils.getValue(childDetails, "stateProvince", true);
- jsonObject.put(JsonFormUtils.VALUE, county);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("Ce_Sub_County")) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, county);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("Ce_Sub_County")) {
String subcounty = Utils.getValue(childDetails, "countyDistrict", true);
- jsonObject.put(JsonFormUtils.VALUE, subcounty);
- } else if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase("Ce_Ward")) {
+ jsonObject.put(ChildJsonFormUtils.VALUE, subcounty);
+ } else if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase("Ce_Ward")) {
String ward = Utils.getValue(childDetails, "cityVillage", true);
- jsonObject.put(JsonFormUtils.VALUE, ward);
+ jsonObject.put(ChildJsonFormUtils.VALUE, ward);
} else {
- jsonObject.put(JsonFormUtils.VALUE,
- childDetails.get(jsonObject.optString(JsonFormUtils.KEY)));
+ jsonObject.put(ChildJsonFormUtils.VALUE,
+ childDetails.get(jsonObject.optString(ChildJsonFormUtils.KEY)));
}
- jsonObject.put(JsonFormUtils.READ_ONLY, nonEditableFields.contains(jsonObject.getString(JsonFormUtils.KEY)));
+ jsonObject.put(ChildJsonFormUtils.READ_ONLY, nonEditableFields.contains(jsonObject.getString(ChildJsonFormUtils.KEY)));
}
}
private static void getDobUnknown(Map childDetails, JSONObject jsonObject) throws JSONException {
JSONObject optionsObject = jsonObject.getJSONArray(Constants.JSON_FORM_KEY.OPTIONS).getJSONObject(0);
- optionsObject.put(JsonFormUtils.VALUE,
+ optionsObject.put(ChildJsonFormUtils.VALUE,
Utils.getValue(childDetails, "dob_unknown", false));
}
@NotNull
private static String getPrefix(JSONObject jsonObject) throws JSONException {
String prefix = "";
- if (jsonObject.has(JsonFormUtils.ENTITY_ID)) {
- String entityId = jsonObject.getString(JsonFormUtils.ENTITY_ID);
+ if (jsonObject.has(ChildJsonFormUtils.ENTITY_ID)) {
+ String entityId = jsonObject.getString(ChildJsonFormUtils.ENTITY_ID);
if (!TextUtils.isEmpty(entityId) && entityId.equalsIgnoreCase(Constants.KEY.MOTHER))
prefix = "mother_";
else if (!TextUtils.isEmpty(entityId) && entityId.equalsIgnoreCase(Constants.KEY.FATHER))
@@ -204,8 +207,8 @@ public static void tagEventSyncMetadata(Event event) {
}
private static void updateBirthFacilityHierarchy(Map childDetails, JSONObject jsonObject) throws JSONException {
- if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.BIRTH_FACILITY_NAME)) {
- jsonObject.put(JsonFormUtils.READ_ONLY, true);
+ if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.BIRTH_FACILITY_NAME)) {
+ jsonObject.put(ChildJsonFormUtils.READ_ONLY, true);
List birthFacilityHierarchy = null;
String birthFacilityName = Utils.getValue(childDetails, KipConstants.KEY.BIRTH_FACILITY_NAME, false);
if (birthFacilityName != null) {
@@ -222,13 +225,13 @@ private static void updateBirthFacilityHierarchy(Map childDetail
.javaToJsonString(birthFacilityHierarchy, new TypeToken>() {
}.getType());
if (StringUtils.isNotBlank(birthFacilityHierarchyString)) {
- jsonObject.put(JsonFormUtils.VALUE, birthFacilityHierarchyString);
+ jsonObject.put(ChildJsonFormUtils.VALUE, birthFacilityHierarchyString);
}
}
}
private static void updateResidentialAreaHierarchy(Map childDetails, JSONObject jsonObject) throws JSONException {
- if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.RESIDENTIAL_AREA)) {
+ if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.RESIDENTIAL_AREA)) {
List residentialAreaHierarchy;
String address3 = Utils.getValue(childDetails, KipConstants.KEY.ADDRESS_3, false);
if (address3 != null && address3.equalsIgnoreCase(KipConstants.KEY.OTHER)) {
@@ -243,13 +246,13 @@ private static void updateResidentialAreaHierarchy(Map childDeta
.javaToJsonString(residentialAreaHierarchy, new TypeToken>() {
}.getType());
if (StringUtils.isNotBlank(residentialAreaHierarchyString)) {
- jsonObject.put(JsonFormUtils.VALUE, residentialAreaHierarchyString);
+ jsonObject.put(ChildJsonFormUtils.VALUE, residentialAreaHierarchyString);
}
}
}
private static void updateHomeFacilityHierarchy(Map childDetails, JSONObject jsonObject) throws JSONException {
- if (jsonObject.getString(JsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.HOME_FACILITY)) {
+ if (jsonObject.getString(ChildJsonFormUtils.KEY).equalsIgnoreCase(KipConstants.KEY.HOME_FACILITY)) {
List homeFacilityHierarchy = LocationHelper.getInstance()
.getOpenMrsLocationHierarchy(Utils.getValue(childDetails,
KipConstants.KEY.HOME_FACILITY, false), false);
@@ -261,26 +264,26 @@ private static void updateHomeFacilityHierarchy(Map childDetails
String entireTreeString = AssetHandler.javaToJsonString(entireTree, new TypeToken>() {
}.getType());
if (StringUtils.isNotBlank(homeFacilityHierarchyString)) {
- jsonObject.put(JsonFormUtils.VALUE, homeFacilityHierarchyString);
+ jsonObject.put(ChildJsonFormUtils.VALUE, homeFacilityHierarchyString);
jsonObject.put(JsonFormConstants.TREE, new JSONArray(entireTreeString));
}
}
}
private static void addNonEditableFields(List nonEditableFields, JSONObject jsonObject) throws JSONException {
- jsonObject.put(JsonFormUtils.READ_ONLY,
- nonEditableFields.contains(jsonObject.getString(JsonFormUtils.KEY)));
+ jsonObject.put(ChildJsonFormUtils.READ_ONLY,
+ nonEditableFields.contains(jsonObject.getString(ChildJsonFormUtils.KEY)));
}
private static void updateRegistrationEventType(JSONObject form, Map childDetails) throws JSONException {
- if (form.has(JsonFormUtils.ENCOUNTER_TYPE) && form.getString(JsonFormUtils.ENCOUNTER_TYPE)
+ if (form.has(ChildJsonFormUtils.ENCOUNTER_TYPE) && form.getString(ChildJsonFormUtils.ENCOUNTER_TYPE)
.equals(Constants.EventType.BITRH_REGISTRATION)) {
- form.put(JsonFormUtils.ENCOUNTER_TYPE, Constants.EventType.UPDATE_BITRH_REGISTRATION);
+ form.put(ChildJsonFormUtils.ENCOUNTER_TYPE, Constants.EventType.UPDATE_BITRH_REGISTRATION);
}
- if (form.has(JsonFormUtils.STEP1) && form.getJSONObject(JsonFormUtils.STEP1).has(KipConstants.KEY.TITLE) && form.getJSONObject(JsonFormUtils.STEP1).getString(KipConstants.KEY.TITLE)
+ if (form.has(ChildJsonFormUtils.STEP1) && form.getJSONObject(ChildJsonFormUtils.STEP1).has(KipConstants.KEY.TITLE) && form.getJSONObject(ChildJsonFormUtils.STEP1).getString(KipConstants.KEY.TITLE)
.equals(Constants.EventType.BITRH_REGISTRATION)) {
- form.getJSONObject(JsonFormUtils.STEP1).put(KipConstants.KEY.TITLE, KipConstants.FormTitleUtil.UPDATE_CHILD_FORM);
+ form.getJSONObject(ChildJsonFormUtils.STEP1).put(KipConstants.KEY.TITLE, KipConstants.FormTitleUtil.UPDATE_CHILD_FORM);
}
//Update father details if it exists or create a new one
@@ -346,11 +349,11 @@ public static void addRelationshipTypesQuestions(JSONObject form) {
}
}
- questions.getJSONObject(i).remove(JsonFormUtils.VALUES);
- questions.getJSONObject(i).put(JsonFormUtils.VALUES, values);
+ questions.getJSONObject(i).remove(ChildJsonFormUtils.VALUES);
+ questions.getJSONObject(i).put(ChildJsonFormUtils.VALUES, values);
// Set the default relationship type.
- questions.getJSONObject(i).remove(JsonFormUtils.VALUE);
- questions.getJSONObject(i).put(JsonFormUtils.VALUE, value);
+ questions.getJSONObject(i).remove(ChildJsonFormUtils.VALUE);
+ questions.getJSONObject(i).put(ChildJsonFormUtils.VALUE, value);
}
}
} catch (JSONException e) {
@@ -456,6 +459,7 @@ private static JSONArray extractValues(JSONArray fields) {
StringBuilder sinovac = new StringBuilder();
StringBuilder mordana = new StringBuilder();
StringBuilder pfizer = new StringBuilder();
+ StringBuilder johnsonJohnson = new StringBuilder();
try {
for (int i = 0; i < fields.length(); i++) {
JSONObject field = fields.getJSONObject(i);
@@ -475,6 +479,8 @@ private static JSONArray extractValues(JSONArray fields) {
}
if (key.contains("pfizer_vials") && field.has(KipConstants.KeyUtils.VALUE)) {
sinovac.insert(0, field.optString(KipConstants.KeyUtils.VALUE) + ":");
+ } if (key.contains("johnson_and_johnson_vials") && field.has(KipConstants.KeyUtils.VALUE)) {
+ sinovac.insert(0, field.optString(KipConstants.KeyUtils.VALUE) + ":");
}
}
}
@@ -482,10 +488,10 @@ private static JSONArray extractValues(JSONArray fields) {
Timber.e(exception);
}
- return createNewFields(fields, azOxford.toString(), sinopharm.toString(), sinovac.toString(), mordana.toString(), pfizer.toString());
+ return createNewFields(fields, azOxford.toString(), sinopharm.toString(), sinovac.toString(), mordana.toString(), pfizer.toString(), johnsonJohnson.toString());
}
- private static JSONArray createNewFields(JSONArray fields, String azOxford, String sinopharm, String sinovac, String morderna, String pfzer) {
+ private static JSONArray createNewFields(JSONArray fields, String azOxford, String sinopharm, String sinovac, String morderna, String pfzer, String johnsonJohnson) {
JSONArray newFormFields = new JSONArray();
try {
for (int i = 0; i < fields.length(); i++) {
@@ -512,6 +518,11 @@ private static JSONArray createNewFields(JSONArray fields, String azOxford, Stri
field.put(KipConstants.KeyUtils.VALUE, pfzer);
newFormFields.put(field);
}
+
+ if (key.equalsIgnoreCase(KipConstants.JOHNSON_AND_JOHNSON_VIALS_AMOUNT)) {
+ field.put(KipConstants.KeyUtils.VALUE, johnsonJohnson);
+ newFormFields.put(field);
+ }
}
}
} catch (JSONException exception) {
@@ -555,6 +566,7 @@ public static void appendFormValues(Map settings, JSONArray fiel
String[] sinovac = settings.get(KipConstants.SINOVAC_VIALS_AMOUNT).split(":");
String[] moderna = settings.get(KipConstants.MODERNA_VIALS_AMOUNT).split(":");
String[] pfizer = settings.get(KipConstants.PFIZER_VIALS_AMOUNT).split(":");
+ String[] johnsonAndJohnson = settings.get(KipConstants.JOHNSON_AND_JOHNSON_VIALS_AMOUNT).split(":");
for (int i = 0; i < fields.length(); i++) {
JSONObject field = fields.getJSONObject(i);
@@ -590,6 +602,12 @@ public static void appendFormValues(Map settings, JSONArray fiel
field.put(KipConstants.VALUE, pfizer[1]);
} else if (fieldKey.equalsIgnoreCase(PFIZER_VIALS_EXPIRY)) {
field.put(KipConstants.VALUE, pfizer[2]);
+ } else if (fieldKey.equalsIgnoreCase(JOHNSON_AND_JOHNSON_VIALS_AMOUNT)) {
+ field.put(KipConstants.VALUE, johnsonAndJohnson[0]);
+ } else if (fieldKey.equalsIgnoreCase(JOHNSON_AND_JOHNSON_VIALS_LOT_NUMBER)) {
+ field.put(KipConstants.VALUE, johnsonAndJohnson[1]);
+ } else if (fieldKey.equalsIgnoreCase(JOHNSON_AND_JOHNSON_VIALS_EXPIRY)) {
+ field.put(KipConstants.VALUE, johnsonAndJohnson[2]);
}
}
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipReportUtils.java b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipReportUtils.java
index 4d4d23d..e6a3fce 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/util/KipReportUtils.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/util/KipReportUtils.java
@@ -6,7 +6,7 @@
import org.json.JSONArray;
import org.json.JSONObject;
import org.smartregister.child.util.Constants;
-import org.smartregister.child.util.JsonFormUtils;
+import org.smartregister.child.util.ChildJsonFormUtils;
import org.smartregister.child.util.Utils;
import org.smartregister.clientandeventmodel.Event;
import org.smartregister.domain.tag.FormTag;
@@ -34,7 +34,7 @@ public static void createReportAndSaveReport(@NonNull List
String providerId = KipApplication.getInstance().context().allSharedPreferences().fetchRegisteredANM();
String locationId = KipApplication.getInstance().context().allSharedPreferences().getPreference(Constants.CURRENT_LOCATION_ID);
Report report = new Report();
- report.setFormSubmissionId(JsonFormUtils.generateRandomUUIDString());
+ report.setFormSubmissionId(ChildJsonFormUtils.generateRandomUUIDString());
report.setHia2Indicators(hia2Indicators);
report.setLocationId(locationId);
report.setProviderId(providerId);
@@ -47,7 +47,7 @@ public static void createReportAndSaveReport(@NonNull List
report.setReportDate(new DateTime(calendar.getTime()));
report.setReportType(reportType);
- JSONObject reportJson = new JSONObject(JsonFormUtils.gson.toJson(report));
+ JSONObject reportJson = new JSONObject(ChildJsonFormUtils.gson.toJson(report));
KipApplication.getInstance().hia2ReportRepository().addReport(reportJson);
createReportAndProcessEvent(reportJson);
@@ -58,7 +58,7 @@ public static void createReportAndSaveReport(@NonNull List
private static void createReportAndProcessEvent(@NonNull JSONObject reportJson) throws Exception {
FormTag formTag = KipJsonFormUtils.formTag(KipChildUtils.getAllSharedPreferences());
- Event baseEvent = JsonFormUtils.createEvent(new JSONArray(), new JSONObject(),
+ Event baseEvent = ChildJsonFormUtils.createEvent(new JSONArray(), new JSONObject(),
formTag, "", KipConstants.EventType.REPORT_CREATION, "");
baseEvent.addDetails("reportJson", reportJson.toString());
baseEvent.setFormSubmissionId(reportJson.optString("formSubmissionId"));
diff --git a/opensrp-kip/src/main/java/org/smartregister/kip/view/NavigationMenu.java b/opensrp-kip/src/main/java/org/smartregister/kip/view/NavigationMenu.java
index fb8e8ce..3664167 100755
--- a/opensrp-kip/src/main/java/org/smartregister/kip/view/NavigationMenu.java
+++ b/opensrp-kip/src/main/java/org/smartregister/kip/view/NavigationMenu.java
@@ -30,12 +30,13 @@
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.smartregister.child.util.Constants;
-import org.smartregister.child.util.JsonFormUtils;
+import org.smartregister.child.util.ChildJsonFormUtils;
import org.smartregister.child.util.Utils;
import org.smartregister.client.utils.domain.Form;
import org.smartregister.domain.FetchStatus;
import org.smartregister.kip.R;
import org.smartregister.kip.activity.Covid19VaccineStockSettingsActivity;
+import org.smartregister.kip.activity.Moh510ReportActivity;
import org.smartregister.kip.activity.ReportRegisterActivity;
import org.smartregister.kip.activity.KipStockActivity;
import org.smartregister.kip.adapter.NavigationAdapter;
@@ -79,6 +80,7 @@ public class NavigationMenu implements NavigationContract.View, SyncStatusBroadc
private RelativeLayout covidStockUpdate;
private LinearLayout outOfAreaMenu;
private LinearLayout stockControl;
+ private LinearLayout moh510Report;
private View parentView;
private LinearLayout reportView;
@@ -181,6 +183,7 @@ public void prepareViews(Activity activity) {
covidStockUpdate = rootView.findViewById(R.id.covid19_vaccine_stock_section);
outOfAreaMenu = rootView.findViewById(R.id.out_of_area_menu);
stockControl = rootView.findViewById(R.id.stock_control);
+ moh510Report = rootView.findViewById(R.id.moh510_report_activity_view);
ImageView ivLogo = rootView.findViewById(R.id.ivLogo);
LinearLayout locationLayout = rootView.findViewById(R.id.giz_location_layout);
@@ -224,11 +227,28 @@ public void onClick(View v) {
registerCovid19UpdateActivity(activity);
recordOutOfArea(activity);
recordStockControl(activity);
+ downloadMoh510Report(activity);
// update all actions
mPresenter.refreshLastSync();
}
+ private void downloadMoh510Report(final Activity parentActivity){
+ moh510Report.setOnClickListener(v -> startMoh510Report(parentActivity));
+ }
+
+ private void startMoh510Report(@Nullable Activity parentActivity){
+ if (parentActivity instanceof Moh510ReportActivity) {
+ drawer.closeDrawer(GravityCompat.START);
+ return;
+ }
+
+ if (parentActivity != null) {
+ Intent intent = new Intent(parentActivity, Moh510ReportActivity.class);
+ parentActivity.startActivity(intent);
+ }
+ }
+
private void recordStockControl(final Activity parentActivity){
stockControl.setOnClickListener(v -> startStockActivity(parentActivity));
}
@@ -252,7 +272,7 @@ private void recordOutOfArea(final Activity parentActivity) {
private void startFormActivity(Activity activity) {
try {
JSONObject formJson = new FormUtils(activity).getFormJson(KipConstants.JSON_FORM.OUT_OF_CATCHMENT_SERVICE);
- JsonFormUtils.addAvailableVaccines(activity, formJson);
+ ChildJsonFormUtils.addAvailableVaccines(activity, formJson);
Form form = new Form();
form.setWizard(false);
@@ -263,7 +283,7 @@ private void startFormActivity(Activity activity) {
intent.putExtra(Constants.INTENT_KEY.JSON, formJson.toString());
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form);
intent.putExtra(JsonFormConstants.PERFORM_FORM_TRANSLATION, true);
- activity.startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON);
+ activity.startActivityForResult(intent, ChildJsonFormUtils.REQUEST_CODE_GET_JSON);
} catch (Exception e) {
Timber.e(e);
}
diff --git a/opensrp-kip/src/main/res/layout/activity_moh510_report.xml b/opensrp-kip/src/main/res/layout/activity_moh510_report.xml
new file mode 100644
index 0000000..1f701c7
--- /dev/null
+++ b/opensrp-kip/src/main/res/layout/activity_moh510_report.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/opensrp-kip/src/main/res/layout/app_bar_report_summary.xml b/opensrp-kip/src/main/res/layout/app_bar_report_summary.xml
index 3c15a3f..468ce32 100755
--- a/opensrp-kip/src/main/res/layout/app_bar_report_summary.xml
+++ b/opensrp-kip/src/main/res/layout/app_bar_report_summary.xml
@@ -1,5 +1,5 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/opensrp-kip/src/main/res/layout/app_moh710_reports.xml b/opensrp-kip/src/main/res/layout/app_moh710_reports.xml
index ca79c21..90b29cc 100755
--- a/opensrp-kip/src/main/res/layout/app_moh710_reports.xml
+++ b/opensrp-kip/src/main/res/layout/app_moh710_reports.xml
@@ -1,5 +1,5 @@
-
-
+
diff --git a/opensrp-kip/src/main/res/layout/fragment_me.xml b/opensrp-kip/src/main/res/layout/fragment_me.xml
index ded0bb2..7e8ec46 100755
--- a/opensrp-kip/src/main/res/layout/fragment_me.xml
+++ b/opensrp-kip/src/main/res/layout/fragment_me.xml
@@ -1,5 +1,6 @@
+ app:tint="@color/me_page_arrow" />
-
@@ -234,4 +234,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/opensrp-kip/src/main/res/layout/location_spinner_view.xml b/opensrp-kip/src/main/res/layout/location_spinner_view.xml
index babae37..1b66c7b 100755
--- a/opensrp-kip/src/main/res/layout/location_spinner_view.xml
+++ b/opensrp-kip/src/main/res/layout/location_spinner_view.xml
@@ -12,7 +12,7 @@
android:layout_weight=".28"
android:orientation="horizontal">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/opensrp-kip/src/main/res/layout/navigation_drawer.xml b/opensrp-kip/src/main/res/layout/navigation_drawer.xml
index 4c8ada8..5411197 100755
--- a/opensrp-kip/src/main/res/layout/navigation_drawer.xml
+++ b/opensrp-kip/src/main/res/layout/navigation_drawer.xml
@@ -338,6 +338,41 @@
android:textSize="@dimen/table_contents_text_size" />
+
+
+
+
+
+
+
+
+
diff --git a/opensrp-kip/src/main/res/layout/opd_profile_overview_row.xml b/opensrp-kip/src/main/res/layout/opd_profile_overview_row.xml
index 07b4ee7..01225c6 100644
--- a/opensrp-kip/src/main/res/layout/opd_profile_overview_row.xml
+++ b/opensrp-kip/src/main/res/layout/opd_profile_overview_row.xml
@@ -1,5 +1,5 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/opensrp-kip/src/main/res/layout/toolbar_mho510_report_content.xml b/opensrp-kip/src/main/res/layout/toolbar_mho510_report_content.xml
new file mode 100644
index 0000000..a1557dc
--- /dev/null
+++ b/opensrp-kip/src/main/res/layout/toolbar_mho510_report_content.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/opensrp-kip/src/main/res/values/strings.xml b/opensrp-kip/src/main/res/values/strings.xml
index 6256c61..477ddd1 100755
--- a/opensrp-kip/src/main/res/values/strings.xml
+++ b/opensrp-kip/src/main/res/values/strings.xml
@@ -14,6 +14,7 @@
Add new child
Card Scanner
Record out of catchment vaccination
+ MOH 510 Report
Record out of catchment vaccination
Register