BASE=`pwd`
APPLDIR=$BASE/appl
DATADIR=$BASE/data
PATH=$PATH:$BASE/ihd/bin:.
export PATH APPLDIR DATADIR

perso=./tmp/perso.q
#./appl/sh/perso | awk -F^ ' substr($16,1,2)=="00" { print $1 } ' - >$perso
./appl/sh/perso | awk -F^ ' { print $1 } ' - >$perso

./appl/sh/agend | awk -F^ ' FILENAME==ARGV[1] { pers[$1]=1;next }

pers[sp($5)]==1 {  x[substr($2,1,5)substr($4,1,2)$6]=sep($5) }
function sep(s) { split(s,a,"|"); return a[1]" "a[2] }
function sp(s) { split(s,a,"|"); return a[1]}
function trail(txt) { while (substr(txt,length(txt),1)==" ") txt=substr(txt,1,length(txt)-1); return (txt) }
END {
print "var eqp = new Array()"
for (i in x) printf  "eqp[\"%s\"]=\"%s\"\n",i,trail(x[i])
} ' $perso - >../js/eqp1.js

# |  1 H00 regist 06 00   0 | 2 H01 pacien 05 51   6 | 3 H02 fechai 10 00  11 |
# |  4 H03 valida 04 00  21 | 5 H04 profes 12 52  25 | 6 H05 fechae 10 00  37 |
# |  7 H06 transs 01 00  47 | 8 H07 transc 20 00  48 | 9 H08 usuari 20 00  68 |
# | 10 H09 ecog00 02 01  88 |11 H10 eva000 02 01  90 |12 H11 filler 296 15  92 |



# |  1 H00 codigo 12 07   0 | 2 H01 identi 40 00  12 | 3 H02 nombre 40 00  52 |
# |  4 H03 patern 40 00  92 | 5 H04 matern 40 00 132 | 6 H05 direcc 40 00 172 |
# |  7 H06 comuna 25 00 212 | 8 H07 ciudad 25 00 237 | 9 H08 correo 40 00 262 |
# | 10 H09 telefo 50 00 302 |11 H10 especi 02 51 352 |12 H11 regist 06 01 354 |
# | 13 H12 fechai 10 00 360 |14 H13 fechae 10 00 370 |15 H14 zonas  03 53 380 |
# | 16 H15 status 02 52 383 |17 H16 conara 06 00 385 |

