Changeset 153
- Timestamp:
- Sep 18, 2008, 9:10:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/GPLALERT.m
r152 r153 23 23 EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE 24 24 ; 25 ; ALTXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED 26 ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE 25 ; ALTXML AND ALTOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED 27 26 ; 28 ; ^^ IVITXML NOT FOUND - MUST LEARN WHAT THIS IS 29 ; 30 ; RPC ALERTS **NEED** TO BE VERIFIED 31 ; ORQQAL LIST 32 ; ORQQPP LIST 33 ; 34 N ALTRSLT,ALTVMAP 35 D LIST^ORQQAL(.ALTRSLT,DFN) 36 I $P(ALTRSLT(1),U,1)="" D Q ; NO ALLERGIES FOUND 27 ; GET ADVERSE REACTIONS AND ALLERGIES 28 N GMRA,GMRAL S GMRA="0^0^111" 29 D EN1^GMRADPT 30 I $G(GMRAL)'=1 D Q ; NO ALLERGIES FOUND THUS *QUIT* 37 31 . S @ALTOUTXML@(0)=0 38 . ; QUESTION - SHOULD !KNOWN OR !ASSESSMENT BE DIFFERENT INDICATORS39 . I DEBUG W !,"NO KNOWN ALLERGIES or NO ALLERGY ASSESSMENT"40 32 41 33 ; DEFINE MAPPING 42 ; ... 43 ; 44 ; 45 ; D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP) 34 N ALTTVMAP,ALTVMAP,ALTTARYTMP,ALTARYTMP 35 S ALTTVMAP=$NA(^TMP("GPLALERT",$J,"ALERTS")) 36 S ALTTARYTMP=$NA(^TMP("GPLALERT",$J,"ALERTSARYTMP")) 37 K @ALTTVMAP,@ALTTARYTMP 38 N ALTTMP,ALTCNT S ALTTMP=$NA(GMRAL),ALTCNT=1 39 F S ALTTMP=$Q(@ALTTMP) Q:ALTTMP="" D 40 . I $QS(ALTTMP,2)="S" W !,"S FOUND",! Q 41 . S ALTVMAP=$NA(@ALTTVMAP@(ALTCNT)) 42 . K @ALTVMAP 43 . S @ALTVMAP@("ALERTOBJECTID")="ALERT"_ALTCNT 44 . N ALERTDESCRIPTIONTEXT S ALERTDESCRIPTIONTEXT="Patient has an " ; X $ZINT H 5 45 . S ALERTDESCRIPTIONTEXT=ALERTDESCRIPTIONTEXT_$S($P(@ALTTMP,U,4)=1:"ADVERSE",$P(@ALTTMP,U,5)=1:"ALLERGIC",1:"UNKNOWN") 46 . S ALERTDESCRIPTIONTEXT=ALERTDESCRIPTIONTEXT_" reaction to "_$P(@ALTTMP,U,2)_"." 47 . S @ALTVMAP@("ALERTDESCRIPTIONTEXT")=ALERTDESCRIPTIONTEXT 48 . S @ALTVMAP@("ALERTCODEVALUE")="ALERT CODE VALUE" 49 . S @ALTVMAP@("ALERTCODESYSTEM")="ALERT CODE SYSTEM" 50 . S @ALTVMAP@("ALERTSTATUSTEXT")="ALERT STATUS TEXT" 51 . S @ALTVMAP@("ALERTSOURCEID")="ALERT SOURCE ID" 52 . S @ALTVMAP@("ALERTAGENTPRODUCTOBJECTID")="ALERT AGENT PRODUCT OBJECT ID" 53 . S @ALTVMAP@("ALERTAGENTPRODUCTSOURCEID")="A" 54 . S @ALTVMAP@("ALERTAGENTPRODUCTNAMETEXT")="B" 55 . S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")="C" 56 . S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")="D" 57 . S ALTARYTMP=$NA(@ALTTARYTMP@(ALTCNT)) 58 . K @ALTARYTMP 59 . D MAP^GPLXPATH(ALTXML,ALTVMAP,ALTARYTMP) 60 . I ALTCNT=1 D CP^GPLXPATH(ALTARYTMP,ALTOUTXML) 61 . I ALTCNT>1 D INSINNER^GPLXPATH(ALTOUTXML,ALTARYTMP) 62 . S ALTCNT=ALTCNT+1 46 63 47 X $ZINT64 Q 48 65 49 M @ALTOUTXML=@ALTXML ; JUST COPY THE TEMPLATE FOR TESTING ..GPL50 Q ; QUIT51 52 ; BELOW CODE REMAINS FOR MY KNOWLEDGE AS TEMPLATE53 54 N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR55 D VITALS^ORQQVI(.VITRSLT,DFN,"","")56 I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT57 I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC58 . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!59 . S @VITOUTXML@(0)=060 I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT61 ; ZWR RPCRSLT62 S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))63 S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))64 K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES65 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX66 D VITDATES(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY67 ; I DEBUG ZWR VDATES ;DEBUG68 S VCNT=$$SORTDT^CCRUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE69 ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY70 S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS71 F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST72 . I $D(VITRSLT(VSORT(J))) D73 . . S VITVMAP=$NA(@VITTVMAP@(J))74 . . K @VITVMAP75 . . I DEBUG W "VMAP= ",VITVMAP,!76 . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY77 . . I DEBUG W "VITAL ",VSORT(J),!78 . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT"),!79 . . I DEBUG W $P(VITPTMP,U,4),!80 . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID81 . . I $P(VITPTMP,U,2)="HT" D82 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"83 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")84 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"85 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"86 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J87 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"88 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"89 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="248327008"90 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"91 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""92 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)93 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)94 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"95 . . E I $P(VITPTMP,U,2)="WT" D96 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"97 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")98 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"99 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"100 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J101 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"102 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"103 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="107647005"104 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"105 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""106 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)107 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)108 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"109 . . E I $P(VITPTMP,U,2)="BP" D110 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"111 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")112 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"113 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"114 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J115 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"116 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"117 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="392570002"118 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"119 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""120 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)121 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)122 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""123 . . E I $P(VITPTMP,U,2)="T" D124 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"125 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")126 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"127 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"128 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J129 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"130 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"131 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="309646008"132 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"133 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""134 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)135 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)136 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"137 . . E I $P(VITPTMP,U,2)="R" D138 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"139 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")140 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"141 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"142 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J143 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"144 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"145 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366147009"146 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"147 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""148 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)149 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)150 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""151 . . E I $P(VITPTMP,U,2)="P" D152 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"153 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")154 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"155 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"156 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J157 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"158 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"159 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="366199006"160 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"161 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""162 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)163 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)164 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""165 . . E I $P(VITPTMP,U,2)="PN" D166 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"167 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")168 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"169 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"170 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J171 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"172 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"173 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")="22253000"174 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")="SNOMED"175 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""176 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)177 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)178 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""179 . . E D180 . . . ;W "IN VITAL: OTHER",!181 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"182 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT")183 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"184 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"185 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J186 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"187 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"188 . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODEVALUE")=""189 . . . ;S @VITVMAP@("VITALSIGNSDESCRIPTIONCODINGSYSTEM")=""190 . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""191 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)192 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)193 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"194 . . S VITARYTMP=$NA(@VITTARYTMP@(J))195 . . K @VITARYTMP196 . . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)197 . . I J=1 D ; FIRST ONE IS JUST A COPY198 . . . ; W "FIRST ONE",!199 . . . D CP^GPLXPATH(VITARYTMP,VITOUTXML)200 . . . I DEBUG W "VITOUTXML ",VITOUTXML,!201 . . I J>1 D ; AFTER THE FIRST, INSERT INNER XML202 . . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP)203 ; ZWR ^TMP($J,"VITALS",*)204 ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS205 I DEBUG D PARY^GPLXPATH(VITOUTXML)206 N VITTMP,I207 D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS208 I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@209 . W "VITALS MISSING ",!210 . F I=1:1:VITTMP(0) W VITTMP(I),!211 Q212 ;213 VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY214 ; OF DATES IN THE VITALS RESULTS215 N VDTI,VDTJ,VTDCNT216 S VTDCNT=0 ; COUNT TO BUILD ARRAY217 S VDTJ="" ; USED TO VISIT THE RESULTS218 F VDTI=0:0 D Q:$O(VITRSLT(VDTJ))="" ; VISIT ALL RESULTS219 . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT220 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER221 . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE222 Q223 ;
Note:
See TracChangeset
for help on using the changeset viewer.