SyncController { public boolean isSelectedPatientToReload(String pid, String dfn, String vistaId, String icn) { boolean check = false; if (StringUtils.hasText(pid)) { PatientDemographics pt = null; if (StringUtils.hasText(dfn) && StringUtils.hasText(vistaId)) { pt = patientDao.findByLocalId(vistaId, dfn); } else if (StringUtils.hasText(icn)) { pt = patientDao.findByPid(icn); } if (pt != null && pid.equalsIgnoreCase(pt.getPid())) { check = true; } } return check; }  @Autowired void setApplicationContext(ApplicationContext ctx); @Autowired void setSyncService(ISyncService syncService); @Autowired void setRosterService(IRosterService rosterService); @Autowired void setPatientDao(IPatientDAO patientDao); @Autowired void setVistaAccountDao(IVistaAccountDao vistaAccountDao); @Autowired void setUserContext(UserContext userContext); @Autowired void setPatientContext(PatientContext patientContext); @Autowired void setVprUpdateJob(VprUpdateJob vprUpdateJob); @Autowired void setMetricRegistry(MetricRegistry metricRegistry); @Autowired void setUserAuditService(IUserAuditService userAuditService); @Autowired void setPatientSelectDao(IPatientSelectDAO patientSelectDao); @RequestMapping(value = "/sync/stats", method = GET) ModelAndView stats(HttpServletRequest request); @RequestMapping(value = "/sync/command/detail", method = GET) ModelAndView getCommandDetail(); @RequestMapping(value = "/sync/patient/queues", method = GET) ModelAndView getPatientQueues(); @RequestMapping(value = "/sync/operationalSyncStatus", method = GET) ModelAndView getOperationalSyncStatus(HttpServletRequest request); @RequestMapping(value = "/sync/reindexStatus", method = GET) ModelAndView getReindexStatus(HttpServletRequest request); @RequestMapping(value = "/sync/loadRosterPatients", method = POST) ModelAndView loadRosterPatients(HttpServletRequest request, @RequestParam final String uid); @RequestMapping(value = "/sync/expire", method = POST) ModelAndView expire(@RequestParam(required = false) final String icn,
                               @RequestParam(required = false) final String dfn,
                               @RequestParam(required = true) final String vistaId,
                               @RequestParam(required = false) final PointInTime time, 
                               HttpServletRequest request); @RequestMapping(value = "/sync/load", method = POST) ModelAndView load(@RequestParam(required = false) final String icn, @RequestParam(required = false) final String dfn, 
    		@RequestParam(required = false) final String prioritySelect, @RequestParam(required = false) List<String> prioritySite, HttpServletRequest request); @RequestMapping(value = "/sync/mvi", method = POST) ModelAndView mviSync(@RequestBody String mvi, HttpServletRequest request); @RequestMapping(value = "/sync/clearPatient", method = POST) ModelAndView clearPatient(@RequestParam(required = false) String icn,
                                     @RequestParam(required = false) String pid,
                                     @RequestParam(required = false) String dfn,
                                     HttpServletRequest request); @RequestMapping(value = "/sync/toggleAutoUpdates", method = POST) ModelAndView autoUpdates(HttpServletRequest request); @RequestMapping(value = "/sync/cancel", method = POST) ModelAndView cancelPendingMessages(HttpServletRequest request); @RequestMapping(value = "/sync/clearAllPatients", method = POST) ModelAndView clearAllPatient(HttpServletRequest request); @RequestMapping(value = "/sync/reindexPatient", method = POST) ModelAndView reindexPatient(@RequestParam(required = true) final String pid, HttpServletRequest request); @RequestMapping(value = "/sync/reindexAllPatients", method = POST) ModelAndView reindexAllPatients(HttpServletRequest request); @RequestMapping(value = "/sync/error/redeliver") ModelAndView resendSyncError(@RequestParam(required = true) String recId, HttpServletRequest request); @RequestMapping(value = "/sync/syncErrors", method = GET) ModelAndView syncErrors(Pageable pageable,
                                   @RequestParam(required = false) String format,
                                   @RequestParam(required = false) Boolean includeWarnings,
                                   @RequestParam(required = false) String searchString,
                                   @RequestParam(required = false) String searchAreas,
                                   HttpServletRequest request); @RequestMapping(value = "/sync/syncErrors/clear", method = POST) ModelAndView clearAllSyncErrors(HttpServletRequest request); boolean isSelectedPatientToReload(String pid, String dfn, String vistaId, String icn); @RequestMapping(value = "/sync/simulateErrors/patientData", method = POST) ModelAndView toggleSimulatePatientErrors(@RequestParam(required = false) Boolean simulateErrors); @RequestMapping(value = "/sync/operationalInProgress", method = GET) ModelAndView isOperationalDataSynching();  }
@Test public void testIsSelectedPatientToReload_LocalId() throws Exception { PatientDemographics pt = new PatientDemographics(); pt.setData("pid", "2"); when(mockPatientDao.findByLocalId("545", "8")).thenReturn(pt); Assert.assertTrue(controller.isSelectedPatientToReload("2", "8", "545", null)); Assert.assertFalse(controller.isSelectedPatientToReload("3", "", "", "")); }
@Test public void testIsSelectedPatientToReload_Icn() throws Exception { PatientDemographics pt = new PatientDemographics(); pt.setData("pid", "1001"); when(mockPatientDao.findByPid("1001")).thenReturn(pt); Assert.assertTrue(controller.isSelectedPatientToReload("1001", null, null, "1001")); Assert.assertFalse(controller.isSelectedPatientToReload("3", null, null, "1001")); }