Changeset 187


Ignore:
Timestamp:
Oct 6, 2008, 7:33:38 PM (16 years ago)
Author:
George Lilly
Message:

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

Location:
ccr/trunk/p
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/CCRMEDS2.m

    r186 r187  
    179179 . ; --- END OF DIRECTIONS ---
    180180 . ;
    181  . S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
    182  . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
     181 . ; S @MAP@("MEDPTINSTRUCTIONS","F")="52.41^105"
     182 . S @MAP@("MEDPTINSTRUCTIONS")=$G(^PSRX(RXIEN,"PI",1,0)) ;GPL
     183 . W @MAP@("MEDPTINSTRUCTIONS"),!
     184 . ; S @MAP@("MEDFULLFILLMENTINSTRUCTIONS","F")="52.41^9"
     185 . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")=$G(^PSRX(RXIEN,"SIG1",1,0)) ;GPL
     186 . W @MAP@("MEDFULLFILLMENTINSTRUCTIONS"),!
    183187 . S @MAP@("MEDRFNO")=$$GET1^DIQ(52.41,RXIEN,13)
    184188 . N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"MAPPED"))
  • ccr/trunk/p/CCRUTIL.m

    r149 r187  
    5858 N VSRT ; TEMP FOR HASHING DATES
    5959 N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
    60  S ZCNT=0 ; COUNTING NUMBER OF DATES
    61  S ZTMP="" ;
    62  F ZI=0:0 D  Q:$O(V2(ZTMP))=""  ; FOR EACH DATE IN THE ARRAY
    63  . S ZCNT=ZCNT+1 ; INCREMENT THE COUNT
    64  . S ZTMP=$O(V2(ZTMP)) ; NEXT DATE
    65  . I $D(V2(ZTMP)) D  ; IF THE DATE EXISTS
    66  . . S ZP1=$P(V2(ZTMP),".",1) ; THE DATE PIECE
    67  . . S ZP2=$P(V2(ZTMP),".",2) ; THE TIME PIECE
    68  . . S VSRT(ZP1,ZP2_"00000"_ZCNT)=ZCNT ; HASH ON DATE AND TIME
    69  . . ; S VSRT($P(V2(ZTMP),U,4)_"000000"_ZCNT)=ZCNT ; PULL DATE
    70  . I DEBUG W "ZTMP=",ZTMP," "
    71  S V1(0)=ZCNT ; ARRAYS ARE THE SAME SIZE
    72  ; I DEBUG ZWR V2
    73  ; I DEBUG ZWR VSRT
    74  N ZD,ZT ; DATA AND TIME ITERATORS
    75  N ZDONE ; DONE FLAG
    76  S (ZD,ZT)=""
    77  S ZDONE=0
    78  N UORDR ; ORDER TO USE 1=FORWARD -1=REVERSE
    79  S UORDR=ORDR ; DIRECTION TO SORT
    80  I ORDR="" S UORDR=1
    81  N ZZCNT S ZZCNT=0 ; ANOTHER COUNTER
    82  F ZI=0:0 D  Q:ZDONE  ; VISIT THE ARRAY IN DATE ORDER
    83  . S ZD=$O(VSRT(ZD),UORDR) ; NEXT DATE
    84  . I ZD="" S ZDONE=1
    85  . I 'ZDONE D  ; MORE DATES
    86  . . S ZT="" ; WANT FIRST TIME FOR THIS DATE
    87  . . F ZJ=0:0 D  Q:$O(VSRT(ZD,ZT),UORDR)=""  ; LOOP THROUGH ALL TIMES
    88  . . . S ZT=$O(VSRT(ZD,ZT),UORDR) ; NEXT TIME
    89  . . . S ZZCNT=ZZCNT+1 ; INCREMENT COUNTER
    90  . . . S V1(ZZCNT)=VSRT(ZD,ZT) ; PULL OUT THE INDEX
     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
    9179 Q ZCNT
    9280 ;
    93 SORTDT2(V1,V2,ORDR) ; REWRITE TO USE 3 INSTEAD OF 2 LVLS OF INDEX
    94  ; AND $Q INSTEAD OF $O
    95  ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
    96  ; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE
    97  ; DATE AND TIME ORDER. DEFAULT IS FORWARD
    98  ; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT
    99  ; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER
    100  ; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER
    101  ; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC
    102  ; BOTH V1 AND V2 ARE PASSED BY REFERENCE
    103  N VSRT ; TEMP FOR HASHING DATES
    104  N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
    105  S ZCNT=0 ; COUNTING NUMBER OF DATES
    106  S ZTMP="" ;
    107  F ZI=0:0 D  Q:$O(V2(ZTMP))=""  ; FOR EACH DATE IN THE ARRAY
    108  . S ZCNT=ZCNT+1 ; INCREMENT THE COUNT
    109  . S ZTMP=$O(V2(ZTMP)) ; NEXT DATE
    110  . I $D(V2(ZTMP)) D  ; IF THE DATE EXISTS
    111  . . S ZP1=$P(V2(ZTMP),".",1) ; THE DATE PIECE
    112  . . S ZP2=$P(V2(ZTMP),".",2) ; THE TIME PIECE
    113  . . S VSRT(ZP1,ZP2,ZCNT)=ZCNT ; HASH ON DATE AND TIME
    114  . I DEBUG W "ZTMP=",ZTMP," "
    115  S V1(0)=ZCNT ; ARRAYS ARE THE SAME SIZE
    116  ; I DEBUG ZWR V2
    117  ; I DEBUG ZWR VSRT
    118  N ZD,ZT ; DATA AND TIME ITERATORS
    119  N ZDONE ; DONE FLAG
    120  S (ZD,ZT)=""
    121  S ZDONE=0
    122  N UORDR ; ORDER TO USE 1=FORWARD -1=REVERSE
    123  S UORDR=ORDR ; DIRECTION TO SORT
    124  I ORDR="" S UORDR=1
    125  N ZZCNT S ZZCNT=0 ; ANOTHER COUNTER
    126  F ZI=0:0 D  Q:ZDONE  ; VISIT THE ARRAY IN DATE ORDER
    127  . S ZD=$O(VSRT(ZD),UORDR) ; NEXT DATE fix this
    128  . I ZD="" S ZDONE=1
    129  . I 'ZDONE D  ; MORE DATES
    130  . . S ZT="" ; WANT FIRST TIME FOR THIS DATE
    131  . . F ZJ=0:0 D  Q:$O(VSRT(ZD,ZT),UORDR)=""  ; LOOP THROUGH ALL TIMES
    132  . . . S ZT=$O(VSRT(ZD,ZT),UORDR) ; NEXT TIME
    133  . . . S ZZCNT=ZZCNT+1 ; INCREMENT COUNTER
    134  . . . S V1(ZZCNT)=VSRT(ZD,ZT) ; PULL OUT THE INDEX
    135  Q ZCNT
    136  ;
  • ccr/trunk/p/GPLVITAL.m

    r146 r187  
    11GPLVITAL ; CCDCCR/CJE - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
    2           ;;0.1;CCDCCR;;JUL 16,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 FROM TOP",!
    21           Q
    22           ;
     2 ;;0.1;CCDCCR;;JUL 16,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 FROM TOP",!
     21 Q
     22 ;
    2323EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
    24           ;
    25           ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
    26           ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
    27           ;
    28           N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
    29           D VITALS^ORQQVI(.VITRSLT,DFN,"","")
    30           I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
    31           I $P(VITRSLT(1),U,2)="No vitals found." D  Q  ; NULL RESULT FROM RPC
    32           . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
    33           . S @VITOUTXML@(0)=0
    34           I $P(VITRSLT(1),U,2)="No vitals found." Q  ; QUIT
    35           ; ZWR RPCRSLT
    36           S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
    37           S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
    38           K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
    39           N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
    40           D VITDATES(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
    41           ; I DEBUG ZWR VDATES ;DEBUG
    42           S VCNT=$$SORTDT^CCRUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
    43           ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
    44           S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
    45           F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
    46           . I $D(VITRSLT(VSORT(J))) D
    47           . . S VITVMAP=$NA(@VITTVMAP@(J))
    48           . . K @VITVMAP
    49           . . I DEBUG W "VMAP= ",VITVMAP,!
    50           . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
    51           . . I DEBUG W "VITAL ",VSORT(J),!
    52           . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT"),!
    53           . . I DEBUG W $P(VITPTMP,U,4),!
    54           . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
    55           . . I $P(VITPTMP,U,2)="HT" D
    56           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    57           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    58           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
    59           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    60           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    61           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    62           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
    63           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="248327008"
    64           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    65           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    66           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    67           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    68           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
    69           . . E  I $P(VITPTMP,U,2)="WT" D
    70           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    71           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    72           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
    73           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    74           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    75           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    76           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
    77           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="107647005"
    78           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    79           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    80           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    81           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    82           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
    83           . . E  I $P(VITPTMP,U,2)="BP" D
    84           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    85           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    86           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
    87           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    88           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    89           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    90           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
    91           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="392570002"
    92           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    93           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    94           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    95           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    96           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    97           . . E  I $P(VITPTMP,U,2)="T" D
    98           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    99           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    100           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
    101           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    102           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    103           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    104           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
    105           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="309646008"
    106           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    107           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    108           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    109           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    110           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
    111           . . E  I $P(VITPTMP,U,2)="R" D
    112           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    113           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    114           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
    115           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    116           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    117           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    118           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
    119           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366147009"
    120           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    121           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    122           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    123           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    124           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    125           . . E  I $P(VITPTMP,U,2)="P" D
    126           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    127           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    128           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
    129           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    130           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    131           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    132           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
    133           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366199006"
    134           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    135           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    136           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    137           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    138           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    139           . . E  I $P(VITPTMP,U,2)="PN" D
    140           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    141           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    142           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
    143           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    144           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    145           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    146           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
    147           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="22253000"
    148           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
    149           . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    150           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    151           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    152           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    153           . . E  D
    154           . . . ;W "IN VITAL:  OTHER",!
    155           . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    156           . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
    157           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
    158           . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    159           . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    160           . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
    161           . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
    162           . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")=""
    163           . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")=""
    164           . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    165           . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    166           . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    167           . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
    168           . . S VITARYTMP=$NA(@VITTARYTMP@(J))
    169           . . K @VITARYTMP
    170           . . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)
    171           . . I J=1 D  ; FIRST ONE IS JUST A COPY
    172           . . . ; W "FIRST ONE",!
    173           . . . D CP^GPLXPATH(VITARYTMP,VITOUTXML)
    174           . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
    175           . . I J>1 D  ; AFTER THE FIRST, INSERT INNER XML
    176           . . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP)
    177           ; ZWR ^TMP($J,"VITALS",*)
    178           ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
    179           I DEBUG D PARY^GPLXPATH(VITOUTXML)
    180           N VITTMP,I
    181           D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
    182           I VITTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
    183           . W "VITALS MISSING ",!
    184           . F I=1:1:VITTMP(0) W VITTMP(I),!
    185           Q
    186           ;
     24 ;
     25 ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
     26 ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
     27 ;
     28 N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
     29 D VITALS^ORQQVI(.VITRSLT,DFN,"","")
     30 I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
     31 I $P(VITRSLT(1),U,2)="No vitals found." D  Q  ; NULL RESULT FROM RPC
     32 . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
     33 . S @VITOUTXML@(0)=0
     34 I $P(VITRSLT(1),U,2)="No vitals found." Q  ; QUIT
     35 ; ZWR RPCRSLT
     36 S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
     37 S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
     38 K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
     39 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
     40 D VITDATES(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
     41 ; I DEBUG ZWR VDATES ;DEBUG
     42 S VCNT=$$SORTDT^CCRUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
     43 ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
     44 S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
     45 F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
     46 . I $D(VITRSLT(VSORT(J))) D
     47 . . S VITVMAP=$NA(@VITTVMAP@(J))
     48 . . K @VITVMAP
     49 . . I DEBUG W "VMAP= ",VITVMAP,!
     50 . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
     51 . . I DEBUG W "VITAL ",VSORT(J),!
     52 . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT"),!
     53 . . I DEBUG W $P(VITPTMP,U,4),!
     54 . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
     55 . . I $P(VITPTMP,U,2)="HT" D
     56 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     57 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     58 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
     59 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     60 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     61 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     62 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
     63 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="248327008"
     64 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     65 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     66 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     67 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     68 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
     69 . . E  I $P(VITPTMP,U,2)="WT" D
     70 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     71 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     72 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
     73 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     74 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     75 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     76 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
     77 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="107647005"
     78 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     79 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     80 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     81 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     82 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
     83 . . E  I $P(VITPTMP,U,2)="BP" D
     84 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     85 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     86 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
     87 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     88 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     89 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     90 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
     91 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="392570002"
     92 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     93 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     94 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     95 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     96 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     97 . . E  I $P(VITPTMP,U,2)="T" D
     98 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     99 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     100 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
     101 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     102 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     103 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     104 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
     105 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="309646008"
     106 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     107 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     108 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     109 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     110 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
     111 . . E  I $P(VITPTMP,U,2)="R" D
     112 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     113 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     114 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
     115 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     116 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     117 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     118 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
     119 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366147009"
     120 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     121 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     122 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     123 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     124 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     125 . . E  I $P(VITPTMP,U,2)="P" D
     126 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     127 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     128 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
     129 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     130 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     131 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     132 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
     133 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366199006"
     134 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     135 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     136 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     137 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     138 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     139 . . E  I $P(VITPTMP,U,2)="PN" D
     140 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     141 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     142 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
     143 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     144 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     145 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     146 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
     147 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="22253000"
     148 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"
     149 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     150 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     151 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     152 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     153 . . E  D
     154 . . . ;W "IN VITAL:  OTHER",!
     155 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     156 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")
     157 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
     158 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     159 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     160 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
     161 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
     162 . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")=""
     163 . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")=""
     164 . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     165 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     166 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     167 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
     168 . . S VITARYTMP=$NA(@VITTARYTMP@(J))
     169 . . K @VITARYTMP
     170 . . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)
     171 . . I J=1 D  ; FIRST ONE IS JUST A COPY
     172 . . . ; W "FIRST ONE",!
     173 . . . D CP^GPLXPATH(VITARYTMP,VITOUTXML)
     174 . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
     175 . . I J>1 D  ; AFTER THE FIRST, INSERT INNER XML
     176 . . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP)
     177 ; ZWR ^TMP($J,"VITALS",*)
     178 ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
     179 I DEBUG D PARY^GPLXPATH(VITOUTXML)
     180 N VITTMP,I
     181 D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
     182 I VITTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
     183 . W "VITALS MISSING ",!
     184 . F I=1:1:VITTMP(0) W VITTMP(I),!
     185 Q
     186 ;
    187187VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
    188          ; OF DATES IN THE VITALS RESULTS
    189          N VDTI,VDTJ,VTDCNT
    190          S VTDCNT=0 ; COUNT TO BUILD ARRAY
    191          S VDTJ="" ; USED TO VISIT THE RESULTS
    192          F VDTI=0:0 D  Q:$O(VITRSLT(VDTJ))=""  ; VISIT ALL RESULTS
    193          . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
    194          . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
    195          . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
    196          Q
    197          ;
     188 ; OF DATES IN THE VITALS RESULTS
     189 N VDTI,VDTJ,VTDCNT
     190 S VTDCNT=0 ; COUNT TO BUILD ARRAY
     191 S VDTJ="" ; USED TO VISIT THE RESULTS
     192 F VDTI=0:0 D  Q:$O(VITRSLT(VDTJ))=""  ; VISIT ALL RESULTS
     193 . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
     194 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
     195 . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
     196 S VDT(0)=VTDCNT
     197 Q
     198 ;
Note: See TracChangeset for help on using the changeset viewer.