#!/bin/ksh
fname=${1:-"f.dcm"}
firstline=${2:-"0"}
exam=${3:-"12345"}
headerprefix=${4:-""}
detailprefix=${5:-""}
printcsvheader=1
printcsvdetail=2
#mojoe_dir="/export/home/sdc/mojoe"
mojoe_dir=$MOJOE_DIR
if (test ${#mojoe_dir} -lt 1)
    then
    mojoe_dir=$HOME/mojoe
fi
# extract summary?
if (test $fname = "esummary") then
    billtable=$mojoe_dir/log/billing/mojoe_ebill_$exam.txt
    echo $headerprefix > $billtable
    echo $detailprefix >> $billtable
    exit
fi
billtable=$mojoe_dir/log/billing/mojoe_elist_$exam.txt
if (test $firstline -eq 1) then
    if (test ${#headerprefix} -gt 0) then
        $mojoe_dir/dicom/infodcm2 $fname $printcsvheader $headerprefix 2>&1 > $billtable
    else
        $mojoe_dir/dicom/infodcm2 $fname $printcsvheader 2>&1 > $billtable
    fi
fi
if (test ${#detailprefix} -gt 0) then
    $mojoe_dir/dicom/infodcm2 $fname $printcsvdetail $detailprefix 2>&1 >> $billtable
else
    $mojoe_dir/dicom/infodcm2 $fname $printcsvdetail 2>&1 >> $billtable
fi
