Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau committed Nov 20, 2024
1 parent 1b338c3 commit f726e01
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/adapters/encounter-diagnoses-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const constructNewDiagnosis = (value: any, field: FormField, patientUuid: string
diagnosis: {
coded: value,
},
certainty: 'CONFIRMED',
rank: field.questionOptions.rank, // rank 1 denotes a diagnosis is primary, else secondary
certainty: 'PROVISIONAL',
rank: field.questionOptions.diagnosis.rank, // rank 1 denotes a diagnosis is primary, else secondary
formFieldPath: `rfe-forms-${field.id}`,
formFieldNamespace: 'rfe-forms',
};
Expand Down
10 changes: 5 additions & 5 deletions src/adapters/encounter-diagnoses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const diagnoses = [
encounter: {
uuid: '9a4b06bd-d655-414f-b9ce-69e940c337ce',
},
certainty: 'CONFIRMED',
certainty: 'PROVISIONAL',
rank: 1,
voided: false,
display: 'Schistosoma Mansonii Infection',
Expand All @@ -118,7 +118,7 @@ const diagnoses = [
encounter: {
uuid: '9a4b06bd-d655-414f-b9ce-69e940c337ce',
},
certainty: 'CONFIRMED',
certainty: 'PROVISIONAL',
rank: 1,
voided: false,
display: 'Infection due to Entamoeba Histolytica',
Expand All @@ -143,7 +143,7 @@ describe('EncounterDiagnosesAdapter', () => {
diagnosis: {
coded: '127133AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
certainty: 'CONFIRMED',
certainty: 'PROVISIONAL',
rank: 1,
formFieldPath: 'rfe-forms-DiagNosIS',
formFieldNamespace: 'rfe-forms',
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('EncounterDiagnosesAdapter', () => {
const value = '128138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
field.meta.previousValue = {
uuid: '0e20bb67-5d7f-41e0-96a1-751efc21a96f',
certainty: 'CONFIRMED',
certainty: 'PROVISIONAL',
condition: null,
formFieldPath: 'rfe-forms-DiagNosIS_1',
formFieldNamespace: 'rfe-forms',
Expand All @@ -192,7 +192,7 @@ describe('EncounterDiagnosesAdapter', () => {
diagnosis: {
coded: '128138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
certainty: 'CONFIRMED',
certainty: 'PROVISIONAL',
rank: 1,
formFieldPath: 'rfe-forms-DiagNosIS',
formFieldNamespace: 'rfe-forms',
Expand Down
8 changes: 6 additions & 2 deletions src/processors/encounter/encounter-processor-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,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
Expand Down Expand Up @@ -360,5 +363,6 @@ export async function hydrateRepeatField(
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);
}
6 changes: 1 addition & 5 deletions src/transformers/default-schema-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,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'];
Expand Down
5 changes: 4 additions & 1 deletion src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ export interface FormQuestionOptions {
comment?: string;
orientation?: 'vertical' | 'horizontal';
shownCommentOptions?: { validators?: Array<Record<string, any>>; hide?: { hideWhenExpression: string } };
rank?: number;
diagnosis?: {
rank?: number;
isConfirmed?: boolean;
};
}

export interface QuestionAnswerOption {
Expand Down

0 comments on commit f726e01

Please sign in to comment.