Compare commits
67 Commits
dev-nagpur
...
dev-server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
964f2c4178 | ||
|
|
e64fb09144 | ||
|
|
05ce1d8411 | ||
|
|
b6ae754f1b | ||
|
|
c3acb41590 | ||
|
|
2ee6b65ca5 | ||
|
|
28b8409207 | ||
|
|
5c56ef7630 | ||
|
|
2fbc280b4a | ||
|
|
e9c8a9a887 | ||
|
|
e7ecf7eedf | ||
|
|
e3435f2182 | ||
|
|
f6cdd64ef6 | ||
|
|
7ad21ea5a9 | ||
|
|
6c89efeb5e | ||
|
|
63eaf1cadc | ||
|
|
c180f7be31 | ||
|
|
c243ec6c8f | ||
|
|
7c9238591b | ||
|
|
5c843ca232 | ||
|
|
736dff2b11 | ||
|
|
20dd1e41eb | ||
|
|
ad6670a1e8 | ||
|
|
e6f8ab69e9 | ||
|
|
ccd2138f66 | ||
|
|
d54436996d | ||
|
|
52a555a63a | ||
|
|
8e80cfe525 | ||
|
|
f26f54e51d | ||
|
|
1d029b8ff8 | ||
|
|
c88efd148b | ||
|
|
cb27983d21 | ||
|
|
0b268dda47 | ||
|
|
d9777edf02 | ||
|
|
238424ad89 | ||
|
|
c1f02c878c | ||
|
|
b344dbcb69 | ||
|
|
af7b426416 | ||
|
|
07abfcce6c | ||
|
|
2c62cc11ba | ||
|
|
312e2da79a | ||
|
|
9768a0a835 | ||
|
|
db7aba4549 | ||
|
|
302239d191 | ||
|
|
cc1ae1ff82 | ||
|
|
d420a42fcc | ||
|
|
21b3960ca9 | ||
|
|
9183216cfe | ||
|
|
a72bd3d59e | ||
|
|
54be3a1037 | ||
|
|
69055b5498 | ||
|
|
7dde6bf976 | ||
|
|
ee0f1d748a | ||
|
|
d32e7b6cbb | ||
|
|
d306d0b9fa | ||
|
|
8e074e01c9 | ||
|
|
6b0c81213e | ||
|
|
51480393da | ||
|
|
d9221a3bb6 | ||
|
|
569155d193 | ||
|
|
ad029e4cce | ||
|
|
31654be3bb | ||
|
|
738375afc5 | ||
|
|
e77b4d9a23 | ||
|
|
cf429b4fc3 | ||
|
|
30df9732a7 | ||
|
|
a1ce200ad8 |
107
.gitlab-ci.yml
107
.gitlab-ci.yml
@@ -1,63 +1,31 @@
|
|||||||
# This file is a template, and might need editing before it works on your project.
|
|
||||||
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
|
||||||
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
|
||||||
# This specific template is located at:
|
|
||||||
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Android.gitlab-ci.yml
|
|
||||||
|
|
||||||
# Read more about this script on this blog post https://about.gitlab.com/2018/10/24/setting-up-gitlab-ci-for-android-projects/, by Jason Lenny
|
|
||||||
# If you are interested in using Android with FastLane for publishing take a look at the Android-Fastlane template.
|
|
||||||
|
|
||||||
image: eclipse-temurin:17-jdk-jammy
|
image: eclipse-temurin:17-jdk-jammy
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
|
|
||||||
# ANDROID_COMPILE_SDK is the version of Android you're compiling with.
|
|
||||||
# It should match compileSdkVersion.
|
|
||||||
ANDROID_COMPILE_SDK: "34"
|
ANDROID_COMPILE_SDK: "34"
|
||||||
|
|
||||||
# ANDROID_BUILD_TOOLS is the version of the Android build tools you are using.
|
|
||||||
# It should match buildToolsVersion.
|
|
||||||
ANDROID_BUILD_TOOLS: "33.0.2"
|
ANDROID_BUILD_TOOLS: "33.0.2"
|
||||||
|
|
||||||
# It's what version of the command line tools we're going to download from the official site.
|
|
||||||
# Official Site-> https://developer.android.com/studio/index.html
|
|
||||||
# There, look down below at the cli tools only, sdk tools package is of format:
|
|
||||||
# commandlinetools-os_type-ANDROID_SDK_TOOLS_latest.zip
|
|
||||||
# when the script was last modified for latest compileSdkVersion, it was which is written down below
|
|
||||||
ANDROID_SDK_TOOLS: "9477386"
|
ANDROID_SDK_TOOLS: "9477386"
|
||||||
|
|
||||||
|
# Keystore credentials stored as GitLab CI/CD variables
|
||||||
|
KEYSTORE_PASSWORD: $KS_PASSWORD
|
||||||
|
KEY_ALIAS: $KS_ALIAS
|
||||||
|
KEY_PASSWORD: $KS_KEY_PASSWORD
|
||||||
|
|
||||||
# Packages installation before running script
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get --quiet update --yes
|
- apt-get --quiet update --yes
|
||||||
- apt-get --quiet install --yes wget unzip
|
- apt-get --quiet install --yes wget unzip
|
||||||
|
|
||||||
# Setup path as android_home for moving/exporting the downloaded sdk into it
|
|
||||||
- export ANDROID_HOME="${PWD}/android-sdk-root"
|
- export ANDROID_HOME="${PWD}/android-sdk-root"
|
||||||
# Create a new directory at specified location
|
|
||||||
- install -d $ANDROID_HOME
|
- install -d $ANDROID_HOME
|
||||||
# Here we are installing androidSDK tools from official source,
|
|
||||||
# (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well)
|
|
||||||
# after that unzipping those tools and
|
|
||||||
# then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build
|
|
||||||
- wget --no-verbose --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
|
- wget --no-verbose --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
|
||||||
- unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/cmdline-tools.zip"
|
- unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/cmdline-tools.zip"
|
||||||
- mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
|
- mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
|
||||||
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin
|
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin
|
||||||
|
|
||||||
# Nothing fancy here, just checking sdkManager version
|
|
||||||
- sdkmanager --version
|
- sdkmanager --version
|
||||||
|
|
||||||
# use yes to accept all licenses
|
|
||||||
- yes | sdkmanager --licenses > /dev/null || true
|
- yes | sdkmanager --licenses > /dev/null || true
|
||||||
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
|
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
|
||||||
- sdkmanager "platform-tools"
|
- sdkmanager "platform-tools"
|
||||||
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
|
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
|
||||||
|
|
||||||
# Not necessary, but just for surity
|
|
||||||
- chmod +x ./gradlew
|
- chmod +x ./gradlew
|
||||||
|
|
||||||
# Basic android and gradle stuff
|
|
||||||
# Check linting
|
|
||||||
lintDebug:
|
lintDebug:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
stage: build
|
stage: build
|
||||||
@@ -69,7 +37,6 @@ lintDebug:
|
|||||||
expose_as: "lint-report"
|
expose_as: "lint-report"
|
||||||
when: always
|
when: always
|
||||||
|
|
||||||
# Make Project
|
|
||||||
assembleDebug:
|
assembleDebug:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
stage: build
|
stage: build
|
||||||
@@ -78,8 +45,68 @@ assembleDebug:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- app/build/outputs/
|
- app/build/outputs/
|
||||||
|
|
||||||
|
# Job for building signed release APK for tags containing "release" on any branch
|
||||||
|
assembleRelease:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- |
|
||||||
|
if [[ "$CI_COMMIT_TAG" =~ release ]]; then
|
||||||
|
echo "Decoding keystore file from Base64"
|
||||||
|
|
||||||
|
# Debug: Print the first few characters of BASE64_KEYSTORE
|
||||||
|
echo "First 20 characters of BASE64_KEYSTORE: ${BASE64_KEYSTORE:0:20}..."
|
||||||
|
|
||||||
|
# Check if BASE64_KEYSTORE is a file path
|
||||||
|
if [[ "$BASE64_KEYSTORE" == /* ]] && [[ -f "$BASE64_KEYSTORE" ]]; then
|
||||||
|
echo "BASE64_KEYSTORE appears to be a file path. Reading content..."
|
||||||
|
BASE64_CONTENT=$(cat "$BASE64_KEYSTORE")
|
||||||
|
else
|
||||||
|
echo "BASE64_KEYSTORE is not a file path. Using as-is."
|
||||||
|
BASE64_CONTENT="$BASE64_KEYSTORE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove any potential whitespace or newline characters
|
||||||
|
CLEANED_KEYSTORE=$(echo "$BASE64_CONTENT" | tr -d '[:space:]')
|
||||||
|
|
||||||
|
# Attempt to decode and save to a file
|
||||||
|
if echo "$CLEANED_KEYSTORE" | base64 -d > "$CI_PROJECT_DIR/app/keystore.jks" 2>/tmp/base64_error; then
|
||||||
|
echo "Keystore file decoded successfully"
|
||||||
|
else
|
||||||
|
echo "Error decoding keystore file:"
|
||||||
|
cat /tmp/base64_error
|
||||||
|
echo "First 20 characters of cleaned content: ${CLEANED_KEYSTORE:0:20}..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the keystore file was created and has content
|
||||||
|
if [ -s "$CI_PROJECT_DIR/app/keystore.jks" ]; then
|
||||||
|
echo "Keystore file created successfully"
|
||||||
|
# Print file size for verification
|
||||||
|
ls -l "$CI_PROJECT_DIR/app/keystore.jks"
|
||||||
|
else
|
||||||
|
echo "Error: Keystore file is empty or not created"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building signed release APK"
|
||||||
|
./gradlew assembleRelease \
|
||||||
|
-Pandroid.injected.signing.store.file="$CI_PROJECT_DIR/app/keystore.jks" \
|
||||||
|
-Pandroid.injected.signing.store.password="$KEYSTORE_PASSWORD" \
|
||||||
|
-Pandroid.injected.signing.key.alias="$KEY_ALIAS" \
|
||||||
|
-Pandroid.injected.signing.key.password="$KEY_PASSWORD"
|
||||||
|
else
|
||||||
|
echo "Tag '$CI_COMMIT_TAG' does not contain 'release'. Skipping release build."
|
||||||
|
fi
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- app/build/outputs/
|
||||||
|
expire_in: never
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ /release/
|
||||||
|
when: always
|
||||||
|
- when: never
|
||||||
|
|
||||||
# Run all tests, if any fails, interrupt the pipeline(fail it)
|
|
||||||
debugTests:
|
debugTests:
|
||||||
needs: [lintDebug, assembleDebug]
|
needs: [lintDebug, assembleDebug]
|
||||||
interruptible: true
|
interruptible: true
|
||||||
@@ -98,4 +125,4 @@ publishTestResults:
|
|||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
reports:
|
reports:
|
||||||
junit: app/build/test-results/testDebugUnitTest/*.xml
|
junit: app/build/test-results/testDebugUnitTest/*.xml
|
||||||
15
README.md
15
README.md
@@ -1,4 +1,17 @@
|
|||||||
|
# Latest hpos app version
|
||||||
|
## current version : 2.1.132
|
||||||
|
|
||||||
### Release key
|
### Release key
|
||||||
|
|
||||||
key0: prime24
|
key0: prime24
|
||||||
|
|
||||||
|
### Version 133.3
|
||||||
|
|
||||||
|
Printer not added yet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## added secure server
|
||||||
|
## aded molbio server
|
||||||
|
## advanced with ping network check
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ plugins {
|
|||||||
id 'androidx.navigation.safeargs.kotlin'
|
id 'androidx.navigation.safeargs.kotlin'
|
||||||
id 'kotlin-kapt'
|
id 'kotlin-kapt'
|
||||||
id 'com.google.firebase.crashlytics'
|
id 'com.google.firebase.crashlytics'
|
||||||
|
id 'kotlin-parcelize'
|
||||||
}
|
}
|
||||||
//apply plugin: 'kotlin-android'
|
//apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
@@ -15,14 +16,19 @@ android {
|
|||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
// dev -> development, quality -> qc, uat -> User Acceptance Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production
|
// dev -> development, quality -> qc, uat -> User Acceptance Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production
|
||||||
|
// server -> for server switching for internal test
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting.iocl"
|
applicationId "in.sminnovations.hpostesting.server"
|
||||||
minSdk 21
|
minSdk 30
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 127
|
versionCode 138
|
||||||
versionName "2.1.127"
|
versionName "2.1.132"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
cppFlags ''
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +36,7 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
@@ -53,6 +60,12 @@ android {
|
|||||||
packagingOptions {
|
packagingOptions {
|
||||||
exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
|
exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
|
||||||
}
|
}
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path file('src/main/cpp/CMakeLists.txt')
|
||||||
|
version '3.22.1'
|
||||||
|
}
|
||||||
|
}
|
||||||
// testOptions {
|
// testOptions {
|
||||||
// unitTests {
|
// unitTests {
|
||||||
// includeAndroidResources = true
|
// includeAndroidResources = true
|
||||||
@@ -76,7 +89,6 @@ dependencies {
|
|||||||
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
||||||
implementation("com.google.firebase:firebase-perf-ktx")
|
implementation("com.google.firebase:firebase-perf-ktx")
|
||||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||||
implementation("com.google.firebase:firebase-config-ktx")
|
|
||||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||||
implementation 'com.google.firebase:firebase-firestore-ktx'
|
implementation 'com.google.firebase:firebase-firestore-ktx'
|
||||||
implementation 'com.google.firebase:firebase-auth-ktx'
|
implementation 'com.google.firebase:firebase-auth-ktx'
|
||||||
@@ -124,7 +136,6 @@ dependencies {
|
|||||||
implementation 'com.github.mik3y:usb-serial-for-android:3.8.0'
|
implementation 'com.github.mik3y:usb-serial-for-android:3.8.0'
|
||||||
|
|
||||||
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
|
|
||||||
// CSV read, write
|
// CSV read, write
|
||||||
implementation 'com.opencsv:opencsv:5.9'
|
implementation 'com.opencsv:opencsv:5.9'
|
||||||
|
|
||||||
@@ -172,4 +183,7 @@ dependencies {
|
|||||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
|
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
|
||||||
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
|
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,64 +1,36 @@
|
|||||||
{
|
{
|
||||||
"project_info": {
|
"project_info": {
|
||||||
"project_number": "243503501547",
|
"project_number": "1012719870714",
|
||||||
"project_id": "iocl-iisc-hpos",
|
"project_id": "hpos-prod",
|
||||||
"storage_bucket": "iocl-iisc-hpos.appspot.com"
|
"storage_bucket": "hpos-prod.appspot.com"
|
||||||
},
|
},
|
||||||
"client": [
|
"client": [
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:243503501547:android:f17de652a3524d047feeae",
|
"mobilesdk_app_id": "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "com.iocl_iisc.hposqc"
|
"package_name": "in.sminnovations.hpostesting.server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [],
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyBPxgcDkZfZMr8cFrkMWkVf1a-MstzWC1k"
|
"current_key": "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
"appinvite_service": {
|
"appinvite_service": {
|
||||||
"other_platform_oauth_client": []
|
"other_platform_oauth_client": [
|
||||||
}
|
{
|
||||||
}
|
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
||||||
},
|
"client_type": 3
|
||||||
{
|
}
|
||||||
"client_info": {
|
]
|
||||||
"mobilesdk_app_id": "1:243503501547:android:e1bb0f338c8448dd7feeae",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "in.sminnovations.hposregistration.iocl"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyBPxgcDkZfZMr8cFrkMWkVf1a-MstzWC1k"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:243503501547:android:18b8b33b2dc3776d7feeae",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "in.sminnovations.hpostesting.iocl"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyBPxgcDkZfZMr8cFrkMWkVf1a-MstzWC1k"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 3,
|
|
||||||
"artifactType": {
|
|
||||||
"type": "APK",
|
|
||||||
"kind": "Directory"
|
|
||||||
},
|
|
||||||
"applicationId": "in.sminnovations.hpostesting.iocl",
|
|
||||||
"variantName": "release",
|
|
||||||
"elements": [
|
|
||||||
{
|
|
||||||
"type": "SINGLE",
|
|
||||||
"filters": [],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 128,
|
|
||||||
"versionName": "2.1.128",
|
|
||||||
"outputFile": "app-release.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File",
|
|
||||||
"baselineProfiles": [
|
|
||||||
{
|
|
||||||
"minApi": 28,
|
|
||||||
"maxApi": 30,
|
|
||||||
"baselineProfiles": [
|
|
||||||
"baselineProfiles/1/app-release.dm"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"minApi": 31,
|
|
||||||
"maxApi": 2147483647,
|
|
||||||
"baselineProfiles": [
|
|
||||||
"baselineProfiles/0/app-release.dm"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"minSdkVersionForDexing": 21
|
|
||||||
}
|
|
||||||
@@ -24,6 +24,11 @@
|
|||||||
<uses-feature android:name="android.hardware.usb.host" />
|
<uses-feature android:name="android.hardware.usb.host" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
||||||
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.ACCOUNT_MANAGER"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="com.example.hpostesting.HPOSTestingApplication"
|
android:name="com.example.hpostesting.HPOSTestingApplication"
|
||||||
@@ -38,9 +43,12 @@
|
|||||||
android:theme="@style/Theme.HPOSTesting"
|
android:theme="@style/Theme.HPOSTesting"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.UpdateValuesActivity"
|
android:name="com.example.hpostesting.presentation.reportgen.ReportActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name="com.example.hpostesting.presentation.main_base.UpdateValuesActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="com.example.hpostesting.util.MyAuthenticatorService"
|
android:name="com.example.hpostesting.util.MyAuthenticatorService"
|
||||||
@@ -56,7 +64,7 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.ui.PasswordResetActivity"
|
android:name="com.example.hpostesting.presentation.main_base.ui.PasswordResetActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
@@ -68,19 +76,23 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardActivity"
|
android:name="com.example.hpostesting.presentation.trueheme_test.DigitalCardActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
|
<activity
|
||||||
|
android:name="com.example.hpostesting.presentation.hb_test.HBTestActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.autodac.AutoDacActivity"
|
android:name="com.example.hpostesting.presentation.autodac.AutoDacActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.jig.JigActivity"
|
android:name="com.example.hpostesting.presentation.jig.JigActivity"
|
||||||
android:exported="false"
|
android:exported="true"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity"
|
android:name="com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity"
|
||||||
@@ -96,7 +108,7 @@
|
|||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.HemocubeActivity"
|
android:name="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
||||||
@@ -123,8 +135,8 @@
|
|||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
android:name="com.example.hpostesting.presentation.main_base.DashboardActivity"
|
||||||
android:exported="false"
|
android:exported="true"
|
||||||
android:label="@string/title_activity_dashboard"
|
android:label="@string/title_activity_dashboard"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
@@ -166,7 +178,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.testRight.TestRightActivity"
|
android:name="com.example.hpostesting.presentation.testRight.TestRightActivity"
|
||||||
android:exported="false"
|
android:exported="true"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
|
|||||||
24
app/src/main/cpp/CMakeLists.txt
Normal file
24
app/src/main/cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.18.1)
|
||||||
|
|
||||||
|
project("native-server")
|
||||||
|
|
||||||
|
# Create the shared library from server.cpp
|
||||||
|
add_library(
|
||||||
|
native-server
|
||||||
|
SHARED
|
||||||
|
server.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Find Android logging library
|
||||||
|
find_library(
|
||||||
|
log-lib
|
||||||
|
log
|
||||||
|
)
|
||||||
|
|
||||||
|
# Link logging library to our native lib
|
||||||
|
target_link_libraries(
|
||||||
|
native-server
|
||||||
|
${log-lib}
|
||||||
|
)
|
||||||
|
|
||||||
53
app/src/main/cpp/server.cpp
Normal file
53
app/src/main/cpp/server.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include <jni.h>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
std::vector<std::pair<int, std::pair<std::string, std::unordered_map<std::string, std::string>>>> firebaseDataOrdered = {
|
||||||
|
{0, {"dev", {{"apiKey", "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"}, {"appId", "1:650071678820:android:a53292637abb7c0d6c6471"}, {"projectId", "hpos-af3cc"}, {"storageBucket", "hpos-af3cc.appspot.com"}}}},
|
||||||
|
{1, {"qc-qa", {{"apiKey", "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs"}, {"appId", "1:1004619739289:android:3dbcefb10ea99654e5c808"}, {"projectId", "hpos-qa"}, {"storageBucket", "hpos-qa.appspot.com"}}}},
|
||||||
|
{2, {"prod", {{"apiKey", "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"}, {"appId", "1:1012719870714:android:d8d7c962d96f4097de5f43"}, {"projectId", "hpos-prod"}, {"storageBucket", "hpos-prod.appspot.com"}}}},
|
||||||
|
{3, {"pre prod", {{"apiKey", "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38"}, {"appId", "1:121176529204:android:e6841fdac57bdc95bbed61"}, {"projectId", "hpos-preprod"}, {"storageBucket", "hpos-preprod.appspot.com"}}}},
|
||||||
|
// {4, {"SMI R&D", {{"apiKey", "AIzaSyAVxpilbB804iRCCpMBDjjmdZhQguctGHM"}, {"appId", "1:327771387914:android:a3b4ed2e42ea6e38dc87f3"}, {"projectId", "hposrandd"}, {"storageBucket", "hposrandd.firebasestorage.app"}}}},
|
||||||
|
{5, {"molbio", {{"apiKey", "molbio"}, {"appId", "molbio"}, {"projectId", "molbio"}, {"storageBucket", "molbio"}}}}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_com_example_hpostesting_firebase_FirebaseManager_getFirebaseDataMap(JNIEnv *env,jobject thiz) {
|
||||||
|
jclass mapClass = env->FindClass("java/util/LinkedHashMap");
|
||||||
|
jmethodID init = env->GetMethodID(mapClass, "<init>", "()V");
|
||||||
|
jmethodID put = env->GetMethodID(mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||||
|
jobject outerMap = env->NewObject(mapClass, init);
|
||||||
|
|
||||||
|
for (const auto &entry : firebaseDataOrdered) {
|
||||||
|
int order = entry.first;
|
||||||
|
const std::string &outerKeyStr = entry.second.first;
|
||||||
|
const auto &innerMapData = entry.second.second;
|
||||||
|
|
||||||
|
jobject innerMap = env->NewObject(mapClass, init);
|
||||||
|
// "int" field for order
|
||||||
|
|
||||||
|
jstring intKey = env->NewStringUTF("int");
|
||||||
|
jstring intValue = env->NewStringUTF(std::to_string(order).c_str());
|
||||||
|
env->CallObjectMethod(innerMap, put, intKey, intValue);
|
||||||
|
env->DeleteLocalRef(intKey);
|
||||||
|
env->DeleteLocalRef(intValue);
|
||||||
|
|
||||||
|
// actual firebase config keys
|
||||||
|
for (const auto &innerPair : innerMapData) {
|
||||||
|
jstring key = env->NewStringUTF(innerPair.first.c_str());
|
||||||
|
jstring value = env->NewStringUTF(innerPair.second.c_str());
|
||||||
|
env->CallObjectMethod(innerMap, put, key, value);
|
||||||
|
env->DeleteLocalRef(key);
|
||||||
|
env->DeleteLocalRef(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
jstring outerKey = env->NewStringUTF(outerKeyStr.c_str());
|
||||||
|
env->CallObjectMethod(outerMap, put, outerKey, innerMap);
|
||||||
|
env->DeleteLocalRef(outerKey);
|
||||||
|
env->DeleteLocalRef(innerMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outerMap;
|
||||||
|
}
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
package com.example.hpostesting.FHIRFormater
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class RecommendedFHIRConverter {
|
||||||
|
|
||||||
|
private fun createPatient(data: HemoCubeTestData, useStandardCodes: Boolean): JSONObject {
|
||||||
|
val patient = JSONObject()
|
||||||
|
patient.put("resourceType", "Patient")
|
||||||
|
patient.put("id", "patient-${data.sampleid}")
|
||||||
|
|
||||||
|
// Structured name
|
||||||
|
val nameArray = JSONArray()
|
||||||
|
val nameObj = JSONObject()
|
||||||
|
nameObj.put("use", "official")
|
||||||
|
nameObj.put("text", data.name)
|
||||||
|
nameArray.put(nameObj)
|
||||||
|
patient.put("name", nameArray)
|
||||||
|
|
||||||
|
// Gender (FHIR uses "male", "female", "other", "unknown")
|
||||||
|
patient.put("gender", data.gender.lowercase())
|
||||||
|
|
||||||
|
// Birth date estimation from age (optional: validate or remove if unknown)
|
||||||
|
val birthYear = try {
|
||||||
|
2025 - data.age.toInt()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
if (birthYear != null) patient.put("birthDate", "$birthYear-01-01")
|
||||||
|
|
||||||
|
// ABHA ID as identifier
|
||||||
|
if (data.abhaId.isNotBlank()) {
|
||||||
|
val identifiers = JSONArray()
|
||||||
|
val identifier = JSONObject()
|
||||||
|
identifier.put("system", "https://healthid.ndhm.gov.in")
|
||||||
|
identifier.put("value", data.abhaId)
|
||||||
|
identifiers.put(identifier)
|
||||||
|
patient.put("identifier", identifiers)
|
||||||
|
}
|
||||||
|
|
||||||
|
return patient
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun createDevice(data: HemoCubeTestData): JSONObject {
|
||||||
|
val device = JSONObject()
|
||||||
|
device.put("resourceType", "Device")
|
||||||
|
device.put("id", "device-${data.deviceSerialNumber}")
|
||||||
|
device.put("serialNumber", data.deviceSerialNumber)
|
||||||
|
|
||||||
|
// Device type as codeable concept
|
||||||
|
val type = JSONObject()
|
||||||
|
type.put("text", data.deviceType)
|
||||||
|
device.put("type", type)
|
||||||
|
|
||||||
|
// Device version
|
||||||
|
if (!data.appVersion.isNullOrBlank()) {
|
||||||
|
val versions = JSONArray()
|
||||||
|
val version = JSONObject()
|
||||||
|
version.put("type", JSONObject().put("text", "appVersion"))
|
||||||
|
version.put("value", data.appVersion)
|
||||||
|
versions.put(version)
|
||||||
|
device.put("version", versions)
|
||||||
|
}
|
||||||
|
|
||||||
|
return device
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun createHemoglobinObservation(data: HemoCubeTestData, useStandardCodes: Boolean): JSONObject {
|
||||||
|
val observation = JSONObject()
|
||||||
|
observation.put("resourceType", "Observation")
|
||||||
|
observation.put("id", "hemoglobin-${data.sampleid}")
|
||||||
|
observation.put("status", if (data.testStatus == true) "final" else "preliminary")
|
||||||
|
|
||||||
|
// Standard LOINC code or fallback
|
||||||
|
val code = JSONObject()
|
||||||
|
val codingArray = JSONArray()
|
||||||
|
if (useStandardCodes) {
|
||||||
|
val coding = JSONObject()
|
||||||
|
coding.put("system", "http://loinc.org")
|
||||||
|
coding.put("code", "718-7") // LOINC for Hemoglobin [Mass/volume] in Blood
|
||||||
|
coding.put("display", "Hemoglobin [Mass/volume] in Blood")
|
||||||
|
codingArray.put(coding)
|
||||||
|
}
|
||||||
|
code.put("coding", codingArray)
|
||||||
|
code.put("text", "Hemoglobin Analysis")
|
||||||
|
observation.put("code", code)
|
||||||
|
|
||||||
|
// Subject reference to patient
|
||||||
|
observation.put("subject", JSONObject().put("reference", "Patient/patient-${data.sampleid}"))
|
||||||
|
|
||||||
|
// Device reference
|
||||||
|
observation.put("device", JSONObject().put("reference", "Device/device-${data.deviceSerialNumber}"))
|
||||||
|
|
||||||
|
// Time of observation
|
||||||
|
if (!data.testTime.isNullOrBlank()) {
|
||||||
|
observation.put("effectiveDateTime", data.testTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main result: if hb3 or hb4 exists, use as value
|
||||||
|
val hbValue = data.hb3 ?: data.hb4
|
||||||
|
if (hbValue != null) {
|
||||||
|
val valueQuantity = JSONObject()
|
||||||
|
valueQuantity.put("value", hbValue)
|
||||||
|
valueQuantity.put("unit", "g/dL")
|
||||||
|
valueQuantity.put("system", "http://unitsofmeasure.org")
|
||||||
|
valueQuantity.put("code", "g/dL")
|
||||||
|
observation.put("valueQuantity", valueQuantity)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional extensions
|
||||||
|
val components = JSONArray()
|
||||||
|
|
||||||
|
fun addComponent(codeText: String, value: Double?) {
|
||||||
|
if (value != null) {
|
||||||
|
val comp = JSONObject()
|
||||||
|
comp.put("code", JSONObject().put("text", codeText))
|
||||||
|
comp.put("valueQuantity", JSONObject().put("value", value))
|
||||||
|
components.put(comp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addComponent("HB3", data.hb3)
|
||||||
|
addComponent("HB4", data.hb4)
|
||||||
|
addComponent("Device Ratio", data.deviceRatio)
|
||||||
|
addComponent("Blood Group", null) // can't use non-numeric here unless coded properly
|
||||||
|
|
||||||
|
if (components.length() > 0) {
|
||||||
|
observation.put("component", components)
|
||||||
|
}
|
||||||
|
|
||||||
|
return observation
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createBundleEntry(resource: JSONObject): JSONObject {
|
||||||
|
val entry = JSONObject()
|
||||||
|
entry.put("fullUrl", "urn:uuid:${resource.getString("id")}")
|
||||||
|
entry.put("resource", resource)
|
||||||
|
entry.put("request", JSONObject().apply {
|
||||||
|
put("method", "POST")
|
||||||
|
put("url", resource.getString("resourceType"))
|
||||||
|
})
|
||||||
|
return entry
|
||||||
|
}
|
||||||
|
|
||||||
|
fun convertToFHIR(data: HemoCubeTestData, useStandardCodes: Boolean = false): String {
|
||||||
|
val bundle = JSONObject()
|
||||||
|
bundle.put("resourceType", "Bundle")
|
||||||
|
bundle.put("id", "hemocube-test-${data.sampleid}")
|
||||||
|
bundle.put("type", "collection")
|
||||||
|
|
||||||
|
val entries = JSONArray()
|
||||||
|
|
||||||
|
entries.put(createBundleEntry(createPatient(data, useStandardCodes)))
|
||||||
|
entries.put(createBundleEntry(createDevice(data)))
|
||||||
|
entries.put(createBundleEntry(createHemoglobinObservation(data, useStandardCodes)))
|
||||||
|
|
||||||
|
bundle.put("entry", entries)
|
||||||
|
return bundle.toString(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun sus() {
|
||||||
|
val sampleData = HemoCubeTestData(
|
||||||
|
sampleid = 1234,
|
||||||
|
_id = "local-001",
|
||||||
|
name = "John Doe",
|
||||||
|
incubationTime = "15",
|
||||||
|
bloodGroup = "B+",
|
||||||
|
age = "30",
|
||||||
|
state = "Karnataka",
|
||||||
|
abhaId = "29-1234-4567",
|
||||||
|
userImageURL = "https://example.com/user.jpg",
|
||||||
|
location = UserData.Location(latitude = 12.9716, longitude = 77.5946),
|
||||||
|
reportUploadTime = "2025-07-15T09:30:00+05:30",
|
||||||
|
testType = "HEMOCUBE",
|
||||||
|
testTime = "2025-07-15T09:15:00+05:30",
|
||||||
|
testStatus = true,
|
||||||
|
gender = "male",
|
||||||
|
localFlag = true,
|
||||||
|
deviceId = "device-5678",
|
||||||
|
appVersion = "1.4.2",
|
||||||
|
deviceSerialNumber = "SN-001-XY",
|
||||||
|
deviceType = "HEMOCUBE",
|
||||||
|
kitSerial = "KIT-20250715",
|
||||||
|
resultData = "Raw data goes here",
|
||||||
|
led1Buffer = 0.123,
|
||||||
|
led2Buffer = 0.456,
|
||||||
|
led3Buffer = 0.789,
|
||||||
|
led4Buffer = 0.321,
|
||||||
|
led1Sample = 0.654,
|
||||||
|
led2Sample = 0.987,
|
||||||
|
led3Sample = 0.432,
|
||||||
|
led4Sample = 0.210,
|
||||||
|
led1Average = 0.300,
|
||||||
|
led2Average = 0.500,
|
||||||
|
led3Average = 0.400,
|
||||||
|
led4Average = 0.450,
|
||||||
|
abs1 = 0.12,
|
||||||
|
abs2 = 0.23,
|
||||||
|
abs3 = 0.34,
|
||||||
|
abs4 = 0.45,
|
||||||
|
hb3 = 13.5,
|
||||||
|
hb4 = 13.7,
|
||||||
|
led1Gain1 = 1.1,
|
||||||
|
led2Gain1 = 1.2,
|
||||||
|
led3Gain1 = 1.3,
|
||||||
|
led4Gain1 = 1.4,
|
||||||
|
deviceRatio = 0.87,
|
||||||
|
calculatedRatio = 0.89,
|
||||||
|
predictedDenovixRatio = 0.91,
|
||||||
|
slopeRatio = 0.93,
|
||||||
|
coefficients = "a=1.0,b=2.0,c=3.0",
|
||||||
|
classificationResult = "Normal",
|
||||||
|
prdClassification = "PRD1",
|
||||||
|
deviceRatioClass = "A",
|
||||||
|
slopeRatioClass = "B",
|
||||||
|
borderlineMethod2Class = "C",
|
||||||
|
errorMessages = "",
|
||||||
|
batteryLevel = "85%",
|
||||||
|
batteryCapacity = "2800mAh",
|
||||||
|
batteryMaxCapacity = "3000mAh",
|
||||||
|
batteryTemperature = "35C",
|
||||||
|
batteryVoltage = "3.7V",
|
||||||
|
molbioFlag = false,
|
||||||
|
quickCapture = false,
|
||||||
|
solution = "Blood Sample",
|
||||||
|
concentration = "13.5g/dL",
|
||||||
|
filter = "None",
|
||||||
|
volume = "20uL",
|
||||||
|
isCSVCreated = true,
|
||||||
|
labName = "ABC Labs",
|
||||||
|
cuvetteSize = "Standard",
|
||||||
|
district = "Bangalore Urban",
|
||||||
|
centerName = "Health Center 1",
|
||||||
|
ipAddress = "192.168.1.101",
|
||||||
|
configUpdatedRecent = "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
val converter = RecommendedFHIRConverter()
|
||||||
|
val standardFhir = converter.convertToFHIR(sampleData, useStandardCodes = true)
|
||||||
|
|
||||||
|
println("FHIR Bundle Output:\n$standardFhir")
|
||||||
|
}
|
||||||
@@ -14,25 +14,37 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class HPOSTestingApplication : Application() {
|
class HPOSTestingApplication : Application() {
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
companion object {
|
||||||
|
init {
|
||||||
|
System.loadLibrary("native-server")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var firebaseManager: FirebaseManager
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
|
// You can now use firebaseManager here after Hilt injects it
|
||||||
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
||||||
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val firestore = FirebaseFirestore.getInstance()
|
val firestore = firebaseManager.getCurrentFirestore()
|
||||||
firestore.firestoreSettings = firestoreSettings
|
firestore.firestoreSettings = firestoreSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,6 @@ import retrofit2.http.PUT
|
|||||||
import retrofit2.http.Part
|
import retrofit2.http.Part
|
||||||
|
|
||||||
interface MolbioResultApi {
|
interface MolbioResultApi {
|
||||||
|
|
||||||
@PUT("deviceService/results/HPOS")
|
@PUT("deviceService/results/HPOS")
|
||||||
suspend fun uploadResults(
|
suspend fun uploadResults(
|
||||||
@Body molbioV2ResultRequest: MolbioV2ResultRequest,
|
@Body molbioV2ResultRequest: MolbioV2ResultRequest,
|
||||||
@@ -47,6 +46,7 @@ interface MolbioResultApi {
|
|||||||
// suspend fun deviceUpdate(
|
// suspend fun deviceUpdate(
|
||||||
// @Body deviceUpdateRequest: DeviceUpdateRequest,
|
// @Body deviceUpdateRequest: DeviceUpdateRequest,
|
||||||
// ): ResponseBody
|
// ): ResponseBody
|
||||||
|
|
||||||
@POST("deviceService/device/getUpdate")
|
@POST("deviceService/device/getUpdate")
|
||||||
suspend fun deviceUpdate(
|
suspend fun deviceUpdate(
|
||||||
@Body deviceUpdateRequest: DeviceUpdateRequest,
|
@Body deviceUpdateRequest: DeviceUpdateRequest,
|
||||||
@@ -62,7 +62,6 @@ interface MolbioResultApi {
|
|||||||
@Part logFile: MultipartBody.Part,
|
@Part logFile: MultipartBody.Part,
|
||||||
): UploadLogsResponse
|
): UploadLogsResponse
|
||||||
|
|
||||||
|
|
||||||
@PUT("deviceService/device/uploadDeviceDiagnostics")
|
@PUT("deviceService/device/uploadDeviceDiagnostics")
|
||||||
suspend fun deviceDiagnostics(
|
suspend fun deviceDiagnostics(
|
||||||
@Body deviceDiagnosticsRequest: DeviceDiagnosticsRequest
|
@Body deviceDiagnosticsRequest: DeviceDiagnosticsRequest
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ object Constants {
|
|||||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||||
|
|
||||||
const val MOLBIO_INTEGRATION = true
|
var MOLBIO_INTEGRATION = true
|
||||||
|
var FIREBASE_INTEGRATION = false
|
||||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||||
const val DEVICE_ID_API = "deviceIDAPI"
|
const val DEVICE_ID_API = "deviceIDAPI"
|
||||||
@@ -43,9 +44,9 @@ object Constants {
|
|||||||
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
||||||
|
|
||||||
const val TEST_RIGHT_TOTAL_PIXEL = 3694
|
const val TEST_RIGHT_TOTAL_PIXEL = 3694
|
||||||
|
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE = 34
|
||||||
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE = 35
|
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM = 9
|
||||||
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM = 10
|
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM_RANDD= 129
|
||||||
|
|
||||||
const val RANGE_IN_RESULT_CALCULATIONS = 10
|
const val RANGE_IN_RESULT_CALCULATIONS = 10
|
||||||
|
|
||||||
@@ -107,7 +108,6 @@ object Constants {
|
|||||||
const val DEVICE_ID = "DEVICE_ID"
|
const val DEVICE_ID = "DEVICE_ID"
|
||||||
const val LABNAME = "LAB_NAME"
|
const val LABNAME = "LAB_NAME"
|
||||||
const val CUVETTE_SIZE = "CUVETTE_SIZE"
|
const val CUVETTE_SIZE = "CUVETTE_SIZE"
|
||||||
const val LAST_UPDATED = "LAST_UPDATED"
|
|
||||||
const val IS_TOKEN_AVAILABLE = "IS_TOKEN_AVAILABLE"
|
const val IS_TOKEN_AVAILABLE = "IS_TOKEN_AVAILABLE"
|
||||||
const val BUFFER_LED_LOWER_BOUND = 21000
|
const val BUFFER_LED_LOWER_BOUND = 21000
|
||||||
const val BUFFER_LED_UPPER_BOUND = 23500
|
const val BUFFER_LED_UPPER_BOUND = 23500
|
||||||
@@ -1583,26 +1583,31 @@ object Constants {
|
|||||||
listOf(0.0, 0.0)
|
listOf(0.0, 0.0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//Hemocube for 10mm
|
//Trueheme for 10mm
|
||||||
const val positiveBoderLine10mm1 = 1.3
|
//Before changing below values review before
|
||||||
const val positiveBoderLine10mm2 = 1.66
|
//classification borderline metric
|
||||||
const val negativeBoderLine10mm1 = 2.0
|
const val positiveBoderLineMetricCheck10mmMin = 1.3
|
||||||
const val negativeBoderLine10mm2 = 2.4
|
const val positiveBoderLineMetricCheck10mmMax = 1.66
|
||||||
|
const val negativeBoderLineMetricCheck10mmMin = 2.0
|
||||||
|
const val negativeBoderLineMetricCheck10mmMax = 2.4
|
||||||
|
//classification device ratio
|
||||||
const val normalMin10mm = 0.07
|
const val normalMin10mm = 0.07
|
||||||
const val normalMax10mm = 0.23
|
const val normalMax10mm = 0.23
|
||||||
const val negativeBorderlineMin10mm = 0.23
|
const val negativeBorderlineMin10mm = 0.23
|
||||||
const val negativeBorderlineMax10mm = 0.27
|
const val negativeBorderlineMax10mm = 0.27
|
||||||
const val sickleCellTraitMin10mm = 0.27
|
const val sickleCellTraitMin10mm = 0.27
|
||||||
const val sickleCellTraitMax10mm = 0.31
|
const val sickleCellTraitMax10mm = 0.31
|
||||||
const val positiveForSickleCellMin10mm = 0.31
|
const val positiveBoderlineMin10mm = 0.31
|
||||||
const val positiveForSickleCellMax10mm = 0.39
|
const val positiveBoderlineMax10mm = 0.39
|
||||||
const val sickleCellDiseaseMin10mm = 0.39
|
const val sickleCellDiseaseMin10mm = 0.39
|
||||||
const val sickleCellDiseaseMax10mm = 0.7
|
const val sickleCellDiseaseMax10mm = 0.7
|
||||||
//Hemocube for 2mm
|
//Trueheme for 2mm
|
||||||
const val positiveBoderLine2mm1 = 0.8
|
//classification borderline metric
|
||||||
const val positiveBoderLine2mm2 = 1.1
|
const val positiveBoderLineMetricCheck2mmMin = 0.8
|
||||||
const val negativeBoderLine2mm1 = 1.5
|
const val positiveBoderLineMetricCheck2mmMax = 1.1
|
||||||
const val negativeBoderLine2mm2 = 1.9
|
const val negativeBoderLineMetricCheck2mmMin = 1.5
|
||||||
|
const val negativeBoderLineMetricCheck2mmMax = 1.9
|
||||||
|
//classification device ratio
|
||||||
const val normalMin2mm = 0.1
|
const val normalMin2mm = 0.1
|
||||||
const val normalMax2mm = 0.23
|
const val normalMax2mm = 0.23
|
||||||
const val negativeBorderlineMin2mm = 0.23
|
const val negativeBorderlineMin2mm = 0.23
|
||||||
@@ -1623,6 +1628,7 @@ object Constants {
|
|||||||
const val min10mmLed2 = 0.05
|
const val min10mmLed2 = 0.05
|
||||||
const val max10mmLed2 = 0.41
|
const val max10mmLed2 = 0.41
|
||||||
|
|
||||||
|
//Check used in handling the buffer values on buffer complete
|
||||||
const val bufferMinLed1 = 21000.00
|
const val bufferMinLed1 = 21000.00
|
||||||
const val bufferMaxLed1 = 23000.00
|
const val bufferMaxLed1 = 23000.00
|
||||||
const val bufferMinLed2 = 17000.00
|
const val bufferMinLed2 = 17000.00
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.example.hpostesting.data.model.test.TestType
|
|||||||
|
|
||||||
object DataHolder {
|
object DataHolder {
|
||||||
|
|
||||||
|
var sampleId: String = "sampleId"
|
||||||
var selectedTestType: TestType = TestType.SICKLECERT
|
var selectedTestType: TestType = TestType.SICKLECERT
|
||||||
val usbConnected = MutableLiveData(true)
|
val usbConnected = MutableLiveData(true)
|
||||||
var mobileUniqueId: String? = null
|
var mobileUniqueId: String? = null
|
||||||
@@ -37,6 +38,8 @@ object DataHolder {
|
|||||||
val intensityReferenceArray = ArrayList<Double>()
|
val intensityReferenceArray = ArrayList<Double>()
|
||||||
var selectedTest: UserData? = null
|
var selectedTest: UserData? = null
|
||||||
var hemoCubeTestData: HemoCubeTestData? = null
|
var hemoCubeTestData: HemoCubeTestData? = null
|
||||||
|
var bloodGroup: String = "Unknown"
|
||||||
|
var age = "0"
|
||||||
var kitSerial: String = ""
|
var kitSerial: String = ""
|
||||||
var centerName: String = ""
|
var centerName: String = ""
|
||||||
var district: String = ""
|
var district: String = ""
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ enum class TestStatus(val code: Double) {
|
|||||||
BUFFER_PRINT_STARTED(6.0),
|
BUFFER_PRINT_STARTED(6.0),
|
||||||
BUFFER_PRINT_COMPLETED(7.0),
|
BUFFER_PRINT_COMPLETED(7.0),
|
||||||
SAMPLE_STARTED(8.0),
|
SAMPLE_STARTED(8.0),
|
||||||
|
CUVETTE_ABSENTT(30.2),
|
||||||
|
CUVETTE_PRESENTT(30.1),
|
||||||
SAMPLE_COMPLETED(9.0),
|
SAMPLE_COMPLETED(9.0),
|
||||||
SAMPLE_PRINT_STARTED(10.0),
|
SAMPLE_PRINT_STARTED(10.0),
|
||||||
SAMPLE_PRINT_COMPLETED(11.0),
|
SAMPLE_PRINT_COMPLETED(11.0),
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ interface HemoCubeDao {
|
|||||||
|
|
||||||
@Query("DELETE FROM hemo_cube_test_table WHERE _id = :id")
|
@Query("DELETE FROM hemo_cube_test_table WHERE _id = :id")
|
||||||
suspend fun deleteById(id: String)
|
suspend fun deleteById(id: String)
|
||||||
|
@Query("DELETE FROM hemo_cube_test_table WHERE testStatus = 0")
|
||||||
|
suspend fun deleteByStatus()
|
||||||
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
||||||
suspend fun updateFieldById(id: String, newValue: Boolean)
|
suspend fun updateFieldById(id: String, newValue: Boolean)
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.example.hpostesting.data.model.patient.UserData
|
|||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
||||||
version = 36,
|
version = 38,
|
||||||
exportSchema = false
|
exportSchema = false
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class LocalFileDataSourceImpl @Inject constructor() : LocalFileDataSource {
|
|||||||
"name",
|
"name",
|
||||||
"incubationTime",
|
"incubationTime",
|
||||||
"bloodGroup",
|
"bloodGroup",
|
||||||
"birthYear", // Include other fields from the data class
|
"age", // Include other fields from the data class
|
||||||
"state",
|
"state",
|
||||||
"abhaId",
|
"abhaId",
|
||||||
"userImageURL",
|
"userImageURL",
|
||||||
@@ -110,7 +110,7 @@ class LocalFileDataSourceImpl @Inject constructor() : LocalFileDataSource {
|
|||||||
data.name,
|
data.name,
|
||||||
data.incubationTime,
|
data.incubationTime,
|
||||||
data.bloodGroup,
|
data.bloodGroup,
|
||||||
data.birthYear, // Include other fields similarly
|
data.age, // Include other fields similarly
|
||||||
data.state,
|
data.state,
|
||||||
data.abhaId,
|
data.abhaId,
|
||||||
data.userImageURL,
|
data.userImageURL,
|
||||||
@@ -177,7 +177,7 @@ class LocalFileDataSourceImpl @Inject constructor() : LocalFileDataSource {
|
|||||||
"name",
|
"name",
|
||||||
"incubationTime",
|
"incubationTime",
|
||||||
"bloodGroup",
|
"bloodGroup",
|
||||||
"birthYear", // Include other fields from the data class
|
"age", // Include other fields from the data class
|
||||||
"state",
|
"state",
|
||||||
"abhaId",
|
"abhaId",
|
||||||
"userImageURL",
|
"userImageURL",
|
||||||
@@ -233,7 +233,7 @@ class LocalFileDataSourceImpl @Inject constructor() : LocalFileDataSource {
|
|||||||
data.name,
|
data.name,
|
||||||
data.incubationTime,
|
data.incubationTime,
|
||||||
data.bloodGroup,
|
data.bloodGroup,
|
||||||
data.birthYear, // Include other fields similarly
|
data.age, // Include other fields similarly
|
||||||
data.state,
|
data.state,
|
||||||
data.abhaId,
|
data.abhaId,
|
||||||
data.userImageURL,
|
data.userImageURL,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ data class HemoCubeTestData(
|
|||||||
var name: String = "",
|
var name: String = "",
|
||||||
var incubationTime: String = "",
|
var incubationTime: String = "",
|
||||||
var bloodGroup: String = "",
|
var bloodGroup: String = "",
|
||||||
var birthYear: String = "",
|
var age: String = "",
|
||||||
var state: String = "",
|
var state: String = "",
|
||||||
var abhaId: String = "",
|
var abhaId: String = "",
|
||||||
var userImageURL: String = "",
|
var userImageURL: String = "",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ data class UserData(
|
|||||||
var name: String = "",
|
var name: String = "",
|
||||||
var incubationTime: String = "",
|
var incubationTime: String = "",
|
||||||
var gender: String = "",
|
var gender: String = "",
|
||||||
var birthYear: String = "",
|
var age: String = "",
|
||||||
var abhaId: String = "",
|
var abhaId: String = "",
|
||||||
var bloodGroup: String = "",
|
var bloodGroup: String = "",
|
||||||
var userImageURL: String = "",
|
var userImageURL: String = "",
|
||||||
@@ -63,7 +63,7 @@ fun UserData.toHemoCubeTestData() = HemoCubeTestData(
|
|||||||
sampleid = sampleid,
|
sampleid = sampleid,
|
||||||
bloodGroup = bloodGroup,
|
bloodGroup = bloodGroup,
|
||||||
incubationTime = incubationTime,
|
incubationTime = incubationTime,
|
||||||
birthYear = birthYear,
|
age = age,
|
||||||
gender = gender,
|
gender = gender,
|
||||||
state = state,
|
state = state,
|
||||||
abhaId = abhaId,
|
abhaId = abhaId,
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ package com.example.hpostesting.data.model.test
|
|||||||
|
|
||||||
enum class TestType {
|
enum class TestType {
|
||||||
SICKLECERT,
|
SICKLECERT,
|
||||||
SICKLEFIND
|
SICKLEFIND,
|
||||||
|
HB_EST
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
@@ -37,17 +40,18 @@ import com.example.hpostesting.data.model.patient.UserData
|
|||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import com.google.firebase.storage.ktx.storage
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.ConnectException
|
import java.net.ConnectException
|
||||||
import java.net.SocketTimeoutException
|
import java.net.SocketTimeoutException
|
||||||
|
import java.time.LocalTime
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Named
|
import javax.inject.Named
|
||||||
|
|
||||||
@@ -55,11 +59,30 @@ class NetworkException(message: String, cause: Throwable) : Exception(message, c
|
|||||||
class DatabaseRepository @Inject constructor(
|
class DatabaseRepository @Inject constructor(
|
||||||
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
||||||
private val molbioResultApi: MolbioResultApi,
|
private val molbioResultApi: MolbioResultApi,
|
||||||
|
private val firebaseManager: FirebaseManager,
|
||||||
) : Repository {
|
) : Repository {
|
||||||
|
|
||||||
private val db: FirebaseFirestore = Firebase.firestore
|
private val localdb: FirebaseFirestore
|
||||||
private val storage = Firebase.storage
|
get() = firebaseManager.getCurrentFirestore()
|
||||||
|
|
||||||
|
private val localStg: FirebaseStorage
|
||||||
|
get() = firebaseManager.getCurrentStorage()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // Example function to add data to Firestore , like the basic data as test data
|
||||||
|
// @RequiresApi(Build.VERSION_CODES.O)
|
||||||
|
// fun addtodb(data: String) {
|
||||||
|
// val date = LocalTime.now()
|
||||||
|
// localdb.collection("BasicData")
|
||||||
|
// .add(mapOf("data $date" to data))
|
||||||
|
// .addOnSuccessListener {
|
||||||
|
// Log.d("UPLOAD", "Data uploaded successfully ${localdb.app.name}")
|
||||||
|
// }
|
||||||
|
// .addOnFailureListener { exception ->
|
||||||
|
// Log.d("UPLOAD", "Failed to upload data: ${exception.message} ${localdb.app.name}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
||||||
return try {
|
return try {
|
||||||
val response = apiCall.invoke()
|
val response = apiCall.invoke()
|
||||||
@@ -108,13 +131,13 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
val userdata =
|
||||||
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
localdb.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
localdb.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.collection("testData").add(data).await()
|
localdb.collection("testData").add(data).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
@@ -122,15 +145,10 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
override suspend fun addQcTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addQcTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
|
||||||
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
localdb.collection("qcData").add(data!!).await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
|
||||||
userdata.documents.forEach {
|
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
db.collection("qcData").add(data).await()
|
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
}
|
}
|
||||||
@@ -142,7 +160,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("buffers").add(data!!).await()
|
localdb.collection("buffers").add(data!!).await()
|
||||||
Response.Success(data.kitno)
|
Response.Success(data.kitno)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -152,7 +170,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("diagnostics").add(data!!).await()
|
localdb.collection("diagnostics").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -163,7 +181,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("jigs").add(data!!).await()
|
localdb.collection("jigs").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -177,7 +195,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
val file = Uri.fromFile(File(filePath))
|
val file = Uri.fromFile(File(filePath))
|
||||||
val riversRef = storage.reference.child("$patientID/${file.lastPathSegment}")
|
val riversRef = localStg.reference.child("$patientID/${file.lastPathSegment}")
|
||||||
riversRef.putFile(file).await()
|
riversRef.putFile(file).await()
|
||||||
return Response.Success(true)
|
return Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -188,7 +206,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun addToPendingQueue(pendingUploads: PendingUploads): Response<Boolean> {
|
suspend fun addToPendingQueue(pendingUploads: PendingUploads): Response<Boolean> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("pendingUploads").document(pendingUploads.pendingId).set(pendingUploads)
|
localdb.collection("pendingUploads").document(pendingUploads.pendingId).set(pendingUploads)
|
||||||
.await()
|
.await()
|
||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
@@ -201,7 +219,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
suspend fun getAllFromPendingQueue(): List<PendingUploads> {
|
suspend fun getAllFromPendingQueue(): List<PendingUploads> {
|
||||||
val pendingList = mutableListOf<PendingUploads>()
|
val pendingList = mutableListOf<PendingUploads>()
|
||||||
return try {
|
return try {
|
||||||
val querySnapshot = db.collection("pendingUploads").orderBy("timeAdded").get().await()
|
val querySnapshot = localdb.collection("pendingUploads").orderBy("timeAdded").get().await()
|
||||||
|
|
||||||
for (doc in querySnapshot.documents) {
|
for (doc in querySnapshot.documents) {
|
||||||
val pendingFile = doc.toObject(PendingUploads::class.java)
|
val pendingFile = doc.toObject(PendingUploads::class.java)
|
||||||
@@ -219,7 +237,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun removeFromPendingQueue(fileName: String): Response<Boolean> {
|
suspend fun removeFromPendingQueue(fileName: String): Response<Boolean> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("pendingUploads").document(fileName).delete().await()
|
localdb.collection("pendingUploads").document(fileName).delete().await()
|
||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -229,11 +247,11 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getDeviceData(): List<DeviceData> {
|
suspend fun getDeviceData(): List<DeviceData> {
|
||||||
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
return localdb.collection("devices").get().await().toObjects(DeviceData::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
||||||
val querySnapshot = db.collection("devices").get().await()
|
val querySnapshot = localdb.collection("devices").get().await()
|
||||||
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
||||||
|
|
||||||
// Find the DeviceData object with the specified deviceId
|
// Find the DeviceData object with the specified deviceId
|
||||||
@@ -242,7 +260,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("devices").add(data!!).await()
|
localdb.collection("devices").add(data!!).await()
|
||||||
Response.Success(data.deviceProvisionResponse)
|
Response.Success(data.deviceProvisionResponse)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -252,7 +270,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
||||||
return try {
|
return try {
|
||||||
db.collection("devices").add(data!!).await()
|
localdb.collection("devices").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -267,13 +285,13 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
val userdata =
|
||||||
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
localdb.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
localdb.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.collection("testData").add(data).await()
|
localdb.collection("testData").add(data).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import androidx.room.Room
|
|||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.util.PropertyProvider
|
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
@@ -36,9 +35,14 @@ import com.example.hpostesting.domain.LogFileManager
|
|||||||
import com.example.hpostesting.domain.LogFileManagerImpl
|
import com.example.hpostesting.domain.LogFileManagerImpl
|
||||||
import com.example.hpostesting.domain.SaveRawData
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
||||||
|
import com.example.hpostesting.util.NetworkMonitor
|
||||||
|
import com.example.hpostesting.util.PropertyProvider
|
||||||
import com.example.hpostesting.util.PropertyProviderImpl
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
@@ -107,22 +111,52 @@ object AppModule {
|
|||||||
return SaveRawDataTest(repository)
|
return SaveRawDataTest(repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideFirebaseFirestore(): FirebaseFirestore {
|
||||||
|
return FirebaseFirestore.getInstance()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideFirebaseStorage(): FirebaseStorage {
|
||||||
|
return FirebaseStorage.getInstance()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideFirebaseManager(
|
||||||
|
@ApplicationContext context: Context,
|
||||||
|
): FirebaseManager {
|
||||||
|
return FirebaseManager(context)
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideDatabaseRepository(
|
fun provideDatabaseRepository(
|
||||||
|
firebaseManager: FirebaseManager,
|
||||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
molbioResultApi: MolbioResultApi
|
molbioResultApi: MolbioResultApi
|
||||||
): DatabaseRepository {
|
): DatabaseRepository {
|
||||||
return DatabaseRepository(molbioAuthApi = molbioAuthApi, molbioResultApi = molbioResultApi)
|
return DatabaseRepository(
|
||||||
|
firebaseManager = firebaseManager,
|
||||||
|
molbioAuthApi = molbioAuthApi,
|
||||||
|
molbioResultApi = molbioResultApi
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideRepository(
|
fun provideRepository(
|
||||||
|
firebaseManager: FirebaseManager,
|
||||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
molbioResultApi: MolbioResultApi
|
molbioResultApi: MolbioResultApi
|
||||||
): Repository {
|
): Repository {
|
||||||
return DatabaseRepository(molbioAuthApi, molbioResultApi)
|
return DatabaseRepository(
|
||||||
|
firebaseManager = firebaseManager,
|
||||||
|
molbioAuthApi = molbioAuthApi,
|
||||||
|
molbioResultApi = molbioResultApi
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -206,4 +240,13 @@ object AppModule {
|
|||||||
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
||||||
return UsbServiceListenerImpl(context)
|
return UsbServiceListenerImpl(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideNetworkMonitor(
|
||||||
|
@ApplicationContext context: Context
|
||||||
|
): NetworkMonitor {
|
||||||
|
return NetworkMonitor(context).apply { startMonitoring() }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
package com.example.hpostesting.firebase
|
||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Process
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.google.firebase.FirebaseApp
|
||||||
|
import com.google.firebase.FirebaseOptions
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class FirebaseManager @Inject constructor(private val context: Context) {
|
||||||
|
private var defaultServers = mutableListOf<FirebaseConfig>()
|
||||||
|
external fun getFirebaseDataMap(): Map<String, Map<String, String>>
|
||||||
|
private val map: Map<String, Map<String, String>> = getFirebaseDataMap()
|
||||||
|
companion object {
|
||||||
|
init {
|
||||||
|
System.loadLibrary("native-server") //use NDK ro secure somethings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val sharedPreferencesServerConfig = context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
||||||
|
private val sharedPreferencesDev = context.getSharedPreferences("DevMode",Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
private var currentFirestore: FirebaseFirestore = FirebaseFirestore.getInstance()
|
||||||
|
private var currentStorage: FirebaseStorage = FirebaseStorage.getInstance()
|
||||||
|
private var updateStatus = false
|
||||||
|
|
||||||
|
|
||||||
|
private fun Map<String, String>.toFirebaseConfig(server: String): FirebaseConfig? {
|
||||||
|
val apiKey = this["apiKey"] ?: return null
|
||||||
|
val appId = this["appId"] ?: return null
|
||||||
|
val projectId = this["projectId"] ?: return null
|
||||||
|
val storageBucket = this["storageBucket"] ?: return null
|
||||||
|
return FirebaseConfig(
|
||||||
|
serverName = server,
|
||||||
|
projectId = projectId,
|
||||||
|
appId = appId,
|
||||||
|
apiKey = apiKey,
|
||||||
|
storageBucket = storageBucket
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun populate() {
|
||||||
|
defaultServers.clear()
|
||||||
|
map.forEach { (server, config) ->
|
||||||
|
config.toFirebaseConfig(server)?.let {
|
||||||
|
defaultServers.add(it)
|
||||||
|
} ?: Log.w("Firebase", "Skipping $server due to missing keys")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
populate()
|
||||||
|
val lastSelectedServer = getLastSelectedServer()
|
||||||
|
switchServer(lastSelectedServer)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setDevModeOn(state : Boolean){
|
||||||
|
sharedPreferencesDev.edit {
|
||||||
|
putBoolean( "isDevModeOn",state )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDevMode(): Boolean {
|
||||||
|
return sharedPreferencesDev.getBoolean("isDevModeOn",false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getCurrentFirestore(): FirebaseFirestore = currentFirestore
|
||||||
|
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
||||||
|
|
||||||
|
fun switchServer(firebaseConfig: FirebaseConfig) {
|
||||||
|
if (firebaseConfig.serverName =="molbio" ||firebaseConfig.apiKey == "molbio"){
|
||||||
|
saveSelectedServer(firebaseConfig)
|
||||||
|
makeMolbioAsBackEnd()
|
||||||
|
}else {
|
||||||
|
makeSMIBackEnd()
|
||||||
|
saveSelectedServer(firebaseConfig)
|
||||||
|
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
||||||
|
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
||||||
|
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
||||||
|
updateStatus = true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getOrInitializeFirebaseApp(firebaseConfig: FirebaseConfig): FirebaseApp {
|
||||||
|
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
||||||
|
|
||||||
|
return if (existingApp != null) {
|
||||||
|
existingApp
|
||||||
|
} else {
|
||||||
|
|
||||||
|
val options = FirebaseOptions.Builder().setProjectId(firebaseConfig.projectId)
|
||||||
|
.setApplicationId(firebaseConfig.appId).setApiKey(firebaseConfig.apiKey)
|
||||||
|
.setStorageBucket(firebaseConfig.storageBucket).build()
|
||||||
|
|
||||||
|
FirebaseApp.initializeApp(context, options, firebaseConfig.serverName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saveSelectedServer(firebaseConfig: FirebaseConfig) {
|
||||||
|
with(sharedPreferencesServerConfig.edit()) {
|
||||||
|
putString("selectedServerName", firebaseConfig.serverName)
|
||||||
|
putString("projectId", firebaseConfig.projectId)
|
||||||
|
putString("appId", firebaseConfig.appId)
|
||||||
|
putString("apiKey", firebaseConfig.apiKey)
|
||||||
|
putString("storageBucket", firebaseConfig.storageBucket)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun restartApp() {
|
||||||
|
if (updateStatus) {
|
||||||
|
updateStatus = false
|
||||||
|
delayedRestart(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLastSelectedServer(): FirebaseConfig {
|
||||||
|
val selectedServerName =
|
||||||
|
sharedPreferencesServerConfig.getString("selectedServerName", defaultServers.first().serverName)
|
||||||
|
val projectId = sharedPreferencesServerConfig.getString("projectId", defaultServers.first().projectId)
|
||||||
|
val appId = sharedPreferencesServerConfig.getString("appId", defaultServers.first().appId)
|
||||||
|
val apiKey = sharedPreferencesServerConfig.getString("apiKey", defaultServers.first().apiKey)
|
||||||
|
val storageBucket =
|
||||||
|
sharedPreferencesServerConfig.getString("storageBucket", defaultServers.first().storageBucket)
|
||||||
|
|
||||||
|
return FirebaseConfig(
|
||||||
|
serverName = selectedServerName ?: defaultServers.first().serverName,
|
||||||
|
projectId = projectId ?: defaultServers.first().projectId,
|
||||||
|
appId = appId ?: defaultServers.first().appId,
|
||||||
|
apiKey = apiKey ?: defaultServers.first().apiKey,
|
||||||
|
storageBucket = storageBucket ?: defaultServers.first().storageBucket
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAvailableServers(): List<FirebaseConfig> {
|
||||||
|
return defaultServers
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun makeMolbioAsBackEnd(){
|
||||||
|
Constants.FIREBASE_INTEGRATION = false
|
||||||
|
Constants.MOLBIO_INTEGRATION = true
|
||||||
|
restartApp()
|
||||||
|
}
|
||||||
|
private fun makeSMIBackEnd(){
|
||||||
|
Constants.FIREBASE_INTEGRATION = true
|
||||||
|
Constants.MOLBIO_INTEGRATION = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun restartApp(context: Context) {
|
||||||
|
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
||||||
|
intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
context.startActivity(intent)
|
||||||
|
Process.killProcess(Process.myPid())
|
||||||
|
}
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
|
fun delayedRestart(context: Context) {
|
||||||
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
delay(5000L)
|
||||||
|
restartApp(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//private val firebaseConfigDev = FirebaseConfig(
|
||||||
|
// serverName = "dev",
|
||||||
|
// apiKey = "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I",
|
||||||
|
// appId = "1:650071678820:android:a53292637abb7c0d6c6471",
|
||||||
|
// projectId = "hpos-af3cc",
|
||||||
|
// storageBucket = "hpos-af3cc.appspot.com"
|
||||||
|
//)
|
||||||
|
//private val firebaseConfigQaQc = FirebaseConfig(
|
||||||
|
// serverName = "qc-qa",
|
||||||
|
// apiKey = "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs",
|
||||||
|
// appId = "1:1004619739289:android:3dbcefb10ea99654e5c808",
|
||||||
|
// projectId = "hpos-qa",
|
||||||
|
// storageBucket = "hpos-qa.appspot.com"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//private val firebaseConfigProd = FirebaseConfig(
|
||||||
|
// serverName = "prod",
|
||||||
|
// apiKey = "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs",
|
||||||
|
// appId = "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
||||||
|
// projectId = "hpos-prod",
|
||||||
|
// storageBucket = "hpos-prod.appspot.com"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//private val firebaseConfigPreProd = FirebaseConfig(
|
||||||
|
// serverName = "pre prod",
|
||||||
|
// apiKey = "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38",
|
||||||
|
// appId = "1:121176529204:android:e6841fdac57bdc95bbed61",
|
||||||
|
// projectId = "hpos-preprod",
|
||||||
|
// storageBucket = "hpos-preprod.appspot.com"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//private val firebaseConfigSmiRandD= FirebaseConfig(
|
||||||
|
// serverName = "SMI R&D",
|
||||||
|
// apiKey = "AIzaSyAVxpilbB804iRCCpMBDjjmdZhQguctGHM",
|
||||||
|
// appId = "1:327771387914:android:a3b4ed2e42ea6e38dc87f3",
|
||||||
|
// projectId = "hposrandd",
|
||||||
|
// storageBucket = "hposrandd.firebasestorage.app"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//private val configMolbio = FirebaseConfig(
|
||||||
|
// serverName = "molbio",
|
||||||
|
// apiKey = "molbio",
|
||||||
|
// appId = "molbio",
|
||||||
|
// projectId = "molbio",
|
||||||
|
// storageBucket = "molbio"
|
||||||
|
//)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
package com.example.hpostesting.firebase
|
||||||
/*
|
/*
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
* // Notice: All information contained herein is, and remains
|
* // Notice: All information contained herein is, and remains
|
||||||
@@ -10,9 +11,11 @@
|
|||||||
* // is strictly forbidden unless prior written permission is obtained
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
data class FirebaseConfig(
|
||||||
|
val serverName: String,
|
||||||
|
val apiKey: String,
|
||||||
|
val appId: String,
|
||||||
|
val projectId: String,
|
||||||
|
val storageBucket: String
|
||||||
|
)
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
|
||||||
|
|
||||||
interface ItemClickListener {
|
|
||||||
fun onClick(pos: Int)
|
|
||||||
}
|
|
||||||
@@ -19,18 +19,19 @@ import android.content.SharedPreferences
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContentProviderCompat.requireContext
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
|
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
||||||
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||||
import com.google.android.material.snackbar.Snackbar
|
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.journeyapps.barcodescanner.ScanIntentResult
|
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||||
import com.journeyapps.barcodescanner.ScanOptions
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
@@ -48,13 +49,12 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||||
private var fromWhere = "Home"
|
private var fromWhere = "Home"
|
||||||
private val TAG = "KitScanActivity"
|
private val TAG = "KitScanActivity"
|
||||||
private lateinit var binding: ActivityKitScanBinding
|
private lateinit var binding: ActivityKitScanBinding
|
||||||
|
private lateinit var firebaseManager: FirebaseManager
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
var sdkHandler: SDKHandler? = null
|
var sdkHandler: SDKHandler? = null
|
||||||
@@ -73,21 +73,21 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun processScannedData(contents: String) {//edited auto selection of cuvette size
|
private fun processScannedData(contents: String) {//edited auto selection of cuvette size
|
||||||
if(contents.contains("SMI/SC/")){
|
if (contents.contains("SMI/SC/")) {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "2mm")
|
putString(Constants.CUVETTE_SIZE, "2mm")
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
||||||
binding.nameEditText.setText(contents)
|
binding.nameEditText.setText(contents)
|
||||||
}else if(contents.contains("SMI/SC-2-D10/")){
|
} else if (contents.contains("SMI/SC-2-D10/")) {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "10mm")
|
putString(Constants.CUVETTE_SIZE, "10mm")
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Toast.makeText(this, "Selected cuvette size: 10mm", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Selected cuvette size: 10mm", Toast.LENGTH_SHORT).show()
|
||||||
binding.nameEditText.setText(contents)
|
binding.nameEditText.setText(contents)
|
||||||
}else{
|
} else {
|
||||||
Toast.makeText(this, R.string.invalid_kit, Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.invalid_kit, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,33 +129,51 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
firebaseManager = FirebaseManager(this)
|
||||||
|
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||||
binding = ActivityKitScanBinding.inflate(layoutInflater)
|
binding = ActivityKitScanBinding.inflate(layoutInflater)
|
||||||
sharedPreference = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreference = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
binding.toolbar.title = "Kit Serial Number"
|
binding.toolbar.title = "Kit Serial Number"
|
||||||
fromWhere = intent.getStringExtra("fromWhere").toString()
|
fromWhere = intent.getStringExtra("fromWhere").toString()
|
||||||
val maxTest = if(sharedPreference.getString(Constants.CUVETTE_SIZE, "10mm").toString() == "2mm"){
|
|
||||||
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE
|
val maxTest = if (currentServer == "SMI R&D"){
|
||||||
}else{
|
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM_RANDD
|
||||||
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM
|
|
||||||
|
Log.d(TAG, "onCreate RandD mode")
|
||||||
|
}else {
|
||||||
|
if (sharedPreference.getString(Constants.CUVETTE_SIZE, "10mm").toString() == "2mm") {
|
||||||
|
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE
|
||||||
|
} else {
|
||||||
|
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
||||||
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
||||||
|
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
// moveToNext()
|
||||||
|
// }else{
|
||||||
|
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
moveToNext()
|
moveToNext()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this@KitScanActivity, "Limit Reached, Use New KIT for testing", Toast.LENGTH_SHORT).show()
|
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
||||||
DataHolder.sampleReadCounter = 0
|
moveToNext()
|
||||||
DataHolder.kitSerial = ""
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
this@KitScanActivity,
|
||||||
|
"Limit Reached, Use New KIT for testing",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
DataHolder.sampleReadCounter = 0
|
||||||
|
DataHolder.kitSerial = ""
|
||||||
|
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.KIT_NUMBER, "")
|
putString(Constants.KIT_NUMBER, "")
|
||||||
putString(Constants.BUFFER_VALUE_1, "")
|
putString(Constants.BUFFER_VALUE_1, "")
|
||||||
putString(Constants.BUFFER_VALUE_2, "")
|
putString(Constants.BUFFER_VALUE_2, "")
|
||||||
apply()
|
apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,13 +226,13 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
binding.btnGo.setOnClickListener {
|
binding.btnGo.setOnClickListener {
|
||||||
val serialNumber = binding.nameEditText.text.toString().trim()
|
val serialNumber = binding.nameEditText.text.toString().trim()
|
||||||
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
||||||
if(serialNumber.contains("SMI/SC/")){
|
if (serialNumber.contains("SMI/SC/")) {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "2mm")
|
putString(Constants.CUVETTE_SIZE, "2mm")
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
||||||
}else if(serialNumber.contains("SMI/SC-2-D10/")){
|
} else if (serialNumber.contains("SMI/SC-2-D10/")) {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "10mm")
|
putString(Constants.CUVETTE_SIZE, "10mm")
|
||||||
apply()
|
apply()
|
||||||
@@ -297,7 +315,8 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
if (mScannerInfoList.isNotEmpty()) {
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this,"Scanner Is not available In this device", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, "Scanner Is not available In this device", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +354,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val editableResult: Editable = Editable.Factory.getInstance().newEditable(result)
|
val editableResult: Editable = Editable.Factory.getInstance().newEditable(result)
|
||||||
processScannedData(result)
|
processScannedData(result)
|
||||||
// binding.nameEditText.text = editableResult
|
// binding.nameEditText.text = editableResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,38 +367,45 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
|
|
||||||
private fun isSerialValid(s: String): Boolean {
|
private fun isSerialValid(s: String): Boolean {
|
||||||
if (s.contains("SMI/SC/")) {
|
if (s.contains("SMI/SC/")) {
|
||||||
if(s.length != 17){
|
if (s.length != 17) {
|
||||||
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC/000/00/000"
|
binding.nameEditText.error =
|
||||||
|
"Invalid Kit Serial Number, correct example SMI/SC/000/00/000"
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}else if(s.contains("SMI/SC-2-D10/")){
|
} else if (s.contains("SMI/SC-2-D10/")) {
|
||||||
if(s.length != 27){
|
if (s.length != 27) {
|
||||||
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC-2-D10/000000/000/000"
|
binding.nameEditText.error =
|
||||||
|
"Invalid Kit Serial Number, correct example SMI/SC-2-D10/000000/000/000"
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if(fromWhere == "Main"){
|
if (fromWhere == "Main") {
|
||||||
DataHolder.deviceType.observe(this) { deviceType ->
|
if (DataHolder.selectedTestType == TestType.HB_EST) {
|
||||||
when (deviceType) {
|
val i = Intent(applicationContext, HBTestActivity::class.java)
|
||||||
Constants.DEVICE_TYPE_HEMOCUBE -> {
|
startActivity(i)
|
||||||
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
} else {
|
||||||
startActivity(i)
|
DataHolder.deviceType.observe(this) { deviceType ->
|
||||||
}
|
when (deviceType) {
|
||||||
|
Constants.DEVICE_TYPE_HEMOCUBE -> {
|
||||||
|
val i = Intent(applicationContext, TrueHemeTestActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
|
||||||
Constants.DEVICE_TYPE_TEST_RIGHT -> {
|
Constants.DEVICE_TYPE_TEST_RIGHT -> {
|
||||||
val i = Intent(applicationContext, TestRightActivity::class.java)
|
val i = Intent(applicationContext, TestRightActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
Constants.DEVICE_TYPE_TRUEHEME -> {
|
Constants.DEVICE_TYPE_TRUEHEME -> {
|
||||||
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
val i = Intent(applicationContext, TrueHemeTestActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -416,6 +442,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun timeDifference(createdAt: String): Long {
|
private fun timeDifference(createdAt: String): Long {
|
||||||
val currentTime = Calendar.getInstance().time
|
val currentTime = Calendar.getInstance().time
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
import android.location.Location
|
import android.location.Location
|
||||||
@@ -30,12 +31,11 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient
|
import com.google.android.gms.location.FusedLocationProviderClient
|
||||||
import com.google.android.gms.location.LocationCallback
|
import com.google.android.gms.location.LocationCallback
|
||||||
import com.google.android.gms.location.LocationRequest
|
import com.google.android.gms.location.LocationRequest
|
||||||
@@ -48,12 +48,12 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
private val TAG = "MainActivity"
|
private val TAG = "MainActivity"
|
||||||
private lateinit var fusedLocationClient: FusedLocationProviderClient
|
private lateinit var fusedLocationClient: FusedLocationProviderClient
|
||||||
private lateinit var locationCallback: LocationCallback
|
private lateinit var locationCallback: LocationCallback
|
||||||
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
private val usbReceiver = object : BroadcastReceiver() {
|
private val usbReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent) {
|
override fun onReceive(context: Context?, intent: Intent) {
|
||||||
@@ -73,14 +73,21 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
sharedPreference = getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
binding.myToolbar.title = "Test Type"
|
binding.myToolbar.title = "Test Type"
|
||||||
setSupportActionBar(binding.myToolbar)
|
setSupportActionBar(binding.myToolbar)
|
||||||
|
if ((sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN")) {
|
||||||
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
|
}else{
|
||||||
|
binding.cvItem3.visibility = View.GONE
|
||||||
|
}
|
||||||
setupListeners()
|
setupListeners()
|
||||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
||||||
getLocation()
|
getLocation()
|
||||||
|
|
||||||
locationCallback = object : LocationCallback() {
|
locationCallback = object : LocationCallback() {
|
||||||
override fun onLocationResult(locationResult: LocationResult) {
|
override fun onLocationResult(locationResult: LocationResult) {
|
||||||
locationResult.lastLocation?.let { location ->
|
locationResult.lastLocation?.let { location ->
|
||||||
@@ -92,7 +99,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val usbFilter = IntentFilter().apply {
|
val usbFilter = IntentFilter().apply {
|
||||||
addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
||||||
addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
||||||
@@ -103,7 +109,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
with(binding) {
|
with(binding) {
|
||||||
if (deviceType == Constants.DEVICE_TYPE_HEMOCUBE) {
|
if (deviceType == Constants.DEVICE_TYPE_HEMOCUBE) {
|
||||||
cvItem1.visibility = View.VISIBLE
|
cvItem1.visibility = View.VISIBLE
|
||||||
cvItem3.visibility = View.GONE
|
cvItem3.visibility = View.VISIBLE
|
||||||
cvItem2.visibility = View.GONE
|
cvItem2.visibility = View.GONE
|
||||||
cvItem4.visibility = View.GONE
|
cvItem4.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@@ -111,12 +117,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataHolder.selectedTest == null) {
|
// if (DataHolder.selectedTest == null) {
|
||||||
startActivity(Intent(this, DashboardActivity::class.java))
|
// startActivity(Intent(this, DashboardActivity::class.java))
|
||||||
finish()
|
// finish()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun checkAndUpdateUsbConnection() {
|
private fun checkAndUpdateUsbConnection() {
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber()
|
val availableDrivers = UsbSerialProber.getDefaultProber()
|
||||||
.findAllDrivers(getSystemService(Context.USB_SERVICE) as UsbManager)
|
.findAllDrivers(getSystemService(Context.USB_SERVICE) as UsbManager)
|
||||||
@@ -132,7 +139,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
when {
|
when {
|
||||||
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
binding.cvItem3.visibility = View.GONE
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
binding.cvItem2.visibility = View.GONE
|
binding.cvItem2.visibility = View.GONE
|
||||||
binding.cvItem4.visibility = View.GONE
|
binding.cvItem4.visibility = View.GONE
|
||||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
||||||
@@ -141,7 +148,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
device.productId == Constants.HEMO_CUBE_V2_PRODUCT_ID && device.vendorId == Constants.HEMO_CUBE_V2_VENDOR_ID -> {
|
device.productId == Constants.HEMO_CUBE_V2_PRODUCT_ID && device.vendorId == Constants.HEMO_CUBE_V2_VENDOR_ID -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
binding.cvItem3.visibility = View.GONE
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
binding.cvItem2.visibility = View.GONE
|
binding.cvItem2.visibility = View.GONE
|
||||||
binding.cvItem4.visibility = View.GONE
|
binding.cvItem4.visibility = View.GONE
|
||||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
||||||
@@ -150,7 +157,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
device.productId == 24577 && device.vendorId == 1027 -> {
|
device.productId == 24577 && device.vendorId == 1027 -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
binding.cvItem3.visibility = View.GONE
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
binding.cvItem2.visibility = View.GONE
|
binding.cvItem2.visibility = View.GONE
|
||||||
binding.cvItem4.visibility = View.GONE
|
binding.cvItem4.visibility = View.GONE
|
||||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_TRUEHEME)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_TRUEHEME)
|
||||||
@@ -159,7 +166,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
device.productId == 8963 && device.vendorId == 1659 -> {
|
device.productId == 8963 && device.vendorId == 1659 -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
binding.cvItem3.visibility = View.GONE
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
binding.cvItem2.visibility = View.GONE
|
binding.cvItem2.visibility = View.GONE
|
||||||
binding.cvItem4.visibility = View.GONE
|
binding.cvItem4.visibility = View.GONE
|
||||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
||||||
@@ -168,7 +175,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
device.productId == 4614 && device.vendorId == 7111 -> {
|
device.productId == 4614 && device.vendorId == 7111 -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
binding.cvItem3.visibility = View.GONE
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
binding.cvItem2.visibility = View.GONE
|
binding.cvItem2.visibility = View.GONE
|
||||||
binding.cvItem4.visibility = View.GONE
|
binding.cvItem4.visibility = View.GONE
|
||||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
||||||
@@ -232,6 +239,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
startActivity(i)
|
startActivity(i)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
binding.cvItem3.setOnClickListener {
|
||||||
|
DataHolder.selectedTestType = TestType.HB_EST
|
||||||
|
val i = Intent(applicationContext, KitScanActivity::class.java)
|
||||||
|
i.putExtra("fromWhere","Main")
|
||||||
|
startActivity(i)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
DataHolder.usbConnected.observe(this) {
|
DataHolder.usbConnected.observe(this) {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@@ -28,11 +29,12 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||||
|
|
||||||
|
@SuppressLint("CustomSplashScreen")
|
||||||
class SplashActivity : AppCompatActivity() {
|
class SplashActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivitySplashBinding
|
private lateinit var binding: ActivitySplashBinding
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
@@ -42,7 +42,7 @@ import java.util.Locale
|
|||||||
|
|
||||||
class UserListAdapter(
|
class UserListAdapter(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel,
|
private val trueHemeTestViewModel: TrueHemeTestViewModel,
|
||||||
options: FirestoreRecyclerOptions<UserData>,
|
options: FirestoreRecyclerOptions<UserData>,
|
||||||
private val view: View,
|
private val view: View,
|
||||||
private val batLevel: Int,
|
private val batLevel: Int,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ class AssuranceControlsFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
val i = Intent(requireContext(), HemocubeActivity::class.java)
|
val i = Intent(requireContext(), TrueHemeTestActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import com.example.hpostesting.data.constant.HemoCubeCommands
|
|||||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
@@ -44,7 +44,7 @@ import kotlin.math.log10
|
|||||||
class HemoCubeBufferCheckFragment : Fragment() {
|
class HemoCubeBufferCheckFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var currentDeviceData: DeviceData? = null
|
private var currentDeviceData: DeviceData? = null
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
@@ -123,13 +123,13 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
trueHemeTestViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
currentDeviceData = it
|
currentDeviceData = it
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
if (isNetworkAvailable) {
|
if (isNetworkAvailable) {
|
||||||
hemoCubeViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
trueHemeTestViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), R.string.internt_not, Toast.LENGTH_SHORT
|
requireContext(), R.string.internt_not, Toast.LENGTH_SHORT
|
||||||
@@ -137,7 +137,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
isOnline = isNetworkAvailable
|
isOnline = isNetworkAvailable
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
trueHemeTestViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
showToast(R.string.kit_uploaded)
|
showToast(R.string.kit_uploaded)
|
||||||
}
|
}
|
||||||
@@ -152,11 +152,11 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
trueHemeTestViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
binding.tvSubtitle4.text = it
|
binding.tvSubtitle4.text = it
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
trueHemeTestViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||||
binding.tvDeviceMessages.text = it
|
binding.tvDeviceMessages.text = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultData += stringData
|
resultData += stringData
|
||||||
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
stringData.contains("SN") -> {
|
stringData.contains("SN") -> {
|
||||||
@@ -209,11 +209,11 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.messages.postValue("Start")
|
trueHemeTestViewModel.messages.postValue("Start")
|
||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("#BS") -> {
|
stringData.contains("#BS") -> {
|
||||||
hemoCubeViewModel.messages.postValue("Buffer Started")
|
trueHemeTestViewModel.messages.postValue("Buffer Started")
|
||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("#BC") -> {
|
stringData.contains("#BC") -> {
|
||||||
@@ -232,7 +232,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("#SC") -> {
|
stringData.contains("#SC") -> {
|
||||||
hemoCubeViewModel.messages.postValue("Sample Completed \nGathering data")
|
trueHemeTestViewModel.messages.postValue("Sample Completed \nGathering data")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val prdClassification = absorbanceBasedClassification(_predictedDenovixRatio)
|
val prdClassification = absorbanceBasedClassification(_predictedDenovixRatio)
|
||||||
hemoCubeViewModel.messages.postValue(prdClassification)
|
trueHemeTestViewModel.messages.postValue(prdClassification)
|
||||||
|
|
||||||
val bufferData = BufferCheckData(
|
val bufferData = BufferCheckData(
|
||||||
_id = UUID.randomUUID().toString(),
|
_id = UUID.randomUUID().toString(),
|
||||||
@@ -385,15 +385,15 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
testTime = SimpleDateFormat(
|
testTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time),
|
).format(Calendar.getInstance().time),
|
||||||
batteryLevel = hemoCubeViewModel.getBatteryLevel().toString(),
|
batteryLevel = trueHemeTestViewModel.getBatteryLevel().toString(),
|
||||||
batteryCapacity = hemoCubeViewModel.getBatteryCapacity(requireContext()).toString(),
|
batteryCapacity = trueHemeTestViewModel.getBatteryCapacity(requireContext()).toString(),
|
||||||
batteryMaxCapacity = hemoCubeViewModel.getBatteryMaxCapacity(requireContext())
|
batteryMaxCapacity = trueHemeTestViewModel.getBatteryMaxCapacity(requireContext())
|
||||||
.toString(),
|
.toString(),
|
||||||
batteryTemperature = hemoCubeViewModel.getBatteryTemperature().toString(),
|
batteryTemperature = trueHemeTestViewModel.getBatteryTemperature().toString(),
|
||||||
batteryVoltage = hemoCubeViewModel.getBatteryVoltage(requireContext()).toString()
|
batteryVoltage = trueHemeTestViewModel.getBatteryVoltage(requireContext()).toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
hemoCubeViewModel.uploadHemoCubeResultToDatabaseForBufferCheck(isOnline, bufferData)
|
trueHemeTestViewModel.uploadHemoCubeResultToDatabaseForBufferCheck(isOnline, bufferData)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), "Error while processing device data", Toast.LENGTH_SHORT
|
requireContext(), "Error while processing device data", Toast.LENGTH_SHORT
|
||||||
@@ -404,7 +404,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
private fun findResult(calculatedRatio: Double?): String {
|
private fun findResult(calculatedRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
hemoCubeViewModel.messages.postValue("result classification")
|
trueHemeTestViewModel.messages.postValue("result classification")
|
||||||
if (calculatedRatio != null) {
|
if (calculatedRatio != null) {
|
||||||
if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||||
if (calculatedRatio in 0.05..0.155) return "Normal"
|
if (calculatedRatio in 0.05..0.155) return "Normal"
|
||||||
@@ -426,7 +426,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
hemoCubeViewModel.messages.postValue("result classification")
|
trueHemeTestViewModel.messages.postValue("result classification")
|
||||||
if (predictedDenovixRatio != null) {
|
if (predictedDenovixRatio != null) {
|
||||||
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
||||||
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
||||||
@@ -482,20 +482,20 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeviceInfo() {
|
private fun getDeviceInfo() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
trueHemeTestViewModel.progressBar.postValue(true)
|
||||||
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
hemoCubeViewModel.messages.postValue(stringData)
|
trueHemeTestViewModel.messages.postValue(stringData)
|
||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
trueHemeTestViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import androidx.core.view.get
|
|||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -47,7 +47,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.example.hpostesting.data.constant.HemoCubeCommands
|
|||||||
import com.example.hpostesting.data.model.calibration.CalibrationData
|
import com.example.hpostesting.data.model.calibration.CalibrationData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
||||||
|
|||||||
@@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.AdapterView
|
|
||||||
import android.widget.ArrayAdapter
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.preference.ListPreference
|
|
||||||
import androidx.preference.Preference
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
|
||||||
import com.example.hpostesting.data.model.TestState
|
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
|
||||||
|
|
||||||
private var isLanguageChanged = false
|
|
||||||
|
|
||||||
class SlideshowFragment : Fragment(){
|
|
||||||
private var selectedItem = "10mm"
|
|
||||||
private val values = arrayOf("10mm", "2mm")
|
|
||||||
private lateinit var binding: FragmentSlideshowBinding
|
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
|
||||||
): View {
|
|
||||||
binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
|
||||||
sharedPreferences =
|
|
||||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME,""))
|
|
||||||
|
|
||||||
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
|
||||||
val time = sharedPreferences.getString(Constants.LAST_UPDATED,"NA").toString()
|
|
||||||
binding.lastUpdated.text = "Last updated config: $time"
|
|
||||||
binding.btnGo.setOnClickListener {
|
|
||||||
var labname = binding.nameEditText.text.toString()
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
|
||||||
this.labName = labname
|
|
||||||
}
|
|
||||||
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.LABNAME, labname)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(),
|
|
||||||
"Lab Name is Added successfully.",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, values)
|
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
|
||||||
val pos: Int
|
|
||||||
if(selectedItem == "10mm"){
|
|
||||||
pos = 0
|
|
||||||
}else{
|
|
||||||
pos = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.spinnerCuvette.adapter = adapter
|
|
||||||
binding.spinnerCuvette.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
|
||||||
// Handle item selection here
|
|
||||||
selectedItem = values[position]
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
|
||||||
// Do nothing here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.spinnerCuvette.setSelection(pos)
|
|
||||||
binding.btnAddSize.setOnClickListener {
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.CUVETTE_SIZE, selectedItem)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
Toast.makeText(requireContext(), "Selected cuvette size: $selectedItem", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
childFragmentManager.beginTransaction().replace(binding.container.id,PrefsFragment()).commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class PrefsFragment: PreferenceFragmentCompat(){
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
||||||
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
|
||||||
|
|
||||||
val languagePreference = ListPreference(requireContext())
|
|
||||||
languagePreference.key = "language_preference"
|
|
||||||
languagePreference.title = getString(R.string.app_language)
|
|
||||||
languagePreference.summary = getString(R.string.select_language)
|
|
||||||
languagePreference.entries = arrayOf("English", "Kannada", "Hindi")
|
|
||||||
languagePreference.entryValues = arrayOf("en", "kn", "hi")
|
|
||||||
languagePreference.setDefaultValue("en")
|
|
||||||
|
|
||||||
languagePreference.onPreferenceChangeListener =
|
|
||||||
Preference.OnPreferenceChangeListener { _, newValue ->
|
|
||||||
val languageCode = newValue as String
|
|
||||||
updateLanguage(requireContext(), languageCode)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
|
||||||
setPreferenceScreen(preferenceScreen)
|
|
||||||
|
|
||||||
// App Version Preference
|
|
||||||
val appVersionPreference = Preference(requireContext())
|
|
||||||
appVersionPreference.title = "App Version"
|
|
||||||
appVersionPreference.summary =
|
|
||||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + " ]"
|
|
||||||
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
|
||||||
preferenceScreen.addPreference(appVersionPreference)
|
|
||||||
setPreferenceScreen(preferenceScreen)
|
|
||||||
if (isLanguageChanged) {
|
|
||||||
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private fun updateLanguage(context: Context, languageCode: String) {
|
|
||||||
LanguageManager.persistLanguagePreference(context, languageCode)
|
|
||||||
LanguageManager.setLocale(context, languageCode)
|
|
||||||
requireActivity().recreate() // Recreate activity to apply language changes
|
|
||||||
isLanguageChanged = true
|
|
||||||
}
|
|
||||||
private fun getAppVersion(context: Context): String {
|
|
||||||
return try {
|
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
||||||
pInfo.versionName
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
|
||||||
"N/A"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getAppEnvironment(context: Context): String {
|
|
||||||
return try {
|
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
||||||
pInfo.packageName.substringAfterLast('.')
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
|
||||||
"N/A"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard.ui.gallery
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
|
|
||||||
class mGalleryViewModel : ViewModel() {
|
|
||||||
|
|
||||||
private val _text = MutableLiveData<String>().apply {
|
|
||||||
value = "This is gallery Fragment"
|
|
||||||
}
|
|
||||||
val text: LiveData<String> = _text
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard.ui.slideshow
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
|
|
||||||
class SlideshowViewModel : ViewModel() {
|
|
||||||
|
|
||||||
private val _text = MutableLiveData<String>().apply {
|
|
||||||
value = "This is slideshow Fragment"
|
|
||||||
}
|
|
||||||
val text: LiveData<String> = _text
|
|
||||||
}
|
|
||||||
@@ -26,14 +26,14 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
||||||
|
|
||||||
class DeviceFragment : Fragment() {
|
class DeviceFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentDeviceBinding
|
private lateinit var binding: FragmentDeviceBinding
|
||||||
private val deviceViewModel: HemoCubeViewModel by activityViewModels()
|
private val deviceViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var deviceId = ""
|
private var deviceId = ""
|
||||||
private var startListening = MutableLiveData(false)
|
private var startListening = MutableLiveData(false)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -34,13 +33,12 @@ import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
|||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.encryption.Encryption
|
import com.example.hpostesting.encryption.Encryption
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||||
|
import okio.ByteString.Companion.decodeBase64
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
|
||||||
|
|
||||||
class DeviceProvisionFragment : Fragment() {
|
class DeviceProvisionFragment : Fragment() {
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
@@ -150,17 +148,18 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
DashboardActivity::class.java
|
DashboardActivity::class.java
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"An error in device provision: ${response.data.message}",
|
"An error in device provision: ${response.data.message}",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
|
Log.d("Error in hpos network", "observeViewModel:${response.data.message} ")
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
response.exception.let { message ->
|
response.exception.let { message ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@@ -168,7 +167,9 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
"An error occurred in device provision: $message",
|
"An error occurred in device provision: $message",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
|
Log.d("Error in hpos network 2", "observeViewModel:$message} ")
|
||||||
}
|
}
|
||||||
|
Log.d("Error in hpos network 3", "observeViewModel: $response} ")
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Loading -> {
|
is Result.Loading -> {
|
||||||
@@ -248,11 +249,15 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
|
|
||||||
private fun encryptAndSaveToFile(username: String, password: String) {
|
private fun encryptAndSaveToFile(username: String, password: String) {
|
||||||
val messageToEncrypt = "$username\n$password"
|
val messageToEncrypt = "$username\n$password"
|
||||||
val encryptionKey =
|
val encryptionKey = Settings.Secure.getString(requireContext().contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
Settings.Secure.getString(context?.contentResolver, Settings.Secure.ANDROID_ID)
|
|
||||||
val encryptedString = Encryption.encrypt(messageToEncrypt, encryptionKey)
|
val encryptedString = Encryption.encrypt(messageToEncrypt, encryptionKey)
|
||||||
Log.d("DEVICE ID/encryptionKey", encryptionKey)
|
Log.d("DEVICE ID/encryptionKey", encryptionKey)
|
||||||
val target = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
val target = File(requireContext().getExternalFilesDir(null), "HPOSDocuments")
|
||||||
|
if (!target.exists()) {
|
||||||
|
target.mkdirs() // Create the directory if it doesn't exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// val target = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
||||||
val file = File(target, "credentials.txt")
|
val file = File(target, "credentials.txt")
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
|||||||
@@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.hb_test
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.hardware.usb.UsbDevice
|
||||||
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
|
import android.hardware.usb.UsbManager
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.get
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
|
import com.example.hpostesting.util.UsbService
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityHbTestBinding
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class HBTestActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var databaseRepository: DatabaseRepository
|
||||||
|
private lateinit var binding: ActivityHbTestBinding
|
||||||
|
val viewModel: HBTestViewModel by viewModels()
|
||||||
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
|
private var mConnection: UsbDeviceConnection? = null
|
||||||
|
lateinit var mService: UsbService
|
||||||
|
|
||||||
|
private val TAG = "HemoCube"
|
||||||
|
|
||||||
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
|
synchronized(this) {
|
||||||
|
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
||||||
|
|
||||||
|
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
|
||||||
|
device?.apply {
|
||||||
|
connectUsb(true)
|
||||||
|
DataHolder.usbConnected.postValue(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onErrorReported("permission denied for device")
|
||||||
|
DataHolder.usbConnected.postValue(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val connection = object : ServiceConnection {
|
||||||
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
|
val binder = service as UsbService.UsbServiceBinder
|
||||||
|
mService = binder.getService()
|
||||||
|
viewModel.isServiceConnected = true
|
||||||
|
mConnection.let { mService.connect(mDriver, mConnection!!) }
|
||||||
|
moveToNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceDisconnected(arg0: ComponentName) {
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val firebaseManager = FirebaseManager(this)
|
||||||
|
val lastSelectedServer = firebaseManager.getLastSelectedServer()
|
||||||
|
// switchFirebaseServer(lastSelectedServer)
|
||||||
|
Log.d("CURRENT SERVR......","server : ${lastSelectedServer.serverName}")
|
||||||
|
binding = ActivityHbTestBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
// setSupportActionBar(binding.myToolbar)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
setupListener()
|
||||||
|
connectUsb(false)
|
||||||
|
|
||||||
|
}
|
||||||
|
// private fun switchFirebaseServer(config: FirebaseConfig) {
|
||||||
|
// val (newFirestore, newStorage) = firebaseManager.switchFirestoreServer(config)
|
||||||
|
// databaseRepository.switchServer(newFirestore, newStorage)
|
||||||
|
//// Toast.makeText(this, "server switched", Toast.LENGTH_SHORT).show()// Update repository with new Firestore and Storage
|
||||||
|
// }
|
||||||
|
private fun setupListener() {
|
||||||
|
DataHolder.usbConnected.observe(this) {
|
||||||
|
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
||||||
|
if (it) {
|
||||||
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
||||||
|
} else {
|
||||||
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
||||||
|
Toast.makeText(this, "Device is Disconnected", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
||||||
|
|
||||||
|
if (availableDrivers.isEmpty()) {
|
||||||
|
onErrorReported("No Device is Connected")
|
||||||
|
} else {
|
||||||
|
mDriver = availableDrivers[0]
|
||||||
|
mConnection = manager.openDevice(mDriver.device)
|
||||||
|
|
||||||
|
if (mConnection == null) {
|
||||||
|
requestUserPermission(manager, mDriver.device)
|
||||||
|
} else {
|
||||||
|
setupService()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onErrorReported(msg: String) {
|
||||||
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
|
if (!isFinishing) onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun moveToNext() {
|
||||||
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
|
supportFragmentManager.beginTransaction().replace(binding.fgHbTest.id, HBTestFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MutableImplicitPendingIntent")
|
||||||
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
|
val mPendingIntent: PendingIntent
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
|
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||||
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||||
|
registerReceiver(broadcastReceiver, filter)
|
||||||
|
manager.requestPermission(device, mPendingIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setupService() {
|
||||||
|
val intent = Intent(this, UsbService::class.java)
|
||||||
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
if (viewModel.isServiceConnected) {
|
||||||
|
mService.disconnect()
|
||||||
|
unbindService(connection)
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,399 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.hb_test
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.method.ScrollingMovementMethod
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentAutoDacBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHbTestBinding
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
import kotlin.math.log10
|
||||||
|
|
||||||
|
class HBTestFragment : Fragment() {
|
||||||
|
private var isUsingExistingBuffer = false
|
||||||
|
private var led1Average = 0.0
|
||||||
|
private var led3Average = 0.0
|
||||||
|
private var led2Average = 0.0
|
||||||
|
private var led4Average = 0.0
|
||||||
|
private var led1SampleForDevice = 0.0
|
||||||
|
private var led2SampleForDevice = 0.0
|
||||||
|
private var led3SampleForDevice = 0.0
|
||||||
|
private var led4SampleForDevice = 0.0
|
||||||
|
private var led1BufferForDevice = 0.0
|
||||||
|
private var led2BufferForDevice = 0.0
|
||||||
|
private var led3BufferForDevice = 0.0
|
||||||
|
private var led4BufferForDevice = 0.0
|
||||||
|
private var x = 0.0
|
||||||
|
private var deviceId = ""
|
||||||
|
private var hbEst = 0.0
|
||||||
|
private var testStatusCode = 0.0
|
||||||
|
private var testDetails: HemoCubeTestData = HemoCubeTestData()
|
||||||
|
private lateinit var binding: FragmentHbTestBinding
|
||||||
|
private val hBTestViewModel: HBTestViewModel by activityViewModels()
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private var currentDeviceData: DeviceData? = null
|
||||||
|
private var resultData: String = ""
|
||||||
|
// private val messages = MutableLiveData<String>()
|
||||||
|
private var startListening = MutableLiveData(false)
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
binding = FragmentHbTestBinding.inflate(inflater, container, false)
|
||||||
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
initViews()
|
||||||
|
observeViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initViews() {
|
||||||
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
listenToHemoCube()
|
||||||
|
getDeviceId()
|
||||||
|
binding.tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
||||||
|
binding.btnSubmit.setOnClickListener {
|
||||||
|
hBTestViewModel.messages.postValue(resultData)
|
||||||
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
testDetails.localFlag = false
|
||||||
|
testDetails.testStatus = true
|
||||||
|
testDetails.deviceId = deviceId
|
||||||
|
testDetails._id = DataHolder.sampleId
|
||||||
|
testDetails.kitSerial = DataHolder.kitSerial
|
||||||
|
testDetails.classificationResult = "HB: $hbEst"
|
||||||
|
testDetails.hb3 = x
|
||||||
|
testDetails.hb4 = hbEst
|
||||||
|
testDetails.age = DataHolder.age
|
||||||
|
testDetails.bloodGroup = DataHolder.bloodGroup
|
||||||
|
testDetails.led1Buffer = led1BufferForDevice
|
||||||
|
testDetails.led2Buffer = led2BufferForDevice
|
||||||
|
testDetails.led3Buffer = led3BufferForDevice
|
||||||
|
testDetails.led4Buffer = led4BufferForDevice
|
||||||
|
testDetails.led1Sample = led1SampleForDevice
|
||||||
|
testDetails.led2Sample = led2SampleForDevice
|
||||||
|
testDetails.led3Sample = led3SampleForDevice
|
||||||
|
testDetails.led4Sample = led4SampleForDevice
|
||||||
|
testDetails.led1Average = led1Average
|
||||||
|
testDetails.led2Average = led2Average
|
||||||
|
testDetails.led3Average = led3Average
|
||||||
|
testDetails.led4Average = led4Average
|
||||||
|
testDetails.testType = "HB Est"
|
||||||
|
testDetails.testTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
hBTestViewModel.uploadFirebaseQc(testDetails)
|
||||||
|
}
|
||||||
|
binding.btnBuffer.setOnClickListener {
|
||||||
|
binding.btnBuffer.visibility = View.GONE
|
||||||
|
binding.btnSample.isEnabled = false
|
||||||
|
binding.btnSample.isClickable = false
|
||||||
|
hBTestViewModel.messages.postValue("Buffer Started")
|
||||||
|
runBCommand()
|
||||||
|
}
|
||||||
|
binding.btnSample.setOnClickListener {
|
||||||
|
hBTestViewModel.messages.postValue("Sample Started")
|
||||||
|
binding.btnSample.visibility = View.GONE
|
||||||
|
binding.btnBuffer.visibility = View.GONE
|
||||||
|
runSCommand()
|
||||||
|
}
|
||||||
|
if (isBufferValueAvailable()) {
|
||||||
|
isUsingExistingBuffer = true
|
||||||
|
binding.btnBuffer.text = "Refresh Buffer"
|
||||||
|
binding.btnSample.isEnabled = true
|
||||||
|
binding.btnSample.isClickable = true
|
||||||
|
}else{
|
||||||
|
binding.btnBuffer.text = "Start Buffer"
|
||||||
|
binding.btnSample.isEnabled = false
|
||||||
|
binding.btnSample.isClickable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun observeViewModel() {
|
||||||
|
|
||||||
|
hBTestViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
|
currentDeviceData = it
|
||||||
|
}
|
||||||
|
|
||||||
|
hBTestViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
|
binding.tvSubtitle4.text = it
|
||||||
|
}
|
||||||
|
|
||||||
|
hBTestViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
|
if (result == "Success") {
|
||||||
|
showToast("Data uploaded successfully")
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
|
if (result == "Local") {
|
||||||
|
showToast("Data uploading failed, note it down manually")
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDeviceId() {
|
||||||
|
hBTestViewModel.progressBar.postValue(true)
|
||||||
|
(activity as HBTestActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
//deviceId = stringData
|
||||||
|
hBTestViewModel.messages.postValue(stringData)
|
||||||
|
binding.tvSubtitle4.text = stringData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hBTestViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runBCommand() {
|
||||||
|
hBTestViewModel.progressBar.postValue(true)
|
||||||
|
(activity as HBTestActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hBTestViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runSCommand() {
|
||||||
|
hBTestViewModel.progressBar.postValue(true)
|
||||||
|
(activity as HBTestActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.START_SAMPLE,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hBTestViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runPCommand() {
|
||||||
|
hBTestViewModel.progressBar.postValue(true)
|
||||||
|
(activity as HBTestActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.PRINT_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hBTestViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fun extractV2HardwareId(input: String): String? {
|
||||||
|
val pattern = Regex("SNS\\s*(.*?)\\s*SNE")
|
||||||
|
val matchResult: MatchResult? = pattern.find(input)
|
||||||
|
|
||||||
|
return matchResult?.groups?.get(1)?.value
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
|
val fullReadOutput = StringBuilder()
|
||||||
|
startListening.postValue(true)
|
||||||
|
|
||||||
|
try {
|
||||||
|
(activity as HBTestActivity).mService.listenToHemoCube(object :
|
||||||
|
UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
fullReadOutput.append(stringData)
|
||||||
|
resultData += stringData
|
||||||
|
hBTestViewModel.messages.postValue(resultData)
|
||||||
|
// binding.tvSubtitle4.text = resultData
|
||||||
|
if (stringData.contains("SNE")) {
|
||||||
|
val slData = stringData.split(" ")
|
||||||
|
if (slData.size > 1) {
|
||||||
|
val hardwareId = slData[1].trim()
|
||||||
|
deviceId = extractV2HardwareId(resultData).toString()
|
||||||
|
hBTestViewModel.messages.postValue("Place buffer and click below button to start test")
|
||||||
|
// with(sharedPreferences.edit()) {
|
||||||
|
// putString(Constants.DEVICE_ID, hardwareId)
|
||||||
|
// apply()
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnBuffer.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resultData.contains("#BC") && testStatusCode < 1.0) {
|
||||||
|
testStatusCode = 1.1
|
||||||
|
resultData += getString(R.string.buffer_completed)
|
||||||
|
hBTestViewModel.messages.postValue(resultData)
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSample.visibility = View.VISIBLE
|
||||||
|
binding.btnSample.isEnabled = true
|
||||||
|
binding.btnSample.isClickable = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultData.contains("#SC") && testStatusCode < 1.3) {
|
||||||
|
testStatusCode = 1.4
|
||||||
|
resultData +=getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data)
|
||||||
|
hBTestViewModel.messages.postValue(resultData)
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
|
runPCommand()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultData.contains("REND") && testStatusCode < 1.5) {
|
||||||
|
testStatusCode = 1.6
|
||||||
|
runResult()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hBTestViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun runResult() {
|
||||||
|
resultData += "\nFetching results...\n"
|
||||||
|
hBTestViewModel.messages.postValue(resultData)
|
||||||
|
|
||||||
|
val resultLines = resultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
|
var bufferIntensity = resultLines[1].split(' ')[1].trim()
|
||||||
|
led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
|
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()!!
|
||||||
|
} else {
|
||||||
|
bufferIntensity.toDoubleOrNull()!!
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferIntensity = resultLines[2].split(' ')[1].trim()
|
||||||
|
led2BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
|
sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()!!
|
||||||
|
} else {
|
||||||
|
bufferIntensity.toDoubleOrNull()!!
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferIntensity = resultLines[3].split(' ')[1].trim()
|
||||||
|
led3BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
|
sharedPreferences.getString(Constants.BUFFER_VALUE_3, "")?.toDoubleOrNull()!!
|
||||||
|
} else {
|
||||||
|
bufferIntensity.toDoubleOrNull()!!
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferIntensity = resultLines[4].split(' ')[1].trim()
|
||||||
|
led4BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
|
sharedPreferences.getString(Constants.BUFFER_VALUE_4, "")?.toDoubleOrNull()!!
|
||||||
|
} else {
|
||||||
|
bufferIntensity.toDoubleOrNull()!!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
led1SampleForDevice = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
|
led2SampleForDevice = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
|
led3SampleForDevice = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
|
led4SampleForDevice = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
|
|
||||||
|
led1Average = log10(led1BufferForDevice.div(led1SampleForDevice))
|
||||||
|
led2Average = log10(led2BufferForDevice.div(led2SampleForDevice))
|
||||||
|
led3Average = log10(led3BufferForDevice.div(led3SampleForDevice))
|
||||||
|
led4Average = log10(led4BufferForDevice.div(led4SampleForDevice))
|
||||||
|
|
||||||
|
x = led1Average - led3Average
|
||||||
|
|
||||||
|
hbEst = (7.347 * x * x) + (12.704 * x) + 0.9033
|
||||||
|
|
||||||
|
resultData +="\n Result: HB EST: $hbEst"
|
||||||
|
if (!isUsingExistingBuffer) {
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.BUFFER_VALUE_1, led1BufferForDevice.toString())
|
||||||
|
putString(Constants.BUFFER_VALUE_2, led2BufferForDevice.toString())
|
||||||
|
putString(Constants.BUFFER_VALUE_3, led3BufferForDevice.toString())
|
||||||
|
putString(Constants.BUFFER_VALUE_4, led4BufferForDevice.toString())
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hBTestViewModel.messages.postValue(resultData)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun showToast(message: String) {
|
||||||
|
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
private fun isBufferValueAvailable(): Boolean {
|
||||||
|
return try {
|
||||||
|
if (sharedPreferences.getString(
|
||||||
|
Constants.BUFFER_VALUE_1, ""
|
||||||
|
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||||
|
&& sharedPreferences.getString(Constants.BUFFER_VALUE_3, "") != ""
|
||||||
|
&& sharedPreferences.getString(Constants.BUFFER_VALUE_4, "") != ""
|
||||||
|
) {
|
||||||
|
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")
|
||||||
|
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
||||||
|
Constants.BUFFER_VALUE_2,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
||||||
|
Constants.BUFFER_VALUE_3,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
||||||
|
Constants.BUFFER_VALUE_4,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
?.toDouble()!! > 0.0
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showToast("error_exist")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.hb_test
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
|
import com.example.hpostesting.data.model.Response
|
||||||
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.repository.Repository
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@HiltViewModel
|
||||||
|
class HBTestViewModel @Inject constructor(
|
||||||
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
|
private val repository: Repository,
|
||||||
|
context: Context,
|
||||||
|
) : ViewModel() {
|
||||||
|
var isServiceConnected = false
|
||||||
|
val progressBar = MutableLiveData(false)
|
||||||
|
val messages = MutableLiveData<String>()
|
||||||
|
private val sharedPreference: SharedPreferences =
|
||||||
|
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
|
fun uploadFirebaseQc(testDetails: HemoCubeTestData){
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
when (val response = repository.addTestToDatabase(testDetails)) {
|
||||||
|
is Response.Success -> {
|
||||||
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
|
fireBaseUpload.postValue("Success")
|
||||||
|
testDetails.localFlag = true
|
||||||
|
hemoCubeDao.updateTest(testDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
is Response.Error -> {
|
||||||
|
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
hemoCubeDao.updateTest(testDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun addAutoDacDataToDb(data: DiagnosticsData) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
when (val response = repository.addDiagnostics(data)) {
|
||||||
|
is Response.Success -> {
|
||||||
|
fireBaseUpload.postValue("Success")
|
||||||
|
}
|
||||||
|
|
||||||
|
is Response.Error -> {
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,29 +11,14 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.os.BatteryManager
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
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 androidx.fragment.app.activityViewModels
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
|
||||||
|
|
||||||
class AboutFragment : Fragment() {
|
class AboutFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentAboutBinding
|
private lateinit var binding: FragmentAboutBinding
|
||||||
@@ -11,32 +11,28 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
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 androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class ActivitiesFragment : Fragment() {
|
class ActivitiesFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentActivitiesBinding
|
private lateinit var binding: FragmentActivitiesBinding
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
private lateinit var adapter: OfflineUserListAdapter
|
private lateinit var adapter: OfflineUserListAdapter
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
@@ -50,9 +46,15 @@ class ActivitiesFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
hemoCubeViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
trueHemeTestViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
||||||
|
|
||||||
if (userData.isNotEmpty()) {
|
if (userData.isNotEmpty()) {
|
||||||
|
userData.forEach { user ->
|
||||||
|
if((isBetween15And30Minutes(user.incubationTime) > 30 || isBetween15And30Minutes(user.incubationTime) < 0 ) && user.testStatus == false){
|
||||||
|
trueHemeTestViewModel.deleteByStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.rvOrderOffline.visibility = View.VISIBLE
|
binding.rvOrderOffline.visibility = View.VISIBLE
|
||||||
binding.noDataText.visibility = View.GONE
|
binding.noDataText.visibility = View.GONE
|
||||||
val bm =
|
val bm =
|
||||||
@@ -68,5 +70,16 @@ class ActivitiesFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private fun isBetween15And30Minutes(createdAt: String): Long {
|
||||||
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
val createdAtDate: Date = formatter.parse(createdAt)!!
|
||||||
|
|
||||||
|
val currentTime = Calendar.getInstance().time
|
||||||
|
|
||||||
|
val diffMillis = currentTime.time - createdAtDate.time
|
||||||
|
|
||||||
|
return diffMillis / (60 * 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.constant.Constants.FIREBASE_INTEGRATION
|
||||||
|
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
||||||
|
|
||||||
|
class AppVersionTapManager {
|
||||||
|
|
||||||
|
private var tapCount = 0
|
||||||
|
private val maxTapCount = 5
|
||||||
|
val shouldEnable = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
||||||
|
val notEnable = MOLBIO_INTEGRATION && !FIREBASE_INTEGRATION
|
||||||
|
|
||||||
|
fun registerTap(onMaxTapsReached: () -> Unit) {
|
||||||
|
tapCount++
|
||||||
|
if (tapCount >= maxTapCount && shouldEnable) {
|
||||||
|
onMaxTapsReached()
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private fun reset() {
|
||||||
|
tapCount = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
@@ -30,7 +30,6 @@ import android.net.Uri
|
|||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -44,7 +43,6 @@ import androidx.core.content.FileProvider
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.findNavController
|
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
@@ -61,7 +59,7 @@ import com.example.hpostesting.presentation.KitScanActivity
|
|||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
@@ -102,12 +100,12 @@ class HomeFragment : Fragment() {
|
|||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
private lateinit var binding: FragmentHomeBinding
|
private lateinit var binding: FragmentHomeBinding
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel by activityViewModels()
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
private lateinit var rvAdapter: UserListAdapter
|
private lateinit var rvAdapter: UserListAdapter
|
||||||
private var batLevel: Int =
|
private var batLevel: Int =
|
||||||
0 // Initialize with a default value, or obtain the actual battery level
|
0 // Initialize with a default value, or obtain the actual battery level
|
||||||
private lateinit var adapter: OfflineUserListAdapter
|
private lateinit var adapter: OfflineUserListAdapter
|
||||||
private val homeViewModel: HemoCubeViewModel by activityViewModels()
|
private val homeViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
private var isTokenAvailable by Delegates.notNull<Boolean>()
|
private var isTokenAvailable by Delegates.notNull<Boolean>()
|
||||||
private var natsToken: String = ""
|
private var natsToken: String = ""
|
||||||
private var deviceId: String = ""
|
private var deviceId: String = ""
|
||||||
@@ -141,7 +139,7 @@ class HomeFragment : Fragment() {
|
|||||||
deleteIncompleteRegistrations(userData)
|
deleteIncompleteRegistrations(userData)
|
||||||
}
|
}
|
||||||
// getLocationIP()
|
// getLocationIP()
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
deleteHemoCubeIncompleteRegistrations(userData)
|
deleteHemoCubeIncompleteRegistrations(userData)
|
||||||
if (userData.isNotEmpty()) {
|
if (userData.isNotEmpty()) {
|
||||||
val userList = mutableListOf<HemoCubeTestData>()
|
val userList = mutableListOf<HemoCubeTestData>()
|
||||||
@@ -172,11 +170,12 @@ class HomeFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
trueHemeTestViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
|
trueHemeTestViewModel.fireBaseBulkUpload.postValue("Done")
|
||||||
}
|
}
|
||||||
if (result == "Error") {
|
if (result == "Error") {
|
||||||
Toast.makeText(requireContext(), R.string.test_upload_failed, Toast.LENGTH_SHORT)
|
Toast.makeText(requireContext(), R.string.test_upload_failed, Toast.LENGTH_SHORT)
|
||||||
@@ -194,7 +193,7 @@ class HomeFragment : Fragment() {
|
|||||||
// binding.uploadData.setOnClickListener {
|
// binding.uploadData.setOnClickListener {
|
||||||
//// showUploadDialog(requireContext())
|
//// showUploadDialog(requireContext())
|
||||||
// }
|
// }
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
//
|
//
|
||||||
// }else{
|
// }else{
|
||||||
@@ -289,8 +288,17 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.P)
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
private fun checkNetworkStatus() {
|
private fun checkNetworkStatus() {
|
||||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
||||||
// Toast.makeText(requireContext(),"connected"+isConnected+wasConnected, Toast.LENGTH_SHORT).show()
|
// Toast.makeText(requireContext(),"connected"+isConnected+wasConnected, Toast.LENGTH_SHORT).show()
|
||||||
|
if(isConnected){
|
||||||
|
binding.tvTitleNoInternet.text = "Please enter the user id and select blood group to start the test."
|
||||||
|
binding.internetIcon.setImageDrawable(AppCompatResources.getDrawable(requireContext(),R.drawable.internet))
|
||||||
|
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||||
|
}else{
|
||||||
|
binding.internetIcon.setImageDrawable(AppCompatResources.getDrawable(requireContext(),R.drawable.off))
|
||||||
|
binding.tvTitleNoInternet.text = getString(R.string.internet_not_available_please_enter_the_user_id_manually)
|
||||||
|
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
if (isConnected != wasConnected) {
|
if (isConnected != wasConnected) {
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
binding.tvTitleNoInternet.text = "Please enter the user id and select blood group to start the test."
|
binding.tvTitleNoInternet.text = "Please enter the user id and select blood group to start the test."
|
||||||
@@ -370,9 +378,11 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
if(Constants.MOLBIO_INTEGRATION){
|
if(Constants.MOLBIO_INTEGRATION){
|
||||||
hemoCubeViewModel.sendDataToMolbio()
|
trueHemeTestViewModel.sendDataToMolbio()
|
||||||
|
}
|
||||||
|
if(Constants.FIREBASE_INTEGRATION) {
|
||||||
|
trueHemeTestViewModel.sendDataToFirebase()
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.sendDataToFirebase()
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
binding.tvTitleNoInternet.text = getString(R.string.internet_not_available_please_enter_the_user_id_manually)
|
binding.tvTitleNoInternet.text = getString(R.string.internet_not_available_please_enter_the_user_id_manually)
|
||||||
@@ -403,7 +413,8 @@ class HomeFragment : Fragment() {
|
|||||||
var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||||
deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString()
|
deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString()
|
||||||
|
|
||||||
val target = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
// val target = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
||||||
|
val target = File(requireContext().getExternalFilesDir(null), "HPOSDocuments")
|
||||||
val file = File(target, "credentials.txt") //this file contains userID and password to communicate with API.
|
val file = File(target, "credentials.txt") //this file contains userID and password to communicate with API.
|
||||||
|
|
||||||
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
||||||
@@ -423,7 +434,7 @@ class HomeFragment : Fragment() {
|
|||||||
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
}else{
|
}else{
|
||||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
trueHemeTestViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
}
|
}
|
||||||
//isTokenAvailable = true
|
//isTokenAvailable = true
|
||||||
// hemoCubeViewModel.startPeriodicCheckUpdate()
|
// hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
@@ -449,7 +460,7 @@ class HomeFragment : Fragment() {
|
|||||||
callLogin(userID, password)
|
callLogin(userID, password)
|
||||||
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
}else{
|
}else{
|
||||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
trueHemeTestViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -460,7 +471,7 @@ class HomeFragment : Fragment() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
trueHemeTestViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
updateTokens(response)
|
updateTokens(response)
|
||||||
@@ -491,14 +502,14 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
trueHemeTestViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
|
|
||||||
Log.d("success,", "uploded")
|
Log.d("success,", "uploded")
|
||||||
it.data.data?.forEach { id ->
|
it.data.data?.forEach { id ->
|
||||||
id.rawData?.let { it1 ->
|
id.rawData?.let { it1 ->
|
||||||
hemoCubeViewModel.updateMolbioFlag(
|
trueHemeTestViewModel.updateMolbioFlag(
|
||||||
it1._id
|
it1._id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -525,7 +536,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
trueHemeTestViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
// Toast.makeText(
|
// Toast.makeText(
|
||||||
@@ -555,7 +566,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
trueHemeTestViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
val updatedversion = response.data.data?.version.toString()
|
val updatedversion = response.data.data?.version.toString()
|
||||||
@@ -581,7 +592,7 @@ class HomeFragment : Fragment() {
|
|||||||
Log.d("versionnow", currentversion.toString())
|
Log.d("versionnow", currentversion.toString())
|
||||||
Log.d("versionnow", updatedversion.toString())
|
Log.d("versionnow", updatedversion.toString())
|
||||||
if (updatedversion > currentversion.toString()) {
|
if (updatedversion > currentversion.toString()) {
|
||||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
trueHemeTestViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"new version ${response.data.data?.version} Available",
|
"new version ${response.data.data?.version} Available",
|
||||||
@@ -617,7 +628,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
trueHemeTestViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
val url = response.data
|
val url = response.data
|
||||||
@@ -785,16 +796,58 @@ class HomeFragment : Fragment() {
|
|||||||
private fun setUserId() {
|
private fun setUserId() {
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
val userId = binding.userId.text.toString()
|
val userId = binding.userId.text.toString()
|
||||||
|
DataHolder.sampleId = userId
|
||||||
|
val age = binding.age.text.toString()
|
||||||
|
DataHolder.age = age
|
||||||
val bloodGroup = binding.etBloodGroup.text.toString()
|
val bloodGroup = binding.etBloodGroup.text.toString()
|
||||||
if (userId.length >= 5 && bloodGroup != "Select Blood Group") {
|
DataHolder.bloodGroup = bloodGroup
|
||||||
DataHolder.selectedTest = UserData(
|
|
||||||
_id = userId,
|
// if (userId.length >= 5 && bloodGroup != "Select Blood Group") {
|
||||||
bloodGroup = bloodGroup,
|
// DataHolder.selectedTest = UserData(
|
||||||
incubationTime = SimpleDateFormat(
|
// _id = userId,
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
// bloodGroup = bloodGroup,
|
||||||
).format(Calendar.getInstance().time).toString()
|
// incubationTime = SimpleDateFormat(
|
||||||
)
|
// "yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
// ).format(Calendar.getInstance().time).toString()
|
||||||
|
// )
|
||||||
|
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
|
if (userId.length >= 5 && bloodGroup.isNotEmpty() && age.isNotEmpty()) {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
// Add user first, ensuring it's done before fetching the user
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
trueHemeTestViewModel.addUser(
|
||||||
|
HemoCubeTestData(
|
||||||
|
_id = userId,
|
||||||
|
age = age,
|
||||||
|
bloodGroup = bloodGroup,
|
||||||
|
incubationTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time).toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now fetch the user after the addUser operation is complete
|
||||||
|
val user = withContext(Dispatchers.IO) {
|
||||||
|
trueHemeTestViewModel.hemoCubeDao.getUserByID(userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
user?.let {
|
||||||
|
DataHolder.selectedTest = UserData(
|
||||||
|
sampleid = it.sampleid,
|
||||||
|
_id = it._id,
|
||||||
|
age = it.age,
|
||||||
|
bloodGroup = it.bloodGroup,
|
||||||
|
incubationTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time).toString()
|
||||||
|
)
|
||||||
|
findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
|
} ?: run {
|
||||||
|
Log.e("Error", "User not found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// hemoCubeViewModel.addUser(
|
// hemoCubeViewModel.addUser(
|
||||||
// HemoCubeTestData(
|
// HemoCubeTestData(
|
||||||
// _id = userId,
|
// _id = userId,
|
||||||
@@ -806,6 +859,9 @@ class HomeFragment : Fragment() {
|
|||||||
// )
|
// )
|
||||||
Toast.makeText(requireContext(), "Successfully added- $userId", Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), "Successfully added- $userId", Toast.LENGTH_SHORT).show()
|
||||||
binding.userId.setText("")
|
binding.userId.setText("")
|
||||||
|
binding.age.setText("")
|
||||||
|
binding.etBloodGroup.setText("")
|
||||||
|
|
||||||
// val userData = UserData(_id = userId)
|
// val userData = UserData(_id = userId)
|
||||||
// DataHolder.selectedTest = userData
|
// DataHolder.selectedTest = userData
|
||||||
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
@@ -895,7 +951,7 @@ class HomeFragment : Fragment() {
|
|||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
hemoCubeViewModel,
|
trueHemeTestViewModel,
|
||||||
recyclerViewOptions,
|
recyclerViewOptions,
|
||||||
it,
|
it,
|
||||||
batLevel,
|
batLevel,
|
||||||
@@ -964,7 +1020,7 @@ class HomeFragment : Fragment() {
|
|||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
hemoCubeViewModel,
|
trueHemeTestViewModel,
|
||||||
recyclerViewOptions,
|
recyclerViewOptions,
|
||||||
it,
|
it,
|
||||||
batLevel,
|
batLevel,
|
||||||
@@ -1040,7 +1096,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUnprocessedCSVData() {
|
private fun checkUnprocessedCSVData() {
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
val downloadDataVisibility =
|
val downloadDataVisibility =
|
||||||
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.VISIBLE else View.GONE
|
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||||
@@ -1161,7 +1217,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun downloadLocalDBData(dialog: DialogInterface) {
|
private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||||
var csvDownloaded = false
|
var csvDownloaded = false
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
|
|
||||||
//
|
//
|
||||||
// userDataList.forEach { userData ->
|
// userDataList.forEach { userData ->
|
||||||
@@ -1200,7 +1256,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
if (downloadList.isNotEmpty()) {
|
if (downloadList.isNotEmpty()) {
|
||||||
// Call ViewModel function to create CSV with filtered data
|
// Call ViewModel function to create CSV with filtered data
|
||||||
hemoCubeViewModel.createCSV(downloadList, requireContext())
|
trueHemeTestViewModel.createCSV(downloadList, requireContext())
|
||||||
csvDownloaded = true
|
csvDownloaded = true
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
@@ -1232,19 +1288,19 @@ class HomeFragment : Fragment() {
|
|||||||
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
||||||
userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
if (userData._id.isEmpty()) {
|
if (userData._id.isEmpty()) {
|
||||||
hemoCubeViewModel.deleteById(userData._id)
|
trueHemeTestViewModel.deleteById(userData._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
hemoCubeViewModel.networkStatusLiveData.removeObservers(viewLifecycleOwner)
|
trueHemeTestViewModel.networkStatusLiveData.removeObservers(viewLifecycleOwner)
|
||||||
hemoCubeViewModel.allKitTestData.removeObservers(viewLifecycleOwner)
|
trueHemeTestViewModel.allKitTestData.removeObservers(viewLifecycleOwner)
|
||||||
hemoCubeViewModel.allUserData.removeObservers(viewLifecycleOwner)
|
trueHemeTestViewModel.allUserData.removeObservers(viewLifecycleOwner)
|
||||||
hemoCubeViewModel.uploadLogs.removeObservers(viewLifecycleOwner)
|
trueHemeTestViewModel.uploadLogs.removeObservers(viewLifecycleOwner)
|
||||||
hemoCubeViewModel.checkUpdate.removeObservers(viewLifecycleOwner)
|
trueHemeTestViewModel.checkUpdate.removeObservers(viewLifecycleOwner)
|
||||||
hemoCubeViewModel.downloadcertificate.removeObservers(viewLifecycleOwner)
|
trueHemeTestViewModel.downloadcertificate.removeObservers(viewLifecycleOwner)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadCsv() {
|
private fun downloadCsv() {
|
||||||
@@ -1620,10 +1676,10 @@ class HomeFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
trueHemeTestViewModel.login(createLoginRequestData(userID, password))
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
trueHemeTestViewModel.login(createLoginRequestData(userID, password))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun timeDifference(createdAt: String): Long {
|
private fun timeDifference(createdAt: String): Long {
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -23,7 +23,6 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
@@ -33,29 +32,22 @@ import androidx.navigation.ui.AppBarConfiguration
|
|||||||
import androidx.navigation.ui.navigateUp
|
import androidx.navigation.ui.navigateUp
|
||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import com.example.hpostesting.util.Result
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.model.login.LoginRequest
|
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.presentation.utils.NatsManager
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.presentation.jig.JigActivity
|
import com.example.hpostesting.presentation.jig.JigActivity
|
||||||
|
import com.example.hpostesting.presentation.utils.NatsManager
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
|
||||||
import com.google.firebase.ktx.Firebase
|
|
||||||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
|
||||||
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
|
||||||
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.BuildConfig
|
import `in`.sminnovations.hpostesting.BuildConfig
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
interface NatsMessageCallback {
|
interface NatsMessageCallback {
|
||||||
fun onMessageReceived(topic: String, message: String)
|
fun onMessageReceived(topic: String, message: String)
|
||||||
@@ -68,7 +60,8 @@ open interface IDataCollector: NatsMessageCallback {
|
|||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||||
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
@Inject
|
||||||
|
lateinit var databaseRepository: DatabaseRepository
|
||||||
val TAG = "DashboardActivity"
|
val TAG = "DashboardActivity"
|
||||||
private var isRegistered = false
|
private var isRegistered = false
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
@@ -76,9 +69,10 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
lateinit var sharedPreferences: SharedPreferences
|
lateinit var sharedPreferences: SharedPreferences
|
||||||
var responses: String = ""
|
var responses: String = ""
|
||||||
lateinit var nats: NatsManager
|
lateinit var nats: NatsManager
|
||||||
|
|
||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
// TODO: Remove hemocube viewmodel
|
// TODO: Remove hemocube viewmodel
|
||||||
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
private val hemocubeViewModel: TrueHemeTestViewModel by viewModels()
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
@@ -86,6 +80,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
super.attachBaseContext(newBase)
|
super.attachBaseContext(newBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onMessageReceived(topic: String, message: String) {
|
override fun onMessageReceived(topic: String, message: String) {
|
||||||
// Handle incoming messages from NATS
|
// Handle incoming messages from NATS
|
||||||
|
|
||||||
@@ -95,11 +90,15 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
@SuppressLint("SetWorldReadable")
|
@SuppressLint("SetWorldReadable")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
val firebaseManager = FirebaseManager(this)
|
||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
nats = NatsManager(this)
|
nats = NatsManager(this)
|
||||||
|
|
||||||
|
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
nats.connect()
|
nats.connect()
|
||||||
}
|
}
|
||||||
@@ -108,7 +107,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
Log.d("DashboardActivity", "Saved Kit Serial: $savedKitSerial")
|
Log.d("DashboardActivity", "Saved Kit Serial: $savedKitSerial")
|
||||||
// Toast.makeText(this, "Saved Kit Serial: $savedKitSerial", Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this, "Saved Kit Serial: $savedKitSerial", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) + " ]"
|
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) +"->"+currentServer+"]"
|
||||||
binding.appBarDashboard.versionName.text = versionName
|
binding.appBarDashboard.versionName.text = versionName
|
||||||
|
|
||||||
|
|
||||||
@@ -117,90 +116,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
nats.sub("server.hpos.${deviceId}.ping")
|
nats.sub("server.hpos.${deviceId}.ping")
|
||||||
nats.pub("server.hpos.${deviceId}.ping", "THIS IS A TEST MSG")
|
nats.pub("server.hpos.${deviceId}.ping", "THIS IS A TEST MSG")
|
||||||
|
|
||||||
val configSettings = remoteConfigSettings {
|
|
||||||
minimumFetchIntervalInSeconds = 3600
|
|
||||||
}
|
|
||||||
remoteConfig.setConfigSettingsAsync(configSettings)
|
|
||||||
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
|
|
||||||
|
|
||||||
remoteConfig.fetchAndActivate()
|
|
||||||
.addOnCompleteListener(this) { task ->
|
|
||||||
if (task.isSuccessful) {
|
|
||||||
val normalMin2mm = remoteConfig.getDouble("normalMin2mm")
|
|
||||||
val normalMax2mm = remoteConfig.getDouble("normalMax2mm")
|
|
||||||
val negativeBorderlineMin2mm = remoteConfig.getDouble("negativeBorderlineMin2mm")
|
|
||||||
val negativeBorderlineMax2mm = remoteConfig.getDouble("negativeBorderlineMax2mm")
|
|
||||||
val positiveForSickleCellMin2mm = remoteConfig.getDouble("positiveForSickleCellMin2mm")
|
|
||||||
val positiveForSickleCellMax2mm = remoteConfig.getDouble("positiveForSickleCellMax2mm")
|
|
||||||
val sickleCellTraitMin2mm = remoteConfig.getDouble("sickleCellTraitMin2mm")
|
|
||||||
val sickleCellTraitMax2mm = remoteConfig.getDouble("sickleCellTraitMax2mm")
|
|
||||||
val sickleCellDiseaseMin2mm = remoteConfig.getDouble("sickleCellDiseaseMin2mm")
|
|
||||||
val sickleCellDiseaseMax2mm = remoteConfig.getDouble("sickleCellDiseaseMax2mm")
|
|
||||||
val positiveBoderLine2mm1 = remoteConfig.getDouble("positiveBoderLine2mm1")
|
|
||||||
val positiveBoderLine2mm2 = remoteConfig.getDouble("positiveBoderLine2mm2")
|
|
||||||
val negativeBoderLine2mm1 = remoteConfig.getDouble("negativeBoderLine2mm1")
|
|
||||||
val negativeBoderLine2mm2 = remoteConfig.getDouble("negativeBoderLine2mm2")
|
|
||||||
|
|
||||||
val normalMin10mm = remoteConfig.getDouble("normalMin10mm")
|
|
||||||
val normalMax10mm = remoteConfig.getDouble("normalMax10mm")
|
|
||||||
val negativeBorderlineMin10mm = remoteConfig.getDouble("negativeBorderlineMin10mm")
|
|
||||||
val negativeBorderlineMax10mm = remoteConfig.getDouble("negativeBorderlineMax10mm")
|
|
||||||
val positiveForSickleCellMin10mm = remoteConfig.getDouble("positiveForSickleCellMin10mm")
|
|
||||||
val positiveForSickleCellMax10mm = remoteConfig.getDouble("positiveForSickleCellMax10mm")
|
|
||||||
val sickleCellTraitMin10mm = remoteConfig.getDouble("sickleCellTraitMin10mm")
|
|
||||||
val sickleCellTraitMax10mm = remoteConfig.getDouble("sickleCellTraitMax10mm")
|
|
||||||
val sickleCellDiseaseMin10mm = remoteConfig.getDouble("sickleCellDiseaseMin10mm")
|
|
||||||
val sickleCellDiseaseMax10mm = remoteConfig.getDouble("sickleCellDiseaseMax10mm")
|
|
||||||
val positiveBoderLine10mm1 = remoteConfig.getDouble("positiveBoderLine10mm1")
|
|
||||||
val positiveBoderLine10mm2 = remoteConfig.getDouble("positiveBoderLine10mm2")
|
|
||||||
val negativeBoderLine10mm1 = remoteConfig.getDouble("negativeBoderLine10mm1")
|
|
||||||
val negativeBoderLine10mm2 = remoteConfig.getDouble("negativeBoderLine10mm2")
|
|
||||||
|
|
||||||
val bufferMinLed1 = remoteConfig.getDouble("bufferMinLed1")
|
|
||||||
val bufferMaxLed1 = remoteConfig.getDouble("bufferMaxLed1")
|
|
||||||
val bufferMinLed2 = remoteConfig.getDouble("bufferMinLed2")
|
|
||||||
val bufferMaxLed2 = remoteConfig.getDouble("bufferMaxLed2")
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString("bufferMinLed1", bufferMinLed1.toString())
|
|
||||||
putString("bufferMaxLed1", bufferMaxLed1.toString())
|
|
||||||
putString("bufferMinLed2", bufferMinLed2.toString())
|
|
||||||
putString("bufferMaxLed2", bufferMaxLed2.toString())//buffer
|
|
||||||
putString("normalMin2mm", normalMin2mm.toString())//2mm
|
|
||||||
putString("normalMax2mm", normalMax2mm.toString())
|
|
||||||
putString("negativeBorderlineMin2mm", negativeBorderlineMin2mm.toString())
|
|
||||||
putString("negativeBorderlineMax2mm", negativeBorderlineMax2mm.toString())
|
|
||||||
putString("positiveForSickleCellMin2mm", positiveForSickleCellMin2mm.toString())
|
|
||||||
putString("positiveForSickleCellMax2mm", positiveForSickleCellMax2mm.toString())
|
|
||||||
putString("sickleCellTraitMin2mm", sickleCellTraitMin2mm.toString())
|
|
||||||
putString("sickleCellTraitMax2mm", sickleCellTraitMax2mm.toString())
|
|
||||||
putString("sickleCellDiseaseMin2mm", sickleCellDiseaseMin2mm.toString())
|
|
||||||
putString("sickleCellDiseaseMax2mm", sickleCellDiseaseMax2mm.toString())
|
|
||||||
putString("positiveBoderLine2mm1", positiveBoderLine2mm1.toString())
|
|
||||||
putString("positiveBoderLine2mm2", positiveBoderLine2mm2.toString())
|
|
||||||
putString("negativeBoderLine2mm1", negativeBoderLine2mm1.toString())
|
|
||||||
putString("negativeBoderLine2mm2", negativeBoderLine2mm2.toString())//2mm
|
|
||||||
putString("normalMin10mm", normalMin10mm.toString())//10mm
|
|
||||||
putString("normalMax10mm", normalMax10mm.toString())
|
|
||||||
putString("negativeBorderlineMin10mm", negativeBorderlineMin10mm.toString())
|
|
||||||
putString("negativeBorderlineMax10mm", negativeBorderlineMax10mm.toString())
|
|
||||||
putString("positiveForSickleCellMin10mm", positiveForSickleCellMin10mm.toString())
|
|
||||||
putString("positiveForSickleCellMax10mm", positiveForSickleCellMax10mm.toString())
|
|
||||||
putString("sickleCellTraitMin10mm", sickleCellTraitMin10mm.toString())
|
|
||||||
putString("sickleCellTraitMax10mm", sickleCellTraitMax10mm.toString())
|
|
||||||
putString("sickleCellDiseaseMin10mm", sickleCellDiseaseMin10mm.toString())
|
|
||||||
putString("sickleCellDiseaseMax10mm", sickleCellDiseaseMax10mm.toString())
|
|
||||||
putString("positiveBoderLine10mm1", positiveBoderLine10mm1.toString())
|
|
||||||
putString("positiveBoderLine10mm2", positiveBoderLine10mm2.toString())
|
|
||||||
putString("negativeBoderLine10mm1", negativeBoderLine10mm1.toString())
|
|
||||||
putString("negativeBoderLine10mm2", negativeBoderLine10mm2.toString())//10mm
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Config params updated")
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Config params Fetch failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hemocubeViewModel.deviceUpdate.observe(this) {
|
hemocubeViewModel.deviceUpdate.observe(this) {
|
||||||
Log.d("DashboardLogs",it.toString())
|
Log.d("DashboardLogs",it.toString())
|
||||||
|
|
||||||
@@ -250,6 +165,12 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fun sendData(data:String){ this was used to send the basic data for server validation
|
||||||
|
// databaseRepository.addtodb(data)
|
||||||
|
// Toast.makeText(this, "data uploaded", Toast.LENGTH_SHORT).show()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.dashboard, menu)
|
menuInflater.inflate(R.menu.dashboard, menu)
|
||||||
@@ -375,6 +296,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
return try {
|
return try {
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
pInfo.versionName
|
pInfo.versionName
|
||||||
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
"N/A"
|
"N/A"
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
@@ -25,19 +25,20 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.presentation.reportgen.ReportActivity
|
||||||
import com.example.hpostesting.presentation.autodac.AutoDacActivity
|
import com.example.hpostesting.presentation.autodac.AutoDacActivity
|
||||||
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
||||||
import com.example.hpostesting.presentation.calibration.CalibrationActivity
|
import com.example.hpostesting.presentation.calibration.CalibrationActivity
|
||||||
import com.example.hpostesting.presentation.dashboard.ui.PasswordResetActivity
|
import com.example.hpostesting.presentation.main_base.ui.PasswordResetActivity
|
||||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||||
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
||||||
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity
|
import com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
||||||
|
|
||||||
|
|
||||||
class GalleryFragment : Fragment() {
|
class PanelFragment : Fragment() {
|
||||||
|
|
||||||
private var _binding: FragmentGalleryBinding? = null
|
private var _binding: FragmentGalleryBinding? = null
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
@@ -49,7 +50,7 @@ class GalleryFragment : Fragment() {
|
|||||||
|
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
@@ -89,6 +90,7 @@ class GalleryFragment : Fragment() {
|
|||||||
binding.btnDeviceInfo.visibility = View.VISIBLE
|
binding.btnDeviceInfo.visibility = View.VISIBLE
|
||||||
binding.btnResetPassword.visibility = View.VISIBLE
|
binding.btnResetPassword.visibility = View.VISIBLE
|
||||||
binding.btnUpdateValues.visibility = View.VISIBLE
|
binding.btnUpdateValues.visibility = View.VISIBLE
|
||||||
|
binding.btnPrintReport.visibility = View.GONE
|
||||||
}else{
|
}else{
|
||||||
binding.btnResetPassword.visibility = View.GONE
|
binding.btnResetPassword.visibility = View.GONE
|
||||||
binding.btnDeviceProvision.visibility = View.GONE
|
binding.btnDeviceProvision.visibility = View.GONE
|
||||||
@@ -102,6 +104,7 @@ class GalleryFragment : Fragment() {
|
|||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.visibility = View.GONE
|
||||||
binding.btnDeviceInfo.visibility = View.VISIBLE
|
binding.btnDeviceInfo.visibility = View.VISIBLE
|
||||||
binding.btnUpdateValues.visibility = View.GONE
|
binding.btnUpdateValues.visibility = View.GONE
|
||||||
|
binding.btnPrintReport.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnResetPassword.setOnClickListener{
|
binding.btnResetPassword.setOnClickListener{
|
||||||
@@ -136,12 +139,17 @@ class GalleryFragment : Fragment() {
|
|||||||
startActivity(Intent(requireContext(), DeviceActivity::class.java))
|
startActivity(Intent(requireContext(), DeviceActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.btnPrintReport.setOnClickListener{
|
||||||
|
startActivity(Intent(requireContext(), ReportActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
binding.btnFirefox.setOnClickListener {
|
binding.btnFirefox.setOnClickListener {
|
||||||
val intent = Intent(Intent.ACTION_VIEW)
|
val intent = Intent(Intent.ACTION_VIEW)
|
||||||
intent.component = ComponentName("org.mozilla.firefox", "org.mozilla.gecko.BrowserApp")
|
intent.component = ComponentName("org.mozilla.firefox", "org.mozilla.gecko.BrowserApp")
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnFiles.setOnClickListener {
|
binding.btnFiles.setOnClickListener {
|
||||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||||
intent.type = "file/*"
|
intent.type = "file/*"
|
||||||
@@ -0,0 +1,337 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
import androidx.preference.Preference
|
||||||
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import com.example.hpostesting.firebase.FirebaseConfig
|
||||||
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
||||||
|
|
||||||
|
|
||||||
|
private var isLanguageChanged = false
|
||||||
|
|
||||||
|
class SlideshowFragment : Fragment() {
|
||||||
|
private var selectedItem = "10mm"
|
||||||
|
private val values = arrayOf("10mm", "2mm")
|
||||||
|
private lateinit var binding: FragmentSlideshowBinding
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
||||||
|
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME, ""))
|
||||||
|
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE, "10mm").toString()
|
||||||
|
binding.btnGo.setOnClickListener {
|
||||||
|
var labname = binding.nameEditText.text.toString()
|
||||||
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
|
this.labName = labname
|
||||||
|
}
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.LABNAME, labname)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(), "Lab Name is Added successfully.", Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, values)
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
val pos: Int
|
||||||
|
if (selectedItem == "10mm") {
|
||||||
|
pos = 0
|
||||||
|
} else {
|
||||||
|
pos = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.spinnerCuvette.adapter = adapter
|
||||||
|
binding.spinnerCuvette.onItemSelectedListener =
|
||||||
|
object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
||||||
|
) {
|
||||||
|
// Handle item selection here
|
||||||
|
selectedItem = values[position]
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.spinnerCuvette.setSelection(pos)
|
||||||
|
binding.btnAddSize.setOnClickListener {
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.CUVETTE_SIZE, selectedItem)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(), "Selected cuvette size: $selectedItem", Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
childFragmentManager.beginTransaction().replace(binding.container.id, PrefsFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PrefsFragment : PreferenceFragmentCompat() {
|
||||||
|
private lateinit var tapManager: AppVersionTapManager
|
||||||
|
private lateinit var serverPreference: Preference
|
||||||
|
private lateinit var currentServerPreference: Preference
|
||||||
|
lateinit var firebaseManager: FirebaseManager
|
||||||
|
private var topDevMode = false
|
||||||
|
lateinit var databaseRepository: DatabaseRepository
|
||||||
|
|
||||||
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
firebaseManager = FirebaseManager(requireContext())
|
||||||
|
databaseRepository = (activity as DashboardActivity).databaseRepository
|
||||||
|
tapManager = AppVersionTapManager()
|
||||||
|
topDevMode = firebaseManager.getDevMode()
|
||||||
|
val sharedPreference =
|
||||||
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||||
|
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||||
|
|
||||||
|
|
||||||
|
// Language Preference
|
||||||
|
val languagePreference = ListPreference(requireContext()).apply {
|
||||||
|
key = "language_preference"
|
||||||
|
title = getString(R.string.app_language)
|
||||||
|
summary = getString(R.string.select_language)
|
||||||
|
entries = arrayOf("English", "Kannada", "Hindi")
|
||||||
|
entryValues = arrayOf("en", "kn", "hi")
|
||||||
|
setDefaultValue("en")
|
||||||
|
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_translate_24)
|
||||||
|
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
|
val languageCode = newValue as String
|
||||||
|
updateLanguage(requireContext(), languageCode)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val servers = firebaseManager.getAvailableServers()
|
||||||
|
val serverNames = servers.map { it.serverName }.toTypedArray()
|
||||||
|
|
||||||
|
val serverSelectorPreference = CustomDialogPreference(requireContext()).apply {
|
||||||
|
key = "server_preference"
|
||||||
|
title = "Select the Server"
|
||||||
|
summary = "Current server: $currentServer"
|
||||||
|
setEntries(serverNames)
|
||||||
|
setEntryValues(serverNames)
|
||||||
|
setValue(currentServer)
|
||||||
|
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_sync_24)
|
||||||
|
setOnPreferenceChangeListener { newValue ->
|
||||||
|
val preferenceConfig = servers.find { it.serverName == newValue }
|
||||||
|
switchFirebaseServer(preferenceConfig!!)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add preferences to screen
|
||||||
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
|
||||||
|
|
||||||
|
val developerToggle = SwitchPreferenceCompat(requireContext()).apply {
|
||||||
|
title = "Developer Options"
|
||||||
|
summary = "Enable or disable developer options"
|
||||||
|
icon =
|
||||||
|
ContextCompat.getDrawable(requireContext(), R.drawable.baseline_developer_mode_24)
|
||||||
|
key = "developer_options" // Unique key for SharedPreferences
|
||||||
|
|
||||||
|
// Load toggle state from SharedPreferences
|
||||||
|
isChecked = firebaseManager.getDevMode()
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val isEnabled = newValue as Boolean
|
||||||
|
firebaseManager.setDevModeOn(isEnabled)
|
||||||
|
|
||||||
|
if (!isEnabled) {
|
||||||
|
preferenceScreen.removePreference(this)
|
||||||
|
preferenceScreen.removePreference(serverSelectorPreference)
|
||||||
|
}
|
||||||
|
if (!firebaseManager.getDevMode() && currentServer != "prod"){
|
||||||
|
val prodConfig = servers.find { it.serverName == "prod" }
|
||||||
|
switchFirebaseServer(prodConfig!!)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val appVersionPreference = Preference(requireContext()).apply {
|
||||||
|
title = "App Version"
|
||||||
|
summary =
|
||||||
|
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + "->" + currentServer + "]"
|
||||||
|
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
||||||
|
|
||||||
|
setOnPreferenceClickListener {
|
||||||
|
tapManager.registerTap {
|
||||||
|
firebaseManager.setDevModeOn(true)
|
||||||
|
|
||||||
|
|
||||||
|
if (firebaseManager.getDevMode() && currentServer != "dev") {
|
||||||
|
Toast.makeText(requireContext(), "Now you are a Developer", Toast.LENGTH_SHORT).show()
|
||||||
|
Toast.makeText(requireContext(), "Setting Up developer Environmnet", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preferenceScreen.findPreference<SwitchPreferenceCompat>("developer_options") == null) {
|
||||||
|
preferenceScreen.addPreference(developerToggle)
|
||||||
|
}
|
||||||
|
if (preferenceScreen.findPreference<ListPreference>("server_preference") == null) {
|
||||||
|
preferenceScreen.addPreference(serverSelectorPreference)
|
||||||
|
}
|
||||||
|
|
||||||
|
developerToggle.isChecked = true
|
||||||
|
updateServerPreference(currentServer)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
|
if (firebaseManager.getDevMode()) {
|
||||||
|
developerToggle.isChecked = true // Ensure it's checked
|
||||||
|
preferenceScreen.addPreference(developerToggle)
|
||||||
|
preferenceScreen.addPreference(serverSelectorPreference)
|
||||||
|
}
|
||||||
|
|
||||||
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
|
if (isLanguageChanged) {
|
||||||
|
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun updateServerPreference(newServer: String) {
|
||||||
|
(findPreference<CustomDialogPreference>("server_preference"))?.let { pref ->
|
||||||
|
pref.setValue(newServer)
|
||||||
|
pref.summary = "Current server: $newServer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun switchFirebaseServer(firebaseConfig: FirebaseConfig) {
|
||||||
|
firebaseManager.switchServer(firebaseConfig)
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Switched to ${firebaseConfig.serverName}, Please wait for few seconds",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
Toast.makeText(requireContext(), "Restart needed restarting the app", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
firebaseManager.restartApp()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateLanguage(context: Context, languageCode: String) {
|
||||||
|
LanguageManager.persistLanguagePreference(context, languageCode)
|
||||||
|
LanguageManager.setLocale(context, languageCode)
|
||||||
|
requireActivity().recreate()
|
||||||
|
isLanguageChanged = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getAppVersion(context: Context): String {
|
||||||
|
return try {
|
||||||
|
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
|
pInfo.versionName
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
"N/A"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getAppEnvironment(context: Context): String {
|
||||||
|
return try {
|
||||||
|
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
|
pInfo.packageName.substringAfterLast('.')
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
"N/A"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// CustomDialogPreference.kt
|
||||||
|
class CustomDialogPreference(context: Context) : Preference(context) {
|
||||||
|
private var entries: Array<String> = arrayOf()
|
||||||
|
private var entryValues: Array<String> = arrayOf()
|
||||||
|
private var currentValue: String = ""
|
||||||
|
private var onValueChangeListener: ((String) -> Boolean)? = null
|
||||||
|
|
||||||
|
fun setEntries(entries: Array<String>) {
|
||||||
|
this.entries = entries
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setEntryValues(values: Array<String>) {
|
||||||
|
this.entryValues = values
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setValue(value: String) {
|
||||||
|
currentValue = value
|
||||||
|
persistString(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setOnPreferenceChangeListener(listener: (String) -> Boolean) {
|
||||||
|
onValueChangeListener = listener
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick() {
|
||||||
|
val builder = MaterialAlertDialogBuilder(context)
|
||||||
|
builder.setTitle(title)
|
||||||
|
|
||||||
|
builder.setSingleChoiceItems(entries, entries.indexOf(currentValue)) { dialog, which ->
|
||||||
|
val newValue = entryValues[which]
|
||||||
|
if (onValueChangeListener?.invoke(newValue) == true) {
|
||||||
|
setValue(newValue)
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setNegativeButton("Cancel") { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,18 +11,13 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.enableEdgeToEdge
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityUpdateValuesBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityUpdateValuesBinding
|
||||||
|
|
||||||
class UpdateValuesActivity : AppCompatActivity() {
|
class UpdateValuesActivity : AppCompatActivity() {
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard.ui
|
package com.example.hpostesting.presentation.main_base.ui
|
||||||
|
|
||||||
import com.example.hpostesting.util.SecureStorage
|
import com.example.hpostesting.util.SecureStorage
|
||||||
import android.accounts.Account
|
import android.accounts.Account
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard.ui
|
package com.example.hpostesting.presentation.main_base.ui
|
||||||
|
|
||||||
import com.example.hpostesting.util.SecureStorage
|
import com.example.hpostesting.util.SecureStorage
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.example.hpostesting.presentation.reportgen
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import com.example.hpostesting.presentation.reportgen.ui.report.ReportFragment
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class ReportActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.report_gen)
|
||||||
|
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, ReportFragment()) //Direct constructor
|
||||||
|
.commitNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.example.hpostesting.presentation.reportgen.ui.report
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.cardview.widget.CardView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
|
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
class BufferAdapter(
|
||||||
|
private var dataList: List<HemoCubeTestData>,
|
||||||
|
private val onItemClick: (HemoCubeTestData) -> Unit
|
||||||
|
) : RecyclerView.Adapter<BufferAdapter.ViewHolder>() {
|
||||||
|
|
||||||
|
private var selectedItems: List<HemoCubeTestData> = emptyList()
|
||||||
|
|
||||||
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
val cardView: CardView = view.findViewById(R.id.cardView)
|
||||||
|
val sampleId: TextView = view.findViewById(R.id.sampleId)
|
||||||
|
val testTime: TextView = view.findViewById(R.id.testTime)
|
||||||
|
val result: TextView = view.findViewById(R.id.result)
|
||||||
|
val selectionIndicator: View = view.findViewById(R.id.selectionIndicator)
|
||||||
|
|
||||||
|
init {
|
||||||
|
cardView.setOnClickListener {
|
||||||
|
if (adapterPosition != RecyclerView.NO_POSITION) {
|
||||||
|
onItemClick(dataList[adapterPosition])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(
|
||||||
|
LayoutInflater.from(parent.context).inflate(R.layout.item_buffer_card, parent, false)
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
val item = dataList[position]
|
||||||
|
val isSelected = selectedItems.contains(item)
|
||||||
|
|
||||||
|
holder.sampleId.text = "Sample ID: ${item._id}"
|
||||||
|
holder.testTime.text = "Time: ${item.testTime}"
|
||||||
|
holder.result.text = "Result: ${item.classificationResult}"
|
||||||
|
|
||||||
|
// Update selection appearance
|
||||||
|
if (isSelected) {
|
||||||
|
holder.cardView.setCardBackgroundColor(Color.parseColor("#E3F2FD"))
|
||||||
|
holder.selectionIndicator.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
holder.cardView.setCardBackgroundColor(Color.WHITE)
|
||||||
|
holder.selectionIndicator.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = dataList.size
|
||||||
|
|
||||||
|
fun updateList(newList: List<HemoCubeTestData>) {
|
||||||
|
dataList = newList
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateSelectedItems(newSelectedItems: List<HemoCubeTestData>) {
|
||||||
|
selectedItems = newSelectedItems
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,329 @@
|
|||||||
|
package com.example.hpostesting.presentation.reportgen.ui.report
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.Typeface
|
||||||
|
import android.graphics.pdf.PdfDocument
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
|
object ReportGen {
|
||||||
|
|
||||||
|
private const val PAGE_WIDTH = 595 // A4 width in points
|
||||||
|
private const val PAGE_HEIGHT = 842 // A4 height in points
|
||||||
|
private const val MARGIN_LEFT = 50f
|
||||||
|
private const val MARGIN_RIGHT = 50f
|
||||||
|
private const val MARGIN_TOP = 80f
|
||||||
|
private const val MARGIN_BOTTOM = 80f
|
||||||
|
|
||||||
|
fun generate(context: Context, dataList: List<HemoCubeTestData>) {
|
||||||
|
if (dataList.isEmpty()) {
|
||||||
|
Toast.makeText(context, "No items selected for report generation", Toast.LENGTH_SHORT).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d("ReportGen", "Generating report for ${dataList.size} items")
|
||||||
|
|
||||||
|
val message = if (dataList.size == 1) {
|
||||||
|
"Report for kit ${dataList.first()._id} started."
|
||||||
|
} else {
|
||||||
|
"Report for ${dataList.size} kits started."
|
||||||
|
}
|
||||||
|
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
val pdfFile = createProfessionalPdfReport(context, dataList)
|
||||||
|
previewPdf(context, pdfFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createProfessionalPdfReport(context: Context, dataList: List<HemoCubeTestData>): File {
|
||||||
|
val timestamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
||||||
|
val file = File(context.getExternalFilesDir(null), "HemoCube_Report_$timestamp.pdf")
|
||||||
|
|
||||||
|
val pdfDocument = PdfDocument()
|
||||||
|
|
||||||
|
// Paint styles
|
||||||
|
val headerPaint = Paint().apply {
|
||||||
|
typeface = Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD)
|
||||||
|
textSize = 20f
|
||||||
|
color = Color.rgb(0, 102, 153) // Professional blue
|
||||||
|
}
|
||||||
|
|
||||||
|
val titlePaint = Paint().apply {
|
||||||
|
typeface = Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD)
|
||||||
|
textSize = 18f
|
||||||
|
color = Color.BLACK
|
||||||
|
}
|
||||||
|
|
||||||
|
val sectionHeaderPaint = Paint().apply {
|
||||||
|
typeface = Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD)
|
||||||
|
textSize = 14f
|
||||||
|
color = Color.rgb(0, 102, 153)
|
||||||
|
}
|
||||||
|
|
||||||
|
val contentPaint = Paint().apply {
|
||||||
|
textSize = 11f
|
||||||
|
color = Color.DKGRAY
|
||||||
|
}
|
||||||
|
|
||||||
|
val boldContentPaint = Paint().apply {
|
||||||
|
typeface = Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD)
|
||||||
|
textSize = 11f
|
||||||
|
color = Color.BLACK
|
||||||
|
}
|
||||||
|
|
||||||
|
val disclaimerPaint = Paint().apply {
|
||||||
|
textSize = 9f
|
||||||
|
color = Color.GRAY
|
||||||
|
typeface = Typeface.create(Typeface.DEFAULT, Typeface.ITALIC)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create one page per test data
|
||||||
|
dataList.forEachIndexed { index, testData ->
|
||||||
|
val pageInfo = PdfDocument.PageInfo.Builder(PAGE_WIDTH, PAGE_HEIGHT, index + 1).create()
|
||||||
|
val page = pdfDocument.startPage(pageInfo)
|
||||||
|
val canvas = page.canvas
|
||||||
|
|
||||||
|
drawPage(canvas, testData, index + 1, dataList.size,
|
||||||
|
headerPaint, titlePaint, sectionHeaderPaint,
|
||||||
|
contentPaint, boldContentPaint, disclaimerPaint,context)
|
||||||
|
|
||||||
|
pdfDocument.finishPage(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
pdfDocument.writeTo(FileOutputStream(file))
|
||||||
|
pdfDocument.close()
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawPage(
|
||||||
|
canvas: Canvas,
|
||||||
|
testData: HemoCubeTestData,
|
||||||
|
pageNumber: Int,
|
||||||
|
totalPages: Int,
|
||||||
|
headerPaint: Paint,
|
||||||
|
titlePaint: Paint,
|
||||||
|
sectionHeaderPaint: Paint,
|
||||||
|
contentPaint: Paint,
|
||||||
|
boldContentPaint: Paint,
|
||||||
|
disclaimerPaint: Paint,
|
||||||
|
context: Context
|
||||||
|
) {
|
||||||
|
var currentY = MARGIN_TOP
|
||||||
|
|
||||||
|
// Header with logo placeholder and title
|
||||||
|
drawHeader(canvas, headerPaint, titlePaint, currentY, context)
|
||||||
|
currentY += 100f
|
||||||
|
|
||||||
|
// Sample Information Section
|
||||||
|
currentY = drawSection(canvas, "SAMPLE INFORMATION", sectionHeaderPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Sample ID:", testData.sampleid.toString(), boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Blood Group:", testData.bloodGroup, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY += 15f
|
||||||
|
|
||||||
|
// Test Information Section
|
||||||
|
currentY = drawSection(canvas, "TEST INFORMATION", sectionHeaderPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Test ID:", testData._id, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Test Type:", testData.testType ?: "TrueHeme", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Test Time:", testData.testTime ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Incubation Time:", testData.incubationTime, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Kit Serial:", testData.kitSerial, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Device Serial:", testData.deviceSerialNumber, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY += 15f
|
||||||
|
|
||||||
|
// Test Results Section
|
||||||
|
currentY = drawSection(canvas, "TEST RESULTS", sectionHeaderPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Classification Result:", testData.classificationResult, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Device Ratio:", testData.deviceRatio?.toString() ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Calculated Ratio:", testData.calculatedRatio?.toString() ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Slope Ratio:", testData.slopeRatio?.toString() ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY += 15f
|
||||||
|
|
||||||
|
// LED Measurements Section
|
||||||
|
currentY = drawSection(canvas, "LED MEASUREMENTS", sectionHeaderPaint, currentY)
|
||||||
|
currentY = drawLEDData(canvas, testData, boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY += 15f
|
||||||
|
|
||||||
|
// Laboratory Information Section
|
||||||
|
currentY = drawSection(canvas, "LABORATORY INFORMATION", sectionHeaderPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Lab Name:", testData.labName ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "Center Name:", testData.centerName ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "District:", testData.district ?: "N/A", boldContentPaint, contentPaint, currentY)
|
||||||
|
currentY += 15f
|
||||||
|
|
||||||
|
// Footer with page number and disclaimer
|
||||||
|
drawFooter(canvas, pageNumber, totalPages, contentPaint, disclaimerPaint)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawHeader(canvas: Canvas, headerPaint: Paint, titlePaint: Paint, startY: Float, context: Context) {
|
||||||
|
// Load and draw actual logo
|
||||||
|
try {
|
||||||
|
// Method 1: Load from drawable resources
|
||||||
|
val logoDrawable = ContextCompat.getDrawable(context, R.mipmap.hpos_icon) // Replace with your logo resource
|
||||||
|
logoDrawable?.let { drawable ->
|
||||||
|
val logoWidth = 70
|
||||||
|
val logoHeight = 60
|
||||||
|
drawable.setBounds(
|
||||||
|
MARGIN_LEFT.toInt(),
|
||||||
|
(startY - 20f).toInt(),
|
||||||
|
(MARGIN_LEFT + logoWidth).toInt(),
|
||||||
|
(startY + logoHeight - 20f).toInt()
|
||||||
|
)
|
||||||
|
drawable.draw(canvas)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Fallback to placeholder if logo loading fails
|
||||||
|
val logoPaint = Paint().apply {
|
||||||
|
color = Color.rgb(0, 102, 153)
|
||||||
|
style = Paint.Style.FILL
|
||||||
|
}
|
||||||
|
canvas.drawRect(MARGIN_LEFT, startY - 20f, MARGIN_LEFT + 60f, startY + 20f, logoPaint)
|
||||||
|
|
||||||
|
// Draw "LOGO" text as placeholder
|
||||||
|
val placeholderPaint = Paint().apply {
|
||||||
|
color = Color.WHITE
|
||||||
|
textSize = 12f
|
||||||
|
typeface = Typeface.create(Typeface.DEFAULT_BOLD, Typeface.BOLD)
|
||||||
|
textAlign = Paint.Align.CENTER
|
||||||
|
}
|
||||||
|
canvas.drawText("LOGO", MARGIN_LEFT + 30f, startY, placeholderPaint)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Company name and title
|
||||||
|
canvas.drawText("HemoCube", MARGIN_LEFT + 80f, startY + 10f, headerPaint)
|
||||||
|
canvas.drawText("Medical Test Report", MARGIN_LEFT, startY + 40f, titlePaint)
|
||||||
|
|
||||||
|
// Report generation date
|
||||||
|
val currentDate = SimpleDateFormat("dd MMM yyyy, HH:mm", Locale.getDefault()).format(Date())
|
||||||
|
canvas.drawText("Generated: $currentDate", PAGE_WIDTH - MARGIN_RIGHT - 150f, startY + 10f, Paint().apply {
|
||||||
|
textSize = 10f
|
||||||
|
color = Color.GRAY
|
||||||
|
})
|
||||||
|
|
||||||
|
// Line under header
|
||||||
|
val linePaint = Paint().apply {
|
||||||
|
color = Color.rgb(0, 102, 153)
|
||||||
|
strokeWidth = 2f
|
||||||
|
}
|
||||||
|
canvas.drawLine(MARGIN_LEFT, startY + 60f, PAGE_WIDTH - MARGIN_RIGHT, startY + 60f, linePaint)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawSection(canvas: Canvas, title: String, paint: Paint, y: Float): Float {
|
||||||
|
canvas.drawText(title, MARGIN_LEFT, y, paint)
|
||||||
|
|
||||||
|
// Underline for section
|
||||||
|
val linePaint = Paint().apply {
|
||||||
|
color = Color.rgb(0, 102, 153)
|
||||||
|
strokeWidth = 1f
|
||||||
|
}
|
||||||
|
canvas.drawLine(MARGIN_LEFT, y + 5f, MARGIN_LEFT + paint.measureText(title), y + 5f, linePaint)
|
||||||
|
|
||||||
|
return y + 25f
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawKeyValuePair(canvas: Canvas, key: String, value: String, keyPaint: Paint, valuePaint: Paint, y: Float): Float {
|
||||||
|
canvas.drawText(key, MARGIN_LEFT + 10f, y, keyPaint)
|
||||||
|
canvas.drawText(value, MARGIN_LEFT + 150f, y, valuePaint)
|
||||||
|
return y + 18f
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawLEDData(canvas: Canvas, testData: HemoCubeTestData, keyPaint: Paint, valuePaint: Paint, startY: Float): Float {
|
||||||
|
var currentY = startY
|
||||||
|
|
||||||
|
currentY = drawKeyValuePair(canvas, "LED1 Sample:", testData.led1Sample?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "LED2 Sample:", testData.led2Sample?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "LED3 Sample:", testData.led3Sample?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "LED4 Sample:", testData.led4Sample?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
|
||||||
|
currentY = drawKeyValuePair(canvas, "ABS1:", testData.abs1?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "ABS2:", testData.abs2?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "ABS3:", testData.abs3?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
currentY = drawKeyValuePair(canvas, "ABS4:", testData.abs4?.toString() ?: "N/A", keyPaint, valuePaint, currentY)
|
||||||
|
|
||||||
|
return currentY
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawFooter(canvas: Canvas, pageNumber: Int, totalPages: Int, contentPaint: Paint, disclaimerPaint: Paint) {
|
||||||
|
val footerY = PAGE_HEIGHT - MARGIN_BOTTOM + 20f
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
canvas.drawText("Page $pageNumber of $totalPages", PAGE_WIDTH - MARGIN_RIGHT - 80f, footerY, contentPaint)
|
||||||
|
|
||||||
|
// Disclaimer
|
||||||
|
val disclaimerText = "DISCLAIMER: This report is generated by HemoCube automated system. " +
|
||||||
|
"Results should be interpreted by qualified medical professionals. " +
|
||||||
|
"This report is for diagnostic purposes only and should not be used as the sole basis for medical decisions. " +
|
||||||
|
"Please consult with your healthcare provider for proper interpretation and treatment recommendations."
|
||||||
|
|
||||||
|
val disclaimerLines = wrapText(disclaimerText, disclaimerPaint, PAGE_WIDTH - MARGIN_LEFT - MARGIN_RIGHT)
|
||||||
|
var disclaimerY = footerY + 20f
|
||||||
|
|
||||||
|
disclaimerLines.forEach { line ->
|
||||||
|
canvas.drawText(line, MARGIN_LEFT, disclaimerY, disclaimerPaint)
|
||||||
|
disclaimerY += 12f
|
||||||
|
}
|
||||||
|
|
||||||
|
// Footer line
|
||||||
|
val linePaint = Paint().apply {
|
||||||
|
color = Color.rgb(0, 102, 153)
|
||||||
|
strokeWidth = 1f
|
||||||
|
}
|
||||||
|
canvas.drawLine(MARGIN_LEFT, footerY - 10f, PAGE_WIDTH - MARGIN_RIGHT, footerY - 10f, linePaint)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun wrapText(text: String, paint: Paint, maxWidth: Float): List<String> {
|
||||||
|
val words = text.split(" ")
|
||||||
|
val lines = mutableListOf<String>()
|
||||||
|
var currentLine = ""
|
||||||
|
|
||||||
|
for (word in words) {
|
||||||
|
val testLine = if (currentLine.isEmpty()) word else "$currentLine $word"
|
||||||
|
if (paint.measureText(testLine) <= maxWidth) {
|
||||||
|
currentLine = testLine
|
||||||
|
} else {
|
||||||
|
if (currentLine.isNotEmpty()) {
|
||||||
|
lines.add(currentLine)
|
||||||
|
}
|
||||||
|
currentLine = word
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine.isNotEmpty()) {
|
||||||
|
lines.add(currentLine)
|
||||||
|
}
|
||||||
|
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun previewPdf(context: Context, file: File) {
|
||||||
|
val uri = FileProvider.getUriForFile(
|
||||||
|
context,
|
||||||
|
"${context.packageName}.fileprovider",
|
||||||
|
file
|
||||||
|
)
|
||||||
|
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||||
|
setDataAndType(uri, "application/pdf")
|
||||||
|
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NO_HISTORY
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
context.startActivity(intent)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
Toast.makeText(context, "No PDF viewer found", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
package com.example.hpostesting.presentation.reportgen.ui.report
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.Typeface
|
||||||
|
import android.graphics.pdf.PdfDocument
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.Spinner
|
||||||
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import androidx.core.widget.addTextChangedListener
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.presentation.reportgen.viewModel.ReportViewModel
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class ReportFragment : Fragment() {
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = ReportFragment()
|
||||||
|
}
|
||||||
|
private val viewModel: ReportViewModel by viewModels()
|
||||||
|
private lateinit var recyclerView: RecyclerView
|
||||||
|
private lateinit var searchBar: EditText
|
||||||
|
private lateinit var filterSpinner: Spinner
|
||||||
|
private lateinit var generateBtn: Button
|
||||||
|
private lateinit var selectedCountText: TextView
|
||||||
|
private lateinit var calendarButton: Button
|
||||||
|
|
||||||
|
private lateinit var adapter: BufferAdapter
|
||||||
|
private var selectedItems: MutableList<HemoCubeTestData> = mutableListOf()
|
||||||
|
private var allData: List<HemoCubeTestData> = emptyList()
|
||||||
|
private var currentFilter = "Today"
|
||||||
|
private var customDate: String? = null
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
|
): View = inflater.inflate(R.layout.fragment_report, container, false)
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
initViews(view)
|
||||||
|
setupRecyclerView()
|
||||||
|
setupFilterSpinner()
|
||||||
|
setupObservers()
|
||||||
|
setupListeners()
|
||||||
|
|
||||||
|
// default filter to Today
|
||||||
|
setDefaultFilter()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initViews(view: View) {
|
||||||
|
recyclerView = view.findViewById(R.id.bufferRecyclerView)
|
||||||
|
searchBar = view.findViewById(R.id.searchBar)
|
||||||
|
filterSpinner = view.findViewById(R.id.filterSpinner)
|
||||||
|
generateBtn = view.findViewById(R.id.generateReportButton)
|
||||||
|
selectedCountText = view.findViewById(R.id.selectedCountText)
|
||||||
|
calendarButton = view.findViewById(R.id.calendarButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupRecyclerView() {
|
||||||
|
recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
adapter = BufferAdapter(emptyList()) { item ->
|
||||||
|
toggleItemSelection(item)
|
||||||
|
updateUI()
|
||||||
|
}
|
||||||
|
recyclerView.adapter = adapter
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupFilterSpinner() {
|
||||||
|
val filterOptions = arrayOf("Today", "Yesterday", "All", "Custom Date")
|
||||||
|
val spinnerAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, filterOptions)
|
||||||
|
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
filterSpinner.adapter = spinnerAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setDefaultFilter() {
|
||||||
|
filterSpinner.setSelection(0) // Today
|
||||||
|
currentFilter = "Today"
|
||||||
|
calendarButton.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupObservers() {
|
||||||
|
viewModel.allKitTestData.observe(viewLifecycleOwner) { list ->
|
||||||
|
allData = list
|
||||||
|
filterList(searchBar.text.toString(), currentFilter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupListeners() {
|
||||||
|
searchBar.addTextChangedListener { editable ->
|
||||||
|
filterList(editable.toString(), currentFilter)
|
||||||
|
}
|
||||||
|
|
||||||
|
filterSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>, view: View?, pos: Int, id: Long) {
|
||||||
|
currentFilter = parent.getItemAtPosition(pos).toString()
|
||||||
|
|
||||||
|
if (currentFilter == "Custom Date") {
|
||||||
|
calendarButton.visibility = View.VISIBLE
|
||||||
|
if (customDate == null) {
|
||||||
|
showDatePicker()
|
||||||
|
} else {
|
||||||
|
filterList(searchBar.text.toString(), currentFilter)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
calendarButton.visibility = View.GONE
|
||||||
|
customDate = null
|
||||||
|
filterList(searchBar.text.toString(), currentFilter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(p0: AdapterView<*>?) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
calendarButton.setOnClickListener {
|
||||||
|
showDatePicker()
|
||||||
|
}
|
||||||
|
|
||||||
|
generateBtn.setOnClickListener {
|
||||||
|
if (selectedItems.isNotEmpty()) {
|
||||||
|
ReportGen.generate(requireContext(), selectedItems)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showDatePicker() {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
val year = calendar.get(Calendar.YEAR)
|
||||||
|
val month = calendar.get(Calendar.MONTH)
|
||||||
|
val day = calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
|
||||||
|
DatePickerDialog(requireContext(), { _, selectedYear, selectedMonth, selectedDay ->
|
||||||
|
val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
|
val selectedCalendar = Calendar.getInstance()
|
||||||
|
selectedCalendar.set(selectedYear, selectedMonth, selectedDay)
|
||||||
|
customDate = sdf.format(selectedCalendar.time)
|
||||||
|
|
||||||
|
// Update calendar button text
|
||||||
|
val displayFormat = SimpleDateFormat("MMM dd, yyyy", Locale.getDefault())
|
||||||
|
calendarButton.text = displayFormat.format(selectedCalendar.time)
|
||||||
|
|
||||||
|
filterList(searchBar.text.toString(), currentFilter)
|
||||||
|
}, year, month, day).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toggleItemSelection(item: HemoCubeTestData) {
|
||||||
|
if (selectedItems.contains(item)) {
|
||||||
|
selectedItems.remove(item)
|
||||||
|
} else {
|
||||||
|
selectedItems.add(item)
|
||||||
|
}
|
||||||
|
adapter.updateSelectedItems(selectedItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateUI() {
|
||||||
|
selectedCountText.text = "Selected: ${selectedItems.size}"
|
||||||
|
generateBtn.visibility = if (selectedItems.isNotEmpty()) View.VISIBLE else View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun filterList(query: String, filter: String) {
|
||||||
|
val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
|
val today = sdf.format(Date())
|
||||||
|
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, -1)
|
||||||
|
val yesterday = sdf.format(calendar.time)
|
||||||
|
|
||||||
|
val filtered = allData.filter { item ->
|
||||||
|
val matchesSearch = item._id.contains(query, true) ||
|
||||||
|
item.classificationResult.contains(query, true)
|
||||||
|
val matchesDate = when (filter) {
|
||||||
|
"Today" -> item.testTime?.contains(today)
|
||||||
|
"Yesterday" -> item.testTime?.contains(yesterday)
|
||||||
|
"Custom Date" -> customDate?.let { item.testTime?.contains(it) } ?: true
|
||||||
|
"All" -> true
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
|
||||||
|
matchesSearch && matchesDate ?: true
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter.updateList(filtered)
|
||||||
|
|
||||||
|
// Clear selections if items are no longer visible
|
||||||
|
selectedItems.removeAll { selectedItem ->
|
||||||
|
!filtered.contains(selectedItem)
|
||||||
|
}
|
||||||
|
adapter.updateSelectedItems(selectedItems)
|
||||||
|
updateUI()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
package com.example.hpostesting.presentation.reportgen.viewModel
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
|
@HiltViewModel
|
||||||
|
class ReportViewModel @Inject constructor(
|
||||||
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
|
) : ViewModel() {
|
||||||
|
// val allKitTestData: LiveData<List<HemoCubeTestData>> = hemoCubeDao.getAll()
|
||||||
|
val allKitTestData = MutableLiveData<List<HemoCubeTestData>>()
|
||||||
|
init {
|
||||||
|
loadTestData()
|
||||||
|
}
|
||||||
|
private fun loadTestData() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
val data = hemoCubeDao.getAll()
|
||||||
|
if (data.value.isNullOrEmpty()) {
|
||||||
|
allKitTestData.value = dummyDataList
|
||||||
|
} else {
|
||||||
|
allKitTestData.value = data.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val dummyDataList = listOf(
|
||||||
|
HemoCubeTestData(
|
||||||
|
sampleid = 1,
|
||||||
|
_id = "ID001",
|
||||||
|
name = "John Doe",
|
||||||
|
incubationTime = "15 mins",
|
||||||
|
bloodGroup = "A+",
|
||||||
|
age = "30",
|
||||||
|
state = "Karnataka",
|
||||||
|
abhaId = "ABHA123456",
|
||||||
|
userImageURL = "https://example.com/image1.jpg",
|
||||||
|
location = UserData.Location(latitude = 12.9716, longitude = 77.5946),
|
||||||
|
reportUploadTime = "2025-07-20T10:30:00",
|
||||||
|
testTime = "2025-07-20T10:00:00",
|
||||||
|
gender = "Male",
|
||||||
|
classificationResult = "Normal",
|
||||||
|
prdClassification = "Class A",
|
||||||
|
deviceSerialNumber = "SN123456",
|
||||||
|
deviceId = "DEVICE001",
|
||||||
|
appVersion = "1.2.3",
|
||||||
|
kitSerial = "KIT001",
|
||||||
|
resultData = "{\"hb\":13.5}",
|
||||||
|
led1Buffer = 0.95,
|
||||||
|
led2Buffer = 1.01,
|
||||||
|
led3Buffer = 0.98,
|
||||||
|
led4Buffer = 1.02,
|
||||||
|
led1Sample = 0.75,
|
||||||
|
led2Sample = 0.80,
|
||||||
|
led3Sample = 0.78,
|
||||||
|
led4Sample = 0.81,
|
||||||
|
led1Average = 0.85,
|
||||||
|
led2Average = 0.86,
|
||||||
|
led3Average = 0.87,
|
||||||
|
led4Average = 0.88,
|
||||||
|
abs1 = 0.10,
|
||||||
|
abs2 = 0.12,
|
||||||
|
abs3 = 0.11,
|
||||||
|
abs4 = 0.13,
|
||||||
|
hb3 = 13.2,
|
||||||
|
hb4 = 13.6,
|
||||||
|
led1Gain1 = 1.1,
|
||||||
|
led2Gain1 = 1.1,
|
||||||
|
led3Gain1 = 1.1,
|
||||||
|
led4Gain1 = 1.1,
|
||||||
|
led1Air1 = 0.5,
|
||||||
|
led2Air1 = 0.5,
|
||||||
|
led3Air1 = 0.5,
|
||||||
|
led4Air1 = 0.5,
|
||||||
|
deviceRatio = 1.23,
|
||||||
|
calculatedRatio = 1.21,
|
||||||
|
predictedDenovixRatio = 1.22,
|
||||||
|
slopeRatio = 0.98,
|
||||||
|
coefficients = "{\"a\":0.1,\"b\":0.2}",
|
||||||
|
deviceRatioClass = "Optimal",
|
||||||
|
slopeRatioClass = "Stable",
|
||||||
|
borderlineMethod2Class = "Negative",
|
||||||
|
errorMessages = "",
|
||||||
|
batteryLevel = "85%",
|
||||||
|
batteryCapacity = "4000mAh",
|
||||||
|
batteryMaxCapacity = "5000mAh",
|
||||||
|
batteryTemperature = "36C",
|
||||||
|
batteryVoltage = "3.7V",
|
||||||
|
molbioFlag = true,
|
||||||
|
quickCapture = true,
|
||||||
|
solution = "NaCl",
|
||||||
|
concentration = "5%",
|
||||||
|
filter = "HE",
|
||||||
|
volume = "0.5ml",
|
||||||
|
isCSVCreated = true,
|
||||||
|
labName = "LabCorp",
|
||||||
|
cuvetteSize = "Standard",
|
||||||
|
district = "Bangalore Urban",
|
||||||
|
centerName = "Health Center 1",
|
||||||
|
ipAddress = "192.168.0.100",
|
||||||
|
configUpdatedRecent = "2025-07-19T08:45:00"
|
||||||
|
),
|
||||||
|
|
||||||
|
HemoCubeTestData(
|
||||||
|
sampleid = 2,
|
||||||
|
_id = "ID002",
|
||||||
|
name = "Jane Smith",
|
||||||
|
incubationTime = "10 mins",
|
||||||
|
bloodGroup = "B-",
|
||||||
|
age = "28",
|
||||||
|
state = "Maharashtra",
|
||||||
|
abhaId = "ABHA654321",
|
||||||
|
userImageURL = "https://example.com/image2.jpg",
|
||||||
|
location = UserData.Location(latitude = 18.5204, longitude = 73.8567),
|
||||||
|
reportUploadTime = "2025-07-21T09:15:00",
|
||||||
|
testTime = "2025-07-21T08:45:00",
|
||||||
|
gender = "Female",
|
||||||
|
classificationResult = "Anemia",
|
||||||
|
prdClassification = "Class B",
|
||||||
|
deviceSerialNumber = "SN654321",
|
||||||
|
deviceId = "DEVICE002",
|
||||||
|
appVersion = "1.2.3",
|
||||||
|
kitSerial = "KIT002",
|
||||||
|
resultData = "{\"hb\":9.0}",
|
||||||
|
led1Buffer = 1.05,
|
||||||
|
led2Buffer = 1.00,
|
||||||
|
led3Buffer = 1.02,
|
||||||
|
led4Buffer = 0.99,
|
||||||
|
led1Sample = 0.60,
|
||||||
|
led2Sample = 0.65,
|
||||||
|
led3Sample = 0.63,
|
||||||
|
led4Sample = 0.62,
|
||||||
|
led1Average = 0.70,
|
||||||
|
led2Average = 0.71,
|
||||||
|
led3Average = 0.72,
|
||||||
|
led4Average = 0.69,
|
||||||
|
abs1 = 0.15,
|
||||||
|
abs2 = 0.16,
|
||||||
|
abs3 = 0.17,
|
||||||
|
abs4 = 0.14,
|
||||||
|
hb3 = 9.2,
|
||||||
|
hb4 = 8.8,
|
||||||
|
led1Gain1 = 1.2,
|
||||||
|
led2Gain1 = 1.2,
|
||||||
|
led3Gain1 = 1.2,
|
||||||
|
led4Gain1 = 1.2,
|
||||||
|
led1Air1 = 0.6,
|
||||||
|
led2Air1 = 0.6,
|
||||||
|
led3Air1 = 0.6,
|
||||||
|
led4Air1 = 0.6,
|
||||||
|
deviceRatio = 0.95,
|
||||||
|
calculatedRatio = 0.93,
|
||||||
|
predictedDenovixRatio = 0.94,
|
||||||
|
slopeRatio = 1.02,
|
||||||
|
coefficients = "{\"a\":0.15,\"b\":0.25}",
|
||||||
|
deviceRatioClass = "Low",
|
||||||
|
slopeRatioClass = "Fluctuating",
|
||||||
|
borderlineMethod2Class = "Positive",
|
||||||
|
errorMessages = "Low Hb detected",
|
||||||
|
batteryLevel = "78%",
|
||||||
|
batteryCapacity = "3800mAh",
|
||||||
|
batteryMaxCapacity = "5000mAh",
|
||||||
|
batteryTemperature = "37C",
|
||||||
|
batteryVoltage = "3.6V",
|
||||||
|
molbioFlag = false,
|
||||||
|
quickCapture = false,
|
||||||
|
solution = "PBS",
|
||||||
|
concentration = "3%",
|
||||||
|
filter = "LE",
|
||||||
|
volume = "0.4ml",
|
||||||
|
isCSVCreated = false,
|
||||||
|
labName = "MedLab",
|
||||||
|
cuvetteSize = "Small",
|
||||||
|
district = "Pune",
|
||||||
|
centerName = "Health Center 2",
|
||||||
|
ipAddress = "192.168.0.101",
|
||||||
|
configUpdatedRecent = "2025-07-20T11:00:00"
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.testRight
|
package com.example.hpostesting.presentation.testRight
|
||||||
|
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
@@ -112,14 +112,14 @@ class TestRightResults : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateResults() {
|
private fun updateResults() {
|
||||||
if (viewModel.testDetails?.name == "" && viewModel.testDetails?.birthYear == "") {
|
if (viewModel.testDetails?.name == "" && viewModel.testDetails?.age == "") {
|
||||||
binding.tvName.visibility = View.GONE
|
binding.tvName.visibility = View.GONE
|
||||||
binding.tvAge.visibility = View.GONE
|
binding.tvAge.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
binding.tvName.text = getString(R.string.name_in_textview, viewModel.testDetails?.name)
|
binding.tvName.text = getString(R.string.name_in_textview, viewModel.testDetails?.name)
|
||||||
binding.tvAge.text = getString(
|
binding.tvAge.text = getString(
|
||||||
R.string.age_in_textview,
|
R.string.age_in_textview,
|
||||||
viewModel.testDetails?.birthYear?.toInt()?.calculateAgeFromYOB().toString()
|
viewModel.testDetails?.age?.toInt()?.calculateAgeFromYOB().toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.UserDao
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
import com.example.hpostesting.data.model.CalculationVariableForTest
|
import com.example.hpostesting.data.model.CalculationVariableForTest
|
||||||
@@ -36,6 +35,7 @@ import com.example.hpostesting.domain.SaveRawDataTest
|
|||||||
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
||||||
import com.example.hpostesting.domain.TestRightResultCalculation
|
import com.example.hpostesting.domain.TestRightResultCalculation
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
|
import com.example.hpostesting.util.NetworkMonitor
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -55,10 +55,10 @@ class TestRightViewModel @Inject constructor(
|
|||||||
private val saveRawDataTest: SaveRawDataTest,
|
private val saveRawDataTest: SaveRawDataTest,
|
||||||
private val repository: DatabaseRepository,
|
private val repository: DatabaseRepository,
|
||||||
private val userDao: UserDao,
|
private val userDao: UserDao,
|
||||||
|
networkMonitor: NetworkMonitor,
|
||||||
context: Context?
|
context: Context?
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
|
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|
||||||
@@ -69,9 +69,8 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
var testDetails = DataHolder.selectedTest
|
var testDetails = DataHolder.selectedTest
|
||||||
|
|
||||||
private val _networkStatusLiveData = context?.let { NetworkStatusLiveData(it) }
|
private var _networkStatusLiveData = networkMonitor.isConnected
|
||||||
val networkStatusLiveData: NetworkStatusLiveData?
|
val networkStatusLiveData = _networkStatusLiveData
|
||||||
get() = _networkStatusLiveData
|
|
||||||
|
|
||||||
val allUserData = userDao.getAll()
|
val allUserData = userDao.getAll()
|
||||||
|
|
||||||
@@ -82,6 +81,11 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
||||||
|
|
||||||
|
init {
|
||||||
|
networkMonitor.startMonitoring()
|
||||||
|
_networkStatusLiveData = networkMonitor.isConnected
|
||||||
|
}
|
||||||
|
|
||||||
fun mapDeviceConstants(string: String) {
|
fun mapDeviceConstants(string: String) {
|
||||||
if (string.isNotEmpty()) {
|
if (string.isNotEmpty()) {
|
||||||
val listOfStrings = string.split(",")
|
val listOfStrings = string.split(",")
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import androidx.core.view.get
|
|||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -48,7 +48,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class TrueHemeActivity : AppCompatActivity() {
|
class TrueHemeActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
@@ -177,14 +177,14 @@ class TrueHemeActivity : AppCompatActivity() {
|
|||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, TrueHemeTestFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
if (fragment is HemoCubeFragment) {
|
if (fragment is TrueHemeTestFragment) {
|
||||||
fragment.handleBackButtonPress()
|
fragment.handleBackButtonPress()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import com.example.hpostesting.data.model.TestState
|
|||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
import com.example.hpostesting.presentation.utils.UIUtils
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
@@ -336,7 +336,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
startListening.postValue(true)
|
startListening.postValue(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
(activity as TrueHemeTestActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
@@ -357,7 +357,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun getDeviceInfo() {
|
private fun getDeviceInfo() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
@@ -593,7 +593,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.isEnabled = true
|
||||||
binding.btnSubmit.isClickable = true
|
binding.btnSubmit.isClickable = true
|
||||||
// binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
// binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||||
binding.ivCheck.visibility = View.VISIBLE
|
binding.ivCheck.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -736,7 +736,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processResult() {
|
private fun processResult(){
|
||||||
try {
|
try {
|
||||||
hemoCubeViewModel.messages.postValue(getString(R.string.processing_result))
|
hemoCubeViewModel.messages.postValue(getString(R.string.processing_result))
|
||||||
val deviceLog = resultData
|
val deviceLog = resultData
|
||||||
@@ -1067,7 +1067,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
binding.btnPlacebuffer.visibility = View.GONE
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.START_BUFFER_COMMAND,
|
HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1081,7 +1081,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun startSampleProcess() {
|
private fun startSampleProcess() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.START_SAMPLE,
|
HemoCubeCommands.START_SAMPLE,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1095,7 +1095,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendFirstGainCommand() {
|
private fun sendFirstGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.FIRST_GAIN_COMMAND,
|
HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1109,7 +1109,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendSecondGainCommand() {
|
private fun sendSecondGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.SECOND_GAIN_COMMAND,
|
HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1123,7 +1123,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendThirdGainCommand() {
|
private fun sendThirdGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.THIRD_GAIN_COMMAND,
|
HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1137,7 +1137,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendForthGainCommand() {
|
private fun sendForthGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.FORTH_GAIN_COMMAND,
|
HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1151,7 +1151,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun fetchResult() {
|
private fun fetchResult() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.PRINT_COMMAND,
|
HemoCubeCommands.PRINT_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1170,7 +1170,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun reconnect() {
|
private fun reconnect() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
(activity as HemocubeActivity).reconnectDevice()
|
(activity as TrueHemeTestActivity).reconnectDevice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,8 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
import androidx.work.ExistingPeriodicWorkPolicy
|
||||||
import androidx.work.PeriodicWorkRequestBuilder
|
import androidx.work.PeriodicWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.util.Result
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||||
@@ -46,10 +43,12 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
|
import com.example.hpostesting.util.CsvWriter
|
||||||
|
import com.example.hpostesting.util.NetworkMonitor
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
@@ -70,20 +69,22 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
|
networkMonitor: NetworkMonitor,
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference =
|
private val sharedPreference = context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
private val workManager = WorkManager.getInstance(context)
|
private val workManager = WorkManager.getInstance(context)
|
||||||
|
// init {
|
||||||
// init {
|
// startPeriodicCheckUpdate()
|
||||||
// startPeriodicCheckUpdate()
|
// }
|
||||||
// }
|
init {
|
||||||
|
networkMonitor.startMonitoring()
|
||||||
|
}
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = networkMonitor.isConnected
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
@@ -181,7 +182,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
val logFile = logFileManager.createLogFile().let { file ->
|
val logFile = logFileManager.createLogFile().let { file ->
|
||||||
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
||||||
val multipartFile =
|
val multipartFile =
|
||||||
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
requestBody?.let { MultipartBody.Part.createFormData("logFile", file.name, it) }
|
||||||
multipartFile?.let { partFile ->
|
multipartFile?.let { partFile ->
|
||||||
repository.uploadLogs(partFile).let { result ->
|
repository.uploadLogs(partFile).let { result ->
|
||||||
uploadLogs.postValue(result)
|
uploadLogs.postValue(result)
|
||||||
@@ -193,37 +194,35 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||||
isOnline: Boolean,
|
isOnline: Boolean,
|
||||||
bufferCheckData: BufferCheckData,
|
bufferCheckData: BufferCheckData,
|
||||||
) =
|
) = viewModelScope.launch {
|
||||||
viewModelScope.launch {
|
if (isOnline) {
|
||||||
if (isOnline) {
|
try {
|
||||||
try {
|
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
when (val response =
|
is Response.Success -> {
|
||||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
is Response.Success -> {
|
fireBaseUpload.postValue("Success")
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
bufferCheckData.localFlag = true
|
||||||
fireBaseUpload.postValue("Success")
|
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||||
bufferCheckData.localFlag = true
|
|
||||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
|
||||||
}
|
|
||||||
|
|
||||||
is Response.Error -> {
|
|
||||||
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
|
||||||
fireBaseUpload.postValue("Error")
|
|
||||||
bufferCheckData.localFlag = true
|
|
||||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
is Response.Error -> {
|
||||||
fireBaseUpload.postValue("Error")
|
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
bufferCheckData.localFlag = true
|
||||||
|
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e: Exception) {
|
||||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
fireBaseUpload.postValue("Local")
|
fireBaseUpload.postValue("Error")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||||
|
fireBaseUpload.postValue("Local")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun bulkAddResultKitTestToDb(bufferCheckData: BufferCheckData) {
|
fun bulkAddResultKitTestToDb(bufferCheckData: BufferCheckData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
@@ -287,7 +286,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||||
testDetails?.incubationTime = DataHolder.hemoCubeTestData?.incubationTime.toString()
|
testDetails?.incubationTime = DataHolder.hemoCubeTestData?.incubationTime.toString()
|
||||||
testDetails?.name = DataHolder.hemoCubeTestData?.name.toString()
|
testDetails?.name = DataHolder.hemoCubeTestData?.name.toString()
|
||||||
testDetails?.birthYear = DataHolder.hemoCubeTestData?.birthYear.toString()
|
testDetails?.age = DataHolder.hemoCubeTestData?.age.toString()
|
||||||
testDetails?.userImageURL = DataHolder.hemoCubeTestData?.userImageURL.toString()
|
testDetails?.userImageURL = DataHolder.hemoCubeTestData?.userImageURL.toString()
|
||||||
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||||
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||||
@@ -396,8 +395,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
when (val response =
|
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -415,10 +413,9 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBufferLocalFlag(bufferId: String) =
|
private fun updateBufferLocalFlag(bufferId: String) = viewModelScope.launch {
|
||||||
viewModelScope.launch {
|
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
||||||
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun getLocalUserDataForCsv(context: Context): Boolean {
|
fun getLocalUserDataForCsv(context: Context): Boolean {
|
||||||
val localUserDataLiveData: LiveData<List<HemoCubeTestData>> = hemoCubeDao.getAll()
|
val localUserDataLiveData: LiveData<List<HemoCubeTestData>> = hemoCubeDao.getAll()
|
||||||
@@ -434,7 +431,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
userData._id,
|
userData._id,
|
||||||
userData.name,
|
userData.name,
|
||||||
userData.bloodGroup,
|
userData.bloodGroup,
|
||||||
userData.birthYear,
|
userData.age,
|
||||||
userData.classificationResult,
|
userData.classificationResult,
|
||||||
userData.testTime.toString(),
|
userData.testTime.toString(),
|
||||||
userData.userImageURL
|
userData.userImageURL
|
||||||
@@ -455,16 +452,12 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun getBatteryLevel(): Float? {
|
fun getBatteryLevel(): Float? {
|
||||||
val batteryPct: Float? = batteryStatus?.let { intent ->
|
val batteryPct: Float? = batteryStatus?.let { intent ->
|
||||||
val level: Int =
|
val level: Int = intent.getIntExtra(
|
||||||
intent.getIntExtra(
|
BatteryManager.EXTRA_LEVEL, -1
|
||||||
BatteryManager.EXTRA_LEVEL,
|
)
|
||||||
-1
|
val scale: Int = intent.getIntExtra(
|
||||||
)
|
BatteryManager.EXTRA_SCALE, -1
|
||||||
val scale: Int =
|
)
|
||||||
intent.getIntExtra(
|
|
||||||
BatteryManager.EXTRA_SCALE,
|
|
||||||
-1
|
|
||||||
)
|
|
||||||
level * 100 / scale.toFloat()
|
level * 100 / scale.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,8 +467,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
fun getBatteryTemperature(): Float? {
|
fun getBatteryTemperature(): Float? {
|
||||||
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||||
val temperature = intent.getIntExtra(
|
val temperature = intent.getIntExtra(
|
||||||
BatteryManager.EXTRA_TEMPERATURE,
|
BatteryManager.EXTRA_TEMPERATURE, 0
|
||||||
0
|
|
||||||
)
|
)
|
||||||
temperature.toFloat() / 10
|
temperature.toFloat() / 10
|
||||||
}
|
}
|
||||||
@@ -484,14 +476,11 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBatteryVoltage(context: Context): Float {
|
fun getBatteryVoltage(context: Context): Float {
|
||||||
val batteryIntent =
|
val batteryIntent = context.registerReceiver(
|
||||||
context.registerReceiver(
|
null, IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||||
null,
|
)
|
||||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
|
||||||
)
|
|
||||||
val voltage = batteryIntent?.getIntExtra(
|
val voltage = batteryIntent?.getIntExtra(
|
||||||
BatteryManager.EXTRA_VOLTAGE,
|
BatteryManager.EXTRA_VOLTAGE, 0
|
||||||
0
|
|
||||||
) ?: 0
|
) ?: 0
|
||||||
|
|
||||||
// milli-volts to volts
|
// milli-volts to volts
|
||||||
@@ -500,8 +489,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
|
|
||||||
fun getBatteryCapacity(context: Context): Int {
|
fun getBatteryCapacity(context: Context): Int {
|
||||||
val batteryManager =
|
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
|
||||||
val currentCapacity =
|
val currentCapacity =
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
@@ -510,8 +498,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun getBatteryMaxCapacity(context: Context): Float {
|
fun getBatteryMaxCapacity(context: Context): Float {
|
||||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
val designCapacity =
|
val designCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
|
||||||
val currentCapacity =
|
val currentCapacity =
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
@@ -528,8 +515,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
hemoCubeTestData.forEach { data ->
|
hemoCubeTestData.forEach { data ->
|
||||||
data.localFlag = true
|
data.localFlag = true
|
||||||
hemoCubeDao.updateCSVFieldById(
|
hemoCubeDao.updateCSVFieldById(
|
||||||
data._id,
|
data._id, true
|
||||||
true
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.trueheme_test
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.trueheme_test
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -33,7 +33,7 @@ import java.util.Locale
|
|||||||
|
|
||||||
class DigitalCardFragment : Fragment() {
|
class DigitalCardFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentDigitalCardBinding
|
private lateinit var binding: FragmentDigitalCardBinding
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class DigitalCardFragment : Fragment() {
|
|||||||
binding.progressBar.visibility = View.VISIBLE
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
Log.d("DigitalCardFragment", "Name: ${DataHolder.hemoCubeTestData?.name}")
|
Log.d("DigitalCardFragment", "Name: ${DataHolder.hemoCubeTestData?.name}")
|
||||||
Log.d("DigitalCardFragment", "DOB: ${testDetails?.birthYear}")
|
Log.d("DigitalCardFragment", "DOB: ${testDetails?.age}")
|
||||||
Log.d("DigitalCardFragment", "Gender: ${testDetails?.gender}")
|
Log.d("DigitalCardFragment", "Gender: ${testDetails?.gender}")
|
||||||
Log.d("DigitalCardFragment", "State: ${testDetails?.state}")
|
Log.d("DigitalCardFragment", "State: ${testDetails?.state}")
|
||||||
Log.d("DigitalCardFragment", "ABHA ID: ${testDetails?.abhaId}")
|
Log.d("DigitalCardFragment", "ABHA ID: ${testDetails?.abhaId}")
|
||||||
@@ -67,7 +67,7 @@ class DigitalCardFragment : Fragment() {
|
|||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
binding.name.text = "Name: ${DataHolder.hemoCubeTestData?.name}"
|
binding.name.text = "Name: ${DataHolder.hemoCubeTestData?.name}"
|
||||||
binding.dob.text = "DOB: ${testDetails?.birthYear}"
|
binding.dob.text = "DOB: ${testDetails?.age}"
|
||||||
binding.gender.text = "Gender: ${testDetails?.gender}"
|
binding.gender.text = "Gender: ${testDetails?.gender}"
|
||||||
binding.State.text = "State: ${testDetails?.state}"
|
binding.State.text = "State: ${testDetails?.state}"
|
||||||
binding.abhaid.text = "ABHA ID: ${testDetails?.abhaId}"
|
binding.abhaid.text = "ABHA ID: ${testDetails?.abhaId}"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.trueheme_test
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
@@ -25,7 +25,6 @@ import android.content.SharedPreferences
|
|||||||
import android.hardware.usb.UsbDevice
|
import android.hardware.usb.UsbDevice
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
import android.icu.text.SimpleDateFormat
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
@@ -37,27 +36,20 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
import com.google.firebase.ktx.Firebase
|
|
||||||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
|
||||||
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
|
||||||
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
|
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
open class HemocubeActivity : AppCompatActivity() {
|
open class TrueHemeTestActivity : AppCompatActivity() {
|
||||||
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
lateinit var sharedPreferences: SharedPreferences
|
lateinit var sharedPreferences: SharedPreferences
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
@@ -117,95 +109,6 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
setupListener()
|
setupListener()
|
||||||
connectUsb(false)
|
connectUsb(false)
|
||||||
val configSettings = remoteConfigSettings {
|
|
||||||
minimumFetchIntervalInSeconds = 10//3600
|
|
||||||
}
|
|
||||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
remoteConfig.setConfigSettingsAsync(configSettings)
|
|
||||||
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
|
|
||||||
|
|
||||||
remoteConfig.fetchAndActivate()
|
|
||||||
.addOnCompleteListener(this) { task ->
|
|
||||||
if (task.isSuccessful) {
|
|
||||||
val normalMin2mm = remoteConfig.getDouble("normalMin2mm")
|
|
||||||
val normalMax2mm = remoteConfig.getDouble("normalMax2mm")
|
|
||||||
val negativeBorderlineMin2mm = remoteConfig.getDouble("negativeBorderlineMin2mm")
|
|
||||||
val negativeBorderlineMax2mm = remoteConfig.getDouble("negativeBorderlineMax2mm")
|
|
||||||
val positiveForSickleCellMin2mm = remoteConfig.getDouble("positiveForSickleCellMin2mm")
|
|
||||||
val positiveForSickleCellMax2mm = remoteConfig.getDouble("positiveForSickleCellMax2mm")
|
|
||||||
val sickleCellTraitMin2mm = remoteConfig.getDouble("sickleCellTraitMin2mm")
|
|
||||||
val sickleCellTraitMax2mm = remoteConfig.getDouble("sickleCellTraitMax2mm")
|
|
||||||
val sickleCellDiseaseMin2mm = remoteConfig.getDouble("sickleCellDiseaseMin2mm")
|
|
||||||
val sickleCellDiseaseMax2mm = remoteConfig.getDouble("sickleCellDiseaseMax2mm")
|
|
||||||
val positiveBoderLine2mm1 = remoteConfig.getDouble("positiveBoderLine2mm1")
|
|
||||||
val positiveBoderLine2mm2 = remoteConfig.getDouble("positiveBoderLine2mm2")
|
|
||||||
val negativeBoderLine2mm1 = remoteConfig.getDouble("negativeBoderLine2mm1")
|
|
||||||
val negativeBoderLine2mm2 = remoteConfig.getDouble("negativeBoderLine2mm2")
|
|
||||||
|
|
||||||
val normalMin10mm = remoteConfig.getDouble("normalMin10mm")
|
|
||||||
val normalMax10mm = remoteConfig.getDouble("normalMax10mm")
|
|
||||||
val negativeBorderlineMin10mm = remoteConfig.getDouble("negativeBorderlineMin10mm")
|
|
||||||
val negativeBorderlineMax10mm = remoteConfig.getDouble("negativeBorderlineMax10mm")
|
|
||||||
val positiveForSickleCellMin10mm = remoteConfig.getDouble("positiveForSickleCellMin10mm")
|
|
||||||
val positiveForSickleCellMax10mm = remoteConfig.getDouble("positiveForSickleCellMax10mm")
|
|
||||||
val sickleCellTraitMin10mm = remoteConfig.getDouble("sickleCellTraitMin10mm")
|
|
||||||
val sickleCellTraitMax10mm = remoteConfig.getDouble("sickleCellTraitMax10mm")
|
|
||||||
val sickleCellDiseaseMin10mm = remoteConfig.getDouble("sickleCellDiseaseMin10mm")
|
|
||||||
val sickleCellDiseaseMax10mm = remoteConfig.getDouble("sickleCellDiseaseMax10mm")
|
|
||||||
val positiveBoderLine10mm1 = remoteConfig.getDouble("positiveBoderLine10mm1")
|
|
||||||
val positiveBoderLine10mm2 = remoteConfig.getDouble("positiveBoderLine10mm2")
|
|
||||||
val negativeBoderLine10mm1 = remoteConfig.getDouble("negativeBoderLine10mm1")
|
|
||||||
val negativeBoderLine10mm2 = remoteConfig.getDouble("negativeBoderLine10mm2")
|
|
||||||
|
|
||||||
val bufferMinLed1 = remoteConfig.getDouble("bufferMinLed1")
|
|
||||||
val bufferMaxLed1 = remoteConfig.getDouble("bufferMaxLed1")
|
|
||||||
val bufferMinLed2 = remoteConfig.getDouble("bufferMinLed2")
|
|
||||||
val bufferMaxLed2 = remoteConfig.getDouble("bufferMaxLed2")
|
|
||||||
val time = SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
|
||||||
).format(Calendar.getInstance().time).toString()
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.LAST_UPDATED, time)
|
|
||||||
putString("bufferMinLed1", bufferMinLed1.toString())
|
|
||||||
putString("bufferMaxLed1", bufferMaxLed1.toString())
|
|
||||||
putString("bufferMinLed2", bufferMinLed2.toString())
|
|
||||||
putString("bufferMaxLed2", bufferMaxLed2.toString())//buffer
|
|
||||||
putString("normalMin2mm", normalMin2mm.toString())//2mm
|
|
||||||
putString("normalMax2mm", normalMax2mm.toString())
|
|
||||||
putString("negativeBorderlineMin2mm", negativeBorderlineMin2mm.toString())
|
|
||||||
putString("negativeBorderlineMax2mm", negativeBorderlineMax2mm.toString())
|
|
||||||
putString("positiveForSickleCellMin2mm", positiveForSickleCellMin2mm.toString())
|
|
||||||
putString("positiveForSickleCellMax2mm", positiveForSickleCellMax2mm.toString())
|
|
||||||
putString("sickleCellTraitMin2mm", sickleCellTraitMin2mm.toString())
|
|
||||||
putString("sickleCellTraitMax2mm", sickleCellTraitMax2mm.toString())
|
|
||||||
putString("sickleCellDiseaseMin2mm", sickleCellDiseaseMin2mm.toString())
|
|
||||||
putString("sickleCellDiseaseMax2mm", sickleCellDiseaseMax2mm.toString())
|
|
||||||
putString("positiveBoderLine2mm1", positiveBoderLine2mm1.toString())
|
|
||||||
putString("positiveBoderLine2mm2", positiveBoderLine2mm2.toString())
|
|
||||||
putString("negativeBoderLine2mm1", negativeBoderLine2mm1.toString())
|
|
||||||
putString("negativeBoderLine2mm2", negativeBoderLine2mm2.toString())//2mm
|
|
||||||
putString("normalMin10mm", normalMin10mm.toString())//10mm
|
|
||||||
putString("normalMax10mm", normalMax10mm.toString())
|
|
||||||
putString("negativeBorderlineMin10mm", negativeBorderlineMin10mm.toString())
|
|
||||||
putString("negativeBorderlineMax10mm", negativeBorderlineMax10mm.toString())
|
|
||||||
putString("positiveForSickleCellMin10mm", positiveForSickleCellMin10mm.toString())
|
|
||||||
putString("positiveForSickleCellMax10mm", positiveForSickleCellMax10mm.toString())
|
|
||||||
putString("sickleCellTraitMin10mm", sickleCellTraitMin10mm.toString())
|
|
||||||
putString("sickleCellTraitMax10mm", sickleCellTraitMax10mm.toString())
|
|
||||||
putString("sickleCellDiseaseMin10mm", sickleCellDiseaseMin10mm.toString())
|
|
||||||
putString("sickleCellDiseaseMax10mm", sickleCellDiseaseMax10mm.toString())
|
|
||||||
putString("positiveBoderLine10mm1", positiveBoderLine10mm1.toString())
|
|
||||||
putString("positiveBoderLine10mm2", positiveBoderLine10mm2.toString())
|
|
||||||
putString("negativeBoderLine10mm1", negativeBoderLine10mm1.toString())
|
|
||||||
putString("negativeBoderLine10mm2", negativeBoderLine10mm2.toString())//10mm
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
Toast.makeText(this@HemocubeActivity, "Config params updated", Toast.LENGTH_SHORT).show()
|
|
||||||
Log.d(TAG, "Config params updated")
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Config params Fetch failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListener() {
|
private fun setupListener() {
|
||||||
@@ -289,7 +192,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, TrueHemeTestFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +207,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
// }
|
// }
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
if (fragment is HemoCubeFragment) {
|
if (fragment is TrueHemeTestFragment) {
|
||||||
if (fragment.handleBackButtonPress()) {
|
if (fragment.handleBackButtonPress()) {
|
||||||
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
||||||
return
|
return
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.trueheme_test
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -27,7 +27,6 @@ import androidx.work.PeriodicWorkRequestBuilder
|
|||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
import com.example.hpostesting.util.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
@@ -50,6 +49,7 @@ import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
|||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
|
import com.example.hpostesting.util.NetworkMonitor
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -66,14 +66,16 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class HemoCubeViewModel @Inject constructor(
|
class TrueHemeTestViewModel @Inject constructor(
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
val hemoCubeDao: HemoCubeDao,
|
||||||
private val hemoCubeBufferDao: HemoCubeBufferDao,
|
private val hemoCubeBufferDao: HemoCubeBufferDao,
|
||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
|
networkMonitor: NetworkMonitor,
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
private var testUpload: Boolean = false
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
@@ -86,6 +88,9 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
// init {
|
// init {
|
||||||
// startPeriodicCheckUpdate()
|
// startPeriodicCheckUpdate()
|
||||||
// }
|
// }
|
||||||
|
init {
|
||||||
|
networkMonitor.startMonitoring()
|
||||||
|
}
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
@@ -102,7 +107,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData =networkMonitor.isConnected
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allLocalData = hemoCubeDao.getAll()
|
val allLocalData = hemoCubeDao.getAll()
|
||||||
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
||||||
@@ -132,20 +137,84 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
parseData()
|
parseData()
|
||||||
addResultTestToDb(quickCapture)
|
//addResultTestToDb(quickCapture)
|
||||||
|
if(Constants.FIREBASE_INTEGRATION){
|
||||||
|
addResultTestToDb(quickCapture)
|
||||||
|
}else{
|
||||||
|
uploadToMolbio()
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
parseData()
|
parseData()
|
||||||
addResultTestToDb(quickCapture)
|
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
// addResultTestToDb(quickCapture,isOnline)
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
|
testDetails?.localFlag = false
|
||||||
hemoCubeDao.updateTest(testDetails!!)
|
hemoCubeDao.updateTest(testDetails!!)
|
||||||
fireBaseUpload.postValue("Local")
|
fireBaseUpload.postValue("Local")
|
||||||
|
|
||||||
|
// parseData()
|
||||||
|
// addResultTestToDb(quickCapture)
|
||||||
|
// testDetails?.testTime = SimpleDateFormat(
|
||||||
|
// "yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
// ).format(Calendar.getInstance().time)
|
||||||
|
// hemoCubeDao.updateTest(testDetails!!)
|
||||||
|
// fireBaseUpload.postValue("Local")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Testdb", "Upload failed: ${e.message}")
|
Log.e("Testdb", "Upload failed: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun uploadToMolbio(){
|
||||||
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
|
testDetails!!.testStatus = true
|
||||||
|
testDetails.localFlag = true
|
||||||
|
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
fireBaseUpload.postValue("Success")
|
||||||
|
testDetails.reportUploadTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
val currentTimeFormatted = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
|
||||||
|
Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
// Sanitize testDetails before using it in the API call
|
||||||
|
val sanitizedTestDetails = sanitizeDoubleValues(testDetails)
|
||||||
|
|
||||||
|
// Now, use sanitizedTestDetails for the API call
|
||||||
|
uploadResult(
|
||||||
|
MolbioV2ResultRequest(
|
||||||
|
mutableListOf(
|
||||||
|
MolbioV2Result(
|
||||||
|
rawData = sanitizedTestDetails,
|
||||||
|
analysisId = sanitizedTestDetails._id,
|
||||||
|
analysisDate = currentTimeFormatted,
|
||||||
|
analysisStatus = sanitizedTestDetails.classificationResult,
|
||||||
|
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[sanitizedTestDetails.deviceId]?.toString(),
|
||||||
|
interpretation = sanitizedTestDetails.classificationResult,
|
||||||
|
testId = sanitizedTestDetails._id,
|
||||||
|
testTime = currentTimeFormatted,
|
||||||
|
collectionTime = currentTimeFormatted,
|
||||||
|
expiryTime = currentTimeFormatted,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
viewModelScope.launch {
|
||||||
|
hemoCubeDao.updateTest(testDetails)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun login(loginRequest: LoginRequest) = viewModelScope.launch {
|
fun login(loginRequest: LoginRequest) = viewModelScope.launch {
|
||||||
loginResponse.postValue(Result.Loading())
|
loginResponse.postValue(Result.Loading())
|
||||||
@@ -221,16 +290,20 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
it.data.data?.forEach { id ->
|
it.data.data?.forEach { id ->
|
||||||
id.rawData?.let { it1 ->
|
id.rawData?.let { it1 ->
|
||||||
|
updateLocalFlag(it1._id)
|
||||||
updateMolbioFlag(
|
updateMolbioFlag(
|
||||||
it1._id
|
it1._id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fireBaseBulkUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
|
fireBaseBulkUpload.postValue("Error")
|
||||||
Log.d("result","result upload error")
|
Log.d("result","result upload error")
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
fireBaseBulkUpload.postValue("Error")
|
||||||
Log.d("result","result upload else")
|
Log.d("result","result upload else")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,7 +321,12 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(testUpload){
|
||||||
|
fireBaseBulkUpload.postValue("Success")
|
||||||
|
}
|
||||||
|
// else{
|
||||||
|
// fireBaseBulkUpload.postValue("Error")
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -399,7 +477,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||||
testDetails?.incubationTime = DataHolder.hemoCubeTestData?.incubationTime.toString()
|
testDetails?.incubationTime = DataHolder.hemoCubeTestData?.incubationTime.toString()
|
||||||
testDetails?.name = DataHolder.hemoCubeTestData?.name.toString()
|
testDetails?.name = DataHolder.hemoCubeTestData?.name.toString()
|
||||||
testDetails?.birthYear = DataHolder.hemoCubeTestData?.birthYear.toString()
|
testDetails?.age = DataHolder.hemoCubeTestData?.age.toString()
|
||||||
testDetails?.userImageURL = DataHolder.hemoCubeTestData?.userImageURL.toString()
|
testDetails?.userImageURL = DataHolder.hemoCubeTestData?.userImageURL.toString()
|
||||||
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||||
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||||
@@ -422,13 +500,13 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails?.centerName = sharedPreference.getString(Constants.CENTER_NAME, "").toString()
|
testDetails?.centerName = sharedPreference.getString(Constants.CENTER_NAME, "").toString()
|
||||||
testDetails?.district = sharedPreference.getString(Constants.DISTRICT, "").toString()
|
testDetails?.district = sharedPreference.getString(Constants.DISTRICT, "").toString()
|
||||||
testDetails?.ipAddress = sharedPreference.getString(Constants.IP_ADDRESS, "").toString()
|
testDetails?.ipAddress = sharedPreference.getString(Constants.IP_ADDRESS, "").toString()
|
||||||
testDetails?.configUpdatedRecent = sharedPreference.getString(Constants.LAST_UPDATED, "NA").toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addResultTestToDb(quickCapture: Boolean) {
|
private fun addResultTestToDb(quickCapture: Boolean) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
testDetails!!.quickCapture = quickCapture
|
testDetails!!.quickCapture = quickCapture
|
||||||
|
testDetails.testStatus = true
|
||||||
testDetails.reportUploadTime = SimpleDateFormat(
|
testDetails.reportUploadTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
@@ -461,6 +539,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}else{
|
}else{
|
||||||
when (val response = repository.addTestToDatabase(testDetails)) {
|
when (val response = repository.addTestToDatabase(testDetails)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
|
testDetails.localFlag = true
|
||||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
@@ -468,7 +547,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
testDetails.localFlag = true
|
|
||||||
if (Constants.MOLBIO_INTEGRATION) {
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
// Sanitize testDetails before using it in the API call
|
// Sanitize testDetails before using it in the API call
|
||||||
val sanitizedTestDetails = sanitizeDoubleValues(testDetails)
|
val sanitizedTestDetails = sanitizeDoubleValues(testDetails)
|
||||||
@@ -520,13 +599,13 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(userData)) {
|
when (repository.addTestToDatabase(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseBulkUpload.postValue("Success")
|
testUpload = true
|
||||||
userData.localFlag = true
|
userData.localFlag = true
|
||||||
updateLocalFlag(userData._id)
|
updateLocalFlag(userData._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
fireBaseBulkUpload.postValue("Error")
|
testUpload = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,6 +670,10 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
||||||
}
|
}
|
||||||
|
fun deleteByStatus() = viewModelScope.launch {
|
||||||
|
hemoCubeDao.deleteByStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getLocalUserDataForCsv(context: Context): Boolean {
|
fun getLocalUserDataForCsv(context: Context): Boolean {
|
||||||
val localUserDataLiveData: LiveData<List<HemoCubeTestData>> = hemoCubeDao.getAll()
|
val localUserDataLiveData: LiveData<List<HemoCubeTestData>> = hemoCubeDao.getAll()
|
||||||
@@ -606,7 +689,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
userData._id,
|
userData._id,
|
||||||
userData.name,
|
userData.name,
|
||||||
userData.bloodGroup,
|
userData.bloodGroup,
|
||||||
userData.birthYear,
|
userData.age,
|
||||||
userData.classificationResult,
|
userData.classificationResult,
|
||||||
userData.testTime.toString(),
|
userData.testTime.toString(),
|
||||||
userData.userImageURL
|
userData.userImageURL
|
||||||
@@ -712,4 +795,11 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
}
|
}
|
||||||
|
fun updateLocalData() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
parseData()
|
||||||
|
hemoCubeDao.updateTest(testDetails!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ import android.os.Build
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import io.nats.client.AuthHandler
|
import io.nats.client.AuthHandler
|
||||||
import io.nats.client.Connection
|
import io.nats.client.Connection
|
||||||
import io.nats.client.Message
|
import io.nats.client.Message
|
||||||
|
|||||||
117
app/src/main/java/com/example/hpostesting/util/NetworkChecker.kt
Normal file
117
app/src/main/java/com/example/hpostesting/util/NetworkChecker.kt
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
package com.example.hpostesting.util
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
|
import android.net.NetworkRequest
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.SupervisorJob
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.isActive
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class NetworkMonitor @Inject constructor(
|
||||||
|
@ApplicationContext private val context: Context
|
||||||
|
) {
|
||||||
|
private var isMonitoringStarted = false
|
||||||
|
private val connectivityManager =
|
||||||
|
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
|
private val _isConnected = MutableLiveData(false)
|
||||||
|
val isConnected: LiveData<Boolean> get() = _isConnected
|
||||||
|
|
||||||
|
private val networkScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
|
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
performPingCheck()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
_isConnected.postValue(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCapabilitiesChanged(
|
||||||
|
network: Network, networkCapabilities: NetworkCapabilities
|
||||||
|
) {
|
||||||
|
// Recheck connectivity when capabilities change (e.g., network becomes validated)
|
||||||
|
performPingCheck()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
fun startMonitoring() {
|
||||||
|
if (isMonitoringStarted) return // Already started, do nothing.
|
||||||
|
isMonitoringStarted = true
|
||||||
|
// Check initial connectivity status
|
||||||
|
val network = connectivityManager.activeNetwork
|
||||||
|
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
||||||
|
val isInitiallyConnected = capabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true
|
||||||
|
|
||||||
|
if (isInitiallyConnected) {
|
||||||
|
performPingCheck()
|
||||||
|
} else {
|
||||||
|
_isConnected.postValue(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
val networkRequest =
|
||||||
|
NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||||
|
// Start periodic checks:
|
||||||
|
startPeriodicPingCheck()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stopMonitoring() { // never needed to call
|
||||||
|
try {
|
||||||
|
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||||
|
} catch (_: IllegalArgumentException) {
|
||||||
|
// Ignore if callback was not registered
|
||||||
|
}
|
||||||
|
networkScope.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun performPingCheck() {
|
||||||
|
networkScope.launch {
|
||||||
|
try {
|
||||||
|
val url = URL("https://www.google.com")
|
||||||
|
val connection = url.openConnection() as HttpURLConnection
|
||||||
|
connection.connectTimeout = 2000
|
||||||
|
connection.readTimeout = 2000
|
||||||
|
connection.setRequestProperty("Connection", "close")
|
||||||
|
connection.connect()
|
||||||
|
|
||||||
|
// Consider any 2xx response as successful
|
||||||
|
val isReachable = connection.responseCode in 200..299
|
||||||
|
_isConnected.postValue(isReachable)
|
||||||
|
connection.disconnect()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
_isConnected.postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startPeriodicPingCheck(intervalMillis: Long = 1 * 60_000L) {
|
||||||
|
networkScope.launch {
|
||||||
|
while (isActive) {
|
||||||
|
performPingCheck()
|
||||||
|
delay(intervalMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.example.hpostesting.util
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.ConnectivityManager
|
|
||||||
import android.net.Network
|
|
||||||
import android.net.NetworkCapabilities
|
|
||||||
import android.net.NetworkRequest
|
|
||||||
import android.os.Build
|
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
|
|
||||||
class NetworkStatusLiveData(context: Context) : LiveData<Boolean>() {
|
|
||||||
|
|
||||||
private val connectivityManager: ConnectivityManager =
|
|
||||||
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
||||||
|
|
||||||
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
|
||||||
override fun onAvailable(network: Network) {
|
|
||||||
postValue(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLost(network: Network) {
|
|
||||||
postValue(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
override fun onActive() {
|
|
||||||
super.onActive()
|
|
||||||
postValue(isNetworkAvailable())
|
|
||||||
registerNetworkCallback()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onInactive() {
|
|
||||||
super.onInactive()
|
|
||||||
unregisterNetworkCallback()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun registerNetworkCallback() {
|
|
||||||
val networkRequest = NetworkRequest.Builder()
|
|
||||||
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
|
||||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
|
||||||
.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun unregisterNetworkCallback() {
|
|
||||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
private fun isNetworkAvailable(): Boolean {
|
|
||||||
val network = connectivityManager.activeNetwork
|
|
||||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
|
|
||||||
return networkCapabilities != null &&
|
|
||||||
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
|
||||||
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
5
app/src/main/res/drawable/baseline_add_circle_24.xml
Normal file
5
app/src/main/res/drawable/baseline_add_circle_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/baseline_cloud_24.xml
Normal file
5
app/src/main/res/drawable/baseline_cloud_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/baseline_cloud_done_24.xml
Normal file
5
app/src/main/res/drawable/baseline_cloud_done_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM10,17l-3.5,-3.5 1.41,-1.41L10,14.17 15.18,9l1.41,1.41L10,17z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/baseline_cloud_sync_24.xml
Normal file
5
app/src/main/res/drawable/baseline_cloud_sync_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M21.5,14.98c-0.02,0 -0.03,0 -0.05,0.01C21.2,13.3 19.76,12 18,12c-1.4,0 -2.6,0.83 -3.16,2.02C13.26,14.1 12,15.4 12,17c0,1.66 1.34,3 3,3l6.5,-0.02c1.38,0 2.5,-1.12 2.5,-2.5S22.88,14.98 21.5,14.98zM10,4.26v2.09C7.67,7.18 6,9.39 6,12c0,1.77 0.78,3.34 2,4.44V14h2v6H4v-2h2.73C5.06,16.54 4,14.4 4,12C4,8.27 6.55,5.15 10,4.26zM20,6h-2.73c1.43,1.26 2.41,3.01 2.66,5l-2.02,0C17.68,9.64 16.98,8.45 16,7.56V10h-2V4h6V6z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/baseline_developer_mode_24.xml
Normal file
5
app/src/main/res/drawable/baseline_developer_mode_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M7,5h10v2h2L19,3c0,-1.1 -0.9,-1.99 -2,-1.99L7,1c-1.1,0 -2,0.9 -2,2v4h2L7,5zM15.41,16.59L20,12l-4.59,-4.59L14,8.83 17.17,12 14,15.17l1.41,1.42zM10,15.17L6.83,12 10,8.83 8.59,7.41 4,12l4.59,4.59L10,15.17zM17,19L7,19v-2L5,17v4c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2v-4h-2v2z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/baseline_info_24.xml
Normal file
5
app/src/main/res/drawable/baseline_info_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
5
app/src/main/res/drawable/baseline_translate_24.xml
Normal file
5
app/src/main/res/drawable/baseline_translate_24.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
53
app/src/main/res/layout/activity_hb_test.xml
Normal file
53
app/src/main/res/layout/activity_hb_test.xml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
~ // Notice: All information contained herein is, and remains
|
||||||
|
~ // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
~ // if any. The intellectual and technical concepts contained
|
||||||
|
~ // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
~ // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
~ // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
~ // Dissemination of this information or reproduction of this material
|
||||||
|
~ // is strictly forbidden unless prior written permission is obtained
|
||||||
|
~ // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- <androidx.appcompat.widget.Toolbar-->
|
||||||
|
<!-- android:id="@+id/my_toolbar"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="?attr/actionBarSize"-->
|
||||||
|
<!-- android:background="?attr/colorPrimary"-->
|
||||||
|
<!-- app:titleTextColor="#FFFFFF"-->
|
||||||
|
<!-- android:elevation="4dp"-->
|
||||||
|
<!-- app:menu="@menu/my_menu"-->
|
||||||
|
<!-- android:theme="@style/ToolbarTheme"-->
|
||||||
|
<!-- app:popupTheme="@style/ThemeOverlay.AppCompat.Light"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toTopOf="parent"/>-->
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fg_hb_test"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:text="@string/scan_qr_code_of_the_kit"
|
android:text="@string/scan_qr_code_of_the_kit"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.example.hpostesting.presentation.hemocube.DigitalCardFragment">
|
tools:context="com.example.hpostesting.presentation.trueheme_test.DigitalCardFragment">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/userCard"
|
android:id="@+id/userCard"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
tools:context="com.example.hpostesting.presentation.main_base.PanelFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
@@ -55,7 +55,21 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
android:id="@+id/btn_print_report"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="Print Report"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
|
<Button
|
||||||
android:id="@+id/btn_diagnostics"
|
android:id="@+id/btn_diagnostics"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -67,7 +81,7 @@
|
|||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
app:layout_constraintTop_toBottomOf="@id/btn_print_report" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_auto_dac"
|
android:id="@+id/btn_auto_dac"
|
||||||
@@ -153,6 +167,7 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_update_values"
|
android:id="@+id/btn_update_values"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -160,12 +175,13 @@
|
|||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:text="Update values"
|
android:text="Update valueLs"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
app:layout_constraintTop_toBottomOf="@id/btn_reset_password" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_firefox"
|
android:id="@+id/btn_firefox"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
158
app/src/main/res/layout/fragment_hb_test.xml
Normal file
158
app/src/main/res/layout/fragment_hb_test.xml
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
~ // Notice: All information contained herein is, and remains
|
||||||
|
~ // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
~ // if any. The intellectual and technical concepts contained
|
||||||
|
~ // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
~ // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
~ // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
~ // Dissemination of this information or reproduction of this material
|
||||||
|
~ // is strictly forbidden unless prior written permission is obtained
|
||||||
|
~ // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.example.hpostesting.presentation.autodac.AutoDacFragment">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <TextView-->
|
||||||
|
<!-- android:id="@+id/tv_title"-->
|
||||||
|
<!-- style="@style/title1"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
|
<!-- android:text="@string/diagnostics"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle2"
|
||||||
|
style="@style/title2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="HB Test"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle3"
|
||||||
|
style="@style/title2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle4"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="320dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:text="Start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle3" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_buffer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Buffer Start"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_sample"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:text="Sample Start"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_buffer" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_submit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:text="Submit"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_sample" />
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_read"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:text="@string/read"-->
|
||||||
|
<!-- android:layout_margin="16dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
|
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_check"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:src="@drawable/check"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:elevation="12dp"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateDrawable="@drawable/progressbar_drawable"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.example.hpostesting.presentation.hemocube.HemoCubeFragment">
|
tools:context="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_parent"
|
android:id="@+id/cl_parent"
|
||||||
|
|||||||
@@ -101,6 +101,26 @@
|
|||||||
android:inputType="textCapCharacters"
|
android:inputType="textCapCharacters"
|
||||||
android:hint="@string/sample_id" />
|
android:hint="@string/sample_id" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/til_age"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/til_name">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/age"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLength="2"
|
||||||
|
android:inputType="number"
|
||||||
|
android:hint="@string/age" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
@@ -112,13 +132,13 @@
|
|||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/til_name">
|
app:layout_constraintTop_toBottomOf="@+id/til_age">
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
android:id="@+id/et_blood_group"
|
android:id="@+id/et_blood_group"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/select_blood_group"
|
android:hint="@string/select_blood_group"
|
||||||
android:inputType="none"
|
android:inputType="none"
|
||||||
android:labelFor="@id/til_blood_group"
|
android:labelFor="@id/til_blood_group"
|
||||||
app:simpleItems="@array/blood_group" />
|
app:simpleItems="@array/blood_group" />
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||||
|
|
||||||
@@ -103,9 +104,9 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="Refresh"
|
android:text="Refresh"
|
||||||
android:visibility="visible"
|
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:layout_constraintEnd_toEndOf="@id/btn_scan_now"
|
android:visibility="visible"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context="com.example.hpostesting.presentation.dashboard.ui.LoginFragment">
|
tools:context="com.example.hpostesting.presentation.main_base.ui.LoginFragment">
|
||||||
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title2" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title2" />
|
||||||
|
|
||||||
|
|||||||
63
app/src/main/res/layout/fragment_report.xml
Normal file
63
app/src/main/res/layout/fragment_report.xml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/searchBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="Search by smaple ID or result"
|
||||||
|
android:imeOptions="actionSearch"
|
||||||
|
android:inputType="text" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="8dp">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/filterSpinner"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:entries="@array/filter_options" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/calendarButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Select Date"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/selectedCountText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Selected: 0"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/bufferRecyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginTop="8dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/generateReportButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Generate Report"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="com.example.hpostesting.presentation.dashboard.SlideshowFragment">
|
tools:context="com.example.hpostesting.presentation.main_base.SlideshowFragment">
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_parent"
|
android:id="@+id/cl_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -88,24 +88,12 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="@id/spinnerCuvette"
|
app:layout_constraintBottom_toBottomOf="@id/spinnerCuvette"
|
||||||
app:layout_constraintStart_toEndOf="@id/spinnerCuvette"
|
app:layout_constraintStart_toEndOf="@id/spinnerCuvette"
|
||||||
app:layout_constraintTop_toTopOf="@id/spinnerCuvette" />
|
app:layout_constraintTop_toTopOf="@id/spinnerCuvette" />
|
||||||
<TextView
|
|
||||||
android:id="@+id/last_updated"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:text="Last"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="17sp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_add_size"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginStart="30dp"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/last_updated"
|
app:layout_constraintTop_toBottomOf="@+id/btn_add_size"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginTop="10dp"/>
|
android:layout_marginTop="10dp"/>
|
||||||
|
|||||||
54
app/src/main/res/layout/item_buffer_card.xml
Normal file
54
app/src/main/res/layout/item_buffer_card.xml
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/cardView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
app:cardCornerRadius="8dp"
|
||||||
|
app:cardElevation="4dp">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sampleId"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Kit No: Sample123"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/selectionIndicator"
|
||||||
|
android:layout_width="12dp"
|
||||||
|
android:layout_height="12dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:background="@drawable/ic_baseline_check_circle_24"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/testTime"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/sampleId"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="Time: 2024-01-15 10:30"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/result"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/testTime"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="Result: Positive"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
6
app/src/main/res/layout/report_gen.xml
Normal file
6
app/src/main/res/layout/report_gen.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_home"
|
android:id="@+id/nav_home"
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.HomeFragment"
|
android:name="com.example.hpostesting.presentation.main_base.HomeFragment"
|
||||||
android:label="@string/menu_home"
|
android:label="@string/menu_home"
|
||||||
app:popUpToInclusive="true"
|
app:popUpToInclusive="true"
|
||||||
app:popUpTo="@id/nav_home"
|
app:popUpTo="@id/nav_home"
|
||||||
@@ -36,23 +36,23 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_profile"
|
android:id="@+id/nav_profile"
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.GalleryFragment"
|
android:name="com.example.hpostesting.presentation.main_base.PanelFragment"
|
||||||
android:label="@string/profile"
|
android:label="@string/profile"
|
||||||
tools:layout="@layout/fragment_gallery" />
|
tools:layout="@layout/fragment_gallery" />
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.SlideshowFragment"
|
android:name="com.example.hpostesting.presentation.main_base.SlideshowFragment"
|
||||||
android:label="@string/action_settings"
|
android:label="@string/action_settings"
|
||||||
tools:layout="@layout/fragment_slideshow" />
|
tools:layout="@layout/fragment_slideshow" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_about"
|
android:id="@+id/nav_about"
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.AboutFragment"
|
android:name="com.example.hpostesting.presentation.main_base.AboutFragment"
|
||||||
android:label="@string/action_about"
|
android:label="@string/action_about"
|
||||||
tools:layout="@layout/fragment_about" />
|
tools:layout="@layout/fragment_about" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_activity"
|
android:id="@+id/nav_activity"
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.ActivitiesFragment"
|
android:name="com.example.hpostesting.presentation.main_base.ActivitiesFragment"
|
||||||
android:label="@string/action_activity"
|
android:label="@string/action_activity"
|
||||||
tools:layout="@layout/fragment_activities" />
|
tools:layout="@layout/fragment_activities" />
|
||||||
<activity
|
<activity
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
android:label="MainActivity" />
|
android:label="MainActivity" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/loginFragment"
|
android:id="@+id/loginFragment"
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.ui.LoginFragment"
|
android:name="com.example.hpostesting.presentation.main_base.ui.LoginFragment"
|
||||||
android:label="@string/login"
|
android:label="@string/login"
|
||||||
tools:layout="@layout/fragment_login" >
|
tools:layout="@layout/fragment_login" >
|
||||||
<action
|
<action
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/hemoCubeFragment"
|
android:id="@+id/hemoCubeFragment"
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.HemoCubeFragment"
|
android:name="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment"
|
||||||
android:label="fragment_hemo_cube_reference"
|
android:label="fragment_hemo_cube_reference"
|
||||||
tools:layout="@layout/fragment_hemo_cube_reference" >
|
tools:layout="@layout/fragment_hemo_cube_reference" >
|
||||||
<action
|
<action
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/digitalCardFragment"
|
android:id="@+id/digitalCardFragment"
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardFragment"
|
android:name="com.example.hpostesting.presentation.trueheme_test.DigitalCardFragment"
|
||||||
android:label="fragment_digital_card"
|
android:label="fragment_digital_card"
|
||||||
tools:layout="@layout/fragment_digital_card" />
|
tools:layout="@layout/fragment_digital_card" />
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -305,4 +305,7 @@
|
|||||||
<string name="quick_capture">Quick Capture</string>
|
<string name="quick_capture">Quick Capture</string>
|
||||||
<string name="reset_password_for_this_device">Reset password for this device</string>
|
<string name="reset_password_for_this_device">Reset password for this device</string>
|
||||||
<string name="calibrate_device">Calibrate the device</string>
|
<string name="calibrate_device">Calibrate the device</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -304,6 +304,9 @@
|
|||||||
<string name="quick_capture">ತ್ವರಿತ ಕ್ಯಾಪ್ಚರ್</string>
|
<string name="quick_capture">ತ್ವರಿತ ಕ್ಯಾಪ್ಚರ್</string>
|
||||||
<string name="reset_password_for_this_device">ಈ ಸಾಧನಕ್ಕಾಗಿ ಪಾಸ್ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಿ</string>
|
<string name="reset_password_for_this_device">ಈ ಸಾಧನಕ್ಕಾಗಿ ಪಾಸ್ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಿ</string>
|
||||||
<string name="calibrate_device">ಸಾಧನವನ್ನು ಮಾಪನಾಂಕ ಮಾಡಿ</string>
|
<string name="calibrate_device">ಸಾಧನವನ್ನು ಮಾಪನಾಂಕ ಮಾಡಿ</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
|
|
||||||
<!-- Add translations for other strings -->
|
<!-- Add translations for other strings -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
<item>ka</item>
|
<item>ka</item>
|
||||||
<!-- Use language codes (e.g., en, kn) as values -->
|
<!-- Use language codes (e.g., en, kn) as values -->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="district">
|
<string-array name="district">
|
||||||
<item>Mysuru</item>
|
<item>Mysuru</item>
|
||||||
<item>Kodagu</item>
|
<item>Kodagu</item>
|
||||||
@@ -32,4 +33,13 @@
|
|||||||
<item>Other</item>
|
<item>Other</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|
||||||
|
<string-array name="filter_options">
|
||||||
|
<item>Today</item>
|
||||||
|
<item>Yesterday</item>
|
||||||
|
<item>All</item>
|
||||||
|
<item>Custom Date</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
<string name="acquire">Acquire</string>
|
<string name="acquire">Acquire</string>
|
||||||
<string name="enter_patient_details">Enter Patient Details</string>
|
<string name="enter_patient_details">Enter Patient Details</string>
|
||||||
<string name="patient_name">Patient Name</string>
|
<string name="patient_name">Patient Name</string>
|
||||||
<string name="age">Age in years</string>
|
<string name="age">Age</string>
|
||||||
<string name="gender">Gender</string>
|
<string name="gender">Gender</string>
|
||||||
<string name="name_error">Name can\'t be empty</string>
|
<string name="name_error">Name can\'t be empty</string>
|
||||||
<string name="age_error">Age can\'t be empty</string>
|
<string name="age_error">Age can\'t be empty</string>
|
||||||
@@ -305,4 +305,7 @@
|
|||||||
<string name="quick_capture">Quick Capture</string>
|
<string name="quick_capture">Quick Capture</string>
|
||||||
<string name="reset_password_for_this_device">Reset password for this device</string>
|
<string name="reset_password_for_this_device">Reset password for this device</string>
|
||||||
<string name="calibrate_device">Calibrate Device</string>
|
<string name="calibrate_device">Calibrate Device</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
|
||||||
~ // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
~ // Notice: All information contained herein is, and remains
|
|
||||||
~ // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
~ // if any. The intellectual and technical concepts contained
|
|
||||||
~ // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
~ // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
~ // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
~ // Dissemination of this information or reproduction of this material
|
|
||||||
~ // is strictly forbidden unless prior written permission is obtained
|
|
||||||
~ // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
-->
|
|
||||||
<defaultsMap>
|
|
||||||
<entry>
|
|
||||||
<key>BUFFER_FLAGS_ENABLED</key>
|
|
||||||
<value>true</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveBoderLine10mm1</key>
|
|
||||||
<value>1.3</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveBoderLine10mm2</key>
|
|
||||||
<value>1.66</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBoderLine10mm1</key>
|
|
||||||
<value>2.0</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBoderLine10mm2</key>
|
|
||||||
<value>2.4</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>normalMin10mm</key>
|
|
||||||
<value>0.1</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>normalMax10mm</key>
|
|
||||||
<value>0.23</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBorderlineMin10mm</key>
|
|
||||||
<value>0.23</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBorderlineMax10mm</key>
|
|
||||||
<value>0.25</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellTraitMin10mm</key>
|
|
||||||
<value>0.25</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellTraitMax10mm</key>
|
|
||||||
<value>0.31</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveForSickleCellMin10mm</key>
|
|
||||||
<value>0.31</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveForSickleCellMax10mm</key>
|
|
||||||
<value>0.43</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellDiseaseMin10mm</key>
|
|
||||||
<value>0.43</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellDiseaseMax10mm</key>
|
|
||||||
<value>0.7</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveBoderLine2mm1</key>
|
|
||||||
<value>0.8</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveBoderLine2mm2</key>
|
|
||||||
<value>1.1</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBoderLine2mm1</key>
|
|
||||||
<value>1.5</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBoderLine2mm2</key>
|
|
||||||
<value>1.9</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>normalMin2mm</key>
|
|
||||||
<value>0.1</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>normalMax2mm</key>
|
|
||||||
<value>0.23</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBorderlineMin2mm</key>
|
|
||||||
<value>0.23</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>negativeBorderlineMax2mm</key>
|
|
||||||
<value>0.25</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellTraitMin2mm</key>
|
|
||||||
<value>0.25</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellTraitMax2mm</key>
|
|
||||||
<value>0.31</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveForSickleCellMin2mm</key>
|
|
||||||
<value>0.31</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>positiveForSickleCellMax2mm</key>
|
|
||||||
<value>0.45</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellDiseaseMin2mm</key>
|
|
||||||
<value>0.45</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>sickleCellDiseaseMax2mm</key>
|
|
||||||
<value>0.7</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>bufferMinLed1</key>
|
|
||||||
<value>21000.00</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>bufferMaxLed1</key>
|
|
||||||
<value>23000.00</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>bufferMinLed2</key>
|
|
||||||
<value>17000.00</value>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<key>bufferMaxLed2</key>
|
|
||||||
<value>19000.00</value>
|
|
||||||
</entry>
|
|
||||||
</defaultsMap>
|
|
||||||
@@ -16,12 +16,12 @@ package com.example.hpostesting
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
||||||
|
import com.example.hpostesting.util.NetworkMonitor
|
||||||
import io.mockk.*
|
import io.mockk.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@@ -43,7 +43,7 @@ class AutoDacViewModelTest {
|
|||||||
private val repository = mockk<Repository>()
|
private val repository = mockk<Repository>()
|
||||||
private val context = mockk<Context>()
|
private val context = mockk<Context>()
|
||||||
private val sharedPreferences = mockk<SharedPreferences>()
|
private val sharedPreferences = mockk<SharedPreferences>()
|
||||||
private val networkStatusLiveData = mockk<NetworkStatusLiveData>()
|
private val networkStatusLiveData = mockk<NetworkMonitor>()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
@@ -54,7 +54,7 @@ class AutoDacViewModelTest {
|
|||||||
every { context.getSystemService(any()) } returns networkStatusLiveData
|
every { context.getSystemService(any()) } returns networkStatusLiveData
|
||||||
|
|
||||||
// Mocking the NetworkStatusLiveData
|
// Mocking the NetworkStatusLiveData
|
||||||
every { networkStatusLiveData.observe(any(), any()) } just Runs
|
every { networkStatusLiveData.startMonitoring() } just Runs
|
||||||
|
|
||||||
every { hemoCubeDao.getAll() } returns mockk()
|
every { hemoCubeDao.getAll() } returns mockk()
|
||||||
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.example.hpostesting.util.Result
|
|||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||||
import com.example.hpostesting.util.TestCoroutineRule
|
import com.example.hpostesting.util.TestCoroutineRule
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.impl.annotations.MockK
|
import io.mockk.impl.annotations.MockK
|
||||||
@@ -59,7 +59,7 @@ class HemocubeViewModelTest {
|
|||||||
@MockK(relaxed = true)
|
@MockK(relaxed = true)
|
||||||
lateinit var observer: Observer<Result<LoginResponse>>
|
lateinit var observer: Observer<Result<LoginResponse>>
|
||||||
|
|
||||||
private lateinit var viewModel: HemoCubeViewModel
|
private lateinit var viewModel: TrueHemeTestViewModel
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment
|
||||||
import junit.framework.TestCase.assertEquals
|
import junit.framework.TestCase.assertEquals
|
||||||
import junit.framework.TestCase.assertNull
|
import junit.framework.TestCase.assertNull
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@@ -24,17 +24,17 @@ import org.mockito.Mock
|
|||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
class HemoCubeFragmentTest {
|
class TrueHemeTestFragmentTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mockSharedPreferences: SharedPreferences
|
private lateinit var mockSharedPreferences: SharedPreferences
|
||||||
|
|
||||||
private lateinit var hemoCubeFragment: HemoCubeFragment
|
private lateinit var trueHemeTestFragment: TrueHemeTestFragment
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
hemoCubeFragment = HemoCubeFragment()
|
trueHemeTestFragment = TrueHemeTestFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -48,7 +48,7 @@ class HemoCubeFragmentTest {
|
|||||||
).thenReturn("dummy_value")
|
).thenReturn("dummy_value")
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val deviceId = hemoCubeFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
val deviceId = trueHemeTestFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP1-9000", deviceId)
|
assertEquals("HPP1-9000", deviceId)
|
||||||
@@ -81,11 +81,11 @@ class HemoCubeFragmentTest {
|
|||||||
val readingsPerSample = 1
|
val readingsPerSample = 1
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
val result = trueHemeTestFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals(true, result)
|
assertEquals(true, result)
|
||||||
assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
assertEquals(trueHemeTestFragment.allReadingsComplete(0, 1), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -94,7 +94,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input = "Some text SN ABC123 some more text"
|
val input = "Some text SN ABC123 some more text"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("ABC123", result)
|
assertEquals("ABC123", result)
|
||||||
@@ -106,7 +106,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input = "Some text without SN"
|
val input = "Some text without SN"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -118,7 +118,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input = ""
|
val input = ""
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -130,7 +130,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input: String? = null
|
val input: String? = null
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = input?.let { hemoCubeFragment.extractV1HardwareId(it) }
|
val result = input?.let { trueHemeTestFragment.extractV1HardwareId(it) }
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -158,7 +158,7 @@ class HemoCubeFragmentTest {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HCV-000-3001", result)
|
assertEquals("HCV-000-3001", result)
|
||||||
@@ -170,7 +170,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input = "SNS ABC123 SNE"
|
val input = "SNS ABC123 SNE"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("ABC123", result)
|
assertEquals("ABC123", result)
|
||||||
@@ -182,7 +182,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input = "No hardware ID in this input"
|
val input = "No hardware ID in this input"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -194,7 +194,7 @@ class HemoCubeFragmentTest {
|
|||||||
val input = "SNS XYZ789 SNE"
|
val input = "SNS XYZ789 SNE"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("XYZ789", result)
|
assertEquals("XYZ789", result)
|
||||||
@@ -218,7 +218,7 @@ class HemoCubeFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HCV-000-3013", result)
|
assertEquals("HCV-000-3013", result)
|
||||||
@@ -241,7 +241,7 @@ class HemoCubeFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP1-4001", result)
|
assertEquals("HPP1-4001", result)
|
||||||
@@ -264,7 +264,7 @@ class HemoCubeFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP1-000-4001", result)
|
assertEquals("HPP1-000-4001", result)
|
||||||
@@ -287,7 +287,7 @@ class HemoCubeFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP-000-4001", result)
|
assertEquals("HPP-000-4001", result)
|
||||||
@@ -310,7 +310,7 @@ class HemoCubeFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP-000-5001", result)
|
assertEquals("HPP-000-5001", result)
|
||||||
@@ -318,111 +318,123 @@ class HemoCubeFragmentTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationNormalWithStartRange() {
|
fun testDeviceRatioClassificationNormalWithStartRange() {
|
||||||
val ratio = 0.16
|
val ratio = 0.08
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationNormal() {
|
fun testDeviceRatioClassificationNormal() {
|
||||||
val ratio = 0.22
|
val ratio = 0.22
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||||
val ratio = 0.235
|
val ratio = 0.235
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
|
assertEquals("Negative Borderline", result)
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
fun testDeviceRatioClassificationNegativeBorderlineUpperBound() {
|
||||||
|
val ratio = 0.265
|
||||||
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Negative Borderline", result)
|
assertEquals("Negative Borderline", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellTraitLowerBound() {
|
fun testDeviceRatioClassificationSickleCellTraitLowerBound() {
|
||||||
val ratio = 0.251
|
val ratio = 0.271
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Negative Borderline", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellTraitUpperBound() {
|
fun testDeviceRatioClassificationSickleCellTraitUpperBound() {
|
||||||
val ratio = 0.309
|
val ratio = 0.309
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||||
|
val ratio = 0.312
|
||||||
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
|
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
fun testDeviceRatioClassificationPositiveForSickleCellUpperBound() {
|
||||||
val ratio = 0.39
|
val ratio = 0.39
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() {
|
fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() {
|
||||||
val ratio = 0.391
|
val ratio = 0.391
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellDisease() {
|
fun testDeviceRatioClassificationSickleCellDisease() {
|
||||||
val ratio = 0.45
|
val ratio = 0.691
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationInvalid() {
|
fun testDeviceRatioClassificationInvalid() {
|
||||||
val ratio: Double? = null
|
val ratio: Double? = null
|
||||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||||
assertEquals("Invalid", result)
|
assertEquals("Invalid", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
||||||
val result =
|
val result =
|
||||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5)
|
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Negative Borderline", 2.5)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
||||||
val result =
|
val result =
|
||||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2)
|
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Negative Borderline", 2.2)
|
||||||
assertEquals("Negative borderline. Confirm with HPLC", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||||
0.5,
|
"10mm",0.5,
|
||||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
1.4
|
1.4
|
||||||
)
|
)
|
||||||
assertEquals("Positive for Sickle Cell. Confirm with HPLC", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||||
0.5,
|
"10mm",0.5,
|
||||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
1.33
|
1.33
|
||||||
)
|
)
|
||||||
assertEquals("Positive for Sickle Cell. Confirm with HPLC", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
val result = trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Normal", 30.0)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||||
0.5,
|
"10mm",0.5,
|
||||||
"Negative Borderline, Repeat Test",
|
"Negative Borderline, Repeat Test",
|
||||||
70.0
|
70.0
|
||||||
)
|
)
|
||||||
@@ -432,14 +444,14 @@ class HemoCubeFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
||||||
val result =
|
val result =
|
||||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Sickle Cell Trait", 70.0)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||||
0.5,
|
"10mm",0.5,
|
||||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
1.67
|
1.67
|
||||||
)
|
)
|
||||||
@@ -449,7 +461,7 @@ class HemoCubeFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
||||||
val result =
|
val result =
|
||||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Sickle Cell Disease", 70.0)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +473,7 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.2
|
val led2Average = 0.2
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -479,7 +491,7 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.14
|
val led2Average = 0.14
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -497,7 +509,7 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.18
|
val led2Average = 0.18
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -515,7 +527,7 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.195
|
val led2Average = 0.195
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -533,7 +545,7 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.189
|
val led2Average = 0.189
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -25,4 +25,3 @@ plugins {
|
|||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user