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