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
|
---|
6 |
|
---|
7 |
|
---|
8 | for MyFile in $(ls -1 /home/nancy/CCR-Template/QRDA/PAT_*_QRDA_V1_0_0-11-04-2010_21.xml);
|
---|
9 | do
|
---|
10 | StructuredBodyLine=$(grep -n "<structuredBody" "$MyFile" | awk -F: '{ print $1 }')
|
---|
11 | echo "structuredBody Line number is $StructuredBodyLine"
|
---|
12 | a="$(($StructuredBodyLine+2))"
|
---|
13 | b="$(($StructuredBodyLine+5))"
|
---|
14 | #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
|
---|
15 | echo "a is $a start line to delete for <components>/<section> pairs"
|
---|
16 | echo "b is $b end line to delete"
|
---|
17 | echo "$MyFile"
|
---|
18 | #We can either put this next line in after the fact or before. Currently it is before
|
---|
19 | #sed -in '/structuredBody/{ s/$/\n<MeasuresSection\/>/ }' "$MyFile"
|
---|
20 | #sed -in "$c"s/<MeasuresSection\/>//p "$MyFile"
|
---|
21 | #MS=$(cat MeasuresAndReportingParametersWithVariables.xml)
|
---|
22 | sed -in "$a","$b"d "$MyFile"
|
---|
23 | #insert the contents of this file after the structured body line
|
---|
24 | sed -in '/MeasuresSection/r MeasuresAndReportingParametersWithVariables.xml' "$MyFile"
|
---|
25 | sed -in s/\<MeasuresSection\\/\>// "$MyFile"
|
---|
26 | done
|
---|
27 |
|
---|
28 |
|
---|
29 | rm -rf /home/nancy/CCR-Template/QRDA/PAT*.xmln
|
---|
30 |
|
---|
31 | NewFunction()
|
---|
32 | {
|
---|
33 | File="PAT_$1_QRDA_V1_0_0-11-04-2010_21.xml"
|
---|
34 | shift
|
---|
35 | while [ "0" != "$#" ]
|
---|
36 | do
|
---|
37 | echo "Now I am in the function"
|
---|
38 | echo "$File"
|
---|
39 | echo "$1"
|
---|
40 | sed -in "s/<!--@@@$1-Tpl@@@//" "$File"
|
---|
41 | sed -in "s/<!--@@@$1-Item@@@//" "$File"
|
---|
42 | sed -in "s/<!--@@@$1-Act@@@//" "$File"
|
---|
43 | sed -in "s/<!--@@@M-Set2011@@@//" "$File"
|
---|
44 | sed -in "s/@@@@$1-Tpl@@@@-->//" "$File"
|
---|
45 | sed -in "s/@@@@$1-Item@@@@-->//" "$File"
|
---|
46 | sed -in "s/@@@@$1-Act@@@@-->//" "$File"
|
---|
47 | sed -in "s/@@@@M-Set2011@@@@-->//" "$File"
|
---|
48 | sed -in "s/<!--@@@M-Param2011@@@//" "$File"
|
---|
49 | sed -in "s/@@@@M-Param2011@@@@//" "$File"
|
---|
50 |
|
---|
51 | shift
|
---|
52 | done
|
---|
53 | }
|
---|
54 |
|
---|
55 | while read Line ;
|
---|
56 | do
|
---|
57 | echo "$Line"
|
---|
58 |
|
---|
59 | NewFunction $Line
|
---|
60 | done < "MEASURES-BY-PATIENT.txt"
|
---|
61 |
|
---|
62 | rm -rf /home/nancy/CCR-Template/QRDA/PAT*.xmln
|
---|