Commit f35b3046 authored by thecml's avatar thecml
Browse files

Merge branch 'master' of https://gitlab.au.dk/cfp/air

parents c996bd82 25659090
Pipeline #102376 passed with stage
in 5 minutes and 17 seconds
......@@ -16,17 +16,17 @@ app.use(cors(corsOptions));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
var corsOptions = {
origin: "http://localhost:8081"
};
var corsOptions = {
origin: "http://localhost:8081"
};
/*var corsOptions = {
origin: "https://air-app.azurewebsites.net"
};*/
// var corsOptions = {
// origin: "https://air-app.azurewebsites.net"
// };
const log = bunyan.createLogger({ name: "AIR_UI_Backend: " });
const predictionURL_training = 'https://air-fastapi.azurewebsites.net/predict_training';
const predictionURL_alarm = 'https://air-fastapi.azurewebsites.net/predict_alarm';
const log = bunyan.createLogger({ name: "AIR_UI_Backend: " });
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 => {
......@@ -129,12 +129,15 @@ app.post("/home/:ssn", async (req, res) => {
var assistiveAidsWithCorrectDateFormat = changeLendDateFormat(citizenData.Assistive_Aids);
var sortedAssistiveAids = sortAssistiveAidsByDate(assistiveAidsWithCorrectDateFormat);
//Case Complete Training
var assistiveAidsTraining = appendAssistiveAidsISO(sortedAssistiveAids);
var loanPeriod = calculateMeanLoanPeriod(sortedAssistiveAids);
//Remove invalid assistive aids iso's
var sortedAndCleanedAssistiveAids = removeInvalidAssistiveAidsFromList(sortedAssistiveAids);
//Case Alarm
var assistiveAidsWithoutAlarm = removeAlarmFromAssistiveAidsList(sortedAssistiveAids);
//Assistive Aids and Loan Period Calculations for the complete training case
var assistiveAidsTraining = appendAssistiveAidsISO(sortedAndCleanedAssistiveAids);
var loanPeriod = calculateMeanLoanPeriod(sortedAndCleanedAssistiveAids);
//Assistive Aids Calculations for the alarm case (it utilizes the same loan period as the complete training case)
var assistiveAidsWithoutAlarm = removeAlarmFromAssistiveAidsList(sortedAndCleanedAssistiveAids);
var assistiveAidsAlarm = appendAssistiveAidsISO(assistiveAidsWithoutAlarm);
//Input to ML model for both cases
......@@ -152,7 +155,8 @@ app.post("/home/:ssn", async (req, res) => {
await deleteVariable([
citizenData,
assistiveAidsWithCorrectDateFormat,
sortedAssistiveAids,
sortedAssistiveAids,
sortedAndCleanedAssistiveAids,
assistiveAidsTraining,
loanPeriod,
inputForCompleteTrainingPrediction,
......@@ -189,6 +193,15 @@ function sortAssistiveAidsByDate(assistiveAids){
}
}
function removeInvalidAssistiveAidsFromList(assistiveAids) {
for( var i = 0; i < assistiveAids.length; i++) {
if ( assistiveAids[i].iso === '999999') {
assistiveAids.splice(i, 1);
}
}
return assistiveAids;
}
function removeAlarmFromAssistiveAidsList(assistiveAids) {
for( var i = 0; i < assistiveAids.length; i++) {
if ( assistiveAids[i].iso === '222718') {
......@@ -229,11 +242,11 @@ function dateDifferenceInDays(assistiveAidLendDate) {
return Math.round(((differenceInTime))/(oneDayInMilliseconds) - 1);
}
//http.createServer(app).listen(80);
//https.createServer(app).listen(443);
//log.info(`Server is listening on port ${80} and ${443}.`);
// http.createServer(app).listen(80);
// https.createServer(app).listen(443);
// log.info(`Server is listening on port ${80} and ${443}.`);
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
log.info(`Server is listening on port ${PORT}.`);
});
\ No newline at end of file
app.listen(PORT, () => {
log.info(`Server is listening on port ${PORT}.`);
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment