UpdateHL7Elements()

Top  Previous  Next

Object: EHL7.HL7Vendors

FileName: EHL7.dll

 

METHOD

 

Name: UpdateHL7Elements()

Parameters: 1) strXML (String) An XML string containing update information for the elements you wish to modify for the selected segment in the selected vendor's HL7 definition.

Returns: Boolean

Description: Returns True if the updates were successfully applied to the vendor definition and false on failure.  On failure check the LastError property for the error description.  To delete a segment prepare the XML string and set the DELETE attribute to "True".  This method works both as an ADD method and as an UPDATE method because if an ELEMENT item is not found it is added.

 

*NOTE* Development license required to call this method successfully

 

Example XML:

<ELEMENTS COUNT="2">

<ELEMENT ITEMGUID="8337C2CC-88F5-4208-A9E6-CB6527D946AB" FIELDNUMBER="6" SEGMENT="EVN"

DESCRIPTION="Event Occurred" FIELDLEN="26" HL7DATATYPE="TS" TABLEID="0" HL7ITEMNUM="1278" REQUIRED="0" />

<ELEMENT ITEMGUID="7817163C89F49D42AF975AACD06EDF47" FIELDNUMBER="7" SEGMENT="EVN"

DESCRIPTION="New Segment" FIELDLEN="20" HL7DATATYPE="CE" TABLEID="0" HL7ITEMNUM="0" REQUIRED="0" />

</ELEMENTS>

 

*Note: XML node and attribute names are case sensitive and should be uppercase:

The SEGMENT attribute is the name of the segment whose elements you are updating.
The DESCRIPTION attribute is the description of the element
The FIELDNUMBER attribute is the sequential field number within the segment that this element falls. Must be > 0
The FIELDLEN attribute is the maximum size of the field.  Should be a whole number > 0
The HL7DATATYPE attribute is the HL7 datatype of the field.  Refer to the HL7 Rules for data types
The TABLEID attribute is the HL7 Table ID associated with this element (if applicable).  Set to "0" or ignore.
The HL7ITEMNUM is an optional numeric indicator that is used as a reference to vendor specific HL7 documentation.
The REQUIRED attribute is a boolean (0 or 1) that indicates whether this element is defined as required for the segment.
The ITEMGUID attribute is the GUID assigned to be assigned to the Segment Element by EasyHL7. 

 

*Programming Note: When the updates are performed, code items are identified by the ITEMGUID not the code and value.  Duplicates can be created. If the elements indicated by ITEMGUID are not found they are added.  FIELDNUMBERs must be sequential numbered 1 to <XX>(total # of elements).  If you wish to insert an element into position 5, you must first issue updates on elements 5 through <XX> and renumber them to 6 through <XX> + 1.

 

See Also: AddHL7Segment(), SegmentsXML, HL7ElementsXML(), QSXML Object

 

Example Code to do this:

Private Sub VendorTest()

Dim myVendorObj As New EHL7.HL7Vendors

Dim strVendorID As String

Dim strXML As String

Dim domNode As Object

Dim myXMLObj As New EHL7.qsXML

myVendorObj.VendorPath = "C:\EasyHL7"

'Process the XML        

strVendorID = myVendorObj.GetVendorID("Default","2.3")

If strVendorID = "" Then

    MsgBox myVendorObj.LastError

    Set myVendorObj = Nothing

    Exit Sub

End If

If Not MyVendorObj.OpenVendor(strVendorID) Then

    MsgBox myVendorObj.LastError

    Set myVendorObj = Nothing

    Exit Sub

End If

With myXMLObj

    strXML = "<SEGMENT></SEGMENT>"

    .OpenFromString strXML

    Set domNode = .GetRootElement()

    .SetAttribute domNode, "NAME", "DHL"

    .SetAttribute domNode, "DESCRIPTION", "My Test Segment"

    .SetAttribute domNode, "ITEMGUID", CreateGUID()

    'The order of the attributes is not important        

    strXML = .XML

End With

If Not myVendorObj.AddHL7Segment(strXML) Then

    MsgBox myVendorObj.LastError

    Exit Sub

End If

'Now we have added the Segment let's add 2 field elements

With myXMLObj

   strXML = "<ELEMENTS></ELEMENTS>"

    .OpenFromString strXML

    Set domNode = .GetRootElement()

    .SetAttribute domNode, "COUNT", "2"

    strXML = "<ELEMENT></ELEMENT>"

    Set chldNode = .XMLAddNode(domNode,strXML)

     'The order in which we add the attributes to each chldNode is not important

    .SetAttribute chldNode,"SEGMENT","DHL"

    .SetAttribute chldNode,"DESCRIPTION","Field #1"

    .SetAttribute chldNode,"FIELDLEN","50"

    .SetAttribute chldNode,"HL7DATATYPE","ST"

    .SetAttribute chldNode,"FIELDNUMBER","1"

    .SetAttribute chldNode,"ITEMGUID",CreateGuid()

    'Setting this is optional

    .SetAttribute chldNode,"HL7ITEMNUM","0"

    .SetAttribute chldNode,"TABLEID","0"

    'Create the second element            

    Set chldNode = .XMLAddNode(domNode,strXML)

     'The order in which we add the attributes to each chldNode is not important

    .SetAttribute chldNode,"SEGMENT","DHL"

    .SetAttribute chldNode,"DESCRIPTION","Field #2 Patient Gender"

    .SetAttribute chldNode,"FIELDLEN","25"

    .SetAttribute chldNode,"HL7DATATYPE","CE"

    .SetAttribute chldNode,"FIELDNUMBER","2"

    .SetAttribute chldNode,"ITEMGUID",CreateGuid()

    'Setting these 2 are optional

    .SetAttribute chldNode,"HL7ITEMNUM","0"

    .SetAttribute chldNode,"TABLEID","1"

    strXML = .XML           

End With

If Not myVendorObj.UpdateHL7Elements(strXML) Then

       MsgBox myVendorObj.LastError

End If

End Sub