Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › string match
- This topic has 15 replies, 5 voices, and was last updated 14 years, 2 months ago by David Barr.
-
CreatorTopic
-
July 28, 2010 at 10:57 pm #51901Jason BondParticipant
I have a proc I’m calling within a copy command in a XLT. The proc searches the field specified in the copy command for the word “Procedure:”, and returns a “1” if it finds it. I’m using this in a repeating OBX segment. It works fine the way it is, what I need though is to be able to specify more than one value or string to search for. In other words, I want it to search for, in this example, the word “Procedure:” or the word “Left”, and so on. I’m copying the proc below, it’s a very simple string match proc. 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
}
-
CreatorTopic
-
AuthorReplies
-
-
July 28, 2010 at 11:47 pm #72183David BarrParticipantCode:
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”.
-
August 2, 2010 at 10:23 pm #72184Jason BondParticipant
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.
-
August 3, 2010 at 8:55 am #72185Robert KersemakersParticipant
Hmmm. It should have worked. Make sure you treat xlateInVals as a list! I thinks that’s the problem.
You can also use regexp:
Code:set xlateOutVals [regexp {Procedure|Left} [lindex $xlateInVals 0]]
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands
-
August 3, 2010 at 12:33 pm #72186Jim KosloskeyParticipant
Jason,
Show us the data item you are searching against.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
August 3, 2010 at 5:11 pm #72187Jason BondParticipant
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
-
August 3, 2010 at 5:18 pm #72188Jason BondParticipant
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?
-
August 3, 2010 at 5:23 pm #72189Jim KosloskeyParticipant
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.
-
August 3, 2010 at 5:28 pm #72190Jason BondParticipant
it will end up being case sensitive, I just had those in there for testing, I was changing values a lot for test purposes.
-
August 3, 2010 at 6:09 pm #72191Jim KosloskeyParticipant
Jason,
Show us the Tcl code you have thus far.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
August 3, 2010 at 8:48 pm #72192Jason BondParticipant
######################################################################
# 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
}
-
August 3, 2010 at 9:14 pm #72193Jim KosloskeyParticipant
######################################################################
# 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.
-
August 3, 2010 at 9:15 pm #72194Jason BondParticipant
thanks, I’ll give it a try.
-
August 4, 2010 at 3:21 pm #72195Jared ParishParticipant
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:
Code:
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
-
August 4, 2010 at 4:59 pm #72196Jason BondParticipant
thanks much to all who responded.
-
August 4, 2010 at 7:56 pm #72197David BarrParticipant
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.:
Code: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]
}
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.