Changeset 153


Ignore:
Timestamp:
Sep 18, 2008, 9:10:25 PM (16 years ago)
Author:
chrisu
Message:

finally something that works for me ;) wip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/GPLALERT.m

    r152 r153  
    2323EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE
    2424          ;
    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
    2726          ;
    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*
    3731          . S @ALTOUTXML@(0)=0
    38           . ; QUESTION - SHOULD !KNOWN OR !ASSESSMENT BE DIFFERENT INDICATORS
    39           . I DEBUG W !,"NO KNOWN ALLERGIES or NO ALLERGY ASSESSMENT"
    4032
    4133          ; 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
    4663
    47           X $ZINT
     64          Q
    4865
    49           M @ALTOUTXML=@ALTXML ; JUST COPY THE TEMPLATE FOR TESTING ..GPL
    50           Q ; QUIT
    51 
    52           ; BELOW CODE REMAINS FOR MY KNOWLEDGE AS TEMPLATE
    53 
    54           N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
    55           D VITALS^ORQQVI(.VITRSLT,DFN,"","")
    56           I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q  ; RETURN NOT FOUND AND QUIT
    57           I $P(VITRSLT(1),U,2)="No vitals found." D  Q  ; NULL RESULT FROM RPC
    58           . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
    59           . S @VITOUTXML@(0)=0
    60           I $P(VITRSLT(1),U,2)="No vitals found." Q  ; QUIT
    61           ; ZWR RPCRSLT
    62           S VITTVMAP=$NA(^TMP("GPLCCR",$J,"VITALS"))
    63           S VITTARYTMP=$NA(^TMP("GPLCCR",$J,"VITALARYTMP"))
    64           K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
    65           N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
    66           D VITDATES(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
    67           ; I DEBUG ZWR VDATES ;DEBUG
    68           S VCNT=$$SORTDT^CCRUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
    69           ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
    70           S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
    71           F J=1:1:VCNT  D  ; FOR EACH VITAL IN THE LIST
    72           . I $D(VITRSLT(VSORT(J))) D
    73           . . S VITVMAP=$NA(@VITTVMAP@(J))
    74           . . K @VITVMAP
    75           . . I DEBUG W "VMAP= ",VITVMAP,!
    76           . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
    77           . . 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 OBJID
    81           . . I $P(VITPTMP,U,2)="HT" D
    82           . . . 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"_J
    87           . . . 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" D
    96           . . . 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"_J
    101           . . . 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" D
    110           . . . 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"_J
    115           . . . 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" D
    124           . . . 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"_J
    129           . . . 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" D
    138           . . . 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"_J
    143           . . . 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" D
    152           . . . 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"_J
    157           . . . 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" D
    166           . . . 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"_J
    171           . . . 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  D
    180           . . . ;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"_J
    186           . . . 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 @VITARYTMP
    196           . . D MAP^GPLXPATH(VITXML,VITVMAP,VITARYTMP)
    197           . . I J=1 D  ; FIRST ONE IS JUST A COPY
    198           . . . ; 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 XML
    202           . . . D INSINNER^GPLXPATH(VITOUTXML,VITARYTMP)
    203           ; ZWR ^TMP($J,"VITALS",*)
    204           ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
    205           I DEBUG D PARY^GPLXPATH(VITOUTXML)
    206           N VITTMP,I
    207           D MISSING^GPLXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
    208           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           Q
    212           ;
    213 VITDATES(VDT) ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
    214          ; OF DATES IN THE VITALS RESULTS
    215          N VDTI,VDTJ,VTDCNT
    216          S VTDCNT=0 ; COUNT TO BUILD ARRAY
    217          S VDTJ="" ; USED TO VISIT THE RESULTS
    218          F VDTI=0:0 D  Q:$O(VITRSLT(VDTJ))=""  ; VISIT ALL RESULTS
    219          . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
    220          . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
    221          . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
    222          Q
    223          ;
Note: See TracChangeset for help on using the changeset viewer.