Package ca.uhn.hl7v2.conf.spec.message

Examples of ca.uhn.hl7v2.conf.spec.message.Field


    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Field")) {
          Field field = parseFieldProfile(child);
          segment.setField(childIndex++, field);
        }
      }
    }
View Full Code Here


    struct.setPredicate(getValueOfFirstElement("Predicate", elem));
  }

  /** Parses a field profile */
  private Field parseFieldProfile(Element elem) throws ProfileException {
    Field field = new Field();
    log.debug("  Parsing field profile: " + elem.getAttribute("Name"));

    field.setUsage(elem.getAttribute("Usage"));
    String itemNo = elem.getAttribute("ItemNo");
    String min = elem.getAttribute("Min");
    String max = elem.getAttribute("Max");

    try {
      if (itemNo.length() > 0) {
        field.setItemNo(Short.parseShort(itemNo));
      }
    } catch (NumberFormatException e) {
      throw new ProfileException("Invalid ItemNo: " + itemNo + "( for name "
          + elem.getAttribute("Name") + ")", e);
    } // try-catch

    try {
      field.setMin(Short.parseShort(min));
      if (max.indexOf('*') >= 0) {
        field.setMax((short) -1);
      } else {
        field.setMax(Short.parseShort(max));
      }
    } catch (NumberFormatException e) {
      throw new ProfileException("Min and max must be short integers: " + min + ", " + max, e);
    }

    parseAbstractComponentData(field, elem);

    int childIndex = 1;
    NodeList children = elem.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Component")) {
          Component comp = (Component) parseComponentProfile(child, false);
          field.setComponent(childIndex++, comp);
        }
      }
    }

    return field;
View Full Code Here

    public HL7Exception[] testSegment(ca.uhn.hl7v2.model.Segment segment, Seg profile, String profileID) throws ProfileException {
        ArrayList<HL7Exception> exList = new ArrayList<HL7Exception>(20);
        ArrayList<Integer> allowedFields = new ArrayList<Integer>(20);
       
        for (int i = 1; i <= profile.getFields(); i++) {
            Field field = profile.getField(i);
           
            //only test a field in detail if it isn't X
            if (!field.getUsage().equalsIgnoreCase("X")) {
                allowedFields.add(new Integer(i));
               
                //see which instances have content
                try {
                    Type[] instances = segment.getField(i);
                    ArrayList<Type> instancesWithContent = new ArrayList<Type>(10);
                    for (int j = 0; j < instances.length; j++) {
                        if (hasContent(instances[j])) instancesWithContent.add(instances[j]);
                    }
                   
                    HL7Exception ce = testCardinality(instancesWithContent.size(),
                    field.getMin(), field.getMax(), field.getUsage(), field.getName());
                    if (ce != null) {
                        ce.setFieldPosition(i);
                        exList.add(ce);
                    }
                   
View Full Code Here

  private HL7Exception[] doTestSegment(ca.uhn.hl7v2.model.Segment segment, Seg profile, String profileID, boolean theValidateChildren) throws ProfileException {
    ArrayList<HL7Exception> exList = new ArrayList<HL7Exception>(20);
        ArrayList<Integer> allowedFields = new ArrayList<Integer>(20);
       
        for (int i = 1; i <= profile.getFields(); i++) {
            Field field = profile.getField(i);
           
            //only test a field in detail if it isn't X
            if (!field.getUsage().equalsIgnoreCase("X")) {
                allowedFields.add(new Integer(i));
               
                //see which instances have content
                try {
                    Type[] instances = segment.getField(i);
                    ArrayList<Type> instancesWithContent = new ArrayList<Type>(10);
                    for (int j = 0; j < instances.length; j++) {
                        if (hasContent(instances[j])) instancesWithContent.add(instances[j]);
                    }
                   
                    HL7Exception ce = testCardinality(instancesWithContent.size(),
                    field.getMin(), field.getMax(), field.getUsage(), field.getName());
                    if (ce != null) {
                        ce.setFieldPosition(i);
                        exList.add(ce);
                    }
                   
View Full Code Here

    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Field")) {
          Field field = parseFieldProfile(child);
          segment.setField(childIndex++, field);
        }
      }
    }
View Full Code Here

    struct.setPredicate(getValueOfFirstElement("Predicate", elem));
  }

  /** Parses a field profile */
  private Field parseFieldProfile(Element elem) throws ProfileException {
    Field field = new Field();
    log.debug("  Parsing field profile: " + elem.getAttribute("Name"));

    field.setUsage(elem.getAttribute("Usage"));
    String itemNo = elem.getAttribute("ItemNo");
    String min = elem.getAttribute("Min");
    String max = elem.getAttribute("Max");

    try {
      if (itemNo.length() > 0) {
        field.setItemNo(Short.parseShort(itemNo));
      }
    } catch (NumberFormatException e) {
      throw new ProfileException("Invalid ItemNo: " + itemNo + "( for name " + elem.getAttribute("Name") + ")", e);
    } // try-catch

    try {
      field.setMin(Short.parseShort(min));
      if (max.indexOf('*') >= 0) {
        field.setMax((short) -1);
      } else {
        field.setMax(Short.parseShort(max));
      }
    } catch (NumberFormatException e) {
      throw new ProfileException("Min and max must be short integers: " + min + ", " + max, e);
    }

    parseAbstractComponentData(field, elem);

    int childIndex = 1;
    NodeList children = elem.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Component")) {
          Component comp = (Component) parseComponentProfile(child, false);
          field.setComponent(childIndex++, comp);
        }
      }
    }

    return field;
View Full Code Here

    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Field")) {
          Field field = parseFieldProfile(child);
          segment.setField(childIndex++, field);
        }
      }
    }
View Full Code Here

    struct.setPredicate(getValueOfFirstElement("Predicate", elem));
  }

  /** Parses a field profile */
  private Field parseFieldProfile(Element elem) throws ProfileException {
    Field field = new Field();
    log.debug("  Parsing field profile: " + elem.getAttribute("Name"));

    field.setUsage(elem.getAttribute("Usage"));
    String itemNo = elem.getAttribute("ItemNo");
    String min = elem.getAttribute("Min");
    String max = elem.getAttribute("Max");

    try {
      if (itemNo.length() > 0) {
        field.setItemNo(Short.parseShort(itemNo));
      }
    } catch (NumberFormatException e) {
      throw new ProfileException("Invalid ItemNo: " + itemNo + "( for name "
          + elem.getAttribute("Name") + ")", e);
    } // try-catch

    try {
      field.setMin(Short.parseShort(min));
      if (max.indexOf('*') >= 0) {
        field.setMax((short) -1);
      } else {
        field.setMax(Short.parseShort(max));
      }
    } catch (NumberFormatException e) {
      throw new ProfileException("Min and max must be short integers: " + min + ", " + max, e);
    }

    parseAbstractComponentData(field, elem);

    int childIndex = 1;
    NodeList children = elem.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Component")) {
          Component comp = (Component) parseComponentProfile(child, false);
          field.setComponent(childIndex++, comp);
        }
      }
    }

    return field;
View Full Code Here

      String profileID, boolean theValidateChildren) throws ProfileException {
    List<HL7Exception> exList = new ArrayList<HL7Exception>();
    List<Integer> allowedFields = new ArrayList<Integer>();

    for (int i = 1; i <= profile.getFields(); i++) {
      Field field = profile.getField(i);

      // only test a field in detail if it isn't X
      if (!field.getUsage().equalsIgnoreCase("X")) {
        allowedFields.add(i);

        // see which instances have content
        try {
          Type[] instances = segment.getField(i);
          List<Type> instancesWithContent = new ArrayList<Type>();
          for (Type instance : instances) {
            if (!instance.isEmpty())
              instancesWithContent.add(instance);
          }

          HL7Exception ce = testCardinality(instancesWithContent.size(), field.getMin(),
              field.getMax(), field.getUsage(), field.getName());
          if (ce != null) {
            ce.setFieldPosition(i);
            exList.add(ce);
          }
View Full Code Here

    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element child = (Element) n;
        if (child.getNodeName().equalsIgnoreCase("Field")) {
          Field field = parseFieldProfile(child);
          segment.setField(childIndex++, field);
        }
      }
    }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.conf.spec.message.Field

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.