finally something that works for me ;) wip

This commit is contained in:
chrisu 2008-09-19 01:10:25 +00:00
parent 0cd1055eb2
commit d1d5b035c2
1 changed files with 35 additions and 193 deletions

View File

@ -22,202 +22,44 @@ GPLALERT ; CCDCCR/CKU - CCR/CCD PROCESSING FOR ALERTS ; 09/11/08
;
EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE
;
; ALTXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
; ALTXML AND ALTOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
;
; ^^ IVITXML NOT FOUND - MUST LEARN WHAT THIS IS
;
; RPC ALERTS **NEED** TO BE VERIFIED
; ORQQAL LIST
; ORQQPP LIST
;
N ALTRSLT,ALTVMAP
D LIST^ORQQAL(.ALTRSLT,DFN)
I $P(ALTRSLT(1),U,1)="" D Q ; NO ALLERGIES FOUND
; GET ADVERSE REACTIONS AND ALLERGIES
N GMRA,GMRAL S GMRA="0^0^111"
D EN1^GMRADPT
I $G(GMRAL)'=1 D Q ; NO ALLERGIES FOUND THUS *QUIT*
. S @ALTOUTXML@(0)=0
. ; QUESTION - SHOULD !KNOWN OR !ASSESSMENT BE DIFFERENT INDICATORS
. I DEBUG W !,"NO KNOWN ALLERGIES or NO ALLERGY ASSESSMENT"
; DEFINE MAPPING
; ...
;
;
; D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)
N ALTTVMAP,ALTVMAP,ALTTARYTMP,ALTARYTMP
S ALTTVMAP=$NA(^TMP("GPLALERT",$J,"ALERTS"))
S ALTTARYTMP=$NA(^TMP("GPLALERT",$J,"ALERTSARYTMP"))
K @ALTTVMAP,@ALTTARYTMP
N ALTTMP,ALTCNT S ALTTMP=$NA(GMRAL),ALTCNT=1
F S ALTTMP=$Q(@ALTTMP) Q:ALTTMP="" D
. I $QS(ALTTMP,2)="S" W !,"S FOUND",! Q
. S ALTVMAP=$NA(@ALTTVMAP@(ALTCNT))
. K @ALTVMAP
. S @ALTVMAP@("ALERTOBJECTID")="ALERT"_ALTCNT
. N ALERTDESCRIPTIONTEXT S ALERTDESCRIPTIONTEXT="Patient has an " ; X $ZINT H 5
. S ALERTDESCRIPTIONTEXT=ALERTDESCRIPTIONTEXT_$S($P(@ALTTMP,U,4)=1:"ADVERSE",$P(@ALTTMP,U,5)=1:"ALLERGIC",1:"UNKNOWN")
. S ALERTDESCRIPTIONTEXT=ALERTDESCRIPTIONTEXT_" reaction to "_$P(@ALTTMP,U,2)_"."
. S @ALTVMAP@("ALERTDESCRIPTIONTEXT")=ALERTDESCRIPTIONTEXT
. S @ALTVMAP@("ALERTCODEVALUE")="ALERT CODE VALUE"
. S @ALTVMAP@("ALERTCODESYSTEM")="ALERT CODE SYSTEM"
. S @ALTVMAP@("ALERTSTATUSTEXT")="ALERT STATUS TEXT"
. S @ALTVMAP@("ALERTSOURCEID")="ALERT SOURCE ID"
. S @ALTVMAP@("ALERTAGENTPRODUCTOBJECTID")="ALERT AGENT PRODUCT OBJECT ID"
. S @ALTVMAP@("ALERTAGENTPRODUCTSOURCEID")="A"
. S @ALTVMAP@("ALERTAGENTPRODUCTNAMETEXT")="B"
. S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")="C"
. S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")="D"
. S ALTARYTMP=$NA(@ALTTARYTMP@(ALTCNT))
. K @ALTARYTMP
. D MAP^GPLXPATH(ALTXML,ALTVMAP,ALTARYTMP)
. I ALTCNT=1 D CP^GPLXPATH(ALTARYTMP,ALTOUTXML)
. I ALTCNT>1 D INSINNER^GPLXPATH(ALTOUTXML,ALTARYTMP)
. S ALTCNT=ALTCNT+1
X $ZINT
M @ALTOUTXML=@ALTXML ; JUST COPY THE TEMPLATE FOR TESTING ..GPL
Q ; QUIT
; BELOW CODE REMAINS FOR MY KNOWLEDGE AS TEMPLATE
N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
D VITALS^ORQQVI(.VITRSLT,DFN,"","")
I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC
. I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
. S @VITOUTXML@(0)=0
I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT
; ZWR RPCRSLT
S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
D VITDATES(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
; I DEBUG ZWR VDATES ;DEBUG
S VCNT=$$SORTDT^CCRUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
. I $D(VITRSLT(VSORT(J))) D
. . S VITVMAP=$NA(@VITTVMAP@(J))
. . K @VITVMAP
. . I DEBUG W "VMAP= ",VITVMAP,!
. . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
. . I DEBUG W "VITAL ",VSORT(J),!
. . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^CCRUTIL($P(VITPTMP,U,4),"DT"),!
. . I DEBUG W $P(VITPTMP,U,4),!
. . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
. . 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)
. . . I DEBUG 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
I DEBUG 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
;
VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
; OF DATES IN THE VITALS RESULTS
N VDTI,VDTJ,VTDCNT
S VTDCNT=0 ; COUNT TO BUILD ARRAY
S VDTJ="" ; USED TO VISIT THE RESULTS
F VDTI=0:0 D Q:$O(VITRSLT(VDTJ))="" ; VISIT ALL RESULTS
. S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
. S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
. S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
Q
;