rewrote Date sort routine to fix Vitals bug. debugging meds.

This commit is contained in:
george 2008-10-06 23:33:38 +00:00
parent 9a7a927275
commit b41654cf7b
3 changed files with 220 additions and 271 deletions

View File

@ -178,8 +178,12 @@ EXTRACT(MINXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEM
. ;
. ; --- END OF DIRECTIONS ---
. ;
. S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
. ; S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
. S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PI",1,0)) ;GPL
. W @MAP@("MEDPTINSTRUCTIONS"),!
. ; S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
. S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"SIG1",1,0)) ;GPL
. W @MAP@("MEDFULLFILLMENTINSTRUCTIONS"),!
. S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
. N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"MAPPED"))
. K @RESULT

View File

@ -57,80 +57,24 @@ SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
; 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
;
SORTDT2(V1,V2,ORDR) ; REWRITE TO USE 3 INSTEAD OF 2 LVLS OF INDEX
; AND $Q INSTEAD OF $O
; 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,ZCNT)=ZCNT ; HASH ON DATE AND TIME
. 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 fix this
. 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
S ZCNT=V2(0) ; COUNTING NUMBER OF DATES
F ZI=1:1:ZCNT D ; FOR EACH DATE IN THE ARRAY
. I $D(V2(ZI)) D ; IF THE DATE EXISTS
. . S ZP1=$P(V2(ZI),".",1) ; THE DATE PIECE
. . S ZP2=$P(V2(ZI),".",2) ; THE TIME PIECE
. . ; W "DATE: ",ZP1," TIME: ",ZP2,!
. . S VSRT(ZP1,ZP2,ZI)=ZI ; INDEX OF DATE, TIME AND COUNT
N ZG
S ZG=$Q(VSRT(""))
F D Q:ZG="" ;
. ; W ZG,!
. D PUSH^GPLXPATH("V1",@ZG)
. S ZG=$Q(@ZG)
I ORDR=-1 D ; HAVE TO REVERSE ORDER
. N ZG2
. F ZI=1:1:V1(0) D ; FOR EACH ELELMENT
. . S ZG2(V1(0)-ZI+1)=V1(ZI) ; SET IN REVERSE ORDER
. S ZG2(0)=V1(0)
. D CP^GPLXPATH("ZG2","V1") ; COPY OVER THE NEW ARRAY
Q ZCNT
;

View File

@ -1,197 +1,198 @@
GPLVITAL ; CCDCCR/CJE - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
;;0.1;CCDCCR;;JUL 16,2008;
;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
;General Public License See attached copy of the License.
;
;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;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 FROM TOP",!
Q
;
;;0.1;CCDCCR;;JUL 16,2008;
;Copyright 2008 WorldVistA. Licensed under the terms of the GNU
;General Public License See attached copy of the License.
;
;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;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 FROM TOP",!
Q
;
EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
;
; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
;
N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
D VITALS^ORQQVI(.VITRSLT,DFN,"","")
I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC
. I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
. S @VITOUTXML@(0)=0
I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT
; ZWR RPCRSLT
S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
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
S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
. I $D(VITRSLT(VSORT(J))) D
. . S VITVMAP=$NA(@VITTVMAP@(J))
. . K @VITVMAP
. . I DEBUG W "VMAP= ",VITVMAP,!
. . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
. . 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"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="248327008"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
. . E I $P(VITPTMP,U,2)="WT" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="107647005"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
. . E I $P(VITPTMP,U,2)="BP" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="392570002"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E I $P(VITPTMP,U,2)="T" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="309646008"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
. . E I $P(VITPTMP,U,2)="R" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366147009"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E I $P(VITPTMP,U,2)="P" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366199006"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E I $P(VITPTMP,U,2)="PN" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="22253000"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E D
. . . ;W "IN VITAL: OTHER",!
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
. . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")=""
. . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")=""
. . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
. . S VITARYTMP=$NA(@VITTARYTMP@(J))
. . K @VITARYTMP
. . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)
. . I J=1 D ; FIRST ONE IS JUST A COPY
. . . ; W "FIRST ONE",!
. . . D CP^GPLXPATH(VITARYTMP,VITOUTXML)
. . . I DEBUG W "VITOUTXML ",VITOUTXML,!
. . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
. . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP)
; ZWR ^TMP($J,"VITALS",*)
; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
I DEBUG D PARY^GPLXPATH(VITOUTXML)
N VITTMP,I
D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
. W "VITALS MISSING ",!
. F I=1:1:VITTMP(0) W VITTMP(I),!
Q
;
;
; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
;
N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
D VITALS^ORQQVI(.VITRSLT,DFN,"","")
I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC
. I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
. S @VITOUTXML@(0)=0
I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT
; ZWR RPCRSLT
S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
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
S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
. I $D(VITRSLT(VSORT(J))) D
. . S VITVMAP=$NA(@VITTVMAP@(J))
. . K @VITVMAP
. . I DEBUG W "VMAP= ",VITVMAP,!
. . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
. . 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"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="248327008"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
. . E I $P(VITPTMP,U,2)="WT" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="107647005"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
. . E I $P(VITPTMP,U,2)="BP" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="392570002"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E I $P(VITPTMP,U,2)="T" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="309646008"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
. . E I $P(VITPTMP,U,2)="R" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366147009"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E I $P(VITPTMP,U,2)="P" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366199006"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E I $P(VITPTMP,U,2)="PN" D
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="22253000"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . E D
. . . ;W "IN VITAL: OTHER",!
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
. . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")=""
. . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")=""
. . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
. . S VITARYTMP=$NA(@VITTARYTMP@(J))
. . K @VITARYTMP
. . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)
. . I J=1 D ; FIRST ONE IS JUST A COPY
. . . ; W "FIRST ONE",!
. . . D CP^GPLXPATH(VITARYTMP,VITOUTXML)
. . . I DEBUG W "VITOUTXML ",VITOUTXML,!
. . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
. . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP)
; ZWR ^TMP($J,"VITALS",*)
; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
I DEBUG D PARY^GPLXPATH(VITOUTXML)
N VITTMP,I
D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
. W "VITALS MISSING ",!
. F I=1:1:VITTMP(0) W VITTMP(I),!
Q
;
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
;
; 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
S VDT(0)=VTDCNT
Q
;