Check if a node is a leaf node

Verified
Added by iNTERFACEWARE

Use node.isLeaf() to check if a node is a leaf node (has no children), works for all node types

Source Code
   local Msg, Name = hl7.parse{vmd='example/demo.vmd', data=Data}
   
   -- test if the patient birth time is is a leaf node
   local isleaf = Msg.PID[7][1]:isLeaf()
   --> true
   
   -- test if the patient "Family Name" is a leaf node
   local isleaf = Msg.PID[5][1][1]:isLeaf()
   --> false
Description
Use node.isLeaf() to check if a node is a leaf node (has no children), works for all node types
Usage Details

Use node.isLeaf() to check if a node is a leaf node (has no children).

Note: The node.isLeaf() function works with all types of node trees.

How to use the snippet:

  • Paste the code into your script