Ignore:
Timestamp:
Jan 4, 2012, 9:40:24 PM (13 years ago)
Author:
George Lilly
Message:

certification version without tabs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/branches/ohum/p/C0CVITAL.m

    r1333 r1337  
    1 C0CVITAL        ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
    2         ;;1.0;C0C;;May 19, 2009;Build 1
    3         ;Copyright 2008,2009 George Lilly, University of Minnesota and others.
    4         ;Licensed under the terms of the GNU General Public License.
    5         ;See attached copy of the License.
    6         ;
    7         ;This program is free software; you can redistribute it and/or modify
    8         ;it under the terms of the GNU General Public License as published by
    9         ;the Free Software Foundation; either version 2 of the License, or
    10         ;(at your option) any later version.
    11         ;
    12         ;This program is distributed in the hope that it will be useful,
    13         ;but WITHOUT ANY WARRANTY; without even the implied warranty of
    14         ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15         ;GNU General Public License for more details.
    16         ;
    17         ;You should have received a copy of the GNU General Public License along
    18         ;with this program; if not, write to the Free Software Foundation, Inc.,
    19         ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    20         ;
    21         W "NO ENTRY FROM TOP",!
    22         Q
    23         ;
    24 EXTRACT(VITXML,DFN,VITOUTXML)   ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
    25         ;
    26         ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
    27         ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
    28         ;
    29         N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
    30         S C0CVLMT=$$GET^C0CPARMS("VITLIMIT") ; GET THE LIMIT PARM
    31         S C0CVSTRT=$$GET^C0CPARMS("VITSTART") ; GET START PARM
    32         D DT^DILF(,C0CVLMT,.C0CEDT) ;
    33         D DT^DILF(,C0CVSTRT,.C0CSDT) ;
    34         ;D DT^DILF(,C0CVLMT,.C0CSDT) ; GPL TESTING
    35         ;D DT^DILF(,C0CVSTRT,.C0CEDT) ;
    36         W "VITALS START: ",C0CVSTRT," LIMIT: ",C0CVLMT,!
    37         I $$RPMS^C0CUTIL() D VITRPMS QUIT
    38         I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VITVISTA QUIT
    39         ;I $$SYSNAME^C0CSYS()="RPMS" D VITRPMS
    40         ;E  D VITVISTA
    41         Q
    42         ;
    43 VITVISTA        ; EXTRACT VITALS FROM VISTA INTO PROVIDED XML TEMPLATE
    44         D FASTVIT^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT) ; GPL THIS ONE WORKS FOR AT
    45         ; LEAST ONE SET OF VITALS - TO DO, CALL IT REPETIVELY TO GET EARLIER VITALS
    46         ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT)
    47         ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CSDT,C0CEDT)
    48         ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CVSTRT,C0CVLMT) ; GPL LET GMR HANDLE THE DATES
    49         I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
    50         I $P(VITRSLT(1),U,2)="No vitals found." D  Q  ; NULL RESULT FROM RPC
    51         . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
    52         . S @VITOUTXML@(0)=0
    53         I $P(VITRSLT(1),U,2)="No vitals found." Q  ; QUIT
    54         ; ZWR RPCRSLT
    55         S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
    56         S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
    57         K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
    58         N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
    59         D VITDVISTA(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
    60         I DEBUG ZWR VDATES ;DEBUG
    61         S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
    62         ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
    63         S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
    64         F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
    65         . I $D(VITRSLT(VSORT(J))) D
    66         . . S VITVMAP=$NA(@VITTVMAP@(J))
    67         . . K @VITVMAP
    68         . . I DEBUG W "VMAP= ",VITVMAP,!
    69         . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
    70         . . I DEBUG W "VITAL ",VSORT(J),!
    71         . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
    72         . . I DEBUG W $P(VITPTMP,U,4),!
    73         . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
    74                . . ;B  ;gpl
    75                . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
    76                . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D  ;
    77                . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1"
    78         . . I $P(VITPTMP,U,2)="HT" D
    79         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    80         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    81         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
    82         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    83         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    84         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    85         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
    86         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
    87         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    88         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    89         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    90         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    91         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
    92         . . E  I $P(VITPTMP,U,2)="WT" D
    93         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    94         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    95         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
    96         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    97         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    98         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    99         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
    100         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
    101         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    102         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    103         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    104         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    105         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
    106         . . E  I $P(VITPTMP,U,2)="BP" D
    107         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    108         . . . ;S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    109         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
    110         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    111         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    112         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    113         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
    114         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
    115         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    116         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    117         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    118         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    119         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    120         . . E  I $P(VITPTMP,U,2)="T" D
    121         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    122         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    123         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
    124         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    125         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    126         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    127         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
    128         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
    129         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    130         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    131         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    132         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    133         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
    134         . . E  I $P(VITPTMP,U,2)="R" D
    135         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    136         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    137         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
    138         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    139         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    140         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    141         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
    142         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
    143         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    144         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    145         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    146         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    147         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    148         . . E  I $P(VITPTMP,U,2)="P" D
    149         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    150         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    151         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
    152         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    153         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    154         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    155         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
    156         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
    157         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    158         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    159         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    160         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    161         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    162         . . E  I $P(VITPTMP,U,2)="PN" D
    163         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    164         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    165         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
    166         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    167         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    168         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    169         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
    170         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
    171         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    172         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    173         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    174         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    175         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    176         . . E  I $P(VITPTMP,U,2)="BMI" D
    177         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    178         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    179         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
    180         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    181         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    182         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    183         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
    184         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="60621009"
    185         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    186         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    187         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
    188         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    189         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
    190         . . E  D
    191         . . . ;W "IN VITAL:  OTHER",!
    192         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    193         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    194         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
    195         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    196         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    197         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
    198         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
    199         . . . ;S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
    200         . . . ;S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
    201         . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    202         . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
    203         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
    204         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
    205                . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D  ;
    206                . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1" ;
    207         . . S VITARYTMP=$NA(@VITTARYTMP@(J))
    208         . . K @VITARYTMP
    209         . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
    210         . . I J=1 D  ; FIRST ONE IS JUST A COPY
    211         . . . ; W "FIRST ONE",!
    212         . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
    213         . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
    214         . . I J>1 D  ; AFTER THE FIRST, INSERT INNER XML
    215         . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
    216         ; ZWR ^TMP($J,"VITALS",*)
    217         ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
    218         I DEBUG D PARY^C0CXPATH(VITOUTXML)
    219         N VITTMP,I
    220         D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
    221         I VITTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
    222         . W "VITALS MISSING ",!
    223         . F I=1:1:VITTMP(0) W VITTMP(I),!
    224         Q
    225         ;
    226 VITRPMS ; EXTRACT VITALS FROM RPMS INTO PROVIDED XML TEMPLATE
    227         ; RPMS VITAL RPC ONLY RETURNS LATEST VITAL IN SPECIFIED DATE RANGE NOT ALL VITALS IN DATE RANGE
    228         ; WE NEED TO SETUP THE VARIABLES THE INTERNAL CALL NEEDS TO BYPASS A HARD CODE OF ONE VITAL FOR DATE RANGE
    229         N END,START,DATA
    230         D DT^DILF("",C0CVLMT,.END)
    231         D DT^DILF("",C0CVSTRT,.START)
    232         ; RPC OUTPUT FORMAT:
    233         ; vfile ien^vital name^vital abbr^date/time taken(FM FORMAT)^value+units (US & metric)
    234         D QUERY^BEHOVM("LISTX") ; RUN QUERY VITALS CALL
    235         I '$D(^TMP("CIAVMRPC",$J)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
    236         ;ZW ^TMP("CIAVMRPC",$J)
    237         S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
    238         S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
    239         K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
    240         N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
    241         D VITDRPMS(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
    242         S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
    243         ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
    244         S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
    245         F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
    246         . I $D(^TMP("CIAVMRPC",$J,0,(VSORT(J)))) D
    247         . . S VITVMAP=$NA(@VITTVMAP@(J))
    248         . . K @VITVMAP
    249         . . I DEBUG W "VMAP= ",VITVMAP,!
    250         . . S VITPTMP=^TMP("CIAVMRPC",$J,0,(VSORT(J))) ; DATE SORTED VITAL FROM RETURN ARRAY
    251         . . I DEBUG W "VITAL ",VSORT(J),!
    252         . . I DEBUG W ^TMP("CIAVMRPC",$J,0,(VSORT(J)))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
    253         . . I DEBUG W $P(VITPTMP,U,4),!
    254         . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
    255         . . I $P(VITPTMP,U,3)="HT" D
    256         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    257         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    258         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
    259         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    260         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    261         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    262         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
    263         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
    264         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    265         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    266         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    267         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    268         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    269         . . E  I $P(VITPTMP,U,3)="WT" D
    270         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    271         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    272         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
    273         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    274         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    275         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    276         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
    277         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
    278         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    279         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    280         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    281         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    282         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    283         . . E  I $P(VITPTMP,U,3)="BP" D
    284         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    285         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    286         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
    287         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    288         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    289         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    290         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
    291         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
    292         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    293         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    294         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    295         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    296         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    297         . . E  I $P(VITPTMP,U,3)="TMP" D
    298         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    299         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    300         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
    301         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    302         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    303         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    304         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
    305         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
    306         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    307         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    308         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    309         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    310         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    311         . . E  I $P(VITPTMP,U,3)="RS" D
    312         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    313         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    314         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
    315         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    316         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    317         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    318         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
    319         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
    320         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    321         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    322         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    323         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    324         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    325         . . E  I $P(VITPTMP,U,3)="PU" D
    326         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    327         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    328         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
    329         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    330         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    331         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    332         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
    333         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
    334         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    335         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    336         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    337         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    338         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    339         . . E  I $P(VITPTMP,U,3)="PA" D
    340         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    341         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    342         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
    343         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    344         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    345         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    346         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
    347         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
    348         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
    349         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    350         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    351         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    352         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    353         . . E  D
    354         . . . ;W "IN VITAL:  OTHER",!
    355         . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
    356         . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
    357         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
    358         . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
    359         . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
    360         . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
    361         . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
    362         . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
    363         . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
    364         . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
    365         . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
    366         . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
    367         . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
    368         . . S VITARYTMP=$NA(@VITTARYTMP@(J))
    369         . . K @VITARYTMP
    370         . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
    371         . . I J=1 D  ; FIRST ONE IS JUST A COPY
    372         . . . ; W "FIRST ONE",!
    373         . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
    374         . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
    375         . . I J>1 D  ; AFTER THE FIRST, INSERT INNER XML
    376         . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
    377         ; ZWR ^TMP($J,"VITALS",*)
    378         ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
    379         I DEBUG D PARY^C0CXPATH(VITOUTXML)
    380         N VITTMP,I
    381         D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
    382         I VITTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
    383         . W "VITALS MISSING ",!
    384         . F I=1:1:VITTMP(0) W VITTMP(I),!
    385         K ^TMP("CIAVMRPC",$J)
    386         Q
    387         ;
    388 VITDRPMS(VDT)   ; RUN DATE SORTING ALGORITHM FOR RPMS
    389         ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
    390         ; OF DATES IN THE VITALS RESULTS
    391         N VDTI,VDTJ,VTDCNT
    392         S VTDCNT=0 ; COUNT TO BUILD ARRAY
    393         S VDTJ="" ; USED TO VISIT THE RESULTS
    394         F VDTI=0:0 D  Q:$O(^TMP("CIAVMRPC",$J,0,VDTJ))=""  ; VISIT ALL RESULTS
    395         . S VDTJ=$O(^TMP("CIAVMRPC",$J,0,VDTJ)) ; NEXT RESULT
    396         . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
    397         . S VDT(VTDCNT)=$P(^TMP("CIAVMRPC",$J,0,VDTJ),U,4) ; PULL OUT THE DATE
    398         S VDT(0)=VTDCNT
    399         Q
    400         ;
    401 VITDVISTA(VDT)  ; RUN DATE SORTING ALGORITHM FOR VISTA
    402         ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
    403         ; OF DATES IN THE VITALS RESULTS
    404         N VDTI,VDTJ,VTDCNT
    405         S VTDCNT=0 ; COUNT TO BUILD ARRAY
    406         S VDTJ="" ; USED TO VISIT THE RESULTS
    407         F VDTI=0:0 D  Q:$O(VITRSLT(VDTJ))=""  ; VISIT ALL RESULTS
    408         . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
    409         . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
    410         . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
    411         S VDT(0)=VTDCNT
    412         Q
    413         ;
     1C0CVITAL ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
     2 ;;1.0;C0C;;May 19, 2009;Build 38
     3 ;Copyright 2008,2009 George Lilly, University of Minnesota and others.
     4 ;Licensed under the terms of the GNU General Public License.
     5 ;See attached copy of the License.
     6 ;
     7 ;This program is free software; you can redistribute it and/or modify
     8 ;it under the terms of the GNU General Public License as published by
     9 ;the Free Software Foundation; either version 2 of the License, or
     10 ;(at your option) any later version.
     11 ;
     12 ;This program is distributed in the hope that it will be useful,
     13 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ;GNU General Public License for more details.
     16 ;
     17 ;You should have received a copy of the GNU General Public License along
     18 ;with this program; if not, write to the Free Software Foundation, Inc.,
     19 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     20 ;
     21 W "NO ENTRY FROM TOP",!
     22 Q
     23 ;
     24EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
     25 ;
     26 ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
     27 ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
     28 ;
     29 N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
     30 S C0CVLMT=$$GET^C0CPARMS("VITLIMIT") ; GET THE LIMIT PARM
     31 S C0CVSTRT=$$GET^C0CPARMS("VITSTART") ; GET START PARM
     32 D DT^DILF(,C0CVLMT,.C0CEDT) ;
     33 D DT^DILF(,C0CVSTRT,.C0CSDT) ;
     34 ;D DT^DILF(,C0CVLMT,.C0CSDT) ; GPL TESTING
     35 ;D DT^DILF(,C0CVSTRT,.C0CEDT) ;
     36 W "VITALS START: ",C0CVSTRT," LIMIT: ",C0CVLMT,!
     37 I $$RPMS^C0CUTIL() D VITRPMS QUIT
     38 I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VITVISTA QUIT
     39 ;I $$SYSNAME^C0CSYS()="RPMS" D VITRPMS
     40 ;E  D VITVISTA
     41 Q
     42 ;
     43VITVISTA ; EXTRACT VITALS FROM VISTA INTO PROVIDED XML TEMPLATE
     44 D FASTVIT^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT) ; GPL THIS ONE WORKS FOR AT
     45 ; LEAST ONE SET OF VITALS - TO DO, CALL IT REPETIVELY TO GET EARLIER VITALS
     46 ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT)
     47 ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CSDT,C0CEDT)
     48 ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CVSTRT,C0CVLMT) ; GPL LET GMR HANDLE THE DATES
     49 I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
     50 I $P(VITRSLT(1),U,2)="No vitals found." D  Q  ; NULL RESULT FROM RPC
     51 . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
     52 . S @VITOUTXML@(0)=0
     53 I $P(VITRSLT(1),U,2)="No vitals found." Q  ; QUIT
     54 ; ZWR RPCRSLT
     55 S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
     56 S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
     57 K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
     58 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
     59 D VITDVISTA(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
     60 I DEBUG ZWR VDATES ;DEBUG
     61 S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
     62 ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
     63 S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
     64 F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
     65 . I $D(VITRSLT(VSORT(J))) D
     66 . . S VITVMAP=$NA(@VITTVMAP@(J))
     67 . . K @VITVMAP
     68 . . I DEBUG W "VMAP= ",VITVMAP,!
     69 . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
     70 . . I DEBUG W "VITAL ",VSORT(J),!
     71 . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
     72 . . I DEBUG W $P(VITPTMP,U,4),!
     73 . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
     74        . . ;B  ;gpl
     75        . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
     76        . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D  ;
     77        . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1"
     78 . . I $P(VITPTMP,U,2)="HT" D
     79 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     80 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     81 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
     82 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     83 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     84 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     85 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
     86 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
     87 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     88 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     89 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     90 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     91 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
     92 . . E  I $P(VITPTMP,U,2)="WT" D
     93 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     94 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     95 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
     96 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     97 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     98 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     99 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
     100 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
     101 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     102 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     103 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     104 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     105 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
     106 . . E  I $P(VITPTMP,U,2)="BP" D
     107 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     108 . . . ;S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     109 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
     110 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     111 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     112 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     113 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
     114 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
     115 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     116 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     117 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     118 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     119 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     120 . . E  I $P(VITPTMP,U,2)="T" D
     121 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     122 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     123 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
     124 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     125 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     126 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     127 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
     128 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
     129 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     130 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     131 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     132 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     133 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
     134 . . E  I $P(VITPTMP,U,2)="R" D
     135 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     136 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     137 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
     138 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     139 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     140 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     141 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
     142 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
     143 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     144 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     145 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     146 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     147 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     148 . . E  I $P(VITPTMP,U,2)="P" D
     149 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     150 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     151 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
     152 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     153 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     154 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     155 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
     156 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
     157 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     158 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     159 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     160 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     161 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     162 . . E  I $P(VITPTMP,U,2)="PN" D
     163 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     164 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     165 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
     166 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     167 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     168 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     169 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
     170 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
     171 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     172 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     173 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     174 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     175 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     176 . . E  I $P(VITPTMP,U,2)="BMI" D
     177 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     178 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     179 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
     180 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     181 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     182 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     183 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
     184 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="60621009"
     185 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     186 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     187 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
     188 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     189 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
     190 . . E  D
     191 . . . ;W "IN VITAL:  OTHER",!
     192 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     193 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     194 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
     195 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     196 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     197 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
     198 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
     199 . . . ;S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
     200 . . . ;S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
     201 . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     202 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
     203 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
     204 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
     205        . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D  ;
     206        . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1" ;
     207 . . S VITARYTMP=$NA(@VITTARYTMP@(J))
     208 . . K @VITARYTMP
     209 . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
     210 . . I J=1 D  ; FIRST ONE IS JUST A COPY
     211 . . . ; W "FIRST ONE",!
     212 . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
     213 . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
     214 . . I J>1 D  ; AFTER THE FIRST, INSERT INNER XML
     215 . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
     216 ; ZWR ^TMP($J,"VITALS",*)
     217 ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
     218 I DEBUG D PARY^C0CXPATH(VITOUTXML)
     219 N VITTMP,I
     220 D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
     221 I VITTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
     222 . W "VITALS MISSING ",!
     223 . F I=1:1:VITTMP(0) W VITTMP(I),!
     224 Q
     225 ;
     226VITRPMS ; EXTRACT VITALS FROM RPMS INTO PROVIDED XML TEMPLATE
     227 ; RPMS VITAL RPC ONLY RETURNS LATEST VITAL IN SPECIFIED DATE RANGE NOT ALL VITALS IN DATE RANGE
     228 ; WE NEED TO SETUP THE VARIABLES THE INTERNAL CALL NEEDS TO BYPASS A HARD CODE OF ONE VITAL FOR DATE RANGE
     229 N END,START,DATA
     230 D DT^DILF("",C0CVLMT,.END)
     231 D DT^DILF("",C0CVSTRT,.START)
     232 ; RPC OUTPUT FORMAT:
     233 ; vfile ien^vital name^vital abbr^date/time taken(FM FORMAT)^value+units (US & metric)
     234 D QUERY^BEHOVM("LISTX") ; RUN QUERY VITALS CALL
     235 I '$D(^TMP("CIAVMRPC",$J)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
     236 ;ZW ^TMP("CIAVMRPC",$J)
     237 S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
     238 S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
     239 K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
     240 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
     241 D VITDRPMS(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
     242 S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
     243 ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
     244 S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
     245 F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
     246 . I $D(^TMP("CIAVMRPC",$J,0,(VSORT(J)))) D
     247 . . S VITVMAP=$NA(@VITTVMAP@(J))
     248 . . K @VITVMAP
     249 . . I DEBUG W "VMAP= ",VITVMAP,!
     250 . . S VITPTMP=^TMP("CIAVMRPC",$J,0,(VSORT(J))) ; DATE SORTED VITAL FROM RETURN ARRAY
     251 . . I DEBUG W "VITAL ",VSORT(J),!
     252 . . I DEBUG W ^TMP("CIAVMRPC",$J,0,(VSORT(J)))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
     253 . . I DEBUG W $P(VITPTMP,U,4),!
     254 . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
     255 . . I $P(VITPTMP,U,3)="HT" D
     256 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     257 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     258 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
     259 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     260 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     261 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     262 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
     263 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
     264 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     265 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     266 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     267 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     268 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     269 . . E  I $P(VITPTMP,U,3)="WT" D
     270 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     271 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     272 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
     273 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     274 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     275 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     276 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
     277 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
     278 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     279 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     280 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     281 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     282 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     283 . . E  I $P(VITPTMP,U,3)="BP" D
     284 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     285 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     286 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
     287 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     288 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     289 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     290 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
     291 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
     292 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     293 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     294 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     295 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     296 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     297 . . E  I $P(VITPTMP,U,3)="TMP" D
     298 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     299 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     300 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
     301 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     302 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     303 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     304 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
     305 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
     306 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     307 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     308 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     309 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     310 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     311 . . E  I $P(VITPTMP,U,3)="RS" D
     312 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     313 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     314 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
     315 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     316 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     317 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     318 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
     319 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
     320 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     321 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     322 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     323 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     324 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     325 . . E  I $P(VITPTMP,U,3)="PU" D
     326 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     327 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     328 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
     329 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     330 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     331 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     332 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
     333 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
     334 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     335 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     336 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     337 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     338 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     339 . . E  I $P(VITPTMP,U,3)="PA" D
     340 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     341 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     342 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
     343 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     344 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     345 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     346 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
     347 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
     348 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
     349 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     350 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     351 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     352 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     353 . . E  D
     354 . . . ;W "IN VITAL:  OTHER",!
     355 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
     356 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
     357 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
     358 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
     359 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
     360 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
     361 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
     362 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
     363 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
     364 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
     365 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
     366 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
     367 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
     368 . . S VITARYTMP=$NA(@VITTARYTMP@(J))
     369 . . K @VITARYTMP
     370 . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
     371 . . I J=1 D  ; FIRST ONE IS JUST A COPY
     372 . . . ; W "FIRST ONE",!
     373 . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
     374 . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
     375 . . I J>1 D  ; AFTER THE FIRST, INSERT INNER XML
     376 . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
     377 ; ZWR ^TMP($J,"VITALS",*)
     378 ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
     379 I DEBUG D PARY^C0CXPATH(VITOUTXML)
     380 N VITTMP,I
     381 D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
     382 I VITTMP(0)>0 D  ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
     383 . W "VITALS MISSING ",!
     384 . F I=1:1:VITTMP(0) W VITTMP(I),!
     385 K ^TMP("CIAVMRPC",$J)
     386 Q
     387 ;
     388VITDRPMS(VDT) ; RUN DATE SORTING ALGORITHM FOR RPMS
     389 ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
     390 ; OF DATES IN THE VITALS RESULTS
     391 N VDTI,VDTJ,VTDCNT
     392 S VTDCNT=0 ; COUNT TO BUILD ARRAY
     393 S VDTJ="" ; USED TO VISIT THE RESULTS
     394 F VDTI=0:0 D  Q:$O(^TMP("CIAVMRPC",$J,0,VDTJ))=""  ; VISIT ALL RESULTS
     395 . S VDTJ=$O(^TMP("CIAVMRPC",$J,0,VDTJ)) ; NEXT RESULT
     396 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
     397 . S VDT(VTDCNT)=$P(^TMP("CIAVMRPC",$J,0,VDTJ),U,4) ; PULL OUT THE DATE
     398 S VDT(0)=VTDCNT
     399 Q
     400 ;
     401VITDVISTA(VDT) ; RUN DATE SORTING ALGORITHM FOR VISTA
     402 ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
     403 ; OF DATES IN THE VITALS RESULTS
     404 N VDTI,VDTJ,VTDCNT
     405 S VTDCNT=0 ; COUNT TO BUILD ARRAY
     406 S VDTJ="" ; USED TO VISIT THE RESULTS
     407 F VDTI=0:0 D  Q:$O(VITRSLT(VDTJ))=""  ; VISIT ALL RESULTS
     408 . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
     409 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
     410 . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
     411 S VDT(0)=VTDCNT
     412 Q
     413 ;
Note: See TracChangeset for help on using the changeset viewer.