@Test public void getFlags_shouldReturnAllFlags() { List<SimpleObject> flags = controller.getFlags(7, calculationManager); for (SimpleObject flag : flags) { TestUtils.printJson(flag); Assert.assertThat(flag, hasKey("message")); Assert.assertThat((String) flag.get("message"), not(startsWith("ERROR"))); } }
@SharedAction public List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager) { List<SimpleObject> flags = new ArrayList<SimpleObject>(); for (PatientFlagCalculation calc : calculationManager.getFlagCalculations()) { try { CalculationResult result = Context.getService(PatientCalculationService.class).evaluate(patientId, calc); if (result != null && (Boolean) result.getValue()) { flags.add(SimpleObject.create("message", calc.getFlagMessage())); } } catch (Exception ex) { log.error("Error evaluating " + calc.getClass(), ex); return Collections.singletonList(SimpleObject.create("message", "ERROR EVALUATING '" + calc.getFlagMessage() + "'")); } } return flags; }
PatientUtilsFragmentController { @SharedAction public List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager) { List<SimpleObject> flags = new ArrayList<SimpleObject>(); for (PatientFlagCalculation calc : calculationManager.getFlagCalculations()) { try { CalculationResult result = Context.getService(PatientCalculationService.class).evaluate(patientId, calc); if (result != null && (Boolean) result.getValue()) { flags.add(SimpleObject.create("message", calc.getFlagMessage())); } } catch (Exception ex) { log.error("Error evaluating " + calc.getClass(), ex); return Collections.singletonList(SimpleObject.create("message", "ERROR EVALUATING '" + calc.getFlagMessage() + "'")); } } return flags; } }
PatientUtilsFragmentController { @SharedAction public List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager) { List<SimpleObject> flags = new ArrayList<SimpleObject>(); for (PatientFlagCalculation calc : calculationManager.getFlagCalculations()) { try { CalculationResult result = Context.getService(PatientCalculationService.class).evaluate(patientId, calc); if (result != null && (Boolean) result.getValue()) { flags.add(SimpleObject.create("message", calc.getFlagMessage())); } } catch (Exception ex) { log.error("Error evaluating " + calc.getClass(), ex); return Collections.singletonList(SimpleObject.create("message", "ERROR EVALUATING '" + calc.getFlagMessage() + "'")); } } return flags; }  }
PatientUtilsFragmentController { @SharedAction public List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager) { List<SimpleObject> flags = new ArrayList<SimpleObject>(); for (PatientFlagCalculation calc : calculationManager.getFlagCalculations()) { try { CalculationResult result = Context.getService(PatientCalculationService.class).evaluate(patientId, calc); if (result != null && (Boolean) result.getValue()) { flags.add(SimpleObject.create("message", calc.getFlagMessage())); } } catch (Exception ex) { log.error("Error evaluating " + calc.getClass(), ex); return Collections.singletonList(SimpleObject.create("message", "ERROR EVALUATING '" + calc.getFlagMessage() + "'")); } } return flags; }  @SharedAction List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager); @SharedAction List<SimpleObject> getScheduled(@RequestParam("date") Date date, UiUtils ui); @SharedAction List<SimpleObject> getSeenPatients(@RequestParam("date") Date date, UiUtils ui); @AppAction(EmrConstants.APP_CHART) SimpleObject[] recentlyViewed(UiUtils ui, Session session); SimpleObject age(@RequestParam("patientId") Patient patient, @RequestParam("now") Date now); SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui); SimpleObject[] getFathers(@RequestParam("patientId") Patient patient,UiUtils ui); String patientExist(@RequestParam("patientId") String patientId,UiUtils ui); }
PatientUtilsFragmentController { @SharedAction public List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager) { List<SimpleObject> flags = new ArrayList<SimpleObject>(); for (PatientFlagCalculation calc : calculationManager.getFlagCalculations()) { try { CalculationResult result = Context.getService(PatientCalculationService.class).evaluate(patientId, calc); if (result != null && (Boolean) result.getValue()) { flags.add(SimpleObject.create("message", calc.getFlagMessage())); } } catch (Exception ex) { log.error("Error evaluating " + calc.getClass(), ex); return Collections.singletonList(SimpleObject.create("message", "ERROR EVALUATING '" + calc.getFlagMessage() + "'")); } } return flags; }  @SharedAction List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager); @SharedAction List<SimpleObject> getScheduled(@RequestParam("date") Date date, UiUtils ui); @SharedAction List<SimpleObject> getSeenPatients(@RequestParam("date") Date date, UiUtils ui); @AppAction(EmrConstants.APP_CHART) SimpleObject[] recentlyViewed(UiUtils ui, Session session); SimpleObject age(@RequestParam("patientId") Patient patient, @RequestParam("now") Date now); SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui); SimpleObject[] getFathers(@RequestParam("patientId") Patient patient,UiUtils ui); String patientExist(@RequestParam("patientId") String patientId,UiUtils ui);  }