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
54282bb7
Commit
54282bb7
authored
May 16, 2024
by
Malsha Jayakody
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/exercise-manage' into final-app
parents
bb74bb1a
d8b561e1
Changes
4
Show 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 @
54282bb7
...
@@ -20,6 +20,7 @@ export default {
...
@@ -20,6 +20,7 @@ export default {
EXERCISE_HOME
:
'
Exercise_Home
'
,
EXERCISE_HOME
:
'
Exercise_Home
'
,
EXERCISE_FORM
:
'
Health_Form
'
,
EXERCISE_FORM
:
'
Health_Form
'
,
EXERCISE_MAIN_MENU
:
'
Exercise_Home_Menu
'
,
EXERCISE_MAIN_MENU
:
'
Exercise_Home_Menu
'
,
EXERCISE_MAIN_NEW_MENU
:
'
Exercise_Home_New_Menu
'
,
EXERCISE_VIEW
:
'
Exercise_View
'
,
EXERCISE_VIEW
:
'
Exercise_View
'
,
EXERCISE_ACTION_VIEW
:
'
Exercise_ACTION_View
'
,
EXERCISE_ACTION_VIEW
:
'
Exercise_ACTION_View
'
,
EXERCISE_PROGRESS
:
'
Exercise_PROGRESS
'
,
EXERCISE_PROGRESS
:
'
Exercise_PROGRESS
'
,
...
...
src/navigations/ExerciseNavigator.js
View file @
54282bb7
...
@@ -68,7 +68,7 @@ function ExerciseNavigator() {
...
@@ -68,7 +68,7 @@ function ExerciseNavigator() {
<>
<>
<
Stack
.
Screen
name
=
{
ROUTES
.
EXERCISE_WELCOME
}
component
=
{
WelcomeExercise
}
key
=
"
ExerciseWelcome
"
/>
<
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_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
>
<
/Stack.Navigator
>
...
...
src/screens/home/exercise/HealthFormExercise.js
View file @
54282bb7
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
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
{
Formik
}
from
'
formik
'
;
import
CheckBox
from
'
@react-native-community/checkbox
'
;
import
CheckBox
from
'
@react-native-community/checkbox
'
;
import
LinearGradient
from
'
react-native-linear-gradient
'
;
import
LinearGradient
from
'
react-native-linear-gradient
'
;
import
{
COLORS
,
IMGS
,
ROUTES
}
from
'
../../../constants
'
;
import
{
COLORS
,
IMGS
,
ROUTES
}
from
'
../../../constants
'
;
import
Button
from
'
../../../components/Button
'
;
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
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
database
from
'
@react-native-firebase/database
'
;
import
database
from
'
@react-native-firebase/database
'
;
import
Dot
from
'
../../../assets/icons/dot.svg
'
;
import
Dot
from
'
../../../assets/icons/dot.svg
'
;
...
@@ -20,34 +20,50 @@ const HealthFormExercise = (props) => {
...
@@ -20,34 +20,50 @@ const HealthFormExercise = (props) => {
const
[
initialBodyTemp
,
setInitialBodyTemp
]
=
useState
();
const
[
initialBodyTemp
,
setInitialBodyTemp
]
=
useState
();
const
[
initialHeartRate
,
setInitialHeartRate
]
=
useState
();
const
[
initialHeartRate
,
setInitialHeartRate
]
=
useState
();
const
[
dataArray
,
setDataArray
]
=
useState
(
null
);
const
[
dataArray
,
setDataArray
]
=
useState
(
null
);
const
[
isWearbleDevice
,
setIsWearbleDevice
]
=
useState
(
false
);
const
[
wearableModalVisible
,
setWearableModalVisible
]
=
useState
(
false
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
isWearbleDevice
)
{
// Reference to your Firebase Realtime Database
// Reference to your Firebase Realtime Database
const
databaseRef
=
database
().
ref
(
'
test
'
);
const
databaseRef
=
database
().
ref
(
'
test
'
);
ToastAndroid
.
show
(
'
Data reading on device !
'
,
ToastAndroid
.
SHORT
);
ToastAndroid
.
show
(
'
Data reading on device !
'
,
ToastAndroid
.
SHORT
);
// Attach an asynchronous listener to read the data at our reference
// Attach an asynchronous listener to read the data at our reference
const
onDataChange
=
(
snapshot
)
=>
{
const
onDataChange
=
(
snapshot
)
=>
{
const
data
=
snapshot
.
val
();
const
data
=
snapshot
.
val
();
setDataArray
(
data
);
setDataArray
(
data
);
console
.
log
(
"
dada
"
,
data
)
console
.
log
(
"
data
"
,
data
);
};
};
updateDeviceState
()
databaseRef
.
on
(
'
value
'
,
onDataChange
);
databaseRef
.
on
(
'
value
'
,
onDataChange
);
// Detach the listener when component unmount
s
// Detach the listener when component unmounts or when isWearableDevice change
s
return
()
=>
{
return
()
=>
{
databaseRef
.
off
(
'
value
'
,
onDataChange
);
databaseRef
.
off
(
'
value
'
,
onDataChange
);
};
};
},
[]);
// Empty dependency array to run the effect only once
}
const
onSubmit
=
async
(
values
)
=>
{
},
[
isWearbleDevice
]);
const
updateDeviceState
=
async
()
=>
{
let
userDataString
=
await
AsyncStorage
.
getItem
(
'
userData
'
);
let
userDataString
=
await
AsyncStorage
.
getItem
(
'
userData
'
);
let
userData
=
JSON
.
parse
(
userDataString
);
let
userData
=
JSON
.
parse
(
userDataString
);
console
.
log
(
userData
)
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"
//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
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
;
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) => {
...
@@ -76,7 +92,7 @@ const HealthFormExercise = (props) => {
return
(
return
(
<
SafeAreaView
>
<
SafeAreaView
>
<
Formik
<
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)}
onSubmit={values => onSubmit(values)}
enableReinitialize={true}
enableReinitialize={true}
>
>
...
@@ -117,13 +133,46 @@ const HealthFormExercise = (props) => {
...
@@ -117,13 +133,46 @@ const HealthFormExercise = (props) => {
/>
/>
</View>
</View>
<View style={Styles.closeDiv}>
<View style={Styles.closeDiv}>
<TouchableOpacity onPress={() =>
setModalVisible(false)
}>
<TouchableOpacity onPress={() =>
{ setModalVisible(false); setWearableModalVisible(true) }
}>
<Text style={Styles.closeButton}>Close</Text>
<Text style={Styles.closeButton}>Close</Text>
</TouchableOpacity>
</TouchableOpacity>
</View>
</View>
</View>
</View>
</View>
</View>
</Modal>
</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>
<Text style={Styles.textInputLabel}>SystolicBP (mmHg)</Text>
<View style={Styles.inputBox}>
<View style={Styles.inputBox}>
...
@@ -237,6 +286,13 @@ const Styles = StyleSheet.create({
...
@@ -237,6 +286,13 @@ const Styles = StyleSheet.create({
fontSize: 18,
fontSize: 18,
fontWeight: 'bold',
fontWeight: 'bold',
},
},
closeNewButton: {
marginTop: 10,
color: COLORS.danger,
textAlign: 'center',
fontSize: 18,
fontWeight: 'bold',
},
submitButton: {
submitButton: {
backgroundColor: '#1899D6',
backgroundColor: '#1899D6',
borderRadius: 10, // Adjust the border radius as needed
borderRadius: 10, // Adjust the border radius as needed
...
@@ -354,8 +410,17 @@ const Styles = StyleSheet.create({
...
@@ -354,8 +410,17 @@ const Styles = StyleSheet.create({
display: "flex",
display: "flex",
flexDirection: "row",
flexDirection: "row",
justifyContent: "center",
justifyContent: "center",
alignItems:"center",
alignItems:
"center",
width: "100%"
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 @
54282bb7
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
const
BASE_PATH
=
'
http://1
39.162.3.203:801
0
'
;
const
BASE_PATH
=
'
http://1
6.170.242.186:808
0
'
;
const
BASE_PATH2
=
'
http://1
39.162.3.203
:8070/api/mother
'
;
const
BASE_PATH2
=
'
http://1
0.0.2.2
:8070/api/mother
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
//initialize payment API Call
export
let
meternalHealthPredict
=
async
(
Age
,
SystolicBP
,
DiastolicBP
,
Blood_glucose
,
BodyTemp
,
HeartRate
)
=>
{
export
let
meternalHealthPredict
=
async
(
Age
,
SystolicBP
,
DiastolicBP
,
Blood_glucose
,
BodyTemp
,
HeartRate
)
=>
{
try
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH
+
'
/predict
'
,
{
let
value
=
await
axios
.
post
(
BASE_PATH
+
'
/predict
'
,
{
...
@@ -22,7 +21,6 @@ export let meternalHealthPredict = async (Age,SystolicBP, DiastolicBP, Blood_glu
...
@@ -22,7 +21,6 @@ export let meternalHealthPredict = async (Age,SystolicBP, DiastolicBP, Blood_glu
}
}
//initialize payment API Call
export
let
addInitialExercises
=
async
(
id
,
riskLevel
)
=>
{
export
let
addInitialExercises
=
async
(
id
,
riskLevel
)
=>
{
try
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/initial_exercises
'
,
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/initial_exercises
'
,
{
...
@@ -36,7 +34,7 @@ export let addInitialExercises = async (id, riskLevel) => {
...
@@ -36,7 +34,7 @@ export let addInitialExercises = async (id, riskLevel) => {
}
}
//initialize payment API Call
export
let
getAllExerciseDay
=
async
(
id
,
dateNum
)
=>
{
export
let
getAllExerciseDay
=
async
(
id
,
dateNum
)
=>
{
try
{
try
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/get_all_exercise_day
'
,
{
let
value
=
await
axios
.
post
(
BASE_PATH2
+
'
/get_all_exercise_day
'
,
{
...
@@ -48,3 +46,16 @@ export let getAllExerciseDay = async (id, dateNum) => {
...
@@ -48,3 +46,16 @@ export let getAllExerciseDay = async (id, dateNum) => {
return
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