From c44c257d6becf401b50b1e5ae7b92f7b26bbc370 Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 25 Jul 2023 11:13:19 +0530 Subject: [PATCH 01/17] added filter for stock recon --- .../inventory_report/inventory_report.dart | 8 +- .../inventory_report.freezed.dart | 133 +++++++++++++++--- .../search_households/search_households.dart | 8 +- .../local_store/sql_store/sql_store.g.dart | 114 +++++++++++++++ .../sql_store/tables/household.dart | 3 + .../data/repositories/local/household.dart | 24 +++- .../local/stock_reconciliation.dart | 5 + .../lib/models/data_model.mapper.g.dart | 30 ++-- .../lib/models/entities/household.dart | 18 +++ .../lib/models/entities/user.dart | 13 +- .../lib/models/model_configs/household.json | 15 ++ .../inventory/reports/report_details.dart | 23 ++- 12 files changed, 343 insertions(+), 51 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.dart b/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.dart index a423f1ed6..a29af4b90 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.dart @@ -96,6 +96,8 @@ class InventoryReportBloc final data = await stockReconciliationRepository.search( StockReconciliationSearchModel( tenantId: envConfig.variables.tenantId, + facilityId: event.facilityId, + productVariantId: event.productVariantId, ), ); @@ -119,8 +121,10 @@ class InventoryReportEvent with _$InventoryReportEvent { required String productVariantId, }) = InventoryReportLoadStockDataEvent; - const factory InventoryReportEvent.loadStockReconciliationData() = - InventoryReportLoadStockReconciliationDataEvent; + const factory InventoryReportEvent.loadStockReconciliationData({ + required String facilityId, + required String productVariantId, + }) = InventoryReportLoadStockReconciliationDataEvent; } @freezed diff --git a/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.freezed.dart b/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.freezed.dart index dc4258fa3..c3875e2ad 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.freezed.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/inventory_report/inventory_report.freezed.dart @@ -16,12 +16,15 @@ final _privateConstructorUsedError = UnsupportedError( /// @nodoc mixin _$InventoryReportEvent { + String get facilityId => throw _privateConstructorUsedError; + String get productVariantId => throw _privateConstructorUsedError; @optionalTypeArgs TResult when({ required TResult Function(InventoryReportType reportType, String facilityId, String productVariantId) loadStockData, - required TResult Function() loadStockReconciliationData, + required TResult Function(String facilityId, String productVariantId) + loadStockReconciliationData, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -29,7 +32,8 @@ mixin _$InventoryReportEvent { TResult? Function(InventoryReportType reportType, String facilityId, String productVariantId)? loadStockData, - TResult? Function()? loadStockReconciliationData, + TResult? Function(String facilityId, String productVariantId)? + loadStockReconciliationData, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -37,7 +41,8 @@ mixin _$InventoryReportEvent { TResult Function(InventoryReportType reportType, String facilityId, String productVariantId)? loadStockData, - TResult Function()? loadStockReconciliationData, + TResult Function(String facilityId, String productVariantId)? + loadStockReconciliationData, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -65,6 +70,10 @@ mixin _$InventoryReportEvent { required TResult orElse(), }) => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $InventoryReportEventCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc @@ -72,6 +81,8 @@ abstract class $InventoryReportEventCopyWith<$Res> { factory $InventoryReportEventCopyWith(InventoryReportEvent value, $Res Function(InventoryReportEvent) then) = _$InventoryReportEventCopyWithImpl<$Res, InventoryReportEvent>; + @useResult + $Res call({String facilityId, String productVariantId}); } /// @nodoc @@ -84,14 +95,34 @@ class _$InventoryReportEventCopyWithImpl<$Res, final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? facilityId = null, + Object? productVariantId = null, + }) { + return _then(_value.copyWith( + facilityId: null == facilityId + ? _value.facilityId + : facilityId // ignore: cast_nullable_to_non_nullable + as String, + productVariantId: null == productVariantId + ? _value.productVariantId + : productVariantId // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } } /// @nodoc -abstract class _$$InventoryReportLoadStockDataEventCopyWith<$Res> { +abstract class _$$InventoryReportLoadStockDataEventCopyWith<$Res> + implements $InventoryReportEventCopyWith<$Res> { factory _$$InventoryReportLoadStockDataEventCopyWith( _$InventoryReportLoadStockDataEvent value, $Res Function(_$InventoryReportLoadStockDataEvent) then) = __$$InventoryReportLoadStockDataEventCopyWithImpl<$Res>; + @override @useResult $Res call( {InventoryReportType reportType, @@ -185,7 +216,8 @@ class _$InventoryReportLoadStockDataEvent required TResult Function(InventoryReportType reportType, String facilityId, String productVariantId) loadStockData, - required TResult Function() loadStockReconciliationData, + required TResult Function(String facilityId, String productVariantId) + loadStockReconciliationData, }) { return loadStockData(reportType, facilityId, productVariantId); } @@ -196,7 +228,8 @@ class _$InventoryReportLoadStockDataEvent TResult? Function(InventoryReportType reportType, String facilityId, String productVariantId)? loadStockData, - TResult? Function()? loadStockReconciliationData, + TResult? Function(String facilityId, String productVariantId)? + loadStockReconciliationData, }) { return loadStockData?.call(reportType, facilityId, productVariantId); } @@ -207,7 +240,8 @@ class _$InventoryReportLoadStockDataEvent TResult Function(InventoryReportType reportType, String facilityId, String productVariantId)? loadStockData, - TResult Function()? loadStockReconciliationData, + TResult Function(String facilityId, String productVariantId)? + loadStockReconciliationData, required TResult orElse(), }) { if (loadStockData != null) { @@ -262,8 +296,11 @@ abstract class InventoryReportLoadStockDataEvent _$InventoryReportLoadStockDataEvent; InventoryReportType get reportType; + @override String get facilityId; + @override String get productVariantId; + @override @JsonKey(ignore: true) _$$InventoryReportLoadStockDataEventCopyWith< _$InventoryReportLoadStockDataEvent> @@ -271,13 +308,16 @@ abstract class InventoryReportLoadStockDataEvent } /// @nodoc -abstract class _$$InventoryReportLoadStockReconciliationDataEventCopyWith< - $Res> { +abstract class _$$InventoryReportLoadStockReconciliationDataEventCopyWith<$Res> + implements $InventoryReportEventCopyWith<$Res> { factory _$$InventoryReportLoadStockReconciliationDataEventCopyWith( _$InventoryReportLoadStockReconciliationDataEvent value, $Res Function(_$InventoryReportLoadStockReconciliationDataEvent) then) = __$$InventoryReportLoadStockReconciliationDataEventCopyWithImpl<$Res>; + @override + @useResult + $Res call({String facilityId, String productVariantId}); } /// @nodoc @@ -290,28 +330,66 @@ class __$$InventoryReportLoadStockReconciliationDataEventCopyWithImpl<$Res> _$InventoryReportLoadStockReconciliationDataEvent _value, $Res Function(_$InventoryReportLoadStockReconciliationDataEvent) _then) : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? facilityId = null, + Object? productVariantId = null, + }) { + return _then(_$InventoryReportLoadStockReconciliationDataEvent( + facilityId: null == facilityId + ? _value.facilityId + : facilityId // ignore: cast_nullable_to_non_nullable + as String, + productVariantId: null == productVariantId + ? _value.productVariantId + : productVariantId // ignore: cast_nullable_to_non_nullable + as String, + )); + } } /// @nodoc class _$InventoryReportLoadStockReconciliationDataEvent implements InventoryReportLoadStockReconciliationDataEvent { - const _$InventoryReportLoadStockReconciliationDataEvent(); + const _$InventoryReportLoadStockReconciliationDataEvent( + {required this.facilityId, required this.productVariantId}); + + @override + final String facilityId; + @override + final String productVariantId; @override String toString() { - return 'InventoryReportEvent.loadStockReconciliationData()'; + return 'InventoryReportEvent.loadStockReconciliationData(facilityId: $facilityId, productVariantId: $productVariantId)'; } @override bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$InventoryReportLoadStockReconciliationDataEvent); + other is _$InventoryReportLoadStockReconciliationDataEvent && + (identical(other.facilityId, facilityId) || + other.facilityId == facilityId) && + (identical(other.productVariantId, productVariantId) || + other.productVariantId == productVariantId)); } @override - int get hashCode => runtimeType.hashCode; + int get hashCode => Object.hash(runtimeType, facilityId, productVariantId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$InventoryReportLoadStockReconciliationDataEventCopyWith< + _$InventoryReportLoadStockReconciliationDataEvent> + get copyWith => + __$$InventoryReportLoadStockReconciliationDataEventCopyWithImpl< + _$InventoryReportLoadStockReconciliationDataEvent>( + this, _$identity); @override @optionalTypeArgs @@ -319,9 +397,10 @@ class _$InventoryReportLoadStockReconciliationDataEvent required TResult Function(InventoryReportType reportType, String facilityId, String productVariantId) loadStockData, - required TResult Function() loadStockReconciliationData, + required TResult Function(String facilityId, String productVariantId) + loadStockReconciliationData, }) { - return loadStockReconciliationData(); + return loadStockReconciliationData(facilityId, productVariantId); } @override @@ -330,9 +409,10 @@ class _$InventoryReportLoadStockReconciliationDataEvent TResult? Function(InventoryReportType reportType, String facilityId, String productVariantId)? loadStockData, - TResult? Function()? loadStockReconciliationData, + TResult? Function(String facilityId, String productVariantId)? + loadStockReconciliationData, }) { - return loadStockReconciliationData?.call(); + return loadStockReconciliationData?.call(facilityId, productVariantId); } @override @@ -341,11 +421,12 @@ class _$InventoryReportLoadStockReconciliationDataEvent TResult Function(InventoryReportType reportType, String facilityId, String productVariantId)? loadStockData, - TResult Function()? loadStockReconciliationData, + TResult Function(String facilityId, String productVariantId)? + loadStockReconciliationData, required TResult orElse(), }) { if (loadStockReconciliationData != null) { - return loadStockReconciliationData(); + return loadStockReconciliationData(facilityId, productVariantId); } return orElse(); } @@ -389,8 +470,20 @@ class _$InventoryReportLoadStockReconciliationDataEvent abstract class InventoryReportLoadStockReconciliationDataEvent implements InventoryReportEvent { - const factory InventoryReportLoadStockReconciliationDataEvent() = + const factory InventoryReportLoadStockReconciliationDataEvent( + {required final String facilityId, + required final String productVariantId}) = _$InventoryReportLoadStockReconciliationDataEvent; + + @override + String get facilityId; + @override + String get productVariantId; + @override + @JsonKey(ignore: true) + _$$InventoryReportLoadStockReconciliationDataEventCopyWith< + _$InventoryReportLoadStockReconciliationDataEvent> + get copyWith => throw _privateConstructorUsedError; } /// @nodoc diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 34ad6755d..f918dbe13 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -252,7 +252,13 @@ class SearchHouseholdsBloc if (householdId == null) continue; final households = await household.search( - HouseholdSearchModel(clientReferenceId: [householdId]), + HouseholdSearchModel( + clientReferenceId: [householdId], + // [TODO]: Need to take this data from location service on search screen. + latitude: 90, + longitude: 180, + maxRadius: 100, + ), ); if (households.isEmpty) continue; diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart index 10f3436ce..d0e72ffc4 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart @@ -3700,6 +3700,9 @@ class $FacilityTable extends Facility class HouseholdData extends DataClass implements Insertable { final String? id; final int? memberCount; + final double? latitude; + final double? longitude; + final double? maxRadius; final String? auditCreatedBy; final int? auditCreatedTime; final String? auditModifiedBy; @@ -3712,6 +3715,9 @@ class HouseholdData extends DataClass implements Insertable { HouseholdData( {this.id, this.memberCount, + this.latitude, + this.longitude, + this.maxRadius, this.auditCreatedBy, this.auditCreatedTime, this.auditModifiedBy, @@ -3728,6 +3734,12 @@ class HouseholdData extends DataClass implements Insertable { .mapFromDatabaseResponse(data['${effectivePrefix}id']), memberCount: const IntType() .mapFromDatabaseResponse(data['${effectivePrefix}member_count']), + latitude: const RealType() + .mapFromDatabaseResponse(data['${effectivePrefix}latitude']), + longitude: const RealType() + .mapFromDatabaseResponse(data['${effectivePrefix}longitude']), + maxRadius: const RealType() + .mapFromDatabaseResponse(data['${effectivePrefix}max_radius']), auditCreatedBy: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}audit_created_by']), auditCreatedTime: const IntType().mapFromDatabaseResponse( @@ -3757,6 +3769,15 @@ class HouseholdData extends DataClass implements Insertable { if (!nullToAbsent || memberCount != null) { map['member_count'] = Variable(memberCount); } + if (!nullToAbsent || latitude != null) { + map['latitude'] = Variable(latitude); + } + if (!nullToAbsent || longitude != null) { + map['longitude'] = Variable(longitude); + } + if (!nullToAbsent || maxRadius != null) { + map['max_radius'] = Variable(maxRadius); + } if (!nullToAbsent || auditCreatedBy != null) { map['audit_created_by'] = Variable(auditCreatedBy); } @@ -3791,6 +3812,15 @@ class HouseholdData extends DataClass implements Insertable { memberCount: memberCount == null && nullToAbsent ? const Value.absent() : Value(memberCount), + latitude: latitude == null && nullToAbsent + ? const Value.absent() + : Value(latitude), + longitude: longitude == null && nullToAbsent + ? const Value.absent() + : Value(longitude), + maxRadius: maxRadius == null && nullToAbsent + ? const Value.absent() + : Value(maxRadius), auditCreatedBy: auditCreatedBy == null && nullToAbsent ? const Value.absent() : Value(auditCreatedBy), @@ -3825,6 +3855,9 @@ class HouseholdData extends DataClass implements Insertable { return HouseholdData( id: serializer.fromJson(json['id']), memberCount: serializer.fromJson(json['memberCount']), + latitude: serializer.fromJson(json['latitude']), + longitude: serializer.fromJson(json['longitude']), + maxRadius: serializer.fromJson(json['maxRadius']), auditCreatedBy: serializer.fromJson(json['auditCreatedBy']), auditCreatedTime: serializer.fromJson(json['auditCreatedTime']), auditModifiedBy: serializer.fromJson(json['auditModifiedBy']), @@ -3842,6 +3875,9 @@ class HouseholdData extends DataClass implements Insertable { return { 'id': serializer.toJson(id), 'memberCount': serializer.toJson(memberCount), + 'latitude': serializer.toJson(latitude), + 'longitude': serializer.toJson(longitude), + 'maxRadius': serializer.toJson(maxRadius), 'auditCreatedBy': serializer.toJson(auditCreatedBy), 'auditCreatedTime': serializer.toJson(auditCreatedTime), 'auditModifiedBy': serializer.toJson(auditModifiedBy), @@ -3857,6 +3893,9 @@ class HouseholdData extends DataClass implements Insertable { HouseholdData copyWith( {String? id, int? memberCount, + double? latitude, + double? longitude, + double? maxRadius, String? auditCreatedBy, int? auditCreatedTime, String? auditModifiedBy, @@ -3869,6 +3908,9 @@ class HouseholdData extends DataClass implements Insertable { HouseholdData( id: id ?? this.id, memberCount: memberCount ?? this.memberCount, + latitude: latitude ?? this.latitude, + longitude: longitude ?? this.longitude, + maxRadius: maxRadius ?? this.maxRadius, auditCreatedBy: auditCreatedBy ?? this.auditCreatedBy, auditCreatedTime: auditCreatedTime ?? this.auditCreatedTime, auditModifiedBy: auditModifiedBy ?? this.auditModifiedBy, @@ -3884,6 +3926,9 @@ class HouseholdData extends DataClass implements Insertable { return (StringBuffer('HouseholdData(') ..write('id: $id, ') ..write('memberCount: $memberCount, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude, ') + ..write('maxRadius: $maxRadius, ') ..write('auditCreatedBy: $auditCreatedBy, ') ..write('auditCreatedTime: $auditCreatedTime, ') ..write('auditModifiedBy: $auditModifiedBy, ') @@ -3901,6 +3946,9 @@ class HouseholdData extends DataClass implements Insertable { int get hashCode => Object.hash( id, memberCount, + latitude, + longitude, + maxRadius, auditCreatedBy, auditCreatedTime, auditModifiedBy, @@ -3916,6 +3964,9 @@ class HouseholdData extends DataClass implements Insertable { (other is HouseholdData && other.id == this.id && other.memberCount == this.memberCount && + other.latitude == this.latitude && + other.longitude == this.longitude && + other.maxRadius == this.maxRadius && other.auditCreatedBy == this.auditCreatedBy && other.auditCreatedTime == this.auditCreatedTime && other.auditModifiedBy == this.auditModifiedBy && @@ -3930,6 +3981,9 @@ class HouseholdData extends DataClass implements Insertable { class HouseholdCompanion extends UpdateCompanion { final Value id; final Value memberCount; + final Value latitude; + final Value longitude; + final Value maxRadius; final Value auditCreatedBy; final Value auditCreatedTime; final Value auditModifiedBy; @@ -3942,6 +3996,9 @@ class HouseholdCompanion extends UpdateCompanion { const HouseholdCompanion({ this.id = const Value.absent(), this.memberCount = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + this.maxRadius = const Value.absent(), this.auditCreatedBy = const Value.absent(), this.auditCreatedTime = const Value.absent(), this.auditModifiedBy = const Value.absent(), @@ -3955,6 +4012,9 @@ class HouseholdCompanion extends UpdateCompanion { HouseholdCompanion.insert({ this.id = const Value.absent(), this.memberCount = const Value.absent(), + this.latitude = const Value.absent(), + this.longitude = const Value.absent(), + this.maxRadius = const Value.absent(), this.auditCreatedBy = const Value.absent(), this.auditCreatedTime = const Value.absent(), this.auditModifiedBy = const Value.absent(), @@ -3968,6 +4028,9 @@ class HouseholdCompanion extends UpdateCompanion { static Insertable custom({ Expression? id, Expression? memberCount, + Expression? latitude, + Expression? longitude, + Expression? maxRadius, Expression? auditCreatedBy, Expression? auditCreatedTime, Expression? auditModifiedBy, @@ -3981,6 +4044,9 @@ class HouseholdCompanion extends UpdateCompanion { return RawValuesInsertable({ if (id != null) 'id': id, if (memberCount != null) 'member_count': memberCount, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (maxRadius != null) 'max_radius': maxRadius, if (auditCreatedBy != null) 'audit_created_by': auditCreatedBy, if (auditCreatedTime != null) 'audit_created_time': auditCreatedTime, if (auditModifiedBy != null) 'audit_modified_by': auditModifiedBy, @@ -3996,6 +4062,9 @@ class HouseholdCompanion extends UpdateCompanion { HouseholdCompanion copyWith( {Value? id, Value? memberCount, + Value? latitude, + Value? longitude, + Value? maxRadius, Value? auditCreatedBy, Value? auditCreatedTime, Value? auditModifiedBy, @@ -4008,6 +4077,9 @@ class HouseholdCompanion extends UpdateCompanion { return HouseholdCompanion( id: id ?? this.id, memberCount: memberCount ?? this.memberCount, + latitude: latitude ?? this.latitude, + longitude: longitude ?? this.longitude, + maxRadius: maxRadius ?? this.maxRadius, auditCreatedBy: auditCreatedBy ?? this.auditCreatedBy, auditCreatedTime: auditCreatedTime ?? this.auditCreatedTime, auditModifiedBy: auditModifiedBy ?? this.auditModifiedBy, @@ -4029,6 +4101,15 @@ class HouseholdCompanion extends UpdateCompanion { if (memberCount.present) { map['member_count'] = Variable(memberCount.value); } + if (latitude.present) { + map['latitude'] = Variable(latitude.value); + } + if (longitude.present) { + map['longitude'] = Variable(longitude.value); + } + if (maxRadius.present) { + map['max_radius'] = Variable(maxRadius.value); + } if (auditCreatedBy.present) { map['audit_created_by'] = Variable(auditCreatedBy.value); } @@ -4064,6 +4145,9 @@ class HouseholdCompanion extends UpdateCompanion { return (StringBuffer('HouseholdCompanion(') ..write('id: $id, ') ..write('memberCount: $memberCount, ') + ..write('latitude: $latitude, ') + ..write('longitude: $longitude, ') + ..write('maxRadius: $maxRadius, ') ..write('auditCreatedBy: $auditCreatedBy, ') ..write('auditCreatedTime: $auditCreatedTime, ') ..write('auditModifiedBy: $auditModifiedBy, ') @@ -4095,6 +4179,21 @@ class $HouseholdTable extends Household late final GeneratedColumn memberCount = GeneratedColumn( 'member_count', aliasedName, true, type: const IntType(), requiredDuringInsert: false); + final VerificationMeta _latitudeMeta = const VerificationMeta('latitude'); + @override + late final GeneratedColumn latitude = GeneratedColumn( + 'latitude', aliasedName, true, + type: const RealType(), requiredDuringInsert: false); + final VerificationMeta _longitudeMeta = const VerificationMeta('longitude'); + @override + late final GeneratedColumn longitude = GeneratedColumn( + 'longitude', aliasedName, true, + type: const RealType(), requiredDuringInsert: false); + final VerificationMeta _maxRadiusMeta = const VerificationMeta('maxRadius'); + @override + late final GeneratedColumn maxRadius = GeneratedColumn( + 'max_radius', aliasedName, true, + type: const RealType(), requiredDuringInsert: false); final VerificationMeta _auditCreatedByMeta = const VerificationMeta('auditCreatedBy'); @override @@ -4153,6 +4252,9 @@ class $HouseholdTable extends Household List get $columns => [ id, memberCount, + latitude, + longitude, + maxRadius, auditCreatedBy, auditCreatedTime, auditModifiedBy, @@ -4181,6 +4283,18 @@ class $HouseholdTable extends Household memberCount.isAcceptableOrUnknown( data['member_count']!, _memberCountMeta)); } + if (data.containsKey('latitude')) { + context.handle(_latitudeMeta, + latitude.isAcceptableOrUnknown(data['latitude']!, _latitudeMeta)); + } + if (data.containsKey('longitude')) { + context.handle(_longitudeMeta, + longitude.isAcceptableOrUnknown(data['longitude']!, _longitudeMeta)); + } + if (data.containsKey('max_radius')) { + context.handle(_maxRadiusMeta, + maxRadius.isAcceptableOrUnknown(data['max_radius']!, _maxRadiusMeta)); + } if (data.containsKey('audit_created_by')) { context.handle( _auditCreatedByMeta, diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart index 17de021d2..f9f5fc744 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart @@ -6,6 +6,9 @@ import 'package:drift/drift.dart'; class Household extends Table { TextColumn get id => text().nullable()(); IntColumn get memberCount => integer().nullable()(); + RealColumn get latitude => real().nullable()(); + RealColumn get longitude => real().nullable()(); + RealColumn get maxRadius => real().nullable()(); TextColumn get auditCreatedBy => text().nullable()(); IntColumn get auditCreatedTime => integer().nullable()(); TextColumn get auditModifiedBy => text().nullable()(); diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart index b7bfeb42a..e3c58b0b2 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart @@ -1,7 +1,6 @@ import 'dart:async'; - +import 'dart:math'; import 'package:drift/drift.dart'; - import '../../../models/data_model.dart'; import '../../../utils/utils.dart'; import '../../data_repository.dart'; @@ -25,6 +24,27 @@ class HouseholdLocalRepository ), ], ); + // if (query.latitude != null && + // query.longitude != null && + // query.maxRadius != null) { + // final latitude = query.latitude!; + // final longitude = query.longitude!; + // final radiusInMeters = query.maxRadius!; + // final latitudeDifference = radiusInMeters / 111320; + // final longitudeDifference = radiusInMeters / + // (111320 * cos(latitude * pi / 180)); // Convert to meters + + // selectQuery.where( + // sql.address.latitude + // .isBiggerOrEqualValue(latitude - latitudeDifference) & + // sql.address.latitude + // .isSmallerOrEqualValue(latitude + latitudeDifference) & + // sql.address.longitude + // .isBiggerOrEqualValue(longitude - longitudeDifference) & + // sql.address.longitude + // .isSmallerOrEqualValue(longitude + longitudeDifference), + // ); + // } final results = await (selectQuery ..where( diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/stock_reconciliation.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/stock_reconciliation.dart index 1ebc67d27..4a3655cf5 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/stock_reconciliation.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/stock_reconciliation.dart @@ -31,6 +31,11 @@ class StockReconciliationLocalRepository extends LocalRepository< ..where( buildAnd( [ + if (query.facilityId != null) + sql.stockReconciliation.facilityId.equals(query.facilityId), + if (query.productVariantId != null) + sql.stockReconciliation.productVariantId + .equals(query.productVariantId), if (query.clientReferenceId != null) sql.stockReconciliation.id.equals( query.id, diff --git a/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart b/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart index b320f56af..06e74991a 100644 --- a/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart +++ b/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart @@ -986,15 +986,15 @@ class HouseholdSearchModelMapper extends BaseMapper { @override Function get decoder => decode; HouseholdSearchModel decode(dynamic v) => checked(v, (Map map) => fromMap(map)); - HouseholdSearchModel fromMap(Map map) => HouseholdSearchModel.ignoreDeleted(id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), clientReferenceId: Mapper.i.$getOpt(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), boundaryCode: Mapper.i.$getOpt(map, 'boundaryCode')); + HouseholdSearchModel fromMap(Map map) => HouseholdSearchModel.ignoreDeleted(id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), maxRadius: Mapper.i.$getOpt(map, 'maxRadius'), clientReferenceId: Mapper.i.$getOpt(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), boundaryCode: Mapper.i.$getOpt(map, 'boundaryCode')); @override Function get encoder => (HouseholdSearchModel v) => encode(v); dynamic encode(HouseholdSearchModel v) => toMap(v); - Map toMap(HouseholdSearchModel h) => {if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId') != null) 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.boundaryCode, 'boundaryCode') != null) 'boundaryCode': Mapper.i.$enc(h.boundaryCode, 'boundaryCode')}; + Map toMap(HouseholdSearchModel h) => {if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(h.latitude, 'latitude'), if (Mapper.i.$enc(h.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(h.longitude, 'longitude'), if (Mapper.i.$enc(h.maxRadius, 'maxRadius') != null) 'maxRadius': Mapper.i.$enc(h.maxRadius, 'maxRadius'), if (Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId') != null) 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.boundaryCode, 'boundaryCode') != null) 'boundaryCode': Mapper.i.$enc(h.boundaryCode, 'boundaryCode')}; - @override String stringify(HouseholdSearchModel self) => 'HouseholdSearchModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, additionalFields: ${Mapper.asString(self.additionalFields)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)})'; - @override int hash(HouseholdSearchModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.additionalFields) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId); - @override bool equals(HouseholdSearchModel self, HouseholdSearchModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.additionalFields, other.additionalFields) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId); + @override String stringify(HouseholdSearchModel self) => 'HouseholdSearchModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, additionalFields: ${Mapper.asString(self.additionalFields)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, maxRadius: ${Mapper.asString(self.maxRadius)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)})'; + @override int hash(HouseholdSearchModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.additionalFields) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.maxRadius) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId); + @override bool equals(HouseholdSearchModel self, HouseholdSearchModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.additionalFields, other.additionalFields) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.maxRadius, other.maxRadius) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId); @override Function get typeFactory => (f) => f(); } @@ -1007,14 +1007,14 @@ extension HouseholdSearchModelMapperExtension on HouseholdSearchModel { abstract class HouseholdSearchModelCopyWith<$R> { factory HouseholdSearchModelCopyWith(HouseholdSearchModel value, Then then) = _HouseholdSearchModelCopyWithImpl<$R>; - $R call({String? id, int? memberCount, List? clientReferenceId, String? tenantId, String? boundaryCode}); + $R call({String? id, int? memberCount, double? latitude, double? longitude, double? maxRadius, List? clientReferenceId, String? tenantId, String? boundaryCode}); $R apply(HouseholdSearchModel Function(HouseholdSearchModel) transform); } class _HouseholdSearchModelCopyWithImpl<$R> extends BaseCopyWith implements HouseholdSearchModelCopyWith<$R> { _HouseholdSearchModelCopyWithImpl(HouseholdSearchModel value, Then then) : super(value, then); - @override $R call({Object? id = $none, Object? memberCount = $none, Object? clientReferenceId = $none, Object? tenantId = $none, Object? boundaryCode = $none}) => $then(HouseholdSearchModel.ignoreDeleted(id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), clientReferenceId: or(clientReferenceId, $value.clientReferenceId), tenantId: or(tenantId, $value.tenantId), boundaryCode: or(boundaryCode, $value.boundaryCode))); + @override $R call({Object? id = $none, Object? memberCount = $none, Object? latitude = $none, Object? longitude = $none, Object? maxRadius = $none, Object? clientReferenceId = $none, Object? tenantId = $none, Object? boundaryCode = $none}) => $then(HouseholdSearchModel.ignoreDeleted(id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), maxRadius: or(maxRadius, $value.maxRadius), clientReferenceId: or(clientReferenceId, $value.clientReferenceId), tenantId: or(tenantId, $value.tenantId), boundaryCode: or(boundaryCode, $value.boundaryCode))); } class HouseholdModelMapper extends BaseMapper { @@ -1022,15 +1022,15 @@ class HouseholdModelMapper extends BaseMapper { @override Function get decoder => decode; HouseholdModel decode(dynamic v) => checked(v, (Map map) => fromMap(map)); - HouseholdModel fromMap(Map map) => HouseholdModel(additionalFields: Mapper.i.$getOpt(map, 'additionalFields'), id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), clientReferenceId: Mapper.i.$get(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), rowVersion: Mapper.i.$getOpt(map, 'rowVersion'), address: Mapper.i.$getOpt(map, 'address'), auditDetails: Mapper.i.$getOpt(map, 'auditDetails'), isDeleted: Mapper.i.$getOpt(map, 'isDeleted') ?? false); + HouseholdModel fromMap(Map map) => HouseholdModel(additionalFields: Mapper.i.$getOpt(map, 'additionalFields'), id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), maxRadius: Mapper.i.$getOpt(map, 'maxRadius'), clientReferenceId: Mapper.i.$get(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), rowVersion: Mapper.i.$getOpt(map, 'rowVersion'), address: Mapper.i.$getOpt(map, 'address'), auditDetails: Mapper.i.$getOpt(map, 'auditDetails'), isDeleted: Mapper.i.$getOpt(map, 'isDeleted') ?? false); @override Function get encoder => (HouseholdModel v) => encode(v); dynamic encode(HouseholdModel v) => toMap(v); - Map toMap(HouseholdModel h) => {if (Mapper.i.$enc(h.additionalFields, 'additionalFields') != null) 'additionalFields': Mapper.i.$enc(h.additionalFields, 'additionalFields'), if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.rowVersion, 'rowVersion') != null) 'rowVersion': Mapper.i.$enc(h.rowVersion, 'rowVersion'), if (Mapper.i.$enc(h.address, 'address') != null) 'address': Mapper.i.$enc(h.address, 'address'), if (Mapper.i.$enc(h.auditDetails, 'auditDetails') != null) 'auditDetails': Mapper.i.$enc(h.auditDetails, 'auditDetails'), if (Mapper.i.$enc(h.isDeleted, 'isDeleted') != null) 'isDeleted': Mapper.i.$enc(h.isDeleted, 'isDeleted')}; + Map toMap(HouseholdModel h) => {if (Mapper.i.$enc(h.additionalFields, 'additionalFields') != null) 'additionalFields': Mapper.i.$enc(h.additionalFields, 'additionalFields'), if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(h.latitude, 'latitude'), if (Mapper.i.$enc(h.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(h.longitude, 'longitude'), if (Mapper.i.$enc(h.maxRadius, 'maxRadius') != null) 'maxRadius': Mapper.i.$enc(h.maxRadius, 'maxRadius'), 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.rowVersion, 'rowVersion') != null) 'rowVersion': Mapper.i.$enc(h.rowVersion, 'rowVersion'), if (Mapper.i.$enc(h.address, 'address') != null) 'address': Mapper.i.$enc(h.address, 'address'), if (Mapper.i.$enc(h.auditDetails, 'auditDetails') != null) 'auditDetails': Mapper.i.$enc(h.auditDetails, 'auditDetails'), if (Mapper.i.$enc(h.isDeleted, 'isDeleted') != null) 'isDeleted': Mapper.i.$enc(h.isDeleted, 'isDeleted')}; - @override String stringify(HouseholdModel self) => 'HouseholdModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)}, rowVersion: ${Mapper.asString(self.rowVersion)}, address: ${Mapper.asString(self.address)}, additionalFields: ${Mapper.asString(self.additionalFields)})'; - @override int hash(HouseholdModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId) ^ Mapper.hash(self.rowVersion) ^ Mapper.hash(self.address) ^ Mapper.hash(self.additionalFields); - @override bool equals(HouseholdModel self, HouseholdModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId) && Mapper.isEqual(self.rowVersion, other.rowVersion) && Mapper.isEqual(self.address, other.address) && Mapper.isEqual(self.additionalFields, other.additionalFields); + @override String stringify(HouseholdModel self) => 'HouseholdModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, maxRadius: ${Mapper.asString(self.maxRadius)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)}, rowVersion: ${Mapper.asString(self.rowVersion)}, address: ${Mapper.asString(self.address)}, additionalFields: ${Mapper.asString(self.additionalFields)})'; + @override int hash(HouseholdModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.maxRadius) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId) ^ Mapper.hash(self.rowVersion) ^ Mapper.hash(self.address) ^ Mapper.hash(self.additionalFields); + @override bool equals(HouseholdModel self, HouseholdModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.maxRadius, other.maxRadius) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId) && Mapper.isEqual(self.rowVersion, other.rowVersion) && Mapper.isEqual(self.address, other.address) && Mapper.isEqual(self.additionalFields, other.additionalFields); @override Function get typeFactory => (f) => f(); } @@ -1046,7 +1046,7 @@ abstract class HouseholdModelCopyWith<$R> { HouseholdAdditionalFieldsCopyWith<$R>? get additionalFields; AddressModelCopyWith<$R>? get address; AuditDetailsCopyWith<$R>? get auditDetails; - $R call({HouseholdAdditionalFields? additionalFields, String? id, int? memberCount, String? clientReferenceId, String? tenantId, int? rowVersion, AddressModel? address, AuditDetails? auditDetails, bool? isDeleted}); + $R call({HouseholdAdditionalFields? additionalFields, String? id, int? memberCount, double? latitude, double? longitude, double? maxRadius, String? clientReferenceId, String? tenantId, int? rowVersion, AddressModel? address, AuditDetails? auditDetails, bool? isDeleted}); $R apply(HouseholdModel Function(HouseholdModel) transform); } @@ -1056,7 +1056,7 @@ class _HouseholdModelCopyWithImpl<$R> extends BaseCopyWith i @override HouseholdAdditionalFieldsCopyWith<$R>? get additionalFields => $value.additionalFields != null ? HouseholdAdditionalFieldsCopyWith($value.additionalFields!, (v) => call(additionalFields: v)) : null; @override AddressModelCopyWith<$R>? get address => $value.address != null ? AddressModelCopyWith($value.address!, (v) => call(address: v)) : null; @override AuditDetailsCopyWith<$R>? get auditDetails => $value.auditDetails != null ? AuditDetailsCopyWith($value.auditDetails!, (v) => call(auditDetails: v)) : null; - @override $R call({Object? additionalFields = $none, Object? id = $none, Object? memberCount = $none, String? clientReferenceId, Object? tenantId = $none, Object? rowVersion = $none, Object? address = $none, Object? auditDetails = $none, Object? isDeleted = $none}) => $then(HouseholdModel(additionalFields: or(additionalFields, $value.additionalFields), id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), clientReferenceId: clientReferenceId ?? $value.clientReferenceId, tenantId: or(tenantId, $value.tenantId), rowVersion: or(rowVersion, $value.rowVersion), address: or(address, $value.address), auditDetails: or(auditDetails, $value.auditDetails), isDeleted: or(isDeleted, $value.isDeleted))); + @override $R call({Object? additionalFields = $none, Object? id = $none, Object? memberCount = $none, Object? latitude = $none, Object? longitude = $none, Object? maxRadius = $none, String? clientReferenceId, Object? tenantId = $none, Object? rowVersion = $none, Object? address = $none, Object? auditDetails = $none, Object? isDeleted = $none}) => $then(HouseholdModel(additionalFields: or(additionalFields, $value.additionalFields), id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), maxRadius: or(maxRadius, $value.maxRadius), clientReferenceId: clientReferenceId ?? $value.clientReferenceId, tenantId: or(tenantId, $value.tenantId), rowVersion: or(rowVersion, $value.rowVersion), address: or(address, $value.address), auditDetails: or(auditDetails, $value.auditDetails), isDeleted: or(isDeleted, $value.isDeleted))); } class HouseholdAdditionalFieldsMapper extends BaseMapper { @@ -3697,7 +3697,7 @@ abstract class UserModelCopyWith<$R> { factory UserModelCopyWith(UserModel value, Then then) = _UserModelCopyWithImpl<$R>; UserAdditionalFieldsCopyWith<$R>? get additionalFields; AuditDetailsCopyWith<$R>? get auditDetails; - $R call({UserAdditionalFields? additionalFields, String? id, String? userName, String? salutation, String? name, String? gender, String? mobileNumber, String? emailId, String? altContactNumber, String? pan, String? aadhaarNumber, String? permanentAddress, String? permanentCity, String? permanentPinCode, String? correspondenceAddress, String? correspondenceCity, String? correspondencePinCode, String? alternatemobilenumber, bool? active, String? locale, String? type, bool? accountLocked, int? accountLockedDate, String? fatherOrHusbandName, String? relationship, String? signature, String? bloodGroup, String? photo, String? identificationMark, int? createdBy, String? lastModifiedBy, String? tenantId, String? uuid, String? createdDate, int? rowVersion, AuditDetails? auditDetails, bool? isDeleted}); + $R call({UserAdditionalFields? additionalFields, String? id, String? userName, String? salutation, String? name, String? gender, String? mobileNumber, String? emailId, String? altContactNumber, String? pan, String? aadhaarNumber, String? permanentAddress, String? permanentCity, String? permanentPinCode, String? correspondenceAddress, String? correspondenceCity, String? correspondencePinCode, String? alternatemobilenumber, bool? active, String? locale, String? type, bool? accountLocked, int? accountLockedDate, String? fatherOrHusbandName, String? relationship, String? signature, String? bloodGroup, String? photo, String? identificationMark, int? createdBy, String? lastModifiedBy, String? tenantId, List? uuid, String? createdDate, int? rowVersion, AuditDetails? auditDetails, bool? isDeleted}); $R apply(UserModel Function(UserModel) transform); } diff --git a/apps/health_campaign_field_worker_app/lib/models/entities/household.dart b/apps/health_campaign_field_worker_app/lib/models/entities/household.dart index 03b084fe6..3664b4e20 100644 --- a/apps/health_campaign_field_worker_app/lib/models/entities/household.dart +++ b/apps/health_campaign_field_worker_app/lib/models/entities/household.dart @@ -9,12 +9,18 @@ import '../../data/local_store/sql_store/sql_store.dart'; class HouseholdSearchModel extends EntitySearchModel { final String? id; final int? memberCount; + final double? latitude; + final double? longitude; + final double? maxRadius; final List? clientReferenceId; final String? tenantId; HouseholdSearchModel({ this.id, this.memberCount, + this.latitude, + this.longitude, + this.maxRadius, this.clientReferenceId, this.tenantId, super.boundaryCode, @@ -25,6 +31,9 @@ class HouseholdSearchModel extends EntitySearchModel { HouseholdSearchModel.ignoreDeleted({ this.id, this.memberCount, + this.latitude, + this.longitude, + this.maxRadius, this.clientReferenceId, this.tenantId, super.boundaryCode, @@ -38,6 +47,9 @@ class HouseholdModel extends EntityModel { final String? id; final int? memberCount; + final double? latitude; + final double? longitude; + final double? maxRadius; final String clientReferenceId; final String? tenantId; final int? rowVersion; @@ -48,6 +60,9 @@ class HouseholdModel extends EntityModel { this.additionalFields, this.id, this.memberCount, + this.latitude, + this.longitude, + this.maxRadius, required this.clientReferenceId, this.tenantId, this.rowVersion, @@ -66,6 +81,9 @@ class HouseholdModel extends EntityModel { isDeleted: Value(isDeleted), id: Value(id), memberCount: Value(memberCount), + latitude: Value(latitude), + longitude: Value(longitude), + maxRadius: Value(maxRadius), clientReferenceId: Value(clientReferenceId), tenantId: Value(tenantId), rowVersion: Value(rowVersion), diff --git a/apps/health_campaign_field_worker_app/lib/models/entities/user.dart b/apps/health_campaign_field_worker_app/lib/models/entities/user.dart index 1e71d5b0e..598c695fd 100644 --- a/apps/health_campaign_field_worker_app/lib/models/entities/user.dart +++ b/apps/health_campaign_field_worker_app/lib/models/entities/user.dart @@ -10,14 +10,14 @@ class UserSearchModel extends EntitySearchModel { final String? id; final String? userName; final List? uuid; - + UserSearchModel({ this.id, this.userName, this.uuid, super.boundaryCode, super.isDeleted, - }) : super(); + }): super(); @MappableConstructor() UserSearchModel.ignoreDeleted({ @@ -25,11 +25,12 @@ class UserSearchModel extends EntitySearchModel { this.userName, this.uuid, super.boundaryCode, - }) : super(isDeleted: false); + }): super(isDeleted: false); } @MappableClass(ignoreNull: true) class UserModel extends EntityModel { + static const schemaName = 'User'; final String? id; @@ -63,7 +64,7 @@ class UserModel extends EntityModel { final int? createdBy; final String? lastModifiedBy; final String? tenantId; - final String? uuid; + final List? uuid; final String? createdDate; final int? rowVersion; final UserAdditionalFields? additionalFields; @@ -106,7 +107,7 @@ class UserModel extends EntityModel { this.rowVersion, super.auditDetails, super.isDeleted = false, - }) : super(); + }): super(); UserCompanion get companion { return UserCompanion( @@ -150,7 +151,7 @@ class UserModel extends EntityModel { uuid: Value(uuid?.toString()), createdDate: Value(createdDate), rowVersion: Value(rowVersion), - ); + ); } } diff --git a/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json b/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json index a7bd9843f..47dee9c98 100644 --- a/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json +++ b/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json @@ -12,6 +12,21 @@ "name": "memberCount", "type": "int", "includeForQuery": true + }, + { + "name": "latitude", + "type": "double", + "includeForQuery": true + }, + { + "name": "longitude", + "type": "double", + "includeForQuery": true + }, + { + "name": "maxRadius", + "type": "double", + "includeForQuery": true } ], "customAttributes": [ diff --git a/apps/health_campaign_field_worker_app/lib/pages/inventory/reports/report_details.dart b/apps/health_campaign_field_worker_app/lib/pages/inventory/reports/report_details.dart index 480d7a0e0..12d4e6146 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/inventory/reports/report_details.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/inventory/reports/report_details.dart @@ -58,13 +58,26 @@ class _InventoryReportDetailsPageState void handleSelection(FormGroup form) { final event = widget.reportType == InventoryReportType.reconciliation - ? const InventoryReportLoadStockReconciliationDataEvent() + ? InventoryReportLoadStockReconciliationDataEvent( + facilityId: form.control(_facilityKey).value != null + ? (form.control(_facilityKey).value as FacilityModel).id + : '', + productVariantId: form.control(_productVariantKey).value != null + ? (form.control(_productVariantKey).value + as ProductVariantModel) + .id + : '', + ) : InventoryReportLoadStockDataEvent( reportType: widget.reportType, - facilityId: (form.control(_facilityKey).value as FacilityModel).id, - productVariantId: - (form.control(_productVariantKey).value as ProductVariantModel) - .id, + facilityId: form.control(_facilityKey).value != null + ? (form.control(_facilityKey).value as FacilityModel).id + : '', + productVariantId: form.control(_productVariantKey).value != null + ? (form.control(_productVariantKey).value + as ProductVariantModel) + .id + : '', ); context.read().add(event); From 9734489f13954336c1d3dea92689ea6d30a78e2f Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 25 Jul 2023 11:17:17 +0530 Subject: [PATCH 02/17] removed un-used code --- .../search_households/search_households.dart | 4 ---- .../data/repositories/local/household.dart | 22 ------------------- 2 files changed, 26 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index f918dbe13..7a5917d5a 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -254,10 +254,6 @@ class SearchHouseholdsBloc final households = await household.search( HouseholdSearchModel( clientReferenceId: [householdId], - // [TODO]: Need to take this data from location service on search screen. - latitude: 90, - longitude: 180, - maxRadius: 100, ), ); diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart index e3c58b0b2..2df0c0fbd 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart @@ -24,28 +24,6 @@ class HouseholdLocalRepository ), ], ); - // if (query.latitude != null && - // query.longitude != null && - // query.maxRadius != null) { - // final latitude = query.latitude!; - // final longitude = query.longitude!; - // final radiusInMeters = query.maxRadius!; - // final latitudeDifference = radiusInMeters / 111320; - // final longitudeDifference = radiusInMeters / - // (111320 * cos(latitude * pi / 180)); // Convert to meters - - // selectQuery.where( - // sql.address.latitude - // .isBiggerOrEqualValue(latitude - latitudeDifference) & - // sql.address.latitude - // .isSmallerOrEqualValue(latitude + latitudeDifference) & - // sql.address.longitude - // .isBiggerOrEqualValue(longitude - longitudeDifference) & - // sql.address.longitude - // .isSmallerOrEqualValue(longitude + longitudeDifference), - // ); - // } - final results = await (selectQuery ..where( buildAnd( From a1d3edeb571b72ddf225c675b2013a2c6d28c883 Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 25 Jul 2023 20:37:39 +0530 Subject: [PATCH 03/17] added fallback code --- .../search_households/search_households.dart | 8 +- .../search_households.freezed.dart | 186 +++++++++++++----- .../data/repositories/local/household.dart | 71 ++++--- .../lib/pages/login.dart | 4 +- .../lib/pages/search_beneficiary.dart | 54 +++-- .../lib/widgets/member_card/member_card.dart | 8 +- 6 files changed, 237 insertions(+), 94 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 7a5917d5a..04aa82ab6 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -250,10 +250,12 @@ class SearchHouseholdsBloc .toList(); if (householdId == null) continue; - final households = await household.search( HouseholdSearchModel( clientReferenceId: [householdId], + latitude: event.latitude, + longitude: event.longitude, + maxRadius: 100, ), ); @@ -336,12 +338,16 @@ class SearchHouseholdsEvent with _$SearchHouseholdsEvent { const factory SearchHouseholdsEvent.searchByHousehold({ required String projectId, + double? latitude, + double? longitude, required HouseholdModel householdModel, }) = SearchHouseholdsByHouseholdsEvent; const factory SearchHouseholdsEvent.searchByHouseholdHead({ required String searchText, required String projectId, + double? latitude, + double? longitude, }) = SearchHouseholdsSearchByHouseholdHeadEvent; const factory SearchHouseholdsEvent.clear() = SearchHouseholdsClearEvent; diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart index 5c1cac7df..b0c72b14a 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart @@ -19,9 +19,11 @@ mixin _$SearchHouseholdsEvent { @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, HouseholdModel householdModel) + required TResult Function(String projectId, double? latitude, + double? longitude, HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId) + required TResult Function(String searchText, String projectId, + double? latitude, double? longitude) searchByHouseholdHead, required TResult Function() clear, }) => @@ -29,9 +31,11 @@ mixin _$SearchHouseholdsEvent { @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, HouseholdModel householdModel)? + TResult? Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId)? + TResult? Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult? Function()? clear, }) => @@ -39,9 +43,11 @@ mixin _$SearchHouseholdsEvent { @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, HouseholdModel householdModel)? + TResult Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId)? + TResult Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult Function()? clear, required TResult orElse(), @@ -144,9 +150,11 @@ class _$SearchHouseholdsInitializedEvent @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, HouseholdModel householdModel) + required TResult Function(String projectId, double? latitude, + double? longitude, HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId) + required TResult Function(String searchText, String projectId, + double? latitude, double? longitude) searchByHouseholdHead, required TResult Function() clear, }) { @@ -157,9 +165,11 @@ class _$SearchHouseholdsInitializedEvent @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, HouseholdModel householdModel)? + TResult? Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId)? + TResult? Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult? Function()? clear, }) { @@ -170,9 +180,11 @@ class _$SearchHouseholdsInitializedEvent @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, HouseholdModel householdModel)? + TResult Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId)? + TResult Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult Function()? clear, required TResult orElse(), @@ -241,7 +253,11 @@ abstract class _$$SearchHouseholdsByHouseholdsEventCopyWith<$Res> { $Res Function(_$SearchHouseholdsByHouseholdsEvent) then) = __$$SearchHouseholdsByHouseholdsEventCopyWithImpl<$Res>; @useResult - $Res call({String projectId, HouseholdModel householdModel}); + $Res call( + {String projectId, + double? latitude, + double? longitude, + HouseholdModel householdModel}); } /// @nodoc @@ -258,6 +274,8 @@ class __$$SearchHouseholdsByHouseholdsEventCopyWithImpl<$Res> @override $Res call({ Object? projectId = null, + Object? latitude = freezed, + Object? longitude = freezed, Object? householdModel = null, }) { return _then(_$SearchHouseholdsByHouseholdsEvent( @@ -265,6 +283,14 @@ class __$$SearchHouseholdsByHouseholdsEventCopyWithImpl<$Res> ? _value.projectId : projectId // ignore: cast_nullable_to_non_nullable as String, + latitude: freezed == latitude + ? _value.latitude + : latitude // ignore: cast_nullable_to_non_nullable + as double?, + longitude: freezed == longitude + ? _value.longitude + : longitude // ignore: cast_nullable_to_non_nullable + as double?, householdModel: null == householdModel ? _value.householdModel : householdModel // ignore: cast_nullable_to_non_nullable @@ -278,16 +304,23 @@ class __$$SearchHouseholdsByHouseholdsEventCopyWithImpl<$Res> class _$SearchHouseholdsByHouseholdsEvent implements SearchHouseholdsByHouseholdsEvent { const _$SearchHouseholdsByHouseholdsEvent( - {required this.projectId, required this.householdModel}); + {required this.projectId, + this.latitude, + this.longitude, + required this.householdModel}); @override final String projectId; @override + final double? latitude; + @override + final double? longitude; + @override final HouseholdModel householdModel; @override String toString() { - return 'SearchHouseholdsEvent.searchByHousehold(projectId: $projectId, householdModel: $householdModel)'; + return 'SearchHouseholdsEvent.searchByHousehold(projectId: $projectId, latitude: $latitude, longitude: $longitude, householdModel: $householdModel)'; } @override @@ -297,12 +330,17 @@ class _$SearchHouseholdsByHouseholdsEvent other is _$SearchHouseholdsByHouseholdsEvent && (identical(other.projectId, projectId) || other.projectId == projectId) && + (identical(other.latitude, latitude) || + other.latitude == latitude) && + (identical(other.longitude, longitude) || + other.longitude == longitude) && (identical(other.householdModel, householdModel) || other.householdModel == householdModel)); } @override - int get hashCode => Object.hash(runtimeType, projectId, householdModel); + int get hashCode => + Object.hash(runtimeType, projectId, latitude, longitude, householdModel); @JsonKey(ignore: true) @override @@ -316,41 +354,48 @@ class _$SearchHouseholdsByHouseholdsEvent @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, HouseholdModel householdModel) + required TResult Function(String projectId, double? latitude, + double? longitude, HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId) + required TResult Function(String searchText, String projectId, + double? latitude, double? longitude) searchByHouseholdHead, required TResult Function() clear, }) { - return searchByHousehold(projectId, householdModel); + return searchByHousehold(projectId, latitude, longitude, householdModel); } @override @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, HouseholdModel householdModel)? + TResult? Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId)? + TResult? Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult? Function()? clear, }) { - return searchByHousehold?.call(projectId, householdModel); + return searchByHousehold?.call( + projectId, latitude, longitude, householdModel); } @override @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, HouseholdModel householdModel)? + TResult Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId)? + TResult Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult Function()? clear, required TResult orElse(), }) { if (searchByHousehold != null) { - return searchByHousehold(projectId, householdModel); + return searchByHousehold(projectId, latitude, longitude, householdModel); } return orElse(); } @@ -404,10 +449,14 @@ abstract class SearchHouseholdsByHouseholdsEvent implements SearchHouseholdsEvent { const factory SearchHouseholdsByHouseholdsEvent( {required final String projectId, + final double? latitude, + final double? longitude, required final HouseholdModel householdModel}) = _$SearchHouseholdsByHouseholdsEvent; String get projectId; + double? get latitude; + double? get longitude; HouseholdModel get householdModel; @JsonKey(ignore: true) _$$SearchHouseholdsByHouseholdsEventCopyWith< @@ -422,7 +471,11 @@ abstract class _$$SearchHouseholdsSearchByHouseholdHeadEventCopyWith<$Res> { $Res Function(_$SearchHouseholdsSearchByHouseholdHeadEvent) then) = __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res>; @useResult - $Res call({String searchText, String projectId}); + $Res call( + {String searchText, + String projectId, + double? latitude, + double? longitude}); } /// @nodoc @@ -440,6 +493,8 @@ class __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res> $Res call({ Object? searchText = null, Object? projectId = null, + Object? latitude = freezed, + Object? longitude = freezed, }) { return _then(_$SearchHouseholdsSearchByHouseholdHeadEvent( searchText: null == searchText @@ -450,6 +505,14 @@ class __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res> ? _value.projectId : projectId // ignore: cast_nullable_to_non_nullable as String, + latitude: freezed == latitude + ? _value.latitude + : latitude // ignore: cast_nullable_to_non_nullable + as double?, + longitude: freezed == longitude + ? _value.longitude + : longitude // ignore: cast_nullable_to_non_nullable + as double?, )); } } @@ -459,16 +522,23 @@ class __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res> class _$SearchHouseholdsSearchByHouseholdHeadEvent implements SearchHouseholdsSearchByHouseholdHeadEvent { const _$SearchHouseholdsSearchByHouseholdHeadEvent( - {required this.searchText, required this.projectId}); + {required this.searchText, + required this.projectId, + this.latitude, + this.longitude}); @override final String searchText; @override final String projectId; + @override + final double? latitude; + @override + final double? longitude; @override String toString() { - return 'SearchHouseholdsEvent.searchByHouseholdHead(searchText: $searchText, projectId: $projectId)'; + return 'SearchHouseholdsEvent.searchByHouseholdHead(searchText: $searchText, projectId: $projectId, latitude: $latitude, longitude: $longitude)'; } @override @@ -479,11 +549,16 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent (identical(other.searchText, searchText) || other.searchText == searchText) && (identical(other.projectId, projectId) || - other.projectId == projectId)); + other.projectId == projectId) && + (identical(other.latitude, latitude) || + other.latitude == latitude) && + (identical(other.longitude, longitude) || + other.longitude == longitude)); } @override - int get hashCode => Object.hash(runtimeType, searchText, projectId); + int get hashCode => + Object.hash(runtimeType, searchText, projectId, latitude, longitude); @JsonKey(ignore: true) @override @@ -498,41 +573,48 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, HouseholdModel householdModel) + required TResult Function(String projectId, double? latitude, + double? longitude, HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId) + required TResult Function(String searchText, String projectId, + double? latitude, double? longitude) searchByHouseholdHead, required TResult Function() clear, }) { - return searchByHouseholdHead(searchText, projectId); + return searchByHouseholdHead(searchText, projectId, latitude, longitude); } @override @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, HouseholdModel householdModel)? + TResult? Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId)? + TResult? Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult? Function()? clear, }) { - return searchByHouseholdHead?.call(searchText, projectId); + return searchByHouseholdHead?.call( + searchText, projectId, latitude, longitude); } @override @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, HouseholdModel householdModel)? + TResult Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId)? + TResult Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult Function()? clear, required TResult orElse(), }) { if (searchByHouseholdHead != null) { - return searchByHouseholdHead(searchText, projectId); + return searchByHouseholdHead(searchText, projectId, latitude, longitude); } return orElse(); } @@ -585,11 +667,15 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent abstract class SearchHouseholdsSearchByHouseholdHeadEvent implements SearchHouseholdsEvent { const factory SearchHouseholdsSearchByHouseholdHeadEvent( - {required final String searchText, required final String projectId}) = - _$SearchHouseholdsSearchByHouseholdHeadEvent; + {required final String searchText, + required final String projectId, + final double? latitude, + final double? longitude}) = _$SearchHouseholdsSearchByHouseholdHeadEvent; String get searchText; String get projectId; + double? get latitude; + double? get longitude; @JsonKey(ignore: true) _$$SearchHouseholdsSearchByHouseholdHeadEventCopyWith< _$SearchHouseholdsSearchByHouseholdHeadEvent> @@ -639,9 +725,11 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, HouseholdModel householdModel) + required TResult Function(String projectId, double? latitude, + double? longitude, HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId) + required TResult Function(String searchText, String projectId, + double? latitude, double? longitude) searchByHouseholdHead, required TResult Function() clear, }) { @@ -652,9 +740,11 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, HouseholdModel householdModel)? + TResult? Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId)? + TResult? Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult? Function()? clear, }) { @@ -665,9 +755,11 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, HouseholdModel householdModel)? + TResult Function(String projectId, double? latitude, double? longitude, + HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId)? + TResult Function(String searchText, String projectId, double? latitude, + double? longitude)? searchByHouseholdHead, TResult Function()? clear, required TResult orElse(), diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart index 2df0c0fbd..85efe52a0 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart @@ -1,6 +1,8 @@ import 'dart:async'; import 'dart:math'; +import 'dart:math' as math; import 'package:drift/drift.dart'; + import '../../../models/data_model.dart'; import '../../../utils/utils.dart'; import '../../data_repository.dart'; @@ -14,6 +16,9 @@ class HouseholdLocalRepository HouseholdSearchModel query, [ String? userId, ]) async { + print(query.latitude); + print(query.longitude); + print("-----Search Queries----"); final selectQuery = sql.select(sql.household).join( [ leftOuterJoin( @@ -24,29 +29,49 @@ class HouseholdLocalRepository ), ], ); - final results = await (selectQuery - ..where( - buildAnd( - [ - if (query.clientReferenceId != null) - sql.household.clientReferenceId - .isIn(query.clientReferenceId!), - if (query.id != null) - sql.household.id.equals( - query.id, - ), - if (query.tenantId != null) - sql.household.tenantId.equals( - query.tenantId, - ), - if (userId != null) - sql.household.auditCreatedBy.equals( - userId, - ), - ], - ), - )) - .get(); + + (selectQuery + ..where( + buildAnd( + [ + if (query.clientReferenceId != null) + sql.household.clientReferenceId.isIn(query.clientReferenceId!), + if (query.id != null) + sql.household.id.equals( + query.id, + ), + if (query.tenantId != null) + sql.household.tenantId.equals( + query.tenantId, + ), + if (userId != null) + sql.household.auditCreatedBy.equals( + userId, + ), + if (query.latitude != null && + query.longitude != null && + query.maxRadius != null) + CustomExpression(''' + (6371393 * acos( + cos(${query.latitude! * math.pi / 180.0}) * cos((address.latitude * ${math.pi / 180.0})) + * cos((address.longitude * ${math.pi / 180.0}) - ${query.longitude! * math.pi / 180.0}) + + sin(${query.latitude! * math.pi / 180.0}) * sin((address.latitude * ${math.pi / 180.0})) + )) <= ${query.maxRadius!} + '''), + ], + ), + )); + + if (query.latitude != null && + query.longitude != null && + query.maxRadius != null) { + // Use custom SQL expression within the 'where' clause + + print("-----"); + + print("---RAW-DATA---"); + } + final results = await selectQuery.get(); return results .map((e) { diff --git a/apps/health_campaign_field_worker_app/lib/pages/login.dart b/apps/health_campaign_field_worker_app/lib/pages/login.dart index 3a9f0ff27..262c1fa66 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/login.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/login.dart @@ -187,12 +187,12 @@ class _LoginPageState extends LocalizedState { FormGroup buildForm() => fb.group({ _userId: FormControl( - value: '', + value: 'distNihAP1', validators: [Validators.required], ), _password: FormControl( validators: [Validators.required], - value: '', + value: 'eGov@1234', ), }); } 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 2a6dea15b..a6f2acfb5 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,6 +2,7 @@ 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/beneficiary_registration/beneficiary_registration.dart'; import '../blocs/search_households/search_households.dart'; @@ -78,25 +79,44 @@ class _SearchBeneficiaryPageState ], ), ), - DigitSearchBar( - controller: searchController, - hintText: localizations.translate( - i18.searchBeneficiary.beneficiarySearchHintText, - ), - textCapitalization: TextCapitalization.words, - onChanged: (value) { - final bloc = context.read(); - if (value.trim().length < 2) { - bloc.add(const SearchHouseholdsClearEvent()); + BlocBuilder( + builder: (context, locationState) { + return Column( + children: [ + Text( + locationState.latitude.toString(), + ), + Text( + locationState.longitude.toString(), + ), + DigitSearchBar( + controller: searchController, + hintText: localizations.translate( + i18.searchBeneficiary + .beneficiarySearchHintText, + ), + textCapitalization: TextCapitalization.words, + onChanged: (value) { + final bloc = + context.read(); + if (value.trim().length < 2) { + bloc.add( + const SearchHouseholdsClearEvent()); - return; - } + return; + } - bloc.add( - SearchHouseholdsSearchByHouseholdHeadEvent( - searchText: value.trim(), - projectId: context.projectId, - ), + bloc.add( + SearchHouseholdsSearchByHouseholdHeadEvent( + searchText: value.trim(), + projectId: context.projectId, + latitude: locationState.latitude, + longitude: locationState.longitude, + ), + ); + }, + ), + ], ); }, ), 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 a6244da3d..9834a04fe 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 @@ -14,8 +14,8 @@ import '../action_card/action_card.dart'; class MemberCard extends StatelessWidget { final String name; final String gender; - final int years; - final int months; + final int? years; + final int? months; final bool isHead; final IndividualModel individual; final bool isDelivered; @@ -29,7 +29,7 @@ class MemberCard extends StatelessWidget { required this.individual, required this.name, required this.gender, - required this.years, + this.years, this.isHead = false, this.months = 0, required this.localizations, @@ -130,7 +130,7 @@ class MemberCard extends StatelessWidget { ), Expanded( child: Text( - " | $years ${localizations.translate(i18.memberCard.deliverDetailsYearText)} $months ${localizations.translate(i18.memberCard.deliverDetailsMonthsText)}", + " | ${years ?? '-'} ${localizations.translate(i18.memberCard.deliverDetailsYearText)} ${months ?? '-'} ${localizations.translate(i18.memberCard.deliverDetailsMonthsText)}", style: theme.textTheme.bodyMedium, ), ), From 8d53a7b0164eee94e1d6a0f0c0dd4e9ebee6e440 Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 25 Jul 2023 20:45:56 +0530 Subject: [PATCH 04/17] added query --- .../data/repositories/local/household.dart | 59 +++++++++++-------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart index b7bfeb42a..51f48359e 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart @@ -1,5 +1,6 @@ import 'dart:async'; - +import 'dart:math'; +import 'dart:math' as math; import 'package:drift/drift.dart'; import '../../../models/data_model.dart'; @@ -26,29 +27,39 @@ class HouseholdLocalRepository ], ); - final results = await (selectQuery - ..where( - buildAnd( - [ - if (query.clientReferenceId != null) - sql.household.clientReferenceId - .isIn(query.clientReferenceId!), - if (query.id != null) - sql.household.id.equals( - query.id, - ), - if (query.tenantId != null) - sql.household.tenantId.equals( - query.tenantId, - ), - if (userId != null) - sql.household.auditCreatedBy.equals( - userId, - ), - ], - ), - )) - .get(); + (selectQuery + ..where( + buildAnd( + [ + if (query.clientReferenceId != null) + sql.household.clientReferenceId.isIn(query.clientReferenceId!), + if (query.id != null) + sql.household.id.equals( + query.id, + ), + if (query.tenantId != null) + sql.household.tenantId.equals( + query.tenantId, + ), + if (userId != null) + sql.household.auditCreatedBy.equals( + userId, + ), + if (query.latitude != null && + query.longitude != null && + query.maxRadius != null) + CustomExpression(''' + (6371393 * acos( + cos(${query.latitude! * math.pi / 180.0}) * cos((address.latitude * ${math.pi / 180.0})) + * cos((address.longitude * ${math.pi / 180.0}) - ${query.longitude! * math.pi / 180.0}) + + sin(${query.latitude! * math.pi / 180.0}) * sin((address.latitude * ${math.pi / 180.0})) + )) <= ${query.maxRadius!} + '''), + ], + ), + )); + + final results = await selectQuery.get(); return results .map((e) { From 6d53ef8a2bad0647f9ee0b6c505ced5b276187ab Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 31 Jul 2023 09:35:16 +0530 Subject: [PATCH 05/17] enabled proximity bases search --- .../search_households/search_households.dart | 96 ++- .../search_households.freezed.dart | 672 ++++++++++++++++-- .../no_sql/schema/app_configuration.dart | 3 + .../no_sql/schema/app_configuration.g.dart | 161 ++++- .../local_store/no_sql/schema/oplog.g.dart | 2 + .../local_store/sql_store/sql_store.g.dart | 38 - .../sql_store/tables/household.dart | 1 - .../lib/data/repositories/local/address.dart | 102 +++ .../data/repositories/local/household.dart | 7 +- .../lib/data/repositories/oplog/oplog.dart | 31 + .../lib/data/repositories/remote/mdms.dart | 1 + .../models/app_config/app_config_model.dart | 44 +- .../app_config/app_config_model.freezed.dart | 31 +- .../models/app_config/app_config_model.g.dart | 2 + .../lib/models/data_model.dart | 1 + .../lib/models/data_model.mapper.g.dart | 42 +- .../lib/models/entities/address.dart | 9 + .../lib/models/entities/household.dart | 6 +- .../lib/models/model_configs/address.json | 14 +- .../lib/models/model_configs/household.json | 11 +- .../lib/pages/authenticated.dart | 9 + .../household_location.dart | 174 ++--- .../individual_details.dart | 1 + .../lib/pages/search_beneficiary.dart | 345 +++++---- .../lib/utils/constants.dart | 1 + .../lib/utils/i18_key_constants.dart | 4 + .../lib/utils/typedefs.dart | 2 + .../network_manager_provider_wrapper.dart | 1 + .../pubspec.lock | 4 +- .../pubspec.yaml | 1 + 30 files changed, 1403 insertions(+), 413 deletions(-) create mode 100644 apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 04aa82ab6..a381acbe2 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stream_transform/stream_transform.dart'; +import '../../data/repositories/local/address.dart'; import '../../data/repositories/local/project_beneficiary.dart'; import '../../data/repositories/local/task.dart'; import '../../models/data_model.dart'; @@ -26,6 +27,7 @@ class SearchHouseholdsBloc final String userUid; final IndividualDataRepository individual; final HouseholdDataRepository household; + final AddressLocalRepository addressRepository; final HouseholdMemberDataRepository householdMember; final ProjectBeneficiaryDataRepository projectBeneficiary; final TaskDataRepository taskDataRepository; @@ -39,6 +41,7 @@ class SearchHouseholdsBloc required this.projectBeneficiary, required this.taskDataRepository, required this.beneficiaryType, + required this.addressRepository, }) : super(const SearchHouseholdsState()) { on( _handleSearchByHouseholdHead, @@ -46,6 +49,7 @@ class SearchHouseholdsBloc const Duration(milliseconds: 100), ), ); + on(_handleSearchByProximitity); on(_handleClear); on(_handleSearchByHousehold); on(_handleInitialize); @@ -193,6 +197,85 @@ class SearchHouseholdsBloc } } + FutureOr _handleSearchByProximitity( + SearchHouseholdsByProximityEvent event, + SearchHouseholdsEmitter emit, + ) async { + emit(state.copyWith(loading: true)); + final results = + await addressRepository.searchHouseHoldbyAddress(AddressSearchModel( + latitude: event.latitude, + longitude: event.longititude, + maxRadius: event.maxRadius, + )); + final containers = []; + for (final element in results) { + final members = await householdMember.search( + HouseholdMemberSearchModel( + householdClientReferenceId: element.clientReferenceId, + ), + ); + final head = await householdMember.search( + HouseholdMemberSearchModel( + householdClientReferenceId: element.clientReferenceId, + isHeadOfHousehold: true, + ), + ); + + final individualIds = members + .map((element) => element.individualClientReferenceId) + .whereNotNull() + .toList(); + + final allHouseholdMembers = await individual.search( + IndividualSearchModel( + clientReferenceId: individualIds, + ), + ); + + final headOfHousehold = allHouseholdMembers.firstWhere((element) => + element.clientReferenceId == head.first.individualClientReferenceId); + + final projectBeneficiaries = beneficiaryType != BeneficiaryType.individual + ? await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: [element.clientReferenceId], + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ) + : await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: individualIds, + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ); + + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + )); + + containers.add( + HouseholdMemberWrapper( + household: element, + headOfHousehold: headOfHousehold, + members: allHouseholdMembers, + projectBeneficiaries: projectBeneficiaries, + tasks: tasks.isEmpty ? null : tasks, + ), + ); + } + emit(state.copyWith( + householdMembers: containers, + loading: false, + searchQuery: null, + )); + + return; + } + FutureOr _handleSearchByHouseholdHead( SearchHouseholdsSearchByHouseholdHeadEvent event, SearchHouseholdsEmitter emit, @@ -255,7 +338,7 @@ class SearchHouseholdsBloc clientReferenceId: [householdId], latitude: event.latitude, longitude: event.longitude, - maxRadius: 100, + maxRadius: event.maxRadius, ), ); @@ -340,16 +423,27 @@ class SearchHouseholdsEvent with _$SearchHouseholdsEvent { required String projectId, double? latitude, double? longitude, + double? maxRadius, + required final bool isProximityEnabled, required HouseholdModel householdModel, }) = SearchHouseholdsByHouseholdsEvent; const factory SearchHouseholdsEvent.searchByHouseholdHead({ required String searchText, required String projectId, + required final bool isProximityEnabled, double? latitude, double? longitude, + double? maxRadius, }) = SearchHouseholdsSearchByHouseholdHeadEvent; + const factory SearchHouseholdsEvent.searchByProximity({ + required double latitude, + required double longititude, + required String projectId, + required double maxRadius, + }) = SearchHouseholdsByProximityEvent; + const factory SearchHouseholdsEvent.clear() = SearchHouseholdsClearEvent; } diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart index b0c72b14a..7463afeae 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.freezed.dart @@ -19,36 +19,75 @@ mixin _$SearchHouseholdsEvent { @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, double? latitude, - double? longitude, HouseholdModel householdModel) + required TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId, - double? latitude, double? longitude) + required TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius) searchByHouseholdHead, + required TResult Function(double latitude, double longititude, + String projectId, double maxRadius) + searchByProximity, required TResult Function() clear, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, double? latitude, double? longitude, + TResult? Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult? Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult? Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult? Function()? clear, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, double? latitude, double? longitude, + TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult Function()? clear, required TResult orElse(), }) => @@ -61,6 +100,8 @@ mixin _$SearchHouseholdsEvent { searchByHousehold, required TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value) searchByHouseholdHead, + required TResult Function(SearchHouseholdsByProximityEvent value) + searchByProximity, required TResult Function(SearchHouseholdsClearEvent value) clear, }) => throw _privateConstructorUsedError; @@ -71,6 +112,8 @@ mixin _$SearchHouseholdsEvent { searchByHousehold, TResult? Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult? Function(SearchHouseholdsByProximityEvent value)? + searchByProximity, TResult? Function(SearchHouseholdsClearEvent value)? clear, }) => throw _privateConstructorUsedError; @@ -81,6 +124,7 @@ mixin _$SearchHouseholdsEvent { searchByHousehold, TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult Function(SearchHouseholdsByProximityEvent value)? searchByProximity, TResult Function(SearchHouseholdsClearEvent value)? clear, required TResult orElse(), }) => @@ -150,12 +194,25 @@ class _$SearchHouseholdsInitializedEvent @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, double? latitude, - double? longitude, HouseholdModel householdModel) + required TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId, - double? latitude, double? longitude) + required TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius) searchByHouseholdHead, + required TResult Function(double latitude, double longititude, + String projectId, double maxRadius) + searchByProximity, required TResult Function() clear, }) { return initialize(); @@ -165,12 +222,25 @@ class _$SearchHouseholdsInitializedEvent @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, double? latitude, double? longitude, + TResult? Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult? Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult? Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult? Function()? clear, }) { return initialize?.call(); @@ -180,12 +250,25 @@ class _$SearchHouseholdsInitializedEvent @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, double? latitude, double? longitude, + TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult Function()? clear, required TResult orElse(), }) { @@ -204,6 +287,8 @@ class _$SearchHouseholdsInitializedEvent searchByHousehold, required TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value) searchByHouseholdHead, + required TResult Function(SearchHouseholdsByProximityEvent value) + searchByProximity, required TResult Function(SearchHouseholdsClearEvent value) clear, }) { return initialize(this); @@ -217,6 +302,8 @@ class _$SearchHouseholdsInitializedEvent searchByHousehold, TResult? Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult? Function(SearchHouseholdsByProximityEvent value)? + searchByProximity, TResult? Function(SearchHouseholdsClearEvent value)? clear, }) { return initialize?.call(this); @@ -230,6 +317,7 @@ class _$SearchHouseholdsInitializedEvent searchByHousehold, TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult Function(SearchHouseholdsByProximityEvent value)? searchByProximity, TResult Function(SearchHouseholdsClearEvent value)? clear, required TResult orElse(), }) { @@ -257,6 +345,8 @@ abstract class _$$SearchHouseholdsByHouseholdsEventCopyWith<$Res> { {String projectId, double? latitude, double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel}); } @@ -276,6 +366,8 @@ class __$$SearchHouseholdsByHouseholdsEventCopyWithImpl<$Res> Object? projectId = null, Object? latitude = freezed, Object? longitude = freezed, + Object? maxRadius = freezed, + Object? isProximityEnabled = null, Object? householdModel = null, }) { return _then(_$SearchHouseholdsByHouseholdsEvent( @@ -291,6 +383,14 @@ class __$$SearchHouseholdsByHouseholdsEventCopyWithImpl<$Res> ? _value.longitude : longitude // ignore: cast_nullable_to_non_nullable as double?, + maxRadius: freezed == maxRadius + ? _value.maxRadius + : maxRadius // ignore: cast_nullable_to_non_nullable + as double?, + isProximityEnabled: null == isProximityEnabled + ? _value.isProximityEnabled + : isProximityEnabled // ignore: cast_nullable_to_non_nullable + as bool, householdModel: null == householdModel ? _value.householdModel : householdModel // ignore: cast_nullable_to_non_nullable @@ -307,6 +407,8 @@ class _$SearchHouseholdsByHouseholdsEvent {required this.projectId, this.latitude, this.longitude, + this.maxRadius, + required this.isProximityEnabled, required this.householdModel}); @override @@ -316,11 +418,15 @@ class _$SearchHouseholdsByHouseholdsEvent @override final double? longitude; @override + final double? maxRadius; + @override + final bool isProximityEnabled; + @override final HouseholdModel householdModel; @override String toString() { - return 'SearchHouseholdsEvent.searchByHousehold(projectId: $projectId, latitude: $latitude, longitude: $longitude, householdModel: $householdModel)'; + return 'SearchHouseholdsEvent.searchByHousehold(projectId: $projectId, latitude: $latitude, longitude: $longitude, maxRadius: $maxRadius, isProximityEnabled: $isProximityEnabled, householdModel: $householdModel)'; } @override @@ -334,13 +440,17 @@ class _$SearchHouseholdsByHouseholdsEvent other.latitude == latitude) && (identical(other.longitude, longitude) || other.longitude == longitude) && + (identical(other.maxRadius, maxRadius) || + other.maxRadius == maxRadius) && + (identical(other.isProximityEnabled, isProximityEnabled) || + other.isProximityEnabled == isProximityEnabled) && (identical(other.householdModel, householdModel) || other.householdModel == householdModel)); } @override - int get hashCode => - Object.hash(runtimeType, projectId, latitude, longitude, householdModel); + int get hashCode => Object.hash(runtimeType, projectId, latitude, longitude, + maxRadius, isProximityEnabled, householdModel); @JsonKey(ignore: true) @override @@ -354,48 +464,89 @@ class _$SearchHouseholdsByHouseholdsEvent @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, double? latitude, - double? longitude, HouseholdModel householdModel) + required TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId, - double? latitude, double? longitude) + required TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius) searchByHouseholdHead, + required TResult Function(double latitude, double longititude, + String projectId, double maxRadius) + searchByProximity, required TResult Function() clear, }) { - return searchByHousehold(projectId, latitude, longitude, householdModel); + return searchByHousehold(projectId, latitude, longitude, maxRadius, + isProximityEnabled, householdModel); } @override @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, double? latitude, double? longitude, + TResult? Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult? Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult? Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult? Function()? clear, }) { - return searchByHousehold?.call( - projectId, latitude, longitude, householdModel); + return searchByHousehold?.call(projectId, latitude, longitude, maxRadius, + isProximityEnabled, householdModel); } @override @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, double? latitude, double? longitude, + TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult Function()? clear, required TResult orElse(), }) { if (searchByHousehold != null) { - return searchByHousehold(projectId, latitude, longitude, householdModel); + return searchByHousehold(projectId, latitude, longitude, maxRadius, + isProximityEnabled, householdModel); } return orElse(); } @@ -409,6 +560,8 @@ class _$SearchHouseholdsByHouseholdsEvent searchByHousehold, required TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value) searchByHouseholdHead, + required TResult Function(SearchHouseholdsByProximityEvent value) + searchByProximity, required TResult Function(SearchHouseholdsClearEvent value) clear, }) { return searchByHousehold(this); @@ -422,6 +575,8 @@ class _$SearchHouseholdsByHouseholdsEvent searchByHousehold, TResult? Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult? Function(SearchHouseholdsByProximityEvent value)? + searchByProximity, TResult? Function(SearchHouseholdsClearEvent value)? clear, }) { return searchByHousehold?.call(this); @@ -435,6 +590,7 @@ class _$SearchHouseholdsByHouseholdsEvent searchByHousehold, TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult Function(SearchHouseholdsByProximityEvent value)? searchByProximity, TResult Function(SearchHouseholdsClearEvent value)? clear, required TResult orElse(), }) { @@ -451,12 +607,16 @@ abstract class SearchHouseholdsByHouseholdsEvent {required final String projectId, final double? latitude, final double? longitude, + final double? maxRadius, + required final bool isProximityEnabled, required final HouseholdModel householdModel}) = _$SearchHouseholdsByHouseholdsEvent; String get projectId; double? get latitude; double? get longitude; + double? get maxRadius; + bool get isProximityEnabled; HouseholdModel get householdModel; @JsonKey(ignore: true) _$$SearchHouseholdsByHouseholdsEventCopyWith< @@ -474,8 +634,10 @@ abstract class _$$SearchHouseholdsSearchByHouseholdHeadEventCopyWith<$Res> { $Res call( {String searchText, String projectId, + bool isProximityEnabled, double? latitude, - double? longitude}); + double? longitude, + double? maxRadius}); } /// @nodoc @@ -493,8 +655,10 @@ class __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res> $Res call({ Object? searchText = null, Object? projectId = null, + Object? isProximityEnabled = null, Object? latitude = freezed, Object? longitude = freezed, + Object? maxRadius = freezed, }) { return _then(_$SearchHouseholdsSearchByHouseholdHeadEvent( searchText: null == searchText @@ -505,6 +669,10 @@ class __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res> ? _value.projectId : projectId // ignore: cast_nullable_to_non_nullable as String, + isProximityEnabled: null == isProximityEnabled + ? _value.isProximityEnabled + : isProximityEnabled // ignore: cast_nullable_to_non_nullable + as bool, latitude: freezed == latitude ? _value.latitude : latitude // ignore: cast_nullable_to_non_nullable @@ -513,6 +681,10 @@ class __$$SearchHouseholdsSearchByHouseholdHeadEventCopyWithImpl<$Res> ? _value.longitude : longitude // ignore: cast_nullable_to_non_nullable as double?, + maxRadius: freezed == maxRadius + ? _value.maxRadius + : maxRadius // ignore: cast_nullable_to_non_nullable + as double?, )); } } @@ -524,21 +696,27 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent const _$SearchHouseholdsSearchByHouseholdHeadEvent( {required this.searchText, required this.projectId, + required this.isProximityEnabled, this.latitude, - this.longitude}); + this.longitude, + this.maxRadius}); @override final String searchText; @override final String projectId; @override + final bool isProximityEnabled; + @override final double? latitude; @override final double? longitude; + @override + final double? maxRadius; @override String toString() { - return 'SearchHouseholdsEvent.searchByHouseholdHead(searchText: $searchText, projectId: $projectId, latitude: $latitude, longitude: $longitude)'; + return 'SearchHouseholdsEvent.searchByHouseholdHead(searchText: $searchText, projectId: $projectId, isProximityEnabled: $isProximityEnabled, latitude: $latitude, longitude: $longitude, maxRadius: $maxRadius)'; } @override @@ -550,15 +728,19 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent other.searchText == searchText) && (identical(other.projectId, projectId) || other.projectId == projectId) && + (identical(other.isProximityEnabled, isProximityEnabled) || + other.isProximityEnabled == isProximityEnabled) && (identical(other.latitude, latitude) || other.latitude == latitude) && (identical(other.longitude, longitude) || - other.longitude == longitude)); + other.longitude == longitude) && + (identical(other.maxRadius, maxRadius) || + other.maxRadius == maxRadius)); } @override - int get hashCode => - Object.hash(runtimeType, searchText, projectId, latitude, longitude); + int get hashCode => Object.hash(runtimeType, searchText, projectId, + isProximityEnabled, latitude, longitude, maxRadius); @JsonKey(ignore: true) @override @@ -573,48 +755,89 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, double? latitude, - double? longitude, HouseholdModel householdModel) + required TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId, - double? latitude, double? longitude) + required TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius) searchByHouseholdHead, + required TResult Function(double latitude, double longititude, + String projectId, double maxRadius) + searchByProximity, required TResult Function() clear, }) { - return searchByHouseholdHead(searchText, projectId, latitude, longitude); + return searchByHouseholdHead(searchText, projectId, isProximityEnabled, + latitude, longitude, maxRadius); } @override @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, double? latitude, double? longitude, + TResult? Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult? Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult? Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult? Function()? clear, }) { - return searchByHouseholdHead?.call( - searchText, projectId, latitude, longitude); + return searchByHouseholdHead?.call(searchText, projectId, + isProximityEnabled, latitude, longitude, maxRadius); } @override @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, double? latitude, double? longitude, + TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult Function()? clear, required TResult orElse(), }) { if (searchByHouseholdHead != null) { - return searchByHouseholdHead(searchText, projectId, latitude, longitude); + return searchByHouseholdHead(searchText, projectId, isProximityEnabled, + latitude, longitude, maxRadius); } return orElse(); } @@ -628,6 +851,8 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent searchByHousehold, required TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value) searchByHouseholdHead, + required TResult Function(SearchHouseholdsByProximityEvent value) + searchByProximity, required TResult Function(SearchHouseholdsClearEvent value) clear, }) { return searchByHouseholdHead(this); @@ -641,6 +866,8 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent searchByHousehold, TResult? Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult? Function(SearchHouseholdsByProximityEvent value)? + searchByProximity, TResult? Function(SearchHouseholdsClearEvent value)? clear, }) { return searchByHouseholdHead?.call(this); @@ -654,6 +881,7 @@ class _$SearchHouseholdsSearchByHouseholdHeadEvent searchByHousehold, TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult Function(SearchHouseholdsByProximityEvent value)? searchByProximity, TResult Function(SearchHouseholdsClearEvent value)? clear, required TResult orElse(), }) { @@ -669,19 +897,283 @@ abstract class SearchHouseholdsSearchByHouseholdHeadEvent const factory SearchHouseholdsSearchByHouseholdHeadEvent( {required final String searchText, required final String projectId, + required final bool isProximityEnabled, final double? latitude, - final double? longitude}) = _$SearchHouseholdsSearchByHouseholdHeadEvent; + final double? longitude, + final double? maxRadius}) = _$SearchHouseholdsSearchByHouseholdHeadEvent; String get searchText; String get projectId; + bool get isProximityEnabled; double? get latitude; double? get longitude; + double? get maxRadius; @JsonKey(ignore: true) _$$SearchHouseholdsSearchByHouseholdHeadEventCopyWith< _$SearchHouseholdsSearchByHouseholdHeadEvent> get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$SearchHouseholdsByProximityEventCopyWith<$Res> { + factory _$$SearchHouseholdsByProximityEventCopyWith( + _$SearchHouseholdsByProximityEvent value, + $Res Function(_$SearchHouseholdsByProximityEvent) then) = + __$$SearchHouseholdsByProximityEventCopyWithImpl<$Res>; + @useResult + $Res call( + {double latitude, + double longititude, + String projectId, + double maxRadius}); +} + +/// @nodoc +class __$$SearchHouseholdsByProximityEventCopyWithImpl<$Res> + extends _$SearchHouseholdsEventCopyWithImpl<$Res, + _$SearchHouseholdsByProximityEvent> + implements _$$SearchHouseholdsByProximityEventCopyWith<$Res> { + __$$SearchHouseholdsByProximityEventCopyWithImpl( + _$SearchHouseholdsByProximityEvent _value, + $Res Function(_$SearchHouseholdsByProximityEvent) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? latitude = null, + Object? longititude = null, + Object? projectId = null, + Object? maxRadius = null, + }) { + return _then(_$SearchHouseholdsByProximityEvent( + latitude: null == latitude + ? _value.latitude + : latitude // ignore: cast_nullable_to_non_nullable + as double, + longititude: null == longititude + ? _value.longititude + : longititude // ignore: cast_nullable_to_non_nullable + as double, + projectId: null == projectId + ? _value.projectId + : projectId // ignore: cast_nullable_to_non_nullable + as String, + maxRadius: null == maxRadius + ? _value.maxRadius + : maxRadius // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc + +class _$SearchHouseholdsByProximityEvent + implements SearchHouseholdsByProximityEvent { + const _$SearchHouseholdsByProximityEvent( + {required this.latitude, + required this.longititude, + required this.projectId, + required this.maxRadius}); + + @override + final double latitude; + @override + final double longititude; + @override + final String projectId; + @override + final double maxRadius; + + @override + String toString() { + return 'SearchHouseholdsEvent.searchByProximity(latitude: $latitude, longititude: $longititude, projectId: $projectId, maxRadius: $maxRadius)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SearchHouseholdsByProximityEvent && + (identical(other.latitude, latitude) || + other.latitude == latitude) && + (identical(other.longititude, longititude) || + other.longititude == longititude) && + (identical(other.projectId, projectId) || + other.projectId == projectId) && + (identical(other.maxRadius, maxRadius) || + other.maxRadius == maxRadius)); + } + + @override + int get hashCode => + Object.hash(runtimeType, latitude, longititude, projectId, maxRadius); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SearchHouseholdsByProximityEventCopyWith< + _$SearchHouseholdsByProximityEvent> + get copyWith => __$$SearchHouseholdsByProximityEventCopyWithImpl< + _$SearchHouseholdsByProximityEvent>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initialize, + required TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel) + searchByHousehold, + required TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius) + searchByHouseholdHead, + required TResult Function(double latitude, double longititude, + String projectId, double maxRadius) + searchByProximity, + required TResult Function() clear, + }) { + return searchByProximity(latitude, longititude, projectId, maxRadius); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initialize, + TResult? Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel)? + searchByHousehold, + TResult? Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? + searchByHouseholdHead, + TResult? Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, + TResult? Function()? clear, + }) { + return searchByProximity?.call(latitude, longititude, projectId, maxRadius); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initialize, + TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel)? + searchByHousehold, + TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? + searchByHouseholdHead, + TResult Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, + TResult Function()? clear, + required TResult orElse(), + }) { + if (searchByProximity != null) { + return searchByProximity(latitude, longititude, projectId, maxRadius); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SearchHouseholdsInitializedEvent value) + initialize, + required TResult Function(SearchHouseholdsByHouseholdsEvent value) + searchByHousehold, + required TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value) + searchByHouseholdHead, + required TResult Function(SearchHouseholdsByProximityEvent value) + searchByProximity, + required TResult Function(SearchHouseholdsClearEvent value) clear, + }) { + return searchByProximity(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SearchHouseholdsInitializedEvent value)? initialize, + TResult? Function(SearchHouseholdsByHouseholdsEvent value)? + searchByHousehold, + TResult? Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? + searchByHouseholdHead, + TResult? Function(SearchHouseholdsByProximityEvent value)? + searchByProximity, + TResult? Function(SearchHouseholdsClearEvent value)? clear, + }) { + return searchByProximity?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SearchHouseholdsInitializedEvent value)? initialize, + TResult Function(SearchHouseholdsByHouseholdsEvent value)? + searchByHousehold, + TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? + searchByHouseholdHead, + TResult Function(SearchHouseholdsByProximityEvent value)? searchByProximity, + TResult Function(SearchHouseholdsClearEvent value)? clear, + required TResult orElse(), + }) { + if (searchByProximity != null) { + return searchByProximity(this); + } + return orElse(); + } +} + +abstract class SearchHouseholdsByProximityEvent + implements SearchHouseholdsEvent { + const factory SearchHouseholdsByProximityEvent( + {required final double latitude, + required final double longititude, + required final String projectId, + required final double maxRadius}) = _$SearchHouseholdsByProximityEvent; + + double get latitude; + double get longititude; + String get projectId; + double get maxRadius; + @JsonKey(ignore: true) + _$$SearchHouseholdsByProximityEventCopyWith< + _$SearchHouseholdsByProximityEvent> + get copyWith => throw _privateConstructorUsedError; +} + /// @nodoc abstract class _$$SearchHouseholdsClearEventCopyWith<$Res> { factory _$$SearchHouseholdsClearEventCopyWith( @@ -725,12 +1217,25 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { @optionalTypeArgs TResult when({ required TResult Function() initialize, - required TResult Function(String projectId, double? latitude, - double? longitude, HouseholdModel householdModel) + required TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, + HouseholdModel householdModel) searchByHousehold, - required TResult Function(String searchText, String projectId, - double? latitude, double? longitude) + required TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius) searchByHouseholdHead, + required TResult Function(double latitude, double longititude, + String projectId, double maxRadius) + searchByProximity, required TResult Function() clear, }) { return clear(); @@ -740,12 +1245,25 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { @optionalTypeArgs TResult? whenOrNull({ TResult? Function()? initialize, - TResult? Function(String projectId, double? latitude, double? longitude, + TResult? Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult? Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult? Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult? Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult? Function()? clear, }) { return clear?.call(); @@ -755,12 +1273,25 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { @optionalTypeArgs TResult maybeWhen({ TResult Function()? initialize, - TResult Function(String projectId, double? latitude, double? longitude, + TResult Function( + String projectId, + double? latitude, + double? longitude, + double? maxRadius, + bool isProximityEnabled, HouseholdModel householdModel)? searchByHousehold, - TResult Function(String searchText, String projectId, double? latitude, - double? longitude)? + TResult Function( + String searchText, + String projectId, + bool isProximityEnabled, + double? latitude, + double? longitude, + double? maxRadius)? searchByHouseholdHead, + TResult Function(double latitude, double longititude, String projectId, + double maxRadius)? + searchByProximity, TResult Function()? clear, required TResult orElse(), }) { @@ -779,6 +1310,8 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { searchByHousehold, required TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value) searchByHouseholdHead, + required TResult Function(SearchHouseholdsByProximityEvent value) + searchByProximity, required TResult Function(SearchHouseholdsClearEvent value) clear, }) { return clear(this); @@ -792,6 +1325,8 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { searchByHousehold, TResult? Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult? Function(SearchHouseholdsByProximityEvent value)? + searchByProximity, TResult? Function(SearchHouseholdsClearEvent value)? clear, }) { return clear?.call(this); @@ -805,6 +1340,7 @@ class _$SearchHouseholdsClearEvent implements SearchHouseholdsClearEvent { searchByHousehold, TResult Function(SearchHouseholdsSearchByHouseholdHeadEvent value)? searchByHouseholdHead, + TResult Function(SearchHouseholdsByProximityEvent value)? searchByProximity, TResult Function(SearchHouseholdsClearEvent value)? clear, required TResult orElse(), }) { diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.dart index ec73de63c..ee14af1a0 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.dart @@ -15,6 +15,9 @@ class AppConfiguration { @Name("SYNC_METHOD") late String? syncMethod; + @Name("PROXIMITY_SEARCH_RANGE") + late double? maxRadius; + @Name("SYNC_TRIGGER") late String? syncTrigger; diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.g.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.g.dart index 93c86551f..22ea7e1a8 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.g.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/app_configuration.g.dart @@ -105,23 +105,28 @@ const AppConfigurationSchema = CollectionSchema( name: r'PERSISTENCE_MODE', type: IsarType.string, ), - r'SYNC_METHOD': PropertySchema( + r'PROXIMITY_SEARCH_RANGE': PropertySchema( id: 15, + name: r'PROXIMITY_SEARCH_RANGE', + type: IsarType.double, + ), + r'SYNC_METHOD': PropertySchema( + id: 16, name: r'SYNC_METHOD', type: IsarType.string, ), r'SYNC_TRIGGER': PropertySchema( - id: 16, + id: 17, name: r'SYNC_TRIGGER', type: IsarType.string, ), r'TENANT_ID': PropertySchema( - id: 17, + id: 18, name: r'TENANT_ID', type: IsarType.string, ), r'TRANSPORT_TYPES': PropertySchema( - id: 18, + id: 19, name: r'TRANSPORT_TYPES', type: IsarType.objectList, target: r'TransportTypes', @@ -462,11 +467,12 @@ void _appConfigurationSerialize( ); writer.writeString(offsets[13], object.networkDetection); writer.writeString(offsets[14], object.persistenceMode); - writer.writeString(offsets[15], object.syncMethod); - writer.writeString(offsets[16], object.syncTrigger); - writer.writeString(offsets[17], object.tenantId); + writer.writeDouble(offsets[15], object.maxRadius); + writer.writeString(offsets[16], object.syncMethod); + writer.writeString(offsets[17], object.syncTrigger); + writer.writeString(offsets[18], object.tenantId); writer.writeObjectList( - offsets[18], + offsets[19], allOffsets, TransportTypesSchema.serialize, object.transportTypes, @@ -560,11 +566,12 @@ AppConfiguration _appConfigurationDeserialize( ); object.networkDetection = reader.readStringOrNull(offsets[13]); object.persistenceMode = reader.readStringOrNull(offsets[14]); - object.syncMethod = reader.readStringOrNull(offsets[15]); - object.syncTrigger = reader.readStringOrNull(offsets[16]); - object.tenantId = reader.readStringOrNull(offsets[17]); + object.maxRadius = reader.readDoubleOrNull(offsets[15]); + object.syncMethod = reader.readStringOrNull(offsets[16]); + object.syncTrigger = reader.readStringOrNull(offsets[17]); + object.tenantId = reader.readStringOrNull(offsets[18]); object.transportTypes = reader.readObjectList( - offsets[18], + offsets[19], TransportTypesSchema.deserialize, allOffsets, TransportTypes(), @@ -673,12 +680,14 @@ P _appConfigurationDeserializeProp

( case 14: return (reader.readStringOrNull(offset)) as P; case 15: - return (reader.readStringOrNull(offset)) as P; + return (reader.readDoubleOrNull(offset)) as P; case 16: return (reader.readStringOrNull(offset)) as P; case 17: return (reader.readStringOrNull(offset)) as P; case 18: + return (reader.readStringOrNull(offset)) as P; + case 19: return (reader.readObjectList( offset, TransportTypesSchema.deserialize, @@ -2216,6 +2225,90 @@ extension AppConfigurationQueryFilter }); } + QueryBuilder + maxRadiusIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'PROXIMITY_SEARCH_RANGE', + )); + }); + } + + QueryBuilder + maxRadiusIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'PROXIMITY_SEARCH_RANGE', + )); + }); + } + + QueryBuilder + maxRadiusEqualTo( + double? value, { + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'PROXIMITY_SEARCH_RANGE', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + maxRadiusGreaterThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'PROXIMITY_SEARCH_RANGE', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + maxRadiusLessThan( + double? value, { + bool include = false, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'PROXIMITY_SEARCH_RANGE', + value: value, + epsilon: epsilon, + )); + }); + } + + QueryBuilder + maxRadiusBetween( + double? lower, + double? upper, { + bool includeLower = true, + bool includeUpper = true, + double epsilon = Query.epsilon, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'PROXIMITY_SEARCH_RANGE', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + epsilon: epsilon, + )); + }); + } + QueryBuilder syncMethodIsNull() { return QueryBuilder.apply(this, (query) { @@ -2978,6 +3071,20 @@ extension AppConfigurationQuerySortBy }); } + QueryBuilder + sortByMaxRadius() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'PROXIMITY_SEARCH_RANGE', Sort.asc); + }); + } + + QueryBuilder + sortByMaxRadiusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'PROXIMITY_SEARCH_RANGE', Sort.desc); + }); + } + QueryBuilder sortBySyncMethod() { return QueryBuilder.apply(this, (query) { @@ -3051,6 +3158,20 @@ extension AppConfigurationQuerySortThenBy }); } + QueryBuilder + thenByMaxRadius() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'PROXIMITY_SEARCH_RANGE', Sort.asc); + }); + } + + QueryBuilder + thenByMaxRadiusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'PROXIMITY_SEARCH_RANGE', Sort.desc); + }); + } + QueryBuilder thenBySyncMethod() { return QueryBuilder.apply(this, (query) { @@ -3125,6 +3246,13 @@ extension AppConfigurationQueryWhereDistinct }); } + QueryBuilder + distinctByMaxRadius() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'PROXIMITY_SEARCH_RANGE'); + }); + } + QueryBuilder distinctBySyncMethod({bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -3260,6 +3388,13 @@ extension AppConfigurationQueryProperty }); } + QueryBuilder + maxRadiusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'PROXIMITY_SEARCH_RANGE'); + }); + } + QueryBuilder syncMethodProperty() { return QueryBuilder.apply(this, (query) { diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/oplog.g.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/oplog.g.dart index 0025108d9..e175b463e 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/oplog.g.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/no_sql/schema/oplog.g.dart @@ -251,6 +251,7 @@ P _opLogDeserializeProp

( const _OpLogentityTypeEnumValueMap = { r'user': r'user', r'facility': r'facility', + r'address': r'address', r'household': r'household', r'householdMember': r'householdMember', r'individual': r'individual', @@ -277,6 +278,7 @@ const _OpLogentityTypeEnumValueMap = { const _OpLogentityTypeValueEnumMap = { r'user': DataModelType.user, r'facility': DataModelType.facility, + r'address': DataModelType.address, r'household': DataModelType.household, r'householdMember': DataModelType.householdMember, r'individual': DataModelType.individual, diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart index d0e72ffc4..09d4f24c1 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/sql_store.g.dart @@ -3702,7 +3702,6 @@ class HouseholdData extends DataClass implements Insertable { final int? memberCount; final double? latitude; final double? longitude; - final double? maxRadius; final String? auditCreatedBy; final int? auditCreatedTime; final String? auditModifiedBy; @@ -3717,7 +3716,6 @@ class HouseholdData extends DataClass implements Insertable { this.memberCount, this.latitude, this.longitude, - this.maxRadius, this.auditCreatedBy, this.auditCreatedTime, this.auditModifiedBy, @@ -3738,8 +3736,6 @@ class HouseholdData extends DataClass implements Insertable { .mapFromDatabaseResponse(data['${effectivePrefix}latitude']), longitude: const RealType() .mapFromDatabaseResponse(data['${effectivePrefix}longitude']), - maxRadius: const RealType() - .mapFromDatabaseResponse(data['${effectivePrefix}max_radius']), auditCreatedBy: const StringType() .mapFromDatabaseResponse(data['${effectivePrefix}audit_created_by']), auditCreatedTime: const IntType().mapFromDatabaseResponse( @@ -3775,9 +3771,6 @@ class HouseholdData extends DataClass implements Insertable { if (!nullToAbsent || longitude != null) { map['longitude'] = Variable(longitude); } - if (!nullToAbsent || maxRadius != null) { - map['max_radius'] = Variable(maxRadius); - } if (!nullToAbsent || auditCreatedBy != null) { map['audit_created_by'] = Variable(auditCreatedBy); } @@ -3818,9 +3811,6 @@ class HouseholdData extends DataClass implements Insertable { longitude: longitude == null && nullToAbsent ? const Value.absent() : Value(longitude), - maxRadius: maxRadius == null && nullToAbsent - ? const Value.absent() - : Value(maxRadius), auditCreatedBy: auditCreatedBy == null && nullToAbsent ? const Value.absent() : Value(auditCreatedBy), @@ -3857,7 +3847,6 @@ class HouseholdData extends DataClass implements Insertable { memberCount: serializer.fromJson(json['memberCount']), latitude: serializer.fromJson(json['latitude']), longitude: serializer.fromJson(json['longitude']), - maxRadius: serializer.fromJson(json['maxRadius']), auditCreatedBy: serializer.fromJson(json['auditCreatedBy']), auditCreatedTime: serializer.fromJson(json['auditCreatedTime']), auditModifiedBy: serializer.fromJson(json['auditModifiedBy']), @@ -3877,7 +3866,6 @@ class HouseholdData extends DataClass implements Insertable { 'memberCount': serializer.toJson(memberCount), 'latitude': serializer.toJson(latitude), 'longitude': serializer.toJson(longitude), - 'maxRadius': serializer.toJson(maxRadius), 'auditCreatedBy': serializer.toJson(auditCreatedBy), 'auditCreatedTime': serializer.toJson(auditCreatedTime), 'auditModifiedBy': serializer.toJson(auditModifiedBy), @@ -3895,7 +3883,6 @@ class HouseholdData extends DataClass implements Insertable { int? memberCount, double? latitude, double? longitude, - double? maxRadius, String? auditCreatedBy, int? auditCreatedTime, String? auditModifiedBy, @@ -3910,7 +3897,6 @@ class HouseholdData extends DataClass implements Insertable { memberCount: memberCount ?? this.memberCount, latitude: latitude ?? this.latitude, longitude: longitude ?? this.longitude, - maxRadius: maxRadius ?? this.maxRadius, auditCreatedBy: auditCreatedBy ?? this.auditCreatedBy, auditCreatedTime: auditCreatedTime ?? this.auditCreatedTime, auditModifiedBy: auditModifiedBy ?? this.auditModifiedBy, @@ -3928,7 +3914,6 @@ class HouseholdData extends DataClass implements Insertable { ..write('memberCount: $memberCount, ') ..write('latitude: $latitude, ') ..write('longitude: $longitude, ') - ..write('maxRadius: $maxRadius, ') ..write('auditCreatedBy: $auditCreatedBy, ') ..write('auditCreatedTime: $auditCreatedTime, ') ..write('auditModifiedBy: $auditModifiedBy, ') @@ -3948,7 +3933,6 @@ class HouseholdData extends DataClass implements Insertable { memberCount, latitude, longitude, - maxRadius, auditCreatedBy, auditCreatedTime, auditModifiedBy, @@ -3966,7 +3950,6 @@ class HouseholdData extends DataClass implements Insertable { other.memberCount == this.memberCount && other.latitude == this.latitude && other.longitude == this.longitude && - other.maxRadius == this.maxRadius && other.auditCreatedBy == this.auditCreatedBy && other.auditCreatedTime == this.auditCreatedTime && other.auditModifiedBy == this.auditModifiedBy && @@ -3983,7 +3966,6 @@ class HouseholdCompanion extends UpdateCompanion { final Value memberCount; final Value latitude; final Value longitude; - final Value maxRadius; final Value auditCreatedBy; final Value auditCreatedTime; final Value auditModifiedBy; @@ -3998,7 +3980,6 @@ class HouseholdCompanion extends UpdateCompanion { this.memberCount = const Value.absent(), this.latitude = const Value.absent(), this.longitude = const Value.absent(), - this.maxRadius = const Value.absent(), this.auditCreatedBy = const Value.absent(), this.auditCreatedTime = const Value.absent(), this.auditModifiedBy = const Value.absent(), @@ -4014,7 +3995,6 @@ class HouseholdCompanion extends UpdateCompanion { this.memberCount = const Value.absent(), this.latitude = const Value.absent(), this.longitude = const Value.absent(), - this.maxRadius = const Value.absent(), this.auditCreatedBy = const Value.absent(), this.auditCreatedTime = const Value.absent(), this.auditModifiedBy = const Value.absent(), @@ -4030,7 +4010,6 @@ class HouseholdCompanion extends UpdateCompanion { Expression? memberCount, Expression? latitude, Expression? longitude, - Expression? maxRadius, Expression? auditCreatedBy, Expression? auditCreatedTime, Expression? auditModifiedBy, @@ -4046,7 +4025,6 @@ class HouseholdCompanion extends UpdateCompanion { if (memberCount != null) 'member_count': memberCount, if (latitude != null) 'latitude': latitude, if (longitude != null) 'longitude': longitude, - if (maxRadius != null) 'max_radius': maxRadius, if (auditCreatedBy != null) 'audit_created_by': auditCreatedBy, if (auditCreatedTime != null) 'audit_created_time': auditCreatedTime, if (auditModifiedBy != null) 'audit_modified_by': auditModifiedBy, @@ -4064,7 +4042,6 @@ class HouseholdCompanion extends UpdateCompanion { Value? memberCount, Value? latitude, Value? longitude, - Value? maxRadius, Value? auditCreatedBy, Value? auditCreatedTime, Value? auditModifiedBy, @@ -4079,7 +4056,6 @@ class HouseholdCompanion extends UpdateCompanion { memberCount: memberCount ?? this.memberCount, latitude: latitude ?? this.latitude, longitude: longitude ?? this.longitude, - maxRadius: maxRadius ?? this.maxRadius, auditCreatedBy: auditCreatedBy ?? this.auditCreatedBy, auditCreatedTime: auditCreatedTime ?? this.auditCreatedTime, auditModifiedBy: auditModifiedBy ?? this.auditModifiedBy, @@ -4107,9 +4083,6 @@ class HouseholdCompanion extends UpdateCompanion { if (longitude.present) { map['longitude'] = Variable(longitude.value); } - if (maxRadius.present) { - map['max_radius'] = Variable(maxRadius.value); - } if (auditCreatedBy.present) { map['audit_created_by'] = Variable(auditCreatedBy.value); } @@ -4147,7 +4120,6 @@ class HouseholdCompanion extends UpdateCompanion { ..write('memberCount: $memberCount, ') ..write('latitude: $latitude, ') ..write('longitude: $longitude, ') - ..write('maxRadius: $maxRadius, ') ..write('auditCreatedBy: $auditCreatedBy, ') ..write('auditCreatedTime: $auditCreatedTime, ') ..write('auditModifiedBy: $auditModifiedBy, ') @@ -4189,11 +4161,6 @@ class $HouseholdTable extends Household late final GeneratedColumn longitude = GeneratedColumn( 'longitude', aliasedName, true, type: const RealType(), requiredDuringInsert: false); - final VerificationMeta _maxRadiusMeta = const VerificationMeta('maxRadius'); - @override - late final GeneratedColumn maxRadius = GeneratedColumn( - 'max_radius', aliasedName, true, - type: const RealType(), requiredDuringInsert: false); final VerificationMeta _auditCreatedByMeta = const VerificationMeta('auditCreatedBy'); @override @@ -4254,7 +4221,6 @@ class $HouseholdTable extends Household memberCount, latitude, longitude, - maxRadius, auditCreatedBy, auditCreatedTime, auditModifiedBy, @@ -4291,10 +4257,6 @@ class $HouseholdTable extends Household context.handle(_longitudeMeta, longitude.isAcceptableOrUnknown(data['longitude']!, _longitudeMeta)); } - if (data.containsKey('max_radius')) { - context.handle(_maxRadiusMeta, - maxRadius.isAcceptableOrUnknown(data['max_radius']!, _maxRadiusMeta)); - } if (data.containsKey('audit_created_by')) { context.handle( _auditCreatedByMeta, diff --git a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart index f9f5fc744..a3d41aefc 100644 --- a/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/local_store/sql_store/tables/household.dart @@ -8,7 +8,6 @@ class Household extends Table { IntColumn get memberCount => integer().nullable()(); RealColumn get latitude => real().nullable()(); RealColumn get longitude => real().nullable()(); - RealColumn get maxRadius => real().nullable()(); TextColumn get auditCreatedBy => text().nullable()(); IntColumn get auditCreatedTime => integer().nullable()(); TextColumn get auditModifiedBy => text().nullable()(); diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart new file mode 100644 index 000000000..89dbdbdd5 --- /dev/null +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart @@ -0,0 +1,102 @@ +import 'dart:async'; + +import 'package:drift/drift.dart'; +import 'dart:math' as math; +import '../../../models/data_model.dart'; +import '../../../utils/utils.dart'; +import '../../local_store/sql_store/sql_store.dart'; +import '../oplog/oplog.dart'; + +class AddressLocalRepository { + final LocalSqlDataStore sql; + final OpLogManager opLogManager; + + AddressLocalRepository(this.sql, this.opLogManager); + + FutureOr> searchHouseHoldbyAddress( + AddressSearchModel query, [ + String? userId, + ]) async { + final selectQuery = sql.select(sql.address).join( + [ + leftOuterJoin( + sql.household, + sql.household.clientReferenceId.equalsExp( + sql.address.relatedClientReferenceId, + ), + ), + ], + ); + + (selectQuery + ..where(buildAnd([ + sql.address.relatedClientReferenceId.isNotNull(), + sql.household.clientReferenceId.isNotNull(), + if (query.latitude != null && + query.longitude != null && + query.maxRadius != null) + CustomExpression(''' + (6371393 * acos( + cos(${query.latitude! * math.pi / 180.0}) * cos((address.latitude * ${math.pi / 180.0})) + * cos((address.longitude * ${math.pi / 180.0}) - ${query.longitude! * math.pi / 180.0}) + + sin(${query.latitude! * math.pi / 180.0}) * sin((address.latitude * ${math.pi / 180.0})) + )) <= ${query.maxRadius!} + '''), + ]))); + final results = await selectQuery.get(); + + return results + .map((e) { + final household = e.readTableOrNull(sql.household); + final address = e.readTableOrNull(sql.address); + + return HouseholdModel( + id: household?.id, + tenantId: household?.tenantId, + clientReferenceId: household!.clientReferenceId, + memberCount: household.memberCount, + rowVersion: household.rowVersion, + isDeleted: household.isDeleted, + auditDetails: AuditDetails( + createdBy: household.auditCreatedBy!, + createdTime: household.auditCreatedTime!, + lastModifiedBy: household.auditModifiedBy, + lastModifiedTime: household.auditModifiedTime, + ), + address: address == null + ? null + : AddressModel( + id: address.id, + relatedClientReferenceId: address.relatedClientReferenceId, + tenantId: address.tenantId, + doorNo: address.doorNo, + latitude: address.latitude, + longitude: address.longitude, + landmark: address.landmark, + locationAccuracy: address.locationAccuracy, + addressLine1: address.addressLine1, + addressLine2: address.addressLine2, + city: address.city, + pincode: address.pincode, + locality: address.localityBoundaryCode != null + ? LocalityModel( + code: address.localityBoundaryCode!, + name: address.localityBoundaryName, + ) + : null, + type: address.type, + rowVersion: address.rowVersion, + auditDetails: AuditDetails( + createdBy: household.auditCreatedBy!, + createdTime: household.auditCreatedTime!, + lastModifiedBy: household.auditModifiedBy, + lastModifiedTime: household?.auditModifiedTime, + ), + ), + ); + }) + .where((element) => element.isDeleted != true) + .toList(); + return []; + } +} diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart index 8d46a85da..f6e1ae9e5 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/household.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:math'; import 'dart:math' as math; import 'package:drift/drift.dart'; @@ -16,9 +15,6 @@ class HouseholdLocalRepository HouseholdSearchModel query, [ String? userId, ]) async { - print(query.latitude); - print(query.longitude); - print("-----Search Queries----"); final selectQuery = sql.select(sql.household).join( [ leftOuterJoin( @@ -50,7 +46,8 @@ class HouseholdLocalRepository ), if (query.latitude != null && query.longitude != null && - query.maxRadius != null) + query.maxRadius != null && + query.isProximityEnabled == true) CustomExpression(''' (6371393 * acos( cos(${query.latitude! * math.pi / 180.0}) * cos((address.latitude * ${math.pi / 180.0})) diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/oplog/oplog.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/oplog/oplog.dart index 95ff78c11..aa4c37d8c 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/oplog/oplog.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/oplog/oplog.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:math'; import 'package:collection/collection.dart'; import 'package:isar/isar.dart'; @@ -273,6 +274,36 @@ class IndividualOpLogManager extends OpLogManager { int? getRowVersion(IndividualModel entity) => entity.rowVersion; } +class AddressOpLogManager extends OpLogManager { + AddressOpLogManager(super.isar); + + @override + AddressModel applyServerGeneratedIdToEntity( + AddressModel entity, + String serverGeneratedId, + int rowVersion, + ) { + return entity; + } + + @override + String getClientReferenceId( + AddressModel entity, + ) { + return entity.relatedClientReferenceId!; + } + + @override + int? getRowVersion(AddressModel entity) { + return entity.rowVersion; + } + + @override + String? getServerGeneratedId(AddressModel entity) { + return entity.relatedClientReferenceId; + } +} + class HouseholdOpLogManager extends OpLogManager { HouseholdOpLogManager(super.isar); 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 966db81f0..f7d8730b0 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 @@ -126,6 +126,7 @@ class MdmsRepository { ..syncMethod = element.syncMethod ..syncTrigger = element.syncTrigger ..tenantId = element.tenantId + ..maxRadius = element.maxRadius ..backgroundServiceConfig = backgroundServiceConfig; final List languageList = element.languages.map((element) { 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 2e07fe6fd..c1d802568 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 @@ -47,7 +47,7 @@ class MdmsMasterDetailModel with _$MdmsMasterDetailModel { class AppConfigPrimaryWrapperModel with _$AppConfigPrimaryWrapperModel { const factory AppConfigPrimaryWrapperModel({ @JsonKey(name: 'HCM-FIELD-APP-CONFIG') - final AppConfigSecondaryWrapperModel? appConfig, + final AppConfigSecondaryWrapperModel? appConfig, }) = _AppConfigPrimaryWrapperModel; factory AppConfigPrimaryWrapperModel.fromJson( @@ -71,41 +71,35 @@ class AppConfigSecondaryWrapperModel with _$AppConfigSecondaryWrapperModel { @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: '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/app_config/app_config_model.freezed.dart b/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.freezed.dart index a65d1bac7..b98fd3008 100644 --- a/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.freezed.dart +++ b/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.freezed.dart @@ -1002,6 +1002,8 @@ mixin _$AppConfig { List get languages => throw _privateConstructorUsedError; @JsonKey(name: 'TENANT_ID') String? get tenantId => throw _privateConstructorUsedError; + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + double? get maxRadius => throw _privateConstructorUsedError; @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') List get householdDeletionReasonOptions => throw _privateConstructorUsedError; @@ -1055,6 +1057,8 @@ abstract class $AppConfigCopyWith<$Res> { List languages, @JsonKey(name: 'TENANT_ID') String? tenantId, + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + double? maxRadius, @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') List householdDeletionReasonOptions, @JsonKey(name: 'BANDWIDTH_BATCH_SIZE') @@ -1101,6 +1105,7 @@ class _$AppConfigCopyWithImpl<$Res, $Val extends AppConfig> Object? syncTrigger = null, Object? languages = null, Object? tenantId = freezed, + Object? maxRadius = freezed, Object? householdDeletionReasonOptions = null, Object? bandWidthBatchSize = null, Object? backgroundServiceConfig = freezed, @@ -1138,6 +1143,10 @@ class _$AppConfigCopyWithImpl<$Res, $Val extends AppConfig> ? _value.tenantId : tenantId // ignore: cast_nullable_to_non_nullable as String?, + maxRadius: freezed == maxRadius + ? _value.maxRadius + : maxRadius // ignore: cast_nullable_to_non_nullable + as double?, householdDeletionReasonOptions: null == householdDeletionReasonOptions ? _value.householdDeletionReasonOptions : householdDeletionReasonOptions // ignore: cast_nullable_to_non_nullable @@ -1228,6 +1237,8 @@ abstract class _$$_AppConfigCopyWith<$Res> implements $AppConfigCopyWith<$Res> { List languages, @JsonKey(name: 'TENANT_ID') String? tenantId, + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + double? maxRadius, @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') List householdDeletionReasonOptions, @JsonKey(name: 'BANDWIDTH_BATCH_SIZE') @@ -1274,6 +1285,7 @@ class __$$_AppConfigCopyWithImpl<$Res> Object? syncTrigger = null, Object? languages = null, Object? tenantId = freezed, + Object? maxRadius = freezed, Object? householdDeletionReasonOptions = null, Object? bandWidthBatchSize = null, Object? backgroundServiceConfig = freezed, @@ -1311,6 +1323,10 @@ class __$$_AppConfigCopyWithImpl<$Res> ? _value.tenantId : tenantId // ignore: cast_nullable_to_non_nullable as String?, + maxRadius: freezed == maxRadius + ? _value.maxRadius + : maxRadius // ignore: cast_nullable_to_non_nullable + as double?, householdDeletionReasonOptions: null == householdDeletionReasonOptions ? _value._householdDeletionReasonOptions : householdDeletionReasonOptions // ignore: cast_nullable_to_non_nullable @@ -1376,6 +1392,8 @@ class _$_AppConfig implements _AppConfig { required final List languages, @JsonKey(name: 'TENANT_ID') this.tenantId, + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + this.maxRadius, @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') required final List householdDeletionReasonOptions, @@ -1438,6 +1456,9 @@ class _$_AppConfig implements _AppConfig { @override @JsonKey(name: 'TENANT_ID') final String? tenantId; + @override + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + final double? maxRadius; final List _householdDeletionReasonOptions; @override @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') @@ -1520,7 +1541,7 @@ class _$_AppConfig implements _AppConfig { @override String toString() { - return 'AppConfig(networkDetection: $networkDetection, persistenceMode: $persistenceMode, syncMethod: $syncMethod, syncTrigger: $syncTrigger, languages: $languages, tenantId: $tenantId, householdDeletionReasonOptions: $householdDeletionReasonOptions, bandWidthBatchSize: $bandWidthBatchSize, backgroundServiceConfig: $backgroundServiceConfig, householdMemberDeletionReasonOptions: $householdMemberDeletionReasonOptions, genderOptions: $genderOptions, checklistTypes: $checklistTypes, idTypeOptions: $idTypeOptions, deliveryCommentOptions: $deliveryCommentOptions, backendInterface: $backendInterface, callSupportOptions: $callSupportOptions, transportTypes: $transportTypes)'; + return 'AppConfig(networkDetection: $networkDetection, persistenceMode: $persistenceMode, syncMethod: $syncMethod, syncTrigger: $syncTrigger, languages: $languages, tenantId: $tenantId, maxRadius: $maxRadius, householdDeletionReasonOptions: $householdDeletionReasonOptions, bandWidthBatchSize: $bandWidthBatchSize, backgroundServiceConfig: $backgroundServiceConfig, householdMemberDeletionReasonOptions: $householdMemberDeletionReasonOptions, genderOptions: $genderOptions, checklistTypes: $checklistTypes, idTypeOptions: $idTypeOptions, deliveryCommentOptions: $deliveryCommentOptions, backendInterface: $backendInterface, callSupportOptions: $callSupportOptions, transportTypes: $transportTypes)'; } @override @@ -1540,6 +1561,8 @@ class _$_AppConfig implements _AppConfig { .equals(other._languages, _languages) && (identical(other.tenantId, tenantId) || other.tenantId == tenantId) && + (identical(other.maxRadius, maxRadius) || + other.maxRadius == maxRadius) && const DeepCollectionEquality().equals( other._householdDeletionReasonOptions, _householdDeletionReasonOptions) && @@ -1577,6 +1600,7 @@ class _$_AppConfig implements _AppConfig { syncTrigger, const DeepCollectionEquality().hash(_languages), tenantId, + maxRadius, const DeepCollectionEquality().hash(_householdDeletionReasonOptions), const DeepCollectionEquality().hash(_bandWidthBatchSize), backgroundServiceConfig, @@ -1618,6 +1642,8 @@ abstract class _AppConfig implements AppConfig { required final List languages, @JsonKey(name: 'TENANT_ID') final String? tenantId, + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + final double? maxRadius, @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') required final List householdDeletionReasonOptions, @@ -1665,6 +1691,9 @@ abstract class _AppConfig implements AppConfig { @JsonKey(name: 'TENANT_ID') String? get tenantId; @override + @JsonKey(name: 'PROXIMITY_SEARCH_RANGE') + double? get maxRadius; + @override @JsonKey(name: 'HOUSEHOLD_DELETION_REASON_OPTIONS') List get householdDeletionReasonOptions; @override diff --git a/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.g.dart b/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.g.dart index c7af4a9b2..a4f2d7c17 100644 --- a/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.g.dart +++ b/apps/health_campaign_field_worker_app/lib/models/app_config/app_config_model.g.dart @@ -98,6 +98,7 @@ _$_AppConfig _$$_AppConfigFromJson(Map json) => _$_AppConfig( .map((e) => Languages.fromJson(e as Map)) .toList(), tenantId: json['TENANT_ID'] as String?, + maxRadius: (json['PROXIMITY_SEARCH_RANGE'] as num?)?.toDouble(), householdDeletionReasonOptions: (json['HOUSEHOLD_DELETION_REASON_OPTIONS'] as List) .map((e) => DeletionReasonOptions.fromJson(e as Map)) @@ -145,6 +146,7 @@ Map _$$_AppConfigToJson(_$_AppConfig instance) => 'SYNC_TRIGGER': instance.syncTrigger, 'LANGUAGES': instance.languages, 'TENANT_ID': instance.tenantId, + 'PROXIMITY_SEARCH_RANGE': instance.maxRadius, 'HOUSEHOLD_DELETION_REASON_OPTIONS': instance.householdDeletionReasonOptions, 'BANDWIDTH_BATCH_SIZE': instance.bandWidthBatchSize, diff --git a/apps/health_campaign_field_worker_app/lib/models/data_model.dart b/apps/health_campaign_field_worker_app/lib/models/data_model.dart index cec8803d6..ed9091f6d 100644 --- a/apps/health_campaign_field_worker_app/lib/models/data_model.dart +++ b/apps/health_campaign_field_worker_app/lib/models/data_model.dart @@ -124,6 +124,7 @@ class AuditDetails { enum DataModelType { user, facility, + address, household, householdMember, individual, diff --git a/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart b/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart index 06e74991a..9b3ff38f0 100644 --- a/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart +++ b/apps/health_campaign_field_worker_app/lib/models/data_model.mapper.g.dart @@ -450,15 +450,15 @@ class AddressSearchModelMapper extends BaseMapper { @override Function get decoder => decode; AddressSearchModel decode(dynamic v) => checked(v, (Map map) => fromMap(map)); - AddressSearchModel fromMap(Map map) => AddressSearchModel.ignoreDeleted(id: Mapper.i.$getOpt(map, 'id'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), boundaryCode: Mapper.i.$getOpt(map, 'boundaryCode')); + AddressSearchModel fromMap(Map map) => AddressSearchModel.ignoreDeleted(id: Mapper.i.$getOpt(map, 'id'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), maxRadius: Mapper.i.$getOpt(map, 'maxRadius'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), boundaryCode: Mapper.i.$getOpt(map, 'boundaryCode')); @override Function get encoder => (AddressSearchModel v) => encode(v); dynamic encode(AddressSearchModel v) => toMap(v); - Map toMap(AddressSearchModel a) => {if (Mapper.i.$enc(a.id, 'id') != null) 'id': Mapper.i.$enc(a.id, 'id'), if (Mapper.i.$enc(a.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(a.tenantId, 'tenantId'), if (Mapper.i.$enc(a.boundaryCode, 'boundaryCode') != null) 'boundaryCode': Mapper.i.$enc(a.boundaryCode, 'boundaryCode')}; + Map toMap(AddressSearchModel a) => {if (Mapper.i.$enc(a.id, 'id') != null) 'id': Mapper.i.$enc(a.id, 'id'), if (Mapper.i.$enc(a.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(a.latitude, 'latitude'), if (Mapper.i.$enc(a.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(a.longitude, 'longitude'), if (Mapper.i.$enc(a.maxRadius, 'maxRadius') != null) 'maxRadius': Mapper.i.$enc(a.maxRadius, 'maxRadius'), if (Mapper.i.$enc(a.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(a.tenantId, 'tenantId'), if (Mapper.i.$enc(a.boundaryCode, 'boundaryCode') != null) 'boundaryCode': Mapper.i.$enc(a.boundaryCode, 'boundaryCode')}; - @override String stringify(AddressSearchModel self) => 'AddressSearchModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, additionalFields: ${Mapper.asString(self.additionalFields)}, id: ${Mapper.asString(self.id)}, tenantId: ${Mapper.asString(self.tenantId)})'; - @override int hash(AddressSearchModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.additionalFields) ^ Mapper.hash(self.id) ^ Mapper.hash(self.tenantId); - @override bool equals(AddressSearchModel self, AddressSearchModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.additionalFields, other.additionalFields) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.tenantId, other.tenantId); + @override String stringify(AddressSearchModel self) => 'AddressSearchModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, additionalFields: ${Mapper.asString(self.additionalFields)}, id: ${Mapper.asString(self.id)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, maxRadius: ${Mapper.asString(self.maxRadius)}, tenantId: ${Mapper.asString(self.tenantId)})'; + @override int hash(AddressSearchModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.additionalFields) ^ Mapper.hash(self.id) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.maxRadius) ^ Mapper.hash(self.tenantId); + @override bool equals(AddressSearchModel self, AddressSearchModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.additionalFields, other.additionalFields) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.maxRadius, other.maxRadius) && Mapper.isEqual(self.tenantId, other.tenantId); @override Function get typeFactory => (f) => f(); } @@ -471,14 +471,14 @@ extension AddressSearchModelMapperExtension on AddressSearchModel { abstract class AddressSearchModelCopyWith<$R> { factory AddressSearchModelCopyWith(AddressSearchModel value, Then then) = _AddressSearchModelCopyWithImpl<$R>; - $R call({String? id, String? tenantId, String? boundaryCode}); + $R call({String? id, double? latitude, double? longitude, double? maxRadius, String? tenantId, String? boundaryCode}); $R apply(AddressSearchModel Function(AddressSearchModel) transform); } class _AddressSearchModelCopyWithImpl<$R> extends BaseCopyWith implements AddressSearchModelCopyWith<$R> { _AddressSearchModelCopyWithImpl(AddressSearchModel value, Then then) : super(value, then); - @override $R call({Object? id = $none, Object? tenantId = $none, Object? boundaryCode = $none}) => $then(AddressSearchModel.ignoreDeleted(id: or(id, $value.id), tenantId: or(tenantId, $value.tenantId), boundaryCode: or(boundaryCode, $value.boundaryCode))); + @override $R call({Object? id = $none, Object? latitude = $none, Object? longitude = $none, Object? maxRadius = $none, Object? tenantId = $none, Object? boundaryCode = $none}) => $then(AddressSearchModel.ignoreDeleted(id: or(id, $value.id), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), maxRadius: or(maxRadius, $value.maxRadius), tenantId: or(tenantId, $value.tenantId), boundaryCode: or(boundaryCode, $value.boundaryCode))); } class AddressModelMapper extends BaseMapper { @@ -986,15 +986,15 @@ class HouseholdSearchModelMapper extends BaseMapper { @override Function get decoder => decode; HouseholdSearchModel decode(dynamic v) => checked(v, (Map map) => fromMap(map)); - HouseholdSearchModel fromMap(Map map) => HouseholdSearchModel.ignoreDeleted(id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), maxRadius: Mapper.i.$getOpt(map, 'maxRadius'), clientReferenceId: Mapper.i.$getOpt(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), boundaryCode: Mapper.i.$getOpt(map, 'boundaryCode')); + HouseholdSearchModel fromMap(Map map) => HouseholdSearchModel.ignoreDeleted(id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), maxRadius: Mapper.i.$getOpt(map, 'maxRadius'), isProximityEnabled: Mapper.i.$getOpt(map, 'isProximityEnabled'), clientReferenceId: Mapper.i.$getOpt(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), boundaryCode: Mapper.i.$getOpt(map, 'boundaryCode')); @override Function get encoder => (HouseholdSearchModel v) => encode(v); dynamic encode(HouseholdSearchModel v) => toMap(v); - Map toMap(HouseholdSearchModel h) => {if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(h.latitude, 'latitude'), if (Mapper.i.$enc(h.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(h.longitude, 'longitude'), if (Mapper.i.$enc(h.maxRadius, 'maxRadius') != null) 'maxRadius': Mapper.i.$enc(h.maxRadius, 'maxRadius'), if (Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId') != null) 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.boundaryCode, 'boundaryCode') != null) 'boundaryCode': Mapper.i.$enc(h.boundaryCode, 'boundaryCode')}; + Map toMap(HouseholdSearchModel h) => {if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(h.latitude, 'latitude'), if (Mapper.i.$enc(h.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(h.longitude, 'longitude'), if (Mapper.i.$enc(h.maxRadius, 'maxRadius') != null) 'maxRadius': Mapper.i.$enc(h.maxRadius, 'maxRadius'), if (Mapper.i.$enc(h.isProximityEnabled, 'isProximityEnabled') != null) 'isProximityEnabled': Mapper.i.$enc(h.isProximityEnabled, 'isProximityEnabled'), if (Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId') != null) 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.boundaryCode, 'boundaryCode') != null) 'boundaryCode': Mapper.i.$enc(h.boundaryCode, 'boundaryCode')}; - @override String stringify(HouseholdSearchModel self) => 'HouseholdSearchModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, additionalFields: ${Mapper.asString(self.additionalFields)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, maxRadius: ${Mapper.asString(self.maxRadius)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)})'; - @override int hash(HouseholdSearchModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.additionalFields) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.maxRadius) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId); - @override bool equals(HouseholdSearchModel self, HouseholdSearchModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.additionalFields, other.additionalFields) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.maxRadius, other.maxRadius) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId); + @override String stringify(HouseholdSearchModel self) => 'HouseholdSearchModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, additionalFields: ${Mapper.asString(self.additionalFields)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, maxRadius: ${Mapper.asString(self.maxRadius)}, isProximityEnabled: ${Mapper.asString(self.isProximityEnabled)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)})'; + @override int hash(HouseholdSearchModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.additionalFields) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.maxRadius) ^ Mapper.hash(self.isProximityEnabled) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId); + @override bool equals(HouseholdSearchModel self, HouseholdSearchModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.additionalFields, other.additionalFields) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.maxRadius, other.maxRadius) && Mapper.isEqual(self.isProximityEnabled, other.isProximityEnabled) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId); @override Function get typeFactory => (f) => f(); } @@ -1007,14 +1007,14 @@ extension HouseholdSearchModelMapperExtension on HouseholdSearchModel { abstract class HouseholdSearchModelCopyWith<$R> { factory HouseholdSearchModelCopyWith(HouseholdSearchModel value, Then then) = _HouseholdSearchModelCopyWithImpl<$R>; - $R call({String? id, int? memberCount, double? latitude, double? longitude, double? maxRadius, List? clientReferenceId, String? tenantId, String? boundaryCode}); + $R call({String? id, int? memberCount, double? latitude, double? longitude, double? maxRadius, bool? isProximityEnabled, List? clientReferenceId, String? tenantId, String? boundaryCode}); $R apply(HouseholdSearchModel Function(HouseholdSearchModel) transform); } class _HouseholdSearchModelCopyWithImpl<$R> extends BaseCopyWith implements HouseholdSearchModelCopyWith<$R> { _HouseholdSearchModelCopyWithImpl(HouseholdSearchModel value, Then then) : super(value, then); - @override $R call({Object? id = $none, Object? memberCount = $none, Object? latitude = $none, Object? longitude = $none, Object? maxRadius = $none, Object? clientReferenceId = $none, Object? tenantId = $none, Object? boundaryCode = $none}) => $then(HouseholdSearchModel.ignoreDeleted(id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), maxRadius: or(maxRadius, $value.maxRadius), clientReferenceId: or(clientReferenceId, $value.clientReferenceId), tenantId: or(tenantId, $value.tenantId), boundaryCode: or(boundaryCode, $value.boundaryCode))); + @override $R call({Object? id = $none, Object? memberCount = $none, Object? latitude = $none, Object? longitude = $none, Object? maxRadius = $none, Object? isProximityEnabled = $none, Object? clientReferenceId = $none, Object? tenantId = $none, Object? boundaryCode = $none}) => $then(HouseholdSearchModel.ignoreDeleted(id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), maxRadius: or(maxRadius, $value.maxRadius), isProximityEnabled: or(isProximityEnabled, $value.isProximityEnabled), clientReferenceId: or(clientReferenceId, $value.clientReferenceId), tenantId: or(tenantId, $value.tenantId), boundaryCode: or(boundaryCode, $value.boundaryCode))); } class HouseholdModelMapper extends BaseMapper { @@ -1022,15 +1022,15 @@ class HouseholdModelMapper extends BaseMapper { @override Function get decoder => decode; HouseholdModel decode(dynamic v) => checked(v, (Map map) => fromMap(map)); - HouseholdModel fromMap(Map map) => HouseholdModel(additionalFields: Mapper.i.$getOpt(map, 'additionalFields'), id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), maxRadius: Mapper.i.$getOpt(map, 'maxRadius'), clientReferenceId: Mapper.i.$get(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), rowVersion: Mapper.i.$getOpt(map, 'rowVersion'), address: Mapper.i.$getOpt(map, 'address'), auditDetails: Mapper.i.$getOpt(map, 'auditDetails'), isDeleted: Mapper.i.$getOpt(map, 'isDeleted') ?? false); + HouseholdModel fromMap(Map map) => HouseholdModel(additionalFields: Mapper.i.$getOpt(map, 'additionalFields'), id: Mapper.i.$getOpt(map, 'id'), memberCount: Mapper.i.$getOpt(map, 'memberCount'), latitude: Mapper.i.$getOpt(map, 'latitude'), longitude: Mapper.i.$getOpt(map, 'longitude'), clientReferenceId: Mapper.i.$get(map, 'clientReferenceId'), tenantId: Mapper.i.$getOpt(map, 'tenantId'), rowVersion: Mapper.i.$getOpt(map, 'rowVersion'), address: Mapper.i.$getOpt(map, 'address'), auditDetails: Mapper.i.$getOpt(map, 'auditDetails'), isDeleted: Mapper.i.$getOpt(map, 'isDeleted') ?? false); @override Function get encoder => (HouseholdModel v) => encode(v); dynamic encode(HouseholdModel v) => toMap(v); - Map toMap(HouseholdModel h) => {if (Mapper.i.$enc(h.additionalFields, 'additionalFields') != null) 'additionalFields': Mapper.i.$enc(h.additionalFields, 'additionalFields'), if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(h.latitude, 'latitude'), if (Mapper.i.$enc(h.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(h.longitude, 'longitude'), if (Mapper.i.$enc(h.maxRadius, 'maxRadius') != null) 'maxRadius': Mapper.i.$enc(h.maxRadius, 'maxRadius'), 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.rowVersion, 'rowVersion') != null) 'rowVersion': Mapper.i.$enc(h.rowVersion, 'rowVersion'), if (Mapper.i.$enc(h.address, 'address') != null) 'address': Mapper.i.$enc(h.address, 'address'), if (Mapper.i.$enc(h.auditDetails, 'auditDetails') != null) 'auditDetails': Mapper.i.$enc(h.auditDetails, 'auditDetails'), if (Mapper.i.$enc(h.isDeleted, 'isDeleted') != null) 'isDeleted': Mapper.i.$enc(h.isDeleted, 'isDeleted')}; + Map toMap(HouseholdModel h) => {if (Mapper.i.$enc(h.additionalFields, 'additionalFields') != null) 'additionalFields': Mapper.i.$enc(h.additionalFields, 'additionalFields'), if (Mapper.i.$enc(h.id, 'id') != null) 'id': Mapper.i.$enc(h.id, 'id'), if (Mapper.i.$enc(h.memberCount, 'memberCount') != null) 'memberCount': Mapper.i.$enc(h.memberCount, 'memberCount'), if (Mapper.i.$enc(h.latitude, 'latitude') != null) 'latitude': Mapper.i.$enc(h.latitude, 'latitude'), if (Mapper.i.$enc(h.longitude, 'longitude') != null) 'longitude': Mapper.i.$enc(h.longitude, 'longitude'), 'clientReferenceId': Mapper.i.$enc(h.clientReferenceId, 'clientReferenceId'), if (Mapper.i.$enc(h.tenantId, 'tenantId') != null) 'tenantId': Mapper.i.$enc(h.tenantId, 'tenantId'), if (Mapper.i.$enc(h.rowVersion, 'rowVersion') != null) 'rowVersion': Mapper.i.$enc(h.rowVersion, 'rowVersion'), if (Mapper.i.$enc(h.address, 'address') != null) 'address': Mapper.i.$enc(h.address, 'address'), if (Mapper.i.$enc(h.auditDetails, 'auditDetails') != null) 'auditDetails': Mapper.i.$enc(h.auditDetails, 'auditDetails'), if (Mapper.i.$enc(h.isDeleted, 'isDeleted') != null) 'isDeleted': Mapper.i.$enc(h.isDeleted, 'isDeleted')}; - @override String stringify(HouseholdModel self) => 'HouseholdModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, maxRadius: ${Mapper.asString(self.maxRadius)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)}, rowVersion: ${Mapper.asString(self.rowVersion)}, address: ${Mapper.asString(self.address)}, additionalFields: ${Mapper.asString(self.additionalFields)})'; - @override int hash(HouseholdModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.maxRadius) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId) ^ Mapper.hash(self.rowVersion) ^ Mapper.hash(self.address) ^ Mapper.hash(self.additionalFields); - @override bool equals(HouseholdModel self, HouseholdModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.maxRadius, other.maxRadius) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId) && Mapper.isEqual(self.rowVersion, other.rowVersion) && Mapper.isEqual(self.address, other.address) && Mapper.isEqual(self.additionalFields, other.additionalFields); + @override String stringify(HouseholdModel self) => 'HouseholdModel(boundaryCode: ${Mapper.asString(self.boundaryCode)}, isDeleted: ${Mapper.asString(self.isDeleted)}, auditDetails: ${Mapper.asString(self.auditDetails)}, id: ${Mapper.asString(self.id)}, memberCount: ${Mapper.asString(self.memberCount)}, latitude: ${Mapper.asString(self.latitude)}, longitude: ${Mapper.asString(self.longitude)}, clientReferenceId: ${Mapper.asString(self.clientReferenceId)}, tenantId: ${Mapper.asString(self.tenantId)}, rowVersion: ${Mapper.asString(self.rowVersion)}, address: ${Mapper.asString(self.address)}, additionalFields: ${Mapper.asString(self.additionalFields)})'; + @override int hash(HouseholdModel self) => Mapper.hash(self.boundaryCode) ^ Mapper.hash(self.isDeleted) ^ Mapper.hash(self.auditDetails) ^ Mapper.hash(self.id) ^ Mapper.hash(self.memberCount) ^ Mapper.hash(self.latitude) ^ Mapper.hash(self.longitude) ^ Mapper.hash(self.clientReferenceId) ^ Mapper.hash(self.tenantId) ^ Mapper.hash(self.rowVersion) ^ Mapper.hash(self.address) ^ Mapper.hash(self.additionalFields); + @override bool equals(HouseholdModel self, HouseholdModel other) => Mapper.isEqual(self.boundaryCode, other.boundaryCode) && Mapper.isEqual(self.isDeleted, other.isDeleted) && Mapper.isEqual(self.auditDetails, other.auditDetails) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.memberCount, other.memberCount) && Mapper.isEqual(self.latitude, other.latitude) && Mapper.isEqual(self.longitude, other.longitude) && Mapper.isEqual(self.clientReferenceId, other.clientReferenceId) && Mapper.isEqual(self.tenantId, other.tenantId) && Mapper.isEqual(self.rowVersion, other.rowVersion) && Mapper.isEqual(self.address, other.address) && Mapper.isEqual(self.additionalFields, other.additionalFields); @override Function get typeFactory => (f) => f(); } @@ -1046,7 +1046,7 @@ abstract class HouseholdModelCopyWith<$R> { HouseholdAdditionalFieldsCopyWith<$R>? get additionalFields; AddressModelCopyWith<$R>? get address; AuditDetailsCopyWith<$R>? get auditDetails; - $R call({HouseholdAdditionalFields? additionalFields, String? id, int? memberCount, double? latitude, double? longitude, double? maxRadius, String? clientReferenceId, String? tenantId, int? rowVersion, AddressModel? address, AuditDetails? auditDetails, bool? isDeleted}); + $R call({HouseholdAdditionalFields? additionalFields, String? id, int? memberCount, double? latitude, double? longitude, String? clientReferenceId, String? tenantId, int? rowVersion, AddressModel? address, AuditDetails? auditDetails, bool? isDeleted}); $R apply(HouseholdModel Function(HouseholdModel) transform); } @@ -1056,7 +1056,7 @@ class _HouseholdModelCopyWithImpl<$R> extends BaseCopyWith i @override HouseholdAdditionalFieldsCopyWith<$R>? get additionalFields => $value.additionalFields != null ? HouseholdAdditionalFieldsCopyWith($value.additionalFields!, (v) => call(additionalFields: v)) : null; @override AddressModelCopyWith<$R>? get address => $value.address != null ? AddressModelCopyWith($value.address!, (v) => call(address: v)) : null; @override AuditDetailsCopyWith<$R>? get auditDetails => $value.auditDetails != null ? AuditDetailsCopyWith($value.auditDetails!, (v) => call(auditDetails: v)) : null; - @override $R call({Object? additionalFields = $none, Object? id = $none, Object? memberCount = $none, Object? latitude = $none, Object? longitude = $none, Object? maxRadius = $none, String? clientReferenceId, Object? tenantId = $none, Object? rowVersion = $none, Object? address = $none, Object? auditDetails = $none, Object? isDeleted = $none}) => $then(HouseholdModel(additionalFields: or(additionalFields, $value.additionalFields), id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), maxRadius: or(maxRadius, $value.maxRadius), clientReferenceId: clientReferenceId ?? $value.clientReferenceId, tenantId: or(tenantId, $value.tenantId), rowVersion: or(rowVersion, $value.rowVersion), address: or(address, $value.address), auditDetails: or(auditDetails, $value.auditDetails), isDeleted: or(isDeleted, $value.isDeleted))); + @override $R call({Object? additionalFields = $none, Object? id = $none, Object? memberCount = $none, Object? latitude = $none, Object? longitude = $none, String? clientReferenceId, Object? tenantId = $none, Object? rowVersion = $none, Object? address = $none, Object? auditDetails = $none, Object? isDeleted = $none}) => $then(HouseholdModel(additionalFields: or(additionalFields, $value.additionalFields), id: or(id, $value.id), memberCount: or(memberCount, $value.memberCount), latitude: or(latitude, $value.latitude), longitude: or(longitude, $value.longitude), clientReferenceId: clientReferenceId ?? $value.clientReferenceId, tenantId: or(tenantId, $value.tenantId), rowVersion: or(rowVersion, $value.rowVersion), address: or(address, $value.address), auditDetails: or(auditDetails, $value.auditDetails), isDeleted: or(isDeleted, $value.isDeleted))); } class HouseholdAdditionalFieldsMapper extends BaseMapper { diff --git a/apps/health_campaign_field_worker_app/lib/models/entities/address.dart b/apps/health_campaign_field_worker_app/lib/models/entities/address.dart index ce0fa8b01..eeeb77eb3 100644 --- a/apps/health_campaign_field_worker_app/lib/models/entities/address.dart +++ b/apps/health_campaign_field_worker_app/lib/models/entities/address.dart @@ -8,10 +8,16 @@ import '../../data/local_store/sql_store/sql_store.dart'; @MappableClass(ignoreNull: true) class AddressSearchModel extends EntitySearchModel { final String? id; + final double? latitude; + final double? longitude; + final double? maxRadius; final String? tenantId; AddressSearchModel({ this.id, + this.latitude, + this.longitude, + this.maxRadius, this.tenantId, super.boundaryCode, super.isDeleted, @@ -20,6 +26,9 @@ class AddressSearchModel extends EntitySearchModel { @MappableConstructor() AddressSearchModel.ignoreDeleted({ this.id, + this.latitude, + this.longitude, + this.maxRadius, this.tenantId, super.boundaryCode, }): super(isDeleted: false); diff --git a/apps/health_campaign_field_worker_app/lib/models/entities/household.dart b/apps/health_campaign_field_worker_app/lib/models/entities/household.dart index 3664b4e20..e78d1a352 100644 --- a/apps/health_campaign_field_worker_app/lib/models/entities/household.dart +++ b/apps/health_campaign_field_worker_app/lib/models/entities/household.dart @@ -12,6 +12,7 @@ class HouseholdSearchModel extends EntitySearchModel { final double? latitude; final double? longitude; final double? maxRadius; + final bool? isProximityEnabled; final List? clientReferenceId; final String? tenantId; @@ -21,6 +22,7 @@ class HouseholdSearchModel extends EntitySearchModel { this.latitude, this.longitude, this.maxRadius, + this.isProximityEnabled, this.clientReferenceId, this.tenantId, super.boundaryCode, @@ -34,6 +36,7 @@ class HouseholdSearchModel extends EntitySearchModel { this.latitude, this.longitude, this.maxRadius, + this.isProximityEnabled, this.clientReferenceId, this.tenantId, super.boundaryCode, @@ -49,7 +52,6 @@ class HouseholdModel extends EntityModel { final int? memberCount; final double? latitude; final double? longitude; - final double? maxRadius; final String clientReferenceId; final String? tenantId; final int? rowVersion; @@ -62,7 +64,6 @@ class HouseholdModel extends EntityModel { this.memberCount, this.latitude, this.longitude, - this.maxRadius, required this.clientReferenceId, this.tenantId, this.rowVersion, @@ -83,7 +84,6 @@ class HouseholdModel extends EntityModel { memberCount: Value(memberCount), latitude: Value(latitude), longitude: Value(longitude), - maxRadius: Value(maxRadius), clientReferenceId: Value(clientReferenceId), tenantId: Value(tenantId), rowVersion: Value(rowVersion), diff --git a/apps/health_campaign_field_worker_app/lib/models/model_configs/address.json b/apps/health_campaign_field_worker_app/lib/models/model_configs/address.json index b737004ce..bb8917d60 100644 --- a/apps/health_campaign_field_worker_app/lib/models/model_configs/address.json +++ b/apps/health_campaign_field_worker_app/lib/models/model_configs/address.json @@ -21,17 +21,27 @@ "includeForEntity": false, "includeForTable": false }, + { "name": "doorNo", "type": "String" }, { "name": "latitude", - "type": "double" + "type": "double", + "includeForQuery": true }, { "name": "longitude", - "type": "double" + "type": "double", + "includeForQuery": true + }, + { + "name": "maxRadius", + "type": "double", + "includeForQuery": true, + "includeForEntity": false, + "includeForTable": false }, { "name": "locationAccuracy", diff --git a/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json b/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json index 47dee9c98..2c2460b3c 100644 --- a/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json +++ b/apps/health_campaign_field_worker_app/lib/models/model_configs/household.json @@ -26,7 +26,16 @@ { "name": "maxRadius", "type": "double", - "includeForQuery": true + "includeForQuery": true, + "includeForEntity": false, + "includeForTable": false + }, + { + "name": "isProximityEnabled", + "type": "bool", + "includeForQuery": true, + "includeForEntity": false, + "includeForTable": false } ], "customAttributes": [ diff --git a/apps/health_campaign_field_worker_app/lib/pages/authenticated.dart b/apps/health_campaign_field_worker_app/lib/pages/authenticated.dart index 787e87bb1..784ebebe1 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/authenticated.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/authenticated.dart @@ -11,6 +11,9 @@ import '../blocs/localization/app_localization.dart'; import '../blocs/search_households/search_households.dart'; import '../blocs/sync/sync.dart'; import '../data/local_store/no_sql/schema/oplog.dart'; +import '../data/local_store/sql_store/sql_store.dart'; +import '../data/repositories/local/address.dart'; +import '../data/repositories/oplog/oplog.dart'; import '../models/data_model.dart'; import '../router/app_router.dart'; import '../router/authenticated_route_observer.dart'; @@ -69,10 +72,16 @@ class AuthenticatedPageWrapper extends StatelessWidget { providers: [ BlocProvider( create: (context) { + final isar = context.read(); + return SearchHouseholdsBloc( beneficiaryType: context.beneficiaryType, userUid: context.loggedInUserUuid, projectId: context.projectId, + addressRepository: AddressLocalRepository( + context.read(), + AddressOpLogManager(isar), + ), projectBeneficiary: context.repository< ProjectBeneficiaryModel, ProjectBeneficiarySearchModel>(), diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/household_location.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/household_location.dart index 2469da106..382ca417b 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/household_location.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/household_location.dart @@ -74,97 +74,105 @@ class _HouseholdLocationPageState height: 85, child: DigitCard( margin: const EdgeInsets.only(left: 0, right: 0, top: 10), - child: DigitElevatedButton( - onPressed: () { - form.markAllAsTouched(); - if (!form.valid) return; + child: BlocBuilder( + builder: (context, locationState) { + return DigitElevatedButton( + onPressed: () { + form.markAllAsTouched(); + if (!form.valid) return; - final addressLine1 = - form.control(_addressLine1Key).value as String?; - final addressLine2 = - form.control(_addressLine2Key).value as String?; - final landmark = - form.control(_landmarkKey).value as String?; - final postalCode = - form.control(_postalCodeKey).value as String?; + final addressLine1 = + form.control(_addressLine1Key).value as String?; + final addressLine2 = + form.control(_addressLine2Key).value as String?; + final landmark = + form.control(_landmarkKey).value as String?; + final postalCode = + form.control(_postalCodeKey).value as String?; - registrationState.maybeWhen( - orElse: () { - return; - }, - create: ( - address, - householdModel, - individualModel, - registrationDate, - searchQuery, - loading, - isHeadOfHousehold, - ) { - var addressModel = AddressModel( - addressLine1: addressLine1, - addressLine2: addressLine2, - landmark: landmark, - pincode: postalCode, - type: AddressType.correspondence, - latitude: form.control(_latKey).value, - longitude: form.control(_lngKey).value, - locationAccuracy: - form.control(_accuracyKey).value, - locality: LocalityModel( - code: context.boundary.code!, - name: context.boundary.name, - ), - tenantId: envConfig.variables.tenantId, - rowVersion: 1, - auditDetails: AuditDetails( - createdBy: context.loggedInUserUuid, - createdTime: context.millisecondsSinceEpoch(), - ), - ); + registrationState.maybeWhen( + orElse: () { + return; + }, + create: ( + address, + householdModel, + individualModel, + registrationDate, + searchQuery, + loading, + isHeadOfHousehold, + ) { + var addressModel = AddressModel( + addressLine1: addressLine1, + addressLine2: addressLine2, + landmark: landmark, + pincode: postalCode, + type: AddressType.correspondence, + latitude: form.control(_latKey).value ?? + locationState.latitude, + longitude: form.control(_lngKey).value ?? + locationState.longitude, + locationAccuracy: + form.control(_accuracyKey).value ?? + locationState.accuracy, + locality: LocalityModel( + code: context.boundary.code!, + name: context.boundary.name, + ), + tenantId: envConfig.variables.tenantId, + rowVersion: 1, + auditDetails: AuditDetails( + createdBy: context.loggedInUserUuid, + createdTime: + context.millisecondsSinceEpoch(), + ), + ); - bloc.add( - BeneficiaryRegistrationSaveAddressEvent( - addressModel, - ), - ); - router.push(HouseHoldDetailsRoute()); - }, - editHousehold: ( - address, - householdModel, - individuals, - registrationDate, - loading, - ) { - var addressModel = address.copyWith( - addressLine1: addressLine1, - addressLine2: addressLine2, - landmark: landmark, - locality: address.locality, - pincode: postalCode, - type: AddressType.correspondence, - latitude: form.control(_latKey).value, - longitude: form.control(_lngKey).value, - locationAccuracy: - form.control(_accuracyKey).value, - ); + bloc.add( + BeneficiaryRegistrationSaveAddressEvent( + addressModel, + ), + ); + router.push(HouseHoldDetailsRoute()); + }, + editHousehold: ( + address, + householdModel, + individuals, + registrationDate, + loading, + ) { + var addressModel = address.copyWith( + addressLine1: addressLine1, + addressLine2: addressLine2, + landmark: landmark, + locality: address.locality, + pincode: postalCode, + type: AddressType.correspondence, + latitude: form.control(_latKey).value, + longitude: form.control(_lngKey).value, + locationAccuracy: + form.control(_accuracyKey).value, + ); - bloc.add( - BeneficiaryRegistrationSaveAddressEvent( - addressModel, - ), + bloc.add( + BeneficiaryRegistrationSaveAddressEvent( + addressModel, + ), + ); + router.push(HouseHoldDetailsRoute()); + }, ); - router.push(HouseHoldDetailsRoute()); }, + child: Center( + child: Text( + localizations + .translate(i18.householdLocation.actionLabel), + ), + ), ); }, - child: Center( - child: Text( - localizations - .translate(i18.householdLocation.actionLabel), - ), - ), ), ), ), diff --git a/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/individual_details.dart b/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/individual_details.dart index b1a070a0e..4309bc513 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/individual_details.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/beneficiary_registration/individual_details.dart @@ -63,6 +63,7 @@ class _IndividualDetailsPageState SearchHouseholdsByHouseholdsEvent( householdModel: value.householdModel, projectId: context.projectId, + isProximityEnabled: false, ), ); router.push(AcknowledgementRoute()); 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 a6f2acfb5..67531fd4b 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 @@ -4,6 +4,7 @@ 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'; import '../blocs/search_households/search_households.dart'; import '../models/beneficiary_statistics/beneficiary_statistics_model.dart'; @@ -28,163 +29,207 @@ class SearchBeneficiaryPage extends LocalizedStatefulWidget { class _SearchBeneficiaryPageState extends LocalizedState { final TextEditingController searchController = TextEditingController(); + bool isProximityEnabled = false; @override Widget build(BuildContext context) { final theme = Theme.of(context); return KeyboardVisibilityBuilder( - builder: (context, isKeyboardVisible) => Scaffold( - body: BlocBuilder( - builder: (context, searchState) { - return ScrollableContent( - header: const Column(children: [ - BackNavigationHelpHeaderWidget(), - ]), - slivers: [ - SliverToBoxAdapter( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(8), - child: Align( - alignment: Alignment.topLeft, - child: Text( - localizations.translate( - i18.searchBeneficiary.statisticsLabelText, + builder: (context, isKeyboardVisible) => + BlocBuilder( + builder: (appcontext, state) { + if (state is! AppInitialized) return const Offstage(); + + final appConfig = state.appConfiguration; + + return Scaffold( + body: BlocBuilder( + builder: (context, searchState) { + return ScrollableContent( + header: const Column(children: [ + BackNavigationHelpHeaderWidget(), + ]), + slivers: [ + SliverToBoxAdapter( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8), + child: Align( + alignment: Alignment.topLeft, + child: Text( + localizations.translate( + i18.searchBeneficiary.statisticsLabelText, + ), + style: theme.textTheme.displayMedium, + textAlign: TextAlign.center, + ), ), - style: theme.textTheme.displayMedium, - textAlign: TextAlign.center, ), - ), - ), - BeneficiaryStatisticsCard( - beneficiaryStatistics: - BeneficiaryStatisticsWrapperModel( - beneficiaryStatisticsList: [ - BeneficiaryStatisticsModel( - title: - searchState.registeredHouseholds.toString(), - content: localizations.translate( - '${context.beneficiaryType.name.toUpperCase()}_${i18.searchBeneficiary.noOfHouseholdsRegistered}', - ), + BeneficiaryStatisticsCard( + beneficiaryStatistics: + BeneficiaryStatisticsWrapperModel( + beneficiaryStatisticsList: [ + BeneficiaryStatisticsModel( + title: searchState.registeredHouseholds + .toString(), + content: localizations.translate( + '${context.beneficiaryType.name.toUpperCase()}_${i18.searchBeneficiary.noOfHouseholdsRegistered}', + ), + ), + BeneficiaryStatisticsModel( + title: searchState.deliveredInterventions + .toString(), + content: localizations.translate( + '${context.beneficiaryType.name.toUpperCase()}_${i18.searchBeneficiary.noOfResourcesDelivered}', + ), + ), + ], ), - BeneficiaryStatisticsModel( - title: - searchState.deliveredInterventions.toString(), - content: localizations.translate( - '${context.beneficiaryType.name.toUpperCase()}_${i18.searchBeneficiary.noOfResourcesDelivered}', + ), + BlocBuilder( + builder: (context, locationState) { + return Column( + children: [ + DigitSearchBar( + controller: searchController, + hintText: localizations.translate( + i18.searchBeneficiary + .beneficiarySearchHintText, + ), + textCapitalization: + TextCapitalization.words, + onChanged: (value) { + final bloc = + context.read(); + if (value.trim().length < 2) { + bloc.add( + const SearchHouseholdsClearEvent(), + ); + + return; + } + + bloc.add( + SearchHouseholdsSearchByHouseholdHeadEvent( + searchText: value.trim(), + projectId: context.projectId, + latitude: locationState.latitude, + longitude: locationState.longitude, + isProximityEnabled: + isProximityEnabled, + maxRadius: appConfig.maxRadius, + ), + ); + }, + ), + Row( + children: [ + Switch( + value: isProximityEnabled, + onChanged: (value) { + setState(() { + isProximityEnabled = value; + }); + if (locationState.hasPermissions && + value && + locationState.latitude != null && + locationState.longitude != null && + appConfig.maxRadius != null) { + final bloc = context + .read(); + bloc.add(SearchHouseholdsEvent + .searchByProximity( + latitude: locationState.latitude!, + longititude: + locationState.longitude!, + projectId: context.projectId, + maxRadius: appConfig.maxRadius!, + )); + } + }, + ), + Text( + localizations.translate( + i18.searchBeneficiary.proximityLabel, + ), + ), + ], + ), + ], + ); + }, + ), + const SizedBox(height: 16), + if (searchState.resultsNotFound) + DigitInfoCard( + description: localizations.translate( + i18.searchBeneficiary + .beneficiaryInfoDescription, + ), + title: localizations.translate( + i18.searchBeneficiary.beneficiaryInfoTitle, ), ), - ], + ], + ), + ), + if (searchState.loading) + const SliverFillRemaining( + child: Center( + child: CircularProgressIndicator(), ), ), - BlocBuilder( - builder: (context, locationState) { - return Column( - children: [ - Text( - locationState.latitude.toString(), - ), - Text( - locationState.longitude.toString(), - ), - DigitSearchBar( - controller: searchController, - hintText: localizations.translate( - i18.searchBeneficiary - .beneficiarySearchHintText, + SliverList( + delegate: SliverChildBuilderDelegate( + (ctx, index) { + final i = + searchState.householdMembers.elementAt(index); + + return ViewBeneficiaryCard( + householdMember: i, + onOpenPressed: () async { + final bloc = context.read(); + final projectId = context.projectId; + + await context.router.push( + BeneficiaryWrapperRoute( + wrapper: i, ), - textCapitalization: TextCapitalization.words, - onChanged: (value) { - final bloc = - context.read(); - if (value.trim().length < 2) { - bloc.add( - const SearchHouseholdsClearEvent()); - - return; - } - - bloc.add( - SearchHouseholdsSearchByHouseholdHeadEvent( - searchText: value.trim(), - projectId: context.projectId, - latitude: locationState.latitude, - longitude: locationState.longitude, - ), - ); - }, - ), - ], + ); + + bloc.add( + SearchHouseholdsSearchByHouseholdHeadEvent( + searchText: searchController.text, + projectId: projectId, + isProximityEnabled: isProximityEnabled, + ), + ); + }, ); }, + childCount: searchState.householdMembers.length, ), - const SizedBox(height: 16), - if (searchState.resultsNotFound) - DigitInfoCard( - description: localizations.translate( - i18.searchBeneficiary.beneficiaryInfoDescription, - ), - title: localizations.translate( - i18.searchBeneficiary.beneficiaryInfoTitle, - ), - ), - ], - ), - ), - if (searchState.loading) - const SliverFillRemaining( - child: Center( - child: CircularProgressIndicator(), ), - ), - SliverList( - delegate: SliverChildBuilderDelegate( - (ctx, index) { - final i = searchState.householdMembers.elementAt(index); - - return ViewBeneficiaryCard( - householdMember: i, - onOpenPressed: () async { - final bloc = context.read(); - final projectId = context.projectId; - - await context.router.push( - BeneficiaryWrapperRoute( - wrapper: i, - ), - ); + ], + ); + }, + ), + bottomNavigationBar: SizedBox( + height: 85, + child: DigitCard( + margin: const EdgeInsets.only(left: 0, right: 0, top: 10), + child: BlocBuilder( + builder: (context, state) { + final router = context.router; - bloc.add( - SearchHouseholdsSearchByHouseholdHeadEvent( - searchText: searchController.text, - projectId: projectId, - ), - ); - }, - ); - }, - childCount: searchState.householdMembers.length, - ), - ), - ], - ); - }, - ), - bottomNavigationBar: SizedBox( - height: 85, - child: DigitCard( - margin: const EdgeInsets.only(left: 0, right: 0, top: 10), - child: BlocBuilder( - builder: (context, state) { - final router = context.router; - - final searchQuery = state.searchQuery; - VoidCallback? onPressed; - - onPressed = - state.loading || searchQuery == null || searchQuery.isEmpty + final searchQuery = state.searchQuery; + VoidCallback? onPressed; + + onPressed = state.loading || + searchQuery == null || + searchQuery.isEmpty ? null : () { FocusManager.instance.primaryFocus?.unfocus(); @@ -196,18 +241,20 @@ class _SearchBeneficiaryPageState )); }; - return DigitElevatedButton( - onPressed: onPressed, - child: Center( - child: Text(localizations.translate( - i18.searchBeneficiary.beneficiaryAddActionLabel, - )), - ), - ); - }, + return DigitElevatedButton( + onPressed: onPressed, + child: Center( + child: Text(localizations.translate( + i18.searchBeneficiary.beneficiaryAddActionLabel, + )), + ), + ); + }, + ), + ), ), - ), - ), + ); + }, ), ); } diff --git a/apps/health_campaign_field_worker_app/lib/utils/constants.dart b/apps/health_campaign_field_worker_app/lib/utils/constants.dart index 01450deac..b88b6518b 100644 --- a/apps/health_campaign_field_worker_app/lib/utils/constants.dart +++ b/apps/health_campaign_field_worker_app/lib/utils/constants.dart @@ -11,6 +11,7 @@ import '../data/local_store/no_sql/schema/localization.dart'; import '../data/local_store/no_sql/schema/oplog.dart'; import '../data/local_store/no_sql/schema/service_registry.dart'; import '../data/local_store/sql_store/sql_store.dart'; +import '../data/repositories/local/address.dart'; import '../data/repositories/local/boundary.dart'; import '../data/repositories/local/facility.dart'; import '../data/repositories/local/household.dart'; 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 a2ee3a7c2..5b6320eae 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 @@ -179,8 +179,12 @@ class SearchBeneficiary { String get beneficiaryAddActionLabel => 'BENEFICIARY_ADD_ACTION_LABEL'; String get iconLabel => 'ICON_LABEL'; + String get yearsAbbr => 'YEARS_ABBR'; + String get monthsAbbr => 'MONTHS_ABBR'; + + String get proximityLabel => 'PROXIMITY_LABEL'; } class IndividualDetails { diff --git a/apps/health_campaign_field_worker_app/lib/utils/typedefs.dart b/apps/health_campaign_field_worker_app/lib/utils/typedefs.dart index a049626cd..ca7afb02e 100644 --- a/apps/health_campaign_field_worker_app/lib/utils/typedefs.dart +++ b/apps/health_campaign_field_worker_app/lib/utils/typedefs.dart @@ -4,6 +4,8 @@ import '../models/entities/user.dart'; typedef FacilityDataRepository = DataRepository; +typedef AddressDataRepository + = DataRepository; typedef HouseholdDataRepository = DataRepository; typedef HouseholdMemberDataRepository diff --git a/apps/health_campaign_field_worker_app/lib/widgets/network_manager_provider_wrapper.dart b/apps/health_campaign_field_worker_app/lib/widgets/network_manager_provider_wrapper.dart index 94c74991d..b29ee2acd 100644 --- a/apps/health_campaign_field_worker_app/lib/widgets/network_manager_provider_wrapper.dart +++ b/apps/health_campaign_field_worker_app/lib/widgets/network_manager_provider_wrapper.dart @@ -8,6 +8,7 @@ import '../blocs/app_initialization/app_initialization.dart'; import '../data/data_repository.dart'; import '../data/local_store/sql_store/sql_store.dart'; import '../data/network_manager.dart'; +import '../data/repositories/local/address.dart'; import '../data/repositories/local/boundary.dart'; import '../data/repositories/local/facility.dart'; import '../data/repositories/local/household.dart'; diff --git a/apps/health_campaign_field_worker_app/pubspec.lock b/apps/health_campaign_field_worker_app/pubspec.lock index 65bacd5ab..ec055b924 100644 --- a/apps/health_campaign_field_worker_app/pubspec.lock +++ b/apps/health_campaign_field_worker_app/pubspec.lock @@ -1126,10 +1126,10 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.5" pluto_grid: dependency: "direct main" description: diff --git a/apps/health_campaign_field_worker_app/pubspec.yaml b/apps/health_campaign_field_worker_app/pubspec.yaml index c06579c12..700f0622f 100644 --- a/apps/health_campaign_field_worker_app/pubspec.yaml +++ b/apps/health_campaign_field_worker_app/pubspec.yaml @@ -46,6 +46,7 @@ dependencies: url_launcher: ^6.1.10 connectivity_plus: ^4.0.1 material_design_icons_flutter: ^6.0.7096 + shared_preferences: ^2.1.0 pretty_dio_logger: ^1.2.0-beta-1 pluto_grid: ^7.0.1 From c36c860a8d649ce4cc0d9806394d943c52930b08 Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 7 Aug 2023 15:41:46 +0530 Subject: [PATCH 06/17] modified the query --- .../lib/data/repositories/local/address.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart index 89dbdbdd5..5fc1d2c72 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart @@ -42,6 +42,11 @@ class AddressLocalRepository { + sin(${query.latitude! * math.pi / 180.0}) * sin((address.latitude * ${math.pi / 180.0})) )) <= ${query.maxRadius!} '''), + if (query.latitude != null && + query.longitude != null && + query.maxRadius != null) + sql.address.longitude.isNotNull(), + sql.address.latitude.isNotNull(), ]))); final results = await selectQuery.get(); From c8a1c4e891e2840503e999739de369100e2eee2d Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 8 Aug 2023 10:07:01 +0530 Subject: [PATCH 07/17] modfied the query --- .../lib/data/repositories/local/address.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart b/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart index 5fc1d2c72..4f053fa0c 100644 --- a/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart +++ b/apps/health_campaign_field_worker_app/lib/data/repositories/local/address.dart @@ -102,6 +102,5 @@ class AddressLocalRepository { }) .where((element) => element.isDeleted != true) .toList(); - return []; } } From d9d06dad6b0fdbdab3df68c71ee5b3a1827b20f2 Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 21 Aug 2023 12:24:28 +0530 Subject: [PATCH 08/17] added clearing the search bar when proximity search is triggered --- .../lib/pages/search_beneficiary.dart | 1 + 1 file changed, 1 insertion(+) 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 dc4ffbb0e..805291b94 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 @@ -129,6 +129,7 @@ class _SearchBeneficiaryPageState Switch( value: isProximityEnabled, onChanged: (value) { + searchController.clear(); setState(() { isProximityEnabled = value; }); From 3b186c156af750bb422194496322d208e10033f8 Mon Sep 17 00:00:00 2001 From: Naveen Date: Mon, 21 Aug 2023 17:50:13 +0530 Subject: [PATCH 09/17] added filters --- .../search_households/search_households.dart | 1 + .../lib/pages/search_beneficiary.dart | 78 +++++++++++-------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 6665f4ef4..841103377 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -201,6 +201,7 @@ class SearchHouseholdsBloc SearchHouseholdsByProximityEvent event, SearchHouseholdsEmitter emit, ) async { + print("_handleSearchByProximitity"); emit(state.copyWith(loading: true)); final results = await addressRepository.searchHouseHoldbyAddress(AddressSearchModel( 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 805291b94..592fbfb9d 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 @@ -124,41 +124,51 @@ class _SearchBeneficiaryPageState ); }, ), - Row( - children: [ - Switch( - value: isProximityEnabled, - onChanged: (value) { - searchController.clear(); - setState(() { - isProximityEnabled = value; - }); + locationState.latitude != null + ? Row( + children: [ + Switch( + value: isProximityEnabled, + onChanged: (value) { + searchController.clear(); + setState(() { + isProximityEnabled = value; + }); - if (locationState.hasPermissions && - value && - locationState.latitude != null && - locationState.longitude != null && - appConfig.maxRadius != null) { - final bloc = context - .read(); - bloc.add(SearchHouseholdsEvent - .searchByProximity( - latitude: locationState.latitude!, - longititude: - locationState.longitude!, - projectId: context.projectId, - maxRadius: appConfig.maxRadius!, - )); - } - }, - ), - Text( - localizations.translate( - i18.searchBeneficiary.proximityLabel, - ), - ), - ], - ), + if (locationState + .hasPermissions && + value && + locationState.latitude != + null && + locationState.longitude != + null && + appConfig.maxRadius != + null) { + final bloc = context.read< + SearchHouseholdsBloc>(); + bloc.add(SearchHouseholdsEvent + .searchByProximity( + latitude: + locationState.latitude!, + longititude: locationState + .longitude!, + projectId: + context.projectId, + maxRadius: + appConfig.maxRadius!, + )); + } + }, + ), + Text( + localizations.translate( + i18.searchBeneficiary + .proximityLabel, + ), + ), + ], + ) + : const Offstage(), ], ); }, From 9b758a1d1d61cd4c0031493d3f90f1035e36b5a6 Mon Sep 17 00:00:00 2001 From: Naveen J <83631045+naveen-egov@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:16:10 +0530 Subject: [PATCH 10/17] Update dart.yml (#200) --- .github/workflows/dart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 9337398e9..abc4d00ad 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + - uses: dart-lang/setup-dart@v1 - name: Flutter action uses: subosito/flutter-action@v2.8.0 From 9b2992536bc9e66c1a003498401a980dc89d449c Mon Sep 17 00:00:00 2001 From: Naveen J <83631045+naveen-egov@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:24:48 +0530 Subject: [PATCH 11/17] Update dart.yml --- .github/workflows/dart.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index abc4d00ad..ddc70adc3 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -18,6 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1 + - run: dart pub get - name: Flutter action uses: subosito/flutter-action@v2.8.0 From 84e1e3bb420fff160caf6f1dac4d3242e5fab3a5 Mon Sep 17 00:00:00 2001 From: Naveen J <83631045+naveen-egov@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:30:31 +0530 Subject: [PATCH 12/17] Update dart.yml --- .github/workflows/dart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index ddc70adc3..38048decd 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1 - - run: dart pub get + - run: dart pub upgrade - name: Flutter action uses: subosito/flutter-action@v2.8.0 From 87383b38dc975e405eb3840da40d12df1db9dfb0 Mon Sep 17 00:00:00 2001 From: Naveen J <83631045+naveen-egov@users.noreply.github.com> Date: Tue, 22 Aug 2023 09:58:02 +0530 Subject: [PATCH 13/17] Update dart.yml --- .github/workflows/dart.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 38048decd..6635a8331 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -17,8 +17,9 @@ jobs: steps: - uses: actions/checkout@v3 + with: + flutter-version: "3.10.5" - uses: dart-lang/setup-dart@v1 - - run: dart pub upgrade - name: Flutter action uses: subosito/flutter-action@v2.8.0 From ad52060d6162ce05c4914f15cfb4e4dd9373f2af Mon Sep 17 00:00:00 2001 From: Naveen J <83631045+naveen-egov@users.noreply.github.com> Date: Tue, 22 Aug 2023 09:59:07 +0530 Subject: [PATCH 14/17] Update dart.yml --- .github/workflows/dart.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 6635a8331..e6cfae801 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -17,12 +17,13 @@ jobs: steps: - uses: actions/checkout@v3 - with: - flutter-version: "3.10.5" + - uses: dart-lang/setup-dart@v1 - name: Flutter action uses: subosito/flutter-action@v2.8.0 + with: + flutter-version: "3.10.5" - name: Generate models run: ./tools/install_bricks.sh From a22ef1cddcdb14ae132da2e9689b96c01803f0bc Mon Sep 17 00:00:00 2001 From: Anil Singha <99383116+anilsingha-eGov@users.noreply.github.com> Date: Tue, 5 Sep 2023 15:02:12 +0530 Subject: [PATCH 15/17] HLM-3379: Fixed proximity based search --- .../search_households/search_households.dart | 297 ++++++++++++------ .../lib/pages/search_beneficiary.dart | 50 ++- 2 files changed, 245 insertions(+), 102 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 841103377..0ea95629c 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -201,7 +201,6 @@ class SearchHouseholdsBloc SearchHouseholdsByProximityEvent event, SearchHouseholdsEmitter emit, ) async { - print("_handleSearchByProximitity"); emit(state.copyWith(loading: true)); final results = await addressRepository.searchHouseHoldbyAddress(AddressSearchModel( @@ -295,113 +294,235 @@ class SearchHouseholdsBloc searchQuery: event.searchText, )); - final results = await individual.search( - IndividualSearchModel( - name: NameSearchModel(givenName: event.searchText.trim()), - ), - ); + if (event.isProximityEnabled) { + try { + final results = await addressRepository.searchHouseHoldbyAddress( + AddressSearchModel( + latitude: event.latitude, + longitude: event.longitude, + maxRadius: event.maxRadius, + ), + ); + final householdMembers = []; + + for (final element in results) { + final members = await householdMember.search( + HouseholdMemberSearchModel( + householdClientReferenceId: element.clientReferenceId, + ), + ); + + for (final member in members) { + final allHouseholdMembers = await householdMember.search( + HouseholdMemberSearchModel( + householdClientReferenceId: member.householdClientReferenceId, + ), + ); - final householdMembers = []; + householdMembers.addAll(allHouseholdMembers); + } + } - for (final element in results) { - final members = await householdMember.search( - HouseholdMemberSearchModel( - individualClientReferenceId: element.clientReferenceId, - isHeadOfHousehold: true, + final containers = []; + final groupedHouseholds = householdMembers + .groupListsBy((element) => element.householdClientReferenceId); + + for (final entry in groupedHouseholds.entries) { + final householdId = entry.key; + final individualIds = entry.value + .map((element) => element.individualClientReferenceId) + .whereNotNull() + .toList(); + + if (householdId == null) continue; + final households = await household.search( + HouseholdSearchModel( + clientReferenceId: [householdId], + latitude: event.latitude, + longitude: event.longitude, + maxRadius: event.maxRadius, + ), + ); + + if (households.isEmpty) continue; + + final resultHousehold = households.first; + + final individuals = await individual.search( + IndividualSearchModel( + clientReferenceId: individualIds, + name: NameSearchModel(givenName: event.searchText.trim()), + ), + ); + + final head = individuals.firstWhereOrNull( + (element) => + element.clientReferenceId == + entry.value + .firstWhereOrNull( + (element) => element.isHeadOfHousehold, + ) + ?.individualClientReferenceId, + ); + + if (head == null) continue; + + final projectBeneficiaries = + beneficiaryType != BeneficiaryType.individual + ? await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: [ + resultHousehold.clientReferenceId, + ], + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ) + : await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: individualIds, + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ); + + if (projectBeneficiaries.isEmpty) continue; + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + )); + + containers.add( + HouseholdMemberWrapper( + household: resultHousehold, + headOfHousehold: head, + members: individuals, + projectBeneficiaries: projectBeneficiaries, + tasks: tasks.isEmpty ? null : tasks, + ), + ); + } + + emit(state.copyWith( + householdMembers: containers, + loading: false, + )); + } catch (error) { + emit(state.copyWith( + loading: false, + householdMembers: [], + )); + } + } else { + final results = await individual.search( + IndividualSearchModel( + name: NameSearchModel(givenName: event.searchText.trim()), ), ); - for (final member in members) { - final allHouseholdMembers = await householdMember.search( + final householdMembers = []; + + for (final element in results) { + final members = await householdMember.search( HouseholdMemberSearchModel( - householdClientReferenceId: member.householdClientReferenceId, + individualClientReferenceId: element.clientReferenceId, + isHeadOfHousehold: true, ), ); - householdMembers.addAll(allHouseholdMembers); - } - } - - final containers = []; - final groupedHouseholds = householdMembers - .groupListsBy((element) => element.householdClientReferenceId); + for (final member in members) { + final allHouseholdMembers = await householdMember.search( + HouseholdMemberSearchModel( + householdClientReferenceId: member.householdClientReferenceId, + ), + ); - for (final entry in groupedHouseholds.entries) { - final householdId = entry.key; - final individualIds = entry.value - .map((element) => element.individualClientReferenceId) - .whereNotNull() - .toList(); + householdMembers.addAll(allHouseholdMembers); + } + } - if (householdId == null) continue; - final households = await household.search( - HouseholdSearchModel( - clientReferenceId: [householdId], - latitude: event.latitude, - longitude: event.longitude, - maxRadius: event.maxRadius, - ), - ); + final containers = []; + final groupedHouseholds = householdMembers + .groupListsBy((element) => element.householdClientReferenceId); + + for (final entry in groupedHouseholds.entries) { + final householdId = entry.key; + final individualIds = entry.value + .map((element) => element.individualClientReferenceId) + .whereNotNull() + .toList(); + + if (householdId == null) continue; + final households = await household.search( + HouseholdSearchModel( + clientReferenceId: [householdId], + latitude: event.latitude, + longitude: event.longitude, + maxRadius: event.maxRadius, + ), + ); - if (households.isEmpty) continue; + if (households.isEmpty) continue; - final resultHousehold = households.first; + final resultHousehold = households.first; - final individuals = await individual.search( - IndividualSearchModel(clientReferenceId: individualIds), - ); + final individuals = await individual.search( + IndividualSearchModel(clientReferenceId: individualIds), + ); - final head = individuals.firstWhereOrNull( - (element) => - element.clientReferenceId == - entry.value - .firstWhereOrNull( - (element) => element.isHeadOfHousehold, - ) - ?.individualClientReferenceId, - ); + final head = individuals.firstWhereOrNull( + (element) => + element.clientReferenceId == + entry.value + .firstWhereOrNull( + (element) => element.isHeadOfHousehold, + ) + ?.individualClientReferenceId, + ); - if (head == null) continue; + if (head == null) continue; + + final projectBeneficiaries = + beneficiaryType != BeneficiaryType.individual + ? await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: [ + resultHousehold.clientReferenceId, + ], + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ) + : await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: individualIds, + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ); + + if (projectBeneficiaries.isEmpty) continue; + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + )); - final projectBeneficiaries = beneficiaryType != BeneficiaryType.individual - ? await projectBeneficiary.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: [ - resultHousehold.clientReferenceId, - ], - //[TODO] Need to check for beneficiaryId - projectId: event.projectId, - ), - ) - : await projectBeneficiary.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: individualIds, - //[TODO] Need to check for beneficiaryId - projectId: event.projectId, - ), - ); + containers.add( + HouseholdMemberWrapper( + household: resultHousehold, + headOfHousehold: head, + members: individuals, + projectBeneficiaries: projectBeneficiaries, + tasks: tasks.isEmpty ? null : tasks, + ), + ); + } - if (projectBeneficiaries.isEmpty) continue; - final tasks = await taskDataRepository.search(TaskSearchModel( - projectBeneficiaryClientReferenceId: - projectBeneficiaries.map((e) => e.clientReferenceId).toList(), + emit(state.copyWith( + householdMembers: containers, + loading: false, )); - - containers.add( - HouseholdMemberWrapper( - household: resultHousehold, - headOfHousehold: head, - members: individuals, - projectBeneficiaries: projectBeneficiaries, - tasks: tasks.isEmpty ? null : tasks, - ), - ); } - - emit(state.copyWith( - householdMembers: containers, - loading: false, - )); } FutureOr _handleClear( 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 592fbfb9d..7bf236882 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 @@ -103,25 +103,40 @@ class _SearchBeneficiaryPageState onChanged: (value) { final bloc = context.read(); - if (value.trim().length < 2) { + + if (value.trim().length < 2 && + !isProximityEnabled) { bloc.add( const SearchHouseholdsClearEvent(), ); return; + } else { + if (isProximityEnabled && + value.trim().length < 2) { + bloc.add(SearchHouseholdsEvent + .searchByProximity( + latitude: locationState.latitude!, + longititude: + locationState.longitude!, + projectId: context.projectId, + maxRadius: appConfig.maxRadius!, + )); + } else { + bloc.add( + SearchHouseholdsSearchByHouseholdHeadEvent( + searchText: value.trim(), + projectId: context.projectId, + latitude: locationState.latitude, + longitude: + locationState.longitude, + isProximityEnabled: + isProximityEnabled, + maxRadius: appConfig.maxRadius, + ), + ); + } } - - bloc.add( - SearchHouseholdsSearchByHouseholdHeadEvent( - searchText: value.trim(), - projectId: context.projectId, - latitude: locationState.latitude, - longitude: locationState.longitude, - isProximityEnabled: - isProximityEnabled, - maxRadius: appConfig.maxRadius, - ), - ); }, ), locationState.latitude != null @@ -143,7 +158,8 @@ class _SearchBeneficiaryPageState locationState.longitude != null && appConfig.maxRadius != - null) { + null && + isProximityEnabled) { final bloc = context.read< SearchHouseholdsBloc>(); bloc.add(SearchHouseholdsEvent @@ -157,6 +173,12 @@ class _SearchBeneficiaryPageState maxRadius: appConfig.maxRadius!, )); + } else { + final bloc = context.read< + SearchHouseholdsBloc>(); + bloc.add( + const SearchHouseholdsClearEvent(), + ); } }, ), From c8b2ff47db006e8de10ee6df2df59982c49258f3 Mon Sep 17 00:00:00 2001 From: Anil Singha <99383116+anilsingha-eGov@users.noreply.github.com> Date: Tue, 5 Sep 2023 15:20:37 +0530 Subject: [PATCH 16/17] Revert "HLM-3379: Fixed proximity based search" This reverts commit a22ef1cddcdb14ae132da2e9689b96c01803f0bc. --- .../search_households/search_households.dart | 297 ++++++------------ .../lib/pages/search_beneficiary.dart | 50 +-- 2 files changed, 102 insertions(+), 245 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 0ea95629c..841103377 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -201,6 +201,7 @@ class SearchHouseholdsBloc SearchHouseholdsByProximityEvent event, SearchHouseholdsEmitter emit, ) async { + print("_handleSearchByProximitity"); emit(state.copyWith(loading: true)); final results = await addressRepository.searchHouseHoldbyAddress(AddressSearchModel( @@ -294,235 +295,113 @@ class SearchHouseholdsBloc searchQuery: event.searchText, )); - if (event.isProximityEnabled) { - try { - final results = await addressRepository.searchHouseHoldbyAddress( - AddressSearchModel( - latitude: event.latitude, - longitude: event.longitude, - maxRadius: event.maxRadius, - ), - ); - final householdMembers = []; - - for (final element in results) { - final members = await householdMember.search( - HouseholdMemberSearchModel( - householdClientReferenceId: element.clientReferenceId, - ), - ); - - for (final member in members) { - final allHouseholdMembers = await householdMember.search( - HouseholdMemberSearchModel( - householdClientReferenceId: member.householdClientReferenceId, - ), - ); - - householdMembers.addAll(allHouseholdMembers); - } - } + final results = await individual.search( + IndividualSearchModel( + name: NameSearchModel(givenName: event.searchText.trim()), + ), + ); - final containers = []; - final groupedHouseholds = householdMembers - .groupListsBy((element) => element.householdClientReferenceId); + final householdMembers = []; - for (final entry in groupedHouseholds.entries) { - final householdId = entry.key; - final individualIds = entry.value - .map((element) => element.individualClientReferenceId) - .whereNotNull() - .toList(); - - if (householdId == null) continue; - final households = await household.search( - HouseholdSearchModel( - clientReferenceId: [householdId], - latitude: event.latitude, - longitude: event.longitude, - maxRadius: event.maxRadius, - ), - ); - - if (households.isEmpty) continue; - - final resultHousehold = households.first; - - final individuals = await individual.search( - IndividualSearchModel( - clientReferenceId: individualIds, - name: NameSearchModel(givenName: event.searchText.trim()), - ), - ); - - final head = individuals.firstWhereOrNull( - (element) => - element.clientReferenceId == - entry.value - .firstWhereOrNull( - (element) => element.isHeadOfHousehold, - ) - ?.individualClientReferenceId, - ); - - if (head == null) continue; - - final projectBeneficiaries = - beneficiaryType != BeneficiaryType.individual - ? await projectBeneficiary.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: [ - resultHousehold.clientReferenceId, - ], - //[TODO] Need to check for beneficiaryId - projectId: event.projectId, - ), - ) - : await projectBeneficiary.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: individualIds, - //[TODO] Need to check for beneficiaryId - projectId: event.projectId, - ), - ); - - if (projectBeneficiaries.isEmpty) continue; - final tasks = await taskDataRepository.search(TaskSearchModel( - projectBeneficiaryClientReferenceId: - projectBeneficiaries.map((e) => e.clientReferenceId).toList(), - )); - - containers.add( - HouseholdMemberWrapper( - household: resultHousehold, - headOfHousehold: head, - members: individuals, - projectBeneficiaries: projectBeneficiaries, - tasks: tasks.isEmpty ? null : tasks, - ), - ); - } - - emit(state.copyWith( - householdMembers: containers, - loading: false, - )); - } catch (error) { - emit(state.copyWith( - loading: false, - householdMembers: [], - )); - } - } else { - final results = await individual.search( - IndividualSearchModel( - name: NameSearchModel(givenName: event.searchText.trim()), + for (final element in results) { + final members = await householdMember.search( + HouseholdMemberSearchModel( + individualClientReferenceId: element.clientReferenceId, + isHeadOfHousehold: true, ), ); - final householdMembers = []; - - for (final element in results) { - final members = await householdMember.search( + for (final member in members) { + final allHouseholdMembers = await householdMember.search( HouseholdMemberSearchModel( - individualClientReferenceId: element.clientReferenceId, - isHeadOfHousehold: true, + householdClientReferenceId: member.householdClientReferenceId, ), ); - for (final member in members) { - final allHouseholdMembers = await householdMember.search( - HouseholdMemberSearchModel( - householdClientReferenceId: member.householdClientReferenceId, - ), - ); - - householdMembers.addAll(allHouseholdMembers); - } + householdMembers.addAll(allHouseholdMembers); } + } - final containers = []; - final groupedHouseholds = householdMembers - .groupListsBy((element) => element.householdClientReferenceId); - - for (final entry in groupedHouseholds.entries) { - final householdId = entry.key; - final individualIds = entry.value - .map((element) => element.individualClientReferenceId) - .whereNotNull() - .toList(); - - if (householdId == null) continue; - final households = await household.search( - HouseholdSearchModel( - clientReferenceId: [householdId], - latitude: event.latitude, - longitude: event.longitude, - maxRadius: event.maxRadius, - ), - ); + final containers = []; + final groupedHouseholds = householdMembers + .groupListsBy((element) => element.householdClientReferenceId); - if (households.isEmpty) continue; + for (final entry in groupedHouseholds.entries) { + final householdId = entry.key; + final individualIds = entry.value + .map((element) => element.individualClientReferenceId) + .whereNotNull() + .toList(); - final resultHousehold = households.first; + if (householdId == null) continue; + final households = await household.search( + HouseholdSearchModel( + clientReferenceId: [householdId], + latitude: event.latitude, + longitude: event.longitude, + maxRadius: event.maxRadius, + ), + ); - final individuals = await individual.search( - IndividualSearchModel(clientReferenceId: individualIds), - ); + if (households.isEmpty) continue; - final head = individuals.firstWhereOrNull( - (element) => - element.clientReferenceId == - entry.value - .firstWhereOrNull( - (element) => element.isHeadOfHousehold, - ) - ?.individualClientReferenceId, - ); + final resultHousehold = households.first; - if (head == null) continue; - - final projectBeneficiaries = - beneficiaryType != BeneficiaryType.individual - ? await projectBeneficiary.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: [ - resultHousehold.clientReferenceId, - ], - //[TODO] Need to check for beneficiaryId - projectId: event.projectId, - ), - ) - : await projectBeneficiary.search( - ProjectBeneficiarySearchModel( - beneficiaryClientReferenceId: individualIds, - //[TODO] Need to check for beneficiaryId - projectId: event.projectId, - ), - ); - - if (projectBeneficiaries.isEmpty) continue; - final tasks = await taskDataRepository.search(TaskSearchModel( - projectBeneficiaryClientReferenceId: - projectBeneficiaries.map((e) => e.clientReferenceId).toList(), - )); + final individuals = await individual.search( + IndividualSearchModel(clientReferenceId: individualIds), + ); - containers.add( - HouseholdMemberWrapper( - household: resultHousehold, - headOfHousehold: head, - members: individuals, - projectBeneficiaries: projectBeneficiaries, - tasks: tasks.isEmpty ? null : tasks, - ), - ); - } + final head = individuals.firstWhereOrNull( + (element) => + element.clientReferenceId == + entry.value + .firstWhereOrNull( + (element) => element.isHeadOfHousehold, + ) + ?.individualClientReferenceId, + ); - emit(state.copyWith( - householdMembers: containers, - loading: false, + if (head == null) continue; + + final projectBeneficiaries = beneficiaryType != BeneficiaryType.individual + ? await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: [ + resultHousehold.clientReferenceId, + ], + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ) + : await projectBeneficiary.search( + ProjectBeneficiarySearchModel( + beneficiaryClientReferenceId: individualIds, + //[TODO] Need to check for beneficiaryId + projectId: event.projectId, + ), + ); + + if (projectBeneficiaries.isEmpty) continue; + final tasks = await taskDataRepository.search(TaskSearchModel( + projectBeneficiaryClientReferenceId: + projectBeneficiaries.map((e) => e.clientReferenceId).toList(), )); + + containers.add( + HouseholdMemberWrapper( + household: resultHousehold, + headOfHousehold: head, + members: individuals, + projectBeneficiaries: projectBeneficiaries, + tasks: tasks.isEmpty ? null : tasks, + ), + ); } + + emit(state.copyWith( + householdMembers: containers, + loading: false, + )); } FutureOr _handleClear( 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 7bf236882..592fbfb9d 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 @@ -103,40 +103,25 @@ class _SearchBeneficiaryPageState onChanged: (value) { final bloc = context.read(); - - if (value.trim().length < 2 && - !isProximityEnabled) { + if (value.trim().length < 2) { bloc.add( const SearchHouseholdsClearEvent(), ); return; - } else { - if (isProximityEnabled && - value.trim().length < 2) { - bloc.add(SearchHouseholdsEvent - .searchByProximity( - latitude: locationState.latitude!, - longititude: - locationState.longitude!, - projectId: context.projectId, - maxRadius: appConfig.maxRadius!, - )); - } else { - bloc.add( - SearchHouseholdsSearchByHouseholdHeadEvent( - searchText: value.trim(), - projectId: context.projectId, - latitude: locationState.latitude, - longitude: - locationState.longitude, - isProximityEnabled: - isProximityEnabled, - maxRadius: appConfig.maxRadius, - ), - ); - } } + + bloc.add( + SearchHouseholdsSearchByHouseholdHeadEvent( + searchText: value.trim(), + projectId: context.projectId, + latitude: locationState.latitude, + longitude: locationState.longitude, + isProximityEnabled: + isProximityEnabled, + maxRadius: appConfig.maxRadius, + ), + ); }, ), locationState.latitude != null @@ -158,8 +143,7 @@ class _SearchBeneficiaryPageState locationState.longitude != null && appConfig.maxRadius != - null && - isProximityEnabled) { + null) { final bloc = context.read< SearchHouseholdsBloc>(); bloc.add(SearchHouseholdsEvent @@ -173,12 +157,6 @@ class _SearchBeneficiaryPageState maxRadius: appConfig.maxRadius!, )); - } else { - final bloc = context.read< - SearchHouseholdsBloc>(); - bloc.add( - const SearchHouseholdsClearEvent(), - ); } }, ), From 4445e88534d8cb8363a7dc0d981e92a3617b18ca Mon Sep 17 00:00:00 2001 From: Anil Singha <99383116+anilsingha-eGov@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:33:51 +0530 Subject: [PATCH 17/17] HLM-3379: Fixed proximity based search (#205) * HLM-3379: Fixed proximity based search * HLM-3379: Code updated * HLM-3379: Updated code * Proximity Based search Code review changes * HLM-3379:Updated distance display info inside brackets --------- Co-authored-by: Ramkrishna-egov --- .../search_households/search_households.dart | 49 +++++++++++++----- .../lib/pages/search_beneficiary.dart | 50 +++++++++++++------ .../beneficiary/view_beneficiary_card.dart | 2 +- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart index 841103377..86c3cc8a9 100644 --- a/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart +++ b/apps/health_campaign_field_worker_app/lib/blocs/search_households/search_households.dart @@ -201,7 +201,6 @@ class SearchHouseholdsBloc SearchHouseholdsByProximityEvent event, SearchHouseholdsEmitter emit, ) async { - print("_handleSearchByProximitity"); emit(state.copyWith(loading: true)); final results = await addressRepository.searchHouseHoldbyAddress(AddressSearchModel( @@ -295,21 +294,36 @@ class SearchHouseholdsBloc searchQuery: event.searchText, )); - final results = await individual.search( + final List proximityBasedResults = + await addressRepository.searchHouseHoldbyAddress(AddressSearchModel( + latitude: event.latitude, + longitude: event.longitude, + maxRadius: event.maxRadius, + )); + final List results = await individual.search( IndividualSearchModel( name: NameSearchModel(givenName: event.searchText.trim()), ), ); final householdMembers = []; - - for (final element in results) { - final members = await householdMember.search( - HouseholdMemberSearchModel( - individualClientReferenceId: element.clientReferenceId, - isHeadOfHousehold: true, - ), - ); + final r = event.isProximityEnabled ? proximityBasedResults : results; + for (final element in r) { + final members = event.isProximityEnabled + ? await householdMember.search( + HouseholdMemberSearchModel( + householdClientReferenceId: + (element as HouseholdModel).clientReferenceId, + isHeadOfHousehold: true, + ), + ) + : await householdMember.search( + HouseholdMemberSearchModel( + individualClientReferenceId: + (element as IndividualModel).clientReferenceId, + isHeadOfHousehold: true, + ), + ); for (final member in members) { final allHouseholdMembers = await householdMember.search( @@ -347,9 +361,18 @@ class SearchHouseholdsBloc final resultHousehold = households.first; - final individuals = await individual.search( - IndividualSearchModel(clientReferenceId: individualIds), - ); + final individuals = event.isProximityEnabled + ? await individual.search( + IndividualSearchModel( + clientReferenceId: individualIds, + name: NameSearchModel(givenName: event.searchText.trim()), + ), + ) + : await individual.search( + IndividualSearchModel( + clientReferenceId: individualIds, + ), + ); final head = individuals.firstWhereOrNull( (element) => 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 592fbfb9d..7bf236882 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 @@ -103,25 +103,40 @@ class _SearchBeneficiaryPageState onChanged: (value) { final bloc = context.read(); - if (value.trim().length < 2) { + + if (value.trim().length < 2 && + !isProximityEnabled) { bloc.add( const SearchHouseholdsClearEvent(), ); return; + } else { + if (isProximityEnabled && + value.trim().length < 2) { + bloc.add(SearchHouseholdsEvent + .searchByProximity( + latitude: locationState.latitude!, + longititude: + locationState.longitude!, + projectId: context.projectId, + maxRadius: appConfig.maxRadius!, + )); + } else { + bloc.add( + SearchHouseholdsSearchByHouseholdHeadEvent( + searchText: value.trim(), + projectId: context.projectId, + latitude: locationState.latitude, + longitude: + locationState.longitude, + isProximityEnabled: + isProximityEnabled, + maxRadius: appConfig.maxRadius, + ), + ); + } } - - bloc.add( - SearchHouseholdsSearchByHouseholdHeadEvent( - searchText: value.trim(), - projectId: context.projectId, - latitude: locationState.latitude, - longitude: locationState.longitude, - isProximityEnabled: - isProximityEnabled, - maxRadius: appConfig.maxRadius, - ), - ); }, ), locationState.latitude != null @@ -143,7 +158,8 @@ class _SearchBeneficiaryPageState locationState.longitude != null && appConfig.maxRadius != - null) { + null && + isProximityEnabled) { final bloc = context.read< SearchHouseholdsBloc>(); bloc.add(SearchHouseholdsEvent @@ -157,6 +173,12 @@ class _SearchBeneficiaryPageState maxRadius: appConfig.maxRadius!, )); + } else { + final bloc = context.read< + SearchHouseholdsBloc>(); + bloc.add( + const SearchHouseholdsClearEvent(), + ); } }, ), 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 44c045081..238836582 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 @@ -170,7 +170,7 @@ class _ViewBeneficiaryCardState extends LocalizedState { 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)'} ', + '${householdMember.household.memberCount ?? 1} Members \n ${((widget.distance!) * 1000).round() > 999 ? '(${((widget.distance!).round())} km)' : '(${((widget.distance!) * 1000).round()} mts)'}', status: context.beneficiaryType != BeneficiaryType.individual ? householdMember.tasks?.first.status != null ? 'delivered'