/** * This constructor creates a new Patient object from the given {@link Person} object. All * attributes are copied over to the new object. NOTE! All child collection objects are copied * as pointers, each individual element is not copied. <br> * <br> * * @param person the person object to copy onto a new Patient * @see Person#Person(Person) */ public Patient(Person person) { super(person); if (person != null) { this.patientId = person.getPersonId(); if (person.getUuid() != null) { this.setUuid(person.getUuid()); } } setPatient(true); }
/** * @see org.openmrs.api.PersonService#savePersonMergeLog(PersonMergeLog) */ @Override public PersonMergeLog savePersonMergeLog(PersonMergeLog personMergeLog) throws SerializationException, APIException { //verify required fields if (Context.getSerializationService().getDefaultSerializer() == null) { throw new APIException("serializer.default.not.found", (Object[]) null); } log.debug("Auditing merging of non-preferred person " + personMergeLog.getLoser().getUuid() + " with preferred person " + personMergeLog.getWinner().getId()); //populate the mergedData XML from the PersonMergeLogData object String serialized = Context.getSerializationService().getDefaultSerializer() .serialize(personMergeLog.getPersonMergeLogData()); personMergeLog.setSerializedMergedData(serialized); log.debug(serialized); //save the bean to the database return dao.savePersonMergeLog(personMergeLog); }
/** * @throws HL7Exception * @see HL7Service#createPersonFromNK1(NK1) */ @Test public void getPersonFromNK1_shouldReturnASavedNewPerson() throws HL7Exception { HL7Service hl7service = Context.getHL7Service(); Message message = hl7service .parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||2178037d-f86b-4f12-8d8b-be3ebc220022^^^UUID^v4||||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212"); ORU_R01 oru = (ORU_R01) message; List<NK1> nk1List = new ORUR01Handler().getNK1List(oru); Person result = hl7service.createPersonFromNK1(nk1List.get(0)); Assert.assertNotNull("should have returned a person", result); Assert.assertNotNull("the person should exist", Context.getPersonService().getPersonByUuid(result.getUuid())); }
setUuid(person.getUuid()); addresses = person.getAddresses(); names = person.getNames();
/** * @see SessionController1_8#get(WebRequest) * @verifies return the session id if the user is authenticated */ @Test public void get_shouldReturnTheSessionIdAndUserIfTheUserIsAuthenticated() throws Exception { Assert.assertTrue(Context.isAuthenticated()); Object ret = controller.get(request); Object userProp = PropertyUtils.getProperty(ret, "user"); Assert.assertEquals(SESSION_ID, PropertyUtils.getProperty(ret, "sessionId")); Assert.assertEquals(true, PropertyUtils.getProperty(ret, "authenticated")); Assert.assertEquals(Context.getAuthenticatedUser().getUuid(), PropertyUtils.getProperty(userProp, "uuid")); Object personProp = PropertyUtils.getProperty(userProp, "person"); Assert.assertEquals(Context.getAuthenticatedUser().getPerson().getUuid(), PropertyUtils.getProperty(personProp, "uuid")); }
@Test public void shouldGetAPersonByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); Person person = service.getPersonByUuid(getUuid()); assertEquals(person.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertNotNull(PropertyUtils.getProperty(result, "preferredName")); assertEquals(person.getGender(), PropertyUtils.getProperty(result, "gender")); assertNull(PropertyUtils.getProperty(result, "auditInfo")); }