From f64baa88d28d566bfc92f589db091e3d3bbe9fe1 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan <70560433+hamza-vd@users.noreply.github.com> Date: Fri, 31 May 2024 13:08:42 +0500 Subject: [PATCH] Fix for empty PlanDef id (#3293) * Fix empty plan def id execution * Fix spotless error --- .../questionnaire/QuestionnaireViewModel.kt | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt index 391edaa178..3e5265ac97 100644 --- a/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt +++ b/android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireViewModel.kt @@ -756,16 +756,18 @@ constructor( questionnaireConfig: QuestionnaireConfig, ) { questionnaireConfig.planDefinitions?.forEach { planId -> - kotlin - .runCatching { - fhirCarePlanGenerator.generateOrUpdateCarePlan( - planDefinitionId = planId, - subject = subject, - data = bundle, - generateCarePlanWithWorkflowApi = questionnaireConfig.generateCarePlanWithWorkflowApi, - ) - } - .onFailure { Timber.e(it) } + if (planId.isNotEmpty()) { + kotlin + .runCatching { + fhirCarePlanGenerator.generateOrUpdateCarePlan( + planDefinitionId = planId, + subject = subject, + data = bundle, + generateCarePlanWithWorkflowApi = questionnaireConfig.generateCarePlanWithWorkflowApi, + ) + } + .onFailure { Timber.e(it) } + } } }