public String getUOM(boolean isCD4Conclusion) {
    if (!isCD4Conclusion) {
      if (test != null && test.getUnitOfMeasure() != null) {
        return test.getUnitOfMeasure().getName();
      }
    }

    return "";
  }
  private List<IdValuePair> getTestsForTypeOfSample(TypeOfSample typeOfSample) {
    List<Test> testList = TypeOfSampleUtil.getTestListBySampleTypeId(typeOfSample.getId(), false);

    List<IdValuePair> valueList = new ArrayList<IdValuePair>();

    for (Test test : testList) {
      if (test.getOrderable()) {
        valueList.add(new IdValuePair(test.getId(), TestService.getUserLocalizedTestName(test)));
      }
    }

    return valueList;
  }
  private void setTestMapForAllTests() {
    testIdToBucketList = new HashMap<String, TestBucket>();
    concatSection_TestToBucketMap = new HashMap<String, TestBucket>();
    testBucketList = new ArrayList<TestBucket>();

    TestDAO testDAO = new TestDAOImpl();
    List<Test> testList = testDAO.getAllActiveTests(false);

    for (Test test : testList) {
      TestBucket bucket = new TestBucket();

      bucket.testName = TestService.getUserLocalizedTestName(test);
      bucket.testSection = test.getTestSection().getLocalizedName();

      testIdToBucketList.put(test.getId(), bucket);
      testBucketList.add(bucket);
    }
  }
  @Test
  public void sample_save_should_form_test_to_sample_associations() throws Exception {
    testService.createOrUpdate(referenceDataTest);
    us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name");
    assertEquals("Test Name", savedTest.getTestName());
    assertEquals("New", savedTest.getTestSection().getTestSectionName());

    referenceDataSample.addTest(
        new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName()));
    typeOfSampleService.createOrUpdate(referenceDataSample);
    TypeOfSample savedSample = typeOfSampleDAO.getTypeOfSampleByUUID(sampleUuid);
    assertEquals("Sample Name", savedSample.getDescription());
    assertEquals("Sample Name", savedSample.getLocalAbbreviation());
    TypeOfSampleTest sampleTestAssoc =
        typeOfSampleTestDAO.getTypeOfSampleTestForTest(savedTest.getId());
    assertNotNull(sampleTestAssoc);
    assertEquals(savedTest.getId(), sampleTestAssoc.getTestId());
    assertEquals(savedSample.getId(), sampleTestAssoc.getTypeOfSampleId());
  }
Esempio n. 5
0
  @Test
  public void associate_tests_with_panel() throws Exception {
    testService.createOrUpdate(referenceDataTest);

    us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name");
    assertEquals("Test Name", savedTest.getTestName());
    assertEquals("New", savedTest.getTestSection().getTestSectionName());

    referenceDataPanel.addTest(
        new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName()));
    panelService.createOrUpdate(referenceDataPanel);

    Panel savedPanel = panelDAO.getPanelByName("Panel Name");
    assertNotNull(savedPanel);
    assertEquals("Panel Name", savedPanel.getDescription());

    List panelTestAssoc = panelItemDAO.getPanelItemsForPanel(savedPanel.getId());
    assertNotNull(panelTestAssoc);
    assertEquals(1, panelTestAssoc.size());
    PanelItem panelItem = (PanelItem) panelTestAssoc.get(0);
    assertEquals(savedTest.getId(), panelItem.getTest().getId());
  }
  private void setAnalysisForDateRange() {
    AnalysisDAO analysisDAO = new AnalysisDAOImpl();
    List<Analysis> analysisList =
        analysisDAO.getAnalysisStartedOrCompletedInDateRange(lowDate, highDate);

    for (Analysis analysis : analysisList) {
      Test test = analysis.getTest();

      if (test != null) {
        TestBucket testBucket = null;
        if (USER_TEST_SECTION_ID.equals(analysis.getTestSection().getId())) {
          String concatedName =
              analysis.getTestSection().getLocalizedName()
                  + TestService.getUserLocalizedTestName(analysis.getTest());
          testBucket = concatSection_TestToBucketMap.get(concatedName);
          if (testBucket == null) {
            testBucket = new TestBucket();
            testBucket.testName = TestService.getUserLocalizedReportingTestName(test);
            testBucket.testSection = analysis.getTestSection().getLocalizedName();
            concatSection_TestToBucketMap.put(concatedName, testBucket);
          }
        } else {
          testBucket = testIdToBucketList.get(test.getId());
        }

        if (testBucket != null) {
          if (NOT_STARTED_STATUS_ID.equals(analysis.getStatusId())) {
            testBucket.notStartedCount++;
          } else if (inProgress(analysis)) {
            testBucket.inProgressCount++;
          } else if (FINALIZED_STATUS_ID.equals(analysis.getStatusId())) {
            testBucket.finishedCount++;
          }
        }
      }
    }
  }
  protected ActionForward performAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // The first job is to determine if we are coming to this action with an
    // ID parameter in the request. If there is no parameter, we are
    // creating a new TestAnalyte.
    // If there is a parameter present, we should bring up an existing
    // TestAnalyte to edit.
    TestAnalyteTestResultActionForm dynaForm = (TestAnalyteTestResultActionForm) form;

    String forward = FWD_SUCCESS;
    request.setAttribute(ALLOW_EDITS_KEY, "false");
    request.setAttribute(PREVIOUS_DISABLED, "true");
    request.setAttribute(NEXT_DISABLED, "true");

    // CHANGED
    // String selectedTestId = (String) request.getParameter("Test");

    List methods = new ArrayList();
    MethodDAO methodDAO = new MethodDAOImpl();
    methods = methodDAO.getAllMethods();

    // Get tests/testsections by user system id
    // bugzilla 2160
    UserTestSectionDAO userTestSectionDAO = new UserTestSectionDAOImpl();
    List testSections = userTestSectionDAO.getAllUserTestSections(request);
    // bugzilla 2291
    List tests = userTestSectionDAO.getAllUserTests(request, false);

    List selectedAnalyteTypes = new ArrayList();
    // bugzilla 1870
    List selectedAnalyteIsReportables = new ArrayList();
    List selectedAnalyteResultGroups = new ArrayList();
    List selectedAnalyteIds = new ArrayList();
    List selectedAnalyteNames = new ArrayList();
    List selectedTestAnalyteIds = new ArrayList();
    List testAnalyteLastupdatedList = new ArrayList();

    List testResultResultGroups = new ArrayList();
    List testResultResultGroupTypes = new ArrayList();
    List testResultValueList = new ArrayList();
    List dictionaryEntryIdList = new ArrayList();
    List flagsList = new ArrayList();
    // bugzilla 1845 add testResult sortOrder
    List sortList = new ArrayList();
    List significantDigitsList = new ArrayList();
    List quantLimitList = new ArrayList();
    List testResultIdList = new ArrayList();
    List testResultLastupdatedList = new ArrayList();
    Test test = new Test();

    // FIXED BUG - NEED TO REFRESH SELECTIONS ON GOING INTO FORM
    // get 3 drop down selections so we can repopulate
    // String selectedTestSectionId = (String) dynaForm
    // .get("selectedTestSectionId");
    // String selectedMethodId = (String) dynaForm.get("selectedMethodId");
    // String selectedTestId = (String) dynaForm.get("selectedTestId");

    String selectedTestId = null;
    String selectedTestSectionId = null;
    String selectedMethodId = null;
    // END BUG FIX

    // initialize the form
    dynaForm.initialize(mapping);
    dynaForm.resetLists();

    // bugzilla 1350 need to check if test has been selected so stray
    // components don't display
    if (!StringUtil.isNullorNill(selectedTestId)) {
      // if test is selected enable the save button
      request.setAttribute(ALLOW_EDITS_KEY, "true");
      test.setId(selectedTestId);
      TestDAO testDAO = new TestDAOImpl();
      testDAO.getData(test);

      TestAnalyteDAO testAnalyteDAO = new TestAnalyteDAOImpl();
      List testAnalytes = testAnalyteDAO.getAllTestAnalytesPerTest(test);

      TestResultDAO testResultDAO = new TestResultDAOImpl();
      List testResults = testResultDAO.getAllActiveTestResultsPerTest(test);

      DictionaryDAO dictDAO = new DictionaryDAOImpl();

      if (testAnalytes != null && testAnalytes.size() > 0) {

        for (int i = 0; i < testAnalytes.size(); i++) {
          TestAnalyte ta = (TestAnalyte) testAnalytes.get(i);
          selectedAnalyteTypes.add(ta.getTestAnalyteType());
          // bugzilla 1870
          selectedAnalyteIsReportables.add(ta.getIsReportable());
          if (ta.getResultGroup() != null) {
            selectedAnalyteResultGroups.add(ta.getResultGroup());
          } else {
            selectedAnalyteResultGroups.add("");
          }
          selectedAnalyteIds.add(ta.getAnalyte().getId());
          selectedAnalyteNames.add(ta.getAnalyte().getAnalyteName());
          selectedTestAnalyteIds.add(ta.getId());
        }

        if (testResults != null && testResults.size() > 0) {
          for (int i = 0; i < testResults.size(); i++) {
            TestResult tr = (TestResult) testResults.get(i);
            testResultIdList.add(tr.getId());
            testResultLastupdatedList.add(tr.getLastupdated());
            testResultResultGroups.add(tr.getResultGroup());
            testResultResultGroupTypes.add(tr.getTestResultType());
            if (tr.getTestResultType()
                .equals(SystemConfiguration.getInstance().getDictionaryType())) {
              dictionaryEntryIdList.add(tr.getValue());
              Dictionary dict = new Dictionary();
              dict.setId(tr.getValue());
              dictDAO.getData(dict);
              // bugzilla 1847: use dictEntryDisplayValue
              testResultValueList.add(dict.getDictEntryDisplayValue());
            } else {
              dictionaryEntryIdList.add("");
              testResultValueList.add(tr.getValue());
            }
            if (tr.getFlags() == null) {
              flagsList.add("");
            } else {
              flagsList.add(tr.getFlags());
            }
            // bugzilla 1845 add testResult sortOrder
            if (tr.getSortOrder() == null) {
              sortList.add("");
            } else {
              sortList.add(tr.getSortOrder());
            }
            if (tr.getSignificantDigits() == null) {
              significantDigitsList.add("");
            } else {
              significantDigitsList.add(tr.getSignificantDigits());
            }
            if (tr.getQuantLimit() == null) {
              quantLimitList.add("");
            } else {
              quantLimitList.add(tr.getQuantLimit());
            }
          }
        }
        isNew = false;
      } else {

        isNew = true;
      }
    } else {
      isNew = true;
    }

    PropertyUtils.setProperty(dynaForm, "selectedAnalyteTypes", selectedAnalyteTypes);
    // bugzilla 1870
    PropertyUtils.setProperty(
        dynaForm, "selectedAnalyteIsReportables", selectedAnalyteIsReportables);
    PropertyUtils.setProperty(dynaForm, "selectedAnalyteResultGroups", selectedAnalyteResultGroups);
    PropertyUtils.setProperty(dynaForm, "selectedAnalyteIds", selectedAnalyteIds);
    PropertyUtils.setProperty(dynaForm, "selectedTestAnalyteIds", selectedTestAnalyteIds);
    PropertyUtils.setProperty(dynaForm, "testAnalyteLastupdatedList", testAnalyteLastupdatedList);
    PropertyUtils.setProperty(dynaForm, "selectedAnalyteNames", selectedAnalyteNames);

    PropertyUtils.setProperty(dynaForm, "testResultResultGroups", testResultResultGroups);

    PropertyUtils.setProperty(dynaForm, "testResultResultGroupTypes", testResultResultGroupTypes);

    PropertyUtils.setProperty(dynaForm, "testResultValueList", testResultValueList);

    PropertyUtils.setProperty(dynaForm, "testResultIdList", testResultIdList);

    PropertyUtils.setProperty(dynaForm, "testResultLastupdatedList", testResultLastupdatedList);

    PropertyUtils.setProperty(dynaForm, "dictionaryEntryIdList", dictionaryEntryIdList);

    PropertyUtils.setProperty(dynaForm, "flagsList", flagsList);
    // bugzilla 1845 add testResult sortOrder
    PropertyUtils.setProperty(dynaForm, "sortList", sortList);

    PropertyUtils.setProperty(dynaForm, "significantDigitsList", significantDigitsList);

    PropertyUtils.setProperty(dynaForm, "quantLimitList", quantLimitList);

    PropertyUtils.setProperty(dynaForm, "test", (test == null ? new Test() : test));

    // sort three drop down lists
    Collections.sort(testSections, TestSectionComparator.NAME_COMPARATOR);

    // bugzilla 1844 - no longer sort by name but by description
    Collections.sort(tests, TestComparator.DESCRIPTION_COMPARATOR);
    Collections.sort(methods, MethodComparator.NAME_COMPARATOR);

    PropertyUtils.setProperty(dynaForm, "testSections", testSections);
    PropertyUtils.setProperty(dynaForm, "methods", methods);
    PropertyUtils.setProperty(dynaForm, "tests", tests);

    PropertyUtils.setProperty(dynaForm, "selectedTestSectionId", selectedTestSectionId);
    PropertyUtils.setProperty(dynaForm, "selectedMethodId", selectedMethodId);
    PropertyUtils.setProperty(dynaForm, "selectedTestId", selectedTestId);
    return mapping.findForward(forward);
  }
 public String getSortOrder() {
   return test == null ? "0" : test.getSortOrder();
 }
 public boolean isReportable() {
   return test == null ? false : "Y".equals(test.getIsReportable());
 }
Esempio n. 10
0
 public String getTestMethodName() {
   return (test != null && test.getMethod() != null) ? test.getMethod().getMethodName() : null;
 }