Skip to content

Commit

Permalink
Merge pull request #45 from OpenSRP/simprints_outcome
Browse files Browse the repository at this point in the history
Simprints outcome
  • Loading branch information
mahmud6390 authored Dec 25, 2020
2 parents c74c5f8 + dee5e7f commit ceb7018
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 44 deletions.
24 changes: 12 additions & 12 deletions opensrp-brac-hnpp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {

android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
compileSdkVersion 29
buildToolsVersion androidBuildToolsVersion

compileOptions {
Expand All @@ -35,7 +35,7 @@ android {
defaultConfig {
applicationId "org.smartregister.brac.hnpp"
minSdkVersion 18
targetSdkVersion 28
targetSdkVersion 29
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true

Expand Down Expand Up @@ -107,24 +107,24 @@ android {
productFlavors {

training{
versionCode 27
versionName "3.0.1"
versionCode 28
versionName "3.0.2"
dimension = 'baseDimension'
applicationIdSuffix ".training"
buildConfigField "boolean", 'IS_TRAINING', 'true'
buildConfigField "String", 'opensrp_url_training', '"http://mhealthtest.brac.net:8080/opensrp/"'
buildConfigField "String", 'opensrp_url_live', '"http://mhealthtest.brac.net:8080/opensrp/"'
}
normal{
versionCode 28
versionName "1.3.2"
versionCode 29
versionName "1.3.3"
dimension = 'baseDimension'
buildConfigField "boolean", 'IS_TRAINING', 'false'
// buildConfigField "String", 'opensrp_url_training', '"http://mhealth.brac.net:8080/opensrp/"'
// buildConfigField "String", 'opensrp_url_live', '"http://mhealth.brac.net:8080/opensrp/"'
//
buildConfigField "String", 'opensrp_url_training', '"http://hnpptest.mpower-social.com:8080/opensrp/"'
buildConfigField "String", 'opensrp_url_live', '"http://hnpptest.mpower-social.com:8080/opensrp/"'
buildConfigField "String", 'opensrp_url_training', '"http://mhealth.brac.net:8080/opensrp/"'
buildConfigField "String", 'opensrp_url_live', '"http://mhealth.brac.net:8080/opensrp/"'

// buildConfigField "String", 'opensrp_url_training', '"http://hnpptest.mpower-social.com:8080/opensrp/"'
// buildConfigField "String", 'opensrp_url_live', '"http://hnpptest.mpower-social.com:8080/opensrp/"'

}
}
Expand All @@ -140,7 +140,7 @@ dependencies {
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
api('org.smartregister:opensrp-client-simprints:2.0.7-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-simprints:2.1.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand Down
1 change: 1 addition & 0 deletions opensrp-brac-hnpp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
tools:replace="android:allowBackup"
android:icon="@drawable/ic_app_icon"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
android:theme="@style/HNPPTheme">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@
"err": "প্রশ্নের উত্তর দিন"
},
"relevance": {
"step2:has_family_planning_method": {
"step1:has_family_planning_method": {
"type": "string",
"ex": "equalTo(., \"হ্যাঁ\")"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
Expand Down Expand Up @@ -34,6 +35,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.CoreLibrary;
import org.smartregister.brac.hnpp.HnppApplication;
import org.smartregister.brac.hnpp.custom_view.FamilyMemberFloatingMenu;
import org.smartregister.brac.hnpp.fragment.HnppMemberProfileDueFragment;
Expand All @@ -44,7 +46,6 @@
import org.smartregister.brac.hnpp.location.SSModel;
import org.smartregister.brac.hnpp.model.ReferralFollowUpModel;
import org.smartregister.brac.hnpp.repository.HnppVisitLogRepository;
import org.smartregister.brac.hnpp.utils.ANCRegister;
import org.smartregister.brac.hnpp.utils.FormApplicability;
import org.smartregister.brac.hnpp.utils.HnppDBUtils;
import org.smartregister.brac.hnpp.utils.HnppConstants;
Expand All @@ -69,6 +70,8 @@
import org.smartregister.family.util.DBConstants;
import org.smartregister.helper.ImageRenderHelper;
import org.smartregister.simprint.SimPrintsConstantHelper;
import org.smartregister.simprint.SimPrintsHelper;
import org.smartregister.simprint.SimPrintsLibrary;
import org.smartregister.simprint.SimPrintsVerification;
import org.smartregister.simprint.SimPrintsVerifyActivity;
import org.smartregister.util.FormUtils;
Expand All @@ -89,6 +92,8 @@ public class HnppFamilyOtherMemberProfileActivity extends CoreFamilyOtherMemberP
public static final int REQUEST_HOME_VISIT = 5555;
public static final int REQUEST_SIMPRINTS_VERIFY = 1222;
public static final String IS_COMES_IDENTITY = "is_comes";
// public static final String SESSION_ID = "session_id";
//public static final String SELECTED_GU_ID = "selected_gu_id";
private static final int REQUEST_CODE_PREGNANCY_OUTCOME = 5556;

private CustomFontTextView textViewDetails3;
Expand Down Expand Up @@ -138,6 +143,9 @@ private void updateFingerPrintIcon(){
if(isComesFromIdentity){
isVerified = true;
verificationNeeded = true;
// String sessionId = getIntent().getStringExtra(SESSION_ID);
// String selectedGuId = getIntent().getStringExtra(SELECTED_GU_ID);
// sendSessionIdToSimprints(sessionId,selectedGuId);
}
moduleId = HnppDBUtils.getModuleId(familyHead);
guId = HnppDBUtils.getGuid(baseEntityId);
Expand Down Expand Up @@ -864,4 +872,10 @@ public void updateAncRegisterVisible(String eventType){
menu.findItem(R.id.action_anc_registration).setVisible(false);
}
}
// private void sendSessionIdToSimprints(String sessionId, String guId){
// Utils.startAsyncTask(new ConfirmIdentificationTask(sessionId,guId),null);
//
// }


}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import com.simprints.libsimprints.Identification;
import com.simprints.libsimprints.Tier;

import org.smartregister.CoreLibrary;
import org.smartregister.brac.hnpp.HnppApplication;
import org.smartregister.brac.hnpp.R;
import org.smartregister.brac.hnpp.adapter.IdentityAdapter;
import org.smartregister.brac.hnpp.fragment.HnppDashBoardFragment;
Expand All @@ -53,6 +55,7 @@
import org.smartregister.family.util.DBConstants;
import org.smartregister.family.util.Utils;
import org.smartregister.simprint.SimPrintsConstantHelper;
import org.smartregister.simprint.SimPrintsHelper;
import org.smartregister.simprint.SimPrintsIdentification;
import org.smartregister.simprint.SimPrintsIdentifyActivity;
import org.smartregister.simprint.SimPrintsRegistration;
Expand All @@ -69,6 +72,7 @@
public class SimprintsIdentityActivity extends SecuredActivity implements View.OnClickListener {

private static final int REQUEST_CODE_IDENTIFY = 1445;
private static final int REQUEST_CODE = 213;
private LinearLayout selectionBar,notFoundPanel;
private String moduleId = "";
private RecyclerView recyclerView;
Expand Down Expand Up @@ -120,6 +124,9 @@ public void onClick(View v) {
break;
case R.id.not_found_btn:
showNotFoundDialog();
if(!sessionId.isEmpty()){
startSimPrintsConfirmation(sessionId,"","");
}
break;
}
}
Expand Down Expand Up @@ -224,7 +231,7 @@ public void onClick(View v) {

dialog.dismiss();
if(!TextUtils.isEmpty(moduleId)){
SimPrintsIdentifyActivity.startSimprintsIdentifyActivity(SimprintsIdentityActivity.this, moduleId, REQUEST_CODE_IDENTIFY);
SimPrintsIdentifyActivity.startSimprintsIdentifyActivity(SimprintsIdentityActivity.this, moduleId, CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM(), REQUEST_CODE_IDENTIFY);

}else{
Toast.makeText(SimprintsIdentityActivity.this,"Please select module id",Toast.LENGTH_LONG).show();
Expand All @@ -234,6 +241,24 @@ public void onClick(View v) {
dialog.show();

}
String baseEntityId;
public void startSimPrintsConfirmation(String sessiodId, String simPrintsGuid,String baseEntityId) {
this.baseEntityId = baseEntityId;

//Log.v("SIMPRINTS_IDENTITY","projectId:"+HnppConstants.getSimPrintsProjectId()+":userId:"+CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM());
SimPrintsHelper simPrintsHelper = new SimPrintsHelper(HnppConstants.getSimPrintsProjectId(), CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM());
Intent intent;
if (TextUtils.isEmpty(simPrintsGuid)) {
//Log.v("SIMPRINTS_IDENTITY","confirmSelectedGuid non selected>>"+sessiodId);
intent = simPrintsHelper.confirmIdentity(HnppApplication.getHNPPInstance().getApplicationContext(), sessiodId, "none_selected");

} else {
//Log.v("SIMPRINTS_IDENTITY","sessionId:"+sessiodId+":guId"+simPrintsGuid+":appcontext:"+HnppApplication.getHNPPInstance().getApplicationContext());
intent = simPrintsHelper.confirmIdentity(HnppApplication.getHNPPInstance().getApplicationContext(), sessiodId, simPrintsGuid);
}
startActivityForResult(intent, REQUEST_CODE);
}

private void openProfile(String baseEntityId){

CommonPersonObjectClient patient = HnppDBUtils.createFromBaseEntity(baseEntityId);
Expand All @@ -254,6 +279,8 @@ private void openProfile(String baseEntityId){
intent.putExtra(HnppConstants.KEY.HOUSE_HOLD_ID,moduleId);
intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_NAME, houseHoldHead);
intent.putExtra(HnppFamilyOtherMemberProfileActivity.IS_COMES_IDENTITY,true);
// intent.putExtra(HnppFamilyOtherMemberProfileActivity.SESSION_ID,sessionId);
// intent.putExtra(HnppFamilyOtherMemberProfileActivity.SELECTED_GU_ID,selectedGuId);
startActivity(intent);
finish();

Expand Down Expand Up @@ -368,16 +395,28 @@ private void hideProgressDialog(){
}
private AppExecutors appExecutors = new AppExecutors();
ArrayList<IdentityModel> identityModelList = new ArrayList<>();
String sessionId = "";
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK && data !=null){

switch (requestCode){
case REQUEST_CODE: {
Boolean check = data.getBooleanExtra(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK, false);
//Log.v("SIMPRINTS_IDENTITY","onActivityREsult>check"+check);
if (check && !TextUtils.isEmpty(baseEntityId)) {
openProfile(baseEntityId);
}
}

break;
case REQUEST_CODE_IDENTIFY:
Boolean check = data.getBooleanExtra(Constants.SIMPRINTS_BIOMETRICS_COMPLETE_CHECK,true);
if(check){
showProgressDialog();
sessionId = data.getStringExtra(Constants.SIMPRINTS_SESSION_ID);
Log.v("SIMPRINTS_IDENTITY","sessionId:"+sessionId+":moduleId:"+moduleId);
appExecutors.diskIO().execute(() -> {
try {

Expand All @@ -392,20 +431,17 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
case TIER_2:
case TIER_3:
case TIER_4:
IdentityModel identityModel = new IdentityModel();
String[] ourPut = HnppDBUtils.getBaseEntityByGuId(identification.getGuid());
if(ourPut!=null && !TextUtils.isEmpty(ourPut[1])){
Log.v("SIMPRINTS_IDENTITY","baseid:"+ourPut[0]+":identification.getGuid()"+identification.getGuid());
identityModel.setBaseEntityId(ourPut[0]);
identityModel.setName(ourPut[1]);
case TIER_5:
IdentityModel identityModel = HnppDBUtils.getBaseEntityByGuId(identification.getGuid());
if(identityModel!=null && !TextUtils.isEmpty(identityModel.getBaseEntityId())){
Log.v("SIMPRINTS_IDENTITY","baseid:"+identityModel.getBaseEntityId()+":identification.getGuid()"+identification.getGuid());
identityModel.setTier(identification.getTier().toString().replace("_"," "));
identityModel.setFamilyHead(ourPut[3]);
identityModel.setAge(ourPut[4]);
if(!TextUtils.isEmpty(ourPut[2])) {
String id = ourPut[2].replace(org.smartregister.family.util.Constants.IDENTIFIER.FAMILY_SUFFIX,"")
identityModel.setOriginalGuId(identification.getGuid());
if(identityModel.getId()!=null) {
String id = identityModel.getId().replace(org.smartregister.family.util.Constants.IDENTIFIER.FAMILY_SUFFIX,"")
.replace(HnppConstants.IDENTIFIER.FAMILY_TEXT,"");
id = id.substring(id.length() - MEMBER_ID_SUFFIX);
identityModel.setGuid("ID: " + id);
identityModel.setId("ID: " + id);
}
if(identityModelList.size()!=3){
identityModelList.add(identityModel);
Expand Down Expand Up @@ -450,7 +486,8 @@ private void updateAdapter() {
@Override
public void onClick(int position, IdentityModel content) {
if(!content.getBaseEntityId().isEmpty()){
openProfile(content.getBaseEntityId());
startSimPrintsConfirmation(sessionId,content.getOriginalGuId(),content.getBaseEntityId());

}else {
Toast.makeText(SimprintsIdentityActivity.this,getString(R.string.not_match),Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void onBindViewHolder(@NonNull final IdentityViewHolder viewHolder, int p
final IdentityModel content = contentList.get(position);
viewHolder.textViewName.setText(content.getName());
viewHolder.textViewName.setText(viewHolder.textViewName.getText()+", বয়স: "+content.getAge());
viewHolder.textViewGuid.setText(content.getGuid());
viewHolder.textViewGuid.setText(content.getId());
viewHolder.textViewTier.setText(content.getTier());
viewHolder.textViewFamilyName.setText("খানা প্রধান: "+content.getFamilyHead());
if(!TextUtils.isEmpty(content.getHusband())){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//package org.smartregister.brac.hnpp.task;
//
//import android.os.AsyncTask;
//import android.text.TextUtils;
//import android.util.Log;
//
//import org.smartregister.CoreLibrary;
//import org.smartregister.brac.hnpp.HnppApplication;
//import org.smartregister.brac.hnpp.utils.HnppConstants;
//import org.smartregister.simprint.SimPrintsHelper;
//
//public class ConfirmIdentificationTask extends AsyncTask<Void, Void, Void> {
//
// private String sessiodId;
// private String selectedGuid;
//
// public ConfirmIdentificationTask(String sessiodId, String selectedGuid) {
// this.sessiodId = sessiodId;
// this.selectedGuid = selectedGuid;
// }
//
// @Override
// protected Void doInBackground(Void... voids) {
// confirmSelectedGuid(sessiodId, selectedGuid);
// return null;
// }
//
//
// private void confirmSelectedGuid(String sessionid, String simPrintsGuid) {
// Log.v("SIMPRINTS_IDENTITY","projectId:"+HnppConstants.getSimPrintsProjectId()+":userId:"+CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM());
// SimPrintsHelper simPrintsHelper = new SimPrintsHelper(HnppConstants.getSimPrintsProjectId(), CoreLibrary.getInstance().context().allSharedPreferences().fetchRegisteredANM());
// if (TextUtils.isEmpty(simPrintsGuid)) {
// Log.v("SIMPRINTS_IDENTITY","confirmSelectedGuid>>"+sessiodId);
// simPrintsHelper.confirmIdentity(HnppApplication.getHNPPInstance().getApplicationContext(), sessionid, "none_selected");
//
// } else {
// Log.v("SIMPRINTS_IDENTITY","sessionId:"+sessiodId+":guId"+simPrintsGuid+":appcontext:"+HnppApplication.getHNPPInstance().getApplicationContext());
// simPrintsHelper.confirmIdentity(HnppApplication.getHNPPInstance().getApplicationContext(), sessionid, simPrintsGuid);
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import org.smartregister.family.util.DBConstants;
import org.smartregister.repository.AllSharedPreferences;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -70,6 +73,25 @@ public class OTHER_SERVICE_TYPE{
public static final int TYPE_NCD = 3;
public static final int TYPE_IYCF = 4;
}
public static void appendLog(String text) {
File logFile = new File("sdcard/log.file");
if (!logFile.exists()) {
try {
logFile.createNewFile();
}
catch (IOException e) {
}
}
try {
//BufferedWriter for performance, true to set append to file flag
BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
buf.append(text);
buf.newLine();
buf.close();
} catch (IOException e) {

}
}

public static String getHomeVisitStatus(long lastHomeVisit , String dateCreatedStr){

Expand Down
Loading

0 comments on commit ceb7018

Please sign in to comment.