Package org.openmrs

Examples of org.openmrs.PersonName


  @Override
    public PersonName getValue(FormEntryContext context, HttpServletRequest request) {
    String family = (String) HtmlFormEntryUtil.getParameterAsType(request, context.getFieldName(this) + "_family", String.class);
    String given = (String) HtmlFormEntryUtil.getParameterAsType(request, context.getFieldName(this) + "_give", String.class);
    if (StringUtils.hasText(family) || StringUtils.hasText(given)) {
      return new PersonName(given, null, family);
    } else {
      return null;
    }
  }
View Full Code Here


    }

    FormEntryContext context = session.getContext();

    if (nameWidget != null) {
      PersonName name = (PersonName) nameWidget.getValue(context, request);

      if (patient != null) {
        if (!name.isPreferred()) {
          PersonName currentPreferredName = context.getExistingPatient().getPersonName();
          if (currentPreferredName != null){
            currentPreferredName.setPreferred(false);
            currentPreferredName.setVoided(true);
          }
        }
      }
     
      // HACK: we need to set the date created and uuid here as a hack around a hibernate flushing issue (see saving the Patient in FormEntrySession applyActions())
View Full Code Here

    }

    validateMandatoryField(context, request, identifierLocationWidget, identifierLocationErrorWidget, ret);

    if(nameWidget != null){
      PersonName personName = nameWidget.getValue(context, request);
      if(!StringUtils.hasText(personName.getGivenName()) || !StringUtils.hasText(personName.getFamilyName())){
        ret.add(new FormSubmissionError(context.getFieldName(nameErrorWidget), Context.getMessageSourceService().getMessage("htmlformentry.error.name.required")));
      }
    }
   
    if (ageWidget != null && validateMandatoryField(context, request, ageWidget, ageErrorWidget, ageOrBirthdDateErrorMessage)) {
View Full Code Here

    } else if (person2 == null || person2.getPersonName() == null) {
      return -1;
    }
   
    // if neither are null, do the actual comparison
    PersonName name1 = person1.getPersonName();
    PersonName name2 = person2.getPersonName();
   
    int ret = OpenmrsUtil.compareWithNullAsGreatest(name1.getFamilyName(), name2.getFamilyName());
   
    if (ret == 0) {
      ret = OpenmrsUtil.compareWithNullAsGreatest(name1.getFamilyName2(), name2.getFamilyName2());
    }
   
    if (ret == 0) {
      ret = OpenmrsUtil.compareWithNullAsGreatest(name1.getGivenName(), name2.getGivenName());
    }
   
    if (ret == 0) {
      ret = OpenmrsUtil.compareWithNullAsGreatest(name1.getMiddleName(), name2.getMiddleName());
    }
   
    if (ret == 0) {
      ret = OpenmrsUtil.compareWithNullAsGreatest(name1.getFamilyNamePrefix(), name2.getFamilyNamePrefix());
    }
   
    if (ret == 0) {
      ret = OpenmrsUtil.compareWithNullAsGreatest(name1.getFamilyNameSuffix(), name2.getFamilyNameSuffix());
    }
 
    return ret;
  }
View Full Code Here

    }
    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();
            }
        }
     }
View Full Code Here

  }

  @Override
    public PersonName getValue(FormEntryContext context, HttpServletRequest request) {
   
    PersonName returnPersonName = new PersonName();
    returnPersonName.setPrefix(getWidgetValue("prefix", context, request));
    returnPersonName.setGivenName(getWidgetValue("givenName", context, request));
    returnPersonName.setMiddleName(getWidgetValue("middleName", context, request));
    returnPersonName.setFamilyName(getWidgetValue("familyName", context, request));
    returnPersonName.setFamilyName2(getWidgetValue("familyName2", context, request));
    returnPersonName.setFamilyNamePrefix(getWidgetValue("familyNamePrefix", context, request));
    returnPersonName.setFamilyNameSuffix(getWidgetValue("familyNameSuffix", context, request));
    returnPersonName.setDegree(getWidgetValue("degree", context, request));
   
    if (context.getExistingPatient() != null) {
      PersonName originalPreferedName = context.getExistingPatient().getPersonName();
     
      if (originalPreferedName != null && isPersonNameEqual(originalPreferedName, returnPersonName)) {
        returnPersonName = originalPreferedName;
      }
    }
View Full Code Here

  }

  @Override
    public void setInitialValue(Object value) {
    if (value != null) {
      PersonName initialValue = (PersonName) value;
      setWidgetValue("prefix", initialValue.getPrefix());
      setWidgetValue("givenName", initialValue.getGivenName());
      setWidgetValue("middleName", initialValue.getMiddleName());
      setWidgetValue("familyNamePrefix", initialValue.getFamilyNamePrefix());
      setWidgetValue("familyNameSuffix", initialValue.getFamilyNameSuffix());
      setWidgetValue("familyName", initialValue.getFamilyName());
      setWidgetValue("familyName2", initialValue.getFamilyName2());
      setWidgetValue("degree", initialValue.getDegree());
    }
  }
View Full Code Here

   *
   * @return the "fake" person
   */
  public static Patient getFakePerson() {
    Patient demo = new Patient(12345);
    demo.addName(new PersonName("Demo", "The", "Person"));
    Location l = Context.getLocationService().getAllLocations().iterator().next();
    for (PatientIdentifierType pit : Context.getPatientService().getAllPatientIdentifierTypes()) {
      if (StringUtils.isEmpty(pit.getValidator())) {
        demo.addIdentifier(new PatientIdentifier("Testing" + pit.getName() + "123", pit, l));
      }
View Full Code Here

  public Object createNewUser(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response)
          throws ResponseException {
    initUserController();
    validatePost(post);
    Person person = new Person();
    PersonName name = new PersonName(post.get("firstName").toString(), null, post.get("lastName").toString());
    name.setPreferred(true);
    person.addName(name);
    person.setGender(post.get("gender").toString());
    Location location = Context.getLocationService().getLocationByUuid(post.get("location").toString());
    if (location == null) {
      throw new ResponseException(
View Full Code Here

        middle = nameObjects.get(i).get("middleName").toString();
      }
      if (nameObjects.get(i).get("familyName") != null) {
        last = nameObjects.get(i).get("familyName").toString();
      }
      PersonName name = new PersonName(first, middle, last);
      if (i == 0) {
        name.setPreferred(Boolean.TRUE);
      }
      p.addName(name);
    }
    return p;
  }
View Full Code Here

TOP

Related Classes of org.openmrs.PersonName

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.