agend=./tmp/agend
./appl/sh/agend > $agend

# |  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 |
awk -F"^" ' BEGIN  { } 
fec($6) >= inic {
xx=trail($2)"^"trail($5)"^"$6
z[xx]=$1
x3[xx$7]=$7
}
function fec(x) { return substr(x,7)""substr(x,4,2)""substr(x,1,2) }
function trail(txt) { while (substr(txt,length(txt),1)==" ") txt=substr(txt,1,length(txt)-1); return (txt) }
END {
	for (i in z) print i"^"z[i]"^"x3[i"A"]"^"x3[i"V"]"^"x3[i"C"]
} ' $agend
exit
000001^00001|HERRERA^26/11/2018^0300^17.142.186-1|Villena^26/12/2018^A^2019-03-2520:22:09^Telemed2019^
000002^00001|HERRERA^26/12/2018^0300^17.142.186-1|Villena^26/12/2018^V^2019-03-2520:22:09^Telemed2019^
000003^00001|HERRERA^26/11/2018^0300^17.142.186-1|Villena^26/12/2018^C^2019-03-2520:22:09^Telemed2019^
000004^00001|HERRERA^26/11/2018^0319^17.142.186-1|Villena^12/12/2018^A^2019-03-2520:22:09^Telemed2019^
000005^00001|HERRERA^26/11/2018^0319^17.142.186-1|Villena^12/12/2018^V^2019-03-2520:22:09^Telemed2019^
000006^00001|HERRERA^26/11/2018^0319^17.142.186-1|Villena^12/12/2018^C^2019-03-2520:22:09^Telemed2019^
000007^00001|HERRERA^26/11/2018^0326^17.142.186-1|Villena^19/12/2018^A^2019-03-2520:22:09^Telemed2019^
000008^00001|HERRERA^26/11/2018^0326^17.142.186-1|Villena^19/12/2018^V^2019-03-2520:22:09^Telemed2019^
000009^00001|HERRERA^26/11/2018^0326^17.142.186-1|Villena^19/12/2018^C^2019-03-2520:22:09^Telemed2019^
000010^00002|CASTRO^26/11/2018^0013^16.203.285-2|Correa^06/12/2018^A^2019-03-2520:22:09 ^Telemed2019^
