@Override protected PatientIdentifierType getObjectByUuid(String uuid) { return Context.getPatientService().getPatientIdentifierTypeByUuid(uuid); } }
/** * @see PatientService#getPatientIdentifierTypeByUuid(String) */ @Test public void getPatientIdentifierTypeByUuid_shouldFetchPatientIdentifierTypeWithGivenUuid() throws Exception { PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByUuid( "1a339fe9-38bc-4ab3-b180-320988c0b968"); Assert.assertNotNull(identifierType); Assert.assertTrue(identifierType.getClass().isAssignableFrom(PatientIdentifierType.class)); }
/** * @see PatientService#getPatientIdentifierTypeByUuid(String) */ @Test public void getPatientIdentifierTypeByUuid_shouldReturnNullWhenPatientIdentifierTypeWithGivenUuidDoesNotExist() throws Exception { PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByUuid( "thisuuiddoesnotexist"); Assert.assertNull(identifierType); }
/** * @see PatientService#getPatientIdentifierTypeByUuid(String) */ @Test public void getPatientIdentifierTypeByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() throws Exception { Assert.assertNull(Context.getPatientService().getPatientIdentifierTypeByUuid("some invalid uuid")); }
/** * @see PatientService#getPatientIdentifierTypeByUuid(String) */ @Test public void getPatientIdentifierTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "1a339fe9-38bc-4ab3-b180-320988c0b968"; PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(uuid); Assert.assertEquals(1, (int) patientIdentifierType.getPatientIdentifierTypeId()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override public PatientIdentifierType getByUniqueId(String uniqueId) { PatientIdentifierType type = service().getPatientIdentifierTypeByUuid(uniqueId); if (type == null) type = service().getPatientIdentifierTypeByName(uniqueId); return type; }
@Override public PatientIdentifierType newObject() { return Context.getService(PatientService.class).getPatientIdentifierTypeByUuid(getUuidProperty()); }
@Override public PatientIdentifierType newObject() { return Context.getService(PatientService.class).getPatientIdentifierTypeByUuid(getUuidProperty()); }
/** * Sets the identifier type for a patient identifier. * * @param instance * @param identifierType * @throws org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException */ @PropertySetter("identifierType") public void setIdentifierType(PatientIdentifier instance, PatientIdentifierType identifierType) { String uuid = identifierType.getUuid(); String name = identifierType.getName(); boolean reset = false; if (!reset && !StringUtils.isEmpty(uuid)) { PatientIdentifierType pit = Context.getPatientService().getPatientIdentifierTypeByUuid(uuid); if (pit != null) { instance.setIdentifierType(pit); reset = true; } } if (!reset && !StringUtils.isEmpty(name)) { PatientIdentifierType pit = Context.getPatientService().getPatientIdentifierTypeByName(name); if (pit != null) { instance.setIdentifierType(pit); reset = true; } } }
identifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(id);
@Test public void shouldPurgeAPatientIdentifierType() throws Exception { final String uuid = "158d6b17-a8ab-435b-8fe3-952a04bda757"; assertNotNull(service.getPatientIdentifierTypeByUuid(uuid)); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + uuid); req.addParameter("purge", "true"); handle(req); assertNull(service.getPatientIdentifierTypeByUuid(uuid)); }
@Test public void shouldEditingAPatientIdentifierType() throws Exception { final String newName = "updated name"; SimpleObject patientIdentifierType = new SimpleObject(); patientIdentifierType.add("name", newName); String json = new ObjectMapper().writeValueAsString(patientIdentifierType); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); assertEquals(newName, service.getPatientIdentifierTypeByUuid(getUuid()).getName()); }
@Test public void shouldRetireAPatientIdentifierType() throws Exception { assertEquals(false, service.getPatientIdentifierTypeByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req); assertEquals(true, service.getPatientIdentifierTypeByUuid(getUuid()).isRetired()); assertEquals(reason, service.getPatientIdentifierTypeByUuid(getUuid()).getRetireReason()); }
Assert.assertFalse(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "1a339fe9-38bc-4ab3-b180-320988c0b968"))); Assert.assertFalse(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c")));
@Test public void shouldGetAPatientIdentifierTypeByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); PatientIdentifierType patientIdentifierType = service.getPatientIdentifierTypeByUuid(getUuid()); assertEquals(patientIdentifierType.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(patientIdentifierType.getName(), PropertyUtils.getProperty(result, "name")); }
Assert.assertTrue(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "1a339fe9-38bc-4ab3-b180-320988c0b968"))); Assert.assertTrue(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c")));
Assert.assertTrue(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "1a339fe9-38bc-4ab3-b180-320988c0b968"))); Assert.assertTrue(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c")));
Assert.assertTrue(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "1a339fe9-38bc-4ab3-b180-320988c0b968"))); Assert.assertTrue(dependencies.contains(Context.getPatientService().getPatientIdentifierTypeByUuid( "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c")));