コード例 #1
0
  @RequestMapping(value = "/showCollectionSummaryForTesting", method = RequestMethod.GET)
  public ModelAndView showCollectionSummaryForTesting(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "collectionId") String collectionId) {
    ModelAndView mv = new ModelAndView();
    collectionId = collectionId.trim();
    Long collectedSampleId = Long.parseLong(collectionId);
    CollectedSample collectedSample =
        collectedSampleRepository.findCollectedSampleById(collectedSampleId);
    mv.addObject("collection", new CollectedSampleViewModel(collectedSample));
    mv.addObject("collectionId", collectedSample.getId());
    mv.addObject("collectionFields", utilController.getFormFieldsForForm("collectedSample"));

    mv.setViewName("bloodtesting/collectionSummaryForBloodTesting");

    mv.addObject("refreshUrl", getUrl(request));

    return mv;
  }
コード例 #2
0
  @RequestMapping(value = "/showBloodTypingResultsForCollection", method = RequestMethod.GET)
  public ModelAndView showBloodTypingResultsForCollection(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "collectionId") String collectionId) {
    ModelAndView mv = new ModelAndView();
    collectionId = collectionId.trim();
    Long collectedSampleId = Long.parseLong(collectionId);
    CollectedSample collectedSample =
        collectedSampleRepository.findCollectedSampleById(collectedSampleId);
    BloodTestingRuleResult ruleResult =
        bloodTestingRepository.getAllTestsStatusForCollection(collectedSampleId);
    mv.addObject("collection", new CollectedSampleViewModel(collectedSample));
    mv.addObject("collectionId", collectedSample.getId());
    mv.addObject("bloodTypingOutputForCollection", ruleResult);
    mv.addObject("collectionFields", utilController.getFormFieldsForForm("collectedSample"));

    List<BloodTest> bloodTypingTests = bloodTestingRepository.getBloodTypingTests();
    Map<String, BloodTest> bloodTypingTestsMap = new LinkedHashMap<String, BloodTest>();
    for (BloodTest bloodTypingTest : bloodTypingTests) {
      bloodTypingTestsMap.put(bloodTypingTest.getId().toString(), bloodTypingTest);
    }
    mv.addObject("allBloodTypingTests", bloodTypingTestsMap);

    List<BloodTest> allBloodTypingTests = bloodTestingRepository.getBloodTypingTests();
    Map<String, BloodTest> allBloodTypingTestsMap = new TreeMap<String, BloodTest>();
    for (BloodTest bloodTypingTest : allBloodTypingTests) {
      allBloodTypingTestsMap.put(bloodTypingTest.getId().toString(), bloodTypingTest);
    }
    mv.addObject("allBloodTypingTests", allBloodTypingTestsMap);

    mv.setViewName("bloodtesting/bloodTypingSummaryCollection");

    mv.addObject("refreshUrl", getUrl(request));

    return mv;
  }
コード例 #3
0
  @RequestMapping(value = "/addCollectionsToBloodTypingPlate")
  public ModelAndView addCollectionsToBloodTypingPlate(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "collectionNumbers[]") List<String> collectionNumbers) {

    // here the key of the map corresponds to the index of the
    // collection number in the parameter collectionNumbers
    // corresponding to the collected sample in the value of the map
    List<CollectedSample> collections =
        collectedSampleRepository.verifyCollectionNumbers(collectionNumbers);

    int numErrors = 0;
    int numValid = 0;
    for (CollectedSample c : collections) {
      if (c == null) numErrors++;
      else numValid++;
    }

    ModelAndView mv = new ModelAndView();
    mv.addObject("collections", collections);
    mv.addObject("collectionNumbers", StringUtils.join(collectionNumbers, ","));
    mv.addObject("plate", bloodTestingRepository.getPlate("bloodtyping"));

    Map<String, Object> tips = new HashMap<String, Object>();
    if (numErrors > 0 || numValid == 0) {
      mv.addObject("success", false);
      mv.setViewName("bloodtesting/bloodTypingWorksheetForm");
      mv.addObject("refreshUrl", "bloodTypingWorksheetGenerator.html");
      utilController.addTipsToModel(tips, "bloodtyping.plate.step1");
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      mv.addObject("errorMessage", "Please fix the errors noted. Some collections do not exist.");
    } else {

      // this is a map with id of the collected sample as the key
      Map<Long, CollectedSample> collectionMap = new HashMap<Long, CollectedSample>();
      for (CollectedSample c : collections) {
        collectionMap.put(c.getId(), c);
      }
      mv.addObject("collectionMap", collectionMap);

      // no errors but the user should be warned if there are any collections for which testing
      // partly done
      Map<Long, BloodTestingRuleResult> collectionsWithBloodTypingTests =
          collectedSampleRepository.filterCollectionsWithBloodTypingResults(collections);
      mv.addObject("collectionsWithBloodTypingTests", collectionsWithBloodTypingTests);

      Map<String, BloodTest> bloodTypingTestsMap = new HashMap<String, BloodTest>();
      for (BloodTest bloodTypingTest : bloodTestingRepository.getBloodTypingTests()) {
        bloodTypingTestsMap.put(bloodTypingTest.getId().toString(), bloodTypingTest);
      }
      mv.addObject("bloodTypingTests", bloodTypingTestsMap);

      mv.addObject("success", true);
      mv.setViewName("bloodtesting/bloodTypingWells");
      mv.addObject("refreshUrl", getUrl(request));
      mv.addObject("changeCollectionsUrl", "bloodTypingWorksheetGenerator.html");
      utilController.addTipsToModel(tips, "bloodtyping.plate.step2");
      mv.addObject("bloodTestsOnPlate", getBloodTestsOnPlate());
      mv.addObject("bloodTypingConfig", genericConfigRepository.getConfigProperties("bloodTyping"));
    }

    mv.addObject("tips", tips);
    return mv;
  }
コード例 #4
0
  @SuppressWarnings("unchecked")
  @RequestMapping(value = "/saveBloodTypingTests", method = RequestMethod.POST)
  public ModelAndView saveBloodTypingTests(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "bloodTypingTests") String bloodTypingTests,
      @RequestParam(value = "collectionNumbers[]") List<String> collectionNumbers,
      @RequestParam(value = "refreshUrl") String refreshUrl,
      @RequestParam(value = "saveUninterpretableResults") boolean saveUninterpretableResults) {

    ModelAndView mv = new ModelAndView();
    List<CollectedSample> collections =
        collectedSampleRepository.verifyCollectionNumbers(collectionNumbers);
    mv.addObject("collectionNumbers", StringUtils.join(collectionNumbers, ","));
    mv.addObject("collections", collections);

    Map<Long, Map<Long, String>> bloodTypingTestResults = parseBloodTestResults(bloodTypingTests);
    Map<Long, Map<Long, String>> errorMap = null;
    mv.addObject("bloodTypingTestResults", bloodTypingTestResults);
    boolean success = true;
    Map<String, Object> results = null;
    try {
      results =
          bloodTestingRepository.saveBloodTestingResults(
              bloodTypingTestResults, saveUninterpretableResults);
      if (results != null) errorMap = (Map<Long, Map<Long, String>>) results.get("errors");
    } catch (Exception ex) {
      ex.printStackTrace();
      success = false;
    }
    if (errorMap != null && !errorMap.isEmpty()) success = false;
    Map<String, Object> tips = new HashMap<String, Object>();

    System.out.println(errorMap);

    if (success) {
      List<BloodTest> allBloodTypingTests = bloodTestingRepository.getBloodTypingTests();
      Map<String, BloodTest> allBloodTypingTestsMap = new HashMap<String, BloodTest>();
      for (BloodTest allBloodTypingTest : allBloodTypingTests) {
        allBloodTypingTestsMap.put(allBloodTypingTest.getId().toString(), allBloodTypingTest);
      }
      mv.addObject("allBloodTypingTests", allBloodTypingTestsMap);
      mv.addObject("collectionFields", utilController.getFormFieldsForForm("collectedSample"));
      mv.addObject("collectionsByCollectionId", results.get("collections"));

      List<String> collectionIds = new ArrayList<String>();
      for (CollectedSample collection : collections) {
        collectionIds.add(collection.getId().toString());
      }
      mv.addObject("collectionIds", StringUtils.join(collectionIds, ","));

      mv.addObject("bloodTypingOutput", results.get("bloodTestingResults"));
      mv.addObject("success", success);
      mv.setViewName("bloodtesting/bloodTypingWellsSuccess");
    } else {
      // errors found
      mv.addObject("plate", bloodTestingRepository.getPlate("bloodtyping"));
      mv.addObject("errorMap", errorMap);
      mv.addObject("bloodTypingTests", bloodTypingTests);
      mv.addObject("success", success);
      mv.addObject("refreshUrl", refreshUrl);
      mv.addObject("changeCollectionsUrl", "bloodTypingWorksheetGenerator.html");
      mv.addObject(
          "collectionsWithUninterpretableResults",
          results.get("collectionsWithUninterpretableResults"));
      mv.addObject("collectionsByCollectionId", results.get("collections"));

      utilController.addTipsToModel(tips, "bloodtyping.plate.step2");
      mv.addObject("bloodTestsOnPlate", getBloodTestsOnPlate());
      mv.addObject("bloodTypingConfig", genericConfigRepository.getConfigProperties("bloodTyping"));
      mv.addObject(
          "errorMessage",
          "There were errors adding tests. Please verify the results in the wells highlighted in red.");
      mv.setViewName("bloodtesting/bloodTypingWellsError");
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }

    return mv;
  }