Beispiel #1
0
  private boolean hasDemographicInfo(PersonName name) {
    boolean result = false;
    if (name != null) {
      result = !(name.getFirstName().contentEquals("") && name.getLastName().contentEquals(""));
    }

    return result;
  }
  public static PersonName ExtractPersonName(PRPAMT201306UV02ParameterList params) {
    log.debug("Entering HL7Parser201305.ExtractPersonName method...");

    PersonName personname = new PersonName();

    // Extract the name from the query parameters - Assume only one was specified
    if (params.getLivingSubjectName() != null
        && params.getLivingSubjectName().size() > 0
        && params.getLivingSubjectName().get(0) != null) {
      PRPAMT201306UV02LivingSubjectName name = params.getLivingSubjectName().get(0);

      if (name.getValue() != null && name.getValue().size() > 0 && name.getValue().get(0) != null) {
        List<Serializable> choice = name.getValue().get(0).getContent();

        log.info("choice.size()=" + choice.size());

        Iterator<Serializable> iterSerialObjects = choice.iterator();

        String nameString = "";
        EnExplicitFamily lastname = null;
        EnExplicitGiven firstname = null;

        while (iterSerialObjects.hasNext()) {
          log.info("in iterSerialObjects.hasNext() loop");

          Serializable contentItem = iterSerialObjects.next();

          if (contentItem instanceof String) {
            log.info("contentItem is string");
            String strValue = (String) contentItem;

            if (nameString != null) {
              nameString += strValue;
            } else {
              nameString = strValue;
            }
            log.info("nameString=" + nameString);
          } else if (contentItem instanceof JAXBElement) {
            log.info("contentItem is JAXBElement");

            JAXBElement oJAXBElement = (JAXBElement) contentItem;

            if (oJAXBElement.getValue() instanceof EnExplicitFamily) {
              lastname = new EnExplicitFamily();
              lastname = (EnExplicitFamily) oJAXBElement.getValue();
              log.info("found lastname element; content=" + lastname.getContent());
            } else if (oJAXBElement.getValue() instanceof EnExplicitGiven) {
              if (firstname == null) {
                firstname = new EnExplicitGiven();
                firstname = (EnExplicitGiven) oJAXBElement.getValue();
                log.info("found firstname element; content=" + firstname.getContent());
              } else {
                // this would be where to add handle for middlename
              }
            } else {
              log.info("other name part=" + (ENXPExplicit) oJAXBElement.getValue());
            }
          } else {
            log.info("contentItem is other");
          }
        }

        // If text string in patient name, then set in name
        // else set in element.
        boolean namefound = false;
        if (lastname != null && lastname.getContent() != null) {
          personname.setLastName(lastname.getContent());
          log.info("FamilyName : " + personname.getLastName());
          namefound = true;
        }

        if (firstname != null && firstname.getContent() != null) {
          personname.setFirstName(firstname.getContent());
          log.info("GivenName : " + personname.getFirstName());
          namefound = true;
        }

        if (!namefound && !nameString.trim().contentEquals("")) {
          log.info("setting name by nameString " + nameString);
          personname.setLastName(nameString);
        }
      } else {
        log.info("message does not contain a subject name");
      }
    } else {
      log.info("message does not contain a subject name");
    }

    log.debug("Exiting HL7Parser201305.ExtractPersonName method...");
    return personname;
  }