Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EmidWife-New
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-24-005
EmidWife-New
Commits
d8b561e1
Commit
d8b561e1
authored
May 16, 2024
by
isuraem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes_in_exercise
parent
e307cf1f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
31 deletions
+108
-31
src/constants/routes.js
src/constants/routes.js
+1
-0
src/navigations/ExerciseNavigator.js
src/navigations/ExerciseNavigator.js
+1
-1
src/screens/home/exercise/HealthFormExercise.js
src/screens/home/exercise/HealthFormExercise.js
+90
-25
src/services/exercises/index.js
src/services/exercises/index.js
+16
-5
No files found.
src/constants/routes.js
View file @
d8b561e1
...
...
@@ -20,6 +20,7 @@ export default {
EXERCISE_HOME
:
'
Exercise_Home
'
,
EXERCISE_FORM
:
'
Health_Form
'
,
EXERCISE_MAIN_MENU
:
'
Exercise_Home_Menu
'
,
EXERCISE_MAIN_NEW_MENU
:
'
Exercise_Home_New_Menu
'
,
EXERCISE_VIEW
:
'
Exercise_View
'
,
EXERCISE_ACTION_VIEW
:
'
Exercise_ACTION_View
'
,
EXERCISE_PROGRESS
:
'
Exercise_PROGRESS
'
...
...
src/navigations/ExerciseNavigator.js
View file @
d8b561e1
...
...
@@ -68,7 +68,7 @@ function ExerciseNavigator() {
<>
<
Stack
.
Screen
name
=
{
ROUTES
.
EXERCISE_WELCOME
}
component
=
{
WelcomeExercise
}
key
=
"
ExerciseWelcome
"
/>
<
Stack
.
Screen
name
=
{
ROUTES
.
EXERCISE_FORM
}
component
=
{
HealthFormExercise
}
key
=
"
ExerciseForm
"
/>
<
Stack
.
Screen
name
=
{
ROUTES
.
EXERCISE_MAIN_
MENU
}
component
=
{
MainMenuExercise
}
key
=
"
MainMenu
Exercise
"
/>
<
Stack
.
Screen
name
=
{
ROUTES
.
EXERCISE_MAIN_
NEW_MENU
}
component
=
{
MainMenuExercise
}
key
=
"
MainMenuNew
Exercise
"
/>
<
/
>
)}
<
/Stack.Navigator
>
...
...
src/screens/home/exercise/HealthFormExercise.js
View file @
d8b561e1
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
{
TextInput
,
View
,
SafeAreaView
,
KeyboardAvoidingView
,
TouchableOpacity
,
Text
,
Modal
,
StyleSheet
,
ScrollView
,
ToastAndroid
,
Image
}
from
'
react-native
'
;
import
{
TextInput
,
View
,
SafeAreaView
,
KeyboardAvoidingView
,
TouchableOpacity
,
Text
,
Modal
,
StyleSheet
,
ScrollView
,
ToastAndroid
,
Image
}
from
'
react-native
'
;
import
{
Formik
}
from
'
formik
'
;
import
CheckBox
from
'
@react-native-community/checkbox
'
;
import
LinearGradient
from
'
react-native-linear-gradient
'
;
import
{
COLORS
,
IMGS
,
ROUTES
}
from
'
../../../constants
'
;
import
Button
from
'
../../../components/Button
'
;
import
{
meternalHealthPredict
,
addInitialExercises
}
from
'
../../../services/exercises/index
'
;
import
{
meternalHealthPredict
,
addInitialExercises
,
updateDeviceStatus
}
from
'
../../../services/exercises/index
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
database
from
'
@react-native-firebase/database
'
;
import
Dot
from
'
../../../assets/icons/dot.svg
'
;
...
...
@@ -20,34 +20,50 @@ const HealthFormExercise = (props) => {
const
[
initialBodyTemp
,
setInitialBodyTemp
]
=
useState
();
const
[
initialHeartRate
,
setInitialHeartRate
]
=
useState
();
const
[
dataArray
,
setDataArray
]
=
useState
(
null
);
const
[
isWearbleDevice
,
setIsWearbleDevice
]
=
useState
(
false
);
const
[
wearableModalVisible
,
setWearableModalVisible
]
=
useState
(
false
);
useEffect
(()
=>
{
// Reference to your Firebase Realtime Database
const
databaseRef
=
database
().
ref
(
'
test
'
);
ToastAndroid
.
show
(
'
Data reading on device !
'
,
ToastAndroid
.
SHORT
);
// Attach an asynchronous listener to read the data at our reference
const
onDataChange
=
(
snapshot
)
=>
{
const
data
=
snapshot
.
val
();
setDataArray
(
data
);
console
.
log
(
"
dada
"
,
data
)
};
if
(
isWearbleDevice
)
{
// Reference to your Firebase Realtime Database
const
databaseRef
=
database
().
ref
(
'
test
'
);
ToastAndroid
.
show
(
'
Data reading on device !
'
,
ToastAndroid
.
SHORT
);
databaseRef
.
on
(
'
value
'
,
onDataChange
);
// Attach an asynchronous listener to read the data at our reference
const
onDataChange
=
(
snapshot
)
=>
{
const
data
=
snapshot
.
val
();
setDataArray
(
data
);
console
.
log
(
"
data
"
,
data
);
};
updateDeviceState
()
databaseRef
.
on
(
'
value
'
,
onDataChange
);
// Detach the listener when component unmounts
return
()
=>
{
databaseRef
.
off
(
'
value
'
,
onDataChange
);
};
},
[]);
// Empty dependency array to run the effect only once
const
onSubmit
=
async
(
values
)
=>
{
// Detach the listener when component unmounts or when isWearableDevice changes
return
()
=>
{
databaseRef
.
off
(
'
value
'
,
onDataChange
);
};
}
},
[
isWearbleDevice
]);
const
updateDeviceState
=
async
()
=>
{
let
userDataString
=
await
AsyncStorage
.
getItem
(
'
userData
'
);
let
userData
=
JSON
.
parse
(
userDataString
);
console
.
log
(
userData
)
let
respond
=
await
meternalHealthPredict
(
userData
.
age
,
values
.
SystolicBP
,
values
.
DiastolicBP
,
values
.
Blood_glucose
,
values
.
BodyTemp
,
values
.
HeartRate
);
let
deviceStatus
=
isWearbleDevice
;
await
updateDeviceStatus
(
userData
.
_id
,
deviceStatus
);
}
if
(
respond
.
data
.
prediction
)
{
const
onSubmit
=
async
(
values
)
=>
{
let
userDataString
=
await
AsyncStorage
.
getItem
(
'
userData
'
);
let
userData
=
JSON
.
parse
(
userDataString
);
console
.
log
(
values
)
let
respond
=
await
meternalHealthPredict
(
userData
.
age
,
values
.
SystolicBP
,
values
.
DiastolicBP
,
values
.
Blood_glucose
,
values
.
BodyTemp
,
values
.
HeartRate
);
console
.
log
(
respond
)
if
(
respond
)
{
ToastAndroid
.
show
(
'
Prediction getting successfully !
'
,
ToastAndroid
.
SHORT
);
//0:"high risk",1:"low risk",2:"mid risk"
let
prediction
=
respond
.
data
.
prediction
===
"
high risk
"
?
0
:
respond
.
data
.
prediction
===
"
low risk
"
?
1
:
respond
.
data
.
prediction
===
"
mid risk
"
?
2
:
null
;
let
predictionStatus
=
respond
.
data
.
prediction
===
"
high risk
"
?
20
:
respond
.
data
.
prediction
===
"
low risk
"
?
0
:
respond
.
data
.
prediction
===
"
mid risk
"
?
10
:
null
;
...
...
@@ -76,7 +92,7 @@ const HealthFormExercise = (props) => {
return
(
<
SafeAreaView
>
<
Formik
initialValues
=
{{
SystolicBP
:
''
,
DiastolicBP
:
''
,
Blood_glucose
:
''
,
BodyTemp
:
`
${
dataArray
?.
temp
}
` || '', HeartRate: `
$
{
dataArray
?.
bpm
}
` ||
'' }}
initialValues
=
{{
SystolicBP
:
''
,
DiastolicBP
:
''
,
Blood_glucose
:
''
,
BodyTemp
:
isWearbleDevice
?
`
${
dataArray
?.
temp
}
` : '', HeartRate: isWearbleDevice ? `
$
{
dataArray
?.
bpm
}
` :
'' }}
onSubmit={values => onSubmit(values)}
enableReinitialize={true}
>
...
...
@@ -110,20 +126,53 @@ const HealthFormExercise = (props) => {
//borderRadius style will help us make the Round Shape Image
style={{ width: 72, height: 100, borderRadius: 20, paddingVertical: 10, paddingHorizontal: 10, marginLeft: 20, marginTop: 10 }}
/>
<Image
<Image
source={require("../../../assets/glucose.jpg")}
//borderRadius style will help us make the Round Shape Image
style={{ width: 72, height: 100, borderRadius: 20, paddingVertical: 10, paddingHorizontal: 10, marginLeft: 20, marginTop: 10 }}
/>
</View>
<View style={Styles.closeDiv}>
<TouchableOpacity onPress={() =>
setModalVisible(false)
}>
<TouchableOpacity onPress={() =>
{ setModalVisible(false); setWearableModalVisible(true) }
}>
<Text style={Styles.closeButton}>Close</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
<Modal
animationType="slide"
transparent={true}
visible={wearableModalVisible}
onRequestClose={() => {
setWearableModalVisible(!wearableModalVisible);
}}
>
<View style={Styles.centeredView}>
<View style={Styles.modalView}>
<Text>Do you have a wearable device?</Text>
<View style={Styles.buttonRow}>
<TouchableOpacity
onPress={() => {
setIsWearbleDevice(true);
setWearableModalVisible(false);
}}
>
<Text style={Styles.closeButton}>Yes</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
setWearableModalVisible(false);
}}
>
<Text style={Styles.closeNewButton}>No</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
<Text style={Styles.textInputLabel}>SystolicBP (mmHg)</Text>
<View style={Styles.inputBox}>
...
...
@@ -237,6 +286,13 @@ const Styles = StyleSheet.create({
fontSize: 18,
fontWeight: 'bold',
},
closeNewButton: {
marginTop: 10,
color: COLORS.danger,
textAlign: 'center',
fontSize: 18,
fontWeight: 'bold',
},
submitButton: {
backgroundColor: '#1899D6',
borderRadius: 10, // Adjust the border radius as needed
...
...
@@ -354,8 +410,17 @@ const Styles = StyleSheet.create({
display: "flex",
flexDirection: "row",
justifyContent: "center",
alignItems:"center",
alignItems:
"center",
width: "100%"
},
buttonRow: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center',
width: '100%',
marginTop: 10,
gap: 20
}
});
src/services/exercises/index.js
View file @
d8b561e1
import
axios
from
"
axios
"
;
const
BASE_PATH
=
'
http://1
39.162.3.203:801
0
'
;
const
BASE_PATH2
=
'
http://1
39.162.3.203
:8070/api/mother
'
;
const
BASE_PATH
=
'
http://1
6.170.242.186:808
0
'
;
const
BASE_PATH2
=
'
http://1
0.0.2.2
:8070/api/mother
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
//initialize payment API Call
export
let
meternalHealthPredict
=
async
(
Age
,
SystolicBP
,
DiastolicBP
,
Blood_glucose
,
BodyTemp
,
HeartRate
)
=>
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH
+
'
/predict
'
,
{
...
...
@@ -22,7 +21,6 @@ export let meternalHealthPredict = async (Age,SystolicBP, DiastolicBP, Blood_glu
}
//initialize payment API Call
export
let
addInitialExercises
=
async
(
id
,
riskLevel
)
=>
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/initial_exercises
'
,
{
...
...
@@ -36,7 +34,7 @@ export let addInitialExercises = async (id, riskLevel) => {
}
//initialize payment API Call
export
let
getAllExerciseDay
=
async
(
id
,
dateNum
)
=>
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/get_all_exercise_day
'
,
{
...
...
@@ -47,4 +45,17 @@ export let getAllExerciseDay = async (id, dateNum) => {
}
catch
(
error
)
{
return
error
}
}
export
let
updateDeviceStatus
=
async
(
id
,
deviceStatus
)
=>
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/update_device_status
'
,
{
_id
:
id
,
deviceStatus
:
deviceStatus
})
return
value
;
}
catch
(
error
)
{
return
error
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment