@Override protected VisitType getObjectByUuid(String uuid) { return Context.getVisitService().getVisitTypeByUuid(uuid); } }
visitType = visitService.getVisitType(Integer.parseInt(visitTypeIdOrUuid)); } else { visitType = visitService.getVisitTypeByUuid(visitTypeIdOrUuid);
@Test public void getVisitTypeByUuid_shouldReturnNullIfVisitTypeIsNotFound() { assertNull(visitService.getVisitTypeByUuid("759799ab-c9a5-435e-b671-77773ada74e1")); }
@Test public void getVisitTypeByUuid_shouldGetCorrentVisitType() { VisitType visitType = visitService.getVisitTypeByUuid("c0c579b0-8e59-401d-8a4a-976a0b183519"); assertNotNull(visitType); assertEquals("Initial HIV Clinic Visit", visitType.getName()); }
.assertEquals(Context.getVisitService().getVisitTypeByUuid(visitTypeUuid), encounter.getVisit() .getVisitType());
/** * Fetches a visitType by uuid, if no match is found, it tries to look up one with a matching * name with the assumption that the passed parameter is a visitType name * * @see DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public VisitType getByUniqueId(String uuid) { VisitType visitType = Context.getVisitService().getVisitTypeByUuid(uuid); //We assume the caller was fetching by name, 1.9.0 has no method to fetch by name if (visitType == null) { List<VisitType> visitTypes = Context.getVisitService().getAllVisitTypes(); for (VisitType possibleVisitType : visitTypes) { if (possibleVisitType.getName().equalsIgnoreCase(uuid)) return possibleVisitType; } } return visitType; }
@Override public VisitType newObject() { return Context.getVisitService().getVisitTypeByUuid(getUuidProperty()); }
@Test public void shouldPurgeAVisitType() throws Exception { String uuid = "759799ab-c9a5-435e-b671-77773ada74e6"; Assert.assertNotNull(service.getVisitTypeByUuid(uuid)); int originalCount = service.getAllVisitTypes().size(); handle(newDeleteRequest(getURI() + "/" + uuid, new Parameter("purge", "true"))); Assert.assertNull(service.getVisitTypeByUuid(uuid)); Assert.assertEquals(originalCount - 1, service.getAllVisitTypes().size()); }
@Test public void shouldRetireAVisitType() throws Exception { VisitType visitType = service.getVisitTypeByUuid(RestTestConstants1_9.VISIT_TYPE_UUID); Assert.assertFalse(visitType.isRetired()); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "test reason"))); visitType = service.getVisitTypeByUuid(RestTestConstants1_9.VISIT_TYPE_UUID); Assert.assertTrue(visitType.isRetired()); Assert.assertEquals("test reason", visitType.getRetireReason()); }
@Test public void createEncounter_shouldEditVisitPropertyForAnExisitingEncounter() throws Exception { EncounterService es = Context.getEncounterService(); VisitService vs = Context.getVisitService(); Encounter encounter = es.getEncounterByUuid(getUuid()); Visit newVisit = new Visit(encounter.getPatient(), vs.getVisitTypeByUuid(RestTestConstants1_9.VISIT_TYPE_UUID), new SimpleDateFormat("yyyy-MM-dd").parse("2008-08-01")); vs.saveVisit(newVisit); String json = "{\"visit\":\"" + newVisit.getUuid() + "\"}"; SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class); Object newEncounterObject = handle(newPostRequest(getURI() + "/" + getUuid(), post)); Assert.assertNotNull(newEncounterObject); Encounter update = es.getEncounterByUuid(getUuid()); //the encounter should have been res assigned to the new visit Assert.assertEquals(newVisit, update.getVisit()); }
@Test public void shouldEditAVisitType() throws Exception { String json = "{ \"name\":\"new visit type\", \"description\":\"new description\" }"; handle(newPostRequest(getURI() + "/" + getUuid(), json)); VisitType updated = service.getVisitTypeByUuid(RestTestConstants1_9.VISIT_TYPE_UUID); Assert.assertNotNull(updated); Assert.assertEquals("new visit type", updated.getName()); Assert.assertEquals("new description", updated.getDescription()); }