@Test public void shouldSetFinalStatusOnNewObsByDefault() throws Exception { Obs obs = new Obs(); assertThat(obs.getStatus(), is(Obs.Status.FINAL)); }
@Test public void saveObs_shouldSetStatusToAmendedWhenModifyingAnObsWithFinalStatus() throws Exception { Obs existing = obsService.getObs(7); existing.setValueNumeric(60.0); Obs amended = obsService.saveObs(existing, "testing"); assertThat(amended.getValueNumeric(), is(60.0)); assertThat(amended.getStatus(), is(Obs.Status.AMENDED)); assertThat(existing.getStatus(), is(Obs.Status.FINAL)); }
@Test public void saveObs_shouldNotChangeStatusOfPreliminaryWhenModifyingAnObs() throws Exception { Obs existing = obsService.getObs(9); existing.setValueNumeric(175.0); Obs newObs = obsService.saveObs(existing, "testing"); assertThat(newObs.getValueNumeric(), is(175.0)); assertThat(newObs.getStatus(), is(Obs.Status.PRELIMINARY)); }
/** * Tests that we support a manual workaround in case you need to modify a FINAL obs and leave its status as FINAL */ @Test public void shouldNotAutomaticallySetStatusWhenManuallyCopyingAnObs() throws Exception { Obs existing = obsService.getObs(7); Obs newObs = Obs.newInstance(existing); newObs.setValueNumeric(60.0); newObs.setPreviousVersion(existing); newObs = obsService.saveObs(newObs, null); obsService.voidObs(existing, "testing"); assertThat(existing.getStatus(), is(Obs.Status.FINAL)); assertThat(existing.getVoided(), is(true)); assertThat(newObs.getStatus(), is(Obs.Status.FINAL)); } }
@Test public void saveObs_shouldLetYouChangeStatusFromPreliminaryToFinalWhenModifyingAnObs() throws Exception { Obs existing = obsService.getObs(9); existing.setValueNumeric(175.0); existing.setStatus(Obs.Status.FINAL); Obs newObs = obsService.saveObs(existing, "testing"); assertThat(newObs.getValueNumeric(), is(175.0)); assertThat(newObs.getStatus(), is(Obs.Status.FINAL)); }
@Test public void newInstance_shouldCopyMostFields() throws Exception { Obs obs = new Obs(); obs.setStatus(Obs.Status.PRELIMINARY); obs.setInterpretation(Obs.Interpretation.LOW); obs.setConcept(new Concept()); obs.setValueNumeric(1.2); Obs copy = Obs.newInstance(obs); // these fields are not copied assertThat(copy.getObsId(), nullValue()); assertThat(copy.getUuid(), not(obs.getUuid())); // other fields are copied assertThat(copy.getConcept(), is(obs.getConcept())); assertThat(copy.getValueNumeric(), is(obs.getValueNumeric())); assertThat(copy.getStatus(), is(obs.getStatus())); assertThat(copy.getInterpretation(), is(obs.getInterpretation())); // TODO test that the rest of the fields are set }
newObs.setDateVoided(obsToCopy.getDateVoided()); newObs.setVoidReason(obsToCopy.getVoidReason()); newObs.setStatus(obsToCopy.getStatus()); newObs.setInterpretation(obsToCopy.getInterpretation());