#!/bin/bash

echo "Which  directory contains your CCRs?  Please provide the full path /home/vademo4-09/CCR or whatever is appropriate"
read mypath
#sample file name PAT_100955_CCR_V1_0_0.xml
for i in $(ls -1 $mypath/PAT_*_CCR_V1_0_0.xml); do 
echo "$i" | awk -F_ '{ print $2 }' >> CCR-DFNs.txt
#list of the DFNs for the patients who have CCRs in the CCR directory
file="CCR-DFNs.txt"
done
for DFN in $(cat "${file}");
do
echo "java -jar /usr/share/java/saxon.jar -o /home/vademo4-09/QRDA/PAT_${DFN}_QRDA_V1_0_0-`date +%m-%d-%Y_%H`.xml /home/vademo4-09/CCR/PAT_${DFN}_CCR_V1_0_0.xml New-ccr_qrda.xsl" >> "qrda2-`date +%m-%d-%Y_%H`.sh";done


#model lines of gernerated file
#!/bin/bash
#java -jar /usr/share/java/saxon.jar -o /home/vademo4-09/QRDA/M1-PAT_100146_QRDA_V1_0_0.xml /home/vademo4-09/CCR/M1_100146_CCR_V1_0_0.xml M1-ccr_qrda.xsl
