XINDEX fixes, and generalized Date sort utility for Vitals SORTDT^CCRUTIL

This commit is contained in:
george 2008-08-30 17:29:46 +00:00
parent 9ff7d946bb
commit 0333b2585b
5 changed files with 71 additions and 13 deletions

View File

@ -17,8 +17,9 @@ CCRUTIL ;CCRCCD/SMH - Various Utilites for generating the CCR/CCD;06/15/08
;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;
W "No Entry at Top!" Q
W "No Entry at Top!"
Q
;
FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time)
; If not passed, or passed incorrectly, it's assumed that it is D.
@ -46,3 +47,46 @@ FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrins
I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time.
E Q $P(UTC,"T")
;
SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE
; DATE AND TIME ORDER. DEFAULT IS FORWARD
; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT
; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER
; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER
; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC
; BOTH V1 AND V2 ARE PASSED BY REFERENCE
N VSRT ; TEMP FOR HASHING DATES
N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
S ZCNT=0 ; COUNTING NUMBER OF DATES
S ZTMP="" ;
F ZI=0:0 D Q:$O(V2(ZTMP))="" ; FOR EACH DATE IN THE ARRAY
. S ZCNT=ZCNT+1 ; INCREMENT THE COUNT
. S ZTMP=$O(V2(ZTMP)) ; NEXT DATE
. I $D(V2(ZTMP)) D ; IF THE DATE EXISTS
. . S ZP1=$P(V2(ZTMP),".",1) ; THE DATE PIECE
. . S ZP2=$P(V2(ZTMP),".",2) ; THE TIME PIECE
. . S VSRT(ZP1,ZP2_"00000"_ZCNT)=ZCNT ; HASH ON DATE AND TIME
. . ; S VSRT($P(V2(ZTMP),U,4)_"000000"_ZCNT)=ZCNT ; PULL DATE
. I DEBUG W "ZTMP=",ZTMP," "
S V1(0)=ZCNT ; ARRAYS ARE THE SAME SIZE
I DEBUG ZWR V2
I DEBUG ZWR VSRT
N ZD,ZT ; DATA AND TIME ITERATORS
N ZDONE ; DONE FLAG
S (ZD,ZT)=""
S ZDONE=0
N UORDR ; ORDER TO USE 1=FORWARD -1=REVERSE
S UORDR=ORDR ; DIRECTION TO SORT
I ORDR="" S UORDR=1
N ZZCNT S ZZCNT=0 ; ANOTHER COUNTER
F ZI=0:0 D Q:ZDONE ; VISIT THE ARRAY IN DATE ORDER
. S ZD=$O(VSRT(ZD),UORDR) ; NEXT DATE
. I ZD="" S ZDONE=1
. I 'ZDONE D ; MORE DATES
. . S ZT="" ; WANT FIRST TIME FOR THIS DATE
. . F ZJ=0:0 D Q:$O(VSRT(ZD,ZT),UORDR)="" ; LOOP THROUGH ALL TIMES
. . . S ZT=$O(VSRT(ZD,ZT),UORDR) ; NEXT TIME
. . . S ZZCNT=ZZCNT+1 ; INCREMENT COUNTER
. . . S V1(ZZCNT)=VSRT(ZD,ZT) ; PULL OUT THE INDEX
Q ZCNT
;

View File

@ -204,7 +204,7 @@ ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML
. . I J'="" S K(J)="" ; HASHING ACTOR
. . ; TO GET RID OF DUPLICATES
S I="" ; GOING TO $O THROUGH THE HASH
F J=0:0 D Q:$O(K(I))=""
F J=0:0 D Q:$O(K(I))="" ;
. S I=$O(K(I)) ; WALK THROUGH THE HASH OF ACTORS
. S $P(L,U,1)=I ; FIRST PIECE IS THE OBJECT ID
. S $P(L,U,2)=$P($P(I,"ACTOR",2),"_",1) ; ACTOR TYPE

View File

@ -33,7 +33,7 @@ EXTRACT(IPXML,DFN,OUTXML) ; EXTRACT PROBLEMS INTO PROVIDED XML TEMPLATE
S TARYTMP=$NA(^TMP("GPLCCR",$J,"PROBARYTMP"))
K @TVMAP,@TARYTMP ; KILL OLD ARRAY VALUES
D LIST^ORQQPL3(.RPCRSLT,DFN,"") ; CALL THE PROBLEM LIST RPC
I '$D(RPCRSLT(1)) D Q ; RPC RETURNS NULL
I '$D(RPCRSLT(1)) D Q ; RPC RETURNS NULL
. W "NULL RESULT FROM LIST^ORQQPL3 ",!
. S @OUTXML@(0)=0
. ; Q

View File

@ -80,7 +80,7 @@ ZTEST(ZARY,WHICH) ; try out the tests using a passed array ZTEST
; . . D ZTEST^GPLUNIT(@ZARY,@NT@(J))
I '$D(ZARY(WHICH)) D ; TEST SECTION DOESN'T EXIST
. W "ERROR -- TEST SECTION DOESN'T EXIST -> ",WHICH,!
. Q ; EXIT
. Q ; EXIT
N FIRST,LAST
S FIRST=$P(ZARY(WHICH),"^",1)
S LAST=$P(ZARY(WHICH),"^",2)
@ -112,7 +112,7 @@ TEST ; RUN ALL THE TEST CASES
W "FAILED: ",TFAILED,!
W !
W "THE TESTS!",!
ZWR ZTMP
I DEBUG ZWR ZTMP
Q
;
GTSTS(GTZARY,RTN) ; return an array of test names

View File

@ -36,9 +36,11 @@ EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
N VSORT,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
S VCNT=$$VITSORT(.VSORT,.VITRSLT) ; PUT VITALS IN DATE ORDER
; AND COUNT THEM VSORT CONTAINS INDEXES ONLY
N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
D VITDATES(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
I DEBUG ZWR VDATES ;DEBUG
S VCNT=$$SORTDT^CCRUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
. I $D(VITRSLT(VSORT(J))) D
. . S VITVMAP=$NA(@VITTVMAP@(J))
@ -181,14 +183,15 @@ EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
. F I=1:1:VITTMP(0) W VITTMP(I),!
Q
;
VITSORT(V1,V2) ; DATE SORT VITALS ARRAY AND RETURN INDEX IN V1 AND COUNT
VITSORT(V1,V2) ; DEPRECATED USE $$RSORTDT^CCRUTIL
; DATE SORT VITALS ARRAY AND RETURN INDEX IN V1 AND COUNT
; AS EXTRINSIC
; BOTH V1 AND V2 ARE PASSED BY REFERENCE
N VSRT ; TEMP FOR HASHING DATES
N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
S ZCNT=0 ; COUNTING NUMBER OF VITALS
S ZTMP="" ;
F ZI=0:0 D Q:$O(V2(ZTMP))="" ; FOR EACH VITAL IN THE ARRAY
F ZI=0:0 D Q:$O(V2(ZTMP))="" ; FOR EACH VITAL IN THE ARRAY
. S ZCNT=ZCNT+1 ; INCREMENT THE COUNT
. S ZTMP=$O(V2(ZTMP)) ; NEXT VITAL
. I $D(V2(ZTMP)) D ; IF THE RESULT EXISTS
@ -205,7 +208,7 @@ VITSORT(V1,V2) ; DATE SORT VITALS ARRAY AND RETURN INDEX IN V1 AND COUNT
S (ZD,ZT)=""
S ZDONE=0
N ZZCNT S ZZCNT=0 ; ANOTHER COUNTER
F ZI=0:0 D Q:ZDONE ; VISIT THE ARRAY IN DATE ORDER
F ZI=0:0 D Q:ZDONE ; VISIT THE ARRAY IN DATE ORDER
. S ZD=$O(VSRT(ZD),-1) ; NEXT DATE
. I ZD="" S ZDONE=1
. I 'ZDONE D ; MORE DATES
@ -217,4 +220,15 @@ VITSORT(V1,V2) ; DATE SORT VITALS ARRAY AND RETURN INDEX IN V1 AND COUNT
. ; S V1(ZI)=ZI ; PLUG FOR NOW, DATES NOT SORTED
I DEBUG ZWR V1
Q ZCNT
;
;
VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
; OF DATES IN THE VITALS RESULTS
N VDTI,VDTJ,VTDCNT
S VTDCNT=0 ; COUNT TO BUILD ARRAY
S VDTJ="" ; USED TO VISIT THE RESULTS
F VDTI=0:0 D Q:$O(VITRSLT(VDTJ))="" ; VISIT ALL RESULTS
. S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
. S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
. S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
Q
;