@Override
  public String execute() throws Exception {
    Program program = programService.getProgram(programId);

    Collection<OrganisationUnit> orgunits = selectionTreeManager.getRootOrganisationUnits();

    program = programService.getProgram(programId);

    // ---------------------------------------------------------------------
    // Get orgunitIds
    // ---------------------------------------------------------------------

    Collection<Integer> orgunitIds = new HashSet<>();

    for (OrganisationUnit orgunit : orgunits) {
      if (facilityLB.equals("selected")) {
        orgunitIds.add(orgunit.getId());
      } else if (facilityLB.equals("childrenOnly")) {
        orgunitIds.addAll(
            organisationUnitService.getOrganisationUnitHierarchy().getChildren(orgunit.getId()));
        orgunitIds.remove(orgunit.getId());
      } else {
        orgunitIds.addAll(
            organisationUnitService.getOrganisationUnitHierarchy().getChildren(orgunit.getId()));
      }
    }

    if (orgunitIds.size() > 0) {
      grid =
          programStageInstanceService.getCompletenessProgramStageInstance(
              orgunitIds, program, startDate, endDate, i18n);
    }

    return (type == null) ? SUCCESS : type;
  }
  public String execute() throws Exception {
    patientAttributes = patientAttributeService.getAllPatientAttributes();

    programs = programService.getProgramsByCurrentUser();

    organisationUnit = selectionManager.getSelectedOrganisationUnit();

    if (organisationUnit == null) {
      status = 1;
    }

    return SUCCESS;
  }
  public Collection<PatientAttribute> getPatientAttributesWithoutProgram() {
    Collection<PatientAttribute> result = patientAttributeStore.getAll();

    Collection<Program> programs = programService.getAllPrograms();

    if (result != null) {
      for (Program program : programs) {
        result.removeAll(program.getAttributes());
      }
      return result;
    }

    return new HashSet<PatientAttribute>();
  }
示例#4
0
  @Override
  public String execute() throws Exception {
    name = name.trim();

    Program match = programService.getProgramByName(name);

    if (match != null && (id == null || match.getId() != id.intValue())) {
      message = i18n.getString("duplicate_names");

      return ERROR;
    }

    message = i18n.getString("everything_is_ok");

    return SUCCESS;
  }
  // -------------------------------------------------------------------------
  // Action implementation
  // -------------------------------------------------------------------------
  public String execute() throws Exception {
    statementManager.initialise();

    Program selProgram = programService.getProgram(programList);

    OrganisationUnit selOrgUnit = organisationUnitService.getOrganisationUnit(ouIDTB);

    System.out.println(
        "NBITS Report_"
            + selOrgUnit.getName()
            + "_"
            + selProgram.getName()
            + "_StartTime: "
            + new Date());

    List<OrganisationUnit> orgUnitList =
        new ArrayList<OrganisationUnit>(
            organisationUnitService.getOrganisationUnitWithChildren(ouIDTB));

    List<OrganisationUnit> programOrgUnits =
        new ArrayList<OrganisationUnit>(selProgram.getOrganisationUnits());

    orgUnitList.retainAll(programOrgUnits);

    Date sDate = format.parseDate(startDate);

    Date eDate = format.parseDate(endDate);

    System.out.println("Start Date" + sDate + "-----" + "End Date: " + eDate);
    generateReport(selProgram, orgUnitList, sDate, eDate);

    System.out.println(
        "NBITS Report_"
            + selOrgUnit.getName()
            + "_"
            + selProgram.getName()
            + "_EndTime: "
            + new Date());

    statementManager.destroy();

    return SUCCESS;
  }
  @Override
  public String execute() throws Exception {
    patient = patientService.getPatient(patientId);

    Collection<Program> programs =
        programService.getProgramsByCurrentUser(Program.MULTIPLE_EVENTS_WITH_REGISTRATION);
    programs.addAll(
        programService.getProgramsByCurrentUser(Program.SINGLE_EVENT_WITH_REGISTRATION));

    // ---------------------------------------------------------------------
    // Get relationship
    // ---------------------------------------------------------------------

    relationships = relationshipService.getRelationshipsForPatient(patient);

    Collection<ProgramInstance> programInstances = patient.getProgramInstances();

    // ---------------------------------------------------------------------
    // Get patient-attribute-values
    // ---------------------------------------------------------------------

    Collection<PatientAttributeValue> _attributeValues =
        patientAttributeValueService.getPatientAttributeValues(patient);
    attributeValues = new HashSet<PatientAttributeValue>();

    for (PatientAttributeValue attributeValue : _attributeValues) {
      String value = attributeValue.getValue();
      if (attributeValue.getPatientAttribute().getValueType().equals(PatientAttribute.TYPE_AGE)) {
        Date date = format.parseDate(value);
        value = PatientAttribute.getAgeFromDate(date) + "";
        attributeValue.setValue(value);
      }

      attributeValues.add(attributeValue);
    }

    // ---------------------------------------------------------------------
    // Get patient-identifiers
    // ---------------------------------------------------------------------

    Collection<PatientIdentifier> _identifiers = patient.getIdentifiers();
    identifiers = new HashSet<PatientIdentifier>();

    for (Program program : programs) {
      Collection<PatientIdentifierType> identifierTypes = program.getIdentifierTypes();
      for (PatientIdentifier identifier : _identifiers) {
        if (!identifierTypes.contains(identifier.getIdentifierType())) {
          identifiers.add(identifier);
        }
      }
    }
    // ---------------------------------------------------------------------
    // Get program enrollment
    // ---------------------------------------------------------------------

    activeProgramInstances = new HashSet<ProgramInstance>();

    completedProgramInstances = new HashSet<ProgramInstance>();

    for (ProgramInstance programInstance : programInstances) {
      if (programs.contains(programInstance.getProgram())) {
        if (programInstance.getStatus() == ProgramInstance.STATUS_ACTIVE) {
          activeProgramInstances.add(programInstance);

          programIndicatorsMap.putAll(
              programIndicatorService.getProgramIndicatorValues(programInstance));
        } else {
          completedProgramInstances.add(programInstance);
        }
      }
    }

    // ---------------------------------------------------------------------
    // Patient-Audit
    // ---------------------------------------------------------------------

    patientAudits = patientAuditService.getPatientAudits(patient);

    Calendar today = Calendar.getInstance();
    PeriodType.clearTimeOfDay(today);
    Date date = today.getTime();
    String visitor = currentUserService.getCurrentUsername();
    PatientAudit patientAudit =
        patientAuditService.getPatientAudit(
            patient.getId(), visitor, date, PatientAudit.MODULE_PATIENT_DASHBOARD);
    if (patientAudit == null) {
      patientAudit =
          new PatientAudit(patient, visitor, date, PatientAudit.MODULE_PATIENT_DASHBOARD);
      patientAuditService.savePatientAudit(patientAudit);
    }

    return SUCCESS;
  }