[1004] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | #there are many reads and comments in this document for debugging
|
---|
| 4 | #This scipt requires a provider organization file for each provider to be in the directory, and AllM1EncounterCodes.txt,
|
---|
| 5 | #First fix all of the Measures sections in all of the files
|
---|
| 6 | #The following files must be in the same directory as the QRDA files being processed:
|
---|
| 7 | #MeasuresAndReportingParametersWithVariables.xml
|
---|
| 8 | #MEASURES-BY-PATIENT.txt
|
---|
| 9 | #This script which is FixMeasuresSection.sh
|
---|
| 10 |
|
---|
| 11 | #PAT_*_QRDA_V1_0_0-11-08-2010_19.xml is assumged to be the file
|
---|
| 12 | #TEMPORARY
|
---|
| 13 | #bash FixMeasuresSection.sh
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | #Find out which files to edit and assign them to the variable "MyFile". As you can see, here I loop through particular files in the same directory with this script
|
---|
| 17 |
|
---|
| 18 | for MyFile in $(ls PAT_*_QRDA_V1_0_0-11-10-2010_16.xml)
|
---|
| 19 | do
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | #Process the problem section by calling the function FunctionProcessProblemSection
|
---|
| 23 | #You will need the following files
|
---|
| 24 | # LineNumberDownFunction
|
---|
| 25 | # AllI9ProblemCodes.txt
|
---|
| 26 | # LineNumberUpDownFunction
|
---|
| 27 | # This file FunctionProcessProblemSection
|
---|
| 28 | #echo "MyFile is $MyFile"
|
---|
| 29 | #source FunctionProcessProblemSection
|
---|
| 30 | #FunctionProcessProblemSection $MyFile
|
---|
| 31 | #cp $MyFile $MyFile"BU"
|
---|
| 32 | #Replace where is just says SSN for the patient with the SSN ID HL7 number
|
---|
| 33 | #since this is a medicare patient, no privacy violation as that will also appear in the Payer's section
|
---|
| 34 |
|
---|
| 35 | echo "xml files are in the directory"
|
---|
| 36 | pwd
|
---|
| 37 | #read
|
---|
| 38 |
|
---|
| 39 | #replace the @@@UUID-DOC@@@,@@@UUID-SET@@@ and @@@UUID-PAYER@@@ with UUIDs
|
---|
| 40 | #should probably do that in the problem section as well with WV HL7 ID as root and UUID as an extension for now
|
---|
| 41 |
|
---|
| 42 | VerNum=$(grep versionNumber "$MyFile"|awk -F\" '{print $2}')
|
---|
| 43 | echo "$VerNum"
|
---|
| 44 |
|
---|
| 45 | if [ "1" = "$VerNum" ]
|
---|
| 46 | then
|
---|
| 47 | #uuid is a Linux command that generates a new uuid
|
---|
| 48 | u=$(uuid)
|
---|
| 49 | sed -i s/'@@@UUID-DOC@@@'/$u/ $MyFile
|
---|
| 50 |
|
---|
| 51 | sed -i s/'@@@UUID-SET@@@'/$u/ $MyFile
|
---|
| 52 | sed -i s/'@@@UUID-PAYER@@@'/$u/ $MyFile
|
---|
| 53 |
|
---|
| 54 | else
|
---|
| 55 | echo "UUIDs should remain unchanged because this is not the first version of this document"
|
---|
| 56 |
|
---|
| 57 | fi
|
---|
| 58 | echo "replace UUID site markers"
|
---|
| 59 | u=""
|
---|
| 60 | VerNum=""
|
---|
| 61 | #read
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | #make sure <state></state> is no longer than two
|
---|
| 65 |
|
---|
| 66 | echo "Fix the state line length"
|
---|
| 67 |
|
---|
| 68 | sed -i 's/Alabama/AL/gI' $MyFile
|
---|
| 69 | sed -i 's/Alaska/AK/gI' $MyFile
|
---|
| 70 | sed -i 's/Arizona/AZ/gI' $MyFile
|
---|
| 71 | sed -i 's/Arkansas/AR/gI' $MyFile
|
---|
| 72 | sed -i 's/California/CA/gI' $MyFile
|
---|
| 73 | sed -i 's/Colorado/CO/gI' $MyFile
|
---|
| 74 | sed -i 's/Connecticut/CT/gI' $MyFile
|
---|
| 75 | sed -i 's/Delaware/DE/gI' $MyFile
|
---|
| 76 | sed -i 's/District of Columbia/DC/gI' $MyFile
|
---|
| 77 | sed -i 's/Florida/FL/gI' $MyFile
|
---|
| 78 | sed -i 's/Georgia/GA/gI' $MyFile
|
---|
| 79 | sed -i 's/Hawaii/HI/gI' $MyFile
|
---|
| 80 | sed -i 's/Idaho/ID/gI' $MyFile
|
---|
| 81 | sed -i 's/Illinois/IL/gI' $MyFile
|
---|
| 82 | sed -i 's/Indiana/IN/gI' $MyFile
|
---|
| 83 | sed -i 's/Iowa/IA/gI' $MyFile
|
---|
| 84 | sed -i 's/Kansas/KS/gI' $MyFile
|
---|
| 85 | sed -i 's/Kentucky/KY/gI' $MyFile
|
---|
| 86 | sed -i 's/Louisiana/LA/gI' $MyFile
|
---|
| 87 | sed -i 's/Maine/ME/gI' $MyFile
|
---|
| 88 | sed -i 's/Maryland/MD/gI' $MyFile
|
---|
| 89 | sed -i 's/Massachusetts/MA/gI' $MyFile
|
---|
| 90 | sed -i 's/Michigan/MI/gI' $MyFile
|
---|
| 91 | sed -i 's/Minnesota/MN/gI' $MyFile
|
---|
| 92 | sed -i 's/Mississippi/MS/gI' $MyFile
|
---|
| 93 | sed -i 's/Missouri/MO/gI' $MyFile
|
---|
| 94 | sed -i 's/Montana/MT/gI' $MyFile
|
---|
| 95 | sed -i 's/Nebraska/NE/gI' $MyFile
|
---|
| 96 | sed -i 's/Nevada/NV/gI' $MyFile
|
---|
| 97 | sed -i 's/New Hampshire/NH/gI' $MyFile
|
---|
| 98 | sed -i 's/New Jersey/NJ/gI' $MyFile
|
---|
| 99 | sed -i 's/New Mexico/NM/gI' $MyFile
|
---|
| 100 | sed -i 's/New York/NY/gI' $MyFile
|
---|
| 101 | sed -i 's/North Carolina/NC/gI' $MyFile
|
---|
| 102 | sed -i 's/North Dakota/ND/gI' $MyFile
|
---|
| 103 | sed -i 's/Ohio/OH/gI' $MyFile
|
---|
| 104 | sed -i 's/Oklahoma/OK/gI' $MyFile
|
---|
| 105 | sed -i 's/Oregon/OR/gI' $MyFile
|
---|
| 106 | sed -i 's/Pennsylvania/PA/gI' $MyFile
|
---|
| 107 | sed -i 's/Rhode Island/RI/gI' $MyFile
|
---|
| 108 | sed -i 's/South Carolina/SC/gI' $MyFile
|
---|
| 109 | sed -i 's/South Dakota/SD/gI' $MyFile
|
---|
| 110 | sed -i 's/Tennessee/TN/gI' $MyFile
|
---|
| 111 | sed -i 's/Texas/TX/gI' $MyFile
|
---|
| 112 | sed -i 's/Utah/UT/gI' $MyFile
|
---|
| 113 | sed -i 's/Vermont/VT/gI' $MyFile
|
---|
| 114 | sed -i 's/Virginia/VA/gI' $MyFile
|
---|
| 115 | sed -i 's/Washington/WA/gI' $MyFile
|
---|
| 116 | sed -i 's/West Virginia/WV/'gI $MyFile
|
---|
| 117 | sed -i 's/Wisconsin/WI/gI' $MyFile
|
---|
| 118 | sed -i 's/Wyoming/WY/gI' $MyFile
|
---|
| 119 | sed -i 's/American Samoa/AS/gI' $MyFile
|
---|
| 120 | sed -i 's/Guam/GU/gI' $MyFile
|
---|
| 121 | sed -i 's/Northern Mariana Islands/MP/gI' $MyFile
|
---|
| 122 | sed -i 's/Puerto Rico/PR/gI' $MyFile
|
---|
| 123 | sed -i 's/Virgin Islands/VI/gI' $MyFile
|
---|
| 124 | sed -i 's/West VA/WV/gI' $MyFile
|
---|
| 125 | sed -i 's/N Carolina/NC/gI' $MyFile
|
---|
| 126 | sed -i 's/N Dakota/ND/gI' $MyFile
|
---|
| 127 | sed -i 's/S Carolina/SC/gI' $MyFile
|
---|
| 128 | sed -i 's/S Dakota/SD/gI' $MyFile
|
---|
| 129 | sed -i 's/Puerto Rico/PR/gI' $MyFile
|
---|
| 130 | sed -i 's/Virgin Islands/VI/gI' $MyFile
|
---|
| 131 | sed -i 's/"W. VA"/WV/gI' $MyFile
|
---|
| 132 | sed -i 's/"N. Carolina"/NC/gI' $MyFile
|
---|
| 133 | sed -i 's/"N. Dakota"/ND/gI' $MyFile
|
---|
| 134 | sed -i 's/"S. Carolina"/SC/gI' $MyFile
|
---|
| 135 | sed -i 's/"S. Dakota"/SD/gI' $MyFile
|
---|
| 136 | sed -i 's/"R.I."/RI/gI' $MyFile
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | #Fix the state entries
|
---|
| 140 |
|
---|
| 141 | (grep -n '<state>' $MyFile |awk -F\: '{print $1}') >> statetags.txt
|
---|
| 142 |
|
---|
| 143 | for i in $(cat statetags.txt);
|
---|
| 144 | do
|
---|
| 145 | StateLineLength=$(sed -n "$i"p "$MyFile" | sed 's/^[ \t]*//' |awk '{print length}')
|
---|
| 146 |
|
---|
| 147 | echo "StateLineLength is $StateLineLength"
|
---|
| 148 | if [ ! "17" = "$StateLineLength" ]
|
---|
| 149 | then
|
---|
| 150 |
|
---|
| 151 | cat -n $MyFile | grep '<state>';echo "$MyFile"
|
---|
| 152 | echo "Urgent there is a problem with the <state> tag in $MyFile"
|
---|
| 153 | #read
|
---|
| 154 |
|
---|
| 155 | fi
|
---|
| 156 | done
|
---|
| 157 |
|
---|
| 158 | StateLineLength=""
|
---|
| 159 | rm -rf statetags.txt #UNCOMMENT THIS!!!
|
---|
| 160 |
|
---|
| 161 | echo "$MyFile"
|
---|
| 162 | a1=$(grep -n \"SSN\" $MyFile | awk -F\" '{print $2}'); echo "$a1"
|
---|
| 163 | echo "$a1 is the line with SSN on it"
|
---|
| 164 | sed -i s/@@SSN@@/"$a1"/ $MyFile
|
---|
| 165 | sed -i 's/SSN/2.16.840.1.113883.4.1/' $MyFile
|
---|
| 166 | a1=""
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | echo "SSN code added"
|
---|
| 170 | echo "About to start fixing the problem section"
|
---|
| 171 | #read
|
---|
| 172 | #PROBLEM SECTION FUNCTION REMOVED
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | #PROBLEM SECTION 1 FIX - TEMPLATE
|
---|
| 178 | #Add the added template line after 2.16.840.1.113883.10.20.1.50
|
---|
| 179 | sed -in /"2.16.840.1.113883.10.20.1.50"/s/$/"\\n<templateId root=\"2.16.840.1.113883.3.249.11.100.12\"\\/>"/ "$MyFile"
|
---|
| 180 | cat -n "$MyFile" | grep "3.249.11.100.12"
|
---|
| 181 |
|
---|
| 182 | #read
|
---|
| 183 | #PROBLEM FIX 2 - TABLE
|
---|
| 184 | #Remove the table in the beginning of the section
|
---|
| 185 | if grep -q "11450-4" "$MyFile" >>/dev/null
|
---|
| 186 | then
|
---|
| 187 | ProblemSectionKey=$(grep -n "11450-4" "$MyFile" | awk -F: '{print $1}')
|
---|
| 188 | grep -n "2.16.840.1.113883.10.20.1.27" "$MyFile" | awk -F: '{print $1}' >> Problem27TemplateLines.txt
|
---|
| 189 | #read
|
---|
| 190 | startline="$ProblemSectionKey"
|
---|
| 191 | endline="$(head -1 Problem27TemplateLines.txt)"
|
---|
| 192 | echo "$startline is startline"
|
---|
| 193 | echo "$endline is endline"
|
---|
| 194 | cat -n "$MyFile" | grep '<table>'
|
---|
| 195 | #Remove the table at the beginning of the problem section but leaves <text/>
|
---|
| 196 | sed -in "$startline,$endline{ s/<text>/<text\/>\n<text>/ }" "$MyFile"
|
---|
| 197 | sed -in "$startline,$endline{ /<text>/,/<\/text>/d }" "$MyFile"
|
---|
| 198 |
|
---|
| 199 | # this in an example of one that works
|
---|
| 200 | #sed -in "$startline,$endline{ /<table>/,/<\/table>/d }" M1-PAT_100839_QRDA_V1_0_0.xml
|
---|
| 201 | cat -n "$MyFile" | grep '<table>'
|
---|
| 202 | echo "Done removing the table"
|
---|
| 203 | startline=""
|
---|
| 204 | endline=""
|
---|
| 205 | rm -rf Problem27TemplateLines.txt
|
---|
| 206 | rm -rf MyValueLinesInProblems.txt
|
---|
| 207 | fi
|
---|
| 208 | #PROBLEM SECTION FIX 3 - TEXT TAGS
|
---|
| 209 | #Remove <text> </text> section near effectiveTime
|
---|
| 210 | #read
|
---|
| 211 |
|
---|
| 212 | index="0"
|
---|
| 213 | grep -n "2.16.840.1.113883.3.249.11.100.8" $MyFile | awk -F: '{print $1}' >> MyTextLinesKeysProblems.txt
|
---|
| 214 | for i in $(cat MyTextLinesKeysProblems.txt);
|
---|
| 215 | do
|
---|
| 216 | startline="$(($i+$index))"
|
---|
| 217 | endline="$(($i+$index+10))"
|
---|
| 218 | sed -in "$startline,$endline{ /<text>/,/<\/text>/d }" "$MyFile"
|
---|
| 219 | index="$((index-3))"
|
---|
| 220 | done
|
---|
| 221 | index=""
|
---|
| 222 | starline=""
|
---|
| 223 | endline=""
|
---|
| 224 | rm -rf MyTextLinesKeysProblems.txt
|
---|
| 225 | echo "done removing <text>"
|
---|
| 226 | #read
|
---|
| 227 |
|
---|
| 228 | #PROBLEM SECTION 4 FIX - REMOVE BAD VALUE LINE
|
---|
| 229 | #remove the value tags after the 2.16.840.1.113883.10.20.1.50 enty
|
---|
| 230 | index="0"
|
---|
| 231 | echo "value Lines in Problems about to be written to the file"
|
---|
| 232 | #grep -n "2.16.840.1.113883.10.20.1.50" $MyFile | awk -F: '{print $1}'
|
---|
| 233 | grep -n "2.16.840.1.113883.10.20.1.50" $MyFile | awk -F: '{print $1}' >> MyValueLinesInProblems.txt
|
---|
| 234 | for i in $(cat MyValueLinesInProblems.txt);
|
---|
| 235 | do
|
---|
| 236 | startline="$((i+index))"
|
---|
| 237 | endline="$(($i+index+8))"
|
---|
| 238 | #sed -in "$startline,$endline{ /<value>/,/<\/value>/d }" "$MyFile"
|
---|
| 239 | sed -in "$startline,$endline{ /<value>/,/<\/value>/d }" "$MyFile"
|
---|
| 240 | echo "a value line was deleted from the $startline area"
|
---|
| 241 | index="$((index-3))"
|
---|
| 242 | done
|
---|
| 243 | index=""
|
---|
| 244 | starline=""
|
---|
| 245 | endline=""
|
---|
| 246 | cat MyValueLinesInProblems.txt
|
---|
| 247 | rm -rf MyValueLinesInProblems.txt
|
---|
| 248 | echo "done removing bad value lines"
|
---|
| 249 | #read
|
---|
| 250 |
|
---|
| 251 | #PROBLEM SECTION 5 FIX - ADD GOOD VALUE LINE
|
---|
| 252 |
|
---|
| 253 | #Put in a good value line if there are bad ones
|
---|
| 254 |
|
---|
| 255 | cat -n "$MyFile" | grep "55561003"; echo "greped 55561003"
|
---|
| 256 | cat -n "$MyFile" | grep "2.16.840.1.113883.3.249.11.100.12";echo "grepped 2.16.840.1.113883.3.249.11.100.12"
|
---|
| 257 | cat -n "$MyFile" | grep "2.16.840.1.113883.10.20.1.50"; echo "grepped 2.16.840.1.113883.10.20.1.50"
|
---|
| 258 | echo " about to add xsi value lines with sed"
|
---|
| 259 | #read
|
---|
| 260 |
|
---|
| 261 | #sed -in '/"2.16.840.1.113883.10.20.1.50"/{n;n;n;s/$/\n<value xsi:type="CE" code="55561003" codeSystem="2.16.840.1. 113883.6.96" displayName="Active" codeSystemName="SNM" \/>/}' "$MyFile"
|
---|
| 262 | sed -in '/"2.16.840.1.113883.10.20.1.50"/{N;N;N;s/$/\n<value xsi:type="CE" code="55561003" codeSystem="2.16.840.1.113883.6.96" displayName="Active" codeSystemName="SNM" \/>/}' "$MyFile"
|
---|
| 263 | #echo "value Lines in Problems about to be written to screen and then the file"
|
---|
| 264 | #grep -n "2.16.840.1.113883.10.20.1.50" $MyFile | awk -F: '{print $1}'
|
---|
| 265 | #grep -n "2.16.840.1.113883.10.20.1.50" $MyFile | awk -F: '{print $1}' >> MyValueLinesInProblems.txt
|
---|
| 266 | #for i in $(cat MyValueLinesInProblems.txt)
|
---|
| 267 | #do
|
---|
| 268 | # sed -in "$i","$((i+6))"p "$MyFile"
|
---|
| 269 | #done
|
---|
| 270 | #rm -rf MyValueLinesInProblems.txt
|
---|
| 271 | echo "done adding good value line"
|
---|
| 272 | #read
|
---|
| 273 |
|
---|
| 274 | #PROBLEM #6 - XSI PROBLEM
|
---|
| 275 | #Fix the missing xsi:code value lines
|
---|
| 276 | #Fix any wrong value elements in the problem section
|
---|
| 277 | #I don't think there are any
|
---|
| 278 |
|
---|
| 279 | #cat MyStatusTemplates.txt
|
---|
| 280 | #echo "above checking the MyStatusTemplates.txt file content"
|
---|
| 281 | #read
|
---|
| 282 |
|
---|
| 283 | echo "issuing the sed command to delete the buffer"
|
---|
| 284 |
|
---|
| 285 | sed -e 'd' /home/nancy/CCR-Template/MyFile.txt
|
---|
| 286 | #read
|
---|
| 287 | Startline="$(cat "$MyFile" | grep -n "11450-4" | awk -F: '{print $1}')"
|
---|
| 288 | grep -n "2.16.840.1.113883.10.20.1.50" "$MyFile" | awk -F: '{print $1}' >> MyStatusTemplates.txt
|
---|
| 289 | Endline="$(tail -1 MyStatusTemplates.txt)"
|
---|
| 290 | cat -n "$MyFile" | grep '<value code'
|
---|
| 291 | echo "Endline is $Endline"
|
---|
| 292 | echo "startline is $Startline"
|
---|
| 293 |
|
---|
| 294 | #echo 'about to run the sed -fix the xsi code"
|
---|
| 295 | #sed -in "158,401{ s/<value code/<value xsi:type=\"CD\" code/ }" "$MyFile"
|
---|
| 296 | sed -in "$Startline,$Endline{ s/<value code/<value xsi:type=\"CD\" code/ }" "$MyFile"
|
---|
| 297 | sed -in "$Startline,$Endline{ s/<value displayName/<value xsi:type=\"CD\" displayName/ }" "$MyFile"
|
---|
| 298 |
|
---|
| 299 | StartLine=""
|
---|
| 300 | Endline=""
|
---|
| 301 | rm -rf MyStatusTemplates.txt
|
---|
| 302 | echo "done checking for bad value lines"
|
---|
| 303 | #read
|
---|
| 304 |
|
---|
| 305 |
|
---|
| 306 | #Done fixing Problem Section**********
|
---|
| 307 |
|
---|
| 308 | #Fix that dummy number they gave us with the right entry for Matt or Nancy
|
---|
| 309 | echo "if grep -q Nancy $MyFile then"
|
---|
| 310 | if grep -q Nancy $MyFile then
|
---|
| 311 | then
|
---|
| 312 | sed -i 's/6558574524/1558574525/' $MyFile
|
---|
| 313 | else
|
---|
| 314 | sed -i 's/6558574524/1124022827/' $MyFile
|
---|
| 315 | fi
|
---|
| 316 |
|
---|
| 317 | echo "read change NPIs for Matt and Nancy"
|
---|
| 318 | #read
|
---|
| 319 | #Line adminstrative gender code is on
|
---|
| 320 | a=$(grep -n birthTime $MyFile|awk -F: '{print $1}')
|
---|
| 321 |
|
---|
| 322 | sed -i 's/AdministrativeGender\"\ codeSystem=\"\"/AdministrativeGender\"\ codeSystem=\"2.16.840.1.113883.5.1\"/' $MyFile
|
---|
| 323 | #sed -i 's/AdministrativeGender\"\ codeSystem=\"\"/codeSystem=\"2.16.840.1.113883.5.1\"/' $MyFile
|
---|
| 324 | #sed -i 's/administrativeGenderCode displayName=\"FEMALE\"/administrativeGenderCode/' $MyFile
|
---|
| 325 | #sed -i 's/administrativeGenderCode displayName=\"MALE\"/administrativeGenderCode/' $MyFile
|
---|
| 326 |
|
---|
| 327 | #now that the adminstrativeGenderCode is fixed, save it in a variable
|
---|
| 328 | agc=$(grep AdminstrativeGender $MyFile)
|
---|
| 329 |
|
---|
| 330 | echo "Moving header including up to birthTime into MyNewFile.xml"
|
---|
| 331 | #Send the part of the file up to and including administrativeGenderCode and birthTime to MyNewFile
|
---|
| 332 | head -"$a" $MyFile >> MyNewFile.xml
|
---|
| 333 |
|
---|
| 334 | a=""
|
---|
| 335 | agc=""
|
---|
| 336 | #read
|
---|
| 337 | #the race and ethnicity will eventually come from the CCR Social History
|
---|
| 338 | #orde needs to be adminGender, birthTIme, race, ethnicity
|
---|
| 339 | #Now add the administrative gender
|
---|
| 340 |
|
---|
| 341 |
|
---|
| 342 | #now add the race code line to my new file
|
---|
| 343 | #right now everybody is native Hawaiian until we get this fixed!
|
---|
| 344 | #Plan to use only the existing VistA codes which match meaningful use
|
---|
| 345 | echo '<raceCode code="2076-8" codeSystem="2.16.840.1.113883.5.104"/>' >> MyNewFile.xml
|
---|
| 346 | echo '<ethnicGroupCode code="2186-5" codeSystem="2.16.840.1.113883.5.50"/>' >> MyNewFile.xml
|
---|
| 347 | echo '</patient>' >> MyNewFile.xml
|
---|
| 348 |
|
---|
| 349 | tail -6 MyNewFile.xml
|
---|
| 350 |
|
---|
| 351 | #the race and ethnicity that will eventually come from the CCR Social History
|
---|
| 352 | echo "fix administrativeGender, birthTime, raceCode and ethnicGroup"
|
---|
| 353 | #read
|
---|
| 354 | #copy the lines with the birthTime and <patient> and into the file in tieir proper place
|
---|
| 355 | #by pulling their locatin from the original file relative to the administrativeGenderCode line
|
---|
| 356 |
|
---|
| 357 |
|
---|
| 358 | #The providerOrganization sectiono is missing entrirely so put it in from these hard coded files for Matt and Nancy
|
---|
| 359 | #in their proper place right after the </patient tag
|
---|
| 360 |
|
---|
| 361 | if grep -q Nancy $MyFile
|
---|
| 362 | then
|
---|
| 363 | cat NancysProviderOranization.txt >> MyNewFile.xml
|
---|
| 364 | else
|
---|
| 365 | cat MatthewsProviderOranization.txt >> MyNewFile.xml
|
---|
| 366 | fi
|
---|
| 367 | #this just adds a line feed to MyNewFile.xml
|
---|
| 368 | echo >> MyNewFile.xml
|
---|
| 369 |
|
---|
| 370 | echo "read Provider organizaton added"
|
---|
| 371 | #read
|
---|
| 372 | #put the document beginning with /patientRole until the </participant> tag that is 2 lines after the only incidence of </associated person just before the <documentationOf> into MyNewFile.xml
|
---|
| 373 | d=$(grep -n "/patientRole" $MyFile|awk -F: '{print $1}');echo $d
|
---|
| 374 | e=$(($d+1));echo $e
|
---|
| 375 | f=$(grep -n "/associatedPerson" $MyFile|awk -F: '{print $1}');echo $f
|
---|
| 376 | g=$(($f+2));echo $g
|
---|
| 377 | cat $MyFile | sed -n $d,$g"p" >> MyNewFile.xml
|
---|
| 378 | #now add in the </patient role and </recordTarget>
|
---|
| 379 | echo "read /patientRole to /participant Person added"
|
---|
| 380 | #read
|
---|
| 381 | #now add the documentation of pulling the data from the encounter procedures later in the document. Searches for Encounters that are
|
---|
| 382 | #appropriate for the measure which will be in Encounter.txt
|
---|
| 383 |
|
---|
| 384 | #!!!!ADD MATT HERE
|
---|
| 385 | for i in $(cat AllEncounterCodes.txt);
|
---|
| 386 | do
|
---|
| 387 |
|
---|
| 388 | if [ "0" = "$(grep -q "$i" "$MyFile";echo "$?")" ]
|
---|
| 389 | then
|
---|
| 390 | echo $(grep -n "$i" "$MyFile" | awk -F: '{print $1}') >> Encounters.txt
|
---|
| 391 | echo "$i"
|
---|
| 392 | echo "above code added"
|
---|
| 393 | fi
|
---|
| 394 | done
|
---|
| 395 | cat "Encounters.txt"
|
---|
| 396 | #read
|
---|
| 397 |
|
---|
| 398 | if [ -f Encounters.txt ]
|
---|
| 399 | then
|
---|
| 400 | for i in $(cat Encounters.txt);
|
---|
| 401 | do
|
---|
| 402 | echo
|
---|
| 403 | echo "<documentationOf>" >> MyNewFile.xml
|
---|
| 404 | echo "<serviceEvent>" >> MyNewFile.xml
|
---|
| 405 | cat $MyFile | sed -n $i"p" >> MyNewFile.xml
|
---|
| 406 | x=$(($i+5)); echo $x
|
---|
| 407 | y=$(($i+8)); echo $y
|
---|
| 408 | #echo "sed -n "$x","$y"p >> MyNewFile.xml"
|
---|
| 409 | cat "$MyFile" | sed -n "$x","$y"p >> MyNewFile.xml
|
---|
| 410 | cat EndDocumentationOfSectionNancy.txt >> MyNewFile.xml
|
---|
| 411 | #added a line feed
|
---|
| 412 | echo >> MyNewFile.xml
|
---|
| 413 | #for testing print out the last 10 lines to the screen
|
---|
| 414 | tail MyNewFile.xml
|
---|
| 415 | done
|
---|
| 416 | else echo "$MyFile" >> FilesWithoutEncounters.txt
|
---|
| 417 | fi
|
---|
| 418 | tail MyNewFile.xml
|
---|
| 419 | rm -rf Encounters.txt
|
---|
| 420 | y=""
|
---|
| 421 | x=""
|
---|
| 422 |
|
---|
| 423 | echo "read documentationOf added and each section of that tailed -10"
|
---|
| 424 | #read
|
---|
| 425 | #read
|
---|
| 426 | #takes the low value date and puts it in the high value if the the is a nullFlavor there and it also corrects the dates by adding a 0
|
---|
| 427 | #in the 5th digit position if the date is 7 long instead of 8 and a zero in the 5th and next to the last position if the date is 6 long (ie,too short in either the low or high value) The latter is fixed now so it can be trimmed out - soon All dates and times are 8 or more
|
---|
| 428 | echo "<component>" >> MyNewFile.xml
|
---|
| 429 | p=$(grep -n '<structuredBody>' $MyFile | awk -F: '{print $1}')
|
---|
| 430 | q=$(grep -n '</ClinicalDocument>' $MyFile | awk -F: '{print $1}')
|
---|
| 431 | cat "$MyFile" | sed -n "$p","$q"p >> MyNewFile.xml
|
---|
| 432 | # take out <high nullFlavor="UNK"/> and replace it with the same value that is in low value everywhere it appears
|
---|
| 433 |
|
---|
| 434 | grep -n '<high nullFlavor="UNK"/>' MyNewFile.xml | awk -F: '{print $1}' >> NullFlavorTimes.txt
|
---|
| 435 | #NullFlavorTimes.txt has the line numbers
|
---|
| 436 | for i in $(cat NullFlavorTimes.txt);
|
---|
| 437 | do
|
---|
| 438 | #low value is one line above the high value with the nullFlavor, so get the date as it is
|
---|
| 439 | l=$(($i-1));echo $l
|
---|
| 440 | m=$(sed -n "$l"p MyNewFile.xml)
|
---|
| 441 | n=$(echo "$m" | awk -F\" '{print $2}')
|
---|
| 442 | u=$(echo "${#n}")
|
---|
| 443 | #fixes the date in low value if it is 7 long
|
---|
| 444 | if [ $u = 7 ]
|
---|
| 445 | then
|
---|
| 446 | v=$(echo $n |cut -c1-4)
|
---|
| 447 | w=$(echo $n |cut -c5-7)
|
---|
| 448 | j=$(echo $v"0"$w);echo $n
|
---|
| 449 | sed -i "$l"s/"$n"/"$j"/ MyNewFile.xml
|
---|
| 450 | n="$j"
|
---|
| 451 | #fixes the date if it is 6 long
|
---|
| 452 | elif [ $u = 6 ]
|
---|
| 453 | then
|
---|
| 454 | v=$(echo $n |cut -c1-4)
|
---|
| 455 | w=$(echo $n |cut -c5)
|
---|
| 456 | x=$(echo $n |cut -c6)
|
---|
| 457 | j=$(echo $v"0"$w"0"$x);echo $n
|
---|
| 458 | sed -i "$l"s/"$n"/"$j"/ MyNewFile.xml
|
---|
| 459 | n="$j"
|
---|
| 460 | fi
|
---|
| 461 | #now puts the low value corrected date in the high value
|
---|
| 462 | o="value="\""$n"\"""
|
---|
| 463 | echo $o
|
---|
| 464 | echo $i
|
---|
| 465 | #echo "sed -i "$i"s/nullFlavor=\"UNK\"/$o/ MyNewFile.xml"
|
---|
| 466 | sed -i "$i"s/'nullFlavor=\"UNK\"'/"$o"/ MyNewFile.xml
|
---|
| 467 | done
|
---|
| 468 | rm -rf NullFlavorTimes.txt
|
---|
| 469 |
|
---|
| 470 | l=""
|
---|
| 471 | m=""
|
---|
| 472 | n=""
|
---|
| 473 | u=""
|
---|
| 474 | v=""
|
---|
| 475 | w=""
|
---|
| 476 | j=""
|
---|
| 477 | o=""
|
---|
| 478 | i=""
|
---|
| 479 | echo "read NullFlavorTimes Fixed"
|
---|
| 480 | #
|
---|
| 481 | #read
|
---|
| 482 |
|
---|
| 483 |
|
---|
| 484 | #THIS NEEDS TO BE REPLACED WITH CUTTING OUT PROCEDURES NOT IN THE DOWNLOADABLE RESOURCE TABLE
|
---|
| 485 | #CODE FOR DELETING PROCEDURES WAS HERE AND IS NOW IN CodeForDeletingProcedures.txt
|
---|
| 486 |
|
---|
| 487 | #Replace anything with SNOMED or SNOMED-CT with SNM and replace anything with ICD9CM with I9 and and replace where it says codeSystem="" in the problem list with codeSysetm="2.16.840.1.113883.6.103"
|
---|
| 488 | #in lines that contain ICD9CM, replace codeSystem="" with codeSystem="2.16.840.1.113883.6.103"
|
---|
| 489 | sed -i '/ICD9CM/s/codeSystem=\"\"/codeSystem=\"2.16.840.1.113883.6.103\"/' MyNewFile.xml
|
---|
| 490 | sed -i 's/SNOMED-CT/SNM/' MyNewFile.xml
|
---|
| 491 | sed -i 's/ICD9CM/I9/' MyNewFile.xml
|
---|
| 492 | sed -i 's/ICD9/I9/' MyNewFile.xml
|
---|
| 493 | sed -i 's/SNOMED/SNM/' MyNewFile.xml
|
---|
| 494 |
|
---|
| 495 |
|
---|
| 496 | #Now put out a new file that has the same name as the original with Ver2 at the end which will contain the corrected header
|
---|
| 497 | echo "replace the codes with their proper names"
|
---|
| 498 | #read
|
---|
| 499 |
|
---|
| 500 |
|
---|
| 501 | cp MyNewFile.xml $(echo $MyFile | echo $(awk -F. '{print $1}')"Ver2.xml")
|
---|
| 502 | #mv MyNewFile.xml $(echo $MyFile | echo $(awk -F. '{print $1}')"Ver2.xml")
|
---|
| 503 | if grep -q 30954-2 MyNewFile.xml
|
---|
| 504 | then
|
---|
| 505 | echo "$MyFile contains results" >> FilesWithResults.txt
|
---|
| 506 | echo "$MyFile contains results"
|
---|
| 507 | fi
|
---|
| 508 | rm -rf MyNewFile.xml
|
---|
| 509 | rm -rf MyNewFile.xmln
|
---|
| 510 | echo "this is the end"
|
---|
| 511 | #read
|
---|
| 512 | echo "end $MyFile"
|
---|
| 513 | done
|
---|
| 514 |
|
---|
| 515 | echo "read FilesWithResults.txt has the names of files for running the results script"
|
---|
| 516 | #read
|
---|
| 517 | exit
|
---|