GPLVITALS ; CCDCCR/CJE - CCR/CCD PROCESSING FOR VITALS ; 07/16/08 ;;0.1;CCDCCR;;JUL 16,2008; ;Copyright 2008 WorldVistA. Licensed under the terms of the GNU ;General Public License See attached copy of the License. ; ;This program is free software; you can redistribute it and/or modify ;it under the terms of the GNU General Public License as published by ;the Free Software Foundation; either version 2 of the License, or ;(at your option) any later version. ; ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ; ;You should have received a copy of the GNU General Public License along ;with this program; if not, write to the Free Software Foundation, Inc., ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ; W "NO ENTRY FROM TOP",! Q ; EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE ; ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED ; IVITXML WILL CONTAIN ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE ; N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF D VITALS^ORQQVI(.VITRSLT,DFN,"","") I '$D(VITRSLT(1)) W "ERROR RUNNINIG VITALS RPC",! Q ; ZWR RPCRSLT S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS")) S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP")) F J=1:1:VITRSLT(1) D ; FOR EACH VITAL IN THE LIST . I $D(VITRSLT(J)) D . . S VITVMAP=$NA(@VITTVMAP@(J)) . . K @VITVMAP . . I DEBUG W "VMAP= ",VITVMAP,! . . S VITPTMP=VITRSLT(J) ; PULL OUT VITAL FROM RPC RETURN ARRAY . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID FOR VITAL . . I $P(VITPTMP,U,2)="HT" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="248327008" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in" . . E I $P(VITPTMP,U,2)="WT" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="107647005" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs" . . E I $P(VITPTMP,U,2)="BP" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="392570002" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . E I $P(VITPTMP,U,2)="T" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="309646008" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F" . . E I $P(VITPTMP,U,2)="R" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366147009" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . E I $P(VITPTMP,U,2)="P" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366199006" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . E I $P(VITPTMP,U,2)="PN" D . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="22253000" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . E D . . . ;W "IN VITAL: OTHER",! . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER" . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="" . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="" . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN" . . S VITARYTMP=$NA(@VITTARYTMP@(J)) . . K @VITARYTMP . . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP) . . I J=1 D ; FIRST ONE IS JUST A COPY . . . ; W "FIRST ONE",! . . . D CP^GPLXPATH(VITARYTMP,VITOUTXML) . . . W "VITOUTXML ",VITOUTXML,! . . I J>1 D ; AFTER THE FIRST, INSERT INNER XML . . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP) ; ZWR ^TMP($J,"VITALS",*) ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS D PARY^GPLXPATH(VITOUTXML) N VITTMP,I D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ . W "VITALS MISSING ",! . F I=1:1:VITTMP(0) W VITTMP(I),! Q ;