private void initializeHL7(string sHL7Message) { deMessage = new HL7DataElement(sHL7Message.Trim()); try { HL7Segment messageHeader = getMessageHeader(); HL7Field field = messageHeader.getField(MESSAGE_TYPE_POS); HL7FieldItem fieldItem = field.getFieldItem(1); HL7Component messageType = fieldItem.getComponent(1); string sMessageID = ""; try { HL7Component messageID = fieldItem.getComponent(2); sMessageID = messageID.toString(); } catch (ComponentNotFoundException componentnotfoundexception) { } if (sMessageID.Length > 0) { sMessageType = messageType.toString() + "_" + sMessageID; } else { sMessageType = messageType.toString(); } try { field = messageHeader.getField(MESSAGE_ENCODING_POS); sHL7Encoding = field.toString(); sXMLEncoding = "UTF-8";//characterSet.getXML(sHL7Encoding); } catch (FieldNotFoundException e) { //debug("Character set not found in HL7. Using system defaults."); sHL7Encoding = ""; sXMLEncoding = "UTF-8"; } } catch (ComponentNotFoundException e) { throw new InvalidMessageTypeException(e.Message); } catch (FieldNotFoundException e) { throw new MessageTypeNotFoundException(e.Message); } catch (SegmentNotFoundException e) { throw new MessageHeaderNotFoundException(e.Message); } }
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); }