Example #1
0
        public string get(string sSegmentName, int iSegmentOccurence, int iFieldPos, int iFieldOccurence, int iComponentPos, int iSubComponentPos)

        {
            String     sString = "";
            HL7Segment segment = getHL7Segment(sSegmentName, iSegmentOccurence);

            sString = segment.toString();
            if (iFieldPos > 0)
            {
                HL7Field field = segment.getField(iFieldPos);
                sString = field.toString();
                if (iFieldOccurence > 0)
                {
                    HL7FieldItem fieldItem = field.getFieldItem(iFieldOccurence);
                    sString = fieldItem.toString();
                    if (iComponentPos > 0)
                    {
                        HL7Component component = fieldItem.getComponent(iComponentPos);
                        sString = component.toString();
                        if (iSubComponentPos > 0)
                        {
                            HL7SubComponent subComponent = component.getSubComponent(iSubComponentPos);
                            sString = subComponent.toString();
                        }
                    }
                }
            }
            return(sString);
        }
Example #2
0
        public HL7SubComponent getSubComponent(int iSubComponentPos)
        {
            string sString = "";

            try
            {
                sString = deComponent.getString(delimeters.getSD(), iSubComponentPos);
            }
            catch (UnableToGetStringException e)
            {
                throw new SubComponentNotFoundException(e.Message);
            }
            HL7SubComponent subComp = new HL7SubComponent(sString, delimeters);

            return(subComp);
        }
Example #3
0
        public HL7Component(XmlElement componentElement, HL7Delimeters delim)
        {
            delimeters = delim;
            string      sComponent        = "";
            int         iLastPopulatedPos = 0;
            XmlNodeList subComponentList  = componentElement.ChildNodes;

            if (subComponentList.Count == 0)
            {
                HL7SubComponent subComponent = new HL7SubComponent(componentElement, delimeters);
                sComponent = sComponent + subComponent.toString();
            }
            else
            {
                if (subComponentList.Count == 1 && componentElement.ChildNodes[0].NodeType == XmlNodeType.Text)
                {
                    HL7SubComponent subComponent = new HL7SubComponent(componentElement, delimeters);
                    sComponent = sComponent + subComponent.toString();
                    if (subComponent.toString().Length > 0)
                    {
                        iLastPopulatedPos = sComponent.Length;
                    }
                }
                else
                {
                    for (int i = 0; i < subComponentList.Count; i++)
                    {
                        XmlElement      subComponentElement = (XmlElement)subComponentList[i];
                        HL7SubComponent subComponent        = new HL7SubComponent(subComponentElement, delimeters);
                        sComponent = sComponent + subComponent.toString() + char.ToString(delimeters.getSD());
                        if (subComponent.toString().Length > 0)
                        {
                            iLastPopulatedPos = sComponent.Length - 1;
                        }
                    }
                }

                sComponent = sComponent.Substring(0, iLastPopulatedPos);
            }
            deComponent = new HL7DataElement(sComponent);
        }
Example #4
0
        public void buildXML(XmlDocument doc, XmlElement componentElement)
        {
            HL7SubComponent subComponent         = new HL7SubComponent("", delimeters);
            int             iNumberSubComponents = getLength();

            if (iNumberSubComponents == 1)
            {
                subComponent = getSubComponent(1);
                subComponent.buildXML(componentElement);
            }
            else
            {
                for (int i = 1; i <= iNumberSubComponents; i++)
                {
                    subComponent = getSubComponent(i);

                    XmlElement subComponentElement = doc.CreateElement("SUBCOMPONENT." + i.ToString());
                    componentElement.AppendChild(subComponentElement);
                    subComponent.buildXML(subComponentElement);
                }
            }
        }