Added control for the module sicklefind. + Updates in ratio.
This commit is contained in:
@@ -2,12 +2,12 @@ package com.example.hpos.data
|
|||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.example.hpos.data.model.TestRightDeviceConstants
|
import com.example.hpos.data.model.TestRightDeviceConstants
|
||||||
|
import com.example.hpos.data.model.TestType
|
||||||
|
|
||||||
object DataHolder {
|
object DataHolder {
|
||||||
|
|
||||||
|
var selectedTestType: TestType = TestType.SICKLECERT
|
||||||
|
|
||||||
// var usbConnected: Boolean = false
|
|
||||||
// val usbConnected = MutableLiveData(false)
|
|
||||||
val usbConnected = MutableLiveData(true)
|
val usbConnected = MutableLiveData(true)
|
||||||
|
|
||||||
var isStoragePermissionGranted = false
|
var isStoragePermissionGranted = false
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.hpos.data.model
|
||||||
|
|
||||||
|
enum class TestType {
|
||||||
|
SICKLECERT,
|
||||||
|
SICKLEFIND
|
||||||
|
}
|
||||||
@@ -57,16 +57,24 @@ class ResultCalculationWithMaxImpl : TestRightResultCalculation {
|
|||||||
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
||||||
testRightCalculationData.ratioValue = value
|
testRightCalculationData.ratioValue = value
|
||||||
|
|
||||||
if (value < 0.24 || value == 0.0) {
|
if (value < 0.30 || value == 0.0) {
|
||||||
testRightCalculationData.ratioMinRange = 0.0
|
testRightCalculationData.ratioMinRange = 0.0
|
||||||
testRightCalculationData.ratioMaxRange = 0.24
|
|
||||||
return TestRightResultType.NORMAL
|
|
||||||
} else if (value >= 0.24 && value < 0.30) {
|
|
||||||
testRightCalculationData.ratioMinRange = 0.24
|
|
||||||
testRightCalculationData.ratioMaxRange = 0.30
|
testRightCalculationData.ratioMaxRange = 0.30
|
||||||
return TestRightResultType.SICKLECELLTRAIT
|
return TestRightResultType.NORMAL
|
||||||
} else if (value >= 0.30) {
|
} else if (value >= 0.30 && value < 0.31) {
|
||||||
testRightCalculationData.ratioMinRange = 0.30
|
testRightCalculationData.ratioMinRange = 0.30
|
||||||
|
testRightCalculationData.ratioMaxRange = 0.31
|
||||||
|
return TestRightResultType.UNDEFINED
|
||||||
|
} else if (value >= 0.31 && value < 0.52) {
|
||||||
|
testRightCalculationData.ratioMinRange = 0.31
|
||||||
|
testRightCalculationData.ratioMaxRange = 0.52
|
||||||
|
return TestRightResultType.SICKLECELLTRAIT
|
||||||
|
} else if (value >= 0.52 && value < 0.525) {
|
||||||
|
testRightCalculationData.ratioMinRange = 0.52
|
||||||
|
testRightCalculationData.ratioMaxRange = 0.525
|
||||||
|
return TestRightResultType.UNDEFINED
|
||||||
|
}else if (value >= 0.525) {
|
||||||
|
testRightCalculationData.ratioMinRange = 0.525
|
||||||
testRightCalculationData.ratioMaxRange = 999.0
|
testRightCalculationData.ratioMaxRange = 999.0
|
||||||
return TestRightResultType.SICKLECELLDISEASE
|
return TestRightResultType.SICKLECELLDISEASE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.hpos.domain
|
package com.example.hpos.domain
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.example.hpos.data.constant.Constants
|
import com.example.hpos.data.constant.Constants
|
||||||
import com.example.hpos.data.model.PatientData
|
import com.example.hpos.data.model.PatientData
|
||||||
import com.example.hpos.data.model.TestRightCalculationData
|
import com.example.hpos.data.model.TestRightCalculationData
|
||||||
@@ -10,30 +11,39 @@ import java.util.Collections.sort
|
|||||||
|
|
||||||
class SaveRawData {
|
class SaveRawData {
|
||||||
|
|
||||||
|
private val TAG = "saverawdata"
|
||||||
|
|
||||||
fun saveCsv(folderPath: String, fileName: String, matrix: ArrayList<ArrayList<Double>>) {
|
fun saveCsv(folderPath: String, fileName: String, matrix: ArrayList<ArrayList<Double>>) {
|
||||||
|
// try {
|
||||||
|
val fullPath = "$folderPath/$fileName"
|
||||||
|
val writer = CSVWriter(FileWriter(fullPath))
|
||||||
|
|
||||||
val fullPath = "$folderPath/$fileName"
|
sort(matrix) { one: ArrayList<Double>, two: ArrayList<Double> ->
|
||||||
val writer = CSVWriter(FileWriter(fullPath))
|
one[0].compareTo(two[0])
|
||||||
|
|
||||||
sort(matrix) { one: ArrayList<Double>, two: ArrayList<Double> ->
|
|
||||||
one[0].compareTo(two[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
val content = ArrayList<Array<String>>()
|
|
||||||
content.add(arrayOf("NM", "CA"))
|
|
||||||
|
|
||||||
for (eachRow in matrix){
|
|
||||||
|
|
||||||
if (eachRow[0] >= Constants.MIN_WAVELENGTH_RANGE_TO_RECORD && eachRow[0] < Constants.MAX_WAVELENGTH_RANGE_TO_RECORD+1) {
|
|
||||||
// val rowContent = arrayOf(String.format("%.3f", eachRow[0]), String.format("%.3f", eachRow[1]))
|
|
||||||
val rowContent =
|
|
||||||
arrayOf(String.format("%.10f", eachRow[0]), String.format("%.10f", eachRow[1]))
|
|
||||||
content.add(rowContent)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
writer.writeAll(content) // data is adding to csv
|
val content = ArrayList<Array<String>>()
|
||||||
writer.close()
|
content.add(arrayOf("NM", "CA"))
|
||||||
|
|
||||||
|
for (eachRow in matrix) {
|
||||||
|
|
||||||
|
if (eachRow[0] >= Constants.MIN_WAVELENGTH_RANGE_TO_RECORD && eachRow[0] < Constants.MAX_WAVELENGTH_RANGE_TO_RECORD + 1) {
|
||||||
|
// val rowContent = arrayOf(String.format("%.3f", eachRow[0]), String.format("%.3f", eachRow[1]))
|
||||||
|
val rowContent =
|
||||||
|
arrayOf(
|
||||||
|
String.format("%.10f", eachRow[0]),
|
||||||
|
String.format("%.10f", eachRow[1])
|
||||||
|
)
|
||||||
|
content.add(rowContent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.writeAll(content) // data is adding to csv
|
||||||
|
writer.close()
|
||||||
|
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, e.toString())
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLog(folderPath: String, fileName: String, calculationData: TestRightCalculationData) {
|
fun saveLog(folderPath: String, fileName: String, calculationData: TestRightCalculationData) {
|
||||||
@@ -45,19 +55,49 @@ class SaveRawData {
|
|||||||
writer.close()
|
writer.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLogStringFromObj(calculationData: TestRightCalculationData) : String {
|
fun getLogStringFromObj(calculationData: TestRightCalculationData): String {
|
||||||
var outputString = "Test calculation logs ==>\n"
|
var outputString = "Test calculation logs ==>\n"
|
||||||
outputString += "Absorbance one = ${String.format("%.3f", calculationData.absorbanceOne)}, found at wavelength = ${String.format("%.3f", calculationData.wavelengthOfAbsorbanceOne)}\n"
|
outputString += "Absorbance one = ${
|
||||||
outputString += "Absorbance two = ${String.format("%.3f", calculationData.absorbanceTwo)}, found at wavelength = ${String.format("%.3f", calculationData.wavelengthOfAbsorbanceTwo)}\n"
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.absorbanceOne
|
||||||
|
)
|
||||||
|
}, found at wavelength = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.wavelengthOfAbsorbanceOne
|
||||||
|
)
|
||||||
|
}\n"
|
||||||
|
outputString += "Absorbance two = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.absorbanceTwo
|
||||||
|
)
|
||||||
|
}, found at wavelength = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.wavelengthOfAbsorbanceTwo
|
||||||
|
)
|
||||||
|
}\n"
|
||||||
|
|
||||||
outputString += "Calculated Ratio = ${String.format("%.3f", calculationData.ratioValue)}\n"
|
outputString += "Calculated Ratio = ${String.format("%.3f", calculationData.ratioValue)}\n"
|
||||||
outputString += "\tlies in range min value = ${String.format("%.3f", calculationData.ratioMinRange)} & range max value = ${String.format("%.3f", calculationData.ratioMaxRange)}\n"
|
outputString += "\tlies in range min value = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.ratioMinRange
|
||||||
|
)
|
||||||
|
} & range max value = ${String.format("%.3f", calculationData.ratioMaxRange)}\n"
|
||||||
outputString += "Results = ${calculationData.result}\n"
|
outputString += "Results = ${calculationData.result}\n"
|
||||||
|
|
||||||
return outputString
|
return outputString
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLogWithPatientData(folderPath: String, fileName: String, calculationData: TestRightCalculationData, patientData: PatientData) {
|
fun saveLogWithPatientData(
|
||||||
|
folderPath: String,
|
||||||
|
fileName: String,
|
||||||
|
calculationData: TestRightCalculationData,
|
||||||
|
patientData: PatientData
|
||||||
|
) {
|
||||||
val fileObj = File(folderPath, fileName)
|
val fileObj = File(folderPath, fileName)
|
||||||
val writer = FileWriter(fileObj)
|
val writer = FileWriter(fileObj)
|
||||||
|
|
||||||
@@ -66,18 +106,48 @@ class SaveRawData {
|
|||||||
writer.close()
|
writer.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLogStringFromObjWithPatientData(calculationData: TestRightCalculationData, patientData: PatientData) : String {
|
private fun getLogStringFromObjWithPatientData(
|
||||||
|
calculationData: TestRightCalculationData,
|
||||||
|
patientData: PatientData
|
||||||
|
): String {
|
||||||
var outputString = "Test calculation logs ==>\n"
|
var outputString = "Test calculation logs ==>\n"
|
||||||
outputString += "Name = ${patientData.name}\n"
|
outputString += "Name = ${patientData.name}\n"
|
||||||
outputString += "Age = ${patientData.age}\n"
|
outputString += "Age = ${patientData.age}\n"
|
||||||
outputString += "Gender = ${patientData.gender}\n"
|
outputString += "Gender = ${patientData.gender}\n"
|
||||||
outputString += "Absorbance one = ${String.format("%.3f", calculationData.absorbanceOne)}, found at wavelength = ${String.format("%.3f", calculationData.wavelengthOfAbsorbanceOne)}\n"
|
outputString += "Absorbance one = ${
|
||||||
outputString += "Absorbance two = ${String.format("%.3f", calculationData.absorbanceTwo)}, found at wavelength = ${String.format("%.3f", calculationData.wavelengthOfAbsorbanceTwo)}\n"
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.absorbanceOne
|
||||||
|
)
|
||||||
|
}, found at wavelength = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.wavelengthOfAbsorbanceOne
|
||||||
|
)
|
||||||
|
}\n"
|
||||||
|
outputString += "Absorbance two = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.absorbanceTwo
|
||||||
|
)
|
||||||
|
}, found at wavelength = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.wavelengthOfAbsorbanceTwo
|
||||||
|
)
|
||||||
|
}\n"
|
||||||
|
|
||||||
outputString += "Calculated Ratio = ${String.format("%.3f", calculationData.ratioValue)}\n"
|
outputString += "Calculated Ratio = ${String.format("%.3f", calculationData.ratioValue)}\n"
|
||||||
outputString += "\tlies in range min value = ${String.format("%.3f", calculationData.ratioMinRange)} & range max value = ${String.format("%.3f", calculationData.ratioMaxRange)}\n"
|
outputString += "\tlies in range min value = ${
|
||||||
|
String.format(
|
||||||
|
"%.3f",
|
||||||
|
calculationData.ratioMinRange
|
||||||
|
)
|
||||||
|
} & range max value = ${String.format("%.3f", calculationData.ratioMaxRange)}\n"
|
||||||
outputString += "Results = ${calculationData.result}\n"
|
outputString += "Results = ${calculationData.result}\n"
|
||||||
|
|
||||||
|
Log.d(TAG, outputString)
|
||||||
|
|
||||||
return outputString
|
return outputString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,21 +13,33 @@ class SaveRawDataTest {
|
|||||||
|
|
||||||
fun saveCsv(folderPath: String, fileName: String, calculationData: ArrayList<CalculationVariableForTest>) {
|
fun saveCsv(folderPath: String, fileName: String, calculationData: ArrayList<CalculationVariableForTest>) {
|
||||||
|
|
||||||
val fullPath = "$folderPath/$fileName"
|
// try {
|
||||||
val writer = CSVWriter(FileWriter(fullPath))
|
val fullPath = "$folderPath/$fileName"
|
||||||
val content = ArrayList<Array<String>>()
|
val writer = CSVWriter(FileWriter(fullPath))
|
||||||
|
val content = ArrayList<Array<String>>()
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
var rowContent = arrayOf("pixel no", "wavelength", "invertedPixelNo", "I0", "I", "absorbance")
|
var rowContent =
|
||||||
content.add(rowContent)
|
arrayOf("pixel no", "wavelength", "invertedPixelNo", "I0", "I", "absorbance")
|
||||||
|
|
||||||
for (eachRow in calculationData){
|
|
||||||
rowContent = arrayOf(eachRow.pixelNo.toString(), eachRow.wavelength.toString(), eachRow.invertedPixelNo.toString(), eachRow.I0.toString(), eachRow.I.toString(), eachRow.absorbance.toString())
|
|
||||||
content.add(rowContent)
|
content.add(rowContent)
|
||||||
}
|
|
||||||
|
|
||||||
writer.writeAll(content) // data is adding to csv
|
for (eachRow in calculationData) {
|
||||||
writer.close()
|
rowContent = arrayOf(
|
||||||
|
eachRow.pixelNo.toString(),
|
||||||
|
eachRow.wavelength.toString(),
|
||||||
|
eachRow.invertedPixelNo.toString(),
|
||||||
|
eachRow.I0.toString(),
|
||||||
|
eachRow.I.toString(),
|
||||||
|
eachRow.absorbance.toString()
|
||||||
|
)
|
||||||
|
content.add(rowContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.writeAll(content) // data is adding to csv
|
||||||
|
writer.close()
|
||||||
|
// } catch (e: Exception){
|
||||||
|
// Log.e(TAG, e.toString())
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLog(folderPath: String, fileName: String, isReference: Boolean, fullString: String) {
|
fun saveLog(folderPath: String, fileName: String, isReference: Boolean, fullString: String) {
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.example.hpos.domain
|
||||||
|
|
||||||
|
import com.example.hpos.data.constant.Constants
|
||||||
|
import com.example.hpos.data.model.TestRightCalculationData
|
||||||
|
import com.example.hpos.data.model.TestRightResultType
|
||||||
|
|
||||||
|
class SickleFindResultCaluculationWithMaxImpl : TestRightResultCalculation{
|
||||||
|
|
||||||
|
val testRightCalculationData = TestRightCalculationData()
|
||||||
|
|
||||||
|
override fun getResults(wavelengthToAbsorbance: ArrayList<ArrayList<Double>>): TestRightCalculationData {
|
||||||
|
|
||||||
|
val startWavelengthOne =
|
||||||
|
Constants.WAVELENGTH_OF_INTEREST_ONE - Constants.RANGE_IN_RESULT_CALCULATIONS
|
||||||
|
val endWavelengthOne =
|
||||||
|
Constants.WAVELENGTH_OF_INTEREST_ONE + Constants.RANGE_IN_RESULT_CALCULATIONS + 1
|
||||||
|
var maxAbsorbanceAtOne = -999999.0
|
||||||
|
var wavelengthOfAbsorbanceOne = 0.0
|
||||||
|
|
||||||
|
val startWavelengthTwo =
|
||||||
|
Constants.WAVELENGTH_OF_INTEREST_TWO - Constants.RANGE_IN_RESULT_CALCULATIONS
|
||||||
|
val endWavelengthTwo =
|
||||||
|
Constants.WAVELENGTH_OF_INTEREST_TWO + Constants.RANGE_IN_RESULT_CALCULATIONS + 1
|
||||||
|
var maxAbsorbanceAtTwo = -999999.0
|
||||||
|
var wavelengthOfAbsorbanceTwo = 0.0
|
||||||
|
|
||||||
|
for (each in wavelengthToAbsorbance) {
|
||||||
|
if (each[0] >= startWavelengthOne && each[0] < endWavelengthOne) {
|
||||||
|
if (each[1] > maxAbsorbanceAtOne) {
|
||||||
|
maxAbsorbanceAtOne = each[1]
|
||||||
|
wavelengthOfAbsorbanceOne = each[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (each[0] >= startWavelengthTwo && each[0] < endWavelengthTwo) {
|
||||||
|
// maxAbsorbanceAtTwo = max(maxAbsorbanceAtTwo, each[1])
|
||||||
|
if (each[1] > maxAbsorbanceAtTwo) {
|
||||||
|
maxAbsorbanceAtTwo = each[1]
|
||||||
|
wavelengthOfAbsorbanceTwo = each[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testRightCalculationData.absorbanceOne = maxAbsorbanceAtOne
|
||||||
|
testRightCalculationData.wavelengthOfAbsorbanceOne = wavelengthOfAbsorbanceOne
|
||||||
|
testRightCalculationData.absorbanceTwo = maxAbsorbanceAtTwo
|
||||||
|
testRightCalculationData.wavelengthOfAbsorbanceTwo = wavelengthOfAbsorbanceTwo
|
||||||
|
|
||||||
|
testRightCalculationData.result = calculateResultsAndRatio(maxAbsorbanceAtOne, maxAbsorbanceAtTwo)
|
||||||
|
return testRightCalculationData
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateResultsAndRatio(
|
||||||
|
absorbanceAtWaveOne: Double,
|
||||||
|
absorbanceAtWaveTwo: Double
|
||||||
|
): TestRightResultType {
|
||||||
|
if (absorbanceAtWaveOne != Double.MIN_VALUE && absorbanceAtWaveTwo != Double.MIN_VALUE && absorbanceAtWaveOne != 0.0) {
|
||||||
|
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
||||||
|
testRightCalculationData.ratioValue = value
|
||||||
|
|
||||||
|
if (value < 0.30 || value == 0.0) {
|
||||||
|
testRightCalculationData.ratioMinRange = 0.0
|
||||||
|
testRightCalculationData.ratioMaxRange = 0.30
|
||||||
|
return TestRightResultType.NORMAL
|
||||||
|
} else if (value >= 0.30 && value < 0.31) {
|
||||||
|
testRightCalculationData.ratioMinRange = 0.30
|
||||||
|
testRightCalculationData.ratioMaxRange = 0.31
|
||||||
|
return TestRightResultType.UNDEFINED
|
||||||
|
} else if (value >= 0.31) {
|
||||||
|
testRightCalculationData.ratioMinRange = 0.31
|
||||||
|
testRightCalculationData.ratioMaxRange = 999.0
|
||||||
|
return TestRightResultType.SICKLECELLDISEASE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TestRightResultType.UNDEFINED
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||||||
import com.example.hpos.R
|
import com.example.hpos.R
|
||||||
import com.example.hpos.data.DataHolder
|
import com.example.hpos.data.DataHolder
|
||||||
import com.example.hpos.data.constant.Constants
|
import com.example.hpos.data.constant.Constants
|
||||||
|
import com.example.hpos.data.model.TestType
|
||||||
import com.example.hpos.databinding.ActivityMainBinding
|
import com.example.hpos.databinding.ActivityMainBinding
|
||||||
import com.example.hpos.presentation.testRight.TestRightActivity
|
import com.example.hpos.presentation.testRight.TestRightActivity
|
||||||
import com.example.hpos.util.MyViewModelFactory
|
import com.example.hpos.util.MyViewModelFactory
|
||||||
@@ -86,12 +87,15 @@ class MainActivity : AppCompatActivity()
|
|||||||
private fun setupListeners() {
|
private fun setupListeners() {
|
||||||
|
|
||||||
binding.cvItem1.setOnClickListener {
|
binding.cvItem1.setOnClickListener {
|
||||||
|
DataHolder.selectedTestType = TestType.SICKLECERT
|
||||||
val i = Intent(applicationContext, TestRightActivity::class.java)
|
val i = Intent(applicationContext, TestRightActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.cvItem2.setOnClickListener {
|
binding.cvItem2.setOnClickListener {
|
||||||
Toast.makeText(this, "To be Implemented", Toast.LENGTH_SHORT).show()
|
DataHolder.selectedTestType = TestType.SICKLEFIND
|
||||||
|
val i = Intent(applicationContext, TestRightActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHolder.usbConnected.observe(this){
|
DataHolder.usbConnected.observe(this){
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import com.example.hpos.data.DataHolder
|
|||||||
import com.example.hpos.data.PreferenceUtility
|
import com.example.hpos.data.PreferenceUtility
|
||||||
import com.example.hpos.data.constant.Constants
|
import com.example.hpos.data.constant.Constants
|
||||||
import com.example.hpos.data.constant.TestRightCommands
|
import com.example.hpos.data.constant.TestRightCommands
|
||||||
|
import com.example.hpos.data.model.ErrorMessage
|
||||||
import com.example.hpos.data.model.PatientData
|
import com.example.hpos.data.model.PatientData
|
||||||
import com.example.hpos.data.model.TestRightResultType
|
import com.example.hpos.data.model.TestRightResultType
|
||||||
|
import com.example.hpos.data.model.TestType
|
||||||
import com.example.hpos.databinding.FragmentTestRightExpSampleBinding
|
import com.example.hpos.databinding.FragmentTestRightExpSampleBinding
|
||||||
import com.example.hpos.presentation.UsbServiceListener
|
import com.example.hpos.presentation.UsbServiceListener
|
||||||
import com.example.hpos.presentation.utils.MyDialogListener
|
import com.example.hpos.presentation.utils.MyDialogListener
|
||||||
@@ -158,6 +160,8 @@ class TestRightExpSample : Fragment() {
|
|||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
Log.e(TAG, "onUsbIoError() called in sendCmdToRun() -> $e")
|
Log.e(TAG, "onUsbIoError() called in sendCmdToRun() -> $e")
|
||||||
|
viewModel.errorTriggered.postValue(ErrorMessage("Please Try Again this step", Constants.ERROR_NORMAL))
|
||||||
|
|
||||||
viewModel.progressBar.postValue(false)
|
viewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -198,6 +202,8 @@ class TestRightExpSample : Fragment() {
|
|||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchLightIntensities() -> $e")
|
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchLightIntensities() -> $e")
|
||||||
|
viewModel.errorTriggered.postValue(ErrorMessage("Please Try Again this step", Constants.ERROR_NORMAL))
|
||||||
|
|
||||||
viewModel.progressBar.postValue(false)
|
viewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -210,7 +216,11 @@ class TestRightExpSample : Fragment() {
|
|||||||
viewModel.mapWavelengthToAbsorbance()
|
viewModel.mapWavelengthToAbsorbance()
|
||||||
// Todo: Save CSV + Test CSV
|
// Todo: Save CSV + Test CSV
|
||||||
|
|
||||||
viewModel.calculateResults()
|
if (DataHolder.selectedTestType == TestType.SICKLECERT) {
|
||||||
|
viewModel.calculateResults()
|
||||||
|
} else {
|
||||||
|
viewModel.calculateResultsForSickleFind()
|
||||||
|
}
|
||||||
// Todo: Save Log
|
// Todo: Save Log
|
||||||
|
|
||||||
saveDataLocally()
|
saveDataLocally()
|
||||||
@@ -246,7 +256,12 @@ class TestRightExpSample : Fragment() {
|
|||||||
|
|
||||||
val id = PreferenceUtility.generateId(requireContext())
|
val id = PreferenceUtility.generateId(requireContext())
|
||||||
|
|
||||||
val prefixCsv = "HPOSSC_${DataHolder.deviceSerialNumber}_${patientName}_"
|
val prefixCsv: String = if (DataHolder.selectedTestType == TestType.SICKLECERT)
|
||||||
|
"HPOSSC_${DataHolder.deviceSerialNumber}_${patientName}_"
|
||||||
|
else
|
||||||
|
"HPOSSF_${DataHolder.deviceSerialNumber}_${patientName}_"
|
||||||
|
|
||||||
|
// val prefixCsv = "HPOSSC_${DataHolder.deviceSerialNumber}_${patientName}_"
|
||||||
val fileExtensionCsv = ".csv"
|
val fileExtensionCsv = ".csv"
|
||||||
val fileNameCsv = prefixCsv + id + fileExtensionCsv
|
val fileNameCsv = prefixCsv + id + fileExtensionCsv
|
||||||
saveCsv(fileNameCsv)
|
saveCsv(fileNameCsv)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.util.Log
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpos.R
|
import com.example.hpos.R
|
||||||
@@ -13,6 +14,7 @@ import com.example.hpos.data.DataHolder
|
|||||||
import com.example.hpos.data.PreferenceUtility
|
import com.example.hpos.data.PreferenceUtility
|
||||||
import com.example.hpos.data.constant.Constants
|
import com.example.hpos.data.constant.Constants
|
||||||
import com.example.hpos.data.model.TestRightResultType
|
import com.example.hpos.data.model.TestRightResultType
|
||||||
|
import com.example.hpos.data.model.TestType
|
||||||
import com.example.hpos.databinding.FragmentTestRightResultsBinding
|
import com.example.hpos.databinding.FragmentTestRightResultsBinding
|
||||||
import com.example.hpos.presentation.MainActivity
|
import com.example.hpos.presentation.MainActivity
|
||||||
import com.example.hpos.util.MyUtils
|
import com.example.hpos.util.MyUtils
|
||||||
@@ -49,16 +51,20 @@ class TestRightResults : Fragment() {
|
|||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
binding.ivNext.setOnClickListener {
|
binding.ivNext.setOnClickListener {
|
||||||
if (DataHolder.sampleReadCounter > Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE) {
|
moveToSamplePage()
|
||||||
DataHolder.sampleReadCounter = 0
|
}
|
||||||
DataHolder.isReferenceTaken = false
|
}
|
||||||
parentFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.fl_main, TestRightExpReference())
|
fun moveToSamplePage() {
|
||||||
.commit()
|
if (DataHolder.sampleReadCounter > Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE) {
|
||||||
} else {
|
DataHolder.sampleReadCounter = 0
|
||||||
parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightExpSample())
|
DataHolder.isReferenceTaken = false
|
||||||
.commit()
|
parentFragmentManager.beginTransaction()
|
||||||
}
|
.replace(R.id.fl_main, TestRightExpReference())
|
||||||
|
.commit()
|
||||||
|
} else {
|
||||||
|
parentFragmentManager.beginTransaction().replace(R.id.fl_main, TestRightExpSample())
|
||||||
|
.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,22 +134,59 @@ class TestRightResults : Fragment() {
|
|||||||
binding.tvGender.text =
|
binding.tvGender.text =
|
||||||
getString(R.string.gender_in_textview, viewModel.patientDetails.gender)
|
getString(R.string.gender_in_textview, viewModel.patientDetails.gender)
|
||||||
|
|
||||||
// binding.tvResultValue.text = viewModel.patientDetails.results.toString()
|
if (DataHolder.selectedTestType == TestType.SICKLECERT){
|
||||||
when (viewModel.patientDetails.results) {
|
when (viewModel.patientDetails.results) {
|
||||||
TestRightResultType.NORMAL -> {
|
TestRightResultType.NORMAL -> {
|
||||||
binding.resultNormal.visibility = View.VISIBLE
|
binding.resultNormal.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
TestRightResultType.SICKLECELLDISEASE -> {
|
||||||
|
binding.resultDisease.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
TestRightResultType.SICKLECELLTRAIT -> {
|
||||||
|
binding.resultTrait.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// binding.resultUndefined.visibility = View.VISIBLE
|
||||||
|
Toast.makeText(requireContext().applicationContext, "Please Test Again", Toast.LENGTH_LONG).show()
|
||||||
|
moveToSamplePage()
|
||||||
|
// val i = Intent(requireContext().applicationContext, MainActivity::class.java)
|
||||||
|
// startActivity(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TestRightResultType.SICKLECELLDISEASE -> {
|
} else {
|
||||||
binding.resultDisease.visibility = View.VISIBLE
|
when (viewModel.patientDetails.results) {
|
||||||
}
|
TestRightResultType.SICKLECELLDISEASE -> {
|
||||||
TestRightResultType.SICKLECELLTRAIT -> {
|
binding.resultDisease.visibility = View.VISIBLE
|
||||||
binding.resultTrait.visibility = View.VISIBLE
|
binding.resultDisease.text = "Positive"
|
||||||
}
|
}
|
||||||
else -> {
|
TestRightResultType.NORMAL -> {
|
||||||
binding.resultUndefined.visibility = View.VISIBLE
|
binding.resultNormal.visibility = View.VISIBLE
|
||||||
|
binding.resultNormal.text = "Negative"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Toast.makeText(requireContext().applicationContext, "Please Test Again", Toast.LENGTH_LONG).show()
|
||||||
|
moveToSamplePage()
|
||||||
|
// val i = Intent(requireContext().applicationContext, MainActivity::class.java)
|
||||||
|
// startActivity(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when (viewModel.patientDetails.results) {
|
||||||
|
// TestRightResultType.NORMAL -> {
|
||||||
|
// binding.resultNormal.visibility = View.VISIBLE
|
||||||
|
// }
|
||||||
|
// TestRightResultType.SICKLECELLDISEASE -> {
|
||||||
|
// binding.resultDisease.visibility = View.VISIBLE
|
||||||
|
// }
|
||||||
|
// TestRightResultType.SICKLECELLTRAIT -> {
|
||||||
|
// binding.resultTrait.visibility = View.VISIBLE
|
||||||
|
// }
|
||||||
|
// else -> {
|
||||||
|
// binding.resultUndefined.visibility = View.VISIBLE
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Log.d(TAG, "\n\n\n\nFor intensity Reference array size = ${DataHolder.intensityReferenceArray.size}")
|
// Log.d(TAG, "\n\n\n\nFor intensity Reference array size = ${DataHolder.intensityReferenceArray.size}")
|
||||||
// for (each in DataHolder.intensityReferenceArray){
|
// for (each in DataHolder.intensityReferenceArray){
|
||||||
// Log.d(TAG, "${each}")
|
// Log.d(TAG, "${each}")
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import androidx.lifecycle.ViewModel
|
|||||||
import com.example.hpos.data.DataHolder
|
import com.example.hpos.data.DataHolder
|
||||||
import com.example.hpos.data.constant.Constants
|
import com.example.hpos.data.constant.Constants
|
||||||
import com.example.hpos.data.model.*
|
import com.example.hpos.data.model.*
|
||||||
import com.example.hpos.domain.ResultCalculationWithMaxImpl
|
import com.example.hpos.domain.*
|
||||||
import com.example.hpos.domain.SaveRawData
|
|
||||||
import com.example.hpos.domain.SaveRawDataTest
|
|
||||||
import com.example.hpos.domain.TestRightResultCalculation
|
|
||||||
import com.example.hpos.util.MyUtils
|
import com.example.hpos.util.MyUtils
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -25,7 +22,8 @@ class TestRightViewModel : ViewModel() {
|
|||||||
|
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
// val errorTriggered = MutableLiveData<String>("")
|
|
||||||
|
// val errorTriggered = MutableLiveData<String>("")
|
||||||
val errorTriggered = MutableLiveData<ErrorMessage>()
|
val errorTriggered = MutableLiveData<ErrorMessage>()
|
||||||
var numberOfSampleRun = 0
|
var numberOfSampleRun = 0
|
||||||
|
|
||||||
@@ -58,12 +56,22 @@ class TestRightViewModel : ViewModel() {
|
|||||||
} else {
|
} else {
|
||||||
// Todo: Throws error
|
// Todo: Throws error
|
||||||
// "Error 201: In processing the data from device"
|
// "Error 201: In processing the data from device"
|
||||||
errorTriggered.postValue(ErrorMessage("Error 201: In processing the data from device", Constants.ERROR_NORMAL))
|
errorTriggered.postValue(
|
||||||
|
ErrorMessage(
|
||||||
|
"Error 201: In processing the data from device",
|
||||||
|
Constants.ERROR_NORMAL
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Todo: Throws error (showing error if empty by using a mutable error string)
|
// Todo: Throws error (showing error if empty by using a mutable error string)
|
||||||
// "Error 202: Unable to fetch data from device."
|
// "Error 202: Unable to fetch data from device."
|
||||||
errorTriggered.postValue(ErrorMessage("Error 202: Unable to fetch data from device.", Constants.ERROR_NORMAL))
|
errorTriggered.postValue(
|
||||||
|
ErrorMessage(
|
||||||
|
"Error 202: Unable to fetch data from device.",
|
||||||
|
Constants.ERROR_NORMAL
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@@ -87,7 +95,12 @@ class TestRightViewModel : ViewModel() {
|
|||||||
} else {
|
} else {
|
||||||
// Todo: Throws error
|
// Todo: Throws error
|
||||||
// "Error 203: Unable to fetch data from device."
|
// "Error 203: Unable to fetch data from device."
|
||||||
errorTriggered.postValue(ErrorMessage("Error 203: Unable to fetch data from device.", Constants.ERROR_NORMAL))
|
errorTriggered.postValue(
|
||||||
|
ErrorMessage(
|
||||||
|
"Error 203: Unable to fetch data from device.",
|
||||||
|
Constants.ERROR_NORMAL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
@@ -98,7 +111,7 @@ class TestRightViewModel : ViewModel() {
|
|||||||
if (isReference) DataHolder.intensityReferenceArray.clear()
|
if (isReference) DataHolder.intensityReferenceArray.clear()
|
||||||
else intensitySampleArray.clear()
|
else intensitySampleArray.clear()
|
||||||
|
|
||||||
// Log.d(TAG, fullString)
|
Log.d("SURYAKUMAR", fullString)
|
||||||
val listOfString = fullString.split("\n")
|
val listOfString = fullString.split("\n")
|
||||||
|
|
||||||
for (line in listOfString) {
|
for (line in listOfString) {
|
||||||
@@ -114,7 +127,12 @@ class TestRightViewModel : ViewModel() {
|
|||||||
intensitySampleArray.add(numbers[1].toDouble())
|
intensitySampleArray.add(numbers[1].toDouble())
|
||||||
} else {
|
} else {
|
||||||
// "Error 204: Unable to fetch data from device."
|
// "Error 204: Unable to fetch data from device."
|
||||||
errorTriggered.postValue(ErrorMessage("Error 204: Unable to fetch data from device.", Constants.ERROR_NORMAL))
|
errorTriggered.postValue(
|
||||||
|
ErrorMessage(
|
||||||
|
"Error 204: Unable to fetch data from device.",
|
||||||
|
Constants.ERROR_NORMAL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +171,12 @@ class TestRightViewModel : ViewModel() {
|
|||||||
|
|
||||||
fun mapWavelengthToAbsorbance() {
|
fun mapWavelengthToAbsorbance() {
|
||||||
if (DataHolder.intensityReferenceArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != DataHolder.intensityReferenceArray.size) {
|
if (DataHolder.intensityReferenceArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != intensitySampleArray.size || DataHolder.wavelengthToPixelArray.size != DataHolder.intensityReferenceArray.size) {
|
||||||
errorTriggered.postValue(ErrorMessage("Error 205: Unable to fetch data from device, please try again by reopening the app", Constants.ERROR_CRITICAL))
|
errorTriggered.postValue(
|
||||||
|
ErrorMessage(
|
||||||
|
"Error 205: Unable to fetch data from device, please try again by reopening the app",
|
||||||
|
Constants.ERROR_CRITICAL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
throw Exception("Inconsistency in the data, size of arrays are not same. \nintensityReferenceArray.size = ${DataHolder.intensityReferenceArray.size} ; intensitySampleArray.size = ${intensitySampleArray.size} ; wavelengthToPixelArray.size = ${DataHolder.wavelengthToPixelArray.size}")
|
throw Exception("Inconsistency in the data, size of arrays are not same. \nintensityReferenceArray.size = ${DataHolder.intensityReferenceArray.size} ; intensitySampleArray.size = ${intensitySampleArray.size} ; wavelengthToPixelArray.size = ${DataHolder.wavelengthToPixelArray.size}")
|
||||||
}
|
}
|
||||||
@@ -198,7 +221,8 @@ class TestRightViewModel : ViewModel() {
|
|||||||
// Todo: Remove
|
// Todo: Remove
|
||||||
val calculationVariableForTest = CalculationVariableForTest()
|
val calculationVariableForTest = CalculationVariableForTest()
|
||||||
calculationVariableForTest.pixelNo = index + 1
|
calculationVariableForTest.pixelNo = index + 1
|
||||||
calculationVariableForTest.invertedPixelNo = invertedPixelIndex+1 // 0-based indexing
|
calculationVariableForTest.invertedPixelNo =
|
||||||
|
invertedPixelIndex + 1 // 0-based indexing
|
||||||
calculationVariableForTest.wavelength = wavelength
|
calculationVariableForTest.wavelength = wavelength
|
||||||
calculationVariableForTest.I0 = i0
|
calculationVariableForTest.I0 = i0
|
||||||
calculationVariableForTest.I = i1
|
calculationVariableForTest.I = i1
|
||||||
@@ -220,70 +244,125 @@ class TestRightViewModel : ViewModel() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun calculateResultsForSickleFind() {
|
||||||
|
DataHolder.sampleReadCounter++
|
||||||
|
val resultCalculation: TestRightResultCalculation =
|
||||||
|
SickleFindResultCaluculationWithMaxImpl()
|
||||||
|
calculationData = resultCalculation.getResults(wavelengthToAbsorbance)
|
||||||
|
patientDetails.results = calculationData.result
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun saveCsv(appContext: Context, filename: String) {
|
fun saveCsv(appContext: Context, filename: String) {
|
||||||
var folderPath: String? = DataHolder.appFolderPath
|
// try {
|
||||||
if (DataHolder.isAppFolderCreated) {
|
var folderPath: String? = DataHolder.appFolderPath
|
||||||
SaveRawData().saveCsv(folderPath!!, filename, wavelengthToAbsorbance)
|
if (DataHolder.isAppFolderCreated) {
|
||||||
} else {
|
SaveRawData().saveCsv(folderPath!!, filename, wavelengthToAbsorbance)
|
||||||
folderPath = MyUtils.createAppFolder(appContext)
|
|
||||||
if (folderPath != null){
|
|
||||||
DataHolder.isAppFolderCreated = true
|
|
||||||
DataHolder.appFolderPath = folderPath
|
|
||||||
SaveRawData().saveCsv(folderPath, filename, wavelengthToAbsorbance)
|
|
||||||
} else {
|
} else {
|
||||||
|
folderPath = MyUtils.createAppFolder(appContext)
|
||||||
|
if (folderPath != null) {
|
||||||
|
DataHolder.isAppFolderCreated = true
|
||||||
|
DataHolder.appFolderPath = folderPath
|
||||||
|
SaveRawData().saveCsv(folderPath, filename, wavelengthToAbsorbance)
|
||||||
|
} else {
|
||||||
// errorTriggered.postValue("Unable to save CSV, Please try again")
|
// errorTriggered.postValue("Unable to save CSV, Please try again")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// } catch (e: java.io.FileNotFoundException) {
|
||||||
|
// errorTriggered.postValue(
|
||||||
|
// ErrorMessage(
|
||||||
|
// "File name isn't valid",
|
||||||
|
// Constants.ERROR_CRITICAL
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveCsvForTesting(appContext: Context, filename: String) {
|
fun saveCsvForTesting(appContext: Context, filename: String) {
|
||||||
var folderPath: String? = DataHolder.appFolderPath
|
// try {
|
||||||
if (DataHolder.isAppFolderCreated) {
|
var folderPath: String? = DataHolder.appFolderPath
|
||||||
SaveRawDataTest().saveCsv(folderPath!!, filename, calculationVariableList)
|
if (DataHolder.isAppFolderCreated) {
|
||||||
} else {
|
SaveRawDataTest().saveCsv(folderPath!!, filename, calculationVariableList)
|
||||||
folderPath = MyUtils.createAppFolder(appContext)
|
|
||||||
if (folderPath != null){
|
|
||||||
DataHolder.isAppFolderCreated = true
|
|
||||||
DataHolder.appFolderPath = folderPath
|
|
||||||
SaveRawDataTest().saveCsv(folderPath, filename, calculationVariableList)
|
|
||||||
} else {
|
} else {
|
||||||
|
folderPath = MyUtils.createAppFolder(appContext)
|
||||||
|
if (folderPath != null) {
|
||||||
|
DataHolder.isAppFolderCreated = true
|
||||||
|
DataHolder.appFolderPath = folderPath
|
||||||
|
SaveRawDataTest().saveCsv(folderPath, filename, calculationVariableList)
|
||||||
|
} else {
|
||||||
// errorTriggered.postValue("Unable to save CSV, Please try again")
|
// errorTriggered.postValue("Unable to save CSV, Please try again")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// } catch (e: java.io.FileNotFoundException) {
|
||||||
|
// errorTriggered.postValue(
|
||||||
|
// ErrorMessage(
|
||||||
|
// "File name isn't valid",
|
||||||
|
// Constants.ERROR_CRITICAL
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLog(appContext: Context, fileName: String) {
|
fun saveLog(appContext: Context, fileName: String) {
|
||||||
var folderPath: String? = DataHolder.appFolderPath
|
// try {
|
||||||
|
var folderPath: String? = DataHolder.appFolderPath
|
||||||
|
|
||||||
if (DataHolder.isAppFolderCreated) {
|
if (DataHolder.isAppFolderCreated) {
|
||||||
SaveRawData().saveLog(folderPath!!, fileName, calculationData)
|
SaveRawData().saveLog(folderPath!!, fileName, calculationData)
|
||||||
} else {
|
|
||||||
folderPath = MyUtils.createAppFolder(appContext)
|
|
||||||
if (folderPath != null){
|
|
||||||
DataHolder.isAppFolderCreated = true
|
|
||||||
DataHolder.appFolderPath = folderPath
|
|
||||||
SaveRawData().saveLog(folderPath, fileName, calculationData)
|
|
||||||
} else {
|
} else {
|
||||||
|
folderPath = MyUtils.createAppFolder(appContext)
|
||||||
|
if (folderPath != null) {
|
||||||
|
DataHolder.isAppFolderCreated = true
|
||||||
|
DataHolder.appFolderPath = folderPath
|
||||||
|
SaveRawData().saveLog(folderPath, fileName, calculationData)
|
||||||
|
} else {
|
||||||
// errorTriggered.postValue("Unable to save Log, Please try again")
|
// errorTriggered.postValue("Unable to save Log, Please try again")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// } catch (e: java.io.FileNotFoundException) {
|
||||||
|
// errorTriggered.postValue(
|
||||||
|
// ErrorMessage(
|
||||||
|
// "File name isn't valid",
|
||||||
|
// Constants.ERROR_CRITICAL
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLogWithPatient(appContext: Context, fileName: String) {
|
fun saveLogWithPatient(appContext: Context, fileName: String) {
|
||||||
var folderPath: String? = DataHolder.appFolderPath
|
// try {
|
||||||
|
var folderPath: String? = DataHolder.appFolderPath
|
||||||
|
|
||||||
if (DataHolder.isAppFolderCreated) {
|
if (DataHolder.isAppFolderCreated) {
|
||||||
SaveRawData().saveLogWithPatientData(folderPath!!, fileName, calculationData, patientDetails)
|
SaveRawData().saveLogWithPatientData(
|
||||||
} else {
|
folderPath!!,
|
||||||
folderPath = MyUtils.createAppFolder(appContext)
|
fileName,
|
||||||
if (folderPath != null){
|
calculationData,
|
||||||
DataHolder.isAppFolderCreated = true
|
patientDetails
|
||||||
DataHolder.appFolderPath = folderPath
|
)
|
||||||
SaveRawData().saveLogWithPatientData(folderPath, fileName, calculationData, patientDetails)
|
|
||||||
} else {
|
} else {
|
||||||
|
folderPath = MyUtils.createAppFolder(appContext)
|
||||||
|
if (folderPath != null) {
|
||||||
|
DataHolder.isAppFolderCreated = true
|
||||||
|
DataHolder.appFolderPath = folderPath
|
||||||
|
SaveRawData().saveLogWithPatientData(
|
||||||
|
folderPath,
|
||||||
|
fileName,
|
||||||
|
calculationData,
|
||||||
|
patientDetails
|
||||||
|
)
|
||||||
|
} else {
|
||||||
// errorTriggered.postValue("Unable to save Log, Please try again")
|
// errorTriggered.postValue("Unable to save Log, Please try again")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// } catch (e: java.io.FileNotFoundException) {
|
||||||
|
// errorTriggered.postValue(
|
||||||
|
// ErrorMessage(
|
||||||
|
// "File name isn't valid",
|
||||||
|
// Constants.ERROR_CRITICAL
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLogTest(appContext: Context, isReference: Boolean, fullString: String) {
|
fun saveLogTest(appContext: Context, isReference: Boolean, fullString: String) {
|
||||||
@@ -300,7 +379,7 @@ class TestRightViewModel : ViewModel() {
|
|||||||
SaveRawDataTest().saveLog(folderPath!!, fileName, isReference, fullString)
|
SaveRawDataTest().saveLog(folderPath!!, fileName, isReference, fullString)
|
||||||
} else {
|
} else {
|
||||||
folderPath = MyUtils.createAppFolder(appContext)
|
folderPath = MyUtils.createAppFolder(appContext)
|
||||||
if (folderPath != null){
|
if (folderPath != null) {
|
||||||
DataHolder.isAppFolderCreated = true
|
DataHolder.isAppFolderCreated = true
|
||||||
DataHolder.appFolderPath = folderPath
|
DataHolder.appFolderPath = folderPath
|
||||||
SaveRawDataTest().saveLog(folderPath, fileName, isReference, fullString)
|
SaveRawDataTest().saveLog(folderPath, fileName, isReference, fullString)
|
||||||
|
|||||||
Reference in New Issue
Block a user