From b323b2ea5c501364967291cc2a87b9b20005af4b Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Wed, 15 May 2024 22:31:11 +0530 Subject: [PATCH 1/3] feat: list children filtered by patient id for case report form --- src/data/entities/D2Survey.ts | 3 +++ src/data/utils/surveyProgramHelper.ts | 12 ++++-------- .../usecases/GetPaginatedPatientSurveysUseCase.ts | 10 +++++++--- src/domain/utils/PPSProgramsHelper.ts | 12 ++++++++++++ src/webapp/hooks/useSurveys.ts | 3 +++ 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/data/entities/D2Survey.ts b/src/data/entities/D2Survey.ts index eb7c6e2c..1bb3a9eb 100644 --- a/src/data/entities/D2Survey.ts +++ b/src/data/entities/D2Survey.ts @@ -47,6 +47,9 @@ export const PREVALENCE_SURVEY_NAME_DATAELEMENT_ID = "HXnhZ8rsDts"; export const AMR_SURVEYS_PREVALENCE_DEA_AST_GUIDELINES = "SmuESJHyhC2"; export const AMR_SURVEYS_PREVALENCE_DEA_CUSTOM_AST_GUIDE = "lyeNV8Ag6lp"; +export const AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID = "mUaaSzbeMmj"; +export const AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19 = "yq8en6ZkENB"; + //Prevalence Tracked Entity Attribute types export const PREVALENCE_FACILITY_LEVEL_TET = "eY4BDBKXegX"; export const PREVALENCE_CASE_REPORT_TET = "hyR1eTHLX8B"; diff --git a/src/data/utils/surveyProgramHelper.ts b/src/data/utils/surveyProgramHelper.ts index eb586e11..e36f6b5b 100644 --- a/src/data/utils/surveyProgramHelper.ts +++ b/src/data/utils/surveyProgramHelper.ts @@ -2,10 +2,6 @@ import { Id } from "../../domain/entities/Ref"; import { SURVEY_FORM_TYPES } from "../../domain/entities/Survey"; import { AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF, - AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRL, - AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_PIS, - AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_SRL, - AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_SSTF, PPS_COUNTRY_QUESTIONNAIRE_ID, PPS_HOSPITAL_FORM_ID, PPS_PATIENT_REGISTER_ID, @@ -27,6 +23,8 @@ import { SURVEY_ID_DATAELEMENT_ID, SURVEY_ID_FACILITY_LEVEL_DATAELEMENT_ID, WARD_ID_DATAELEMENT_ID, + AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID, + AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19, } from "../entities/D2Survey"; export const isTrackerProgram = (programId: Id) => { @@ -99,13 +97,11 @@ export const getParentDataElementForProgram = (programId: Id): Id => { case PREVALENCE_CASE_REPORT_FORM_ID: return AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF; case PREVALENCE_SAMPLE_SHIP_TRACK_FORM_ID: - return AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_SSTF; case PREVALENCE_CENTRAL_REF_LAB_FORM_ID: - return AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRL; case PREVALENCE_PATHOGEN_ISO_STORE_TRACK_ID: - return AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_PIS; + return AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID; case PREVALENCE_SUPRANATIONAL_REF_LAB_ID: - return AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_SRL; + return AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19; case PPS_COUNTRY_QUESTIONNAIRE_ID: case PPS_HOSPITAL_FORM_ID: case PPS_WARD_REGISTER_ID: diff --git a/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts b/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts index 126dbb3c..d1c6825b 100644 --- a/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts +++ b/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts @@ -1,7 +1,7 @@ import { FutureData } from "../../data/api-futures"; import { Id } from "../entities/Ref"; import { Survey, SURVEY_FORM_TYPES, SurveyBase } from "../entities/Survey"; -import { getProgramId } from "../utils/PPSProgramsHelper"; +import { getProgramId, isPrevalencePatientChild } from "../utils/PPSProgramsHelper"; import { PaginatedReponse } from "../entities/TablePagination"; import { PaginatedSurveyRepository } from "../repositories/PaginatedSurveyRepository"; import { SurveyRepository } from "../repositories/SurveyRepository"; @@ -21,13 +21,17 @@ export class GetPaginatedPatientSurveysUseCase { orgUnitId: Id, parentSurveyId: Id | undefined, parentWardRegisterId: Id | undefined, + parentPatientId: Id | undefined, page: number, pageSize: number ): FutureData> { const programId = getProgramId(surveyFormType); - const parentId = - surveyFormType === "PPSPatientRegister" ? parentWardRegisterId : parentSurveyId; + const parentId = isPrevalencePatientChild(surveyFormType) + ? parentPatientId + : surveyFormType === "PPSPatientRegister" + ? parentWardRegisterId + : parentSurveyId; return this.paginatedSurveyRepo .getSurveys(surveyFormType, programId, orgUnitId, parentId, page, pageSize) diff --git a/src/domain/utils/PPSProgramsHelper.ts b/src/domain/utils/PPSProgramsHelper.ts index 904a6eb2..3c60b121 100644 --- a/src/domain/utils/PPSProgramsHelper.ts +++ b/src/domain/utils/PPSProgramsHelper.ts @@ -239,3 +239,15 @@ export const isPaginatedSurveyList = (surveyFormType: SURVEY_FORM_TYPES): boolea return false; } }; + +export const isPrevalencePatientChild = (surveyFormType: SURVEY_FORM_TYPES): boolean => { + switch (surveyFormType) { + case "PrevalenceCentralRefLabForm": + case "PrevalencePathogenIsolatesLog": + case "PrevalenceSampleShipTrackForm": + case "PrevalenceSupranationalRefLabForm": + return true; + default: + return false; + } +}; diff --git a/src/webapp/hooks/useSurveys.ts b/src/webapp/hooks/useSurveys.ts index 2bbfcd0a..7b56aedf 100644 --- a/src/webapp/hooks/useSurveys.ts +++ b/src/webapp/hooks/useSurveys.ts @@ -24,6 +24,7 @@ export function useSurveys(surveyFormType: SURVEY_FORM_TYPES) { currentWardRegister, currentPrevalenceSurveyForm, currentFacilityLevelForm, + currentCaseReportForm, } = useCurrentSurveys(); const { currentModule } = useCurrentModule(); @@ -105,6 +106,7 @@ export function useSurveys(surveyFormType: SURVEY_FORM_TYPES) { orgUnitId, parentSurveyId, currentWardRegister?.id, + currentCaseReportForm?.id, page, PAGE_SIZE ) @@ -149,6 +151,7 @@ export function useSurveys(surveyFormType: SURVEY_FORM_TYPES) { getOrgUnitByFormType, isAdmin, hospitalState, + currentCaseReportForm?.id, ]); return { From 7d8ca3a2b0a900f432de9b908f85a2406ecac783 Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Wed, 15 May 2024 22:58:12 +0530 Subject: [PATCH 2/3] fix: child count for case report forms --- src/data/utils/surveyChildCountHelper.ts | 17 +++++++++++++---- .../GetPaginatedPatientSurveysUseCase.ts | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/data/utils/surveyChildCountHelper.ts b/src/data/utils/surveyChildCountHelper.ts index 2ec3197f..8d78b20b 100644 --- a/src/data/utils/surveyChildCountHelper.ts +++ b/src/data/utils/surveyChildCountHelper.ts @@ -41,14 +41,23 @@ export const getSurveyChildCount = ( const eventCount = getTrackerSurveyCount(childId, orgUnitId, parentSurveyId, api); return { type: "value", value: eventCount }; - } else { + } else if (secondaryparentId) { const eventCounts = childIds.value.map(id => { - return getTrackerSurveyCount(id, orgUnitId, parentSurveyId, api).map(count => { - return { id: id, count: count }; - }); + return getTrackerSurveyCount(id, orgUnitId, secondaryparentId, api).map( + count => { + return { id: id, count: count }; + } + ); }); return { type: "map", value: Future.sequential(eventCounts) }; + } else { + return { + type: "map", + value: Future.error( + new Error("secondaryparentId not provided for multichild program") + ), + }; } } else { if (childIds.type === "singleChild") { diff --git a/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts b/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts index d1c6825b..e8838c2f 100644 --- a/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts +++ b/src/domain/usecases/GetPaginatedPatientSurveysUseCase.ts @@ -46,6 +46,7 @@ export class GetPaginatedPatientSurveysUseCase { surveyFormType: surveyFormType, orgUnitId: survey.assignedOrgUnit.id, parentSurveyId: survey.rootSurvey.id, + secondaryparentId: survey.id, surveyReporsitory: this.paginatedSurveyRepo, }) ).map(([parentDetails, childCount]): Survey => { From c763c788f8183e804d0c96243b6089f1921dcb2f Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Thu, 16 May 2024 00:07:29 +0530 Subject: [PATCH 3/3] feat: auto populate case report patient id in child forms --- src/data/utils/questionHelper.ts | 6 ++++- src/domain/usecases/GetSurveyUseCase.ts | 23 ++++++++++++++++--- .../components/survey/hook/useSurveyForm.ts | 5 +++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/data/utils/questionHelper.ts b/src/data/utils/questionHelper.ts index 778e663c..07d05b07 100644 --- a/src/data/utils/questionHelper.ts +++ b/src/data/utils/questionHelper.ts @@ -15,6 +15,8 @@ import { Id } from "../../domain/entities/Ref"; import { Option, ProgramDataElement, TrackedEntityAttibute } from "../entities/D2Program"; import { AMR_SURVEYS_PREVALENCE_DEA_SURVEY_ID, + AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID, + AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19, AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF, AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRL, AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_PIS, @@ -352,7 +354,9 @@ export const mapTrackedAttributesToQuestions = ( currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRL || currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_PIS || currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_SRL || - currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF) + currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF || + currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID || + currentQuestion.id === AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19) ) { currentQuestion.disabled = true; } diff --git a/src/domain/usecases/GetSurveyUseCase.ts b/src/domain/usecases/GetSurveyUseCase.ts index 85c58c90..81ee3733 100644 --- a/src/domain/usecases/GetSurveyUseCase.ts +++ b/src/domain/usecases/GetSurveyUseCase.ts @@ -1,5 +1,7 @@ import { FutureData } from "../../data/api-futures"; import { + AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID, + AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19, AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF, AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRL, AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_PIS, @@ -30,13 +32,18 @@ export class GetSurveyUseCase { surveyFormType: SURVEY_FORM_TYPES, parentPPSSurveyId: Id | undefined, parentWardRegisterId: Id | undefined, - parentPrevalenceSurveyId: Id | undefined + parentPrevalenceSurveyId: Id | undefined, + parentCaseReportId: Id | undefined ): FutureData { const programId = getProgramId(surveyFormType); if (parentPPSSurveyId) { return this.getPPSSurveyForm(programId, parentPPSSurveyId, parentWardRegisterId); } else if (parentPrevalenceSurveyId) { - return this.getPrevalenceSurveyForm(programId, parentPrevalenceSurveyId); + return this.getPrevalenceSurveyForm( + programId, + parentPrevalenceSurveyId, + parentCaseReportId + ); } else return this.surveyReporsitory.getForm(programId, undefined, undefined); } @@ -116,7 +123,8 @@ export class GetSurveyUseCase { getPrevalenceSurveyForm( programId: Id, - parentPrevalenceSurveyId: Id + parentPrevalenceSurveyId: Id, + parentCaseReportId: Id | undefined ): FutureData { return this.surveyReporsitory .getForm(programId, undefined, undefined) @@ -136,11 +144,20 @@ export class GetSurveyUseCase { question.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_SRL || question.id === AMR_SURVEYS_PREVALENCE_TEA_SURVEY_ID_CRF; + const isPatientIdQuestion = + question.id === AMR_SURVEYS_PREVALENCE_TEA_PATIENT_ID || + question.id === AMR_SURVEYS_PREVALENCE_TEA_PATIENT_IDA19; + if (isSurveyIdQuestion && question.type === "text") { return { ...question, value: parentPrevalenceSurveyId, }; + } else if (isPatientIdQuestion && question.type === "text") { + return { + ...question, + value: parentCaseReportId, + }; } else { return question; } diff --git a/src/webapp/components/survey/hook/useSurveyForm.ts b/src/webapp/components/survey/hook/useSurveyForm.ts index 31fb349a..818ab668 100644 --- a/src/webapp/components/survey/hook/useSurveyForm.ts +++ b/src/webapp/components/survey/hook/useSurveyForm.ts @@ -23,6 +23,7 @@ export function useSurveyForm(formType: SURVEY_FORM_TYPES, eventId: string | und currentWardRegister, currentPrevalenceSurveyForm, currentFacilityLevelForm, + currentCaseReportForm, } = useCurrentSurveys(); const { hasReadOnlyAccess } = useReadOnlyAccess(); @@ -46,7 +47,8 @@ export function useSurveyForm(formType: SURVEY_FORM_TYPES, eventId: string | und formType, currentPPSSurveyForm?.id, currentWardRegister?.id, - currentPrevalenceSurveyForm?.id + currentPrevalenceSurveyForm?.id, + currentCaseReportForm?.id ) .run( questionnaireForm => { @@ -146,6 +148,7 @@ export function useSurveyForm(formType: SURVEY_FORM_TYPES, eventId: string | und currentFacilityLevelForm, currentPrevalenceSurveyForm, currentModule, + currentCaseReportForm?.id, ]); const updateQuestion = useCallback((question: Question, stageId?: string) => {