› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › string match
thank you all,
Jason
######################################################################
# Name: cpacs_string_reports
# Purpose:
# UPoC type: xltp
# Args: none
# Notes: All data is presented through special variables. The initial
# upvar in this proc provides access to the required variables.
#
# This proc style only works when called from a code fragment
# within an XLT.
#
proc cpacs_string_reports {} {
upvar xlateId xlateId
xlateInList xlateInList
xlateInTypes xlateInTypes
xlateInVals xlateInVals
xlateOutList xlateOutList
xlateOutTypes xlateOutTypes
xlateOutVals xlateOutVals
set xlateOutVals [string match “*Procedure*” $xlateInVals]
echo in $xlateInVals
echo out $xlateOutVals
}
set matched 0
foreach pattern { “*Procedure*” “*Left*” } {
if { [string match $pattern [lindex $xlateInVals 0]] } {
set matched 1
}
}
set xlateOutVals [list $matched]
A better way to do it might be to use regexp and specify a search pattern like “Procedure|Left”.
that still returns a “1” for Procedure and nothing for Left. My problem is getting multiple values in the code, it will search for the first value but never for the second one. I appreciate greatly any help on this.
Hmmm. It should have worked. Make sure you treat xlateInVals as a list! I thinks that’s the problem.
You can also use regexp:
set xlateOutVals [regexp {Procedure|Left} [lindex $xlateInVals 0]]
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands
Jason,
Show us the data item you are searching against.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
this is a part of the message format. I’m looking at OBX-5. When certain words are found the proc returns a “1”, then I have IF logic that alters that field to send BOLD code for the word to our HIS. I want to be able to specify multiple words to search for. Being that it’s an iteration it isn’t searching for more than the first value. I know I have the syntax wrong to put multiple search values in the code.
OBX|1|TX|DefaultObservationID|1|||||||F
OBX|2|TX|DefaultObservationID|1| Good Samaritan Regional Medical Center||||||F
OBX|3|TX|DefaultObservationID|1| 3600 NW Samaritan Dr||||||F
OBX|4|TX|DefaultObservationID|1| Corvallis, OR 97330||||||F
OBX|5|TX|DefaultObservationID|1| 541-768-5111||||||F
OBX|6|TX|DefaultObservationID|1| Transthoracic Echocardiogram Report||||||F
OBX|7|TX|DefaultObservationID|1|Name: TEST, GSR233 DOB: 02/23/1957||||||F
OBX|8|TX|DefaultObservationID|1|Facility MRN: MG00000158 Age: 53 yrs||||||F
OBX|9|TX|DefaultObservationID|1|Study Date: 07/20/2010 Gender: Female||||||F
OBX|10|TX|DefaultObservationID|1|Pt. Location: GED Height: 70 in||||||F
OBX|11|TX|DefaultObservationID|1|Ordering Physician: Dale, P Weight: 185 lb||||||F
OBX|12|TX|DefaultObservationID|1|Referring Physician: Dale, P Daniel BSA: 2.0 meters2||||||F
OBX|13|TX|DefaultObservationID|1|Performed By: Ron DeYoung BP: 115/85 mmHg||||||F
OBX|14|TX|DefaultObservationID|1| HR: 85||||||F
OBX|15|TX|DefaultObservationID|1|||||||F
OBX|16|TX|DefaultObservationID|1|||||||F
OBX|17|TX|DefaultObservationID|1|Interpretation Summary||||||F
OBX|18|TX|DefaultObservationID|1|||||||F
OBX|19|TX|DefaultObservationID|1|||||||F
OBX|20|TX|DefaultObservationID|1|Procedure:||||||F
OBX|21|TX|DefaultObservationID|1|A two-dimensional transthoracic echocardiogram with color flow Doppler||||||F
OBX|22|TX|DefaultObservationID|1|was performed. The patient was in atrial fibrillation with controlled||||||F
OBX|23|TX|DefaultObservationID|1|ventricular rate during the exam.||||||F
OBX|24|TX|DefaultObservationID|1|Procedure:Ventricle:||||||F
OBX|25|TX|DefaultObservationID|1|Procedure: ventricle is normal in size, thickness and function. A mass||||||F
OBX|26|TX|DefaultObservationID|1|is noted in the left ventricle. The left ventricle is normal in||||||F
OBX|27|TX|DefaultObservationID|1|structure and function. There are regional wall motion abnormalities||||||F
I’m also really bad at TCL. I’m sure your code suggestions are much more valid than my testing suggests. Can you give me the code in the proc I gave, where in the proc it goes?
Jason,
Are you intending to be case sensitive?
In the example you sent, I don’t find the word ‘Left’ I find the word ‘left’.
If you do not want to be case sensitive, add the -nocase switch to your string map.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
it will end up being case sensitive, I just had those in there for testing, I was changing values a lot for test purposes.
Jason,
Show us the Tcl code you have thus far.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
######################################################################
# Name: cpacs_string_reports
# Purpose:
# UPoC type: xltp
# Args: none
# Notes: All data is presented through special variables. The initial
# upvar in this proc provides access to the required variables.
#
# This proc style only works when called from a code fragment
# within an XLT.
#
proc cpacs_string_reports {} {
upvar xlateId xlateId
xlateInList xlateInList
xlateInTypes xlateInTypes
xlateInVals xlateInVals
xlateOutList xlateOutList
xlateOutTypes xlateOutTypes
xlateOutVals xlateOutVals
set xlateOutVals [string match “*Procedure:*” $xlateInVals]
echo in $xlateInVals
echo out $xlateOutVals
}
######################################################################
# Name: cpacs_string_reports
# Purpose:
# UPoC type: xltp
# Args: none
# Notes: All data is presented through special variables. The initial
# upvar in this proc provides access to the required variables.
#
# This proc style only works when called from a code fragment
# within an XLT.
#
proc cpacs_string_reports {} {
upvar xlateId xlateId
xlateInList xlateInList
xlateInTypes xlateInTypes
xlateInVals xlateInVals
xlateOutList xlateOutList
xlateOutTypes xlateOutTypes
xlateOutVals xlateOutVals
set match 0
set pattern_list
foreach pattern $pattern_list {
if {[string match $pattern [lindex $xlateOutVals 0]]} {
set match 1
break
}
set xlateOutVals [lreplace $xlateOutVals 0 0 $match]
echo in $xlateInVals
echo out $xlateOutVals
}
I have not tested the ove so I may have fumble fingered something but this is essentially what David Barr was suggesting and I think you should get the idea. If you would like to discuss what is there and why off line, email me.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
thanks, I’ll give it a try.
Jason,
One of my clients has CPACs and MEDITECH. Meditech only accepts textual report which usually means ugly reports. But with the following tcl code, I bold the headers to make it look a little prettier. Here is code I use in a XLT TCL Pre Proc:
set debug 0
for { set x 0 } { $x < [llength $xlateInVals] } { incr x } {
if { $debug } { puts "list item($x):[lindex $xlateInVals $x]" }
set item [lindex $xlateInVals $x]
set item [string map {
"Patient:" "\H\Patient:\N\"
"Age/DOB:" "\H\Age/DOB:\N\"
"Mailing Address:" "\H\Mailing Address:\N\"
"Age:" "\H\Age:\N\"
"Sex:" "\H\Sex:\N\"
"City:" "\H\City:\N\"
"State:" "\H\State:\N\"
"Zip:" "\H\Zip:\N\"
"Home Ph:" "\H\Home Ph:\N\"
"Arrival:" "\H\Arrival:\N\"
"Time Left ED:" "\H\Time Left ED:\N\"
"RN Disposition:" "\H\RN Disposition:\N\"
"CC / Curr Imp:" "\H\CC / Curr Imp:\N\"
"Current Medications" "\H\Current Medications\N\"
"Medication Dose Route Frequency Last Dose RN Comments" "\H\Medication Dose Route Frequency Last Dose RN Comments\N\"
"Allergies" "\H\Allergies\N\"
"Allergic Substance Reaction Severity User Name" "\H\Allergic Substance Reaction Severity User Name\N\"
"Vital Signs" "\H\Vital Signs\N\"
"Sys Dia PulsRespSAT O2 DelTemp (Route Pain SComment Taken at User Name" "\H\Sys Dia PulsRespSAT O2 DelTemp (Route Pain SComment Taken at User Name\N\"
"RN Eval:" "\H\RN Eval:\N\"
"RN Dispo:" "\H\RN Dispo:\N\"
"Res/PA/NP:" "\H\Res/PA/NP:\N\"
"EMS/PMD" "\H\EMS/PMD\N\"
"Dx/Instr" "\H\Dx/Instr\N\"
"RN/Triage" "\H\RN/Triage\N\"
"RN Notes:" "\H\RN Notes:\N\"
"Last Entry:" "\H\Last Entry:\N\"
"HPI:" "\H\HPI:\N\"
"PMH:" "\H\PMH:\N\"
"Surgeries:" "\H\Surgeries:\N\"
"TRIAGE DATA:" "\H\TRIAGE DATA:\N\"
"Last Tetanus:" "\H\Last Tetanus:\N\"
"LMP:" "\H\LMP:\N\"
"PREHOSPITAL CARE:" "\H\PREHOSPITAL CARE:\N\"
"SAFETY SCREENING:" "\H\SAFETY SCREENING:\N\"
"CODE STATUS:" "\H\CODE STATUS:\N\"
"HISTORY OF:" "\H\HISTORY OF:\N\"
"Nurse Note:" "\H\Nurse Note:\N\"
"hpi:" "\H\hpi:\N\"
"GENERAL MEDICINE PHYSICAL EXAM:" "\H\GENERAL MEDICINE PHYSICAL EXAM:\N\"
"MENTAL STATUS:" "\H\MENTAL STATUS:\N\"
"EYES:" "\H\EYES:\N\"
"THROAT:" "\H\THROAT:\N\"
"NECK:" "\H\NECK:\N\"
"CHEST WALL:" "\H\CHEST WALL:\N\"
"HEART:" "\H\HEART:\N\"
"LUNGS:" "\H\LUNGS:\N\"
"ABDOMEN:" "\H\ABDOMEN:\N\"
"GU:" "\H\GU:\N\"
"EXTREMITIES:" "\H\EXTREMITIES:\N\"
"SKIN:" "\H\SKIN:\N\"
"GENERAL APPEARANCE:" "\H\GENERAL APPEARANCE:\N\"
"Transferred from:" "\H\Transferred from:\N\"
"HPI:" "\H\HPI:\N\"
"Associated Symptoms:" "\H\Associated Symptoms:\N\"
"Symptoms worsened by:" "\H\Symptoms worsened by:\N\"
"Symptoms improved with:" "\H\Symptoms improved with:\N\"
"History obtained from:" "\H\History obtained from:\N\"
"ROS:" "\H\ROS:\N\"
"LMP:" "\H\LMP:\N\"
"PMH:" "\H\PMH:\N\"
"Surgeries:" "\H\Surgeries:\N\"
"FH:" "\H\FH:\N\"
"SH:" "\H\SH:\N\"
"PHYSICAL EXAM:" "\H\PHYSICAL EXAM:\N\"
"VITAL SIGNS:" "\H\VITAL SIGNS:\N\"
"GENERAL APPEARANCE:" "\H\GENERAL APPEARANCE:\N\"
"MENTAL STATUS:" "\H\MENTAL STATUS:\N\"
"NEURO:" "\H\NEURO:\N\"
"HEAD:" "\H\HEAD:\N\"
"EYES:" "\H\EYES:\N\"
"NOSE:" "\H\NOSE:\N\"
"MOUTH:" "\H\MOUTH:\N\"
"THROAT:" "\H\THROAT:\N\"
"NECK:" "\H\NECK:\N\"
"CHEST WALL:" "\H\CHEST WALL:\N\"
"LUNGS:" "\H\LUNGS:\N\"
"HEART:" "\H\HEART:\N\"
"ABDOMEN:" "\H\ABDOMEN:\N\"
"GENITOURINARY:" "\H\GENITOURINARY:\N\"
"BACK:" "\H\BACK:\N\"
"RECTAL:" "\H\RECTAL:\N\"
"EXTREMITIES:" "\H\EXTREMITIES:\N\"
"SKIN:" "\H\SKIN:\N\"
"DIFFERENTIAL DX:" "\H\DIFFERENTIAL DX:\N\"
"ABDOMEN(adult) Dx:" "\H\ABDOMEN(adult) Dx:\N\"
"CLINICAL DECSION TOOLS:" "\H\CLINICAL DECSION TOOLS:\N\"
"RESULTS REVIEWED:" "\H\RESULTS REVIEWED:\N\"
"ED COURSE:" "\H\ED COURSE:\N\"
"MLP Supervision:" "\H\MLP Supervision:\N\"
"PROCEDURE:" "\H\PROCEDURE:\N\"
"DISPOSITION:" "\H\DISPOSITION:\N\"
"CRITICAL CARE TIME:" "\H\CRITICAL CARE TIME:\N\"
"MD Sgntr:" "\H\MD Sgntr:\N\"
"RN Sgntr:" "\H\RN Sgntr:\N\"
} $item]
set xlateOutVals [lreplace $xlateOutVals $x $x $item]
}
I welcome any comments. Always looking to improve my code.
- Jared Parish
thanks much to all who responded.
I would try to come up with regular expressions that matched the headers but don’t match other lines. This makes the code shorter and less susceptible to change based on the report contents. E.g.:
set debug 0
for { set x 0 } { $x < [llength $xlateInVals] } { incr x } {
if { $debug } { puts "list item($x):[lindex $xlateInVals $x]" }
set item [lindex $xlateInVals $x]
set patterns {
{^(.*:)$}
{^(w+/[w/]*w)$}
{(Medication +Dose +Route +Frequency +Last Dose +RN Comments)}
}
foreach pat $patterns {
if { [regsub — $pat $item {\H\1\N\} item] } {
break
}
}
set xlateOutVals [lreplace $xlateOutVals $x $x $item]
}