Exemple #1
0
  public void init(InteractionState interactionState, IForm form, FormTable table) {
    Transaction tr = RegaDBMain.getApp().createTransaction();

    for (UITestItem ti : testItems) {
      Test t = getTest(tr, ti);
      if (t != null) {
        Label l = new Label(TestComboBox.getLabel(t));
        FormField testResultField;
        if (ValueTypes.getValueType(t.getTestType().getValueType()) == ValueTypes.NOMINAL_VALUE) {
          testResultField = new ComboBox(interactionState, form);
          for (TestNominalValue tnv : t.getTestType().getTestNominalValues()) {
            ((ComboBox) testResultField)
                .addItem(new DataComboMessage<TestNominalValue>(tnv, tnv.getValue()));
          }
          ((ComboBox) testResultField).sort();

          if (ti.noValueSelected) ((ComboBox) testResultField).addNoSelectionItem();

          ((ComboBox) testResultField).selectIndex(0);

          if (ti.defaultValue != null && interactionState.isEditable())
            ((ComboBox) testResultField).selectItem(ti.defaultValue);
        } else {
          testResultField =
              FormField.getTextField(
                  ValueTypes.getValueType(t.getTestType().getValueType()), interactionState, form);
        }

        table.addLineToTable(l, testResultField);
        testFormFields.add(testResultField);
      } else {
        System.err.println("ViralIsolateForm: test does not exist: '" + ti.description + '\'');
      }
    }
  }
Exemple #2
0
  @SuppressWarnings("rawtypes")
  @Override
  public File run() throws Exception {
    File result = File.createTempFile("nadir_", ".csv", getResultDir());
    PrintStream out = new PrintStream(new FileOutputStream(result));

    TestType tt = pTestType.getTestTypeComboBox().currentValue();
    ValueTypes vt = ValueTypes.getValueType(tt.getValueType());
    String hql =
        "select tr.patient.patientId, tr.test.description, tr.testDate, tr.value from TestResult tr join tr.patient.patientDatasets patient_dataset"
            + " where patient_dataset.id.dataset.datasetIi = :var_dataset"
            + " and tr.testDate <= :var_date"
            + " and tr.test.testIi in (select testIi from Test t where t.testType.testTypeIi = :var_testtype)"
            + " order by tr.patient.patientId, ";

    if (vt == ValueTypes.LIMITED_NUMBER)
      hql += "cast(substring(tr.value, 2, length(tr.value)) as double)";
    else hql += "cast(tr.value as double)";

    Transaction t = RegaDBMain.getApp().createTransaction();
    Query q = t.createQuery(hql);
    q.setParameter("var_dataset", pDataset.getDataset().getDatasetIi());
    q.setParameter("var_date", pDate.getDate());
    q.setParameter("var_testtype", tt.getTestTypeIi());

    out.println("patient_id,test,test_date,value");

    List r = q.list();
    String prevPatientId = null;
    for (Object o : r) {
      Object[] oo = (Object[]) o;
      String patientId = (String) oo[0];
      String test = (String) oo[1];
      Date testDate = (Date) oo[2];
      String value = (String) oo[3];

      if (!patientId.equals(prevPatientId)) {
        out.println(
            '"'
                + patientId
                + "\",\""
                + test
                + "\",\""
                + DateUtils.format(testDate)
                + "\",\""
                + value
                + '"');
        prevPatientId = patientId;
      }
    }

    t.commit();
    out.close();

    return result;
  }