Source:
<code>public void saveRadiologyOrderEncounter_shouldCreateRadiologyOrderEncounterAttachedToExistingActiveVisitGivenPatientWithActiveVisit() throws Exception { Patient patient = patientService.getPatient(PATIENT_ID_WITH_NO_RADIOLOGY_ORDER_AND_NO_EXISTIG_ENCOUNTER_AND_ACTIVE_VISIT); Provider provider = providerService.getProviderByUuid(RADIOLOGY_ORDER_PROVIDER_UUID); Date encounterDatetime = new GregorianCalendar(2010, Calendar.OCTOBER, 10).getTime(); <START> Visit preExistingVisit = visitService.getVisit(3001); <END> assertThat(encounterService.getEncountersByPatient(patient), is(empty())); assertThat(visitService.getActiveVisitsByPatient(patient), is(Arrays.asList(preExistingVisit))); Encounter encounter = (Encounter) saveRadiologyOrderEncounterMethod.invoke(radiologyServiceImpl, new Object[] { patient, provider, encounterDatetime }); assertNotNull(encounter); assertThat(encounter.getPatient(), is(patient)); assertThat(encounter.getProvidersByRole(radiologyProperties.getOrderingProviderEncounterRole()) .size(), is(1)); assertThat(encounter.getProvidersByRole(radiologyProperties.getOrderingProviderEncounterRole()) .contains(provider), is(true)); assertThat(encounter.getEncounterDatetime(), is(encounterDatetime)); assertThat(encounter.getEncounterType(), is(radiologyProperties.getRadiologyOrderEncounterType())); assertThat(encounterService.getEncountersByPatient(patient), is(Arrays.asList(encounter))); assertThat(visitService.getActiveVisitsByPatient(patient), is(Arrays.asList(preExistingVisit))); }</code><technical_language>@bgeVam replace magic number 3001 visitService.getActiveVisitsByPatient(patient) assert is is(not(empty())</technical_language>

Target:
public void saveRadiologyOrderEncounter_shouldCreateRadiologyOrderEncounterAttachedToExistingActiveVisitGivenPatientWithActiveVisit() throws Exception { Patient patient = patientService.getPatient(PATIENT_ID_WITH_NO_RADIOLOGY_ORDER_AND_NO_EXISTIG_ENCOUNTER_AND_ACTIVE_VISIT); Provider provider = providerService.getProviderByUuid(RADIOLOGY_ORDER_PROVIDER_UUID); Date encounterDatetime = new GregorianCalendar(2010, Calendar.OCTOBER, 10).getTime(); List<Visit> preExistingVisits = visitService.getActiveVisitsByPatient(patient); assertThat(encounterService.getEncountersByPatient(patient), is(empty())); assertThat(visitService.getActiveVisitsByPatient(patient), is(not(empty()))); Encounter encounter = (Encounter) saveRadiologyOrderEncounterMethod.invoke(radiologyServiceImpl, new Object[] { patient, provider, encounterDatetime }); assertNotNull(encounter); assertThat(encounter.getPatient(), is(patient)); assertThat(encounter.getProvidersByRole(radiologyProperties.getRadiologyOrderingProviderEncounterRole()) .size(), is(1)); assertThat(encounter.getProvidersByRole(radiologyProperties.getRadiologyOrderingProviderEncounterRole()) .contains(provider), is(true)); assertThat(encounter.getEncounterDatetime(), is(encounterDatetime)); assertThat(encounter.getVisit() .getVisitType(), is(radiologyProperties.getRadiologyVisitType())); assertThat(encounter.getEncounterType(), is(radiologyProperties.getRadiologyOrderEncounterType())); assertThat(encounterService.getEncountersByPatient(patient), is(Arrays.asList(encounter))); assertThat(visitService.getActiveVisitsByPatient(patient), is(preExistingVisits)); }