/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getPersonId(); }
/** * Required parameters constructor A value is also required, but that can be one of: valueCoded, * valueDrug, valueNumeric, or valueText * * @param person The Person this obs is acting on * @param question The question concept this obs is related to * @param obsDatetime The time this obs took place * @param location The location this obs took place */ public Obs(Person person, Concept question, Date obsDatetime, Location location) { this.person = person; if (person != null) { this.personId = person.getPersonId(); } this.concept = question; this.obsDatetime = obsDatetime; this.location = location; }
/** * @see java.beans.PropertyEditorSupport#getAsText() */ @Override public String getAsText() { Person t = (Person) getValue(); if (t == null) { return ""; } else { return (t.getPersonId() == null) ? "" : t.getPersonId().toString(); } }
/** * @see org.openmrs.api.ObsService#getObservationsByPersonAndConcept(org.openmrs.Person, * org.openmrs.Concept) */ @Override @Transactional(readOnly = true) public List<Obs> getObservationsByPersonAndConcept(Person who, Concept question) throws APIException { List<Person> whom = new ArrayList<>(); if (who != null && who.getPersonId() != null) { whom.add(who); } List<Concept> questions = new ArrayList<>(); questions.add(question); return Context.getObsService().getObservations(whom, null, questions, null, null, null, null, null, null, null, null, false); }
/** * Set the person object to this obs object. This will also set the personId on this obs object * * @see #setPersonId(Integer) * @param person the Patient/Person object that this obs is acting on */ public void setPerson(Person person) { markAsDirty(this.person, person); this.person = person; if (person != null) { setPersonId(person.getPersonId()); } }
/** * generate a relationship hash for use in mergePatients; follows the convention: * [relationshipType][A|B][relativeId] * * @param rel relationship under consideration * @param primary the focus of the hash * @return hash depicting relevant information to avoid duplicates */ private String relationshipHash(Relationship rel, Person primary) { boolean isA = rel.getPersonA().equals(primary); return rel.getRelationshipType().getRelationshipTypeId().toString() + (isA ? "A" : "B") + (isA ? rel.getPersonB().getPersonId().toString() : rel.getPersonA().getPersonId().toString()); }
/** * @param pid A PID segment of an hl7 message * @return The internal id number of the Patient described by the PID segment, or null of the * patient is not found, or if the PID segment is ambiguous * @throws HL7Exception */ @Override @Transactional(readOnly = true) public Integer resolvePatientId(PID pid) throws HL7Exception { Person p = resolvePersonFromIdentifiers(pid.getPatientIdentifierList()); if (p != null && p.getIsPatient()) { return p.getPersonId(); } return null; }
try { Person person = Context.getPersonService().getPerson(Integer.valueOf(idNumber)); return person.getPersonId(); List<Person> persons = Context.getPersonService().getPeople(givenName + " " + familyName, null); if (persons.size() == 1) { return persons.get(0).getPersonId(); } else if (persons.isEmpty()) { log.error("Couldn't find a person named " + givenName + " " + familyName);
/** * 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 PersonService#getPersonByUuid(String) */ @Test public void getPersonByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "ba1b19c2-3ed6-4f63-b8c0-f762dc8d7562"; Person person = Context.getPersonService().getPersonByUuid(uuid); Assert.assertEquals(1, (int) person.getPersonId()); }
if (person.getPersonId() != null) {
/** * Add a Person to the submission stack. A Person must be the first object added to the * submission stack. * * @param Person person to add * @throws InvalidActionException */ public void beginPerson(Person person) throws InvalidActionException { // person has to be at the top of the stack if (stack.size() > 0) throw new InvalidActionException("Person can only go on the top of the stack"); if (person.getPersonId() == null && !personsToCreate.contains(person)) personsToCreate.add(person); stack.push(person); }
/** * https://tickets.openmrs.org/browse/TRUNK-3728 * * @see PatientService#savePatient(Patient) */ @Test public void savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient() throws Exception { Person person = personService.getPerson(1); Patient patient = patientService.getPatientOrPromotePerson(person.getPersonId()); PatientIdentifier patientIdentifier = new PatientIdentifier("some identifier", new PatientIdentifierType(2), new Location(1)); patientIdentifier.setPreferred(true); patient.addIdentifier(patientIdentifier); patientService.savePatient(patient); }
if (!obs.getPerson().getPersonId().equals(p.getPatientId())) { obs.setPerson(p);
@Override public void removeAll() { List<Person> personList = personService.getPeople("", null); for (Person person : personList) { if (person.getPersonId() != 1) { //You can't delete first person in db personService.purgePerson(person); } } }
public static void setProvider(Encounter encounter, Person provider) { EncounterRole unknownRole = Context.getEncounterService().getEncounterRoleByUuid( EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID); if (unknownRole == null) { throw new IllegalStateException("No 'Unknown' encounter role with uuid " + EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID + "."); } Collection<Provider> providers = Context.getProviderService().getProvidersByPerson(provider); if (providers == null || providers.isEmpty()) { throw new IllegalArgumentException("No provider with personId " + provider.getPersonId()); } encounter.setProvider(unknownRole, providers.iterator().next()); } }
personId = person.getPersonId(); setUuid(person.getUuid()); addresses = person.getAddresses();
public PersonStub(Person person){ if (person != null){ this.setId(person.getPersonId()); PersonName name = person.getPersonName(); if (name != null) { this.givenName = name.getGivenName(); this.middleName = name.getMiddleName(); this.familyName = name.getFamilyName(); this.familyName2 = name.getFamilyName2(); } } }
/** * Fails if there is no provider or if the provider id does not match the expected id */ public void assertProvider(Integer expectedProviderId) { assertProvider(); Assert.assertEquals(expectedProviderId, getProvider(getEncounterCreated()).getPersonId()); }
/** * Fails if there is no provider with an assigned id associated with the encounter */ public void assertProvider() { assertEncounterCreated(); Assert.assertNotNull(getProvider(getEncounterCreated())); Assert.assertNotNull(getProvider(getEncounterCreated()).getPersonId()); }