From e77e0b3149df40782edfdc5108d3ddaab0358029 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 7 Nov 2024 15:40:53 +0300 Subject: [PATCH] code review --- src/processors/encounter/encounter-processor-helper.ts | 8 ++++++-- src/transformers/default-schema-transformer.ts | 6 +----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/processors/encounter/encounter-processor-helper.ts b/src/processors/encounter/encounter-processor-helper.ts index 9b7758ac..011e342e 100644 --- a/src/processors/encounter/encounter-processor-helper.ts +++ b/src/processors/encounter/encounter-processor-helper.ts @@ -316,7 +316,10 @@ export async function hydrateRepeatField( } const unMappedDiagnoses = encounter.diagnoses.filter((diagnosis) => { - return !assignedDiagnosesIds.includes(diagnosis?.diagnosis?.coded.uuid); + return ( + !assignedDiagnosesIds.includes(diagnosis?.diagnosis?.coded.uuid) && + diagnosis.formFieldPath.startsWith(`rfe-forms-${field.id}_`) + ); }); const sortedDiagnoses = unMappedDiagnoses @@ -381,5 +384,6 @@ function transformNestedObsGroups(field: FormField, value: any): any { function prepareDiagnosis(fields: FormField[]) { return fields .filter((field) => field.type === 'diagnosis' && hasSubmission(field)) - .map((field) => field.meta.submission.newValue); + .flatMap((field) => [field.meta.submission.newValue, field.meta.submission.voidedValue]) + .filter((d) => d); } diff --git a/src/transformers/default-schema-transformer.ts b/src/transformers/default-schema-transformer.ts index b7311f17..e0eadc62 100644 --- a/src/transformers/default-schema-transformer.ts +++ b/src/transformers/default-schema-transformer.ts @@ -273,11 +273,7 @@ function handleDiagnosis(question: FormField) { question.questionOptions.datasource = { name: 'problem_datasource', config: { - class: [ - '8d4918b0-c2cc-11de-8d13-0010c6dffd0f', - '8d492954-c2cc-11de-8d13-0010c6dffd0f', - '8d492b2a-c2cc-11de-8d13-0010c6dffd0f', - ], + class: '8d4918b0-c2cc-11de-8d13-0010c6dffd0f', }, }; delete question.questionOptions['dataSource'];