Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Fischer Pedersen
AIR
Commits
f69bba75
Commit
f69bba75
authored
Dec 17, 2021
by
Christian Marius Lillelund
Browse files
Merge branch 'master' of
https://gitlab.au.dk/cfp/air
parents
e8b5e276
ab649567
Pipeline
#99980
passed with stage
in 4 minutes and 35 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
web/api/server.js
View file @
f69bba75
...
...
@@ -25,7 +25,8 @@ app.use(express.urlencoded({ extended: true }));
};*/
const
log
=
bunyan
.
createLogger
({
name
:
"
AIR_UI_Backend:
"
});
const
predictionURL_training_fall
=
'
https://air-fastapi.azurewebsites.net/predict_training
'
const
predictionURL_training
=
'
https://air-fastapi.azurewebsites.net/predict_training
'
const
predictionURL_alarm
=
'
https://air-fastapi.azurewebsites.net/predict_alarm
'
async
function
deleteVariable
(
variablesMarkedForDeletion
)
{
variablesMarkedForDeletion
.
forEach
(
element
=>
{
...
...
@@ -53,11 +54,20 @@ function dataPreparationForML(age, gender, assistiveAids, loanPeriod) {
}
}
async
function
get
ML
Prediction
(
inputFor
ML
Prediction
)
{
predictionResult
=
axios
.
post
(
predictionURL_training
_fall
,
inputFor
ML
Prediction
).
then
(
result
=>
{
async
function
get
CompleteTraining
Prediction
(
inputFor
CompleteTraining
Prediction
)
{
predictionResult
=
axios
.
post
(
predictionURL_training
,
inputFor
CompleteTraining
Prediction
).
then
(
result
=>
{
return
result
.
data
;
}).
catch
(
error
=>
{
log
.
error
(
"
getMLPrediction() threw an exception:
"
,
error
)
log
.
error
(
"
getCompleteTrainingPrediction() threw an exception:
"
,
error
)
})
return
predictionResult
}
async
function
getAlarmPrediction
(
inputForAlarmPrediction
)
{
predictionResult
=
axios
.
post
(
predictionURL_alarm
,
inputForAlarmPrediction
).
then
(
result
=>
{
return
result
.
data
;
}).
catch
(
error
=>
{
log
.
error
(
"
getAlarmPrediction() threw an exception:
"
,
error
)
})
return
predictionResult
}
...
...
@@ -120,18 +130,40 @@ app.post("/home/:ssn", async (req, res) => {
var
sortedAssistiveAids
=
sortAssistiveAidsByDate
(
assistiveAidsWithCorrectDateFormat
)
//console.log("SORTED AIDS BY DATE: ", sortedAssistiveAids)
//Case Complete Training
//console.log("SORTED AIDS BY DATE LENGTH: ", sortedAssistiveAids.length);
var
assistiveAids
=
appendAssistiveAidsISO
(
sortedAssistiveAids
);
//console.log("APPENDED AIDS: ", assistiveAids);
var
assistiveAids
Training
=
appendAssistiveAidsISO
(
sortedAssistiveAids
);
//console.log("APPENDED AIDS: ", assistiveAids
Training
);
var
loanPeriod
=
calculateMeanLoanPeriod
(
sortedAssistiveAids
);
var
inputDataForMLPrediction
=
dataPreparationForML
(
citizenData
.
age
,
citizenData
.
gender
,
assistiveAids
,
loanPeriod
);
var
citizenPrediction
=
await
getMLPrediction
(
inputDataForMLPrediction
);
//Case Alarm
var
assistiveAidsWithoutAlarm
=
removeAlarmFromAssistiveAidsList
(
sortedAssistiveAids
);
//console.log("APPENDED AIDS Without Alarm: ", assistiveAidsWithoutAlarm);
var
assistiveAidsAlarm
=
appendAssistiveAidsISO
(
assistiveAidsWithoutAlarm
);
//console.log("APPENDED AIDS Without Alarm: ", {assistiveAidsAlarm})
var
inputForCompleteTrainingPrediction
=
dataPreparationForML
(
citizenData
.
age
,
citizenData
.
gender
,
assistiveAidsTraining
,
loanPeriod
);
var
inputForAlarmPrediction
=
dataPreparationForML
(
citizenData
.
age
,
citizenData
.
gender
,
assistiveAidsAlarm
,
loanPeriod
);
var
citizenCompleteTrainingPrediction
=
await
getCompleteTrainingPrediction
(
inputForCompleteTrainingPrediction
);
var
citizenAlarmPrediction
=
await
getAlarmPrediction
(
inputForAlarmPrediction
);
convertDataSizeToKb
(
"
Combined datasize from both the ML Model and Database in Kb:
"
,
{
citizenData
,
citizenPrediction
})
res
.
json
({
citizenData
,
citizenPrediction
})
await
deleteVariable
([
citizenData
,
assistiveAidsWithCorrectDateFormat
,
sortedAssistiveAids
,
assistiveAids
,
loanPeriod
,
inputDataForMLPrediction
,
citizenPrediction
])
}
//console.log("Alarm Prediction: ", citizenAlarmPrediction)
convertDataSizeToKb
(
"
Combined datasize from both the ML Model and Database in Kb:
"
,
{
citizenData
,
citizenCompleteTrainingPrediction
,
citizenAlarmPrediction
})
res
.
json
({
citizenData
,
citizenCompleteTrainingPrediction
,
citizenAlarmPrediction
})
await
deleteVariable
([
citizenData
,
assistiveAidsWithCorrectDateFormat
,
sortedAssistiveAids
,
assistiveAidsTraining
,
loanPeriod
,
inputForCompleteTrainingPrediction
,
inputForAlarmPrediction
,
citizenCompleteTrainingPrediction
,
citizenAlarmPrediction
])
}
});
function
changeLendDateFormat
(
assistiveAids
)
{
...
...
@@ -160,6 +192,15 @@ function sortAssistiveAidsByDate(assistiveAids){
}
}
function
removeAlarmFromAssistiveAidsList
(
assistiveAids
)
{
for
(
var
i
=
0
;
i
<
assistiveAids
.
length
;
i
++
)
{
if
(
assistiveAids
[
i
].
iso
===
'
222718
'
)
{
assistiveAids
.
splice
(
i
,
1
);
}
}
return
assistiveAids
}
function
appendAssistiveAidsISO
(
assistiveAids
)
{
var
assistiveAidsISOString
=
""
;
for
(
var
i
=
0
;
i
<
assistiveAids
.
length
;
i
++
)
{
...
...
web/vue-app/src/services/DataService.ts
View file @
f69bba75
...
...
@@ -19,11 +19,11 @@ class DataService {
store
.
dispatch
(
"
trainingPlans
"
,
citizenInformation
.
data
.
citizenData
.
Training_Plans
);
store
.
dispatch
(
"
homeCare
"
,
citizenInformation
.
data
.
citizenData
.
Home_Care
);
store
.
dispatch
(
"
probabilityComplete
"
,
citizenInformation
.
data
.
citizenPrediction
.
CompleteProb
);
store
.
dispatch
(
"
probabilityFall
"
,
citizenInformation
.
data
.
citizenPrediction
.
FallProb
);
store
.
dispatch
(
"
probabilityExplanationComplete
"
,
citizenInformation
.
data
.
citizenPrediction
.
CompleteArguments
);
store
.
dispatch
(
"
probabilityExplanationFall
"
,
citizenInformation
.
data
.
citizenPrediction
.
FallArguments
);
store
.
dispatch
(
"
compliance
"
,
citizenInformation
.
data
.
citizenPrediction
.
ComplianceProb
);
store
.
dispatch
(
"
probabilityComplete
"
,
citizenInformation
.
data
.
citizen
CompleteTraining
Prediction
.
CompleteProb
);
store
.
dispatch
(
"
probabilityFall
"
,
citizenInformation
.
data
.
citizen
CompleteTraining
Prediction
.
FallProb
);
store
.
dispatch
(
"
probabilityExplanationComplete
"
,
citizenInformation
.
data
.
citizen
CompleteTraining
Prediction
.
CompleteArguments
);
store
.
dispatch
(
"
probabilityExplanationFall
"
,
citizenInformation
.
data
.
citizen
CompleteTraining
Prediction
.
FallArguments
);
store
.
dispatch
(
"
compliance
"
,
citizenInformation
.
data
.
citizen
CompleteTraining
Prediction
.
ComplianceProb
);
return
true
;
}
}
...
...
web/vue-app/src/store/TrainingPlanStore.ts
View file @
f69bba75
...
...
@@ -13,7 +13,7 @@ const trainingPlanStore: Module<any, any> = {
},
mutations
:
{
SET_TRAINING_PLAN
(
state
,
value
)
{
state
.
trainingPlans
=
getDefaultStat
e
;
state
.
trainingPlans
=
valu
e
;
},
RESET_STATE_TRAINING_PLAN
(
state
)
{
//state.trainingPlans = [];
...
...
Write
Preview
Supports
Markdown
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