source: ccr2ccd-xslt/trunk/make/FunctionProcessProblemSection@ 1418

Last change on this file since 1418 was 1033, checked in by mishpers@gmail.com, 14 years ago

Add missing files that were on Nancy's local computer

File size: 5.2 KB
Line 
1#!/bin/bash/
2#Find the last line number in the Problem Section by finding the next <component line that is after the last
3#line entry in the MyFileToProcess.txt
4#Process each section found in MyFileToProcess.txt one line at a time to determine whether or not they are in the downloadable resource file
5#by Beginning at the KeyLineNumber which is $1 proceed down until you find a line beginning with <value and process that line to
6#extract the I9 code found in code="xxxx" and check to see if that is in the list of AllI9ProblemCodes.txt
7#if it is not in the list, store the beginning and ending line numbers to prepare to delete the problem.
8#Delete the offending Problem
9#Delete the text files that were created which are
10#PatientProblemEntryTemplateRows.txt
11#ProblemCodes.txt
12#You will need the following files
13# LineNumberDownFunction
14# AllI9ProblemCodes.txt
15# LineNumberUpDownFunction
16# This file FunctionProcessProblemSection
17FunctionProcessProblemSection ()
18{
19local File
20local LastLineInProblemSection
21local ProblemCode
22local BeginProblemSectionCodeLineNumber
23local EndProblemSectionLineNumber
24local a
25local b
26local i
27local KeyLineNumber
28File="$1"
29echo "File is $File"
30read
31#read
32 #Find the code that identifies the near beginning of the problem section
33 BeginProblemSectionCodeLineNumber="$(grep -n "11450-4" "$File" | awk -F: '{ print $1 }')"
34 echo "BeginProblemSectionCodeLineNumber is $BeginProblemSectionCodeLineNumber"
35 #Use the LineNumberDownFunction to find the last line in the problem section
36 source LineNumberDownFunction
37 LineNumberDownFunction $BeginProblemSectionCodeLineNumber "$BeginProblemSectionCodeLineNumber" '</component>' "$File"
38 echo "result of LineNumberDownFunction is $TestSectionInformation which has the last line of the problem section in the second entry with a separator that is a colon"
39 #read
40 #Parse the Variable that comes out from that function to get the last line of the section
41 echo "$TestSectionInformation" | awk -F: '{ print $2 }'
42 EndProblemSectionLineNumber="$(echo "$TestSectionInformation" | awk -F: '{ print $2 }')"
43 echo "$EndProblemSectionLineNumber is the last line in the problem section"
44 #read
45 #Search the problem section to extract the problem codes by finding the template lines for problems, seaching the next 10 lines for the value line and parsing that to get the problem code
46 echo "BeginProblemSectionCodeLineNumber is $BeginProblemSectionCodeLineNumber and EndProblemSectionLineNumber is $EndProblemSectionLineNumber"
47 echo "$File"
48 grep -n "2.16.840.1.113883.3.249.11.100.8" "$File" | awk -F: '{ print $1 }' >> PatientProblemEntryTemplateRows.txt
49 #head -"$EndProblemSectionLineNumber" "$File" | tail -"$(($EndProblemSectionLineNumber-$BeginProblemSectionCodeLineNumber))" | grep -n "2.16.840.1.113883.3.249.11.100.8" | awk -F: '{ print $1 }' >> PatientProblemEntryTemplateRows.txt
50 #sed -n "$BeginProblemSectionCodeLineNumber","$EndProblemSectionLineNumber"p "$File" | grep -n "2.16.840.1.113883.3.249.11.100.8" | awk -F: '{ print $1 }' >> PatientProblemEntryTemplateRows.txt
51 cat PatientProblemEntryTemplateRows.txt
52 echo "Template 2.16.840.1.113883.3.249.11.100.8 row numbers are above"
53 if [ -s PatientProblemEntryTemplateRows.txt ]
54 then
55 for i in $(cat PatientProblemEntryTemplateRows.txt)
56 do
57 echo "$i"
58 head -"$(( $i+10 ))" "$File" \
59 | tail \
60 | grep '<value ' \
61 | awk -F'code="' '{ print $2 }' \
62 | awk -F\" '{ print $1}' >> ProblemCodes.txt
63 done
64 fi
65 echo "Problem codes in the problem section are"
66 cat "ProblemCodes.txt"
67 read
68 #Now find out what I9 problem codes are not in the downloadable resource and print those to a file
69 for i in $(cat ProblemCodes.txt)
70 do
71 cat AllI9ProblemCodes.txt \
72 |grep -q "$i";echo $?
73 cat AllI9ProblemCodes.txt \
74 |grep -q "$i"
75 if [ "1" = "$?" ]
76 then
77 echo "There was an problem not found in the Downloadable Resource list of I9 problems"
78 echo "$i"
79 echo "the line above should have a single problem number"
80 grep -n "code=\"$i" "$File" | awk -F: '{ print $1 }'
81 echo "the line above should have a line number where the problem number was found"
82 echo "that line number will be set to KeyLineNumber and handed off to the LineUpDownFunction"
83 KeyLineNumber=$(grep -n "code=\"$i" "$File" | awk -F: '{ print $1 }')
84 echo "The KeyNumber to hand the LineUpDownFunction is $KeyLineNumber"
85 read
86 source LineNumberUpDownFunction
87 LineNumberUpDownFunction "$KeyLineNumber" '<entry ' '</entry>' "$File"
88 echo "above is the output from the LineNumberUpDownFunction. It is in variable called SectionInformation"
89 echo "that has the key line number, the line with <entry and the line with </entry and then the File name"
90 echo "separated by colons"
91 a=$(echo "$SectionInformation" | awk -F: '{print $2 }')
92 b=$(echo "$SectionInformation" | awk -F: '{print $3 }')
93 sed -n "$a","$b"d "$File"
94 echo "Problem $i was deleted from $File"
95 echo "Confirming Problem was deleted with grep -q"
96 grep -q "$ProblemToDeleted" "$File"
97 echo " Is the problem deleted? dollar? is $?"
98 #read
99 xmlwf "$File"
100 echo "Just checked to see if $File is well formed and dollar? is $?"
101 read
102
103 fi
104 done
105 rm -rf PatientProblemEntryTemplateRows.txt
106 rm -rf ProblemCodes.txt
107
108 }
Note: See TracBrowser for help on using the repository browser.