@Test public void shouldGetBedDetailsById() { int deluxeBedId = 1; BedDetails details = bedManagementService.getBedDetailsById(String.valueOf(deluxeBedId)); assertNotNull(details); assertNotNull(details.getPatients()); assertNotNull(details.getCurrentAssignments()); assertEquals("deluxe", details.getBedType().getName()); }
@Test public void shouldUnAssingPatientFromBed() throws Exception { PatientService patientService = Context.getPatientService(); Patient patient = patientService.getPatient(4); BedDetails bedDetails = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertEquals(Integer.valueOf(12), bedDetails.getBed().getId()); BedDetails unAssignedBed = bedManagementService.unAssignPatientFromBed(patient); assertEquals(Integer.valueOf(12), unAssignedBed.getBed().getId()); bedDetails = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertNull(bedDetails); }
@Test public void shouldReturnBedAssignmentDetailsByPatient() { PatientService patientService = Context.getPatientService(); Patient patient = patientService.getPatient(3); LocationService locationService = Context.getLocationService(); Location ward = locationService.getLocation(123452); String bedNumFromDataSetup = "307-a"; BedDetails bedDetails = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertEquals(ward.getId(), bedDetails.getPhysicalLocation().getId()); assertEquals(bedIdFromDataSetup, bedDetails.getBedId()); assertEquals(bedNumFromDataSetup, bedDetails.getBedNumber()); }
@Test public void shouldAssignPatientToBed() throws Exception { PatientService patientService = Context.getPatientService(); Patient patient = patientService.getPatient(5); BedDetails bedDetails = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertNull(bedDetails); EncounterService encounterService = Context.getEncounterService(); List<Encounter> encountersByPatient = encounterService.getEncountersByPatient(patient); bedManagementService.assignPatientToBed(patient, encountersByPatient.get(0), "10"); BedDetails assigned = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertNotNull(assigned); assertNotNull(assigned.getCurrentAssignments()); assertNull(assigned.getLastAssignment()); }
@Test public void shouldAssignUnassignExistingPatientFromBed() throws Exception { int bedId = 9; PatientService patientService = Context.getPatientService(); Patient patient = patientService.getPatient(3); EncounterService encounterService = Context.getEncounterService(); List<Encounter> encountersByPatient = encounterService.getEncountersByPatient(patient); BedDetails bedDetails = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertNotNull(bedDetails); Assert.assertEquals(11, bedDetails.getBedId()); bedManagementService.assignPatientToBed( patient, encountersByPatient.get(0), String.valueOf(bedId)); bedDetails = bedManagementService.getBedAssignmentDetailsByPatient(patient); assertEquals(bedId, bedDetails.getBedId()); }