Package org.openmrs

Examples of org.openmrs.PersonAttribute


                            Pattern withinQuotes = Pattern.compile("[\"\'](.*)[\"\']");
                            Matcher matcher = withinQuotes.matcher(split[1]);
                            matcher.find();
                            String patientAttr = matcher.group(1);

                            PersonAttribute pa = context.getExistingPatient().getAttribute(patientAttr);
                            if (pa != null) {
                                attributeValues.add(pa.getValue());
                            } else {
                                attributeValues.add(null);
                            }
                        }
                        // add the value to the attribute list
View Full Code Here


      demo.setBirthdate(cal.getTime());
    }
   
    for (PersonAttributeType type : Context.getPersonService().getAllPersonAttributeTypes()) {
      if (type.getFormat() != null && type.getFormat().equals("java.lang.String")) {
        demo.addAttribute(new PersonAttribute(type, "Test " + type.getName() + " Attribute"));
      }
    }
    PersonAddress addr = new PersonAddress();
    addr.setCityVillage("Rwinkwavu");
    addr.setCountyDistrict("Kayonza District");
View Full Code Here

   */
  private Person addAttributes(Person p, SimpleObject post) throws ResponseException {
    List<LinkedHashMap> attributeObjects = (List<LinkedHashMap>) post.get("attributes");
    for (int i = 0; i < attributeObjects.size(); i++) {
      if (attributeObjects.get(i).get("attributeType") != null && attributeObjects.get(i).get("value") != null) {
        PersonAttribute pa = new PersonAttribute();
        PersonAttributeType paType = Context.getPersonService().getPersonAttributeTypeByUuid(
            attributeObjects.get(i).get("attributeType").toString());
        if (paType == null) {
          throw new ResponseException(
                                      "Person Attribute Type not found") {};
        }
        pa.setAttributeType(paType);
        String paValue = attributeObjects.get(i).get("value").toString();
        if (paValue == null) {
          throw new ResponseException(
                                      "Person Attribute Value cannot be null") {};
        }
        pa.setValue(paValue);
        p.addAttribute(pa);
      }
    }
    return p;
  }
View Full Code Here

    }
    //Location location = Context.getLocationService().getLocationByUuid(post.get("location").toString());
    Integer userLocation = Integer.parseInt(Context.getPersonService().getPersonByUuid(
        Context.getAuthenticatedUser().getPerson().getUuid()).getAttribute("Health Center").getValue());
    Location location = Context.getLocationService().getLocation(userLocation);
    PersonAttribute locationAttribute = new PersonAttribute();
    locationAttribute.setAttributeType(Context.getPersonService().getPersonAttributeTypeByName("Health Center"));
    locationAttribute.setValue(location.getId().toString());
    person.addAttribute(locationAttribute);
    if (post.get("attributes") != null) {
      addAttributes(person, post);
    }
    if (post.get("addresses") != null) {
View Full Code Here

    Location location = Context.getLocationService().getLocationByUuid(post.get("location").toString());
    if (location == null) {
      throw new ResponseException(
                                  "Location uuid not found") {};
    }
    PersonAttribute locationAttribute = new PersonAttribute();
    locationAttribute.setAttributeType(Context.getPersonService().getPersonAttributeTypeByName("Health Center"));
    locationAttribute.setValue(location.getId().toString());
    person.addAttribute(locationAttribute);
    if (post.get("email") != null) {
      PersonAttribute emailAttribute = new PersonAttribute();
      emailAttribute.setAttributeType(Context.getPersonService().getPersonAttributeTypeByName("Email"));
      emailAttribute.setValue(post.get("email").toString());
      person.addAttribute(emailAttribute);
    }
    if (post.get("phone") != null) {
      PersonAttribute phoneAttribute = new PersonAttribute();
      phoneAttribute.setAttributeType(Context.getPersonService().getPersonAttributeTypeByName("Primary Contact"));
      phoneAttribute.setValue(post.get("phone").toString());
      person.addAttribute(phoneAttribute);
    }
    if (post.get("donateOrgans") != null) {
      PersonAttribute donateOrgansAttribute = new PersonAttribute();
      donateOrgansAttribute.setAttributeType(Context.getPersonService().getPersonAttributeTypeByName("Donate Organs"));
      donateOrgansAttribute.setValue(post.get("donateOrgans").toString());
      person.addAttribute(donateOrgansAttribute);
    }
    String type = post.get("type").toString();
    if (type.equals(TYPE[0])) {
      person = savePatient(person, post, location);
View Full Code Here

TOP

Related Classes of org.openmrs.PersonAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.