#!/bin/bash/ #Find the last line number in the Problem Section by finding the next ' "$File" 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" #read #Parse the Variable that comes out from that function to get the last line of the section echo "$TestSectionInformation" | awk -F: '{ print $2 }' EndProblemSectionLineNumber="$(echo "$TestSectionInformation" | awk -F: '{ print $2 }')" echo "$EndProblemSectionLineNumber is the last line in the problem section" #read #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 echo "BeginProblemSectionCodeLineNumber is $BeginProblemSectionCodeLineNumber and EndProblemSectionLineNumber is $EndProblemSectionLineNumber" echo "$File" grep -n "2.16.840.1.113883.3.249.11.100.8" "$File" | awk -F: '{ print $1 }' >> PatientProblemEntryTemplateRows.txt #head -"$EndProblemSectionLineNumber" "$File" | tail -"$(($EndProblemSectionLineNumber-$BeginProblemSectionCodeLineNumber))" | grep -n "2.16.840.1.113883.3.249.11.100.8" | awk -F: '{ print $1 }' >> PatientProblemEntryTemplateRows.txt #sed -n "$BeginProblemSectionCodeLineNumber","$EndProblemSectionLineNumber"p "$File" | grep -n "2.16.840.1.113883.3.249.11.100.8" | awk -F: '{ print $1 }' >> PatientProblemEntryTemplateRows.txt cat PatientProblemEntryTemplateRows.txt echo "Template 2.16.840.1.113883.3.249.11.100.8 row numbers are above" if [ -s PatientProblemEntryTemplateRows.txt ] then for i in $(cat PatientProblemEntryTemplateRows.txt) do echo "$i" head -"$(( $i+10 ))" "$File" \ | tail \ | grep '> ProblemCodes.txt done fi echo "Problem codes in the problem section are" cat "ProblemCodes.txt" read #Now find out what I9 problem codes are not in the downloadable resource and print those to a file for i in $(cat ProblemCodes.txt) do cat AllI9ProblemCodes.txt \ |grep -q "$i";echo $? cat AllI9ProblemCodes.txt \ |grep -q "$i" if [ "1" = "$?" ] then echo "There was an problem not found in the Downloadable Resource list of I9 problems" echo "$i" echo "the line above should have a single problem number" grep -n "code=\"$i" "$File" | awk -F: '{ print $1 }' echo "the line above should have a line number where the problem number was found" echo "that line number will be set to KeyLineNumber and handed off to the LineUpDownFunction" KeyLineNumber=$(grep -n "code=\"$i" "$File" | awk -F: '{ print $1 }') echo "The KeyNumber to hand the LineUpDownFunction is $KeyLineNumber" read source LineNumberUpDownFunction LineNumberUpDownFunction "$KeyLineNumber" '' "$File" echo "above is the output from the LineNumberUpDownFunction. It is in variable called SectionInformation" echo "that has the key line number, the line with