本文整理汇总了Java中org.openmrs.Person类的典型用法代码示例。如果您正苦于以下问题:Java Person类的具体用法?Java Person怎么用?Java Person使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Person类属于org.openmrs包,在下文中一共展示了Person类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRelationship
import org.openmrs.Person; //导入依赖的package包/类
public String[] createRelationship(Integer personAId, Integer personBId, Integer relationshipTypeId, String startDateStr)
throws Exception {
PersonService ps = Context.getPersonService();
Person personA = ps.getPerson(personAId);
Person personB = ps.getPerson(personBId);
RelationshipType relType = Context.getPersonService().getRelationshipType(relationshipTypeId);
Relationship rel = new Relationship();
rel.setPersonA(personA);
rel.setPersonB(personB);
rel.setRelationshipType(relType);
if (StringUtils.isNotBlank(startDateStr)) {
rel.setStartDate(Context.getDateFormat().parse(startDateStr));
}
Map<String, String> map = new HashMap<String, String>();
MapBindingResult errors = new MapBindingResult(map, Relationship.class.getName());
new RelationshipValidator().validate(rel, errors);
String errmsgs[];
if (!errors.hasErrors()) {
ps.saveRelationship(rel);
errmsgs = null;
return errmsgs;
}
errmsgs = errors.getGlobalError().getCodes();
return errmsgs;
}
示例2: PersonListItem
import org.openmrs.Person; //导入依赖的package包/类
/**
* Convenience constructor that creates a PersonListItem from the given Person. All relevant
* attributes are pulled off of the Person object and copied to this PersonListItem. And
* set the best match name based on the search criteria.
*
* @param person the Person to turn into a PersonListItem
* @param searchName Search query string of the name
* @should identify best matching name for the family name
* @should identify best matching name as preferred name even if other names match
* @should identify best matching name as other name for the middle name
* @should identify best matching name as other name for the given name
* @should identify best matching name in multiple search names
*/
public PersonListItem(Person person, String searchName) {
this(person);
if (person != null && !StringUtils.isBlank(searchName)) {
String[] searchNames = searchName.split(" ");
String fullName;
boolean foundABestMatch = false;
for (PersonName personName : person.getNames()) {
fullName = personName.getFullName();
if (!foundABestMatch && containsAll(fullName, searchNames)) {
familyName = personName.getFamilyName();
givenName = personName.getGivenName();
middleName = personName.getMiddleName();
foundABestMatch = true;
continue; // process the next name
}
if (!StringUtils.isBlank(otherNames)) {
otherNames += ",";
}
otherNames += " " + fullName;
}
}
}
示例3: initBinder
import org.openmrs.Person; //导入依赖的package包/类
/**
* Allows for Integers to be used as values in input tags. Normally, only strings and lists are
* expected
*
* @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
* org.springframework.web.bind.ServletRequestDataBinder)
*/
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
super.initBinder(request, binder);
binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(Context.getDateFormat(), true));
binder.registerCustomEditor(java.util.Date.class, "valueDatetime", new CustomDateEditor(Context.getDateTimeFormat(),
true));
binder.registerCustomEditor(java.util.Date.class, "valueTime", new CustomDateEditor(Context.getTimeFormat(), true));
binder.registerCustomEditor(Location.class, new LocationEditor());
binder.registerCustomEditor(java.lang.Boolean.class, new CustomBooleanEditor(true)); //allow for an empty boolean value
binder.registerCustomEditor(Person.class, new PersonEditor());
binder.registerCustomEditor(Order.class, new OrderEditor());
binder.registerCustomEditor(Concept.class, new ConceptEditor());
binder.registerCustomEditor(Location.class, new LocationEditor());
binder.registerCustomEditor(Encounter.class, new EncounterEditor());
binder.registerCustomEditor(Drug.class, new DrugEditor());
}
示例4: setupFormBackingObject
import org.openmrs.Person; //导入依赖的package包/类
/**
* Setup the person object. Should be called by the
* PersonFormController.formBackingObject(request)
*
* @param person
* @return the given person object
*/
protected Person setupFormBackingObject(Person person) {
// set a default name and address for the person. This allows us to use person.names[0] binding in the jsp
if (person.getNames().size() < 1) {
person.addName(new PersonName());
}
if (person.getAddresses().size() < 1) {
person.addAddress(new PersonAddress());
}
// initialize the user/person sets
// hibernate seems to have an issue with empty lists/sets if they aren't initialized
person.getAttributes().size();
return person;
}
示例5: createObservation_shouldCreateObservationWithCodedConcept
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with coded concepts", method = "createObs(Integer, Integer,Integer, String, String)")
public void createObservation_shouldCreateObservationWithCodedConcept() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(21);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
dwrService.createObs(2, null, 21, "7", "1/12/2014");
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListBefore.size() + 1, obsListAfter.size());
Concept answerConcept = conceptService.getConcept(7);
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(answerConcept, addedObs.getValueCoded());
}
示例6: createObservation_shouldCreateObservationWithBooleanConceptWithValueYes
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value yes", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueYes() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "1/12/2014";
dwrService.createObs(2, null, 18, "Yes", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.true");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例7: createObservation_shouldCreateObservationWithBooleanConceptWithValueNo
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value no", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueNo() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "2/12/2014";
dwrService.createObs(2, null, 18, "No", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.false");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例8: createObservation_shouldCreateObservationWithBooleanConceptWithValueTrue
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value true", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueTrue() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "3/12/2014";
dwrService.createObs(2, null, 18, "True", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.true");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例9: createObservation_shouldCreateObservationWithBooleanConceptWithValueFalse
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value false", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueFalse() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "4/12/2014";
dwrService.createObs(2, null, 18, "False", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.false");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例10: createObservation_shouldCreateObservationWithBooleanConceptWithValueZero
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value zero", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueZero() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "5/12/2014";
dwrService.createObs(2, null, 18, "0", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.false");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例11: createObservation_shouldCreateObservationWithBooleanConceptWithValueOne
import org.openmrs.Person; //导入依赖的package包/类
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value one", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueOne() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "6/12/2014";
dwrService.createObs(2, null, 18, "1", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.true");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例12: run
import org.openmrs.Person; //导入依赖的package包/类
public void run() {
setUrl(defaultUrl);
checkEmptyVal((Person) null);
if (fieldGenTag != null) {
Object initialValue = this.fieldGenTag.getVal();
setParameter("initialValue", initialValue == null ? "" : initialValue);
}
}
示例13: ProviderListItem
import org.openmrs.Person; //导入依赖的package包/类
public ProviderListItem(Provider provider) {
Person person = provider.getPerson();
if (person != null) {
displayName = person.getPersonName().getFullName();
} else {
displayName = provider.getName();
}
identifier = provider.getIdentifier();
providerId = provider.getProviderId();
retired = provider.isRetired();
}
示例14: formBackingObject
import org.openmrs.Person; //导入依赖的package包/类
@Override
protected CommandObject formBackingObject(HttpServletRequest request) throws Exception {
if (!Context.isAuthenticated()) {
return new CommandObject();
}
Person person = Context.getPersonService().getPerson(Integer.valueOf(request.getParameter("personId")));
List<Concept> concepts = null;
Concept concept = null;
if (request.getParameter("conceptId") != null) {
concept = Context.getConceptService().getConcept(Integer.valueOf(request.getParameter("conceptId")));
concepts = Collections.singletonList(concept);
}
ObsService os = Context.getObsService();
List<Obs> ret = os.getObservations(Collections.singletonList(person), null, concepts, null, null, null, null, null,
null, null, null, true);
Collections.sort(ret, new Comparator<Obs>() {
public int compare(Obs left, Obs right) {
int temp = left.getConcept().getName().getName().compareTo(right.getConcept().getName().getName());
if (temp == 0) {
temp = OpenmrsUtil.compareWithNullAsGreatest(left.getVoided(), right.getVoided());
}
if (temp == 0) {
temp = OpenmrsUtil.compareWithNullAsLatest(left.getObsDatetime(), right.getObsDatetime());
}
return temp;
}
});
return new CommandObject(person, concept, ret);
}
示例15: formBackingObject
import org.openmrs.Person; //导入依赖的package包/类
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
if (!Context.isAuthenticated()) {
return new Person();
} else {
return Context.getPersonService().getPerson(Integer.valueOf(request.getParameter("personId")));
}
}