# get Discharge Instructions text from CCDA set textDI [parseString "2.16.840.1.113883.10.20.22.2.41" "" "" 1 "$xml"] # get first followup to start the loop set start 0 set followup [get_next_follow_up_visit $debug "$textDI" $start] lassign [split "$followup" "|"] code provider address msi start if {$code > 4} {set dispList [return_error $debug $module $mh "$provider"] ; return $dispList} # looping through referrals - if and while there are more referrals, process each one while {$code 4} {set dispList [return_error $debug $module $mh "$provider"] ; return $dispList} }
<section><title>Hospital Discharge Instructions</title>Detailed Instructions from 2/27/2018 10:26 AM:Follow-Up AppointmentsFollow-Up With : Marshall, Cindy NP (844530) - NP Family MedicineFollow Up Address Telephone 1 : 164 BROAD ST, HAMILTON 13346 (315)8244600</section>
# https://wiki.tcl-lang.org/1948package require tdomset fh [open test.ccd r]; fconfigure $fh -translation binary; set xml [read $fh]; close $fhset doc [dom parse -simple -keepEmpties -baseurl urn:hl7-org:v3 $xml]set root [$doc documentElement]set ns {ns urn:hl7-org:v3}$doc selectNodesNamespaces $ns# set node [$root selectNodes {ns:id}]if {$node eq ""} {echo node is empty; return 0}set id_root [$node getAttribute root]set id_extension [$node getAttribute extension]echo id_root: $id_rootecho id_extension: $id_extension# set node [$root selectNodes {ns:code[1]}] if {$node eq ""} {echo node is empty; return 0} set code_codeSystem [$node getAttribute codeSystem] set code_displayName [$node getAttribute displayName] echo code_codeSystem: $code_codeSystem echo code_displayName: $code_displayName # 17 Daws Rd. set node [$root selectNodes {/ns:ClinicalDocument/ns:recordTarget/ns:patientRole/ns:addr[1]/ns:streetAddressLine/text()}] if {$node eq ""} {echo node is empty; return 0} #puts [$node data] puts [$node nodeValue] # data # For a processing instruction node the data part is returned. For a text node, comment node or cdata section node the value is returned. Otherwise an error is generated. # nodeValue ?newValue? # Returns the value of that node object. This is the the text or the data for element nodes of type # TEXT_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE or CDATA_SECTION_NODE). Otherwise it is empty. # If the node is a TEXT_NODE, COMMENT_NODE or PROCESSING_INSTRUCTION_NODE and the optional argument newValue is given, the node is set to that value. #regsub -all {/} $xpath {/ns:} newxpath #string map {/ /ns:} newxpath
set node [$root selectNodes {ns:code[1]}] if {$node eq ""} {echo node is empty; return 0} set code_codeSystem [$node getAttribute codeSystem] set code_displayName [$node getAttribute displayName] echo code_codeSystem: $code_codeSystem echo code_displayName: $code_displayName # 17 Daws Rd. set node [$root selectNodes {/ns:ClinicalDocument/ns:recordTarget/ns:patientRole/ns:addr[1]/ns:streetAddressLine/text()}] if {$node eq ""} {echo node is empty; return 0} #puts [$node data] puts [$node nodeValue] # data # For a processing instruction node the data part is returned. For a text node, comment node or cdata section node the value is returned. Otherwise an error is generated. # nodeValue ?newValue? # Returns the value of that node object. This is the the text or the data for element nodes of type # TEXT_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE or CDATA_SECTION_NODE). Otherwise it is empty. # If the node is a TEXT_NODE, COMMENT_NODE or PROCESSING_INSTRUCTION_NODE and the optional argument newValue is given, the node is set to that value. #regsub -all {/} $xpath {/ns:} newxpath #string map {/ /ns:} newxpath