1 | CCRUTIL ;CCRCCD/SMH - Various Utilites for generating the CCR/CCD;06/15/08
|
---|
2 | ;;0.1;CCRCCD;;Jun 15, 2008;
|
---|
3 | ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
|
---|
4 | ;General Public License See attached copy of the License.
|
---|
5 | ;
|
---|
6 | ;This program is free software; you can redistribute it and/or modify
|
---|
7 | ;it under the terms of the GNU General Public License as published by
|
---|
8 | ;the Free Software Foundation; either version 2 of the License, or
|
---|
9 | ;(at your option) any later version.
|
---|
10 | ;
|
---|
11 | ;This program is distributed in the hope that it will be useful,
|
---|
12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | ;GNU General Public License for more details.
|
---|
15 | ;
|
---|
16 | ;You should have received a copy of the GNU General Public License along
|
---|
17 | ;with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
18 | ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
19 | ;
|
---|
20 | W "No Entry at Top!"
|
---|
21 | Q
|
---|
22 | ;
|
---|
23 | FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
|
---|
24 | ; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time)
|
---|
25 | ; If not passed, or passed incorrectly, it's assumed that it is D.
|
---|
26 | ; FM Date format is "YYYMMDD.HHMMSS" HHMMSS may not be supplied.
|
---|
27 | ; UTC date is formatted as follows: YYYY-MM-DDThh:mm:ss_offsetfromUTC
|
---|
28 | ; UTC, Year, Month, Day, Hours, Minutes, Seconds, Time offset (obtained from Mailman Site Parameters)
|
---|
29 | N UTC,Y,M,D,H,MM,S,OFF
|
---|
30 | S Y=1700+$E(DATE,1,3)
|
---|
31 | S M=$E(DATE,4,5)
|
---|
32 | S D=$E(DATE,6,7)
|
---|
33 | S H=$E(DATE,9,10)
|
---|
34 | I $L(H)=1 S H="0"_H
|
---|
35 | S MM=$E(DATE,11,12)
|
---|
36 | I $L(MM)=1 S MM="0"_MM
|
---|
37 | S S=$E(DATE,13,14)
|
---|
38 | I $L(S)=1 S S="0"_S
|
---|
39 | S OFF=$$TZ^XLFDT ; See Kernel Manual for documentation.
|
---|
40 | ; If H, MM and S are empty, it means that the FM date didn't supply the time.
|
---|
41 | ; In this case, set H, MM and S to "00"
|
---|
42 | ; S:('$L(H)&'$L(MM)&'$L(S)) (H,MM,S)="00" ; IF ONLY SOME ARE MISSING?
|
---|
43 | S:'$L(H) H="00"
|
---|
44 | S:'$L(MM) MM="00"
|
---|
45 | S:'$L(S) S="00"
|
---|
46 | S UTC=Y_"-"_M_"-"_D_"T"_H_":"_MM_$S(S="":":00",1:":"_S)_OFF ; Skip's code to fix hanging colon if no seconds
|
---|
47 | I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time.
|
---|
48 | E Q $P(UTC,"T")
|
---|
49 | ;
|
---|
50 | SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
|
---|
51 | ; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE
|
---|
52 | ; DATE AND TIME ORDER. DEFAULT IS FORWARD
|
---|
53 | ; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT
|
---|
54 | ; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER
|
---|
55 | ; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER
|
---|
56 | ; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC
|
---|
57 | ; BOTH V1 AND V2 ARE PASSED BY REFERENCE
|
---|
58 | N VSRT ; TEMP FOR HASHING DATES
|
---|
59 | N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
|
---|
60 | S ZCNT=V2(0) ; COUNTING NUMBER OF DATES
|
---|
61 | F ZI=1:1:ZCNT D ; FOR EACH DATE IN THE ARRAY
|
---|
62 | . I $D(V2(ZI)) D ; IF THE DATE EXISTS
|
---|
63 | . . S ZP1=$P(V2(ZI),".",1) ; THE DATE PIECE
|
---|
64 | . . S ZP2=$P(V2(ZI),".",2) ; THE TIME PIECE
|
---|
65 | . . ; W "DATE: ",ZP1," TIME: ",ZP2,!
|
---|
66 | . . S VSRT(ZP1,ZP2,ZI)=ZI ; INDEX OF DATE, TIME AND COUNT
|
---|
67 | N ZG
|
---|
68 | S ZG=$Q(VSRT(""))
|
---|
69 | F D Q:ZG="" ;
|
---|
70 | . ; W ZG,!
|
---|
71 | . D PUSH^GPLXPATH("V1",@ZG)
|
---|
72 | . S ZG=$Q(@ZG)
|
---|
73 | I ORDR=-1 D ; HAVE TO REVERSE ORDER
|
---|
74 | . N ZG2
|
---|
75 | . F ZI=1:1:V1(0) D ; FOR EACH ELELMENT
|
---|
76 | . . S ZG2(V1(0)-ZI+1)=V1(ZI) ; SET IN REVERSE ORDER
|
---|
77 | . S ZG2(0)=V1(0)
|
---|
78 | . D CP^GPLXPATH("ZG2","V1") ; COPY OVER THE NEW ARRAY
|
---|
79 | Q ZCNT
|
---|
80 | ; |
---|