Skip to content

Commit

Permalink
Merge pull request #262 from egovernments/HLM-2650-Multiround-fix
Browse files Browse the repository at this point in the history
Multi round fixes :: task reload, Location null check , deliveries co…
  • Loading branch information
Ramkrishna-egov authored Oct 10, 2023
2 parents 6fe78c8 + c1bcda6 commit bd616df
Show file tree
Hide file tree
Showing 19 changed files with 842 additions and 550 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import '../../data/data_repository.dart';
import '../../models/data_model.dart';
import '../../models/project_type/project_type_model.dart';
import '../../utils/utils.dart';

part 'deliver_intervention.freezed.dart';

Expand Down Expand Up @@ -128,12 +127,10 @@ class DeliverInterventionBloc
if (currentRunningCycle != 0) {
if (event.lastCycle == currentRunningCycle) {
// Calculate the length of deliveries in the current cycle
final deliveryLength = fetchDeliveries(
event.projectType.cycles!
.firstWhere((c) => c.id == event.lastCycle)
.deliveries,
event.individualModel,
)?.length ??
final deliveryLength = event.projectType.cycles!
.firstWhere((c) => c.id == event.lastCycle)
.deliveries
?.length ??
0;
final isNotLastDose = event.lastDose < deliveryLength;
// Get a list of past cycles
Expand Down Expand Up @@ -207,16 +204,15 @@ class DeliverInterventionBloc
int currentDose = event.dose;
Cycle? currentCycle = event.cycle;

final deliveriesList =
fetchDeliveries(currentCycle.deliveries, event.individualModel);
final deliveriesList = currentCycle.deliveries;

if (deliveriesList != null) {
List<DeliveryModel> futureDeliveries = [];
// Iterate over deliveries starting from the current dose
for (int index = currentDose; index < deliveriesList.length; index++) {
var delivery = deliveriesList[index];

String? deliveryStrategy = delivery.doseCriteria?.deliveryStrategy;
String? deliveryStrategy = delivery.deliveryStrategy;

// Check if the delivery strategy is indirect
if (deliveryStrategy == DeliverStrategyType.indirect.toValue()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ class Cycles {
@embedded
class Deliveries {
@Name("doseCriteria")
DoseCriteria? doseCriteriaModel;
List<DoseCriteria>? doseCriteriaModel;
@Name("mandatoryWaitSinceLastDeliveryInDays")
String? mandatoryWaitSinceLastDeliveryInDays;
@Name("deliveryStrategy")
String? deliveryStrategy;
}

@embedded
class DoseCriteria {
String? mandatoryWaitSinceLastDeliveryInDays;
String? deliveryStrategy;
@Name("condition")
String? condition;
@Name("ProductVariants")
List<ProductVariants>? productVariants;
}

Expand Down
Loading

0 comments on commit bd616df

Please sign in to comment.