Example #1
0
  @Override
  @SuppressWarnings("unchecked")
  protected void process(File csvFile) throws Exception {

    Transaction t = createTransaction();
    Query q = createQuery(t);

    List<Object[]> list = (List<Object[]>) q.list();
    if (list.size() < 1) throw new EmptyResultException();

    ArrayList<String> row;
    Table out = new Table();

    for (Object[] o : list) {
      TestResult tr = (TestResult) o[0];
      PatientAttributeValue pc = (PatientAttributeValue) o[1];
      PatientAttributeValue bdt = (PatientAttributeValue) o[2];
      Date bd = DateUtils.parseDate(bdt.getValue());

      Date tDate = tr.getTestDate();
      int testCode = TestCode.T4.getCode();

      if (bd != null
          && tDate != null
          && DateUtils.getDateOffset(bd, Calendar.YEAR, 15).after(tDate)) {
        // < 15 years old at time of test
        testCode = TestCode.T4PERCENT.getCode();
        if (!tr.getTest()
            .getTestType()
            .getDescription()
            .equals(StandardObjects.getCd4PercentageTestType().getDescription())) continue;
      } else {
        if (tr.getTest()
            .getTestType()
            .getDescription()
            .equals(StandardObjects.getCd4PercentageTestType().getDescription())) continue;
      }

      String value = tr.getValue();

      row = new ArrayList<String>();

      row.add(getCentreName());
      row.add(OriginCode.ARC.getCode() + "");
      row.add(pc.getValue());
      row.add(getFormattedDate(tDate));
      row.add(TypeOfInformationCode.LAB_RESULT.getCode() + "");
      row.add(testCode + "");
      row.add(getFormattedDecimal(value, 0, 0));
      row.add("");

      out.addRow(row);
    }

    t.commit();
    out.exportAsCsv(new FileOutputStream(csvFile), ';', false);
  }
Example #2
0
  @Override
  public void setAttributeValue(Attribute attribute, Instance instance, Patient patient) {
    RegaService rs = ruleService.getRegaService();

    PatientAttributeValue pav =
        rs.getPatientAttributeValue(
            patient, ClinicalAttributeFactory.CLINICAL_REGA_ATTRIBUTE_RECENT_BLOOD_HB);

    if (pav == null) return; // The is no recent blood hb for this patient

    String strVal = pav.getValue();
    Double dVal;

    if (strVal.equals("N/A")) {
      return; // There is no value
    } else if (strVal.contains("/")) {
      dVal = Double.parseDouble(strVal.replace('/', '.'));
    } else {
      dVal = Double.parseDouble(strVal);
    }

    logger.info("Recent Blood HB for " + patient.getPatientId() + " is " + dVal);
    instance.setValue(attribute, dVal);
  }