diff --git a/api/src/main/java/org/openmrs/module/eptsreports/metadata/HivMetadata.java b/api/src/main/java/org/openmrs/module/eptsreports/metadata/HivMetadata.java index 6fe01aee5d..8806cb8135 100644 --- a/api/src/main/java/org/openmrs/module/eptsreports/metadata/HivMetadata.java +++ b/api/src/main/java/org/openmrs/module/eptsreports/metadata/HivMetadata.java @@ -23,929 +23,903 @@ @Component("hivMetadata") public class HivMetadata extends ProgramsMetadata { - private String gpSTarvFarmaciaEncounterTypeUuid = "eptsreports.sTarvFarmaciaEncounterTypeUuid"; - - private String gpArtProgramUuid = "eptsreports.artProgramUuid"; - - private String gpPtvEtvProgramUuid = "eptsreports.ptvEtvProgramUuid"; - - // Concepts Id = 856 - public Concept getHivViralLoadConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.hivViralLoadConceptUuid"); - return getConcept(uuid); - } - - public Concept getCriteriaForArtStart() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.criteriaForArtStartUuid"); - return getConcept(uuid); - } - - // concept_id=5096 - public Concept getReturnVisitDateForArvDrugConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.returnVisitDateForArvDrugConceptUuid"); - return getConcept(uuid); - } - // concept_id=6123 - public Concept getDateOfHivDiagnosisConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.dateOfHIVDiagnosis"); - return getConcept(uuid); - } - - // concept_id=1190 - public Concept getARVStartDate() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.historicalStartDateConceptUuid"); - return getConcept(uuid); - } - - // concept_id=1255 - public Concept getARVPlanConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.arvPlanConceptUuid"); - return getConcept(uuid); - } - - // concept_id=1088 - public Concept getRegimeConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.regimeUuid"); - return getConcept(uuid); - } - - public Concept getRestartConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.restartConceptUuid"); - return getConcept(uuid); - } - - // concept_id = 1707 - public Concept getAbandoned() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.abandonedConceptUuid"); - return getConcept(uuid); - } - - // Second line ARV concepts - // 6328 - public Concept getAzt3tcAbcEfvConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.AZT_3TC_ABC_EFV_ConceptUuid"); - return getConcept(uuid); - } - // 6327 - public Concept getD4t3tcAbcEfvConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.D4T_3TC_ABC_EFV_ConceptUuid"); - return getConcept(uuid); - } - // 6326 - public Concept getAzt3tcAbcLpvConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.AZT_3TC_ABC_LPV_ConceptUuid"); - return getConcept(uuid); - } - // 6325 - public Concept getD4t3tcAbcLpvConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.D4T_3TC_ABC_LPV_ConceptUuid"); - return getConcept(uuid); - } - // 6109 - public Concept getAztDdiLpvConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.AZT_DDI_LPV_ConceptUuid"); - return getConcept(uuid); - } - // 1315 - public Concept getTdf3tcEfvConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.TDF_3TC_EFV_ConceptUuid"); - return getConcept(uuid); - } - // 1314 - public Concept getAzt3tcLpvConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.AZT_3TC_LPV_ConceptUuid"); - return getConcept(uuid); - } - // 1313 - public Concept getAbc3tcEfvConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.ABC_3TC_EFV_ConceptUuid"); - return getConcept(uuid); - } - // 1312 - public Concept getAbc3tcNvpConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.ABC_3TC_NVP_ConceptUuid"); - return getConcept(uuid); - } - // 1311 - public Concept getAbc3tcLpvConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.ABC_3TC_LPV_ConceptUuid"); - return getConcept(uuid); - } - // - public Concept getTdf3tcLpvConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.TDF_3TC_LPV_ConceptUuid"); - return getConcept(uuid); - } - // concept id 6306 - public Concept getAcceptContactConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.acceptContactConceptUuid"); - return getConcept(uuid); - } - - // concept id 1066 - public Concept getNoConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.noConceptUuid"); - return getConcept(uuid); - } - - public Concept getDataInicioProfilaxiaIsoniazidaConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.DataInicioProfilaxiaIsoniazidaConceptUuid"); - return getConcept(uuid); - } - - public Concept getDataFinalizacaoProfilaxiaIsoniazidaConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.DataFimProfilaxiaIsoniazidaConceptUuid"); - return getConcept(uuid); - } - - // concept_id=6122 - public Concept getIsoniazidUsageConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.isoniazidUseConceptUuid"); - return getConcept(uuid); - } - // concept_id=1695 - public Concept getCD4AbsoluteOBSConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.cd4AbsoluteOBSUuid"); - return getConcept(uuid); - } - - // concept_id=6314 - public Concept getCoucelingActivityConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.coucelingActivityTypeUuid"); - return getConcept(uuid); - } - - // concept_id=5356 - public Concept getcurrentWhoHivStageConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.currentWhoHivStageUuid"); - return getConcept(uuid); - } - // concept_id=1205 - public Concept getWho2AdultStageConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.who2AdultStageUuid"); - return getConcept(uuid); - } - - // concept_id=1206 - public Concept getWho3AdultStageConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.who3AdultStageUuid"); - return getConcept(uuid); - } - // concept_id=1207 - public Concept getWho4AdultStageConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.who4AdultStageUuid"); - return getConcept(uuid); - } - - // concept_id = 1366 - public Concept getPatientHasDiedConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.patientHasDiedConceptUuid"); - return getConcept(uuid); - } - - // concept_id = 1981 - public Concept getTypeOfVisitConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.typeOfVisit"); - return getConcept(uuid); - } - - // concept_id = 2003 - public Concept getPatientFoundConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.patientFound"); - return getConcept(uuid); - } - - // concept_id = 1065 - public Concept getPatientFoundYesConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.yesConceptUuid"); - return getConcept(uuid); - } - - // concept_id = 2160 - public Concept getBuscaConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.busca"); - return getConcept(uuid); - } - // concept_id = 6254 - public Concept getSecondAttemptConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.secondAttempt"); - return getConcept(uuid); - } - // concept_id = 6255 - public Concept getThirdAttemptConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.thirdAttempt"); - return getConcept(uuid); - } - // concept_id = 2016 - public Concept getDefaultingMotiveConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.defaultingMotive"); - return getConcept(uuid); - } - // concept_id = 2158 - public Concept getReportOfVisitSupportConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.reportOfVisitSupport"); - return getConcept(uuid); - } - // concept_id = 2157 - public Concept getPatientHadDifficultyConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.patientHadDifficulty"); - return getConcept(uuid); - } - // concept_id = 1272 - public Concept getPatientFoundForwardedConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.patientFoundForwarded"); - return getConcept(uuid); - } - // concept_id = 2037 - public Concept getWhoGaveInformationConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.whoGaveInformation"); - return getConcept(uuid); - } - // concept_id = 2180 - public Concept getCardDeliveryDateConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.cardDeliveryDate"); - return getConcept(uuid); - } - - // concept_id = 1709 - public Concept getSuspendedTreatmentConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.suspendedTreatmentConceptUuid"); - return getConcept(uuid); - } - - // concept_id = 6269 - private Concept getActiveOnProgramConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.activeOnProgramConcept"); - return getConcept(uuid); - } - - // concept_id = 1126 - public Concept getUrogenitalExamFindingsConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.urogenitalExamFindingsConcept"); - return getConcept(uuid); - } - - // concept_id = 1115 - public Concept getNormalConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.normalConcept"); - return getConcept(uuid); - } - - // concept_id = 1116 - public Concept getAbnormalConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.abnormalConcept"); - return getConcept(uuid); - } - - // concept_id = 1399 - public Concept getSecretionsConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.secretionsConcept"); - return getConcept(uuid); - } - - // concept_id = 1400 - public Concept getCondylomasConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.condylomasConcept"); - return getConcept(uuid); - } - - // concept_id = 1602 - public Concept getUlcersConcept() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.ulcersConcept"); - return getConcept(uuid); - } - - // concept_id=5488 - public Concept getAdherenceCoucelingConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.adherenceCounselingUuid"); - return getConcept(uuid); - } - // concept_id=5497 - public Concept getCD4AbsoluteConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.cd4AbsolutoUuid"); - return getConcept(uuid); - } - // concept_id=730 - public Concept getCD4PercentConcept() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.cd4PercentUuid"); - return getConcept(uuid); - } - // concept_id=1714 - public Concept getAdherence() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.poorAdherenceUuid"); - return getConcept(uuid); - } - // concept_id=2015 - public Concept getAdverseReaction() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.adverseReactionUuid"); - return getConcept(uuid); - } - // Concept 6292 - public Concept getNeutropenia() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.neutropenia"); - return getConcept(uuid); - } - // Concept 6293 - public Concept getPancreatitis() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.pancreatitis"); - return getConcept(uuid); - } - // Concept 6294 - public Concept getHepatotoxicity() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.hepatotoxicity"); - return getConcept(uuid); - } - // Concept 6295 - public Concept getPsychologicalChanges() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.psychologicalChanges"); - return getConcept(uuid); - } - // Concept 6296 - public Concept getMyopathy() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.myopathy"); - return getConcept(uuid); - } - // Concept 6297 - public Concept getSkinAllergy() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.skinAllergy"); - return getConcept(uuid); - } - // Concept 6298 - public Concept getLipodystrophy() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.lipodystrophy"); - return getConcept(uuid); - } - // Concept 6299 - public Concept getLacticAcidosis() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.lacticAcidosis"); - return getConcept(uuid); - } - // Concept 821 - public Concept getPeripheralNeuropathy() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.peripheralNeuropathy"); - return getConcept(uuid); - } - // Concept 16 - public Concept getDiarrhea() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.diarrhea"); - return getConcept(uuid); - } - // Concept 1406 - public Concept getOtherDiagnosis() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.otherDiagnosis"); - return getConcept(uuid); - } - // Concept 23724 GAAC - public Concept getGaac() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.gaac"); - return getConcept(uuid); - } - // Concept 23725 AF - public Concept getFamilyApproach() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.familyApproach"); - return getConcept(uuid); - } - // Concept 23726 CA - public Concept getAccessionClubs() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.accessionClubs"); - return getConcept(uuid); - } - // Concept 23727 PU - public Concept getSingleStop() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.singleStop"); - return getConcept(uuid); - } - // Concept 23729 FR - public Concept getRapidFlow() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.rapidFlow"); - return getConcept(uuid); - } - // Concept 23730 DT - public Concept getQuarterlyDispensation() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.quarterlyDispensation"); - return getConcept(uuid); - } - // Concept 23731 DC - public Concept getCommunityDispensation() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.communityDispensation"); - return getConcept(uuid); - } - // Concept 23732 Other Model - public Concept getAnotherModel() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.anotherModel"); - return getConcept(uuid); - } - // Concept 1256 Start Drugs - public Concept getStartDrugs() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.startDrugs"); - return getConcept(uuid); - } - // Concept 1257 Continue Regimen - public Concept getContinueRegimen() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.continueRegimen"); - return getConcept(uuid); - } - // Concept 23808 Pre-ART Start Date - public Concept getPreArtStartDate() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.preArtStartDate"); - return getConcept(uuid); - } - - // Concept 23866 Date of ART Pickup - public Concept getArtDatePickup() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.preArtPickupDate"); - return getConcept(uuid); - } - - // Concept 6300 Date of ART Pickup - public Concept getTypeOfPatientTransferredFrom() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.typeOfPatientTransferredFrom"); - return getConcept(uuid); - } - - // Concept 6273 patient state - public Concept getStateOfStayOfArtPatient() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.stateOfStayArtPatient"); - return getConcept(uuid); - } - - // Concept 2031 REASON PATIENT NOT FOUND BY ACTIVIST - public Concept getReasonPatientNotFound() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.reasonPatientNotFound"); - return getConcept(uuid); - } - - // Concept 2027 PATIENT IS DEAD - public Concept getPatientIsDead() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.patientIsdead"); - return getConcept(uuid); - } - - // Concept 6276 Date of ART Pickup - public Concept getArtStatus() { - String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.art"); - return getConcept(uuid); - } - - // Concept 1706 TRANSFERRED OUT TO ANOTHER FACILITY - public Concept getTransferredOutConcept() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.transferOutToAnotherFacilityConceptUuid"); - return getConcept(uuid); - } - // Encounter types - // encounterType_id = 6 - public EncounterType getAdultoSeguimentoEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.sTarvAdultoSeguimentoEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounterType_id = 9 - public EncounterType getARVPediatriaSeguimentoEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.sTarvPediatriaSeguimentoEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounterType_id= 21 - public EncounterType getBuscaActivaEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.buscaActivaEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounterType_id = 5 - public EncounterType getARVAdultInitialEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.sTarvAdultoInitialAEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounterType_id = 7 - public EncounterType getARVPediatriaInitialEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.sTarvPediatriaInicialAEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounterType_id = 18 - public EncounterType getARVPharmaciaEncounterType() { - String uuid = - Context.getAdministrationService().getGlobalProperty(gpSTarvFarmaciaEncounterTypeUuid); - return getEncounterType(uuid); - } - - // encounter_type_id = 29 - public EncounterType getEvaluationAndPrepForARTEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.evaluationAndPrepForARTEncounterTypeUuid"); - return getEncounterType(uuid); - } - // encounter_type 13 - public EncounterType getMisauLaboratorioEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.misauLaboratorioEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounter type 34 - public EncounterType getPrevencaoPositivaInicialEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.apssPrevencaoPositivaInicialInicialEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounter type 35 - public EncounterType getPrevencaoPositivaSeguimentoEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.apssPrevencaoPositivaSeguimentoEncounterTypeUuid"); - return getEncounterType(uuid); - } - - /** - * encounter type 36 Coming from ICAP - * - * @return encounter type - */ - public EncounterType getVisitaApoioReintegracaoParteAEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.visitaApoioReintegracaoParteA"); - return getEncounterType(uuid); - } - - /** - * encounter type 37 Coming from ICAP - * - * @return encounter type - */ - public EncounterType getVisitaApoioReintegracaoParteBEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.visitaApoioReintegracaoParteB"); - return getEncounterType(uuid); - } - - // encounter_type_id = 1 - public EncounterType getARVAdultInitialBEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.adultInitialBEncounterType"); - return getEncounterType(uuid); - } - - // encounter_type_id = 3 - public EncounterType getARVPediatriaInitialBEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.pediatriaInitialBEncounterType"); - return getEncounterType(uuid); - } - - // encounter_type_id = 19 - public EncounterType getArtAconselhamentoEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.artAconselhamentoEncounterType"); - return getEncounterType(uuid); - } - - // encounter_type_id = 24 - public EncounterType getArtAconselhamentoSeguimentoEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.artAconselhamentoSeguimentoEncounterType"); - return getEncounterType(uuid); - } - - // encounter_type = 52 - public EncounterType getMasterCardDrugPickupEncounterType() { - String uuid = - Context.getAdministrationService() - .getGlobalProperty("eptsreports.masterCardDrugPickupEncounterTypeUuid"); - return getEncounterType(uuid); - } - - // encounter_type = 53 - public EncounterType getMasterCardEncounterType() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.masterCardEncounterType"); - return getEncounterType(uuid); - } - // Programs - - // program_id=2 - public Program getARTProgram() { - String uuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgram(uuid); - } - - public Program getPtvEtvProgram() { - String uuid = Context.getAdministrationService().getGlobalProperty(gpPtvEtvProgramUuid); - return getProgram(uuid); - } - - // program_id=1 - public Program getHIVCareProgram() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.hivCareProgramUuid"); - return getProgram(uuid); - } - - // Identifier types - public PatientIdentifierType getNidServiceTarvIdentifierType() { - String uuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.nidServicoTarvUuid"); - return getPatientIdentifierType(uuid); - } - - // Program Workflow States - public ProgramWorkflowState getTransferredOutToAnotherHealthFacilityWorkflowState() { - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgramWorkflowState(artProgramUuid, "2", "TRANSFERRED OUT TO ANOTHER FACILITY"); - } - - public ProgramWorkflowState getTransferredFromOtherHealthFacilityWorkflowState() { - // TODO Refactor this method, use #getTransferredFromOtherHealthFacilityWorkflowState(Program, - // ProgramWorkflow) - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - String transferFromOtherUuid = - Context.getAdministrationService() - .getGlobalProperty(gpTransferFromOtherFacilityConceptUuid); - return getProgramWorkflowState(artProgramUuid, "2", transferFromOtherUuid); - } - - public ProgramWorkflowState getArtCareTransferredFromOtherHealthFacilityWorkflowState() { - Program hivCareProgram = getHIVCareProgram(); - ProgramWorkflow workflow = getPreArtWorkflow(); - ProgramWorkflowState state = - getTransferredFromOtherHealthFacilityWorkflowState(hivCareProgram, workflow); - return state; - } - - public ProgramWorkflowState getArtTransferredFromOtherHealthFacilityWorkflowState() { - Program hivCareProgram = getARTProgram(); - ProgramWorkflow workflow = getArtWorkflow(); - ProgramWorkflowState state = - getTransferredFromOtherHealthFacilityWorkflowState(hivCareProgram, workflow); - return state; - } - - public ProgramWorkflowState getArtCareTransferredOutToAnotherHealthFacilityWorkflowState() { - Program hivCareProgram = getHIVCareProgram(); - ProgramWorkflow workflow = getPreArtWorkflow(); - ProgramWorkflowState state = - getTransferredOutToAnotherHealthFacilityWorkflowState(hivCareProgram, workflow); - return state; - } - - public ProgramWorkflowState getArtCareActiveOnProgramWorkflowState() { - Program hivCareProgram = getHIVCareProgram(); - ProgramWorkflow workflow = getPreArtWorkflow(); - ProgramWorkflowState state = getActiveOnProgramWorkflowState(hivCareProgram, workflow); - return state; - } - - public ProgramWorkflowState getArtActiveOnProgramWorkflowState() { - Program hivCareProgram = getARTProgram(); - ProgramWorkflow workflow = getArtWorkflow(); - ProgramWorkflowState state = getActiveOnProgramWorkflowState(hivCareProgram, workflow); - return state; - } - - public ProgramWorkflowState getArtCareAbandonedWorkflowState() { - Program hivCareProgram = getHIVCareProgram(); - ProgramWorkflow workflow = getPreArtWorkflow(); - ProgramWorkflowState state = getAbandonedWorkflowState(hivCareProgram, workflow); - return state; - } - - public ProgramWorkflowState getSuspendedTreatmentWorkflowState() { - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgramWorkflowState(artProgramUuid, "2", "SUSPEND TREATMENT"); - } - - public ProgramWorkflowState getAbandonedWorkflowState() { - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgramWorkflowState(artProgramUuid, "2", "ABANDONED"); - } - - public ProgramWorkflowState getPatientHasDiedWorkflowState() { - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgramWorkflowState(artProgramUuid, "2", "PATIENT HAS DIED"); - } - - public ProgramWorkflowState getPatientIsBreastfeedingWorkflowState() { - String ptvProgramUuid = - Context.getAdministrationService().getGlobalProperty(gpPtvEtvProgramUuid); - return getProgramWorkflowState(ptvProgramUuid, "5", "GAVE BIRTH"); - } - - public ProgramWorkflowState getArtCareDeadWorkflowState() { - Program hivCareProgram = getHIVCareProgram(); - ProgramWorkflow workflow = getPreArtWorkflow(); - return getDeadWorkflowState(hivCareProgram, workflow); - } - - public ProgramWorkflowState getPateintActiveArtWorkflowState() { - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgramWorkflowState(artProgramUuid, "2", "c50d6bdc-8a79-43ae-ab45-abbaa6b45e7d"); - } - - public ProgramWorkflowState getPateintTransferedFromOtherFacilityWorkflowState() { - String artProgramUuid = Context.getAdministrationService().getGlobalProperty(gpArtProgramUuid); - return getProgramWorkflowState(artProgramUuid, "2", "TRANSFER FROM OTHER FACILITY"); - } - - public ProgramWorkflowState getPateintPregnantWorkflowState() { - String ptvProgramUuid = - Context.getAdministrationService().getGlobalProperty(gpPtvEtvProgramUuid); - return getProgramWorkflowState(ptvProgramUuid, "5", "PREGNANT"); - } - - public ProgramWorkflowState getPateintActiveOnHIVCareProgramtWorkflowState() { - String hivCareProgramUuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.hivCareProgramUuid"); - return getProgramWorkflowState(hivCareProgramUuid, "1", "ACTIVE ON PROGRAM"); - } - - public ProgramWorkflowState getPateintTransferedFromOtherFacilityHIVCareWorkflowState() { - String hivCareProgramUuid = - Context.getAdministrationService().getGlobalProperty("eptsreports.hivCareProgramUuid"); - return getProgramWorkflowState(hivCareProgramUuid, "1", "TRANSFER FROM OTHER FACILITY"); - } - - // Concept 5356 - public Concept getCurrentWHOHIVStageConcept() { - return getConcept( - Context.getAdministrationService() - .getGlobalProperty("eptsreports.currentWHOHIVStageConceptUuid")); - } - - public ProgramWorkflow getPreArtWorkflow() { - return getProgramWorkflow(getHIVCareProgram().getUuid(), "1"); - } - - private ProgramWorkflowState getActiveOnProgramWorkflowState( - Program program, ProgramWorkflow programWorkflow) { - Concept activeOnProgram = getActiveOnProgramConcept(); - return getProgramWorkflowState( - program.getUuid(), programWorkflow.getUuid(), activeOnProgram.getUuid()); - } - - private ProgramWorkflowState getAbandonedWorkflowState( - Program program, ProgramWorkflow programWorkflow) { - Concept abandoned = getAbandoned(); - return getProgramWorkflowState( - program.getUuid(), programWorkflow.getUuid(), abandoned.getUuid()); - } - - private ProgramWorkflowState getDeadWorkflowState( - Program program, ProgramWorkflow programWorkflow) { - Concept dead = getPatientHasDiedConcept(); - return getProgramWorkflowState(program.getUuid(), programWorkflow.getUuid(), dead.getUuid()); - } - - private ProgramWorkflowState getTransferredOutToAnotherHealthFacilityWorkflowState( - Program program, ProgramWorkflow programWorkflow) { - Concept transferOutToAnotherFacility = getTransferOutToAnotherFacilityConcept(); - return getProgramWorkflowState( - program.getUuid(), programWorkflow.getUuid(), transferOutToAnotherFacility.getUuid()); - } - - private ProgramWorkflowState getTransferredFromOtherHealthFacilityWorkflowState( - Program program, ProgramWorkflow programWorkflow) { - Concept transferFromOtherFacility = getTransferFromOtherFacilityConcept(); - return getProgramWorkflowState( - program.getUuid(), programWorkflow.getUuid(), transferFromOtherFacility.getUuid()); - } - - public ProgramWorkflowState getArtCareInitiatedWorkflowState() { - Program hivCareProgram = getHIVCareProgram(); - ProgramWorkflow workflow = getPreArtWorkflow(); - Concept startDrugs = getStartDrugsConcept(); - return getProgramWorkflowState( - hivCareProgram.getUuid(), workflow.getUuid(), startDrugs.getUuid()); - } - - public ProgramWorkflowState getArtSuspendedTreatmentWorkflowState() { - Program artProgram = getARTProgram(); - ProgramWorkflow workflow = getArtWorkflow(); - Concept suspendedTreatment = getSuspendedTreatmentConcept(); - return getProgramWorkflowState( - artProgram.getUuid(), workflow.getUuid(), suspendedTreatment.getUuid()); - } - - private ProgramWorkflow getArtWorkflow() { - return getProgramWorkflow(getARTProgram().getUuid(), "2"); - } - - public ProgramWorkflowState getArtTransferredOutToAnotherHealthFacilityWorkflowState() { - Program artProgram = getARTProgram(); - ProgramWorkflow workflow = getArtWorkflow(); - ProgramWorkflowState state = - getTransferredOutToAnotherHealthFacilityWorkflowState(artProgram, workflow); - return state; - } - - public ProgramWorkflowState getArtDeadWorkflowState() { - Program artProgram = getARTProgram(); - ProgramWorkflow workflow = getArtWorkflow(); - return getDeadWorkflowState(artProgram, workflow); - } - - public ProgramWorkflowState getArtAbandonedWorkflowState() { - Program artProgram = getARTProgram(); - ProgramWorkflow workflow = getArtWorkflow(); - ProgramWorkflowState state = getAbandonedWorkflowState(artProgram, workflow); - return state; - } + private final String gpSTarvFarmaciaEncounterTypeUuid = "eptsreports.sTarvFarmaciaEncounterTypeUuid"; + + private final String gpArtProgramUuid = "eptsreports.artProgramUuid"; + + private final String gpPtvEtvProgramUuid = "eptsreports.ptvEtvProgramUuid"; + + // Concepts Id = 856 + public Concept getHivViralLoadConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.hivViralLoadConceptUuid"); + return getConcept(uuid); + } + + public Concept getCriteriaForArtStart() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.criteriaForArtStartUuid"); + return getConcept(uuid); + } + + // concept_id=5096 + public Concept getReturnVisitDateForArvDrugConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.returnVisitDateForArvDrugConceptUuid"); + return getConcept(uuid); + } + + // concept_id=6123 + public Concept getDateOfHivDiagnosisConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.dateOfHIVDiagnosis"); + return getConcept(uuid); + } + + // concept_id=1190 + public Concept getARVStartDate() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.historicalStartDateConceptUuid"); + return getConcept(uuid); + } + + // concept_id=1255 + public Concept getARVPlanConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.arvPlanConceptUuid"); + return getConcept(uuid); + } + + // concept_id=1088 + public Concept getRegimeConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.regimeUuid"); + return getConcept(uuid); + } + + public Concept getRestartConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.restartConceptUuid"); + return getConcept(uuid); + } + + // concept_id = 1707 + public Concept getAbandoned() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.abandonedConceptUuid"); + return getConcept(uuid); + } + + // Second line ARV concepts + // 6328 + public Concept getAzt3tcAbcEfvConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.AZT_3TC_ABC_EFV_ConceptUuid"); + return getConcept(uuid); + } + + // 6327 + public Concept getD4t3tcAbcEfvConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.D4T_3TC_ABC_EFV_ConceptUuid"); + return getConcept(uuid); + } + + // 6326 + public Concept getAzt3tcAbcLpvConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.AZT_3TC_ABC_LPV_ConceptUuid"); + return getConcept(uuid); + } + + // 6325 + public Concept getD4t3tcAbcLpvConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.D4T_3TC_ABC_LPV_ConceptUuid"); + return getConcept(uuid); + } + + // 6109 + public Concept getAztDdiLpvConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.AZT_DDI_LPV_ConceptUuid"); + return getConcept(uuid); + } + + // 1315 + public Concept getTdf3tcEfvConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.TDF_3TC_EFV_ConceptUuid"); + return getConcept(uuid); + } + + // 1314 + public Concept getAzt3tcLpvConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.AZT_3TC_LPV_ConceptUuid"); + return getConcept(uuid); + } + + // 1313 + public Concept getAbc3tcEfvConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.ABC_3TC_EFV_ConceptUuid"); + return getConcept(uuid); + } + + // 1312 + public Concept getAbc3tcNvpConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.ABC_3TC_NVP_ConceptUuid"); + return getConcept(uuid); + } + + // 1311 + public Concept getAbc3tcLpvConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.ABC_3TC_LPV_ConceptUuid"); + return getConcept(uuid); + } + + // + public Concept getTdf3tcLpvConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.TDF_3TC_LPV_ConceptUuid"); + return getConcept(uuid); + } + + // concept id 6306 + public Concept getAcceptContactConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.acceptContactConceptUuid"); + return getConcept(uuid); + } + + // concept id 1066 + @Override + public Concept getNoConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.noConceptUuid"); + return getConcept(uuid); + } + + public Concept getDataInicioProfilaxiaIsoniazidaConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.DataInicioProfilaxiaIsoniazidaConceptUuid"); + return getConcept(uuid); + } + + public Concept getDataFinalizacaoProfilaxiaIsoniazidaConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.DataFimProfilaxiaIsoniazidaConceptUuid"); + return getConcept(uuid); + } + + // concept_id=6122 + public Concept getIsoniazidUsageConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.isoniazidUseConceptUuid"); + return getConcept(uuid); + } + + // concept_id=1695 + public Concept getCD4AbsoluteOBSConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.cd4AbsoluteOBSUuid"); + return getConcept(uuid); + } + + // concept_id=6314 + public Concept getCoucelingActivityConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.coucelingActivityTypeUuid"); + return getConcept(uuid); + } + + // concept_id=5356 + public Concept getcurrentWhoHivStageConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.currentWhoHivStageUuid"); + return getConcept(uuid); + } + + // concept_id=1205 + public Concept getWho2AdultStageConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.who2AdultStageUuid"); + return getConcept(uuid); + } + + // concept_id=1206 + public Concept getWho3AdultStageConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.who3AdultStageUuid"); + return getConcept(uuid); + } + + // concept_id=1207 + public Concept getWho4AdultStageConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.who4AdultStageUuid"); + return getConcept(uuid); + } + + // concept_id = 1366 + public Concept getPatientHasDiedConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.patientHasDiedConceptUuid"); + return getConcept(uuid); + } + + // concept_id = 1981 + public Concept getTypeOfVisitConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.typeOfVisit"); + return getConcept(uuid); + } + + // concept_id = 2003 + public Concept getPatientFoundConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.patientFound"); + return getConcept(uuid); + } + + // concept_id = 1065 + public Concept getPatientFoundYesConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.yesConceptUuid"); + return getConcept(uuid); + } + + // concept_id = 2160 + public Concept getBuscaConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.busca"); + return getConcept(uuid); + } + + // concept_id = 6254 + public Concept getSecondAttemptConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.secondAttempt"); + return getConcept(uuid); + } + + // concept_id = 6255 + public Concept getThirdAttemptConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.thirdAttempt"); + return getConcept(uuid); + } + + // concept_id = 2016 + public Concept getDefaultingMotiveConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.defaultingMotive"); + return getConcept(uuid); + } + + // concept_id = 2158 + public Concept getReportOfVisitSupportConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.reportOfVisitSupport"); + return getConcept(uuid); + } + + // concept_id = 2157 + public Concept getPatientHadDifficultyConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.patientHadDifficulty"); + return getConcept(uuid); + } + + // concept_id = 1272 + public Concept getPatientFoundForwardedConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.patientFoundForwarded"); + return getConcept(uuid); + } + + // concept_id = 2037 + public Concept getWhoGaveInformationConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.whoGaveInformation"); + return getConcept(uuid); + } + + // concept_id = 2180 + public Concept getCardDeliveryDateConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.cardDeliveryDate"); + return getConcept(uuid); + } + + // concept_id = 1709 + public Concept getSuspendedTreatmentConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.suspendedTreatmentConceptUuid"); + return getConcept(uuid); + } + + // concept_id = 6269 + private Concept getActiveOnProgramConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.activeOnProgramConcept"); + return getConcept(uuid); + } + + // concept_id = 1126 + public Concept getUrogenitalExamFindingsConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.urogenitalExamFindingsConcept"); + return getConcept(uuid); + } + + // concept_id = 1115 + public Concept getNormalConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.normalConcept"); + return getConcept(uuid); + } + + // concept_id = 1116 + public Concept getAbnormalConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.abnormalConcept"); + return getConcept(uuid); + } + + // concept_id = 1399 + public Concept getSecretionsConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.secretionsConcept"); + return getConcept(uuid); + } + + // concept_id = 1400 + public Concept getCondylomasConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.condylomasConcept"); + return getConcept(uuid); + } + + // concept_id = 1602 + public Concept getUlcersConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.ulcersConcept"); + return getConcept(uuid); + } + + // concept_id=5488 + public Concept getAdherenceCoucelingConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.adherenceCounselingUuid"); + return getConcept(uuid); + } + + // concept_id=5497 + public Concept getCD4AbsoluteConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.cd4AbsolutoUuid"); + return getConcept(uuid); + } + + // concept_id=730 + public Concept getCD4PercentConcept() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.cd4PercentUuid"); + return getConcept(uuid); + } + + // concept_id=1714 + public Concept getAdherence() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.poorAdherenceUuid"); + return getConcept(uuid); + } + + // concept_id=2015 + public Concept getAdverseReaction() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.adverseReactionUuid"); + return getConcept(uuid); + } + + // Concept 6292 + public Concept getNeutropenia() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.neutropenia"); + return getConcept(uuid); + } + + // Concept 6293 + public Concept getPancreatitis() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.pancreatitis"); + return getConcept(uuid); + } + + // Concept 6294 + public Concept getHepatotoxicity() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.hepatotoxicity"); + return getConcept(uuid); + } + + // Concept 6295 + public Concept getPsychologicalChanges() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.psychologicalChanges"); + return getConcept(uuid); + } + + // Concept 6296 + public Concept getMyopathy() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.myopathy"); + return getConcept(uuid); + } + + // Concept 6297 + public Concept getSkinAllergy() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.skinAllergy"); + return getConcept(uuid); + } + + // Concept 6298 + public Concept getLipodystrophy() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.lipodystrophy"); + return getConcept(uuid); + } + + // Concept 6299 + public Concept getLacticAcidosis() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.lacticAcidosis"); + return getConcept(uuid); + } + + // Concept 821 + public Concept getPeripheralNeuropathy() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.peripheralNeuropathy"); + return getConcept(uuid); + } + + // Concept 16 + public Concept getDiarrhea() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.diarrhea"); + return getConcept(uuid); + } + + // Concept 1406 + public Concept getOtherDiagnosis() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.otherDiagnosis"); + return getConcept(uuid); + } + + // Concept 23724 GAAC + public Concept getGaac() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.gaac"); + return getConcept(uuid); + } + + // Concept 23725 AF + public Concept getFamilyApproach() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.familyApproach"); + return getConcept(uuid); + } + + // Concept 23726 CA + public Concept getAccessionClubs() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.accessionClubs"); + return getConcept(uuid); + } + + // Concept 23727 PU + public Concept getSingleStop() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.singleStop"); + return getConcept(uuid); + } + + // Concept 23729 FR + public Concept getRapidFlow() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.rapidFlow"); + return getConcept(uuid); + } + + // Concept 23730 DT + public Concept getQuarterlyDispensation() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.quarterlyDispensation"); + return getConcept(uuid); + } + + // Concept 23731 DC + public Concept getCommunityDispensation() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.communityDispensation"); + return getConcept(uuid); + } + + // Concept 23732 Other Model + public Concept getAnotherModel() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.anotherModel"); + return getConcept(uuid); + } + + // Concept 1256 Start Drugs + public Concept getStartDrugs() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.startDrugs"); + return getConcept(uuid); + } + + // Concept 1257 Continue Regimen + public Concept getContinueRegimen() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.continueRegimen"); + return getConcept(uuid); + } + + // Concept 23808 Pre-ART Start Date + public Concept getPreArtStartDate() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.preArtStartDate"); + return getConcept(uuid); + } + + // Concept 23866 Date of ART Pickup + public Concept getArtDatePickup() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.preArtPickupDate"); + return getConcept(uuid); + } + + // Concept 6300 Date of ART Pickup + public Concept getTypeOfPatientTransferredFrom() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.typeOfPatientTransferredFrom"); + return getConcept(uuid); + } + + // Concept 6273 patient state + public Concept getStateOfStayOfArtPatient() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.stateOfStayArtPatient"); + return getConcept(uuid); + } + + // Concept 2031 REASON PATIENT NOT FOUND BY ACTIVIST + public Concept getReasonPatientNotFound() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.reasonPatientNotFound"); + return getConcept(uuid); + } + + // Concept 2027 PATIENT IS DEAD + public Concept getPatientIsDead() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.patientIsdead"); + return getConcept(uuid); + } + + // Concept 6276 Date of ART Pickup + public Concept getArtStatus() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.art"); + return getConcept(uuid); + } + + // Concept 1706 TRANSFERRED OUT TO ANOTHER FACILITY + public Concept getTransferredOutConcept() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.transferOutToAnotherFacilityConceptUuid"); + return getConcept(uuid); + } + + // Concept 23722 APPLICATION FOR LABORATORY RESEARCH + public Concept getApplicationForLaboratoryResearch() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.applicationForLaboratoryResearch"); + return getConcept(uuid); + } + + // Concept 1305 HIV VIRAL LOAD, QUALITATIVE + public Concept getHivViralLoadQualitative() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.viralLoadQualitativeConceptUuid"); + return getConcept(uuid); + } + + // Encounter types + // encounterType_id = 6 + public EncounterType getAdultoSeguimentoEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.sTarvAdultoSeguimentoEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounterType_id = 9 + public EncounterType getARVPediatriaSeguimentoEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.sTarvPediatriaSeguimentoEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounterType_id= 21 + public EncounterType getBuscaActivaEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.buscaActivaEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounterType_id = 5 + public EncounterType getARVAdultInitialEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.sTarvAdultoInitialAEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounterType_id = 7 + public EncounterType getARVPediatriaInitialEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.sTarvPediatriaInicialAEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounterType_id = 18 + public EncounterType getARVPharmaciaEncounterType() { + final String uuid = Context.getAdministrationService().getGlobalProperty(this.gpSTarvFarmaciaEncounterTypeUuid); + return getEncounterType(uuid); + } + + // encounter_type_id = 29 + public EncounterType getEvaluationAndPrepForARTEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.evaluationAndPrepForARTEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounter_type 13 + public EncounterType getMisauLaboratorioEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.misauLaboratorioEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounter type 34 + public EncounterType getPrevencaoPositivaInicialEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.apssPrevencaoPositivaInicialInicialEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounter type 35 + public EncounterType getPrevencaoPositivaSeguimentoEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.apssPrevencaoPositivaSeguimentoEncounterTypeUuid"); + return getEncounterType(uuid); + } + + /** + * encounter type 36 Coming from ICAP + * + * @return encounter type + */ + public EncounterType getVisitaApoioReintegracaoParteAEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.visitaApoioReintegracaoParteA"); + return getEncounterType(uuid); + } + + /** + * encounter type 37 Coming from ICAP + * + * @return encounter type + */ + public EncounterType getVisitaApoioReintegracaoParteBEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.visitaApoioReintegracaoParteB"); + return getEncounterType(uuid); + } + + // encounter_type_id = 1 + public EncounterType getARVAdultInitialBEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.adultInitialBEncounterType"); + return getEncounterType(uuid); + } + + // encounter_type_id = 3 + public EncounterType getARVPediatriaInitialBEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.pediatriaInitialBEncounterType"); + return getEncounterType(uuid); + } + + // encounter_type_id = 19 + public EncounterType getArtAconselhamentoEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.artAconselhamentoEncounterType"); + return getEncounterType(uuid); + } + + // encounter_type_id = 24 + public EncounterType getArtAconselhamentoSeguimentoEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.artAconselhamentoSeguimentoEncounterType"); + return getEncounterType(uuid); + } + + // encounter_type = 52 + public EncounterType getMasterCardDrugPickupEncounterType() { + final String uuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.masterCardDrugPickupEncounterTypeUuid"); + return getEncounterType(uuid); + } + + // encounter_type = 53 + public EncounterType getMasterCardEncounterType() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.masterCardEncounterType"); + return getEncounterType(uuid); + } + // Programs + + // program_id=2 + public Program getARTProgram() { + final String uuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgram(uuid); + } + + public Program getPtvEtvProgram() { + final String uuid = Context.getAdministrationService().getGlobalProperty(this.gpPtvEtvProgramUuid); + return getProgram(uuid); + } + + // program_id=1 + public Program getHIVCareProgram() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.hivCareProgramUuid"); + return getProgram(uuid); + } + + // Identifier types + public PatientIdentifierType getNidServiceTarvIdentifierType() { + final String uuid = Context.getAdministrationService().getGlobalProperty("eptsreports.nidServicoTarvUuid"); + return getPatientIdentifierType(uuid); + } + + // Program Workflow States + public ProgramWorkflowState getTransferredOutToAnotherHealthFacilityWorkflowState() { + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgramWorkflowState(artProgramUuid, "2", "TRANSFERRED OUT TO ANOTHER FACILITY"); + } + + public ProgramWorkflowState getTransferredFromOtherHealthFacilityWorkflowState() { + // TODO Refactor this method, use + // #getTransferredFromOtherHealthFacilityWorkflowState(Program, + // ProgramWorkflow) + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + final String transferFromOtherUuid = Context.getAdministrationService() + .getGlobalProperty(this.gpTransferFromOtherFacilityConceptUuid); + return getProgramWorkflowState(artProgramUuid, "2", transferFromOtherUuid); + } + + public ProgramWorkflowState getArtCareTransferredFromOtherHealthFacilityWorkflowState() { + final Program hivCareProgram = this.getHIVCareProgram(); + final ProgramWorkflow workflow = this.getPreArtWorkflow(); + final ProgramWorkflowState state = this.getTransferredFromOtherHealthFacilityWorkflowState(hivCareProgram, + workflow); + return state; + } + + public ProgramWorkflowState getArtTransferredFromOtherHealthFacilityWorkflowState() { + final Program hivCareProgram = this.getARTProgram(); + final ProgramWorkflow workflow = this.getArtWorkflow(); + final ProgramWorkflowState state = this.getTransferredFromOtherHealthFacilityWorkflowState(hivCareProgram, + workflow); + return state; + } + + public ProgramWorkflowState getArtCareTransferredOutToAnotherHealthFacilityWorkflowState() { + final Program hivCareProgram = this.getHIVCareProgram(); + final ProgramWorkflow workflow = this.getPreArtWorkflow(); + final ProgramWorkflowState state = this.getTransferredOutToAnotherHealthFacilityWorkflowState(hivCareProgram, + workflow); + return state; + } + + public ProgramWorkflowState getArtCareActiveOnProgramWorkflowState() { + final Program hivCareProgram = this.getHIVCareProgram(); + final ProgramWorkflow workflow = this.getPreArtWorkflow(); + final ProgramWorkflowState state = this.getActiveOnProgramWorkflowState(hivCareProgram, workflow); + return state; + } + + public ProgramWorkflowState getArtActiveOnProgramWorkflowState() { + final Program hivCareProgram = this.getARTProgram(); + final ProgramWorkflow workflow = this.getArtWorkflow(); + final ProgramWorkflowState state = this.getActiveOnProgramWorkflowState(hivCareProgram, workflow); + return state; + } + + public ProgramWorkflowState getArtCareAbandonedWorkflowState() { + final Program hivCareProgram = this.getHIVCareProgram(); + final ProgramWorkflow workflow = this.getPreArtWorkflow(); + final ProgramWorkflowState state = this.getAbandonedWorkflowState(hivCareProgram, workflow); + return state; + } + + public ProgramWorkflowState getSuspendedTreatmentWorkflowState() { + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgramWorkflowState(artProgramUuid, "2", "SUSPEND TREATMENT"); + } + + public ProgramWorkflowState getAbandonedWorkflowState() { + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgramWorkflowState(artProgramUuid, "2", "ABANDONED"); + } + + public ProgramWorkflowState getPatientHasDiedWorkflowState() { + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgramWorkflowState(artProgramUuid, "2", "PATIENT HAS DIED"); + } + + public ProgramWorkflowState getPatientIsBreastfeedingWorkflowState() { + final String ptvProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpPtvEtvProgramUuid); + return getProgramWorkflowState(ptvProgramUuid, "5", "GAVE BIRTH"); + } + + public ProgramWorkflowState getArtCareDeadWorkflowState() { + final Program hivCareProgram = this.getHIVCareProgram(); + final ProgramWorkflow workflow = this.getPreArtWorkflow(); + return this.getDeadWorkflowState(hivCareProgram, workflow); + } + + public ProgramWorkflowState getPateintActiveArtWorkflowState() { + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgramWorkflowState(artProgramUuid, "2", "c50d6bdc-8a79-43ae-ab45-abbaa6b45e7d"); + } + + public ProgramWorkflowState getPateintTransferedFromOtherFacilityWorkflowState() { + final String artProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpArtProgramUuid); + return getProgramWorkflowState(artProgramUuid, "2", "TRANSFER FROM OTHER FACILITY"); + } + + public ProgramWorkflowState getPateintPregnantWorkflowState() { + final String ptvProgramUuid = Context.getAdministrationService().getGlobalProperty(this.gpPtvEtvProgramUuid); + return getProgramWorkflowState(ptvProgramUuid, "5", "PREGNANT"); + } + + public ProgramWorkflowState getPateintActiveOnHIVCareProgramtWorkflowState() { + final String hivCareProgramUuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.hivCareProgramUuid"); + return getProgramWorkflowState(hivCareProgramUuid, "1", "ACTIVE ON PROGRAM"); + } + + public ProgramWorkflowState getPateintTransferedFromOtherFacilityHIVCareWorkflowState() { + final String hivCareProgramUuid = Context.getAdministrationService() + .getGlobalProperty("eptsreports.hivCareProgramUuid"); + return getProgramWorkflowState(hivCareProgramUuid, "1", "TRANSFER FROM OTHER FACILITY"); + } + + // Concept 5356 + public Concept getCurrentWHOHIVStageConcept() { + return getConcept( + Context.getAdministrationService().getGlobalProperty("eptsreports.currentWHOHIVStageConceptUuid")); + } + + public ProgramWorkflow getPreArtWorkflow() { + return getProgramWorkflow(this.getHIVCareProgram().getUuid(), "1"); + } + + private ProgramWorkflowState getActiveOnProgramWorkflowState(final Program program, + final ProgramWorkflow programWorkflow) { + final Concept activeOnProgram = this.getActiveOnProgramConcept(); + return getProgramWorkflowState(program.getUuid(), programWorkflow.getUuid(), activeOnProgram.getUuid()); + } + + private ProgramWorkflowState getAbandonedWorkflowState(final Program program, + final ProgramWorkflow programWorkflow) { + final Concept abandoned = this.getAbandoned(); + return getProgramWorkflowState(program.getUuid(), programWorkflow.getUuid(), abandoned.getUuid()); + } + + private ProgramWorkflowState getDeadWorkflowState(final Program program, final ProgramWorkflow programWorkflow) { + final Concept dead = this.getPatientHasDiedConcept(); + return getProgramWorkflowState(program.getUuid(), programWorkflow.getUuid(), dead.getUuid()); + } + + private ProgramWorkflowState getTransferredOutToAnotherHealthFacilityWorkflowState(final Program program, + final ProgramWorkflow programWorkflow) { + final Concept transferOutToAnotherFacility = this.getTransferOutToAnotherFacilityConcept(); + return getProgramWorkflowState(program.getUuid(), programWorkflow.getUuid(), + transferOutToAnotherFacility.getUuid()); + } + + private ProgramWorkflowState getTransferredFromOtherHealthFacilityWorkflowState(final Program program, + final ProgramWorkflow programWorkflow) { + final Concept transferFromOtherFacility = this.getTransferFromOtherFacilityConcept(); + return getProgramWorkflowState(program.getUuid(), programWorkflow.getUuid(), + transferFromOtherFacility.getUuid()); + } + + public ProgramWorkflowState getArtCareInitiatedWorkflowState() { + final Program hivCareProgram = this.getHIVCareProgram(); + final ProgramWorkflow workflow = this.getPreArtWorkflow(); + final Concept startDrugs = this.getStartDrugsConcept(); + return getProgramWorkflowState(hivCareProgram.getUuid(), workflow.getUuid(), startDrugs.getUuid()); + } + + public ProgramWorkflowState getArtSuspendedTreatmentWorkflowState() { + final Program artProgram = this.getARTProgram(); + final ProgramWorkflow workflow = this.getArtWorkflow(); + final Concept suspendedTreatment = this.getSuspendedTreatmentConcept(); + return getProgramWorkflowState(artProgram.getUuid(), workflow.getUuid(), suspendedTreatment.getUuid()); + } + + private ProgramWorkflow getArtWorkflow() { + return getProgramWorkflow(this.getARTProgram().getUuid(), "2"); + } + + public ProgramWorkflowState getArtTransferredOutToAnotherHealthFacilityWorkflowState() { + final Program artProgram = this.getARTProgram(); + final ProgramWorkflow workflow = this.getArtWorkflow(); + final ProgramWorkflowState state = this.getTransferredOutToAnotherHealthFacilityWorkflowState(artProgram, + workflow); + return state; + } + + public ProgramWorkflowState getArtDeadWorkflowState() { + final Program artProgram = this.getARTProgram(); + final ProgramWorkflow workflow = this.getArtWorkflow(); + return this.getDeadWorkflowState(artProgram, workflow); + } + + public ProgramWorkflowState getArtAbandonedWorkflowState() { + final Program artProgram = this.getARTProgram(); + final ProgramWorkflow workflow = this.getArtWorkflow(); + final ProgramWorkflowState state = this.getAbandonedWorkflowState(artProgram, workflow); + return state; + } } diff --git a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ResumoMensalCohortQueries.java b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ResumoMensalCohortQueries.java index 603b0177f1..2268d04c29 100644 --- a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ResumoMensalCohortQueries.java +++ b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/cohorts/ResumoMensalCohortQueries.java @@ -18,6 +18,7 @@ import static org.openmrs.module.reporting.evaluation.parameter.Mapped.mapStraightThrough; import java.util.Date; +import org.openmrs.Concept; import org.openmrs.Location; import org.openmrs.api.context.Context; import org.openmrs.module.eptsreports.metadata.HivMetadata; @@ -43,11 +44,14 @@ public class ResumoMensalCohortQueries { private HivMetadata hivMetadata; private TbMetadata tbMetadata; + private GenericCohortQueries genericCohortQueries; @Autowired - public ResumoMensalCohortQueries(HivMetadata hivMetadata, TbMetadata tbMetadata) { + public ResumoMensalCohortQueries( + HivMetadata hivMetadata, TbMetadata tbMetadata, GenericCohortQueries genericCohortQueries) { this.hivMetadata = hivMetadata; this.tbMetadata = tbMetadata; + this.genericCohortQueries = genericCohortQueries; } /** A1 Number of patients who initiated Pre-TARV at this HF by end of previous month */ @@ -479,4 +483,357 @@ private DateObsCohortDefinition getLastArvPickupDateCohort() { cd.setTimeModifier(BaseObsCohortDefinition.TimeModifier.LAST); return cd; } + + /** + * E1: Number of active patients in ART at the end of current month who performed Viral Load Test + * (Annual Notification) B12 OR (B1 OR B2 OR B3) AND NOT (B5 OR B6 OR B7 OR B8) + * + * @return CohortDefinition + */ + public CohortDefinition getNumberOfActivePatientsInArtAtEndOfCurrentMonthWithVlPerformed() { + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName( + "Number of active patients in ART at the end of current month who performed Viral Load Test (Annual Notification)"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + + cd.addSearch( + "common", + map( + getStandardDefinitionForEcolumns(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + + cd.addSearch( + "F", + map( + getPatientsWithCodedObsAndAnswers( + hivMetadata.getApplicationForLaboratoryResearch(), + hivMetadata.getHivViralLoadConcept()), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "E1x", + map( + genericCohortQueries.generalSql( + "E1x", + ResumoMensalQueries.getE1ExclusionCriteria( + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId(), + hivMetadata.getApplicationForLaboratoryResearch().getConceptId(), + hivMetadata.getHivViralLoadConcept().getConceptId())), + "startDate=${startDate},endDate=${endDate},location=${location}")); + + cd.setCompositionString("(common AND F) AND NOT E1x"); + return cd; + } + + public CohortDefinition getStandardDefinitionForEcolumns() { + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName("Standard columns for E1, E2 and E3"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + + cd.addSearch( + "B12", + map( + getPatientsWhoInitiatedPreTarvDuringCurrentMonthAndScreenedTB(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "B1", + map( + getPatientsWhoInitiatedTarvAtThisFacilityDuringCurrentMonthB1(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "B2", + map( + getNumberOfPatientsTransferredInFromOtherHealthFacilitiesDuringCurrentMonthB2(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "B3", + map( + getPatientsWithStartDrugs(), + "onOrAfter=${startDate},onOrBefore=${endDate},locationList=${location}")); + cd.addSearch( + "B5", + map( + getPatientsTransferredOut(), + "onOrAfter=${startDate},onOrBefore=${endDate},locationList=${location}")); + cd.addSearch( + "B6", + map( + getPatientsWhoSuspendedTreatment(), + "onOrAfter=${startDate},onOrBefore=${endDate},locationList=${location}")); + cd.addSearch( + "B7", + map( + getNumberOfPatientsWhoAbandonedArtDuringCurrentMonthB7(), + "onOrBefore=${endDate},locationList=${location},value1=${endDate-90d},value2=${endDate}")); + cd.addSearch( + "B8", + map( + getPatientsWhoDied(), + "onOrAfter=${startDate},onOrBefore=${endDate},locationList=${location}")); + cd.setCompositionString("(B12 OR (B1 OR B2 OR B3)) AND NOT (B5 OR B6 OR B7 OR B8)"); + return cd; + } + + /** Filter only those patients */ + private CohortDefinition getPatientsWithCodedObsAndAnswers(Concept question, Concept answer) { + SqlCohortDefinition cd = new SqlCohortDefinition(); + cd.setName( + "Patients with lab request having question and answer - encounter date within boundaries"); + cd.addParameter(new Parameter("startDate", "After Date", Date.class)); + cd.addParameter(new Parameter("endDate", "Before Date", Date.class)); + cd.addParameter(new Parameter("location", "location", Location.class)); + cd.setQuery( + ResumoMensalQueries.getPatientsWithCodedObsAndAnswers( + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId(), + question.getConceptId(), + answer.getConceptId())); + return cd; + } + + /** + * get patients who have viral load test done + * + * @return CohortDefinition + */ + private CohortDefinition getViralLoadTestDone() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + cd.setName("Viral load test"); + cd.addParameter(new Parameter("startDate", "After Date", Date.class)); + cd.addParameter(new Parameter("endDate", "Before Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.setQuery( + ResumoMensalQueries.getPatientsHavingViralLoadResults( + hivMetadata.getHivViralLoadConcept().getConceptId(), + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId())); + return cd; + } + + /** + * Get patients with coded observation + * + * @param question + * @return + */ + private CohortDefinition gePatientsWithCodedObs(Concept question) { + SqlCohortDefinition cd = new SqlCohortDefinition(); + cd.setName("Patients with Viral load qualitative done"); + cd.addParameter(new Parameter("startDate", "After Date", Date.class)); + cd.addParameter(new Parameter("endDate", "Before Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.setQuery( + ResumoMensalQueries.gePatientsWithCodedObs( + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId(), + question.getConceptId())); + return cd; + } + + /** + * Combine the viral load and viral load qualitative + * + * @return CohortDefinition + */ + private CohortDefinition getViralLoadOrQualitative() { + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName("Combined viral load and its qualitative patients"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.addSearch( + "VL", + map( + getViralLoadTestDone(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "VLQ", + map( + gePatientsWithCodedObs(hivMetadata.getHivViralLoadQualitative()), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.setCompositionString("VL OR VLQ"); + return cd; + } + + /** + * E2 Get the combinations together E2: Number of active patients in ART at the end of current + * month who received a Viral Load Test Result (Annual Notification + * + * @return CohortDefinition + */ + public CohortDefinition + getNumberOfActivePatientsInArtAtTheEndOfTheCurrentMonthHavingVlTestResults() { + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName( + "E2: Number of active patients in ART at the end of current month who received a Viral Load Test Result (Annual Notification"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.addSearch( + "C", + map( + getStandardDefinitionForEcolumns(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "VL", + map( + getViralLoadOrQualitative(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "Ex2", + map( + genericCohortQueries.generalSql( + "Ex2", + ResumoMensalQueries.getE2ExclusionCriteria( + hivMetadata.getHivViralLoadConcept().getConceptId(), + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId(), + hivMetadata.getHivViralLoadQualitative().getConceptId())), + "startDate=${startDate},endDate=${endDate},location=${location}")); + + cd.setCompositionString("(C AND VL) AND NOT Ex2"); + return cd; + } + + /** + * E3: Number of active patients in ART at the end of current month who received supressed Viral + * Load Result (Annual Notification) + * + * @return CohortDefinition + */ + public CohortDefinition getActivePatientsOnArtWhoRecievedVldSuppressionResults() { + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName( + "Number of active patients in ART at the end of current month who received supressed Viral Load Result (Annual Notification)"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.addSearch( + "C", + map( + getStandardDefinitionForEcolumns(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "SUPP", + map( + getViralLoadSuppression(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "QUAL", + map( + gePatientsWithCodedObs(hivMetadata.getHivViralLoadQualitative()), + "startDate=${startDate},endDate=${endDate},location=${location}")); + + cd.addSearch( + "Ex3", + map( + genericCohortQueries.generalSql( + "Ex3", + ResumoMensalQueries.getE3ExclusionCriteria( + hivMetadata.getHivViralLoadConcept().getConceptId(), + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId(), + hivMetadata.getHivViralLoadQualitative().getConceptId())), + "startDate=${startDate},endDate=${endDate},location=${location}")); + + cd.setCompositionString("(C AND (SUPP OR QUAL)) AND NOT Ex3"); + return cd; + } + + private CohortDefinition getViralLoadSuppression() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + cd.setName("Viral load suppression"); + cd.addParameter(new Parameter("startDate", "After Date", Date.class)); + cd.addParameter(new Parameter("endDate", "Before Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.setQuery( + ResumoMensalQueries.getPatientsHavingViralLoadSuppression( + hivMetadata.getHivViralLoadConcept().getConceptId(), + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId())); + return cd; + } + + /** + * F1: Number of patients who had clinical appointment during the reporting month + * + * @return CohortDefinition + */ + public CohortDefinition getNumberOfPatientsWhoHadClinicalAppointmentDuringTheReportingMonth() { + SqlCohortDefinition cd = new SqlCohortDefinition(); + cd.setName("F1: Number of patients who had clinical appointment during the reporting month"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.setQuery( + ResumoMensalQueries.getPatientsWithGivenEncounterType( + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId())); + return cd; + } + + /** + * F2: Number of patients who had clinical appointment during the reporting month and were + * screened for TB + * + * @return CohortDefinition + */ + public CohortDefinition + getNumberOfPatientsWhoHadClinicalAppointmentDuringTheReportingMonthAndScreenedFoTb() { + SqlCohortDefinition sqlCohortDefinition = new SqlCohortDefinition(); + sqlCohortDefinition.setName("Exclusions"); + sqlCohortDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class)); + sqlCohortDefinition.addParameter(new Parameter("endDate", "End Date", Date.class)); + sqlCohortDefinition.addParameter(new Parameter("location", "Location", Location.class)); + sqlCohortDefinition.setQuery( + ResumoMensalQueries.getPatientsForF2ForExclusionFromMainQuery( + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId(), + tbMetadata.getHasTbSymptomsConcept().getConceptId(), + hivMetadata.getYesConcept().getConceptId(), + tbMetadata.getTBTreatmentPlanConcept().getConceptId())); + + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName( + "Number of patients who had clinical appointment during the reporting month and were screened for TB"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + cd.addSearch( + "F2F", + map( + getPatientsWithCodedObsAndAnswers( + tbMetadata.getHasTbSymptomsConcept(), hivMetadata.getYesConcept()), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "F2x", + map(sqlCohortDefinition, "startDate=${startDate},endDate=${endDate},location=${location}")); + + cd.setCompositionString("F2F AND NOT F2x"); + return cd; + } + + /** + * F3: Number of patients who had at least one clinical appointment during the year + * + * @return CohortDefinition + */ + public CohortDefinition getNumberOfPatientsWithAtLeastOneClinicalAppointmentDuringTheYear() { + CompositionCohortDefinition cd = new CompositionCohortDefinition(); + cd.setName("Number of patients who had at least one clinical appointment during the year"); + cd.addParameter(new Parameter("startDate", "Start Date", Date.class)); + cd.addParameter(new Parameter("endDate", "End Date", Date.class)); + cd.addParameter(new Parameter("location", "Location", Location.class)); + + cd.addSearch( + "F1", + map( + getNumberOfPatientsWhoHadClinicalAppointmentDuringTheReportingMonth(), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.addSearch( + "Fx3", + map( + genericCohortQueries.generalSql( + "Fx3", + ResumoMensalQueries.getF3Exclusion( + hivMetadata.getAdultoSeguimentoEncounterType().getEncounterTypeId())), + "startDate=${startDate},endDate=${endDate},location=${location}")); + cd.setCompositionString("F1 AND NOT Fx3"); + return cd; + } } diff --git a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/datasets/resumo/ResumoMensalDataSetDefinition.java b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/datasets/resumo/ResumoMensalDataSetDefinition.java index e7c8d065ea..d01576555e 100644 --- a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/datasets/resumo/ResumoMensalDataSetDefinition.java +++ b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/datasets/resumo/ResumoMensalDataSetDefinition.java @@ -60,6 +60,7 @@ public ResumoMensalDataSetDefinition( public DataSetDefinition constructResumoMensalDataset() { CohortIndicatorDataSetDefinition dsd = new CohortIndicatorDataSetDefinition(); + String mappings = "startDate=${startDate},endDate=${endDate},location=${location}"; dsd.setName("Resumo Mensal Data set B"); dsd.addParameters(getParameters()); @@ -410,6 +411,91 @@ public DataSetDefinition constructResumoMensalDataset() { getPatientsWhoInitiatedPreTarvDuringCurrentMonthAndDiagnosedForActiveTB(), ""); + // E1 indicators + + addRow( + dsd, + "E1", + "Annual Notification", + map( + eptsGeneralIndicator.getIndicator( + "E1", + map( + resumoMensalCohortQueries + .getNumberOfActivePatientsInArtAtEndOfCurrentMonthWithVlPerformed(), + mappings)), + mappings), + resumoMensalAandBdisaggregations.disAggForE()); + // E2 + addRow( + dsd, + "E2", + "Annual Notification", + map( + eptsGeneralIndicator.getIndicator( + "E2", + map( + resumoMensalCohortQueries + .getNumberOfActivePatientsInArtAtTheEndOfTheCurrentMonthHavingVlTestResults(), + mappings)), + mappings), + resumoMensalAandBdisaggregations.disAggForE()); + + // E3 + addRow( + dsd, + "E3", + "Annual Notification", + map( + eptsGeneralIndicator.getIndicator( + "E3", + map( + resumoMensalCohortQueries + .getActivePatientsOnArtWhoRecievedVldSuppressionResults(), + mappings)), + mappings), + resumoMensalAandBdisaggregations.disAggForE()); + + // F1 + dsd.addColumn( + "F1", + "Number of patients who had clinical appointment during the reporting month", + map( + eptsGeneralIndicator.getIndicator( + "F1", + map( + resumoMensalCohortQueries + .getNumberOfPatientsWhoHadClinicalAppointmentDuringTheReportingMonth(), + mappings)), + mappings), + ""); + // F2 + dsd.addColumn( + "F2", + "Number of patients who had clinical appointment during the reporting month and were screened for TB", + map( + eptsGeneralIndicator.getIndicator( + "F2", + map( + resumoMensalCohortQueries + .getNumberOfPatientsWhoHadClinicalAppointmentDuringTheReportingMonthAndScreenedFoTb(), + mappings)), + mappings), + ""); + // F3 + dsd.addColumn( + "F3", + "Number of patients who had at least one clinical appointment during the year", + map( + eptsGeneralIndicator.getIndicator( + "F3", + map( + resumoMensalCohortQueries + .getNumberOfPatientsWithAtLeastOneClinicalAppointmentDuringTheYear(), + mappings)), + mappings), + ""); + return dsd; } diff --git a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/dimensions/EptsCommonDimension.java b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/dimensions/EptsCommonDimension.java index 80fac8afdd..a6c3c84db7 100644 --- a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/dimensions/EptsCommonDimension.java +++ b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/dimensions/EptsCommonDimension.java @@ -84,6 +84,9 @@ public CohortDefinitionDimension age(final AgeDimensionCohortInterface ageDimens dim.addCohortDefinition( "0-4", ageDimensionCohort.createXtoYAgeCohort("patients with age between 0 and 4 years", 0, 4)); + dim.addCohortDefinition( + "0-14", + ageDimensionCohort.createXtoYAgeCohort("patients with age between 0 and 14 years", 0, 14)); dim.addCohortDefinition( "0-15", ageDimensionCohort.createXtoYAgeCohort("patients with age between 0 and 15 years", 0, 15)); diff --git a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/disaggregations/ResumoMensalAandBdisaggregations.java b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/disaggregations/ResumoMensalAandBdisaggregations.java index 9859824dd4..7a49f529b6 100644 --- a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/disaggregations/ResumoMensalAandBdisaggregations.java +++ b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/disaggregations/ResumoMensalAandBdisaggregations.java @@ -28,13 +28,13 @@ public List getUnder14YearsColumns() { new ColumnParameters("fiveTo9years", "5 to 9 years patients", "age=5-9", "02"); ColumnParameters tenTo14yearsMale = new ColumnParameters( - "tenTo14yearsMale", "10 to 14 years male patients", "gender=M|age=10-15", "03"); + "tenTo14yearsMale", "10 to 14 years male patients", "gender=M|age=10-14", "03"); ColumnParameters tenTo14yearsFemale = new ColumnParameters( - "tenTo14yearsFemale", "10 to 14 years female patients", "gender=F|age=10-15", "04"); + "tenTo14yearsFemale", "10 to 14 years female patients", "gender=F|age=10-14", "04"); ColumnParameters under14yearsTotal = new ColumnParameters( - "under14yearsTotal", "Under 15 years patients - Totals", "age=0-15", "05"); + "under14yearsTotal", "Under 15 years patients - Totals", "age=0-14", "05"); return Arrays.asList( under4years, fiveTo9years, tenTo14yearsMale, tenTo14yearsFemale, under14yearsTotal); @@ -62,9 +62,9 @@ public List getAdultPatients() { public List getAdolescentesColumns() { ColumnParameters tenTo14Male = - new ColumnParameters("tenTo14Male", "10 to 14 years male", "gender=M|age=10-15", "01"); + new ColumnParameters("tenTo14Male", "10 to 14 years male", "gender=M|age=10-14", "01"); ColumnParameters tenTo14Female = - new ColumnParameters("tenTo14Female", "10 to 14 years female", "gender=F|age=10-15", "02"); + new ColumnParameters("tenTo14Female", "10 to 14 years female", "gender=F|age=10-14", "02"); ColumnParameters fifteenTo19Female = new ColumnParameters( "fifteenTo19Female", "15 to 19 years female", "gender=F|age=15-19", "03"); @@ -76,4 +76,16 @@ public List getAdolescentesColumns() { return Arrays.asList( tenTo14Male, tenTo14Female, fifteenTo19Female, fifteenTo19Male, adolescentTotals); } + + /** + * Get teh disaggregations for the patients under 14 years and those above 14 yeara + * + * @return List of ColumnParameters + */ + public List disAggForE() { + ColumnParameters under14Years = + new ColumnParameters("under14", "Under 14 years", "age=0-14", "01"); + ColumnParameters over14Years = new ColumnParameters("over14", "15+ years", "age=15+", "02"); + return Arrays.asList(under14Years, over14Years); + } } diff --git a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/queries/ResumoMensalQueries.java b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/queries/ResumoMensalQueries.java index b1d8fee206..a47cfca282 100644 --- a/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/queries/ResumoMensalQueries.java +++ b/api/src/main/java/org/openmrs/module/eptsreports/reporting/library/queries/ResumoMensalQueries.java @@ -120,4 +120,243 @@ public static String getPatientsTransferredFromAnotherHealthFacilityByEndOfPrevi typeOfPantientConcept, tarvConcept); } + + public static String getPatientsForF2ForExclusionFromMainQuery( + int encounterType, int tbSymptomsConcept, int yesConcept, int tbTreatmentPlanConcept) { + String query = + "SELECT p.patient_id " + + "FROM patient p " + + " JOIN encounter e " + + " ON p.patient_id = e.patient_id " + + " JOIN obs o " + + " ON o.encounter_id = e.encounter_id " + + " JOIN (SELECT pat.patient_id AS patient_id, enc.encounter_datetime AS endDate FROM encounter enc JOIN patient pat ON pat.patient_id=enc.patient_id " + + " JOIN obs ob ON enc.encounter_id=ob.encounter_id WHERE pat.voided = 0 AND enc.voided = 0 AND ob.voided = 0 " + + " AND enc.location_id = :location AND enc.encounter_datetime BETWEEN :startDate AND :endDate " + + " AND enc.encounter_type= %d AND ob.concept_id=%d AND ob.value_coded=%d) ed " + + " ON p.patient_id=ed.patient_id" + + " WHERE p.voided = 0 " + + " AND e.voided = 0 " + + " AND e.encounter_type = %d " + + " AND e.location_id = :location " + + " AND e.encounter_datetime = ed.endDate " + + " AND o.voided = 0 " + + " AND o.concept_id = %d "; + return String.format( + query, encounterType, tbSymptomsConcept, yesConcept, encounterType, tbTreatmentPlanConcept); + } + + /** + * Get patients with encounters within start and end date F1: Number of patients who had clinical + * appointment during the reporting month + * + * @return String + */ + public static String getPatientsWithGivenEncounterType(int encounterType) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id " + + " WHERE e.encounter_type=%d AND e.location_id=:location " + + " AND e.encounter_datetime BETWEEN :startDate AND :endDate AND p.voided=0 AND e.voided=0 "; + return String.format(query, encounterType); + } + + /** + * Get patients with viral load suppression + * + * @return String + */ + public static String getPatientsHavingViralLoadSuppression( + int viralLoadConcept, int encounterType) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " WHERE p.voided=0 AND e.voided=0 AND o.voided=0 AND e.location_id=:location " + + " AND e.encounter_datetime BETWEEN :startDate AND :endDate " + + " AND o.value_numeric IS NOT NULL " + + " AND o.concept_id=%d " + + " AND e.encounter_type=%d " + + " AND o.value_numeric < 1000"; + return String.format(query, viralLoadConcept, encounterType); + } + + /** + * getPatientsWithCodedObsAndAnswers + * + * @return String + */ + public static String getPatientsWithCodedObsAndAnswers( + int encounterType, int questionConceptId, int answerConceptId) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " WHERE p.voided = 0 AND e.voided = 0 AND o.voided = 0 " + + " AND e.location_id = :location AND e.encounter_datetime BETWEEN :startDate AND :endDate AND e.encounter_type=%d " + + " AND o.concept_id=%d AND o.value_coded=%d"; + return String.format(query, encounterType, questionConceptId, answerConceptId); + } + + /** + * Get patients with viral load suppression + * + * @return String + */ + public static String getPatientsHavingViralLoadResults(int viralLoadConcept, int encounterType) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " WHERE p.voided=0 AND e.voided=0 AND o.voided=0 AND e.location_id=:location " + + " AND e.encounter_datetime BETWEEN :startDate AND :endDate " + + " AND o.value_numeric IS NOT NULL " + + " AND o.concept_id=%d " + + " AND e.encounter_type=%d "; + return String.format(query, viralLoadConcept, encounterType); + } + + /** + * Get patients with any coded obs value + * + * @return String + */ + public static String gePatientsWithCodedObs(int encounterType, int conceptId) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " WHERE p.voided = 0 AND e.voided = 0 AND o.voided = 0 " + + " AND e.location_id = :location AND e.encounter_datetime BETWEEN :startDate AND :endDate AND e.encounter_type=%d " + + " AND o.concept_id=%d "; + return String.format(query, encounterType, conceptId); + } + + /** + * E1 exclusions + * + * @return String + */ + public static String getE1ExclusionCriteria( + int encounterType, int questionConceptId, int answerConceptId) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " JOIN (SELECT pat.patient_id AS patient_id, enc.encounter_datetime AS endDate FROM patient pat " + + " JOIN encounter enc ON pat.patient_id=enc.patient_id JOIN obs ob ON enc.encounter_id=ob.encounter_id " + + " WHERE pat.voided = 0 AND enc.voided = 0 AND ob.voided = 0 AND enc.location_id = :location " + + " AND enc.encounter_datetime BETWEEN :startDate AND :endDate AND enc.encounter_type=%d AND " + + " ob.concept_id=%d AND ob.value_coded=%d) ed " + + " ON p.patient_id=ed.patient_id " + + " WHERE p.voided = 0 AND e.voided = 0 AND o.voided = 0 " + + " AND e.location_id = :location AND e.encounter_datetime BETWEEN " + + " IF(MONTH(:startDate) = 12 && DAY(:startDate) = 21, :startDate, CONCAT(YEAR(:startDate)-1, '-12','-21')) " + + " AND ed.endDate AND e.encounter_type=%d " + + " AND o.concept_id=%d AND o.value_coded=%d"; + return String.format( + query, + encounterType, + questionConceptId, + answerConceptId, + encounterType, + questionConceptId, + answerConceptId); + } + + /** + * E2 exclusions + * + * @param viralLoadConcept + * @param encounterType + * @param qualitativeConcept + * @return String + */ + public static String getE2ExclusionCriteria( + int viralLoadConcept, int encounterType, int qualitativeConcept) { + + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + "JOIN (SELECT pat.patient_id AS patient_id, enc.encounter_datetime AS endDate FROM patient pat JOIN encounter enc ON pat.patient_id=enc.patient_id JOIN obs ob " + + " ON enc.encounter_id=ob.encounter_id " + + " WHERE pat.voided=0 AND enc.voided=0 AND ob.voided=0 AND enc.location_id=:location AND enc.encounter_datetime " + + " BETWEEN :startDate AND :endDate AND ob.concept_id IN(%d, %d) AND enc.encounter_type=%d) ed " + + " ON p.patient_id=ed.patient_id " + + " WHERE p.voided=0 AND e.voided=0 AND o.voided=0 AND e.location_id=:location " + + " AND e.encounter_datetime BETWEEN " + + " IF(MONTH(:startDate) = 12 && DAY(:startDate) = 21, :startDate, CONCAT(YEAR(:startDate)-1, '-12','-21')) " + + " AND ed.endDate " + + " AND o.concept_id IN (%d, %d)" + + " AND e.encounter_type=%d "; + return String.format( + query, + viralLoadConcept, + qualitativeConcept, + encounterType, + viralLoadConcept, + qualitativeConcept, + encounterType); + } + + /** + * E3 exclusion + * + * @param viralLoadConcept + * @param encounterType + * @param qualitativeConcept + * @return + */ + public static String getE3ExclusionCriteria( + int viralLoadConcept, int encounterType, int qualitativeConcept) { + String query = + "SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " JOIN (SELECT pat.patient_id AS patient_id, enc.encounter_datetime AS endDate FROM patient pat " + + " JOIN encounter enc ON pat.patient_id=enc.patient_id JOIN obs ob ON enc.encounter_id=ob.encounter_id " + + " WHERE pat.voided=0 AND enc.voided=0 AND ob.voided=0 AND enc.location_id=:location " + + " AND enc.encounter_datetime BETWEEN :startDate AND :endDate AND ob.value_numeric IS NOT NULL " + + " AND ob.concept_id=%d AND enc.encounter_type=%d AND ob.value_numeric < 1000) ed " + + " ON p.patient_id=ed.patient_id" + + " WHERE p.voided=0 AND e.voided=0 AND o.voided=0 AND e.location_id=:location " + + " AND e.encounter_datetime BETWEEN " + + " IF(MONTH(:startDate) = 12 && DAY(:startDate) = 21, :startDate, CONCAT(YEAR(:startDate)-1, '-12','-21')) " + + " AND ed.endDate " + + " AND o.value_numeric IS NOT NULL " + + " AND o.concept_id=%d " + + " AND e.encounter_type=%d " + + " AND o.value_numeric < 1000" + + " UNION " + + " SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN obs o ON e.encounter_id=o.encounter_id " + + " JOIN (SELECT pat.patient_id AS patient_id, enc.encounter_datetime AS endDate FROM patient pat " + + " JOIN encounter enc ON pat.patient_id=enc.patient_id JOIN obs ob ON enc.encounter_id=ob.encounter_id " + + " WHERE pat.voided = 0 AND enc.voided = 0 AND ob.voided = 0 AND enc.location_id = :location AND " + + " enc.encounter_datetime BETWEEN :startDate AND :endDate AND enc.encounter_type=%d AND ob.concept_id=%d) ed " + + " ON p.patient_id=ed.patient_id " + + " WHERE p.voided = 0 AND e.voided = 0 AND o.voided = 0 " + + " AND e.location_id = :location AND e.encounter_datetime BETWEEN " + + " IF(MONTH(:startDate) = 12 && DAY(:startDate) = 21, :startDate, CONCAT(YEAR(:startDate)-1, '-12','-21')) " + + " AND ed.endDate " + + " AND e.encounter_type=%d " + + " AND o.concept_id=%d "; + + return String.format( + query, + viralLoadConcept, + encounterType, + viralLoadConcept, + encounterType, + encounterType, + qualitativeConcept, + encounterType, + qualitativeConcept); + } + + /** + * F3 exclusions + * + * @param encounterType + * @return + */ + public static String getF3Exclusion(int encounterType) { + String query = + " SELECT p.patient_id FROM patient p JOIN encounter e ON p.patient_id=e.patient_id JOIN ( " + + " SELECT pat.patient_id AS patient_id, enc.encounter_datetime AS endDate FROM encounter enc JOIN patient pat " + + " ON enc.patient_id=pat.patient_id WHERE enc.encounter_type=%d AND enc.location_id=:location " + + " AND enc.encounter_datetime BETWEEN :startDate AND :endDate AND pat.voided=0 AND enc.voided=0) ed " + + " ON p.patient_id=ed.patient_id" + + " WHERE e.encounter_type=%d AND e.location_id=:location " + + " AND e.encounter_datetime BETWEEN " + + " IF(MONTH(:startDate) = 12 && DAY(:startDate) = 21, :startDate, CONCAT(YEAR(:startDate)-1, '-12','-21')) " + + " AND ed.endDate " + + "AND p.voided=0 AND e.voided=0 "; + return String.format(query, encounterType, encounterType); + } } diff --git a/api/src/main/resources/Relatorio_Mensal.xls b/api/src/main/resources/Relatorio_Mensal.xls index d6c5de3135..f52377214c 100644 Binary files a/api/src/main/resources/Relatorio_Mensal.xls and b/api/src/main/resources/Relatorio_Mensal.xls differ diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index e3e511f39e..6deaa9d67c 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -1349,6 +1349,24 @@ + + + eptsreports.applicationForLaboratoryResearch + 92653c45-9eb2-486d-90c0-3e00569e99c0 + + UUID for the APPLICATION FOR LABORATORY RESEARCH concept + + + + + + eptsreports.viralLoadQualitativeConceptUuid + e1da2704-1d5f-11e0-b929-000c29ad1d07 + + UUID for the Viral load qualitative concept + + +