@Override protected PersonAttribute getObjectByUuid(String uuid) { return Context.getPersonService().getPersonAttributeByUuid(uuid); } }
/** * @see org.openmrs.api.PersonService#getRelationshipsByPerson(org.openmrs.Person) */ @Override @Transactional(readOnly = true) public List<Relationship> getRelationshipsByPerson(Person p) throws APIException { // search both the left side and the right side of the relationship // for this person List<Relationship> rels = Context.getPersonService().getRelationships(p, null, null); rels.addAll(Context.getPersonService().getRelationships(null, p, null)); return rels; }
/** * @see org.openmrs.api.PersonService#unvoidPersonAddress(org.openmrs.PersonAddress) */ @Override public PersonAddress unvoidPersonAddress(PersonAddress personAddress) throws APIException { return Context.getPersonService().savePersonAddress(personAddress); }
/** * @see RequireVoidReasonVoidHandler#handle(Voidable,User,Date,String) */ @Test public void handle_shouldNotThrowExceptionIfVoidReasonIsNullForUnsupportedTypes() { Person p = Context.getPersonService().getPerson(1); Context.getPersonService().voidPerson(p, null); } }
/** * Run this before each unit test in this class. * * @throws Exception */ @Before public void runBeforeAllTests() { validator = new PersonAddressValidator(); ps = Context.getPersonService(); }
/** * @see PersonService#getPersonAttribute(Integer) */ @Test public void getPersonAttribute_shouldReturnPersonAttributeWhenGivenIdDoesExist() throws Exception { PersonAttribute personAttribute = Context.getPersonService().getPersonAttribute(17); Assert.assertNotNull(personAttribute); assertTrue("Expecting the return is of a person attribute", personAttribute.getClass().equals( PersonAttribute.class)); }
@Override public void unretirePersonAttributeType(PersonAttributeType type) throws APIException { checkIfPersonAttributeTypesAreLocked(); type.setRetired(false); type.setDateRetired(null); type.setRetiredBy(null); type.setRetireReason(null); Context.getPersonService().savePersonAttributeType(type); }
/** * @see PersonService#getRelationshipType(Integer) */ @Test public void getRelationshipType_shouldReturnRelationshipTypeWithTheGivenRelationshipTypeId() throws Exception { RelationshipType relationshipType = Context.getPersonService().getRelationshipType(1); Assert.assertNotNull(relationshipType); assertTrue("Expecting the return is of a relationship type", relationshipType.getClass().equals( RelationshipType.class)); }
/** * @see PersonService#getAllPersonMergeLogs(boolean) */ @Test public void getAllPersonMergeLogs_shouldRetrieveAllPersonMergeLogsAndDeserializeThem() throws Exception { PersonMergeLog personMergeLog = getTestPersonMergeLog(); Context.getPersonService().savePersonMergeLog(personMergeLog); List<PersonMergeLog> result = Context.getPersonService().getAllPersonMergeLogs(true); Assert.assertEquals("could not retrieve expected number of PersonMergeLog objects", 1, result.size()); Assert.assertNotNull("PersonMergeLog at index 0 is null", result.get(0)); Assert.assertNotNull("PersonMergeLog data has not been deserialized", result.get(0).getPersonMergeLogData()); }
/** * @see PersonService#getPersonAttributeTypeByName(String) */ @Test public void getPersonAttributeTypeByName_shouldReturnPersonAttributeTypeWhenNameMatchesGivenTypeName() throws Exception { PersonAttributeType attributeType = Context.getPersonService().getPersonAttributeTypeByName("Birthplace"); Assert.assertNotNull(attributeType); }
/** * @see PersonService#getRelationships(Person,Person,RelationshipType,Date) */ @Test public void getRelationships2_shouldFetchRelationshipsMatchingTheGivenToPerson() throws Exception { PersonService personService = Context.getPersonService(); Person secondPerson = personService.getPerson(7); List<Relationship> relationships = personService.getRelationships(null, secondPerson, null, new Date()); Assert.assertNotNull(relationships); assertTrue("There should be relationship found given the to person", relationships.size() > 0); }
/** * @see PersonService#getRelationshipType(Integer) */ @Test public void getRelationshipType_shouldReturnNullWhenNoRelationshipTypeMatchesGivenRelationshipTypeId() throws Exception { RelationshipType relationshipType = Context.getPersonService().getRelationshipType(10000); Assert.assertNull(relationshipType); }
/** * @see PersonService#getRelationshipTypeByName(String) */ @Test public void getRelationshipTypeByName_shouldReturnNullWhenNoRelationshipTypeMatchTheGivenName() throws Exception { RelationshipType relationshipType = Context.getPersonService().getRelationshipTypeByName("Supervisor"); Assert.assertNull(relationshipType); }
/** * @see PersonService#getPersonAddressByUuid(String) */ @Test public void getPersonAddressByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() throws Exception { Assert.assertNull(Context.getPersonService().getPersonAddressByUuid("some invalid uuid")); }
@Before public void onSetUpInTransaction() { if (ps == null) { ps = Context.getPatientService(); adminService = Context.getAdministrationService(); personService = Context.getPersonService(); } }
/** * @see PersonService#savePerson(Person) */ @Test public void savePerson_shouldUpdateExistingObjectWhenPersonIdIsNotNull() throws Exception { Person personSaved = Context.getPersonService().getPerson(1); Assert.assertNotNull(personSaved.getId()); personSaved.setGender("M"); Person personUpdated = Context.getPersonService().savePerson(personSaved); Assert.assertEquals("M", personUpdated.getGender()); }
/** * @see PersonService#savePersonMergeLog(PersonMergeLog) */ @Test public void savePersonMergeLog_shouldSerializePersonMergeLogData() throws Exception { PersonMergeLog personMergeLog = getTestPersonMergeLog(); personMergeLog.setSerializedMergedData(null); PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog); Assert.assertNotNull("PatientMergeLogData has not been serialized", persisted.getSerializedMergedData()); }
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldVoidNonPreferredPersonObject() throws Exception { Patient notPreferred = patientService.getPatient(2); voidOrders(Collections.singleton(notPreferred)); Context.getPatientService().mergePatients(patientService.getPatient(6), notPreferred); Assert.assertTrue(Context.getPersonService().getPerson(2).getVoided()); }
/** * @see PersonService#savePersonMergeLog(PersonMergeLog) */ @Test public void savePersonMergeLog_shouldSetCreatorIfNull() throws Exception { PersonMergeLog personMergeLog = getTestPersonMergeLog(); personMergeLog.setCreator(null); PersonMergeLog persisted = Context.getPersonService().savePersonMergeLog(personMergeLog); Assert.assertEquals("creator has not been correctly set", Context.getAuthenticatedUser().getUserId(), persisted .getCreator().getUserId()); }
/** * @see AuditableInterceptor#onSave(Object,Serializable,Object[],String[],Type[]) */ @Test public void onSave_shouldBeCalledWhenSavingOpenmrsObject() { User u = new User(); u.setSystemId("user"); u.setPerson(Context.getPersonService().getPerson(1)); Context.getUserService().createUser(u, "Admin123"); Assert.assertSame(Context.getAuthenticatedUser(), u.getCreator()); Assert.assertNotNull(u.getDateCreated()); }