JMeadowsPatientService implements IJMeadowsPatientService, EnvironmentAware { @Override public List<VistaDataChunk> fetchDodPatientData(PatientIds patientIds) { LOG.debug("JMeadowsPatientService.fetchDodPatientData - Entering method..."); validatePatientIds(patientIds); List<VistaDataChunk> oaVistaDataChunk = new ArrayList<VistaDataChunk>(); JMeadowsQueryBuilder queryBuilder = createDodJMeadowsQueryBuilder(patientIds, jMeadowsConfiguration); long startTime = System.currentTimeMillis(); Map<String,ForkJoinTask<List<VistaDataChunk>>> tasksList = new HashMap<String,ForkJoinTask<List<VistaDataChunk>>>(); tasksList.put("Allergies", pool.submit(new FetchDoDPatientDataTask( jMeadowsAllergyService, "fetchDodPatientAllergies", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Vitals", pool.submit(new FetchDoDPatientDataTask( jMeadowsVitalService, "fetchDodPatientVitals", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Labs", pool.submit(new FetchDoDPatientDataTask( jMeadowsLabService, "fetchDodPatientLabs", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("OutpatientMedications", pool.submit(new FetchDoDPatientDataTask( jMeadowsMedicationService, "fetchDodPatientOutpatientMedications", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("InpatientMedications", pool.submit(new FetchDoDPatientDataTask( jMeadowsMedicationService, "fetchDodPatientInpatientMedications", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("RadiologyReports", pool.submit(new FetchDoDPatientDataTask( jMeadowsRadiologyService, "fetchDodPatientRadiologyReports", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Problems", pool.submit(new FetchDoDPatientDataTask( jMeadowsProblemService, "fetchDodPatientProblems", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("OutpatientNotes", pool.submit(new FetchDoDPatientDataTask( jMeadowsNoteService, "fetchDodNotes", new Object[]{OUTPATIENT, queryBuilder.build(), patientIds}))); tasksList.put("InpatientNotes", pool.submit(new FetchDoDPatientDataTask( jMeadowsNoteService, "fetchDodNotes", new Object[]{INPATIENT, queryBuilder.build(), patientIds}))); tasksList.put("Consults", pool.submit(new FetchDoDPatientDataTask( jMeadowsConsultNoteService, "fetchDodConsults", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Demographics", pool.submit(new FetchDoDPatientDataTask( jMeadowsDemographicsService, "fetchDodPatientDemographics", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Immunizations", pool.submit(new FetchDoDPatientDataTask( jMeadowsImmunizationService, "fetchDodPatientImmunizations", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Orders", pool.submit(new FetchDoDPatientDataTask( jMeadowsOrderService, "fetchDodPatientOrders", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Encounters", pool.submit(new FetchDoDPatientDataTask( jMeadowsEncounterService, "fetchDodPatientEncounters", new Object[]{queryBuilder.build(), patientIds}))); tasksList.put("Appointments", pool.submit(new FetchDoDPatientDataTask( jMeadowsAppointmentService, "fetchDodPatientAppointments", new Object[]{queryBuilder.build(), patientIds}))); try { Set<String> keys = tasksList.keySet(); if (NullChecker.isNotNullish(keys)){ for(String key : keys){ oaVistaDataChunk.addAll(tasksList.get(key).join()); } } } catch(RuntimeException re){ ForkJoinTask<List<VistaDataChunk>> task; Set<String> keys = tasksList.keySet(); if (NullChecker.isNotNullish(keys)){ for(String key : keys){ task = tasksList.get(key); if (!task.isDone()){ if(task.cancel(true)){ LOG.debug(key + " task cancelled successfully!."); } else{ LOG.debug(key + " task could not be cancelled!."); } } } } throw re; } finally { LOG.debug("total time to fetch DoD patient data: " + (System.currentTimeMillis() - startTime) + "ms, PID: " + patientIds.getPid() + ", parallelism: " + pool.getParallelism()); } LOG.debug("JMeadowsPatientService.fetchDodPatientData - Leaving method with " + oaVistaDataChunk.size() + " VistaDataChunk objects."); return oaVistaDataChunk; }  @Autowired void setJMeadowsConfiguration(JMeadowsConfiguration jMeadowsConfiguration); @Autowired void setJMeadowsAllergyService(IJMeadowsAllergyService IJMeadowsAllergyService); @Autowired void setJMeadowsLabService(IJMeadowsLabService IJMeadowsLabService); @Autowired void setJMeadowsMedicationService(IJMeadowsMedicationService IJMeadowsMedicationService); @Autowired void setJMeadowsRadiologyService(IJMeadowsRadiologyService IJMeadowsRadiologyService); @Autowired void setJMeadowsDemographicsService(IJMeadowsDemographicsService IJMeadowsDemographicsService); @Autowired void setJMeadowsVitalService(IJMeadowsVitalService IJMeadowsVitalService); @Autowired void setJMeadowsProblemService(IJMeadowsProblemService IJMeadowsProblemService); @Autowired void setJMeadowsNoteService(IJMeadowsNoteService IJMeadowsProgressNoteService); @Autowired void setJMeadowsConsultNoteService(IJMeadowsConsultNoteService IJMeadowsConsultNoteService); @Autowired void setJMeadowsImmunizationService(IJMeadowsImmunizationService IJMeadowsImmunizationService); @Autowired void setJMeadowsOrderService(IJMeadowsOrderService ijMeadowsOrderService); @Autowired void setJMeadowsEncounterService(IJMeadowsEncounterService ijMeadowsEncounterService); @Autowired void setJMeadowsAppointmentService(IJMeadowsAppointmentService ijMeadowsAppointmentService); @PostConstruct void init(); @Override List<VistaDataChunk> fetchDodPatientData(PatientIds patientIds); @Override void setEnvironment(Environment environment);  }
@Test public void testFetchDoDPatientData() { jMeadowsPatientService.setJMeadowsAllergyService(createMockAllergyService()); jMeadowsPatientService.setJMeadowsVitalService(createMockVitalService()); jMeadowsPatientService.setJMeadowsLabService(createMockLabService()); jMeadowsPatientService.setJMeadowsDemographicsService(createMockDemographicsService()); jMeadowsPatientService.setJMeadowsProblemService(createMockProblemService()); jMeadowsPatientService.setJMeadowsMedicationService(createMockMedService()); jMeadowsPatientService.setJMeadowsRadiologyService(createMockRadiologyService()); jMeadowsPatientService.setJMeadowsNoteService(createMockNoteService()); jMeadowsPatientService.setJMeadowsConsultNoteService(createMockConsultNoteService()); jMeadowsPatientService.setJMeadowsImmunizationService(createMockImmunizationService()); jMeadowsPatientService.setJMeadowsEncounterService(createMockEncounterService()); jMeadowsPatientService.setJMeadowsAppointmentService(createMockAppointmentService()); PatientIds patientIds = new PatientIds.Builder() .pid("test.pid") .icn("test.icn") .uid("") .edipi("test.edipi") .build(); List<VistaDataChunk> respList = jMeadowsPatientService.fetchDodPatientData(patientIds); assertNotNull(respList); assertTrue(getVistaDataChunkIndexWithContent(respList,mockAllergyJsonContent) != -1); assertTrue(getVistaDataChunkIndexWithContent(respList,mockVitalJsonContent) != -1); }
@Test public void testIllegalParamsCheck() { PatientIds patientIds = null; Exception exception = null; try { jMeadowsPatientService.fetchDodPatientData(patientIds); } catch (Exception e) { exception = e; } assertThat(exception, instanceOf(IllegalArgumentException.class)); }