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); }
private string convertToHL7(XmlDocument xMsg) { String sHL7Message = ""; XmlElement rootElement = (XmlElement)xMsg.FirstChild; XmlElement messageHeaderElement = (XmlElement)rootElement.GetElementsByTagName(MESSAGE_HEADER)[0]; XmlElement fieldSepartorElement = (XmlElement)messageHeaderElement.GetElementsByTagName(FIELD_SERARATOR_FIELD_POS)[0]; XmlElement encodingCharactersElement = (XmlElement)messageHeaderElement.GetElementsByTagName(ENCODING_CHARACTER_FIELD_POS)[0]; string sDel = fieldSepartorElement.InnerText + encodingCharactersElement.InnerText; delimeters = new HL7Delimeters(sDel); XmlNodeList segmentList = rootElement.ChildNodes; int iSegmentTotal = segmentList.Count; for (int i = 0; i < iSegmentTotal; i++) { XmlElement segmentElement = (XmlElement)segmentList[i]; HL7Segment segment = new HL7Segment(segmentElement, delimeters); if (segment.getLength() > 0) { sHL7Message = sHL7Message + segment.toString() + SEGMENT_DELIMETER; } } return(sHL7Message); }