|
|
|
|
@@ -12,15 +12,21 @@ import android.content.ContentValues;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Environment;
|
|
|
|
|
import android.provider.Settings;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
|
import android.widget.Spinner;
|
|
|
|
|
import android.widget.TableLayout;
|
|
|
|
|
import android.widget.TableRow;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
@@ -28,10 +34,13 @@ import com.google.android.gms.tasks.OnCompleteListener;
|
|
|
|
|
import com.google.android.gms.tasks.Task;
|
|
|
|
|
import com.google.firebase.database.DatabaseReference;
|
|
|
|
|
import com.google.firebase.database.FirebaseDatabase;
|
|
|
|
|
import com.opencsv.CSVReader;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.io.FileReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
@@ -39,27 +48,34 @@ import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener{
|
|
|
|
|
private Button confirmatory,screening;
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
|
|
|
|
|
private Button confirmatory, screening;
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_CODE_PICK_FILE = 300;
|
|
|
|
|
String FilePath;
|
|
|
|
|
private TextView result;
|
|
|
|
|
float number1;
|
|
|
|
|
float number2;
|
|
|
|
|
private String TestRandomKey,saveCurrentDate, saveCurrentTime;
|
|
|
|
|
private String TestRandomKey, saveCurrentDate, saveCurrentTime;
|
|
|
|
|
private DatabaseReference TestRef;
|
|
|
|
|
private TextView result_confirmatory;
|
|
|
|
|
String device;
|
|
|
|
|
String result_test;
|
|
|
|
|
String result_test1;
|
|
|
|
|
String targetUri;
|
|
|
|
|
TextView Type;
|
|
|
|
|
String line;
|
|
|
|
|
TableLayout table;
|
|
|
|
|
RelativeLayout relativeLayout1;
|
|
|
|
|
String Extension;
|
|
|
|
|
|
|
|
|
|
String directory_path;
|
|
|
|
|
float value;
|
|
|
|
|
int flag=0;
|
|
|
|
|
int columnCount = 0;
|
|
|
|
|
int flag = 0;
|
|
|
|
|
String serial_no, sample_name, numbers1, numbers2, ratios, resultsamp;
|
|
|
|
|
|
|
|
|
|
File file=null;
|
|
|
|
|
File file = null;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
@@ -68,24 +84,31 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
String directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
|
|
|
|
|
screening=findViewById(R.id.screening);
|
|
|
|
|
confirmatory=findViewById(R.id.confirmatory);
|
|
|
|
|
screening = findViewById(R.id.screening);
|
|
|
|
|
confirmatory = findViewById(R.id.confirmatory);
|
|
|
|
|
relativeLayout1 = findViewById(R.id.RelativeLayout1);
|
|
|
|
|
table = findViewById(R.id.table_main);
|
|
|
|
|
TestRef = FirebaseDatabase.getInstance().getReference().child("Test_Data");
|
|
|
|
|
|
|
|
|
|
Type = findViewById(R.id.type);
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
|
|
|
|
Spinner Spinner_gender = findViewById(R.id.spinner_device);
|
|
|
|
|
Spinner Spinner_type = findViewById(R.id.spinner_device);
|
|
|
|
|
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
|
|
|
|
|
R.array.instrument, android.R.layout.simple_spinner_item);
|
|
|
|
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
|
Spinner_gender.setAdapter(adapter);
|
|
|
|
|
Spinner_gender.setOnItemSelectedListener(this);
|
|
|
|
|
result=findViewById(R.id.result);
|
|
|
|
|
result_confirmatory=findViewById(R.id.result_confirmatory);
|
|
|
|
|
Spinner_type.setAdapter(adapter);
|
|
|
|
|
Spinner_type.setOnItemSelectedListener(this);
|
|
|
|
|
result = findViewById(R.id.result);
|
|
|
|
|
result_confirmatory = findViewById(R.id.result_confirmatory);
|
|
|
|
|
if (!Environment.isExternalStorageManager()) {
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
|
|
|
|
|
Uri uri = Uri.fromParts("package", this.getPackageName(), null);
|
|
|
|
|
intent.setData(uri);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
|
|
|
|
|
if(ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},23);
|
|
|
|
|
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 23);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
@@ -95,7 +118,7 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
File file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
@@ -114,13 +137,7 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
@@ -129,7 +146,7 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
screening.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
flag=1;
|
|
|
|
|
flag = 1;
|
|
|
|
|
createfolder();
|
|
|
|
|
|
|
|
|
|
selectCSVFile();
|
|
|
|
|
@@ -140,7 +157,7 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
confirmatory.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
flag=2;
|
|
|
|
|
flag = 2;
|
|
|
|
|
createfolder();
|
|
|
|
|
|
|
|
|
|
selectCSVFile();
|
|
|
|
|
@@ -149,22 +166,19 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void selectCSVFile(){
|
|
|
|
|
private void selectCSVFile() {
|
|
|
|
|
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
|
|
|
|
|
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 23);
|
|
|
|
|
}
|
|
|
|
|
Uri uri = Uri.parse((Environment.getExternalStorageDirectory().getPath() + "/SickleCell/"));
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
|
intent.setDataAndType(uri, "*/*");
|
|
|
|
|
intent.setDataAndType(uri, "*/*");
|
|
|
|
|
|
|
|
|
|
// intent.setType("*/*");
|
|
|
|
|
startActivityForResult(intent,REQUEST_CODE_PICK_FILE);
|
|
|
|
|
// intent.setType("*/*");
|
|
|
|
|
startActivityForResult(intent, REQUEST_CODE_PICK_FILE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -179,299 +193,403 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIt
|
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e("file",data.getData().getPath());
|
|
|
|
|
Log.e("file", data.getData().getPath());
|
|
|
|
|
|
|
|
|
|
FilePath = data.getData().getPath();
|
|
|
|
|
Log.e("Filepath",FilePath);
|
|
|
|
|
Log.e("Filepath", FilePath);
|
|
|
|
|
|
|
|
|
|
String filename1=FilePath.substring(FilePath.lastIndexOf("/")+1);
|
|
|
|
|
String filename1 = FilePath.substring(FilePath.lastIndexOf("/") + 1);
|
|
|
|
|
|
|
|
|
|
Log.e("file",filename1);
|
|
|
|
|
Log.e("file", filename1);
|
|
|
|
|
Extension = FilePath.substring(FilePath.lastIndexOf("."));
|
|
|
|
|
Log.e("Entension ", Extension);
|
|
|
|
|
|
|
|
|
|
String s = FilePath;
|
|
|
|
|
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
targetUri = directory_path+filename1;
|
|
|
|
|
targetUri = directory_path + filename1;
|
|
|
|
|
if (!Extension.contains("csv")) {
|
|
|
|
|
Type.setText("Wrong file Format");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
if(flag==1)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
} else if (flag == 1) {
|
|
|
|
|
ImportCSV(new File(targetUri));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(flag==2)
|
|
|
|
|
{
|
|
|
|
|
} else if (flag == 2) {
|
|
|
|
|
ImportCSV2(new File(targetUri));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ImportCSV(File from) {
|
|
|
|
|
ContentValues cv = new ContentValues();
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
try {
|
|
|
|
|
value = 0;
|
|
|
|
|
number1 = 0;
|
|
|
|
|
number2 = 0;
|
|
|
|
|
resultsamp = "";
|
|
|
|
|
table.removeAllViews();
|
|
|
|
|
try {
|
|
|
|
|
CSVReader reader = new CSVReader(new FileReader(from));
|
|
|
|
|
String[] line;
|
|
|
|
|
InputStream inputStream = new FileInputStream(from);
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String line;
|
|
|
|
|
if(device.equals("TestRight"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Log.e("device", "Test right");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
if (values[0].equals("427.084")) {
|
|
|
|
|
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[0].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value= number2/number1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] header = reader.readNext(); // assuming first read
|
|
|
|
|
if (header != null) { // and there is a (header) line
|
|
|
|
|
columnCount = header.length; // get the column count
|
|
|
|
|
}
|
|
|
|
|
Log.e("columc", String.valueOf(columnCount));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (device.equals("TestRight")) {
|
|
|
|
|
|
|
|
|
|
else if (device.equals("Denovix"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
resultsamp = "";
|
|
|
|
|
|
|
|
|
|
Type.setText(" Select Test Type * ");
|
|
|
|
|
Type.setTextColor(Color.WHITE);
|
|
|
|
|
|
|
|
|
|
if (columnCount > 100) {
|
|
|
|
|
Type.setText("Wrong File");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e("device", "Test right");
|
|
|
|
|
while ((line = reader.readNext()) != null) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] values = line;
|
|
|
|
|
|
|
|
|
|
if (values[0].equals("427.084")) {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (values[0].equals("555.035")) {
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (number1 != 0 || number2 != 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value = number2 / number1;
|
|
|
|
|
Log.e("value", String.valueOf(value));
|
|
|
|
|
if (value < 0.16 || value == 0.0) {
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test = result.getText().toString();
|
|
|
|
|
result_test1 = result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_test = result.getText().toString();
|
|
|
|
|
result_test1 = result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText("Wrong File");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (device.equals("Denovix")) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText(" Select Test Type * ");
|
|
|
|
|
Type.setTextColor(Color.WHITE);
|
|
|
|
|
resultsamp = "";
|
|
|
|
|
|
|
|
|
|
Log.e("device", "denovix");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
if (values[2].equals("427.084")) {
|
|
|
|
|
if (columnCount < 100) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText("Wrong file");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
init1();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ((line = reader.readNext()) != null) {
|
|
|
|
|
|
|
|
|
|
String[] values = line;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (values[1].equals("Blank")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((values[262].replaceAll("[^\\d.]", "")).equals("427") || (values[390].replaceAll("[^\\d.]", "")).equals("555")) {
|
|
|
|
|
continue; //just skip the rows if row number is 0 or 1
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[262].replaceAll("[^\\d.]", "")));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[390]).replaceAll("[^\\d.]", ""));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (number1 != 0 || number2 != 0) {
|
|
|
|
|
|
|
|
|
|
value = number2 / number1;
|
|
|
|
|
Log.e("value", String.valueOf(value));
|
|
|
|
|
if (value < 0.16 || value == 0.0) {
|
|
|
|
|
resultsamp = "Negative";
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
resultsamp = "Positive";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (columnCount < 100) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText("Wrong file");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serial_no = values[0];
|
|
|
|
|
sample_name = values[1];
|
|
|
|
|
numbers1 = values[262];
|
|
|
|
|
numbers2 = values[390];
|
|
|
|
|
ratios = String.valueOf(value);
|
|
|
|
|
init(serial_no, sample_name, ratios, resultsamp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[2].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value=number2/number1;
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("Error in reading CSV file: " + ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ImportCSV2(File from) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
|
number1 = 0;
|
|
|
|
|
number2 = 0;
|
|
|
|
|
table.removeAllViews();
|
|
|
|
|
try {
|
|
|
|
|
CSVReader reader = new CSVReader(new FileReader(from));
|
|
|
|
|
String[] line;
|
|
|
|
|
InputStream inputStream = new FileInputStream(from);
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String line;
|
|
|
|
|
if(device.equals("TestRight"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Log.e("device", "Test right");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
|
|
|
|
|
if (values[0].equals("427.084")) {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[0].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value=number2/number1;
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(value>=0.16 && value < 0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle Cell Trait");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if( value >=0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle-Cell Disease");
|
|
|
|
|
result_test=result.getText().toString();
|
|
|
|
|
result_test1=result_confirmatory.getText().toString();
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
String[] header = reader.readNext(); // assuming first read
|
|
|
|
|
if (header != null) { // and there is a (header) line
|
|
|
|
|
columnCount = header.length; // get the column count
|
|
|
|
|
}
|
|
|
|
|
Log.e("columc", String.valueOf(columnCount));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (device.equals("TestRight")) {
|
|
|
|
|
resultsamp = "";
|
|
|
|
|
|
|
|
|
|
else if (device.equals("Denovix"))
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText(" Select Test Type * ");
|
|
|
|
|
Type.setTextColor(Color.WHITE);
|
|
|
|
|
|
|
|
|
|
if (columnCount > 100) {
|
|
|
|
|
Type.setText("Wrong File");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.e("device", "Test right");
|
|
|
|
|
while ((line = reader.readNext()) != null) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] values = line;
|
|
|
|
|
|
|
|
|
|
if (values[0].equals("427.084")) {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (values[0].equals("555.035")) {
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[1]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (number1 != 0 || number2 != 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
value = number2 / number1;
|
|
|
|
|
Log.e("value", String.valueOf(value));
|
|
|
|
|
if (value < 0.16 || value == 0.0) {
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
result_test = result.getText().toString();
|
|
|
|
|
result_test1 = result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
result_test = result.getText().toString();
|
|
|
|
|
result_test1 = result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (value >= 0.16 && value < 0.24) {
|
|
|
|
|
result_confirmatory.setText("Sickle Cell Trait");
|
|
|
|
|
result_test = result.getText().toString();
|
|
|
|
|
result_test1 = result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
} else if (value >= 0.24) {
|
|
|
|
|
result_confirmatory.setText("Sickle-Cell Disease");
|
|
|
|
|
result_test = result.getText().toString();
|
|
|
|
|
result_test1 = result_confirmatory.getText().toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText("Wrong File");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (device.equals("Denovix")) {
|
|
|
|
|
resultsamp = "";
|
|
|
|
|
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText(" Select Test Type * ");
|
|
|
|
|
Type.setTextColor(Color.WHITE);
|
|
|
|
|
|
|
|
|
|
Log.e("device", "denovix");
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
String[] values = line.split(",");
|
|
|
|
|
if (values[2].equals("427.084")) {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
if (columnCount < 100) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText("Wrong file");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
init1();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ((line = reader.readNext()) != null) {
|
|
|
|
|
|
|
|
|
|
String[] values = line;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (values[1].equals("Blank")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((values[262].replaceAll("[^\\d.]", "")).equals("427") || (values[390].replaceAll("[^\\d.]", "")).equals("555")) {
|
|
|
|
|
continue; //just skip the rows if row number is 0 or 1
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
number1 = Float.parseFloat(String.valueOf(values[262].replaceAll("[^\\d.]", "")));
|
|
|
|
|
Log.e("number1", String.valueOf(number1));
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[390]).replaceAll("[^\\d.]", ""));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (number1 != 0 || number2 != 0) {
|
|
|
|
|
|
|
|
|
|
value = number2 / number1;
|
|
|
|
|
Log.e("value", String.valueOf(value));
|
|
|
|
|
if (value < 0.16 || value == 0.0) {
|
|
|
|
|
resultsamp = "Negative";
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
resultsamp = "Positive";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (value >= 0.16 && value < 0.24) {
|
|
|
|
|
|
|
|
|
|
resultsamp = "Sickle Cell Trait ";
|
|
|
|
|
|
|
|
|
|
} else if (value > 0.24) {
|
|
|
|
|
resultsamp = "Sickle-Cell Disease";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else if (columnCount < 100) {
|
|
|
|
|
result_confirmatory.setText("");
|
|
|
|
|
result.setText("");
|
|
|
|
|
Type.setText("Wrong file");
|
|
|
|
|
Type.setTextColor(Color.RED);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serial_no = values[0];
|
|
|
|
|
sample_name = values[1];
|
|
|
|
|
numbers1 = values[262];
|
|
|
|
|
numbers2 = values[390];
|
|
|
|
|
ratios = String.valueOf(value);
|
|
|
|
|
init(serial_no, sample_name, ratios, resultsamp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(values[2].equals("555.035"))
|
|
|
|
|
{
|
|
|
|
|
number2 = Float.parseFloat(String.valueOf(values[3]));
|
|
|
|
|
Log.e("number2", String.valueOf(number2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
value=number2/number1;
|
|
|
|
|
Log.e("value",String.valueOf(value));
|
|
|
|
|
if(value<0.16)
|
|
|
|
|
{
|
|
|
|
|
result.setText("Negative");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.setText("Positive");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(value>=0.16 && value < 0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle Cell Trait ");
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if( value >0.24)
|
|
|
|
|
{
|
|
|
|
|
result_confirmatory.setText("Sickle-Cell Disease");
|
|
|
|
|
SaveTestInfoToDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("Error in reading CSV file: " + ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
if(parent.getId() == R.id.spinner_device)
|
|
|
|
|
{
|
|
|
|
|
if (parent.getId() == R.id.spinner_device) {
|
|
|
|
|
device = parent.getItemAtPosition(position).toString();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -482,8 +600,8 @@ else if (device.equals("Denovix"))
|
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void createfolder()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private void createfolder() {
|
|
|
|
|
directory_path = Environment.getExternalStorageDirectory().getPath() + "/SickleCell/";
|
|
|
|
|
file = new File(directory_path);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
@@ -493,54 +611,47 @@ else if (device.equals("Denovix"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveTestInfoToDatabase()
|
|
|
|
|
{
|
|
|
|
|
private void SaveTestInfoToDatabase() {
|
|
|
|
|
HashMap<String, Object> productMap = new HashMap<>();
|
|
|
|
|
productMap.put("Value", String.valueOf(value));
|
|
|
|
|
productMap.put("number1", String.valueOf(number1));
|
|
|
|
|
productMap.put("number2",String.valueOf(number2));
|
|
|
|
|
productMap.put("Device",device);
|
|
|
|
|
productMap.put("Result",result_test);
|
|
|
|
|
productMap.put("Result Confirmatory",result_test1);
|
|
|
|
|
productMap.put("Directory Path",directory_path);
|
|
|
|
|
productMap.put("Full Path",targetUri);
|
|
|
|
|
productMap.put("number2", String.valueOf(number2));
|
|
|
|
|
productMap.put("Device", device);
|
|
|
|
|
productMap.put("Result", result_test);
|
|
|
|
|
productMap.put("Result Confirmatory", result_test1);
|
|
|
|
|
productMap.put("Directory Path", directory_path);
|
|
|
|
|
productMap.put("Full Path", targetUri);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// productMap("Result",String.valueOf(result.getText().toString()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat currentDate = new SimpleDateFormat("MMM dd, yyyy");
|
|
|
|
|
|
|
|
|
|
saveCurrentDate = currentDate.format(calendar.getTime());
|
|
|
|
|
saveCurrentDate = saveCurrentDate .replaceAll("[^A-Za-z0-9 ]","");
|
|
|
|
|
saveCurrentDate = saveCurrentDate.replaceAll("[^A-Za-z0-9 ]", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat currentTime = new SimpleDateFormat("h:mm a");
|
|
|
|
|
saveCurrentTime = currentTime.format(calendar.getTime());
|
|
|
|
|
|
|
|
|
|
TestRandomKey = saveCurrentDate + saveCurrentTime+String.valueOf( Math.random());
|
|
|
|
|
TestRandomKey = TestRandomKey .replaceAll("[^A-Za-z0-9 ]","");
|
|
|
|
|
|
|
|
|
|
TestRandomKey = saveCurrentDate + saveCurrentTime + String.valueOf(Math.random());
|
|
|
|
|
TestRandomKey = TestRandomKey.replaceAll("[^A-Za-z0-9 ]", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestRef.child(TestRandomKey).updateChildren(productMap)
|
|
|
|
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onComplete(@NonNull Task<Void> task)
|
|
|
|
|
{
|
|
|
|
|
public void onComplete(@NonNull Task<Void> task) {
|
|
|
|
|
if (task.isSuccessful()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Toast.makeText(MainActivity.this, "Test Result added in backend successfully ", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
String message = task.getException().toString();
|
|
|
|
|
Toast.makeText(MainActivity.this, "Error: " + message, Toast.LENGTH_SHORT).show();
|
|
|
|
|
@@ -550,24 +661,73 @@ else if (device.equals("Denovix"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void init1() {
|
|
|
|
|
|
|
|
|
|
TableLayout stk = (TableLayout) findViewById(R.id.table_main);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TableRow tbrow0 = new TableRow(this);
|
|
|
|
|
tbrow0.setBackgroundResource(R.color.purple_700);
|
|
|
|
|
|
|
|
|
|
TextView tv0 = new TextView(this);
|
|
|
|
|
tv0.setText(" S.No ");
|
|
|
|
|
tbrow0.addView(tv0);
|
|
|
|
|
TextView tv1 = new TextView(this);
|
|
|
|
|
tv1.setText(" Name sample ");
|
|
|
|
|
tbrow0.addView(tv1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextView tv2 = new TextView(this);
|
|
|
|
|
tv2.setText(" Ratio ");
|
|
|
|
|
tbrow0.addView(tv2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextView tv3 = new TextView(this);
|
|
|
|
|
tv3.setText("Result ");
|
|
|
|
|
tbrow0.addView(tv3);
|
|
|
|
|
stk.addView(tbrow0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void init(String sno, String samplename, String ratio, String result) {
|
|
|
|
|
|
|
|
|
|
TableLayout stk = (TableLayout) findViewById(R.id.table_main);
|
|
|
|
|
TableRow tbrow = new TableRow(this);
|
|
|
|
|
TextView t1v = new TextView(this);
|
|
|
|
|
t1v.setText("" + sno + " ");
|
|
|
|
|
t1v.setBackgroundResource(R.drawable.cellshape);
|
|
|
|
|
|
|
|
|
|
t1v.setGravity(Gravity.CENTER);
|
|
|
|
|
tbrow.addView(t1v);
|
|
|
|
|
TextView t2v = new TextView(this);
|
|
|
|
|
t2v.setText(samplename + " ");
|
|
|
|
|
t2v.setBackgroundResource(R.drawable.cellshape);
|
|
|
|
|
|
|
|
|
|
t2v.setGravity(Gravity.CENTER);
|
|
|
|
|
tbrow.addView(t2v);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextView t5v = new TextView(this);
|
|
|
|
|
t5v.setText(ratio + " ");
|
|
|
|
|
t5v.setGravity(Gravity.CENTER);
|
|
|
|
|
tbrow.addView(t5v);
|
|
|
|
|
t5v.setBackgroundResource(R.drawable.cellshape);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextView t6v = new TextView(this);
|
|
|
|
|
t6v.setText(" " + result);
|
|
|
|
|
t6v.setGravity(Gravity.LEFT);
|
|
|
|
|
t6v.setBackgroundResource(R.drawable.cellshape);
|
|
|
|
|
|
|
|
|
|
tbrow.addView(t6v);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stk.addView(tbrow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|