From 0df5fc15cf132755ab04ece26aeb664af259518c Mon Sep 17 00:00:00 2001 From: Ramkrishna-egov Date: Wed, 11 Oct 2023 00:07:38 +0530 Subject: [PATCH 1/2] Multi round fixes :: task reload, Location null check , deliveries config changes --- .../deliver_intervention.dart | 16 +- .../no_sql/schema/project_types.dart | 11 +- .../no_sql/schema/project_types.g.dart | 708 ++++++++++++------ .../lib/data/repositories/remote/mdms.dart | 29 +- .../models/app_config/app_config_model.dart | 51 +- .../project_type/project_type_model.dart | 14 +- .../project_type_model.freezed.dart | 263 ++++--- .../project_type/project_type_model.g.dart | 23 +- .../beneficiary/deliver_intervention.dart | 50 +- .../pages/beneficiary/dose_administered.dart | 44 +- .../pages/beneficiary/household_overview.dart | 27 +- .../beneficiary/widgets/past_delivery.dart | 30 +- .../widgets/record_delivery_cycle.dart | 13 +- .../lib/pages/search_beneficiary.dart | 9 +- .../lib/utils/i18_key_constants.dart | 2 + .../lib/utils/utils.dart | 73 +- .../beneficiary/view_beneficiary_card.dart | 9 +- .../lib/widgets/member_card/member_card.dart | 17 +- .../lib/widgets/molecules/digit_table.dart | 2 +- 19 files changed, 841 insertions(+), 550 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/delivery_intervention/deliver_intervention.dart b/apps/health_campaign_field_worker_app/lib/blocs/delivery_intervention/deliver_intervention.dart index 47e6a653b..cf3c8d843 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/delivery_intervention/deliver_intervention.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/delivery_intervention/deliver_intervention.dart @@ -6,7 +6,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import '../../data/data_repository.dart'; import '../../models/data_model.dart'; import '../../models/project_type/project_type_model.dart'; -import '../../utils/utils.dart'; part 'deliver_intervention.freezed.dart'; @@ -128,12 +127,10 @@ class DeliverInterventionBloc if (currentRunningCycle != 0) { if (event.lastCycle == currentRunningCycle) { // Calculate the length of deliveries in the current cycle - final deliveryLength = fetchDeliveries( - event.projectType.cycles! - .firstWhere((c) => c.id == event.lastCycle) - .deliveries, - event.individualModel, - )?.length ?? + final deliveryLength = event.projectType.cycles! + .firstWhere((c) => c.id == event.lastCycle) + .deliveries + ?.length ?? 0; final isNotLastDose = event.lastDose < deliveryLength; // Get a list of past cycles @@ -207,8 +204,7 @@ class DeliverInterventionBloc int currentDose = event.dose; Cycle? currentCycle = event.cycle; - final deliveriesList = - fetchDeliveries(currentCycle.deliveries, event.individualModel); + final deliveriesList = currentCycle.deliveries; if (deliveriesList != null) { List futureDeliveries = []; @@ -216,7 +212,7 @@ class DeliverInterventionBloc for (int index = currentDose; index < deliveriesList.length; index++) { var delivery = deliveriesList[index]; - String? deliveryStrategy = delivery.doseCriteria?.deliveryStrategy; + String? deliveryStrategy = delivery.deliveryStrategy; // Check if the delivery strategy is indirect if (deliveryStrategy == DeliverStrategyType.indirect.toValue()) { diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.dart index 356a3a5a9..d5cc53076 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.dart @@ -43,13 +43,18 @@ class Cycles { @embedded class Deliveries { @Name("doseCriteria") - DoseCriteria? doseCriteriaModel; + List? doseCriteriaModel; + @Name("mandatoryWaitSinceLastDeliveryInDays") + String? mandatoryWaitSinceLastDeliveryInDays; + @Name("deliveryStrategy") + String? deliveryStrategy; } @embedded class DoseCriteria { - String? mandatoryWaitSinceLastDeliveryInDays; - String? deliveryStrategy; + @Name("condition") + String? condition; + @Name("ProductVariants") List? productVariants; } diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.g.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.g.dart index 3629083b4..0f3924969 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.g.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/project_types.g.dart @@ -2372,11 +2372,21 @@ const DeliveriesSchema = Schema( name: r'Deliveries', id: 2357936067587297135, properties: { - r'doseCriteria': PropertySchema( + r'deliveryStrategy': PropertySchema( id: 0, + name: r'deliveryStrategy', + type: IsarType.string, + ), + r'doseCriteria': PropertySchema( + id: 1, name: r'doseCriteria', - type: IsarType.object, + type: IsarType.objectList, target: r'DoseCriteria', + ), + r'mandatoryWaitSinceLastDeliveryInDays': PropertySchema( + id: 2, + name: r'mandatoryWaitSinceLastDeliveryInDays', + type: IsarType.string, ) }, estimateSize: _deliveriesEstimateSize, @@ -2389,131 +2399,6 @@ int _deliveriesEstimateSize( Deliveries object, List offsets, Map> allOffsets, -) { - var bytesCount = offsets.last; - { - final value = object.doseCriteriaModel; - if (value != null) { - bytesCount += 3 + - DoseCriteriaSchema.estimateSize( - value, allOffsets[DoseCriteria]!, allOffsets); - } - } - return bytesCount; -} - -void _deliveriesSerialize( - Deliveries object, - IsarWriter writer, - List offsets, - Map> allOffsets, -) { - writer.writeObject( - offsets[0], - allOffsets, - DoseCriteriaSchema.serialize, - object.doseCriteriaModel, - ); -} - -Deliveries _deliveriesDeserialize( - Id id, - IsarReader reader, - List offsets, - Map> allOffsets, -) { - final object = Deliveries(); - object.doseCriteriaModel = reader.readObjectOrNull( - offsets[0], - DoseCriteriaSchema.deserialize, - allOffsets, - ); - return object; -} - -P _deliveriesDeserializeProp

( - IsarReader reader, - int propertyId, - int offset, - Map> allOffsets, -) { - switch (propertyId) { - case 0: - return (reader.readObjectOrNull( - offset, - DoseCriteriaSchema.deserialize, - allOffsets, - )) as P; - default: - throw IsarError('Unknown property with id $propertyId'); - } -} - -extension DeliveriesQueryFilter - on QueryBuilder { - QueryBuilder - doseCriteriaModelIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNull( - property: r'doseCriteria', - )); - }); - } - - QueryBuilder - doseCriteriaModelIsNotNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'doseCriteria', - )); - }); - } -} - -extension DeliveriesQueryObject - on QueryBuilder { - QueryBuilder doseCriteriaModel( - FilterQuery q) { - return QueryBuilder.apply(this, (query) { - return query.object(q, r'doseCriteria'); - }); - } -} - -// coverage:ignore-file -// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters - -const DoseCriteriaSchema = Schema( - name: r'DoseCriteria', - id: -4142765722663167685, - properties: { - r'deliveryStrategy': PropertySchema( - id: 0, - name: r'deliveryStrategy', - type: IsarType.string, - ), - r'mandatoryWaitSinceLastDeliveryInDays': PropertySchema( - id: 1, - name: r'mandatoryWaitSinceLastDeliveryInDays', - type: IsarType.string, - ), - r'productVariants': PropertySchema( - id: 2, - name: r'productVariants', - type: IsarType.objectList, - target: r'ProductVariants', - ) - }, - estimateSize: _doseCriteriaEstimateSize, - serialize: _doseCriteriaSerialize, - deserialize: _doseCriteriaDeserialize, - deserializeProp: _doseCriteriaDeserializeProp, -); - -int _doseCriteriaEstimateSize( - DoseCriteria object, - List offsets, - Map> allOffsets, ) { var bytesCount = offsets.last; { @@ -2523,64 +2408,64 @@ int _doseCriteriaEstimateSize( } } { - final value = object.mandatoryWaitSinceLastDeliveryInDays; - if (value != null) { - bytesCount += 3 + value.length * 3; - } - } - { - final list = object.productVariants; + final list = object.doseCriteriaModel; if (list != null) { bytesCount += 3 + list.length * 3; { - final offsets = allOffsets[ProductVariants]!; + final offsets = allOffsets[DoseCriteria]!; for (var i = 0; i < list.length; i++) { final value = list[i]; bytesCount += - ProductVariantsSchema.estimateSize(value, offsets, allOffsets); + DoseCriteriaSchema.estimateSize(value, offsets, allOffsets); } } } } + { + final value = object.mandatoryWaitSinceLastDeliveryInDays; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } return bytesCount; } -void _doseCriteriaSerialize( - DoseCriteria object, +void _deliveriesSerialize( + Deliveries object, IsarWriter writer, List offsets, Map> allOffsets, ) { writer.writeString(offsets[0], object.deliveryStrategy); - writer.writeString(offsets[1], object.mandatoryWaitSinceLastDeliveryInDays); - writer.writeObjectList( - offsets[2], + writer.writeObjectList( + offsets[1], allOffsets, - ProductVariantsSchema.serialize, - object.productVariants, + DoseCriteriaSchema.serialize, + object.doseCriteriaModel, ); + writer.writeString(offsets[2], object.mandatoryWaitSinceLastDeliveryInDays); } -DoseCriteria _doseCriteriaDeserialize( +Deliveries _deliveriesDeserialize( Id id, IsarReader reader, List offsets, Map> allOffsets, ) { - final object = DoseCriteria(); + final object = Deliveries(); object.deliveryStrategy = reader.readStringOrNull(offsets[0]); - object.mandatoryWaitSinceLastDeliveryInDays = - reader.readStringOrNull(offsets[1]); - object.productVariants = reader.readObjectList( - offsets[2], - ProductVariantsSchema.deserialize, + object.doseCriteriaModel = reader.readObjectList( + offsets[1], + DoseCriteriaSchema.deserialize, allOffsets, - ProductVariants(), + DoseCriteria(), ); + object.mandatoryWaitSinceLastDeliveryInDays = + reader.readStringOrNull(offsets[2]); return object; } -P _doseCriteriaDeserializeProp

( +P _deliveriesDeserializeProp

( IsarReader reader, int propertyId, int offset, @@ -2590,22 +2475,22 @@ P _doseCriteriaDeserializeProp

( case 0: return (reader.readStringOrNull(offset)) as P; case 1: - return (reader.readStringOrNull(offset)) as P; - case 2: - return (reader.readObjectList( + return (reader.readObjectList( offset, - ProductVariantsSchema.deserialize, + DoseCriteriaSchema.deserialize, allOffsets, - ProductVariants(), + DoseCriteria(), )) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } } -extension DoseCriteriaQueryFilter - on QueryBuilder { - QueryBuilder +extension DeliveriesQueryFilter + on QueryBuilder { + QueryBuilder deliveryStrategyIsNull() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(const FilterCondition.isNull( @@ -2614,7 +2499,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyIsNotNull() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(const FilterCondition.isNotNull( @@ -2623,7 +2508,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyEqualTo( String? value, { bool caseSensitive = true, @@ -2637,7 +2522,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyGreaterThan( String? value, { bool include = false, @@ -2653,7 +2538,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyLessThan( String? value, { bool include = false, @@ -2669,7 +2554,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyBetween( String? lower, String? upper, { @@ -2689,7 +2574,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyStartsWith( String value, { bool caseSensitive = true, @@ -2703,7 +2588,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyEndsWith( String value, { bool caseSensitive = true, @@ -2717,7 +2602,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyContains(String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.contains( @@ -2728,7 +2613,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyMatches(String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.matches( @@ -2739,7 +2624,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( @@ -2749,7 +2634,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder deliveryStrategyIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( @@ -2759,60 +2644,167 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder - mandatoryWaitSinceLastDeliveryInDaysIsNull() { + QueryBuilder + doseCriteriaModelIsNull() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(const FilterCondition.isNull( - property: r'mandatoryWaitSinceLastDeliveryInDays', + property: r'doseCriteria', )); }); } - QueryBuilder - mandatoryWaitSinceLastDeliveryInDaysIsNotNull() { + QueryBuilder + doseCriteriaModelIsNotNull() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'mandatoryWaitSinceLastDeliveryInDays', + property: r'doseCriteria', )); }); } - QueryBuilder - mandatoryWaitSinceLastDeliveryInDaysEqualTo( - String? value, { - bool caseSensitive = true, - }) { + QueryBuilder + doseCriteriaModelLengthEqualTo(int length) { return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'mandatoryWaitSinceLastDeliveryInDays', - value: value, - caseSensitive: caseSensitive, - )); + return query.listLength( + r'doseCriteria', + length, + true, + length, + true, + ); }); } - QueryBuilder - mandatoryWaitSinceLastDeliveryInDaysGreaterThan( - String? value, { - bool include = false, - bool caseSensitive = true, - }) { + QueryBuilder + doseCriteriaModelIsEmpty() { return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'mandatoryWaitSinceLastDeliveryInDays', - value: value, - caseSensitive: caseSensitive, - )); + return query.listLength( + r'doseCriteria', + 0, + true, + 0, + true, + ); }); } - QueryBuilder - mandatoryWaitSinceLastDeliveryInDaysLessThan( - String? value, { - bool include = false, - bool caseSensitive = true, - }) { + QueryBuilder + doseCriteriaModelIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'doseCriteria', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder + doseCriteriaModelLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'doseCriteria', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + doseCriteriaModelLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'doseCriteria', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder + doseCriteriaModelLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'doseCriteria', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder + mandatoryWaitSinceLastDeliveryInDaysIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'mandatoryWaitSinceLastDeliveryInDays', + )); + }); + } + + QueryBuilder + mandatoryWaitSinceLastDeliveryInDaysIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'mandatoryWaitSinceLastDeliveryInDays', + )); + }); + } + + QueryBuilder + mandatoryWaitSinceLastDeliveryInDaysEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'mandatoryWaitSinceLastDeliveryInDays', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mandatoryWaitSinceLastDeliveryInDaysGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'mandatoryWaitSinceLastDeliveryInDays', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + mandatoryWaitSinceLastDeliveryInDaysLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, @@ -2823,7 +2815,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysBetween( String? lower, String? upper, { @@ -2843,7 +2835,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysStartsWith( String value, { bool caseSensitive = true, @@ -2857,7 +2849,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysEndsWith( String value, { bool caseSensitive = true, @@ -2871,7 +2863,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysContains(String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2883,7 +2875,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysMatches(String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2895,7 +2887,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( @@ -2905,7 +2897,7 @@ extension DoseCriteriaQueryFilter }); } - QueryBuilder + QueryBuilder mandatoryWaitSinceLastDeliveryInDaysIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( @@ -2914,12 +2906,132 @@ extension DoseCriteriaQueryFilter )); }); } +} + +extension DeliveriesQueryObject + on QueryBuilder { + QueryBuilder + doseCriteriaModelElement(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'doseCriteria'); + }); + } +} + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +const DoseCriteriaSchema = Schema( + name: r'DoseCriteria', + id: -4142765722663167685, + properties: { + r'ProductVariants': PropertySchema( + id: 0, + name: r'ProductVariants', + type: IsarType.objectList, + target: r'ProductVariants', + ), + r'condition': PropertySchema( + id: 1, + name: r'condition', + type: IsarType.string, + ) + }, + estimateSize: _doseCriteriaEstimateSize, + serialize: _doseCriteriaSerialize, + deserialize: _doseCriteriaDeserialize, + deserializeProp: _doseCriteriaDeserializeProp, +); + +int _doseCriteriaEstimateSize( + DoseCriteria object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final list = object.productVariants; + if (list != null) { + bytesCount += 3 + list.length * 3; + { + final offsets = allOffsets[ProductVariants]!; + for (var i = 0; i < list.length; i++) { + final value = list[i]; + bytesCount += + ProductVariantsSchema.estimateSize(value, offsets, allOffsets); + } + } + } + } + { + final value = object.condition; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _doseCriteriaSerialize( + DoseCriteria object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeObjectList( + offsets[0], + allOffsets, + ProductVariantsSchema.serialize, + object.productVariants, + ); + writer.writeString(offsets[1], object.condition); +} + +DoseCriteria _doseCriteriaDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = DoseCriteria(); + object.productVariants = reader.readObjectList( + offsets[0], + ProductVariantsSchema.deserialize, + allOffsets, + ProductVariants(), + ); + object.condition = reader.readStringOrNull(offsets[1]); + return object; +} + +P _doseCriteriaDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readObjectList( + offset, + ProductVariantsSchema.deserialize, + allOffsets, + ProductVariants(), + )) as P; + case 1: + return (reader.readStringOrNull(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} +extension DoseCriteriaQueryFilter + on QueryBuilder { QueryBuilder productVariantsIsNull() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(const FilterCondition.isNull( - property: r'productVariants', + property: r'ProductVariants', )); }); } @@ -2928,7 +3040,7 @@ extension DoseCriteriaQueryFilter productVariantsIsNotNull() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'productVariants', + property: r'ProductVariants', )); }); } @@ -2937,7 +3049,7 @@ extension DoseCriteriaQueryFilter productVariantsLengthEqualTo(int length) { return QueryBuilder.apply(this, (query) { return query.listLength( - r'productVariants', + r'ProductVariants', length, true, length, @@ -2950,7 +3062,7 @@ extension DoseCriteriaQueryFilter productVariantsIsEmpty() { return QueryBuilder.apply(this, (query) { return query.listLength( - r'productVariants', + r'ProductVariants', 0, true, 0, @@ -2963,7 +3075,7 @@ extension DoseCriteriaQueryFilter productVariantsIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.listLength( - r'productVariants', + r'ProductVariants', 0, false, 999999, @@ -2979,7 +3091,7 @@ extension DoseCriteriaQueryFilter }) { return QueryBuilder.apply(this, (query) { return query.listLength( - r'productVariants', + r'ProductVariants', 0, true, length, @@ -2995,7 +3107,7 @@ extension DoseCriteriaQueryFilter }) { return QueryBuilder.apply(this, (query) { return query.listLength( - r'productVariants', + r'ProductVariants', length, include, 999999, @@ -3013,7 +3125,7 @@ extension DoseCriteriaQueryFilter }) { return QueryBuilder.apply(this, (query) { return query.listLength( - r'productVariants', + r'ProductVariants', lower, includeLower, upper, @@ -3021,6 +3133,160 @@ extension DoseCriteriaQueryFilter ); }); } + + QueryBuilder + conditionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'condition', + )); + }); + } + + QueryBuilder + conditionIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'condition', + )); + }); + } + + QueryBuilder + conditionEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'condition', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'condition', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'condition', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'condition', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'condition', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'condition', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'condition', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'condition', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + conditionIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'condition', + value: '', + )); + }); + } + + QueryBuilder + conditionIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'condition', + value: '', + )); + }); + } } extension DoseCriteriaQueryObject @@ -3028,7 +3294,7 @@ extension DoseCriteriaQueryObject QueryBuilder productVariantsElement(FilterQuery q) { return QueryBuilder.apply(this, (query) { - return query.object(q, r'productVariants'); + return query.object(q, r'ProductVariants'); }); } } diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/remote/mdms.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/remote/mdms.dart index 60444799a..1a59cd922 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/remote/mdms.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/remote/mdms.dart @@ -349,20 +349,21 @@ class MdmsRepository { e.mandatoryWaitSinceLastCycleInDays ..deliveries = e.deliveries?.map((ele) { final newDeliveries = Deliveries(); - newDeliveries.doseCriteriaModel?.deliveryStrategy = - ele.doseCriteria?.deliveryStrategy; - newDeliveries - .doseCriteriaModel?.mandatoryWaitSinceLastDeliveryInDays = - ele.doseCriteria?.mandatoryWaitSinceLastDeliveryInDays; - newDeliveries.doseCriteriaModel?.deliveryStrategy = - ele.doseCriteria?.deliveryStrategy; - newDeliveries.doseCriteriaModel?.productVariants = - ele.doseCriteria?.productVariants?.map((e) { - final productVariants = ProductVariants() - ..productVariantId = e.productVariantId - ..quantity = e.quantity.toString(); - - return productVariants; + newDeliveries.deliveryStrategy = ele.deliveryStrategy; + newDeliveries.mandatoryWaitSinceLastDeliveryInDays = + ele.mandatoryWaitSinceLastDeliveryInDays; + newDeliveries.doseCriteriaModel = ele.doseCriteria?.map((e) { + final doseCriterias = DoseCriteria() + ..condition = e.condition + ..productVariants = e.productVariants?.map((p) { + final productVariants = ProductVariants() + ..quantity = p.quantity.toString() + ..productVariantId = p.productVariantId.toString(); + + return productVariants; + }).toList(); + + return doseCriterias; }).toList(); return newDeliveries; diff --git a/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.dart b/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.dart index 7d927139c..d22d01c41 100644 --- a/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.dart +++ b/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.dart @@ -56,10 +56,11 @@ class MdmsMasterDetailModel with _$MdmsMasterDetailModel { class AppConfigPrimaryWrapperModel with _$AppConfigPrimaryWrapperModel { const factory AppConfigPrimaryWrapperModel({ @JsonKey(name: 'HCM-FIELD-APP-CONFIG') - final AppConfigSecondaryWrapperModel? appConfig, - @JsonKey(name: 'module-version') final RowVersionWrapperModel? rowVersions, + final AppConfigSecondaryWrapperModel? appConfig, + @JsonKey(name: 'module-version') + final RowVersionWrapperModel? rowVersions, @JsonKey(name: 'HCM-SYMPTOMS-TYPES') - final SymptomsTypesSecondaryWrapperModel? symptomsTypes, + final SymptomsTypesSecondaryWrapperModel? symptomsTypes, }) = _AppConfigPrimaryWrapperModel; factory AppConfigPrimaryWrapperModel.fromJson( @@ -95,35 +96,43 @@ class RowVersionWrapperModel with _$RowVersionWrapperModel { @freezed class AppConfig with _$AppConfig { factory AppConfig({ - @JsonKey(name: 'NETWORK_DETECTION') required String networkDetection, - @JsonKey(name: 'PERSISTENCE_MODE') required String persistenceMode, - @JsonKey(name: 'SYNC_METHOD') required String syncMethod, - @JsonKey(name: 'SYNC_TRIGGER') required String syncTrigger, - @JsonKey(name: 'LANGUAGES') required List languages, - @JsonKey(name: 'TENANT_ID') final String? tenantId, - @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') final double? maxRadius, + @JsonKey(name: 'NETWORK_DETECTION') + required String networkDetection, + @JsonKey(name: 'PERSISTENCE_MODE') + required String persistenceMode, + @JsonKey(name: 'SYNC_METHOD') + required String syncMethod, + @JsonKey(name: 'SYNC_TRIGGER') + required String syncTrigger, + @JsonKey(name: 'LANGUAGES') + required List languages, + @JsonKey(name: 'TENANT_ID') + final String? tenantId, + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + final double? maxRadius, @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') - required List householdDeletionReasonOptions, + required List householdDeletionReasonOptions, @JsonKey(name: 'BANDWIDTH_BATCH_SIZE') - required List bandWidthBatchSize, + required List bandWidthBatchSize, @JsonKey(name: 'BACKGROUND_SERVICE_CONFIG') - BackgroundServiceConfig? backgroundServiceConfig, + BackgroundServiceConfig? backgroundServiceConfig, @JsonKey(name: 'HOUSEHOLD_MEMBER_DELETION_REASON_OPTIONS') - required List householdMemberDeletionReasonOptions, + required List + householdMemberDeletionReasonOptions, @JsonKey(name: 'GENDER_OPTIONS_POPULATOR') - required List genderOptions, + required List genderOptions, @JsonKey(name: 'CHECKLIST_TYPES') - required List checklistTypes, + required List checklistTypes, @JsonKey(name: 'ID_TYPE_OPTIONS_POPULATOR') - required List idTypeOptions, + required List idTypeOptions, @JsonKey(name: 'DELIVERY_COMMENT_OPTIONS_POPULATOR') - required List deliveryCommentOptions, + required List deliveryCommentOptions, @JsonKey(name: 'BACKEND_INTERFACE') - required BackendInterface backendInterface, + required BackendInterface backendInterface, @JsonKey(name: 'CALL_SUPPORT') - required List? callSupportOptions, + required List? callSupportOptions, @JsonKey(name: 'TRANSPORT_TYPES') - required List transportTypes, + required List transportTypes, }) = _AppConfig; factory AppConfig.fromJson(Map json) => diff --git a/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.dart b/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.dart index 917b12b90..a7b80ba3a 100644 --- a/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.dart +++ b/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.dart @@ -58,7 +58,13 @@ class Cycle with _$Cycle { @freezed class DeliveryModel with _$DeliveryModel { const factory DeliveryModel({ - DoseCriteriaModel? doseCriteria, + List? doseCriteria, + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + String? mandatoryWaitSinceLastDeliveryInDays, + @JsonKey(name: 'deliveryStrategy') + String? deliveryStrategy, + @Default(0) + int id, }) = _DeliveryModel; factory DeliveryModel.fromJson(Map json) => @@ -68,16 +74,10 @@ class DeliveryModel with _$DeliveryModel { @freezed class DoseCriteriaModel with _$DoseCriteriaModel { const factory DoseCriteriaModel({ - @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - String? mandatoryWaitSinceLastDeliveryInDays, @JsonKey(name: 'condition') String? condition, @JsonKey(name: 'ProductVariants') List? productVariants, - @JsonKey(name: 'deliveryStrategy') - String? deliveryStrategy, - @Default(0) - int id, }) = _DoseCriteriaModel; factory DoseCriteriaModel.fromJson(Map json) => diff --git a/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.freezed.dart b/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.freezed.dart index 571f917bc..928040e06 100644 --- a/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.freezed.dart +++ b/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.freezed.dart @@ -944,7 +944,14 @@ DeliveryModel _$DeliveryModelFromJson(Map json) { /// @nodoc mixin _$DeliveryModel { - DoseCriteriaModel? get doseCriteria => throw _privateConstructorUsedError; + List? get doseCriteria => + throw _privateConstructorUsedError; + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + String? get mandatoryWaitSinceLastDeliveryInDays => + throw _privateConstructorUsedError; + @JsonKey(name: 'deliveryStrategy') + String? get deliveryStrategy => throw _privateConstructorUsedError; + int get id => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -958,9 +965,13 @@ abstract class $DeliveryModelCopyWith<$Res> { DeliveryModel value, $Res Function(DeliveryModel) then) = _$DeliveryModelCopyWithImpl<$Res, DeliveryModel>; @useResult - $Res call({DoseCriteriaModel? doseCriteria}); - - $DoseCriteriaModelCopyWith<$Res>? get doseCriteria; + $Res call( + {List? doseCriteria, + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + String? mandatoryWaitSinceLastDeliveryInDays, + @JsonKey(name: 'deliveryStrategy') + String? deliveryStrategy, + int id}); } /// @nodoc @@ -977,26 +988,30 @@ class _$DeliveryModelCopyWithImpl<$Res, $Val extends DeliveryModel> @override $Res call({ Object? doseCriteria = freezed, + Object? mandatoryWaitSinceLastDeliveryInDays = freezed, + Object? deliveryStrategy = freezed, + Object? id = null, }) { return _then(_value.copyWith( doseCriteria: freezed == doseCriteria ? _value.doseCriteria : doseCriteria // ignore: cast_nullable_to_non_nullable - as DoseCriteriaModel?, + as List?, + mandatoryWaitSinceLastDeliveryInDays: freezed == + mandatoryWaitSinceLastDeliveryInDays + ? _value.mandatoryWaitSinceLastDeliveryInDays + : mandatoryWaitSinceLastDeliveryInDays // ignore: cast_nullable_to_non_nullable + as String?, + deliveryStrategy: freezed == deliveryStrategy + ? _value.deliveryStrategy + : deliveryStrategy // ignore: cast_nullable_to_non_nullable + as String?, + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, ) as $Val); } - - @override - @pragma('vm:prefer-inline') - $DoseCriteriaModelCopyWith<$Res>? get doseCriteria { - if (_value.doseCriteria == null) { - return null; - } - - return $DoseCriteriaModelCopyWith<$Res>(_value.doseCriteria!, (value) { - return _then(_value.copyWith(doseCriteria: value) as $Val); - }); - } } /// @nodoc @@ -1007,10 +1022,13 @@ abstract class _$$_DeliveryModelCopyWith<$Res> __$$_DeliveryModelCopyWithImpl<$Res>; @override @useResult - $Res call({DoseCriteriaModel? doseCriteria}); - - @override - $DoseCriteriaModelCopyWith<$Res>? get doseCriteria; + $Res call( + {List? doseCriteria, + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + String? mandatoryWaitSinceLastDeliveryInDays, + @JsonKey(name: 'deliveryStrategy') + String? deliveryStrategy, + int id}); } /// @nodoc @@ -1025,12 +1043,28 @@ class __$$_DeliveryModelCopyWithImpl<$Res> @override $Res call({ Object? doseCriteria = freezed, + Object? mandatoryWaitSinceLastDeliveryInDays = freezed, + Object? deliveryStrategy = freezed, + Object? id = null, }) { return _then(_$_DeliveryModel( doseCriteria: freezed == doseCriteria - ? _value.doseCriteria + ? _value._doseCriteria : doseCriteria // ignore: cast_nullable_to_non_nullable - as DoseCriteriaModel?, + as List?, + mandatoryWaitSinceLastDeliveryInDays: freezed == + mandatoryWaitSinceLastDeliveryInDays + ? _value.mandatoryWaitSinceLastDeliveryInDays + : mandatoryWaitSinceLastDeliveryInDays // ignore: cast_nullable_to_non_nullable + as String?, + deliveryStrategy: freezed == deliveryStrategy + ? _value.deliveryStrategy + : deliveryStrategy // ignore: cast_nullable_to_non_nullable + as String?, + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, )); } } @@ -1038,17 +1072,40 @@ class __$$_DeliveryModelCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$_DeliveryModel implements _DeliveryModel { - const _$_DeliveryModel({this.doseCriteria}); + const _$_DeliveryModel( + {final List? doseCriteria, + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + this.mandatoryWaitSinceLastDeliveryInDays, + @JsonKey(name: 'deliveryStrategy') + this.deliveryStrategy, + this.id = 0}) + : _doseCriteria = doseCriteria; factory _$_DeliveryModel.fromJson(Map json) => _$$_DeliveryModelFromJson(json); + final List? _doseCriteria; @override - final DoseCriteriaModel? doseCriteria; + List? get doseCriteria { + final value = _doseCriteria; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + final String? mandatoryWaitSinceLastDeliveryInDays; + @override + @JsonKey(name: 'deliveryStrategy') + final String? deliveryStrategy; + @override + @JsonKey() + final int id; @override String toString() { - return 'DeliveryModel(doseCriteria: $doseCriteria)'; + return 'DeliveryModel(doseCriteria: $doseCriteria, mandatoryWaitSinceLastDeliveryInDays: $mandatoryWaitSinceLastDeliveryInDays, deliveryStrategy: $deliveryStrategy, id: $id)'; } @override @@ -1056,13 +1113,25 @@ class _$_DeliveryModel implements _DeliveryModel { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_DeliveryModel && - (identical(other.doseCriteria, doseCriteria) || - other.doseCriteria == doseCriteria)); + const DeepCollectionEquality() + .equals(other._doseCriteria, _doseCriteria) && + (identical(other.mandatoryWaitSinceLastDeliveryInDays, + mandatoryWaitSinceLastDeliveryInDays) || + other.mandatoryWaitSinceLastDeliveryInDays == + mandatoryWaitSinceLastDeliveryInDays) && + (identical(other.deliveryStrategy, deliveryStrategy) || + other.deliveryStrategy == deliveryStrategy) && + (identical(other.id, id) || other.id == id)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, doseCriteria); + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_doseCriteria), + mandatoryWaitSinceLastDeliveryInDays, + deliveryStrategy, + id); @JsonKey(ignore: true) @override @@ -1079,14 +1148,27 @@ class _$_DeliveryModel implements _DeliveryModel { } abstract class _DeliveryModel implements DeliveryModel { - const factory _DeliveryModel({final DoseCriteriaModel? doseCriteria}) = - _$_DeliveryModel; + const factory _DeliveryModel( + {final List? doseCriteria, + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + final String? mandatoryWaitSinceLastDeliveryInDays, + @JsonKey(name: 'deliveryStrategy') + final String? deliveryStrategy, + final int id}) = _$_DeliveryModel; factory _DeliveryModel.fromJson(Map json) = _$_DeliveryModel.fromJson; @override - DoseCriteriaModel? get doseCriteria; + List? get doseCriteria; + @override + @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') + String? get mandatoryWaitSinceLastDeliveryInDays; + @override + @JsonKey(name: 'deliveryStrategy') + String? get deliveryStrategy; + @override + int get id; @override @JsonKey(ignore: true) _$$_DeliveryModelCopyWith<_$_DeliveryModel> get copyWith => @@ -1099,17 +1181,11 @@ DoseCriteriaModel _$DoseCriteriaModelFromJson(Map json) { /// @nodoc mixin _$DoseCriteriaModel { - @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - String? get mandatoryWaitSinceLastDeliveryInDays => - throw _privateConstructorUsedError; @JsonKey(name: 'condition') String? get condition => throw _privateConstructorUsedError; @JsonKey(name: 'ProductVariants') List? get productVariants => throw _privateConstructorUsedError; - @JsonKey(name: 'deliveryStrategy') - String? get deliveryStrategy => throw _privateConstructorUsedError; - int get id => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -1124,15 +1200,10 @@ abstract class $DoseCriteriaModelCopyWith<$Res> { _$DoseCriteriaModelCopyWithImpl<$Res, DoseCriteriaModel>; @useResult $Res call( - {@JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - String? mandatoryWaitSinceLastDeliveryInDays, - @JsonKey(name: 'condition') + {@JsonKey(name: 'condition') String? condition, @JsonKey(name: 'ProductVariants') - List? productVariants, - @JsonKey(name: 'deliveryStrategy') - String? deliveryStrategy, - int id}); + List? productVariants}); } /// @nodoc @@ -1148,18 +1219,10 @@ class _$DoseCriteriaModelCopyWithImpl<$Res, $Val extends DoseCriteriaModel> @pragma('vm:prefer-inline') @override $Res call({ - Object? mandatoryWaitSinceLastDeliveryInDays = freezed, Object? condition = freezed, Object? productVariants = freezed, - Object? deliveryStrategy = freezed, - Object? id = null, }) { return _then(_value.copyWith( - mandatoryWaitSinceLastDeliveryInDays: freezed == - mandatoryWaitSinceLastDeliveryInDays - ? _value.mandatoryWaitSinceLastDeliveryInDays - : mandatoryWaitSinceLastDeliveryInDays // ignore: cast_nullable_to_non_nullable - as String?, condition: freezed == condition ? _value.condition : condition // ignore: cast_nullable_to_non_nullable @@ -1168,14 +1231,6 @@ class _$DoseCriteriaModelCopyWithImpl<$Res, $Val extends DoseCriteriaModel> ? _value.productVariants : productVariants // ignore: cast_nullable_to_non_nullable as List?, - deliveryStrategy: freezed == deliveryStrategy - ? _value.deliveryStrategy - : deliveryStrategy // ignore: cast_nullable_to_non_nullable - as String?, - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, ) as $Val); } } @@ -1189,15 +1244,10 @@ abstract class _$$_DoseCriteriaModelCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - String? mandatoryWaitSinceLastDeliveryInDays, - @JsonKey(name: 'condition') + {@JsonKey(name: 'condition') String? condition, @JsonKey(name: 'ProductVariants') - List? productVariants, - @JsonKey(name: 'deliveryStrategy') - String? deliveryStrategy, - int id}); + List? productVariants}); } /// @nodoc @@ -1211,18 +1261,10 @@ class __$$_DoseCriteriaModelCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? mandatoryWaitSinceLastDeliveryInDays = freezed, Object? condition = freezed, Object? productVariants = freezed, - Object? deliveryStrategy = freezed, - Object? id = null, }) { return _then(_$_DoseCriteriaModel( - mandatoryWaitSinceLastDeliveryInDays: freezed == - mandatoryWaitSinceLastDeliveryInDays - ? _value.mandatoryWaitSinceLastDeliveryInDays - : mandatoryWaitSinceLastDeliveryInDays // ignore: cast_nullable_to_non_nullable - as String?, condition: freezed == condition ? _value.condition : condition // ignore: cast_nullable_to_non_nullable @@ -1231,14 +1273,6 @@ class __$$_DoseCriteriaModelCopyWithImpl<$Res> ? _value._productVariants : productVariants // ignore: cast_nullable_to_non_nullable as List?, - deliveryStrategy: freezed == deliveryStrategy - ? _value.deliveryStrategy - : deliveryStrategy // ignore: cast_nullable_to_non_nullable - as String?, - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, )); } } @@ -1247,23 +1281,15 @@ class __$$_DoseCriteriaModelCopyWithImpl<$Res> @JsonSerializable() class _$_DoseCriteriaModel implements _DoseCriteriaModel { const _$_DoseCriteriaModel( - {@JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - this.mandatoryWaitSinceLastDeliveryInDays, - @JsonKey(name: 'condition') + {@JsonKey(name: 'condition') this.condition, @JsonKey(name: 'ProductVariants') - final List? productVariants, - @JsonKey(name: 'deliveryStrategy') - this.deliveryStrategy, - this.id = 0}) + final List? productVariants}) : _productVariants = productVariants; factory _$_DoseCriteriaModel.fromJson(Map json) => _$$_DoseCriteriaModelFromJson(json); - @override - @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - final String? mandatoryWaitSinceLastDeliveryInDays; @override @JsonKey(name: 'condition') final String? condition; @@ -1277,16 +1303,9 @@ class _$_DoseCriteriaModel implements _DoseCriteriaModel { return EqualUnmodifiableListView(value); } - @override - @JsonKey(name: 'deliveryStrategy') - final String? deliveryStrategy; - @override - @JsonKey() - final int id; - @override String toString() { - return 'DoseCriteriaModel(mandatoryWaitSinceLastDeliveryInDays: $mandatoryWaitSinceLastDeliveryInDays, condition: $condition, productVariants: $productVariants, deliveryStrategy: $deliveryStrategy, id: $id)'; + return 'DoseCriteriaModel(condition: $condition, productVariants: $productVariants)'; } @override @@ -1294,28 +1313,16 @@ class _$_DoseCriteriaModel implements _DoseCriteriaModel { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_DoseCriteriaModel && - (identical(other.mandatoryWaitSinceLastDeliveryInDays, - mandatoryWaitSinceLastDeliveryInDays) || - other.mandatoryWaitSinceLastDeliveryInDays == - mandatoryWaitSinceLastDeliveryInDays) && (identical(other.condition, condition) || other.condition == condition) && const DeepCollectionEquality() - .equals(other._productVariants, _productVariants) && - (identical(other.deliveryStrategy, deliveryStrategy) || - other.deliveryStrategy == deliveryStrategy) && - (identical(other.id, id) || other.id == id)); + .equals(other._productVariants, _productVariants)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - mandatoryWaitSinceLastDeliveryInDays, - condition, - const DeepCollectionEquality().hash(_productVariants), - deliveryStrategy, - id); + int get hashCode => Object.hash(runtimeType, condition, + const DeepCollectionEquality().hash(_productVariants)); @JsonKey(ignore: true) @override @@ -1334,22 +1341,15 @@ class _$_DoseCriteriaModel implements _DoseCriteriaModel { abstract class _DoseCriteriaModel implements DoseCriteriaModel { const factory _DoseCriteriaModel( - {@JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - final String? mandatoryWaitSinceLastDeliveryInDays, - @JsonKey(name: 'condition') - final String? condition, - @JsonKey(name: 'ProductVariants') - final List? productVariants, - @JsonKey(name: 'deliveryStrategy') - final String? deliveryStrategy, - final int id}) = _$_DoseCriteriaModel; + {@JsonKey(name: 'condition') + final String? condition, + @JsonKey(name: 'ProductVariants') + final List? productVariants}) = + _$_DoseCriteriaModel; factory _DoseCriteriaModel.fromJson(Map json) = _$_DoseCriteriaModel.fromJson; - @override - @JsonKey(name: 'mandatoryWaitSinceLastDeliveryInDays') - String? get mandatoryWaitSinceLastDeliveryInDays; @override @JsonKey(name: 'condition') String? get condition; @@ -1357,11 +1357,6 @@ abstract class _DoseCriteriaModel implements DoseCriteriaModel { @JsonKey(name: 'ProductVariants') List? get productVariants; @override - @JsonKey(name: 'deliveryStrategy') - String? get deliveryStrategy; - @override - int get id; - @override @JsonKey(ignore: true) _$$_DoseCriteriaModelCopyWith<_$_DoseCriteriaModel> get copyWith => throw _privateConstructorUsedError; diff --git a/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.g.dart b/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.g.dart index e9d1dd19e..82eeb222a 100644 --- a/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.g.dart +++ b/apps/health_campaign_field_worker_app/lib/models/project_type/project_type_model.g.dart @@ -90,38 +90,37 @@ Map _$$_CycleToJson(_$_Cycle instance) => { _$_DeliveryModel _$$_DeliveryModelFromJson(Map json) => _$_DeliveryModel( - doseCriteria: json['doseCriteria'] == null - ? null - : DoseCriteriaModel.fromJson( - json['doseCriteria'] as Map), + doseCriteria: (json['doseCriteria'] as List?) + ?.map((e) => DoseCriteriaModel.fromJson(e as Map)) + .toList(), + mandatoryWaitSinceLastDeliveryInDays: + json['mandatoryWaitSinceLastDeliveryInDays'] as String?, + deliveryStrategy: json['deliveryStrategy'] as String?, + id: json['id'] as int? ?? 0, ); Map _$$_DeliveryModelToJson(_$_DeliveryModel instance) => { 'doseCriteria': instance.doseCriteria, + 'mandatoryWaitSinceLastDeliveryInDays': + instance.mandatoryWaitSinceLastDeliveryInDays, + 'deliveryStrategy': instance.deliveryStrategy, + 'id': instance.id, }; _$_DoseCriteriaModel _$$_DoseCriteriaModelFromJson(Map json) => _$_DoseCriteriaModel( - mandatoryWaitSinceLastDeliveryInDays: - json['mandatoryWaitSinceLastDeliveryInDays'] as String?, condition: json['condition'] as String?, productVariants: (json['ProductVariants'] as List?) ?.map((e) => ProductVariantsModel.fromJson(e as Map)) .toList(), - deliveryStrategy: json['deliveryStrategy'] as String?, - id: json['id'] as int? ?? 0, ); Map _$$_DoseCriteriaModelToJson( _$_DoseCriteriaModel instance) => { - 'mandatoryWaitSinceLastDeliveryInDays': - instance.mandatoryWaitSinceLastDeliveryInDays, 'condition': instance.condition, 'ProductVariants': instance.productVariants, - 'deliveryStrategy': instance.deliveryStrategy, - 'id': instance.id, }; _$_ProductVariantsModel _$$_ProductVariantsModelFromJson( diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/deliver_intervention.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/deliver_intervention.dart index 58be2eab0..151409630 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/deliver_intervention.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/deliver_intervention.dart @@ -96,44 +96,38 @@ class _DeliverInterventionPageState List? productVariants = projectState .projectType?.cycles?.isNotEmpty == true - ? (fetchDeliveries( + ? (fetchProductVariant( projectState .projectType! .cycles![deliveryInterventionstate.cycle - 1] - .deliveries, + .deliveries?[deliveryInterventionstate + .dose - + 1], state.selectedIndividual, - )?[deliveryInterventionstate.dose - 1] - .doseCriteria - ?.productVariants) + )?.productVariants) : projectState.projectType?.resources; - final int numberOfDoses = - (projectState.projectType?.cycles?.isNotEmpty == true) - ? (fetchDeliveries( - projectState - .projectType - ?.cycles?[ - deliveryInterventionstate.cycle - 1] - .deliveries, - state.selectedIndividual, - )?.length) ?? - 0 - : 0; + final int numberOfDoses = (projectState + .projectType?.cycles?.isNotEmpty == + true) + ? (projectState + .projectType + ?.cycles?[deliveryInterventionstate.cycle - 1] + .deliveries + ?.length) ?? + 0 + : 0; final String? getDeliveryStrategy = projectState .projectType?.cycles?.isNotEmpty == true - ? (fetchDeliveries( - projectState - .projectType - ?.cycles?[deliveryInterventionstate.cycle == 0 - ? deliveryInterventionstate.cycle - : deliveryInterventionstate.cycle - 1] - .deliveries, - state.selectedIndividual, - )?[deliveryInterventionstate.dose - 1] - .doseCriteria - ?.deliveryStrategy) + ? (projectState + .projectType + ?.cycles?[deliveryInterventionstate.cycle == 0 + ? deliveryInterventionstate.cycle + : deliveryInterventionstate.cycle - 1] + .deliveries?[deliveryInterventionstate.dose - 1] + .deliveryStrategy) : DeliverStrategyType.direct.toValue(); final steps = generateSteps(numberOfDoses); diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart index 41e74495c..10c6ec9e1 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart @@ -15,7 +15,6 @@ import '../../blocs/delivery_intervention/deliver_intervention.dart'; import '../../blocs/household_overview/household_overview.dart'; import '../../blocs/localization/app_localization.dart'; import '../../blocs/product_variant/product_variant.dart'; -import '../../blocs/search_households/search_households.dart'; import '../../models/data_model.dart'; import '../../router/app_router.dart'; import '../../utils/environment_config.dart'; @@ -23,7 +22,6 @@ import '../../utils/utils.dart'; import '../../widgets/component_wrapper/product_variant_bloc_wrapper.dart'; import '../../widgets/header/back_navigation_help_header.dart'; import '../../widgets/localized.dart'; -import 'widgets/household_acknowledgement.dart'; class DoseAdministeredPage extends LocalizedStatefulWidget { const DoseAdministeredPage({ @@ -44,7 +42,7 @@ class _DoseAdministeredPageState extends LocalizedState { Widget build(BuildContext context) { final theme = Theme.of(context); final localizations = AppLocalizations.of(context); - + final overViewBloc = context.read().state; // Define a list of TableHeader objects for the header of a table final headerListResource = [ TableHeader( @@ -95,7 +93,7 @@ class _DoseAdministeredPageState extends LocalizedState { // Iterate through future deliveries for (var e in bloc.futureDeliveries!) { - int doseIndex = e.doseCriteria?.id ?? 0; + int doseIndex = e.id; final clientReferenceId = IdGen.i.identifier; final address = bloc.oldTask?.address; // Create and dispatch a DeliverInterventionSubmitEvent with a new TaskModel @@ -120,7 +118,11 @@ class _DoseAdministeredPageState extends LocalizedState { createdBy: context.loggedInUserUuid, createdTime: context.millisecondsSinceEpoch(), ), - resources: e.doseCriteria?.productVariants + resources: fetchProductVariant( + e, + overViewBloc.selectedIndividual, + ) + ?.productVariants ?.map((variant) => TaskResourceModel( clientReferenceId: IdGen.i.identifier, taskclientReferenceId: @@ -171,7 +173,7 @@ class _DoseAdministeredPageState extends LocalizedState { ), AdditionalField( 'DeliveryStrategy', - e.doseCriteria?.deliveryStrategy, + e.deliveryStrategy, ), ], ), @@ -189,12 +191,11 @@ class _DoseAdministeredPageState extends LocalizedState { projectId: context.projectId, projectBeneficiaryType: context.beneficiaryType, )); - }); - context.router.popAndPush( - HouseholdAcknowledgementRoute( - enableViewHousehold: true, - ), - ); + }).then((value) => context.router.popAndPush( + HouseholdAcknowledgementRoute( + enableViewHousehold: true, + ), + )); }, child: Center( child: Text( @@ -262,7 +263,11 @@ class _DoseAdministeredPageState extends LocalizedState { 'Dose $doseIndex', cellKey: 'dose', ), - ...e.doseCriteria!.productVariants! + ...fetchProductVariant( + e, + overViewBloc.selectedIndividual, + )! + .productVariants! .map( (ele) => TableData( variant! @@ -294,16 +299,23 @@ class _DoseAdministeredPageState extends LocalizedState { element: { localizations.translate( i18.beneficiaryDetails.beneficiaryAge, - ): '${deliveryState.futureDeliveries?.first.doseCriteria?.condition?.split('<=age<').first} - ${deliveryState.futureDeliveries?.first.doseCriteria?.condition?.split('<=age<').last} months', + ): '${fetchProductVariant( + deliveryState.futureDeliveries?.first, + overViewBloc.selectedIndividual, + )?.condition?.split('<=age<').first} - ${fetchProductVariant( + deliveryState.futureDeliveries?.first, + overViewBloc.selectedIndividual, + )?.condition?.split('<=age<').last} months', }, ), const Divider(), DigitTable( headerList: headerListResource, tableData: tableDataRows, - leftColumnWidth: 130, + leftColumnWidth: + MediaQuery.of(context).size.width / 2.1, rightColumnWidth: - headerListResource.length * 17 * 6, + headerListResource.length * 87, height: (tableDataRows.length + 1) * 60, ), ], diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/household_overview.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/household_overview.dart index b10779ee3..dd73a9f18 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/household_overview.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/household_overview.dart @@ -496,22 +496,17 @@ class _HouseholdOverviewPageState ?.cycles != null ? !checkEligibilityForAgeAndAdverseEvent( - DigitDOBAge( - years: ageInYears, - months: ageInMonths, - ), - projectState - .projectType, - (taskdata ?? []) - .isNotEmpty - ? taskdata?.last - : null, - adverseEventData, - ) && - !checkStatus( - taskdata, - currentCycle, - ) + DigitDOBAge( + years: ageInYears, + months: ageInMonths, + ), + projectState.projectType, + (taskdata ?? []) + .isNotEmpty + ? taskdata?.last + : null, + adverseEventData, + ) : false, // TODO Need to handle the null check name: e.name?.givenName ?? ' - ', diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/past_delivery.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/past_delivery.dart index 3a141497d..816dfe103 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/past_delivery.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/past_delivery.dart @@ -45,21 +45,20 @@ Widget buildTableContent( child: BlocBuilder( builder: (context, projectState) { // BlocBuilder to get project data based on the current cycle and dose - final item = fetchDeliveries( - projectState.projectType!.cycles![currentCycle - 1].deliveries, - individualModel, - )![currentDose - 1]; + final item = projectState.projectType!.cycles![currentCycle - 1] + .deliveries![currentDose - 1]; return Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, + // mainAxisSize: MainAxisSize.min, children: [ DigitTableCard( + fraction: 2.5, element: { localizations.translate( i18.beneficiaryDetails.beneficiaryAge, //[TODO: Condition need to be handled in generic way,] - ): '${item.doseCriteria?.condition?.split('<=age<').first} - ${item.doseCriteria?.condition?.split('<=age<').last} months', + ): '${fetchProductVariant(item, individualModel)?.condition?.split('<=age<').first} - ${fetchProductVariant(item, individualModel)?.condition?.split('<=age<').last} months', }, ), // const Divider(), @@ -68,7 +67,9 @@ Widget buildTableContent( DigitTable( headerList: headerListResource, tableData: [ - ...item.doseCriteria!.productVariants!.map( + ...fetchProductVariant(item, individualModel)! + .productVariants! + .map( (e) { // Retrieve the SKU value for the product variant. final value = variant! @@ -81,7 +82,10 @@ Widget buildTableContent( // Display the dose information in the first column if it's the first row, // otherwise, display an empty cell. - item.doseCriteria?.productVariants?.indexOf(e) == 0 + fetchProductVariant(item, individualModel)! + .productVariants + ?.indexOf(e) == + 0 ? TableData( 'Dose ${deliverInterventionState.dose}', cellKey: 'dose', @@ -97,9 +101,13 @@ Widget buildTableContent( ), ], leftColumnWidth: 130, - rightColumnWidth: headerListResource.length * 20 * 5, - height: - ((item.doseCriteria?.productVariants ?? []).length + 1) * 60, + rightColumnWidth: headerListResource.length * 66, + height: ((fetchProductVariant(item, individualModel)! + .productVariants ?? + []) + .length + + 1) * + 60, ), ], ); diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/record_delivery_cycle.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/record_delivery_cycle.dart index fce23c332..d469a18b7 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/record_delivery_cycle.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/widgets/record_delivery_cycle.dart @@ -194,8 +194,7 @@ class _RecordDeliveryCycleState extends LocalizedState { DigitTable( selectedIndex: selectedIndex, headerList: headerList, - tableData: - fetchDeliveries(e.deliveries, widget.individualModel)!.map( + tableData: e.deliveries!.map( (item) { final tasks = widget.taskData ?.where((element) => @@ -207,7 +206,7 @@ class _RecordDeliveryCycleState extends LocalizedState { .toValue(), ) ?.value == - '0${item.doseCriteria?.id}' && + '0${item.id}' && element.additionalFields?.fields .firstWhereOrNull( (c) => @@ -221,7 +220,7 @@ class _RecordDeliveryCycleState extends LocalizedState { return TableDataRow([ TableData( - 'Dose ${fetchDeliveries(e.deliveries, widget.individualModel)!.indexOf(item) + 1}', + 'Dose ${e.deliveries!.indexOf(item) + 1}', cellKey: 'dose', ), TableData( @@ -241,11 +240,7 @@ class _RecordDeliveryCycleState extends LocalizedState { ).toList(), leftColumnWidth: 130, rightColumnWidth: headerList.length * 87, - height: ((fetchDeliveries(e.deliveries, widget.individualModel) - ?.length ?? - 0) + - 1) * - 58, + height: ((e.deliveries?.length ?? 0) + 1) * 58, ), ], ), diff --git a/apps/health_campaign_field_worker_app/lib/pages/search_beneficiary.dart b/apps/health_campaign_field_worker_app/lib/pages/search_beneficiary.dart index ae74a5921..fe9329ec4 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/search_beneficiary.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/search_beneficiary.dart @@ -2,7 +2,6 @@ import 'package:digit_components/digit_components.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; -import 'package:location/location.dart'; import '../blocs/app_initialization/app_initialization.dart'; import '../blocs/beneficiary_registration/beneficiary_registration.dart'; @@ -224,12 +223,12 @@ class _SearchBeneficiaryPageState searchState.householdMembers.elementAt(index); final distance = calculateDistance( Coordinate( - locationState.latitude!, - locationState.longitude!, + locationState.latitude, + locationState.longitude, ), Coordinate( - i.household.address!.latitude!, - i.household.address!.longitude!, + i.household.address?.latitude, + i.household.address?.longitude, ), ); diff --git a/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart b/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart index 298886444..4896491fe 100644 --- a/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart +++ b/apps/health_campaign_field_worker_app/lib/utils/i18_key_constants.dart @@ -354,6 +354,8 @@ class HouseholdOverView { String get householdOverViewActionText => 'HOUSEHOLD_OVER_VIEW_ACTION_TEXT'; + String get viewDeliveryLabel => 'VIEW_DELIVERY_DETAILS_LABEL'; + String get householdOverViewAddActionText => 'HOUSEHOLD_OVER_VIEW__ADD_ACTION_TEXT'; } diff --git a/apps/health_campaign_field_worker_app/lib/utils/utils.dart b/apps/health_campaign_field_worker_app/lib/utils/utils.dart index a866bed3f..46bb4d433 100644 --- a/apps/health_campaign_field_worker_app/lib/utils/utils.dart +++ b/apps/health_campaign_field_worker_app/lib/utils/utils.dart @@ -144,33 +144,40 @@ performBackgroundService({ } class Coordinate { - final double latitude; - final double longitude; + final double? latitude; + final double? longitude; Coordinate(this.latitude, this.longitude); } -double calculateDistance(Coordinate start, Coordinate end) { +double? calculateDistance(Coordinate? start, Coordinate? end) { const double earthRadius = 6371.0; // Earth's radius in kilometers double toRadians(double degrees) { return degrees * pi / 180.0; } - double lat1Rad = toRadians(start.latitude); - double lon1Rad = toRadians(start.longitude); - double lat2Rad = toRadians(end.latitude); - double lon2Rad = toRadians(end.longitude); + if (start?.latitude != null && + start?.longitude != null && + end?.latitude != null && + end?.longitude != null) { + double lat1Rad = toRadians(start!.latitude!); + double lon1Rad = toRadians(start.longitude!); + double lat2Rad = toRadians(end!.latitude!); + double lon2Rad = toRadians(end.longitude!); - double dLat = lat2Rad - lat1Rad; - double dLon = lon2Rad - lon1Rad; + double dLat = lat2Rad - lat1Rad; + double dLon = lon2Rad - lon1Rad; - double a = pow(sin(dLat / 2), 2) + - cos(lat1Rad) * cos(lat2Rad) * pow(sin(dLon / 2), 2); - double c = 2 * atan2(sqrt(a), sqrt(1 - a)); - double distance = earthRadius * c; + double a = pow(sin(dLat / 2), 2) + + cos(lat1Rad) * cos(lat2Rad) * pow(sin(dLon / 2), 2); + double c = 2 * atan2(sqrt(a), sqrt(1 - a)); + double distance = earthRadius * c; - return distance; + return distance; + } + + return null; } Timer makePeriodicTimer( @@ -292,7 +299,7 @@ bool checkEligibilityForAgeAndAdverseEvent( projectType?.validMaxAge != null ? totalAgeMonths >= projectType!.validMinAge! && totalAgeMonths <= projectType.validMaxAge! - ? recordedAdverseEvent + ? recordedAdverseEvent && !checkStatus([tasks], currentCycle) ? false : true : false @@ -385,8 +392,7 @@ bool allDosesDelivered( ) { if (selectedCycle == null || selectedCycle.id == 0 || - (fetchDeliveries(selectedCycle.deliveries, individualModel) ?? []) - .isEmpty) { + (selectedCycle.deliveries ?? []).isEmpty) { return true; } else { if ((tasks ?? []).isNotEmpty) { @@ -405,9 +411,7 @@ bool allDosesDelivered( ?.value ?? ''); if (lastDose != null && - lastDose == - fetchDeliveries(selectedCycle.deliveries, individualModel) - ?.length && + lastDose == selectedCycle.deliveries?.length && lastCycle != null && lastCycle == selectedCycle.id && tasks?.last.status != Status.partiallyDelivered.toValue()) { @@ -426,11 +430,11 @@ bool allDosesDelivered( } } -List? fetchDeliveries( - List? deliveries, +DoseCriteriaModel? fetchProductVariant( + DeliveryModel? currentDelivery, IndividualModel? individualModel, ) { - if (deliveries != null && individualModel != null) { + if (currentDelivery != null && individualModel != null) { final individualAge = DigitDateUtils.calculateAge( DigitDateUtils.getFormattedDateToDateTime( individualModel.dateOfBirth!, @@ -439,24 +443,23 @@ List? fetchDeliveries( ); final individualAgeInMonths = individualAge.years * 12 + individualAge.months; - final filteredDeliveries = deliveries.where((delivery) { - final condition = delivery.doseCriteria?.condition; + final filteredCriteria = currentDelivery.doseCriteria?.where((criteria) { + final condition = criteria.condition; if (condition != null) { - //[TODO: Condition need to be handled in generic way,] - final parts = condition.split('<=age<'); - final minCondition = int.tryParse(parts.first); - final maxCondition = int.tryParse(parts.last); - if (minCondition != null && maxCondition != null) { - return individualAgeInMonths >= minCondition && - individualAgeInMonths <= maxCondition; - } + //{TODO: Expression package need to be parsed + final ageRange = condition.split("<=age<"); + final minAge = int.parse(ageRange.first); + final maxAge = int.parse(ageRange.last); + + return individualAgeInMonths >= minAge && + individualAgeInMonths <= maxAge; } return false; }).toList(); - return filteredDeliveries; + return (filteredCriteria ?? []).isNotEmpty ? filteredCriteria?.first : null; } - return []; + return null; } diff --git a/apps/health_campaign_field_worker_app/lib/widgets/beneficiary/view_beneficiary_card.dart b/apps/health_campaign_field_worker_app/lib/widgets/beneficiary/view_beneficiary_card.dart index 51b0b82fb..6a2a77e1b 100644 --- a/apps/health_campaign_field_worker_app/lib/widgets/beneficiary/view_beneficiary_card.dart +++ b/apps/health_campaign_field_worker_app/lib/widgets/beneficiary/view_beneficiary_card.dart @@ -134,6 +134,8 @@ class _ViewBeneficiaryCardState extends LocalizedState { (taskdata ?? []).isNotEmpty ? taskdata?.last : null, adverseEvents, ); + final isAdverseEventRecorded = recordedAdverseEvent(currentCycle, + (taskdata ?? []).isNotEmpty ? taskdata?.last : null, adverseEvents); final isBeneficiaryRefused = checkIfBeneficiaryRefused(taskdata); // TODO need to pass the current cycle @@ -243,8 +245,9 @@ class _ViewBeneficiaryCardState extends LocalizedState { householdMember.household.address?.city, householdMember.household.address?.pincode, ].whereNotNull().take(2).join(' '), - subtitle: - '${householdMember.household.memberCount ?? 1} Members \n ${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts)'}', + subtitle: widget.distance != null + ? '${householdMember.members.length ?? 1} Members \n ${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts)'}' + : '', status: context.beneficiaryType != BeneficiaryType.individual ? (householdMember.tasks ?? []).isNotEmpty && !isNotEligible && @@ -304,7 +307,7 @@ class _ViewBeneficiaryCardState extends LocalizedState { bool isBeneficiaryRefused, bool isStatusReset, ) { - if (isNotEligible && !isStatusReset) { + if (isNotEligible) { return 'Not Eligible'; } else if (taskdata != null) { if (taskdata.isEmpty) { diff --git a/apps/health_campaign_field_worker_app/lib/widgets/member_card/member_card.dart b/apps/health_campaign_field_worker_app/lib/widgets/member_card/member_card.dart index 2c0051645..e78b341d6 100644 --- a/apps/health_campaign_field_worker_app/lib/widgets/member_card/member_card.dart +++ b/apps/health_campaign_field_worker_app/lib/widgets/member_card/member_card.dart @@ -225,10 +225,19 @@ class MemberCard extends StatelessWidget { }, child: Center( child: Text( - localizations.translate( - i18.householdOverView - .householdOverViewActionText, - ), + allDosesDelivered( + tasks, + context.selectedCycle, + adverseEvents, + individual, + ) + ? localizations.translate( + i18.householdOverView.viewDeliveryLabel, + ) + : localizations.translate( + i18.householdOverView + .householdOverViewActionText, + ), ), ), ) diff --git a/packages/digit_components/lib/widgets/molecules/digit_table.dart b/packages/digit_components/lib/widgets/molecules/digit_table.dart index 5749abebc..3697150fa 100644 --- a/packages/digit_components/lib/widgets/molecules/digit_table.dart +++ b/packages/digit_components/lib/widgets/molecules/digit_table.dart @@ -127,7 +127,7 @@ class DigitTable extends StatelessWidget { } return Container( - color: index % 2 == 0 ? theme.scaffoldBackgroundColor : theme.cardColor, + color: index % 2 == 0 ? DigitTheme.instance.colorScheme.surface : theme.cardColor, child: Row(children: list)); } From c1bcda69a016fc500e2c92ba2e480accb818d6c9 Mon Sep 17 00:00:00 2001 From: Ramkrishna-egov Date: Wed, 11 Oct 2023 00:28:33 +0530 Subject: [PATCH 2/2] Code commenting --- .../lib/pages/beneficiary/dose_administered.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart index 10c6ec9e1..2382a462f 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary/dose_administered.dart @@ -307,6 +307,7 @@ class _DoseAdministeredPageState extends LocalizedState { overViewBloc.selectedIndividual, )?.condition?.split('<=age<').last} months', }, + //[TODO:: Need to parse <=age< as an Expression ), const Divider(), DigitTable(