Vitals time extract fixed... Vitals now in date order

This commit is contained in:
george 2008-08-29 19:00:11 +00:00
parent 7dfb1ab484
commit c2f09c1966
1 changed files with 24 additions and 13 deletions

View File

@ -45,9 +45,9 @@ EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
. . K @VITVMAP
. . I DEBUG W "VMAP= ",VITVMAP,!
. . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
. . W "VITAL ",VSORT(J),!
. . W VITRSLT(VSORT(J))," ",$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT"),!
. . W $P(VITPTMP,U,4),!
. . I DEBUG W "VITAL ",VSORT(J),!
. . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT"),!
. . I DEBUG W $P(VITPTMP,U,4),!
. . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
. . I $P(VITPTMP,U,2)="HT" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
@ -184,8 +184,8 @@ EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
VITSORT(V1,V2) ; 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
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
@ -196,14 +196,25 @@ VITSORT(V1,V2) ; DATE SORT VITALS ARRAY AND RETURN INDEX IN V1 AND COUNT
. . S ZP2=$P($P(V2(ZTMP),U,4),".",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
. W "ZTMP=",ZTMP," "
. I DEBUG W "ZTMP=",ZTMP," "
S V1(0)=ZCNT ; ARRAYS ARE THE SAME SIZE
S ZJ=""
ZWR V2
ZWR VSRT
F ZI=1:1:ZCNT D Q:$O(VSRT(ZJ))="" ; VISIT THE ARRAY IN DATE ORDER
. ; S ZJ=$O(VSRT(ZJ)) ; NEXT DATE
. ; S V1(ZI)=VSRT(ZJ) ; ASSIGN INDEX OF NEXT DATE
. S V1(ZI)=ZI ; PLUG FOR NOW, DATES NOT SORTED
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 ZZCNT S ZZCNT=0 ; ANOTHER COUNTER
F ZI=0:0 D Q:ZDONE ; VISIT THE ARRAY IN DATE ORDER
. S ZD=$O(VSRT(ZD)) ; 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))="" ; LOOP THROUGH ALL TIMES
. . . S ZT=$O(VSRT(ZD,ZT)) ; NEXT TIME
. . . S ZZCNT=ZZCNT+1 ; INCREMENT COUNTER
. . . S V1(ZZCNT)=VSRT(ZD,ZT) ; PULL OUT THE INDEX
. ; S V1(ZI)=ZI ; PLUG FOR NOW, DATES NOT SORTED
I DEBUG ZWR V1
Q ZCNT
;