Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bmi calc #64

Merged
merged 33 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cbb28b5
adds a basic login screen
inchw0rm Aug 16, 2022
cb690bc
rename states -> state
inchw0rm Aug 16, 2022
a10ca52
adds state managed token
inchw0rm Aug 19, 2022
ad5f36e
adjusts the gitignore for further configuration adjustments
inchw0rm Aug 23, 2022
434d26f
refines the login
inchw0rm Aug 30, 2022
1ce9364
Merge remote-tracking branch 'upstream/pre-alpha' into pre-alpha
inchw0rm Aug 30, 2022
f301390
refines login, tells docs and pats apart, nurse screen
inchw0rm Aug 30, 2022
fc9cc47
adjusts gitignore
inchw0rm Sep 2, 2022
836d12c
Update lib/util/backend.dart
inchw0rm Sep 5, 2022
b8676c7
Update lib/screens/login_screen.dart
inchw0rm Sep 5, 2022
9e2d7bb
Update lib/screens/study_nurse_screen/study_nurse_screen.dart
inchw0rm Sep 5, 2022
e36e8e9
removes dangling exports and refines code a little
inchw0rm Sep 5, 2022
2321ffd
Merge branch 'pre-alpha' of github.com:inchw0rm/picos into pre-alpha
inchw0rm Sep 5, 2022
dbce40b
fixes typos
inchw0rm Sep 5, 2022
33378b3
fixes the text on the appbar not being centered
inchw0rm Oct 18, 2022
521ca7e
Merge remote-tracking branch 'upstream/pre-alpha' into pre-alpha
inchw0rm Oct 18, 2022
404a836
fixes the titles on the appbar not being centered
inchw0rm Oct 18, 2022
611ed53
Merge branch 'healthcare-it-solutions:pre-alpha' into pre-alpha
inchw0rm Nov 2, 2022
b4e76b8
Merge branches 'pre-alpha', 'pre-alpha', 'pre-alpha', 'pre-alpha' and…
inchw0rm Feb 5, 2023
ac928fc
improves the loading time of the image on the patient screen
inchw0rm Feb 5, 2023
f33a9b4
fixes exceptions while loading the patient screen
inchw0rm Feb 5, 2023
46fc22c
introduces auto calc of BMIs and psuhes to back end
inchw0rm Feb 5, 2023
481e68f
Added patient_registration_data.dart
S1rDan Feb 6, 2023
e6dd3bc
Updated weight.dart
S1rDan Feb 6, 2023
5de1177
Minor modifications to weekly.dart
S1rDan Feb 6, 2023
38431d7
Added disabled parameter to text_field_card.dart
S1rDan Feb 6, 2023
1f5bc06
Fixed weight.dart
S1rDan Feb 6, 2023
c42df61
Async functionality for questionaire_page_storage.dart
S1rDan Feb 6, 2023
93c4c65
Name changes and making use of the new weight page async.
S1rDan Feb 6, 2023
d46d9e2
Merge branch 'pre-alpha' into feature/bmi_calc
S1rDan Feb 6, 2023
00ac0bc
Fixing merge errors
S1rDan Feb 6, 2023
853b179
Minor fix for bmi
S1rDan Feb 6, 2023
5d6d790
Merge branch 'pre-alpha' into feature/bmi_calc
S1rDan Feb 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions lib/models/patient_registration_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* This file is part of Picos, a health tracking mobile app
* Copyright (C) 2022 Healthcare IT Solutions GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import 'package:picos/models/abstract_database_object.dart';

/// Class with patient information collected on registration.
///
/// The attributes within this model may be not complete.
class PatientRegistrationData extends AbstractDatabaseObject {
/// Creates a patient registration data object.
const PatientRegistrationData({
required this.bodyHeight,
String? objectId,
DateTime? createdAt,
DateTime? updatedAt,
}) : super(objectId: objectId, createdAt: createdAt, updatedAt: updatedAt);

/// The database table the objects are stored in.
static const String databaseTable = 'patientData';

/// The patients body height.
final int bodyHeight;

@override
get table {
return databaseTable;
}

/// Returns a copy of this patient registration data object
/// with the given values updated.
@override
PatientRegistrationData copyWith({
int? bodyHeight,
String? objectId,
DateTime? createdAt,
DateTime? updatedAt,
}) {
return PatientRegistrationData(
bodyHeight: bodyHeight ?? this.bodyHeight,
objectId: objectId ?? this.objectId,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
}

@override
List<Object> get props => <Object>[
bodyHeight,
];

@override
Map<String, dynamic> get databaseMapping => <String, dynamic>{
'BodyHeight': bodyHeight,
};
}
8 changes: 4 additions & 4 deletions lib/models/weekly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class Weekly extends AbstractDatabaseObject {
static const String databaseTable = 'PICOS_weekly';

/// The patients body weight.
final int? bodyWeight;
final double? bodyWeight;

/// The patients BMI.
final int? bmi;
final double? bmi;

/// The patients sleep quality assessment.
final int? sleepQuality;
Expand All @@ -57,8 +57,8 @@ class Weekly extends AbstractDatabaseObject {
@override
Weekly copyWith({
DateTime? date,
int? bodyWeight,
int? bmi,
double? bodyWeight,
double? bmi,
int? sleepQuality,
int? walkingDistance,
String? objectId,
Expand Down
66 changes: 56 additions & 10 deletions lib/screens/questionaire_screen/pages/weight.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/* This file is part of Picos, a health tracking mobile app
* Copyright (C) 2022 Healthcare IT Solutions GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import 'dart:math';

import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -6,13 +25,13 @@ import '../widgets/questionaire_page.dart';
import '../widgets/text_field_card.dart';

/// Questionnaire Weight page.
class Weight extends StatelessWidget {
class Weight extends StatefulWidget {
/// Weight constructor.
const Weight({
required this.previousPage,
required this.nextPage,
required this.onChangedBodyWeight,
required this.onChangedBmi,
this.bodyHeight = 0,
Key? key,
}) : super(key: key);

Expand All @@ -23,14 +42,25 @@ class Weight extends StatelessWidget {
final void Function() nextPage;

/// Callback for body weight.
final dynamic Function(String value) onChangedBodyWeight;
final dynamic Function(double? weight, double? bmi) onChangedBodyWeight;

/// The body height.
final int bodyHeight;

/// Callback for bmi.
final dynamic Function(String value) onChangedBmi;
@override
State<Weight> createState() => _WeightState();
}

class _WeightState extends State<Weight> {
static String? _bodyWeight;
static String? _autoCalc;

double _bmi = 0;

double _calculateBmi(int height, double bodyWeight) {
return (bodyWeight / pow(height / 100, 2));
}

@override
Widget build(BuildContext context) {

Expand All @@ -40,19 +70,35 @@ class Weight extends StatelessWidget {
}

return QuestionairePage(
backFunction: previousPage,
nextFunction: nextPage,
backFunction: widget.previousPage,
nextFunction: widget.nextPage,
child: Column(
children: <TextFieldCard>[
TextFieldCard(
label: _bodyWeight!,
hint: 'kg',
onChanged: onChangedBodyWeight,
onChanged: (String weightString) {
if (weightString == '') {
widget.onChangedBodyWeight(null, null);
setState(() {
_bmi = 0;
});
return;
}

double weight = double.parse(weightString);

setState(() {
_bmi = _calculateBmi(widget.bodyHeight, weight);
});

widget.onChangedBodyWeight(weight, _bmi);
},
),
TextFieldCard(
label: 'BMI',
hint: 'kg/m² $_autoCalc',
onChanged: onChangedBmi,
hint: _bmi == 0 ? 'kg/m² $_autoCalc' : _bmi.toString(),
disabled: true,
),
],
),
Expand Down
Loading