Skip to content

Commit

Permalink
Develop (#371)
Browse files Browse the repository at this point in the history
* SelfExamination Skin done.

Adding new Self Examination Skin.
Adding new content pauldrons.
Adding new texts.

* Changing Flutter version of backend-tests.yaml etc.

* Ordering selfExaminations.

* BE Integration test fixed.

Adding test for self examination skin.
Fixing lint.
Fixing FE self examination category.

* Fixing lint.

* Fixing github test

* Changing layout of settings, adding setting account.

User form edited,
ExpanseTile for user data and notifications added.
Donate buton working.
TODO:
 1) Create notification screen
 2) Create notification shedule tasks
 3) Create notification switch in notification settings.

* Fix merge

* Delete ._Runner.xcodeproj

* Adding new screen donate page

TODO: Change placeholder image.
Edited notification switch for turning on/off donate notification.
Donate notification is turned for device not for user.

* Fixing Tests.

* Fixing lints. Adding functionality for opening settings.

* Donate Ilustration image is added to donate page.

Creating donate utils to handle function for showing donatepage.

* fix analyzer.

* Fixing PR.

* Fixing analyzer.

* Renaming file.

* fix/badge_brzy_vyprsi_rozbita_obrazovka (#364)
oprava zobrazovani 2 textu pred vyprsenim badge, oprava zobrazovani stavu vyprseni a ziskani u badge.
(Loono-cz/loono-tasks#6)

* Adding new form for custom examinations.

Adding new form for custom examinations.
Adding new screens.
Adding new widget for customTextInput.
TODO: FE with BE.
TODO: controll inputs.

* Adding error to custom_text_field.

* Addint error messaage into others text input fields

* Adding Translate.

* Adding prepossition Dativ translations.

Adding preposition Dativ translations.
Adding input validation.
Removing TOKS and VENERAL_SISEASES

* Adding function for transform year to month

* Editing examination detail for once examinaiton.

* Edditing examination detail for periodical Custom Examination.

* Fix: Logging with google account.

* fixing stuff for creating custom examinations.

* Přidaní překladů nových prohlídek - nomativ, genitiv, dativ

* Some fixes.

TODO: Control task and figma.

* Fixing bugs.

* Fixing date validation.

* fixing but with date interval instead of month was year.

* Fixing nonperiodic exam has order button not add to calendar.

* Fixing buttons not showing.

* Changing card layouts

TODO: Sorting.

* Fixing lint

* Fixing lint

* Fixing tests.

* Fixing test.

* FIX: Show month right now.

FIX: creating exams ?
FIX: Show month right now.

TODO: Razeni vlastnich prohlidek...

* Fixing desc. of award in custom exam detail.

* lint and format fix.

* analyze test fix.

Co-authored-by: Brambora0 <[email protected]>
  • Loading branch information
KeiShadow and Brambora0 authored Oct 3, 2022
1 parent 2775164 commit 08d326f
Show file tree
Hide file tree
Showing 14 changed files with 326 additions and 146 deletions.
5 changes: 2 additions & 3 deletions lib/helpers/date_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ int daysBetween(DateTime from, DateTime to) {
return (to.difference(from).inHours / 24).round();
}

int transformYearToMonth(String str) => (int.parse(str.replaceAll(RegExp(r'\d+'), '')) * 12);

num transformMonthToYear(num year) => year < 12 ? year : year / 12;
int transformYearToMonth(String str) => (int.parse(str.replaceAll(RegExp(r'[^0-9]'), '')) * 12);
int transformMonthToYear(num month) => (month < 12 ? month : month / 12).round();
12 changes: 5 additions & 7 deletions lib/helpers/examination_action_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ extension ExaminationActionTypeExt on ExaminationActionType {
case ExaminationActionType.CONTROL:
examinationActionTypeUnion = const ExaminationActionTypeUnion.control();
break;
case ExaminationActionType.bLOODCOLLECTION:
case ExaminationActionType.BLOOD_COLLECTION:
examinationActionTypeUnion = const ExaminationActionTypeUnion.bloodcollection();
break;
case ExaminationActionType.vISUALIZATIONMETHODS:
examinationActionTypeUnion = const ExaminationActionTypeUnion.visualizationmethods();
break;
case ExaminationActionType.VISUALIZATION_METHODS:
}

return examinationActionTypeUnion;
}

// ignore: non_constant_identifier_names
String get l10n_name => mapToUnion.when(
examination: () => 'Odborné vyšetření',
examination: () => 'Vyšetření',
control: () => 'Kontrola',
bloodcollection: () => 'Odběr krve',
visualizationmethods: () => 'Konzultace',
bloodcollection: () => 'Odběry',
visualizationmethods: () => 'Zobrazovací metody',
);
}

Expand Down
55 changes: 28 additions & 27 deletions lib/helpers/examination_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore_for_file: constant_identifier_names

import 'package:loono/helpers/date_helpers.dart';
import 'package:loono/helpers/examination_category.dart';
import 'package:loono/helpers/examination_types.dart';
import 'package:loono/helpers/self_examination_category.dart';
Expand All @@ -13,19 +14,31 @@ const int SELF_EXAMINATION_ACTIVE_CARD_INTERVAL_IN_HOURS = 72;
extension ExaminationPreventionStatusExt on ExaminationPreventionStatus {
ExaminationCategory calculateStatus([DateTime? dateTimeNow]) {
final now = dateTimeNow ?? DateTime.now();
final isCustom = examinationCategoryType == ExaminationCategoryType.CUSTOM;
final month = isCustom && intervalYears < 12 ? now.month + intervalYears : now.month;
final years =
isCustom && intervalYears > 12 ? now.year + transformMonthToYear(intervalYears) : now.year;

// STATUS: waiting or newToSchedule
if (([ExaminationStatus.CONFIRMED, ExaminationStatus.UNKNOWN].contains(state)) &&
lastConfirmedDate != null &&
periodicExam == true) {
final lastVisitDateTime = lastConfirmedDate!.toLocal();
final lastVisitDateWithoutDay = DateTime(lastVisitDateTime.year, lastVisitDateTime.month);
DateTime subtractedWaitingDate;
if (examinationCategoryType == ExaminationCategoryType.CUSTOM) {
subtractedWaitingDate = DateTime(
years,
month,
);
} else {
// if last visit date is before: CURRENT_MONTH - (INTERVAL - 2 months)
subtractedWaitingDate = DateTime(
now.year,
now.month - (intervalYears * MONTHS_IN_YEAR - TO_SCHEDULE_MONTHS_TRANSFER),
);
}

// if last visit date is before: CURRENT_MONTH - (INTERVAL - 2 months)
final subtractedWaitingDate = DateTime(
now.year,
now.month - (intervalYears * MONTHS_IN_YEAR - TO_SCHEDULE_MONTHS_TRANSFER),
);
// then waiting time has ended, move to "TO BE SCHEDULED"
if (lastVisitDateWithoutDay.isBefore(subtractedWaitingDate) ||
lastVisitDateWithoutDay.isAtSameMomentAs(subtractedWaitingDate)) {
Expand All @@ -34,7 +47,6 @@ extension ExaminationPreventionStatusExt on ExaminationPreventionStatus {
// else wait
return const ExaminationCategory.waiting();
}

if ([ExaminationStatus.UNKNOWN, ExaminationStatus.CANCELED].contains(state)) {
return const ExaminationCategory.newToSchedule();
}
Expand Down Expand Up @@ -103,27 +115,16 @@ extension CategorizedExaminationListExt on List<CategorizedExamination> {
DateTime(lastVisitDateWithoutDayB.year, lastVisitDateWithoutDayB.month);
return lastVisitDateTimeA.compareTo(lastVisitDateTimeB);
}),
unknownLastVisit: () => where(
(element) =>
element.examination.examinationCategoryType == ExaminationCategoryType.MANDATORY,
).toList().sort((a, b) => a.examination.priority.compareTo(b.examination.priority)),
scheduled: () {
where(
(element) =>
element.examination.examinationCategoryType == ExaminationCategoryType.MANDATORY,
).toList().sort(
(a, b) => a.examination.plannedDate!.compareTo(b.examination.plannedDate!),
);

where(
(element) =>
element.examination.examinationCategoryType == ExaminationCategoryType.CUSTOM,
).toList().sort(
(a, b) => ExaminationTypeExt(a.examination.examinationType)
.l10n_name
.compareTo(ExaminationTypeExt(b.examination.examinationType).l10n_name),
);
},
unknownLastVisit: () => sort(
(a, b) => a.examination.examinationCategoryType == ExaminationCategoryType.CUSTOM
? b.examination.priority.compareTo(a.examination.priority)
: 1,
),
scheduled: () => sort(
(a, b) => a.examination.examinationCategoryType == ExaminationCategoryType.CUSTOM
? b.examination.plannedDate!.compareTo(a.examination.plannedDate!)
: 1,
),
waiting: () {
where(
(element) =>
Expand Down
26 changes: 24 additions & 2 deletions lib/l10n/intl_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,24 @@
"@examination_detail_rewards_get_badge_2": {},
"examination_detail_rewards_get_badge_3": "bodů.",
"@examination_detail_rewards_get_badge_3": {},
"examination_detail_rewards_badge_coat": "superhrdinský plášť",
"@examination_detail_rewards_badge_coat": {},
"examination_detail_rewards_badge_top": "superhrdinský top",
"@examination_detail_rewards_badge_top": {},
"examination_detail_rewards_badge_belt": "superhrdinský opasek",
"@examination_detail_rewards_badge_belt": {},
"examination_detail_rewards_badge_shoes": "superhrdinské boty",
"@examination_detail_rewards_badge_shoes": {},
"examination_detail_rewards_badge_gloves": "superhrdinské rukavice",
"@examination_detail_rewards_badge_gloves": {},
"examination_detail_rewards_badge_headband": "superhrdinskou čelenku",
"@examination_detail_rewards_badge_headband": {},
"examination_detail_rewards_badge_glasses": "superhrdinské brýle",
"@examination_detail_rewards_badge_glasses": {},
"examination_detail_rewards_badge_shield": "superhrdinský štít",
"@examination_detail_rewards_badge_shield": {},
"examination_detail_rewards_badge_pauldrons": "superhrdinské nárameníky",
"@examination_detail_rewards_badge_pauldrons": {},
"calendar_permission_sheet_title": "Přístup ke kalendáři povol v Nastavení svého telefonu",
"@calendar_permission_sheet_title": {},
"calendar_permission_sheet_desc": "Když povolíš přístup ke kalendáři, automaticky se ti do něj budou synchronizovat tvé prohlídky z aplikace.",
Expand Down Expand Up @@ -1390,7 +1408,7 @@
"@yout_last_examination": {},
"examination_term": "Termin vysetreni",
"@examination_term": {},
"once_to": "Jednou za",
"once_to": "Jednou za ",
"@once_to": {},
"note_visiting": "Poznámka k návštevě",
"@note_visiting": {},
Expand All @@ -1411,5 +1429,9 @@
"waiting_you": "Čeká tě",
"@waiting_you": {},
"first_exam_progress": "první prohlídka",
"@first_exam_progress": {}
"@first_exam_progress": {},
"disposable": "Jednorázové",
"@disposable": {},
"regularly": "Pravidelné",
"@regularly": {}
}
40 changes: 40 additions & 0 deletions lib/services/examinations_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,46 @@ class ExaminationsProvider extends ChangeNotifier {
}
}

ExaminationPreventionStatus? updateAndReturnCustomExaminationsRecord(
ExaminationRecord record,
ExaminationPreventionStatus item,
) {
final indexToUpdate =
examinations?.examinations.indexWhere((examination) => examination == item);
if (indexToUpdate != null && indexToUpdate >= 0) {
final updatedItem = examinations?.examinations.elementAt(indexToUpdate).rebuild(
(item) => item
..uuid = record.uuid
..examinationType = record.type
..plannedDate =
(record.status == ExaminationStatus.CONFIRMED || record.firstExam == true)
? item.plannedDate
: record.plannedDate?.toLocal()
..lastConfirmedDate =
(record.status == ExaminationStatus.CONFIRMED || record.firstExam == true)
? record.plannedDate?.toLocal()
: item.lastConfirmedDate
..state = record.status ?? item.state
..firstExam = record.firstExam ?? item.firstExam
..customInterval = record.customInterval
..examinationActionType = record.examinationActionType
..examinationCategoryType = record.examinationCategoryType
..badge = item.badge
..periodicExam = record.periodicExam
..note = record.note,
);

final builder = examinations?.toBuilder();
builder?.examinations.removeAt(indexToUpdate);
builder?.examinations.add(updatedItem!);
examinations = builder?.build();
evaluateExaminations();
notifyListeners();
return updatedItem;
}
return null;
}

void setChoosedCustomExamination(
CategorizedExamination? categorizedExam,
ExaminationPreventionStatus? exam,
Expand Down
104 changes: 92 additions & 12 deletions lib/ui/screens/custom_exam_form/custom_exam_form_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class _CustomExamFormScreenState extends State<CustomExamFormScreen> {
children: [
checkboxConetnt(
context,
'Jednorázové', //TODO: Translation
context.l10n.disposable, //TODO: Translation
() => setState(() {
_isPeriodicExam = false;
_showPeriodDateTimeError = false;
Expand All @@ -189,7 +189,7 @@ class _CustomExamFormScreenState extends State<CustomExamFormScreen> {
),
checkboxConetnt(
context,
'Pravidelné', //TODO: Translation
context.l10n.regularly, //TODO: Translation
() => setState(() {
_isPeriodicExam = true;
_showPeriodDateTimeError = false;
Expand Down Expand Up @@ -235,7 +235,13 @@ class _CustomExamFormScreenState extends State<CustomExamFormScreen> {
onTap: () async {
if (_specialist != null && _examinationType != null) {
if (_isPeriodicExam) {
await sendMandatoryRequest();
if (_lastExamDate != null && _nextExamDate != null) {
await sendMandatoryRequest();
} else if (_lastExamDate != null) {
await sendMandatoryRequestConfirm();
} else {
await sendMandatoryRequestNew();
}
} else {
await sendOnceRequest();
}
Expand Down Expand Up @@ -465,41 +471,108 @@ class _CustomExamFormScreenState extends State<CustomExamFormScreen> {
}
}

Future<void> sendMandatoryRequestNew() async {
final response = await registry.get<ExaminationRepository>().postExamination(
_specialist!,
actionType: _examinationType,
periodicExam: _isPeriodicExam,
note: _note,
customInterval: transformInterval(_customInterval), // Pravidelne
newDate: _nextExamDate,
categoryType: ExaminationCategoryType.CUSTOM,
status: ExaminationStatus.NEW,
firstExam: true,
);

response.map(
success: (res) {
Provider.of<ExaminationsProvider>(context, listen: false).createCustomExamination(res.data);
AutoRouter.of(context).popUntilRouteWithName(MainRoute.name);
showFlushBarSuccess(context, context.l10n.examinatoin_was_added);
},
failure: (err) => showFlushBarError(
context,
statusCodeToText(
context,
err.error.response?.statusCode,
),
),
);
}

Future<void> sendMandatoryRequestConfirm() async {
final response = await registry.get<ExaminationRepository>().postExamination(
_specialist!,
actionType: _examinationType,
periodicExam: _isPeriodicExam,
note: _note,
customInterval: transformInterval(_customInterval), // Pravidelne
newDate: _lastExamDate,
categoryType: ExaminationCategoryType.CUSTOM,
status: ExaminationStatus.CONFIRMED,
firstExam: true,
);

response.map(
success: (res) {
Provider.of<ExaminationsProvider>(context, listen: false)
.createCustomExamination(res.data, lastConfirmedDate: _lastExamDate);
AutoRouter.of(context).popUntilRouteWithName(MainRoute.name);
showFlushBarSuccess(context, context.l10n.examinatoin_was_added);
},
failure: (err) => showFlushBarError(
context,
statusCodeToText(
context,
err.error.response?.statusCode,
),
),
);
}

Future<void> sendMandatoryRequest() async {
final response = await registry.get<ExaminationRepository>().postExamination(
_specialist!,
actionType: _examinationType,
periodicExam: _isPeriodicExam,
note: _note,
customInterval: int.parse(_customInterval[0]), // Pravidelne
customInterval: transformInterval(_customInterval), // Pravidelne
newDate: _lastExamDate,
categoryType: ExaminationCategoryType.CUSTOM,
status: ExaminationStatus.CONFIRMED,
firstExam: true,
);
response.map(
success: (res) {
final frequencyString = _customInterval.split('');
registry
.get<ExaminationRepository>()
.postExamination(
_specialist!,
actionType: _examinationType,
periodicExam: _isPeriodicExam,
note: _note,
customInterval: frequencyString[1] == context.l10n.years
? transformYearToMonth(frequencyString[0])
: int.parse(frequencyString[0]), // Pravidelne
customInterval: transformInterval(_customInterval), // Pravidelne
newDate: _nextExamDate,
categoryType: ExaminationCategoryType.CUSTOM,
status: ExaminationStatus.NEW,
firstExam: false,
)
.then((value) {
Provider.of<ExaminationsProvider>(context, listen: false)
.createCustomExamination(res.data, lastConfirmedDate: _lastExamDate);
AutoRouter.of(context).popUntilRouteWithName(MainRoute.name);
showFlushBarSuccess(context, context.l10n.examinatoin_was_added);
value.map(
success: (newRes) {
Provider.of<ExaminationsProvider>(context, listen: false)
.createCustomExamination(newRes.data, lastConfirmedDate: _lastExamDate);
AutoRouter.of(context).popUntilRouteWithName(MainRoute.name);
showFlushBarSuccess(context, context.l10n.examinatoin_was_added);
},
failure: (err) => showFlushBarError(
context,
statusCodeToText(
context,
err.error.response?.statusCode,
),
),
);
});
},
failure: (err) {
Expand Down Expand Up @@ -543,4 +616,11 @@ class _CustomExamFormScreenState extends State<CustomExamFormScreen> {
},
);
}

int transformInterval(String str) {
final splitedString = str.split(' ');
final number = splitedString[0];
final desc = splitedString[1];
return desc == context.l10n.years ? transformYearToMonth(number) : int.parse(number);
}
}
Loading

0 comments on commit 08d326f

Please sign in to comment.