@Test public void testFetchPatientOutpatientMedications() { try { when(this.mockJMeadowsClient.getPatientMedications(any(JMeadowsQuery.class))).thenReturn(createTestData()); JMeadowsQuery query = new JMeadowsQueryBuilder() .user(user) .patient(patient) .build(); PatientIds patientIds = new PatientIds.Builder() .pid(pid) .icn(icn) .uid(uid) .edipi(edipi) .build(); List<VistaDataChunk> vistaDataChunkList = jMeadowsMedicationService.fetchDodPatientOutpatientMedications(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(2)); List<Medication> testDataList = createTestData(); for(int i = 0; i < vistaDataChunkList.size(); i++) { VistaDataChunk vistaDataChunk = vistaDataChunkList.get(i); assertThat(JMeadowsMedicationService.DOMAIN_MEDICATION, is(vistaDataChunk.getDomain())); assertThat(2, is(vistaDataChunk.getItemCount())); assertThat(i+1, is(vistaDataChunk.getItemIndex())); assertThat(vistaId, is(vistaDataChunk.getParams().get("vistaId"))); assertThat(dfn, is(vistaDataChunk.getParams().get("patientDfn"))); assertThat(vistaId, is(vistaDataChunk.getSystemId())); assertThat(dfn, is(vistaDataChunk.getLocalPatientId())); assertThat(icn, is(vistaDataChunk.getPatientIcn())); assertThat("DOD;" + edipi, is(vistaDataChunk.getPatientId())); assertThat("vrpcb: assertThat(VistaDataChunk.NEW_OR_UPDATE, is(vistaDataChunk.getType())); Map<String,Object> jsonMap = vistaDataChunk.getJsonMap(); Medication testMed = testDataList.get(i); assertThat("DOD", is(jsonMap.get("facilityCode"))); assertThat("DOD", is(jsonMap.get("facilityName"))); assertThat("urn:va:med:DOD:"+edipi+":"+testMed.getCdrEventId(), is(jsonMap.get("uid"))); assertThat(testMed.getActive(), is(jsonMap.get("vaStatus"))); assertThat(testMed.getActive(), is(jsonMap.get("medStatus"))); assertThat(testMed.getMedType(), is(jsonMap.get("medType"))); assertThat("UNKNOWN", is(jsonMap.get("vaType"))); assertThat(testMed.getComment(), is(jsonMap.get("patientInstruction"))); assertThat(testMed.getDrugName(), is(jsonMap.get("productFormName"))); assertThat(testMed.getMedId(), is(jsonMap.get("productFormCode"))); assertThat(testMed.getSigCode(), is(jsonMap.get("sig"))); assertThat(testMed.getDrugName(), is(jsonMap.get("name"))); assertThat(calendarToPointInTime(testMed.getFillOrderDate()).toString(), is(jsonMap.get("overallStart"))); assertThat(calendarToPointInTime(testMed.getStopDate()).toString(), is(jsonMap.get("overallStop"))); List<Map<String, Object>> orders = (List<Map<String, Object>>)jsonMap.get("orders"); assertThat(orders.size(), is(1)); Map<String, Object> order = orders.get(0); assertThat(Integer.parseInt(testMed.getDaysSupply()), is(order.get("daysSupply"))); assertThat(testMed.getQuantity(), is(order.get("quantityOrdered"))); assertThat(Integer.parseInt(testMed.getRefills()), is(order.get("fillsRemaining"))); assertThat(testMed.getOrderingProvider(), is(order.get("providerName"))); List<Map<String, Object>> fills = (List<Map<String, Object>>)jsonMap.get("fills"); List<PrescriptionFill> pfills = testMed.getPrescriptionFills(); assertThat(fills.size(), is(pfills.size())); int j = 0; for(PrescriptionFill aFill : pfills) { Map<String, Object> fill = fills.get(j); assertThat(aFill.getDispensingQuantity(), is(fill.get("quantityDispensed"))); assertThat(aFill.getDispensingPharmacy(), is(fill.get("dispensingPharmacy"))); assertThat(calendarToPointInTime(aFill.getDispenseDate()).toString(), is(fill.get("dispenseDate"))); j++; } } } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }
@Override public List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications - Entering method..."); query.setStatus("O"); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaMedChunk = new ArrayList<VistaDataChunk>(); List<Medication> oaMedication = jMeadowsClient.getPatientMedications(query); LOG.debug("JMeadowsMedicationService.fetchDodOutpatientMedications: " + ((oaMedication == null)? "NO" : ""+oaMedication.size()) + " results retrieved from JMeadows."); if ((oaMedication != null) && (oaMedication.size() > 0)) { oaMedication = (List<Medication>) filterOnSourceProtocol(oaMedication, SOURCE_PROTOCOL_DODADAPTER); int iNumMeds = calculateNumMeds(oaMedication); int iCurMedIdx = 1; for (Medication oMed : oaMedication) { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications: Found DoD Medication - Processing it... idx: " + iCurMedIdx); VistaDataChunk oMedChunk = transformMedicationChunk(oMed, patientIds, iNumMeds, iCurMedIdx); if (oMedChunk != null) { oaMedChunk.add(oMedChunk); iCurMedIdx++; } } } return oaMedChunk; }
JMeadowsMedicationService implements IJMeadowsMedicationService { @Override public List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications - Entering method..."); query.setStatus("O"); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaMedChunk = new ArrayList<VistaDataChunk>(); List<Medication> oaMedication = jMeadowsClient.getPatientMedications(query); LOG.debug("JMeadowsMedicationService.fetchDodOutpatientMedications: " + ((oaMedication == null)? "NO" : ""+oaMedication.size()) + " results retrieved from JMeadows."); if ((oaMedication != null) && (oaMedication.size() > 0)) { oaMedication = (List<Medication>) filterOnSourceProtocol(oaMedication, SOURCE_PROTOCOL_DODADAPTER); int iNumMeds = calculateNumMeds(oaMedication); int iCurMedIdx = 1; for (Medication oMed : oaMedication) { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications: Found DoD Medication - Processing it... idx: " + iCurMedIdx); VistaDataChunk oMedChunk = transformMedicationChunk(oMed, patientIds, iNumMeds, iCurMedIdx); if (oMedChunk != null) { oaMedChunk.add(oMedChunk); iCurMedIdx++; } } } return oaMedChunk; } }
JMeadowsMedicationService implements IJMeadowsMedicationService { @Override public List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications - Entering method..."); query.setStatus("O"); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaMedChunk = new ArrayList<VistaDataChunk>(); List<Medication> oaMedication = jMeadowsClient.getPatientMedications(query); LOG.debug("JMeadowsMedicationService.fetchDodOutpatientMedications: " + ((oaMedication == null)? "NO" : ""+oaMedication.size()) + " results retrieved from JMeadows."); if ((oaMedication != null) && (oaMedication.size() > 0)) { oaMedication = (List<Medication>) filterOnSourceProtocol(oaMedication, SOURCE_PROTOCOL_DODADAPTER); int iNumMeds = calculateNumMeds(oaMedication); int iCurMedIdx = 1; for (Medication oMed : oaMedication) { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications: Found DoD Medication - Processing it... idx: " + iCurMedIdx); VistaDataChunk oMedChunk = transformMedicationChunk(oMed, patientIds, iNumMeds, iCurMedIdx); if (oMedChunk != null) { oaMedChunk.add(oMedChunk); iCurMedIdx++; } } } return oaMedChunk; } @Autowired  JMeadowsMedicationService(JMeadowsConfiguration jMeadowsConfiguration); }
JMeadowsMedicationService implements IJMeadowsMedicationService { @Override public List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications - Entering method..."); query.setStatus("O"); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaMedChunk = new ArrayList<VistaDataChunk>(); List<Medication> oaMedication = jMeadowsClient.getPatientMedications(query); LOG.debug("JMeadowsMedicationService.fetchDodOutpatientMedications: " + ((oaMedication == null)? "NO" : ""+oaMedication.size()) + " results retrieved from JMeadows."); if ((oaMedication != null) && (oaMedication.size() > 0)) { oaMedication = (List<Medication>) filterOnSourceProtocol(oaMedication, SOURCE_PROTOCOL_DODADAPTER); int iNumMeds = calculateNumMeds(oaMedication); int iCurMedIdx = 1; for (Medication oMed : oaMedication) { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications: Found DoD Medication - Processing it... idx: " + iCurMedIdx); VistaDataChunk oMedChunk = transformMedicationChunk(oMed, patientIds, iNumMeds, iCurMedIdx); if (oMedChunk != null) { oaMedChunk.add(oMedChunk); iCurMedIdx++; } } } return oaMedChunk; } @Autowired  JMeadowsMedicationService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds); @Override List<VistaDataChunk> fetchDodPatientInpatientMedications(JMeadowsQuery query, PatientIds patientIds); }
JMeadowsMedicationService implements IJMeadowsMedicationService { @Override public List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications - Entering method..."); query.setStatus("O"); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaMedChunk = new ArrayList<VistaDataChunk>(); List<Medication> oaMedication = jMeadowsClient.getPatientMedications(query); LOG.debug("JMeadowsMedicationService.fetchDodOutpatientMedications: " + ((oaMedication == null)? "NO" : ""+oaMedication.size()) + " results retrieved from JMeadows."); if ((oaMedication != null) && (oaMedication.size() > 0)) { oaMedication = (List<Medication>) filterOnSourceProtocol(oaMedication, SOURCE_PROTOCOL_DODADAPTER); int iNumMeds = calculateNumMeds(oaMedication); int iCurMedIdx = 1; for (Medication oMed : oaMedication) { LOG.debug("JMeadowsMedicationService.fetchDodPatientOutpatientMedications: Found DoD Medication - Processing it... idx: " + iCurMedIdx); VistaDataChunk oMedChunk = transformMedicationChunk(oMed, patientIds, iNumMeds, iCurMedIdx); if (oMedChunk != null) { oaMedChunk.add(oMedChunk); iCurMedIdx++; } } } return oaMedChunk; } @Autowired  JMeadowsMedicationService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientOutpatientMedications(JMeadowsQuery query, PatientIds patientIds); @Override List<VistaDataChunk> fetchDodPatientInpatientMedications(JMeadowsQuery query, PatientIds patientIds); static final String DOMAIN_MEDICATION; }