| 1 | #!/bin/bash/ | 
|---|
| 2 | #The following files must be in the same directory as the QRDA files being processed: | 
|---|
| 3 | #MeasuresAndReportingParametersWithVariables.xml | 
|---|
| 4 | #MEASURES-BY-PATIENT.txt | 
|---|
| 5 | #This script which is FixMeasuresSection.sh | 
|---|
| 6 |  | 
|---|
| 7 | for MyFile in $(ls -1 PAT_*_QRDA_V1_0_0-11-10-2010_16.xml); | 
|---|
| 8 | do | 
|---|
| 9 | StructuredBodyLine=$(grep -n "<structuredBody" "$MyFile" | awk -F: '{ print $1 }') | 
|---|
| 10 | echo "structuredBody Line number is $StructuredBodyLine" | 
|---|
| 11 | a="$(($StructuredBodyLine+2))" | 
|---|
| 12 | b="$(($StructuredBodyLine+5))" | 
|---|
| 13 | #In or for Saxon to do its work, the file it works on must be valid, so 3 sets of component/section tags were added to allow for those that will be replaced when the Measures and reporting parameters section is replaced in the file.  They need to be deleted.  The <MeasuresSection/> tag is added in the Header/Parameter document to anchor the replacement. IT will be deleted when the section is put into the file | 
|---|
| 14 | echo "a is $a start line to delete for <components>/<section> pairs" | 
|---|
| 15 | echo "b is $b end line to delete" | 
|---|
| 16 | echo "$MyFile" | 
|---|
| 17 | #We can either put this next line in after the fact or before.  Currently it is before | 
|---|
| 18 | #sed -in '/structuredBody/{ s/$/\n<MeasuresSection\/>/ }' "$MyFile" | 
|---|
| 19 | #sed -in "$c"s/<MeasuresSection\/>//p "$MyFile" | 
|---|
| 20 | #MS=$(cat MeasuresAndReportingParametersWithVariables.xml) | 
|---|
| 21 | sed -in "$a","$b"d "$MyFile" | 
|---|
| 22 | #insert the contents of this file after the structured body line | 
|---|
| 23 | sed -in '/MeasuresSection/r MeasuresAndReportingParametersWithVariables2011.xml' "$MyFile" | 
|---|
| 24 | sed -in  s/\<MeasuresSection\\/\>// "$MyFile" | 
|---|
| 25 | done | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | rm -rf PAT*.xmln | 
|---|
| 29 |  | 
|---|
| 30 | NewFunction() | 
|---|
| 31 | { | 
|---|
| 32 | File="PAT_$1_QRDA_V1_0_0-11-10-2010_16.xml" | 
|---|
| 33 | shift | 
|---|
| 34 | while [ "0" != "$#" ] | 
|---|
| 35 | do | 
|---|
| 36 | echo "Now I am in the function" | 
|---|
| 37 | echo "$File" | 
|---|
| 38 | echo "$1" | 
|---|
| 39 | sed -in "s/<!--@@@$1-Tpl@@@//" "$File" | 
|---|
| 40 | sed -in "s/<!--@@@$1-item@@@//" "$File" | 
|---|
| 41 | sed -in "s/<!--@@@$1-Act@@@//" "$File" | 
|---|
| 42 | sed -in "s/<!--@@@M-Set2011@@@//" "$File" | 
|---|
| 43 | sed -in "s/@@@@$1-Tpl@@@@-->//" "$File" | 
|---|
| 44 | sed -in "s/@@@@$1-item@@@@-->//" "$File" | 
|---|
| 45 | sed -in "s/@@@@$1-Act@@@@-->//" "$File" | 
|---|
| 46 | sed -in "s/@@@@M-Set2011@@@@-->//" "$File" | 
|---|
| 47 | sed -in "s/<!--@@@M-Param2011@@@//" "$File" | 
|---|
| 48 | sed -in "s/@@@@M-Param2011@@@@-->//" "$File" | 
|---|
| 49 |  | 
|---|
| 50 | shift | 
|---|
| 51 | done | 
|---|
| 52 | } | 
|---|
| 53 |  | 
|---|
| 54 | while read Line ; | 
|---|
| 55 | do | 
|---|
| 56 | echo "$Line" | 
|---|
| 57 |  | 
|---|
| 58 | NewFunction $Line | 
|---|
| 59 | done < "MEASURES-BY-PATIENT.txt" | 
|---|
| 60 |  | 
|---|
| 61 | rm -rf PAT*.xmln | 
|---|