Ignore:
Timestamp:
Dec 4, 2009, 12:11:15 AM (15 years ago)
Author:
George Lilly
Message:

revised back to 6/30/08 version

Location:
WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM
Files:
121 edited

Legend:

Unmodified
Added
Removed
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRM7M1.m

    r613 r623  
    1 PXRM7M1 ;SLC/JVS HL7 PUT MESSAGE IN 772 FILE; 06/01/2007  15:26
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;This routine will use the HL7 Package commands to gather the message
    4         ;into the file 772
    5         Q
    6 EN(ID)  ;Entry Point
    7         ;
    8         S (PROTIEN,PXRM7,PXRM7R,PXRM77,PXRM7ID)=""
    9         S PROTIEN=$O(^ORD(101,"B","PXRM7 RECO SERVER",PROTIEN))
    10         S HL("EID")=PROTIEN
    11         D INIT^HLFNC2(PROTIEN,.PXRM7)
    12         S PXRM7("PID")="HI^D"
    13         S HLA("HLS",1)=PXRM77
    14         D GENERATE^HLMA(HL("EID"),"GM",1,.PXRM7R,.PXRM7ID,)
    15         D STORE^PXRM7API
    16         S ID=ZMID
    17         Q
     1PXRM7M1 ;SLC/JVS HL7 PUT MESSAGE IN 772 FILE; 03/21/2002 ;4/11/02  15:26
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;This routine will use the HL7 Package commands to gather the message
     4 ;into the file 772
     5 Q
     6EN(ID) ;Entry Point
     7 ;
     8 S (PROTIEN,PXRM7,PXRM7R,PXRM77,PXRM7ID)=""
     9 S PROTIEN=$O(^ORD(101,"B","PXRM7 RECO SERVER",PROTIEN))
     10 S HL("EID")=PROTIEN
     11 D INIT^HLFNC2(PROTIEN,.PXRM7)
     12 S PXRM7("PID")="HI^D"
     13 S HLA("HLS",1)=PXRM77
     14 D GENERATE^HLMA(HL("EID"),"GM",1,.PXRM7R,.PXRM7ID,)
     15 S ID=ZMID
     16 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRM7XT.m

    r613 r623  
    1 PXRM7XT ;SLC/JVS HL7 EXTRACT FROM FILE; 06/01/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;This is the beginning of the extraction from the extract file
    4         ;
    5         ;VARIABLE LIST
    6         ;IEN = IEN OF ENTRY IN EXTRACT FILE 810.3
    7         Q
    8 SPLIT   ;SPLIT MESSAGES
    9         ;
    10         N ORC2
    11         I LINE>100 D
    12         .S ORCCNT=ORCCNT+1
    13         .D EN^PXRM7M1(.ID)
    14         .K ^TMP("HLS",$J)
    15         .S ORC2=$G(^TMP("PXRM7HLORC",$J))
    16         .S $P(ORC2,"|",3)="P"_ORCCNT,ORC=ORC2
    17         .S LINE=2
    18         .I $D(SEE) W !,ORC
    19         .S ^TMP("HLS",$J,1)=ORC
    20         Q
    21         ;
    22 EXTRACT(IEN,SEE,ID,MODE)        ;
    23         N ORCCNT
    24         K ERROR,LINE
    25         S ORCCNT=1  ;Count of ORC segments or number of messages created
    26         S LINE=1 ;Line count for the ^TMP("HL7",$J,LINE) global variable
    27         ;-Verify Values
    28         I '$D(^PXRMXT(810.3,IEN)) S ERROR(1)="No Such IEN in file 810.3 "_IEN
    29         I $D(ERROR) D  Q
    30         .I $D(SEE)=1
    31         ;-Extracting Value of Nodes in file
    32         I $D(ERROR) Q
    33         D GETS^DIQ(810.3,IEN,"**","EI","^TMP(""PXRM7"",$J)")
    34         D ORCSEG
    35         ;******Add NTE segment to end of message *******
    36         ;******change 3rd piece of ORC segement to L (last)****
    37         S NTE="NTE||"_LAST_"||"
    38         S ^TMP("HLS",$J,LINE)=NTE,LINE=LINE+1
    39         I SEE=1 W !,NTE
    40         K NTE,LAST
    41         S ORC=$G(^TMP("HLS",$J,1)),$P(ORC,"|",3)="F"_ORCCNT,^TMP("HLS",$J,1)=ORC
    42         ;***********************************************
    43         ;*******TURN ON BELOW TO TRANSMIT TO AUSTIN *****
    44         D EN^PXRM7M1(.ID)
    45         ;***********************************************
    46         K ^TMP("PXRM7",$J)
    47         K ^TMP("HLS",$J)
    48         K ^TMP("PXRM7HLORC",$J)
    49         ;********KILL LEFT OVER ARRAYS AND VARIABLES*****
    50         K HL("EID"),HLA("HLS"),PROTIEN,PXRM7,PXRM77,PXRM7ID,PXRM7R,ZMID
    51         K DA,DISYS,DISYS,EO,HL("EIDS"),HLECH,HLFS,HLN,HLQ,HLSAN,HLX
    52         K IENIEN,IENOBR,IENX,IENY,IENZ,L,LINE,NEXT,QTI,RFS,SEQ
    53         K STATION,USI
    54         ;**************************************************
    55         Q
    56 ORCSEG  ;CREATE ORC SEGMENTS
    57         ;ORDERED IN ORDER OF APPEARANCE IN SEGMENT
    58         ;QTI=QUANTITY AND TIMING
    59         ;EO=ENTERING ORGANIZATION
    60         ;--Below adds extra line feed in front of the message. --
    61         ;---------------------------------------------------
    62         S IENY=IEN_","
    63         ;---------------------------------------------
    64         ;0 PLACER ORDER NUMBER      ORC.2.1
    65         S $P(ORC,"|",3)="P1"
    66         ;---------------------------------------------
    67         ;1 REPORTING PERIOD         ORC.7.1.1
    68         S QTI(1)=$G(^TMP("PXRM7",$J,810.3,IENY,3,"E"))
    69         S $P(QTI,"~",1)=QTI(1)
    70         ;---------------------------------------------
    71         ;2 QUARTER                  ORC.7.3
    72         S QTI(3)=$G(^TMP("PXRM7",$J,810.3,IENY,7,"E"))
    73         S $P(QTI,"~",3)=QTI(3)
    74         ;---------------------------------------------
    75         ;3 BEGINNING DATE           ORC.7.4.1
    76         S QTI(4)=$$HLDATE^HLFNC($G(^TMP("PXRM7",$J,810.3,IENY,.02,"I")),"DT")
    77         S $P(QTI,"~",4)=QTI(4)
    78         ;---------------------------------------------
    79         ;4 ENDING DATE              ORC.7.5.1
    80         S QTI(5)=$$HLDATE^HLFNC($G(^TMP("PXRM7",$J,810.3,IENY,.03,"I")),"DT")
    81         S $P(QTI,"~",5)=QTI(5)
    82         ;---------------------------------------------
    83         ;5 REPORTING YEAR           ORC.7.11.2
    84         S QTI(11)="&"_$G(^TMP("PXRM7",$J,810.3,IENY,4,"E"))
    85         S $P(QTI,"~",11)=QTI(11)
    86         ;---------------------------------------------
    87         ;6 EXTRACT DATE             ORC.9.1
    88         S $P(ORC,"|",10)=$$HLDATE^HLFNC($G(^TMP("PXRM7",$J,810.3,IENY,.06,"I")),"DT")
    89         ;---------------------------------------------
    90         ;7 NAME                     ORC.17.2
    91         S EO(2)=$G(^TMP("PXRM7",$J,810.3,IENY,.01,"E"))
    92         S $P(EO,"~",2)=EO(2)
    93         ;---------------------------------------------
    94         ;8 REPORT EXTRACT PARAMETER ORC.17.5
    95         S EO(5)=$G(^TMP("PXRM7",$J,810.3,IENY,1,"E"))
    96         S $P(EO,"~",5)=EO(5)
    97         ;---------------------------------------------
    98         ;9 REPORT EXTRACT TYPE      ORC.18.2
    99         S $P(ORC,"|",19)="~"_$G(^TMP("PXRM7",$J,810.3,IENY,2,"E"))
    100         ;---------------------------------------------
    101         ;FINISH POPULATING ORC SEGMENT
    102         S $P(ORC,"|",8)=QTI
    103         S $P(ORC,"|",18)=EO
    104         S $P(ORC,"|",1)="ORC"
    105         ;---------------------------------------------
    106         ;SET HL7 TMP ARRAY AND SHOW SEGMENT
    107         S ^TMP("HLS",$J,LINE)=ORC,LINE=LINE+1
    108         I SEE=1 W !,ORC
    109         S ^TMP("PXRM7HLORC",$J)=ORC
    110         K ORC
    111 OBRSEG  ;CREATE OBR SEGMENTS
    112         ;N IENOBR,SEQ,USI,QTI,NEXT,STATION
    113         ;USI=UNIVERSAL SERVICE ID
    114         ;RFS=REASON FOR STUDY
    115         ;
    116         S NEXT=1,LAST=0
    117         S IENOBR=0 F  S IENOBR=$O(^PXRMXT(810.3,IEN,3,IENOBR)) Q:IENOBR<1  D
    118         .S IENIEN=-1 F  S IENIEN=$O(^PXRMXT(810.3,IEN,3,IENOBR,1,IENIEN)) Q:IENIEN="B"  D  Q:IENIEN=""
    119         ..S L=$S(IENIEN=0:1,IENIEN>0:2,IENIEN="":1,1:"")
    120         ..;###---Set Sequence Number
    121         ..S IENX=IENOBR_","_IEN_","
    122         ..S IENZ=IENIEN_","_IENOBR_","_IEN_","
    123         ..S SEQ=$G(^TMP("PXRM7",$J,810.33,IENX,.01,"E"))
    124         ..S OBR(+SEQ_L)="OBR|1|||||||||||||||||||||||||||||||"
    125         ..S $P(OBR(+SEQ_L),"|",2)=NEXT,LAST=NEXT,NEXT=NEXT+1
    126         ..;--------------------------------------------------
    127         ..;10 COUNT TYPE           OBR.4.2
    128         ..;R=REMINDER COUNTS  F=FINDING COUNTS
    129         ..S USI(2)=$S(L=1:"R",L=2:"F",1:"")
    130         ..S $P(USI,"~",2)=USI(2)
    131         ..;--------------------------------------------------
    132         ..;11 REMINDER             OBR.4.5
    133         ..S USI(5)=$G(^TMP("PXRM7",$J,810.33,IENX,.02,"E"))
    134         ..S $P(USI,"~",5)=USI(5)
    135         ..;--------------------------------------------------
    136         ..;12 STATION              OBR.3.1
    137         ..S STATION=$G(^TMP("PXRM7",$J,810.33,IENX,.03,"I"))_","
    138         ..D GETS^DIQ(4,STATION,"**","E","^TMP(""PXRM7"",$J)")
    139         ..S $P(OBR(+SEQ_L),"|",4)=$G(^TMP("PXRM7",$J,4,STATION,99,"E"))
    140         ..;--------------------------------------------------
    141         ..;13 PATIENT LIST         OBR.31.2
    142         ..S RFS(2)=$G(^TMP("PXRM7",$J,810.33,IENX,.04,"E"))
    143         ..S $P(RFS,"~",2)=RFS(2)
    144         ..;--------------------------------------------------
    145         ..;19 REMINDER TERM        OBR.31.1
    146         ..S RFS(1)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.02,"E")),1:"")
    147         ..S $P(RFS,"~",1)=RFS(1)
    148         ..;--------------------------------------------------
    149         ..;20 FINDING TOTAL TYPE   OBR.31.4
    150         ..S RFS(4)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.03,"E")),1:"")
    151         ..S $P(RFS,"~",4)=RFS(4)
    152         ..;--------------------------------------------------
    153         ..;21 GROUP NAME           OBR.31.5
    154         ..S RFS(5)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.04,"E")),1:"")
    155         ..S $P(RFS,"~",5)=RFS(5)
    156         ..;--------------------------------------------------
    157         ..;22 REMINDER STATUS      OBR.4.4
    158         ..S USI(4)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.05,"I")),1:"")
    159         ..S $P(USI,"~",4)=USI(4)
    160         ..;-------------------------------------------------
    161         ..;FINISH POPULATING OBR SEGMENT
    162         ..S $P(OBR(+SEQ_L),"|",5)=USI
    163         ..S $P(OBR(+SEQ_L),"|",32)=RFS
    164         ..;-------------------------------------------------
    165         ..;---Set message in HL7 array
    166         ..;I $L($G(OBR(+SEQ_L)))=255 S OBR(+SEQ_L)=OBR(+SEQ_L)_"|||"
    167         ..S ^TMP("HLS",$J,LINE)=$G(OBR(+SEQ_L)),LINE=LINE+1
    168         ..;
    169         ..I SEE=1 W !," ",OBR(+SEQ_L)
    170         ..K OBR
    171         ..D OBXSEG
    172         ..D SPLIT
    173         ..I (L=1)&(IENIEN="") Q
    174         Q
    175 OBXSEG  ;CREATE THE OBX SEGMENTS
    176         N TERM
    177         ;OV=OBSERVATION VALUE
    178         S $P(OBX(+SEQ_L),"|",3)="MO"
    179         S $P(OBX(+SEQ_L),"|",1)="OBX"
    180         ;---------------------------------------------------
    181         ;###---SET SEQUENCE NUMBER
    182         S $P(OBX(+SEQ_L),"|",2)=1
    183         ;---------------------------------------------------
    184         ;14 TOTAL PATIENTS EVALUATED - REMINDER      OBX.5.1
    185         I L=1 D
    186         .S TERM="TOTAL PATIENTS EVALUATED"
    187         .S OV(1)=$G(^TMP("PXRM7",$J,810.33,IENX,2,"E"))_"~"_TERM
    188         .S $P(OV,"^",1)=OV(1)
    189         ;---------------------------------------------------
    190         ;15 TOTAL PATIENTS APPLICABLE - REMINDER     OBX.5.2
    191         I L=1 D
    192         .S TERM="TOTAL PATIENTS APPLICABLE"
    193         .S OV(2)=$G(^TMP("PXRM7",$J,810.33,IENX,3,"E"))_"~"_TERM
    194         .S $P(OV,"^",2)=OV(2)
    195         ;---------------------------------------------------
    196         ;16 TOTAL PATIENTS NOT APPLICABLE - REMINDER OBX.5.3
    197         I L=1 D
    198         .S TERM="TOTAL PATIENTS NOT APPLICABLE"
    199         .S OV(3)=$G(^TMP("PXRM7",$J,810.33,IENX,4,"E"))_"~"_TERM
    200         .S $P(OV,"^",3)=OV(3)
    201         ;---------------------------------------------------
    202         ;17 TOTAL PATIENTS DUE - REMINDER            OBX.5.4
    203         I L=1 D
    204         .S TERM="TOTAL PATIENTS DUE"
    205         .S OV(4)=$G(^TMP("PXRM7",$J,810.33,IENX,5,"E"))_"~"_TERM
    206         .S $P(OV,"^",4)=OV(4)
    207         ;---------------------------------------------------
    208         ;18 TOTAL PATIENTS NOT DUE - REMINDER        OBX.5.5
    209         I L=1 D
    210         .S TERM="TOTAL PATIENTS NOT DUE"
    211         .S OV(5)=$G(^TMP("PXRM7",$J,810.33,IENX,6,"E"))_"~"_TERM
    212         .S $P(OV,"^",5)=OV(5)
    213         ;---------------------------------------------------
    214         ;23 TOTAL COUNT - FINDING                    OBX.5.1
    215         I L=2 D
    216         .S TERM="TOTAL COUNT"
    217         .S OV(1)=$G(^TMP("PXRM7",$J,810.331,IENZ,1,"E"))_"~"_TERM
    218         .S $P(OV,"^",1)=OV(1)
    219         ;---------------------------------------------------
    220         ;24 APPLICABLE COUNT - FINDING               OBX.5.2
    221         I L=2 D
    222         .S TERM="APPLICABLE COUNT"
    223         .S OV(2)=$G(^TMP("PXRM7",$J,810.331,IENZ,2,"E"))_"~"_TERM
    224         .S $P(OV,"^",2)=OV(2)
    225         ;---------------------------------------------------
    226         ;25 NOT APPLICABLE COUNT- FINDING            OBX.5.3
    227         I L=2 D
    228         .S TERM="NOT APPLICABLE COUNT"
    229         .S OV(3)=$G(^TMP("PXRM7",$J,810.331,IENZ,3,"E"))_"~"_TERM
    230         .S $P(OV,"^",3)=OV(3)
    231         ;---------------------------------------------------
    232         ;26 DUE COUNT - FINDING                      OBX.5.4
    233         I L=2 D
    234         .S TERM="DUE COUNT"
    235         .S OV(4)=$G(^TMP("PXRM7",$J,810.331,IENZ,4,"E"))_"~"_TERM
    236         .S $P(OV,"^",4)=OV(4)
    237         ;---------------------------------------------------
    238         ;27 NOT DUE COUNT - FINDING                  OBX.5.5
    239         I L=2 D
    240         .S TERM="NOT DUE COUNT"
    241         .S OV(5)=$G(^TMP("PXRM7",$J,810.331,IENZ,5,"E"))_"~"_TERM
    242         .S $P(OV,"^",5)=OV(5)
    243         ;---------------------------------------------------
    244         ;FINISH POPULATING OBX SEGMENT
    245         S $P(OBX(+SEQ_L),"|",6)=OV
    246         K OV
    247         ;---------------------------------------------------
    248         ;###---Set message in HL7 array
    249         S ^TMP("HLS",$J,LINE)=$G(OBX(+SEQ_L)),LINE=LINE+1
    250         ;
    251         I SEE=1 W !,"   ",OBX(+SEQ_L)
    252         K OBX
    253         ;---------------------------------------------------
    254         Q
     1PXRM7XT ;SLC/JVS HL7 EXTRACT FROM FILE; 03/21/2002 ;4/11/02  15:26
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;This is the beginning of the extraction from the extract file
     4 ;
     5 ;VARIABLE LIST
     6 ;IEN = IEN OF ENTRY IN EXTRACT FILE 810.3
     7 Q
     8SPLIT ;SPLIT MESSAGES
     9 N ORC2
     10 I LINE>100 D
     11 .S ORCCNT=ORCCNT+1
     12 .D EN^PXRM7M1(.ID)
     13 .K ^TMP("HLS",$J)
     14 .S ORC2=$G(^TMP("PXRM7HLORC",$J))
     15 .S $P(ORC2,"|",3)="P"_ORCCNT,ORC=ORC2
     16 .S LINE=2
     17 .I $D(SEE) W !,ORC
     18 .S ^TMP("HLS",$J,1)=ORC
     19 Q
     20 ;
     21EXTRACT(IEN,SEE,ID,MODE) ;
     22 N ORCCNT
     23 K ERROR,LINE
     24 S ORCCNT=1  ;Count of ORC segments or number of messages created
     25 S LINE=1 ;Line count for the ^TMP("HL7",$J,LINE) global variable
     26 ;-Verify Values
     27 I '$D(^PXRMXT(810.3,IEN)) S ERROR(1)="No Such IEN in file 810.3 "_IEN
     28 I $D(ERROR) D  Q
     29 .I $D(SEE)=1
     30 ;-Extracting Value of Nodes in file
     31 I $D(ERROR) Q
     32 D GETS^DIQ(810.3,IEN,"**","EI","^TMP(""PXRM7"",$J)")
     33 D ORCSEG
     34 ;******Add NTE segment to end of message *******
     35 ;******change 3rd piece of ORC segement to L (last)****
     36 S NTE="NTE||"_LAST_"||"
     37 S ^TMP("HLS",$J,LINE)=NTE,LINE=LINE+1
     38 I SEE=1 W !,NTE
     39 K NTE,LAST
     40 S ORC=$G(^TMP("HLS",$J,1)),$P(ORC,"|",3)="F"_ORCCNT,^TMP("HLS",$J,1)=ORC
     41 ;***********************************************
     42 ;*******TURN ON BELOW TO TRANSMIT TO AUSTIN *****
     43 D EN^PXRM7M1(.ID)
     44 ;***********************************************
     45 K ^TMP("PXRM7",$J)
     46 K ^TMP("HLS",$J)
     47 K ^TMP("PXRM7HLORC",$J)
     48 ;********KILL LEFT OVER ARRAYS AND VARIABLES*****
     49 K HL("EID"),HLA("HLS"),PROTIEN,PXRM7,PXRM77,PXRM7ID,PXRM7R,ZMID
     50 K DA,DISYS,DISYS,EO,HL("EIDS"),HLECH,HLFS,HLN,HLQ,HLSAN,HLX
     51 K IENIEN,IENOBR,IENX,IENY,IENZ,L,LINE,NEXT,QTI,RFS,SEQ
     52 K STATION,USI
     53 ;**************************************************
     54 Q
     55ORCSEG ;CREATE ORC SEGMENTS
     56 ;ORDERED IN ORDER OF APPEARANCE IN SEGMENT
     57 ;QTI=QUANTITY AND TIMING
     58 ;EO=ENTERING ORGANIZATION
     59 ;--Below adds extra line feed in front of the message. --
     60 ;---------------------------------------------------
     61 S IENY=IEN_","
     62 ;---------------------------------------------
     63 ;0 PLACER ORDER NUMBER      ORC.2.1
     64 S $P(ORC,"|",3)="P1"
     65 ;---------------------------------------------
     66 ;1 REPORTING PERIOD         ORC.7.1.1
     67 S QTI(1)=$G(^TMP("PXRM7",$J,810.3,IENY,3,"E"))
     68 S $P(QTI,"~",1)=QTI(1)
     69 ;---------------------------------------------
     70 ;2 QUARTER                  ORC.7.3
     71 S QTI(3)=$G(^TMP("PXRM7",$J,810.3,IENY,7,"E"))
     72 S $P(QTI,"~",3)=QTI(3)
     73 ;---------------------------------------------
     74 ;3 BEGINNING DATE           ORC.7.4.1
     75 S QTI(4)=$$HLDATE^HLFNC($G(^TMP("PXRM7",$J,810.3,IENY,.02,"I")),"DT")
     76 S $P(QTI,"~",4)=QTI(4)
     77 ;---------------------------------------------
     78 ;4 ENDING DATE              ORC.7.5.1
     79 S QTI(5)=$$HLDATE^HLFNC($G(^TMP("PXRM7",$J,810.3,IENY,.03,"I")),"DT")
     80 S $P(QTI,"~",5)=QTI(5)
     81 ;---------------------------------------------
     82 ;5 REPORTING YEAR           ORC.7.11.2
     83 S QTI(11)="&"_$G(^TMP("PXRM7",$J,810.3,IENY,4,"E"))
     84 S $P(QTI,"~",11)=QTI(11)
     85 ;---------------------------------------------
     86 ;6 EXTRACT DATE             ORC.9.1
     87 S $P(ORC,"|",10)=$$HLDATE^HLFNC($G(^TMP("PXRM7",$J,810.3,IENY,.06,"I")),"DT")
     88 ;---------------------------------------------
     89 ;7 NAME                     ORC.17.2
     90 S EO(2)=$G(^TMP("PXRM7",$J,810.3,IENY,.01,"E"))
     91 S $P(EO,"~",2)=EO(2)
     92 ;---------------------------------------------
     93 ;8 REPORT EXTRACT PARAMETER ORC.17.5
     94 S EO(5)=$G(^TMP("PXRM7",$J,810.3,IENY,1,"E"))
     95 S $P(EO,"~",5)=EO(5)
     96 ;---------------------------------------------
     97 ;9 REPORT EXTRACT TYPE      ORC.18.2
     98 S $P(ORC,"|",19)="~"_$G(^TMP("PXRM7",$J,810.3,IENY,2,"E"))
     99 ;---------------------------------------------
     100 ;FINISH POPULATING ORC SEGMENT
     101 S $P(ORC,"|",8)=QTI
     102 S $P(ORC,"|",18)=EO
     103 S $P(ORC,"|",1)="ORC"
     104 ;---------------------------------------------
     105 ;SET HL7 TMP ARRAY AND SHOW SEGMENT
     106 S ^TMP("HLS",$J,LINE)=ORC,LINE=LINE+1
     107 I SEE=1 W !,ORC
     108 S ^TMP("PXRM7HLORC",$J)=ORC
     109 K ORC
     110OBRSEG ;CREATE OBR SEGMENTS
     111 ;N IENOBR,SEQ,USI,QTI,NEXT,STATION
     112 ;USI=UNIVERSAL SERVICE ID
     113 ;RFS=REASON FOR STUDY
     114 ;
     115 S NEXT=1,LAST=0
     116 S IENOBR=0 F  S IENOBR=$O(^PXRMXT(810.3,IEN,3,IENOBR)) Q:IENOBR<1  D
     117 .S IENIEN=-1 F  S IENIEN=$O(^PXRMXT(810.3,IEN,3,IENOBR,1,IENIEN)) Q:IENIEN="B"  D  Q:IENIEN=""
     118 ..S L=$S(IENIEN=0:1,IENIEN>0:2,IENIEN="":1,1:"")
     119 ..;###---Set Sequence Number
     120 ..S IENX=IENOBR_","_IEN_","
     121 ..S IENZ=IENIEN_","_IENOBR_","_IEN_","
     122 ..S SEQ=$G(^TMP("PXRM7",$J,810.33,IENX,.01,"E"))
     123 ..S OBR(+SEQ_L)="OBR|1|||||||||||||||||||||||||||||||"
     124 ..S $P(OBR(+SEQ_L),"|",2)=NEXT,LAST=NEXT,NEXT=NEXT+1
     125 ..;--------------------------------------------------
     126 ..;10 COUNT TYPE           OBR.4.2
     127 ..;R=REMINDER COUNTS  F=FINDING COUNTS
     128 ..S USI(2)=$S(L=1:"R",L=2:"F",1:"")
     129 ..S $P(USI,"~",2)=USI(2)
     130 ..;--------------------------------------------------
     131 ..;11 REMINDER             OBR.4.5
     132 ..S USI(5)=$G(^TMP("PXRM7",$J,810.33,IENX,.02,"E"))
     133 ..S $P(USI,"~",5)=USI(5)
     134 ..;--------------------------------------------------
     135 ..;12 STATION              OBR.3.1
     136 ..S STATION=$G(^TMP("PXRM7",$J,810.33,IENX,.03,"I"))_","
     137 ..D GETS^DIQ(4,STATION,"**","E","^TMP(""PXRM7"",$J)")
     138 ..S $P(OBR(+SEQ_L),"|",4)=$G(^TMP("PXRM7",$J,4,STATION,99,"E"))
     139 ..;--------------------------------------------------
     140 ..;13 PATIENT LIST         OBR.31.2
     141 ..S RFS(2)=$G(^TMP("PXRM7",$J,810.33,IENX,.04,"E"))
     142 ..S $P(RFS,"~",2)=RFS(2)
     143 ..;--------------------------------------------------
     144 ..;19 REMINDER TERM        OBR.31.1
     145 ..S RFS(1)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.02,"E")),1:"")
     146 ..S $P(RFS,"~",1)=RFS(1)
     147 ..;--------------------------------------------------
     148 ..;20 FINDING TOTAL TYPE   OBR.31.4
     149 ..S RFS(4)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.03,"E")),1:"")
     150 ..S $P(RFS,"~",4)=RFS(4)
     151 ..;--------------------------------------------------
     152 ..;21 GROUP NAME           OBR.31.5
     153 ..S RFS(5)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.04,"E")),1:"")
     154 ..S $P(RFS,"~",5)=RFS(5)
     155 ..;--------------------------------------------------
     156 ..;22 REMINDER STATUS      OBR.4.4
     157 ..S USI(4)=$S(L=2:$G(^TMP("PXRM7",$J,810.331,IENZ,.05,"I")),1:"")
     158 ..S $P(USI,"~",4)=USI(4)
     159 ..;-------------------------------------------------
     160 ..;FINISH POPULATING OBR SEGMENT
     161 ..S $P(OBR(+SEQ_L),"|",5)=USI
     162 ..S $P(OBR(+SEQ_L),"|",32)=RFS
     163 ..;-------------------------------------------------
     164 ..;---Set message in HL7 array
     165 ..;I $L($G(OBR(+SEQ_L)))=255 S OBR(+SEQ_L)=OBR(+SEQ_L)_"|||"
     166 ..S ^TMP("HLS",$J,LINE)=$G(OBR(+SEQ_L)),LINE=LINE+1
     167 ..;
     168 ..I SEE=1 W !," ",OBR(+SEQ_L)
     169 ..K OBR
     170 ..D OBXSEG
     171 ..D SPLIT
     172 ..I (L=1)&(IENIEN="") Q
     173 Q
     174OBXSEG ;CREATE THE OBX SEGMENTS
     175 N TERM
     176 ;OV=OBSERVATION VALUE
     177 S $P(OBX(+SEQ_L),"|",3)="MO"
     178 S $P(OBX(+SEQ_L),"|",1)="OBX"
     179 ;---------------------------------------------------
     180 ;###---SET SEQUENCE NUMBER
     181 S $P(OBX(+SEQ_L),"|",2)=1
     182 ;---------------------------------------------------
     183 ;14 TOTAL PATIENTS EVALUATED - REMINDER      OBX.5.1
     184 I L=1 D
     185 .S TERM="TOTAL PATIENTS EVALUATED"
     186 .S OV(1)=$G(^TMP("PXRM7",$J,810.33,IENX,2,"E"))_"~"_TERM
     187 .S $P(OV,"^",1)=OV(1)
     188 ;---------------------------------------------------
     189 ;15 TOTAL PATIENTS APPLICABLE - REMINDER     OBX.5.2
     190 I L=1 D
     191 .S TERM="TOTAL PATIENTS APPLICABLE"
     192 .S OV(2)=$G(^TMP("PXRM7",$J,810.33,IENX,3,"E"))_"~"_TERM
     193 .S $P(OV,"^",2)=OV(2)
     194 ;---------------------------------------------------
     195 ;16 TOTAL PATIENTS NOT APPLICABLE - REMINDER OBX.5.3
     196 I L=1 D
     197 .S TERM="TOTAL PATIENTS NOT APPLICABLE"
     198 .S OV(3)=$G(^TMP("PXRM7",$J,810.33,IENX,4,"E"))_"~"_TERM
     199 .S $P(OV,"^",3)=OV(3)
     200 ;---------------------------------------------------
     201 ;17 TOTAL PATIENTS DUE - REMINDER            OBX.5.4
     202 I L=1 D
     203 .S TERM="TOTAL PATIENTS DUE"
     204 .S OV(4)=$G(^TMP("PXRM7",$J,810.33,IENX,5,"E"))_"~"_TERM
     205 .S $P(OV,"^",4)=OV(4)
     206 ;---------------------------------------------------
     207 ;18 TOTAL PATIENTS NOT DUE - REMINDER        OBX.5.5
     208 I L=1 D
     209 .S TERM="TOTAL PATIENTS NOT DUE"
     210 .S OV(5)=$G(^TMP("PXRM7",$J,810.33,IENX,6,"E"))_"~"_TERM
     211 .S $P(OV,"^",5)=OV(5)
     212 ;---------------------------------------------------
     213 ;23 TOTAL COUNT - FINDING                    OBX.5.1
     214 I L=2 D
     215 .S TERM="TOTAL COUNT"
     216 .S OV(1)=$G(^TMP("PXRM7",$J,810.331,IENZ,1,"E"))_"~"_TERM
     217 .S $P(OV,"^",1)=OV(1)
     218 ;---------------------------------------------------
     219 ;24 APPLICABLE COUNT - FINDING               OBX.5.2
     220 I L=2 D
     221 .S TERM="APPLICABLE COUNT"
     222 .S OV(2)=$G(^TMP("PXRM7",$J,810.331,IENZ,2,"E"))_"~"_TERM
     223 .S $P(OV,"^",2)=OV(2)
     224 ;---------------------------------------------------
     225 ;25 NOT APPLICABLE COUNT- FINDING            OBX.5.3
     226 I L=2 D
     227 .S TERM="NOT APPLICABLE COUNT"
     228 .S OV(3)=$G(^TMP("PXRM7",$J,810.331,IENZ,3,"E"))_"~"_TERM
     229 .S $P(OV,"^",3)=OV(3)
     230 ;---------------------------------------------------
     231 ;26 DUE COUNT - FINDING                      OBX.5.4
     232 I L=2 D
     233 .S TERM="DUE COUNT"
     234 .S OV(4)=$G(^TMP("PXRM7",$J,810.331,IENZ,4,"E"))_"~"_TERM
     235 .S $P(OV,"^",4)=OV(4)
     236 ;---------------------------------------------------
     237 ;27 NOT DUE COUNT - FINDING                  OBX.5.5
     238 I L=2 D
     239 .S TERM="NOT DUE COUNT"
     240 .S OV(5)=$G(^TMP("PXRM7",$J,810.331,IENZ,5,"E"))_"~"_TERM
     241 .S $P(OV,"^",5)=OV(5)
     242 ;---------------------------------------------------
     243 ;FINISH POPULATING OBX SEGMENT
     244 S $P(OBX(+SEQ_L),"|",6)=OV
     245 K OV
     246 ;---------------------------------------------------
     247 ;###---Set message in HL7 array
     248 S ^TMP("HLS",$J,LINE)=$G(OBX(+SEQ_L)),LINE=LINE+1
     249 ;
     250 I SEE=1 W !,"   ",OBX(+SEQ_L)
     251 K OBX
     252 ;---------------------------------------------------
     253 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMCDUE.m

    r613 r623  
    1 PXRMCDUE        ;SLC/PKR - Custom date due calculation routines. ;09/05/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;========================================================
    5 CDBUILD(STRING,DA)      ;Given a custom date due string build the data
    6         ;structure. This is called by a new-style cross-reference after
    7         ;the date due string has passed the input transform so we don't need
    8         ;to validate the elements.
    9         ;Do not execute as part of a verify fields.
    10         I $G(DIUTIL)="VERIFY FIELDS" Q
    11         ;Do not execute as part of exchange.
    12         I $G(PXRMEXCH) Q
    13         N FDA,FILIST,FREQLIST,FUNCTION,IENB,IENS,IND,MSG,NARGS,PFSTACK
    14         S STRING=$$UP^XLFSTR(STRING)
    15         D PARSE(STRING,.FUNCTION,.NARGS,.FILIST,.FREQLIST)
    16         S IENS=DA_","
    17         S FDA(811.9,IENS,46)=FUNCTION,FDA(811.9,IENS,47)=NARGS
    18         S IENB=DA
    19         F IND=1:1:NARGS D
    20         . S IENB=IENB+1
    21         . S IENS="+"_IENB_","_DA_","
    22         . S FDA(811.948,IENS,.01)=FILIST(IND)
    23         . S FDA(811.948,IENS,.02)=FREQLIST(IND)
    24         D UPDATE^DIE("","FDA","","MSG")
    25         I $D(MSG) D
    26         . W !,"The update failed, UPDATE^DIE returned the following error message:"
    27         . D AWRITE^PXRMUTIL("MSG")
    28         Q
    29         ;
    30         ;========================================================
    31 CDUEDATE(DEFARR,FIEVAL) ;Do the custom date due calculation and return
    32         ;the due date.
    33         N DATE,DDUE,DLIST,FI,FREQ,FUNCTION,IND,NARGS,TEMP
    34         S FUNCTION=$P(DEFARR(46),U,1)
    35         S NARGS=$P(DEFARR(46),U,2)
    36         F IND=1:1:NARGS D
    37         . S TEMP=DEFARR(47,IND,0)
    38         . S FI=$P(TEMP,U,1)
    39         . S FREQ=$P(TEMP,U,2)
    40         . S DATE=$S(FIEVAL(FI):+FIEVAL(FI,"DATE"),1:0)
    41         . I DATE>0 S DATE=$$FULLDATE^PXRMDATE(DATE)
    42         . S DLIST(IND)=$$NEWDATE^PXRMDATE(DATE,FREQ)
    43         S TEMP=$S(FUNCTION="MAX_DATE":$$MAXDATE(NARGS,.DLIST),FUNCTION="MIN_DATE":$$MINDATE(NARGS,.DLIST),1:0)
    44         S DDUE=$P(TEMP,U,1)
    45         I DDUE=0 Q -1
    46         S IND=$P(TEMP,U,2)
    47         S TEMP=DEFARR(47,IND,0)
    48         S FI=$P(TEMP,U,1)
    49         S FREQ=$P(TEMP,U,2)
    50         S DATE=+$G(FIEVAL(FI,"DATE"))
    51         S ^TMP(PXRMPID,$J,PXRMITEM,"zCDUE")=FI_U_FREQ_U_DATE
    52         Q DDUE
    53         ;
    54         ;========================================================
    55 CDKILL(X,DA)    ;
    56         ;Do not execute as part of a verify fields.
    57         I $G(DIUTIL)="VERIFY FIELDS" Q
    58         ;Do not execute as part of exchange.
    59         I $G(PXRMEXCH) Q
    60         K ^PXD(811.9,DA,46),^PXD(811.9,DA,47)
    61         Q
    62         ;
    63         ;========================================================
    64 MAXDATE(NARGS,DLIST)    ;Return the maximum date from a list of dates in DLIST.
    65         N IND,INDS,MAXDATE
    66         S (INDS,MAXDATE)=0
    67         F IND=1:1:NARGS I DLIST(IND)>MAXDATE S MAXDATE=DLIST(IND),INDS=IND
    68         Q MAXDATE_U_INDS
    69         ;
    70         ;========================================================
    71 MINDATE(NARGS,DLIST)    ;Return the minimum date from a list of dates in DLIST.
    72         ;Only return 0 if there is no "real" date in the list.
    73         N DATE,IND,INDS,MINDATE
    74         S INDS=0
    75         S MINDATE=9991231
    76         F IND=1:1:NARGS S DATE=DLIST(IND) I DATE<MINDATE,DATE'=0 S MINDATE=DATE,INDS=IND
    77         I MINDATE=9991231 S MINDATE=0
    78         Q MINDATE_U_INDS
    79         ;
    80         ;========================================================
    81 OUTPUT(CDUEDATA,DEFARR) ;Build the custom date due output text.
    82         N CDUEFI,ENTRY,FINAME,TEXT,VPTR
    83         S CDUEFI=$P(CDUEDATA,U,1)
    84         S VPTR=$P(^PXD(811.9,DEFARR("IEN"),20,CDUEFI,0),U,1)
    85         S ENTRY="^"_$P(VPTR,";",2)_$P(VPTR,";",1)_",0)"
    86         S FINAME=$P(@ENTRY,U,1)
    87         S TEXT="Custom date due based on date of finding "_CDUEFI_" ("_FINAME_")"
    88         S TEXT=TEXT_" plus frequency of "_$P(CDUEDATA,U,2)_"."
    89         Q TEXT
    90         ;
    91         ;========================================================
    92 PARSE(STRING,FUNCTION,NARGS,FILIST,FREQLIST)    ;Parse a custom date due
    93         ;string and return the function, number of arguments, finding list,
    94         ;and frequency list. An argument has the form M+NF where M is a
    95         ;finding number, N is an integer, and F is D, M, or Y.
    96         N IND,OPER,PFSTACK
    97         S OPER=","
    98         D POSTFIX^PXRMSTAC(STRING,OPER,.PFSTACK)
    99         S FUNCTION=$$UP^XLFSTR(PFSTACK(1))
    100         S NARGS=0
    101         F IND=2:1:PFSTACK(0) D
    102         . I PFSTACK(IND)=OPER Q
    103         . S NARGS=NARGS+1
    104         . S FILIST(NARGS)=$P(PFSTACK(IND),"+",1)
    105         . S FREQLIST(NARGS)=$P(PFSTACK(IND),"+",2)
    106         Q
    107         ;
    108         ;========================================================
    109 VFREQ(FREQ)     ;Make sure FREQ is a valid frequency.
    110         N VALID
    111         S VALID=1
    112         S FREQ=$$UP^XLFSTR(FREQ)
    113         I (FREQ'?1N.N1"D"),(FREQ'?1N.N1"M"),(FREQ'?1N.N1"Y") S VALID=0
    114         Q VALID
    115         ;
    116         ;========================================================
    117 VCDUE(STRING,DA)        ;Make sure a custom date due string is valid.
    118         ;Do not execute as part of a verify fields.
    119         I $G(DIUTIL)="VERIFY FIELDS" Q 1
    120         ;Do not execute as part of exchange.
    121         I $G(PXRMEXCH) Q 1
    122         I '$D(DA) Q 1
    123         I $L(STRING)>245 Q 0
    124         N FILIST,FREQLIST,FUNCTION,IND,NARGS,TEXT,VALID
    125         D PARSE(STRING,.FUNCTION,.NARGS,.FILIST,.FREQLIST)
    126         S VALID=1
    127         I FUNCTION'="MIN_DATE",FUNCTION'="MAX_DATE" D
    128         . S TEXT=FUNCTION_" is not a valid custom date due function"
    129         . D EN^DDIOL(TEXT)
    130         . S VALID=0
    131         F IND=1:1:NARGS D
    132         . I '$D(^PXD(811.9,DA,20,FILIST(IND),0)) D
    133         .. S TEXT="Finding number "_FILIST(IND)_" is not a valid reminder finding"
    134         .. D EN^DDIOL(TEXT)
    135         .. S VALID=0
    136         . I '$$VFREQ(FREQLIST(IND)) D
    137         .. S TEXT=FREQLIST(IND)_" is not a valid frequency"
    138         .. D EN^DDIOL(TEXT)
    139         .. S VALID=0
    140         Q VALID
    141         ;
    142         ;========================================================
    143 XHELP   ;Executable help for custom date due.
    144         N DONE,IND,TEXT
    145         S DONE=0
    146         F IND=1:1 Q:DONE  D
    147         . S TEXT=$P($T(TEXT+IND),";",3)
    148         . I TEXT="**End Text**" S DONE=1 Q
    149         . W !,TEXT
    150         Q
    151         ;
    152         ;========================================================
    153 TEXT    ;Custom Date Due help text.
    154         ;;The general form for a Custom Date Due string is:
    155         ;; FUNCTION(ARG1,ARG2,...,ARGN)
    156         ;;where FUNCTION is MAX_DATE or MIN_DATE and the arguments have the form
    157         ;;M+FREQ where M is a finding number and FREQ is a number followed by
    158         ;;D for days, M for months, or Y for years.
    159         ;;Here is an example:
    160         ;; MAX_DATE(1+6M,3+1Y)
    161         ;;This will take the date of finding 1 and add 6 months, the date of finding 3
    162         ;;and add 1 year and set the date due to the maximum of those two dates.
    163         ;;
    164         ;;**End Text**
    165         Q
    166         ;
     1PXRMCDUE ;SLC/PKR - Custom date due calculation routines. ;06/30/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;========================================================
     5CDBUILD(STRING,DA) ;Given a custom date due string build the data
     6 ;structure. This is called by a new-style cross-reference after
     7 ;the date due string has passed the input transform so we don't need
     8 ;to validate the elements.
     9 ;Do not execute as part of a verify fields.
     10 I $G(DIUTIL)="VERIFY FIELDS" Q
     11 ;Do not execute as part of exchange.
     12 I $G(PXRMEXCH) Q
     13 N FDA,FILIST,FREQLIST,FUNCTION,IENB,IENS,IND,MSG,NARGS,PFSTACK
     14 S STRING=$$UP^XLFSTR(STRING)
     15 D PARSE(STRING,.FUNCTION,.NARGS,.FILIST,.FREQLIST)
     16 S IENS=DA_","
     17 S FDA(811.9,IENS,46)=FUNCTION,FDA(811.9,IENS,47)=NARGS
     18 S IENB=DA
     19 F IND=1:1:NARGS D
     20 . S IENB=IENB+1
     21 . S IENS="+"_IENB_","_DA_","
     22 . S FDA(811.948,IENS,.01)=FILIST(IND)
     23 . S FDA(811.948,IENS,.02)=FREQLIST(IND)
     24 D UPDATE^DIE("","FDA","","MSG")
     25 I $D(MSG) D
     26 . W !,"The update failed, UPDATE^DIE returned the following error message:"
     27 . D AWRITE^PXRMUTIL("MSG")
     28 Q
     29 ;
     30 ;========================================================
     31CDUEDATE(DEFARR,FIEVAL) ;Do the custom date due calculation and return
     32 ;the due date.
     33 N DATE,DDUE,DLIST,FI,FREQ,FUNCTION,IND,NARGS,TEMP
     34 S FUNCTION=$P(DEFARR(46),U,1)
     35 S NARGS=$P(DEFARR(46),U,2)
     36 F IND=1:1:NARGS D
     37 . S TEMP=DEFARR(47,IND,0)
     38 . S FI=$P(TEMP,U,1)
     39 . S FREQ=$P(TEMP,U,2)
     40 . S DATE=+$G(FIEVAL(FI,"DATE"))
     41 . S DLIST(IND)=$$NEWDATE^PXRMDATE(DATE,FREQ)
     42 S TEMP=$S(FUNCTION="MAX_DATE":$$MAXDATE(NARGS,.DLIST),FUNCTION="MIN_DATE":$$MINDATE(NARGS,.DLIST))
     43 S DDUE=$P(TEMP,U,1)
     44 I DDUE=0 Q -1
     45 S IND=$P(TEMP,U,2)
     46 S TEMP=DEFARR(47,IND,0)
     47 S FI=$P(TEMP,U,1)
     48 S FREQ=$P(TEMP,U,2)
     49 S DATE=+$G(FIEVAL(FI,"DATE"))
     50 S ^TMP(PXRMPID,$J,PXRMITEM,"zCDUE")=FI_U_FREQ_U_DATE
     51 Q DDUE
     52 ;
     53 ;========================================================
     54CDKILL(X,DA) ;
     55 ;Do not execute as part of a verify fields.
     56 I $G(DIUTIL)="VERIFY FIELDS" Q
     57 ;Do not execute as part of exchange.
     58 I $G(PXRMEXCH) Q
     59 K ^PXD(811.9,DA,46),^PXD(811.9,DA,47)
     60 Q
     61 ;
     62 ;========================================================
     63MAXDATE(NARGS,DLIST) ;Return the maximum date from a list of dates in DLIST.
     64 N IND,INDS,MAXDATE
     65 S (INDS,MAXDATE)=0
     66 F IND=1:1:NARGS I DLIST(IND)>MAXDATE S MAXDATE=DLIST(IND),INDS=IND
     67 Q MAXDATE_U_INDS
     68 ;
     69 ;========================================================
     70MINDATE(NARGS,DLIST) ;Return the minimum date from a list of dates in DLIST.
     71 ;Only return 0 if there is no "real" date in the list.
     72 N DATE,IND,INDS,MINDATE
     73 S INDS=0
     74 S MINDATE=9991231
     75 F IND=1:1:NARGS S DATE=DLIST(IND) I DATE<MINDATE,DATE'=0 S MINDATE=DATE,INDS=IND
     76 I MINDATE=9991231 S MINDATE=0
     77 Q MINDATE_U_INDS
     78 ;
     79 ;========================================================
     80OUTPUT(CDUEDATA,DEFARR) ;Build the custom date due output text.
     81 N CDUEFI,ENTRY,FINAME,TEXT,VPTR
     82 S CDUEFI=$P(CDUEDATA,U,1)
     83 S VPTR=$P(^PXD(811.9,DEFARR("IEN"),20,CDUEFI,0),U,1)
     84 S ENTRY="^"_$P(VPTR,";",2)_$P(VPTR,";",1)_",0)"
     85 S FINAME=$P(@ENTRY,U,1)
     86 S TEXT="Custom date due based on date of finding "_CDUEFI_" ("_FINAME_")"
     87 S TEXT=TEXT_" plus frequency of "_$P(CDUEDATA,U,2)_"."
     88 Q TEXT
     89 ;
     90 ;========================================================
     91PARSE(STRING,FUNCTION,NARGS,FILIST,FREQLIST) ;Parse a custom date due
     92 ;string and return the function, number of arguments, finding list,
     93 ;and frequency list. An argument has the form M+NF where M is a
     94 ;finding number, N is an integer, and F is D, M, or Y.
     95 N IND,OPER,PFSTACK
     96 S OPER=","
     97 D POSTFIX^PXRMSTAC(STRING,OPER,.PFSTACK)
     98 S FUNCTION=$$UP^XLFSTR(PFSTACK(1))
     99 S NARGS=0
     100 F IND=2:1:PFSTACK(0) D
     101 . I PFSTACK(IND)=OPER Q
     102 . S NARGS=NARGS+1
     103 . S FILIST(NARGS)=$P(PFSTACK(IND),"+",1)
     104 . S FREQLIST(NARGS)=$P(PFSTACK(IND),"+",2)
     105 Q
     106 ;
     107 ;========================================================
     108VFREQ(FREQ) ;Make sure FREQ is a valid frequency.
     109 N VALID
     110 S VALID=1
     111 S FREQ=$$UP^XLFSTR(FREQ)
     112 I (FREQ'?1N.N1"D"),(FREQ'?1N.N1"M"),(FREQ'?1N.N1"Y") S VALID=0
     113 Q VALID
     114 ;
     115 ;========================================================
     116VCDUE(STRING,DA) ;Make sure a custom date due string is valid.
     117 ;Do not execute as part of a verify fields.
     118 I $G(DIUTIL)="VERIFY FIELDS" Q 1
     119 ;Do not execute as part of exchange.
     120 I $G(PXRMEXCH) Q 1
     121 I '$D(DA) Q 1
     122 I $L(STRING)>245 Q 0
     123 N FILIST,FREQLIST,FUNCTION,IND,NARGS,TEXT,VALID
     124 D PARSE(STRING,.FUNCTION,.NARGS,.FILIST,.FREQLIST)
     125 S VALID=1
     126 I FUNCTION'="MIN_DATE",FUNCTION'="MAX_DATE" D
     127 . S TEXT=FUNCTION_" is not a valid custom date due function"
     128 . D EN^DDIOL(TEXT)
     129 . S VALID=0
     130 F IND=1:1:NARGS D
     131 . I '$D(^PXD(811.9,DA,20,FILIST(IND),0)) D
     132 .. S TEXT="Finding number "_FILIST(IND)_" is not a valid reminder finding"
     133 .. D EN^DDIOL(TEXT)
     134 .. S VALID=0
     135 . I '$$VFREQ(FREQLIST(IND)) D
     136 .. S TEXT=FREQLIST(IND)_" is not a valid frequency"
     137 .. D EN^DDIOL(TEXT)
     138 .. S VALID=0
     139 Q VALID
     140 ;
     141 ;========================================================
     142XHELP ;Executable help for custom date due.
     143 N DONE,IND,TEXT
     144 S DONE=0
     145 F IND=1:1 Q:DONE  D
     146 . S TEXT=$P($T(TEXT+IND),";",3)
     147 . I TEXT="**End Text**" S DONE=1 Q
     148 . W !,TEXT
     149 Q
     150 ;
     151 ;========================================================
     152TEXT ;Custom Date Due help text.
     153 ;;The general form for a Custom Date Due string is:
     154 ;; FUNCTION(ARG1,ARG2,...,ARGN)
     155 ;;where FUNCTION is MAX_DATE or MIN_DATE and the arguments have the form
     156 ;;M+FREQ where M is a finding number and FREQ is a number followed by
     157 ;;D for days, M for months, or Y for years.
     158 ;;Here is an example:
     159 ;; MAX_DATE(1+6M,3+1Y)
     160 ;;This will take the date of finding 1 and add 6 months, the date of finding 3
     161 ;;and add 1 year and set the date due to the maximum of those two dates.
     162 ;;
     163 ;;**End Text**
     164 Q
     165 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMCF.m

    r613 r623  
    1 PXRMCF  ; SLC/PKR - Handle computed findings. ;07/25/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=======================================================
    5 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate computed findings.
    6         N FIEVT,FILENUM,FINDING,FINDPA,ITEM
    7         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    8         S ITEM=""
    9         F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    10         . S FINDING=""
    11         . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
    12         .. K FINDPA
    13         .. M FINDPA=DEFARR(20,FINDING)
    14         .. K FIEVT
    15         .. D FIEVAL(FILENUM,DFN,ITEM,.FINDPA,.FIEVT)
    16         .. M FIEVAL(FINDING)=FIEVT
    17         .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
    18         Q
    19         ;
    20         ;=======================================================
    21 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Patient list evaluator.
    22         ;Return the list in ^TMP($J,PLIST)
    23         N ITEM,FILENUM,PFINDPA
    24         N TEMP,TFINDING,TFINDPA
    25         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    26         S ITEM=""
    27         F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    28         . S TFINDING=""
    29         . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
    30         .. K PFINDPA,TFINDPA
    31         .. M TFINDPA=TERMARR(20,TFINDING)
    32         ..;Set the finding parameters.
    33         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    34         .. D GPLIST(FILENUM,ITEM,.PFINDPA,PLIST)
    35         Q
    36         ;
    37         ;=======================================================
    38 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;General term
    39         ;evaluator.
    40         N FIEVT,FILENUM,ITEM,PFINDPA
    41         N TEMP,TFINDING,TFINDPA
    42         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    43         S ITEM=""
    44         F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    45         . S TFINDING=""
    46         . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
    47         .. K FIEVT,PFINDPA,TFINDPA
    48         .. M TFINDPA=TERMARR(20,TFINDING)
    49         ..;Set the finding parameters.
    50         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    51         .. D FIEVAL(FILENUM,DFN,ITEM,.PFINDPA,.FIEVT)
    52         .. M TFIEVAL(TFINDING)=FIEVT
    53         .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
    54         Q
    55         ;
    56         ;=======================================================
    57 FIEVAL(FILENUM,DFN,ITEM,PFINDPA,FIEVAL) ;
    58         ;Evaluate regular patient findings.
    59         N BDT,CASESEN,COND,CONVAL,DAS,DATA,DATE,EDT,FLIST,ICOND,IND
    60         N NFOUND,NGET,NOCC,NP,PDATA,ROUTINE
    61         N SAVE,SDIR,STATUSA,TEMP,TEST,TEXT,TYPE,UCIFS,VALUE,VSLIST
    62         ;Set the finding search parameters.
    63         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    64         S SDIR=$S(NOCC<0:+1,1:-1)
    65         S TEST=PFINDPA(15)
    66         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    67         S NGET=$S(UCIFS:50,$D(STATUSA):50,1:NOCC)
    68         ;Make sure NGET has the same sign as NOCC.
    69         I NGET'=NOCC S NGET=NGET*($$ABS^XLFMTH(NOCC)/NOCC)
    70         S TEMP=^PXRMD(811.4,ITEM,0)
    71         S TYPE=$P(TEMP,U,5)
    72         I TYPE="" S TYPE="S"
    73         I TYPE="S" D
    74         . S ROUTINE=$P(TEMP,U,3)_"^"_$P(TEMP,U,2)_"(DFN,.TEST,.DATE,.VALUE,.TEXT)"
    75         . D @ROUTINE
    76         .;Make sure that the date is in range.
    77         . I TEST,DATE'<BDT,DATE'>EDT S NFOUND=1
    78         . E  S NFOUND=0
    79         . I NFOUND D
    80         .. S TEST(1)=TEST,DATE(1)=DATE,TEXT(1)=$G(TEXT)
    81         .. S DATA(1,"VALUE")=$G(VALUE)
    82         .. I $D(VALUE)=11 S IND="" F  S IND=$O(VALUE(IND)) Q:IND=""  S DATA(1,IND)=VALUE(IND)
    83         I TYPE="M" D
    84         . S ROUTINE=$P(TEMP,U,3)_"^"_$P(TEMP,U,2)_"(DFN,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)"
    85         . D @ROUTINE
    86         I TYPE'="S",TYPE'="M" D
    87         . S NFOUND=0
    88         . S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","COMPUTED FINDING","WRONG TYPE")=TYPE_" IS NOT SUITABLE FOR REMINDER EVALUATION"
    89         I NFOUND=0 S FIEVAL=0 Q
    90         S NP=0
    91         F IND=1:1:NFOUND Q:NP=NOCC  D
    92         . I TEST(IND),COND'="" D
    93         .. K PDATA M PDATA=DATA(IND)
    94         .. S CONVAL=$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.PDATA)
    95         . E  S CONVAL=TEST(IND)
    96         . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    97         . I SAVE D
    98         .. S NP=NP+1
    99         .. S FIEVAL(NP)=CONVAL
    100         .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
    101         .. S FIEVAL(NP,"DATE")=DATE(IND)
    102         .. S FIEVAL(NP,"TEXT")=$G(TEXT(IND))
    103         .. M FIEVAL(NP)=DATA(IND)
    104         .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=DATA(IND)
    105         ;
    106         ;Save the finding result.
    107         D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
    108         S FIEVAL("FILE NUMBER")=FILENUM
    109         Q
    110         ;
    111         ;=======================================================
    112 GPLIST(FILENUM,CFIEN,PFINDPA,PLIST)     ;Add to the patient list
    113         ;for a regular file.
    114         N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,DATA,DFN,FLIST
    115         N ICOND,IND,IPLIST
    116         N NOCC,NOCCABS,NFOUND,NGET,NP,PARAM,ROUTINE
    117         N SAVE,SOURCE,STATUSA,TEMP,TEXT,TGLIST,TPLIST,TYPE
    118         N UCIFS,VALUE,VSLIST
    119         S TEMP=^PXRMD(811.4,CFIEN,0)
    120         S TYPE=$P(TEMP,U,5)
    121         I TYPE'="L" Q
    122         S TGLIST="GPLIST_PXRMCF"
    123         S PARAM=PFINDPA(15)
    124         S SOURCE=FILENUM_";"_CFIEN
    125         ;Set the finding search parameters.
    126         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    127         S NOCCABS=$$ABS^XLFMTH(NOCC)
    128         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    129         S NGET=$S(UCIFS:50,$D(STATUSA):50,1:NOCCABS)
    130         K ^TMP($J,TGLIST)
    131         S ROUTINE=$P(TEMP,U,3)_"^"_$P(TEMP,U,2)_"(NGET,BDT,EDT,TGLIST,PARAM)"
    132         D @ROUTINE
    133         ;Routine should return:
    134         ;^TMP($J,TGLIST,DFN,N)=DAS_U_DATE_U_FILENUM_U_ITEM_U_VALUE
    135         ;Data values for condition are returned in
    136         ;^TMP($J,TGLIST,DFN,N,SUB)=DATA(SUB)
    137         S DFN=""
    138         F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
    139         . K TPLIST
    140         . M TPLIST=^TMP($J,TGLIST,DFN)
    141         . S (IND,NFOUND)=0
    142         . K IPLIST
    143         . F  S IND=$O(TPLIST(IND)) Q:(IND="")!(NFOUND=NOCCABS)  D
    144         .. S TEMP=TPLIST(IND)
    145         .. K DATA M DATA=TPLIST(IND)
    146         .. S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.DATA),1:1)
    147         .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    148         .. I SAVE D
    149         ... S NFOUND=NFOUND+1
    150         ... S IPLIST(CONVAL,DFN,NFOUND,SOURCE)=TEMP
    151         . M ^TMP($J,PLIST)=IPLIST
    152         K ^TMP($J,TGLIST)
    153         Q
    154         ;
    155         ;=======================================================
    156 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    157         N DATA,DATE,FIEN,IND,JND,NAME,NOUT,PNAME,TEMP,TEXTOUT,VALUE
    158         S FIEN=$P(IFIEVAL("FINDING"),";",1)
    159         S TEMP=^PXRMD(811.4,FIEN,0)
    160         S PNAME=$P(TEMP,U,4)
    161         I PNAME="" S PNAME=$P(TEMP,U,1)
    162         S NAME="Computed Finding: "_PNAME_" = "
    163         S IND=0
    164         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    165         . S VALUE=$G(IFIEVAL(IND,"VALUE"))
    166         . S DATE=IFIEVAL(IND,"DATE")
    167         . S TEMP=NAME_VALUE_" ("_$$EDATE^PXRMDATE(DATE)_")"
    168         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    169         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    170         S NLINES=NLINES+1,TEXT(NLINES)=""
    171         Q
    172         ;
    173         ;=======================================================
    174 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    175         ;maintenance output.
    176         N DATA,DATE,FIEN,IND,JND,NOUT,PNAME,TEMP,TEXTOUT,VALUE
    177         S FIEN=$P(IFIEVAL("FINDING"),";",1)
    178         S TEMP=^PXRMD(811.4,FIEN,0)
    179         S PNAME=$P(TEMP,U,4)
    180         I PNAME="" S PNAME=$P(TEMP,U,1)
    181         S NLINES=NLINES+1
    182         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Computed Finding: "_PNAME
    183         S IND=0
    184         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    185         . S DATE=IFIEVAL(IND,"DATE")
    186         . S TEMP=$$EDATE^PXRMDATE(DATE)
    187         . S VALUE=$G(IFIEVAL(IND,"VALUE"))
    188         . I VALUE'="" S TEMP=TEMP_" value - "_VALUE
    189         .;If there is text append it.
    190         . I $G(IFIEVAL(IND,"TEXT"))'="" S TEMP=TEMP_"; "_IFIEVAL(IND,"TEXT")
    191         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    192         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    193         S NLINES=NLINES+1,TEXT(NLINES)=""
    194         Q
    195         ;
     1PXRMCF ; SLC/PKR - Handle computed findings. ;12/15/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=======================================================
     5EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate computed findings.
     6 N FIEVT,FILENUM,FINDING,FINDPA,ITEM
     7 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     8 S ITEM=""
     9 F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     10 . S FINDING=""
     11 . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
     12 .. K FINDPA
     13 .. M FINDPA=DEFARR(20,FINDING)
     14 .. K FIEVT
     15 .. D FIEVAL(FILENUM,DFN,ITEM,.FINDPA,.FIEVT)
     16 .. M FIEVAL(FINDING)=FIEVT
     17 .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
     18 Q
     19 ;
     20 ;=======================================================
     21EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Patient list evaluator.
     22 ;Return the list in ^TMP($J,PLIST)
     23 N ITEM,FILENUM,PFINDPA
     24 N TEMP,TFINDING,TFINDPA
     25 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     26 S ITEM=""
     27 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     28 . S TFINDING=""
     29 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
     30 .. K PFINDPA,TFINDPA
     31 .. M TFINDPA=TERMARR(20,TFINDING)
     32 ..;Set the finding parameters.
     33 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     34 .. D GPLIST(FILENUM,ITEM,.PFINDPA,PLIST)
     35 Q
     36 ;
     37 ;=======================================================
     38EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;General term
     39 ;evaluator.
     40 N FIEVT,FILENUM,ITEM,PFINDPA
     41 N TEMP,TFINDING,TFINDPA
     42 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     43 S ITEM=""
     44 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     45 . S TFINDING=""
     46 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
     47 .. K FIEVT,PFINDPA,TFINDPA
     48 .. M TFINDPA=TERMARR(20,TFINDING)
     49 ..;Set the finding parameters.
     50 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     51 .. D FIEVAL(FILENUM,DFN,ITEM,.PFINDPA,.FIEVT)
     52 .. M TFIEVAL(TFINDING)=FIEVT
     53 .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
     54 Q
     55 ;
     56 ;=======================================================
     57FIEVAL(FILENUM,DFN,ITEM,PFINDPA,FIEVAL) ;
     58 ;Evaluate regular patient findings.
     59 N BDT,CASESEN,COND,CONVAL,DAS,DATA,DATE,EDT,FLIST,ICOND,IND
     60 N NFOUND,NGET,NOCC,NP,PDATA,ROUTINE
     61 N SAVE,SDIR,STATUSA,TEMP,TEST,TEXT,TYPE,UCIFS,VALUE,VSLIST
     62 ;Set the finding search parameters.
     63 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     64 S SDIR=$S(NOCC<0:+1,1:-1)
     65 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     66 S TEST=PFINDPA(15)
     67 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     68 S NGET=$S(UCIFS:"*",$D(STATUSA):"*",1:NOCC)
     69 S TEMP=^PXRMD(811.4,ITEM,0)
     70 S TYPE=$P(TEMP,U,5)
     71 I TYPE="" S TYPE="S"
     72 I TYPE="S" D
     73 . S ROUTINE=$P(TEMP,U,3)_"^"_$P(TEMP,U,2)_"(DFN,.TEST,.DATE,.VALUE,.TEXT)"
     74 . D @ROUTINE
     75 .;Make sure that the date is in range.
     76 . I TEST,DATE'<BDT,DATE'>EDT S NFOUND=1
     77 . E  S NFOUND=0
     78 . I NFOUND D
     79 .. S TEST(1)=TEST,DATE(1)=DATE,TEXT(1)=$G(TEXT)
     80 .. S DATA(1,"VALUE")=$G(VALUE)
     81 .. I $D(VALUE)=11 S IND="" F  S IND=$O(VALUE(IND)) Q:IND=""  S DATA(1,IND)=VALUE(IND)
     82 I TYPE="M" D
     83 . S ROUTINE=$P(TEMP,U,3)_"^"_$P(TEMP,U,2)_"(DFN,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)"
     84 . D @ROUTINE
     85 I TYPE'="S",TYPE'="M" D
     86 . S NFOUND=0
     87 . S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","COMPUTED FINDING","WRONG TYPE")=TYPE_" IS NOT SUITABLE FOR REMINDER EVALUATION"
     88 I NFOUND=0 S FIEVAL=0 Q
     89 S NP=0
     90 F IND=1:1:NFOUND Q:NP=NOCC  D
     91 . I TEST(IND),COND'="" D
     92 .. K PDATA M PDATA=DATA(IND)
     93 .. S CONVAL=$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.PDATA)
     94 . E  S CONVAL=TEST(IND)
     95 . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     96 . I SAVE D
     97 .. S NP=NP+1
     98 .. S FIEVAL(NP)=CONVAL
     99 .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
     100 .. S FIEVAL(NP,"DATE")=DATE(IND)
     101 .. S FIEVAL(NP,"TEXT")=$G(TEXT(IND))
     102 .. M FIEVAL(NP)=DATA(IND)
     103 .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=DATA(IND)
     104 ;
     105 ;Save the finding result.
     106 D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
     107 S FIEVAL("FILE NUMBER")=FILENUM
     108 Q
     109 ;
     110 ;=======================================================
     111GPLIST(FILENUM,CFIEN,PFINDPA,PLIST) ;Add to the patient list
     112 ;for a regular file.
     113 N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,DATA,DFN,FLIST
     114 N ICOND,IND,IPLIST
     115 N NOCC,NOCCABS,NFOUND,NGET,NP,PARAM,ROUTINE
     116 N SAVE,SOURCE,STATUSA,TEMP,TEXT,TGLIST,TPLIST,TYPE
     117 N UCIFS,VALUE,VSLIST
     118 S TEMP=^PXRMD(811.4,CFIEN,0)
     119 S TYPE=$P(TEMP,U,5)
     120 I TYPE'="L" Q
     121 S TGLIST="GPLIST_PXRMCF"
     122 S PARAM=PFINDPA(15)
     123 S SOURCE=FILENUM_";"_CFIEN
     124 ;Set the finding search parameters.
     125 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     126 S NOCCABS=$$ABS^XLFMTH(NOCC)
     127 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     128 S NGET=$S(UCIFS:"*",$D(STATUSA):"*",1:NOCCABS)
     129 K ^TMP($J,TGLIST)
     130 S ROUTINE=$P(TEMP,U,3)_"^"_$P(TEMP,U,2)_"(NGET,BDT,EDT,TGLIST,PARAM)"
     131 D @ROUTINE
     132 ;Routine should return:
     133 ;^TMP($J,TGLIST,DFN,N)=DAS_U_DATE_U_FILENUM_U_ITEM_U_VALUE
     134 ;Data values for condition are returned in
     135 ;^TMP($J,TGLIST,DFN,N,SUB)=DATA(SUB)
     136 S DFN=""
     137 F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
     138 . K TPLIST
     139 . M TPLIST=^TMP($J,TGLIST,DFN)
     140 . S (IND,NFOUND)=0
     141 . K IPLIST
     142 . F  S IND=$O(TPLIST(IND)) Q:(IND="")!(NFOUND=NOCCABS)  D
     143 .. S TEMP=TPLIST(IND)
     144 .. K DATA M DATA=TPLIST(IND)
     145 .. S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.DATA),1:1)
     146 .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     147 .. I SAVE D
     148 ... S NFOUND=NFOUND+1
     149 ... S IPLIST(CONVAL,DFN,NFOUND,SOURCE)=TEMP
     150 . M ^TMP($J,PLIST)=IPLIST
     151 K ^TMP($J,TGLIST)
     152 Q
     153 ;
     154 ;=======================================================
     155MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     156 N DATA,DATE,FIEN,IND,JND,NAME,NOUT,PNAME,TEMP,TEXTOUT,VALUE
     157 S FIEN=$P(IFIEVAL("FINDING"),";",1)
     158 S TEMP=^PXRMD(811.4,FIEN,0)
     159 S PNAME=$P(TEMP,U,4)
     160 I PNAME="" S PNAME=$P(TEMP,U,1)
     161 S NAME="Computed Finding: "_PNAME_" = "
     162 S IND=0
     163 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     164 . S VALUE=$G(IFIEVAL(IND,"VALUE"))
     165 . S DATE=IFIEVAL(IND,"DATE")
     166 . S TEMP=NAME_VALUE_" ("_$$EDATE^PXRMDATE(DATE)_")"
     167 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     168 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     169 S NLINES=NLINES+1,TEXT(NLINES)=""
     170 Q
     171 ;
     172 ;=======================================================
     173OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     174 ;maintenance output.
     175 N DATA,DATE,FIEN,IND,JND,NOUT,PNAME,TEMP,TEXTOUT,VALUE
     176 S FIEN=$P(IFIEVAL("FINDING"),";",1)
     177 S TEMP=^PXRMD(811.4,FIEN,0)
     178 S PNAME=$P(TEMP,U,4)
     179 I PNAME="" S PNAME=$P(TEMP,U,1)
     180 S NLINES=NLINES+1
     181 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Computed Finding: "_PNAME
     182 S IND=0
     183 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     184 . S DATE=IFIEVAL(IND,"DATE")
     185 . S TEMP=$$EDATE^PXRMDATE(DATE)
     186 . S VALUE=$G(IFIEVAL(IND,"VALUE"))
     187 . I VALUE'="" S TEMP=TEMP_" value - "_VALUE
     188 .;If there is text append it.
     189 . I $G(IFIEVAL(IND,"TEXT"))'="" S TEMP=TEMP_"; "_IFIEVAL(IND,"TEXT")
     190 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     191 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     192 S NLINES=NLINES+1,TEXT(NLINES)=""
     193 Q
     194 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMCOND.m

    r613 r623  
    1 PXRMCOND        ; SLC/PKR - Routines for evaluating conditions. ;06/01/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;============================================================
    5 CASESEN(X,DA,FILENUM)   ;
    6         ;Called by xref on condition case sensitive field in 811.5 and 811.9.
    7         N COND,GBL
    8         S GBL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
    9         S GBL=GBL_DA(1)_",20,"_DA_",3)"
    10         S COND=$P(@GBL,U,1)
    11         D SICOND(COND,.DA,FILENUM)
    12         Q
    13         ;
    14         ;============================================================
    15 COND(CASESEN,ICOND,VSLIST,VA)   ;Evaluate the condition.
    16         N CONVAL,IND,JND,NSTAR,SUB,TEMP,V,VSTAR
    17         S CONVAL=""
    18         ;If there is no condition return true.
    19         I $L($G(ICOND))=0 Q 1
    20         S NSTAR=0
    21         F IND=1:1 S SUB=$P(VSLIST,";",IND) Q:SUB=""  D
    22         . I SUB["*" S NSTAR=NSTAR+1,VSTAR(NSTAR)=$L(SUB,",")_U_SUB
    23         S V=$G(VA("VALUE"))
    24         I 'CASESEN S V=$$UP^XLFSTR(V)
    25         ;Move all non "*" elements of VA into V.
    26         I VSLIST'="" D MV(VSLIST,CASESEN,.V,.VA)
    27         I NSTAR=0 X ICOND S CONVAL=$T
    28         I NSTAR>0 S CONVAL=$$STARCOND(CASESEN,ICOND,.V,.VA,NSTAR,.VSTAR)
    29         Q CONVAL
    30         ;
    31         ;============================================================
    32 KICOND(X,DA,FILENUM)    ;
    33         ;Do not execute as part of a verify fields.
    34         I $G(DIUTIL)="VERIFY FIELDS" Q
    35         ;Do not execute as part of exchange.
    36         I $G(PXRMEXCH) Q
    37         S FILENUM=$G(FILENUM)
    38         I FILENUM=811.5 K ^PXRMD(811.5,DA(1),20,DA,10),^PXRMD(811.5,DA(1),20,DA,11)
    39         I FILENUM=811.9 K ^PXD(811.9,DA(1),20,DA,10),^PXD(811.9,DA(1),20,DA,11)
    40         Q
    41         ;
    42         ;============================================================
    43 MV(VSLIST,CASESEN,V,VA) ;Move the elements of VA included in VSLIST
    44         ;into V and uppercase if necessary.
    45         N IND,NE,RV,RVA,SUB
    46         S NE=$L(VSLIST,";")-1
    47         F IND=1:1:NE D
    48         . S SUB=$P(VSLIST,";",IND)
    49         . I SUB["*" Q
    50         . S RV="V("_SUB_")",RVA="VA("_SUB_")"
    51         .;If VA(SUB) does not exist skip it.
    52         . I '$D(@RVA) Q
    53         . S @RV=$S('CASESEN:$$UP^XLFSTR(@RVA),1:@RVA)
    54         Q
    55         ;
    56         ;============================================================
    57 RECSUB(IND,V,VA,NSTAR,VSTAR,NM,VM,CASESEN,ICOND,CONVAL) ;Called recursively,
    58         ;first substitutes V array elements with "*" in subscript with a
    59         ;replacement value. Once all have been replaced test condition and
    60         ;quit if true. If not true continue until all combinations have been
    61         ;tested.
    62         N JND,RV,RVA,VSUB,VASUB
    63         F JND=1:1:NM(IND) Q:CONVAL  D
    64         . S VASUB=VM(IND,JND)
    65         . S RVA="VA("_VASUB_")"
    66         . S SUB=$P(VSTAR(IND),U,2)
    67         . S RV="V("_SUB_")"
    68         . S @RV=$S('CASESEN:$$UP^XLFSTR(@RVA),1:@RVA)
    69         . I IND<NSTAR D RECSUB(IND+1,.V,.VA,NSTAR,.VSTAR,.NM,.VM,CASESEN,ICOND,.CONVAL)
    70         . I IND=NSTAR X ICOND S CONVAL=$T
    71         ;If there were no substitutions to make, make sure the condition is
    72         ;evaluated.
    73         I 'CONVAL,IND=NSTAR,NM(IND)=0 X ICOND S CONVAL=$T
    74         Q
    75         ;
    76         ;============================================================
    77 SCPAR(FINDPA,CASESEN,COND,UCIFS,ICOND,VSLIST)   ;Set the Condition parameters.
    78         N CONDS
    79         S CONDS=$G(FINDPA(3))
    80         S COND=$P(CONDS,U,1)
    81         ;Even if there is no condition UCIFS could be used for status search.
    82         S UCIFS=$P(CONDS,U,3)
    83         I COND="" Q
    84         S CASESEN=$P(CONDS,U,2)
    85         I CASESEN="" S CASESEN=1
    86         S ICOND=FINDPA(10),VSLIST=FINDPA(11)
    87         Q
    88         ;
    89         ;============================================================
    90 SICOND(X,DA,FILENUM)    ;Set the internal condition field. Wrap all V() in $G.
    91         ;Called by xref on condition field in 811.5 and 811.9.
    92         I X="" Q
    93         ;Do not execute as part of a verify fields.
    94         I $G(DIUTIL)="VERIFY FIELDS" Q
    95         ;Do not execute as part of exchange.
    96         I $G(PXRMEXCH) Q
    97         N CASESEN,GBL,ICOND,IND,SE,SS,SUB,SUBLIST,TEMP,VSLIST,VWSUB,XUP
    98         S GBL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
    99         S GBL=GBL_DA(1)_",20,"_DA_",3)"
    100         S CASESEN=$P(@GBL,U,2)
    101         I CASESEN="" S CASESEN=1
    102         ;Find each V("sub") entry.
    103         S XUP=$$UP^XLFSTR(X)
    104         I 'CASESEN S (ICOND,X)=XUP
    105         I CASESEN S ICOND=$$STRREP^PXRMUTIL(X,"v(","V(")
    106         S SS=1,VSLIST=""
    107         F  S SS=$F(XUP,"V(",SS) Q:SS=0  D
    108         . S SE=$F(X,")",SS)
    109         . S SUB=$E(X,SS,SE-2)
    110         . I $D(SUBLIST(SUB)) Q
    111         . S SUBLIST(SUB)=""
    112         . S VSLIST=VSLIST_SUB_";"
    113         . S VWSUB="V("_SUB_")"
    114         . S TEMP="$G("_VWSUB_")"
    115         . S ICOND=$$STRREP^PXRMUTIL(ICOND,VWSUB,TEMP)
    116         I FILENUM=811.5 S ^PXRMD(811.5,DA(1),20,DA,10)=ICOND,^PXRMD(811.5,DA(1),20,DA,11)=VSLIST
    117         I FILENUM=811.9 S ^PXD(811.9,DA(1),20,DA,10)=ICOND,^PXD(811.9,DA(1),20,DA,11)=VSLIST
    118         Q
    119         ;
    120         ;============================================================
    121 STARCOND(CASESEN,ICOND,V,VA,NSTAR,VSTAR)        ;Execute a star condition,
    122         ;look for any replacements for the * subscripts that will make the
    123         ;Condition true.
    124         N CONVAL,IND,JND,KND,MATCH,NEWV,NM,NVA,ORV,REF,SUB,SUBL,TCOND,TEMP
    125         N VASUB,VSSUB,VM
    126         ;Build a list of the subscripts in VA.
    127         S NVA=0,REF="VA"
    128         F  S REF=$Q(@REF) Q:REF=""  D
    129         . S SUB=$P(REF,"(",2)
    130         . S SUB=$P(SUB,")",1)
    131         . S SUBL=$L(SUB,",")
    132         . S NVA=NVA+1,VASUB(NVA)=SUBL_U_SUB
    133         ;Build a list of replacements for the * subscripts.
    134         F IND=1:1:NSTAR D
    135         . S NM=0
    136         . S VSSUB=$P(VSTAR(IND),U,2)
    137         . S SUBL=+VSTAR(IND)
    138         . F JND=1:1:NVA D
    139         .. I +VASUB(JND)'=SUBL Q
    140         .. S SUB=$P(VASUB(JND),U,2)
    141         .. S MATCH=1
    142         .. F KND=1:1:SUBL D
    143         ... S TEMP=$P(VSSUB,",",KND)
    144         ... I TEMP["*" Q
    145         ... I $P(SUB,",",KND)'=TEMP S MATCH=0,KND=SUBL
    146         .. I MATCH S NM=NM+1,VM(IND,NM)=SUB
    147         . S NM(IND)=NM
    148         S CONVAL=0
    149         F IND=1:1:NSTAR Q:CONVAL  D RECSUB(IND,.V,.VA,NSTAR,.VSTAR,.NM,.VM,CASESEN,ICOND,.CONVAL)
    150         Q CONVAL
    151         ;
    152         ;============================================================
    153 VCOND(X)        ;
    154         ;Input transform on Condition field.
    155         ;Do not execute as part of exchange.
    156         I $G(PXRMEXCH) Q 1
    157         ;The CONDITION must start with "I ".
    158         S X=$$UP^XLFSTR(X)
    159         I $E(X,1,2)'="I " D  Q 0
    160         . S X=""
    161         . D EN^DDIOL("CONDITION must start with ""I"" followed by a single space")
    162         ;The CONDITION cannot contain "^".
    163         I X["^" D  Q 0
    164         . S X=""
    165         . D EN^DDIOL("CONDITION cannot contain ""^""")
    166         ;The CONDITION cannot contain "@".
    167         I X["@" D  Q 0
    168         . S X=""
    169         . D EN^DDIOL("CONDITION cannot contain ""@""")
    170         ;The rest of the condition can only contain spaces if they are in
    171         ;a string.
    172         N COND,TEMP,VALID
    173         S COND=$E(X,3,$L(X))
    174         S VALID=$S(COND[" ":$$VSPACE(COND),1:1)
    175         I VALID S VALID=$S(COND["V(":$$VSUB(COND),1:1)
    176         I VALID D
    177         . D ^DIM
    178         . I '$D(X) D
    179         .. D EN^DDIOL("Not a valid MUMPS string")
    180         .. S VALID=0
    181         Q VALID
    182         ;
    183         ;============================================================
    184 VSPACE(COND)    ;Make sure all spaces in the condition that come after
    185         ;the beginning I are inside a quoted string.
    186         N CHAR,IND,IQ,JND,LQ,NIQ,NQP,NSP,QP,SP,SPACE,VALID
    187         S VALID=1
    188         S (LQ,NQP,NSP)=0
    189         F IND=1:1:$L(COND) D
    190         . S CHAR=$E(COND,IND)
    191         . I CHAR="""" D
    192         .. I LQ S NQP=NQP+1,QP(NQP)=LQ_U_IND,LQ=0
    193         .. E  S LQ=IND
    194         . I CHAR=" " S NSP=NSP+1,SP(NSP)=IND
    195         S NIQ=0
    196         F IND=1:1:NSP D
    197         . S SPACE=SP(NSP)
    198         . S IQ=0
    199         . F JND=1:1:NQP D
    200         .. I SPACE>$P(QP(JND),U,1),SPACE<$P(QP(JND),U,2) S IQ=1,JND=NQP Q
    201         . S NIQ=$S(IQ:0,1:1)
    202         . I NIQ S IND=NSP Q
    203         I NIQ D
    204         . D EN^DDIOL("No spaces are allowed except in quoted strings!")
    205         . S VALID=0
    206         Q VALID
    207         ;
    208         ;============================================================
    209 VSUB(COND)      ;Make sure all V subscripts are quoted strings, numbers
    210         ;or quoted * strings.
    211         N IND,RP,SS,SUB,SUBL,VALID
    212         S (SS,VALID)=1
    213         F  S SS=$F(COND,"V(",SS) Q:('VALID)!(SS=0)  D
    214         . S RP=$F(COND,")",SS)-2
    215         . I RP=-2 D  Q
    216         .. N TEXT
    217         .. S TEXT=$E(COND,SS-2,$L(COND))_" is missing a "")"""
    218         .. D EN^DDIOL(TEXT)
    219         .. S VALID=0
    220         . S SUBL=$E(COND,SS,RP)
    221         . F IND=1:1:$L(SUBL,",") D
    222         .. S SUB=$P(SUBL,",",IND)
    223         ..;Check for a number.
    224         .. I SUB=+SUB Q
    225         ..;Check for a wildcard, must be in quotes any number of * allowed.
    226         .. I SUB?1"""1"*"."*"""" Q
    227         .. ;Check for first and last character = to a ".
    228         .. I ($E(SUB,1)'="""")!($E(SUB,$L(SUB))'="""") S VALID=0
    229         I 'VALID D EN^DDIOL("All V subscripts must be quoted strings, numbers or *!")
    230         Q VALID
    231         ;
     1PXRMCOND ; SLC/PKR - Routines for evaluating conditions. ;11/01/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;============================================================
     5CASESEN(X,DA,FILENUM) ;
     6 ;Called by xref on condition case sensitive field in 811.5 and 811.9.
     7 N COND,GBL
     8 S GBL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
     9 S GBL=GBL_DA(1)_",20,"_DA_",3)"
     10 S COND=$P(@GBL,U,1)
     11 D SICOND(COND,.DA,FILENUM)
     12 Q
     13 ;
     14 ;============================================================
     15COND(CASESEN,ICOND,VSLIST,VA) ;Evaluate the condition.
     16 N CONVAL,IND,JND,NSTAR,SUB,TEMP,V,VSTAR
     17 S CONVAL=""
     18 ;If there is no condition return true.
     19 I $L($G(ICOND))=0 Q 1
     20 S NSTAR=0
     21 F IND=1:1 S SUB=$P(VSLIST,";",IND) Q:SUB=""  D
     22 . I SUB["*" S NSTAR=NSTAR+1,VSTAR(NSTAR)=$L(SUB,",")_U_SUB
     23 S V=$G(VA("VALUE"))
     24 I 'CASESEN S V=$$UP^XLFSTR(V)
     25 ;Move all non "*" elements of VA into V.
     26 I VSLIST'="" D MV(VSLIST,CASESEN,.V,.VA)
     27 I NSTAR=0 X ICOND S CONVAL=$T
     28 I NSTAR>0 S CONVAL=$$STARCOND(CASESEN,ICOND,.V,.VA,NSTAR,.VSTAR)
     29 Q CONVAL
     30 ;
     31 ;============================================================
     32KICOND(X,DA,FILENUM) ;
     33 ;Do not execute as part of a verify fields.
     34 I $G(DIUTIL)="VERIFY FIELDS" Q
     35 ;Do not execute as part of exchange.
     36 I $G(PXRMEXCH) Q
     37 S FILENUM=$G(FILENUM)
     38 I FILENUM=811.5 K ^PXRMD(811.5,DA(1),20,DA,10),^PXRMD(811.5,DA(1),20,DA,11)
     39 I FILENUM=811.9 K ^PXD(811.9,DA(1),20,DA,10),^PXD(811.9,DA(1),20,DA,11)
     40 Q
     41 ;
     42 ;============================================================
     43MV(VSLIST,CASESEN,V,VA) ;Move the elements of VA included in VSLIST
     44 ;into V and uppercase if necessary.
     45 N IND,NE,RV,RVA,SUB
     46 S NE=$L(VSLIST,";")-1
     47 F IND=1:1:NE D
     48 . S SUB=$P(VSLIST,";",IND)
     49 . I SUB["*" Q
     50 . S RV="V("_SUB_")",RVA="VA("_SUB_")"
     51 .;If VA(SUB) does not exist skip it.
     52 . I '$D(@RVA) Q
     53 . S @RV=$S('CASESEN:$$UP^XLFSTR(@RVA),1:@RVA)
     54 Q
     55 ;
     56 ;============================================================
     57RECSUB(IND,V,VA,NSTAR,VSTAR,NM,VM,CASESEN,ICOND,CONVAL) ;Called recursively,
     58 ;first substitutes V array elements with "*" in subscript with a
     59 ;replacement value. Once all have been replaced test condition and
     60 ;quit if true. If not true continue until all combinations have been
     61 ;tested.
     62 N JND,RV,RVA,VSUB,VASUB
     63 F JND=1:1:NM(IND) Q:CONVAL  D
     64 . S VASUB=VM(IND,JND)
     65 . S RVA="VA("_VASUB_")"
     66 . S SUB=$P(VSTAR(IND),U,2)
     67 . S RV="V("_SUB_")"
     68 . S @RV=$S('CASESEN:$$UP^XLFSTR(@RVA),1:@RVA)
     69 . I IND<NSTAR D RECSUB(IND+1,.V,.VA,NSTAR,.VSTAR,.NM,.VM,CASESEN,ICOND,.CONVAL)
     70 . I IND=NSTAR X ICOND S CONVAL=$T
     71 ;If there were no substitutions to make, make sure the condition is
     72 ;evaluated.
     73 I 'CONVAL,IND=NSTAR,NM(IND)=0 X ICOND S CONVAL=$T
     74 Q
     75 ;
     76 ;============================================================
     77SCPAR(FINDPA,CASESEN,COND,UCIFS,ICOND,VSLIST) ;Set the Condition parameters.
     78 N CONDS
     79 S CONDS=$G(FINDPA(3))
     80 S COND=$P(CONDS,U,1)
     81 S UCIFS=$S(COND="":0,1:$P(CONDS,U,3))
     82 I COND="" Q
     83 S CASESEN=$P(CONDS,U,2)
     84 I CASESEN="" S CASESEN=1
     85 S ICOND=FINDPA(10),VSLIST=FINDPA(11)
     86 Q
     87 ;
     88 ;============================================================
     89SICOND(X,DA,FILENUM) ;Set the internal condition field. Wrap all V() in $G.
     90 ;Called by xref on condition field in 811.5 and 811.9.
     91 I X="" Q
     92 ;Do not execute as part of a verify fields.
     93 I $G(DIUTIL)="VERIFY FIELDS" Q
     94 ;Do not execute as part of exchange.
     95 I $G(PXRMEXCH) Q
     96 N CASESEN,GBL,ICOND,IND,SE,SS,SUB,SUBLIST,TEMP,VSLIST,VWSUB,XUP
     97 S GBL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
     98 S GBL=GBL_DA(1)_",20,"_DA_",3)"
     99 S CASESEN=$P(@GBL,U,2)
     100 I CASESEN="" S CASESEN=1
     101 ;Find each V("sub") entry.
     102 S XUP=$$UP^XLFSTR(X)
     103 I 'CASESEN S (ICOND,X)=XUP
     104 I CASESEN S ICOND=$$STRREP^PXRMUTIL(X,"v(","V(")
     105 S SS=1,VSLIST=""
     106 F  S SS=$F(XUP,"V(",SS) Q:SS=0  D
     107 . S SE=$F(X,")",SS)
     108 . S SUB=$E(X,SS,SE-2)
     109 . I $D(SUBLIST(SUB)) Q
     110 . S SUBLIST(SUB)=""
     111 . S VSLIST=VSLIST_SUB_";"
     112 . S VWSUB="V("_SUB_")"
     113 . S TEMP="$G("_VWSUB_")"
     114 . S ICOND=$$STRREP^PXRMUTIL(ICOND,VWSUB,TEMP)
     115 I FILENUM=811.5 S ^PXRMD(811.5,DA(1),20,DA,10)=ICOND,^PXRMD(811.5,DA(1),20,DA,11)=VSLIST
     116 I FILENUM=811.9 S ^PXD(811.9,DA(1),20,DA,10)=ICOND,^PXD(811.9,DA(1),20,DA,11)=VSLIST
     117 Q
     118 ;
     119 ;============================================================
     120STARCOND(CASESEN,ICOND,V,VA,NSTAR,VSTAR) ;Execute a star condition,
     121 ;look for any replacements for the * subscripts that will make the
     122 ;Condition true.
     123 N CONVAL,IND,JND,KND,MATCH,NEWV,NM,NVA,ORV,REF,SUB,SUBL,TCOND,TEMP
     124 N VASUB,VSSUB,VM
     125 ;Build a list of the subscripts in VA.
     126 S NVA=0,REF="VA"
     127 F  S REF=$Q(@REF) Q:REF=""  D
     128 . S SUB=$P(REF,"(",2)
     129 . S SUB=$P(SUB,")",1)
     130 . S SUBL=$L(SUB,",")
     131 . S NVA=NVA+1,VASUB(NVA)=SUBL_U_SUB
     132 ;Build a list of replacements for the * subscripts.
     133 F IND=1:1:NSTAR D
     134 . S NM=0
     135 . S VSSUB=$P(VSTAR(IND),U,2)
     136 . S SUBL=+VSTAR(IND)
     137 . F JND=1:1:NVA D
     138 .. I +VASUB(JND)'=SUBL Q
     139 .. S SUB=$P(VASUB(JND),U,2)
     140 .. S MATCH=1
     141 .. F KND=1:1:SUBL D
     142 ... S TEMP=$P(VSSUB,",",KND)
     143 ... I TEMP["*" Q
     144 ... I $P(SUB,",",KND)'=TEMP S MATCH=0,KND=SUBL
     145 .. I MATCH S NM=NM+1,VM(IND,NM)=SUB
     146 . S NM(IND)=NM
     147 S CONVAL=0
     148 F IND=1:1:NSTAR Q:CONVAL  D RECSUB(IND,.V,.VA,NSTAR,.VSTAR,.NM,.VM,CASESEN,ICOND,.CONVAL)
     149 Q CONVAL
     150 ;
     151 ;============================================================
     152VCOND(X) ;
     153 ;Input transform on Condition field.
     154 ;Do not execute as part of exchange.
     155 I $G(PXRMEXCH) Q 1
     156 ;The CONDITION must start with "I ".
     157 S X=$$UP^XLFSTR(X)
     158 I $E(X,1,2)'="I " D  Q 0
     159 . S X=""
     160 . D EN^DDIOL("CONDITION must start with ""I"" followed by a single space")
     161 ;The CONDITION cannot contain "^".
     162 I X["^" D  Q 0
     163 . S X=""
     164 . D EN^DDIOL("CONDITION cannot contain ""^""")
     165 ;The CONDITION cannot contain "@".
     166 I X["@" D  Q 0
     167 . S X=""
     168 . D EN^DDIOL("CONDITION cannot contain ""@""")
     169 ;The rest of the condition can only contain spaces if they are in
     170 ;a string.
     171 N COND,TEMP,VALID
     172 S COND=$E(X,3,$L(X))
     173 S VALID=$S(COND[" ":$$VSPACE(COND),1:1)
     174 I VALID S VALID=$S(COND["V(":$$VSUB(COND),1:1)
     175 I VALID D
     176 . D ^DIM
     177 . I '$D(X) D
     178 .. D EN^DDIOL("Not a valid MUMPS string")
     179 .. S VALID=0
     180 Q VALID
     181 ;
     182 ;============================================================
     183VSPACE(COND) ;Make sure all spaces in the condition that come after
     184 ;the beginning I are inside a quoted string.
     185 N CHAR,IND,IQ,JND,LQ,NIQ,NQP,NSP,QP,SP,SPACE,VALID
     186 S VALID=1
     187 S (LQ,NQP,NSP)=0
     188 F IND=1:1:$L(COND) D
     189 . S CHAR=$E(COND,IND)
     190 . I CHAR="""" D
     191 .. I LQ S NQP=NQP+1,QP(NQP)=LQ_U_IND,LQ=0
     192 .. E  S LQ=IND
     193 . I CHAR=" " S NSP=NSP+1,SP(NSP)=IND
     194 S NIQ=0
     195 F IND=1:1:NSP D
     196 . S SPACE=SP(NSP)
     197 . S IQ=0
     198 . F JND=1:1:NQP D
     199 .. I SPACE>$P(QP(JND),U,1),SPACE<$P(QP(JND),U,2) S IQ=1,JND=NQP Q
     200 . S NIQ=$S(IQ:0,1:1)
     201 . I NIQ S IND=NSP Q
     202 I NIQ D
     203 . D EN^DDIOL("No spaces are allowed except in quoted strings!")
     204 . S VALID=0
     205 Q VALID
     206 ;
     207 ;============================================================
     208VSUB(COND) ;Make sure all V subscripts are quoted strings, numbers
     209 ;or quoted * strings.
     210 N IND,RP,SS,SUB,SUBL,VALID
     211 S (SS,VALID)=1
     212 F  S SS=$F(COND,"V(",SS) Q:('VALID)!(SS=0)  D
     213 . S RP=$F(COND,")",SS)-2
     214 . I RP=-2 D  Q
     215 .. N TEXT
     216 .. S TEXT=$E(COND,SS-2,$L(COND))_" is missing a "")"""
     217 .. D EN^DDIOL(TEXT)
     218 .. S VALID=0
     219 . S SUBL=$E(COND,SS,RP)
     220 . F IND=1:1:$L(SUBL,",") D
     221 .. S SUB=$P(SUBL,",",IND)
     222 ..;Check for a number.
     223 .. I SUB=+SUB Q
     224 ..;Check for a wildcard, must be in quotes any number of * allowed.
     225 .. I SUB?1"""1"*"."*"""" Q
     226 .. ;Check for first and last character = to a ".
     227 .. I ($E(SUB,1)'="""")!($E(SUB,$L(SUB))'="""") S VALID=0
     228 I 'VALID D EN^DDIOL("All V subscripts must be quoted strings, numbers or *!")
     229 Q VALID
     230 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMCOPY.m

    r613 r623  
    1 PXRMCOPY        ; SLC/PKR,PJH - Copy various reminder files. ;09/13/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================
    5 COPY(PROMPT,ROOT,WHAT)  ;Copy an entry of ROOT into a new entry.
    6         N DIROUT,DTOUT,DUOUT
    7         F  D GETORGR Q:$D(DIROUT)  Q:$D(DTOUT)
    8         Q
    9         ;
    10         ;=====================================================
    11 GETORGR ;Look-up logic to get and copy source entry to destination.
    12         N DA,DIE,DIC,DIK,DIR,DIRUT,FDA,FIELDLEN,FILE
    13         N IENN,IENO,IENS,MSG,NAME,ORGNAME,X,Y
    14         S DIC=ROOT,DIC(0)="AEMQ",DIC("A")=PROMPT
    15         W !
    16         D ^DIC
    17         I $D(DUOUT)!$D(DTOUT) S DIROUT="" Q
    18         S IENO=$P(Y,U,1)
    19         I IENO=-1 S DIROUT="" Q
    20         ;
    21         ;Set the starting place for additions.
    22         D SETSTART^PXRMCOPY(DIC)
    23         S IENN=$$GETFOIEN(ROOT)
    24         D MERGE(IENN,IENO,ROOT)
    25         ;
    26         ;Get the new name.
    27         S ORGNAME=$P(@(ROOT_IENO_",0)"),U,1)
    28         S FILE=$$FNFR^PXRMUTIL(ROOT)
    29         S FIELDLEN=$$GET1^DID(FILE,.01,"","FIELD LENGTH")
    30         S DIR(0)="F"_U_"3:"_FIELDLEN_U_"K:(X?.N)!'(X'?1P.E) X"
    31         S DIR("A")="PLEASE ENTER A UNIQUE NAME"
    32 GETNAM  D ^DIR
    33         I $D(DIRUT) D DELETE(ROOT,IENN) Q
    34         S NAME=Y
    35         ;
    36         ;Make sure the new name is valid.
    37         I '$$VNAME^PXRMINTR(NAME,FILE) G GETNAM
    38         ;
    39         ;Change to the new name.
    40         S IENS=IENN_","
    41         S FDA(FILE,IENS,.01)=NAME
    42         K MSG
    43         D FILE^DIE("","FDA","MSG")
    44         ;Check to make sure the name was not a duplicate.
    45         I $G(MSG("DIERR",1))=740 D  G GETNAM
    46         . W !,NAME," is not a unique name!"
    47         ;Change the class to local and delete the sponsor.
    48         D SCAS(FILE,IENN,"L","")
    49         ;Initialize the edit history.
    50         D INIEH(FILE,ROOT,IENN,IENO)
    51         ;
    52         ;Reindex the cross-references.
    53         S DIK=ROOT,DA=IENN
    54         D IX^DIK
    55         W !
    56         ;
    57         ;Tell the user what has happened and allow for editing of the new item.
    58         S DIR(0)="Y"
    59         S DIR("A")="Do you want to edit it now"
    60         S DIR("A",1)="The original "_WHAT_" "_ORGNAME_" has been copied into "_NAME_"."
    61         D ^DIR Q:$D(DIRUT)
    62         I Y D EDIT^PXRMEDIT(ROOT,IENN)
    63         Q
    64         ;
    65         ;=====================================================
    66 COPYLL  ;Copy a location list.
    67         N PROMPT,ROOT,WHAT
    68         S WHAT="location list"
    69         S ROOT="^PXRMD(810.9,"
    70         S PROMPT="Select the reminder location list to copy: "
    71         D COPY(PROMPT,ROOT,WHAT)
    72         Q
    73         ;
    74         ;=====================================================
    75 COPYREM ;Copy a reminder definition.
    76         N PROMPT,ROOT,WHAT
    77         S WHAT="reminder"
    78         S ROOT="^PXD(811.9,"
    79         S PROMPT="Select the reminder definition to copy: "
    80         D COPY(PROMPT,ROOT,WHAT)
    81         Q
    82         ;
    83         ;=====================================================
    84 COPYTAX ;Copy a taxonomy.
    85         N PROMPT,ROOT,WHAT
    86         S WHAT="taxonomy"
    87         S ROOT="^PXD(811.2,"
    88         S PROMPT="Select the reminder taxonomy to copy: "
    89         D COPY(PROMPT,ROOT,WHAT)
    90         Q
    91         ;
    92         ;=====================================================
    93 COPYTERM        ;Copy a reminder term.
    94         N PROMPT,ROOT,WHAT
    95         S WHAT="reminder term"
    96         S ROOT="^PXRMD(811.5,"
    97         S PROMPT="Select the reminder term to copy: "
    98         D COPY(PROMPT,ROOT,WHAT)
    99         Q
    100         ;
    101         ;=====================================================
    102 DELETE(DIK,DA)  ;Delete the entry just added.
    103         D ^DIK
    104         W !!,"New entry not created due to invalid name!",!
    105         Q
    106         ;
    107         ;=====================================================
    108 GETFOIEN(ROOT)  ;Return the first open IEN in ROOT. This should be called
    109         ;after a call to SETSTART.
    110         N ENTRY,NIEN,OIEN
    111         S ENTRY=ROOT_0_")"
    112         S OIEN=$P(@ENTRY,U,3)
    113         S ENTRY=ROOT_OIEN_")"
    114         F  S NIEN=$O(@ENTRY) Q:+(NIEN-OIEN)>1  Q:+NIEN'>0  S OIEN=NIEN,ENTRY=ROOT_NIEN_")"
    115         Q OIEN+1
    116         ;
    117         ;=====================================================
    118 INIEH(FILENUM,ROOT,IENN,IENO)   ;Initialize the edit history after a copy.
    119         ;First delete any existing history entries.
    120         N ENTRY,IND,IENS,FDA,FDAIEN,MSG,SFN,TARGET,WP
    121         D FIELD^DID(FILENUM,"EDIT HISTORY","","SPECIFIER","TARGET")
    122         S SFN=+$G(TARGET("SPECIFIER"))
    123         I SFN=0 Q
    124         S ENTRY=ROOT_IENN_",110)"
    125         S IND=0
    126         F  S IND=$O(@ENTRY@(IND)) Q:+IND=0  D
    127         . S IENS=IND_","_IENN_","
    128         . S FDA(SFN,IENS,.01)="@"
    129         I $D(FDA(SFN)) D FILE^DIE("K","FDA","MSG")
    130         I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    131         ;Establish an initial entry in the edit history.
    132         K FDA,MSG
    133         S IENS="+1,"_IENN_","
    134         S FDAIEN(IENN)=IENN
    135         S FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    136         S FDA(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
    137         S FDA(SFN,IENS,2)="WP(1,1)"
    138         S WP(1,1,1)="Copied from "_$$GET1^DIQ(FILENUM,IENO,.01)
    139         D UPDATE^DIE("E","FDA","FDAIEN","MSG")
    140         I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    141         Q
    142         ;
    143         ;=====================================================
    144 MERGE(IENN,IENO,ROOT)   ;Use MERGE to copy ROOT(IENO into ROOT(IENN.
    145         N DEST,SOURCE
    146         S DEST=ROOT_IENN_")"
    147         ;Lock the file before merging.
    148         L +@DEST:10
    149         S SOURCE=ROOT_IENO_")"
    150         M @DEST=@SOURCE
    151         ;Unlock the file
    152         L -@DEST
    153         Q
    154         ;
    155         ;=====================================================
    156 SCAS(FILENUM,IEN,CLASS,SPONSOR) ;Set the class field to CLASS and the sponsor
    157         ;field to SPONSOR.
    158         N IENS,FDA,MSG
    159         S IENS=IEN_","
    160         S FDA(FILENUM,IENS,100)=CLASS
    161         S FDA(FILENUM,IENS,101)=SPONSOR
    162         D FILE^DIE("K","FDA","MSG")
    163         I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    164         Q
    165         ;
    166         ;=====================================================
    167 SETSTART(ROOT)  ;Set the starting value to add new entries. Start
    168         ;at the begining so empty spaces are filled in.
    169         N CUR,ENTRY
    170         S ENTRY=ROOT_"0)"
    171         S $P(@ENTRY,U,3)=1
    172         Q
    173         ;
     1PXRMCOPY ; SLC/PKR,PJH - Copy various reminder files. ;05/11/2001
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================
     5COPY(PROMPT,ROOT,WHAT) ;Copy an entry of ROOT into a new entry.
     6 N DIROUT,DTOUT,DUOUT
     7 F  D GETORGR Q:$D(DIROUT)  Q:$D(DTOUT)
     8 Q
     9 ;
     10 ;=====================================================
     11GETORGR ;Look-up logic to get and copy source entry to destination.
     12 N DA,DIE,DIC,DIK,DIR,DIRUT,FDA,FIELDLEN,FILE
     13 N IENN,IENO,IENS,MSG,NAME,ORGNAME,X,Y
     14 S DIC=ROOT,DIC(0)="AEQ",DIC("A")=PROMPT
     15 W !
     16 D ^DIC
     17 I $D(DUOUT)!$D(DTOUT) S DIROUT="" Q
     18 S IENO=$P(Y,U,1)
     19 I IENO=-1 S DIROUT="" Q
     20 ;
     21 ;Set the starting place for additions.
     22 D SETSTART^PXRMCOPY(DIC)
     23 S IENN=$$GETFOIEN(ROOT)
     24 D MERGE(IENN,IENO,ROOT)
     25 ;
     26 ;Get the new name.
     27 S ORGNAME=$P(@(ROOT_IENO_",0)"),U,1)
     28 S FILE=$$FNFR^PXRMUTIL(ROOT)
     29 S FIELDLEN=$$GET1^DID(FILE,.01,"","FIELD LENGTH")
     30 S DIR(0)="F"_U_"3:"_FIELDLEN_U_"K:(X?.N)!'(X'?1P.E) X"
     31 S DIR("A")="PLEASE ENTER A UNIQUE NAME"
     32GETNAM D ^DIR
     33 I $D(DIRUT) D DELETE(ROOT,IENN) Q
     34 S NAME=Y
     35 ;
     36 ;Make sure the new name is valid.
     37 I '$$VNAME^PXRMINTR(NAME,FILE) G GETNAM
     38 ;
     39 ;Change to the new name.
     40 S IENS=IENN_","
     41 S FDA(FILE,IENS,.01)=NAME
     42 K MSG
     43 D FILE^DIE("","FDA","MSG")
     44 ;Check to make sure the name was not a duplicate.
     45 I $G(MSG("DIERR",1))=740 D  G GETNAM
     46 . W !,NAME," is not a unique name!"
     47 ;Change the class to local and delete the sponsor.
     48 D SCAS(FILE,IENN,"L","")
     49 ;Initialize the edit history.
     50 D INIEH(FILE,ROOT,IENN,IENO)
     51 ;
     52 ;Reindex the cross-references.
     53 S DIK=ROOT,DA=IENN
     54 D IX^DIK
     55 W !
     56 ;
     57 ;Tell the user what has happened and allow for editing of the new item.
     58 S DIR(0)="Y"
     59 S DIR("A")="Do you want to edit it now"
     60 S DIR("A",1)="The original "_WHAT_" "_ORGNAME_" has been copied into "_NAME_"."
     61 D ^DIR Q:$D(DIRUT)
     62 I Y D EDIT^PXRMEDIT(ROOT,IENN)
     63 Q
     64 ;
     65 ;=====================================================
     66COPYREM ;Copy a reminder definition.
     67 N PROMPT,ROOT,WHAT
     68 S WHAT="reminder"
     69 S ROOT="^PXD(811.9,"
     70 S PROMPT="Select the reminder item to copy: "
     71 D COPY(PROMPT,ROOT,WHAT)
     72 Q
     73 ;
     74 ;=====================================================
     75COPYTAX ;Copy a taxonomy.
     76 N PROMPT,ROOT,WHAT
     77 S WHAT="taxonomy"
     78 S ROOT="^PXD(811.2,"
     79 S PROMPT="Select the taxonomy item to copy: "
     80 D COPY(PROMPT,ROOT,WHAT)
     81 Q
     82 ;
     83 ;=====================================================
     84COPYTERM ;Copy a reminder term.
     85 N PROMPT,ROOT,WHAT
     86 S WHAT="reminder term"
     87 S ROOT="^PXRMD(811.5,"
     88 S PROMPT="Select the reminder term to copy: "
     89 D COPY(PROMPT,ROOT,WHAT)
     90 Q
     91 ;
     92 ;=====================================================
     93DELETE(DIK,DA) ;Delete the entry just added.
     94 D ^DIK
     95 W !!,"New entry not created due to invalid name!",!
     96 Q
     97 ;
     98 ;=====================================================
     99GETFOIEN(ROOT) ;Return the first open IEN in ROOT. This should be called
     100 ;after a call to SETSTART.
     101 N ENTRY,NIEN,OIEN
     102 S ENTRY=ROOT_0_")"
     103 S OIEN=$P(@ENTRY,U,3)
     104 S ENTRY=ROOT_OIEN_")"
     105 F  S NIEN=$O(@ENTRY) Q:+(NIEN-OIEN)>1  Q:+NIEN'>0  S OIEN=NIEN,ENTRY=ROOT_NIEN_")"
     106 Q OIEN+1
     107 ;
     108 ;=====================================================
     109INIEH(FILENUM,ROOT,IENN,IENO) ;Initialize the edit history after a copy.
     110 ;First delete any existing history entries.
     111 N ENTRY,IND,IENS,FDA,FDAIEN,MSG,SFN,TARGET,WP
     112 D FIELD^DID(FILENUM,"EDIT HISTORY","","SPECIFIER","TARGET")
     113 S SFN=+$G(TARGET("SPECIFIER"))
     114 I SFN=0 Q
     115 S ENTRY=ROOT_IENN_",110)"
     116 S IND=0
     117 F  S IND=$O(@ENTRY@(IND)) Q:+IND=0  D
     118 . S IENS=IND_","_IENN_","
     119 . S FDA(SFN,IENS,.01)="@"
     120 I $D(FDA(SFN)) D FILE^DIE("K","FDA","MSG")
     121 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
     122 ;Establish an initial entry in the edit history.
     123 K FDA,MSG
     124 S IENS="+1,"_IENN_","
     125 S FDAIEN(IENN)=IENN
     126 S FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     127 S FDA(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
     128 S FDA(SFN,IENS,2)="WP(1,1)"
     129 S WP(1,1,1)="Copied from "_$$GET1^DIQ(FILENUM,IENO,.01)
     130 D UPDATE^DIE("E","FDA","FDAIEN","MSG")
     131 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
     132 Q
     133 ;
     134 ;=====================================================
     135MERGE(IENN,IENO,ROOT) ;Use MERGE to copy ROOT(IENO into ROOT(IENN.
     136 N DEST,SOURCE
     137 S DEST=ROOT_IENN_")"
     138 ;Lock the file before merging.
     139 L +@DEST:10
     140 S SOURCE=ROOT_IENO_")"
     141 M @DEST=@SOURCE
     142 ;Unlock the file
     143 L -@DEST
     144 Q
     145 ;
     146 ;=====================================================
     147SCAS(FILENUM,IEN,CLASS,SPONSOR) ;Set the class field to CLASS and the sponsor
     148 ;field to SPONSOR.
     149 N IENS,FDA,MSG
     150 S IENS=IEN_","
     151 S FDA(FILENUM,IENS,100)=CLASS
     152 S FDA(FILENUM,IENS,101)=SPONSOR
     153 D FILE^DIE("K","FDA","MSG")
     154 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
     155 Q
     156 ;
     157 ;=====================================================
     158SETSTART(ROOT) ;Set the starting value to add new entries. Start
     159 ;at the begining so empty spaces are filled in.
     160 N CUR,ENTRY
     161 S ENTRY=ROOT_"0)"
     162 S $P(@ENTRY,U,3)=1
     163 Q
     164 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDATA.m

    r613 r623  
    1 PXRMDATA        ; SLC/PKR - Routines for getting data. ;04/02/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;===============================================
    5 GETDATA(FILENUM,DAS,FIEVT)      ;Return data for a finding.
    6         K FIEVT
    7         I FILENUM=45 D GETDATA^PXRMDGPT(DAS,.FIEVT) Q
    8         I FILENUM=52 D GETDATA^PXRMDOUT(DAS,.FIEVT) Q
    9         I FILENUM=55 D GETDATA^PXRMDIN(DAS,.FIEVT)  Q
    10         I FILENUM="55NVA" D GETDATA^PXRMDNVA(DAS,.FIEVT) Q
    11         I FILENUM=63 D GETDATA^PXRMLAB(DAS,.FIEVT) Q
    12         I FILENUM=70 D GETDATA^PXRMRAD(DAS,.FIEVT) Q
    13         I FILENUM=100 D GETDATA^PXRMORDR(DAS,.FIEVT) Q
    14         I FILENUM=120.5 D GETDATA^PXRMVITL(DAS,.FIEVT) Q
    15         I FILENUM=601.84 D GETDATA^PXRMMH(DAS,.FIEVT) Q
    16         I FILENUM=9000010 D GETDATA^PXRMVSIT(DAS,.FIEVT,1) Q
    17         I FILENUM=9000010.07 D GETDATA^PXRMVPOV(DAS,.FIEVT) Q
    18         I FILENUM=9000010.11 D GETDATA^PXRMIMM(DAS,.FIEVT) Q
    19         I FILENUM=9000010.12 D GETDATA^PXRMSKIN(DAS,.FIEVT) Q
    20         I FILENUM=9000010.13 D GETDATA^PXRMEXAM(DAS,.FIEVT) Q
    21         I FILENUM=9000010.16 D GETDATA^PXRMEDU(DAS,.FIEVT) Q
    22         I FILENUM=9000010.18 D GETDATA^PXRMVCPT(DAS,.FIEVT) Q
    23         I FILENUM=9000010.23 D GETDATA^PXRMHF(DAS,.FIEVT) Q
    24         I FILENUM=9000011 D GETDATA^PXRMPROB(DAS,.FIEVT) Q
    25         Q
    26         ;
    27         ;===============================================
    28 GETFNAME(FINDING)       ;Given a finding of the form IEN;GLOBAL return its name.
    29         N DIC,DO,IEN,FNUM,GLOBAL
    30         S IEN=$P(FINDING,";",1)
    31         S GLOBAL=$P(FINDING,";",2)
    32         S GLOBAL=$S(GLOBAL="PS(55NVA,":"PS(50.7,",GLOBAL="PS(55,":"PSDRUG(",1:GLOBAL)
    33         S DIC="^"_GLOBAL
    34         D DO^DIC1
    35         S FNUM=+$P(DO,U,2)
    36         Q $$GET1^DIQ(FNUM,IEN,.01)
    37         ;
    38         ;===============================================
    39 GETFNUM(ENODE)  ;Given an ENODE return the file number for the data source.
    40         I ENODE="AUTTEDT(" Q 9000010.16
    41         I ENODE="AUTTEXAM(" Q 9000010.13
    42         I ENODE="AUTTHF(" Q 9000010.23
    43         I ENODE="AUTTIMM(" Q 9000010.11
    44         I ENODE="AUTTSK(" Q 9000010.12
    45         I ENODE="GMRD(120.51," Q 120.5
    46         I ENODE="LAB(60," Q 63
    47         I ENODE="ORD(101.43," Q 100
    48         I ENODE="PXD(811.2," Q 811.2
    49         I ENODE="PXRMD(810.9," Q 9000010
    50         I ENODE="PXRMD(811.4," Q 811.4
    51         I ENODE="PXRMD(811.5," Q 811.5
    52         I ENODE="PS(50.605," Q 52_U_55_U_"55NVA"
    53         I ENODE="PS(55," Q 55
    54         I ENODE="PS(55NVA," Q "55NVA"
    55         I ENODE="PSDRUG(" Q 52_U_55_U_"55NVA"
    56         I ENODE="PSNDF(50.6," Q 52_U_55_U_"55NVA"
    57         I ENODE="PSRX(" Q 52
    58         I ENODE="RAMIS(71," Q 70
    59         I ENODE="YTT(601.71," Q 601.84
    60         Q 0
    61         ;
     1PXRMDATA ; SLC/PKR - Routines for getting data. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;===============================================
     5GETDATA(FILENUM,DAS,FIEVT) ;Return data for a finding.
     6 K FIEVT
     7 I FILENUM=45 D GETDATA^PXRMDGPT(DAS,.FIEVT) Q
     8 I FILENUM=52 D GETDATA^PXRMDOUT(DAS,.FIEVT) Q
     9 I FILENUM=55 D GETDATA^PXRMDIN(DAS,.FIEVT)  Q
     10 I FILENUM="55NVA" D GETDATA^PXRMDNVA(DAS,.FIEVT) Q
     11 I FILENUM=63 D GETDATA^PXRMLAB(DAS,.FIEVT) Q
     12 I FILENUM=70 D GETDATA^PXRMRAD(DAS,.FIEVT) Q
     13 I FILENUM=100 D GETDATA^PXRMORDR(DAS,.FIEVT) Q
     14 I FILENUM=120.5 D GETDATA^PXRMVITL(DAS,.FIEVT) Q
     15 I FILENUM=601.2 D GETDATA^PXRMMH(DAS,.FIEVT) Q
     16 I FILENUM=9000010 D GETDATA^PXRMVSIT(DAS,.FIEVT,1) Q
     17 I FILENUM=9000010.07 D GETDATA^PXRMVPOV(DAS,.FIEVT) Q
     18 I FILENUM=9000010.11 D GETDATA^PXRMIMM(DAS,.FIEVT) Q
     19 I FILENUM=9000010.12 D GETDATA^PXRMSKIN(DAS,.FIEVT) Q
     20 I FILENUM=9000010.13 D GETDATA^PXRMEXAM(DAS,.FIEVT) Q
     21 I FILENUM=9000010.16 D GETDATA^PXRMEDU(DAS,.FIEVT) Q
     22 I FILENUM=9000010.18 D GETDATA^PXRMVCPT(DAS,.FIEVT) Q
     23 I FILENUM=9000010.23 D GETDATA^PXRMHF(DAS,.FIEVT) Q
     24 I FILENUM=9000011 D GETDATA^PXRMPROB(DAS,.FIEVT) Q
     25 Q
     26 ;
     27 ;===============================================
     28GETFNAME(FINDING) ;Given a finding of the form IEN;GLOBAL return its name.
     29 N DIC,DO,IEN,FNUM,GLOBAL
     30 S IEN=$P(FINDING,";",1)
     31 S GLOBAL=$P(FINDING,";",2)
     32 S GLOBAL=$S(GLOBAL="PS(55NVA,":"PS(50.7,",GLOBAL="PS(55,":"PSDRUG(",1:GLOBAL)
     33 S DIC="^"_GLOBAL
     34 D DO^DIC1
     35 S FNUM=+$P(DO,U,2)
     36 Q $$GET1^DIQ(FNUM,IEN,.01)
     37 ;
     38 ;===============================================
     39GETFNUM(ENODE) ;Given an ENODE return the file number for the data source.
     40 I ENODE="AUTTEDT(" Q 9000010.16
     41 I ENODE="AUTTEXAM(" Q 9000010.13
     42 I ENODE="AUTTHF(" Q 9000010.23
     43 I ENODE="AUTTIMM(" Q 9000010.11
     44 I ENODE="AUTTSK(" Q 9000010.12
     45 I ENODE="GMRD(120.51," Q 120.5
     46 I ENODE="LAB(60," Q 63
     47 I ENODE="ORD(101.43," Q 100
     48 I ENODE="PXD(811.2," Q 811.2
     49 I ENODE="PXRMD(810.9," Q 9000010
     50 I ENODE="PXRMD(811.4," Q 811.4
     51 I ENODE="PXRMD(811.5," Q 811.5
     52 I ENODE="PS(50.605," Q 52_U_55_U_"55NVA"
     53 I ENODE="PS(55," Q 55
     54 I ENODE="PS(55NVA," Q "55NVA"
     55 I ENODE="PSDRUG(" Q 52_U_55_U_"55NVA"
     56 I ENODE="PSNDF(50.6," Q 52_U_55_U_"55NVA"
     57 I ENODE="PSRX(" Q 52
     58 I ENODE="RAMIS(71," Q 70
     59 I ENODE="YTT(601," Q 601.2
     60 Q 0
     61 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDATE.m

    r613 r623  
    1 PXRMDATE        ; SLC/PKR - Clinical Reminders date utilities. ;01/24/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;==================================================
    5 CEFD(FDA)       ;Called by the Exchange Utility only if the input packed
    6         ;reminder was packed under v1.5  Move Effective Date to Beginning Date.
    7         N IND
    8         S IND=""
    9         F  S IND=$O(FDA(811.902,IND)) Q:IND=""  D
    10         . I '$D(FDA(811.902,IND,12)) Q
    11         .;If the EFFECTIVE PERIOD exists don't do anything.
    12         . I $D(FDA(811.902,IND,9)) Q
    13         . S FDA(811.902,IND,9)=FDA(811.902,IND,12)
    14         . K FDA(811.902,IND,12)
    15         Q
    16         ;
    17         ;==================================================
    18 COMPARE(X)      ;Compare beginning and ending dates, give a warning if
    19         ;Ending Date comes before Beginning Date. Called by ADATE xref in
    20         ;definitions and terms.
    21         ;Do not execute as part of exchange.
    22         I $G(PXRMEXCH) Q
    23         N BDT,EDT
    24         S BDT=$S(X(1)'="":$$CTFMD^PXRMDATE(X(1)),1:0)
    25         S EDT=X(2)
    26         I EDT="" S EDT="T"
    27         S EDT=$$CTFMD^PXRMDATE(EDT)
    28         ;If EDT does not contain a time set it to the end of the day.
    29         I EDT'["." S EDT=EDT_".235959"
    30         I EDT<BDT D
    31         . S BDT=$S(X(1)'="":X(1),1:"")
    32         . S EDT=$S(X(2)'="":X(2),1:"T@2400")
    33         . S TEXT="Warning the ending date ("_EDT_") is before the beginning date ("_BDT_")"
    34         . D EN^DDIOL(TEXT)
    35         Q
    36         ;
    37         ;==================================================
    38 COTN(EFP)       ;Convert an Effective Period to the new date/time format.
    39         ;Possible effective periods are ND, NM, or NY where N is an integer.
    40         S EFP=$$UP^XLFSTR(EFP)
    41         I (EFP?1N.N1"D")!(EFP?1N.N1"M")!(EFP?1N.N1"Y") D
    42         . S NUM=+EFP
    43         . S EFP=$S(NUM=0:"T",1:"T-"_EFP)
    44         Q EFP
    45         ;
    46         ;==================================================
    47 CTFMD(DATE)     ;Convert DATE which may be in any of the FileMan acceptable
    48         ;forms as well as T-NY to a FileMan date. Also understands LAD for
    49         ;Last Admission Date.
    50         N %DT,ND,X,Y
    51         ;Already a FileMan date?
    52         S ND=+DATE
    53         I (ND'<1000000),(ND'>9991231) Q DATE
    54         ;Check for a date FileMan understands.
    55         S X=DATE,%DT="ST"
    56         D ^%DT
    57         ;If it is not a FileMan date check for a symbolic date.
    58         I Y=-1 S Y=$$SYMDATE(DATE)
    59         ;If it is not a date that is understood by SYMDATE return -1
    60         I Y=-1 Q -1
    61         I $G(PXRMDATE)'="",$$ISVSYMD(DATE) D
    62         . N DIFFS
    63         . S DIFFS=-$$FMDIFF^XLFDT(DT,PXRMDATE,2)
    64         . S Y=$$FMADD^XLFDT(Y,0,0,0,DIFFS)
    65         I DATE["LAD" D
    66         . I $G(PXRMLAD)="" S Y=0
    67         . E  D
    68         .. N DIFFS
    69         .. S DIFFS=-$$FMDIFF^XLFDT(DT,$G(PXRMLAD),2)
    70         .. S Y=$$FMADD^XLFDT(Y,0,0,0,DIFFS)
    71         Q Y
    72         ;
    73         ;=================================================
    74 DCHECK(DATE)    ;Trap for special characters before calling CTFMD^PXRMDATE.
    75         ;Used in DIR("PRE") for date inputs.
    76         I $D(DTOUT) Q DATE
    77         I DATE="" Q DATE
    78         I DATE["^" Q DATE
    79         I DATE["?" Q DATE
    80         Q $$CTFMD^PXRMDATE(DATE)
    81         ;
    82         ;==================================================
    83 DUE(DEFARR,RESDATE,FREQ,DUE,DUEDATE,FIEVAL)     ;Compute the due date.
    84         ;This is the date of the resolution finding + the reminder frequency.
    85         ;Subtract the due in advance time to see if the reminder should be
    86         ;marked as due soon.
    87         ;
    88         N DATE,DIAT,DIATOK,LDATE,PXRMITEM,TDDUE,TODAY
    89         S PXRMITEM=DEFARR("IEN")
    90         ;If the final frequency is 0Y then the reminder is not due.
    91         I FREQ="0Y" S DUE=0,DUEDATE="" Q
    92         ;
    93         S DUEDATE=""
    94         ;Check for custom date due.
    95         I DEFARR(45)'="" S DUEDATE=$$CDUEDATE^PXRMCDUE(.DEFARR,.FIEVAL)
    96         I DUEDATE'="",DUEDATE'=-1 G SETDUE
    97         ;
    98         ;No custom date due, do regular date calculation.
    99         I (FREQ="")!(FREQ=-1) D  Q
    100         . S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","NOFREQ")="No reminder frequency - cannot compute due date!"
    101         . S (DUE,DUEDATE)="CNBD"
    102         ;
    103         S LDATE=$S(RESDATE["X":0,1:+RESDATE)
    104         I LDATE=0 S (DUE,DUEDATE)="DUE NOW" Q
    105         S DATE=$$FULLDATE(LDATE),DUEDATE=$$NEWDATE(DATE,FREQ)
    106         ;
    107 SETDUE  ;If the due date is less than or equal to today's date the reminder
    108         ;is due.
    109         S TODAY=$$NOW^PXRMDATE
    110         I +DUEDATE'>TODAY S DUE="DUE NOW"  Q
    111         ;
    112         S DIAT="-"_$P(DEFARR(0),U,4)
    113         I DIAT="-" D
    114         . S DIATOK=0
    115         . S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","DIAT")="Warning no do in advance time"
    116         E  S DIATOK=1
    117         ;
    118         S TDDUE=$S(DIATOK=1:$$NEWDATE(DUEDATE,DIAT),1:DUEDATE)
    119         S DUE=$S(TDDUE'>TODAY:"DUE SOON",1:"RESOLVED")
    120         Q
    121         ;
    122         ;==================================================
    123 DURATION(START,STOP)    ;Return the number days between the Start Date and
    124         ;Stop Date.
    125         I +START=0 Q 0
    126         N PXRMNOW
    127         S PXRMNOW=$$NOW^PXRMDATE
    128         I START>PXRMNOW Q 0
    129         I (STOP="")!(STOP>PXRMNOW) S STOP=PXRMNOW
    130         Q $$FMDIFF^XLFDT(STOP,START)
    131         ;
    132         ;==================================================
    133 EDATE(DATE)     ;Check for an historical (event) date, format as appropriate.
    134         Q $$FMTE^XLFDT(DATE,"5DZ")
    135         ;
    136         ;==================================================
    137 FULLDATE(DATE)  ;See if DATE is a full date, i.e., it has a month and
    138         ;a day along with a year. If the month is missing assume Jan. If the
    139         ;day is missing assume the first. Issue a warning so the user knows
    140         ;what happened. DATE should be in Fileman format.
    141         N DAY,MISSING,MONTH,TDATE,YEAR
    142         S TDATE=DATE
    143         S MISSING=0
    144         S DAY=$E(DATE,6,7)
    145         S MONTH=$E(DATE,4,5)
    146         S YEAR=$E(DATE,1,3)
    147         I +DAY=0 D
    148         . S DAY=1
    149         . S MISSING=1
    150         . S ^TMP(PXRMPID,$J,PXRMITEM,"INFO","NO DAY")="Encounter date missing the day, using the first for the date due calculation."
    151         I +MONTH=0 D
    152         . S MONTH=1
    153         . S MISSING=1
    154         . S ^TMP(PXRMPID,$J,PXRMITEM,"INFO","NO MONTH")="Encounter date missing the month, using January for the date due calculation."
    155         I MISSING D
    156         . S TDATE=(YEAR*1E4)+(MONTH*1E2)+DAY
    157         . I DATE["E" S TDATE=TDATE_"E"
    158         Q TDATE
    159         ;
    160         ;==================================================
    161 FRQINDAY(FREQ)  ;Given a frequency in the form ND, NM, or NY where N is a
    162         ;number and D stands for days, M for months, and Y for years return
    163         ;the value in days.
    164         I FREQ="" Q ""
    165         N CODE,LEN,MULT,NUM
    166         S LEN=$L(FREQ)
    167         S NUM=$E(FREQ,1,LEN-1)
    168         S CODE=$E(FREQ,LEN,LEN)
    169         S MULT=1.0
    170         I CODE="M" S MULT=30.42
    171         I CODE="Y" S MULT=365.25
    172         Q +(MULT*NUM)
    173         ;
    174         ;==================================================
    175 ISVSYMD(DATE)   ;Return true if DATE is a valid symbolic date.
    176         N P1,P1OK,P2,P2OK,OP,PAT
    177         S DATE=$P(DATE,"@",1)
    178         S OP=$S(DATE["+":"+",1:"-")
    179         S P1=$P(DATE,OP,1),P1OK=0
    180         F PAT="T","TODAY","N","NOW" I P1=PAT S P1OK=1 Q:P1OK
    181         I PAT=DATE Q 1
    182         S P2=$P(DATE,OP,2),P2OK=0
    183         F PAT="1N.N","1N.N1""D""","1N.N1""M""","1N.N1""Y""" I P2?@PAT S P2OK=1 Q:P2OK
    184         Q P1OK&P2OK
    185         ;
    186         ;==================================================
    187 NEWDATE(FMDATE,OFFSET)  ;Given a date in VA Fileman format (FMDATE) and an
    188         ;offset of the form NY, NM, ND where N is a number and Y stands for
    189         ;years, M for months, and D for days return the new date in VA Fileman
    190         ;format.
    191         I FMDATE=0 Q 0
    192         N LEN,NEWDATE,NUM,UNIT
    193         S LEN=$L(OFFSET)
    194         S NUM=+$E(OFFSET,1,LEN-1)
    195         S UNIT=$E(OFFSET,LEN)
    196         I UNIT="D" G DAY
    197         I UNIT="M" G MONTH
    198         I UNIT="Y" G YEAR
    199         ;Unknown unit just return the original date
    200         Q FMDATE
    201 DAY     ;
    202         S NEWDATE=+$$FMADD^XLFDT(FMDATE,NUM)
    203         Q NEWDATE
    204 MONTH   ;
    205         ;Convert the months to days and then add the days using the DAY code.
    206         ;Multiply the number of months by the average number of days in a month.
    207         N INT,FRAC
    208         S NUM=30.42*NUM
    209         ;Round the number of days, FMADD^XLFDT has problems with non-integer
    210         ;days.
    211         S INT=+$P(NUM,".",1)
    212         S FRAC=NUM-INT
    213         I FRAC<0.5 S NUM=INT
    214         E  S NUM=INT+1
    215         G DAY
    216         Q
    217 YEAR    ;
    218         Q FMDATE+(10000*NUM)
    219         ;
    220         ;==================================================
    221 NOW()   ;If the reminder global PXRMDATE is defined return it, otherwise
    222         ;return the current date and time.
    223         Q $S(+$G(PXRMDATE)>0:PXRMDATE,1:$$NOW^XLFDT)
    224         ;
    225         ;==================================================
    226 SYMDATE(DATE)   ;Convert a symbolic date into a FileMan date.
    227         N %DT,OPER,PFSTACK,SYM,TIME,X,Y
    228         S TIME=$P(DATE,"@",2),DATE=$P(DATE,"@",1)
    229         S X=$S(DATE="LAD":$G(PXRMLAD),1:"")
    230         I X="" D
    231         . S OPER="+-"
    232         . D POSTFIX^PXRMSTAC(DATE,OPER,.PFSTACK)
    233         I PFSTACK(0)=3 D
    234         . S SYM=PFSTACK(1)
    235         . S SYM=$S(SYM="LAD":"T",SYM="N":"N",SYM="NOW":"N",SYM="T":"T",SYM="TODAY":"T",1:"")
    236         . I SYM="" S Y=-1 Q
    237         .;FileMan only handles D, W, or M so convert Y to months.
    238         . I PFSTACK(2)["Y" S PFSTACK(2)=+PFSTACK(2)*12_"M"
    239         . S X=SYM_PFSTACK(3)_PFSTACK(2)
    240         I PFSTACK(0)=1 S X=PFSTACK(1)
    241         I TIME'="" S X=X_"@"_TIME
    242         S %DT="ST"
    243         D ^%DT
    244         Q Y
    245         ;
    246         ;==================================================
    247 VDATE(VIEN)     ;Given a visit ien return the visit date.
    248         N DATE
    249         I +VIEN>0 S DATE=$P($G(^AUPNVSIT(VIEN,0)),U,1)
    250         E  S DATE=0
    251         I $L(DATE)=0 S DATE=0
    252         ;Check for historical encounter.
    253         I $$ISHIST^PXRMVSIT(VIEN) S DATE=DATE_"E"
    254         Q DATE
    255         ;
     1PXRMDATE ; SLC/PKR - Clinical Reminders date utilities. ;06/20/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;==================================================
     5CEFD(FDA) ;Called by the Exchange Utility only if the input packed
     6 ;reminder was packed under v1.5  Move Effective Date to Beginning Date.
     7 N IND
     8 S IND=""
     9 F  S IND=$O(FDA(811.902,IND)) Q:IND=""  D
     10 . I '$D(FDA(811.902,IND,12)) Q
     11 .;If the EFFECTIVE PERIOD exists don't do anything.
     12 . I $D(FDA(811.902,IND,9)) Q
     13 . S FDA(811.902,IND,9)=FDA(811.902,IND,12)
     14 . K FDA(811.902,IND,12)
     15 Q
     16 ;
     17 ;==================================================
     18COMPARE(X) ;Compare beginning and ending dates, give a warning if
     19 ;Ending Date comes before Beginning Date. Called by ADATE xref in
     20 ;definitions and terms.
     21 ;Do not execute as part of exchange.
     22 I $G(PXRMEXCH) Q
     23 N BDT,EDT
     24 S BDT=$S(X(1)'="":$$CTFMD^PXRMDATE(X(1)),1:0)
     25 S EDT=X(2)
     26 I EDT="" S EDT="T"
     27 S EDT=$$CTFMD^PXRMDATE(EDT)
     28 ;If EDT does not contain a time set it to the end of the day.
     29 I EDT'["." S EDT=EDT_".235959"
     30 I EDT<BDT D
     31 . S BDT=$S(X(1)'="":X(1),1:"")
     32 . S EDT=$S(X(2)'="":X(2),1:"T@2400")
     33 . S TEXT="Warning the ending date ("_EDT_") is before the beginning date ("_BDT_")"
     34 . D EN^DDIOL(TEXT)
     35 Q
     36 ;
     37 ;==================================================
     38COTN(EFP) ;Convert an Effective Period to the new date/time format.
     39 ;Possible effective periods are ND, NM, or NY where N is an integer.
     40 S EFP=$$UP^XLFSTR(EFP)
     41 I (EFP?1N.N1"D")!(EFP?1N.N1"M")!(EFP?1N.N1"Y") D
     42 . S NUM=+EFP
     43 . S EFP=$S(NUM=0:"T",1:"T-"_EFP)
     44 Q EFP
     45 ;
     46 ;==================================================
     47CTFMD(DATE) ;Convert DATE which may be in any of the FileMan acceptable
     48 ;forms as well as T-NY to a FileMan date. Also understands LAD for
     49 ;Last Admission Date.
     50 N %DT,X,Y
     51 ;Check for a date FileMan understands.
     52 S X=DATE,%DT="ST"
     53 D ^%DT
     54 ;If it is not a FileMan date check for a symbolic date.
     55 I Y=-1 S Y=$$SYMDATE(DATE)
     56 ;If it is not a date that is understood by SYMDATE return -1
     57 I Y=-1 Q -1
     58 I $G(PXRMDATE)'="",$$ISVSYMD(DATE) D
     59 . N DIFFS
     60 . S DIFFS=-$$FMDIFF^XLFDT(DT,PXRMDATE,2)
     61 . S Y=$$FMADD^XLFDT(Y,0,0,0,DIFFS)
     62 I DATE["LAD" D
     63 . I $G(PXRMLAD)="" S Y=0
     64 . E  D
     65 .. N DIFFS
     66 .. S DIFFS=-$$FMDIFF^XLFDT(DT,$G(PXRMLAD),2)
     67 .. S Y=$$FMADD^XLFDT(Y,0,0,0,DIFFS)
     68 Q Y
     69 ;
     70 ;=================================================
     71DCHECK(DATE) ;Trap for special characters before calling CTFMD^PXRMDATE.
     72 ;Used in DIR("PRE") for date inputs.
     73 I $D(DTOUT) Q DATE
     74 I DATE="" Q DATE
     75 I DATE["^" Q DATE
     76 I DATE["?" Q DATE
     77 Q $$CTFMD^PXRMDATE(DATE)
     78 ;
     79 ;==================================================
     80DUE(DEFARR,RESDATE,FREQ,DUE,DUEDATE,FIEVAL) ;Compute the due date.
     81 ;This is the date of the resolution finding + the reminder frequency.
     82 ;Subtract the due in advance time to see if the reminder should be
     83 ;marked as due soon.
     84 ;
     85 N DATE,DIAT,DIATOK,LDATE,PXRMITEM,TDDUE,TODAY
     86 S PXRMITEM=DEFARR("IEN")
     87 ;If the final frequency is 0Y then the reminder is not due.
     88 I FREQ="0Y" S DUE=0,DUEDATE="" Q
     89 ;
     90 S DUEDATE=""
     91 ;Check for custom date due.
     92 I DEFARR(45)'="" S DUEDATE=$$CDUEDATE^PXRMCDUE(.DEFARR,.FIEVAL)
     93 I DUEDATE'="",DUEDATE'=-1 G SETDUE
     94 ;
     95 ;No custom date due, do regular date calculation.
     96 I (FREQ="")!(FREQ=-1) D  Q
     97 . S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","NOFREQ")="No reminder frequency - cannot compute due date!"
     98 . S (DUE,DUEDATE)="CNBD"
     99 ;
     100 S LDATE=$S(RESDATE["X":0,1:+RESDATE)
     101 I LDATE=0 S (DUE,DUEDATE)="DUE NOW" Q
     102 S DATE=$$FULLDATE(LDATE),DUEDATE=$$NEWDATE(DATE,FREQ)
     103 ;
     104SETDUE ;If the due date is less than or equal to today's date the reminder
     105 ;is due.
     106 S TODAY=$$NOW^PXRMDATE
     107 I +DUEDATE'>TODAY S DUE="DUE NOW"  Q
     108 ;
     109 S DIAT="-"_$P(DEFARR(0),U,4)
     110 I DIAT="-" D
     111 . S DIATOK=0
     112 . S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","DIAT")="Warning no do in advance time"
     113 E  S DIATOK=1
     114 ;
     115 S TDDUE=$S(DIATOK=1:$$NEWDATE(DUEDATE,DIAT),1:DUEDATE)
     116 S DUE=$S(TDDUE'>TODAY:"DUE SOON",1:"RESOLVED")
     117 Q
     118 ;
     119 ;==================================================
     120DURATION(START,STOP) ;Return the number days between the Start Date and
     121 ;Stop Date.
     122 I +START=0 Q 0
     123 N PXRMNOW
     124 S PXRMNOW=$$NOW^PXRMDATE
     125 I START>PXRMNOW Q 0
     126 I (STOP="")!(STOP>PXRMNOW) S STOP=PXRMNOW
     127 Q $$FMDIFF^XLFDT(STOP,START)
     128 ;
     129 ;==================================================
     130EDATE(DATE) ;Check for an historical (event) date, format as appropriate.
     131 Q $$FMTE^XLFDT(DATE,"5DZ")
     132 ;
     133 ;==================================================
     134FULLDATE(DATE) ;See if DATE is a full date, i.e., it has a month and
     135 ;a day along with a year. If the month is missing assume Jan. If the
     136 ;day is missing assume the first. Issue a warning so the user knows
     137 ;what happened. DATE should be in Fileman format.
     138 N DAY,MISSING,MONTH,TDATE,YEAR
     139 S TDATE=DATE
     140 S MISSING=0
     141 S DAY=$E(DATE,6,7)
     142 S MONTH=$E(DATE,4,5)
     143 S YEAR=$E(DATE,1,3)
     144 I +DAY=0 D
     145 . S DAY=1
     146 . S MISSING=1
     147 . S ^TMP(PXRMPID,$J,PXRMITEM,"INFO","NO DAY")="Encounter date missing the day, using the first for the date due calculation."
     148 I +MONTH=0 D
     149 . S MONTH=1
     150 . S MISSING=1
     151 . S ^TMP(PXRMPID,$J,PXRMITEM,"INFO","NO MONTH")="Encounter date missing the month, using January for the date due calculation."
     152 I MISSING D
     153 . S TDATE=(YEAR*1E4)+(MONTH*1E2)+DAY
     154 . I DATE["E" S TDATE=TDATE_"E"
     155 Q TDATE
     156 ;
     157 ;==================================================
     158FRQINDAY(FREQ) ;Given a frequency in the form ND, NM, or NY where N is a
     159 ;number and D stands for days, M for months, and Y for years return
     160 ;the value in days.
     161 I FREQ="" Q ""
     162 N CODE,LEN,MULT,NUM
     163 S LEN=$L(FREQ)
     164 S NUM=$E(FREQ,1,LEN-1)
     165 S CODE=$E(FREQ,LEN,LEN)
     166 S MULT=1.0
     167 I CODE="M" S MULT=30.42
     168 I CODE="Y" S MULT=365.25
     169 Q +(MULT*NUM)
     170 ;
     171 ;==================================================
     172ISVSYMD(DATE) ;Return true if DATE is a valid symbolic date.
     173 N P1,P1OK,P2,P2OK,OP,PAT
     174 S DATE=$P(DATE,"@",1)
     175 S OP=$S(DATE["+":"+",1:"-")
     176 S P1=$P(DATE,OP,1),P1OK=0
     177 F PAT="T","TODAY","N","NOW" I P1=PAT S P1OK=1 Q:P1OK
     178 I PAT=DATE Q 1
     179 S P2=$P(DATE,OP,2),P2OK=0
     180 F PAT="1N.N","1N.N1""D""","1N.N1""M""","1N.N1""Y""" I P2?@PAT S P2OK=1 Q:P2OK
     181 Q P1OK&P2OK
     182 ;
     183 ;==================================================
     184NEWDATE(FMDATE,OFFSET) ;Given a date in VA Fileman format (FMDATE) and an
     185 ;offset of the form NY, NM, ND where N is a number and Y stands for
     186 ;years, M for months, and D for days return the new date in VA Fileman
     187 ;format.
     188 I FMDATE=0 Q 0
     189 N LEN,NEWDATE,NUM,UNIT
     190 S LEN=$L(OFFSET)
     191 S NUM=+$E(OFFSET,1,LEN-1)
     192 S UNIT=$E(OFFSET,LEN)
     193 I UNIT="D" G DAY
     194 I UNIT="M" G MONTH
     195 I UNIT="Y" G YEAR
     196 ;Unknown unit just return the original date
     197 Q FMDATE
     198DAY ;
     199 S NEWDATE=+$$FMADD^XLFDT(FMDATE,NUM)
     200 Q NEWDATE
     201MONTH ;
     202 ;Convert the months to days and then add the days using the DAY code.
     203 ;Multiply the number of months by the average number of days in a month.
     204 N INT,FRAC
     205 S NUM=30.42*NUM
     206 ;Round the number of days, FMADD^XLFDT has problems with non-integer
     207 ;days.
     208 S INT=+$P(NUM,".",1)
     209 S FRAC=NUM-INT
     210 I FRAC<0.5 S NUM=INT
     211 E  S NUM=INT+1
     212 G DAY
     213 Q
     214YEAR ;
     215 Q FMDATE+(10000*NUM)
     216 ;
     217 ;==================================================
     218NOW() ;If the reminder global PXRMDATE is defined return it, otherwise
     219 ;return the current date and time.
     220 Q $S(+$G(PXRMDATE)>0:PXRMDATE,1:$$NOW^XLFDT)
     221 ;
     222 ;==================================================
     223SYMDATE(DATE) ;Convert a symbolic date into a FileMan date.
     224 N %DT,OPER,PFSTACK,SYM,TIME,X,Y
     225 S TIME=$P(DATE,"@",2),DATE=$P(DATE,"@",1)
     226 S X=$S(DATE="LAD":$G(PXRMLAD),1:"")
     227 I X="" D
     228 . S OPER="+-"
     229 . D POSTFIX^PXRMSTAC(DATE,OPER,.PFSTACK)
     230 I PFSTACK(0)=3 D
     231 . S SYM=PFSTACK(1)
     232 . S SYM=$S(SYM="LAD":"T",SYM="N":"N",SYM="NOW":"N",SYM="T":"T",SYM="TODAY":"T",1:"")
     233 . I SYM="" S Y=-1 Q
     234 .;FileMan only handles D, W, or M so convert Y to months.
     235 . I PFSTACK(2)["Y" S PFSTACK(2)=+PFSTACK(2)*12_"M"
     236 . S X=SYM_PFSTACK(3)_PFSTACK(2)
     237 I PFSTACK(0)=1 S X=PFSTACK(1)
     238 I TIME'="" S X=X_"@"_TIME
     239 S %DT="ST"
     240 D ^%DT
     241 Q Y
     242 ;
     243 ;==================================================
     244VDATE(VIEN) ;Given a visit ien return the visit date.
     245 N DATE
     246 I +VIEN>0 S DATE=$P($G(^AUPNVSIT(VIEN,0)),U,1)
     247 E  S DATE=0
     248 I $L(DATE)=0 S DATE=0
     249 ;Check for historical encounter.
     250 I $$ISHIST^PXRMVSIT(VIEN) S DATE=DATE_"E"
     251 Q DATE
     252 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDBL3.m

    r613 r623  
    1 PXRMDBL3        ; SLC/PJH - Reminder Dialog Generation. (overflow) ;11/08/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMDBL1
    5         ;
    6         ;Set number range for site
    7 START   ;
    8         D SETSTART^PXRMCOPY("^PXRMD(801.41,")
    9         ;Update dialog file for individual dialog items
    10         D UPDATE(.ARRAY,.WPTXT,"E")
    11         ;Create reminder dialog
    12         D UPDATE(.DSET,"","R")
    13         ;
    14         W !!,"Dialog build complete" H 3
    15 END     Q
    16         ;
    17         ;Error Handler
    18         ;-------------
    19 ERR(DESC)       ;
    20         N ERROR,IC,REF
    21         S ERROR(1)="Unable to update dialog file : "_DESC
    22         S ERROR(2)="Error in UPDATE^DIE, needs further investigation"
    23         ;Move MSG into ERROR
    24         S REF="MSG"
    25         F IC=3:1 S REF=$Q(@REF) Q:REF=""  S ERROR(IC)=REF_"="_@REF
    26         ;Screen message
    27         D BMES^XPDUTL(.ERROR)
    28         Q
    29         ;
    30         ;Check if dialog element already exists
    31         ;--------------------------------------
    32 EXISTS(NAME)    ;
    33         N IEN S IEN=$O(^PXRMD(801.41,"B",NAME,""))
    34         I IEN S DSET(1,CNT*5)=IEN Q 1
    35         Q 0
    36         ;
    37         ;Update edit history
    38         ;-------------------
    39 HIS(IENN)       ;
    40         ;First delete any existing history entries.
    41         N ENTRY,IND,IENS,FDA,FDAIEN,MSG,WP
    42         S ENTRY="^PXRMD(801.41,"_IENN_",110)"
    43         S IND=0
    44         F  S IND=$O(@ENTRY@(IND)) Q:+IND=0  D
    45         . S IENS=IND_","_IENN_","
    46         . S FDA(801.44,IENS,.01)="@"
    47         I $D(FDA(801.44)) D
    48         .D FILE^DIE("K","FDA","MSG") I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    49         ;Establish an initial entry in the edit history.
    50         K FDA,MSG
    51         S IENS="+1,"_IENN_","
    52         S FDAIEN(IENN)=IENN
    53         S FDA(801.44,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    54         S FDA(801.44,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
    55         S FDA(801.44,IENS,2)="WP(1,1)"
    56         S WP(1,1,1)="Autogenerated"
    57         D UPDATE^DIE("E","FDA","FDAIEN","MSG")
    58         I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    59         Q
    60         ;
    61         ;Mental Health
    62         ;-------------
    63 MHOK(IEN)       ;
    64         N RNAME,TEST,YT S YT=""
    65         ;Convert ien to name
    66         ;DBIA #5044
    67         S YT("CODE")=$P($G(^YTT(601.71,IEN,0)),U)
    68         ;Quit if no code found
    69         I YT("CODE")="" Q 0
    70         I '$$OK^PXRMDLL(IEN) Q 0
    71         ;Check if valid
    72         ;I TEST(1)["[ERROR]" Q 0
    73         ;
    74         S DNAME=FTYP_" "_YT("CODE")
    75         ;Create arrays
    76         S CNT=CNT+1
    77         ;Convert dialog item name to UC
    78         S DNAME=$TR(DNAME,LOWER,UPPER)
    79         ;Truncate the item name - without finesse
    80         S DSHORT=DNAME
    81         I $L(DSHORT)>40 S DSHORT=$E(DNAME,1,40)
    82         ;Dialog item name, finding item and result
    83         S ARRAY(CNT)=DSHORT_U_U_RESN_U
    84         ;Commented out Result Group Patch 6 until a decision can be made
    85         ;Result group name
    86         ;S RNAME="PXRM "_YT("CODE")_" RESULT GROUP"
    87         ;Result pointer
    88         ;S $P(ARRAY(CNT),U,7)=$O(^PXRMD(801.41,"B",RNAME,""))
    89         ;If aims exclude from p/n
    90         I YT("CODE")="AIMS" S $P(ARRAY(CNT),U,6)=1
    91         ;Prompt text
    92         S WPTXT(CNT,1)=YT("CODE")_" (Mental Health Instrument)"
    93         ;test
    94         W !!,CNT,?5,WPTXT(CNT,1)
    95         Q 1
    96         ;
    97         ;Sub-routine to update dialog file #801.41
    98         ;-----------------------------------------
    99 UPDATE(INP,WPTXT,DTYPE) ;
    100         N CNT,DATA,DESC,IEN,STRING,SUB,TEXT
    101         N FDA,FDAIEN,MSG
    102         ;Get each dialog line in turn
    103         S STRING="Updating "_$S(DTYPE="E":"Dialog Elements",1:"Reminder Dialog")
    104         D BMES^XPDUTL(STRING)
    105         ;
    106         ;Create FDA for each entry in array
    107         S CNT=""
    108         F  S CNT=$O(INP(CNT)) Q:CNT=""  D  Q:$D(MSG)
    109         .;If finding is a finding item parameter no need to build an element
    110         .I DTYPE="E",$P(INP(CNT),U)=801.43 D  Q
    111         ..S DSET(1,CNT)=$P(INP(CNT),U,2)
    112         .;Build FDA array
    113         .K FDAIEN,FDA
    114         .;If existing element and not in replace mode don't update FDA
    115         .I DTYPE="E",'PXRMREPL Q:$$EXISTS($P(INP(CNT),U))
    116         .;Name
    117         .S FDA(801.41,"?+1,",.01)=$P(INP(CNT),U)
    118         .;Dialog type
    119         .S FDA(801.41,"?+1,",4)=DTYPE
    120         .;Class
    121         .S FDA(801.41,"?+1,",100)="L"
    122         .;Sponsor
    123         .S FDA(801.41,"?+1,",101)=""
    124         .;Prompt text/finding entries
    125         .I DTYPE="E" D
    126         ..S FDA(801.41,"?+1,",13)=$P(INP(CNT),U,2)
    127         ..S FDA(801.41,"?+1,",15)=$P(INP(CNT),U,3)
    128         ..S FDA(801.41,"?+1,",17)=$P(INP(CNT),U,4)
    129         ..S FDA(801.41,"?+1,",25)="WPTXT("_CNT_")"
    130         ..;MH fields (exclude from P/N and results pointer)
    131         ..S:$P(INP(CNT),U,6) FDA(801.41,"?+1,",54)=$P(INP(CNT),U,6)
    132         ..;S:$P(INP(CNT),U,7) FDA(801.41,"?+1,",55)=$P(INP(CNT),U,7)
    133         .;Reminder dialog associated reminder/DISABLE
    134         .I DTYPE="R" D
    135         ..S FDA(801.41,"?+1,",2)=REM
    136         ..I PXRMENAB'="Y" S FDA(801.41,"?+1,",3)="DISABLED AT AUTO GENERATE"
    137         .;Dialog items point to prompts and actions, Sets point to dialog items
    138         .N ACNT,SUB
    139         .;S ACNT=0,SUB=2
    140         .S ACNT=0,SUB=1
    141         .F  S ACNT=$O(INP(CNT,ACNT)) Q:ACNT=""  D
    142         ..S SUB=SUB+1,FDA(801.412,"?+"_SUB_",?+1,",.01)=ACNT
    143         ..S FDA(801.412,"?+"_SUB_",?+1,",2)=$P(INP(CNT,ACNT),U)
    144         ..S FDA(801.412,"?+"_SUB_",?+1,",6)=$P(INP(CNT,ACNT),U,2)
    145         ..S FDA(801.412,"?+"_SUB_",?+1,",7)=$P(INP(CNT,ACNT),U,3)
    146         ..S FDA(801.412,"?+"_SUB_",?+1,",8)=$P(INP(CNT,ACNT),U,4)
    147         ..S FDA(801.412,"?+"_SUB_",?+1,",9)=$P(INP(CNT,ACNT),U,5)
    148         .;Update #801.41
    149         .D UPDATE^DIE("","FDA","FDAIEN","MSG")
    150         .I $D(MSG) D ERR($G(INP(CNT))) Q
    151         .;Save IEN of dialog created/used for later use in building dialog set
    152         .I DTYPE="E" S DSET(1,CNT*5)=FDAIEN(1)
    153         .;Insert link to reminder
    154         .I DTYPE="R",PXRMLINK="Y" D
    155         ..S $P(^PXD(811.9,REM,51),U)=FDAIEN(1),^PXD(811.9,"AG",FDAIEN(1),REM)=""
    156         .;Update Edit History
    157         .D HIS(FDAIEN(1))
    158         Q
     1PXRMDBL3 ; SLC/PJH - Reminder Dialog Generation. (overflow) ;04/30/2001
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ; Called from PXRMDBL1
     5 ;
     6 ;Set number range for site
     7START D SETSTART^PXRMCOPY("^PXRMD(801.41,")
     8 ;Update dialog file for individual dialog items
     9 D UPDATE(.ARRAY,.WPTXT,"E")
     10 ;Create reminder dialog
     11 D UPDATE(.DSET,"","R")
     12 ;
     13 W !!,"Dialog build complete" H 3
     14END Q
     15 ;
     16 ;Error Handler
     17 ;-------------
     18ERR(DESC) ;
     19 N ERROR,IC,REF
     20 S ERROR(1)="Unable to update dialog file : "_DESC
     21 S ERROR(2)="Error in UPDATE^DIE, needs further investigation"
     22 ;Move MSG into ERROR
     23 S REF="MSG"
     24 F IC=3:1 S REF=$Q(@REF) Q:REF=""  S ERROR(IC)=REF_"="_@REF
     25 ;Screen message
     26 D BMES^XPDUTL(.ERROR)
     27 Q
     28 ;
     29 ;Check if dialog element already exists
     30 ;--------------------------------------
     31EXISTS(NAME) ;
     32 N IEN S IEN=$O(^PXRMD(801.41,"B",NAME,""))
     33 I IEN S DSET(1,CNT*5)=IEN Q 1
     34 Q 0
     35 ;
     36 ;Update edit history
     37 ;-------------------
     38HIS(IENN) ;
     39 ;First delete any existing history entries.
     40 N ENTRY,IND,IENS,FDA,FDAIEN,MSG,WP
     41 S ENTRY="^PXRMD(801.41,"_IENN_",110)"
     42 S IND=0
     43 F  S IND=$O(@ENTRY@(IND)) Q:+IND=0  D
     44 . S IENS=IND_","_IENN_","
     45 . S FDA(801.44,IENS,.01)="@"
     46 I $D(FDA(801.44)) D
     47 .D FILE^DIE("K","FDA","MSG") I $D(MSG) D AWRITE^PXRMUTIL("MSG")
     48 ;Establish an initial entry in the edit history.
     49 K FDA,MSG
     50 S IENS="+1,"_IENN_","
     51 S FDAIEN(IENN)=IENN
     52 S FDA(801.44,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     53 S FDA(801.44,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
     54 S FDA(801.44,IENS,2)="WP(1,1)"
     55 S WP(1,1,1)="Autogenerated"
     56 D UPDATE^DIE("E","FDA","FDAIEN","MSG")
     57 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
     58 Q
     59 ;
     60 ;Mental Health
     61 ;-------------
     62MHOK(IEN) ;
     63 N RNAME,TEST,YT S YT=""
     64 ;Convert ien to name
     65 S YT("CODE")=$P($G(^YTT(601,IEN,0)),U)
     66 ;Quit if no code found
     67 I YT("CODE")="" Q 0
     68 ;Check if this is an allowable GUI test
     69 I (YT("CODE")'="GAF"),($P($G(^YTT(601.6,IEN,0)),U,4)'="Y") Q 0
     70 ;Get details of test
     71 D SHOWALL^YTAPI3(.TEST,.YT)
     72 ;Check if valid
     73 I TEST(1)["[ERROR]" Q 0
     74 ;
     75 S DNAME=FTYP_" "_YT("CODE")
     76 ;Create arrays
     77 S CNT=CNT+1
     78 ;Convert dialog item name to UC
     79 S DNAME=$TR(DNAME,LOWER,UPPER)
     80 ;Truncate the item name - without finesse
     81 S DSHORT=DNAME
     82 I $L(DSHORT)>40 S DSHORT=$E(DNAME,1,40)
     83 ;Dialog item name, finding item and result
     84 S ARRAY(CNT)=DSHORT_U_U_RESN_U
     85 ;Result group name
     86 S RNAME="PXRM "_YT("CODE")_" RESULT GROUP"
     87 ;Result pointer
     88 S $P(ARRAY(CNT),U,7)=$O(^PXRMD(801.41,"B",RNAME,""))
     89 ;If aims exclude from p/n
     90 I YT("CODE")="AIMS" S $P(ARRAY(CNT),U,6)=1
     91 ;Prompt text
     92 S WPTXT(CNT,1)=YT("CODE")_" (Mental Health Instrument)"
     93 ;test
     94 W !!,CNT,?5,WPTXT(CNT,1)
     95 Q 1
     96 ;
     97 ;Sub-routine to update dialog file #801.41
     98 ;-----------------------------------------
     99UPDATE(INP,WPTXT,DTYPE) ;
     100 N CNT,DATA,DESC,IEN,STRING,SUB,TEXT
     101 N FDA,FDAIEN,MSG
     102 ;Get each dialog line in turn
     103 S STRING="Updating "_$S(DTYPE="E":"Dialog Elements",1:"Reminder Dialog")
     104 D BMES^XPDUTL(STRING)
     105 ;
     106 ;Create FDA for each entry in array
     107 S CNT=""
     108 F  S CNT=$O(INP(CNT)) Q:CNT=""  D  Q:$D(MSG)
     109 .;If finding is a finding item parameter no need to build an element
     110 .I DTYPE="E",$P(INP(CNT),U)=801.43 D  Q
     111 ..S DSET(1,CNT)=$P(INP(CNT),U,2)
     112 .;Build FDA array
     113 .K FDAIEN,FDA
     114 .;If existing element and not in replace mode don't update FDA
     115 .I DTYPE="E",'PXRMREPL Q:$$EXISTS($P(INP(CNT),U))
     116 .;Name
     117 .S FDA(801.41,"?+1,",.01)=$P(INP(CNT),U)
     118 .;Dialog type
     119 .S FDA(801.41,"?+1,",4)=DTYPE
     120 .;Class
     121 .S FDA(801.41,"?+1,",100)="L"
     122 .;Sponsor
     123 .S FDA(801.41,"?+1,",101)=""
     124 .;Prompt text/finding entries
     125 .I DTYPE="E" D
     126 ..S FDA(801.41,"?+1,",13)=$P(INP(CNT),U,2)
     127 ..S FDA(801.41,"?+1,",15)=$P(INP(CNT),U,3)
     128 ..S FDA(801.41,"?+1,",17)=$P(INP(CNT),U,4)
     129 ..S FDA(801.41,"?+1,",25)="WPTXT("_CNT_")"
     130 ..;MH fields (exclude from P/N and results pointer)
     131 ..S:$P(INP(CNT),U,6) FDA(801.41,"?+1,",54)=$P(INP(CNT),U,6)
     132 ..S:$P(INP(CNT),U,7) FDA(801.41,"?+1,",55)=$P(INP(CNT),U,7)
     133 .;Reminder dialog associated reminder/DISABLE
     134 .I DTYPE="R" D
     135 ..S FDA(801.41,"?+1,",2)=REM
     136 ..I PXRMENAB'="Y" S FDA(801.41,"?+1,",3)="DISABLED AT AUTO GENERATE"
     137 .;Dialog items point to prompts and actions, Sets point to dialog items
     138 .N ACNT,SUB
     139 .;S ACNT=0,SUB=2
     140 .S ACNT=0,SUB=1
     141 .F  S ACNT=$O(INP(CNT,ACNT)) Q:ACNT=""  D
     142 ..S SUB=SUB+1,FDA(801.412,"?+"_SUB_",?+1,",.01)=ACNT
     143 ..S FDA(801.412,"?+"_SUB_",?+1,",2)=$P(INP(CNT,ACNT),U)
     144 ..S FDA(801.412,"?+"_SUB_",?+1,",6)=$P(INP(CNT,ACNT),U,2)
     145 ..S FDA(801.412,"?+"_SUB_",?+1,",7)=$P(INP(CNT,ACNT),U,3)
     146 ..S FDA(801.412,"?+"_SUB_",?+1,",8)=$P(INP(CNT,ACNT),U,4)
     147 ..S FDA(801.412,"?+"_SUB_",?+1,",9)=$P(INP(CNT,ACNT),U,5)
     148 .;Update #801.41
     149 .D UPDATE^DIE("","FDA","FDAIEN","MSG")
     150 .I $D(MSG) D ERR($G(INP(CNT))) Q
     151 .;Save IEN of dialog created/used for later use in building dialog set
     152 .I DTYPE="E" S DSET(1,CNT*5)=FDAIEN(1)
     153 .;Insert link to reminder
     154 .I DTYPE="R",PXRMLINK="Y" D
     155 ..S $P(^PXD(811.9,REM,51),U)=FDAIEN(1),^PXD(811.9,"AG",FDAIEN(1),REM)=""
     156 .;Update Edit History
     157 .D HIS(FDAIEN(1))
     158 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDEDT.m

    r613 r623  
    1 PXRMDEDT        ; SLC/PJH - Edit PXRM reminder dialog. ;10/18/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Used by protocol PXRM SELECTION ADD/PXRM GENERAL ADD
    5         ;
    6         ;Add Dialog
    7         ;----------
    8 ADD     N DA,DIC,Y,DTOUT,DUOUT,DTYP,DLAYGO,HED
    9         S HED="ADD DIALOG"
    10         W IORESET
    11         F  D  Q:$D(DTOUT)
    12         .S DIC="^PXRMD(801.41,"
    13         .;Set the starting place for additions.
    14         .D SETSTART^PXRMCOPY(DIC)
    15         .S DIC(0)="AELMQ",DLAYGO=801.41
    16         .S DIC("A")="Select DIALOG to add: "
    17         .S DIC("DR")="4///"_$G(PXRMDTYP)
    18         .D ^DIC
    19         .I $D(DUOUT) S DTOUT=1
    20         .I ($D(DTOUT))!($D(DUOUT)) Q
    21         .I Y=-1 K DIC S DTOUT=1 Q
    22         .I $P(Y,U,3)'=1 W !,"This dialog name already exists" Q
    23         .S DA=$P(Y,U,1)
    24         .;Determine dialog type
    25         .S DTYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
    26         .;Enter dialog type if a new entry
    27         .I DTYP="" D  Q:$D(Y)
    28         ..N DIE,DR
    29         ..S DIE=801.41,DR=4
    30         ..D ^DIE
    31         .;
    32         .;Edit Dialog
    33         .D EDIT(DTYP,DA,0)
    34         Q
    35         ;
    36         ;called by protocol PXRM DIALOG EDIT
    37         ;-----------------------------------
    38 EDIT(TYP,DA,OIEN)       ;
    39         Q:'$$LOCK(DA)
    40         W IORESET
    41         N CS1,CS2,D1,DIC,DIDEL,DIE,DR,DTOUT,DUOUT,DINUSE,TYP,ODA,Y
    42         ;Save checksum
    43         S VALMBCK=""
    44         S CS1=$$FILE^PXRMEXCS(801.41,DA)
    45         ;
    46         ;Check dialog type
    47         S TYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
    48         S DIE="^PXRMD(801.41,",DIDEL=801.41,DINUSE=0,ODA=DA
    49         ;Reminder Dialog
    50         I TYP="R" S DR="[PXRM EDIT REMINDER DIALOG]"
    51         ;Dialog Element
    52         I TYP="E" S DR="[PXRM EDIT ELEMENT]"
    53         ;Additional Prompt
    54         ;I TYP="P" S DR="[PXRM EDIT PROMPT]"
    55         ;Forced Value
    56         I TYP="F" S DR="[PXRM EDIT FORCED VALUE]"
    57         ;Dialog Group (Finding item dialog)
    58         I TYP="G" S DR="[PXRM EDIT GROUP]" ;S VALMBCK="R"
    59         ;Result Group
    60         I TYP="S" S DR="[PXRM RESULT GROUP]"
    61         ;Result Element
    62         I TYP="T" S DR="[PXRM RESULT ELEMENT]"
    63         ;Allows limited edit of national dialogs
    64         I $P($G(^PXRMD(801.41,DA,100)),U)="N" D
    65         .I TYP="T",+$P($G(^PXMRD(801.41,DA,100)),U,4)=0 Q
    66         .I $G(PXRMINST)=1,DUZ(0)="@" Q
    67         .S DR="[PXRM EDIT NATIONAL DIALOG]",DINUSE=1
    68         ;
    69         I "GEPF"[TYP D
    70         .I '$D(^PXRMD(801.41,"AD",DA)) W !,"Not used by any other dialog",! Q
    71         .I PXRMGTYP'="DLG" S DINUSE=1 Q
    72         .I PXRMGTYP="DLG" D  Q
    73         ..N SUB
    74         ..S SUB=0
    75         ..F  S SUB=$O(^PXRMD(801.41,"AD",DA,SUB)) Q:'SUB  Q:DINUSE  D
    76         ...I SUB'=PXRMDIEN S DINUSE=1
    77         I DINUSE D
    78         .W !,"Current dialog element/group name: "_$P($G(^PXRMD(801.41,DA,0)),U)
    79         .I TYP="S" Q
    80         .I PXRMGTYP="DLGE" D
    81         ..W !,"Used by:" D USE^PXRMDLST(DA,10,"")
    82         ..I $D(^PXRMD(801.41,"R",DA))'>0 Q
    83         ..W !,"Used as a Replacement Element/Group for: " D REPLACE^PXRMDLST(DA,10,"")
    84         .I PXRMGTYP'="DLGE" D
    85         ..W !,"Used by:" D USE^PXRMDLST(DA,10,PXRMDIEN)
    86         ..I $D(^PXRMD(801.41,"R",DA))'>0 Q
    87         ..W !,"Used as a Replacement Element/Group for: " D REPLACE^PXRMDLST(DA,10,PXRMDIEN)
    88         ;
    89         ;Save list of components
    90         N COMP D COMP^PXRMDEDX(DA,.COMP)
    91         ;Edit dialog then unlock
    92         I TYP'="P" D ^DIE D UNLOCK(ODA) I $G(DA)="",$G(OIEN)>0 D
    93         .S DA=OIEN,DR="118////@" D ^DIE K DA
    94         I TYP="P" D PROMPT(DA) D UNLOCK(ODA)
    95         I '$D(DUOUT)&($G(D1)'="") D  Q
    96         . I $P($G(^PXRMD(801.41,DA,10,D1,0)),U,2)="" D  Q
    97         . . S DA(1)=DA,DA=D1 Q:'DA
    98         . . S DIK="^PXRMD(801.41,"_DA(1)_",10,"
    99         . . D ^DIK
    100         . . S VALMBG=1
    101         I '$D(DA) D  Q
    102         .;Clear any pointers from #811.9
    103         .I $D(PXRMDIEN) D PURGE(PXRMDIEN)
    104         .;Option to delete components
    105         .I $D(COMP) D DELETE^PXRMDEDX(.COMP)
    106         .S VALMBCK="R"
    107         ;
    108         ;Update edit history
    109         I (TYP'="R") D
    110         .S CS2=$$FILE^PXRMEXCS(801.41,DA) Q:CS2=CS1  Q:+CS2=0
    111         .S DIC="^PXRMD(801.41,"
    112         .D SEHIST^PXRMUTIL(801.41,DIC,DA)
    113         ;
    114         ;Redisplay changes (reminder dialog option only)
    115         I PXRMGTYP="DLG",TYP="R" D
    116         .;Get name of reminder dialog again
    117         .S Y=$P($G(^PXRMD(801.41,DA,0)),U)
    118         .;Format headings to include dialog name
    119         .S PXRMHD="REMINDER DIALOG NAME: "_$P(Y,U)
    120         .;Check if the set is disable and add to header if disabled
    121         .I $P(^PXRMD(801.41,DA,0),U,3)]"" S PXRMHD=PXRMHD_" (DISABLED)"
    122         .;Reset header in case name has changed
    123         .S VALMHDR(1)=PXRMHD
    124         Q
    125         ;
    126         ;Add SINGLE dialog element (protocol PXRM DIALOG SELECTION ITEM)
    127         ;-------------------------
    128 ESEL(PXRMDIEN,SEL)      ;
    129         N DA,DIC,DLAYGO,DNEW,DTOUT,DUOUT,DTYP,Y
    130         ;
    131         S DIC="^PXRMD(801.41,"
    132         S DLAYGO="801.41"
    133         ;Set the starting place for additions.
    134         D SETSTART^PXRMCOPY(DIC)
    135         S DIC(0)="AEMQL"
    136         S DIC("A")="Select new DIALOG ELEMENT: "
    137         S DIC("S")="I ""EG""[$P(^PXRMD(801.41,Y,0),U,4)"
    138         S DIC("DR")="4///E"
    139         W !
    140         D ^DIC
    141         I $D(DUOUT) S DTOUT=1
    142         I ($D(DTOUT))!($D(DUOUT)) Q
    143         I Y=-1 K DIC S DTOUT=1 Q
    144         S DA=$P(Y,U,1) Q:'DA
    145         S DNEW=$P(Y,U,3)
    146         ;Group points to itself
    147         I 'DNEW,$$VGROUP(DA,PXRMDIEN) Q
    148         ;Add to dialog
    149         D EADD(SEL,DA,PXRMDIEN)
    150         ;Determine dialog type
    151         S DTYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
    152         ;
    153         ;Edit Dialog
    154         I DNEW D EDIT(DTYP,DA)
    155         Q
    156         ;
    157         ;Update dialog component multiple
    158         ;--------------------------------
    159 EADD(SEL,NSUB,PXRMDIEN) ;
    160         N DA,DATA,NEXT
    161         S DATA=$G(^PXRMD(801.41,PXRMDIEN,10,0)),NEXT=$P(DATA,U,3)+1
    162         I DATA="" S DATA="^801.412IA"
    163         S DA=NSUB,DA(1)=PXRMDIEN
    164         S ^PXRMD(801.41,PXRMDIEN,10,NEXT,0)=SEL_U_DA_"^^^^^^^"
    165         ;Update next slot
    166         S $P(DATA,U,4)=$P(DATA,U,4)+1,$P(DATA,U,3)=NEXT
    167         S ^PXRMD(801.41,PXRMDIEN,10,0)=DATA
    168         ;Re-index
    169         N DIK,DA S DIK="^PXRMD(801.41,",DA=PXRMDIEN
    170         D IX^DIK
    171         Q
    172         ;
    173         ;Change Dialog Element Type
    174         ;--------------------------
    175 NTYP(TYP)       ;
    176         N X,Y,DIR K DIROUT,DIRUT,DTOUT,DUOUT
    177         S DIR(0)="SA"_U_"E:Element;"
    178         S DIR(0)=DIR(0)_"G:Group;"
    179         S DIR("A")="Dialog Element Type: "
    180         S DIR("B")="E"
    181         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    182         S DIR("??")=U_"D HELP^PXRMDEDT(3)"
    183         D ^DIR K DIR
    184         I $D(DIROUT) S DTOUT=1
    185         I $D(DTOUT)!($D(DUOUT)) Q
    186         S TYP=Y
    187         Q
    188         ;
    189         ;Clear pointers from the reminder file and process ID file
    190         ;---------------------------------------------------------
    191 PURGE(DIEN)     ;
    192         ;Purge pointers to this dialog from reminder file
    193         N RIEN
    194         S RIEN=0
    195         F  S RIEN=$O(^PXD(811.9,"AG",DIEN,RIEN)) Q:'RIEN  D
    196         .K ^PXD(811.9,RIEN,51),^PXD(811.9,"AG",DIEN,RIEN)
    197         ;
    198         Q
    199         ;
    200 VGROUP(DA,IEN)  ;Check dialog index to see if group will point to itself
    201         N FOUND
    202         S FOUND=0
    203         ;
    204         ;Only do check if dialog is a group
    205         I $P($G(^PXRMD(801.41,DA,0)),U,4)'="G" Q FOUND
    206         ;
    207         ;Group cannot be added to itself
    208         I DA=IEN D  Q FOUND
    209         .S FOUND=1
    210         .W !,"A group cannot be added to itself" H 2
    211         ;
    212         ;IEN is the dialog group being added to
    213         D VGROUP1(DA,IEN)
    214         Q FOUND
    215         ;
    216 VGROUP1(DA,DIEN)        ;Examine all parent dialogs
    217         ;
    218         ;End search if already found
    219         Q:FOUND
    220         ;
    221         ;Check if dialog being added is a parent at this level
    222         I $D(^PXRMD(801.41,"AD",DIEN,DA)) D  Q
    223         .S FOUND=1
    224         .W !,"A group cannot be added as it's own descendant" H 2
    225         ;
    226         ;If not look at other parents
    227         N SUB
    228         S SUB=0
    229         F  S SUB=$O(^PXRMD(801.41,"AD",DIEN,SUB)) Q:'SUB  D  Q:FOUND
    230         .;Ignore reminder dialogs
    231         .I $P($G(^PXRMD(801.41,SUB,0)),U,4)'="G" Q
    232         .;Repeat check on other parents
    233         .D VGROUP1(DA,SUB)
    234         Q
    235         ;
    236 HELP(CALL)      ;General help text routine
    237         N HTEXT
    238         N DIWF,DIWL,DIWR,IC
    239         S DIWF="C70",DIWL=0,DIWR=70
    240         ;
    241         I CALL=1 D
    242         .S HTEXT(1)="Select E to edit dialog element. If you wish to create"
    243         .S HTEXT(2)="a new dialog element just for this reminder dialog select"
    244         .S HTEXT(3)="C to copy and replace the current element. Select D to"
    245         .S HTEXT(4)="delete the sequence number/element from the dialog."
    246         I CALL=2 D
    247         .S HTEXT(1)="Enter Y to copy the current dialog element to a new name"
    248         .S HTEXT(2)="and then use this new element in the reminder dialog."
    249         I CALL=3 D
    250         .S HTEXT(1)="Enter G to change the current dialog element into a dialog"
    251         .S HTEXT(2)="group so that additional elements can be added. Enter E to"
    252         .S HTEXT(3)="leave the type of the dialog element unchanged."
    253         I CALL=4 D
    254         .S HTEXT(1)="Enter Y to change the dialog prompt created into a forced"
    255         .S HTEXT(2)="value. To edit the new forced value switch to the forced"
    256         .S HTEXT(3)="value screen using CV. This option only applies to prompts"
    257         .S HTEXT(4)="which update PCE or vitals."
    258         .S HTEXT(5)="Enter N to leave the dialog prompt unchanged."
    259         K ^UTILITY($J,"W")
    260         S IC=""
    261         F  S IC=$O(HTEXT(IC)) Q:IC=""  D
    262         . S X=HTEXT(IC)
    263         . D ^DIWP
    264         W !
    265         S IC=0
    266         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    267         . W !,^UTILITY($J,"W",0,IC,0)
    268         K ^UTILITY($J,"W")
    269         W !
    270         Q
    271         ;
    272 LOCK(DA)        ;Lock the record
    273         N OK
    274         S OK=1
    275         I '$$VEDIT^PXRMUTIL("^PXRMD(801.41,",DA) D
    276         .N DTYP
    277         .S DTYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
    278         .;Allow limit edit of Result Elements that are not lock
    279         .I DTYP="T",+$P($G(^PXRMD(801.41,DA,100)),U,4)=0 Q
    280         .;Allow edit of findings but not component multiple on groups
    281         .I DTYP="G",$G(PXRMDIEN),DA'=PXRMDIEN Q
    282         .I DTYP="G",$G(PXRMGTYP)="DLGE" Q
    283         .;Allow edit of element findings
    284         .I DTYP="E" Q
    285         .S OK=0
    286         .W !!,?5,"VA- and national class reminder dialogs may not be edited" H 2
    287         I 'OK Q 0
    288         ;
    289         L +^PXRMD(801.41,DA):0 I  Q 1
    290         E  W !!,?5,"Another user is editing this file, try later" H 2 Q 0
    291         ;
    292 PROMPT(IEN)     ;
    293         N DIE,DR
    294         S DIE="^PXRMD(801.41,",DA=IEN
    295         S DR=".01;3;100;101;102;24;23;21"
    296         S IEN=$G(^PXRMD(801.41,IEN,46)) I $G(IEN)="" G EX
    297         I $P($G(^PXRMD(801.42,IEN,0)),U)="COM" S DR=DR_";45"
    298 EX      ;
    299         D ^DIE
    300         Q
    301         ;
    302 UNLOCK(DA)      ;Unlock the record
    303         L -^PXRMD(801.41,DA)
    304         Q
     1PXRMDEDT ; SLC/PJH - Edit PXRM reminder dialog. ;07/28/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Used by protocol PXRM SELECTION ADD/PXRM GENERAL ADD
     5 ;
     6 ;Add Dialog
     7 ;----------
     8ADD N DA,DIC,Y,DTOUT,DUOUT,DTYP,DLAYGO,HED
     9 S HED="ADD DIALOG"
     10 W IORESET
     11 F  D  Q:$D(DTOUT)
     12 .S DIC="^PXRMD(801.41,"
     13 .;Set the starting place for additions.
     14 .D SETSTART^PXRMCOPY(DIC)
     15 .S DIC(0)="AELMQ",DLAYGO=801.41
     16 .S DIC("A")="Select DIALOG to add: "
     17 .S DIC("DR")="4///"_$G(PXRMDTYP)
     18 .D ^DIC
     19 .I $D(DUOUT) S DTOUT=1
     20 .I ($D(DTOUT))!($D(DUOUT)) Q
     21 .I Y=-1 K DIC S DTOUT=1 Q
     22 .I $P(Y,U,3)'=1 W !,"This dialog name already exists" Q
     23 .S DA=$P(Y,U,1)
     24 .;Determine dialog type
     25 .S DTYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
     26 .;Enter dialog type if a new entry
     27 .I DTYP="" D  Q:$D(Y)
     28 ..N DIE,DR
     29 ..S DIE=801.41,DR=4
     30 ..D ^DIE
     31 .;
     32 .;Edit Dialog
     33 .D EDIT(DTYP,DA,0)
     34 Q
     35 ;
     36 ;called by protocol PXRM DIALOG EDIT
     37 ;-----------------------------------
     38EDIT(TYP,DA,OIEN) ;
     39 Q:'$$LOCK(DA)
     40 W IORESET
     41 N CS1,CS2,D1,DIC,DIDEL,DIE,DR,DTOUT,DUOUT,DINUSE,TYP,ODA,Y
     42 ;Save checksum
     43 S VALMBCK=""
     44 S CS1=$$FILE^PXRMEXCS(801.41,DA)
     45 ;
     46 ;Check dialog type
     47 S TYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
     48 S DIE="^PXRMD(801.41,",DIDEL=801.41,DINUSE=0,ODA=DA
     49 ;Reminder Dialog
     50 I TYP="R" S DR="[PXRM EDIT REMINDER DIALOG]"
     51 ;Dialog Element
     52 I TYP="E" S DR="[PXRM EDIT ELEMENT]"
     53 ;Additional Prompt
     54 ;I TYP="P" S DR="[PXRM EDIT PROMPT]"
     55 ;Forced Value
     56 I TYP="F" S DR="[PXRM EDIT FORCED VALUE]"
     57 ;Dialog Group (Finding item dialog)
     58 I TYP="G" S DR="[PXRM EDIT GROUP]" ;S VALMBCK="R"
     59 ;Result Group
     60 I TYP="S" S DR="[PXRM RESULT GROUP]"
     61 ;Result Element
     62 I TYP="T" S DR="[PXRM RESULT ELEMENT]"
     63 ;Allows limited edit of national dialogs
     64 I $P($G(^PXRMD(801.41,DA,100)),U)="N" D
     65 .I $G(PXRMINST)=1,DUZ(0)="@" Q
     66 .S DR="[PXRM EDIT NATIONAL DIALOG]",DINUSE=1
     67 ;
     68 I "GEPF"[TYP D
     69 .I '$D(^PXRMD(801.41,"AD",DA)) W !,"Not used by any other dialog",! Q
     70 .I PXRMGTYP'="DLG" S DINUSE=1 Q
     71 .I PXRMGTYP="DLG" D  Q
     72 ..N SUB
     73 ..S SUB=0
     74 ..F  S SUB=$O(^PXRMD(801.41,"AD",DA,SUB)) Q:'SUB  Q:DINUSE  D
     75 ...I SUB'=PXRMDIEN S DINUSE=1
     76 I DINUSE D
     77 .W !,"Current dialog element/group name: "_$P($G(^PXRMD(801.41,DA,0)),U)
     78 .I TYP="S" Q
     79 .I PXRMGTYP="DLGE" D
     80 ..W !,"Used by:" D USE^PXRMDLST(DA,10,"")
     81 ..I $D(^PXRMD(801.41,"R",DA))'>0 Q
     82 ..W !,"Used as a Replacement Element/Group for: " D REPLACE^PXRMDLST(DA,10,"")
     83 .I PXRMGTYP'="DLGE" D
     84 ..W !,"Used by:" D USE^PXRMDLST(DA,10,PXRMDIEN)
     85 ..I $D(^PXRMD(801.41,"R",DA))'>0 Q
     86 ..W !,"Used as a Replacement Element/Group for: " D REPLACE^PXRMDLST(DA,10,PXRMDIEN)
     87 ;
     88 ;Save list of components
     89 N COMP D COMP^PXRMDEDX(DA,.COMP)
     90 ;Edit dialog then unlock
     91 I TYP'="P" D ^DIE D UNLOCK(ODA) I $G(DA)="",$G(OIEN)>0 D
     92 .S DA=OIEN,DR="118////@" D ^DIE K DA
     93 I TYP="P" D PROMPT(DA) D UNLOCK(ODA)
     94 I '$D(DUOUT)&($G(D1)'="") D  Q
     95 . I $P($G(^PXRMD(801.41,DA,10,D1,0)),U,2)="" D  Q
     96 . . S DA(1)=DA,DA=D1 Q:'DA
     97 . . S DIK="^PXRMD(801.41,"_DA(1)_",10,"
     98 . . D ^DIK
     99 . . S VALMBG=1
     100 I '$D(DA) D  Q
     101 .;Clear any pointers from #811.9
     102 .I $D(PXRMDIEN) D PURGE(PXRMDIEN)
     103 .;Option to delete components
     104 .I $D(COMP) D DELETE^PXRMDEDX(.COMP)
     105 .S VALMBCK="R"
     106 ;
     107 ;Update edit history
     108 I (TYP'="R") D
     109 .S CS2=$$FILE^PXRMEXCS(801.41,DA) Q:CS2=CS1  Q:+CS2=0
     110 .S DIC="^PXRMD(801.41,"
     111 .D SEHIST^PXRMUTIL(801.41,DIC,DA)
     112 ;
     113 ;Redisplay changes (reminder dialog option only)
     114 I PXRMGTYP="DLG",TYP="R" D
     115 .;Get name of reminder dialog again
     116 .S Y=$P($G(^PXRMD(801.41,DA,0)),U)
     117 .;Format headings to include dialog name
     118 .S PXRMHD="REMINDER DIALOG NAME: "_$P(Y,U)
     119 .;Check if the set is disable and add to header if disabled
     120 .I $P(^PXRMD(801.41,DA,0),U,3)]"" S PXRMHD=PXRMHD_" (DISABLED)"
     121 .;Reset header in case name has changed
     122 .S VALMHDR(1)=PXRMHD
     123 Q
     124 ;
     125 ;Add SINGLE dialog element (protocol PXRM DIALOG SELECTION ITEM)
     126 ;-------------------------
     127ESEL(PXRMDIEN,SEL) ;
     128 N DA,DIC,DLAYGO,DNEW,DTOUT,DUOUT,DTYP,Y
     129 ;
     130 S DIC="^PXRMD(801.41,"
     131 S DLAYGO="801.41"
     132 ;Set the starting place for additions.
     133 D SETSTART^PXRMCOPY(DIC)
     134 S DIC(0)="AEMQL"
     135 S DIC("A")="Select new DIALOG ELEMENT: "
     136 S DIC("S")="I ""EG""[$P(^PXRMD(801.41,Y,0),U,4)"
     137 S DIC("DR")="4///E"
     138 W !
     139 D ^DIC
     140 I $D(DUOUT) S DTOUT=1
     141 I ($D(DTOUT))!($D(DUOUT)) Q
     142 I Y=-1 K DIC S DTOUT=1 Q
     143 S DA=$P(Y,U,1) Q:'DA
     144 S DNEW=$P(Y,U,3)
     145 ;Group points to itself
     146 I 'DNEW,$$VGROUP(DA,PXRMDIEN) Q
     147 ;Add to dialog
     148 D EADD(SEL,DA,PXRMDIEN)
     149 ;Determine dialog type
     150 S DTYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
     151 ;
     152 ;Edit Dialog
     153 I DNEW D EDIT(DTYP,DA)
     154 Q
     155 ;
     156 ;Update dialog component multiple
     157 ;--------------------------------
     158EADD(SEL,NSUB,PXRMDIEN) ;
     159 N DA,DATA,NEXT
     160 S DATA=$G(^PXRMD(801.41,PXRMDIEN,10,0)),NEXT=$P(DATA,U,3)+1
     161 I DATA="" S DATA="^801.412IA"
     162 S DA=NSUB,DA(1)=PXRMDIEN
     163 S ^PXRMD(801.41,PXRMDIEN,10,NEXT,0)=SEL_U_DA_"^^^^^^^"
     164 ;Update next slot
     165 S $P(DATA,U,4)=$P(DATA,U,4)+1,$P(DATA,U,3)=NEXT
     166 S ^PXRMD(801.41,PXRMDIEN,10,0)=DATA
     167 ;Re-index
     168 N DIK,DA S DIK="^PXRMD(801.41,",DA=PXRMDIEN
     169 D IX^DIK
     170 Q
     171 ;
     172 ;Change Dialog Element Type
     173 ;--------------------------
     174NTYP(TYP) ;
     175 N X,Y,DIR K DIROUT,DIRUT,DTOUT,DUOUT
     176 S DIR(0)="SA"_U_"E:Element;"
     177 S DIR(0)=DIR(0)_"G:Group;"
     178 S DIR("A")="Dialog Element Type: "
     179 S DIR("B")="E"
     180 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     181 S DIR("??")=U_"D HELP^PXRMDEDT(3)"
     182 D ^DIR K DIR
     183 I $D(DIROUT) S DTOUT=1
     184 I $D(DTOUT)!($D(DUOUT)) Q
     185 S TYP=Y
     186 Q
     187 ;
     188 ;Clear pointers from the reminder file and process ID file
     189 ;---------------------------------------------------------
     190PURGE(DIEN) ;
     191 ;Purge pointers to this dialog from reminder file
     192 N RIEN
     193 S RIEN=0
     194 F  S RIEN=$O(^PXD(811.9,"AG",DIEN,RIEN)) Q:'RIEN  D
     195 .K ^PXD(811.9,RIEN,51),^PXD(811.9,"AG",DIEN,RIEN)
     196 ;
     197 Q
     198 ;
     199VGROUP(DA,IEN) ;Check dialog index to see if group will point to itself
     200 N FOUND
     201 S FOUND=0
     202 ;
     203 ;Only do check if dialog is a group
     204 I $P($G(^PXRMD(801.41,DA,0)),U,4)'="G" Q FOUND
     205 ;
     206 ;Group cannot be added to itself
     207 I DA=IEN D  Q FOUND
     208 .S FOUND=1
     209 .W !,"A group cannot be added to itself" H 2
     210 ;
     211 ;IEN is the dialog group being added to
     212 D VGROUP1(DA,IEN)
     213 Q FOUND
     214 ;
     215VGROUP1(DA,DIEN) ;Examine all parent dialogs
     216 ;
     217 ;End search if already found
     218 Q:FOUND
     219 ;
     220 ;Check if dialog being added is a parent at this level
     221 I $D(^PXRMD(801.41,"AD",DIEN,DA)) D  Q
     222 .S FOUND=1
     223 .W !,"A group cannot be added as it's own descendant" H 2
     224 ;
     225 ;If not look at other parents
     226 N SUB
     227 S SUB=0
     228 F  S SUB=$O(^PXRMD(801.41,"AD",DIEN,SUB)) Q:'SUB  D  Q:FOUND
     229 .;Ignore reminder dialogs
     230 .I $P($G(^PXRMD(801.41,SUB,0)),U,4)'="G" Q
     231 .;Repeat check on other parents
     232 .D VGROUP1(DA,SUB)
     233 Q
     234 ;
     235HELP(CALL) ;General help text routine
     236 N HTEXT
     237 N DIWF,DIWL,DIWR,IC
     238 S DIWF="C70",DIWL=0,DIWR=70
     239 ;
     240 I CALL=1 D
     241 .S HTEXT(1)="Select E to edit dialog element. If you wish to create"
     242 .S HTEXT(2)="a new dialog element just for this reminder dialog select"
     243 .S HTEXT(3)="C to copy and replace the current element. Select D to"
     244 .S HTEXT(4)="delete the sequence number/element from the dialog."
     245 I CALL=2 D
     246 .S HTEXT(1)="Enter Y to copy the current dialog element to a new name"
     247 .S HTEXT(2)="and then use this new element in the reminder dialog."
     248 I CALL=3 D
     249 .S HTEXT(1)="Enter G to change the current dialog element into a dialog"
     250 .S HTEXT(2)="group so that additional elements can be added. Enter E to"
     251 .S HTEXT(3)="leave the type of the dialog element unchanged."
     252 I CALL=4 D
     253 .S HTEXT(1)="Enter Y to change the dialog prompt created into a forced"
     254 .S HTEXT(2)="value. To edit the new forced value switch to the forced"
     255 .S HTEXT(3)="value screen using CV. This option only applies to prompts"
     256 .S HTEXT(4)="which update PCE or vitals."
     257 .S HTEXT(5)="Enter N to leave the dialog prompt unchanged."
     258 K ^UTILITY($J,"W")
     259 S IC=""
     260 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     261 . S X=HTEXT(IC)
     262 . D ^DIWP
     263 W !
     264 S IC=0
     265 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     266 . W !,^UTILITY($J,"W",0,IC,0)
     267 K ^UTILITY($J,"W")
     268 W !
     269 Q
     270 ;
     271LOCK(DA) ;Lock the record
     272 N OK
     273 S OK=1
     274 I '$$VEDIT^PXRMUTIL("^PXRMD(801.41,",DA) D
     275 .N DTYP
     276 .S DTYP=$P($G(^PXRMD(801.41,DA,0)),U,4)
     277 .;Allow edit of findings but not component multiple on groups
     278 .I DTYP="G",$G(PXRMDIEN),DA'=PXRMDIEN Q
     279 .I DTYP="G",$G(PXRMGTYP)="DLGE" Q
     280 .;Allow edit of element findings
     281 .I DTYP="E" Q
     282 .S OK=0
     283 .W !!,?5,"VA- and national class reminder dialogs may not be edited" H 2
     284 I 'OK Q 0
     285 ;
     286 L +^PXRMD(801.41,DA):0 I  Q 1
     287 E  W !!,?5,"Another user is editing this file, try later" H 2 Q 0
     288 ;
     289PROMPT(IEN) ;
     290 N DIE,DR
     291 S DIE="^PXRMD(801.41,",DA=IEN
     292 S DR=".01;3;100;101;102;24;23;21"
     293 S IEN=$G(^PXRMD(801.41,IEN,46)) I $G(IEN)="" G EX
     294 I $P($G(^PXRMD(801.42,IEN,0)),U)="COM" S DR=DR_";45"
     295EX ;
     296 D ^DIE
     297 Q
     298 ;
     299UNLOCK(DA) ;Unlock the record
     300 L -^PXRMD(801.41,DA)
     301 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDEV.m

    r613 r623  
    1 PXRMDEV ; SLC/PKR - This is a driver for testing Clinical Reminders.;01/24/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;==================================================
    5 CMOUT   ;Do formatted Clinical Maintenance output.
    6         N DUE,DUECOL,HIST,LAST,LASTCOL,LNUM,RIEN,RNAME,STATUS,STATCOL,TEMP,TYPE
    7         W !!,"Formatted Output:"
    8         S RIEN=$O(^TMP("PXRHM",$J,""))
    9         S RNAME=$O(^TMP("PXRHM",$J,RIEN,""))
    10         S TEMP=$G(^TMP("PXRHM",$J,RIEN,RNAME))
    11         S STATUS=$P(TEMP,U,1)
    12         S DUE=$$EDATE^PXRMDATE($P(TEMP,U,2))
    13         S LAST=$$EDATE^PXRMDATE($P(TEMP,U,3))
    14         S STATCOL=41-($L(STATUS)/2)
    15         S DUECOL=53-($L(DUE)/2)
    16         S LASTCOL=67-($L(LAST)/2)
    17         W !!,?36,"--STATUS--",?47,"--DUE DATE--",?61,"--LAST DONE--",!
    18         W !,RNAME,?STATCOL,STATUS,?DUECOL,DUE,?LASTCOL,LAST,!
    19         S LNUM=0
    20         F  S LNUM=$O(^TMP("PXRHM",$J,RIEN,RNAME,"TXT",LNUM)) Q:LNUM=""  D
    21         . W !,^TMP("PXRHM",$J,RIEN,RNAME,"TXT",LNUM)
    22         Q
    23         ;
    24         ;==================================================
    25 DEB     ;Prompt for patient and reminder by name input component.
    26         N DATE,DFN,DIC,DIR,DIROUT,DTOUT,DUOUT,PXRMITEM,PXRHM,PXRMTDEB,X,Y
    27         S DIC=2,DIC("A")="Select Patient: "
    28         S DIC(0)="AEQMZ"
    29         D ^DIC
    30         I $D(DTOUT)!$D(DUOUT) Q
    31         S DFN=+$P(Y,U,1)
    32         I DFN=-1 W !,"No patient selected!" Q
    33         S DIC=811.9,DIC("A")="Select Reminder: "
    34         D ^DIC
    35         I $D(DIROUT)!$D(DIRUT) Q
    36         I $D(DTOUT)!$D(DUOUT) Q
    37         S PXRMITEM=+$P(Y,U,1)
    38         I PXRMITEM=-1 W !,"No reminder selected!" Q
    39         S DIR(0)="LA"_U_"0"
    40         S DIR("A")="Enter component number 0, 1, 5, 10, 11, 12: "
    41         D ^DIR
    42         I $D(DIROUT)!$D(DIRUT) Q
    43         I $D(DTOUT)!$D(DUOUT) Q
    44         I X="" S X=5
    45         S PXRHM=X
    46         S DIR(0)="DA^"_0_"::ETX"
    47         S DIR("A")="Enter date for reminder evaluation: "
    48         S DIR("B")=$$FMTE^XLFDT($$DT^XLFDT,"D")
    49         S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
    50         W !
    51         D ^DIR K DIR
    52         I $D(DIROUT)!$D(DIRUT) Q
    53         I $D(DTOUT)!$D(DUOUT) Q
    54         S DATE=Y
    55         I $D(^PXD(811.9,PXRMITEM,20,"E","PXRMD(811.5,")) S PXRMTDEB=$$ASKYN^PXRMEUT("N","Display all term findings","","")
    56         D DOREM(DFN,PXRMITEM,PXRHM,DATE)
    57         Q
    58         ;
    59         ;==================================================
    60 DEV     ;Prompt for patient and reminder by name and evaluation date.
    61         N DATE,DFN,DIC,DIROUT,DIRUT,DTOUT,DUOUT,PXRMITEM,PXRHM,PXRMTDEB,REF,X,Y
    62         S DIC=2,DIC("A")="Select Patient: "
    63         S DIC(0)="AEQMZ"
    64         D ^DIC
    65         I $D(DIROUT)!$D(DIRUT) Q
    66         I $D(DTOUT)!$D(DUOUT) Q
    67         S DFN=+$P(Y,U,1)
    68         S DIC=811.9,DIC("A")="Select Reminder: "
    69         D ^DIC
    70         I $D(DIROUT)!$D(DIRUT) Q
    71         I $D(DTOUT)!$D(DUOUT) Q
    72         S PXRMITEM=+$P(Y,U,1)
    73         S PXRHM=5
    74         S DIR(0)="DA^"_0_"::ETX"
    75         S DIR("A")="Enter date for reminder evaluation: "
    76         S DIR("B")=$$FMTE^XLFDT($$DT^XLFDT,"D")
    77         S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
    78         W !
    79         D ^DIR K DIR
    80         I $D(DIROUT)!$D(DIRUT) Q
    81         I $D(DTOUT)!$D(DUOUT) Q
    82         S DATE=Y
    83         I $D(^PXD(811.9,PXRMITEM,20,"E","PXRMD(811.5,")) S PXRMTDEB=$$ASKYN^PXRMEUT("N","Display all term findings","","")
    84         D DOREM(DFN,PXRMITEM,PXRHM,DATE)
    85         Q
    86         ;
    87         ;==================================================
    88 DOREM(DFN,PXRMITEM,PXRMHM,DATE) ;Do the reminder
    89         N DEFARR,FIEVAL,FINDING,PXRMDEBG,PXRMID,REF,TFIEVAL
    90         ;This is a debugging run so set PXRMDEBG.
    91         S PXRMDEBG=1
    92         D DEF^PXRMLDR(PXRMITEM,.DEFARR)
    93         I +$G(DATE)=0 D EVAL^PXRM(DFN,.DEFARR,PXRHM,1,.FIEVAL)
    94         I +$G(DATE)>0 D EVAL^PXRM(DFN,.DEFARR,PXRHM,1,.FIEVAL,DATE)
    95         ;
    96         W !!,"The elements of the FIEVAL array are:"
    97         S REF="FIEVAL"
    98         D AWRITE^PXRMUTIL(REF)
    99         ;
    100         I $G(PXRMTDEB) D
    101         . W !!,"Term findings:"
    102         . S REF="TFIEVAL"
    103         . S FINDING=0
    104         . F  S FINDING=$O(^TMP("PXRMTDEB",$J,FINDING)) Q:FINDING=""  D
    105         .. K TFIEVAL M TFIEVAL(FINDING)=^TMP("PXRMTDEB",$J,FINDING)
    106         .. W !,"Finding ",FINDING,":"
    107         .. D AWRITE^PXRMUTIL(REF)
    108         . K ^TMP("PXRMTDEB",$J)
    109         ;
    110         W !!,"The elements of the ^TMP(PXRMID,$J) array are:"
    111         I $D(PXRMID) S REF="^TMP(PXRMID,$J)" D AWRITE^PXRMUTIL(REF) K ^TMP(PXRMID,$J)
    112         ;
    113         W !!,"The elements of the ^TMP(""PXRHM"",$J) array are:"
    114         S REF="^TMP(""PXRHM"",$J)"
    115         D AWRITE^PXRMUTIL(REF)
    116         ;
    117         I $D(^TMP("PXRHM",$J)) D CMOUT
    118         I PXRHM=12 D MHVCOUT
    119         K ^TMP("PXRM",$J),^TMP("PXRHM",$J),^TMP("PXRMMHVC",$J)
    120         Q
    121         ;==================================================
    122 MHVCOUT ;Do formatted MHV combined output.
    123         N DUE,DUECOL,HIST,LAST,LASTCOL,LNUM,RIEN,RNAME,STATUS,STATCOL,TEMP,TYPE
    124         W !!,"Formatted Output:"
    125         S RIEN=$O(^TMP("PXRMMHVC",$J,""))
    126         S TEMP=^TMP("PXRMMHVC",$J,RIEN,"STATUS")
    127         S STATUS=$P(TEMP,U,1)
    128         S DUE=$$EDATE^PXRMDATE($P(TEMP,U,2))
    129         S LAST=$$EDATE^PXRMDATE($P(TEMP,U,3))
    130         S DUE=$$EDATE^PXRMDATE($P(TEMP,U,2))
    131         S LAST=$$EDATE^PXRMDATE($P(TEMP,U,3))
    132         S STATCOL=41-($L(STATUS)/2)
    133         S DUECOL=53-($L(DUE)/2)
    134         S LASTCOL=67-($L(LAST)/2)
    135         S RNAME=$P(^PXD(811.9,RIEN,0),U,3)
    136         I RNAME="" S RNAME=$P(^PXD(811.9,RIEN,0),U,1)
    137         W !!,?36,"--STATUS--",?47,"--DUE DATE--",?61,"--LAST DONE--",!
    138         W !,RNAME,?STATCOL,STATUS,?DUECOL,DUE,?LASTCOL,LAST,!
    139         W !!,"---------- Detailed Output ----------"
    140         S LNUM=0
    141         F  S LNUM=$O(^TMP("PXRMMHVC",$J,RIEN,"DETAIL",LNUM)) Q:LNUM=""  D
    142         . W !,^TMP("PXRMMHVC",$J,RIEN,"DETAIL",LNUM)
    143         W !!,"---------- Summary Output ----------"
    144         S LNUM=0
    145         F  S LNUM=$O(^TMP("PXRMMHVC",$J,RIEN,"SUMMARY",LNUM)) Q:LNUM=""  D
    146         . W !,^TMP("PXRMMHVC",$J,RIEN,"SUMMARY",LNUM)
    147         Q
    148         ;
     1PXRMDEV ; SLC/PKR - This is a driver for testing Clinical Reminders.;05/04/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;==================================================
     5CMOUT ;Do formatted Clinical Maintenance output.
     6 N DUE,DUECOL,HIST,LAST,LASTCOL,LNUM,RIEN,RNAME,STATUS,STATCOL,TEMP,TYPE
     7 W !!,"Formatted Output:"
     8 S RIEN=$O(^TMP("PXRHM",$J,""))
     9 S RNAME=$O(^TMP("PXRHM",$J,RIEN,""))
     10 S TEMP=$G(^TMP("PXRHM",$J,RIEN,RNAME))
     11 S STATUS=$P(TEMP,U,1)
     12 S DUE=$$EDATE^PXRMDATE($P(TEMP,U,2))
     13 S LAST=$$EDATE^PXRMDATE($P(TEMP,U,3))
     14 S STATCOL=41-($L(STATUS)/2)
     15 S DUECOL=53-($L(DUE)/2)
     16 S LASTCOL=67-($L(LAST)/2)
     17 W !!,?36,"--STATUS--",?47,"--DUE DATE--",?61,"--LAST DONE--",!
     18 W !,RNAME,?STATCOL,STATUS,?DUECOL,DUE,?LASTCOL,LAST,!
     19 S LNUM=0
     20 F  S LNUM=$O(^TMP("PXRHM",$J,RIEN,RNAME,"TXT",LNUM)) Q:LNUM=""  D
     21 . W !,^TMP("PXRHM",$J,RIEN,RNAME,"TXT",LNUM)
     22 Q
     23 ;
     24 ;==================================================
     25DEB ;Prompt for patient and reminder by name input component.
     26 N DATE,DFN,DIC,DIR,DIROUT,DTOUT,DUOUT,PXRMITEM,PXRHM,PXRMTDEB,X,Y
     27 S DIC=2,DIC("A")="Select Patient: "
     28 S DIC(0)="AEQMZ"
     29 D ^DIC
     30 I $D(DTOUT)!$D(DUOUT) Q
     31 S DFN=+$P(Y,U,1)
     32 I DFN=-1 W !,"No patient selected!" Q
     33 S DIC=811.9,DIC("A")="Select Reminder: "
     34 S DIC("S")="I $P(^PXD(811.9,Y,100),U,4)'[""L"""
     35 D ^DIC
     36 I $D(DIROUT)!$D(DIRUT) Q
     37 I $D(DTOUT)!$D(DUOUT) Q
     38 S PXRMITEM=+$P(Y,U,1)
     39 I PXRMITEM=-1 W !,"No reminder selected!" Q
     40 S DIR(0)="LA"_U_"0"
     41 S DIR("A")="Enter component number 0, 1, 5, 10, 11, 12: "
     42 D ^DIR
     43 I $D(DIROUT)!$D(DIRUT) Q
     44 I $D(DTOUT)!$D(DUOUT) Q
     45 I X="" S X=5
     46 S PXRHM=X
     47 S DIR(0)="DA^"_0_"::ETX"
     48 S DIR("A")="Enter date for reminder evaluation: "
     49 S DIR("B")=$$FMTE^XLFDT($$DT^XLFDT,"D")
     50 S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
     51 W !
     52 D ^DIR K DIR
     53 I $D(DIROUT)!$D(DIRUT) Q
     54 I $D(DTOUT)!$D(DUOUT) Q
     55 S DATE=Y
     56 I $D(^PXD(811.9,PXRMITEM,20,"E","PXRMD(811.5,")) S PXRMTDEB=$$ASKYN^PXRMEUT("N","Display all term findings","","")
     57 D DOREM(DFN,PXRMITEM,PXRHM,DATE)
     58 Q
     59 ;
     60 ;==================================================
     61DEV ;Prompt for patient and reminder by name and evaluation date.
     62 N DATE,DFN,DIC,DIROUT,DIRUT,DTOUT,DUOUT,PXRMITEM,PXRHM,PXRMTDEB,REF,X,Y
     63 S DIC=2,DIC("A")="Select Patient: "
     64 S DIC(0)="AEQMZ"
     65 D ^DIC
     66 I $D(DIROUT)!$D(DIRUT) Q
     67 I $D(DTOUT)!$D(DUOUT) Q
     68 S DFN=+$P(Y,U,1)
     69 S DIC=811.9,DIC("A")="Select Reminder: "
     70 S DIC("S")="I $P(^PXD(811.9,Y,100),U,4)'[""L"""
     71 D ^DIC
     72 I $D(DIROUT)!$D(DIRUT) Q
     73 I $D(DTOUT)!$D(DUOUT) Q
     74 S PXRMITEM=+$P(Y,U,1)
     75 S PXRHM=5
     76 S DIR(0)="DA^"_0_"::ETX"
     77 S DIR("A")="Enter date for reminder evaluation: "
     78 S DIR("B")=$$FMTE^XLFDT($$DT^XLFDT,"D")
     79 S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
     80 W !
     81 D ^DIR K DIR
     82 I $D(DIROUT)!$D(DIRUT) Q
     83 I $D(DTOUT)!$D(DUOUT) Q
     84 S DATE=Y
     85 I $D(^PXD(811.9,PXRMITEM,20,"E","PXRMD(811.5,")) S PXRMTDEB=$$ASKYN^PXRMEUT("N","Display all term findings","","")
     86 D DOREM(DFN,PXRMITEM,PXRHM,DATE)
     87 Q
     88 ;
     89 ;==================================================
     90DOREM(DFN,PXRMITEM,PXRMHM,DATE) ;Do the reminder
     91 N DEFARR,FIEVAL,FINDING,PXRMDEBG,PXRMID,REF,TFIEVAL
     92 ;This is a debugging run so set PXRMDEBG.
     93 S PXRMDEBG=1
     94 D DEF^PXRMLDR(PXRMITEM,.DEFARR)
     95 I +$G(DATE)=0 D EVAL^PXRM(DFN,.DEFARR,PXRHM,1,.FIEVAL)
     96 I +$G(DATE)>0 D EVAL^PXRM(DFN,.DEFARR,PXRHM,1,.FIEVAL,DATE)
     97 ;
     98 W !!,"The elements of the FIEVAL array are:"
     99 S REF="FIEVAL"
     100 D AWRITE^PXRMUTIL(REF)
     101 ;
     102 I $G(PXRMTDEB) D
     103 . W !!,"Term findings:"
     104 . S REF="TFIEVAL"
     105 . S FINDING=0
     106 . F  S FINDING=$O(^TMP("PXRMTDEB",$J,FINDING)) Q:FINDING=""  D
     107 .. K TFIEVAL M TFIEVAL(FINDING)=^TMP("PXRMTDEB",$J,FINDING)
     108 .. W !,"Finding ",FINDING,":"
     109 .. D AWRITE^PXRMUTIL(REF)
     110 . K ^TMP("PXRMTDEB",$J)
     111 ;
     112 W !!,"The elements of the ^TMP(PXRMID,$J) array are:"
     113 I $D(PXRMID) S REF="^TMP(PXRMID,$J)" D AWRITE^PXRMUTIL(REF) K ^TMP(PXRMID,$J)
     114 ;
     115 W !!,"The elements of the ^TMP(""PXRHM"",$J) array are:"
     116 S REF="^TMP(""PXRHM"",$J)"
     117 D AWRITE^PXRMUTIL(REF)
     118 ;
     119 I $D(^TMP("PXRHM",$J)) D CMOUT
     120 I PXRHM=12 D MHVCOUT
     121 K ^TMP("PXRM",$J),^TMP("PXRHM",$J),^TMP("PXRMMHVC",$J)
     122 Q
     123 ;==================================================
     124MHVCOUT ;Do formatted MHV combined output.
     125 N DUE,DUECOL,HIST,LAST,LASTCOL,LNUM,RIEN,RNAME,STATUS,STATCOL,TEMP,TYPE
     126 W !!,"Formatted Output:"
     127 S RIEN=$O(^TMP("PXRMMHVC",$J,""))
     128 S TEMP=^TMP("PXRMMHVC",$J,RIEN,"STATUS")
     129 S STATUS=$P(TEMP,U,1)
     130 S DUE=$$EDATE^PXRMDATE($P(TEMP,U,2))
     131 S LAST=$$EDATE^PXRMDATE($P(TEMP,U,3))
     132 S DUE=$$EDATE^PXRMDATE($P(TEMP,U,2))
     133 S LAST=$$EDATE^PXRMDATE($P(TEMP,U,3))
     134 S STATCOL=41-($L(STATUS)/2)
     135 S DUECOL=53-($L(DUE)/2)
     136 S LASTCOL=67-($L(LAST)/2)
     137 S RNAME=$P(^PXD(811.9,RIEN,0),U,3)
     138 I RNAME="" S RNAME=$P(^PXD(811.9,RIEN,0),U,1)
     139 W !!,?36,"--STATUS--",?47,"--DUE DATE--",?61,"--LAST DONE--",!
     140 W !,RNAME,?STATCOL,STATUS,?DUECOL,DUE,?LASTCOL,LAST,!
     141 W !!,"---------- Detailed Output ----------"
     142 S LNUM=0
     143 F  S LNUM=$O(^TMP("PXRMMHVC",$J,RIEN,"DETAIL",LNUM)) Q:LNUM=""  D
     144 . W !,^TMP("PXRMMHVC",$J,RIEN,"DETAIL",LNUM)
     145 W !!,"---------- Summary Output ----------"
     146 S LNUM=0
     147 F  S LNUM=$O(^TMP("PXRMMHVC",$J,RIEN,"SUMMARY",LNUM)) Q:LNUM=""  D
     148 . W !,^TMP("PXRMMHVC",$J,RIEN,"SUMMARY",LNUM)
     149 Q
     150 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLG4.m

    r613 r623  
    1 PXRMDLG4        ; SLC/PJH - Reminder Dialog Edit/Inquiry ;06/05/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 WP(SUB,SUB1,WIDTH,SEQ,VALMCNT)  ;Format WP text
    5         N DIWF,DIWL,DIWR,IC,TEXT,X,TXTCNT,DTXT,CNT,SUB2
    6         S (CNT,SUB2,TXTCNT)=0
    7         F  S SUB2=$O(^PXRMD(801.41,SUB,SUB1,SUB2)) Q:'SUB2  D
    8         .S TXTCNT=TXTCNT+1,DTXT(TXTCNT)=$G(^PXRMD(801.41,SUB,SUB1,SUB2,0))
    9         .S DTXT(TXTCNT)=$$STRREP^PXRMUTIL($G(DTXT(TXTCNT)),"<br>","\\")
    10         I TXTCNT>0 D
    11         .N OUTPUT,NLINES
    12         .S NLINES=0 D FORMAT^PXRMTEXT(1,WIDTH,TXTCNT,.DTXT,.NLINES,.OUTPUT)
    13         .I NLINES>0 K DTXT M DTXT=OUTPUT
    14         S CNT=0
    15         F  S CNT=$O(DTXT(CNT)) Q:CNT=""  D
    16         .S TEXT=$G(DTXT(CNT)),VALMCNT=VALMCNT+1
    17         .S ^TMP(NODE,$J,VALMCNT,0)=SEQ_TEXT,SEQ=$J("",$L(SEQ))
    18         Q
    19         ;
    20 ADD     ;PXRM DIALOG ADD ELEMENT validation
    21         N ANS,DTOUT,DUOUT,LIT,LOCK,Y,PIEN,ERR,IEN,NATIONAL,SEQ
    22         W IORESET
    23         S VALMBCK="R",NATIONAL=0
    24         I $P($G(^PXRMD(801.41,PXRMDIEN,100)),U)="N" S NATIONAL=1
    25         S LOCK=$P($G(^PXRMD(801.41,PXRMDIEN,100)),U,4)
    26         I NATIONAL,'($G(PXRMINST)=1)&(DUZ(0)="@"),$G(LOCK)'=1 D  Q
    27         .W !,"Elements may not be added to national reminder dialogs" H 2
    28         ;
    29         F  D SEQ(.SEQ,.PIEN) Q:$D(DUOUT)!$D(DTOUT)  Q:SEQ
    30         Q:$D(DUOUT)!$D(DTOUT)
    31         ;
    32         ;Check if sequence number is OK
    33         I $G(PIEN)="" Q
    34         S ANS="N" D ASK^PXRMDLG5(.ANS,PIEN) Q:$D(DUOUT)!$D(DTOUT)!($G(ANS)="N")
    35         ;
    36         ;Select a dialog element to add to parent dialog (PIEN)
    37         ;PIEN may be dialog or a group within the dialog
    38         D ESEL^PXRMDEDT(PIEN,SEQ)
    39         ;Rebuild workfile
    40         D BUILD^PXRMDLG(VIEW)
    41         Q
    42         ;
    43 FADD(DIEN,FTAB) ;Additional Findings
    44         N FIND,FSUB,FTYP,FNAME,FNUM
    45         S FSUB=0
    46         F  S FSUB=$O(^PXRMD(801.41,DIEN,3,FSUB)) Q:'FSUB  D
    47         .S FIND=$P($G(^PXRMD(801.41,DIEN,3,FSUB,0)),U) Q:FIND=""
    48         .S FNAME="" D FDESC(FIND) Q:FNAME=""
    49         .;Save additional finding name
    50         .S FOUND=1 D FSAVE(2,FNAME,FTYP,FTAB,FIND)
    51         Q
    52         ;
    53 DETAIL(DIEN,LEV,VIEW,NODE)      ;;Build listman global for all components
    54         N DDATA,DDLG,DEND,DCIEN,DNAM,DSEQ,DSTRT,IND,JND,DSUB
    55         S DSEQ=0
    56         ;
    57         ;Get each sequence number
    58         F  S DSEQ=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ)) Q:'DSEQ  D
    59         .;Determine subscript
    60         .S DSUB=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ,"")) Q:'DSUB
    61         .;Get ien of prompt/component
    62         .S DCIEN=$P($G(^PXRMD(801.41,DIEN,10,DSUB,0)),U,2) Q:'DCIEN
    63         .I "PF"[$P($G(^PXRMD(801.41,DCIEN,0)),U,4) Q
    64         .;Save line in workfile
    65         .D DLINE(DCIEN,LEV,DSEQ,NODE)
    66         .;Build pointers back to parent
    67         .I VIEW'=4 D
    68         ..S ^TMP("PXRMDLG4",$J,"IEN",NSEL)=DIEN_U_DSEQ
    69         ..S ^TMP("PXRMDLG4",$J,"SEQ",LEV_DSEQ)=DCIEN
    70         .;Process any sub-components
    71         .I VIEW<5 D DETAIL(DCIEN,LEV_DSEQ_".",VIEW,NODE)
    72         Q
    73         ;
    74 DLINE(DIEN,LEV,DSEQ,NODE)       ;Save individual component details
    75         N CNT,DBOX,DCAP,DDIS,DMULT,DSUPP,DSHOW,DTYP,DTXT
    76         N IC,RESNM,RESULT,RIEN,RNAME,RCNT
    77         ;Dialog name
    78         S DDATA=$G(^PXRMD(801.41,DIEN,0)),DNAM=$P(DDATA,U) Q:DNAM=""
    79         ;Check if standard PXRM prompt
    80         I $$PXRM^PXRMEXID(DNAM) Q
    81         ;Dialog Type and Disabled
    82         S DDIS=$P(DDATA,U,3),DTYP=$P(DDATA,U,4)
    83         S DTYP=$S(DTYP="G":"Group",1:"Element"),DNAM=DTYP_": "_DNAM
    84         I VIEW=5 S DNAM=DNAM
    85         ;Resolution type and name
    86         S RNAME="",RIEN=$P($G(^PXRMD(801.41,DIEN,1)),U,3)
    87         I RIEN S RNAME=$P($G(^PXRMD(801.9,RIEN,0)),U)
    88         ;
    89         ;Group fields
    90         I DTYP="Group" D
    91         .S DGRP=1,DTXT=$P(DDATA,U,5),DCAP=" [group caption]"
    92         .I DTXT="" S DCAP=""
    93         .I DTXT]"" S DCAP=DTXT_" "_DCAP
    94         .S DBOX=$S($P(DDATA,U,6)="Y":"BOX",1:"NO BOX")
    95         .S DSUPP=$S($P(DDATA,U,11):"SUPPRESS",1:"NO SUPPRESS")
    96         .S DSHOW=$S($P(DDATA,U,10):"HIDE",1:"SHOW")
    97         .S DMULT=$P(DDATA,U,9)
    98         .S DMULT=$S(DMULT=1:"ONE ONLY",DMULT=2:"ONE OR MORE",DMULT=3:"NONE OR ONE",1:"NO SELECTION")
    99         ;
    100         N DPTX,DTXT,EXIST,ITEM,TEMP,SEP,SEQ,TAB,ALTLEN
    101         S NSEL=NSEL+1,NLINE=NLINE+1,ITEM=NSEL,SEP=$E(LEV,$L(LEV)),SEQ=LEV_DSEQ
    102         ;Suppress Item numbers for INQ options
    103         I VIEW=4 S ITEM=""
    104         ;Otherwise display Item, Sequence and Dialog Name
    105         S TEMP=$J(ITEM,4)_$J("",3)_SEQ,TAB=$L(TEMP)+2
    106         S CNT=0 F IC=1:1 Q:'$P(SEQ,".",IC)  S:$P(SEQ,".",IC)<10 CNT=CNT+1
    107         S TAB=TAB+CNT
    108         ;
    109         S ALTLEN=$L(TEMP)
    110         ;Display dialog name
    111         S TEMP=TEMP_$J("",2+CNT)_DNAM
    112         ;Add disabled if present
    113         I DDIS]"" S TEMP=TEMP_" (Disabled)"
    114         ;
    115         S ^TMP(NODE,$J,NLINE,0)=TEMP
    116         ;check for alternate dialog element/group
    117         I VIEW<2!(VIEW>4) D
    118         .I $D(^PXRMD(801.41,DIEN,49))>0 D ALT^PXRMDLG5(DIEN,LEV,DSEQ,NODE,VIEW,.NLINE,CNT,ALTLEN)
    119         ;
    120         ;Dialog Text or P/N Text
    121         I (VIEW=2)!(VIEW=3)!(VIEW=4) D
    122         .N DGBEG,DGSUB,TSUB
    123         .S DGSUB=0,TSUB=$$TSUB^PXRMDLG1(DIEN,VIEW)
    124         .I VIEW=4 S DGBEG=$J("",TAB)_"Text: "
    125         .I VIEW'=4 S DGBEG=$J("",5+$L(SEQ)+CNT+$L(DTYP))_"Text: "
    126         .D WP(DIEN,TSUB,65,.DGBEG,.NLINE)
    127         .I DTYP="Group" D
    128         ..S TEMP=DGBEG_"["_DBOX_", "_DSUPP_", "_DSHOW_", "_DMULT_"]"
    129         ..S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=TEMP
    130         ;
    131         ;Set up selection index
    132         S ^TMP(NODE,$J,"IDX",NSEL,DIEN)=""
    133         ;Insert finding items
    134         I (VIEW=1)!(VIEW=4),("Element;Group"[DTYP) D
    135         .N DSUB,FDATA,FILENUM,FLIT,FLONG,FNAME,FOUND,FREP,FTYP,TEMP
    136         .;Findings
    137         .S FNAME="",FOUND=0
    138         .D FDESC($P($G(^PXRMD(801.41,DIEN,1)),U,5))
    139         .I FNAME'="" S FOUND=1 D FSAVE(1,FNAME,FTYP,TAB)
    140         .;Resolution
    141         .I RNAME]"" D
    142         ..S TEMP=$J("",TAB)_"Resolution: "_RNAME
    143         ..S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=TEMP
    144         .;Result Group
    145         .I VIEW=4 D
    146         ..S RCNT=0 F  S RCNT=$O(^PXRMD(801.41,DIEN,51,RCNT)) Q:RCNT'>0  D
    147         ...S RESULT=$P($G(^PXRMD(801.41,DIEN,51,RCNT,0)),U)
    148         ...S RESNM=$P($G(^PXRMD(801.41,RESULT,0)),U) Q:RESNM=""
    149         ...S TEMP=$J("",TAB)_"Result Group: "_RESNM
    150         ...S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=TEMP
    151         .;Additional findings
    152         .D FADD(DIEN,TAB)
    153         ;Get additional prompts
    154         I VIEW=2 D
    155         .S FIEN=$P($G(^PXRMD(801.41,DIEN,1)),U,5)
    156         .I $G(FIEN)["PXD(811.2," D TAX^PXRMDLG1(FIEN,DSEQ,DIEN,.NLINE,NODE)
    157         .I $G(FIEN)["ICPT"!($G(FIEN)["ICD9") D FIND^PXRMDLG1(FIEN,DSEQ,DIEN,.NLINE,NODE)
    158         .D FADD(DIEN,TAB)
    159         I VIEW,VIEW<5,"Element;Group"[DTYP D PROMPT(DIEN,TAB,"Prompts: ",VIEW)
    160         ;
    161         I VIEW=4,$D(^PXRMD(801.41,DIEN,49))>0 D ALT^PXRMDLG5(DIEN,LEV,DSEQ,NODE,VIEW,.NLINE,CNT,ALTLEN)
    162         S NLINE=NLINE+1
    163         S ^TMP(NODE,$J,NLINE,0)=$J("",79)
    164         Q
    165         ;
    166 FDESC(FIEN)     ;Finding description
    167         N FGLOB,FITEM,FNUM
    168         S FGLOB=$P(FIEN,";",2) Q:FGLOB=""
    169         S FITEM=$P(FIEN,";") Q:FITEM=""
    170         S FNUM=" ["_FITEM_"]"
    171         I FGLOB["ICD9" D  Q
    172         .S FTYP="DIAGNOSIS",FGLOB=U_FGLOB_FITEM_",0)"
    173         .S FNAME=$P($G(@FGLOB),U,3)_FNUM
    174         I FGLOB["WV" D  Q
    175         .S FTYP="WH NOTIFICATION PURPOSE",FGLOB=U_FGLOB_FITEM_",0)"
    176         .S FNAME=$P($G(@FGLOB),U)_FNUM
    177         I FGLOB["ICPT" D  Q
    178         .S FTYP="PROCEDURE",FGLOB=U_FGLOB_FITEM_",0)"
    179         .S FNAME=$P($G(@FGLOB),U,2)_FNUM
    180         I FGLOB["ORD(101.41" D  Q
    181         .S FTYP="QUICK ORDER",FGLOB=U_FGLOB_FITEM_",0)"
    182         .S FNAME=$P($G(@FGLOB),U,2)_FNUM
    183         ;Short name for finding type
    184         S FTYP=$G(DEF1(FGLOB)) Q:FTYP=""
    185         ;Long name
    186         S FTYP=$G(DEF2(FTYP))
    187         S FGLOB=U_FGLOB_FITEM_",0)"
    188         S FNAME=$P($G(@FGLOB),U,1)_FNUM
    189         I FNAME="" S FNAME=$P($G(@FGLOB),U)_FNUM
    190         I FNAME="" S FNAME=FITEM
    191         Q
    192         ;
    193 FSAVE(DSUB,FNAME,FTYP,FTAB,FIEN)        ;Save finding details
    194         N TEMP
    195         I DSUB=1 S FLIT="Finding: "
    196         I DSUB>1 S FLIT="Add. Finding: "
    197         S FLONG=0
    198         ;change code to use IOM instead of default length of 60
    199         I $L(FLIT_FNAME_" ("_FTYP_")")>(IOM-20) S FLONG=1
    200         I 'FLONG S FNAME=FLIT_FNAME_" ("_FTYP_")"
    201         I FLONG S FNAME=FLIT_FNAME
    202         S TEMP=$J("",FTAB)_$E(FNAME,1,(IOM-20))_$J("",60-$L(FNAME))
    203         S NLINE=NLINE+1
    204         S ^TMP(NODE,$J,NLINE,0)=TEMP
    205         I FLONG S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=$J("",FTAB)_"("_FTYP_")"
    206         I VIEW=2 D
    207         .I $G(FIEN)["ICPT"!($G(FIEN)["ICD9") D FIND^PXRMDLG1(FIEN,DSEQ,DIEN,.NLINE,NODE)
    208         Q
    209         ;
    210 PROMPT(IEN,TAB,TEXT,VIEW)       ;additional prompts in the dialog file
    211         N DATA,DDIS,DGSEQ,DSUB,DTITLE,DTXT,DTYP,SEQ,SUB
    212         S SEQ=0
    213         F  S SEQ=$O(^PXRMD(801.41,IEN,10,"B",SEQ)) Q:'SEQ  D
    214         .S SUB=$O(^PXRMD(801.41,IEN,10,"B",SEQ,"")) Q:'SUB
    215         .S DSUB=$P($G(^PXRMD(801.41,IEN,10,SUB,0)),U,2) Q:'DSUB
    216         .S DATA=$G(^PXRMD(801.41,DSUB,0)) Q:DATA=""
    217         .S DNAME=$P(DATA,U),DDIS=$P(DATA,U,3),DTYP=$P(DATA,U,4)
    218         .I "PF"'[DTYP Q
    219         .I DTYP="F" S DNAME=DNAME_" (forced value)"
    220         .I DTYP="P",(VIEW=2)!(VIEW=3) D
    221         ..;Override prompt caption
    222         ..S DTITLE=$P($G(^PXRMD(801.41,IEN,10,SUB,0)),U,6)
    223         ..I DTITLE="" S DTITLE=$P($G(^PXRMD(801.41,DSUB,2)),U,4)
    224         ..S DNAME=DTITLE
    225         .S DNAME=$J("",TAB)_TEXT_DNAME
    226         .S:DDIS]"" DNAME=DNAME_" (Disabled)"
    227         .S NLINE=NLINE+1
    228         .S ^TMP(NODE,$J,NLINE,0)=DNAME
    229         .S TEXT=$J("",$L(TEXT))
    230         Q
    231         ;
    232 SEQ(SEQ,PIEN)   ;Select sequence number to add
    233         N X,Y,TEXT,DIR
    234         K DIROUT,DIRUT,DTOUT,DUOUT
    235         S SEQ=0
    236         S DIR(0)="FA0;1;30"
    237         S DIR("A")="Enter a new SEQUENCE NUMBER: "
    238         S DIR("?")="Enter new sequence number. For detailed help type ??"
    239         S DIR("??")=U_"D HELP^PXRMDLG4(1)"
    240         D ^DIR K DIR
    241         I $D(DIROUT) S DTOUT=1
    242         I $D(DTOUT)!($D(DUOUT)) Q
    243         ;
    244         ;Check that sequence number is new
    245         I $D(^TMP("PXRMDLG4",$J,"SEQ",X)) D  Q
    246         .W !,"Sequence number "_X_" already in use."
    247         ;
    248         ;Then check that the parent is a group or reminder dialog
    249         I X["." D  Q:X=""
    250         .N CLASS,SUB
    251         .;Sequence number of parent
    252         .S SUB=$P(X,".",1,$L(X,".")-1)
    253         .I $G(SUB)=""!($G(SUB)=0) W !,"Invalid sequence number. A sequence number cannot be less then 1" H 2 Q
    254         .;Get IEN of parent dialog or group
    255         .S PIEN=$G(^TMP("PXRMDLG4",$J,"SEQ",SUB))
    256         .;Validate sequence number
    257         .I 'PIEN W !,"Sequence number is not part of an existing group." S X="" Q
    258         .;Validate that the parent is a group or reminder dialog
    259         .I "RG"'[$P($G(^PXRMD(801.41,PIEN,0)),U,4) D  S X="" Q
    260         ..W !,"New sequences can only be added to groups or reminder dialogs"
    261         .;Disallow adding elements to national dialogs or groups
    262         .I $P($G(^PXMRD(801.41,PIEN,100)),U)="N" D  Q:X=""
    263         ..Q:(DUZ(0)="@")&($G(PXRMINST)=1)
    264         ..W !,"Elements cannot be added to a national group" S X=""
    265         ;
    266         ;If adding to top level parent ien is reminder dialog
    267         I X?.N S PIEN=PXRMDIEN
    268         ;
    269         S SEQ=$P(X,".",$L(X,"."))
    270         Q
    271         ;
    272         ;
    273 HELP(CALL)      ;General help text routine.
    274         N HTEXT
    275         N DIWF,DIWL,DIWR,IC
    276         S DIWF="C75",DIWL=0,DIWR=75
    277         ;
    278         I CALL=1 D
    279         .S HTEXT(1)="Sequence numbers can be added at any level. Specify the full"
    280         .S HTEXT(2)="number for the level required (e.g. 15.10.20)."
    281         ;
    282         D HELP^PXRMEUT(.HTEXT)
    283         Q
    284         ;
     1PXRMDLG4 ; SLC/PJH - Reminder Dialog Edit/Inquiry ;10/31/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4WP(SUB,SUB1,WIDTH,SEQ,VALMCNT) ;Format WP text
     5 N DIWF,DIWL,DIWR,IC,TEXT,X,TXTCNT,DTXT,CNT,SUB2
     6 S (CNT,SUB2,TXTCNT)=0
     7 F  S SUB2=$O(^PXRMD(801.41,SUB,SUB1,SUB2)) Q:'SUB2  D
     8 .S TXTCNT=TXTCNT+1,DTXT(TXTCNT)=$G(^PXRMD(801.41,SUB,SUB1,SUB2,0))
     9 .S DTXT(TXTCNT)=$$STRREP^PXRMUTIL($G(DTXT(TXTCNT)),"<br>","\\")
     10 I TXTCNT>0 D
     11 .N OUTPUT,NLINES
     12 .S NLINES=0 D FORMAT^PXRMTEXT(1,WIDTH,TXTCNT,.DTXT,.NLINES,.OUTPUT)
     13 .I NLINES>0 K DTXT M DTXT=OUTPUT
     14 S CNT=0
     15 F  S CNT=$O(DTXT(CNT)) Q:CNT=""  D
     16 .S TEXT=$G(DTXT(CNT)),VALMCNT=VALMCNT+1
     17 .S ^TMP(NODE,$J,VALMCNT,0)=SEQ_TEXT,SEQ=$J("",$L(SEQ))
     18 Q
     19 ;
     20ADD ;PXRM DIALOG ADD ELEMENT validation
     21 N ANS,DTOUT,DUOUT,LIT,LOCK,Y,PIEN,ERR,IEN,NATIONAL,SEQ
     22 W IORESET
     23 S VALMBCK="R",NATIONAL=0
     24 ;Check if national reminder dialog
     25 I $P($G(^PXRMD(801.41,PXRMDIEN,100)),U)="N" S NATIONAL=1
     26 S LOCK=$P($G(^PXRMD(801.41,PXRMDIEN,100)),U,4)
     27 ;Dissallow editing of national dialogs
     28 I NATIONAL,'($G(PXRMINST)=1)&(DUZ(0)="@"),$G(LOCK)'=1 D  Q
     29 .W !,"Elements may not be added to national reminder dialogs" H 2
     30 ;
     31 F  D SEQ(.SEQ,.PIEN) Q:$D(DUOUT)!$D(DTOUT)  Q:SEQ
     32 Q:$D(DUOUT)!$D(DTOUT)
     33 ;
     34 ;Check if sequence number is OK
     35 I $G(PIEN)="" Q
     36 S ANS="N" D ASK^PXRMDLG5(.ANS,PIEN) Q:$D(DUOUT)!$D(DTOUT)!($G(ANS)="N")
     37 ;
     38 ;Select a dialog element to add to parent dialog (PIEN)
     39 ;PIEN may be dialog or a group within the dialog
     40 D ESEL^PXRMDEDT(PIEN,SEQ)
     41 ;Rebuild workfile
     42 D BUILD^PXRMDLG(VIEW)
     43 Q
     44 ;
     45FADD(DIEN,FTAB) ;Additional Findings
     46 N FIND,FSUB,FTYP,FNAME,FNUM
     47 S FSUB=0
     48 F  S FSUB=$O(^PXRMD(801.41,DIEN,3,FSUB)) Q:'FSUB  D
     49 .S FIND=$P($G(^PXRMD(801.41,DIEN,3,FSUB,0)),U) Q:FIND=""
     50 .S FNAME="" D FDESC(FIND) Q:FNAME=""
     51 .;Save additional finding name
     52 .S FOUND=1 D FSAVE(2,FNAME,FTYP,FTAB,FIND)
     53 Q
     54 ;
     55DETAIL(DIEN,LEV,VIEW,NODE) ;;Build listman global for all components
     56 N DDATA,DDLG,DEND,DCIEN,DNAM,DSEQ,DSTRT,IND,JND,DSUB
     57 S DSEQ=0
     58 ;
     59 ;Get each sequence number
     60 F  S DSEQ=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ)) Q:'DSEQ  D
     61 .;Determine subscript
     62 .S DSUB=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ,"")) Q:'DSUB
     63 .;Get ien of prompt/component
     64 .S DCIEN=$P($G(^PXRMD(801.41,DIEN,10,DSUB,0)),U,2) Q:'DCIEN
     65 .;Ignore prompts and forced values
     66 .I "PF"[$P($G(^PXRMD(801.41,DCIEN,0)),U,4) Q
     67 .;Save line in workfile
     68 .D DLINE(DCIEN,LEV,DSEQ,NODE)
     69 .;Build pointers back to parent
     70 .I VIEW'=4 D
     71 ..S ^TMP("PXRMDLG4",$J,"IEN",NSEL)=DIEN_U_DSEQ
     72 ..S ^TMP("PXRMDLG4",$J,"SEQ",LEV_DSEQ)=DCIEN
     73 .;Process any sub-components
     74 .I VIEW<5 D DETAIL(DCIEN,LEV_DSEQ_".",VIEW,NODE)
     75 Q
     76 ;
     77DLINE(DIEN,LEV,DSEQ,NODE) ;Save individual component details
     78 N CNT,DBOX,DCAP,DDIS,DMULT,DSUPP,DSHOW,DTYP,DTXT
     79 N IC,RESNM,RESULT,RIEN,RNAME
     80 ;Dialog name
     81 S DDATA=$G(^PXRMD(801.41,DIEN,0)),DNAM=$P(DDATA,U) Q:DNAM=""
     82 ;Check if standard PXRM prompt
     83 I $$PXRM^PXRMEXID(DNAM) Q
     84 ;Dialog Type and Disabled
     85 S DDIS=$P(DDATA,U,3),DTYP=$P(DDATA,U,4)
     86 S DTYP=$S(DTYP="G":"Group",1:"Element"),DNAM=DTYP_": "_DNAM
     87 I VIEW=5 S DNAM=DNAM
     88 ;Resolution type and name
     89 S RNAME="",RIEN=$P($G(^PXRMD(801.41,DIEN,1)),U,3)
     90 I RIEN S RNAME=$P($G(^PXRMD(801.9,RIEN,0)),U)
     91 ;Result Group
     92 S RESULT=$P(DDATA,U,15)
     93 I RESULT S RESNM=$P($G(^PXRMD(801.41,RESULT,0)),U)
     94 ;
     95 ;Group fields
     96 I DTYP="Group" D
     97 .S DGRP=1,DTXT=$P(DDATA,U,5),DCAP=" [group caption]"
     98 .I DTXT="" S DCAP=""
     99 .I DTXT]"" S DCAP=DTXT_" "_DCAP
     100 .S DBOX=$S($P(DDATA,U,6)="Y":"BOX",1:"NO BOX")
     101 .S DSUPP=$S($P(DDATA,U,11):"SUPPRESS",1:"NO SUPPRESS")
     102 .S DSHOW=$S($P(DDATA,U,10):"HIDE",1:"SHOW")
     103 .S DMULT=$P(DDATA,U,9)
     104 .S DMULT=$S(DMULT=1:"ONE ONLY",DMULT=2:"ONE OR MORE",DMULT=3:"NONE OR ONE",1:"NO SELECTION")
     105 ;
     106 N DPTX,DTXT,EXIST,ITEM,TEMP,SEP,SEQ,TAB,ALTLEN
     107 S NSEL=NSEL+1,NLINE=NLINE+1,ITEM=NSEL,SEP=$E(LEV,$L(LEV)),SEQ=LEV_DSEQ
     108 ;Suppress Item numbers for INQ options
     109 I VIEW=4 S ITEM=""
     110 ;Otherwise display Item, Sequence and Dialog Name
     111 S TEMP=$J(ITEM,4)_$J("",3)_SEQ,TAB=$L(TEMP)+2
     112 S CNT=0 F IC=1:1 Q:'$P(SEQ,".",IC)  S:$P(SEQ,".",IC)<10 CNT=CNT+1
     113 S TAB=TAB+CNT
     114 ;
     115 S ALTLEN=$L(TEMP)
     116 ;Display dialog name
     117 S TEMP=TEMP_$J("",2+CNT)_DNAM
     118 ;Add disabled if present
     119 I DDIS]"" S TEMP=TEMP_" (Disabled)"
     120 ;
     121 S ^TMP(NODE,$J,NLINE,0)=TEMP
     122 ;check for alternate dialog element/group
     123 I VIEW<2!(VIEW>4) D
     124 .I $D(^PXRMD(801.41,DIEN,49))>0 D ALT^PXRMDLG5(DIEN,LEV,DSEQ,NODE,VIEW,.NLINE,CNT,ALTLEN)
     125 ;
     126 ;Dialog Text or P/N Text
     127 I (VIEW=2)!(VIEW=3)!(VIEW=4) D
     128 .N DGBEG,DGSUB,TSUB
     129 .S DGSUB=0,TSUB=$$TSUB^PXRMDLG1(DIEN,VIEW)
     130 .I VIEW=4 S DGBEG=$J("",TAB)_"Text: "
     131 .I VIEW'=4 S DGBEG=$J("",5+$L(SEQ)+CNT+$L(DTYP))_"Text: "
     132 .D WP(DIEN,TSUB,65,.DGBEG,.NLINE)
     133 .I DTYP="Group" D
     134 ..S TEMP=DGBEG_"["_DBOX_", "_DSUPP_", "_DSHOW_", "_DMULT_"]"
     135 ..S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=TEMP
     136 ;
     137 ;Set up selection index
     138 S ^TMP(NODE,$J,"IDX",NSEL,DIEN)=""
     139 ;Insert finding items
     140 I (VIEW=1)!(VIEW=4),("Element;Group"[DTYP) D
     141 .N DSUB,FDATA,FILENUM,FLIT,FLONG,FNAME,FOUND,FREP,FTYP,TEMP
     142 .;Findings
     143 .S FNAME="",FOUND=0
     144 .D FDESC($P($G(^PXRMD(801.41,DIEN,1)),U,5))
     145 .I FNAME'="" S FOUND=1 D FSAVE(1,FNAME,FTYP,TAB)
     146 .;Resolution
     147 .I RNAME]"" D
     148 ..S TEMP=$J("",TAB)_"Resolution: "_RNAME
     149 ..S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=TEMP
     150 .;Additional findings
     151 .D FADD(DIEN,TAB)
     152 ;Get additional prompts
     153 I VIEW=2 D
     154 .S FIEN=$P($G(^PXRMD(801.41,DIEN,1)),U,5)
     155 .I $G(FIEN)["PXD(811.2," D TAX^PXRMDLG1(FIEN,DSEQ,DIEN,.NLINE,NODE)
     156 .I $G(FIEN)["ICPT"!($G(FIEN)["ICD9") D FIND^PXRMDLG1(FIEN,DSEQ,DIEN,.NLINE,NODE)
     157 .D FADD(DIEN,TAB)
     158 I VIEW,VIEW<5,"Element;Group"[DTYP D PROMPT(DIEN,TAB,"Prompts: ",VIEW)
     159 ;
     160 I VIEW=4,$D(^PXRMD(801.41,DIEN,49))>0 D ALT^PXRMDLG5(DIEN,LEV,DSEQ,NODE,VIEW,.NLINE,CNT,ALTLEN)
     161 S NLINE=NLINE+1
     162 S ^TMP(NODE,$J,NLINE,0)=$J("",79)
     163 Q
     164 ;
     165FDESC(FIEN) ;Finding description
     166 N FGLOB,FITEM,FNUM
     167 ;Determine finding type
     168 S FGLOB=$P(FIEN,";",2) Q:FGLOB=""
     169 S FITEM=$P(FIEN,";") Q:FITEM=""
     170 S FNUM=" ["_FITEM_"]"
     171 I FGLOB["ICD9" D  Q
     172 .S FTYP="DIAGNOSIS",FGLOB=U_FGLOB_FITEM_",0)"
     173 .S FNAME=$P($G(@FGLOB),U,3)_FNUM
     174 I FGLOB["WV" D  Q
     175 .S FTYP="WH NOTIFICATION PURPOSE",FGLOB=U_FGLOB_FITEM_",0)"
     176 .S FNAME=$P($G(@FGLOB),U)_FNUM
     177 I FGLOB["ICPT" D  Q
     178 .S FTYP="PROCEDURE",FGLOB=U_FGLOB_FITEM_",0)"
     179 .S FNAME=$P($G(@FGLOB),U,2)_FNUM
     180 I FGLOB["ORD(101.41" D  Q
     181 .S FTYP="QUICK ORDER",FGLOB=U_FGLOB_FITEM_",0)"
     182 .S FNAME=$P($G(@FGLOB),U,2)_FNUM
     183 ;Short name for finding type
     184 S FTYP=$G(DEF1(FGLOB)) Q:FTYP=""
     185 ;Long name
     186 S FTYP=$G(DEF2(FTYP))
     187 S FGLOB=U_FGLOB_FITEM_",0)"
     188 S FNAME=$P($G(@FGLOB),U,1)_FNUM
     189 I FNAME="" S FNAME=$P($G(@FGLOB),U)_FNUM
     190 I FNAME="" S FNAME=FITEM
     191 Q
     192 ;
     193FSAVE(DSUB,FNAME,FTYP,FTAB,FIEN) ;Save finding details
     194 N TEMP
     195 I DSUB=1 S FLIT="Finding: "
     196 I DSUB>1 S FLIT="Add. Finding: "
     197 S FLONG=0
     198 ;change code to use IOM instead of default length of 60
     199 I $L(FLIT_FNAME_" ("_FTYP_")")>(IOM-20) S FLONG=1
     200 I 'FLONG S FNAME=FLIT_FNAME_" ("_FTYP_")"
     201 I FLONG S FNAME=FLIT_FNAME
     202 S TEMP=$J("",FTAB)_$E(FNAME,1,(IOM-20))_$J("",60-$L(FNAME))
     203 S NLINE=NLINE+1
     204 S ^TMP(NODE,$J,NLINE,0)=TEMP
     205 I FLONG S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=$J("",FTAB)_"("_FTYP_")"
     206 I VIEW=2 D
     207 .I $G(FIEN)["ICPT"!($G(FIEN)["ICD9") D FIND^PXRMDLG1(FIEN,DSEQ,DIEN,.NLINE,NODE)
     208 Q
     209 ;
     210PROMPT(IEN,TAB,TEXT,VIEW) ;additional prompts in the dialog file
     211 N DATA,DDIS,DGSEQ,DSUB,DTITLE,DTXT,DTYP,SEQ,SUB
     212 S SEQ=0
     213 F  S SEQ=$O(^PXRMD(801.41,IEN,10,"B",SEQ)) Q:'SEQ  D
     214 .S SUB=$O(^PXRMD(801.41,IEN,10,"B",SEQ,"")) Q:'SUB
     215 .S DSUB=$P($G(^PXRMD(801.41,IEN,10,SUB,0)),U,2) Q:'DSUB
     216 .S DATA=$G(^PXRMD(801.41,DSUB,0)) Q:DATA=""
     217 .S DNAME=$P(DATA,U),DDIS=$P(DATA,U,3),DTYP=$P(DATA,U,4)
     218 .I "PF"'[DTYP Q
     219 .I DTYP="F" S DNAME=DNAME_" (forced value)"
     220 .I DTYP="P",(VIEW=2)!(VIEW=3) D
     221 ..;Override prompt caption
     222 ..S DTITLE=$P($G(^PXRMD(801.41,IEN,10,SUB,0)),U,6)
     223 ..I DTITLE="" S DTITLE=$P($G(^PXRMD(801.41,DSUB,2)),U,4)
     224 ..S DNAME=DTITLE
     225 .S DNAME=$J("",TAB)_TEXT_DNAME
     226 .S:DDIS]"" DNAME=DNAME_" (Disabled)"
     227 .S NLINE=NLINE+1
     228 .S ^TMP(NODE,$J,NLINE,0)=DNAME
     229 .S TEXT=$J("",$L(TEXT))
     230 Q
     231 ;
     232SEQ(SEQ,PIEN) ;Select sequence number to add
     233 N X,Y,TEXT,DIR
     234 K DIROUT,DIRUT,DTOUT,DUOUT
     235 S SEQ=0
     236 S DIR(0)="FA0;1;30"
     237 S DIR("A")="Enter a new SEQUENCE NUMBER: "
     238 S DIR("?")="Enter new sequence number. For detailed help type ??"
     239 S DIR("??")=U_"D HELP^PXRMDLG4(1)"
     240 D ^DIR K DIR
     241 I $D(DIROUT) S DTOUT=1
     242 I $D(DTOUT)!($D(DUOUT)) Q
     243 ;
     244 ;Check that sequence number is new
     245 I $D(^TMP("PXRMDLG4",$J,"SEQ",X)) D  Q
     246 .W !,"Sequence number "_X_" already in use."
     247 ;
     248 ;Then check that the parent is a group or reminder dialog
     249 I X["." D  Q:X=""
     250 .N CLASS,SUB
     251 .;Sequence number of parent
     252 .S SUB=$P(X,".",1,$L(X,".")-1)
     253 .I $G(SUB)=""!($G(SUB)=0) W !,"Invalid sequence number. A sequence number cannot be less then 1" H 2 Q
     254 .;Get IEN of parent dialog or group
     255 .S PIEN=$G(^TMP("PXRMDLG4",$J,"SEQ",SUB))
     256 .;Validate sequence number
     257 .I 'PIEN W !,"Sequence number is not part of an existing group." S X="" Q
     258 .;Validate that the parent is a group or reminder dialog
     259 .I "RG"'[$P($G(^PXRMD(801.41,PIEN,0)),U,4) D  S X="" Q
     260 ..W !,"New sequences can only be added to groups or reminder dialogs"
     261 .;Disallow adding elements to national dialogs or groups
     262 .I $P($G(^PXMRD(801.41,PIEN,100)),U)="N" D  Q:X=""
     263 ..Q:(DUZ(0)="@")&($G(PXRMINST)=1)
     264 ..W !,"Elements cannot be added to a national group" S X=""
     265 ;
     266 ;If adding to top level parent ien is reminder dialog
     267 I X?.N S PIEN=PXRMDIEN
     268 ;
     269 S SEQ=$P(X,".",$L(X,"."))
     270 Q
     271 ;
     272 ;
     273HELP(CALL) ;General help text routine.
     274 N HTEXT
     275 N DIWF,DIWL,DIWR,IC
     276 S DIWF="C75",DIWL=0,DIWR=75
     277 ;
     278 I CALL=1 D
     279 .S HTEXT(1)="Sequence numbers can be added at any level. Specify the full"
     280 .S HTEXT(2)="number for the level required (e.g. 15.10.20)."
     281 ;
     282 D HELP^PXRMEUT(.HTEXT)
     283 Q
     284 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLG5.m

    r613 r623  
    1 PXRMDLG5        ; SLC/PJH - Reminder Dialog Edit/Inquiry ;11/08/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 ALT(DIEN,LEV,DSEQ,NODE,VIEW,NLINE,CNT,ALTLEN)   ;
    5         ;Display branching logic text in dialog summary view
    6         N DATA,DNAM,DTYP,IEN,TERM,TNAME,TSTAT,TEMP
    7         S DATA=$G(^PXRMD(801.41,DIEN,49))
    8         I '+$P(DATA,U)!($P($G(DATA),U,2)="") Q
    9         S TNAME=$P($G(^PXRMD(811.5,$P(DATA,U),0)),U)
    10         S TSTAT=$S($P(DATA,U,2)="1":"TRUE",1:"FALSE")
    11         I +$P(DATA,U,3)>0 D
    12         .S IEN=$P(DATA,U,3),DNAM=$P($G(^PXRMD(801.41,IEN,0)),U)
    13         .S DTYP=$S($P($G(^PXRMD(801.41,IEN,0)),U,4)="E":"Element",$P($G(^PXRMD(801.41,IEN,0)),U,4)="G":"Group")
    14         I $G(DNAM)="" S TEMP="Suppressed if Reminder Term "_TNAME_" evaluates as "_TSTAT
    15         I $G(DNAM)'="" S TEMP="Replaced by "_DNAM_" if Reminder Term "_TNAME_" evaluates as "_TSTAT
    16         D TEXT(.NLINES,CNT,ALTLEN,TEMP,NODE)
    17         Q
    18         ;
    19 ASK(YESNO,PIEN) ;Confirm
    20         K DIR,DIROUT,DIRUT,DNAME,DTOUT,DTYP,DUOUT,TEXT,X,Y
    21         N DDATA,DNAME,DTYP
    22         S DDATA=$G(^PXRMD(801.41,PIEN,0))
    23         ;Parent name and type
    24         S DNAME=$P(DDATA,U),DTYP=$P(DDATA,U,4)
    25         ;
    26         S DIR(0)="YA0"
    27         S DIR("A")="Add sequence "_SEQ_" to "
    28         I DTYP="G" S DIR("A")=DIR("A")_"group "_DNAME_": "
    29         E  S DIR("A")=DIR("A")_"reminder dialog ?: "
    30         S DIR("B")="N",DIR("?")="Enter Y or N. For detailed help type ??"
    31         S DIR("??")=U_"D XHLP^PXRMDLG(1)"
    32         D ^DIR K DIR
    33         I $D(DIROUT) S DTOUT=1
    34         I $D(DTOUT)!($D(DUOUT)) Q
    35         S YESNO=$E(Y(0)) I YESNO'="Y" S DUOUT=1
    36         S VALMBCK="R"
    37         Q
    38         ;
    39 BHELP(VALUE)    ;
    40         N HTEXT
    41         D FULL^VALM1
    42         ;Help text for Reminder Dialog Branching logic
    43         I VALUE=1 D
    44         .;Reminder Term field
    45         .S HTEXT(1)="Enter a reminder term that will be used to determine if the reminder"
    46         .S HTEXT(2)="element/group should be replaced or suppressed if the reminder term evaluation"
    47         .S HTEXT(3)="matches the value in the Reminder Term Status field."
    48         I VALUE=2 D
    49         .;Reminder Term Status field
    50         .S HTEXT(1)="Enter either 1 for true or 0 for false. This value will be used with the"
    51         .S HTEXT(2)="reminder term field to determine if this item should be replaced with a"
    52         .S HTEXT(3)="different element/group defined in the Replacement Element/Group field, or if"
    53         .S HTEXT(4)="this item should be suppressed."
    54         I VALUE=3 D
    55         .;Replacement Element/Group field
    56         .S HTEXT(1)="Enter an element/group that will be used as a replacement to thisitem, or"
    57         .S HTEXT(2)="leave this field blank to suppress this item if the term evaluation"
    58         .S HTEXT(3)="matches the value defined in the term status field. "
    59         I VALUE=4 D
    60         .;Patient Specific field
    61         .S HTEXT(1)="Enter either 1 for true or 0 for false. This value must be set to true"
    62         .S HTEXT(2)="if item in this dialog will be using reminder term to either replace an item"
    63         .S HTEXT(3)="or to suppress an item."
    64         D HELP^PXRMEUT(.HTEXT)
    65         Q
    66         ;
    67 INQ(DIEN)       ;INQ Inquiry/Print option
    68         ; Used by 801.41 print templates
    69         ; [PXRM REMINDER DIALOG]
    70         ; [PXRM DIALOG GROUP]
    71         ;
    72         N DEF,DEF1,DEF2 D DEF^PXRMRUTL("811.902",.DEF,.DEF1,.DEF2)
    73         N NLINE,NODE,NSEL,SUB
    74         S NLINE=0,NODE="PXRMDLG4",NSEL=0
    75         K ^TMP(NODE,$J)
    76         ;
    77         ;Components
    78         W !!,"      Seq.       Dialog",!
    79         D DETAIL^PXRMDLG4(DIEN,"",4,NODE)
    80         ;
    81         ;Print lines from workfile
    82         S SUB=""
    83         F  S SUB=$O(^TMP(NODE,$J,SUB)) Q:'SUB  W !,^TMP(NODE,$J,SUB,0)
    84         K ^TMP(NODE,$J)
    85         Q
    86         ;
    87 MH(IEN) ;Allow IEN=109 (HX2) as a place holder for 601 entries that do not
    88         ;have a corresponding 601.71 entry.
    89         I IEN=109 Q 1
    90         I $G(PXRMINST)=1 Q 1
    91         N MAXNUM
    92         S MAXNUM=+$P($G(^PXRM(800,1,"MH")),U)
    93         I MAXNUM=0 S MAXNUM=25
    94         Q $$ONECR^YTQPXRM5(IEN,MAXNUM)
    95         ;
    96 MHLICR(IEN)     ;Called by input template PXRM EDIT ELEMENT. Preserve Y so template
    97         ;branching works.
    98         N Y
    99         ;DBIA #5042
    100         I $$RL^YTQPXRM3(IEN)="Y" D
    101         .W !,"This MH test requires a license."
    102         .W !,"The question text will not appear in the progress note.",!
    103         .H 1
    104         Q
    105         ;
    106 MSEL(NUM)       ;
    107         I NUM=4,'$$PATCH^XPDUTL("OR*3.0*243") D EN^DDIOL("THIS SELECTION IS NOT VALID, UNTIL CPRS 27 IS INSTALLED") Q 0
    108         Q 1
    109         ;
    110 MHREQHLP        ;
    111         N TEXT
    112         S TEXT(1)="Select 0, ""Optional open and optional complete (partial complete possible)"","
    113         S TEXT(2)="if the user should be able to optionally select/open the MH test in the reminder dialog and optionally complete the MH test before the reminder dialog can be finished."
    114         S TEXT(3)=" "
    115         S TEXT(4)="Select 1, ""Required open and required complete before finish"","
    116         S TEXT(5)="if the user is required to select/open and complete the MH test in the reminder dialog before the reminder dialog can be finished."
    117         S TEXT(6)=" "
    118         S TEXT(7)="Select 2, ""Optional open and required complete or cancel before finish"","
    119         S TEXT(8)="if the user should be able to optionally select/open the MH test in the reminder dialog; however, if the user opens the MH test, then the user is required to complete or cancel the MH test before the reminder dialog can be finished."
    120         S TEXT(9)=" "
    121         S TEXT(10)="Note: Clicking the cancel button in the MH Test is considered the same as not opening the MH Test."
    122         S TEXT(11)="Also, Option 2, ""Optional open and required complete or cancel before finish"", only works with CPRS 27 and"
    123         S TEXT(12)="YS_MHA.dll. If Option 2 is selected and the user is using a pre-CPRS 27 version this option will be treated by CPRS as Option 1, ""Required open and required complete before finish""."
    124         D HELP^PXRMEUT(.TEXT)
    125         Q
    126         ;
    127 NTERM(DA,OTERM,NTERM)   ;
    128         I +OTERM=0 S OTERM=$P($G(DA),U)
    129         I +NTERM=0 K OTERM Q 2
    130         I +OTERM=0,+NTERM>0 K OTERM Q 1
    131         I +OTERM'=+NTERM K OTERM Q 0
    132         K OTERM
    133         Q 1
    134         ;
    135 OTERM(DA)       ;
    136         K OTERM
    137         S OTERM=$P($G(^PXRMD(801.41,DA,49)),U)
    138         Q
    139         ;
    140 RESCHK(IEN)     ;Called by input template PXRM EDIT ELEMENT. Preserve Y so template
    141         ;branching works.
    142         N CNT,FDA,MSG,RG,RGIEN,VALID,Y
    143         S CNT=0
    144         F  S CNT=$O(^PXRMD(801.41,IEN,51,CNT)) Q:CNT'>0  D
    145         .S RGIEN=$P($G(^PXRMD(801.41,IEN,51,CNT,0)),U) I +RGIEN'>0 Q
    146         .S RG=$P($G(^PXRMD(801.41,RGIEN,0)),U,1)
    147         .I RG="" Q
    148         .S VALID=$$RGLSCR(IEN,RG,RGIEN)
    149         .I VALID Q
    150         .W !,"Deleting the result group ",RG," from the element/group."
    151         .S FDA(801.41121,CNT_","_IEN_",",.01)="@"
    152         .D FILE^DIE("E","FDA","MSG")
    153         .S RGKILL=1
    154         .I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    155         Q
    156         ;
    157 RSELEDIT(DA)    ;
    158         N NODE,RESULT
    159         ;RESULT=0 EDIT NOTHING
    160         ;RESULT=1 EDIT INFORMATIONAL TEXT
    161         ;RESULT=2 EDIT EVERYTHING
    162         S RESULT=2
    163         I $G(PXRMINST)=1,DUZ(0)="@" Q RESULT
    164         S NODE=$G(^PXRMD(801.41,DA,100))
    165         I $P(NODE,U)="N" S RESULT=0
    166         I RESULT=0,+$P(NODE,U,4)=0 S RESULT=1
    167         Q RESULT
    168         ;
    169 RGLSCR(DA,X,IEN)        ;Input transform/screen for RESULT GROUP LIST
    170         I $G(PXRMINST)=1 Q 1
    171         I $G(PXRMEXCH)=1 Q 1
    172         N HELP,MHTEST,TEXT,VALID,Y
    173         S NMATCH=0
    174         S MHTEST=$O(^PXRMD(801.41,"B",X),-1)
    175         F  S MHTEST=$O(^PXRMD(801.41,"B",MHTEST)) Q:(NMATCH>1)!(MHTEST'[X)  S NMATCH=NMATCH+1
    176         ;If there is an exact match to the user's input turn help on.
    177         S HELP=$S($G(DIQUIET):0,NMATCH=1:1,1:0)
    178         S VALID=1
    179         ;Make sure the TYPE is a result group
    180         I '$D(^PXRMD(801.41,"TYPE","S",IEN)) D
    181         . I HELP S TEXT(1)="TYPE must be a result group."
    182         . S VALID=0
    183         ;Make sure the finding item for the element matches the
    184         ;MH Test assigned to the Result Group
    185         S MHTEST=+$P($G(^PXRMD(801.41,DA,1)),U,5) I MHTEST="" D
    186         . I HELP S TEXT(2)="The MH test is missing."
    187         . S VALID=0
    188         I +$P($G(^PXRMD(801.41,IEN,50)),U)'=MHTEST D
    189         . I HELP S TEXT(3)="The finding item does not match the MH Test assigned to the Result Group"
    190         . S VALID=0
    191         ;Make sure a scale has been defined.
    192         I +$P($G(^PXRMD(801.41,IEN,50)),U,2)'>0 D
    193         . I HELP S TEXT(4)="An MH Scale must be defined."
    194         . S VALID=0
    195         ;Make sure it is not disabled.
    196         I $P($G(^PXRMD(801.41,IEN,0)),U,3)'="" D
    197         . S VALID=0
    198         . I HELP D
    199         .. N EM,TYPE
    200         .. S TYPE=$P(^PXRMD(801.41,IEN,0),U,4)
    201         .. S TYPE=$$EXTERNAL^DILFD(801.41,4,"",TYPE,.EM)
    202         .. S TEXT(5)="The "_TYPE_" is disabled."
    203         I HELP,'VALID D EN^DDIOL(.TEXT)
    204         Q VALID
    205         ;
    206 TERMS(DA,X)     ;
    207         N TERM
    208         S TERM=$P($G(^PXRMD(801.41,DA,49)),U)
    209         I +TERM=0 D  Q 0
    210         .W !,"Cannot set Reminder Term Status if the Reminder Term field is blank"
    211         .H 2
    212         I +TERM>0,$G(X)="" Q 2
    213         Q 1
    214         ;
    215 TEXT(NLINES,CNT,ATLEN,TEMP,NODE)        ;
    216         N CNT1,NOUT,OUTPUT,WIDHT
    217         S WIDTH=IOM-(2+(CNT+ATLEN))
    218         S CNT1=1 D FORMATS^PXRMTEXT(1,WIDTH,TEMP,.NOUT,.OUTPUT)
    219         I NOUT>0 F CNT1=1:1:NOUT D
    220         .S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=$J("",2+(CNT+ATLEN))_OUTPUT(CNT1)
    221         Q
    222         ;
     1PXRMDLG5 ; SLC/PJH - Reminder Dialog Edit/Inquiry ;05/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;
     5ASK(YESNO,PIEN) ;Confirm
     6 K DIR,DIROUT,DIRUT,DNAME,DTOUT,DTYP,DUOUT,TEXT,X,Y
     7 N DDATA,DNAME,DTYP
     8 S DDATA=$G(^PXRMD(801.41,PIEN,0))
     9 ;Parent name and type
     10 S DNAME=$P(DDATA,U),DTYP=$P(DDATA,U,4)
     11 ;
     12 S DIR(0)="YA0"
     13 S DIR("A")="Add sequence "_SEQ_" to "
     14 I DTYP="G" S DIR("A")=DIR("A")_"group "_DNAME_": "
     15 E  S DIR("A")=DIR("A")_"reminder dialog ?: "
     16 S DIR("B")="N",DIR("?")="Enter Y or N. For detailed help type ??"
     17 S DIR("??")=U_"D XHLP^PXRMDLG(1)"
     18 D ^DIR K DIR
     19 I $D(DIROUT) S DTOUT=1
     20 I $D(DTOUT)!($D(DUOUT)) Q
     21 S YESNO=$E(Y(0)) I YESNO'="Y" S DUOUT=1
     22 S VALMBCK="R"
     23 Q
     24 ;
     25MSEL(NUM) ;
     26 I NUM=4,'$$PATCH^XPDUTL("OR*3.0*243") D EN^DDIOL("THIS SELECTION IS NOT VALID, UNTIL CPRS 27 IS INSTALLED") Q 0
     27 Q 1
     28 ;
     29ALT(DIEN,LEV,DSEQ,NODE,VIEW,NLINE,CNT,ALTLEN) ;
     30 ;Display branching logic text in dialog summary view
     31 N DATA,DNAM,DTYP,IEN,TERM,TNAME,TSTAT,TEMP
     32 S DATA=$G(^PXRMD(801.41,DIEN,49))
     33 I '+$P(DATA,U)!($P($G(DATA),U,2)="") Q
     34 S TNAME=$P($G(^PXRMD(811.5,$P(DATA,U),0)),U)
     35 S TSTAT=$S($P(DATA,U,2)="1":"TRUE",1:"FALSE")
     36 I +$P(DATA,U,3)>0 D
     37 .S IEN=$P(DATA,U,3),DNAM=$P($G(^PXRMD(801.41,IEN,0)),U)
     38 .S DTYP=$S($P($G(^PXRMD(801.41,IEN,0)),U,4)="E":"Element",$P($G(^PXRMD(801.41,IEN,0)),U,4)="G":"Group")
     39 I $G(DNAM)="" S TEMP="Suppressed if Reminder Term "_TNAME_" evaluates as "_TSTAT
     40 I $G(DNAM)'="" S TEMP="Replaced by "_DNAM_" if Reminder Term "_TNAME_" evaluates as "_TSTAT
     41 D TEXT(.NLINES,CNT,ALTLEN,TEMP,NODE)
     42 Q
     43 ;
     44OTERM(DA) ;
     45 K OTERM
     46 S OTERM=$P($G(^PXRMD(801.41,DA,49)),U) Q
     47 ;
     48NTERM(DA,OTERM,NTERM) ;
     49 I +OTERM=0 S OTERM=$P($G(DA),U)
     50 I +NTERM=0 K OTERM Q 2
     51 I +OTERM=0,+NTERM>0 K OTERM Q 1
     52 I +OTERM'=+NTERM K OTERM Q 0
     53 K OTERM
     54 Q 1
     55 ;
     56TERMS(DA,X) ;
     57 N TERM
     58 S TERM=$P($G(^PXRMD(801.41,DA,49)),U)
     59 I +TERM=0 D  Q 0
     60 .W !,"Cannot set Reminder Term Status if the Reminder Term field is blank"
     61 .H 2
     62 I +TERM>0,$G(X)="" Q 2
     63 Q 1
     64 ;
     65BHELP(VALUE) ;
     66 N HTEXT
     67 D FULL^VALM1
     68 ;Help text for Reminder Dialog Branching logic
     69 I VALUE=1 D
     70 .;Reminder Term field
     71 .S HTEXT(1)="Enter a reminder term that will be used to determine if the reminder"
     72 .S HTEXT(2)="element/group should be replaced or suppressed if the reminder term evaluation"
     73 .S HTEXT(3)="matches the value in the Reminder Term Status field."
     74 I VALUE=2 D
     75 .;Reminder Term Status field
     76 .S HTEXT(1)="Enter either 1 for true or 0 for false. This value will be used with the"
     77 .S HTEXT(2)="reminder term field to determine if this item should be replaced with a"
     78 .S HTEXT(3)="different element/group defined in the Replacement Element/Group field, or if"
     79 .S HTEXT(4)="this item should be suppressed."
     80 I VALUE=3 D
     81 .;Replacement Element/Group field
     82 .S HTEXT(1)="Enter an element/group that will be used as a replacement to thisitem, or"
     83 .S HTEXT(2)="leave this field blank to suppress this item if the term evaluation"
     84 .S HTEXT(3)="matches the value defined in the term status field. "
     85 I VALUE=4 D
     86 .;Patient Specific field
     87 .S HTEXT(1)="Enter either 1 for true or 0 for false. This value must be set totrue"
     88 .S HTEXT(2)="if item in this dialog will be using reminder term to either replace an item"
     89 .S HTEXT(3)="or to suppress an item."
     90 D HELP^PXRMEUT(.HTEXT)
     91 Q
     92 ;
     93TEXT(NLINES,CNT,ATLEN,TEMP,NODE) ;
     94 N CNT1,NOUT,OUTPUT,WIDHT
     95 S WIDTH=IOM-(2+(CNT+ATLEN))
     96 S CNT1=1 D FORMATS^PXRMTEXT(1,WIDTH,TEMP,.NOUT,.OUTPUT)
     97 I NOUT>0 F CNT1=1:1:NOUT D
     98 .S NLINE=NLINE+1,^TMP(NODE,$J,NLINE,0)=$J("",2+(CNT+ATLEN))_OUTPUT(CNT1)
     99 Q
     100 ;
     101INQ(DIEN) ;INQ Inquiry/Print option
     102 ;
     103 ; Used by 801.41 print templates
     104 ; [PXRM REMINDER DIALOG]
     105 ; [PXRM DIALOG GROUP]
     106 ;
     107 N DEF,DEF1,DEF2 D DEF^PXRMRUTL("811.902",.DEF,.DEF1,.DEF2)
     108 N NLINE,NODE,NSEL,SUB
     109 S NLINE=0,NODE="PXRMDLG4",NSEL=0
     110 K ^TMP(NODE,$J)
     111 ;
     112 ;Components
     113 W !!,"      Seq.       Dialog",!
     114 D DETAIL^PXRMDLG4(DIEN,"",4,NODE)
     115 ;
     116 ;Print lines from workfile
     117 S SUB=""
     118 F  S SUB=$O(^TMP(NODE,$J,SUB)) Q:'SUB  W !,^TMP(NODE,$J,SUB,0)
     119 K ^TMP(NODE,$J)
     120 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLGZ.m

    r613 r623  
    1 PXRMDLGZ        ; SLC/PJH - Link reminder to dialog. ;01/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Called by option PXRM DIALOG/COMPONENT EDIT
    5         ;
    6 START   N BY,DATA,DDES,DHD,DIC,DNAM,DTYP,FLDS,FR,L,LOGIC,NOW,PNAM,TO,Y
    7         N PXRMBG,PXRMHD,PXRMDIEN,PXRMGTYP,PXRMDTYP,PXRMITEM,PXRMMODE,PXRMNAME
    8         N PXRMTEMP,PXRMTITL,PXRMVIEW
    9         ;Refresh on return
    10         S VALMBCK="R"
    11         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    12         ;Default is display dialog elements
    13         S PXRMDTYP="R",PXRMGTYP="DLGR",PXRMVIEW="AN"
    14         ;Select dialog for display
    15         F  D  Q:'PXRMTEMP
    16         .S PXRMTEMP=""
    17         .D START^PXRMSEL(.PXRMHD,.PXRMGTYP,"PXRMTEMP") Q:'PXRMTEMP
    18         .N X S X="IORESET"
    19         .D ENDR^%ZISS,@(PXRMGTYP_"("_PXRMTEMP_")")
    20 END     Q
    21         ;
    22         ;Reminder View
    23         ;-------------
    24 DLGR(PXRMITEM)  ;
    25         N PXRMDIEN,PXRMCS1,PXRMCS2
    26         ;Format headings to include reminder and name
    27         S DATA=$G(^PXD(811.9,PXRMITEM,0)),RNAM=$P(DATA,U),PNAM=$P(DATA,U,3)
    28         S PXRMHD="REMINDER NAME: "_RNAM
    29         ;
    30         ;Dialog History
    31         F  D  Q:'PXRMDIEN
    32         .D START^PXRMDLGH(PXRMITEM,.PXRMDIEN,"PXRMDIEN") Q:'PXRMDIEN
    33         .N PXRMHD,VALMBCK,VALMBG,VALMSG,VIEW,X,XMZ
    34         .S DNAM=$P($G(^PXRMD(801.41,PXRMDIEN,0)),U)
    35         .I $P($G(^PXRMD(801.41,PXRMDIEN,0)),U,3)]"" S DNAM=DNAM_" (DISABLED)"
    36         .S PXRMHD="REMINDER DIALOG NAME: "_DNAM
    37         .S PXRMCS1=$$FILE^PXRMEXCS(801.41,PXRMDIEN)
    38         .S X="IORESET"
    39         .D ENDR^%ZISS,EN^VALM("PXRM DIALOG LIST")
    40         .I PXRMDIEN,$D(^PXRMD(801.41,PXRMDIEN,0)) D
    41         ..S PXRMCS2=$$FILE^PXRMEXCS(801.41,PXRMDIEN) Q:+PXRMCS2=0
    42         ..Q:PXRMCS1=PXRMCS2
    43         ..D SEHIST^PXRMUTIL(801.41,"^PXRMD(801,41,",PXRMDIEN)
    44         .W IORESET
    45         .D KILL^%ZISS
    46         Q
    47         ;
    48         ;Edit element/prompt/group
    49         ;-------------------------
    50 DLGE(PXRMDIEN)  ;
    51         N LOCK,LFIND
    52         ;Check for Uneditable flag
    53         S LOCK=$P($G(^PXRMD(801.41,PXRMTEMP,100)),U,4)
    54         S LFIND=$P($G(^PXRMD(801.41,PXRMTEMP,1)),U,5)
    55         I LOCK=1,$G(LFIND)'="",$G(LFIND)'["ORD",'$G(PXRMINST) D  Q
    56         .W !,"This item can not be edited" H 2
    57         ;
    58         S PXRMHD="Dialog Name: ",PXRMDIEN=PXRMTEMP
    59         ;Format headings to include dialog name
    60         S DATA=$G(^PXRMD(801.41,PXRMDIEN,0)),DDES=$P(DATA,U),DTYP=$P(DATA,U,4)
    61         ;Test
    62         I DTYP="G" D DLG(PXRMDIEN) Q
    63         ;
    64         S PXRMHD=PXRMHD_" "_DDES W PXRMHD,!
    65         ;Edit selected dialog
    66         D EDIT^PXRMDEDT(DTYP,PXRMDIEN,0)
    67         Q
    68         ;
    69         ;Reminder dialog view
    70         ;--------------------
    71 DLG(PXRMDIEN)   ;
    72         S PXRMDIEN=PXRMTEMP
    73         S PXRMNAME=$P($G(^PXRMD(801.41,PXRMDIEN,0)),U)
    74         S PXRMITEM=$P($G(^PXRMD(801.41,PXRMDIEN,0)),U,2)
    75         ;Format headings to include dialog name
    76         S PXRMHD=PXRMHD_PXRMNAME
    77         ;Check if the set is disable and add to header if disabled
    78         I $P(^PXRMD(801.41,PXRMDIEN,0),U,3)]"" S PXRMHD=PXRMHD_" (DISABLED)"
    79         ;Listman option
    80         D EN^VALM("PXRM DIALOG LIST")
    81         W IORESET
    82         D KILL^%ZISS
    83         Q
    84         ;
    85         ;Other subroutines
    86         ;
    87         ;Ask update or no
    88         ;----------------
    89 ASK(YESNO)      ;
    90         N X,Y,TEXT,DIR
    91         K DIROUT,DIRUT,DTOUT,DUOUT
    92         S DIR(0)="YA0"
    93         S DIR("A")="LINK THIS REMINDER TO DIALOG - "_$P(PXRMHD,": ",2)_": "
    94         S DIR("B")="Y"
    95         S DIR("?")="Enter Y or N. For detailed help type ??"
    96         S DIR("??")=U_"D HLP^PXRMDLGY(1)"
    97         D ^DIR K DIR
    98         I $D(DIROUT) S DTOUT=1
    99         I $D(DTOUT)!($D(DUOUT)) Q
    100         S YESNO=$E(Y(0))
    101         Q
    102         ;
    103         ;Display dialogs autogenerated from this reminder
    104         ;------------------------------------------------
    105 DISP(RIEN)      ;
    106         N ARRAY,DSUB,FIRST
    107         ;Get OTHER dialogs
    108         S FIRST=1,DSUB=""
    109         F  S DSUB=$O(^PXRMD(801.41,"AG",RIEN,DSUB)) Q:'DSUB  D
    110         .W !
    111         .D:FIRST
    112         ..W "DIALOGS ALREADY GENERATED FROM THIS REMINDER:",!! S FIRST=0
    113         .W ?20,$P($G(^PXRMD(801.41,DSUB,0)),U)
    114         ;
    115         I 'FIRST W !
    116         ;
    117         Q
    118         ;
    119         ;Display linked reminders
    120         ;------------------------
    121 DISPL(DIEN)     ;
    122         N ARRAY,DLG,RSUB,FIRST,RNAM
    123         S RSUB=$P($G(^PXRMD(801.41,DIEN,0)),U,2)
    124         I RSUB W !!,"SOURCE REMINDER: "_$P($G(^PXD(811.9,RSUB,0)),U)
    125         ;Linked reminders
    126         S FIRST=1,RNAM=""
    127         F  S RNAM=$O(^PXD(811.9,"B",RNAM)) Q:RNAM=""  D
    128         .S RSUB=$O(^PXD(811.9,"B",RNAM,"")) Q:'RSUB
    129         .S DLG=$P($G(^PXD(811.9,RSUB,51)),U) Q:DLG'=DIEN
    130         .W ! I FIRST W !,"REMINDERS ALREADY LINKED TO THIS DIALOG:",!! S FIRST=0
    131         .W ?18,$P($G(^PXD(811.9,RSUB,0)),U)
    132         Q
    133         ;
    134         ;Link a dialog (called by protocol PXRM DIALOG/REMINDER LINK)
    135         ;-------------
    136 LINK(DIEN)      ;
    137         F  D  Q:$D(DTOUT)!$D(DUOUT)
    138         .W IORESET
    139         .S VALMBCK="R"
    140         .;Display linked reminders
    141         .D DISPL(DIEN)
    142         .;
    143         .N ANS,DIC,DIR,DLG,LIT1,PNAME,PXRMREM,REM
    144         .S DIC("A")="SELECT A REMINDER TO LINK OR CHANGE: "
    145         .S LIT1="You must select a reminder!"
    146         .D SEL(811.9,"AEQMZ",.PXRMREM)
    147         .Q:$D(DTOUT)!$D(DUOUT)
    148         .S REM=$P(PXRMREM(1),U),PNAME=$P(PXRMREM(1),U,3)
    149         .I PNAME]"" W !!,"REMINDER PRINT NAME: "_PNAME,!
    150         .;Display related dialogs
    151         .D DISP(REM)
    152         .;Check if already linked
    153         .S DLG=$P($G(^PXD(811.9,REM,51)),U)
    154         .;Reconfirm to link reminder
    155         .I 'DLG S ANS="" D ASK(.ANS) Q:ANS'="Y"
    156         .;
    157         .N DA,DR,DIE
    158         .;Edit selected reminder
    159         .S DA=REM
    160         .;Settup local variables
    161         .S DIE="^PXD(811.9,",DR=51
    162         .;If no link force entry
    163         .I 'DLG S DR=DR_"///"_PXRMNAME
    164         .D ^DIE
    165         Q
    166         ;
    167         ;Link a Reminder (called by protocol PXRM DIALOG LINK)
    168         ;---------------
    169 RLINK(REM)      ;
    170         N DLG
    171         ;Re-display reminder name
    172         W IORESET
    173         W !,PXRMHD
    174         ;
    175         N DA,DR,DIE
    176         ;Edit selected reminder
    177         S DA=REM
    178         ;Settup local variables
    179         S DIE="^PXD(811.9,",DR=51
    180         ;If no link force entry
    181         D ^DIE
    182         Q
    183         ;
    184         ;General help text routine.
    185         ;--------------------------
    186 HLP(CALL)       ;
    187         N HTEXT
    188         N DIWF,DIWL,DIWR,IC
    189         S DIWF="C75",DIWL=0,DIWR=75
    190         ;
    191         I CALL=1 D
    192         .S HTEXT(1)="Enter Yes to link reminder to this dialog."
    193         I CALL=2 D
    194         .S HTEXT(1)="Enter Yes to link reminder to this dialog."
    195         K ^UTILITY($J,"W")
    196         S IC=""
    197         F  S IC=$O(HTEXT(IC)) Q:IC=""  D
    198         . S X=HTEXT(IC)
    199         . D ^DIWP
    200         W !
    201         S IC=0
    202         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    203         . W !,^UTILITY($J,"W",0,IC,0)
    204         K ^UTILITY($J,"W")
    205         W !
    206         Q
    207         ;
    208         ;Reminder selection
    209         ;------------------
    210 SEL(FILE,MODE,ARRAY)    ;
    211         N X,Y,CNT
    212         K DIROUT,DIRUT,DTOUT,DUOUT
    213         S CNT=0
    214         W !
    215         F  D  Q:$D(DTOUT)  Q:$D(DUOUT)  Q:CNT>0  Q:(Y=-1)&(CNT>0)
    216         .S DIC=FILE,DIC(0)=MODE
    217         .D ^DIC
    218         .I X=(U_U) S DTOUT=1
    219         .I '$D(DTOUT),('$D(DUOUT)) D
    220         ..I +Y'=-1 D  Q
    221         ...S CNT=CNT+1,ARRAY(CNT)=Y_U_Y(0,0)_U_$P(Y(0),U,3)
    222         ..W:CNT=0 !,LIT1
    223         .K DIC
    224         Q
    225         ;
    226         ;Input transform for FINDING ITEM in 801.41
    227 XINP(X) ;Taxonomy findings are not allowed for dialog groups
    228         I $P(X,";",2)="PXD(811.2,",$P($G(^PXRMD(801.41,DA,0)),U,4)="G" D  Q 0
    229         .W $C(7),!,"A taxonomy cannot be entered as the finding item for a group"
    230         ;Only applies to MH
    231         I $P(X,";",2)'="^YTT(601.71," Q 1
    232         I $$OK^PXRMDLL($P(X,";")) Q 1
    233         W *7,!,"This test is not appropriate for the GUI",!
    234         Q 0
     1PXRMDLGZ ; SLC/PJH - Link reminder to dialog. ;05/31/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Called by option PXRM DIALOG/COMPONENT EDIT
     5 ;
     6START N BY,DATA,DDES,DHD,DIC,DNAM,DTYP,FLDS,FR,L,LOGIC,NOW,PNAM,TO,Y
     7 N PXRMBG,PXRMHD,PXRMDIEN,PXRMGTYP,PXRMDTYP,PXRMITEM,PXRMMODE,PXRMNAME
     8 N PXRMTEMP,PXRMTITL,PXRMVIEW
     9 ;Refresh on return
     10 S VALMBCK="R"
     11 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     12 ;Default is display dialog elements
     13 S PXRMDTYP="R",PXRMGTYP="DLGR",PXRMVIEW="AN"
     14 ;Select dialog for display
     15 F  D  Q:'PXRMTEMP
     16 .S PXRMTEMP=""
     17 .D START^PXRMSEL(.PXRMHD,.PXRMGTYP,"PXRMTEMP") Q:'PXRMTEMP
     18 .N X S X="IORESET"
     19 .D ENDR^%ZISS,@(PXRMGTYP_"("_PXRMTEMP_")")
     20END Q
     21 ;
     22 ;Reminder View
     23 ;-------------
     24DLGR(PXRMITEM) ;
     25 N PXRMDIEN,PXRMCS1,PXRMCS2
     26 ;Format headings to include reminder and name
     27 S DATA=$G(^PXD(811.9,PXRMITEM,0)),RNAM=$P(DATA,U),PNAM=$P(DATA,U,3)
     28 S PXRMHD="REMINDER NAME: "_RNAM
     29 ;
     30 ;Dialog History
     31 F  D  Q:'PXRMDIEN
     32 .D START^PXRMDLGH(PXRMITEM,.PXRMDIEN,"PXRMDIEN") Q:'PXRMDIEN
     33 .N PXRMHD,VALMBCK,VALMBG,VALMSG,VIEW,X,XMZ
     34 .S DNAM=$P($G(^PXRMD(801.41,PXRMDIEN,0)),U)
     35 .I $P($G(^PXRMD(801.41,PXRMDIEN,0)),U,3)]"" S DNAM=DNAM_" (DISABLED)"
     36 .S PXRMHD="REMINDER DIALOG NAME: "_DNAM
     37 .S PXRMCS1=$$FILE^PXRMEXCS(801.41,PXRMDIEN)
     38 .S X="IORESET"
     39 .D ENDR^%ZISS,EN^VALM("PXRM DIALOG LIST")
     40 .I PXRMDIEN,$D(^PXRMD(801.41,PXRMDIEN,0)) D
     41 ..S PXRMCS2=$$FILE^PXRMEXCS(801.41,PXRMDIEN) Q:+PXRMCS2=0
     42 ..Q:PXRMCS1=PXRMCS2
     43 ..D SEHIST^PXRMUTIL(801.41,"^PXRMD(801,41,",PXRMDIEN)
     44 .W IORESET
     45 .D KILL^%ZISS
     46 Q
     47 ;
     48 ;Edit element/prompt/group
     49 ;-------------------------
     50DLGE(PXRMDIEN) ;
     51 N LOCK,LFIND
     52 ;Check for Uneditable flag
     53 S LOCK=$P($G(^PXRMD(801.41,PXRMTEMP,100)),U,4)
     54 S LFIND=$P($G(^PXRMD(801.41,PXRMTEMP,1)),U,5)
     55 I LOCK=1,$G(LFIND)'="",$G(LFIND)'["ORD",'$G(PXRMINST) D  Q
     56 .W !,"This item can not be edited" H 2
     57 ;
     58 S PXRMHD="Dialog Name: ",PXRMDIEN=PXRMTEMP
     59 ;Format headings to include dialog name
     60 S DATA=$G(^PXRMD(801.41,PXRMDIEN,0)),DDES=$P(DATA,U),DTYP=$P(DATA,U,4)
     61 ;Test
     62 I DTYP="G" D DLG(PXRMDIEN) Q
     63 ;
     64 S PXRMHD=PXRMHD_" "_DDES W PXRMHD,!
     65 ;Edit selected dialog
     66 D EDIT^PXRMDEDT(DTYP,PXRMDIEN,0)
     67 Q
     68 ;
     69 ;Reminder dialog view
     70 ;--------------------
     71DLG(PXRMDIEN) ;
     72 S PXRMDIEN=PXRMTEMP
     73 S PXRMNAME=$P($G(^PXRMD(801.41,PXRMDIEN,0)),U)
     74 S PXRMITEM=$P($G(^PXRMD(801.41,PXRMDIEN,0)),U,2)
     75 ;Format headings to include dialog name
     76 S PXRMHD=PXRMHD_PXRMNAME
     77 ;Check if the set is disable and add to header if disabled
     78 I $P(^PXRMD(801.41,PXRMDIEN,0),U,3)]"" S PXRMHD=PXRMHD_" (DISABLED)"
     79 ;Listman option
     80 D EN^VALM("PXRM DIALOG LIST")
     81 W IORESET
     82 D KILL^%ZISS
     83 Q
     84 ;
     85 ;Other subroutines
     86 ;
     87 ;Ask update or no
     88 ;----------------
     89ASK(YESNO) ;
     90 N X,Y,TEXT,DIR
     91 K DIROUT,DIRUT,DTOUT,DUOUT
     92 S DIR(0)="YA0"
     93 S DIR("A")="LINK THIS REMINDER TO DIALOG - "_$P(PXRMHD,": ",2)_": "
     94 S DIR("B")="Y"
     95 S DIR("?")="Enter Y or N. For detailed help type ??"
     96 S DIR("??")=U_"D HLP^PXRMDLGY(1)"
     97 D ^DIR K DIR
     98 I $D(DIROUT) S DTOUT=1
     99 I $D(DTOUT)!($D(DUOUT)) Q
     100 S YESNO=$E(Y(0))
     101 Q
     102 ;
     103 ;Display dialogs autogenerated from this reminder
     104 ;------------------------------------------------
     105DISP(RIEN) ;
     106 N ARRAY,DSUB,FIRST
     107 ;Get OTHER dialogs
     108 S FIRST=1,DSUB=""
     109 F  S DSUB=$O(^PXRMD(801.41,"AG",RIEN,DSUB)) Q:'DSUB  D
     110 .W !
     111 .D:FIRST
     112 ..W "DIALOGS ALREADY GENERATED FROM THIS REMINDER:",!! S FIRST=0
     113 .W ?20,$P($G(^PXRMD(801.41,DSUB,0)),U)
     114 ;
     115 I 'FIRST W !
     116 ;
     117 Q
     118 ;
     119 ;Display linked reminders
     120 ;------------------------
     121DISPL(DIEN) ;
     122 N ARRAY,DLG,RSUB,FIRST,RNAM
     123 S RSUB=$P($G(^PXRMD(801.41,DIEN,0)),U,2)
     124 I RSUB W !!,"SOURCE REMINDER: "_$P($G(^PXD(811.9,RSUB,0)),U)
     125 ;Linked reminders
     126 S FIRST=1,RNAM=""
     127 F  S RNAM=$O(^PXD(811.9,"B",RNAM)) Q:RNAM=""  D
     128 .S RSUB=$O(^PXD(811.9,"B",RNAM,"")) Q:'RSUB
     129 .S DLG=$P($G(^PXD(811.9,RSUB,51)),U) Q:DLG'=DIEN
     130 .W ! I FIRST W !,"REMINDERS ALREADY LINKED TO THIS DIALOG:",!! S FIRST=0
     131 .W ?18,$P($G(^PXD(811.9,RSUB,0)),U)
     132 Q
     133 ;
     134 ;Link a dialog (called by protocol PXRM DIALOG/REMINDER LINK)
     135 ;-------------
     136LINK(DIEN) ;
     137 F  D  Q:$D(DTOUT)!$D(DUOUT)
     138 .W IORESET
     139 .S VALMBCK="R"
     140 .;Display linked reminders
     141 .D DISPL(DIEN)
     142 .;
     143 .N ANS,DIC,DIR,DLG,LIT1,PNAME,PXRMREM,REM
     144 .S DIC("A")="SELECT A REMINDER TO LINK OR CHANGE: "
     145 .S LIT1="You must select a reminder!"
     146 .D SEL(811.9,"AEQMZ",.PXRMREM)
     147 .Q:$D(DTOUT)!$D(DUOUT)
     148 .S REM=$P(PXRMREM(1),U),PNAME=$P(PXRMREM(1),U,3)
     149 .I PNAME]"" W !!,"REMINDER PRINT NAME: "_PNAME,!
     150 .;Display related dialogs
     151 .D DISP(REM)
     152 .;Check if already linked
     153 .S DLG=$P($G(^PXD(811.9,REM,51)),U)
     154 .;Reconfirm to link reminder
     155 .I 'DLG S ANS="" D ASK(.ANS) Q:ANS'="Y"
     156 .;
     157 .N DA,DR,DIE
     158 .;Edit selected reminder
     159 .S DA=REM
     160 .;Settup local variables
     161 .S DIE="^PXD(811.9,",DR=51
     162 .;If no link force entry
     163 .I 'DLG S DR=DR_"///"_PXRMNAME
     164 .D ^DIE
     165 Q
     166 ;
     167 ;Link a Reminder (called by protocol PXRM DIALOG LINK)
     168 ;---------------
     169RLINK(REM) ;
     170 N DLG
     171 ;Re-display reminder name
     172 W IORESET
     173 W !,PXRMHD
     174 ;
     175 N DA,DR,DIE
     176 ;Edit selected reminder
     177 S DA=REM
     178 ;Settup local variables
     179 S DIE="^PXD(811.9,",DR=51
     180 ;If no link force entry
     181 D ^DIE
     182 Q
     183 ;
     184 ;General help text routine.
     185 ;--------------------------
     186HLP(CALL) ;
     187 N HTEXT
     188 N DIWF,DIWL,DIWR,IC
     189 S DIWF="C75",DIWL=0,DIWR=75
     190 ;
     191 I CALL=1 D
     192 .S HTEXT(1)="Enter Yes to link reminder to this dialog."
     193 I CALL=2 D
     194 .S HTEXT(1)="Enter Yes to link reminder to this dialog."
     195 K ^UTILITY($J,"W")
     196 S IC=""
     197 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     198 . S X=HTEXT(IC)
     199 . D ^DIWP
     200 W !
     201 S IC=0
     202 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     203 . W !,^UTILITY($J,"W",0,IC,0)
     204 K ^UTILITY($J,"W")
     205 W !
     206 Q
     207 ;
     208 ;Reminder selection
     209 ;------------------
     210SEL(FILE,MODE,ARRAY) ;
     211 N X,Y,CNT
     212 K DIROUT,DIRUT,DTOUT,DUOUT
     213 S CNT=0
     214 W !
     215 F  D  Q:$D(DTOUT)  Q:$D(DUOUT)  Q:CNT>0  Q:(Y=-1)&(CNT>0)
     216 .S DIC=FILE,DIC(0)=MODE
     217 .D ^DIC
     218 .I X=(U_U) S DTOUT=1
     219 .I '$D(DTOUT),('$D(DUOUT)) D
     220 ..I +Y'=-1 D  Q
     221 ...S CNT=CNT+1,ARRAY(CNT)=Y_U_Y(0,0)_U_$P(Y(0),U,3)
     222 ..W:CNT=0 !,LIT1
     223 .K DIC
     224 Q
     225 ;
     226 ;Input transform for FINDING ITEM in 801.41
     227XINP(X) ;Taxonomy findings are not allowed for dialog groups
     228 I $P(X,";",2)="PXD(811.2,",$P($G(^PXRMD(801.41,DA,0)),U,4)="G" D  Q 0
     229 .W $C(7),!,"A taxonomy cannot be entered as the finding item for a group"
     230 ;Only applies to MH
     231 I $P(X,";",2)'="YTT(601," Q 1
     232 ;GAF
     233 I $P($G(^YTT(601,$P(X,";"),0)),U)="GAF" Q 1
     234 ;Check if a VALID GUI test
     235 I $P($G(^YTT(601.6,$P(X,";"),0)),U,4)="Y" Q 1
     236 ;else
     237 W *7,!,"This test is not appropriate for the GUI",!
     238 Q 0
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLL.m

    r613 r623  
    1 PXRMDLL ;SLC/PJH - REMINDER DIALOG LOADER ;09/26/2007
    2         ;;2.0;CLINICAL REMINDERS;**10,6**;Feb 04, 2005;Build 123
    3         ;
    4 OK(DIEN)        ;Check if mental health test is for GUI
    5         I 'DIEN Q 0
    6         Q $$MH^PXRMDLG5(DIEN)
    7         ;
    8 TXT     ;Format text
    9         N NULL
    10         S TEXT=DTXT(SUB),NULL=0
    11         I ($E(TEXT)=" ")!(TEXT="") S NULL=1
    12         I LAST,'NULL S TEXT="<br>"_TEXT
    13         S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
    14         S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
    15         Q
    16         ;
    17 EXP(TIEN,DITEM,DSUB)    ;Expand taxonomy codes
    18         N ACNT,AHIS,ATYP,ARRAY,CODES,CNT,DPCE,DTAX
    19         ;Get taxonomy file details
    20         D TAX(TIEN,.ARRAY)
    21         ;
    22         ;Build dialog from the returned array
    23         ;
    24         ;Main Taxonomy prompt
    25         S DTXT=ARRAY
    26         S OCNT=OCNT+1
    27         S ORY(OCNT)=1_U_DITEM_U_DSUB_U_"S"_U_DEXC
    28         ;Default group indents and selection entry
    29         S $P(ORY(OCNT),U,16)=2,$P(ORY(OCNT),U,18)=2
    30         S OCNT=OCNT+1
    31         S ORY(OCNT)=2_U_DITEM_U_DSUB_U_DTXT
    32         ;
    33         ;Taxonomy CPT/POV resolution prompts
    34         S ACNT=""
    35         F  S ACNT=$O(ARRAY(ACNT)) Q:ACNT=""  D
    36         .;Prompt text
    37         .S DTXT=$P(ARRAY(ACNT),U),DPCE=$P(ARRAY(ACNT),U,4)
    38         .;Historical/Current flag
    39         .S AHIS=0 I $P(ARRAY(ACNT),U,3)=2 S AHIS=1
    40         .;CPT/POV
    41         .S ATYP="POV" I $P(ARRAY(ACNT),U,2)=81 S ATYP="CPT"
    42         .;Initial display
    43         .S DHIDE=0,DCHECK=0,DDIS=0
    44         .;Construct ien for this level
    45         .S DTAX=DSUB_"."_ACNT
    46         .S OCNT=OCNT+1
    47         .S ORY(OCNT)=1_U_DITEM_U_DTAX_U_"T"_U_DEXC_U_U_ATYP_U_AHIS
    48         .S OCNT=OCNT+1
    49         .S ORY(OCNT)=2_U_DITEM_U_DTAX_U_DTXT
    50         Q
    51         ;
    52 GROUP(DIEN,DSUB)        ;Dialog group
    53         N DATA,DBOX,DCAP,DCHK,DENTRY,DEXC,DGIEN,DGRP,DGSEQ,DGSUB,DHIDE,DIND
    54         N DINDPN,DMHEX,DRESL,DSHARE,SUB,DCOUNT
    55         ;Group caption text
    56         S DATA=$G(^PXRMD(801.41,DIEN,0))
    57         S DCAP=$P(DATA,U,5),DBOX=$P(DATA,U,6),DIND=$P(DATA,U,7)
    58         S DSHARE=$P(DATA,U,8),DENTRY=$P(DATA,U,9),DHIDE=$P(DATA,U,10)
    59         S DINDPN=$P(DATA,U,12) S:DINDPN="" DINDPN=0
    60         S DBOX=$S(DBOX="Y":1,1:"")
    61         ;group header is display only if SUPPRESS CHECKBOX
    62         S DCHK="S" I ('DHIDE)&(DSUPP) S DCHK="D",DHIDE=0
    63         ;Default group setting to hide
    64         I DHIDE="" S DHIDE=1
    65         ;
    66         S DEXC=$P($G(^PXRMD(801.41,DIEN,2)),U,3)
    67         ;
    68         S OCNT=OCNT+1,ORY(OCNT)=1_U_DIEN_U_DSUB_U_DCHK_U_DEXC
    69         S $P(ORY(OCNT),U,8)=$$AHIS(DIEN)
    70         S $P(ORY(OCNT),U,15)=DHIDE,$P(ORY(OCNT),U,16)=DIND
    71         S $P(ORY(OCNT),U,17)=DSHARE,$P(ORY(OCNT),U,18)=DENTRY
    72         S $P(ORY(OCNT),U,19)=DBOX,$P(ORY(OCNT),U,20)=DCAP
    73         S $P(ORY(OCNT),U,21)=DINDPN
    74         ;Create type 2 records if if here is additional group text
    75         N LAST,TEXT
    76         S SUB=0,LAST=0 F  S SUB=$O(DTXT(SUB)) Q:'SUB  D
    77         .D TXT
    78         .S OCNT=OCNT+1,ORY(OCNT)=2_U_DIEN_U_DSUB_U_TEXT
    79         ;Get dialog group sub-elements
    80         N DTYP,DSUPP,DDIS,IDENT S DGSEQ=0
    81         F  S DGSEQ=$O(^PXRMD(801.41,DIEN,10,"B",DGSEQ)) Q:'DGSEQ  D
    82         .S DGSUB=$O(^PXRMD(801.41,DIEN,10,"B",DGSEQ,"")) Q:'DGSUB
    83         .S DATA=$G(^PXRMD(801.41,DIEN,10,DGSUB,0))
    84         .S DGIEN=$P(DATA,U,2) Q:'DGIEN
    85         .;Branching logic call to determine if element should be suppress,
    86         .;replace or left as is
    87         .N TERMNODE,TERMSTAT
    88         .S TERMNODE=$G(^PXRMD(801.41,DGIEN,49))
    89         .I $G(TERMNODE)'="" D  Q:TERMSTAT=0
    90         ..S TERMSTAT=1
    91         ..D REPLACE^PXRMDLLB(DFN,TERMNODE,.DGIEN,.DATA,.TERMSTAT)
    92         .;Exclude from P/N
    93         .S DEXC=$P(DATA,U,8)
    94         .I $P($G(^PXRMD(801.41,DGIEN,0)),U,16)'["WHR" D
    95         ..K DTXT S SUB=0 F  S SUB=$O(^PXRMD(801.41,DGIEN,25,SUB)) Q:'SUB  D
    96         ...S DTXT(SUB)=$G(^PXRMD(801.41,DGIEN,25,SUB,0))
    97         .;Check if element is disabled/invalid
    98         .S DATA=$G(^PXRMD(801.41,DGIEN,0)) Q:DATA=""  Q:$P(DATA,U,3)]""
    99         .;If the actual element is exclude from P/N override
    100         .I $P($G(^PXRMD(801.41,DGIEN,2)),U,3) S DEXC=1
    101         .S DTYP=$P(DATA,U,4),DSUPP=$P(DATA,U,11) Q:"EG"'[DTYP
    102         .S DMHEX=$P(DATA,U,14)
    103         .S DRESL=$$RESGROUP^PXRMDLLB(DGIEN)
    104         .;S DRESL=$P(DATA,U,15)
    105         .S DRES=$P($G(^PXRMD(801.41,DGIEN,1)),U,3)
    106         .;Done Elsewhere (historical)
    107         .S DHIS=$$AHIS(DGIEN)
    108         .S DFIND=$P($G(^PXRMD(801.41,DGIEN,1)),U,5)
    109         .S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2)
    110         .S DPCE="" I DFTYP'="" S DPCE=$G(DARRAY(DFTYP))
    111         .;If mental Health ignore if not GUI
    112         .I DPCE="MH" Q:'$$OK(DFIEN)
    113         .S DGRP=DSUB_"."_DGSUB
    114         .;Taxonomy codes need expanding
    115         .I DPCE="T" D EXP(DFIEN,DGIEN,DGRP) Q
    116         .;Translate vitals ien to PCE code - This will need a DBIA
    117         .I DPCE="VIT" S DFIEN=$$GET1^DIQ(120.51,DFIEN,7,"E")
    118         .;Embedded Dialog Group
    119         .I DTYP="G" D GROUP(DGIEN,DGRP) Q
    120         .S DDIS="S" I DSUPP=1 S DDIS="D"
    121         .S DGRP=DSUB_"."_DGSUB,OCNT=OCNT+1
    122         .S ORY(OCNT)=1_U_DGIEN_U_DGRP_U_DDIS_U_DEXC_U_U_U_DHIS_U_DMHEX_U_DRESL_U_$G(DCOUNT)
    123         .;
    124         .N LAST,TEXT
    125         .S SUB=0,LAST=0 F  S SUB=$O(DTXT(SUB)) Q:'SUB  D
    126         ..D TXT
    127         ..S OCNT=OCNT+1,ORY(OCNT)=2_U_DGIEN_U_DGRP_U_TEXT
    128         Q
    129         ;
    130 LOAD(DIEN,DFN)  ;Load dialog questions into array
    131         N DARRAY,DATA,DITEM,DFIND,DFIEN,DFTYP,DPCE,DRES,DSEQ,DSUB,DTXT,DTYP,OCNT
    132         N DDIS,DEXC,DHIDE,DCHECK,DDIS,DHIS,DMHEX,DRESL,DSUPP,SUB,IDENT,TXTCNT
    133         ;Check Status of dialog
    134         S DATA=$G(^PXRMD(801.41,DIEN,0)) Q:DATA=""
    135         ;If disabled ignore
    136         I $P(DATA,U,3)]"" Q
    137         ;Ignore if not a reminder dialog
    138         I $P(DATA,U,4)'="R" Q
    139         ;
    140         ;List of PCE codes
    141         S DARRAY("AUTTEDT(")="PED"
    142         S DARRAY("AUTTEXAM(")="XAM"
    143         S DARRAY("AUTTHF(")="HF"
    144         S DARRAY("AUTTIMM(")="IMM"
    145         S DARRAY("AUTTSK(")="SK"
    146         S DARRAY("GMRD(120.51,")="VIT"
    147         S DARRAY("ORD(101.41,")="Q"
    148         S DARRAY("YTT(601.71,")="MH"
    149         S DARRAY("ICD9(")="POV"
    150         S DARRAY("ICPT(")="CPT"
    151         S DARRAY("PXD(811.2,")="T"
    152         S DARRAY("WV(790.1,")="WHR"
    153         ;
    154         ;Get elements for the dialog
    155         S DSEQ=0,OCNT=0
    156         F  S DSEQ=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ)) Q:'DSEQ  D
    157         .S DSUB=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ,"")) Q:'DSUB
    158         .S DATA=$G(^PXRMD(801.41,DIEN,10,DSUB,0))
    159         .S DITEM=$P(DATA,U,2) Q:DITEM=""
    160         .;Ignore disabled elements
    161         .S DATA=$G(^PXRMD(801.41,DITEM,0)) Q:DATA=""  Q:$P(DATA,U,3)]""
    162         .;Branching logic call to determine if element should be suppress,
    163         .;replace or left as is
    164         .S TERMNODE=$G(^PXRMD(801.41,DITEM,49))
    165         .N TERMSTAT
    166         .I $G(TERMNODE)'="" D  Q:TERMSTAT=0
    167         ..S TERMSTAT=1
    168         ..D REPLACE^PXRMDLLB(DFN,TERMNODE,.DITEM,.DATA,.TERMSTAT)
    169         .S DTYP=$P(DATA,U,4),DSUPP=$P(DATA,U,11)
    170         .S DMHEX=$P(DATA,U,14)
    171         .S DRESL=$$RESGROUP^PXRMDLLB(DITEM)
    172         .;S DRESL=$P(DATA,U,15)
    173         .K DTXT S SUB=0
    174         .F  S SUB=$O(^PXRMD(801.41,DITEM,25,SUB)) Q:'SUB  D
    175         ..S DTXT(SUB)=$G(^PXRMD(801.41,DITEM,25,SUB,0))
    176         .S DRES=$P($G(^PXRMD(801.41,DITEM,1)),U,3)
    177         .S DFIND=$P($G(^PXRMD(801.41,DITEM,1)),U,5)
    178         .S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2)
    179         .S DPCE="" I DFTYP'="" S DPCE=$G(DARRAY(DFTYP))
    180         .;If mental Health ignore if not GUI
    181         .I DPCE="MH" Q:'$$OK(DFIEN)
    182         .;Exclude from PN
    183         .S DEXC=$P($G(^PXRMD(801.41,DITEM,2)),U,3)
    184         .;Taxonomy codes need expanding
    185         .I DPCE="T" D EXP(DFIEN,DITEM,DSUB) Q
    186         .;Translate vitals ien to PCE code - This will need a DBIA
    187         .I DPCE="VIT" S DFIEN=$P($G(^GMRD(120.51,DFIEN,0)),U,7)
    188         .;Done Elsewhere (historical)
    189         .S DHIS=$$AHIS(DITEM)
    190         .;Dialog Group
    191         .I DTYP="G" D GROUP(DITEM,DSUB) Q
    192         .;Dialog type/text and resolution
    193         .S OCNT=OCNT+1,DDIS="S"
    194         .I DSUPP=1 S DDIS="D"
    195         .S ORY(OCNT)=1_U_DITEM_U_DSUB_U_DDIS_U_DEXC_U_U_U_DHIS_U_DMHEX_U_DRESL
    196         .N LAST,TEXT
    197         .S SUB=0,LAST=0 F  S SUB=$O(DTXT(SUB)) Q:'SUB  D
    198         ..D TXT
    199         ..S OCNT=OCNT+1,ORY(OCNT)=2_U_DITEM_U_DSUB_U_TEXT
    200         Q
    201         ;
    202 TAX(TXIEN,ARRAY)        ;Return list of resolutions/codes for taxonomy
    203         N CNT,DTXT,FNODE,RSUB,TDX,TNAME,TPAR,TPR,TYP
    204         N TCUR,TDTXT,TDHTXT,THIS,TPTXT,TPHTXT
    205         ;
    206         ;Get taxonomy name
    207         S TNAME=$P($G(^PXD(811.2,TXIEN,0)),U,1)
    208         ;
    209         ;Check what type of taxonomy codes exist
    210         S TDX=$$TOK^PXRMDLLA(TXIEN,"SDX")
    211         S TPR=$$TOK^PXRMDLLA(TXIEN,"SPR")
    212         ;
    213         ;Taxonomy dialog text
    214         S DTXT=$P($G(^PXD(811.2,TXIEN,0)),U,3)
    215         ;default to taxonomy description if null
    216         I DTXT="" S DTXT=$P($G(^PXD(811.2,TXIEN,0)),U,2)
    217         ;default to taxonomy name if null
    218         I DTXT="" S DTXT=$P($G(^PXD(811.2,TXIEN,0)),U,1)
    219         ;
    220         S CNT=0,ARRAY=DTXT
    221         ;
    222         ;Diagnoses
    223         I TDX D
    224         .;Diagnosis texts
    225         .S TPAR=$G(^PXD(811.2,TXIEN,"SDZ"))
    226         .;Get parameter file node for this finding type
    227         .S FNODE=$O(^PXRMD(801.45,"B","POV","")) Q:FNODE=""
    228         .;check if finding parameters are disabled
    229         .S TCUR=$P($G(^PXRMD(801.45,FNODE,1,1,0)),U,2)
    230         .S THIS=$P($G(^PXRMD(801.45,FNODE,1,2,0)),U,2)
    231         .;get category text (diagnoses)
    232         .I 'TCUR D  ; Current
    233         ..S TDTXT=$P(TPAR,U,2) S:TDTXT="" TDTXT=TNAME
    234         ..S CNT=CNT+1,ARRAY(CNT)=TDTXT_U_80_U_1_U_"POV"
    235         .I 'THIS D  ; Historical
    236         ..S TDHTXT=$P(TPAR,U,3) S:TDHTXT="" TDHTXT=TNAME_" (HISTORICAL)"
    237         ..S CNT=CNT+1,ARRAY(CNT)=TDHTXT_U_80_U_2_U_"POV"
    238         ;Procedures
    239         I TPR D
    240         .;Procedure texts
    241         .S TPAR=$G(^PXD(811.2,TXIEN,"SPZ"))
    242         .;Get parameter file node for this finding type
    243         .S FNODE=$O(^PXRMD(801.45,"B","CPT","")) Q:FNODE=""
    244         .;check if finding parameters are disabled
    245         .S TCUR=$P($G(^PXRMD(801.45,FNODE,1,1,0)),U,2)
    246         .S THIS=$P($G(^PXRMD(801.45,FNODE,1,2,0)),U,2)
    247         .;get category text (procedures)
    248         .I 'TCUR D  ; Current
    249         ..S TPTXT=$P(TPAR,U,2) S:TPTXT="" TPTXT=TNAME
    250         ..S CNT=CNT+1,ARRAY(CNT)=TPTXT_U_81_U_1_U_"CPT"
    251         .I 'THIS D  ; Historical
    252         ..S TPHTXT=$P(TPAR,U,3) S:TPHTXT="" TPHTXT=TNAME_" (HISTORICAL)"
    253         ..S CNT=CNT+1,ARRAY(CNT)=TPHTXT_U_81_U_2_U_"CPT"
    254         ;
    255         Q
    256         ;
    257 AHIS(DITEM)     ;
    258         N RSIEN,RSNAM
    259         S RSIEN=$P($G(^PXRMD(801.41,DITEM,1)),U,3)
    260         I RSIEN="" Q 0
    261         S RSNAM=$P($G(^PXRMD(801.9,RSIEN,0)),U)
    262         I RSNAM["DONE ELSEWHERE" Q 1
    263         N GUI,PIEN,PFOUND
    264         S PIEN=0,PFOUND=0
    265         F  S PIEN=$O(^PXRMD(801.41,DITEM,10,"D",PIEN)) Q:'PIEN  D  Q:PFOUND
    266         .;Ignore elements and groups
    267         .I "EG"[$P($G(^PXRMD(801.41,PIEN,0)),U,4) Q
    268         .;GUI Process
    269         .S GUI=$P($G(^PXRMD(801.41,PIEN,46)),U) Q:'GUI
    270         .;Check if this is PXRM VISIT DATE (or a copy of it)
    271         .I $P($G(^PXRMD(801.42,GUI,0)),U)="VST_DATE" S PFOUND=1
    272         Q PFOUND
     1PXRMDLL ;SLC/PJH - REMINDER DIALOG LOADER ;09/26/2007
     2 ;;2.0;CLINICAL REMINDERS;**10**;Feb 04, 2005;Build 25
     3 ;
     4OK(DIEN) ;Check if mental health test is for GUI
     5 I 'DFIEN Q 0
     6 I $P($G(^YTT(601.6,DFIEN,0)),U,4)="Y" Q 1
     7 I $P($G(^YTT(601,DFIEN,0)),U)="GAF" Q 1
     8 Q 0
     9 ;
     10TXT ;Format text
     11 N NULL
     12 S TEXT=DTXT(SUB),NULL=0
     13 I ($E(TEXT)=" ")!(TEXT="") S NULL=1
     14 I LAST,'NULL S TEXT="<br>"_TEXT
     15 S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
     16 S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
     17 Q
     18 ;
     19EXP(TIEN,DITEM,DSUB) ;Expand taxonomy codes
     20 N ACNT,AHIS,ATYP,ARRAY,CODES,CNT,DPCE,DTAX
     21 ;Get taxonomy file details
     22 D TAX(TIEN,.ARRAY)
     23 ;
     24 ;Build dialog from the returned array
     25 ;
     26 ;Main Taxonomy prompt
     27 S DTXT=ARRAY
     28 S OCNT=OCNT+1
     29 S ORY(OCNT)=1_U_DITEM_U_DSUB_U_"S"_U_DEXC
     30 ;Default group indents and selection entry
     31 S $P(ORY(OCNT),U,16)=2,$P(ORY(OCNT),U,18)=2
     32 S OCNT=OCNT+1
     33 S ORY(OCNT)=2_U_DITEM_U_DSUB_U_DTXT
     34 ;
     35 ;Taxonomy CPT/POV resolution prompts
     36 S ACNT=""
     37 F  S ACNT=$O(ARRAY(ACNT)) Q:ACNT=""  D
     38 .;Prompt text
     39 .S DTXT=$P(ARRAY(ACNT),U),DPCE=$P(ARRAY(ACNT),U,4)
     40 .;Historical/Current flag
     41 .S AHIS=0 I $P(ARRAY(ACNT),U,3)=2 S AHIS=1
     42 .;CPT/POV
     43 .S ATYP="POV" I $P(ARRAY(ACNT),U,2)=81 S ATYP="CPT"
     44 .;Initial display
     45 .S DHIDE=0,DCHECK=0,DDIS=0
     46 .;Construct ien for this level
     47 .S DTAX=DSUB_"."_ACNT
     48 .S OCNT=OCNT+1
     49 .S ORY(OCNT)=1_U_DITEM_U_DTAX_U_"T"_U_DEXC_U_U_ATYP_U_AHIS
     50 .S OCNT=OCNT+1
     51 .S ORY(OCNT)=2_U_DITEM_U_DTAX_U_DTXT
     52 Q
     53 ;
     54GROUP(DIEN,DSUB) ;Dialog group
     55 N DATA,DBOX,DCAP,DCHK,DENTRY,DEXC,DGIEN,DGRP,DGSEQ,DGSUB,DHIDE,DIND
     56 N DINDPN,DMHEX,DRESL,DSHARE,SUB,DCOUNT
     57 ;Group caption text
     58 S DATA=$G(^PXRMD(801.41,DIEN,0))
     59 S DCAP=$P(DATA,U,5),DBOX=$P(DATA,U,6),DIND=$P(DATA,U,7)
     60 S DSHARE=$P(DATA,U,8),DENTRY=$P(DATA,U,9),DHIDE=$P(DATA,U,10)
     61 S DINDPN=$P(DATA,U,12) S:DINDPN="" DINDPN=0
     62 S DBOX=$S(DBOX="Y":1,1:"")
     63 ;group header is display only if SUPPRESS CHECKBOX
     64 S DCHK="S" I ('DHIDE)&(DSUPP) S DCHK="D",DHIDE=0
     65 ;Default group setting to hide
     66 I DHIDE="" S DHIDE=1
     67 ;
     68 S DEXC=$P($G(^PXRMD(801.41,DIEN,2)),U,3)
     69 ;
     70 S OCNT=OCNT+1,ORY(OCNT)=1_U_DIEN_U_DSUB_U_DCHK_U_DEXC
     71 S $P(ORY(OCNT),U,8)=$$AHIS(DIEN)
     72 S $P(ORY(OCNT),U,15)=DHIDE,$P(ORY(OCNT),U,16)=DIND
     73 S $P(ORY(OCNT),U,17)=DSHARE,$P(ORY(OCNT),U,18)=DENTRY
     74 S $P(ORY(OCNT),U,19)=DBOX,$P(ORY(OCNT),U,20)=DCAP
     75 S $P(ORY(OCNT),U,21)=DINDPN
     76 ;Create type 2 records if if here is additional group text
     77 N LAST,TEXT
     78 S SUB=0,LAST=0 F  S SUB=$O(DTXT(SUB)) Q:'SUB  D
     79 .D TXT
     80 .S OCNT=OCNT+1,ORY(OCNT)=2_U_DIEN_U_DSUB_U_TEXT
     81 ;Get dialog group sub-elements
     82 N DTYP,DSUPP,DDIS,IDENT S DGSEQ=0
     83 F  S DGSEQ=$O(^PXRMD(801.41,DIEN,10,"B",DGSEQ)) Q:'DGSEQ  D
     84 .S DGSUB=$O(^PXRMD(801.41,DIEN,10,"B",DGSEQ,"")) Q:'DGSUB
     85 .S DATA=$G(^PXRMD(801.41,DIEN,10,DGSUB,0))
     86 .S DGIEN=$P(DATA,U,2) Q:'DGIEN
     87 .;Branching logic call to determine if element should be suppress,
     88 .;replace or left as is
     89 .N TERMNODE,TERMSTAT
     90 .S TERMNODE=$G(^PXRMD(801.41,DGIEN,49))
     91 .I $G(TERMNODE)'="" D  Q:TERMSTAT=0
     92 ..S TERMSTAT=1
     93 ..D REPLACE^PXRMDLLB(DFN,TERMNODE,.DGIEN,.DATA,.TERMSTAT)
     94 .;Exclude from P/N
     95 .S DEXC=$P(DATA,U,8)
     96 .I $P($G(^PXRMD(801.41,DGIEN,0)),U,16)'["WHR" D
     97 ..K DTXT S SUB=0 F  S SUB=$O(^PXRMD(801.41,DGIEN,25,SUB)) Q:'SUB  D
     98 ...S DTXT(SUB)=$G(^PXRMD(801.41,DGIEN,25,SUB,0))
     99 .;Check if element is disabled/invalid
     100 .S DATA=$G(^PXRMD(801.41,DGIEN,0)) Q:DATA=""  Q:$P(DATA,U,3)]""
     101 .;If the actual element is exclude from P/N override
     102 .I $P($G(^PXRMD(801.41,DGIEN,2)),U,3) S DEXC=1
     103 .S DTYP=$P(DATA,U,4),DSUPP=$P(DATA,U,11) Q:"EG"'[DTYP
     104 .S DMHEX=$P(DATA,U,14),DRESL=$P(DATA,U,15)
     105 .S DRES=$P($G(^PXRMD(801.41,DGIEN,1)),U,3)
     106 .;Done Elsewhere (historical)
     107 .S DHIS=$$AHIS(DGIEN)
     108 .S DFIND=$P($G(^PXRMD(801.41,DGIEN,1)),U,5)
     109 .S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2)
     110 .S DPCE="" I DFTYP'="" S DPCE=$G(DARRAY(DFTYP))
     111 .;If mental Health ignore if not GUI
     112 .I DPCE="MH" Q:'$$OK(DFIEN)
     113 .S DGRP=DSUB_"."_DGSUB
     114 .;Taxonomy codes need expanding
     115 .I DPCE="T" D EXP(DFIEN,DGIEN,DGRP) Q
     116 .;Translate vitals ien to PCE code - This will need a DBIA
     117 .I DPCE="VIT" S DFIEN=$$GET1^DIQ(120.51,DFIEN,7,"E")
     118 .;Embedded Dialog Group
     119 .I DTYP="G" D GROUP(DGIEN,DGRP) Q
     120 .S DDIS="S" I DSUPP=1 S DDIS="D"
     121 .S DGRP=DSUB_"."_DGSUB,OCNT=OCNT+1
     122 .S ORY(OCNT)=1_U_DGIEN_U_DGRP_U_DDIS_U_DEXC_U_U_U_DHIS_U_DMHEX_U_DRESL_U_$G(DCOUNT)
     123 .;
     124 .N LAST,TEXT
     125 .S SUB=0,LAST=0 F  S SUB=$O(DTXT(SUB)) Q:'SUB  D
     126 ..D TXT
     127 ..S OCNT=OCNT+1,ORY(OCNT)=2_U_DGIEN_U_DGRP_U_TEXT
     128 Q
     129 ;
     130LOAD(DIEN,DFN) ;Load dialog questions into array
     131 N DARRAY,DATA,DITEM,DFIND,DFIEN,DFTYP,DPCE,DRES,DSEQ,DSUB,DTXT,DTYP,OCNT
     132 N DDIS,DEXC,DHIDE,DCHECK,DDIS,DHIS,DMHEX,DRESL,DSUPP,SUB,IDENT,TXTCNT
     133 ;Check Status of dialog
     134 S DATA=$G(^PXRMD(801.41,DIEN,0)) Q:DATA=""
     135 ;If disabled ignore
     136 I $P(DATA,U,3)]"" Q
     137 ;Ignore if not a reminder dialog
     138 I $P(DATA,U,4)'="R" Q
     139 ;
     140 ;List of PCE codes
     141 S DARRAY("AUTTEDT(")="PED"
     142 S DARRAY("AUTTEXAM(")="XAM"
     143 S DARRAY("AUTTHF(")="HF"
     144 S DARRAY("AUTTIMM(")="IMM"
     145 S DARRAY("AUTTSK(")="SK"
     146 S DARRAY("GMRD(120.51,")="VIT"
     147 S DARRAY("ORD(101.41,")="Q"
     148 S DARRAY("YTT(601,")="MH"
     149 S DARRAY("ICD9(")="POV"
     150 S DARRAY("ICPT(")="CPT"
     151 S DARRAY("PXD(811.2,")="T"
     152 S DARRAY("WV(790.1,")="WHR"
     153 ;
     154 ;Get elements for the dialog
     155 S DSEQ=0,OCNT=0
     156 F  S DSEQ=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ)) Q:'DSEQ  D
     157 .S DSUB=$O(^PXRMD(801.41,DIEN,10,"B",DSEQ,"")) Q:'DSUB
     158 .S DATA=$G(^PXRMD(801.41,DIEN,10,DSUB,0))
     159 .S DITEM=$P(DATA,U,2) Q:DITEM=""
     160 .;Ignore disabled elements
     161 .S DATA=$G(^PXRMD(801.41,DITEM,0)) Q:DATA=""  Q:$P(DATA,U,3)]""
     162 .;Branching logic call to determine if element should be suppress,
     163 .;replace or left as is
     164 .S TERMNODE=$G(^PXRMD(801.41,DITEM,49))
     165 .N TERMSTAT
     166 .I $G(TERMNODE)'="" D  Q:TERMSTAT=0
     167 ..S TERMSTAT=1
     168 ..D REPLACE^PXRMDLLB(DFN,TERMNODE,.DITEM,.DATA,.TERMSTAT)
     169 .S DTYP=$P(DATA,U,4),DSUPP=$P(DATA,U,11)
     170 .S DMHEX=$P(DATA,U,14),DRESL=$P(DATA,U,15)
     171 .K DTXT S SUB=0
     172 .F  S SUB=$O(^PXRMD(801.41,DITEM,25,SUB)) Q:'SUB  D
     173 ..S DTXT(SUB)=$G(^PXRMD(801.41,DITEM,25,SUB,0))
     174 .S DRES=$P($G(^PXRMD(801.41,DITEM,1)),U,3)
     175 .S DFIND=$P($G(^PXRMD(801.41,DITEM,1)),U,5)
     176 .S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2)
     177 .S DPCE="" I DFTYP'="" S DPCE=$G(DARRAY(DFTYP))
     178 .;If mental Health ignore if not GUI
     179 .I DPCE="MH" Q:'$$OK(DFIEN)
     180 .;Exclude from PN
     181 .S DEXC=$P($G(^PXRMD(801.41,DITEM,2)),U,3)
     182 .;Taxonomy codes need expanding
     183 .I DPCE="T" D EXP(DFIEN,DITEM,DSUB) Q
     184 .;Translate vitals ien to PCE code - This will need a DBIA
     185 .I DPCE="VIT" S DFIEN=$P($G(^GMRD(120.51,DFIEN,0)),U,7)
     186 .;Done Elsewhere (historical)
     187 .S DHIS=$$AHIS(DITEM)
     188 .;Dialog Group
     189 .I DTYP="G" D GROUP(DITEM,DSUB) Q
     190 .;Dialog type/text and resolution
     191 .S OCNT=OCNT+1,DDIS="S"
     192 .I DSUPP=1 S DDIS="D"
     193 .S ORY(OCNT)=1_U_DITEM_U_DSUB_U_DDIS_U_DEXC_U_U_U_DHIS_U_DMHEX_U_DRESL
     194 .N LAST,TEXT
     195 .S SUB=0,LAST=0 F  S SUB=$O(DTXT(SUB)) Q:'SUB  D
     196 ..D TXT
     197 ..S OCNT=OCNT+1,ORY(OCNT)=2_U_DITEM_U_DSUB_U_TEXT
     198 Q
     199 ;
     200TAX(TXIEN,ARRAY) ;Return list of resolutions/codes for taxonomy
     201 N CNT,DTXT,FNODE,RSUB,TDX,TNAME,TPAR,TPR,TYP
     202 N TCUR,TDTXT,TDHTXT,THIS,TPTXT,TPHTXT
     203 ;
     204 ;Get taxonomy name
     205 S TNAME=$P($G(^PXD(811.2,TXIEN,0)),U,1)
     206 ;
     207 ;Check what type of taxonomy codes exist
     208 S TDX=$$TOK^PXRMDLLA(TXIEN,"SDX")
     209 S TPR=$$TOK^PXRMDLLA(TXIEN,"SPR")
     210 ;
     211 ;Taxonomy dialog text
     212 S DTXT=$P($G(^PXD(811.2,TXIEN,0)),U,3)
     213 ;default to taxonomy description if null
     214 I DTXT="" S DTXT=$P($G(^PXD(811.2,TXIEN,0)),U,2)
     215 ;default to taxonomy name if null
     216 I DTXT="" S DTXT=$P($G(^PXD(811.2,TXIEN,0)),U,1)
     217 ;
     218 S CNT=0,ARRAY=DTXT
     219 ;
     220 ;Diagnoses
     221 I TDX D
     222 .;Diagnosis texts
     223 .S TPAR=$G(^PXD(811.2,TXIEN,"SDZ"))
     224 .;Get parameter file node for this finding type
     225 .S FNODE=$O(^PXRMD(801.45,"B","POV","")) Q:FNODE=""
     226 .;check if finding parameters are disabled
     227 .S TCUR=$P($G(^PXRMD(801.45,FNODE,1,1,0)),U,2)
     228 .S THIS=$P($G(^PXRMD(801.45,FNODE,1,2,0)),U,2)
     229 .;get category text (diagnoses)
     230 .I 'TCUR D  ; Current
     231 ..S TDTXT=$P(TPAR,U,2) S:TDTXT="" TDTXT=TNAME
     232 ..S CNT=CNT+1,ARRAY(CNT)=TDTXT_U_80_U_1_U_"POV"
     233 .I 'THIS D  ; Historical
     234 ..S TDHTXT=$P(TPAR,U,3) S:TDHTXT="" TDHTXT=TNAME_" (HISTORICAL)"
     235 ..S CNT=CNT+1,ARRAY(CNT)=TDHTXT_U_80_U_2_U_"POV"
     236 ;Procedures
     237 I TPR D
     238 .;Procedure texts
     239 .S TPAR=$G(^PXD(811.2,TXIEN,"SPZ"))
     240 .;Get parameter file node for this finding type
     241 .S FNODE=$O(^PXRMD(801.45,"B","CPT","")) Q:FNODE=""
     242 .;check if finding parameters are disabled
     243 .S TCUR=$P($G(^PXRMD(801.45,FNODE,1,1,0)),U,2)
     244 .S THIS=$P($G(^PXRMD(801.45,FNODE,1,2,0)),U,2)
     245 .;get category text (procedures)
     246 .I 'TCUR D  ; Current
     247 ..S TPTXT=$P(TPAR,U,2) S:TPTXT="" TPTXT=TNAME
     248 ..S CNT=CNT+1,ARRAY(CNT)=TPTXT_U_81_U_1_U_"CPT"
     249 .I 'THIS D  ; Historical
     250 ..S TPHTXT=$P(TPAR,U,3) S:TPHTXT="" TPHTXT=TNAME_" (HISTORICAL)"
     251 ..S CNT=CNT+1,ARRAY(CNT)=TPHTXT_U_81_U_2_U_"CPT"
     252 ;
     253 Q
     254 ;
     255AHIS(DITEM) ;
     256 N RSIEN,RSNAM
     257 S RSIEN=$P($G(^PXRMD(801.41,DITEM,1)),U,3)
     258 I RSIEN="" Q 0
     259 S RSNAM=$P($G(^PXRMD(801.9,RSIEN,0)),U)
     260 I RSNAM["DONE ELSEWHERE" Q 1
     261 N GUI,PIEN,PFOUND
     262 S PIEN=0,PFOUND=0
     263 F  S PIEN=$O(^PXRMD(801.41,DITEM,10,"D",PIEN)) Q:'PIEN  D  Q:PFOUND
     264 .;Ignore elements and groups
     265 .I "EG"[$P($G(^PXRMD(801.41,PIEN,0)),U,4) Q
     266 .;GUI Process
     267 .S GUI=$P($G(^PXRMD(801.41,PIEN,46)),U) Q:'GUI
     268 .;Check if this is PXRM VISIT DATE (or a copy of it)
     269 .I $P($G(^PXRMD(801.42,GUI,0)),U)="VST_DATE" S PFOUND=1
     270 Q PFOUND
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLLA.m

    r613 r623  
    1 PXRMDLLA        ;SLC/PJH - REMINDER DIALOG LOADER ;11/08/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4 FREC(DFIEN,DFTYP)       ;Build type 3 record
    5         N CSARRAY,CSCNT
    6         ;Dialog type/text and resolution 
    7         S DNAM=$$NAME(DFIEN,DFTYP)
    8         D CODE^PXRMDLLB(DFIEN,DFTYP,.CSARRAY)
    9         I $D(CSARRAY)>0 D  Q
    10         . S CSCNT="" F  S CSCNT=$O(CSARRAY(CSCNT)) Q:CSCNT=""  D
    11         . . S OCNT=OCNT+1
    12         . . S ORY(OCNT)=3_U_DITEM_U_U_DPCE_U_DEXC_U_DFIEN_U_$G(CSARRAY(CSCNT))_U_DNAM_U_U_DVIT
    13         ;Translate vitals ien to PCE code - This will need a DBIA
    14         S DCOD=""
    15         I DPCE="VIT" D
    16         .S DFIEN=$$GET1^DIQ(120.51,DFIEN,7,"E")
    17         .;Vitals Caption
    18         .S DVIT=$P($G(^PXRMD(801.41,DITEM,2)),U,4)
    19         I DFTYP]"" D
    20         .S OCNT=OCNT+1
    21         .S ORY(OCNT)=3_U_DITEM_U_U_DPCE_U_DEXC_U_DFIEN_U_$G(DCOD)_U_DNAM_U_U_DVIT
    22         .;Get order type for orderable items
    23         .;DBIA #3110
    24         .S:DPCE="Q" $P(ORY(OCNT),U,11)=$P($G(^ORD(101.41,DFIEN,0)),U,4)
    25         .;If mental health check if a GAF score and if MH test is required
    26         .I DPCE="MH",DFIEN D
    27         ..;DBIA #5044
    28         ..I $P($G(^YTT(601.71,DFIEN,0)),U)="GAF" S $P(ORY(OCNT),U,12)=1
    29         ..;Check to see if the MH test is required
    30         ..S $P(ORY(OCNT),U,13)=+$P($G(^PXRMD(801.41,DITEM,0)),U,18)
    31         ..I $P(ORY(OCNT),U,13)=2,$$PATCH^XPDUTL("OR*3.0*243")=0 S $P(ORY(OCNT),U,13)=1
    32         Q
    33         ;
    34 GUI(IEN)        ;Work out prompt type for PCE
    35         Q:IEN="" ""
    36         N SUB S SUB=$P($G(^PXRMD(801.41,IEN,46)),U)
    37         Q:'SUB ""
    38         Q $P($G(^PXRMD(801.42,SUB,0)),U)
    39         ;
    40 LOAD(DITEM,DCUR,DTTYP)  ;Load dialog questions into array
    41         N DARRAY,DCOD,DEXC,DFIND,DFIEN,DFTYP,DNAM,DPCE,DRES,DSEQ,DSUB,DTYP,OCNT
    42         N DVIT,NODE,CNT,IDENT
    43         ;DBIA #3110    OR(101.41
    44         ;
    45         ;Build list of PCE codes
    46         S DARRAY("AUTTEDT(")="PED"
    47         S DARRAY("AUTTEXAM(")="XAM"
    48         S DARRAY("AUTTHF(")="HF"
    49         S DARRAY("AUTTIMM(")="IMM"
    50         S DARRAY("AUTTSK(")="SK"
    51         ;
    52         S DARRAY("GMRD(120.51,")="VIT"
    53         S DARRAY("ORD(101.41,")="Q"
    54         S DARRAY("YTT(601.71,")="MH"
    55         ;
    56         S DARRAY("ICD9(")="POV"
    57         S DARRAY("ICPT(")="CPT"
    58         S DARRAY("WV(790.404,")="WH"
    59         S DARRAY("WV(790.1,")="WHR"
    60         ;
    61         S DARRAY("PXD(811.2,")="T"
    62         ;
    63         ;Get the dialog element
    64         S OCNT=0
    65         N TERMNODE,TERMSTAT,TERMOUT
    66         S DTYP=$P($G(^PXRMD(801.41,DITEM,0)),U,4)
    67         ;Finding detail
    68         S DRES=$P($G(^PXRMD(801.41,DITEM,1)),U,3)
    69         S DFIND=$P($G(^PXRMD(801.41,DITEM,1)),U,5)
    70         ;check for WH finding
    71         I $P($G(^PXRMD(801.41,DITEM,0)),U,16)["WHR" S DFIND=$G(WHFIND)
    72         ;
    73         S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2)
    74         S DPCE="",DVIT="" I DFTYP'="" S DPCE=$G(DARRAY(DFTYP))
    75         ;Exclude from P/N
    76         S DEXC=$P($G(^PXRMD(801.41,DITEM,2)),U,3)
    77         ;
    78         ;Non taxonomy codes (3 - finding record)
    79         I DPCE'="T" D FREC(DFIEN,DFTYP)
    80         ;
    81         ;Taxonomy codes need expanding (3 - finding record)
    82         I DPCE="T" D EXP^PXRMDLLB(DFIEN,DCUR,DTTYP)
    83         ;
    84         ;Prompt details (4 - prompt records)
    85         N ARRAY,DTITLE,DREQ,DSEQ,DSSEQ,DSUB,DTYP
    86         ;If not a taxonomy get prompts from dialog file
    87         I DPCE'="T" D PROTH(DITEM)
    88         ;Check for MST findings
    89         I (DPCE'="T"),(DFTYP]"") D MST^PXRMDLLB(DFTYP,DFIEN)
    90         ;If taxonomy use finding parameters (CPT/POV)
    91         I DPCE="T" D
    92         .;Quit if finding type not passed
    93         .Q:DTTYP=""
    94         .N RSUB,FNODE
    95         .;Get parameter file node for this finding type
    96         .S FNODE=$O(^PXRMD(801.45,"B",DTTYP,"")) Q:FNODE=""
    97         .;Derive resolution from line ien 1=done 2=done elsewhere
    98         .S RSUB=DCUR+1 I (RSUB<1)!(RSUB>2) Q
    99         .;Get details from 811.5
    100         .D PRTAX(FNODE,RSUB)
    101         ;Return array of type 4 records
    102         S DSEQ=""
    103         F  S DSEQ=$O(ARRAY(DSEQ)) Q:'DSEQ  D
    104         .S OCNT=OCNT+1
    105         .S ORY(OCNT)=4_U_DITEM_U_DSEQ_U_ARRAY(DSEQ)
    106         .S DSSEQ=""
    107         .F  S DSSEQ=$O(ARRAY(DSEQ,DSSEQ)) Q:'DSSEQ  D
    108         ..S OCNT=OCNT+1
    109         ..S ORY(OCNT)=4_U_DITEM_U_DSEQ_"."_DSSEQ_U_ARRAY(DSEQ,DSSEQ)
    110         ;
    111         ;Get progress note text if defined
    112         I DPCE'="T" D:'DEXC PTXT(DITEM)
    113         ;Additional findings
    114         N FASUB
    115         S FASUB=0
    116         F  S FASUB=$O(^PXRMD(801.41,DITEM,3,FASUB)) Q:'FASUB  D
    117         .S DFIND=$P($G(^PXRMD(801.41,DITEM,3,FASUB,0)),U)
    118         .S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2) Q:DFTYP=""  Q:DFIEN=""
    119         .S DVIT="",DPCE=$G(DARRAY(DFTYP))
    120         .I DPCE'="" D FREC(DFIEN,DFTYP)
    121         Q
    122         ;
    123         ;
    124         ;Returns item name
    125 NAME(DFIEN,DFTYP)       ;
    126         Q:DFTYP="" ""
    127         Q:DFIEN="" ""
    128         N NAME,FGLOB,POSN
    129         ;DBIA #4108
    130         I DFTYP="WV(790.404," S NAME=$P($G(^WV(790.404,DFIEN,0)),U) Q:NAME]"" NAME
    131         I DFTYP="WV(790.1," S NAME=$G(WHNAME) K WHNAME Q:NAME]"" NAME
    132         S POSN=2
    133         S:DFTYP["AUTT" POSN=1 S:DFTYP["AUTTEDT" POSN=4 S:DFTYP["ICD" POSN=3
    134         S FGLOB=U_DFTYP_DFIEN_",0)",NAME=$P($G(@FGLOB),U,POSN)
    135         I (POSN>1),NAME="" S NAME=$P($G(@FGLOB),U)
    136         I NAME="" S NAME=DFIEN
    137         Q NAME
    138         ;
    139 PROTH(IEN)      ; Additional prompts defined in 801.41
    140         N DDATA,DDEF,DIEN,DEXC,DGUI,DNAME,DOVR,DREQ,DSEQ,DSNL,DSUB,DFTEXT
    141         N DTXT,DTYP,PRINT
    142         S DSEQ=0
    143         F  S DSEQ=$O(^PXRMD(801.41,IEN,10,"B",DSEQ)) Q:'DSEQ  D
    144         .;Get prompts in sequence
    145         .S DSUB=$O(^PXRMD(801.41,IEN,10,"B",DSEQ,"")) Q:'DSUB
    146         .;Prompt ien
    147         .S DIEN=$P($G(^PXRMD(801.41,IEN,10,DSUB,0)),U,2) Q:'DIEN
    148         .;Ignore disabled components, and those that are not prompts
    149         .Q:($P($G(^PXRMD(801.41,DIEN,0)),U,3)]"")!("PF"'[$P($G(^(0)),U,4))
    150         .;Set defaults to null
    151         .S DDEF="",DEXC="",DREQ="",DSNL=""
    152         .;Prompt name and GUI process (quit if null)
    153         .S DNAME=$P($G(^PXRMD(801.41,DIEN,0)),U),DGUI=$$GUI(DIEN)
    154         .I $G(DGUI)="WH_NOT_PURP" D
    155         ..S PRINT=$$GET^XPAR($G(DUZ)_";VA(200,^SRV.`"_+$G(SRV)_"^DIV^SYS","PXRM WH PRINT NOW",1,"I")
    156         .;Type Prompt or Forced
    157         .S DTYP=$P($G(^PXRMD(801.41,DIEN,0)),U,4)
    158         .I "PF"[DTYP D
    159         ..;Required/Prompt caption
    160         ..S DDATA=$G(^PXRMD(801.41,DIEN,2)),DTXT=$P(DDATA,U,4)
    161         ..;Default value or forced value
    162         ..S:DTYP="P" DDEF=$P(DDATA,U) S:DTYP="F" DDEF=$P(DDATA,U,2)
    163         ..;Override caption/start new line/exclude PN from dialog file
    164         ..S DDATA=$G(^PXRMD(801.41,IEN,10,DSUB,0)),DREQ=$P(DDATA,U,9)
    165         ..S DOVR=$P(DDATA,U,6),DSNL=$P(DDATA,U,7),DEXC=$P(DDATA,U,8)
    166         ..S DNAME=DTXT I DOVR]"" S DNAME=DOVR
    167         ..;Convert date to fileman format
    168         ..I DGUI="VST_DATE",DDEF["T" S DDEF=$$DT^XLFDT()
    169         .S ARRAY(DSEQ)=DGUI_U_DEXC_U_DDEF_U_DTYP_U_DNAME_U_DSNL_U_DREQ_U_$G(DFTEXT)_U_$G(PRINT)
    170         .;the following section add a comment prompt to the WH review of result
    171         .;section of the reminder dialog
    172         .I DGUI="WH_PAP_RESULT",DFTYP="WV(790.1,",DTYP="P" D
    173         ..N WHCNT,WHFLAG,WHNUM,WHLOOP
    174         ..S WHNUM=DSEQ+1,WHLOOP=0
    175         ..F WHLOOP=0 D
    176         ...S (WHCNT,WHFLAG)=0
    177         ...F  S WHCNT=$O(^PXRMD(801.41,IEN,10,"B",WHCNT)) Q:'WHCNT!(WHFLAG=1)  D
    178         ....I WHCNT=WHNUM S WHFLAG=1,WHNUM=WHNUM+1
    179         ...I WHFLAG=0 S WHLOOP=1
    180         ..S ARRAY(WHNUM)="COM"_U_U_U_"P"_U_"Comment:"_U_U_U
    181         .;Additional checkboxes
    182         .I DGUI="COM",DIEN>1 D
    183         ..N DSSEQ,DSUB,DTEXT
    184         ..S DSSEQ=0
    185         ..F  S DSSEQ=$O(^PXRMD(801.41,DIEN,45,"B",DSSEQ)) Q:'DSSEQ  D
    186         ...S DSUB=$O(^PXRMD(801.41,DIEN,45,"B",DSSEQ,"")) Q:'DSUB
    187         ...S DTEXT=$P($G(^PXRMD(801.41,DIEN,45,DSUB,0)),U,2) Q:DTEXT=""
    188         ...S ARRAY(DSEQ,DSSEQ)=U_DEXC_U_DDEF_U_DTYP_U_DTEXT_U_DSNL_U_DREQ
    189         Q
    190         ;
    191 PRTAX(FNODE,RSUB)       ;Get all additional fields for this resolution type
    192         N ACNT,ASUB
    193         N DDATA,DDEF,DEXC,DGUI,DNAME,DREQ,DSEQ,DSUB,DTYP,PRINT
    194         S ASUB=0,DSEQ=0
    195         F  S ASUB=$O(^PXRMD(801.45,FNODE,1,RSUB,5,ASUB)) Q:'ASUB  D
    196         .S DDATA=$G(^PXRMD(801.45,FNODE,1,RSUB,5,ASUB,0)) Q:DDATA=""
    197         .;Ignore if disabled
    198         .I $P(DDATA,U,3)=1 Q
    199         .S DSUB=$P(DDATA,U) Q:DDATA=""
    200         .S DSEQ=DSEQ+1
    201         .;Set defaults to null
    202         .S DDEF="",DEXC="",DREQ="",DSNL=""
    203         .;Prompt name and GUI process (quit if null)
    204         .S DNAME=$P($G(^PXRMD(801.41,DSUB,0)),U),DGUI=$$GUI(DSUB)
    205         .I $G(DGUI)="WH_NOT_PURP" D
    206         ..S PRINT=$$GET^XPAR($G(DUZ)_";VA(200,^SRV.`"_+$G(SRV)_"^DIV^SYS","PXRM WH PRINT NOW",1,"I")
    207         .;Type Prompt or Forced
    208         .S DTYP=$P($G(^PXRMD(801.41,DSUB,0)),U,4)
    209         .I DTYP="P" D
    210         ..S DREQ=$P(DDATA,U,2),DTXT=$P($G(^PXRMD(801.41,DSUB,2)),U,4)
    211         ..;Override caption/start new line/exclude from PN from finding type
    212         ..S DOVR=$P(DDATA,U,5),DSNL=$P(DDATA,U,6),DEXC=$P(DDATA,U,7)
    213         ..S DNAME=DTXT I DOVR]"" S DNAME=DOVR
    214         ..;Required/Prompt caption
    215         ..S DDATA=$G(^PXRMD(801.41,DSUB,2))
    216         .S ARRAY(DSEQ)=DGUI_U_DEXC_U_DDEF_U_DTYP_U_DNAME_U_DSNL_U_DREQ_U_U_$G(PRINT)
    217         Q
    218         ;
    219 PTXT(ITEM)      ;Get progress note (WP) text for type 6 records
    220         N ARRAY,LAST,NULL,SUB,TEXT,TXTCNT
    221         S SUB=0
    222         F  S SUB=$O(^PXRMD(801.41,ITEM,35,SUB)) Q:'SUB  D
    223         .S ARRAY(SUB)=$G(^PXRMD(801.41,ITEM,35,SUB,0))
    224         S SUB=0,LAST=0 F  S SUB=$O(ARRAY(SUB)) Q:'SUB  D
    225         .S TEXT=$G(ARRAY(SUB))
    226         .S NULL=0 I (TEXT="")!($E(TEXT)=" ") S NULL=1
    227         .I LAST,'NULL S TEXT="<br>"_TEXT
    228         .S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
    229         .S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
    230         .S OCNT=OCNT+1,ORY(OCNT)=6_U_ITEM_U_U_TEXT
    231         Q
    232         ;
    233 TOK(TIEN,TYPE)  ;Check if selectable codes exist
    234         N DATA,FOUND,SUB
    235         S FOUND=0,SUB=0
    236         F  S SUB=$O(^PXD(811.2,TIEN,TYPE,SUB)) Q:'SUB  D  Q:FOUND
    237         .S DATA=$G(^PXD(811.2,TIEN,TYPE,SUB,0)) Q:DATA=""
    238         .;Ignore disabled codes
    239         .I '$P(DATA,U,3) S FOUND=1
    240         Q FOUND
     1PXRMDLLA ;SLC/PJH - REMINDER DIALOG LOADER ;07/29/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4FREC(DFIEN,DFTYP) ;Build type 3 record
     5 N CSARRAY,CSCNT
     6 ;Dialog type/text and resolution 
     7 S DNAM=$$NAME(DFIEN,DFTYP)
     8 D CODE^PXRMDLLB(DFIEN,DFTYP,.CSARRAY)
     9 I $D(CSARRAY)>0 D  Q
     10 . S CSCNT="" F  S CSCNT=$O(CSARRAY(CSCNT)) Q:CSCNT=""  D
     11 . . S OCNT=OCNT+1
     12 . . S ORY(OCNT)=3_U_DITEM_U_U_DPCE_U_DEXC_U_DFIEN_U_$G(CSARRAY(CSCNT))_U_DNAM_U_U_DVIT
     13 ;Translate vitals ien to PCE code - This will need a DBIA
     14 S DCOD=""
     15 I DPCE="VIT" D
     16 .S DFIEN=$$GET1^DIQ(120.51,DFIEN,7,"E")
     17 .;Vitals Caption
     18 .S DVIT=$P($G(^PXRMD(801.41,DITEM,2)),U,4)
     19 I DFTYP]"" D
     20 .S OCNT=OCNT+1
     21 .S ORY(OCNT)=3_U_DITEM_U_U_DPCE_U_DEXC_U_DFIEN_U_$G(DCOD)_U_DNAM_U_U_DVIT
     22 .;Get order type for orderable items
     23 .;DBIA #3110
     24 .S:DPCE="Q" $P(ORY(OCNT),U,11)=$P($G(^ORD(101.41,DFIEN,0)),U,4)
     25 .;If mental health check if a GAF score and if MH test is required
     26 .I DPCE="MH",DFIEN D
     27 ..I $P($G(^YTT(601,DFIEN,0)),U)="GAF" S $P(ORY(OCNT),U,12)=1
     28 ..;Check to see if the MH test is required
     29 ..S $P(ORY(OCNT),U,13)=$S($P($G(^PXRMD(801.41,DITEM,0)),U,18)=1:1,1:0)
     30 Q
     31 ;
     32GUI(IEN) ;Work out prompt type for PCE
     33 Q:IEN="" ""
     34 N SUB S SUB=$P($G(^PXRMD(801.41,IEN,46)),U)
     35 Q:'SUB ""
     36 Q $P($G(^PXRMD(801.42,SUB,0)),U)
     37 ;
     38LOAD(DITEM,DCUR,DTTYP) ;Load dialog questions into array
     39 N DARRAY,DCOD,DEXC,DFIND,DFIEN,DFTYP,DNAM,DPCE,DRES,DSEQ,DSUB,DTYP,OCNT
     40 N DVIT,NODE,CNT,IDENT
     41 ;DBIA #3110    OR(101.41
     42 ;
     43 ;Build list of PCE codes
     44 S DARRAY("AUTTEDT(")="PED"
     45 S DARRAY("AUTTEXAM(")="XAM"
     46 S DARRAY("AUTTHF(")="HF"
     47 S DARRAY("AUTTIMM(")="IMM"
     48 S DARRAY("AUTTSK(")="SK"
     49 ;
     50 S DARRAY("GMRD(120.51,")="VIT"
     51 S DARRAY("ORD(101.41,")="Q"
     52 S DARRAY("YTT(601,")="MH"
     53 ;
     54 S DARRAY("ICD9(")="POV"
     55 S DARRAY("ICPT(")="CPT"
     56 S DARRAY("WV(790.404,")="WH"
     57 S DARRAY("WV(790.1,")="WHR"
     58 ;
     59 S DARRAY("PXD(811.2,")="T"
     60 ;
     61 ;Get the dialog element
     62 S OCNT=0
     63 N TERMNODE,TERMSTAT,TERMOUT
     64 S DTYP=$P($G(^PXRMD(801.41,DITEM,0)),U,4)
     65 ;Finding detail
     66 S DRES=$P($G(^PXRMD(801.41,DITEM,1)),U,3)
     67 S DFIND=$P($G(^PXRMD(801.41,DITEM,1)),U,5)
     68 ;check for WH finding
     69 I $P($G(^PXRMD(801.41,DITEM,0)),U,16)["WHR" S DFIND=$G(WHFIND)
     70 ;
     71 S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2)
     72 S DPCE="",DVIT="" I DFTYP'="" S DPCE=$G(DARRAY(DFTYP))
     73 ;Exclude from P/N
     74 S DEXC=$P($G(^PXRMD(801.41,DITEM,2)),U,3)
     75 ;
     76 ;Non taxonomy codes (3 - finding record)
     77 I DPCE'="T" D FREC(DFIEN,DFTYP)
     78 ;
     79 ;Taxonomy codes need expanding (3 - finding record)
     80 I DPCE="T" D EXP^PXRMDLLB(DFIEN,DCUR,DTTYP)
     81 ;
     82 ;Prompt details (4 - prompt records)
     83 N ARRAY,DTITLE,DREQ,DSEQ,DSSEQ,DSUB,DTYP
     84 ;If not a taxonomy get prompts from dialog file
     85 I DPCE'="T" D PROTH(DITEM)
     86 ;Check for MST findings
     87 I (DPCE'="T"),(DFTYP]"") D MST^PXRMDLLB(DFTYP,DFIEN)
     88 ;If taxonomy use finding parameters (CPT/POV)
     89 I DPCE="T" D
     90 .;Quit if finding type not passed
     91 .Q:DTTYP=""
     92 .N RSUB,FNODE
     93 .;Get parameter file node for this finding type
     94 .S FNODE=$O(^PXRMD(801.45,"B",DTTYP,"")) Q:FNODE=""
     95 .;Derive resolution from line ien 1=done 2=done elsewhere
     96 .S RSUB=DCUR+1 I (RSUB<1)!(RSUB>2) Q
     97 .;Get details from 811.5
     98 .D PRTAX(FNODE,RSUB)
     99 ;Return array of type 4 records
     100 S DSEQ=""
     101 F  S DSEQ=$O(ARRAY(DSEQ)) Q:'DSEQ  D
     102 .S OCNT=OCNT+1
     103 .S ORY(OCNT)=4_U_DITEM_U_DSEQ_U_ARRAY(DSEQ)
     104 .S DSSEQ=""
     105 .F  S DSSEQ=$O(ARRAY(DSEQ,DSSEQ)) Q:'DSSEQ  D
     106 ..S OCNT=OCNT+1
     107 ..S ORY(OCNT)=4_U_DITEM_U_DSEQ_"."_DSSEQ_U_ARRAY(DSEQ,DSSEQ)
     108 ;
     109 ;Get progress note text if defined
     110 I DPCE'="T" D:'DEXC PTXT(DITEM)
     111 ;Additional findings
     112 N FASUB
     113 S FASUB=0
     114 F  S FASUB=$O(^PXRMD(801.41,DITEM,3,FASUB)) Q:'FASUB  D
     115 .S DFIND=$P($G(^PXRMD(801.41,DITEM,3,FASUB,0)),U)
     116 .S DFIEN=$P(DFIND,";"),DFTYP=$P(DFIND,";",2) Q:DFTYP=""  Q:DFIEN=""
     117 .S DVIT="",DPCE=$G(DARRAY(DFTYP))
     118 .I DPCE'="" D FREC(DFIEN,DFTYP)
     119 Q
     120 ;
     121 ;
     122 ;Returns item name
     123NAME(DFIEN,DFTYP) ;
     124 Q:DFTYP="" ""
     125 Q:DFIEN="" ""
     126 N NAME,FGLOB,POSN
     127 ;DBIA #4108
     128 I DFTYP="WV(790.404," S NAME=$P($G(^WV(790.404,DFIEN,0)),U) Q:NAME]"" NAME
     129 I DFTYP="WV(790.1," S NAME=$G(WHNAME) K WHNAME Q:NAME]"" NAME
     130 S POSN=2
     131 S:DFTYP["AUTT" POSN=1 S:DFTYP["AUTTEDT" POSN=4 S:DFTYP["ICD" POSN=3
     132 S FGLOB=U_DFTYP_DFIEN_",0)",NAME=$P($G(@FGLOB),U,POSN)
     133 I (POSN>1),NAME="" S NAME=$P($G(@FGLOB),U)
     134 I NAME="" S NAME=DFIEN
     135 Q NAME
     136 ;
     137PROTH(IEN) ; Additional prompts defined in 801.41
     138 N DDATA,DDEF,DIEN,DEXC,DGUI,DNAME,DOVR,DREQ,DSEQ,DSNL,DSUB,DFTEXT
     139 N DTXT,DTYP,PRINT
     140 S DSEQ=0
     141 F  S DSEQ=$O(^PXRMD(801.41,IEN,10,"B",DSEQ)) Q:'DSEQ  D
     142 .;Get prompts in sequence
     143 .S DSUB=$O(^PXRMD(801.41,IEN,10,"B",DSEQ,"")) Q:'DSUB
     144 .;Prompt ien
     145 .S DIEN=$P($G(^PXRMD(801.41,IEN,10,DSUB,0)),U,2) Q:'DIEN
     146 .;Ignore disabled components, and those that are not prompts
     147 .Q:($P($G(^PXRMD(801.41,DIEN,0)),U,3)]"")!("PF"'[$P($G(^(0)),U,4))
     148 .;Set defaults to null
     149 .S DDEF="",DEXC="",DREQ="",DSNL=""
     150 .;Prompt name and GUI process (quit if null)
     151 .S DNAME=$P($G(^PXRMD(801.41,DIEN,0)),U),DGUI=$$GUI(DIEN)
     152 .I $G(DGUI)="WH_NOT_PURP" D
     153 ..S PRINT=$$GET^XPAR($G(DUZ)_";VA(200,^SRV.`"_+$G(SRV)_"^DIV^SYS","PXRM WH PRINT NOW",1,"I")
     154 .;Type Prompt or Forced
     155 .S DTYP=$P($G(^PXRMD(801.41,DIEN,0)),U,4)
     156 .I "PF"[DTYP D
     157 ..;Required/Prompt caption
     158 ..S DDATA=$G(^PXRMD(801.41,DIEN,2)),DTXT=$P(DDATA,U,4)
     159 ..;Default value or forced value
     160 ..S:DTYP="P" DDEF=$P(DDATA,U) S:DTYP="F" DDEF=$P(DDATA,U,2)
     161 ..;Override caption/start new line/exclude PN from dialog file
     162 ..S DDATA=$G(^PXRMD(801.41,IEN,10,DSUB,0)),DREQ=$P(DDATA,U,9)
     163 ..S DOVR=$P(DDATA,U,6),DSNL=$P(DDATA,U,7),DEXC=$P(DDATA,U,8)
     164 ..S DNAME=DTXT I DOVR]"" S DNAME=DOVR
     165 ..;Convert date to fileman format
     166 ..I DGUI="VST_DATE",DDEF["T" S DDEF=$$DT^XLFDT()
     167 .S ARRAY(DSEQ)=DGUI_U_DEXC_U_DDEF_U_DTYP_U_DNAME_U_DSNL_U_DREQ_U_$G(DFTEXT)_U_$G(PRINT)
     168 .;the following section add a comment prompt to the WH review of result
     169 .;section of the reminder dialog
     170 .I DGUI="WH_PAP_RESULT",DFTYP="WV(790.1,",DTYP="P" D
     171 ..N WHCNT,WHFLAG,WHNUM,WHLOOP
     172 ..S WHNUM=DSEQ+1,WHLOOP=0
     173 ..F WHLOOP=0 D
     174 ...S (WHCNT,WHFLAG)=0
     175 ...F  S WHCNT=$O(^PXRMD(801.41,IEN,10,"B",WHCNT)) Q:'WHCNT!(WHFLAG=1)  D
     176 ....I WHCNT=WHNUM S WHFLAG=1,WHNUM=WHNUM+1
     177 ...I WHFLAG=0 S WHLOOP=1
     178 ..S ARRAY(WHNUM)="COM"_U_U_U_"P"_U_"Comment:"_U_U_U
     179 .;Additional checkboxes
     180 .I DGUI="COM",DIEN>1 D
     181 ..N DSSEQ,DSUB,DTEXT
     182 ..S DSSEQ=0
     183 ..F  S DSSEQ=$O(^PXRMD(801.41,DIEN,45,"B",DSSEQ)) Q:'DSSEQ  D
     184 ...S DSUB=$O(^PXRMD(801.41,DIEN,45,"B",DSSEQ,"")) Q:'DSUB
     185 ...S DTEXT=$P($G(^PXRMD(801.41,DIEN,45,DSUB,0)),U,2) Q:DTEXT=""
     186 ...S ARRAY(DSEQ,DSSEQ)=U_DEXC_U_DDEF_U_DTYP_U_DTEXT_U_DSNL_U_DREQ
     187 Q
     188 ;
     189PRTAX(FNODE,RSUB) ;Get all additional fields for this resolution type
     190 N ACNT,ASUB
     191 N DDATA,DDEF,DEXC,DGUI,DNAME,DREQ,DSEQ,DSUB,DTYP,PRINT
     192 S ASUB=0,DSEQ=0
     193 F  S ASUB=$O(^PXRMD(801.45,FNODE,1,RSUB,5,ASUB)) Q:'ASUB  D
     194 .S DDATA=$G(^PXRMD(801.45,FNODE,1,RSUB,5,ASUB,0)) Q:DDATA=""
     195 .;Ignore if disabled
     196 .I $P(DDATA,U,3)=1 Q
     197 .S DSUB=$P(DDATA,U) Q:DDATA=""
     198 .S DSEQ=DSEQ+1
     199 .;Set defaults to null
     200 .S DDEF="",DEXC="",DREQ="",DSNL=""
     201 .;Prompt name and GUI process (quit if null)
     202 .S DNAME=$P($G(^PXRMD(801.41,DSUB,0)),U),DGUI=$$GUI(DSUB)
     203 .I $G(DGUI)="WH_NOT_PURP" D
     204 ..S PRINT=$$GET^XPAR($G(DUZ)_";VA(200,^SRV.`"_+$G(SRV)_"^DIV^SYS","PXRM WH PRINT NOW",1,"I")
     205 .;Type Prompt or Forced
     206 .S DTYP=$P($G(^PXRMD(801.41,DSUB,0)),U,4)
     207 .I DTYP="P" D
     208 ..S DREQ=$P(DDATA,U,2),DTXT=$P($G(^PXRMD(801.41,DSUB,2)),U,4)
     209 ..;Override caption/start new line/exclude from PN from finding type
     210 ..S DOVR=$P(DDATA,U,5),DSNL=$P(DDATA,U,6),DEXC=$P(DDATA,U,7)
     211 ..S DNAME=DTXT I DOVR]"" S DNAME=DOVR
     212 ..;Required/Prompt caption
     213 ..S DDATA=$G(^PXRMD(801.41,DSUB,2))
     214 .S ARRAY(DSEQ)=DGUI_U_DEXC_U_DDEF_U_DTYP_U_DNAME_U_DSNL_U_DREQ_U_U_$G(PRINT)
     215 Q
     216 ;
     217PTXT(ITEM) ;Get progress note (WP) text for type 6 records
     218 N ARRAY,LAST,NULL,SUB,TEXT,TXTCNT
     219 S SUB=0
     220 F  S SUB=$O(^PXRMD(801.41,ITEM,35,SUB)) Q:'SUB  D
     221 .S ARRAY(SUB)=$G(^PXRMD(801.41,ITEM,35,SUB,0))
     222 S SUB=0,LAST=0 F  S SUB=$O(ARRAY(SUB)) Q:'SUB  D
     223 .S TEXT=$G(ARRAY(SUB))
     224 .S NULL=0 I (TEXT="")!($E(TEXT)=" ") S NULL=1
     225 .I LAST,'NULL S TEXT="<br>"_TEXT
     226 .S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
     227 .S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
     228 .S OCNT=OCNT+1,ORY(OCNT)=6_U_ITEM_U_U_TEXT
     229 Q
     230 ;
     231TOK(TIEN,TYPE) ;Check if selectable codes exist
     232 N DATA,FOUND,SUB
     233 S FOUND=0,SUB=0
     234 F  S SUB=$O(^PXD(811.2,TIEN,TYPE,SUB)) Q:'SUB  D  Q:FOUND
     235 .S DATA=$G(^PXD(811.2,TIEN,TYPE,SUB,0)) Q:DATA=""
     236 .;Ignore disabled codes
     237 .I '$P(DATA,U,3) S FOUND=1
     238 Q FOUND
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLLB.m

    r613 r623  
    1 PXRMDLLB        ;SLC/PJH - REMINDER DIALOG LOADER ;05/01/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4 CODE(DFIEN,DFTYP,ARRAY) ;
    5         N ARY,CNT,CNT1
    6         I DFTYP["ICD9" S CODE=$P($G(^ICD9(DFIEN,0)),U) D PERIOD^ICDAPIU(CODE,.ARY)
    7         I DFTYP["ICPT" S CODE=$P($$CPT^ICPTCOD(DFIEN),U,2) D PERIOD^ICPTAPIU(CODE,.ARY)
    8         I $D(ARY)'>0 Q
    9         I $P($G(ARY(0)),U,2)'>0 Q
    10         S (CNT,CNT1)=0
    11         F  S CNT=$O(ARY(CNT)) Q:CNT=""  D
    12         . S ARRAY(CNT1)=CODE_":"_CNT_":"_$P($G(ARY(CNT)),U)
    13         . S CNT1=CNT1+1
    14         Q
    15         ;
    16 CODES(FILE,TXIEN,ARRAY) ;Return selectable codes from taxonomy file
    17         N CNT,CODE,CSCNT,DATA,DATES,DISPLAY,IEN,INSTALL,TEMP,TEXT,NODE,SUB
    18         S SUB=0,CNT=0,NODE=$S(FILE=80:"SDX",FILE=81:"SPR")
    19         F  S SUB=$O(^PXD(811.2,TXIEN,NODE,SUB)) Q:'SUB  D
    20         .S DATA=$G(^PXD(811.2,TXIEN,NODE,SUB,0)) Q:DATA=""
    21         .;Ignore if disabled
    22         .S DISPLAY=""
    23         .I $P(DATA,U,3)=1 Q
    24         .;Get ien of code
    25         .S IEN=$P(DATA,U) Q:IEN=""
    26         .;get date ranges and text from period api
    27         .K ARY
    28         .I FILE=80 S CODE=$P($G(^ICD9(IEN,0)),U)
    29         .I FILE=81 S CODE=$P($$CPT^ICPTCOD(IEN),U,2)
    30         .S DISPLAY=$P($G(DATA),U,2)
    31         .S TEMP=$$CODE^PXRMVAL(CODE,FILE) Q:'$P(TEMP,U)  Q:$P(TEMP,U,9)=1
    32         .;Set display text from taxonomy selectable code text
    33         .S TEXT=$P(DATA,U,2)
    34         .;otherwise use icd9/cpt description
    35         .I TEXT="",FILE=80 S TEXT=$P($$ICDDX^ICDCODE(IEN),U,3)
    36         .I TEXT="",FILE=81 S TEXT=$P($$CPT^ICPTCOD(IEN),U,3)
    37         .I FILE=80 D PERIOD^ICDAPIU(CODE,.ARY)
    38         .I FILE=81 D PERIOD^ICPTAPIU(CODE,.ARY)
    39         .I $D(ARY)'>0 Q
    40         .I $P($G(ARY(0)),U,2)'>0 Q
    41         .S CSCNT=0 F  S CSCNT=$O(ARY(CSCNT)) Q:CSCNT=""  D
    42         ..S DATES=":"_CSCNT_":"_$P($G(ARY(CSCNT)),U)
    43         ..S TEXT=$P($G(ARY(CSCNT)),U,2) I $G(DISPLAY)'="" S TEXT=DISPLAY
    44         ..S CNT=CNT+1,ARRAY(CNT)=IEN_U_$G(CODE)_$G(DATES)_U_$G(TEXT)
    45         Q
    46         ;
    47 EXP(TIEN,DCUR,DTTYP)    ;Expand taxonomy codes
    48         N CODES,CNT,FILE,LIT,CAT
    49         S FILE=$S(DTTYP="POV":80,DTTYP="CPT":81,1:"") Q:'FILE
    50         S LIT="Selectable "_$S(FILE=80:"Diagnoses:",1:"Procedures:")
    51         S CAT=$P($G(^PXD(811.2,TIEN,0)),U)
    52         ;
    53         S OCNT=OCNT+1
    54         S ORY(OCNT)=3_U_DITEM_U_U_DTTYP_U_U_U_U_U_CAT_U_LIT
    55         ;Get selectable codes
    56         D CODES(FILE,TIEN,.CODES)
    57         S CNT=0
    58         ;Save selectable codes as type 5 records
    59         F  S CNT=$O(CODES(CNT)) Q:'CNT  D
    60         .S OCNT=OCNT+1,ORY(OCNT)=5_U_DITEM_U_U_DTTYP_U_U_CODES(CNT)
    61         Q
    62         ;
    63         ;Pass MST code as a forced value
    64 MST(DFTYP,DFIEN)        ;
    65         ;Validate finding ien
    66         Q:DFIEN=""
    67         ;For each MST term check if finding is mapped
    68         N FOUND,TCOND,TIEN,TNAM,TSUB
    69         S FOUND=0
    70         F TNAM="POSITIVE","NEGATIVE","DECLINES" D  Q:FOUND
    71         .;Get term IEN
    72         .S TIEN=$O(^PXRMD(811.5,"B","MST "_TNAM_" REPORT","")) Q:'TIEN
    73         .;Check if finding is mapped to term
    74         .Q:'$D(^PXRMD(811.5,TIEN,20,"E",DFTYP,DFIEN))
    75         .;If exam and term condition logic is null ignore
    76         .I DFTYP="AUTTEXAM(" D  Q:TCOND=""
    77         ..S TCOND="",TSUB=$O(^PXRMD(811.5,TIEN,20,"E",DFTYP,DFIEN,"")) Q:'TSUB
    78         ..S TCOND=$P($G(^PXRMD(811.5,TIEN,20,TSUB,3)),U)
    79         .;If it is then create additional prompt for MST
    80         .N DSEQ,DEXC,DDEF,DGUI,DTYP,DTEXT,DSNL,DREQ
    81         .;Add to end of array
    82         .S DSEQ=$O(ARRAY(""),-1)+1
    83         .;Null fields
    84         .S DDEF="",DEXC="",DTEXT="",DSNL="",DREQ=""
    85         .;MST status (exept for exams)
    86         .I DFTYP'="AUTTEXAM(" S DDEF=$$STCODE^PXRMMST("MST "_TNAM_" REPORT")
    87         .;GUI process and forced value
    88         .S DGUI="MST",DTYP="F"
    89         .;Save in array
    90         .S ARRAY(DSEQ)=DGUI_U_DEXC_U_DDEF_U_DTYP_U_DTEXT_U_DSNL_U_DREQ
    91         .;Quit after the first term is found
    92         .S FOUND=1
    93         Q
    94         ;
    95 REPLACE(DFN,TERMNODE,DITEM,DATA,TERMSTAT)       ;
    96         ;this section is use to compare the term evalution result against
    97         ;the value store in the Reminder Term Status field.
    98         ;If the value match and the replacement item is active then the orginal
    99         ;item will be replace with the new item.
    100         N TERMOUT
    101         S TERMSTAT=1 I +$P(TERMNODE,U),$P($G(TERMNODE),U,2)'="" D  Q:+TERMSTAT=0
    102         .N DITEMO
    103         .S TERMOUT=$$TERM($P(TERMNODE,U),DFN,$G(DITEM))
    104         .I TERMOUT'=$P(TERMNODE,U,2) Q
    105         .I +$P(TERMNODE,U,3)'>0 S TERMSTAT=0 Q
    106         .S DITEMO=DITEM,DITEM=$P(TERMNODE,U,3),DATA=$G(^PXRMD(801.41,DITEM,0))
    107         .I $G(DATA)=""!($P(DATA,U,3)]"") S DITEM=DITEMO Q
    108         Q
    109         ;
    110 RESGROUP(DIEN)  ;
    111         N CNT,RESULT,TEMP
    112         S RESULT=""
    113         I $$PATCH^XPDUTL("OR*3.0*243")=0 D  Q RESULT
    114         .S RESULT=$P($G(^PXRMD(801.41,DIEN,51,1,0)),U) I RESULT="" Q
    115         .I $P($G(^PXRMD(801.41,RESULT,0)),U,3)'="" S RESULT="" Q
    116         S CNT=0 F  S CNT=$O(^PXRMD(801.41,DIEN,51,CNT)) Q:CNT'>0  D
    117         .S TEMP=$P($G(^PXRMD(801.41,DIEN,51,CNT,0)),U) I TEMP="" Q
    118         .I $P($G(^PXRMD(801.41,TEMP,0)),U,3)'="" S TEMP="" Q
    119         .S RESULT=$S(RESULT="":TEMP,1:RESULT_"~"_TEMP)
    120         Q RESULT
    121         ;
    122 TERM(TERMIEN,DFN,IEN)   ;
    123         ;this section is use to for the term evaluation
    124         N ARRAY,CNT,NODE,RESULT,TERMARR
    125         N DATEORDR,ESUB,FINDPA,FIEVAL,TFIEVAL,NOCC,BDT,EDT,SDIR,SUB,WVIEN
    126         S (TERMARR,TFIEVAL,DATEORDR,FIEVAL)=""
    127         ;build term array
    128         D TERM^PXRMLDR(TERMIEN,.TERMARR)
    129         ;term evaulation
    130         D IEVALTER^PXRMTERM(DFN,.TERMARR,.TERMARR,1,.FIEVAL)
    131         S RESULT=$G(FIEVAL(1))
    132         ;if the item is one of the WH review reminders build finding item and
    133         ;text from the  the WVALERTS API in PXRMCWH
    134         I RESULT=1,$P($G(^PXRMD(801.41,IEN,0)),U,16)["WHR" D
    135         .N IDENT
    136         .S IDENT=$P($G(^PXRMD(801.41,IEN,0)),U,16)
    137         .I $G(FIEVAL(1,"LINK"))=1,$G(FIEVAL(1,"STATUS"))="OPEN",$G(FIEVAL(1,"VALUE"))="Pending" D
    138         ..S WVIEN=$G(FIEVAL(1,"WVIEN"))
    139         ..;DBIA #4102
    140         ..D RESULTS^WVALERTS(.ARRAY,WVIEN) D
    141         ...K WHFIND,WHNAME
    142         ...S NODE=$G(ARRAY(0)) I +$P(NODE,U)'>0 Q
    143         ...S WHFIND=WVIEN_";WV(790.1,",WHNAME=$P($G(NODE),U,3)
    144         ...S (ESUB,SUB)=0 F  S SUB=$O(DTXT(SUB)) Q:SUB'>0  S ESUB=SUB
    145         ...S ESUB=ESUB+1
    146         ...I IDENT="WHRP" D
    147         ....N MOD
    148         ....S DATE=""
    149         ....S DTXT(ESUB)=$P($G(NODE),U,3),ESUB=ESUB+1
    150         ....S DATE=$P($G(NODE),U,4),STR=$$RJ^XLFSTR("Collected: ",20)
    151         ....S STR=STR_$P($G(NODE),U,8)
    152         ....S DTXT(ESUB)=STR,ESUB=ESUB+1
    153         ....S STR=$$RJ^XLFSTR("Lab Accession #: ",20),STR=STR_$P($G(NODE),U,9)
    154         ....S DTXT(ESUB)=STR,ESUB=ESUB+1
    155         ....S STR=$$RJ^XLFSTR("Specimen: ",20),STR=STR_$P($G(NODE),U,10)
    156         ....S DTXT(ESUB)=STR
    157         ...I IDENT="WHRM" D
    158         ....S STR=$$RJ^XLFSTR("Procedure: ",20),STR=STR_$P($G(NODE),U,5)
    159         ....S DTXT(ESUB)=STR,ESUB=ESUB+1
    160         ....S STR=$$RJ^XLFSTR("Primary Diagnosis: ",20),STR=STR_$P($G(NODE),U,6)
    161         ....S DTXT(ESUB)=STR,ESUB=ESUB+1
    162         ....S STR=$$RJ^XLFSTR("Modifiers: ",20),MOD=$P($G(NODE),U,7)
    163         ....I $G(MOD)="" S STR=STR_"<none>"
    164         ....E  S STR=STR_$P($G(MOD),"~",1)
    165         ....S DTXT(ESUB)=STR,ESUB=ESUB+1
    166         ....I $P($G(MOD),"~",2)'="" S DTXT(ESUB)=$$LJ^XLFSTR($P(MOD,"~",2),23)
    167         Q +RESULT
    168         ;
     1PXRMDLLB ;SLC/PJH - REMINDER DIALOG LOADER ;07/29/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4CODE(DFIEN,DFTYP,ARRAY) ;
     5 N ARY,CNT,CNT1
     6 I DFTYP["ICD9" S CODE=$P($G(^ICD9(DFIEN,0)),U) D PERIOD^ICDAPIU(CODE,.ARY)
     7 I DFTYP["ICPT" S CODE=$P($$CPT^ICPTCOD(DFIEN),U,2) D PERIOD^ICPTAPIU(CODE,.ARY)
     8 I $D(ARY)'>0 Q
     9 I $P($G(ARY(0)),U,2)'>0 Q
     10 S (CNT,CNT1)=0
     11 F  S CNT=$O(ARY(CNT)) Q:CNT=""  D
     12 . S ARRAY(CNT1)=CODE_":"_CNT_":"_$P($G(ARY(CNT)),U)
     13 . S CNT1=CNT1+1
     14 Q
     15 ;
     16CODES(FILE,TXIEN,ARRAY) ;Return selectable codes from taxonomy file
     17 N CNT,CODE,CSCNT,DATA,DATES,DISPLAY,IEN,INSTALL,TEMP,TEXT,NODE,SUB
     18 S SUB=0,CNT=0,NODE=$S(FILE=80:"SDX",FILE=81:"SPR")
     19 F  S SUB=$O(^PXD(811.2,TXIEN,NODE,SUB)) Q:'SUB  D
     20 .S DATA=$G(^PXD(811.2,TXIEN,NODE,SUB,0)) Q:DATA=""
     21 .;Ignore if disabled
     22 .S DISPLAY=""
     23 .I $P(DATA,U,3)=1 Q
     24 .;Get ien of code
     25 .S IEN=$P(DATA,U) Q:IEN=""
     26 .;get date ranges and text from period api
     27 .K ARY
     28 .I FILE=80 S CODE=$P($G(^ICD9(IEN,0)),U)
     29 .I FILE=81 S CODE=$P($$CPT^ICPTCOD(IEN),U,2)
     30 .S DISPLAY=$P($G(DATA),U,2)
     31 .S TEMP=$$CODE^PXRMVAL(CODE,FILE) Q:'$P(TEMP,U)  Q:$P(TEMP,U,9)=1
     32 .;Set display text from taxonomy selectable code text
     33 .S TEXT=$P(DATA,U,2)
     34 .;otherwise use icd9/cpt description
     35 .I TEXT="",FILE=80 S TEXT=$P($$ICDDX^ICDCODE(IEN),U,3)
     36 .I TEXT="",FILE=81 S TEXT=$P($$CPT^ICPTCOD(IEN),U,3)
     37 .I FILE=80 D PERIOD^ICDAPIU(CODE,.ARY)
     38 .I FILE=81 D PERIOD^ICPTAPIU(CODE,.ARY)
     39 .I $D(ARY)'>0 Q
     40 .I $P($G(ARY(0)),U,2)'>0 Q
     41 .S CSCNT=0 F  S CSCNT=$O(ARY(CSCNT)) Q:CSCNT=""  D
     42 ..S DATES=":"_CSCNT_":"_$P($G(ARY(CSCNT)),U)
     43 ..S TEXT=$P($G(ARY(CSCNT)),U,2) I $G(DISPLAY)'="" S TEXT=DISPLAY
     44 ..S CNT=CNT+1,ARRAY(CNT)=IEN_U_$G(CODE)_$G(DATES)_U_$G(TEXT)
     45 Q
     46 ;
     47EXP(TIEN,DCUR,DTTYP) ;Expand taxonomy codes
     48 N CODES,CNT,FILE,LIT,CAT
     49 S FILE=$S(DTTYP="POV":80,DTTYP="CPT":81,1:"") Q:'FILE
     50 S LIT="Selectable "_$S(FILE=80:"Diagnoses:",1:"Procedures:")
     51 S CAT=$P($G(^PXD(811.2,TIEN,0)),U)
     52 ;
     53 S OCNT=OCNT+1
     54 S ORY(OCNT)=3_U_DITEM_U_U_DTTYP_U_U_U_U_U_CAT_U_LIT
     55 ;Get selectable codes
     56 D CODES(FILE,TIEN,.CODES)
     57 S CNT=0
     58 ;Save selectable codes as type 5 records
     59 F  S CNT=$O(CODES(CNT)) Q:'CNT  D
     60 .S OCNT=OCNT+1,ORY(OCNT)=5_U_DITEM_U_U_DTTYP_U_U_CODES(CNT)
     61 Q
     62 ;
     63 ;Pass MST code as a forced value
     64MST(DFTYP,DFIEN) ;
     65 ;Validate finding ien
     66 Q:DFIEN=""
     67 ;For each MST term check if finding is mapped
     68 N FOUND,TCOND,TIEN,TNAM,TSUB
     69 S FOUND=0
     70 F TNAM="POSITIVE","NEGATIVE","DECLINES" D  Q:FOUND
     71 .;Get term IEN
     72 .S TIEN=$O(^PXRMD(811.5,"B","MST "_TNAM_" REPORT","")) Q:'TIEN
     73 .;Check if finding is mapped to term
     74 .Q:'$D(^PXRMD(811.5,TIEN,20,"E",DFTYP,DFIEN))
     75 .;If exam and term condition logic is null ignore
     76 .I DFTYP="AUTTEXAM(" D  Q:TCOND=""
     77 ..S TCOND="",TSUB=$O(^PXRMD(811.5,TIEN,20,"E",DFTYP,DFIEN,"")) Q:'TSUB
     78 ..S TCOND=$P($G(^PXRMD(811.5,TIEN,20,TSUB,3)),U)
     79 .;If it is then create additional prompt for MST
     80 .N DSEQ,DEXC,DDEF,DGUI,DTYP,DTEXT,DSNL,DREQ
     81 .;Add to end of array
     82 .S DSEQ=$O(ARRAY(""),-1)+1
     83 .;Null fields
     84 .S DDEF="",DEXC="",DTEXT="",DSNL="",DREQ=""
     85 .;MST status (exept for exams)
     86 .I DFTYP'="AUTTEXAM(" S DDEF=$$STCODE^PXRMMST("MST "_TNAM_" REPORT")
     87 .;GUI process and forced value
     88 .S DGUI="MST",DTYP="F"
     89 .;Save in array
     90 .S ARRAY(DSEQ)=DGUI_U_DEXC_U_DDEF_U_DTYP_U_DTEXT_U_DSNL_U_DREQ
     91 .;Quit after the first term is found
     92 .S FOUND=1
     93 Q
     94 ;
     95REPLACE(DFN,TERMNODE,DITEM,DATA,TERMSTAT) ;
     96 ;this section is use to compare the term evalution result against
     97 ;the value store in the Reminder Term Status field.
     98 ;If the value match and the replacement item is active then the orginal
     99 ;item will be replace with the new item.
     100 N TERMOUT
     101 S TERMSTAT=1 I +$P(TERMNODE,U),$P($G(TERMNODE),U,2)'="" D  Q:+TERMSTAT=0
     102 .N DITEMO
     103 .S TERMOUT=$$TERM($P(TERMNODE,U),DFN,$G(DITEM))
     104 .I TERMOUT'=$P(TERMNODE,U,2) Q
     105 .I +$P(TERMNODE,U,3)'>0 S TERMSTAT=0 Q
     106 .S DITEMO=DITEM,DITEM=$P(TERMNODE,U,3),DATA=$G(^PXRMD(801.41,DITEM,0))
     107 .I $G(DATA)=""!($P(DATA,U,3)]"") S DITEM=DITEMO Q
     108 Q
     109 ;
     110TERM(TERMIEN,DFN,IEN) ;
     111 ;this section is use to for the term evaluation
     112 N ARRAY,CNT,NODE,RESULT,TERMARR
     113 N DATEORDR,ESUB,FINDPA,FIEVAL,TFIEVAL,NOCC,BDT,EDT,SDIR,SUB,WVIEN
     114 S (TERMARR,TFIEVAL,DATEORDR,FIEVAL)=""
     115 ;build term array
     116 D TERM^PXRMLDR(TERMIEN,.TERMARR)
     117 ;term evaulation
     118 D IEVALTER^PXRMTERM(DFN,.TERMARR,.TERMARR,1,.FIEVAL)
     119 S RESULT=$G(FIEVAL(1))
     120 ;if the item is one of the WH review reminders build finding item and
     121 ;text from the  the WVALERTS API in PXRMCWH
     122 I RESULT=1,$P($G(^PXRMD(801.41,IEN,0)),U,16)["WHR" D
     123 .N IDENT
     124 .S IDENT=$P($G(^PXRMD(801.41,IEN,0)),U,16)
     125 .I $G(FIEVAL(1,"LINK"))=1,$G(FIEVAL(1,"STATUS"))="OPEN",$G(FIEVAL(1,"VALUE"))="Pending" D
     126 ..S WVIEN=$G(FIEVAL(1,"WVIEN"))
     127 ..;DBIA #4102
     128 ..D RESULTS^WVALERTS(.ARRAY,WVIEN) D
     129 ...K WHFIND,WHNAME
     130 ...S NODE=$G(ARRAY(0)) I +$P(NODE,U)'>0 Q
     131 ...S WHFIND=WVIEN_";WV(790.1,",WHNAME=$P($G(NODE),U,3)
     132 ...S (ESUB,SUB)=0 F  S SUB=$O(DTXT(SUB)) Q:SUB'>0  S ESUB=SUB
     133 ...S ESUB=ESUB+1
     134 ...I IDENT="WHRP" D
     135 ....N MOD
     136 ....S DATE=""
     137 ....S DTXT(ESUB)=$P($G(NODE),U,3),ESUB=ESUB+1
     138 ....S DATE=$P($G(NODE),U,4),STR=$$RJ^XLFSTR("Collected: ",20)
     139 ....S STR=STR_$P($G(NODE),U,8)
     140 ....S DTXT(ESUB)=STR,ESUB=ESUB+1
     141 ....S STR=$$RJ^XLFSTR("Lab Accession #: ",20),STR=STR_$P($G(NODE),U,9)
     142 ....S DTXT(ESUB)=STR,ESUB=ESUB+1
     143 ....S STR=$$RJ^XLFSTR("Specimen: ",20),STR=STR_$P($G(NODE),U,10)
     144 ....S DTXT(ESUB)=STR
     145 ...I IDENT="WHRM" D
     146 ....S STR=$$RJ^XLFSTR("Procedure: ",20),STR=STR_$P($G(NODE),U,5)
     147 ....S DTXT(ESUB)=STR,ESUB=ESUB+1
     148 ....S STR=$$RJ^XLFSTR("Primary Diagnosis: ",20),STR=STR_$P($G(NODE),U,6)
     149 ....S DTXT(ESUB)=STR,ESUB=ESUB+1
     150 ....S STR=$$RJ^XLFSTR("Modifiers: ",20),MOD=$P($G(NODE),U,7)
     151 ....I $G(MOD)="" S STR=STR_"<none>"
     152 ....E  S STR=STR_$P($G(MOD),"~",1)
     153 ....S DTXT(ESUB)=STR,ESUB=ESUB+1
     154 ....I $P($G(MOD),"~",2)'="" S DTXT(ESUB)=$$LJ^XLFSTR($P(MOD,"~",2),23)
     155 Q +RESULT
     156 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLR.m

    r613 r623  
    1 PXRMDLR ;SLC/PJH - DIALOG RESULTS LOADER ;05/15/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Build score related P/N text from score and result group
    5         ;
    6         ;If not found
    7 START(ORY,RESULT,ORES)  ;
    8         I '$G(RESULT) S ORY(1)="-1^no results for this test" Q
    9         ;
    10         N ARRAY,ERROR,INSERT,OK,SCORE,SUB,YT,X
    11         ;
    12         I RESULT["~" S RESULT=$P(RESULT,"~")
    13         S ERROR=0
    14         ;
    15         ;Get score using API
    16         K ^TMP($J,"YSCOR")
    17         I ORES("CODE")'="DOM80" D  Q:ERROR
    18         .M YT=ORES
    19         .F X=1:1:$L(YT("R1")) I $E(YT("R1"),X)'="X" S YT(X)=X_U_$E(YT("R1"),X)
    20         .K YT("R1")
    21         .D CHECKCR^YTQPXRM4(.ARRAY,.YT)
    22         .S OK=0
    23         .;D PREVIEW^YTAPI4(.ARRAY,.YT)
    24         .I ^TMP($J,"YSCOR",1)'="[DATA]" S ORY(1)="-1^"_^TMP($J,"YSCOR",1)_^TMP($J,"YSCOD",2),ERROR=1 Q
    25         .;I ARRAY(1)'="[DATA]" S ORY(1)="-1^"_ARRAY(1)_ARRAY(2),ERROR=1 Q
    26         .I $P($G(^TMP($J,"YSCOR",2)),"=",2)'="" S SCORE=$P($G(^TMP($J,"YSCOR",2)),"=",2),OK=1
    27         .;S SUB=0,OK=0
    28         .;F  S SUB=$O(ARRAY(SUB)) Q:'SUB  D  Q:OK
    29         .;.I $P(ARRAY(SUB),U)="S1" S SCORE=$P(ARRAY(SUB),U,3),OK=1
    30         .I 'OK S ORY(1)="-1^[ERROR] no score returned",ERROR=1 Q
    31         ;
    32         ;Except for DOM80
    33         I ORES("CODE")="DOM80" D
    34         .I $E(ORES("R1"))="Y" S SCORE=1 Q
    35         .I $E(ORES("R1"),2,3)="YY",($E(ORES("R1"),4)>1) S SCORE=1 Q
    36         .S SCORE=0
    37         ;
    38         S DFN=$G(ORES("DFN"))
    39         S INSERT("SCORE")=SCORE
    40         ;
    41         ;For AIMS special formatting is required
    42         I ORES("CODE")="AIMS" D
    43         .N CNT,LITS,RESP,SUM
    44         .S LITS(0)="none",LITS(1)="minimal",LITS(2)="mild",LITS(3)="moderate"
    45         .S LITS(4)="severe",SUM(2)=0,SUM(3)=0,SUM(4)=0
    46         .F CNT=1:1 S RESP=$E(ORES("R1"),CNT) Q:RESP=""  D
    47         ..S INSERT("R"_CNT)=$G(LITS(RESP))
    48         ..I (CNT<8),(234[RESP) S SUM(RESP)=SUM(RESP)+1
    49         .F CNT=2,3,4 S INSERT("SUM"_CNT)=SUM(CNT)
    50         ;
    51 TEXT    ;
    52         I RESULT["~" S RESULT=$P(RESULT,"~")
    53         ;Load dialog results into ORY array
    54         N DATA,DCON,DITEM,DSEQ,DSUB,DTYP,INS,SEP,TEXT
    55         ;Get the result elements
    56         S DSEQ=0,OCNT=0
    57         F  S DSEQ=$O(^PXRMD(801.41,RESULT,10,"B",DSEQ)) Q:'DSEQ  D
    58         .S DSUB=$O(^PXRMD(801.41,RESULT,10,"B",DSEQ,"")) Q:'DSUB
    59         .S DITEM=$P($G(^PXRMD(801.41,RESULT,10,DSUB,0)),U,2) Q:'DITEM
    60         .;Get the result element
    61         .S DTYP=$P($G(^PXRMD(801.41,DITEM,0)),U,4) Q:DTYP'="T"
    62         .;Get the result element condition
    63         .S DCON=$P($G(^PXRMD(801.41,DITEM,0)),U,13)
    64         .;Skip if condition not satisfied
    65         .I DCON'="" S DCON=$TR(DCON,"~"," ") Q:'$$TRUE(SCORE,DCON,DFN)
    66         .;Get progress note text if defined
    67         .N LAST,NULL,SUB,TEXT S SUB=0,LAST=0
    68         .F  S SUB=$O(^PXRMD(801.41,DITEM,35,SUB)) Q:'SUB  D
    69         ..;Insert score into text (if neccessary)
    70         ..S TEXT=$G(^PXRMD(801.41,DITEM,35,SUB,0))
    71         ..S NULL=0 I ($E(TEXT)=" ")!(TEXT="") S NULL=1
    72         ..;Add line breaks if is or preceded by blank line or starts with space
    73         ..I ('NULL),LAST S TEXT="<br>"_TEXT
    74         ..S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
    75         ..S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
    76         ..;Check for inserts - note there may be embedded TIU markers too
    77         ..N INS
    78         ..S INS=""
    79         ..F  S INS=$O(INSERT(INS)) Q:INS=""  D
    80         ...S SEP="|"_INS_"|" I '$F(TEXT,SEP) Q
    81         ...S TEXT=$P(TEXT,SEP)_$G(INSERT(INS))_$P(TEXT,SEP,2,99)
    82         ..S OCNT=OCNT+1,ORY(OCNT)=7_U_TEXT
    83         Q
    84         ;
    85 MHDLL(ORES,RESULT,SCORE,DFN)    ;
    86         S INSERT("SCORE")=SCORE
    87         D TEXT
    88         Q
    89 OUT(DATA)       ;Display element details
    90         N DITEM S DITEM=$P(DATA,U,2) Q:'DITEM
    91         W $P($G(^PXRMD(801.41,DITEM,0)),U)
    92         W !,$J("Element Condition:  ",19)
    93         W $TR($P($G(^PXRMD(801.41,DITEM,0)),U,13),"~"," ")
    94         W !,$J("Element text:",17)
    95         ;Get progress note text if defined
    96         N SUB,TEXT S SUB=0
    97         F  S SUB=$O(^PXRMD(801.41,DITEM,35,SUB)) Q:'SUB  D
    98         .S TEXT=$G(^PXRMD(801.41,DITEM,35,SUB,0)) W !,?5,TEXT
    99         Q
    100         ;
    101 TRUE(V,COND,DFN)        ; Check if value meets element condition
    102         N RESULT,SEX
    103         I COND["SEX" D  Q RESULT
    104         . S RESULT=0
    105         . S SEX=$P($G(^DPT(DFN,0)),U,2)
    106         . X COND I  S RESULT=1
    107         X COND I  Q 1
    108         Q 0
     1PXRMDLR ;SLC/PJH - DIALOG RESULTS LOADER ;06/09/2000
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;Build score related P/N text from score and result group
     5 ;
     6 ;If not found
     7 I '$G(RESULT) S ORY(1)="-1^no results for this test" Q
     8 ;
     9 N ARRAY,ERROR,INSERT,OK,SCORE,SUB,YT
     10 ;
     11 S ERROR=0
     12 ;
     13 ;Get score using API
     14 S DFN=$G(ORES("DFN"))
     15 I ORES("CODE")'="DOM80" D  Q:ERROR
     16 .M YT=ORES
     17 .D PREVIEW^YTAPI4(.ARRAY,.YT)
     18 .I ARRAY(1)'="[DATA]" S ORY(1)="-1^"_ARRAY(1)_ARRAY(2),ERROR=1 Q
     19 .S SUB=0,OK=0
     20 .F  S SUB=$O(ARRAY(SUB)) Q:'SUB  D  Q:OK
     21 ..I $P(ARRAY(SUB),U)="S1" S SCORE=$P(ARRAY(SUB),U,3),OK=1
     22 .I 'OK S ORY(1)="-1^[ERROR] no score returned",ERROR=1 Q
     23 ;
     24 ;Except for DOM80
     25 I ORES("CODE")="DOM80" D
     26 .I $E(ORES("R1"))="Y" S SCORE=1 Q
     27 .I $E(ORES("R1"),2,3)="YY",($E(ORES("R1"),4)>1) S SCORE=1 Q
     28 .S SCORE=0
     29 ;
     30 S INSERT("SCORE")=SCORE
     31 ;
     32 ;For AIMS special formatting is required
     33 I ORES("CODE")="AIMS" D
     34 .N CNT,LITS,RESP,SUM
     35 .S LITS(0)="none",LITS(1)="minimal",LITS(2)="mild",LITS(3)="moderate"
     36 .S LITS(4)="severe",SUM(2)=0,SUM(3)=0,SUM(4)=0
     37 .F CNT=1:1 S RESP=$E(ORES("R1"),CNT) Q:RESP=""  D
     38 ..S INSERT("R"_CNT)=$G(LITS(RESP))
     39 ..I (CNT<8),(234[RESP) S SUM(RESP)=SUM(RESP)+1
     40 .F CNT=2,3,4 S INSERT("SUM"_CNT)=SUM(CNT)
     41 ;
     42 ;Load dialog results into ORY array
     43 N DATA,DCON,DITEM,DSEQ,DSUB,DTYP,INS,SEP,TEXT
     44 ;Get the result elements
     45 S DSEQ=0,OCNT=0
     46 F  S DSEQ=$O(^PXRMD(801.41,RESULT,10,"B",DSEQ)) Q:'DSEQ  D
     47 .S DSUB=$O(^PXRMD(801.41,RESULT,10,"B",DSEQ,"")) Q:'DSUB
     48 .S DITEM=$P($G(^PXRMD(801.41,RESULT,10,DSUB,0)),U,2) Q:'DITEM
     49 .;Get the result element
     50 .S DTYP=$P($G(^PXRMD(801.41,DITEM,0)),U,4) Q:DTYP'="T"
     51 .;Get the result element condition
     52 .S DCON=$P($G(^PXRMD(801.41,DITEM,0)),U,13)
     53 .;Skip if condition not satisfied
     54 .I DCON'="" S DCON=$TR(DCON,"~"," ") Q:'$$TRUE(SCORE,DCON,DFN)
     55 .;Get progress note text if defined
     56 .N LAST,NULL,SUB,TEXT S SUB=0,LAST=0
     57 .F  S SUB=$O(^PXRMD(801.41,DITEM,35,SUB)) Q:'SUB  D
     58 ..;Insert score into text (if neccessary)
     59 ..S TEXT=$G(^PXRMD(801.41,DITEM,35,SUB,0))
     60 ..S NULL=0 I ($E(TEXT)=" ")!(TEXT="") S NULL=1
     61 ..;Add line breaks if is or preceded by blank line or starts with space
     62 ..I ('NULL),LAST S TEXT="<br>"_TEXT
     63 ..S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
     64 ..S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
     65 ..;Check for inserts - note there may be embedded TIU markers too
     66 ..N INS
     67 ..S INS=""
     68 ..F  S INS=$O(INSERT(INS)) Q:INS=""  D
     69 ...S SEP="|"_INS_"|" I '$F(TEXT,SEP) Q
     70 ...S TEXT=$P(TEXT,SEP)_$G(INSERT(INS))_$P(TEXT,SEP,2,99)
     71 ..S OCNT=OCNT+1,ORY(OCNT)=7_U_TEXT
     72 Q
     73 ;
     74OUT(DATA) ;Display element details
     75 N DITEM S DITEM=$P(DATA,U,2) Q:'DITEM
     76 W $P($G(^PXRMD(801.41,DITEM,0)),U)
     77 W !,$J("Element Condition:  ",19)
     78 W $TR($P($G(^PXRMD(801.41,DITEM,0)),U,13),"~"," ")
     79 W !,$J("Element text:",17)
     80 ;Get progress note text if defined
     81 N SUB,TEXT S SUB=0
     82 F  S SUB=$O(^PXRMD(801.41,DITEM,35,SUB)) Q:'SUB  D
     83 .S TEXT=$G(^PXRMD(801.41,DITEM,35,SUB,0)) W !,?5,TEXT
     84 Q
     85 ;
     86TRUE(V,COND,DFN) ; Check if value meets element condition
     87 N RESULT,SEX
     88 I COND["SEX" D  Q RESULT
     89 . S RESULT=0
     90 . S SEX=$P($G(^DPT(DFN,0)),U,2)
     91 . X COND I  S RESULT=1
     92 X COND I  Q 1
     93 Q 0
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLR1.m

    r613 r623  
    1 PXRMDLR1        ; SLC/AGP - DIALOG ORPHAN REPORT. ; 11/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=======================================================================
    5 START(NUM)      ;
    6         N DIR,POP,ZTDESC,ZTRTN,ZTSAVE
    7         S %ZIS="M"
    8         I NUM=1 S ZTDESC="Dialog Orphan Report" S ZTRTN="EN^PXRMDLR1"
    9         I NUM=2 S ZTDESC="Empty Reminder Dialogs Report" S ZTRTN="EN1^PXRMDLR1"
    10         S ZTSAVE("*")=""
    11         D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS)
    12         Q
    13         ;
    14 EN      ;
    15         N NAME,IEN,TYPE
    16         K ^TMP("PXRMDLR1",$J)
    17         S IEN=0
    18         S NAME="" F  S NAME=$O(^PXRMD(801.41,"B",NAME)) Q:NAME=""  D
    19         . S IEN=$O(^PXRMD(801.41,"B",NAME,"")) Q:IEN'>0
    20         . S TYPE=$P($G(^PXRMD(801.41,IEN,0)),U,4)
    21         . I $G(TYPE)=""!($G(TYPE)="R") Q
    22         . I $D(^PXRMD(801.41,"AD",IEN)) Q
    23         . S TYPE=$S(TYPE="P":"VPROMPT",TYPE="E":"ELEMENT",TYPE="F":"VVALUE",TYPE="G":"GROUP",TYPE="S":"RGROUP",TYPE="T":"RELEMENT")
    24         . S ^TMP("PXRMDLR1",$J,TYPE,NAME)=IEN
    25         I $D(^TMP("PXRMDLR1",$J))>0 D OUTPUT
    26         Q
    27         ;
    28 EN1     ;
    29         N DONE,FOUND,NAME,IEN,TITLE,TYPE
    30         W @IOF
    31         S PCNT=0,PAGE=1,DONE=0,FOUND=0
    32         S TITLE="Empty Reminder Dialogs Report"
    33         D HEADER(.PCNT,PAGE,TITLE)
    34         S IEN=0
    35         S NAME="" F  S NAME=$O(^PXRMD(801.41,"B",NAME)) Q:NAME=""!(DONE=1)  D
    36         . S IEN=$O(^PXRMD(801.41,"B",NAME,"")) Q:IEN'>0
    37         . S TYPE=$P($G(^PXRMD(801.41,IEN,0)),U,4)
    38         . I ($G(TYPE)'="R") Q
    39         . I $D(^PXRMD(801.41,IEN,10))'=0 Q
    40         . S FOUND=1
    41         . I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
    42         . W !,"  "_$G(NAME) S PCNT=PCNT+1 I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
    43         I FOUND=0 W !,"No empty dialog found"
    44         I ($E(IOST,1,2)="C-")&(IO=IO(0)) D
    45         . W !
    46         . S DIR(0)="E" D ^DIR K DIR
    47         Q
    48         ;
    49 OUTPUT  ;
    50         N CAT,DONE,LENGTH,NAME,OCAT,PAGE,PCNT,TITLE,TYPE,X
    51         W @IOF
    52         S PCNT=0,PAGE=1,DONE=0
    53         S TITLE="Reminder Dialog Elements Orphan Report"
    54         D HEADER(.PCNT,PAGE,TITLE)
    55         W !
    56         F CAT="ELEMENT","GROUP","RELEMENT","RGROUP","VPROMPT","VVALUE" D
    57         . I DONE=1 Q
    58         . I $D(^TMP("PXRMDLR1",$J,CAT))'>0 Q
    59         . S TYPE=$S(CAT="VPROMPT":"Additional Prompts",CAT="ELEMENT":"Dialog Elements",CAT="VVALUE":"Force Values",CAT="GROUP":"Dialog Groups",CAT="RGROUP":"Result Groups",CAT="RELEMENT":"Result Elements")
    60         . I (PCNT+4)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
    61         . S LENGTH=$L(TYPE) W !!,TYPE,! F X=1:1:LENGTH W "="
    62         . S PCNT=PCNT+4
    63         . I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
    64         . S NAME="" F  S NAME=$O(^TMP("PXRMDLR1",$J,CAT,NAME)) Q:NAME=""!(DONE=1)  D
    65         . .W !,$$LJ^XLFSTR("",4)_NAME S PCNT=PCNT+1
    66         . .I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
    67         K ^TMP("PXRMDLR1",$J)
    68         I ($E(IOST,1,2)="C-")&(IO=IO(0)) D
    69         . W !
    70         . S DIR(0)="E" D ^DIR K DIR
    71         Q
    72         ;
    73 HEADER(PCNT,PAGE,TITLE) ;
    74         W $$LJ^XLFSTR(TITLE,70)_"Page: "_PAGE,!
    75         F X=1:1:80 W "="
    76         S PCNT=PCNT+3
    77         Q
    78         ;
    79 PAGE(PCNT,PAGE) ;
    80         N DUOUT,DTOUT,DIROUT,DIR
    81         I ($E(IOST,1,2)="C-")&(IO=IO(0)) D
    82         .S DIR(0)="E"
    83         .W !
    84         .D ^DIR K DIR
    85         I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
    86         W:$D(IOF) @IOF
    87         S PAGE=PAGE+1,PCNT=0
    88         I ($E(IOST,1,2)="C-")&(IO=IO(0)) W @IOF D HEADER(.PCNT,PAGE,TITLE)
    89         Q
     1PXRMDLR1 ; SLC/AGP - DIALOG ORPHAN REPORT. ; 02/04/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=======================================================================
     5START(NUM) ;
     6 N DIR,POP,ZTDESC,ZTRTN,ZTSAVE
     7 S %ZIS="M"
     8 I NUM=1 S ZTDESC="Dialog Orphan Report" S ZTRTN="EN^PXRMDLR1"
     9 I NUM=2 S ZTDESC="Empty Reminder Dialogs Report" S ZTRTN="EN1^PXRMDLR1"
     10 S ZTSAVE("*")=""
     11 D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS)
     12 Q
     13 ;
     14EN ;
     15 N NAME,IEN,TYPE
     16 K ^TMP("PXRMDLR1",$J)
     17 S IEN=0
     18 S NAME="" F  S NAME=$O(^PXRMD(801.41,"B",NAME)) Q:NAME=""  D
     19 . S IEN=$O(^PXRMD(801.41,"B",NAME,"")) Q:IEN'>0
     20 . S TYPE=$P($G(^PXRMD(801.41,IEN,0)),U,4)
     21 . I $G(TYPE)=""!($G(TYPE)="R") Q
     22 . I $D(^PXRMD(801.41,"AD",IEN)) Q
     23 . S TYPE=$S(TYPE="P":"VPROMPT",TYPE="E":"ELEMENT",TYPE="F":"VVALUE",TYPE="G":"GROUP",TYPE="S":"RGROUP",TYPE="T":"RELEMENT")
     24 . S ^TMP("PXRMDLR1",$J,TYPE,NAME)=IEN
     25 I $D(^TMP("PXRMDLR1",$J))>0 D OUTPUT
     26 Q
     27 ;
     28EN1 ;
     29 N DONE,FOUND,NAME,IEN,TITLE,TYPE
     30 W @IOF
     31 S PCNT=0,PAGE=1,DONE=0,FOUND=0
     32 S TITLE="Empty Reminder Dialogs Report"
     33 D HEADER(.PCNT,PAGE,TITLE)
     34 S IEN=0
     35 S NAME="" F  S NAME=$O(^PXRMD(801.41,"B",NAME)) Q:NAME=""!(DONE=1)  D
     36 . S IEN=$O(^PXRMD(801.41,"B",NAME,"")) Q:IEN'>0
     37 . S TYPE=$P($G(^PXRMD(801.41,IEN,0)),U,4)
     38 . I ($G(TYPE)'="R") Q
     39 . I $D(^PXRMD(801.41,IEN,10))'=0 Q
     40 . S FOUND=1
     41 . I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
     42 . W !,"  "_$G(NAME) S PCNT=PCNT+1 I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
     43 I FOUND=0 W !,"No empty dialog found"
     44 I ($E(IOST)="C")&(IO=IO(0)) D
     45 . W !
     46 . S DIR(0)="E" D ^DIR K DIR
     47 Q
     48 ;
     49OUTPUT ;
     50 N CAT,DONE,LENGTH,NAME,OCAT,PAGE,PCNT,TITLE,TYPE,X
     51 W @IOF
     52 S PCNT=0,PAGE=1,DONE=0
     53 S TITLE="Reminder Dialog Elements Orphan Report"
     54 D HEADER(.PCNT,PAGE,TITLE)
     55 W !
     56 F CAT="ELEMENT","GROUP","RELEMENT","RGROUP","VPROMPT","VVALUE" D
     57 . I DONE=1 Q
     58 . I $D(^TMP("PXRMDLR1",$J,CAT))'>0 Q
     59 . S TYPE=$S(CAT="VPROMPT":"Additional Prompts",CAT="ELEMENT":"Dialog Elements",CAT="VVALUE":"Force Values",CAT="GROUP":"Dialog Groups",CAT="RGROUP":"Result Groups",CAT="RELEMENT":"Result Elements")
     60 . I (PCNT+4)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
     61 . S LENGTH=$L(TYPE) W !!,TYPE,! F X=1:1:LENGTH W "="
     62 . S PCNT=PCNT+4
     63 . I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
     64 . S NAME="" F  S NAME=$O(^TMP("PXRMDLR1",$J,CAT,NAME)) Q:NAME=""!(DONE=1)  D
     65 . .W !,$$LJ^XLFSTR("",4)_NAME S PCNT=PCNT+1
     66 . .I (PCNT+1)'<IOSL D PAGE(.PCNT,.PAGE) I $G(DONE)=1 Q
     67 K ^TMP("PXRMDLR1",$J)
     68 I ($E(IOST)="C")&(IO=IO(0)) D
     69 . W !
     70 . S DIR(0)="E" D ^DIR K DIR
     71 Q
     72 ;
     73HEADER(PCNT,PAGE,TITLE) ;
     74 W $$LJ^XLFSTR(TITLE,70)_"Page: "_PAGE,!
     75 F X=1:1:80 W "="
     76 S PCNT=PCNT+3
     77 Q
     78 ;
     79PAGE(PCNT,PAGE) ;
     80 N DUOUT,DTOUT,DIROUT,DIR
     81 I ($E(IOST)="C")&(IO=IO(0)) D
     82 .S DIR(0)="E"
     83 .W !
     84 .D ^DIR K DIR
     85 I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
     86 W:$D(IOF) @IOF
     87 S PAGE=PAGE+1,PCNT=0
     88 I $E(IOST)="C",IO=IO(0) W @IOF D HEADER(.PCNT,PAGE,TITLE)
     89 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDNVA.m

    r613 r623  
    1 PXRMDNVA        ; SLC/PKR - Handle non-VA med findings. ;03/14/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;===============================================
    5 GETDATA(DAS,FIEVT)      ;Return data for an non-VA med finding.
    6         ;DBIA #3793
    7         D NVA^PSOPXRM1(DAS,.FIEVT)
    8         S FIEVT("VALUE")=FIEVT("STATUS")
    9         I $G(FIEVT("START DATE"))="" S FIEVT("START DATE")=FIEVT("DOCUMENTED DATE")
    10         S FIEVT("DURATION")=$$DURATION^PXRMDATE(FIEVT("START DATE"),FIEVT("DISCONTINUED DATE"))
    11         Q
    12         ;
    13         ;===============================================
    14 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate terms.
    15         D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
    16         Q
    17         ;
    18         ;====================================================
    19 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    20         N DATE,JND,NOUT,TEMP,TEXTOUT
    21         S TEMP="Non-VA med: "_IFIEVAL("ORDERABLE ITEM")_" = "
    22         S TEMP=TEMP_"("_$$EDATE^PXRMDATE(IFIEVAL("START DATE"))
    23         S DATE=IFIEVAL("DISCONTINUED DATE")
    24         S DATE=$S(DATE="":"NONE",1:$$EDATE^PXRMDATE(DATE))
    25         D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    26         F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    27         Q
    28         ;
    29         ;===============================================
    30 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    31         ;maintenance output.
    32         N DATE,JND,NOUT,TEMP,TEXTOUT
    33         S NLINES=NLINES+1
    34         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Non-VA med: "_IFIEVAL("ORDERABLE ITEM")
    35         S DATE=IFIEVAL("START DATE")
    36         S TEMP="Start Date: "_$$EDATE^PXRMDATE(DATE)
    37         S DATE=IFIEVAL("DISCONTINUED DATE")
    38         S DATE=$S(DATE="":"NONE",1:$$EDATE^PXRMDATE(DATE))
    39         S TEMP=TEMP_" Discontinued Date: "_DATE
    40         I $D(IFIEVAL("DURATION")) S TEMP=TEMP_"  Duration: "_IFIEVAL("DURATION")_" D"
    41         S TEMP=TEMP_" Status: "_IFIEVAL("STATUS")_"\\"
    42         S TEMP=TEMP_"Dosage Form: "_IFIEVAL("DOSAGE FORM")
    43         S TEMP=TEMP_" Dosage: "_IFIEVAL("DOSAGE")
    44         S TEMP=TEMP_" Medication Route: "_IFIEVAL("MEDICATION ROUTE")
    45         D FORMATS^PXRMTEXT(INDENT+1,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    46         F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    47         S NLINES=NLINES+1,TEXT(NLINES)=""
    48         Q
    49         ;
     1PXRMDNVA ; SLC/PKR - Handle non-VA med findings. ;05/24/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;===============================================
     5GETDATA(DAS,FIEVT) ;Return data for an non-VA med finding.
     6 ;DBIA #3793
     7 D NVA^PSOPXRM1(DAS,.FIEVT)
     8 S FIEVT("VALUE")=FIEVT("STATUS")
     9 I $G(FIEVT("START DATE"))="" S FIEVT("START DATE")=FIEVT("DOCUMENTED DATE")
     10 S FIEVT("DURATION")=$$DURATION^PXRMDATE(FIEVT("START DATE"),FIEVT("DISCONTINUED DATE"))
     11 Q
     12 ;
     13 ;===============================================
     14EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate terms.
     15 D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
     16 Q
     17 ;
     18 ;====================================================
     19MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     20 N JND,NOUT,TEMP,TEXTOUT
     21 S TEMP="Non-VA med: "_IFIEVAL("ORDERABLE ITEM")_" = "
     22 S TEMP=TEMP_"("_$$EDATE^PXRMDATE(IFIEVAL("START DATE"))
     23 S TEMP=TEMP_" - "_$$EDATE^PXRMDATE(IFIEVAL("STOP DATE"))_")"
     24 D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     25 F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     26 Q
     27 ;
     28 ;===============================================
     29OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     30 ;maintenance output.
     31 N DATE,JND,NOUT,TEMP,TEXTOUT
     32 S NLINES=NLINES+1
     33 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Non-VA med: "_IFIEVAL("ORDERABLE ITEM")
     34 S DATE=IFIEVAL("START DATE")
     35 S TEMP="Start Date: "_$$EDATE^PXRMDATE(DATE)
     36 S DATE=IFIEVAL("DISCONTINUED DATE")
     37 S DATE=$S(DATE="":"NONE",1:$$EDATE^PXRMDATE(DATE))
     38 S TEMP=TEMP_" Discontinued Date: "_DATE
     39 I $D(IFIEVAL("DURATION")) S TEMP=TEMP_"  Duration: "_IFIEVAL("DURATION")_" D"
     40 S TEMP=TEMP_" Status: "_IFIEVAL("STATUS")_"\\"
     41 S TEMP=TEMP_"Dosage Form: "_IFIEVAL("DOSAGE FORM")
     42 S TEMP=TEMP_" Dosage: "_IFIEVAL("DOSAGE")
     43 S TEMP=TEMP_" Medication Route: "_IFIEVAL("MEDICATION ROUTE")
     44 D FORMATS^PXRMTEXT(INDENT+1,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     45 F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     46 S NLINES=NLINES+1,TEXT(NLINES)=""
     47 Q
     48 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDRGR.m

    r613 r623  
    1 PXRMDRGR        ; SLC/PKR - Handle groups of drug findings. ;06/20/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;Groups are drug classes or VA Generic.
    4         ;==================================================
    5 EVALFI(DFN,DEFARR,ENODE,XREF,FIEVAL)    ;Evaluate drug group findings.
    6         N DRGRIEN,FIEVT,FINDPA,FINDING,NOINDEX
    7         S NOINDEX=0
    8         I $G(^PXRMINDX(52,"DATE BUILT"))="" D
    9         . D NOINDEX^PXRMERRH("D",PXRMITEM,52)
    10         . S NOINDEX=1
    11         I $G(^PXRMINDX(55,"DATE BUILT"))="" D
    12         . D NOINDEX^PXRMERRH("D",PXRMITEM,55)
    13         . S NOINDEX=1
    14         S DRGRIEN=""
    15         F  S DRGRIEN=$O(DEFARR("E",ENODE,DRGRIEN)) Q:+DRGRIEN=0  D
    16         . S FINDING=""
    17         . F  S FINDING=$O(DEFARR("E",ENODE,DRGRIEN,FINDING)) Q:+FINDING=0  D
    18         .. I NOINDEX S FIEVAL(FINDING)=0 Q
    19         .. K FIEVT,FINDPA
    20         .. M FINDPA=DEFARR(20,FINDING)
    21         .. D FIEVAL(DFN,DRGRIEN,.FINDPA,.DEFARR,FINDING,XREF,.FIEVT)
    22         .. M FIEVAL(FINDING)=FIEVT
    23         .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
    24         Q
    25         ;
    26         ;==================================================
    27 EVALPL(FINDPA,ENODE,XREF,TERMARR,PLIST) ;Evaluate drug group
    28         ;terms for building patient lists.
    29         N DRGRIEN,NOINDEX,PFINDPA
    30         N TEMP,TFINDPA,TFINDING
    31         S NOINDEX=0
    32         I $G(^PXRMINDX(52,"DATE BUILT"))="" D
    33         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
    34         . S NOINDEX=1
    35         I $G(^PXRMINDX(55,"DATE BUILT"))="" D
    36         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
    37         . S NOINDEX=1
    38         I NOINDEX Q
    39         S DRGRIEN=""
    40         F  S DRGRIEN=$O(TERMARR("E",ENODE,DRGRIEN)) Q:+DRGRIEN=0  D
    41         . S TFINDING=""
    42         . F  S TFINDING=$O(TERMARR("E",ENODE,DRGRIEN,TFINDING)) Q:+TFINDING=0  D
    43         .. K PFINDPA,TFINDPA
    44         .. M TFINDPA=TERMARR(20,TFINDING)
    45         ..;Set the finding parameters.
    46         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    47         .. D GPLIST(DRGRIEN,.PFINDPA,XREF,.PLIST)
    48         Q
    49         ;
    50         ;==================================================
    51 EVALTERM(DFN,FINDPA,ENODE,XREF,TERMARR,TFIEVAL) ;Evaluate drug
    52         ;group terms.
    53         N DRGRIEN,FIEVT,NOINDEX,PFINDPA
    54         N TEMP,TFINDPA,TFINDING
    55         S NOINDEX=0
    56         I $G(^PXRMINDX(52,"DATE BUILT"))="" D
    57         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
    58         . S NOINDEX=1
    59         I $G(^PXRMINDX(55,"DATE BUILT"))="" D
    60         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
    61         . S NOINDEX=1
    62         S DRGRIEN=""
    63         F  S DRGRIEN=$O(TERMARR("E",ENODE,DRGRIEN)) Q:+DRGRIEN=0  D
    64         . S TFINDING=""
    65         . F  S TFINDING=$O(TERMARR("E",ENODE,DRGRIEN,TFINDING)) Q:+TFINDING=0  D
    66         .. I NOINDEX S TFIEVAL(TFINDING)=0 Q
    67         .. K FIEVT,PFINDPA,TFINDPA
    68         .. M TFINDPA=TERMARR(20,TFINDING)
    69         ..;Set the finding parameters.
    70         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    71         .. D FIEVAL(DFN,DRGRIEN,.PFINDPA,.TERMARR,TFINDING,XREF,.FIEVT)
    72         .. M TFIEVAL(TFINDING)=FIEVT
    73         .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
    74         Q
    75         ;
    76         ;==================================================
    77 FIEVAL(DFN,DRGRIEN,FINDPA,DEFARR,FINDING,XREF,FIEVAL)   ;
    78         N DATE,DATEORDR,DRBEG,DREND,DRUG,DRUGIEN,IND,FIEVT,FIEVTL
    79         N NOCC,NFOUND,POI,POIBEG,POIEND,POIIEN,RXTYL
    80         N SDIR,TDATE,TIND
    81         S NOCC=$P(FINDPA(0),U,14)
    82         I NOCC="" S NOCC=1
    83         S SDIR=$S(NOCC<0:+1,1:-1)
    84         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    85         ;Determine where we search.
    86         D SRXTYL^PXRMRXTY(FINDPA(0),.RXTYL)
    87         D GETPDR(DFN,.RXTYL,.DRBEG,.DREND,.POIBEG,.POIEND)
    88         I DREND=0,POIEND=0 S FIEVAL=0 Q
    89         S (DRUGIEN,NFOUND)=0
    90         F  S DRUGIEN=+$O(^PSDRUG(XREF,DRGRIEN,DRUGIEN)) Q:DRUGIEN=0  D
    91         . I DRUGIEN'<DRBEG,DRUGIEN'>DREND S DRUG=DRUGIEN
    92         . E  S DRUG=0
    93         .;DBIA #221
    94         . S POIIEN=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
    95         . I POIIEN'<POIBEG,POIIEN'>POIEND S POI=POIIEN
    96         . E  S POI=0
    97         . K FIEVT
    98         . D DEVAL^PXRMDRUG(DFN,.FINDPA,.DEFARR,FINDING,.RXTYL,DRUG,POI,.FIEVT)
    99         . I FIEVT D
    100         .. S IND=0
    101         .. F  S IND=+$O(FIEVT(IND)) Q:IND=0  D
    102         ...;Make sure this is not already on the list
    103         ... I $$ONLIST(.FIEVTL,IND,.FIEVT) Q
    104         ... S NFOUND=NFOUND+1,FIEVTL(NFOUND,"DISPENSE DRUG")=DRUGIEN
    105         ... M FIEVTL(NFOUND)=FIEVT(IND)
    106         ... S DATEORDR(FIEVT(IND,"DATE"),NFOUND)=FIEVT(IND,"FINDING")
    107         ...;Don't keep more than NOCC occurrences on the list.
    108         ... I NFOUND>NOCC D
    109         .... S TDATE=$O(DATEORDR(""),-SDIR),TIND=$O(DATEORDR(TDATE,""))
    110         .... K FIEVTL(TIND),DATEORDR(TDATE,TIND)
    111         I NFOUND=0 S FIEVAL=0 Q
    112         ;Order by date.
    113         S DATE="",NFOUND=0
    114         F  S DATE=$O(DATEORDR(DATE),SDIR)  Q:(DATE="")!(NFOUND=NOCC)  D
    115         . S IND=0
    116         . F  S IND=$O(DATEORDR(DATE,IND)) Q:(IND="")!(NFOUND=NOCC)  D
    117         .. S NFOUND=NFOUND+1
    118         .. M FIEVAL(NFOUND)=FIEVTL(IND)
    119         ;Save the finding result.
    120         D SFRES^PXRMUTIL(SDIR,NFOUND,.FIEVAL)
    121         Q
    122         ;
    123         ;==================================================
    124 GETPDR(DFN,RXTYL,DRBEG,DREND,POIBEG,POIEND)     ;Return the beginning drug and
    125         ;ending drug for a patient.
    126         N IBEG,IEND,OBEG,OEND
    127         I $D(RXTYL("I")) D
    128         . S IBEG=+$O(^PXRMINDX(55,"PI",DFN,0))
    129         . S IEND=+$O(^PXRMINDX(55,"PI",DFN,""),-1)
    130         E  S (IBEG,IEND)=0
    131         I $D(RXTYL("O")) D
    132         . S OBEG=+$O(^PXRMINDX(52,"PI",DFN,0))
    133         . S OEND=+$O(^PXRMINDX(52,"PI",DFN,""),-1)
    134         E  S (OBEG,OEND)=0
    135         S DRBEG=$S(IBEG<OBEG:IBEG,1:OBEG)
    136         S DREND=$S(IEND>OEND:IEND,1:OEND)
    137         I $D(RXTYL("N")) D
    138         . S POIBEG=+$O(^PXRMINDX("55NVA","PI",DFN,0))
    139         . S POIEND=+$O(^PXRMINDX("55NVA","PI",DFN,""),-1)
    140         E  S (POIBEG,POIEND)=0
    141         Q
    142         ;
    143         ;==================================================
    144 GPLIST(DRGRIEN,PFINDPA,XREF,PLIST)      ;
    145         N DATE,DFN,DRUGIEN,FILENUM,IND,ITEM,NFOUND,NOCC,POI,RXTYL
    146         N TF,TEMP,TGLIST,TLIST
    147         S TGLIST="GPLIST_PXRMDRGR"
    148         K ^TMP($J,TGLIST)
    149         ;Determine where we search.
    150         D SRXTYL^PXRMRXTY(PFINDPA(0),.RXTYL)
    151         S DRUGIEN=0
    152         F  S DRUGIEN=$O(^PSDRUG(XREF,DRGRIEN,DRUGIEN)) Q:+DRUGIEN=0  D
    153         . ;DBIA #221
    154         . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
    155         . I $D(RXTYL("I")) D GPLIST^PXRMINDL(55,"IP",DRUGIEN,.PFINDPA,TGLIST)
    156         . I $D(RXTYL("N")),POI'="" D GPLIST^PXRMINDL("55NVA","IP",POI,.PFINDPA,TGLIST)
    157         . I $D(RXTYL("O")) D GPLIST^PXRMINDL(52,"IP",DRUGIEN,.PFINDPA,TGLIST)
    158         ;Return the NOCC most recent results for each DFN.
    159         S NOCC=$P(FINDPA(0),U,14)
    160         S NOCC=$S(NOCC<0:-NOCC,NOCC="":1,1:NOCC)
    161         F TF=0,1 D
    162         . S DFN=0
    163         . F  S DFN=$O(^TMP($J,TGLIST,TF,DFN)) Q:DFN=""  D
    164         .. K TLIST
    165         .. S ITEM=""
    166         .. F  S ITEM=$O(^TMP($J,TGLIST,TF,DFN,ITEM)) Q:ITEM=""  D
    167         ... S NFOUND=""
    168         ... F  S NFOUND=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND)) Q:NFOUND=""  D
    169         .... S FILENUM=""
    170         .... F  S FILENUM=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)) Q:FILENUM=""  D
    171         ..... S TEMP=^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)
    172         ..... S DATE=+$P(TEMP,U,3)
    173         ..... S TLIST(TF,DATE,ITEM,NFOUND,FILENUM)=""
    174         .. S DATE="",NFOUND=0
    175         .. F  S DATE=$O(TLIST(TF,DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
    176         ... S ITEM=""
    177         ... F  S ITEM=$O(TLIST(TF,DATE,ITEM)) Q:(ITEM="")!(NFOUND=NOCC)  D
    178         .... S IND=""
    179         .... F  S IND=$O(TLIST(TF,DATE,ITEM,IND)) Q:(IND="")!(NFOUND=NOCC)  D
    180         ..... S FILENUM=""
    181         ..... F  S FILENUM=$O(TLIST(TF,DATE,ITEM,IND,FILENUM)) Q:(FILENUM="")!(NFOUND=NOCC)  D
    182         ...... S NFOUND=NFOUND+1
    183         ...... S ^TMP($J,PLIST,TF,DFN,ITEM,NFOUND,FILENUM)=^TMP($J,TGLIST,TF,DFN,ITEM,IND,FILENUM)
    184         K ^TMP($J,TGLIST)
    185         Q
    186         ;
    187         ;==================================================
    188 ONLIST(FIEVTL,IND,FIEVT)        ;Return true if FIEVT(IND) is already on
    189         ;FIEVTL.
    190         N JND,ONLIST
    191         S (JND,ONLIST)=0
    192         F  S JND=$O(FIEVTL(JND)) Q:(ONLIST)!(JND="")  D
    193         . I FIEVTL(JND,"FILE NUMBER")'=FIEVT(IND,"FILE NUMBER") Q
    194         . I FIEVTL(JND,"DAS")'=FIEVT(IND,"DAS") Q
    195         . S ONLIST=1
    196         Q ONLIST
    197         ;
     1PXRMDRGR ; SLC/PKR - Handle groups of drug findings. ;06/12/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;Groups are drug classes or VA Generic.
     4 ;==================================================
     5EVALFI(DFN,DEFARR,ENODE,XREF,FIEVAL) ;Evaluate drug group findings.
     6 N DRGRIEN,FIEVT,FINDPA,FINDING,NOINDEX
     7 S NOINDEX=0
     8 I $G(^PXRMINDX(52,"DATE BUILT"))="" D
     9 . D NOINDEX^PXRMERRH("D",PXRMITEM,52)
     10 . S NOINDEX=1
     11 I $G(^PXRMINDX(55,"DATE BUILT"))="" D
     12 . D NOINDEX^PXRMERRH("D",PXRMITEM,55)
     13 . S NOINDEX=1
     14 S DRGRIEN=""
     15 F  S DRGRIEN=$O(DEFARR("E",ENODE,DRGRIEN)) Q:+DRGRIEN=0  D
     16 . S FINDING=""
     17 . F  S FINDING=$O(DEFARR("E",ENODE,DRGRIEN,FINDING)) Q:+FINDING=0  D
     18 .. I NOINDEX S FIEVAL(FINDING)=0 Q
     19 .. K FIEVT,FINDPA
     20 .. M FINDPA=DEFARR(20,FINDING)
     21 .. D FIEVAL(DFN,DRGRIEN,.FINDPA,.DEFARR,FINDING,XREF,.FIEVT)
     22 .. M FIEVAL(FINDING)=FIEVT
     23 .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
     24 Q
     25 ;
     26 ;==================================================
     27EVALPL(FINDPA,ENODE,XREF,TERMARR,PLIST) ;Evaluate drug group
     28 ;terms for building patient lists.
     29 N DRGRIEN,NOINDEX,PFINDPA
     30 N TEMP,TFINDPA,TFINDING
     31 S NOINDEX=0
     32 I $G(^PXRMINDX(52,"DATE BUILT"))="" D
     33 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
     34 . S NOINDEX=1
     35 I $G(^PXRMINDX(55,"DATE BUILT"))="" D
     36 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
     37 . S NOINDEX=1
     38 I NOINDEX Q
     39 S DRGRIEN=""
     40 F  S DRGRIEN=$O(TERMARR("E",ENODE,DRGRIEN)) Q:+DRGRIEN=0  D
     41 . S TFINDING=""
     42 . F  S TFINDING=$O(TERMARR("E",ENODE,DRGRIEN,TFINDING)) Q:+TFINDING=0  D
     43 .. K PFINDPA,TFINDPA
     44 .. M TFINDPA=TERMARR(20,TFINDING)
     45 ..;Set the finding parameters.
     46 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     47 .. D GPLIST(DRGRIEN,.PFINDPA,XREF,.PLIST)
     48 Q
     49 ;
     50 ;==================================================
     51EVALTERM(DFN,FINDPA,ENODE,XREF,TERMARR,TFIEVAL) ;Evaluate drug
     52 ;group terms.
     53 N DRGRIEN,FIEVT,NOINDEX,PFINDPA
     54 N TEMP,TFINDPA,TFINDING
     55 S NOINDEX=0
     56 I $G(^PXRMINDX(52,"DATE BUILT"))="" D
     57 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
     58 . S NOINDEX=1
     59 I $G(^PXRMINDX(55,"DATE BUILT"))="" D
     60 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
     61 . S NOINDEX=1
     62 S DRGRIEN=""
     63 F  S DRGRIEN=$O(TERMARR("E",ENODE,DRGRIEN)) Q:+DRGRIEN=0  D
     64 . S TFINDING=""
     65 . F  S TFINDING=$O(TERMARR("E",ENODE,DRGRIEN,TFINDING)) Q:+TFINDING=0  D
     66 .. I NOINDEX S TFIEVAL(TFINDING)=0 Q
     67 .. K FIEVT,PFINDPA,TFINDPA
     68 .. M TFINDPA=TERMARR(20,TFINDING)
     69 ..;Set the finding parameters.
     70 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     71 .. D FIEVAL(DFN,DRGRIEN,.PFINDPA,.TERMARR,TFINDING,XREF,.FIEVT)
     72 .. M TFIEVAL(TFINDING)=FIEVT
     73 .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
     74 Q
     75 ;
     76 ;==================================================
     77FIEVAL(DFN,DRGRIEN,FINDPA,DEFARR,FINDING,XREF,FIEVAL) ;
     78 N DATE,DATEORDR,DRBEG,DREND,DRUG,DRUGIEN,IND,FIEVT,FIEVTL
     79 N NOCC,NFOUND,POI,POIBEG,POIEND,POIIEN,RXTYL
     80 N SDIR,TDATE,TIND
     81 S NOCC=$P(FINDPA(0),U,14)
     82 I NOCC="" S NOCC=1
     83 S SDIR=$S(NOCC<0:+1,1:-1)
     84 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     85 ;Determine where we search.
     86 D SRXTYL^PXRMRXTY(FINDPA(0),.RXTYL)
     87 D GETPDR(DFN,.RXTYL,.DRBEG,.DREND,.POIBEG,.POIEND)
     88 I DREND=0,POIEND=0 S FIEVAL=0 Q
     89 S (DRUGIEN,NFOUND)=0
     90 F  S DRUGIEN=+$O(^PSDRUG(XREF,DRGRIEN,DRUGIEN)) Q:DRUGIEN=0  D
     91 . I DRUGIEN'<DRBEG,DRUGIEN'>DREND S DRUG=DRUGIEN
     92 . E  S DRUG=0
     93 .;DBIA #221
     94 . S POIIEN=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
     95 . I POIIEN'<POIBEG,POIIEN'>POIEND S POI=POIIEN
     96 . E  S POI=0
     97 . K FIEVT
     98 . D DEVAL^PXRMDRUG(DFN,.FINDPA,.DEFARR,FINDING,.RXTYL,DRUG,POI,.FIEVT)
     99 . I FIEVT D
     100 .. S IND=0
     101 .. F  S IND=+$O(FIEVT(IND)) Q:IND=0  D
     102 ... S NFOUND=NFOUND+1,FIEVTL(NFOUND,"DISPENSE DRUG")=DRUGIEN
     103 ... M FIEVTL(NFOUND)=FIEVT(IND)
     104 ... S DATEORDR(FIEVT(IND,"DATE"),NFOUND)=FIEVT(IND,"FINDING")
     105 ...;Don't keep more than NOCC occurrences on the list.
     106 ... I NFOUND>NOCC D
     107 .... S TDATE=$O(DATEORDR(""),-SDIR),TIND=$O(DATEORDR(TDATE,""))
     108 .... K FIEVTL(TIND),DATEORDR(TDATE,TIND)
     109 I NFOUND=0 S FIEVAL=0 Q
     110 ;Order by date.
     111 S DATE="",NFOUND=0
     112 F  S DATE=$O(DATEORDR(DATE),SDIR)  Q:(DATE="")!(NFOUND=NOCC)  D
     113 . S IND=0
     114 . F  S IND=$O(DATEORDR(DATE,IND)) Q:(IND="")!(NFOUND=NOCC)  D
     115 .. S NFOUND=NFOUND+1
     116 .. M FIEVAL(NFOUND)=FIEVTL(IND)
     117 ;Save the finding result.
     118 D SFRES^PXRMUTIL(SDIR,NFOUND,.FIEVAL)
     119 Q
     120 ;
     121 ;==================================================
     122GETPDR(DFN,RXTYL,DRBEG,DREND,POIBEG,POIEND) ;Return the beginning drug and
     123 ;ending drug for a patient.
     124 N IBEG,IEND,OBEG,OEND
     125 I $D(RXTYL("I")) D
     126 . S IBEG=+$O(^PXRMINDX(55,"PI",DFN,0))
     127 . S IEND=+$O(^PXRMINDX(55,"PI",DFN,""),-1)
     128 E  S (IBEG,IEND)=0
     129 I $D(RXTYL("O")) D
     130 . S OBEG=+$O(^PXRMINDX(52,"PI",DFN,0))
     131 . S OEND=+$O(^PXRMINDX(52,"PI",DFN,""),-1)
     132 E  S (OBEG,OEND)=0
     133 S DRBEG=$S(IBEG<OBEG:IBEG,1:OBEG)
     134 S DREND=$S(IEND>OEND:IEND,1:OEND)
     135 I $D(RXTYL("N")) D
     136 . S POIBEG=+$O(^PXRMINDX("55NVA","PI",DFN,0))
     137 . S POIEND=+$O(^PXRMINDX("55NVA","PI",DFN,""),-1)
     138 E  S (POIBEG,POIEND)=0
     139 Q
     140 ;
     141 ;==================================================
     142GPLIST(DRGRIEN,PFINDPA,XREF,PLIST) ;
     143 N DATE,DFN,DRUGIEN,FILENUM,IND,ITEM,NFOUND,NOCC,POI,RXTYL
     144 N TF,TEMP,TGLIST,TLIST
     145 S TGLIST="GPLIST_PXRMDRGR"
     146 K ^TMP($J,TGLIST)
     147 ;Determine where we search.
     148 D SRXTYL^PXRMRXTY(PFINDPA(0),.RXTYL)
     149 S DRUGIEN=0
     150 F  S DRUGIEN=$O(^PSDRUG(XREF,DRGRIEN,DRUGIEN)) Q:+DRUGIEN=0  D
     151 . ;DBIA #221
     152 . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
     153 . I $D(RXTYL("I")) D GPLIST^PXRMINDL(55,"IP",DRUGIEN,.PFINDPA,TGLIST)
     154 . I $D(RXTYL("N")),POI'="" D GPLIST^PXRMINDL("55NVA","IP",POI,.PFINDPA,TGLIST)
     155 . I $D(RXTYL("O")) D GPLIST^PXRMINDL(52,"IP",DRUGIEN,.PFINDPA,TGLIST)
     156 ;Return the NOCC most recent results for each DFN.
     157 S NOCC=$P(FINDPA(0),U,14)
     158 S NOCC=$S(NOCC<0:-NOCC,NOCC="":1,1:NOCC)
     159 F TF=0,1 D
     160 . S DFN=0
     161 . F  S DFN=$O(^TMP($J,TGLIST,TF,DFN)) Q:DFN=""  D
     162 .. K TLIST
     163 .. S ITEM=""
     164 .. F  S ITEM=$O(^TMP($J,TGLIST,TF,DFN,ITEM)) Q:ITEM=""  D
     165 ... S NFOUND=""
     166 ... F  S NFOUND=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND)) Q:NFOUND=""  D
     167 .... S FILENUM=""
     168 .... F  S FILENUM=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)) Q:FILENUM=""  D
     169 ..... S TEMP=^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)
     170 ..... S DATE=+$P(TEMP,U,3)
     171 ..... S TLIST(TF,DATE,ITEM,NFOUND,FILENUM)=""
     172 .. S DATE="",NFOUND=0
     173 .. F  S DATE=$O(TLIST(TF,DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
     174 ... S ITEM=""
     175 ... F  S ITEM=$O(TLIST(TF,DATE,ITEM)) Q:(ITEM="")!(NFOUND=NOCC)  D
     176 .... S IND=""
     177 .... F  S IND=$O(TLIST(TF,DATE,ITEM,IND)) Q:(IND="")!(NFOUND=NOCC)  D
     178 ..... S FILENUM=""
     179 ..... F  S FILENUM=$O(TLIST(TF,DATE,ITEM,IND,FILENUM)) Q:(FILENUM="")!(NFOUND=NOCC)  D
     180 ...... S NFOUND=NFOUND+1
     181 ...... S ^TMP($J,PLIST,TF,DFN,ITEM,NFOUND,FILENUM)=^TMP($J,TGLIST,TF,DFN,ITEM,IND,FILENUM)
     182 K ^TMP($J,TGLIST)
     183 Q
     184 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDRUG.m

    r613 r623  
    1 PXRMDRUG        ; SLC/PKR - Handle drug findings. ;04/23/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;===============================================
    5 DEVAL(DFN,FINDPA,DEFARR,FINDING,RXTYL,DRUG,POI,FIEVAL)  ;Evaluate a drug
    6         ;finding.
    7         I DRUG=0,POI=0 S FIEVAL=0 Q
    8         N DTERM,FIEVT
    9         ;Create the pseudo term.
    10         S DTERM(0)="DTERM",DTERM("IEN")=0
    11         I $D(RXTYL("I")),DRUG>0 D
    12         . M DTERM(20,1)=DEFARR(20,FINDING)
    13         . S $P(DTERM(20,1,0),U,1)=DRUG_";PS(55,"
    14         . S DTERM("E","PS(55,",DRUG,1)=""
    15         I $D(RXTYL("O")),DRUG>0 D
    16         . M DTERM(20,3)=DEFARR(20,FINDING)
    17         . S $P(DTERM(20,3,0),U,1)=DRUG_";PSRX("
    18         . S DTERM("E","PSRX(",DRUG,3)=""
    19         I $D(RXTYL("N")),POI>0 D
    20         . M DTERM(20,2)=DEFARR(20,FINDING)
    21         . S $P(DTERM(20,2,0),U,1)=POI_";PS(55NVA,"
    22         . S DTERM("E","PS(55NVA,",POI,2)=""
    23         K FIEVT
    24         D IEVALTER^PXRMTERM(DFN,.FINDPA,.DTERM,1,.FIEVT)
    25         M FIEVAL=FIEVT(1)
    26         I FIEVAL S FIEVAL("FINDING")=DRUG_";PSDRUG(",FIEVAL("DISPENSE DRUG")=DRUG
    27         Q
    28         ;
    29         ;===============================================
    30 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate drug findings.
    31         N DRUGIEN,DTERM,FIEVT,FINDPA,FINDING
    32         N NOINDEX,POI,RXTYL
    33         S NOINDEX=0
    34         I $G(^PXRMINDX(52,"DATE BUILT"))="" D
    35         . D NOINDEX^PXRMERRH("D",PXRMITEM,52)
    36         . S NOINDEX=1
    37         I $G(^PXRMINDX(55,"DATE BUILT"))="" D
    38         . D NOINDEX^PXRMERRH("D",PXRMITEM,55)
    39         . S NOINDEX=1
    40         S DRUGIEN=""
    41         F  S DRUGIEN=$O(DEFARR("E",ENODE,DRUGIEN)) Q:+DRUGIEN=0  D
    42         . ;DBIA #221
    43         . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
    44         . S FINDING=""
    45         . F  S FINDING=$O(DEFARR("E",ENODE,DRUGIEN,FINDING)) Q:+FINDING=0  D
    46         .. I NOINDEX S FIEVAL(FINDING)=0 Q
    47         .. M FINDPA=DEFARR(20,FINDING)
    48         .. K FIEVT,RXTYL
    49         ..;Determine where we search.
    50         .. D SRXTYL^PXRMRXTY(FINDPA(0),.RXTYL)
    51         .. D DEVAL(DFN,.FINDPA,.DEFARR,FINDING,.RXTYL,DRUGIEN,POI,.FIEVT)
    52         .. M FIEVAL(FINDING)=FIEVT
    53         Q
    54         ;
    55         ;===============================================
    56 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Evaluate drug terms for
    57         ;building patient lists.
    58         N BDT,EDT,DATE,DFN,DRUGIEN,ITEM,FILENUM,IND,LIST,NFOUND,NOCC,NOINDEX
    59         N PFINDPA,POI,RXTYL,TEMP,TF,TFINDPA,TFINDING,TGLIST,TLIST
    60         S NOINDEX=0
    61         I $G(^PXRMINDX(52,"DATE BUILT"))="" D
    62         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
    63         . S NOINDEX=1
    64         I $G(^PXRMINDX(55,"DATE BUILT"))="" D
    65         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
    66         . S NOINDEX=1
    67         I NOINDEX Q
    68         S TGLIST="EVALPL_PXRMDRUG"
    69         K ^TMP($J,TGLIST)
    70         S DRUGIEN=""
    71         F  S DRUGIEN=$O(TERMARR("E",ENODE,DRUGIEN)) Q:+DRUGIEN=0  D
    72         . ;DBIA #221
    73         . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
    74         . S TFINDING=""
    75         . F  S TFINDING=$O(TERMARR("E",ENODE,DRUGIEN,TFINDING)) Q:+TFINDING=0  D
    76         .. K PFINDPA,TFINDPA
    77         .. M TFINDPA=TERMARR(20,TFINDING)
    78         ..;Set the finding parameters.
    79         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    80         ..;Determine where we search.
    81         .. D SRXTYL^PXRMRXTY(PFINDPA(0),.RXTYL)
    82         .. I $D(RXTYL("I")) D GPLIST^PXRMINDL(55,"IP",DRUGIEN,.PFINDPA,TGLIST)
    83         .. I $D(RXTYL("N")),POI'="" D GPLIST^PXRMINDL("55NVA","IP",POI,.PFINDPA,TGLIST)
    84         .. I $D(RXTYL("O")) D GPLIST^PXRMINDL(52,"IP",DRUGIEN,.PFINDPA,TGLIST)
    85         ;Return the NOCC most recent results for each DFN.
    86         S NOCC=$P(FINDPA(0),U,14)
    87         S NOCC=$S(NOCC<0:-NOCC,NOCC="":1,1:NOCC)
    88         F TF=0,1 D
    89         . S DFN=0
    90         . F  S DFN=$O(^TMP($J,TGLIST,TF,DFN)) Q:DFN=""  D
    91         .. K TLIST
    92         .. S ITEM=""
    93         .. F  S ITEM=$O(^TMP($J,TGLIST,TF,DFN,ITEM)) Q:ITEM=""  D
    94         ... S NFOUND=""
    95         ... F  S NFOUND=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND)) Q:NFOUND=""  D
    96         .... S FILENUM=""
    97         .... F  S FILENUM=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)) Q:FILENUM=""  D
    98         ..... S TEMP=^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)
    99         ..... S DATE=+$P(TEMP,U,3)
    100         ..... S TLIST(TF,DATE,ITEM,NFOUND,FILENUM)=""
    101         .. S DATE="",NFOUND=0
    102         .. F  S DATE=$O(TLIST(TF,DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
    103         ... S ITEM=""
    104         ... F  S ITEM=$O(TLIST(TF,DATE,ITEM)) Q:(ITEM="")!(NFOUND=NOCC)  D
    105         .... S IND=""
    106         .... F  S IND=$O(TLIST(TF,DATE,ITEM,IND)) Q:(IND="")!(NFOUND=NOCC)  D
    107         ..... S FILENUM=""
    108         ..... F  S FILENUM=$O(TLIST(TF,DATE,ITEM,IND,FILENUM)) Q:(FILENUM="")!(NFOUND=NOCC)  D
    109         ...... S NFOUND=NFOUND+1
    110         ...... S ^TMP($J,PLIST,TF,DFN,ITEM,NFOUND,FILENUM)=^TMP($J,TGLIST,TF,DFN,ITEM,IND,FILENUM)
    111         K ^TMP($J,TGLIST)
    112         Q
    113         ;
    114         ;===============================================
    115 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate drug terms.
    116         N DATEORDR,DRUGIEN,DTERM,DTFIEVAL,IND,JND,NOINDEX,PFINDPA,POI
    117         N RXTYL,TEMP,TFINDING,TFINDPA
    118         N DATEORDR,NOCC,SDIR
    119         S NOINDEX=0
    120         I $G(^PXRMINDX(52,"DATE BUILT"))="" D
    121         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
    122         . S NOINDEX=1
    123         I $G(^PXRMINDX(55,"DATE BUILT"))="" D
    124         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
    125         . S NOINDEX=1
    126         ;Set NOCC and SDIR.
    127         S NOCC=$P(FINDPA(0),U,14)
    128         I NOCC="" S NOCC=1
    129         S SDIR=$S(NOCC<0:+1,1:-1)
    130         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    131         S DRUGIEN=""
    132         F  S DRUGIEN=$O(TERMARR("E",ENODE,DRUGIEN)) Q:+DRUGIEN=0  D
    133         . ;DBIA #221
    134         . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
    135         . S TFINDING=""
    136         . F  S TFINDING=$O(TERMARR("E",ENODE,DRUGIEN,TFINDING)) Q:+TFINDING=0  D
    137         .. S TFIEVAL(TFINDING)=0
    138         .. I NOINDEX Q
    139         .. K DTERM,DTFIEVAL,PFINDPA,TFINDPA
    140         .. S DTERM(0)="DTERM",DTERM("IEN")=0
    141         .. M TFINDPA=TERMARR(20,TFINDING)
    142         ..;Set the finding parameters.
    143         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    144         ..;Determine where we search.
    145         .. D SRXTYL^PXRMRXTY(PFINDPA(0),.RXTYL)
    146         .. I $D(RXTYL("I")) D
    147         ... M DTERM(20,1)=TERMARR(20,TFINDING)
    148         ... S $P(DTERM(20,1,0),U,1)=DRUGIEN_";PS(55,"
    149         ... S DTERM("E","PS(55,",DRUGIEN,1)=""
    150         .. I $D(RXTYL("N")),POI'="" D
    151         ... M DTERM(20,2)=TERMARR(20,TFINDING)
    152         ... S $P(DTERM(20,2,0),U,1)=POI_";PS(55NVA,"
    153         ... S DTERM("E","PS(55NVA,",POI,2)=""
    154         .. I $D(RXTYL("O")) D
    155         ... M DTERM(20,3)=TERMARR(20,TFINDING)
    156         ... S $P(DTERM(20,3,0),U,1)=DRUGIEN_";PSRX("
    157         ... S DTERM("E","PSRX(",DRUGIEN,3)=""
    158         .. D IEVALTER^PXRMTERM(DFN,.PFINDPA,.DTERM,TFINDING,.DTFIEVAL)
    159         .. D DORDER^PXRMTERM(.DTFIEVAL,.DATEORDR)
    160         .. D COPY^PXRMTERM(NOCC,SDIR,.DTFIEVAL,.DATEORDR,TFINDING,.TFIEVAL)
    161         ..;Save the dispense drug
    162         .. S JND=0
    163         .. F  S JND=+$O(TFIEVAL(TFINDING,JND)) Q:JND=0  S TFIEVAL(TFINDING,JND,"DISPENSE DRUG")=DRUGIEN
    164         Q
    165         ;
    166         ;===============================================
    167 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    168         N DRUG,DRUGIEN,IND,FTYPE,NAME,PFIEVAL,TEMP
    169         S DRUGIEN=IFIEVAL("DISPENSE DRUG")
    170         ;DBIA #10043
    171         S DRUG=$P(^PSDRUG(DRUGIEN,0),U,1)
    172         S NAME="Drug: "_DRUG_" = "
    173         S NLINES=NLINES+1
    174         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Drug: "_DRUG
    175         S IND=0
    176         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    177         . S TEMP=IFIEVAL(IND,"FINDING")
    178         . S FTYPE=$P(TEMP,";",2)
    179         . K PFIEVAL M PFIEVAL=IFIEVAL(IND)
    180         . S PFIEVAL("DISPENSE DRUG")=DRUG
    181         . I FTYPE="PS(55," D MHVOUT^PXRMDIN(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
    182         . I FTYPE="PS(55NVA," D MHVOUT^PXRMDNVA(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
    183         . I FTYPE="PSRX(" D MHVOUT^PXRMDOUT(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
    184         S NLINES=NLINES+1,TEXT(NLINES)=""
    185         Q
    186         ;
    187         ;===============================================
    188 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    189         ;maintenance output.
    190         N DRUG,FTYPE,IND,PFIEVAL,TEMP,TEXTOUT
    191         ;DBIA #10043
    192         S DRUG=$P(^PSDRUG(IFIEVAL("DISPENSE DRUG"),0),U,1)
    193         S NLINES=NLINES+1
    194         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Drug: "_DRUG
    195         S IND=0
    196         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    197         . S TEMP=IFIEVAL(IND,"FINDING")
    198         . S FTYPE=$P(TEMP,";",2)
    199         . K PFIEVAL M PFIEVAL=IFIEVAL(IND)
    200         . S PFIEVAL("DISPENSE DRUG")=DRUG
    201         . I FTYPE="PS(55," D OUTPUT^PXRMDIN(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
    202         . I FTYPE="PS(55NVA," D OUTPUT^PXRMDNVA(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
    203         . I FTYPE="PSRX(" D OUTPUT^PXRMDOUT(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
    204         Q
    205         ;
     1PXRMDRUG ; SLC/PKR - Handle drug findings. ;06/08/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;===============================================
     5DEVAL(DFN,FINDPA,DEFARR,FINDING,RXTYL,DRUG,POI,FIEVAL) ;Evaluate a drug
     6 ;finding.
     7 I DRUG=0,POI=0 S FIEVAL=0 Q
     8 N DTERM,FIEVT
     9 ;Create the pseudo term.
     10 S DTERM(0)="DTERM",DTERM("IEN")=0
     11 I $D(RXTYL("I")),DRUG>0 D
     12 . M DTERM(20,1)=DEFARR(20,FINDING)
     13 . S $P(DTERM(20,1,0),U,1)=DRUG_";PS(55,"
     14 . S DTERM("E","PS(55,",DRUG,1)=""
     15 I $D(RXTYL("O")),DRUG>0 D
     16 . M DTERM(20,3)=DEFARR(20,FINDING)
     17 . S $P(DTERM(20,3,0),U,1)=DRUG_";PSRX("
     18 . S DTERM("E","PSRX(",DRUG,3)=""
     19 I $D(RXTYL("N")),POI>0 D
     20 . M DTERM(20,2)=DEFARR(20,FINDING)
     21 . S $P(DTERM(20,2,0),U,1)=POI_";PS(55NVA,"
     22 . S DTERM("E","PS(55NVA,",POI,2)=""
     23 K FIEVT
     24 D IEVALTER^PXRMTERM(DFN,.FINDPA,.DTERM,1,.FIEVT)
     25 M FIEVAL=FIEVT(1)
     26 I FIEVAL S FIEVAL("FINDING")=DRUG_";PSDRUG(",FIEVAL("DISPENSE DRUG")=DRUG
     27 Q
     28 ;
     29 ;===============================================
     30EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate drug findings.
     31 N DRUGIEN,DTERM,FIEVT,FINDPA,FINDING
     32 N NOINDEX,POI,RXTYL
     33 S NOINDEX=0
     34 I $G(^PXRMINDX(52,"DATE BUILT"))="" D
     35 . D NOINDEX^PXRMERRH("D",PXRMITEM,52)
     36 . S NOINDEX=1
     37 I $G(^PXRMINDX(55,"DATE BUILT"))="" D
     38 . D NOINDEX^PXRMERRH("D",PXRMITEM,55)
     39 . S NOINDEX=1
     40 S DRUGIEN=""
     41 F  S DRUGIEN=$O(DEFARR("E",ENODE,DRUGIEN)) Q:+DRUGIEN=0  D
     42 . ;DBIA #221
     43 . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
     44 . S FINDING=""
     45 . F  S FINDING=$O(DEFARR("E",ENODE,DRUGIEN,FINDING)) Q:+FINDING=0  D
     46 .. I NOINDEX S FIEVAL(FINDING)=0 Q
     47 .. M FINDPA=DEFARR(20,FINDING)
     48 .. K FIEVT,RXTYL
     49 ..;Determine where we search.
     50 .. D SRXTYL^PXRMRXTY(FINDPA(0),.RXTYL)
     51 .. D DEVAL(DFN,.FINDPA,.DEFARR,FINDING,.RXTYL,DRUGIEN,POI,.FIEVT)
     52 .. M FIEVAL(FINDING)=FIEVT
     53 Q
     54 ;
     55 ;===============================================
     56EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate drug terms for
     57 ;building patient lists.
     58 N BDT,EDT,DATE,DFN,DRUGIEN,ITEM,FILENUM,IND,LIST,NFOUND,NOCC,NOINDEX
     59 N PFINDPA,POI,RXTYL,TEMP,TF,TFINDPA,TFINDING,TGLIST,TLIST
     60 S NOINDEX=0
     61 I $G(^PXRMINDX(52,"DATE BUILT"))="" D
     62 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
     63 . S NOINDEX=1
     64 I $G(^PXRMINDX(55,"DATE BUILT"))="" D
     65 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
     66 . S NOINDEX=1
     67 I NOINDEX Q
     68 S TGLIST="EVALPL_PXRMDRUG"
     69 K ^TMP($J,TGLIST)
     70 S DRUGIEN=""
     71 F  S DRUGIEN=$O(TERMARR("E",ENODE,DRUGIEN)) Q:+DRUGIEN=0  D
     72 . ;DBIA #221
     73 . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
     74 . S TFINDING=""
     75 . F  S TFINDING=$O(TERMARR("E",ENODE,DRUGIEN,TFINDING)) Q:+TFINDING=0  D
     76 .. K PFINDPA,TFINDPA
     77 .. M TFINDPA=TERMARR(20,TFINDING)
     78 ..;Set the finding parameters.
     79 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     80 ..;Determine where we search.
     81 .. D SRXTYL^PXRMRXTY(PFINDPA(0),.RXTYL)
     82 .. I $D(RXTYL("I")) D GPLIST^PXRMINDL(55,"IP",DRUGIEN,.PFINDPA,TGLIST)
     83 .. I $D(RXTYL("N")),POI'="" D GPLIST^PXRMINDL("55NVA","IP",POI,.PFINDPA,TGLIST)
     84 .. I $D(RXTYL("O")) D GPLIST^PXRMINDL(52,"IP",DRUGIEN,.PFINDPA,TGLIST)
     85 ;Return the NOCC most recent results for each DFN.
     86 S NOCC=$P(FINDPA(0),U,14)
     87 S NOCC=$S(NOCC<0:-NOCC,NOCC="":1,1:NOCC)
     88 F TF=0,1 D
     89 . S DFN=0
     90 . F  S DFN=$O(^TMP($J,TGLIST,TF,DFN)) Q:DFN=""  D
     91 .. K TLIST
     92 .. S ITEM=""
     93 .. F  S ITEM=$O(^TMP($J,TGLIST,TF,DFN,ITEM)) Q:ITEM=""  D
     94 ... S NFOUND=""
     95 ... F  S NFOUND=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND)) Q:NFOUND=""  D
     96 .... S FILENUM=""
     97 .... F  S FILENUM=$O(^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)) Q:FILENUM=""  D
     98 ..... S TEMP=^TMP($J,TGLIST,TF,DFN,ITEM,NFOUND,FILENUM)
     99 ..... S DATE=+$P(TEMP,U,3)
     100 ..... S TLIST(TF,DATE,ITEM,NFOUND,FILENUM)=""
     101 .. S DATE="",NFOUND=0
     102 .. F  S DATE=$O(TLIST(TF,DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
     103 ... S ITEM=""
     104 ... F  S ITEM=$O(TLIST(TF,DATE,ITEM)) Q:(ITEM="")!(NFOUND=NOCC)  D
     105 .... S IND=""
     106 .... F  S IND=$O(TLIST(TF,DATE,ITEM,IND)) Q:(IND="")!(NFOUND=NOCC)  D
     107 ..... S FILENUM=""
     108 ..... F  S FILENUM=$O(TLIST(TF,DATE,ITEM,IND,FILENUM)) Q:(FILENUM="")!(NFOUND=NOCC)  D
     109 ...... S NFOUND=NFOUND+1
     110 ...... S ^TMP($J,PLIST,TF,DFN,ITEM,NFOUND,FILENUM)=^TMP($J,TGLIST,TF,DFN,ITEM,IND,FILENUM)
     111 K ^TMP($J,TGLIST)
     112 Q
     113 ;
     114 ;===============================================
     115EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate drug terms.
     116 N DATEORDR,DRUGIEN,DTERM,DTFIEVAL,IND,NOINDEX,PFINDPA,POI
     117 N RXTYL,TEMP,TFINDING,TFINDPA
     118 N DATEORDR,NOCC,SDIR
     119 S NOINDEX=0
     120 I $G(^PXRMINDX(52,"DATE BUILT"))="" D
     121 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),52)
     122 . S NOINDEX=1
     123 I $G(^PXRMINDX(55,"DATE BUILT"))="" D
     124 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),55)
     125 . S NOINDEX=1
     126 ;Set NOCC and SDIR.
     127 S NOCC=$P(FINDPA(0),U,14)
     128 I NOCC="" S NOCC=1
     129 S SDIR=$S(NOCC<0:+1,1:-1)
     130 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     131 S DRUGIEN=""
     132 F  S DRUGIEN=$O(TERMARR("E",ENODE,DRUGIEN)) Q:+DRUGIEN=0  D
     133 . ;DBIA #221
     134 . S POI=$P($G(^PSDRUG(DRUGIEN,2)),U,1)
     135 . S TFINDING=""
     136 . F  S TFINDING=$O(TERMARR("E",ENODE,DRUGIEN,TFINDING)) Q:+TFINDING=0  D
     137 .. S TFIEVAL(TFINDING)=0
     138 .. I NOINDEX Q
     139 .. K DTERM,DTFIEVAL,PFINDPA,TFINDPA
     140 .. S DTERM(0)="DTERM",DTERM("IEN")=0
     141 .. M TFINDPA=TERMARR(20,TFINDING)
     142 ..;Set the finding parameters.
     143 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     144 ..;Determine where we search.
     145 .. D SRXTYL^PXRMRXTY(PFINDPA(0),.RXTYL)
     146 .. I $D(RXTYL("I")) D
     147 ... M DTERM(20,1)=TERMARR(20,TFINDING)
     148 ... S $P(DTERM(20,1,0),U,1)=DRUGIEN_";PS(55,"
     149 ... S DTERM("E","PS(55,",DRUGIEN,1)=""
     150 .. I $D(RXTYL("N")),POI'="" D
     151 ... M DTERM(20,2)=TERMARR(20,TFINDING)
     152 ... S $P(DTERM(20,2,0),U,1)=POI_";PS(55NVA,"
     153 ... S DTERM("E","PS(55NVA,",POI,2)=""
     154 .. I $D(RXTYL("O")) D
     155 ... M DTERM(20,3)=TERMARR(20,TFINDING)
     156 ... S $P(DTERM(20,3,0),U,1)=DRUGIEN_";PSRX("
     157 ... S DTERM("E","PSRX(",DRUGIEN,3)=""
     158 .. D IEVALTER^PXRMTERM(DFN,.PFINDPA,.DTERM,TFINDING,.DTFIEVAL)
     159 .. D DORDER^PXRMTERM(.DTFIEVAL,.DATEORDR)
     160 .. D COPY^PXRMTERM(NOCC,SDIR,.DTFIEVAL,.DATEORDR,TFINDING,.TFIEVAL)
     161 .. I TFIEVAL(TFINDING) S TFIEVAL(TFINDING,"DISPENSE DRUG")=DRUGIEN
     162 Q
     163 ;
     164 ;===============================================
     165MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     166 N DRUG,DRUGIEN,IND,FTYPE,NAME,PFIEVAL,TEMP
     167 S DRUGIEN=IFIEVAL("DISPENSE DRUG")
     168 ;DBIA #10043
     169 S DRUG=$P(^PSDRUG(DRUGIEN,0),U,1)
     170 S NAME="Drug: "_DRUG_" = "
     171 S NLINES=NLINES+1
     172 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Drug: "_DRUG
     173 S IND=0
     174 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     175 . S TEMP=IFIEVAL(IND,"FINDING")
     176 . S FTYPE=$P(TEMP,";",2)
     177 . K PFIEVAL M PFIEVAL=IFIEVAL(IND)
     178 . S PFIEVAL("DISPENSE DRUG")=DRUG
     179 . I FTYPE="PS(55," D MHVOUT^PXRMDIN(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
     180 . I FTYPE="PS(55NVA," D MHVOUT^PXRMDNVA(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
     181 . I FTYPE="PSRX(" D MHVOUT^PXRMDOUT(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
     182 S NLINES=NLINES+1,TEXT(NLINES)=""
     183 Q
     184 ;
     185 ;===============================================
     186OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     187 ;maintenance output.
     188 N DRUG,FTYPE,IND,PFIEVAL,TEMP,TEXTOUT
     189 ;DBIA #10043
     190 S DRUG=$P(^PSDRUG(IFIEVAL("DISPENSE DRUG"),0),U,1)
     191 S NLINES=NLINES+1
     192 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Drug: "_DRUG
     193 S IND=0
     194 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     195 . S TEMP=IFIEVAL(IND,"FINDING")
     196 . S FTYPE=$P(TEMP,";",2)
     197 . K PFIEVAL M PFIEVAL=IFIEVAL(IND)
     198 . S PFIEVAL("DISPENSE DRUG")=DRUG
     199 . I FTYPE="PS(55," D OUTPUT^PXRMDIN(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
     200 . I FTYPE="PS(55NVA," D OUTPUT^PXRMDNVA(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
     201 . I FTYPE="PSRX(" D OUTPUT^PXRMDOUT(INDENT+1,.PFIEVAL,.NLINES,.TEXT) Q
     202 Q
     203 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEDIT.m

    r613 r623  
    1 PXRMEDIT        ; SLC/PKR - Clinical Reminder edit driver. ;06/04/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4 EDIT(ROOT,IENN) ;Call the appropriate edit routine.
    5         ;Reminder location list
    6         I ROOT="^PXRMD(810.9," D EDIT^PXRMLLED(ROOT,IENN) Q
    7         ;
    8         ;Taxonomy
    9         I ROOT="^PXD(811.2," D EDIT^PXRMTEDT(ROOT,IENN) Q
    10         ;
    11         ;Reminder term
    12         I ROOT="^PXRMD(811.5," D EDIT^PXRMTMED(ROOT,IENN) Q
    13         ;
    14         ;Reminder definition
    15         I ROOT="^PXD(811.9," D
    16         .;Build list of finding types for finding edit
    17         . N DEF,DEF1,DEF2 D DEF^PXRMRUTL("811.902",.DEF,.DEF1,.DEF2)
    18         .;Edit reminder
    19         . D ALL^PXRMREDT(ROOT,IENN) Q
    20         Q
    21         ;
     1PXRMEDIT ; SLC/PKR - Clinical Reminder edit driver. ;05/18/2000
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4EDIT(ROOT,IENN) ;Call the appropriate edit routine.
     5 ;Taxonomy
     6 I ROOT="^PXD(811.2," D EDIT^PXRMTEDT(ROOT,IENN) Q
     7 ;
     8 ;Reminder term
     9 I ROOT="^PXRMD(811.5," D EDIT^PXRMTMED(ROOT,IENN) Q
     10 ;
     11 ;Reminder
     12 I ROOT="^PXD(811.9," D
     13 .;Build list of finding types for finding edit
     14 . N DEF,DEF1,DEF2 D DEF^PXRMRUTL("811.902",.DEF,.DEF1,.DEF2)
     15 .;Edit reminder
     16 . D ALL^PXRMREDT(ROOT,IENN) Q
     17 Q
     18 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMENOD.m

    r613 r623  
    1 PXRMENOD        ; SLC/PKR - Clinical Reminders "E" node routines. ;12/13/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;========================================================
    5 KENODE(X,DA,FILENUM)    ;Kill the enode in the finding multiple for definitions
    6         ;and terms.
    7         ;Do not execute as part of a verify fields.
    8         I $G(DIUTIL)="VERIFY FIELDS" Q
    9         N DAS,GLOBAL,IEN
    10         S IEN=$P(X,";",1)
    11         S GLOBAL=$P(X,";",2)
    12         I GLOBAL="LAB(60," D
    13         . N SUB
    14         .;DBIA #91-A
    15         . S SUB=$P(^LAB(60,IEN,0),U,4)
    16         . I SUB="CH" Q
    17         . I (SUB="BB")!(SUB="WK") S IEN="" Q
    18         . I SUB="MI" S IEN="M;T;"_IEN Q
    19         .;All other SUB values: AU, CY, EM, SP
    20         . S IEN="A;T;"_IEN
    21         S DAS=IEN
    22         I DAS="" Q
    23         I FILENUM=811.5 K ^PXRMD(811.5,DA(1),20,"E",GLOBAL,DAS,DA)
    24         I FILENUM=811.9 K ^PXD(811.9,DA(1),20,"E",GLOBAL,DAS,DA)
    25         Q
    26         ;
    27         ;========================================================
    28 SENODE(X,DA,FILENUM)    ;Set the enode in the finding multiple for definitions
    29         ;and terms.
    30         ;Do not execute as part of a verify fields.
    31         I $G(DIUTIL)="VERIFY FIELDS" Q
    32         N DAS,GLOBAL,IEN,NAME
    33         S IEN=$P(X,";",1)
    34         S GLOBAL=$P(X,";",2)
    35         I GLOBAL="LAB(60," D
    36         . N SUB
    37         .;DBIA #91-A
    38         . S SUB=$P(^LAB(60,IEN,0),U,4)
    39         . I SUB="CH" Q
    40         . I (SUB="BB")!(SUB="WK") S IEN="" Q
    41         . I SUB="MI" S IEN="M;T;"_IEN Q
    42         .;All other SUB values: AU, CY, EM, SP
    43         . S IEN="A;T;"_IEN
    44         S DAS=IEN
    45         I DAS="" Q
    46         S NAME=""
    47         I FILENUM=811.5 S ^PXRMD(811.5,DA(1),20,"E",GLOBAL,DAS,DA)=NAME
    48         I FILENUM=811.9 S ^PXD(811.9,DA(1),20,"E",GLOBAL,DAS,DA)=NAME
    49         Q
    50         ;
     1PXRMENOD ; SLC/PKR - Clinical Reminders "E" node routines. ;04/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;========================================================
     5KENODE(X,DA,FILENUM) ;Kill the enode in the finding multiple for definitions
     6 ;and terms.
     7 ;Do not execute as part of a verify fields.
     8 I $G(DIUTIL)="VERIFY FIELDS" Q
     9 N DAS,GLOBAL,IEN
     10 S IEN=$P(X,";",1)
     11 S GLOBAL=$P(X,";",2)
     12 I GLOBAL="LAB(60," D
     13 . N SUB
     14 .;DBIA #91-A
     15 . S SUB=$P(^LAB(60,IEN,0),U,4)
     16 . I SUB="CH" Q
     17 . I (SUB="BB")!(SUB="WK") S IEN="" Q
     18 . I SUB="MI" S IEN="M;T;"_IEN Q
     19 .;All other SUB values: AU, CY, EM, SP
     20 . S IEN="A;T;"_IEN
     21 S DAS=IEN
     22 I DAS="" Q
     23 I FILENUM=811.5 K ^PXRMD(811.5,DA(1),20,"E",GLOBAL,DAS,DA)
     24 I FILENUM=811.9 K ^PXD(811.9,DA(1),20,"E",GLOBAL,DAS,DA)
     25 Q
     26 ;
     27 ;========================================================
     28SENODE(X,DA,FILENUM) ;Set the enode in the finding multiple for definitions
     29 ;and terms.
     30 ;Do not execute as part of a verify fields.
     31 I $G(DIUTIL)="VERIFY FIELDS" Q
     32 N DAS,GLOBAL,IEN
     33 S IEN=$P(X,";",1)
     34 S GLOBAL=$P(X,";",2)
     35 I GLOBAL="LAB(60," D
     36 . N SUB
     37 .;DBIA #91-A
     38 . S SUB=$P(^LAB(60,IEN,0),U,4)
     39 . I SUB="CH" Q
     40 . I (SUB="BB")!(SUB="WK") S IEN="" Q
     41 . I SUB="MI" S IEN="M;T;"_IEN Q
     42 .;All other SUB values: AU, CY, EM, SP
     43 . S IEN="A;T;"_IEN
     44 S DAS=IEN
     45 I DAS="" Q
     46 I FILENUM=811.5 S ^PXRMD(811.5,DA(1),20,"E",GLOBAL,DAS,DA)=""
     47 I FILENUM=811.9 S ^PXD(811.9,DA(1),20,"E",GLOBAL,DAS,DA)=""
     48 Q
     49 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEPM.m

    r613 r623  
    1 PXRMEPM ; SLC/PKR/PJH - Extract Definition Management ;07/17/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM EXTRACT DEFINITIONS
    5 START   N PXRMDONE,VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    6         S X="IORESET"
    7         D ENDR^%ZISS
    8         S VALMCNT=0
    9         D EN^VALM("PXRM EXTRACT DEFINITIONS")
    10         Q
    11         ;
    12 BLDLIST ;Build workfile
    13         K ^TMP("PXRMEPM",$J)
    14         N IEN,IND,PLIST
    15         D LIST^PXRMETM("PXRMEPM",.VALMCNT)
    16         Q
    17         ;
    18 ENTRY   ;Entry code
    19         D BLDLIST,XQORM
    20         Q
    21         ;
    22 EXIT    ;Exit code
    23         K ^TMP("PXRMEPM",$J)
    24         K ^TMP("PXRMEPMH",$J)
    25         D CLEAN^VALM10
    26         D FULL^VALM1
    27         S VALMBCK="Q"
    28         Q
    29         ;
    30 HDR     ; Header code
    31         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    32         Q
    33         ;
    34 HLP     ;Help code
    35         N ORU,ORUPRMT,SUB,XQORM
    36         S SUB="PXRMEPMH"
    37         D EN^VALM("PXRM EXTRACT HELP")
    38         Q
    39         ;
    40 INIT    ;Init
    41         S VALMCNT=0
    42         Q
    43         ;
    44 PEXIT   ;PXRM EXCH MENU protocol exit code
    45         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    46         ;Reset after page up/down etc
    47         D XQORM
    48         Q
    49         ;
    50 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT DEFINITION SELECT ENTRY",0))_U_"1:"_VALMCNT
    51         S XQORM("A")="Select Item: "
    52         Q
    53         ;
    54 XSEL    ;PXRM EXTRACT DEFINITION SELECT ENTRY validation
    55         N SEL,IEN
    56         S SEL=$P(XQORNOD(0),"=",2)
    57         ;Remove trailing ,
    58         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    59         ;Invalid selection
    60         I SEL["," D  Q
    61         .W $C(7),!,"Only one item number allowed." H 2
    62         .S VALMBCK="R"
    63         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    64         .W $C(7),!,SEL_" is not a valid item number." H 2
    65         .S VALMBCK="R"
    66         ;
    67         ;Get the list ien.
    68         S IEN=^TMP("PXRMEPM",$J,"SEL",SEL)
    69         ;Display/Edit Extract Definition
    70         D START^PXRMEPED(IEN)
    71         D BLDLIST
    72         S VALMBCK="R"
    73         Q
    74         ;
    75 HELP(CALL)      ;General help text routine
    76         N HTEXT
    77         I CALL=1 D
    78         .S HTEXT(1)="Select DE to display or edit a definition."
    79         .S HTEXT(2)="Select ED to edit a definition"
    80         D HELP^PXRMEUT(.HTEXT)
    81         Q
    82         ;
    83 EPADD   ;Add Rule Option
    84         ;Reset Screen Mode
    85         W IORESET
    86         ;
    87         ;Add Rule
    88         D ADD^PXRMEPED
    89         ;
    90         ;Rebuild Workfile
    91         D BLDLIST
    92         S VALMBCK="R"
    93         Q
    94         ;
    95 EPINQ   ;Definition Inquiry - PXRM EXTRACT DEFINITION DISPLAY/EDIT entry
    96         N IND,LRIEN,VALMY
    97         D EN^VALM2(XQORNOD(0))
    98         ;
    99         ;If there is no list quit.
    100         I '$D(VALMY) Q
    101         S PXRMDONE=0
    102         S IND=""
    103         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    104         .;Get the ien.
    105         .S LRIEN=^TMP("PXRMEPM",$J,"SEL",IND)
    106         .D START^PXRMEPED(LRIEN)
    107         D BLDLIST
    108         S VALMBCK="R"
    109         Q
    110         ;
    111 PPLR    ;Display rule set components
    112         ;used by [PXRM EXTRACT DEFINITION] template)
    113         N ACT,DATA,FIRST,IEN,LRDATA,LRIEN,SEQ,SUB
    114         S IEN=$P(X,U,2) Q:'IEN
    115         W !," Description: ",$P($G(^PXRM(810.4,IEN,0)),U,2)
    116         S SEQ="",FIRST=1
    117         F  S SEQ=$O(^PXRM(810.4,IEN,30,"B",SEQ)) Q:'SEQ  D
    118         .S SUB=$O(^PXRM(810.4,IEN,30,"B",SEQ,"")) Q:'SUB
    119         .S DATA=$G(^PXRM(810.4,IEN,30,SUB,0)) Q:DATA=""
    120         .S LRIEN=$P(DATA,U,2) Q:LRIEN=""
    121         .S ACT=$P(DATA,U,3),LRDATA=$G(^PXRM(810.4,LRIEN,0))
    122         .I FIRST W !!,?2,"List Rules:" S FIRST=0
    123         .W !,?2,SEQ,?7,$P(LRDATA,U),?66
    124         .W $S(ACT="A":"ADD PATIENT",ACT="R":"REMOVE PATIENT",ACT="F":"INSERT FINDING",1:"SELECT PATIENT")
    125         .;Display List Rule fields
    126         .D LROUT^PXRMLRED(LRIEN,23)
    127         .W !
    128         Q
    129         ;
    130 PPFR    ;Display counting rules and count type
    131         ;used by [PXRM EXTRACT DEFINITION] template)
    132         W !
    133         N DATA,GIEN,GSTATUS,IEN,SEQ,SUB
    134         S IEN=$P(X,U,3) Q:'IEN
    135         S SEQ=""
    136         F  S SEQ=$O(^PXRM(810.7,IEN,10,"B",SEQ)) Q:SEQ=""  D
    137         .S SUB=$O(^PXRM(810.7,IEN,10,"B",SEQ,"")) Q:'SUB
    138         .S DATA=$G(^PXRM(810.7,IEN,10,SUB,0)) Q:DATA=""
    139         .S GIEN=$P(DATA,U,2) Q:GIEN=""
    140         .S GSTATUS=$P(DATA,U,3)
    141         .;Get counting groups
    142         .N CTYP,CTXT,DATA,EXCL,FIRST,GNAME,PNAME,TIEN,TNAME,GSEQ,GSUB
    143         .S DATA=$G(^PXRM(810.8,GIEN,0)),GNAME=$P(DATA,U)
    144         .S CTYP=$P(DATA,U,3),PNAME=$P(DATA,U,2),GSEQ="",FIRST=1
    145         .S CTXT=$$TXT(CTYP,GSTATUS)
    146         .F  S GSEQ=$O(^PXRM(810.8,GIEN,10,"B",GSEQ)) Q:GSEQ=""  D
    147         ..S GSUB=$O(^PXRM(810.8,GIEN,10,"B",GSEQ,"")) Q:'GSUB
    148         ..S DATA=$G(^PXRM(810.8,GIEN,10,GSUB,0)) Q:DATA=""
    149         ..S TIEN=$P(DATA,U,2) Q:TIEN=""
    150         ..S EXCL=$P(DATA,U,3) Q:EXCL="E"
    151         ..S TNAME=$P($G(^PXRMD(811.5,TIEN,0)),U)
    152         ..I FIRST D
    153         ...W !,?14,SEQ
    154         ...W ?18,"Counting Group: ",GNAME
    155         ...W !,?18,$$TXT(CTYP,GSTATUS)
    156         ...W !,?23,"Terms:" S FIRST=0
    157         ..W ?30,TNAME,!
    158         Q
    159         ;
    160 SCREEN  ;Screen for 810.210 field .02
    161         S DIC("S")="I $P(^(0),U,3)=3"
    162         Q
    163         ;
    164 TXT(COUNT,COHORT)       ;Text to describe group
    165         N TXT
    166         ;Determine count type
    167         I COUNT="MRFP" S TXT="Most recent finding patient counts for "
    168         I COUNT="MRF" S TXT="Most recent finding counts for "
    169         I COUNT="UR" S TXT="Utilization in period finding counts for "
    170         ;Error
    171         I $G(TXT)="" Q "Unknown count type - error"
    172         ;Determine cohort
    173         S TXT=TXT_$S(COHORT="A":"APPLICABLE",1:"TOTAL")_" patients"
    174         Q TXT
     1PXRMEPM ; SLC/PKR/PJH - Extract Definition Management ;06/21/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM EXTRACT DEFINITIONS
     5START N PXRMDONE,VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     6 S X="IORESET"
     7 D ENDR^%ZISS
     8 S VALMCNT=0
     9 D EN^VALM("PXRM EXTRACT DEFINITIONS")
     10 Q
     11 ;
     12BLDLIST ;Build workfile
     13 K ^TMP("PXRMEPM",$J)
     14 N IEN,IND,PLIST
     15 D LIST^PXRMETM(.PLIST,.IEN)
     16 M ^TMP("PXRMEPM",$J)=PLIST
     17 S VALMCNT=PLIST("VALMCNT")
     18 F IND=1:1:VALMCNT D
     19 .S ^TMP("PXRMEPM",$J,"IDX",IND,IND)=IEN(IND)
     20 Q
     21 ;
     22ENTRY ;Entry code
     23 D BLDLIST,XQORM
     24 Q
     25 ;
     26EXIT ;Exit code
     27 K ^TMP("PXRMEPM",$J)
     28 K ^TMP("PXRMEPMH",$J)
     29 D CLEAN^VALM10
     30 D FULL^VALM1
     31 S VALMBCK="Q"
     32 Q
     33 ;
     34HDR ; Header code
     35 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     36 Q
     37 ;
     38HLP ;Help code
     39 N ORU,ORUPRMT,SUB,XQORM
     40 S SUB="PXRMEPMH"
     41 D EN^VALM("PXRM EXTRACT HELP")
     42 Q
     43 ;
     44INIT ;Init
     45 S VALMCNT=0
     46 Q
     47 ;
     48PEXIT ;PXRM EXCH MENU protocol exit code
     49 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     50 ;Reset after page up/down etc
     51 D XQORM
     52 Q
     53 ;
     54XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT DEFINITION SELECT ENTRY",0))_U_"1:"_VALMCNT
     55 S XQORM("A")="Select Item: "
     56 Q
     57 ;
     58XSEL ;PXRM EXTRACT DEFINITION SELECT ENTRY validation
     59 N SEL,IEN
     60 S SEL=$P(XQORNOD(0),"=",2)
     61 ;Remove trailing ,
     62 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     63 ;Invalid selection
     64 I SEL["," D  Q
     65 .W $C(7),!,"Only one item number allowed." H 2
     66 .S VALMBCK="R"
     67 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     68 .W $C(7),!,SEL_" is not a valid item number." H 2
     69 .S VALMBCK="R"
     70 ;
     71 ;Get the list ien.
     72 S IEN=^TMP("PXRMEPM",$J,"IDX",SEL,SEL)
     73 ;Display/Edit Extract Definition
     74 D START^PXRMEPED(IEN)
     75 D BLDLIST
     76 S VALMBCK="R"
     77 Q
     78 ;
     79HELP(CALL) ;General help text routine
     80 N HTEXT
     81 I CALL=1 D
     82 .S HTEXT(1)="Select DE to display or edit a definition."
     83 .S HTEXT(2)="Select ED to edit a definition"
     84 D HELP^PXRMEUT(.HTEXT)
     85 Q
     86 ;
     87EPADD ;Add Rule Option
     88 ;
     89 ;Reset Screen Mode
     90 W IORESET
     91 ;
     92 ;Add Rule
     93 D ADD^PXRMEPED
     94 ;
     95 ;Rebuild Workfile
     96 D BLDLIST
     97 ;
     98 S VALMBCK="R"
     99 Q
     100 ;
     101EPINQ ;Definition Inquiry - PXRM EXTRACT DEFINITION DISPLAY/EDIT entry
     102 N IND,LRIEN,VALMY
     103 D EN^VALM2(XQORNOD(0))
     104 ;
     105 ;If there is no list quit.
     106 I '$D(VALMY) Q
     107 S PXRMDONE=0
     108 S IND=""
     109 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     110 .;Get the ien.
     111 .S LRIEN=^TMP("PXRMEPM",$J,"IDX",IND,IND)
     112 .D START^PXRMEPED(LRIEN)
     113 D BLDLIST
     114 S VALMBCK="R"
     115 Q
     116 ;
     117PPLR ;Display rule set components
     118 ;used by [PXRM EXTRACT DEFINITION] template)
     119 N ACT,DATA,FIRST,IEN,LRDATA,LRIEN,SEQ,SUB
     120 S IEN=$P(X,U,2) Q:'IEN
     121 W !," Description: ",$P($G(^PXRM(810.4,IEN,0)),U,2)
     122 S SEQ="",FIRST=1
     123 F  S SEQ=$O(^PXRM(810.4,IEN,30,"B",SEQ)) Q:'SEQ  D
     124 .S SUB=$O(^PXRM(810.4,IEN,30,"B",SEQ,"")) Q:'SUB
     125 .S DATA=$G(^PXRM(810.4,IEN,30,SUB,0)) Q:DATA=""
     126 .S LRIEN=$P(DATA,U,2) Q:LRIEN=""
     127 .S ACT=$P(DATA,U,3),LRDATA=$G(^PXRM(810.4,LRIEN,0))
     128 .I FIRST W !!,?2,"List Rules:" S FIRST=0
     129 .W !,?2,SEQ,?7,$P(LRDATA,U),?66
     130 .W $S(ACT="A":"ADD PATIENT",ACT="R":"REMOVE PATIENT",ACT="F":"INSERT FINDING",1:"SELECT PATIENT")
     131 .;Display List Rule fields
     132 .D LROUT^PXRMLRED(LRIEN,23)
     133 .W !
     134 Q
     135 ;
     136PPFR ;Display counting rules and count type
     137 ;used by [PXRM EXTRACT DEFINITION] template)
     138 W !
     139 N DATA,GIEN,GSTATUS,IEN,SEQ,SUB
     140 S IEN=$P(X,U,3) Q:'IEN
     141 S SEQ=""
     142 F  S SEQ=$O(^PXRM(810.7,IEN,10,"B",SEQ)) Q:SEQ=""  D
     143 .S SUB=$O(^PXRM(810.7,IEN,10,"B",SEQ,"")) Q:'SUB
     144 .S DATA=$G(^PXRM(810.7,IEN,10,SUB,0)) Q:DATA=""
     145 .S GIEN=$P(DATA,U,2) Q:GIEN=""
     146 .S GSTATUS=$P(DATA,U,3)
     147 .;Get counting groups
     148 .N CTYP,CTXT,DATA,EXCL,FIRST,GNAME,PNAME,TIEN,TNAME,GSEQ,GSUB
     149 .S DATA=$G(^PXRM(810.8,GIEN,0)),GNAME=$P(DATA,U)
     150 .S CTYP=$P(DATA,U,3),PNAME=$P(DATA,U,2),GSEQ="",FIRST=1
     151 .S CTXT=$$TXT(CTYP,GSTATUS)
     152 .F  S GSEQ=$O(^PXRM(810.8,GIEN,10,"B",GSEQ)) Q:GSEQ=""  D
     153 ..S GSUB=$O(^PXRM(810.8,GIEN,10,"B",GSEQ,"")) Q:'GSUB
     154 ..S DATA=$G(^PXRM(810.8,GIEN,10,GSUB,0)) Q:DATA=""
     155 ..S TIEN=$P(DATA,U,2) Q:TIEN=""
     156 ..S EXCL=$P(DATA,U,3) Q:EXCL="E"
     157 ..S TNAME=$P($G(^PXRMD(811.5,TIEN,0)),U)
     158 ..I FIRST D
     159 ...W !,?14,SEQ
     160 ...W ?18,"Counting Group: ",GNAME
     161 ...W !,?18,$$TXT(CTYP,GSTATUS)
     162 ...W !,?23,"Terms:" S FIRST=0
     163 ..W ?30,TNAME,!
     164 Q
     165 ;
     166SCREEN ;Screen for 810.210 field .02
     167 S DIC("S")="I $P(^(0),U,3)=3"
     168 Q
     169 ;
     170TXT(COUNT,COHORT) ;Text to describe group
     171 N TXT
     172 ;Determine count type
     173 I COUNT="MRFP" S TXT="Most recent finding patient counts for "
     174 I COUNT="MRF" S TXT="Most recent finding counts for "
     175 I COUNT="UR" S TXT="Utilization in period finding counts for "
     176 ;Error
     177 I $G(TXT)="" Q "Unknown count type - error"
     178 ;Determine cohort
     179 S TXT=TXT_$S(COHORT="A":"APPLICABLE",1:"TOTAL")_" patients"
     180 Q TXT
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETCO.m

    r613 r623  
    1 PXRMETCO        ; SLC/PJH - QUERI Extract Compliance Report ;03/27/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;
    5 ADHOC(IEN,PXRMSTRT,PXRMSTOP)    ;Ad Hoc Conformance Report
    6         D DUMMY1^PXRMRUTL
    7         Q
    8         ;
    9         D JOB
    10         Q
    11         ;
    12         ;BOOKMARK - cloned from PXRMETX, needs modifying to avoid patient list
    13         ;update. Build ^TMP("PXRMETX",$J) for report
    14         ;
    15 REPORT  ;Initialise
    16         K ^TMP("PXRMETX",$J)
    17         ;Workfile node for ^TMP
    18         S PXRMNODE="PXRMRULE"
    19         ;Get details from parameter file
    20         N DATA,DATES,LIST,NAME,PARTYPE,TEXT
    21         ;N PERIOD,TEXT,YEAR
    22         S DATA=$G(^PXRM(810.2,IEN,0))
    23         ;
    24         ;Determine Extract Name and period
    25         S NAME=$P(DATA,U),PARTYPE=$P(DATA,U,2)
    26         ;S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/")
    27         ;Calculate report period start and end dates
    28         ;D CALC^PXRMEUT(NEXT,.PXRMSTRT,.PXRMSTOP)
    29         ;Determine output name for patient list and extract summary
    30         S DATES=$$FMTE^XLFDT(PXRMSTRT)_" - "_$$FMTE^XLFDT(PXRMSTOP)
    31         ;
    32         ;Bookmark - Needs inventive patient list names
    33         S LIST=NAME_" REPORT "_DATES
    34         ;Process (single) Denominator rule into patient list
    35         N INDP,INTP,SEQ,SUB,SUFFIX
    36         S SEQ=""
    37         F  S SEQ=$O(^PXRM(810.2,IEN,10,"B",SEQ)) Q:'SEQ  D
    38         .S SUB=$O(^PXRM(810.2,IEN,10,"B",SEQ,"")) Q:'SUB
    39         .S DATA=$G(^PXRM(810.2,IEN,10,SUB,0)) Q:DATA=""
    40         .S PXRMRULE=$P(DATA,U,2) Q:'PXRMRULE
    41         .S SUFFIX=$P(DATA,U,3)
    42         .I SUFFIX="" S SUFFIX="DENOMINATOR "_SEQ
    43         .S INDP=+$P(DATA,U,4)
    44         .S INTP=+$P(DATA,U,5)
    45         .;Create new patient list
    46         .S PXRMLIST=$$CRLST^PXRMRUL1(LIST_" "_SUFFIX) Q:'PXRMLIST
    47         .D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,PXRMSTRT,PXRMSTOP,IEN,INDP,INTP)
    48         .;Clear ^TMP lists created for rule
    49         .D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
    50         .;Process reminders
    51         .D REM^PXRMETXR(SUB,PXRMLIST)
    52         ;
    53         ;Bookmark - Report stuff goes here
    54         ;Update totals section
    55         N APPL,DUE,DATA,ETYP,EVAL
    56         N FAPPL,FCNT,FDATA,FDUE,FEVAL,FGNAM,FIND,FNAPPL,FNDUE,FSEQ
    57         N NAPPL,NDUE,PXRMLIST,RCNT,RIEN,RSEQ,SEQ
    58         S SEQ=0,CNT=1
    59         F  S SEQ=$O(^TMP("PXRMETX",$J,SEQ)) Q:'SEQ  D
    60         .S RCNT=0,RSEQ=0
    61         .F  S RCNT=$O(^TMP("PXRMETX",$J,SEQ,RCNT)) Q:'RCNT  D
    62         ..S DATA=$G(^TMP("PXRMETX",$J,SEQ,RCNT)) Q:'DATA
    63         ..S RIEN=$P(DATA,U),PXRMLIST=$P(DATA,U,5)
    64         ..S EVAL=$P(DATA,U,2),APPL=$P(DATA,U,3),DUE=$P(DATA,U,4)
    65         ..S NAPPL=EVAL-APPL,NDUE=APPL-DUE
    66         ..S CNT=CNT+1,RSEQ=RSEQ+1
    67         ..;bookmark - write patient line
    68         ..;For each count type
    69         ..S ETYP="",FCNT=CNT
    70         ..F  S ETYP=$O(^TMP("PXRMETX",$J,SEQ,RCNT,ETYP)) Q:ETYP=""  D
    71         ...;For each term
    72         ...S FIND=0,FSEQ=0
    73         ...F  S FIND=$O(^TMP("PXRMETX",$J,SEQ,RCNT,ETYP,FIND)) Q:FIND=""  D
    74         ....;Update finding totals
    75         ....S FDATA=$G(^TMP("PXRMETX",$J,SEQ,RCNT,ETYP,FIND)),FCNT=FCNT+1
    76         ....S FEVAL=$P(FDATA,U,2),FAPPL=$P(FDATA,U,3),FDUE=$P(FDATA,U,4)
    77         ....S FNAPPL=FEVAL-FAPPL,FNDUE=FAPPL-FDUE
    78         ....S FSEQ=FSEQ+1,FGNAM=$P(DATA,U,9)
    79         ....;Bookmark - write finding line
    80         ..;Update CNT
    81         ..S CNT=FCNT
    82         Q
    83         ;
    84         ;Determine whether the report should be queued.
    85 JOB     ;
    86         N %ZIS,ZTDESC,ZTSAVE,ZTRTN,ZTSK
    87         S DBDUZ=DUZ
    88         D SAVE^PXRMXQUE
    89         S %ZIS="Q"
    90         S ZTDESC="QUERI Compliance Report - print"
    91         S ZTRTN="REPORT^PXRMETCO"
    92         S ZTSK=1
    93         S PXRMQUE=0
    94         S PXRMQUE=$$DEVICE^PXRMXQUE(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS,.ZTSK)
    95         I PXRMQUE=1 G EXIT
    96         I PXRMQUE>0 S ^XTMP(PXRMXTMP,"PRZTSK")=PXRMQUE
    97         Q
    98         ;
    99 EXIT    ;Clean things up.
    100         D ^%ZISC
    101         D HOME^%ZIS
    102         K IO("Q")
    103         K DIRUT,DTOUT,DUOUT,POP,ZTREQ
    104         I $D(ZTSK) D KILL^%ZTLOAD
    105         K ZTSK,ZTQUEUED
    106         K ^TMP("PXRMXTR",$J)
    107         Q
    108         ;
    109 SAVE    ;Save the variables for queing.
    110         S ZTSAVE("IEN")=""
    111         S ZTSAVE("PXRMSTRT")=""
    112         S ZTSAVE("PXRMSTOP")=""
    113         Q
    114         ;
    115         ;
    116 QUE     ;BOOKMARK - NOT USED
    117         ;Queue the MST synchronization job.
    118         N DIR,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
    119         S MINDT=$$NOW^XLFDT
    120         W !,"Queue the Clinical Reminders MST synchronization."
    121         S DIR("A",1)="Enter the date and time you want the job to start."
    122         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    123         S DIR("A")="Start the task at: "
    124         S DIR(0)="DAU"_U_MINDT_"::RSX"
    125         D ^DIR
    126         I $D(DTOUT)!$D(DUOUT) Q
    127         S SDTIME=Y
    128         K DIR
    129         S DIR(0)="YA"
    130         S DIR("A")="Do you want to run the MST synchronization at the same time every day? "
    131         S DIR("B")="Y"
    132         D ^DIR
    133         I $D(DTOUT)!$D(DUOUT) Q
    134         I Y S STIME="1."_$P(SDTIME,".",2)
    135         E  S STIME=-1
    136         ;
    137         ;Put the task into the queue.
    138         K ZTSAVE
    139         ;S ZTSAVE("START")=SDTIME
    140         S ZTSAVE("STIME")=STIME
    141         S ZTRTN="SYNCH^PXRMMST"
    142         S ZTDESC="Clinical Reminders MST synchronization job"
    143         S ZTDTH=SDTIME
    144         S ZTIO=""
    145         D ^%ZTLOAD
    146         W !,"Task number ",ZTSK," queued."
    147         Q
     1PXRMETCO ; SLC/PJH - QUERI Extract Compliance Report ;01/19/2005
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;
     5ADHOC(IEN,PXRMSTRT,PXRMSTOP) ;Ad Hoc Conformance Report
     6 D DUMMY1^PXRMRUTL
     7 Q
     8 ;
     9 D JOB
     10 Q
     11 ;
     12 ;BOOKMARK - cloned from PXRMETX, needs modifying to avoid patient list
     13 ;update. Build ^TMP("PXRMETX",$J) for report
     14 ;
     15REPORT ;Initialise
     16 K ^TMP("PXRMETX",$J)
     17 ;Workfile node for ^TMP
     18 S PXRMNODE="PXRMRULE"
     19 ;Get details from parameter file
     20 N DATA,DATES,LIST,NAME,PARTYPE,TEXT
     21 ;N PERIOD,TEXT,YEAR
     22 S DATA=$G(^PXRM(810.2,IEN,0))
     23 ;
     24 ;Determine Extract Name and period
     25 S NAME=$P(DATA,U),PARTYPE=$P(DATA,U,2)
     26 ;S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/")
     27 ;Calculate report period start and end dates
     28 ;D CALC^PXRMEUT(NEXT,.PXRMSTRT,.PXRMSTOP)
     29 ;Determine output name for patient list and extract summary
     30 S DATES=$$FMTE^XLFDT(PXRMSTRT)_" - "_$$FMTE^XLFDT(PXRMSTOP)
     31 ;
     32 ;Bookmark - Needs inventive patient list names
     33 S LIST=NAME_" REPORT "_DATES
     34 ;Process (single) Denominator rule into patient list
     35 N SEQ,SUB,SUFFIX
     36 S SEQ=""
     37 F  S SEQ=$O(^PXRM(810.2,IEN,10,"B",SEQ)) Q:'SEQ  D
     38 .S SUB=$O(^PXRM(810.2,IEN,10,"B",SEQ,"")) Q:'SUB
     39 .S DATA=$G(^PXRM(810.2,IEN,10,SUB,0)) Q:DATA=""
     40 .S PXRMRULE=$P(DATA,U,2) Q:'PXRMRULE
     41 .S SUFFIX=$P(DATA,U,3)
     42 .I SUFFIX="" S SUFFIX="DENOMINATOR "_SEQ
     43 .;Create new patient list
     44 .S PXRMLIST=$$CRLST^PXRMRULE(LIST_" "_SUFFIX) Q:'PXRMLIST
     45 .D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,PXRMSTRT,PXRMSTOP,IEN,"","")
     46 .;Clear ^TMP lists created for rule
     47 .D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
     48 .;Process reminders
     49 .D REM^PXRMETXR(SUB,PXRMLIST)
     50 ;
     51 ;Bookmark - Report stuff goes here
     52 ;Update totals section
     53 N APPL,DUE,DATA,ETYP,EVAL
     54 N FAPPL,FCNT,FDATA,FDUE,FEVAL,FGNAM,FIND,FNAPPL,FNDUE,FSEQ
     55 N NAPPL,NDUE,PXRMLIST,RCNT,RIEN,RSEQ,SEQ
     56 S SEQ=0,CNT=1
     57 F  S SEQ=$O(^TMP("PXRMETX",$J,SEQ)) Q:'SEQ  D
     58 .S RCNT=0,RSEQ=0
     59 .F  S RCNT=$O(^TMP("PXRMETX",$J,SEQ,RCNT)) Q:'RCNT  D
     60 ..S DATA=$G(^TMP("PXRMETX",$J,SEQ,RCNT)) Q:'DATA
     61 ..S RIEN=$P(DATA,U),PXRMLIST=$P(DATA,U,5)
     62 ..S EVAL=$P(DATA,U,2),APPL=$P(DATA,U,3),DUE=$P(DATA,U,4)
     63 ..S NAPPL=EVAL-APPL,NDUE=APPL-DUE
     64 ..S CNT=CNT+1,RSEQ=RSEQ+1
     65 ..;bookmark - write patient line
     66 ..;For each count type
     67 ..S ETYP="",FCNT=CNT
     68 ..F  S ETYP=$O(^TMP("PXRMETX",$J,SEQ,RCNT,ETYP)) Q:ETYP=""  D
     69 ...;For each term
     70 ...S FIND=0,FSEQ=0
     71 ...F  S FIND=$O(^TMP("PXRMETX",$J,SEQ,RCNT,ETYP,FIND)) Q:FIND=""  D
     72 ....;Update finding totals
     73 ....S FDATA=$G(^TMP("PXRMETX",$J,SEQ,RCNT,ETYP,FIND)),FCNT=FCNT+1
     74 ....S FEVAL=$P(FDATA,U,2),FAPPL=$P(FDATA,U,3),FDUE=$P(FDATA,U,4)
     75 ....S FNAPPL=FEVAL-FAPPL,FNDUE=FAPPL-FDUE
     76 ....S FSEQ=FSEQ+1,FGNAM=$P(DATA,U,9)
     77 ....;Bookmark - write finding line
     78 ..;Update CNT
     79 ..S CNT=FCNT
     80 Q
     81 ;
     82 ;Determine whether the report should be queued.
     83JOB ;
     84 N %ZIS,ZTDESC,ZTSAVE,ZTRTN,ZTSK
     85 S DBDUZ=DUZ
     86 D SAVE^PXRMXQUE
     87 S %ZIS="Q"
     88 S ZTDESC="QUERI Compliance Report - print"
     89 S ZTRTN="REPORT^PXRMETCO"
     90 S ZTSK=1
     91 S PXRMQUE=0
     92 S PXRMQUE=$$DEVICE^PXRMXQUE(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS,.ZTSK)
     93 I PXRMQUE=1 G EXIT
     94 I PXRMQUE>0 S ^XTMP(PXRMXTMP,"PRZTSK")=PXRMQUE
     95 Q
     96 ;
     97EXIT ;Clean things up.
     98 D ^%ZISC
     99 D HOME^%ZIS
     100 K IO("Q")
     101 K DIRUT,DTOUT,DUOUT,POP,ZTREQ
     102 I $D(ZTSK) D KILL^%ZTLOAD
     103 K ZTSK,ZTQUEUED
     104 K ^TMP("PXRMXTR",$J)
     105 Q
     106 ;
     107SAVE ;Save the variables for queing.
     108 S ZTSAVE("IEN")=""
     109 S ZTSAVE("PXRMSTRT")=""
     110 S ZTSAVE("PXRMSTOP")=""
     111 Q
     112 ;
     113 ;
     114QUE ;BOOKMARK - NOT USED
     115 ;Queue the MST synchronization job.
     116 N DIR,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
     117 S MINDT=$$NOW^XLFDT
     118 W !,"Queue the Clinical Reminders MST synchronization."
     119 S DIR("A",1)="Enter the date and time you want the job to start."
     120 S DIR("A")="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")_" "
     121 S DIR(0)="DAU"_U_MINDT_"::RSX"
     122 D ^DIR
     123 I $D(DTOUT)!$D(DUOUT) Q
     124 S SDTIME=Y
     125 K DIR
     126 S DIR(0)="YA"
     127 S DIR("A")="Do you want to run the MST synchronization at the same time every day? "
     128 S DIR("B")="Y"
     129 D ^DIR
     130 I $D(DTOUT)!$D(DUOUT) Q
     131 I Y S STIME="1."_$P(SDTIME,".",2)
     132 E  S STIME=-1
     133 ;
     134 ;Put the task into the queue.
     135 K ZTSAVE
     136 ;S ZTSAVE("START")=SDTIME
     137 S ZTSAVE("STIME")=STIME
     138 S ZTRTN="SYNCH^PXRMMST"
     139 S ZTDESC="Clinical Reminders MST synchronization job"
     140 S ZTDTH=SDTIME
     141 S ZTIO=""
     142 D ^%ZTLOAD
     143 W !,"Task number ",ZTSK," queued."
     144 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETH.m

    r613 r623  
    1 PXRMETH ; SLC/PJH - Reminder Extract History ;10/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM EXTRACT HISTORY
    5 START(EDIEN)    ;
    6         ;EDIEN is the extract definition IEN.
    7         N VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    8         ;Details of last run
    9         N DATA,NPERIOD,NSDATE,NTAS,PXRMVIEW
    10         S DATA=$G(^PXRM(810.2,EDIEN,0))
    11         S NPERIOD=$P(DATA,U,6),NSDATE=$P(DATA,U,7)
    12         ;Default view is in date created order
    13         S PXRMVIEW="D"
    14         S X="IORESET"
    15         D ENDR^%ZISS
    16         S VALMCNT=0
    17         D EN^VALM("PXRM EXTRACT HISTORY")
    18         Q
    19         ;
    20 DELETE  ;Delete an extract, called by protocol PXRM EXTRACT SUMMARY DELETE.
    21         N CLASS,IEN,IENLIST,IND
    22         S IENLIST=$$LMSEL
    23         F IND=1:1:$L(IENLIST,U) D
    24         .S IEN=$P(IENLIST,U,IND)
    25         .D DELETE^PXRMETXU(IEN)
    26         ;Rebuild workfile
    27         D BLDLIST^PXRMETH1(EDIEN)
    28         ;Refresh
    29         S VALMBCK="R"
    30         Q
    31         ;
    32 ENTRY   ;Entry code
    33         D BLDLIST^PXRMETH1(EDIEN),XQORM
    34         Q
    35         ;
    36 EXIT    ;Exit code
    37         K ^TMP("PXRMETH",$J)
    38         K ^TMP("PXRMETHH",$J)
    39         D CLEAN^VALM10
    40         D FULL^VALM1
    41         S VALMBCK="Q"
    42         Q
    43         ;
    44 EXTRACT(EDIEN)  ;Run Extract/Transmission
    45         ;Reset screen mode
    46         W IORESET
    47         ;Refresh on exit
    48         S VALMBCK="R"
    49         ;
    50         ;Get details from parameter file
    51         N ANS,DATA,DUOUT,DTOUT,EDATE,EXSUMPUG,FREQ,MODE
    52         N NAME,NAT,NEXT,PLISTPUG,RTN,REPL,STATUS,SNEXT,TEXT,XMIT
    53         S DATA=$G(^PXRM(810.2,EDIEN,0))
    54         S NAT=$P($G(^PXRM(810.2,EDIEN,100)),U)
    55         ;Determine Extract Name and Frequency
    56         S NAME=$P(DATA,U),FREQ=$P(DATA,U,3),NEXT=$P(DATA,U,6),RTN="PXRMETX"
    57         ;Save next scheduled extract
    58         S SNEXT=NEXT
    59         ;Select extract period
    60 EXSEL   D SELECT(FREQ,.NEXT) Q:$D(DUOUT)!$D(DTOUT)
    61         ;Warn if period is still open
    62         D WARN(NEXT,.STATUS)
    63         ;Option to continue
    64         S TEXT="Are you sure you want to run a "_NAME_" extract for "_$TR(NEXT,"/"," ")
    65 SURE    ;
    66         S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,1) Q:$D(DUOUT)!$D(DTOUT)  Q:'ANS
    67         ;Purge options
    68 PLIST   ;
    69         S PLISTPUG="N" D ASK^PXRMXD(.PLISTPUG,"Purge Patient List after 5 years?: ",5)
    70         G:$D(DUOUT) SURE Q:$D(DTOUT)
    71         S EXSUMPUG="N" D ASK^PXRMXD(.EXSUMPUG,"Purge Extract Summary after 5 years?: ",5)
    72         G:$D(DUOUT) PLIST Q:$D(DTOUT)
    73         ;Option to transmit
    74         S TEXT="Transmit extract results to AAC"
    75         I NAT="N" S XMIT=$$ASKYN^PXRMEUT("N",TEXT,RTN,3) Q:$D(DUOUT)!$D(DTOUT)
    76         E  S XMIT=0
    77         ;Option to replace scheduled run
    78         S REPL=0
    79         I XMIT,SNEXT=NEXT,STATUS="COMPLETE" D  Q:$D(DUOUT)!$D(DTOUT)
    80         .S TEXT="Does this extract replace the scheduled extract"
    81         .S REPL=$$ASKYN^PXRMEUT("N",TEXT,RTN,4) Q:$D(DUOUT)!$D(DTOUT)
    82         ;
    83         ;Note that the manual extract does not update 810.2
    84         ;exept if the selected period is the same as the scheduled
    85         ;period AND this period is complete
    86         ;
    87         ;Default is to extract and transmit and not update 810.2
    88         S MODE=2 I 'XMIT S MODE=3
    89         ;Update 810.2 if this extract is for current completed period
    90         I REPL S MODE=0 I 'XMIT S MODE=1
    91         ;
    92         ;Extract/transmission run
    93         N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
    94         S ZTDESC="Reminder Extract "_NAME
    95         S ZTRTN="RUN^PXRMETX(EDIEN,NEXT,MODE,EXSUMPUG)"
    96         S ZTSAVE("EDIEN")=""
    97         S ZTSAVE("MODE")=""
    98         S ZTSAVE("NEXT")=""
    99         S ZTSAVE("PLISTPUG")=""
    100         S ZTSAVE("EXSUMPUG")=""
    101         S ZTIO=""
    102         ;
    103         ;Select and verify start date/time for task
    104         N DIR,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
    105         S MINDT=$$NOW^XLFDT
    106         W !,"Queue a "_ZTDESC_" for "_NEXT
    107         S DIR("A",1)="Enter the date and time you want the job to start."
    108         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    109         S DIR("A")="Start the task at: "
    110         S DIR(0)="DAU"_U_MINDT_"::RSX"
    111         D ^DIR
    112         I $D(DTOUT)!$D(DUOUT) Q
    113         S SDTIME=Y
    114         ;
    115         ;Put the task into the queue.
    116         S ZTDTH=SDTIME
    117         D ^%ZTLOAD
    118         W !,"Task number ",ZTSK," queued." H 2
    119         S VALMBCK="Q"
    120         Q
    121         ;
    122 HDR     ; Header code
    123         N VIEW
    124         S VIEW=$S(PXRMVIEW="D":"Creation Date Order",1:"Extract Period Order")
    125         S VALMHDR(2)="          Extract Name: "_$P($G(^PXRM(810.2,EDIEN,0)),U)
    126         S VALMHDR(3)="   Next Extract Period: "_NPERIOD
    127         S VALMHDR(4)="      Scheduled to Run: "_$$FMTE^XLFDT(NSDATE,"5Z")
    128         S VALMHDR(4)=$$LJ^XLFSTR(VALMHDR(4),45)_"    View: "_VIEW
    129         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    130         Q
    131         ;
    132 HLP     ;Help code
    133         N ORU,ORUPRMT,SUB,XQORM
    134         S SUB="PXRMETHH"
    135         D EN^VALM("PXRM EXTRACT HELP")
    136         Q
    137         ;
    138 INIT    ;Init
    139         S VALMCNT=0
    140         Q
    141         ;
    142 LMSEL() ;Return selection list
    143         N IENLIST,IND,VALMY,XIEN
    144         D EN^VALM2(XQORNOD(0))
    145         ;If there is no list quit.
    146         I '$D(VALMY) Q ""
    147         S PXRMDONE=0,IENLIST=""
    148         S IND=""
    149         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    150         .;Get the ien.
    151         .S XIEN=^TMP("PXRMETH",$J,"SEL",IND)
    152         .S IENLIST=$S(IENLIST'="":IENLIST_U_XIEN,1:XIEN)
    153         Q IENLIST
    154         ;
    155 PEXIT   ;PXRM EXCH MENU protocol exit code
    156         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    157         D XQORM
    158         Q
    159         ;
    160 SELECT(FREQ,SEL)        ;Select extract period
    161         N BDATE,EDATE,DA,DIE,DIK,DIR,DR,FDATE,VALID,X
    162         ;Get the new name.
    163         F  D  Q:$D(DTOUT)!$D(DUOUT)  Q:SEL]""
    164         .S DIR("A")="Select EXTRACT PERIOD "
    165         .I FREQ="M" D
    166         ..S DIR("A")=DIR("A")_"(Mnn/yyyy)"
    167         ..S DIR(0)="F"_U_"7:8"_U_"K:'$$VALID^PXRMETH(FREQ,X) X"
    168         .I FREQ="Q" D
    169         ..S DIR("A")=DIR("A")_"(Qnn/yyyy)"
    170         ..S DIR(0)="F"_U_"7:7"_U_"K:'$$VALID^PXRMETH(FREQ,X) X"
    171         .I FREQ="Y" D
    172         ..S DIR("A")=DIR("A")_"(yyyy)"
    173         ..S DIR(0)="N"_U_"2000:2050"_U_"K:(X'?4N) X"
    174         .;Default is next period
    175         .S DIR("B")=NEXT
    176         .W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT)
    177         .;Calculate beginning and end dates for period
    178         .S Y=$$UP^XLFSTR(Y) D CALC^PXRMEUT(Y,.BDATE,.EDATE)
    179         .;Abort if period has not started
    180         .I $$FMDIFF^XLFDT(BDATE,$$NOW^XLFDT)>0 D   Q
    181         ..S FDATE=$$FMTE^XLFDT(BDATE,5)
    182         ..W !,"ERROR -This period does not start until "_FDATE,*7
    183         .S SEL=Y
    184         Q
    185         ;
    186 TLIST   ;Extract summary display
    187         N IEN,IENLIST,IND
    188         S IENLIST=$$LMSEL
    189         F IND=1:1:$L(IENLIST,U) D
    190         .S IEN=$P(IENLIST,U,IND)
    191         .D START^PXRMETT(IEN)
    192         .S VALMBCK="R"
    193         S VALMBCK="R"
    194         Q
    195         ;
    196 TRANS   ;Run Transmission
    197         N IEN,IENLIST,IND
    198         S IENLIST=$$LMSEL
    199         F IND=1:1:$L(IENLIST,U) D
    200         .S IEN=$P(IENLIST,U,IND)
    201         .I $P($G(^PXRMXT(810.3,IEN,100)),U)'="N" D  Q
    202         ..W !,"Local extracts cannot be transmitted to AAC." H 2
    203         .;Transmit extract summary
    204         .N ANS,DUOUT,DTOUT,RTN,TEXT
    205         .S TEXT="Transmit this extract to AAC",ANS="",RTN="PXRMETH"
    206         .S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,3) Q:$D(DUOUT)!$D(DTOUT)
    207         .I ANS D TRANS^PXRMETX(IEN)
    208         ;
    209         ;Rebuild workfile
    210         D BLDLIST^PXRMETH1(EDIEN)
    211         ;Refresh
    212         S VALMBCK="R"
    213         Q
    214         ;
    215 TRHIST  ;Transmission History
    216         N IEN,IENLIST,IND
    217         S IENLIST=$$LMSEL
    218         F IND=1:1:$L(IENLIST,U) D
    219         .S IEN=$P(IENLIST,U,IND)
    220         .D START^PXRMETHL(IEN)
    221         S VALMBCK="R"
    222         Q
    223         ;
    224 VALID(FREQ,INP) ;Validate Period input
    225         W !
    226         N PERIOD,YEAR
    227         ;Convert to upper case
    228         S INP=$$UP^XLFSTR(INP)
    229         ;General format
    230         I $E(INP)'=FREQ D EN^DDIOL("Format should be "_FREQ_"nn/yyyy") Q 0
    231         S PERIOD=$P(INP,"/"),YEAR=$P(INP,"/",2)
    232         S PERIOD=$P(PERIOD,FREQ,2)
    233         ;All runs
    234         I (YEAR<2000)!(YEAR>2050) D EN^DDIOL("Year should be in range 2000-2050") Q 0
    235         ;Quarterly run
    236         I FREQ="Q",(PERIOD>4)!(PERIOD<1) D EN^DDIOL("Quarter should be in range 1-4") Q 0
    237         ;Monthly run
    238         I FREQ="M",(PERIOD>12)!(PERIOD<1) D EN^DDIOL("Month should be in range 1-12") Q 0
    239         ;Otherwise
    240         Q 1
    241         ;
    242 VIEW    ;Select view
    243         W IORESET
    244         S VALMBCK="R"
    245         N X,Y,CODE,DIR
    246         K DIROUT,DIRUT,DTOUT,DUOUT
    247         S DIR(0)="S"_U_"D:Sort by Creation Date;"
    248         S DIR(0)=DIR(0)_"P:Sort by Extract Period;"
    249         S DIR("A")="TYPE OF VIEW"
    250         S DIR("B")=$S(PXRMVIEW="P":"D",1:"P")
    251         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    252         ;BOOKMARK - HELP NEEDS MOVING
    253         S DIR("??")=U_"D HELP^PXRMSEL2(3)"
    254         D ^DIR K DIR
    255         I $D(DIROUT) S DTOUT=1
    256         I $D(DTOUT)!($D(DUOUT)) Q
    257         ;Change display type
    258         S PXRMVIEW=Y
    259         ;
    260         ;Rebuild Workfile
    261         D BLDLIST^PXRMETH1(EDIEN),HDR
    262         Q
    263         ;
    264 WARN(NEXT,STATUS)       ;Warn if period is not completed
    265         N BDATE,EDATE,FDATE
    266         ;Calculate beginning and end dates for period
    267         D CALC^PXRMEUT(NEXT,.BDATE,.EDATE)
    268         ;No warning if period end date is a prior date
    269         I $$FMDIFF^XLFDT($$NOW^XLFDT,EDATE)>0 S STATUS="COMPLETE" Q
    270         ;Else Format date
    271         S FDATE=$$FMTE^XLFDT(EDATE,5),STATUS="INCOMPLETE"
    272         ;And Warn that period end date is a future date
    273         W !!,"WARNING -This period is not complete until "_FDATE
    274         Q
    275 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT HISTORY SELECT ENTRY",0))_U_"1:"_VALMCNT
    276         S XQORM("A")="Select Item: "
    277         Q
    278         ;
    279 XSEL    ;PXRM EXTRACT HISTORY SELECT ENTRY validation
    280         N SEL,PXRMSIEN
    281         S SEL=$P(XQORNOD(0),"=",2)
    282         ;Remove trailing ,
    283         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    284         ;Invalid selection
    285         I SEL["," D  Q
    286         .W $C(7),!,"Only one item number allowed." H 2
    287         .S VALMBCK="R"
    288         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    289         .W $C(7),!,SEL_" is not a valid item number." H 2
    290         .S VALMBCK="R"
    291         ;
    292         ;Get the list ien.
    293         ;S PXRMSIEN=^TMP("PXRMETH",$J,"IDX",SEL,SEL)
    294         S PXRMSIEN=^TMP("PXRMETH",$J,"SEL",SEL)
    295         ;
    296         ;Full screen mode
    297         D FULL^VALM1
    298         ;
    299         ;Options
    300         N X,Y,DIR,OPTION K DIROUT,DIRUT,DTOUT,DUOUT
    301         S DIR(0)="SBM"_U_"DE:Delete Extract;"
    302         S DIR(0)=DIR(0)_"ES:Extract Summary;"
    303         S DIR(0)=DIR(0)_"MT:Manual Transmission;"
    304         S DIR(0)=DIR(0)_"TH:Transmission History;"
    305         S DIR("A")="Select Action"
    306         S DIR("B")="ES"
    307         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    308         S DIR("??")=U_"D HELP^PXRMETH1(1)"
    309         D ^DIR K DIR
    310         I $D(DIROUT) S DTOUT=1
    311         I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
    312         S OPTION=Y
    313         ;
    314         ;Delete an extract
    315         I OPTION="DE" D
    316         .D DELETE^PXRMETXU(PXRMSIEN)
    317         .;Rebuild workfile
    318         .D BLDLIST^PXRMETH1(PXRMSIEN)
    319         .;Refresh
    320         .S VALMBCK="R"
    321         ;
    322         ;Display Extract Summary
    323         I OPTION="ES" D START^PXRMETT(PXRMSIEN)
    324         ;
    325         ;Transmission option
    326         I OPTION="MT" D
    327         .N ANS,DUOUT,DTOUT,RTN,TEXT
    328         .I $P($G(^PXRMXT(810.3,PXRMSIEN,100)),U)'="N" D  Q
    329         ..W !,"Local extracts cannot be transmitted to AAC" H 2 Q
    330         .S TEXT="Transmit this extract to AAC",ANS="",RTN="PXRMETH"
    331         .S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,3) Q:$D(DUOUT)!$D(DTOUT)
    332         .I ANS D TRANS^PXRMETX(PXRMSIEN)
    333         ;
    334         ;Transmission History
    335         I OPTION="TH" D START^PXRMETHL(PXRMSIEN)
    336         ;
    337         S VALMBCK="R"
    338         Q
    339         ;
     1PXRMETH ; SLC/PJH - Reminder Extract History ;08/15/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM EXTRACT HISTORY
     5START(IEN) ;
     6 N VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     7 ;Details of last run
     8 N DATA,NPERIOD,NSDATE,NTAS,PXRMVIEW
     9 S DATA=$G(^PXRM(810.2,IEN,0))
     10 S NPERIOD=$P(DATA,U,6),NSDATE=$P(DATA,U,7)
     11 ;Default view is in date created order
     12 S PXRMVIEW="D"
     13 S X="IORESET"
     14 D ENDR^%ZISS
     15 S VALMCNT=0
     16 D EN^VALM("PXRM EXTRACT HISTORY")
     17 Q
     18 ;
     19ENTRY ;Entry code
     20 D BLDLIST^PXRMETH1(IEN),XQORM
     21 Q
     22 ;
     23EXIT ;Exit code
     24 K ^TMP("PXRMETH",$J)
     25 K ^TMP("PXRMETHH",$J)
     26 D CLEAN^VALM10
     27 D FULL^VALM1
     28 S VALMBCK="Q"
     29 Q
     30 ;
     31HDR ; Header code
     32 N VIEW
     33 S VIEW=$S(PXRMVIEW="D":"Creation Date Order",1:"Extract Period Order")
     34 S VALMHDR(2)="          Extract Name: "_$P($G(^PXRM(810.2,IEN,0)),U)
     35 S VALMHDR(3)="   Next Extract Period: "_NPERIOD
     36 S VALMHDR(4)="      Scheduled to Run: "_NSDATE
     37 S VALMHDR(4)=$$LJ^XLFSTR(VALMHDR(4),45)_"    View: "_VIEW
     38 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     39 Q
     40 ;
     41HLP ;Help code
     42 N ORU,ORUPRMT,SUB,XQORM
     43 S SUB="PXRMETHH"
     44 D EN^VALM("PXRM EXTRACT HELP")
     45 Q
     46 ;
     47INIT ;Init
     48 S VALMCNT=0
     49 Q
     50 ;
     51PEXIT ;PXRM EXCH MENU protocol exit code
     52 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     53 D XQORM
     54 Q
     55 ;
     56XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT HISTORY SELECT ENTRY",0))_U_"1:"_VALMCNT
     57 S XQORM("A")="Select Item: "
     58 Q
     59 ;
     60XSEL ;PXRM EXTRACT HISTORY SELECT ENTRY validation
     61 N SEL,PXRMSIEN
     62 S SEL=$P(XQORNOD(0),"=",2)
     63 ;Remove trailing ,
     64 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     65 ;Invalid selection
     66 I SEL["," D  Q
     67 .W $C(7),!,"Only one item number allowed." H 2
     68 .S VALMBCK="R"
     69 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     70 .W $C(7),!,SEL_" is not a valid item number." H 2
     71 .S VALMBCK="R"
     72 ;
     73 ;Get the list ien.
     74 S PXRMSIEN=^TMP("PXRMETH",$J,"IDX",SEL,SEL)
     75 ;
     76 ;Full screen mode
     77 D FULL^VALM1
     78 ;
     79 ;Options
     80 N X,Y,DIR,OPTION K DIROUT,DIRUT,DTOUT,DUOUT
     81 S DIR(0)="SBM"_U_"ES:Extract Summary;"
     82 S DIR(0)=DIR(0)_"MT:Manual Transmission;"
     83 S DIR(0)=DIR(0)_"TH:Transmission History;"
     84 S DIR("A")="Select Action"
     85 S DIR("B")="ES"
     86 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     87 S DIR("??")=U_"D HELP^PXRMETH1(1)"
     88 D ^DIR K DIR
     89 I $D(DIROUT) S DTOUT=1
     90 I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
     91 S OPTION=Y
     92 ;
     93 ;Display Extract Summary
     94 I OPTION="ES" D
     95 .D START^PXRMETT(PXRMSIEN)
     96 ;
     97 ;Transmission option
     98 I OPTION="MT" D
     99 .N ANS,DUOUT,DTOUT,RTN,TEXT
     100 .I $P($G(^PXRMXT(810.3,PXRMSIEN,100)),U)'="N" D  Q
     101 ..W !,"Local extracts cannot be transmitted to AAC" H 2 Q
     102 .S TEXT="Transmit this extract to AAC",ANS="",RTN="PXRMETH"
     103 .S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,3) Q:$D(DUOUT)!$D(DTOUT)
     104 .I ANS D TRANS^PXRMETX(PXRMSIEN)
     105 ;
     106 ;Transmission History
     107 I OPTION="TH" D
     108 .D START^PXRMETHL(PXRMSIEN)
     109 ;
     110 S VALMBCK="R"
     111 Q
     112 ;
     113EXTRACT(IEN) ;Run Extract/Transmission
     114 ;
     115 ;Reset screen mode
     116 W IORESET
     117 ;Refresh on exit
     118 S VALMBCK="R"
     119 ;
     120 ;Get details from parameter file
     121 N ANS,DATA,DUOUT,DTOUT,EDATE,EXSUMPUG,FREQ,MODE
     122 N NAME,NAT,NEXT,PLISTPUG,RTN,REPL,STATUS,SNEXT,TEXT,XMIT
     123 S DATA=$G(^PXRM(810.2,IEN,0))
     124 S NAT=$P($G(^PXRM(810.2,IEN,100)),U)
     125 ;Determine Extract Name and Frequency
     126 S NAME=$P(DATA,U),FREQ=$P(DATA,U,3),NEXT=$P(DATA,U,6),RTN="PXRMETX"
     127 ;Save next scheduled extract
     128 S SNEXT=NEXT
     129 ;Select extract period
     130EXSEL D SELECT(FREQ,.NEXT) Q:$D(DUOUT)!$D(DTOUT)
     131 ;Warn if period is still open
     132 D WARN(NEXT,.STATUS)
     133 ;Option to continue
     134 S TEXT="Are you sure you want to run a "_NAME_" extract for "_$TR(NEXT,"/"," ")
     135SURE ;
     136 S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,1) Q:$D(DUOUT)!$D(DTOUT)  Q:'ANS
     137 ;Purge options
     138PLIST ;
     139 S PLISTPUG="N" D ASK^PXRMXD(.PLISTPUG,"Purge Patient List after 5 years?: ",5)
     140 G:$D(DUOUT) SURE Q:$D(DTOUT)
     141 S EXSUMPUG="N" D ASK^PXRMXD(.EXSUMPUG,"Purge Extract Summary after 5 years?: ",5)
     142 G:$D(DUOUT) PLIST Q:$D(DTOUT)
     143 ;Option to transmit
     144 S TEXT="Transmit extract results to AAC"
     145 I NAT="N" S XMIT=$$ASKYN^PXRMEUT("N",TEXT,RTN,3) Q:$D(DUOUT)!$D(DTOUT)
     146 E  S XMIT=0
     147 ;Option to replace scheduled run
     148 S REPL=0
     149 I XMIT,SNEXT=NEXT,STATUS="COMPLETE" D  Q:$D(DUOUT)!$D(DTOUT)
     150 .S TEXT="Does this extract replace the scheduled extract"
     151 .S REPL=$$ASKYN^PXRMEUT("N",TEXT,RTN,4) Q:$D(DUOUT)!$D(DTOUT)
     152 ;
     153 ;Note that the manual extract does not update 810.2
     154 ;exept if the selected period is the same as the scheduled
     155 ;period AND this period is complete
     156 ;
     157 ;Default is to extract and transmit and not update 810.2
     158 S MODE=2 I 'XMIT S MODE=3
     159 ;Update 810.2 if this extract is for current completed period
     160 I REPL S MODE=0 I 'XMIT S MODE=1
     161 ;
     162 ;Extract/transmission run
     163 N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
     164 S ZTDESC="Reminder Extract "_NAME
     165 S ZTRTN="RUN^PXRMETX(IEN,NEXT,MODE,EXSUMPUG)"
     166 S ZTSAVE("IEN")=""
     167 S ZTSAVE("MODE")=""
     168 S ZTSAVE("NEXT")=""
     169 S ZTSAVE("PLISTPUG")=""
     170 S ZTSAVE("EXSUMPUG")=""
     171 S ZTIO=""
     172 ;
     173 ;Select and verify start date/time for task
     174 N DIR,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
     175 S MINDT=$$NOW^XLFDT
     176 W !,"Queue a "_ZTDESC_" for "_NEXT
     177 S DIR("A",1)="Enter the date and time you want the job to start."
     178 S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
     179 S DIR("A")="Start the task at: "
     180 S DIR(0)="DAU"_U_MINDT_"::RSX"
     181 D ^DIR
     182 I $D(DTOUT)!$D(DUOUT) Q
     183 S SDTIME=Y
     184 ;
     185 ;Put the task into the queue.
     186 S ZTDTH=SDTIME
     187 D ^%ZTLOAD
     188 W !,"Task number ",ZTSK," queued." H 2
     189 ;
     190 S VALMBCK="Q"
     191 Q
     192 ;
     193SELECT(FREQ,SEL) ;Select extract period
     194 ;
     195 N BDATE,EDATE,DA,DIE,DIK,DIR,DR,FDATE,VALID,X
     196 ;Get the new name.
     197 F  D  Q:$D(DTOUT)!$D(DUOUT)  Q:SEL]""
     198 .S DIR("A")="Select EXTRACT PERIOD "
     199 .I FREQ="M" D
     200 ..S DIR("A")=DIR("A")_"(Mnn/yyyy)"
     201 ..S DIR(0)="F"_U_"7:8"_U_"K:'$$VALID^PXRMETH(FREQ,X) X"
     202 .I FREQ="Q" D
     203 ..S DIR("A")=DIR("A")_"(Qnn/yyyy)"
     204 ..S DIR(0)="F"_U_"7:7"_U_"K:'$$VALID^PXRMETH(FREQ,X) X"
     205 .I FREQ="Y" D
     206 ..S DIR("A")=DIR("A")_"(yyyy)"
     207 ..S DIR(0)="N"_U_"2000:2050"_U_"K:(X'?4N) X"
     208 .;Default is next period
     209 .S DIR("B")=NEXT
     210 .W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT)
     211 .;Calculate beginning and end dates for period
     212 .S Y=$$UP^XLFSTR(Y) D CALC^PXRMEUT(Y,.BDATE,.EDATE)
     213 .;Abort if period has not started
     214 .I $$FMDIFF^XLFDT(BDATE,$$NOW^XLFDT)>0 D   Q
     215 ..S FDATE=$$FMTE^XLFDT(BDATE,5)
     216 ..W !,"ERROR -This period does not start until "_FDATE,*7
     217 .S SEL=Y
     218 Q
     219 ;
     220TLIST ;Extract Totals
     221 N IND,PXRMSIEN,VALMY
     222 D EN^VALM2(XQORNOD(0))
     223 ;If there is no list quit.
     224 I '$D(VALMY) Q
     225 ;PXRMDONE is newed in PXRMLPM
     226 S PXRMDONE=0
     227 S IND=""
     228 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     229 .;Get the ien.
     230 .S PXRMSIEN=^TMP("PXRMETH",$J,"IDX",IND,IND)
     231 .D START^PXRMETT(PXRMSIEN)
     232 ;
     233 S VALMBCK="R"
     234 Q
     235 ;
     236TRANS ;Run Transmission
     237 N IND,PXRMXIEN,VALMY
     238 D EN^VALM2(XQORNOD(0))
     239 ;If there is no list quit.
     240 I '$D(VALMY) Q
     241 S PXRMDONE=0
     242 S IND=""
     243 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     244 .;Get the ien.
     245 .S PXRMXIEN=^TMP("PXRMETH",$J,"IDX",IND,IND)
     246 .I $P($G(^PXRMXT(810.3,PXRMXIEN,100)),U)'="N" D  Q
     247 ..W !,"Local extracts cannot be transmitted to AAC." H 1
     248 .;Transmit extract summary
     249 .N ANS,DUOUT,DTOUT,RTN,TEXT
     250 .S TEXT="Transmit this extract to AAC",ANS="",RTN="PXRMETH"
     251 .S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,3) Q:$D(DUOUT)!$D(DTOUT)
     252 .I ANS D TRANS^PXRMETX(PXRMXIEN)
     253 ;
     254 ;Rebuild workfile
     255 D BLDLIST^PXRMETH1(IEN)
     256 ;Refresh
     257 S VALMBCK="R"
     258 Q
     259 ;
     260TRHIST ;Transmission History
     261 N IND,PXRMSIEN,VALMY
     262 D EN^VALM2(XQORNOD(0))
     263 ;If there is no list quit.
     264 I '$D(VALMY) Q
     265 ;PXRMDONE is newed in PXRMLPM
     266 S PXRMDONE=0
     267 S IND=""
     268 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     269 .;Get the ien.
     270 .S PXRMSIEN=^TMP("PXRMETH",$J,"IDX",IND,IND)
     271 .D START^PXRMETHL(PXRMSIEN)
     272 ;
     273 S VALMBCK="R"
     274 Q
     275 ;
     276VALID(FREQ,INP) ;Validate Period input
     277 W !
     278 N PERIOD,YEAR
     279 ;Convert to upper case
     280 S INP=$$UP^XLFSTR(INP)
     281 ;General format
     282 I $E(INP)'=FREQ D EN^DDIOL("Format should be "_FREQ_"nn/yyyy") Q 0
     283 S PERIOD=$P(INP,"/"),YEAR=$P(INP,"/",2)
     284 S PERIOD=$P(PERIOD,FREQ,2)
     285 ;All runs
     286 I (YEAR<2000)!(YEAR>2050) D EN^DDIOL("Year should be in range 2000-2050") Q 0
     287 ;Quarterly run
     288 I FREQ="Q",(PERIOD>4)!(PERIOD<1) D EN^DDIOL("Quarter should be in range 1-4") Q 0
     289 ;Monthly run
     290 I FREQ="M",(PERIOD>12)!(PERIOD<1) D EN^DDIOL("Month should be in range 1-12") Q 0
     291 ;Otherwise
     292 Q 1
     293 ;
     294VIEW ;Select view
     295 ;
     296 W IORESET
     297 ;
     298 S VALMBCK="R"
     299 ;
     300 N X,Y,CODE,DIR
     301 K DIROUT,DIRUT,DTOUT,DUOUT
     302 S DIR(0)="S"_U_"D:Sort by Creation Date;"
     303 S DIR(0)=DIR(0)_"P:Sort by Extract Period;"
     304 S DIR("A")="TYPE OF VIEW"
     305 S DIR("B")=$S(PXRMVIEW="P":"D",1:"P")
     306 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     307 ;BOOKMARK - HELP NEEDS MOVING
     308 S DIR("??")=U_"D HELP^PXRMSEL2(3)"
     309 D ^DIR K DIR
     310 I $D(DIROUT) S DTOUT=1
     311 I $D(DTOUT)!($D(DUOUT)) Q
     312 ;Change display type
     313 S PXRMVIEW=Y
     314 ;
     315 ;Rebuild Workfile
     316 D BLDLIST^PXRMETH1(IEN),HDR
     317 Q
     318 ;
     319WARN(NEXT,STATUS) ;Warn if period is not completed
     320 N BDATE,EDATE,FDATE
     321 ;Calculate beginning and end dates for period
     322 D CALC^PXRMEUT(NEXT,.BDATE,.EDATE)
     323 ;No warning if period end date is a prior date
     324 I $$FMDIFF^XLFDT($$NOW^XLFDT,EDATE)>0 S STATUS="COMPLETE" Q
     325 ;Else Format date
     326 S FDATE=$$FMTE^XLFDT(EDATE,5),STATUS="INCOMPLETE"
     327 ;And Warn that period end date is a future date
     328 W !!,"WARNING -This period is not complete until "_FDATE
     329 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETH1.m

    r613 r623  
    1 PXRMETH1        ; SLC/PJH - Reminder Extract History ;09/07/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 BLDLIST(EDIEN)  ;Build workfile
    5         ;EDIEN is the extract definition IEN.
    6         N IND,FMTSTR,PLIST
    7         K ^TMP("PXRMETH",$J)
    8         S FMTSTR=$$LMFMTSTR^PXRMTEXT(.VALMDDF,"RLL")
    9         ;Build list of extract summaries in period order
    10         I PXRMVIEW="P" D LIST1(EDIEN,"PXRMETH",FMTSTR)
    11         ;Build list of extract summaries in date order
    12         I PXRMVIEW="D" D LIST2(EDIEN,"PXRMETH",FMTSTR)
    13         Q
    14         ;
    15 FMT(NUMBER,NAME,EDATE,XDATE,AUTO,FMTSTR,NL,OUTPUT)      ;Format
    16         N TAUTO,TDATE,TEMP,TNAME,TSOURCE
    17         S TEMP=NUMBER_U_NAME_U
    18         S TDATE=$$FMTE^XLFDT(EDATE,"5Z")
    19         S TEMP=TEMP_$$LJ^XLFSTR(TDATE,20," ")
    20         S TDATE=XDATE I TDATE S TDATE=$$FMTE^XLFDT(TDATE,"5Z")
    21         S TEMP=TEMP_" "_$$LJ^XLFSTR(TDATE,22," ")
    22         S TAUTO=AUTO
    23         S TEMP=TEMP_TAUTO
    24         D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NL,.OUTPUT)
    25         Q
    26         ;
    27 HELP(CALL)      ;General help text routine.
    28         N HTEXT
    29         I CALL=1 D
    30         .S HTEXT(1)="Select DE to delete an extract.\\"
    31         .S HTEXT(2)="Select ES to view the details of an extract or run a compliance"
    32         .S HTEXT(3)="report for the extract.\\Select MT to transmit extract details to the AAC.\\"
    33         .S HTEXT(4)="Select TH to view the transmission history for an extract."
    34         ;
    35         I CALL=3 D
    36         .S HTEXT(1)="Select Y to send the results of the Extract to the National Austin database."
    37         ;
    38         I CALL=4 D
    39         .S HTEXT(4)="Select Y to overwrite the previous Extract stored in the National Austin Database."
    40         D HELP^PXRMEUT(.HTEXT)
    41         Q
    42         ;
    43 LIST1(EDIEN,NODE,FMTSTR)        ;Build a list of extract summaries for a parameter.
    44         N AUTO,EDATE,HL7ID,HL7SUB,IND,JND,NAME,NL,NUM,OUTPUT
    45         N PERIOD,STR,XDATE,YEAR
    46         ;Build list of extract summaries in reverse date order.
    47         S YEAR="9999",(NUM,VALMCNT)=0
    48         F  S YEAR=$O(^PXRMXT(810.3,"D",EDIEN,YEAR),-1) Q:YEAR=""  D
    49         .S PERIOD="99"
    50         .F  S PERIOD=$O(^PXRMXT(810.3,"D",EDIEN,YEAR,PERIOD),-1) Q:PERIOD=""  D
    51         ..S IND=""
    52         ..F  S IND=$O(^PXRMXT(810.3,"D",EDIEN,YEAR,PERIOD,IND),-1) Q:IND=""  D
    53         ...S NAME=$P($G(^PXRMXT(810.3,IND,0)),U)
    54         ...S EDATE=$P($G(^PXRMXT(810.3,IND,0)),U,6)
    55         ...S AUTO=$P($G(^PXRMXT(810.3,IND,4)),U,5)
    56         ...S AUTO=$S(AUTO="A":"Y",1:"N")
    57         ...S HL7ID=$O(^PXRMXT(810.3,IND,5,"B",""),-1),XDATE="",HL7SUB=""
    58         ...I HL7ID S HL7SUB=$O(^PXRMXT(810.3,IND,5,"B",HL7ID,""))
    59         ...I HL7SUB S XDATE=$P($G(^PXRMXT(810.3,IND,5,HL7SUB,0)),U,2)
    60         ...I 'XDATE S XDATE="Not Transmitted"
    61         ...S NUM=NUM+1
    62         ...D FMT(NUM,NAME,EDATE,XDATE,AUTO,FMTSTR,.NL,.OUTPUT)
    63         ...F JND=1:1:NL D
    64         ....S VALMCNT=VALMCNT+1,^TMP(NODE,$J,VALMCNT,0)=OUTPUT(JND)
    65         ....S ^TMP(NODE,$J,"IDX",VALMCNT,NUM)=""
    66         ....S ^TMP(NODE,$J,"SEL",NUM)=IND
    67         Q
    68         ;
    69 LIST2(EDIEN,NODE,FMTSTR)        ;Build a list of extract summaries for a parameter.
    70         N AUTO,EDATE,HL7ID,HL7SUB,IND,JND,NAME,NL,NUM,OUTPUT
    71         N PERIOD,STR,XDATE,YEAR
    72         ;Build list of extract summaries in reverse date order.
    73         S EDATE="",(NUM,VALMCNT)=0
    74         F  S EDATE=$O(^PXRMXT(810.3,"C",EDIEN,EDATE),-1) Q:'EDATE  D
    75         .S IND=""
    76         .F  S IND=$O(^PXRMXT(810.3,"C",EDIEN,EDATE,IND)) Q:'IND  D
    77         ..S NAME=$P($G(^PXRMXT(810.3,IND,0)),U,1)
    78         ..S AUTO=$P($G(^PXRMXT(810.3,IND,4)),U,5)
    79         ..S AUTO=$S(AUTO="A":"Y",1:"N")
    80         ..S HL7ID=$O(^PXRMXT(810.3,IND,5,"B",""),-1),XDATE="",HL7SUB=""
    81         ..I HL7ID S HL7SUB=$O(^PXRMXT(810.3,IND,5,"B",HL7ID,""))
    82         ..I HL7SUB S XDATE=$P($G(^PXRMXT(810.3,IND,5,HL7SUB,0)),U,2)
    83         ..I 'XDATE S XDATE="Not Transmitted"
    84         ..S NUM=NUM+1
    85         ..D FMT(NUM,NAME,EDATE,XDATE,AUTO,FMTSTR,.NL,.OUTPUT)
    86         ..F JND=1:1:NL D
    87         ...S VALMCNT=VALMCNT+1,^TMP(NODE,$J,VALMCNT,0)=OUTPUT(JND)
    88         ...S ^TMP(NODE,$J,"IDX",VALMCNT,NUM)=""
    89         ...S ^TMP(NODE,$J,"SEL",NUM)=IND
    90         Q
    91         ;
     1PXRMETH1 ; SLC/PJH - Reminder Extract History ;07/24/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4BLDLIST(IEN) ;Build workfile
     5 N IND,PLIST
     6 K ^TMP("PXRMETH",$J)
     7 ;Build list of extract summaries in period order
     8 I PXRMVIEW="P" D LIST1(.PLIST,.IEN)
     9 ;Build list of extract summaries in date order
     10 I PXRMVIEW="D" D LIST2(.PLIST,.IEN)
     11 ;Move into list array
     12 M ^TMP("PXRMETH",$J)=PLIST
     13 S VALMCNT=PLIST("VALMCNT")
     14 ;Allow selection by item
     15 F IND=1:1:VALMCNT D
     16 .S ^TMP("PXRMETH",$J,"IDX",IND,IND)=IEN(IND)
     17 Q
     18 ;
     19HELP(CALL) ;General help text routine.
     20 N HTEXT
     21 I CALL=1 D
     22 .S HTEXT(1)="Select ES to view the details of an extract or run a compliance"
     23 .S HTEXT(2)="report for the extract. Select MT to transmit extract details to the AAC."
     24 .S HTEXT(3)="Select TH to view the transmission history for an extract."
     25 ;
     26 I CALL=3 D
     27 .S HTEXT(1)="Select Y to send the results of the Extract to the National Austin database."
     28 ;
     29 I CALL=4 D
     30 .S HTEXT(4)="Select Y to overwrite the previous Extract stored in the National Austin Database."
     31 D HELP^PXRMEUT(.HTEXT)
     32 Q
     33 ;
     34LIST1(LIST,IEN) ;Build a list of extract summaries for a parameter.
     35 N AUTO,EDATE,HL7ID,HL7SUB,IND,NAME,PERIOD,XDATE,YEAR
     36 ;Build list of extract summaries in reverse date order.
     37 S YEAR="9999",VALMCNT=0
     38 F  S YEAR=$O(^PXRMXT(810.3,"D",IEN,YEAR),-1) Q:YEAR=""  D
     39 .S PERIOD="99"
     40 .F  S PERIOD=$O(^PXRMXT(810.3,"D",IEN,YEAR,PERIOD),-1) Q:PERIOD=""  D
     41 ..S IND=""
     42 ..F  S IND=$O(^PXRMXT(810.3,"D",IEN,YEAR,PERIOD,IND),-1) Q:IND=""  D
     43 ...S NAME=$P($G(^PXRMXT(810.3,IND,0)),U)
     44 ...S EDATE=$P($G(^PXRMXT(810.3,IND,0)),U,6)
     45 ...S AUTO=$P($G(^PXRMXT(810.3,IND,4)),U,5)
     46 ...S AUTO=$S(AUTO="A":"Y",1:"N")
     47 ...S HL7ID=$O(^PXRMXT(810.3,IND,5,"B",""),-1),XDATE="",HL7SUB=""
     48 ...I HL7ID S HL7SUB=$O(^PXRMXT(810.3,IND,5,"B",HL7ID,""))
     49 ...I HL7SUB S XDATE=$P($G(^PXRMXT(810.3,IND,5,HL7SUB,0)),U,2)
     50 ...I 'XDATE S XDATE="Not Transmitted"
     51 ...S VALMCNT=VALMCNT+1
     52 ...S LIST(VALMCNT,0)=$$FRE(VALMCNT,NAME,EDATE,XDATE,AUTO)
     53 ...S IEN(VALMCNT)=IND
     54 S LIST("VALMCNT")=VALMCNT
     55 Q
     56 ;
     57LIST2(LIST,IEN) ;Build a list of extract summaries for a parameter.
     58 N AUTO,EDATE,HL7ID,HL7SUB,IND,NAME,PERIOD,XDATE,YEAR
     59 ;Build list of extract summaries in reverse date order.
     60 S EDATE="",VALMCNT=0
     61 F  S EDATE=$O(^PXRMXT(810.3,"C",IEN,EDATE),-1) Q:'EDATE  D
     62 .S IND=""
     63 .F  S IND=$O(^PXRMXT(810.3,"C",IEN,EDATE,IND)) Q:'IND  D
     64 ..S NAME=$P($G(^PXRMXT(810.3,IND,0)),U)
     65 ..S AUTO=$P($G(^PXRMXT(810.3,IND,4)),U,5)
     66 ..S AUTO=$S(AUTO="A":"Y",1:"N")
     67 ..S HL7ID=$O(^PXRMXT(810.3,IND,5,"B",""),-1),XDATE="",HL7SUB=""
     68 ..I HL7ID S HL7SUB=$O(^PXRMXT(810.3,IND,5,"B",HL7ID,""))
     69 ..I HL7SUB S XDATE=$P($G(^PXRMXT(810.3,IND,5,HL7SUB,0)),U,2)
     70 ..I 'XDATE S XDATE="Not Transmitted"
     71 ..S VALMCNT=VALMCNT+1
     72 ..S LIST(VALMCNT,0)=$$FRE(VALMCNT,NAME,EDATE,XDATE,AUTO)
     73 ..S IEN(VALMCNT)=IND
     74 S LIST("VALMCNT")=VALMCNT
     75 Q
     76 ;
     77FRE(NUMBER,NAME,EDATE,XDATE,AUTO) ;Format
     78 N TAUTO,TDATE,TEMP,TNAME,TSOURCE
     79 S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
     80 S TNAME=$E(NAME,1,27)
     81 S TEMP=TEMP_" "_$$LJ^XLFSTR(TNAME,27," ")
     82 S TDATE=$$FMTE^XLFDT(EDATE,"5Z")
     83 S TEMP=TEMP_" "_$$LJ^XLFSTR(TDATE,20," ")
     84 S TDATE=XDATE I TDATE S TDATE=$$FMTE^XLFDT(TDATE,"5Z")
     85 S TEMP=TEMP_" "_$$LJ^XLFSTR(TDATE,22," ")
     86 S TAUTO=AUTO
     87 S TEMP=TEMP_TAUTO
     88 Q TEMP
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETM.m

    r613 r623  
    1 PXRMETM ; SLC/PKR/PJH - Extract/Transmission Management ;09/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM EXTRACT MANAGEMENT
    5 START   N PXRMDONE,VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    6         S X="IORESET"
    7         D ENDR^%ZISS
    8         S VALMCNT=0
    9         D EN^VALM("PXRM EXTRACT MANAGEMENT")
    10         W IORESET
    11         D KILL^%ZISS
    12         Q
    13         ;
    14 BLDLIST ;Build workfile
    15         K ^TMP("PXRMETM",$J)
    16         N IEN,IND,PLIST
    17         D LIST("PXRMETM",.VALMCNT)
    18         Q
    19         ;
    20 ENTRY   ;Entry code
    21         D BLDLIST,XQORM
    22         Q
    23         ;
    24 EXIT    ;Exit code
    25         K ^TMP("PXRMETM",$J)
    26         K ^TMP("PXRMETMH",$J)
    27         D CLEAN^VALM10
    28         D FULL^VALM1
    29         S VALMBCK="Q"
    30         Q
    31         ;
    32 FMT(NUMBER,NAME,CLASS)  ;Format  entry number, name
    33         ;and date packed.
    34         N TCLASS,TEMP,TNAME,TSOURCE
    35         S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
    36         S TNAME=$E(NAME,1,46)
    37         S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,60," ")
    38         S TCLASS=$S(CLASS="N":"NATIONAL",CLASS="V":"VISN",1:"LOCAL")
    39         S TEMP=TEMP_"  "_TCLASS
    40         Q TEMP
    41         ;
    42 GEN     ;Ad hoc report option
    43         ;Reset Screen Mode
    44         W IORESET
    45         ;
    46         N IND,LISTIEN,VALMY
    47         D EN^VALM2(XQORNOD(0))
    48         ;If there is no list quit.
    49         I '$D(VALMY) Q
    50         S PXRMDONE=0
    51         S IND=""
    52         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    53         .;Get the ien.
    54         .S LISTIEN=^TMP("PXRMETM",$J,"SEL",IND)
    55         .D GENSEL(LISTIEN)
    56         ;
    57         S VALMBCK="R"
    58         Q
    59         ;
    60 GENSEL(IEN)     ;Report for selected extract definition
    61         N ANS,BEGIN,END,RTN,TEXT
    62         D DATES^PXRMEUT(.BEGIN,.END,"Report")
    63         ;Options
    64         S RTN="PXRMETM",TEXT="Run compliance report for this period"
    65         S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,1) Q:'ANS  Q:$D(DUOUT)!$D(DTOUT)
    66         ;Print Report
    67         D ADHOC^PXRMETCO(IEN,BEGIN,END)
    68         Q
    69         ;
    70 HDR     ; Header code
    71         S VALMHDR(1)="Available Extract Definitions:"
    72         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    73         Q
    74         ;
    75 HELP(CALL)      ;General help text routine
    76         N HTEXT
    77         I CALL=1 D
    78         .S HTEXT(1)="Select EDM to edit/display extract definitions.\\"
    79         .S HTEXT(2)="Select VSE to view previous extracts or"
    80         .S HTEXT(3)="initiate a manual extract or transmission."
    81         D HELP^PXRMEUT(.HTEXT)
    82         Q
    83         ;
    84 HLIST   ;Extract History
    85         N IND,LISTIEN,VALMY
    86         D EN^VALM2(XQORNOD(0))
    87         ;If there is no list quit.
    88         I '$D(VALMY) Q
    89         S PXRMDONE=0
    90         S IND=""
    91         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    92         .;Get the ien.
    93         .S LISTIEN=^TMP("PXRMETM",$J,"SEL",IND)
    94         .D START^PXRMETH(LISTIEN)
    95         S VALMBCK="R"
    96         Q
    97         ;
    98 HLP     ;Help code
    99         N ORU,ORUPRMT,SUB,XQORM
    100         S SUB="PXRMETMH"
    101         D EN^VALM("PXRM EXTRACT HELP")
    102         Q
    103         ;
    104 INIT    ;Init
    105         S VALMCNT=0
    106         Q
    107         ;
    108 LIST(NODE,VALMCNT)      ;Build a list of extract definition entries.
    109         N EPCLASS,IND,FNAME,NAME
    110         ;Build the list in alphabetical order.
    111         S VALMCNT=0
    112         S NAME=""
    113         F  S NAME=$O(^PXRM(810.2,"B",NAME)) Q:NAME=""  D
    114         .S IND=$O(^PXRM(810.2,"B",NAME,"")) Q:'IND
    115         .S FNAME=$P($G(^PXRM(810.2,IND,0)),U)
    116         .S EPCLASS=$P($G(^PXRM(810.2,IND,100)),U)
    117         .S VALMCNT=VALMCNT+1
    118         .S ^TMP(NODE,$J,VALMCNT,0)=$$FMT(VALMCNT,FNAME,EPCLASS)
    119         .S ^TMP(NODE,$J,"IDX",VALMCNT,VALMCNT)=""
    120         .S ^TMP(NODE,$J,"SEL",VALMCNT)=IND
    121         Q
    122         ;
    123 PEXIT   ;Protocol exit code
    124         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    125         ;Reset after page up/down etc
    126         D XQORM
    127         Q
    128         ;
    129 PLIST   ;Extract Definition Inquiry
    130         N IND,EPIEN,VALMY
    131         D EN^VALM2(XQORNOD(0))
    132         ;If there is no list quit.
    133         I '$D(VALMY) Q
    134         S PXRMDONE=0
    135         S IND=""
    136         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    137         .;Get the ien.
    138         .S EPIEN=^TMP("PXRMETM",$J,"SEL",IND)
    139         .D START^PXRMEPED(EPIEN)
    140         S VALMBCK="R"
    141         Q
    142         ;
    143 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT MANAGEMENT SELECT ENTRY",0))_U_"1:"_VALMCNT
    144         S XQORM("A")="Select Item: "
    145         Q
    146         ;
    147 XSEL    ;PXRM EXTRACT MANAGEMENT SELECT ENTRY validation
    148         N EDIEN,SEL
    149         S SEL=$P(XQORNOD(0),"=",2)
    150         ;Remove trailing ,
    151         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    152         ;Invalid selection
    153         I SEL["," D  Q
    154         .W $C(7),!,"Only one item number allowed." H 2
    155         .S VALMBCK="R"
    156         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    157         .W $C(7),!,SEL_" is not a valid item number." H 2
    158         .S VALMBCK="R"
    159         ;
    160         ;Get the list ien.
    161         S EDIEN=^TMP("PXRMETM",$J,"SEL",SEL)
    162         ;
    163         ;Full screen mode
    164         D FULL^VALM1
    165         ;
    166         ;Options
    167         N X,Y,DIR,OPTION K DIROUT,DIRUT,DTOUT,DUOUT
    168         S DIR(0)="SBM"_U_"EDM:Extract Definition Management;"
    169         S DIR(0)=DIR(0)_"VSE:Examine/Schedule Extract;"
    170         S DIR("A")="Select Action"
    171         S DIR("B")="VSE"
    172         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    173         S DIR("??")=U_"D HELP^PXRMETM(1)"
    174         D ^DIR K DIR
    175         I $D(DIROUT) S DTOUT=1
    176         I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
    177         S OPTION=Y
    178         ;
    179         ;Display Extract Definitions
    180         I OPTION="EDM" D START^PXRMEPED(EDIEN)
    181         ;
    182         ;Examine/Run Extract
    183         I OPTION="VSE" D START^PXRMETH(EDIEN)
    184         ;
    185         ;Examine/Run Extract
    186         I OPTION="ERE" D GENSEL(EDIEN)
    187         ;
    188         S VALMBCK="R"
    189         Q
    190         ;
     1PXRMETM ; SLC/PKR/PJH - Extract/Transmission Management ;05/15/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM EXTRACT MANAGEMENT
     5START N PXRMDONE,VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     6 S X="IORESET"
     7 D ENDR^%ZISS
     8 S VALMCNT=0
     9 D EN^VALM("PXRM EXTRACT MANAGEMENT")
     10 W IORESET
     11 D KILL^%ZISS
     12 Q
     13 ;
     14BLDLIST ;Build workfile
     15 K ^TMP("PXRMETM",$J)
     16 N IEN,IND,PLIST
     17 D LIST(.PLIST,.IEN)
     18 M ^TMP("PXRMETM",$J)=PLIST
     19 S VALMCNT=PLIST("VALMCNT")
     20 F IND=1:1:VALMCNT D
     21 .S ^TMP("PXRMETM",$J,"IDX",IND,IND)=IEN(IND)
     22 Q
     23 ;
     24LIST(RLIST,IEN) ;Build a list of extract definition entries.
     25 N EPCLASS,IND,FNAME,NAME
     26 ;Build the list in alphabetical order.
     27 S VALMCNT=0
     28 S NAME=""
     29 F  S NAME=$O(^PXRM(810.2,"B",NAME)) Q:NAME=""  D
     30 .S IND=$O(^PXRM(810.2,"B",NAME,"")) Q:'IND
     31 .S FNAME=$P($G(^PXRM(810.2,IND,0)),U)
     32 .S EPCLASS=$P($G(^PXRM(810.2,IND,100)),U)
     33 .S VALMCNT=VALMCNT+1
     34 .S RLIST(VALMCNT,0)=$$FRE(VALMCNT,FNAME,EPCLASS)
     35 .S IEN(VALMCNT)=IND
     36 S RLIST("VALMCNT")=VALMCNT
     37 Q
     38 ;
     39FRE(NUMBER,NAME,CLASS) ;Format  entry number, name
     40 ;and date packed.
     41 N TCLASS,TEMP,TNAME,TSOURCE
     42 S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
     43 S TNAME=$E(NAME,1,46)
     44 S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,60," ")
     45 S TCLASS=$S(CLASS="N":"NATIONAL",CLASS="V":"VISN",1:"LOCAL")
     46 S TEMP=TEMP_"  "_TCLASS
     47 Q TEMP
     48 ;
     49ENTRY ;Entry code
     50 D BLDLIST,XQORM
     51 Q
     52 ;
     53EXIT ;Exit code
     54 K ^TMP("PXRMETM",$J)
     55 K ^TMP("PXRMETMH",$J)
     56 D CLEAN^VALM10
     57 D FULL^VALM1
     58 S VALMBCK="Q"
     59 Q
     60 ;
     61HDR ; Header code
     62 S VALMHDR(1)="Available Extract Definitions:"
     63 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     64 Q
     65 ;
     66HLP ;Help code
     67 N ORU,ORUPRMT,SUB,XQORM
     68 S SUB="PXRMETMH"
     69 D EN^VALM("PXRM EXTRACT HELP")
     70 Q
     71 ;
     72INIT ;Init
     73 S VALMCNT=0
     74 Q
     75 ;
     76PEXIT ;Protocol exit code
     77 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     78 ;Reset after page up/down etc
     79 D XQORM
     80 Q
     81 ;
     82XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT MANAGEMENT SELECT ENTRY",0))_U_"1:"_VALMCNT
     83 S XQORM("A")="Select Item: "
     84 Q
     85 ;
     86XSEL ;PXRM EXTRACT MANAGEMENT SELECT ENTRY validation
     87 N SEL,IEN
     88 S SEL=$P(XQORNOD(0),"=",2)
     89 ;Remove trailing ,
     90 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     91 ;Invalid selection
     92 I SEL["," D  Q
     93 .W $C(7),!,"Only one item number allowed." H 2
     94 .S VALMBCK="R"
     95 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     96 .W $C(7),!,SEL_" is not a valid item number." H 2
     97 .S VALMBCK="R"
     98 ;
     99 ;Get the list ien.
     100 S IEN=^TMP("PXRMETM",$J,"IDX",SEL,SEL)
     101 ;
     102 ;Full screen mode
     103 D FULL^VALM1
     104 ;
     105 ;Options
     106 N X,Y,DIR,OPTION K DIROUT,DIRUT,DTOUT,DUOUT
     107 S DIR(0)="SBM"_U_"EDM:Extract Definition Management;"
     108 S DIR(0)=DIR(0)_"VSE:Examine/Schedule Extract;"
     109 S DIR("A")="Select Action"
     110 S DIR("B")="VSE"
     111 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     112 S DIR("??")=U_"D HELP^PXRMETM(1)"
     113 D ^DIR K DIR
     114 I $D(DIROUT) S DTOUT=1
     115 I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
     116 S OPTION=Y
     117 ;
     118 ;Display Extract Definitions
     119 I OPTION="EDM" D
     120 .D START^PXRMEPED(IEN)
     121 ;
     122 ;Examine/Run Extract
     123 I OPTION="VSE" D
     124 .D START^PXRMETH(IEN)
     125 ;
     126 ;Examine/Run Extract
     127 I OPTION="ERE" D
     128 .D GENSEL(IEN)
     129 ;
     130 S VALMBCK="R"
     131 Q
     132 ;
     133HELP(CALL) ;General help text routine
     134 N HTEXT
     135 I CALL=1 D
     136 .S HTEXT(1)="Select EDM to edit/display extract definitions."
     137 .S HTEXT(2)="extract. Select VSE to view previous extracts or "
     138 .S HTEXT(3)="initiate a manual extract or transmission."
     139 ;
     140 D HELP^PXRMEUT(.HTEXT)
     141 Q
     142 ;
     143GEN ;Ad hoc report option
     144 ;
     145 ;Reset Screen Mode
     146 W IORESET
     147 ;
     148 N IND,LISTIEN,VALMY
     149 D EN^VALM2(XQORNOD(0))
     150 ;If there is no list quit.
     151 I '$D(VALMY) Q
     152 S PXRMDONE=0
     153 S IND=""
     154 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     155 .;Get the ien.
     156 .S LISTIEN=^TMP("PXRMETM",$J,"IDX",IND,IND)
     157 .D GENSEL(LISTIEN)
     158 ;
     159 S VALMBCK="R"
     160 Q
     161 ;
     162GENSEL(IEN) ;Report for selected extract definition
     163 N ANS,BEGIN,END,RTN,TEXT
     164 D DATES^PXRMEUT(.BEGIN,.END,"Report")
     165 ;Options
     166 S RTN="PXRMETM",TEXT="Run compliance report for this period"
     167 S ANS=$$ASKYN^PXRMEUT("N",TEXT,RTN,1) Q:'ANS  Q:$D(DUOUT)!$D(DTOUT)
     168 ;Print Report
     169 D ADHOC^PXRMETCO(IEN,BEGIN,END)
     170 Q
     171 ;
     172HLIST ;Extract History
     173 N IND,LISTIEN,VALMY
     174 D EN^VALM2(XQORNOD(0))
     175 ;If there is no list quit.
     176 I '$D(VALMY) Q
     177 S PXRMDONE=0
     178 S IND=""
     179 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     180 .;Get the ien.
     181 .S LISTIEN=^TMP("PXRMETM",$J,"IDX",IND,IND)
     182 .D START^PXRMETH(LISTIEN)
     183 S VALMBCK="R"
     184 Q
     185 ;
     186PLIST ;Extract Definition Inquiry
     187 N IND,EPIEN,VALMY
     188 D EN^VALM2(XQORNOD(0))
     189 ;If there is no list quit.
     190 I '$D(VALMY) Q
     191 S PXRMDONE=0
     192 S IND=""
     193 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     194 .;Get the ien.
     195 .S EPIEN=^TMP("PXRMETM",$J,"IDX",IND,IND)
     196 .D START^PXRMEPED(EPIEN)
     197 ;
     198 S VALMBCK="R"
     199 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETT.m

    r613 r623  
    1 PXRMETT ; SLC/PJH - Extract Summary Display ;04/09/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM EXTRACT SUMMARY
    5 START(IEN)      N TOGGLE,TOGGLE1,VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    6         S X="IORESET"
    7         D ENDR^%ZISS
    8         S VALMCNT=0,TOGGLE=0,TOGGLE1=0
    9         D EN^VALM("PXRM EXTRACT SUMMARY")
    10         Q
    11         ;
    12 BLDLIST(IEN,FINDINGS,PATIENT)   ;Build workfile.
    13         ;FINDINGS=1 means display finding totals
    14         K ^TMP("PXRMETT",$J)
    15         ;Build a list of extract summary totals.
    16         N APPL,DATA,DUE,IND,LIST,NDUE,NAPPL,OLIST
    17         N PLCNT,PLIST,RIEN,RNAME,SARRAY,SEQ,SNAME,STATION,TOT
    18         ;Build the list in alphabetical order.
    19         S VALMCNT=0,OLIST="",PLCNT=0
    20         S IND=0 F  S IND=$O(^PXRMXT(810.3,IEN,3,IND)) Q:IND'>0  D
    21         .S DATA=$G(^PXRMXT(810.3,IEN,3,IND,0)) Q:DATA=""
    22         .S RIEN=$P(DATA,U,2) Q:'RIEN
    23         .S RNAME=$P(^PXD(811.9,RIEN,0),U,3)
    24         .I RNAME="" S RNAME=$P(^PXD(811.9,RIEN,0),U,1)
    25         .S STATION=$P(DATA,U,3),SARRAY=""
    26         .D GETS^DIQ(4,STATION,99,"E","SARRAY")
    27         .S SNAME=$G(SARRAY(4,STATION_",",99,"E"))
    28         .I SNAME="" S SNAME=STATION
    29         .S TOT=+$P(DATA,U,5),APPL=+$P(DATA,U,6),NAPPL=+$P(DATA,U,7)
    30         .S DUE=+$P(DATA,U,8),NDUE=+$P(DATA,U,9)
    31         .S PLIST=$P(DATA,U,4)
    32         .I PLIST,PLIST'=OLIST D
    33         ..I PLCNT>0 D
    34         ...S VALMCNT=VALMCNT+1
    35         ...S ^TMP("PXRMETT",$J,VALMCNT,0)=""
    36         ...S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    37         ..S PLNAME=$P($G(^PXRMXP(810.5,PLIST,0)),U),OLIST=PLIST Q:PLNAME=""
    38         ..S VALMCNT=VALMCNT+1,PLCNT=PLCNT+1
    39         ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    40         ..S ^TMP("PXRMETT",$J,"SEL",PLCNT)=PLIST
    41         ..S ^TMP("PXRMETT",$J,VALMCNT,0)=$$RJ^XLFSTR(PLCNT,4," ")_" "_PLNAME
    42         .S VALMCNT=VALMCNT+1
    43         .S ^TMP("PXRMETT",$J,VALMCNT,0)=$$FRE(VALMCNT,RNAME,SNAME,TOT,APPL,NAPPL,DUE,NDUE)
    44         .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    45         .;Finding totals
    46         .I +FINDINGS>0 D FBLD(PATIENT)
    47         ;
    48         S ^TMP("PXRMETT",$J,"VALMCNT")=VALMCNT
    49         Q
    50         ;
    51 ENTRY   ;Entry code
    52         D BLDLIST(IEN,TOGGLE,TOGGLE1),XQORM
    53         Q
    54         ;
    55 EXIT    ;Exit code
    56         K ^TMP("PXRMETT",$J)
    57         K ^TMP("PXRMETTH",$J)
    58         D CLEAN^VALM10
    59         D FULL^VALM1
    60         S VALMBCK="Q"
    61         Q
    62         ;
    63 FBLD(PATIENT)   ;Build finding list
    64         N APPL,DATA,DUE,ETYP,EVAL,GNAM,GTYP
    65         N NAPPL,NDUE,OGNAM,SEQ,SUB,TIEN,TNAME,TOTAL
    66         S SUB=0,OGNAM=""
    67         F  S SUB=$O(^PXRMXT(810.3,IEN,3,IND,1,SUB)) Q:'SUB  D
    68         .S DATA=$G(^PXRMXT(810.3,IEN,3,IND,1,SUB,0)) Q:DATA=""
    69         .S TIEN=$P(DATA,U,2) Q:'TIEN
    70         .S TNAME=$P($G(^PXRMD(811.5,TIEN,0)),U)
    71         .S SEQ=$P(DATA,U),ETYP=$P(DATA,U,3),GNAM=$P(DATA,U,9),GTYP=$P(DATA,U,10)
    72         .S TOT=+$P(DATA,U,4),APPL=+$P(DATA,U,5),NAPPL=+$P(DATA,U,6)
    73         .S DUE=+$P(DATA,U,7),NDUE=+$P(DATA,U,8)
    74         .I OGNAM'=GNAM D
    75         ..I OGNAM'="" D
    76         ...S VALMCNT=VALMCNT+1
    77         ...S ^TMP("PXRMETT",$J,VALMCNT,0)=""
    78         ...S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    79         ..S OGNAM=GNAM,VALMCNT=VALMCNT+1
    80         ..S ^TMP("PXRMETT",$J,VALMCNT,0)=$$RJ^XLFSTR("Counting Group: ",21)_GNAM
    81         ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)="",VALMCNT=VALMCNT+1
    82         ..S ^TMP("PXRMETT",$J,VALMCNT,0)=$J("",6)_$$LJ^XLFSTR($$TXT^PXRMEPM(ETYP,GTYP),49)
    83         ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    84         .S VALMCNT=VALMCNT+1
    85         .S ^TMP("PXRMETT",$J,VALMCNT,0)=$$FREF(VALMCNT,TNAME,SEQ,TOT,APPL,NAPPL,DUE,NDUE,ETYP)
    86         .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    87         .I +PATIENT>0 D PBLD(IEN,IND,SUB)
    88         S VALMCNT=VALMCNT+1
    89         S ^TMP("PXRMETT",$J,VALMCNT,0)=""
    90         S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    91         Q
    92         ;
    93 FLIST   ;Toggle list with/without finding totals
    94         S TOGGLE=(TOGGLE+1)#2
    95         I TOGGLE=0 S TOGGLE1=0
    96         ;Rebuild Workfile
    97         D BLDLIST(IEN,TOGGLE,TOGGLE1)
    98         ;Refresh
    99         S VALMBCK="R",VALMBG=1
    100         Q
    101         ;
    102 FRE(NUMBER,NAME,SNAME,TOT,APPL,NAPPL,DUE,NDUE)  ;Format reminder entry
    103         N TEMP,TNAME,TSOURCE
    104         S TEMP="     "
    105         S TNAME=SNAME_"/"_$E(NAME,1,35-$L(SNAME))
    106         S TEMP=TEMP_$$LJ^XLFSTR(TNAME,36," ")
    107         S TEMP=TEMP_$$RJ^XLFSTR(TOT,8," ")
    108         S TEMP=TEMP_$$RJ^XLFSTR(APPL,8," ")
    109         S TEMP=TEMP_$$RJ^XLFSTR(NAPPL,7," ")
    110         S TEMP=TEMP_$$RJ^XLFSTR(DUE,7," ")
    111         S TEMP=TEMP_$$RJ^XLFSTR(NDUE,7," ")
    112         Q TEMP
    113         ;
    114 FREF(NUMBER,NAME,SNAME,TOT,APPL,NAPPL,DUE,NDUE,ETYP)    ;Format finding entry
    115         N TEMP,TNAME,TSOURCE
    116         S TEMP="      "
    117         S TNAME=$E(NAME,1,31)
    118         S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,31," ")
    119         S TEMP=TEMP_"  "_$$RJ^XLFSTR(TOT,8," ")
    120         I ETYP'="FC" D
    121         .S TEMP=TEMP_$$RJ^XLFSTR(APPL,8," ")
    122         .S TEMP=TEMP_$$RJ^XLFSTR(NAPPL,7," ")
    123         .S TEMP=TEMP_$$RJ^XLFSTR(DUE,7," ")
    124         .S TEMP=TEMP_$$RJ^XLFSTR(NDUE,7," ")
    125         Q TEMP
    126         ;
    127 HDR     ; Header code
    128         S VALMHDR(1)="Extract Summary Name: "_$P($G(^PXRMXT(810.3,IEN,0)),U)
    129         S VALMHDR(2)="      Extract Period: "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,2),"5Z")_" - "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,3),"5Z")
    130         S VALMHDR(2)=VALMHDR(2)_"   Created: "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,6),"5Z")
    131         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    132         Q
    133         ;
    134 HLP     ;Help code
    135         N ORU,ORUPRMT,XQORM
    136         S SUB="PXRMETTH"
    137         D EN^VALM("PXRM EXTRACT HELP")
    138         Q
    139         ;
    140 INIT    ;Init
    141         S VALMCNT=0
    142         Q
    143         ;
    144 PBLD(IEN,IND,SUB)       ;
    145         N ARRAY,NAME,LEN,PCNT,DFN,CNT,USTR
    146         S VALMCNT=VALMCNT+1,CNT=0
    147         S PCNT=0 F  S PCNT=$O(^PXRMXT(810.3,IEN,3,IND,1,SUB,1,PCNT)) Q:PCNT'>0  D
    148         .S DFN=$P($G(^PXRMXT(810.3,IEN,3,IND,1,SUB,1,PCNT,0)),U) Q:DFN'>0
    149         .S NAME=$P($G(^DPT(DFN,0)),U)
    150         .S CNT=CNT+1,ARRAY(NAME)=""
    151         S ^TMP("PXRMETT",$J,VALMCNT,0)="     "_$$RJ^XLFSTR("Unique Applicable Patients ("_CNT_")",36," ")
    152         S USTR=$P($G(^TMP("PXRMETT",$J,VALMCNT,0)),"U"),LEN=$L(USTR)
    153         S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    154         S NAME="" F  S NAME=$O(ARRAY(NAME)) Q:NAME=""  D
    155         .S VALMCNT=VALMCNT+1
    156         .S ^TMP("PXRMETT",$J,VALMCNT,0)=USTR_$$LJ^XLFSTR(NAME,36," ")
    157         .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    158         S VALMCNT=VALMCNT+1
    159         S ^TMP("PXRMETT",$J,VALMCNT,0)="  "
    160         S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
    161         Q
    162         ;
    163 PEXIT   ;Protocol exit code
    164         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    165         D XQORM
    166         Q
    167         ;
    168 PLIST(IEN)      ;Patient list display
    169         N IND,PLIEN,VALMY
    170         D EN^VALM2(XQORNOD(0))
    171         ;If there is no list quit.
    172         I '$D(VALMY) Q
    173         ;PXRMDONE is newed in PXRMLPM
    174         S PXRMDONE=0
    175         S IND=""
    176         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    177         .;Get the ien.
    178         .S PLIEN=^TMP("PXRMETT",$J,"SEL",IND)
    179         .D START^PXRMLPP(PLIEN)
    180         S VALMBCK="R"
    181         Q
    182         ;
    183 PLIST1  ;Toggle list with/without finding totals
    184         S TOGGLE1=(TOGGLE1+1)#2
    185         ;Rebuild Workfile
    186         D BLDLIST(IEN,TOGGLE,TOGGLE1)
    187         ;Refresh
    188         S VALMBCK="R",VALMBG=1
    189         Q
    190         ;
    191 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT SUMMARY SELECT ENTRY",0))_U_"1:"_VALMCNT
    192         S XQORM("A")="Select Item: "
    193         Q
    194         ;
    195 XSEL    ;PXRM EXTRACT TOTALS SELECT ENTRY validation
    196         N SEL,PLIEN
    197         S SEL=$P(XQORNOD(0),"=",2)
    198         ;Remove trailing ,
    199         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    200         ;Invalid selection
    201         I SEL["," D  Q
    202         .W $C(7),!,"Only one item number allowed." H 2
    203         .S VALMBCK="R"
    204         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    205         .W $C(7),!,SEL_" is not a valid item number." H 2
    206         .S VALMBCK="R"
    207         ;Get the list ien.
    208         S PLIEN=^TMP("PXRMETT",$J,"SEL",SEL)
    209         D START^PXRMLPP(PLIEN)
    210         S VALMBCK="R"
    211         Q
    212         ;
     1PXRMETT ; SLC/PKR/PJH - Reminder Patient List Patients ;08/08/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM PATIENT LIST
     5START(IEN) N TOGGLE,TOGGLE1,VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     6 S X="IORESET"
     7 D ENDR^%ZISS
     8 S VALMCNT=0,TOGGLE=0,TOGGLE1=0
     9 D EN^VALM("PXRM EXTRACT SUMMARY")
     10 Q
     11 ;
     12BLDLIST(IEN,FINDINGS,PATIENT) ;Build workfile.
     13 K ^TMP("PXRMETT",$J)
     14 ;Build a list of extract summary totals.
     15 N APPL,DATA,DUE,IND,LIST,NDUE,NAPPL,OLIST
     16 N PLCNT,PLIST,RIEN,RNAME,SARRAY,SNAME,STATION,TOT
     17 ;Build the list in alphabetical order.
     18 S IND=0,VALMCNT=0,OLIST="",PLCNT=0
     19 F  S IND=$O(^PXRMXT(810.3,IEN,3,IND)) Q:'IND  D
     20 .S DATA=$G(^PXRMXT(810.3,IEN,3,IND,0)) Q:DATA=""
     21 .S RIEN=$P(DATA,U,2) Q:'RIEN
     22 .S RNAME=$P($G(^PXD(811.9,RIEN,0)),U)
     23 .S STATION=$P(DATA,U,3),SARRAY=""
     24 .D GETS^DIQ(4,STATION,99,"E","SARRAY")
     25 .S SNAME=$G(SARRAY(4,STATION_",",99,"E"))
     26 .I SNAME="" S SNAME=STATION
     27 .S TOT=+$P(DATA,U,5),APPL=+$P(DATA,U,6),NAPPL=+$P(DATA,U,7)
     28 .S DUE=+$P(DATA,U,8),NDUE=+$P(DATA,U,9)
     29 .S PLIST=$P(DATA,U,4)
     30 .I PLIST,PLIST'=OLIST D
     31 ..S PLNAME=$P($G(^PXRMXP(810.5,PLIST,0)),U),OLIST=PLIST Q:PLNAME=""
     32 ..S VALMCNT=VALMCNT+1,PLCNT=PLCNT+1
     33 ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     34 ..S ^TMP("PXRMETT",$J,"SEL",PLCNT)=PLIST
     35 ..S ^TMP("PXRMETT",$J,VALMCNT,0)=$$RJ^XLFSTR(PLCNT,4," ")_" "_PLNAME
     36 ..S VALMCNT=VALMCNT+1
     37 ..S ^TMP("PXRMETT",$J,VALMCNT,0)=""
     38 ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     39 .S VALMCNT=VALMCNT+1
     40 .S ^TMP("PXRMETT",$J,VALMCNT,0)=$$FRE(VALMCNT,RNAME,SNAME,TOT,APPL,NAPPL,DUE,NDUE)
     41 .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     42 .S VALMCNT=VALMCNT+1
     43 .S ^TMP("PXRMETT",$J,VALMCNT,0)=""
     44 .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     45 .;Finding totals
     46 .I +FINDINGS>0 D FBLD(PATIENT)
     47 ;
     48 S ^TMP("PXRMETT",$J,"VALMCNT")=VALMCNT
     49 ;M ^TMP("PXRMETT",$J)=LIST
     50 Q
     51 ;
     52FBLD(PATIENT) ;Build finding list
     53 N APPL,DATA,DUE,ETYP,EVAL,GNAM,GTYP
     54 N NAPPL,NDUE,OGNAM,SEQ,SUB,TIEN,TNAME,TOTAL
     55 S SUB=0,OGNAM=""
     56 F  S SUB=$O(^PXRMXT(810.3,IEN,3,IND,1,SUB)) Q:'SUB  D
     57 .S DATA=$G(^PXRMXT(810.3,IEN,3,IND,1,SUB,0)) Q:DATA=""
     58 .S TIEN=$P(DATA,U,2) Q:'TIEN
     59 .S TNAME=$P($G(^PXRMD(811.5,TIEN,0)),U)
     60 .S SEQ=$P(DATA,U),ETYP=$P(DATA,U,3),GNAM=$P(DATA,U,9),GTYP=$P(DATA,U,10)
     61 .S TOT=+$P(DATA,U,4),APPL=+$P(DATA,U,5),NAPPL=+$P(DATA,U,6)
     62 .S DUE=+$P(DATA,U,7),NDUE=+$P(DATA,U,8)
     63 .I OGNAM'=GNAM D
     64 ..I OGNAM'="" D
     65 ...S VALMCNT=VALMCNT+1
     66 ...S ^TMP("PXRMETT",$J,VALMCNT,0)=""
     67 ...S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     68 ..S OGNAM=GNAM,VALMCNT=VALMCNT+1
     69 ..S ^TMP("PXRMETT",$J,VALMCNT,0)=$$RJ^XLFSTR("Counting Group: ",21)_GNAM
     70 ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)="",VALMCNT=VALMCNT+1
     71 ..S ^TMP("PXRMETT",$J,VALMCNT,0)=$J("",6)_$$LJ^XLFSTR($$TXT^PXRMEPM(ETYP,GTYP),49)
     72 ..S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     73 .S VALMCNT=VALMCNT+1
     74 .S ^TMP("PXRMETT",$J,VALMCNT,0)=$$FREF(VALMCNT,TNAME,SEQ,TOT,APPL,NAPPL,DUE,NDUE,ETYP)
     75 .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     76 .I +PATIENT>0 D PBLD(IEN,IND,SUB)
     77 S VALMCNT=VALMCNT+1
     78 S ^TMP("PXRMETT",$J,VALMCNT,0)=""
     79 S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     80 Q
     81 ;
     82PBLD(IEN,IND,SUB) ;
     83 N ARRAY,NAME,LEN,PCNT,DFN,CNT,USTR
     84 S VALMCNT=VALMCNT+1,CNT=0
     85 S PCNT=0 F  S PCNT=$O(^PXRMXT(810.3,IEN,3,IND,1,SUB,1,PCNT)) Q:PCNT'>0  D
     86 .S DFN=$P($G(^PXRMXT(810.3,IEN,3,IND,1,SUB,1,PCNT,0)),U) Q:DFN'>0
     87 .S NAME=$P($G(^DPT(DFN,0)),U)
     88 .S CNT=CNT+1,ARRAY(NAME)=""
     89 S ^TMP("PXRMETT",$J,VALMCNT,0)="     "_$$RJ^XLFSTR("Unique Applicable Patients ("_CNT_")",36," ")
     90 S USTR=$P($G(^TMP("PXRMETT",$J,VALMCNT,0)),"U"),LEN=$L(USTR)
     91 S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     92 S NAME="" F  S NAME=$O(ARRAY(NAME)) Q:NAME=""  D
     93 .S VALMCNT=VALMCNT+1
     94 .S ^TMP("PXRMETT",$J,VALMCNT,0)=USTR_$$LJ^XLFSTR(NAME,36," ")
     95 .S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     96 S VALMCNT=VALMCNT+1
     97 S ^TMP("PXRMETT",$J,VALMCNT,0)="  "
     98 S ^TMP("PXRMETT",$J,"IDX",VALMCNT,PLCNT)=""
     99 Q
     100 ;
     101FLIST ;Toggle list with/without finding totals
     102 S TOGGLE=(TOGGLE+1)#2
     103 I TOGGLE=0 S TOGGLE1=0
     104 ;Rebuild Workfile
     105 D BLDLIST(IEN,TOGGLE,TOGGLE1)
     106 ;Refresh
     107 S VALMBCK="R",VALMBG=1
     108 Q
     109 ;
     110PLIST1 ;Toggle list with/without finding totals
     111 S TOGGLE1=(TOGGLE1+1)#2
     112 ;Rebuild Workfile
     113 D BLDLIST(IEN,TOGGLE,TOGGLE1)
     114 ;Refresh
     115 S VALMBCK="R",VALMBG=1
     116 Q
     117 ;
     118FRE(NUMBER,NAME,SNAME,TOT,APPL,NAPPL,DUE,NDUE) ;Format reminder entry
     119 N TEMP,TNAME,TSOURCE
     120 S TEMP="     "
     121 S TNAME=SNAME_"/"_$E(NAME,1,35-$L(SNAME))
     122 S TEMP=TEMP_$$LJ^XLFSTR(TNAME,36," ")
     123 S TEMP=TEMP_$$RJ^XLFSTR(TOT,8," ")
     124 S TEMP=TEMP_$$RJ^XLFSTR(APPL,8," ")
     125 S TEMP=TEMP_$$RJ^XLFSTR(NAPPL,7," ")
     126 S TEMP=TEMP_$$RJ^XLFSTR(DUE,7," ")
     127 S TEMP=TEMP_$$RJ^XLFSTR(NDUE,7," ")
     128 Q TEMP
     129 ;
     130FREF(NUMBER,NAME,SNAME,TOT,APPL,NAPPL,DUE,NDUE,ETYP) ;Format finding entry
     131 N TEMP,TNAME,TSOURCE
     132 S TEMP="      "
     133 S TNAME=$E(NAME,1,31)
     134 S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,31," ")
     135 S TEMP=TEMP_"  "_$$RJ^XLFSTR(TOT,8," ")
     136 I ETYP'="FC" D
     137 .S TEMP=TEMP_$$RJ^XLFSTR(APPL,8," ")
     138 .S TEMP=TEMP_$$RJ^XLFSTR(NAPPL,7," ")
     139 .S TEMP=TEMP_$$RJ^XLFSTR(DUE,7," ")
     140 .S TEMP=TEMP_$$RJ^XLFSTR(NDUE,7," ")
     141 Q TEMP
     142 ;
     143ENTRY ;Entry code
     144 D BLDLIST(IEN,TOGGLE,TOGGLE1),XQORM
     145 Q
     146 ;
     147EXIT ;Exit code
     148 K ^TMP("PXRMETT",$J)
     149 K ^TMP("PXRMETTH",$J)
     150 D CLEAN^VALM10
     151 D FULL^VALM1
     152 S VALMBCK="Q"
     153 Q
     154 ;
     155HDR ; Header code
     156 S VALMHDR(1)="Extract Summary Name: "_$P($G(^PXRMXT(810.3,IEN,0)),U)
     157 S VALMHDR(2)="      Extract Period: "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,2),"5Z")_" - "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,3),"5Z")
     158 S VALMHDR(2)=VALMHDR(2)_"   Created: "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,6),"5Z")
     159 ;S VALMHDR(3)=VALMHDR(3)_"        Transmitted: "_$$FMTE^XLFDT($P($G(^PXRMXT(810.3,IEN,0)),U,4),"5Z")
     160 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     161 Q
     162 ;
     163HLP ;Help code
     164 N ORU,ORUPRMT,XQORM
     165 S SUB="PXRMETTH"
     166 D EN^VALM("PXRM EXTRACT HELP")
     167 Q
     168 ;
     169INIT ;Init
     170 S VALMCNT=0
     171 Q
     172 ;
     173XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXTRACT SUMMARY SELECT ENTRY",0))_U_"1:"_VALMCNT
     174 S XQORM("A")="Select Item: "
     175 Q
     176 ;
     177XSEL ;PXRM EXTRACT TOTALS SELECT ENTRY validation
     178 N SEL,PLIEN
     179 S SEL=$P(XQORNOD(0),"=",2)
     180 ;Remove trailing ,
     181 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     182 ;Invalid selection
     183 I SEL["," D  Q
     184 .W $C(7),!,"Only one item number allowed." H 2
     185 .S VALMBCK="R"
     186 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
     187 .W $C(7),!,SEL_" is not a valid item number." H 2
     188 .S VALMBCK="R"
     189 ;
     190 ;Get the list ien.
     191 S PLIEN=^TMP("PXRMETT",$J,"SEL",SEL)
     192 ;
     193 D START^PXRMLPP(PLIEN)
     194 ;
     195 S VALMBCK="R"
     196 Q
     197 ;
     198PEXIT ;Protocol exit code
     199 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     200 D XQORM
     201 Q
     202 ;
     203PLIST(IEN) ;Patient list display
     204 N IND,PLIEN,VALMY
     205 D EN^VALM2(XQORNOD(0))
     206 ;If there is no list quit.
     207 I '$D(VALMY) Q
     208 ;PXRMDONE is newed in PXRMLPM
     209 S PXRMDONE=0
     210 S IND=""
     211 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     212 .;Get the ien.
     213 .S PLIEN=^TMP("PXRMETT",$J,"SEL",IND)
     214 .D START^PXRMLPP(PLIEN)
     215 ;
     216 S VALMBCK="R"
     217 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETX.m

    r613 r623  
    1 PXRMETX ; SLC/PJH - Run Extract for QUERI ;11:42 AM  17 Dec 2008
    2         ;;2.0;CLINICAL REMINDERS;**4,6,7**;Feb 04, 2005;Build 1
    3         ; Modified from FOIA VISTA,
    4         ; Copyright (C) 2007 WorldVistA
    5         ;
    6         ; This program is free software; you can redistribute it and/or modify
    7         ; it under the terms of the GNU General Public License as published by
    8         ; the Free Software Foundation; either version 2 of the License, or
    9         ; (at your option) any later version.
    10         ;
    11         ; This program is distributed in the hope that it will be useful,
    12         ; but WITHOUT ANY WARRANTY; without even the implied warranty of
    13         ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14         ; GNU General Public License for more details.
    15         ;
    16         ; You should have received a copy of the GNU General Public License
    17         ; along with this program; if not, write to the Free Software
    18         ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
    19         ;
    20         ;
    21 AUTO(ID,PURGE)  ;Called from option scheduling (#19.2)
    22         N IEN,LIST,LUVALUE,MODE,NEXT
    23         S LUVALUE(1)=ID
    24         D FIND^DIC(810.2,"","","U",.LUVALUE,"","","","","LIST")
    25         ;Get ien of extract parameter
    26         S IEN=$P(LIST("DILIST",2,1),U,1) Q:'IEN
    27         ;Get next extract period
    28         S NEXT=$P($G(^PXRM(810.2,IEN,0)),U,6) Q:NEXT=""
    29         ;Node is Extract and Transmit
    30         S MODE=$S($P($G(^PXRM(810.2,IEN,100)),U)="N":0,1:1)
    31         ;Run extract
    32         D RUN^PXRMETX(IEN,NEXT,MODE,PURGE)
    33         ;Purge Extract Summary
    34         D PRGES^PXRMETXU
    35         ;Purge Patient Lists
    36         D PRGPL^PXRMETXU
    37         Q
    38         ;
    39 GETNAME(NAME,CLASS)     ;Get the extract name.
    40         I '$D(^PXRMXT(810.3,"B",NAME)) Q NAME
    41         N CNT,NEW
    42         S (CNT,NEW)=0
    43         ;If name exists concatenate count
    44         F  D  Q:NEW
    45         .I '$D(^PXRMXT(810.3,"B",NAME)) S NEW=1 Q
    46         .S CNT=CNT+1,NAME=$P(NAME,"/")_"/"_$$RJ^XLFSTR(CNT,2,0)
    47         Q NAME
    48         ;
    49 IHD     ;Monthly IHD Extract, called from option PXRM EXTRACT VA-IHD QUERI.
    50         D AUTO("VA-IHD QUERI","Y")
    51         Q
    52         ;
    53 MAIL(NAME,NEXT,MODE)    ;Completion mail message
    54         N FREQ,TEXT
    55         S FREQ="year"
    56         I $E(NEXT)="M" S FREQ="month"
    57         I $E(NEXT)="Q" S FREQ="quarter"
    58         ;
    59         I MODE=0 S TEXT="Extract and Transmission"
    60         I MODE=1 S TEXT="Extract (No Transmission)"
    61         I MODE=2 S TEXT="Manual Extract and Transmission"
    62         I MODE=3 S TEXT="Manual Extract (No Transmission)"
    63         ;
    64         S TEXT=NAME_" "_TEXT_" completed for "_FREQ_" "_NEXT
    65         D MES^PXRMEUT(TEXT)
    66         Q
    67         ;
    68 MH      ;Monthly MH Extract, called from option PXRM EXTRACT VA-MH QUERI.
    69         D AUTO("VA-MH QUERI","Y")
    70         Q
    71         ;
    72         ;Begin WV change wv/so 12/17/2008
    73         ;
    74 ACAD    ;Auto CAD entry point
    75         D AUTO("VOE DOQ-IT CAD EXTRACTION")
    76         Q
    77         ;
    78 ADM     ;Auto DM entry point
    79         D AUTO("VOE DOQ-IT DM EXTRACTION")
    80         Q
    81         ;
    82 AHF     ;Auto HF entry point
    83         D AUTO("VOE DOQ-IT HF EXTRACTION")
    84         Q
    85         ;
    86 AHTN    ;Auto HTN entry point
    87         D AUTO("VOE DOQ-IT HTN EXTRACTION")
    88         Q
    89         ;
    90 APC     ;Auto PC entry point
    91         D AUTO("VOE DOQ-IT PC EXTRACTION")
    92         Q
    93         ;End WV change
    94         ;
    95 RUN(IEN,NEXT,MODE,PURGE)        ;Process extract parameter
    96         ; IEN is ien of Extract Parameter
    97         ; NEXT is period to extract
    98         ; MODE = 0 is extract and transmission
    99         ; MODE = 1 is extract only
    100         ; MODE = 2 is manual extract and transmission (doesn't update 810.2)
    101         ; MODE = 3 is manual extract only (doesn't update 810.2)
    102         ;
    103         N CLASS,FDA,FDAIEN,MSG
    104         N PXRMIDOD,PXRMLIST,PXRMNODE,PXRMRULE,PXRMSTRT,PXRMXIEN,PATCREAT,XNAME
    105         N ITER
    106         ;Initialise
    107         K ^TMP("PXRMETX",$J),^TMP("PXRMETX1",$J)
    108         ;Workfile node for ^TMP
    109         S PXRMNODE="PXRMRULE"
    110         ;Get details from parameter file
    111         N DATA,INDP,INTP,LIST,NAME,PARTYPE,PERIOD,SNAME,TEXT,YEAR
    112         ;Get class from extract parameter
    113         S CLASS=$P($G(^PXRM(810.2,IEN,100)),U)
    114         ;Otherwise default to local
    115         I $G(CLASS)="" S CLASS="L"
    116         ;
    117         S DATA=$G(^PXRM(810.2,IEN,0))
    118         ;Determine Extract Name and period
    119         S NAME=$P(DATA,U),PARTYPE=$P(DATA,U,2)
    120         S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/")
    121         ;Calculate report period start and end dates
    122         D CALC^PXRMEUT(NEXT,.PXRMSTRT,.PXRMSTOP)
    123         ;Determine output name for patient list and extract summary
    124         S XNAME=NAME_" "_YEAR_" "_PERIOD
    125         S NAME=$$GETNAME(XNAME)
    126         S ITER=$P(NAME,"/",2)
    127         ;Process (single) Denominator rule into patient list
    128         N SEQ,SUB
    129         S SEQ=""
    130         F  S SEQ=$O(^PXRM(810.2,IEN,10,"B",SEQ)) Q:'SEQ  D
    131         .S SUB=$O(^PXRM(810.2,IEN,10,"B",SEQ,"")) Q:'SUB
    132         .S DATA=$G(^PXRM(810.2,IEN,10,SUB,0)) Q:DATA=""
    133         .S PXRMRULE=$P(DATA,U,2) Q:'PXRMRULE
    134         .S LIST=$P(DATA,U,3) Q:LIST=""
    135         .I LIST["yyyy" S LIST=$P(LIST,"yyyy")_YEAR_$P(LIST,"yyyy",2)
    136         .I LIST["nn" S LIST=$P(LIST,"nn")_$E(PERIOD,2,10)_$P(LIST,"nn",2)
    137         .S INDP=+$P(DATA,U,4)
    138         .S INTP=+$P(DATA,U,5)
    139         .;Create new patient list
    140         .I ITER'="" S LIST=LIST_"/"_ITER
    141         .S PATCREAT="Y",PXRMLIST=$$CRLST^PXRMRUL1(LIST,CLASS) Q:'PXRMLIST
    142         .;
    143         .D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,PXRMSTRT,PXRMSTOP,IEN,YEAR,PERIOD,INDP,INTP,ITER)
    144         .;Clear ^TMP lists created for rule
    145         .D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
    146         .;Process reminders and finding rules
    147         .;If include deceased patients is true then set the flag so reminders
    148         .;will be evaluated for deceased patients.
    149         .S PXRMIDOD=$S(INDP:1,1:0)
    150         .D REM^PXRMETXR(SUB,PXRMLIST,PXRMSTRT,PXRMSTOP,PARTYPE)
    151         ;
    152         ;Get the name
    153         ;S NAME=$$GETNAME(XNAME)
    154         ;Create extract summary entry
    155         S FDA(810.3,"+1,",.01)=NAME
    156         S FDA(810.3,"+1,",.02)=PXRMSTRT
    157         S FDA(810.3,"+1,",.03)=PXRMSTOP
    158         S FDA(810.3,"+1,",.06)=$$NOW^XLFDT
    159         S FDA(810.3,"+1,",1)=IEN
    160         S FDA(810.3,"+1,",2)=PARTYPE
    161         S FDA(810.3,"+1,",3)=$E(PERIOD,2,99)
    162         S FDA(810.3,"+1,",4)=YEAR
    163         S FDA(810.3,"+1,",5)=$S(MODE<2:"A",1:"M")
    164         S FDA(810.3,"+1,",7)=$E(PERIOD)
    165         I PURGE="Y" S FDA(810.3,"+1,",50)=1
    166         S FDA(810.3,"+1,",100)=CLASS
    167         D UPDATE^DIE("","FDA","FDAIEN","MSG")
    168         I $D(MSG) D AWRITE^PXRMUTIL("MSG") G EXIT
    169         ;
    170         ;Update extract summary from ^TMP
    171         D UPDEX(FDAIEN(1))
    172         ;
    173         ;Transmit results
    174         I (MODE=0)!(MODE=2) D TRANS(FDAIEN(1))
    175         ;
    176         ;Update extract parameters
    177         I MODE<2 D UPDPAR
    178         ;
    179         ;Mail message that extract completed
    180         D MAIL(NAME,NEXT,MODE)
    181         ;
    182 EXIT    ;Clear workfile
    183         K ^TMP("PXRMETX",$J),^TMP("PXRMETX1",$J)
    184         Q
    185         ;
    186 TRANS(PXRMXIEN) ;Transmit HL7 messages
    187         N HL7ID,NAME,NEXT
    188         S HL7ID=""
    189         D HL7^PXRM7API(PXRMXIEN,1,.HL7ID)
    190         H 2
    191         ;Lock extract summary
    192         D LOCK(PXRMXIEN) Q:$D(DUOUT)
    193         ;Update run information
    194         S NAME=$P($G(^PXRMXT(810.3,PXRMXIEN,0)),U)
    195         S NEXT=$P($G(^PXRMXT(810.3,PXRMXIEN,4)),U,3)
    196         S FDA(810.3,"?1,",.01)=NAME
    197         S FDA(810.36,"?+2,?1,",.01)=HL7ID
    198         S FDA(810.36,"?+2,?1,",.02)=$$NOW^XLFDT
    199         D UPDATE^DIE("","FDA","","MSG")
    200         ;Unlock extract summary
    201         D UNLOCK(PXRMXIEN)
    202         Q
    203         ;
    204 UPDEX(IEN)      ;Update extract summary
    205         N DUOUT
    206         ;Lock extract summary
    207         D LOCK(IEN) Q:$D(DUOUT)
    208         ;
    209         ;Update totals section
    210         N APPL,CNT,DFN,DUE,DATA,ETYP,EVAL
    211         N FAPPL,FCNT,FDATA,FDUE,FEVAL,FGNAM,FGSTA,FIND,FNAPPL,FNDUE,FSEQ
    212         N GDATA,GSEQ,INST,NAPPL,NDUE,PCNT,PXRMLIST,RCNT,RIEN,RSEQ,SEQ,TEMP
    213         S SEQ="",CNT=1,RSEQ=0
    214         F  S SEQ=$O(^TMP("PXRMETX",$J,SEQ)) Q:SEQ=""  D
    215         .S INST=0
    216         .F  S INST=$O(^TMP("PXRMETX",$J,SEQ,INST)) Q:'INST  D
    217         ..S RCNT=""
    218         ..F  S RCNT=$O(^TMP("PXRMETX",$J,SEQ,INST,RCNT)) Q:RCNT=""  D
    219         ...S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT)) Q:'DATA
    220         ...S RIEN=$P(DATA,U,1),EVAL=$P(DATA,U,2),APPL=$P(DATA,U,3)
    221         ...S NAPPL=$P(DATA,U,4),DUE=$P(DATA,U,5),NDUE=$P(DATA,U,6)
    222         ...S PXRMLIST=$P(DATA,U,7)
    223         ...S CNT=CNT+1,RSEQ=RSEQ+1
    224         ...S TEMP=$$RJ^XLFSTR(RSEQ,3,0)_U_RIEN_U_INST_U_PXRMLIST_U_EVAL_U_APPL_U_NAPPL_U_DUE_U_NDUE
    225         ...S ^PXRMXT(810.3,IEN,3,RSEQ,0)=TEMP
    226         ...S ^PXRMXT(810.3,IEN,3,"B",$P(TEMP,U,1),RSEQ)=""
    227         ...;For each count type
    228         ...S GSEQ="",FCNT=0
    229         ...F  S GSEQ=$O(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ)) Q:GSEQ=""  D
    230         ....S GDATA=$G(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ))
    231         ....S FGNAM=$P(GDATA,U),ETYP=$P(GDATA,U,2),FGSTA=$P(GDATA,U,3)
    232         ....;For each term
    233         ....S FSEQ=0
    234         ....F  S FSEQ=$O(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)) Q:FSEQ=""  D
    235         .....;Get the term ien
    236         .....S FIND=$P($G(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)),U),FCNT=FCNT+1
    237         .....;Update finding totals
    238         .....S FDATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ))
    239         .....S FEVAL=$P(FDATA,U,2),FAPPL=$P(FDATA,U,3),FNAPPL=$P(FDATA,U,4)
    240         .....S FDUE=$P(FDATA,U,5),FNDUE=$P(FDATA,U,6)
    241         .....S TEMP=FSEQ_U_$P(FIND,";")_U_ETYP_U_FEVAL_U_FAPPL_U_FNAPPL_U_FDUE_U_FNDUE_U_FGNAM_U_FGSTA
    242         .....S ^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,0)=TEMP
    243         .....;
    244         .....;AGP REMOVE UNTIL A DECISION CAN BE MADE
    245         .....;S DFN=0,PCNT=0
    246         .....;F  S DFN=$O(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ,DFN)) Q:DFN'>0  D
    247         .....;.S PCNT=PCNT+1,^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,1,PCNT,0)=DFN
    248         .....;I PCNT>0 S ^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,1,0)="^810.3316PA"_U_PCNT_U_PCNT
    249         ....I FCNT>0 S ^PXRMXT(810.3,IEN,3,RSEQ,1,0)="^810.331I"_U_FCNT_U_FCNT
    250         .I RSEQ>0 S ^PXRMXT(810.3,IEN,3,0)="^810.33I"_U_RSEQ_U_RSEQ
    251         ;Unlock extract summary
    252         D UNLOCK(IEN)
    253         Q
    254         ;
    255         ;File locking
    256 LOCK(PXRMXIEN)  L +^PXRMXT(810.3,PXRMXIEN):0
    257         I '$T W !!?5,"Another user is using this extract summary" S DUOUT=1
    258         Q
    259         ;
    260 UNLOCK(PXRMXIEN)        L -^PXRMXT(810.3,PXRMXIEN) Q
    261         ;
    262 UPDPAR  ;Update parameters when run complete
    263         N DATA,LAST,NEXT,PERIOD,TYPE,YEAR
    264         S DATA=$G(^PXRM(810.2,IEN,0)),NEXT=$P(DATA,U,6),TYPE=$P(DATA,U,3)
    265         ;Last run updated
    266         S LAST=NEXT
    267         ;Calculate next run
    268         I TYPE="Y" S NEXT=NEXT+1
    269         I "QM"[TYPE D
    270         .N NUM
    271         .S PERIOD=$P(NEXT,"/",1),YEAR=$P(NEXT,"/",2)
    272         .S NUM=$P(PERIOD,TYPE,2)+1
    273         .I TYPE="Q",NUM>4 S NUM=1,YEAR=YEAR+1
    274         .I TYPE="M",NUM>12 S NUM=1,YEAR=YEAR+1
    275         .S NEXT=TYPE_NUM_"/"_YEAR
    276         ;Update last and next run fields
    277         S $P(^PXRM(810.2,IEN,0),U,4,6)=LAST_U_$$NOW^XLFDT_U_NEXT
    278         Q
    279         ;
     1PXRMETX ; SLC/PJH - Run Extract for QUERI ;1/22/07  21:25
     2 ;;2.0;CLINICAL REMINDERS;**4,7**;Feb 04, 2005;Build 14
     3 ; Modified from FOIA VISTA,
     4 ; Copyright (C) 2007 WorldVistA
     5 ;
     6 ; This program is free software; you can redistribute it and/or modify
     7 ; it under the terms of the GNU General Public License as published by
     8 ; the Free Software Foundation; either version 2 of the License, or
     9 ; (at your option) any later version.
     10 ;
     11 ; This program is distributed in the hope that it will be useful,
     12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 ; GNU General Public License for more details.
     15 ;
     16 ; You should have received a copy of the GNU General Public License
     17 ; along with this program; if not, write to the Free Software
     18 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
     19 ;
     20AUTO(ID,PURGE) ;Called from option scheduling (#19.2)
     21 N IEN,LIST,LUVALUE,MODE,NEXT
     22 S LUVALUE(1)=ID
     23 D FIND^DIC(810.2,"","","U",.LUVALUE,"","","","","LIST")
     24 ;Get ien of extract parameter
     25 S IEN=$P(LIST("DILIST",2,1),U,1) Q:'IEN
     26 ;Get next extract period
     27 S NEXT=$P($G(^PXRM(810.2,IEN,0)),U,6) Q:NEXT=""
     28 ;Node is Extract and Transmit
     29 S MODE=$S($P($G(^PXRM(810.2,IEN,100)),U)="N":0,1:1)
     30 ;Run extract
     31 D RUN^PXRMETX(IEN,NEXT,MODE,PURGE)
     32 ;Purge Extract Summary
     33 D PRGES^PXRMETXU
     34 ;Purge Patient Lists
     35 D PRGPL^PXRMETXU
     36 ;Call the DOQ-IT HL7 generating routine
     37 ;D EXTRACT^VEPER7EX(VDATA(810.2,IEN_",",3,"I"),VDATA(810.2,IEN_",",5,"I"))
     38 Q
     39 ;
     40GETNAME(NAME,CLASS) ;Get the extract name.
     41 I '$D(^PXRMXT(810.3,"B",NAME)) Q NAME
     42 N CNT,NEW
     43 S (CNT,NEW)=0
     44 ;If name exists concatenate count
     45 F  D  Q:NEW
     46 .I '$D(^PXRMXT(810.3,"B",NAME)) S NEW=1 Q
     47 .S CNT=CNT+1,NAME=$P(NAME,"/")_"/"_$$RJ^XLFSTR(CNT,2,0)
     48 Q NAME
     49 ;
     50IHD ;Monthly IHD Extract, called from option PXRM EXTRACT VA-IHD QUERI.
     51 D AUTO("VA-IHD QUERI","Y")
     52 Q
     53 ;
     54MAIL(NAME,NEXT,MODE) ;Completion mail message
     55 N FREQ,TEXT
     56 S FREQ="year"
     57 I $E(NEXT)="M" S FREQ="month"
     58 I $E(NEXT)="Q" S FREQ="quarter"
     59 ;
     60 I MODE=0 S TEXT="Extract and Transmission"
     61 I MODE=1 S TEXT="Extract (No Transmission)"
     62 I MODE=2 S TEXT="Manual Extract and Transmission"
     63 I MODE=3 S TEXT="Manual Extract (No Transmission)"
     64 ;
     65 S TEXT=NAME_" "_TEXT_" completed for "_FREQ_" "_NEXT
     66 D MES^PXRMEUT(TEXT)
     67 Q
     68 ;
     69MH ;Monthly MH Extract, called from option PXRM EXTRACT VA-MH QUERI.
     70 D AUTO("VA-MH QUERI","Y")
     71 Q
     72 ;
     73ACAD ;Auto CAD entry point
     74 D AUTO("VOE DOQ-IT CAD EXTRACTION")
     75 Q
     76 ;
     77ADM ;Auto DM entry point
     78 D AUTO("VOE DOQ-IT DM EXTRACTION")
     79 Q
     80 ;
     81AHF ;Auto HF entry point
     82 D AUTO("VOE DOQ-IT HF EXTRACTION")
     83 Q
     84 ;
     85AHTN ;Auto HTN entry point
     86 D AUTO("VOE DOQ-IT HTN EXTRACTION")
     87 Q
     88 ;
     89APC ;Auto PC entry point
     90 D AUTO("VOE DOQ-IT PC EXTRACTION")
     91 Q
     92 ;
     93RUN(IEN,NEXT,MODE,PURGE) ;Process extract parameter
     94 ; IEN is ien of Extract Parameter
     95 ; NEXT is period to extract
     96 ; MODE = 0 is extract and transmission
     97 ; MODE = 1 is extract only
     98 ; MODE = 2 is manual extract and transmission (doesn't update 810.2)
     99 ; MODE = 3 is manual extract only (doesn't update 810.2)
     100 ;
     101 N CLASS,FDA,FDAIEN,MSG
     102 N PXRMLIST,PXRMNODE,PXRMRULE,PXRMSTRT,PXRMXIEN,PATCREAT,XNAME
     103 ;Initialise
     104 K ^TMP("PXRMETX",$J),^TMP("PXRMETX1",$J)
     105 ;Workfile node for ^TMP
     106 S PXRMNODE="PXRMRULE"
     107 ;Get details from parameter file
     108 N DATA,INDP,INTP,LIST,NAME,PARTYPE,PERIOD,SNAME,TEXT,YEAR
     109 ;Get class from extract parameter
     110 S CLASS=$P($G(^PXRM(810.2,IEN,100)),U)
     111 ;Otherwise default to local
     112 I $G(CLASS)="" S CLASS="L"
     113 ;
     114 S DATA=$G(^PXRM(810.2,IEN,0))
     115 ;Determine Extract Name and period
     116 S NAME=$P(DATA,U),PARTYPE=$P(DATA,U,2)
     117 S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/")
     118 ;Calculate report period start and end dates
     119 D CALC^PXRMEUT(NEXT,.PXRMSTRT,.PXRMSTOP)
     120 ;Determine output name for patient list and extract summary
     121 S XNAME=NAME_" "_YEAR_" "_PERIOD
     122 ;Process (single) Denominator rule into patient list
     123 N SEQ,SUB
     124 S SEQ=""
     125 F  S SEQ=$O(^PXRM(810.2,IEN,10,"B",SEQ)) Q:'SEQ  D
     126 .S SUB=$O(^PXRM(810.2,IEN,10,"B",SEQ,"")) Q:'SUB
     127 .S DATA=$G(^PXRM(810.2,IEN,10,SUB,0)) Q:DATA=""
     128 .S PXRMRULE=$P(DATA,U,2) Q:'PXRMRULE
     129 .S LIST=$P(DATA,U,3) Q:LIST=""
     130 .I LIST["yyyy" S LIST=$P(LIST,"yyyy")_YEAR_$P(LIST,"yyyy",2)
     131 .I LIST["nn" S LIST=$P(LIST,"nn")_$E(PERIOD,2,10)_$P(LIST,"nn",2)
     132 .S INDP=+$P(DATA,U,4)
     133 .S INTP=+$P(DATA,U,5)
     134 .;Create new patient list
     135 .S PATCREAT="Y",PXRMLIST=$$CRLST^PXRMRULE(LIST,CLASS) Q:'PXRMLIST
     136 .;
     137 .D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,PXRMSTRT,PXRMSTOP,IEN,YEAR,PERIOD,INDP,INTP)
     138 .;Clear ^TMP lists created for rule
     139 .D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
     140 .;Process reminders and finding rules
     141 .D REM^PXRMETXR(SUB,PXRMLIST,PXRMSTRT,PXRMSTOP,PARTYPE)
     142 ;
     143 ;Get the name
     144 S NAME=$$GETNAME(XNAME)
     145 ;Create extract summary entry
     146 S FDA(810.3,"+1,",.01)=NAME
     147 S FDA(810.3,"+1,",.02)=PXRMSTRT
     148 S FDA(810.3,"+1,",.03)=PXRMSTOP
     149 S FDA(810.3,"+1,",.06)=$$NOW^XLFDT
     150 S FDA(810.3,"+1,",1)=IEN
     151 S FDA(810.3,"+1,",2)=PARTYPE
     152 S FDA(810.3,"+1,",3)=$E(PERIOD,2,99)
     153 S FDA(810.3,"+1,",4)=YEAR
     154 S FDA(810.3,"+1,",5)=$S(MODE<2:"A",1:"M")
     155 S FDA(810.3,"+1,",7)=$E(PERIOD)
     156 I PURGE="Y" S FDA(810.3,"+1,",50)=1
     157 S FDA(810.3,"+1,",100)=CLASS
     158 D UPDATE^DIE("","FDA","FDAIEN","MSG")
     159 I $D(MSG) D AWRITE^PXRMUTIL("MSG") G EXIT
     160 ;
     161 ;Update extract summary from ^TMP
     162 D UPDEX(FDAIEN(1))
     163 ;
     164 ;Transmit results
     165 I (MODE=0)!(MODE=2) D TRANS(FDAIEN(1))
     166 ;
     167 I $$GET^XPAR("SYS","DOQ-IT")="YES" D EXTRACT^VEPER7EX(VDATA(810.2,IEN_",",3,"I"),VDATA(810.2,IEN_",",5,"I"),PXRMLIST)
     168 ;
     169 ;Update extract parameters
     170 I MODE<2 D UPDPAR
     171 ;
     172 ;Mail message that extract completed
     173 D MAIL(NAME,NEXT,MODE)
     174 ;
     175EXIT ;Clear workfile
     176 K ^TMP("PXRMETX",$J),^TMP("PXRMETX1",$J)
     177 Q
     178 ;
     179TRANS(PXRMXIEN) ;Transmit HL7 messages
     180 N HL7ID,NAME,NEXT
     181 S HL7ID=""
     182 D HL7^PXRM7API(PXRMXIEN,1,.HL7ID)
     183 H 2
     184 ;Lock extract summary
     185 D LOCK(PXRMXIEN) Q:$D(DUOUT)
     186 ;Update run information
     187 S NAME=$P($G(^PXRMXT(810.3,PXRMXIEN,0)),U)
     188 S NEXT=$P($G(^PXRMXT(810.3,PXRMXIEN,4)),U,3)
     189 S FDA(810.3,"?1,",.01)=NAME
     190 S FDA(810.36,"?+2,?1,",.01)=HL7ID
     191 S FDA(810.36,"?+2,?1,",.02)=$$NOW^XLFDT
     192 D UPDATE^DIE("","FDA","","MSG")
     193 ;Unlock extract summary
     194 D UNLOCK(PXRMXIEN)
     195 Q
     196 ;
     197UPDEX(IEN) ;Update extract summary
     198 N DUOUT
     199 ;Lock extract summary
     200 D LOCK(IEN) Q:$D(DUOUT)
     201 ;
     202 ;Update totals section
     203 N APPL,CNT,DFN,DUE,DATA,ETYP,EVAL
     204 N FAPPL,FCNT,FDATA,FDUE,FEVAL,FGNAM,FGSTA,FIND,FNAPPL,FNDUE,FSEQ
     205 N GDATA,GSEQ,INST,NAPPL,NDUE,PCNT,PXRMLIST,RCNT,RIEN,RSEQ,SEQ,TEMP
     206 S SEQ="",CNT=1,RSEQ=0
     207 F  S SEQ=$O(^TMP("PXRMETX",$J,SEQ)) Q:SEQ=""  D
     208 .S INST=0
     209 .F  S INST=$O(^TMP("PXRMETX",$J,SEQ,INST)) Q:'INST  D
     210 ..S RCNT=""
     211 ..F  S RCNT=$O(^TMP("PXRMETX",$J,SEQ,INST,RCNT)) Q:RCNT=""  D
     212 ...S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT)) Q:'DATA
     213 ...S RIEN=$P(DATA,U,1),EVAL=$P(DATA,U,2),APPL=$P(DATA,U,3)
     214 ...S NAPPL=$P(DATA,U,4),DUE=$P(DATA,U,5),NDUE=$P(DATA,U,6)
     215 ...S PXRMLIST=$P(DATA,U,7)
     216 ...S CNT=CNT+1,RSEQ=RSEQ+1
     217 ...S TEMP=$$RJ^XLFSTR(RSEQ,3,0)_U_RIEN_U_INST_U_PXRMLIST_U_EVAL_U_APPL_U_NAPPL_U_DUE_U_NDUE
     218 ...S ^PXRMXT(810.3,IEN,3,RSEQ,0)=TEMP
     219 ...S ^PXRMXT(810.3,IEN,3,"B",$P(TEMP,U,1),RSEQ)=""
     220 ...;For each count type
     221 ...S GSEQ="",FCNT=0
     222 ...F  S GSEQ=$O(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ)) Q:GSEQ=""  D
     223 ....S GDATA=$G(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ))
     224 ....S FGNAM=$P(GDATA,U),ETYP=$P(GDATA,U,2),FGSTA=$P(GDATA,U,3)
     225 ....;For each term
     226 ....S FSEQ=0
     227 ....F  S FSEQ=$O(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)) Q:FSEQ=""  D
     228 .....;Get the term ien
     229 .....S FIND=$P($G(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)),U),FCNT=FCNT+1
     230 .....;Update finding totals
     231 .....S FDATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ))
     232 .....S FEVAL=$P(FDATA,U,2),FAPPL=$P(FDATA,U,3),FNAPPL=$P(FDATA,U,4)
     233 .....S FDUE=$P(FDATA,U,5),FNDUE=$P(FDATA,U,6)
     234 .....S TEMP=FSEQ_U_$P(FIND,";")_U_ETYP_U_FEVAL_U_FAPPL_U_FNAPPL_U_FDUE_U_FNDUE_U_FGNAM_U_FGSTA
     235 .....S ^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,0)=TEMP
     236 .....;
     237 .....;AGP REMOVE UNTIL A DECISION CAN BE MADE
     238 .....;S DFN=0,PCNT=0
     239 .....;F  S DFN=$O(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ,DFN)) Q:DFN'>0  D
     240 .....;.S PCNT=PCNT+1,^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,1,PCNT,0)=DFN
     241 .....;I PCNT>0 S ^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,1,0)="^810.3316PA"_U_PCNT_U_PCNT
     242 ....I FCNT>0 S ^PXRMXT(810.3,IEN,3,RSEQ,1,0)="^810.331I"_U_FCNT_U_FCNT
     243 .I RSEQ>0 S ^PXRMXT(810.3,IEN,3,0)="^810.33I"_U_RSEQ_U_RSEQ
     244 ;Unlock extract summary
     245 D UNLOCK(IEN)
     246 Q
     247 ;
     248 ;File locking
     249LOCK(PXRMXIEN) L +^PXRMXT(810.3,PXRMXIEN):0
     250 I '$T W !!?5,"Another user is using this extract summary" S DUOUT=1
     251 Q
     252 ;
     253UNLOCK(PXRMXIEN) L -^PXRMXT(810.3,PXRMXIEN) Q
     254 ;
     255UPDPAR ;Update parameters when run complete
     256 N DATA,LAST,NEXT,PERIOD,TYPE,YEAR
     257 S DATA=$G(^PXRM(810.2,IEN,0)),NEXT=$P(DATA,U,6),TYPE=$P(DATA,U,3)
     258 ;Last run updated
     259 S LAST=NEXT
     260 ;Calculate next run
     261 I TYPE="Y" S NEXT=NEXT+1
     262 I "QM"[TYPE D
     263 .N NUM
     264 .S PERIOD=$P(NEXT,"/",1),YEAR=$P(NEXT,"/",2)
     265 .S NUM=$P(PERIOD,TYPE,2)+1
     266 .I TYPE="Q",NUM>4 S NUM=1,YEAR=YEAR+1
     267 .I TYPE="M",NUM>12 S NUM=1,YEAR=YEAR+1
     268 .S NEXT=TYPE_NUM_"/"_YEAR
     269 ;Update last and next run fields
     270 S $P(^PXRM(810.2,IEN,0),U,4,6)=LAST_U_$$NOW^XLFDT_U_NEXT
     271 Q
     272 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETXR.m

    r613 r623  
    1 PXRMETXR        ; SLC/PJH,PKR - Reminder section of extract ;02/22/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMETX
    5         ;
    6 DATE    ;Check if finding is most recent in evaluation group
    7         N FDATE,GDATE
    8         ;Determine finding date and existing group date
    9         S FDATE=$G(FIEV(FNUM,"DATE")),GDATE=$G(GROUP(GSEQ,"DATE")) Q:FDATE=""
    10         ;Ignore findings outside to the extract period
    11         ;I $$FMDIFF^XLFDT(PXRMSTRT,FDATE,2)>0 Q
    12         ;If this is first or only entry in group then save finding date
    13         I 'GDATE S GROUP(GSEQ,"DATE")=FDATE,GROUP(GSEQ)=FSEQ Q
    14         ;Save finding if most recent date for the group
    15         I $$FMDIFF^XLFDT(FDATE,GDATE,2)>0 S GROUP(GSEQ,"DATE")=FDATE,GROUP(GSEQ)=FSEQ Q
    16         Q
    17         ;
    18 FIND(SEQ,RCNT,PXRMSTRT,PXRMSTOP)        ;Process findings for reminder
    19         ;Default is extract no findings
    20         N DATA,FCNT,FIEN,FIND,FNUM,FSEQ,GDATA,GROUP,GSEQ,GTYP
    21         S FNUM=0,FCNT=0
    22         F  S FNUM=$O(FIEV(FNUM)) Q:'FNUM  D
    23         .;Ignore if not found for patient
    24         .I +FIEV(FNUM)=0 Q
    25         .;Only terms are counted
    26         .S FIND=$G(FIEV(FNUM,"TERM IEN")) Q:FIND=""
    27         .;Check if in list to be accumulated
    28         .I '$D(REM(RCNT,FIND)) Q
    29         .;Find groups to which finding belongs
    30         .S GSEQ=""
    31         .F  S GSEQ=$O(REM(RCNT,FIND,GSEQ)) Q:GSEQ=""  D
    32         ..;Determine Evaluation type
    33         ..S GTYP=REM(RCNT,FIND,GSEQ)
    34         ..;Ignore utilization groups
    35         ..I GTYP="UR" Q
    36         ..;Sequence determines where the finding will be stored
    37         ..S FSEQ=""
    38         ..F  S FSEQ=$O(REM(RCNT,FIND,GSEQ,FSEQ)) Q:FSEQ=""  D
    39         ...;Evaluation Group logic to save latest entry only
    40         ...I GTYP="MRFP" D DATE Q
    41         ...;Save finding totals
    42         ...D UPD(1)
    43         ;
    44         ;Check for group totals
    45         S GSEQ=""
    46         F  S GSEQ=$O(GROUP(GSEQ)) Q:GSEQ=""  D
    47         .S GDATA=$G(GROUP(GSEQ)) Q:GDATA=""
    48         .;Update if found
    49         .S FSEQ=$P(GDATA,U) D UPD(1)
    50         ;
    51         ;Utilization counts are done separately
    52         N CNT,FDATA,FIND,FINDPA,FTIEN,GTYP,TERMARR,TFIEVAL
    53         ;modify start date to include incomplete dates
    54         I $E(PXRMSTRT,6,7)="01" S PXRMSTRT=$E(PXRMSTRT,1,5)_"00"
    55         ;Include incomplete dates in January
    56         I $E(PXRMSTRT,4,5)="01" S PXRMSTRT=$E(PXRMSTRT,1,3)_"0000"
    57         ;Set start and stop dates for term
    58         ;S $P(FINDPA(0),U,8)=PXRMSTRT,$P(FINDPA(0),U,11)=PXRMSTOP
    59         S $P(FINDPA(0),U,11)=PXRMSTOP
    60         ;Count all entries
    61         S $P(FINDPA(0),U,14)="*"
    62         ;
    63         S FTIEN="",GTYP="UR"
    64         F  S FTIEN=$O(FUTIL(RCNT,FTIEN)) Q:FTIEN=""  D
    65         .S GSEQ=""
    66         .F  S GSEQ=$O(FUTIL(RCNT,FTIEN,GSEQ)) Q:GSEQ=""  D
    67         ..S FSEQ=""
    68         ..F  S FSEQ=$O(FUTIL(RCNT,FTIEN,GSEQ,FSEQ)) Q:FSEQ=""  D
    69         ...;Recover list of term findings
    70         ...K TERMARR M TERMARR=FUTIL(RCNT,FTIEN,GSEQ,FSEQ)
    71         ...;Process term
    72         ...K TFIEVAL D EVALTERM^PXRMTERM(DFN,.FINDPA,.TERMARR,.TFIEVAL)
    73         ...D URCNT(PXRMSTRT,PXRMSTOP,.TFIEVAL)
    74         ;Determine count from PLIST then add to ETX
    75         ;S CNT=+$O(PLIST(1,999999),-1) Q:'CNT
    76         ;D UPD(CNT)
    77         Q
    78         ;
    79 FRULE(FRIEN,RCNT,SEQ,REM,FUTIL) ;Build array of findings in the finding rule
    80         N DATA,FIND,FSEQ,GIEN,GNAM,GSEQ,GTYP,GSTA,SUB,TLIST
    81         S GSEQ=0
    82         F  S GSEQ=$O(^PXRM(810.7,FRIEN,10,"B",GSEQ)) Q:GSEQ=""  D
    83         .S SUB=$O(^PXRM(810.7,FRIEN,10,"B",GSEQ,"")) Q:'SUB
    84         .S DATA=$G(^PXRM(810.7,FRIEN,10,SUB,0)) Q:DATA=""
    85         .;Get the finding group ien and reminder status
    86         .S GIEN=$P(DATA,U,2),GSTA=$P(DATA,U,3) Q:'GIEN
    87         .;If no status then report finding totals for all patients
    88         .I GSTA="" S GSTA="T"
    89         .;Get finding group info
    90         .S DATA=$G(^PXRM(810.8,GIEN,0)) Q:DATA=""
    91         .;Get group name and count type
    92         .S GTYP=$P(DATA,U,3),GNAM=$P(DATA,U) Q:GTYP=""
    93         .;Save group in workfile
    94         .S ^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ)=GNAM_U_GTYP_U_GSTA
    95         .;Get all findings in group
    96         .S FSEQ=0
    97         .F  S FSEQ=$O(^PXRM(810.8,GIEN,10,"B",FSEQ)) Q:FSEQ=""  D
    98         ..S SUB=$O(^PXRM(810.8,GIEN,10,"B",FSEQ,"")) Q:'SUB
    99         ..S DATA=$G(^PXRM(810.8,GIEN,10,SUB,0)) Q:DATA=""
    100         ..;Get the finding ien and exclusion status
    101         ..S FIND=$P(DATA,U,2) Q:'FIND
    102         ..;Initialize count for finding
    103         ..S ^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)=FIND
    104         ..;Reminder evaluation counts work from REM
    105         ..I GTYP'="UR" D  Q
    106         ...S REM(RCNT,FIND,GSEQ,FSEQ)=""
    107         ...S REM(RCNT,FIND,GSEQ)=GTYP
    108         ..;Utilization counts work from FUTIL
    109         ..D TERM^PXRMLDR(FIND,.TLIST)
    110         ..;Save TLIST
    111         ..M FUTIL(RCNT,FIND,GSEQ,FSEQ)=TLIST
    112         Q
    113         ;
    114 REM(SUB,PXRMLIST,PXRMSTRT,PXRMSTOP,PARTYPE)     ;Run reminders against patient
    115         ;lists.
    116         N APPL,DATA,DEFARR,DEFSITE,DFN,DUE,FIEV,FRIEN,FUTIL,IND,INST
    117         N PXRMDATE,RCNT,REM,REMSEQ,RIEN,RNAM,STATUS,SUB1,TODAY
    118         N END,START
    119         ;S START=$H
    120         S TODAY=$$DT^XLFDT
    121         ;Evaluation date is period end except if the period is incomplete
    122         S PXRMDATE=$S($$FMDIFF^XLFDT(PXRMSTOP,TODAY,2)>0:TODAY,1:PXRMSTOP)
    123         ;Scan reminders for this parameter set
    124         S (RCNT,SUB1)=0
    125         S REMSEQ=""
    126         F  S REMSEQ=$O(^PXRM(810.2,IEN,10,SUB,10,"B",REMSEQ)) Q:REMSEQ=""  D
    127         .F  S SUB1=$O(^PXRM(810.2,IEN,10,SUB,10,"B",REMSEQ,SUB1)) Q:'SUB1  D
    128         ..S DATA=$G(^PXRM(810.2,IEN,10,SUB,10,SUB1,0)) Q:DATA=""
    129         ..;Reminder ien
    130         ..S RIEN=$P(DATA,U,2) Q:'RIEN
    131         ..;Evaluation date is period end except if the period is incomplete.
    132         ..S PXRMDATE=$S($$FMDIFF^XLFDT(PXRMSTOP,TODAY,2)>0:TODAY,1:PXRMSTOP)
    133         ..;Finding Rule
    134         ..S FRIEN=$P(DATA,U,3)
    135         ..;Reminder print name
    136         ..S RNAM=$P($G(^PXD(811.9,RIEN,0)),U,3)
    137         ..I RNAM="" S RNAM=$P(^PXD(811.9,RIEN,0),U,1)
    138         ..;Save details to REM array
    139         ..S RCNT=RCNT+1,REM(RCNT)=RIEN_U_RNAM_U_FRIEN
    140         ..;Build list of terms from extract finding rule #810.7
    141         ..I FRIEN D FRULE(FRIEN,RCNT,SEQ,.REM,.FUTIL) Q
    142         ..;If no extract finding rule defined collect all findings in reminder
    143         ..I 'FRIEN D REMF(RIEN,RCNT,SEQ,.REM)
    144         ;
    145         ;Process patient list
    146         S IND=0,DEFSITE=+$P($$SITE^VASITE,U,3)
    147         F  S IND=$O(^PXRMXP(810.5,PXRMLIST,30,IND)) Q:'IND  D
    148         .S DFN=$P($G(^PXRMXP(810.5,PXRMLIST,30,IND,0)),U) Q:'DFN
    149         .S INST=$P($G(^PXRMXP(810.5,PXRMLIST,30,IND,0)),U,2)
    150         .I INST="" S INST=DEFSITE
    151         .S RCNT=0
    152         .F  S RCNT=$O(REM(RCNT)) Q:'RCNT  D
    153         ..S RIEN=$P(REM(RCNT),U),RNAM=$P(REM(RCNT),U,2),FRIEN=$P(REM(RCNT),U,3)
    154         ..;Clear evaluation arrays.
    155         ..K ^TMP("PXRHM",$J),^TMP("PXRMID",$J),FIEV
    156         ..;Evaluate reminders and store results
    157         ..D DEF^PXRMLDR(RIEN,.DEFARR)
    158         ..D EVAL^PXRM(DFN,.DEFARR,1,1,.FIEV,PXRMDATE)
    159         ..;Determine update from reminder status
    160         ..S STATUS=$P($G(^TMP("PXRHM",$J,RIEN,RNAM)),U) I STATUS="" Q
    161         ..;Ignore not applicables
    162         ..S APPL=$S(STATUS["DUE":1,STATUS="RESOLVED":1,STATUS="DONE":1,1:0)
    163         ..;Check if due
    164         ..S DUE=$S(STATUS="DUE NOW":1,1:0)
    165         ..;Compliance totals
    166         ..S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT))
    167         ..;Reminder ien
    168         ..I $P(DATA,U)="" S $P(DATA,U)=RIEN
    169         ..;Evaluated total
    170         ..S $P(DATA,U,2)=$P(DATA,U,2)+1
    171         ..;Applicable total
    172         ..S $P(DATA,U,3)=$P(DATA,U,3)+APPL
    173         ..;Not applicable total
    174         ..I 'APPL,'DUE S $P(DATA,U,4)=$P(DATA,U,4)+1
    175         ..;Due total
    176         ..S $P(DATA,U,5)=$P(DATA,U,5)+DUE
    177         ..;Not due count
    178         ..I APPL,'DUE S $P(DATA,U,6)=$P(DATA,U,6)+1
    179         ..;Add patient list
    180         ..I $P(DATA,U,7)="" S $P(DATA,U,7)=PXRMLIST
    181         ..;Update workfile
    182         ..S ^TMP("PXRMETX",$J,SEQ,INST,RCNT)=DATA
    183         ..;Save finding totals
    184         ..I PARTYPE="CF" D FIND(SEQ,RCNT,PXRMSTRT,PXRMSTOP)
    185         ;Clear evaluation fields
    186         K ^TMP("PXRHM",$J),^TMP("PXRMID",$J)
    187         ;S END=$H
    188         ;W !,"REMINDER EVALUATION TIME"
    189         ;D DETIME^PXRMXSEL(START,END)
    190         Q
    191         ;
    192 REMF(RIEN,RCNT,SEQ,REM) ;Build array of all findings in the reminder
    193         N GNAM,GSEQ,FIND,FSEQ,GTYP,SUB
    194         S GNAM="Finding totals",GSEQ="001",FSEQ=0,GTYP="MRF"
    195         ;Save group name
    196         S ^TMP("PXRMETX",$J,SEQ,RCNT,GSEQ)=GNAM_U_GTYP
    197         ;Select all findings in the reminder
    198         S SUB=0
    199         F  S SUB=$O(^PXD(811.9,RIEN,20,SUB)) Q:'SUB  D
    200         .;Ignore if finding is not a term
    201         .S FIND=$P($G(^PXD(811.9,RIEN,20,SUB,0)),U) Q:FIND'["PXRMD(811.5"
    202         .;Convert to term ien
    203         .S FIND=$P(FIND,";")
    204         .;Build sequence number
    205         .S FSEQ=FSEQ+1,FSEQ=$$RJ^XLFSTR(FSEQ,3,0)
    206         .;Evaluation counts
    207         .S REM(RCNT,FIND,GSEQ,FSEQ)=""
    208         .S REM(RCNT,FIND,GSEQ)=GTYP
    209         .;Update Workfile
    210         .S ^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)=FIND
    211         Q
    212         ;
    213 URCNT(PXRMSTRT,PXRMSTOP,TFIEVAL)        ;
    214         ;Handle counting all valid occurrences for the finding items.
    215         ;Includes historical entries that were entered within the reporting
    216         ;period, cut the encounter date if it is outside the reporting period.
    217         N CNT,DATEENT,FDATE,FILE,FNUM,FOCCNUM,HIST,NODE,SCAT,VIEN
    218         S CNT=0,FNUM=0
    219         F  S FNUM=$O(TFIEVAL(FNUM)) Q:FNUM'>0  D
    220         .S FILE=$G(TFIEVAL(FNUM,"FILE NUMBER"))
    221         .S HIST=$S(FILE=9000010.18:1,FILE=9000010.13:1,FILE=9000010.23:1,FILE=9000010.16:1,FILE=9000010.07:1,FILE=9000010.12:1,FILE=9000010.15:1,1:0)
    222         .S FOCCNUM=0 F  S FOCCNUM=$O(TFIEVAL(FNUM,FOCCNUM)) Q:FOCCNUM'>0  D
    223         ..S FDATE=$P(TFIEVAL(FNUM,FOCCNUM,"DATE"),".") Q:FDATE'>0
    224         ..I HIST=0,FDATE=PXRMSTRT!(FDATE>PXRMSTRT) S CNT=CNT+1
    225         ..I HIST=1 D
    226         ...S VIEN=TFIEVAL(FNUM,FOCCNUM,"VISIT") Q:VIEN'>0
    227         ...S NODE=$G(^AUPNVSIT(VIEN,0))
    228         ...S SCAT=$P(NODE,U,7),DATEENT=$P($P(NODE,U,2),".")
    229         ...I FDATE=PXRMSTRT!(FDATE>PXRMSTRT),SCAT'="E" S CNT=CNT+1 Q
    230         ...I SCAT="E",(DATEENT=PXRMSTRT!(DATEENT>PXRMSTRT))&(DATEENT=PXRMSTOP!(DATEENT<PXRMSTOP)) S CNT=CNT+1
    231         D UPD(CNT)
    232         Q
    233         ;
    234 UPD(CNT)        ;Update totals
    235         S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ))
    236         ;Total count
    237         S $P(DATA,U,2)=$P(DATA,U,2)+CNT
    238         ;Applicable count
    239         S $P(DATA,U,3)=$P(DATA,U,3)+(APPL*CNT)
    240         ;Not applicable count
    241         I 'APPL,'DUE S $P(DATA,U,4)=$P(DATA,U,4)+CNT
    242         ;Due count
    243         S $P(DATA,U,5)=$P(DATA,U,5)+(DUE*CNT)
    244         ;Not due count
    245         I APPL,'DUE S $P(DATA,U,6)=$P(DATA,U,6)+CNT
    246         ;Update current count
    247         S ^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ)=DATA
    248         ;AGP REMOVE UNTIL A DECISION CAN BE MADE
    249         ;I CNT=1,APPL=1 S ^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ,DFN)=DFN
    250         Q
    251         ;
     1PXRMETXR ; SLC/PJH,PKR - Reminder section of extract ;05/01/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRMETX
     5 ;
     6DATE ;Check if finding is most recent in evaluation group
     7 N FDATE,GDATE
     8 ;Determine finding date and existing group date
     9 S FDATE=$G(FIEV(FNUM,"DATE")),GDATE=$G(GROUP(GSEQ,"DATE")) Q:FDATE=""
     10 ;Ignore findings outside to the extract period
     11 ;I $$FMDIFF^XLFDT(PXRMSTRT,FDATE,2)>0 Q
     12 ;If this is first or only entry in group then save finding date
     13 I 'GDATE S GROUP(GSEQ,"DATE")=FDATE,GROUP(GSEQ)=FSEQ Q
     14 ;Save finding if most recent date for the group
     15 I $$FMDIFF^XLFDT(FDATE,GDATE,2)>0 S GROUP(GSEQ,"DATE")=FDATE,GROUP(GSEQ)=FSEQ Q
     16 Q
     17 ;
     18FIND(SEQ,RCNT,PXRMSTRT,PXRMSTOP) ;Process findings for reminder
     19 ;Default is extract no findings
     20 N DATA,FCNT,FIEN,FIND,FNUM,FSEQ,GDATA,GROUP,GSEQ,GTYP
     21 S FNUM=0,FCNT=0
     22 F  S FNUM=$O(FIEV(FNUM)) Q:'FNUM  D
     23 .;Ignore if not found for patient
     24 .I +FIEV(FNUM)=0 Q
     25 .;Only terms are counted
     26 .S FIND=$G(FIEV(FNUM,"TERM IEN")) Q:FIND=""
     27 .;Check if in list to be accumulated
     28 .I '$D(REM(RCNT,FIND)) Q
     29 .;Find groups to which finding belongs
     30 .S GSEQ=""
     31 .F  S GSEQ=$O(REM(RCNT,FIND,GSEQ)) Q:GSEQ=""  D
     32 ..;Determine Evaluation type
     33 ..S GTYP=REM(RCNT,FIND,GSEQ)
     34 ..;Ignore utilization groups
     35 ..I GTYP="UR" Q
     36 ..;Sequence determines where the finding will be stored
     37 ..S FSEQ=""
     38 ..F  S FSEQ=$O(REM(RCNT,FIND,GSEQ,FSEQ)) Q:FSEQ=""  D
     39 ...;Evaluation Group logic to save latest entry only
     40 ...I GTYP="MRFP" D DATE Q
     41 ...;Save finding totals
     42 ...D UPD(1)
     43 ;
     44 ;Check for group totals
     45 S GSEQ=""
     46 F  S GSEQ=$O(GROUP(GSEQ)) Q:GSEQ=""  D
     47 .S GDATA=$G(GROUP(GSEQ)) Q:GDATA=""
     48 .;Update if found
     49 .S FSEQ=$P(GDATA,U) D UPD(1)
     50 ;
     51 ;Utilization counts are done separately
     52 N CNT,FDATA,FIND,FINDPA,FTIEN,GTYP,TERMARR,TFIEVAL
     53 ;modify start date to include incomplete dates
     54 I $E(PXRMSTRT,6,7)="01" S PXRMSTRT=$E(PXRMSTRT,1,5)_"00"
     55 ;Include incomplete dates in January
     56 I $E(PXRMSTRT,4,5)="01" S PXRMSTRT=$E(PXRMSTRT,1,3)_"0000"
     57 ;Set start and stop dates for term
     58 ;S $P(FINDPA(0),U,8)=PXRMSTRT,$P(FINDPA(0),U,11)=PXRMSTOP
     59 S $P(FINDPA(0),U,11)=PXRMSTOP
     60 ;Count all entries
     61 S $P(FINDPA(0),U,14)="*"
     62 ;
     63 S FTIEN="",GTYP="UR"
     64 F  S FTIEN=$O(FUTIL(RCNT,FTIEN)) Q:FTIEN=""  D
     65 .S GSEQ=""
     66 .F  S GSEQ=$O(FUTIL(RCNT,FTIEN,GSEQ)) Q:GSEQ=""  D
     67 ..S FSEQ=""
     68 ..F  S FSEQ=$O(FUTIL(RCNT,FTIEN,GSEQ,FSEQ)) Q:FSEQ=""  D
     69 ...;Recover list of term findings
     70 ...K TERMARR M TERMARR=FUTIL(RCNT,FTIEN,GSEQ,FSEQ)
     71 ...;Process term
     72 ...K TFIEVAL D EVALTERM^PXRMTERM(DFN,.FINDPA,.TERMARR,.TFIEVAL)
     73 ...D URCNT(PXRMSTRT,PXRMSTOP,.TFIEVAL)
     74 ;Determine count from PLIST then add to ETX
     75 ;S CNT=+$O(PLIST(1,999999),-1) Q:'CNT
     76 ;D UPD(CNT)
     77 Q
     78 ;
     79FRULE(FRIEN,RCNT,SEQ,REM,FUTIL) ;Build array of findings in the finding rule
     80 N DATA,FIND,FSEQ,GIEN,GNAM,GSEQ,GTYP,GSTA,SUB,TLIST
     81 S GSEQ=0
     82 F  S GSEQ=$O(^PXRM(810.7,FRIEN,10,"B",GSEQ)) Q:GSEQ=""  D
     83 .S SUB=$O(^PXRM(810.7,FRIEN,10,"B",GSEQ,"")) Q:'SUB
     84 .S DATA=$G(^PXRM(810.7,FRIEN,10,SUB,0)) Q:DATA=""
     85 .;Get the finding group ien and reminder status
     86 .S GIEN=$P(DATA,U,2),GSTA=$P(DATA,U,3) Q:'GIEN
     87 .;If no status then report finding totals for all patients
     88 .I GSTA="" S GSTA="T"
     89 .;Get finding group info
     90 .S DATA=$G(^PXRM(810.8,GIEN,0)) Q:DATA=""
     91 .;Get group name and count type
     92 .S GTYP=$P(DATA,U,3),GNAM=$P(DATA,U) Q:GTYP=""
     93 .;Save group in workfile
     94 .S ^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ)=GNAM_U_GTYP_U_GSTA
     95 .;Get all findings in group
     96 .S FSEQ=0
     97 .F  S FSEQ=$O(^PXRM(810.8,GIEN,10,"B",FSEQ)) Q:FSEQ=""  D
     98 ..S SUB=$O(^PXRM(810.8,GIEN,10,"B",FSEQ,"")) Q:'SUB
     99 ..S DATA=$G(^PXRM(810.8,GIEN,10,SUB,0)) Q:DATA=""
     100 ..;Get the finding ien and exclusion status
     101 ..S FIND=$P(DATA,U,2) Q:'FIND
     102 ..;Initialize count for finding
     103 ..S ^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)=FIND
     104 ..;Reminder evaluation counts work from REM
     105 ..I GTYP'="UR" D  Q
     106 ...S REM(RCNT,FIND,GSEQ,FSEQ)=""
     107 ...S REM(RCNT,FIND,GSEQ)=GTYP
     108 ..;Utilization counts work from FUTIL
     109 ..D TERM^PXRMLDR(FIND,.TLIST)
     110 ..;Save TLIST
     111 ..M FUTIL(RCNT,FIND,GSEQ,FSEQ)=TLIST
     112 Q
     113 ;
     114REM(SUB,PXRMLIST,PXRMSTRT,PXRMSTOP,PARTYPE) ;Run reminders against patient
     115 ;lists.
     116 N APPL,DATA,DEFARR,DEFSITE,DFN,DUE,FIEV,FRIEN,FUTIL,IND,INST
     117 N PXRMDATE,RCNT,REM,RIEN,RNAM,STATUS,SUB1,TODAY
     118 N END,START
     119 ;S START=$H
     120 S TODAY=$$DT^XLFDT
     121 ;Evaluation date is period end except if the period is incomplete
     122 S PXRMDATE=$S($$FMDIFF^XLFDT(PXRMSTOP,TODAY,2)>0:TODAY,1:PXRMSTOP)
     123 ;Scan reminders for this parameter set
     124 S (RCNT,SUB1)=0
     125 F  S SUB1=$O(^PXRM(810.2,IEN,10,SUB,10,SUB1)) Q:'SUB1  D
     126 .S DATA=$G(^PXRM(810.2,IEN,10,SUB,10,SUB1,0)) Q:DATA=""
     127 .;Reminder ien
     128 .S RIEN=$P(DATA,U,2) Q:'RIEN
     129 .;Evaluation date is period end except if the period is incomplete.
     130 .S PXRMDATE=$S($$FMDIFF^XLFDT(PXRMSTOP,TODAY,2)>0:TODAY,1:PXRMSTOP)
     131 .;Finding Rule
     132 .S FRIEN=$P(DATA,U,3)
     133 .;Reminder print name
     134 .S RNAM=$P($G(^PXD(811.9,RIEN,0)),U,3)
     135 .;Save details to REM array
     136 .S RCNT=RCNT+1,REM(RCNT)=RIEN_U_RNAM_U_FRIEN
     137 .;Build list of terms from extract finding rule #810.7
     138 .I FRIEN D FRULE(FRIEN,RCNT,SEQ,.REM,.FUTIL) Q
     139 .;If no extract finding rule defined collect all findings in reminder
     140 .I 'FRIEN D REMF(RIEN,RCNT,SEQ,.REM)
     141 ;
     142 ;Process patient list
     143 S IND=0,DEFSITE=+$P($$SITE^VASITE,U,3)
     144 F  S IND=$O(^PXRMXP(810.5,PXRMLIST,30,IND)) Q:'IND  D
     145 .S DFN=$P($G(^PXRMXP(810.5,PXRMLIST,30,IND,0)),U) Q:'DFN
     146 .S INST=$P($G(^PXRMXP(810.5,PXRMLIST,30,IND,0)),U,2)
     147 .I INST="" S INST=DEFSITE
     148 .S RCNT=0
     149 .F  S RCNT=$O(REM(RCNT)) Q:'RCNT  D
     150 ..S RIEN=$P(REM(RCNT),U),RNAM=$P(REM(RCNT),U,2),FRIEN=$P(REM(RCNT),U,3)
     151 ..;Clear evaluation arrays.
     152 ..K ^TMP("PXRHM",$J),^TMP("PXRMID",$J),FIEV
     153 ..;Evaluate reminders and store results
     154 ..D DEF^PXRMLDR(RIEN,.DEFARR)
     155 ..D EVAL^PXRM(DFN,.DEFARR,1,1,.FIEV,PXRMDATE)
     156 ..;Determine update from reminder status
     157 ..S STATUS=$P($G(^TMP("PXRHM",$J,RIEN,RNAM)),U) I STATUS="" Q
     158 ..;Ignore not applicables
     159 ..S APPL=$S(STATUS["DUE":1,STATUS="RESOLVED":1,STATUS="DONE":1,1:0)
     160 ..;Check if due
     161 ..S DUE=$S(STATUS="DUE NOW":1,1:0)
     162 ..;Compliance totals
     163 ..S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT))
     164 ..;Reminder ien
     165 ..I $P(DATA,U)="" S $P(DATA,U)=RIEN
     166 ..;Evaluated total
     167 ..S $P(DATA,U,2)=$P(DATA,U,2)+1
     168 ..;Applicable total
     169 ..S $P(DATA,U,3)=$P(DATA,U,3)+APPL
     170 ..;Not applicable total
     171 ..I 'APPL,'DUE S $P(DATA,U,4)=$P(DATA,U,4)+1
     172 ..;Due total
     173 ..S $P(DATA,U,5)=$P(DATA,U,5)+DUE
     174 ..;Not due count
     175 ..I APPL,'DUE S $P(DATA,U,6)=$P(DATA,U,6)+1
     176 ..;Add patient list
     177 ..I $P(DATA,U,7)="" S $P(DATA,U,7)=PXRMLIST
     178 ..;Update workfile
     179 ..S ^TMP("PXRMETX",$J,SEQ,INST,RCNT)=DATA
     180 ..;Save finding totals
     181 ..I PARTYPE="CF" D FIND(SEQ,RCNT,PXRMSTRT,PXRMSTOP)
     182 ;Clear evaluation fields
     183 K ^TMP("PXRHM",$J),^TMP("PXRMID",$J)
     184 ;S END=$H
     185 ;W !,"REMINDER EVALUATION TIME"
     186 ;D DETIME^PXRMXSEL(START,END)
     187 Q
     188 ;
     189REMF(RIEN,RCNT,SEQ,REM) ;Build array of all findings in the reminder
     190 N GNAM,GSEQ,FIND,FSEQ,GTYP,SUB
     191 S GNAM="Finding totals",GSEQ="001",FSEQ=0,GTYP="MRF"
     192 ;Save group name
     193 S ^TMP("PXRMETX",$J,SEQ,RCNT,GSEQ)=GNAM_U_GTYP
     194 ;Select all findings in the reminder
     195 S SUB=0
     196 F  S SUB=$O(^PXD(811.9,RIEN,20,SUB)) Q:'SUB  D
     197 .;Ignore if finding is not a term
     198 .S FIND=$P($G(^PXD(811.9,RIEN,20,SUB,0)),U) Q:FIND'["PXRMD(811.5"
     199 .;Convert to term ien
     200 .S FIND=$P(FIND,";")
     201 .;Build sequence number
     202 .S FSEQ=FSEQ+1,FSEQ=$$RJ^XLFSTR(FSEQ,3,0)
     203 .;Evaluation counts
     204 .S REM(RCNT,FIND,GSEQ,FSEQ)=""
     205 .S REM(RCNT,FIND,GSEQ)=GTYP
     206 .;Update Workfile
     207 .S ^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)=FIND
     208 Q
     209 ;
     210URCNT(PXRMSTRT,PXRMSTOP,TFIEVAL) ;
     211 ;Handle counting all valid occurrences for the finding items.
     212 ;Includes historical entries that were entered within the reporting
     213 ;period, cut the encounter date if it is outside the reporting period.
     214 N CNT,DATEENT,FDATE,FILE,FNUM,FOCCNUM,HIST,NODE,SCAT,VIEN
     215 S CNT=0,FNUM=0
     216 F  S FNUM=$O(TFIEVAL(FNUM)) Q:FNUM'>0  D
     217 .S FILE=$G(TFIEVAL(FNUM,"FILE NUMBER"))
     218 .S HIST=$S(FILE=9000010.18:1,FILE=9000010.13:1,FILE=9000010.23:1,FILE=9000010.16:1,FILE=9000010.07:1,FILE=9000010.12:1,FILE=9000010.15:1,1:0)
     219 .S FOCCNUM=0 F  S FOCCNUM=$O(TFIEVAL(FNUM,FOCCNUM)) Q:FOCCNUM'>0  D
     220 ..S FDATE=$P(TFIEVAL(FNUM,FOCCNUM,"DATE"),".") Q:FDATE'>0
     221 ..I HIST=0,FDATE=PXRMSTRT!(FDATE>PXRMSTRT) S CNT=CNT+1
     222 ..I HIST=1 D
     223 ...S VIEN=TFIEVAL(FNUM,FOCCNUM,"VISIT") Q:VIEN'>0
     224 ...S NODE=$G(^AUPNVSIT(VIEN,0))
     225 ...S SCAT=$P(NODE,U,7),DATEENT=$P($P(NODE,U,2),".")
     226 ...I FDATE=PXRMSTRT!(FDATE>PXRMSTRT),SCAT'="E" S CNT=CNT+1 Q
     227 ...I SCAT="E",(DATEENT=PXRMSTRT!(DATEENT>PXRMSTRT))&(DATEENT=PXRMSTOP!(DATEENT<PXRMSTOP)) S CNT=CNT+1
     228 D UPD(CNT)
     229 Q
     230 ;
     231UPD(CNT) ;Update totals
     232 S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ))
     233 ;Total count
     234 S $P(DATA,U,2)=$P(DATA,U,2)+CNT
     235 ;Applicable count
     236 S $P(DATA,U,3)=$P(DATA,U,3)+(APPL*CNT)
     237 ;Not applicable count
     238 I 'APPL,'DUE S $P(DATA,U,4)=$P(DATA,U,4)+CNT
     239 ;Due count
     240 S $P(DATA,U,5)=$P(DATA,U,5)+(DUE*CNT)
     241 ;Not due count
     242 I APPL,'DUE S $P(DATA,U,6)=$P(DATA,U,6)+CNT
     243 ;Update current count
     244 S ^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ)=DATA
     245 ;AGP REMOVE UNTIL A DECISION CAN BE MADE
     246 ;I CNT=1,APPL=1 S ^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ,DFN)=DFN
     247 Q
     248 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMETXU.m

    r613 r623  
    1 PXRMETXU        ; SLC/PJH - Extract utilities ;09/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 HELP(CALL)      ;General help text routine
    5         N HTEXT
    6         I CALL=1 D
    7         .S HTEXT(1)="Enter 'Y' to overwrite this existing list. Enter 'N' to"
    8         .S HTEXT(2)="use a different patient list name."
    9         ;
    10         I CALL=3 D
    11         .S HTEXT(1)="Enter 'Y' to transmit extract. Otherwise enter 'N'."
    12         ;
    13         I CALL=4 D
    14         .S HTEXT(1)="The selected period is the same as next scheduled extract."
    15         .S HTEXT(2)="Enter 'Y' if this extract will replace the scheduled"
    16         .S HTEXT(3)="extract. Enter 'N' if you still want the scheduled extract"
    17         .S HTEXT(4)="to run."
    18         ;
    19         D HELP^PXRMEUT(.HTEXT)
    20         Q
    21         ;
    22 DELETE(IEN)     ;Delete an extract summary.
    23         I IEN="" Q
    24         N DA,DELOK,DIK,NAME
    25         S DELOK=1
    26         S NAME=$P(^PXRMXT(810.3,IEN,0),U,1)
    27         ;Must have PXRM MANAGER key in order to delete national extracts.
    28         I $P($G(^PXRMXT(810.3,IEN,100)),U,1)="N" D
    29         . S DELOK=$S($D(^XUSEC("PXRM MANAGER",DUZ)):1,1:0)
    30         . I 'DELOK D
    31         .. W !!,NAME," is national."
    32         .. W !,"You cannot delete a national extract summary."
    33         .. H 2
    34         I 'DELOK Q
    35         ;Double check the user really wants to delete.
    36         S TEXT="Are you sure you want to delete "_NAME
    37         S DELOK=$$ASKYN^PXRMEUT("N","Are you sure you want to delete "_NAME)
    38         I 'DELOK Q
    39         S DA=IEN
    40         S DIK="^PXRMXT(810.3,"
    41         D ^DIK
    42         W !,"Deleting ",NAME
    43         H 2
    44         Q
    45         ;
    46 PRGES   ;Delete any Extract Summaries over 5 years old
    47         N DIFF,EDATE,OLD
    48         S OLD=0
    49         F  S OLD=$O(^PXRMXT(810.3,OLD)) Q:'OLD  D
    50         .I +$G(^PXRMXT(810.3,OLD,50))'=1 Q
    51         .;Extract Date
    52         .S EDATE=$P($G(^PXRMXT(810.3,OLD,0)),U,6)
    53         .;Ignore if < 5 years (1826 days) since creation
    54         .I $$FMDIFF^XLFDT(DT,EDATE,1)<1826 Q
    55         .;Otherwise delete
    56         .N DIK,DA
    57         .S DIK="^PXRMXT(810.3,",DA=OLD D ^DIK
    58         Q
    59         ;
    60 PRGPL   ;Delete any Patient Lists over 5 years old
    61         N LDATE,OLD
    62         S OLD=0
    63         F  S OLD=$O(^PXRMXP(810.5,OLD)) Q:'OLD  D
    64         .I +$G(^PXRMXP(810.5,OLD,50))'=1 Q
    65         .;Patient List Date
    66         .S LDATE=$P($G(^PXRMXP(810.5,OLD,0)),U,4)
    67         .;Ignore if < 5 years (1826 days) since creation
    68         .I $$FMDIFF^XLFDT(DT,LDATE,1)<1826 Q
    69         .;Otherwise delete
    70         .N DIK,DA
    71         .S DIK="^PXRMXP(810.5,",DA=OLD D ^DIK
    72         Q
    73         ;
     1PXRMETXU ; SLC/PJH - Extract utilities ;08/03/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4HELP(CALL) ;General help text routine
     5 N HTEXT
     6 I CALL=1 D
     7 .S HTEXT(1)="Enter 'Y' to overwrite this existing list. Enter 'N' to"
     8 .S HTEXT(2)="use a different patient list name."
     9 ;
     10 I CALL=3 D
     11 .S HTEXT(1)="Enter 'Y' to transmit extract. Otherwise enter 'N'."
     12 ;
     13 I CALL=4 D
     14 .S HTEXT(1)="The selected period is the same as next scheduled extract."
     15 .S HTEXT(2)="Enter 'Y' to if this extract will replace the scheduled"
     16 .S HTEXT(3)="extract. Enter 'N' if you still want the scheduled extract"
     17 .S HTEXT(3)="to run."
     18 ;
     19 D HELP^PXRMEUT(.HTEXT)
     20 Q
     21 ;
     22PRGES ;Delete any Extract Summaries over 5 years old
     23 N DIFF,EDATE,OLD
     24 S OLD=0
     25 F  S OLD=$O(^PXRMXT(810.3,OLD)) Q:'OLD  D
     26 .I +$G(^PXRMXT(810.3,OLD,50))'=1 Q
     27 .;Extract Date
     28 .S EDATE=$P($G(^PXRMXT(810.3,OLD,0)),U,6)
     29 .;Ignore if < 5 years (1826 days) since creation
     30 .I $$FMDIFF^XLFDT(DT,EDATE,1)<1826 Q
     31 .;Otherwise delete
     32 .N DIK,DA
     33 .S DIK="^PXRMXT(810.3,",DA=OLD D ^DIK
     34 Q
     35 ;
     36PRGPL ;Delete any Patient Lists over 5 years old
     37 N LDATE,OLD
     38 S OLD=0
     39 F  S OLD=$O(^PXRMXP(810.5,OLD)) Q:'OLD  D
     40 .I +$G(^PXRMXP(810.5,OLD,50))'=1 Q
     41 .;Patient List Date
     42 .S LDATE=$P($G(^PXRMXP(810.5,OLD,0)),U,4)
     43 .;Ignore if < 5 years (1826 days) since creation
     44 .I $$FMDIFF^XLFDT(DT,LDATE,1)<1826 Q
     45 .;Otherwise delete
     46 .N DIK,DA
     47 .S DIK="^PXRMXP(810.5,",DA=OLD D ^DIK
     48 Q
     49 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEUT.m

    r613 r623  
    1 PXRMEUT ; SLC/PJH - General extract utilities ;09/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=================================================
    5 ASKNUM(TEXT,MIN,MAX)    ;
    6         N DIR,X,Y
    7         K DIROUT,DIRUT,DTOUT,DUOUT
    8         S DIR(0)="N"_U_MIN_":"_MAX
    9         S DIR("A")=TEXT
    10         S DIR("B")=MIN
    11         S DIR("?")="Enter a number between "_MIN_" and "_MAX_"."
    12         W !
    13         D ^DIR
    14         I $D(DTOUT)!$D(DUOUT) S Y=MIN
    15         Q Y
    16         ;
    17         ;=================================================
    18 ASKYN(DEF,TEXT,RTN,HLP) ;
    19         N DIR,X,Y
    20         K DIROUT,DIRUT,DTOUT,DUOUT
    21         S DIR(0)="Y0"
    22         S DIR("A")=TEXT
    23         S DIR("B")=DEF
    24         S DIR("?")="Enter Y or N."
    25         I $G(RTN)'="",$G(HLP)'="" D
    26         . S DIR("?")="Enter Y or N. For detailed help type ??"
    27         . S DIR("??")=U_"D HELP^"_RTN_"(HLP)"
    28         W !
    29         D ^DIR
    30         I $D(DTOUT)!$D(DUOUT) S Y=DEF
    31         Q Y
    32         ;
    33         ;=================================================
    34 BHELP   ;Write the beginning date help.
    35         N BDHTEXT,%DT
    36         S BDHTEXT(1)="This is the beginning date for the "_LIT_"."
    37         D HELP^PXRMEUT(.BDHTEXT)
    38         S %DT="P",%DT(0)=-DT
    39         D HELP^%DTC
    40         Q
    41         ;
    42         ;=================================================
    43 CALC(NEXT,START,END)    ;Calculate period start and end dates
    44         ;Next is current run period
    45         N CMON,CYR,ETYPE,NMON,NYR,PERIOD,YEAR
    46         ;extract year and period (M1,M2,Q1,Q2,Y etc)
    47         I NEXT["/" S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/"),ETYPE=$E(PERIOD)
    48         I NEXT?4N S YEAR=NEXT,PERIOD="",ETYPE="Y"
    49         ;Two digit year
    50         S CYR=$E(YEAR,3,4),NYR=CYR
    51         ;If yearly use Jan 1st of current year and next
    52         I ETYPE="Y" D
    53         .S CMON="1",NMON="1",NYR=NYR+1
    54         ;If quarterly use start of first month of next quarter
    55         I ETYPE="Q" D
    56         .S CMON=$E(PERIOD,2,99),NMON=CMON*3+1 I NMON>12 S NYR=NYR+1,NMON=1
    57         .S CMON=CMON*3-2
    58         ;If monthly use start of next month
    59         I ETYPE="M" D
    60         .S CMON=$E(PERIOD,2,99),NMON=CMON+1 I NMON>12 S NYR=NYR+1,NMON=1
    61         ;Zero fill the month fields
    62         S CMON=$$RJ^XLFSTR(CMON,2,0),NMON=$$RJ^XLFSTR(NMON,2,0)
    63         ;Zero fill the year fields
    64         S CYR=$$RJ^XLFSTR(CYR,2,0),NYR=$$RJ^XLFSTR(NYR,2,0)
    65         ;Report start date is start of current period
    66         S START=3_CYR_CMON_"01"
    67         ;Report end date is start of next period less one day
    68         S END=$$FMADD^XLFDT(3_NYR_NMON_"01",-1)
    69         Q
    70         ;
    71         ;=================================================
    72 DATES(BDATE,EDATE,LIT)  ;Get a past date range.
    73 BEGIN   ;Select the beginning date.
    74         N DIR,%DT,X,Y
    75         K DIROUT,DIRUT,DTOUT,DUOUT
    76         S DIR(0)="DA^::ETX"
    77         S DIR("A")="Enter "_LIT_" BEGINNING DATE: "
    78         S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
    79         S DIR("?")="For detailed help type ??"
    80         S DIR("??")=U_"D BHELP^PXRMEUT"
    81         W !
    82         D ^DIR K DIR
    83         I $D(DIROUT) S DTOUT=1
    84         I $D(DTOUT)!($D(DUOUT)) Q
    85         S BDATE=Y
    86         I $E(Y,6,7)="00" W $C(7),"  ?? Enter exact date" G BEGIN
    87         S BDATE=Y
    88         ;
    89 END     ;Select the ending date.
    90         S DIR(0)="DA^"_BDATE_"::ETX"
    91         S DIR("A")="Enter "_LIT_" ENDING DATE: "
    92         S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
    93         S DIR("?")="This date cannot be before "_$$FMTE^XLFDT(BDATE,"D")_". For detailed help type ??"
    94         S DIR("??")=U_"D EHELP^PXRMEUT"
    95         D ^DIR
    96         I $D(DIROUT) S DTOUT=1
    97         I $D(DTOUT) Q
    98         I $D(DUOUT) G BEGIN
    99         S EDATE=Y
    100         I $E(Y,6,7)="00" W $C(7),"  ?? Enter exact date" G END
    101         K DIROUT,DIRUT,DTOUT,DUOUT
    102         Q
    103         ;
    104         ;=================================================
    105 DOCUMENT(PXRMLIST,PXRMRULE,INDP,INTP,BEG,END)   ;Document how the
    106         ;list was built.
    107         N CDATE,CLASS,CREATOR,IND,LDATA,LNAME
    108         N NDL,NL,NPAT,OUTPUT,SNAME,SOURCE,TEXT,TYPE,VALMCNT
    109         K ^TMP("PXRMLRED",$J)
    110         S LDATA=$G(^PXRMXP(810.5,PXRMLIST,0))
    111         S LNAME=$P(LDATA,U,1)
    112         S CDATE=$P(LDATA,U,4)
    113         S SOURCE=$P(LDATA,U,5),SNAME="NONE"
    114         ;Check if generated from #810.2
    115         I SOURCE S SNAME="Extract Parameter - "_$P($G(^PXRM(810.2,SOURCE,0)),U)
    116         ;If not check if generated from #810.4
    117         I 'SOURCE S SOURCE=$P(LDATA,U,6) S:SOURCE SNAME="List Rule - "_$P($G(^PXRM(810.4,SOURCE,0)),U)
    118         ;Creator
    119         S CREATOR=+$P(LDATA,U,7)
    120         S CREATOR=$S(CREATOR>0:$$GET1^DIQ(200,CREATOR,.01),1:"None")
    121         ;Type
    122         S TYPE=$P(LDATA,U,8)
    123         S TYPE=$$EXTERNAL^DILFD(810.5,.08,"",TYPE,.EM)
    124         ;Class
    125         S CLASS=$P($G(^PXRMXP(810.5,PXRMLIST,100)),U,1)
    126         S CLASS=$S(CLASS="N":"National",CLASS="V":"VISN",1:"Local")
    127         S NPAT=$P(^PXRMXP(810.5,PXRMLIST,30,0),U,4)
    128         S TEXT(1)="List Name: "_LNAME_" ("_NPAT_" patients)"
    129         S TEXT(2)=" Created: "_$$FMTE^XLFDT(CDATE,"5Z")
    130         S TEXT(2)=$$LJ^XLFSTR(TEXT(2),40)_"Creator: "_CREATOR
    131         S TEXT(3)=" Class: "_CLASS
    132         S TEXT(3)=$$LJ^XLFSTR(TEXT(3),40)_"Type: "_TYPE
    133         S TEXT(4)=" Source: "_SNAME
    134         S TEXT(5)=" Patient List Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
    135         S TEXT(6)=" Patient List Ending Date: "_$$FMTE^XLFDT(END,"5Z")
    136         S TEXT(7)=" "
    137         S NL=7
    138         F IND=1:1:NL S ^PXRMXP(810.5,PXRMLIST,200,IND,0)=TEXT(IND)
    139         D BLDLIST^PXRMLRED(PXRMRULE,3)
    140         F IND=1:1:VALMCNT S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=^TMP("PXRMLRED",$J,IND,0)
    141         S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=" --- List Build Information ---"
    142         S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
    143         S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Ending Date: "_$$FMTE^XLFDT(END,"5Z")
    144         S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=" "
    145         S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include deceased patients: "_$S(INDP:"Yes",1:"No")
    146         S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include test patients: "_$S(INTP:"Yes",1:"No")
    147         ;Get the beginning and ending date information
    148         D DOCDATES^PXRMEUT1(PXRMRULE,BEG,END,.NDL,.OUTPUT)
    149         F IND=1:1:NDL S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=OUTPUT(IND)
    150         S ^PXRMXP(810.5,PXRMLIST,200,0)=U_U_NL_U_NL_U_DT_U
    151         K ^TMP("PXRMLRED",$J)
    152         Q
    153         ;
    154         ;=================================================
    155 EHELP   ;Write the ending date help.
    156         N EDHTEXT,%DT
    157         S EDHTEXT(1)="This is the ending date for the "_LIT_"."
    158         D HELP^PXRMEUT(.EDHTEXT)
    159         S %DT="P",%DT(0)=-DT
    160         D HELP^%DTC
    161         Q
    162         ;
    163         ;=================================================
    164 HELP(HTEXT)     ;General help text output routine.
    165         N IND,NIN,NOUT,TEXTIN,TEXOUT
    166         ;Make sure the text is in a form the formatting routine can handle.
    167         S IND="",NIN=0
    168         F  S IND=$O(HTEXT(IND)) Q:IND=""  S NIN=NIN+1,TEXTIN(NIN)=HTEXT(IND)
    169         D FORMAT^PXRMTEXT(1,72,NIN,.TEXTIN,.NOUT,.TEXTOUT)
    170         F IND=1:1:NOUT W !,TEXTOUT(IND)
    171         W !
    172         Q
    173         ;
    174         ;=================================================
    175 LDELOK(LISTIEN) ;Return a 1 if it is ok for this user to delete the list.
    176         N CREATOR,DELOK
    177         S CREATOR=$P(^PXRMXP(810.5,LISTIEN,0),U,7)
    178         S DELOK=$S(CREATOR=DUZ:1,$D(^XUSEC("PXRM MANAGER",DUZ)):1,1:0)
    179         Q DELOK
    180         ;
    181         ;=================================================
    182 MES(TEXT)       ;General mail message
    183         N XMSUB
    184         K ^TMP("PXRMXMZ",$J)
    185         S XMSUB="CLINICAL REMINDER EXTRACT"
    186         S ^TMP("PXRMXMZ",$J,1,0)=TEXT
    187         D SEND^PXRMMSG(XMSUB)
    188         Q
    189         ;
    190         ;=================================================
    191 PERIOD(FREQ)    ;Calculate next period
    192         N CMON,CUR,CYR,ETYPE,NEXT,PERIOD,YEAR
    193         ;Format current date YY/MM/DD
    194         S CUR=$$FMTE^XLFDT($$NOW^XLFDT,7)
    195         ;extract year and period
    196         S YEAR=$P(CUR,"/"),PERIOD=$P(CUR,"/",2)
    197         ;If yearly current year
    198         I FREQ="Y" D
    199         .S NEXT=YEAR
    200         ;If quarterly use current quarter
    201         I FREQ="Q" D
    202         .S NEXT="Q"_((PERIOD-1\3)+1)_"/"_YEAR
    203         ;If monthly use current month
    204         I FREQ="M" D
    205         .S NEXT="M"_PERIOD_"/"_YEAR
    206         Q NEXT
    207         ;
    208         ;=================================================
    209 RMPAT(NODE,INDP,INTP)   ;Remove dead and test patients from
    210         ;the list.
    211         I INDP,INTP Q
    212         N DFN,DOD,REMOVE
    213         S DFN=0
    214         F  S DFN=$O(^TMP($J,NODE,DFN)) Q:DFN=""  D
    215         .;DBIA 3744
    216         . S REMOVE=$S('INTP:$$TESTPAT^VADPT(DFN),1:0)
    217         . I REMOVE K ^TMP($J,NODE,DFN) Q
    218         . I INDP Q
    219         .;DBIA #10035
    220         . S DOD=+$P($G(^DPT(DFN,.35)),U,1)
    221         . I DOD=0 Q
    222         . K ^TMP($J,NODE,DFN)
    223         Q
    224         ;
     1PXRMEUT ; SLC/PJH - General extract utilities ;06/27/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=================================================
     5ASKNUM(TEXT,MIN,MAX) ;
     6 N DIR,X,Y
     7 K DIROUT,DIRUT,DTOUT,DUOUT
     8 S DIR(0)="N"_U_MIN_":"_MAX
     9 S DIR("A")=TEXT
     10 S DIR("B")=MIN
     11 S DIR("?")="Enter a number between "_MIN_" and "_MAX_"."
     12 W !
     13 D ^DIR
     14 I $D(DTOUT)!$D(DUOUT) S Y=MIN
     15 Q Y
     16 ;
     17 ;=================================================
     18ASKYN(DEF,TEXT,RTN,HLP) ;
     19 N DIR,X,Y
     20 K DIROUT,DIRUT,DTOUT,DUOUT
     21 S DIR(0)="Y0"
     22 S DIR("A")=TEXT
     23 S DIR("B")=DEF
     24 S DIR("?")="Enter Y or N."
     25 I $G(RTN)'="",$G(HLP)'="" D
     26 . S DIR("?")="Enter Y or N. For detailed help type ??"
     27 . S DIR("??")=U_"D HELP^"_RTN_"(HLP)"
     28 W !
     29 D ^DIR
     30 I $D(DTOUT)!$D(DUOUT) S Y=DEF
     31 Q Y
     32 ;
     33 ;=================================================
     34BHELP ;Write the beginning date help.
     35 N BDHTEXT,%DT
     36 S BDHTEXT(1)="This is the beginning date for the "_LIT_"."
     37 D HELP^PXRMEUT(.BDHTEXT)
     38 S %DT="P",%DT(0)=-DT
     39 D HELP^%DTC
     40 Q
     41 ;
     42 ;=================================================
     43CALC(NEXT,START,END) ;Calculate period start and end dates
     44 ;Next is current run period
     45 N CMON,CYR,ETYPE,NMON,NYR,PERIOD,YEAR
     46 ;extract year and period (M1,M2,Q1,Q2,Y etc)
     47 I NEXT["/" S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/"),ETYPE=$E(PERIOD)
     48 I NEXT?4N S YEAR=NEXT,PERIOD="",ETYPE="Y"
     49 ;Two digit year
     50 S CYR=$E(YEAR,3,4),NYR=CYR
     51 ;If yearly use Jan 1st of current year and next
     52 I ETYPE="Y" D
     53 .S CMON="1",NMON="1",NYR=NYR+1
     54 ;If quarterly use start of first month of next quarter
     55 I ETYPE="Q" D
     56 .S CMON=$E(PERIOD,2,99),NMON=CMON*3+1 I NMON>12 S NYR=NYR+1,NMON=1
     57 .S CMON=CMON*3-2
     58 ;If monthly use start of next month
     59 I ETYPE="M" D
     60 .S CMON=$E(PERIOD,2,99),NMON=CMON+1 I NMON>12 S NYR=NYR+1,NMON=1
     61 ;Zero fill the month fields
     62 S CMON=$$RJ^XLFSTR(CMON,2,0),NMON=$$RJ^XLFSTR(NMON,2,0)
     63 ;Zero fill the year fields
     64 S CYR=$$RJ^XLFSTR(CYR,2,0),NYR=$$RJ^XLFSTR(NYR,2,0)
     65 ;Report start date is start of current period
     66 S START=3_CYR_CMON_"01"
     67 ;Report end date is start of next period less one day
     68 S END=$$FMADD^XLFDT(3_NYR_NMON_"01",-1)
     69 Q
     70 ;
     71 ;=================================================
     72DATES(BDATE,EDATE,LIT) ;Get a past date range.
     73BEGIN ;Select the beginning date.
     74 N DIR,%DT,X,Y
     75 K DIROUT,DIRUT,DTOUT,DUOUT
     76 S DIR(0)="DA^::ETX"
     77 S DIR("A")="Enter "_LIT_" BEGINNING DATE: "
     78 S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
     79 S DIR("?")="For detailed help type ??"
     80 S DIR("??")=U_"D BHELP^PXRMEUT"
     81 W !
     82 D ^DIR K DIR
     83 I $D(DIROUT) S DTOUT=1
     84 I $D(DTOUT)!($D(DUOUT)) Q
     85 S BDATE=Y
     86 I $E(Y,6,7)="00" W $C(7),"  ?? Enter exact date" G BEGIN
     87 S BDATE=Y
     88 ;
     89END ;Select the ending date.
     90 S DIR(0)="DA^"_BDATE_"::ETX"
     91 S DIR("A")="Enter "_LIT_" ENDING DATE: "
     92 S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
     93 S DIR("?")="This date cannot be before "_$$FMTE^XLFDT(BDATE,"D")_". For detailed help type ??"
     94 S DIR("??")=U_"D EHELP^PXRMEUT"
     95 D ^DIR
     96 I $D(DIROUT) S DTOUT=1
     97 I $D(DTOUT) Q
     98 I $D(DUOUT) G BEGIN
     99 S EDATE=Y
     100 I $E(Y,6,7)="00" W $C(7),"  ?? Enter exact date" G END
     101 K DIROUT,DIRUT,DTOUT,DUOUT
     102 Q
     103 ;
     104 ;=================================================
     105DOCUMENT(PXRMLIST,PXRMRULE,INDP,INTP,BEG,END) ;Document how the
     106 ;list was built.
     107 N CDATE,CLASS,CREATOR,IND,LDATA,LNAME
     108 N NDL,NL,NPAT,OUTPUT,SNAME,SOURCE,TEXT,TYPE,VALMCNT
     109 K ^TMP("PXRMLRED",$J)
     110 S LDATA=$G(^PXRMXP(810.5,PXRMLIST,0))
     111 S LNAME=$P(LDATA,U,1)
     112 S CDATE=$P(LDATA,U,4)
     113 S SOURCE=$P(LDATA,U,5),SNAME="NONE"
     114 ;Check if generated from #810.2
     115 I SOURCE S SNAME="Extract Parameter - "_$P($G(^PXRM(810.2,SOURCE,0)),U)
     116 ;If not check if generated from #810.4
     117 I 'SOURCE S SOURCE=$P(LDATA,U,6) S:SOURCE SNAME="List Rule - "_$P($G(^PXRM(810.4,SOURCE,0)),U)
     118 ;Creator
     119 S CREATOR=+$P(LDATA,U,7)
     120 S CREATOR=$S(CREATOR>0:$$GET1^DIQ(200,CREATOR,.01),1:"None")
     121 ;Type
     122 S TYPE=$P(LDATA,U,8)
     123 S TYPE=$$EXTERNAL^DILFD(810.5,.08,"",TYPE,.EM)
     124 ;Class
     125 S CLASS=$P($G(^PXRMXP(810.5,PXRMLIST,100)),U,1)
     126 S CLASS=$S(CLASS="N":"National",CLASS="V":"VISN",1:"Local")
     127 S NPAT=$P(^PXRMXP(810.5,PXRMLIST,30,0),U,4)
     128 S TEXT(1)="List Name: "_LNAME_" ("_NPAT_" patients)"
     129 S TEXT(2)=" Created: "_$$FMTE^XLFDT(CDATE,"5Z")
     130 S TEXT(2)=$$LJ^XLFSTR(TEXT(2),40)_"Creator: "_CREATOR
     131 S TEXT(3)=" Class: "_CLASS
     132 S TEXT(3)=$$LJ^XLFSTR(TEXT(3),40)_"Type: "_TYPE
     133 S TEXT(4)=" Source: "_SNAME
     134 S TEXT(5)=" Patient List Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
     135 S TEXT(6)=" Patient List Ending Date: "_$$FMTE^XLFDT(END,"5Z")
     136 S TEXT(7)=" "
     137 S NL=7
     138 F IND=1:1:NL S ^PXRMXP(810.5,PXRMLIST,200,IND,0)=TEXT(IND)
     139 D BLDLIST^PXRMLRED(PXRMRULE,3)
     140 F IND=1:1:VALMCNT S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=^TMP("PXRMLRED",$J,IND,0)
     141 S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=" --- List Build Information ---"
     142 S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
     143 S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Ending Date: "_$$FMTE^XLFDT(END,"5Z")
     144 S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=" "
     145 S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include deceased patients: "_$S(INDP:"Yes",1:"No")
     146 S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include test patients: "_$S(INTP:"Yes",1:"No")
     147 ;Get the beginning and ending date information
     148 D DOCDATES^PXRMEUT1(PXRMRULE,BEG,END,.NDL,.OUTPUT)
     149 F IND=1:1:NDL S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=OUTPUT(IND)
     150 S ^PXRMXP(810.5,PXRMLIST,200,0)=U_U_NL_U_NL_U_DT_U
     151 K ^TMP("PXRMLRED",$J)
     152 Q
     153 ;
     154 ;=================================================
     155EHELP ;Write the ending date help.
     156 N EDHTEXT,%DT
     157 S EDHTEXT(1)="This is the ending date for the "_LIT_"."
     158 D HELP^PXRMEUT(.EDHTEXT)
     159 S %DT="P",%DT(0)=-DT
     160 D HELP^%DTC
     161 Q
     162 ;
     163 ;=================================================
     164HELP(HTEXT) ;General help text routine. Write out the text in the HTEXT
     165 ;array.
     166 N DIWF,DIWL,DIWR,IC,X
     167 S DIWF="C70",DIWL=0,DIWR=70
     168 K ^UTILITY($J,"W")
     169 S IC=""
     170 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     171 . S X=HTEXT(IC)
     172 . D ^DIWP
     173 W !
     174 S IC=0
     175 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     176 . W !,^UTILITY($J,"W",0,IC,0)
     177 K ^UTILITY($J,"W")
     178 W !
     179 Q
     180 ;
     181 ;=================================================
     182LDELOK(LISTIEN) ;Return a 1 if it is ok for this user to delete the list.
     183 N CREATOR,DELOK
     184 S CREATOR=$P(^PXRMXP(810.5,LISTIEN,0),U,7)
     185 S DELOK=$S(CREATOR=DUZ:1,$D(^XUSEC("PXRM MANAGER",DUZ)):1,1:0)
     186 Q DELOK
     187 ;
     188 ;=================================================
     189MES(TEXT) ;General mail message
     190 N XMSUB
     191 K ^TMP("PXRMXMZ",$J)
     192 S XMSUB="CLINICAL REMINDER EXTRACT"
     193 S ^TMP("PXRMXMZ",$J,1,0)=TEXT
     194 D SEND^PXRMMSG(XMSUB)
     195 Q
     196 ;
     197 ;=================================================
     198PERIOD(FREQ) ;Calculate next period
     199 N CMON,CUR,CYR,ETYPE,NEXT,PERIOD,YEAR
     200 ;Format current date YY/MM/DD
     201 S CUR=$$FMTE^XLFDT($$NOW^XLFDT,7)
     202 ;extract year and period
     203 S YEAR=$P(CUR,"/"),PERIOD=$P(CUR,"/",2)
     204 ;If yearly current year
     205 I FREQ="Y" D
     206 .S NEXT=YEAR
     207 ;If quarterly use current quarter
     208 I FREQ="Q" D
     209 .S NEXT="Q"_((PERIOD-1\3)+1)_"/"_YEAR
     210 ;If monthly use current month
     211 I FREQ="M" D
     212 .S NEXT="M"_PERIOD_"/"_YEAR
     213 Q NEXT
     214 ;
     215 ;=================================================
     216RMPAT(NODE,INDP,INTP) ;Remove dead and test patients from
     217 ;the list.
     218 I INDP,INTP Q
     219 N DFN,DOD,REMOVE
     220 S DFN=0
     221 F  S DFN=$O(^TMP($J,NODE,DFN)) Q:DFN=""  D
     222 .;DBIA 3744
     223 . S REMOVE=$S('INTP:$$TESTPAT^VADPT(DFN),1:0)
     224 . I REMOVE K ^TMP($J,NODE,DFN) Q
     225 . I INDP Q
     226 .;DBIA #10035
     227 . S DOD=+$P($G(^DPT(DFN,.35)),U,1)
     228 . I DOD=0 Q
     229 . K ^TMP($J,NODE,DFN)
     230 Q
     231 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEUT1.m

    r613 r623  
    1 PXRMEUT1        ; SLC/PKR - General extract utilities ;05/08/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;=================================================
    4 CLDATES ;Cleanup entries in ^TMP("PXRMDDOC",$J) before making date checks.
    5         ;For drug findings consolidate PS(55, PS(55NVA, and PSRX( back to
    6         ;PSDRUG(.
    7         N FI,FIND0,ITEM,GLOBAL,LIST
    8         S FIND0=""
    9         F  S FIND0=$O(^TMP("PXRMDDOC",$J,FIND0)) Q:FIND0=""  D
    10         . S FI=$P(FIND0,U,1)
    11         . S GLOBAL=$P(FI,";",2)
    12         . I GLOBAL'["PS" Q
    13         . S GLOBAL="PSDRUG("
    14         . S ITEM=$P(FI,";",1)
    15         . S FI=ITEM_";"_GLOBAL_U_$P(FIND0,U,2,11)
    16         . S LIST(FIND0)=FI
    17         ;
    18         S FIND0=""
    19         F  S FIND0=$O(LIST(FIND0)) Q:FIND0=""  D
    20         . S FI=LIST(FIND0)
    21         . S ^TMP("PXRMDDOC",$J,FI)=^TMP("PXRMDDOC",$J,FIND0)
    22         . K ^TMP("PXRMDDOC",$J,FIND0)
    23         Q
    24         ;
    25         ;=================================================
    26 DAYSIM(FMDATE)  ;Given a FileMan date return the number of days in the month.
    27         N MONTH
    28         S MONTH=$E(FMDATE,4,5)
    29         S DAYS=$S(MONTH="01":31,MONTH="02":28,MONTH="03":31,MONTH="04":30,MONTH="05":31,MONTH="06":30,MONTH="07":31,MONTH="08":31,MONTH="09":30,MONTH="10":31,MONTH="11":30,MONTH="12":31,1:"")
    30         I MONTH="02" D
    31         . N LYEAR,YEAR
    32         . S YEAR=$E(FMDATE,1,3)+1700
    33         . S LYEAR=$S((YEAR#4=0)&(YEAR#100'=0):1,YEAR#400=0:1,1:0)
    34         . I LYEAR S DAYS=29
    35         Q DAYS
    36         ;
    37         ;=================================================
    38 DCONV(DATE,LBBDT,LBEDT) ;Convert dates to actual values.
    39         I DATE=0 Q DATE
    40         N PXRMDATE
    41         S PXRMDATE=$S(DATE["BDT":LBBDT,1:LBEDT)
    42         S DATE=$$STRREP^PXRMUTIL(DATE,"BDT","T")
    43         Q $$CTFMD^PXRMDATE(DATE)
    44         ;
    45         ;=================================================
    46 DOCDATES(RULESET,LBBDT,LBEDT,NL,OUTPUT) ;
    47         N EM,FRACT,FRDATA,FRDATES,FRIEN,FRLST,FRLIEN,FROLST,FROUT,FRPAT
    48         N FRPERM,FRSTRT,FRTIEN,FRTYP,FSEQ,OPER,PXRMFVPL
    49         N RRIEN,RSDATA,RSDATES,RBDT,REDT,SEQ,SUB
    50         I $G(PXRMDDOC)=2 D CLDATES
    51         ;Build the variable pointer list.
    52         D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
    53         S SEQ="",NL=0
    54         F  S SEQ=$O(^PXRM(810.4,RULESET,30,"B",SEQ)) Q:'SEQ  D
    55         . S SUB=$O(^PXRM(810.4,RULESET,30,"B",SEQ,"")) Q:'SUB
    56         . S RSDATA=$G(^PXRM(810.4,RULESET,30,SUB,0)) Q:RSDATA=""
    57         . S OPER=$P(RSDATA,U,3)
    58         . S OPER=$$EXTERNAL^DILFD(810.41,.03,"",OPER,.EM)
    59         . S RSDATES=$G(^PXRM(810.4,RULESET,30,SUB,1))
    60         .;Finding rule ien.
    61         . S FRIEN=$P(RSDATA,U,2) Q:'FRIEN
    62         .;Check if entry is a finding rule (not a set or reminder rule)
    63         . S FRDATA=$G(^PXRM(810.4,FRIEN,0)),FRTYP=$P(FRDATA,U,3) Q:FRTYP=3
    64         . S FRDATES=$P(FRDATA,U,4,5)
    65         .;Get term IEN for finding rule
    66         . I FRTYP=1 S FRTIEN=$P(FRDATA,U,7) Q:'FRTIEN
    67         .;Get Reminder definition IEN for Reminder rule
    68         . I FRTYP=2 S RRIEN=$P(FRDATA,U,10) Q:'RRIEN
    69         .;Determine RBDT and REDT
    70         . D RDATES(RSDATES,FRDATES,LBBDT,LBEDT,.RBDT,.REDT)
    71         . S NL=NL+1,OUTPUT(NL)=""
    72         . S NL=NL+1,OUTPUT(NL)="SEQUENCE "_SEQ_" "_$P(FRDATA,U,1)
    73         . S NL=NL+1,OUTPUT(NL)=" Operation: "_OPER
    74         .;Term finding rules
    75         . I FRTYP=1 D TERM(FRTIEN,LBBDT,LBEDT,RBDT,REDT,.PXRMFVPL,.NL,.OUTPUT)
    76         .;Reminder Definition List Rule
    77         . I FRTYP=2 D REM(RRIEN,LBBDT,LBEDT,RBDT,REDT,.PXRMFVPL,.NL,.OUTPUT)
    78         Q
    79         ;
    80         ;=================================================
    81 FMULPRT(FARR,PXRMFVPL,NL,OUTPUT)        ;Print the finding multiple
    82         ;information.
    83         ;Q
    84         N BDT,EDT,DERROR,FNAME,FTYPE,IND,NOCC,TBDT,TEDT,TEMP,VPTR
    85         S IND=0
    86         F  S IND=+$O(FARR(20,IND)) Q:IND=0  D
    87         . S VPTR=$P(FARR(20,IND,0),U,1)
    88         . S FNAME=$$ENTRYNAM^PXRMPTD2(VPTR)
    89         . S FTYPE=$$FTYPE^PXRMPTD2(VPTR,1)
    90         . S NL=NL+1,OUTPUT(NL)="  FINDING "_IND_"-"_FTYPE_"."_FNAME
    91         .;Set the finding parameters.
    92         . D SSPAR^PXRMUTIL(FARR(20,IND,0),.NOCC,.BDT,.EDT)
    93         . S NL=NL+1,OUTPUT(NL)="   Beginning Date/Time: "_$$FMTE^XLFDT(BDT,"5Z")
    94         . S NL=NL+1,OUTPUT(NL)="   Ending Date/Time:    "_$$FMTE^XLFDT(EDT,"5Z")
    95         . I $G(PXRMDDOC)'=2 Q
    96         . S DERROR=0
    97         . S TEMP=$G(^TMP("PXRMDDOC",$J,$P(FARR(20,IND,0),U,1,11)))
    98         .;If TEMP is null then no evaluation was required and the check
    99         .;cannot be made
    100         . I TEMP="" Q
    101         . I $P(TEMP,U,1)'=BDT D
    102         .. S DERROR=1
    103         .. S NL=NL+1,OUTPUT(NL)="  There is a consistency problem with the beginning date!"
    104         .. S NL=NL+1,OUTPUT(NL)="  Date used to build the list was: "_$$FMTE^XLFDT($P(TEMP,U,1),"5Z")
    105         . I $P(TEMP,U,2)'=EDT D
    106         .. S DERROR=1
    107         .. S NL=NL+1,OUTPUT(NL)="  There is a consistency problem with the ending date!"
    108         .. S NL=NL+1,OUTPUT(NL)="  Date used to build the list was: "_$$FMTE^XLFDT($P(TEMP,U,2),"5Z")
    109         . I DERROR D
    110         .. S NL=NL+1,OUTPUT(NL)="  Please notify the developers."
    111         .. ;S NL=NL+1,OUTPUT(NL)="  Please enter a Remedy ticket."
    112         .. S NL=NL+1,OUTPUT(NL)=" "
    113         Q
    114         ;
    115         ;=================================================
    116 RDATES(RSDATES,FRDATES,LBBDT,LBEDT,RBDT,REDT)   ;Determine the beginning and
    117         ;ending dates.
    118         ;Date precedence: LIST BUILD < RULE SET < FINDING RULE < TERM/REMINDER
    119         S RBDT=$P(FRDATES,U,1),REDT=$P(FRDATES,U,2)
    120         I RBDT="",REDT="" S RBDT=$P(RSDATES,U,1),REDT=$P(RSDATES,U,2)
    121         I RBDT="",REDT="" S RBDT=LBBDT,REDT=LBEDT
    122         I RBDT="" S RBDT=0
    123         I REDT="" S REDT=LBEDT
    124         I REDT=0 S REDT=DT
    125         ;Convert RBDT and REDT to FileMan dates.
    126         S RBDT=$$DCONV(RBDT,LBBDT,LBEDT)
    127         S REDT=$$DCONV(REDT,LBBDT,LBEDT)
    128         ;If the month is missing use January for the beginning date and
    129         ;December for the ending date.
    130         I $E(RBDT,4,5)="00" S RBDT=$E(RBDT,1,3)_"01"_$E(RBDT,6,7)
    131         I $E(REDT,4,5)="00" S REDT=$E(REDT,1,3)_"12"_$E(REDT,6,7)
    132         ;If the day is missing use the first for beginning date and the end
    133         ;of the month for ending date.
    134         I $E(RBDT,6,7)="00" S RBDT=$E(RBDT,1,5)_"01"
    135         I $E(REDT,6,7)="00" S REDT=$E(REDT,1,5)_$$DAYSIM(REDT)
    136         Q
    137         ;
    138         ;=================================================
    139 REM(IEN,LBBDT,LBEDT,RBDT,REDT,PXRMFVPL,NL,OUTPUT)       ;
    140         N DEFARR
    141         D DEF^PXRMLDR(IEN,.DEFARR)
    142         D DATES^PXRMRUL1(LBBDT,LBEDT,RBDT,REDT,.DEFARR)
    143         S NL=NL+1,OUTPUT(NL)=" REMINDER DEFINITION "_$P(DEFARR(0),U,1)
    144         D FMULPRT(.DEFARR,.PXRMFVPL,.NL,.OUTPUT)
    145         Q
    146         ;
    147         ;=================================================
    148 TERM(IEN,LBBDT,LBEDT,RBDT,REDT,PXRMFVPL,NL,OUTPUT)      ;
    149         N TERMARR
    150         D TERM^PXRMLDR(IEN,.TERMARR)
    151         D DATES^PXRMRUL1(LBBDT,LBEDT,RBDT,REDT,.TERMARR)
    152         S NL=NL+1,OUTPUT(NL)=" TERM "_$P(TERMARR(0),U,1)
    153         D FMULPRT(.TERMARR,.PXRMFVPL,.NL,.OUTPUT)
    154         Q
    155         ;
     1PXRMEUT1 ; SLC/PKR - General extract utilities ;08/09/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;=================================================
     4DCONV(DATE,LBBDT,LBEDT) ;Convert dates to actual values.
     5 I DATE=0 Q DATE
     6 N PXRMDATE
     7 S PXRMDATE=$S(DATE["BDT":LBBDT,1:LBEDT)
     8 S DATE=$$STRREP^PXRMUTIL(DATE,"BDT","T")
     9 Q $$CTFMD^PXRMDATE(DATE)
     10 ;
     11 ;=================================================
     12DAYSIM(FMDATE) ;Given a FileMan date return the number of days in the month.
     13 N MONTH
     14 S MONTH=$E(FMDATE,4,5)
     15 S DAYS=$S(MONTH="01":31,MONTH="02":28,MONTH="03":31,MONTH="04":30,MONTH="05":31,MONTH="06":30,MONTH="07":31,MONTH="08":31,MONTH="09":30,MONTH="10":31,MONTH="11":30,MONTH="12":31,1:"")
     16 I MONTH="02" D
     17 . N LYEAR,YEAR
     18 . S YEAR=$E(FMDATE,1,3)+1700
     19 . S LYEAR=$S((YEAR#4=0)&(YEAR#100'=0):1,YEAR#400=0:1,1:0)
     20 . I LYEAR S DAYS=29
     21 Q DAYS
     22 ;
     23 ;=================================================
     24DOCDATES(RULESET,LBBDT,LBEDT,NL,OUTPUT) ;
     25 N FINDPA,FRACT,FRDATA,FRDATES,FRIEN,FRLST,FRLIEN,FROLST,FROUT,FRPAT
     26 N FRPERM,FRSTRT,FRTIEN,FRTYP,FSEQ,PXRMDATE,PXRMFVPL
     27 N RRIEN,RSDATA,RSDATES,RBDT,REDT,SEQ,SUB
     28 ;Build the variable pointer list.
     29 D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
     30 S SEQ="",NL=0
     31 F  S SEQ=$O(^PXRM(810.4,RULESET,30,"B",SEQ)) Q:'SEQ  D
     32 . S SUB=$O(^PXRM(810.4,RULESET,30,"B",SEQ,"")) Q:'SUB
     33 . S RSDATA=$G(^PXRM(810.4,RULESET,30,SUB,0)) Q:RSDATA=""
     34 . S RSDATES=$G(^PXRM(810.4,RULESET,30,SUB,1))
     35 .;Finding rule ien.
     36 . S FRIEN=$P(RSDATA,U,2) Q:'FRIEN
     37 .;Check if entry is a finding rule (not a set or reminder rule)
     38 . S FRDATA=$G(^PXRM(810.4,FRIEN,0)),FRTYP=$P(FRDATA,U,3) Q:FRTYP=3
     39 . S FRDATES=$P(FRDATA,U,4,5)
     40 .;Get term IEN for finding rule
     41 . I FRTYP=1 S FRTIEN=$P(FRDATA,U,7) Q:'FRTIEN
     42 .;Get Reminder definition IEN for Reminder rule
     43 . I FRTYP=2 S RRIEN=$P(FRDATA,U,10) Q:'RRIEN
     44 .;Determine RBDT and REDT
     45 . D RDATES(RSDATES,FRDATES,LBBDT,LBEDT,.RBDT,.REDT)
     46 . S PXRMDATE=LBEDT
     47 . S $P(FINDPA(0),U,8)=RBDT,$P(FINDPA(0),U,11)=REDT
     48 . S NL=NL+1,OUTPUT(NL)=""
     49 . S NL=NL+1,OUTPUT(NL)="SEQUENCE "_SEQ_" "_$P(FRDATA,U,1)
     50 .;Term finding rules
     51 . I FRTYP=1 D TERM(FRTIEN,.FINDPA,.PXRMFVPL,.NL,.OUTPUT)
     52 .;Reminder Definition List Rule
     53 . I FRTYP=2 D REM(RRIEN,.FINDPA,.PXRMFVPL,.NL,.OUTPUT)
     54 Q
     55 ;
     56 ;=================================================
     57FMULPRT(DEFARR,FINDPA,PXRMFVPL,NL,OUTPUT) ;Print the finding multiple
     58 ;information.
     59 N BDT,EDT,FNAME,FTYPE,IND,NOCC,PFINDPA,TFINDPA,VPTR
     60 S IND=0
     61 F  S IND=+$O(DEFARR(20,IND)) Q:IND=0  D
     62 . S VPTR=$P(DEFARR(20,IND,0),U,1)
     63 . S FNAME=$$ENTRYNAM^PXRMPTD2(VPTR)
     64 . S FTYPE=$$FTYPE^PXRMPTD2(VPTR,1)
     65 . S NL=NL+1,OUTPUT(NL)="  FINDING "_IND_"-"_FTYPE_"."_FNAME
     66 . K PFINDPA,TFINDPA
     67 . M TFINDPA=DEFARR(20,IND)
     68 .;Set the finding parameters.
     69 . D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     70 . D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     71 . S NL=NL+1,OUTPUT(NL)="   Beginning Date/Time: "_$$FMTE^XLFDT(BDT,"5Z")
     72 . S NL=NL+1,OUTPUT(NL)="   Ending Date/Time:    "_$$FMTE^XLFDT(EDT,"5Z")
     73 Q
     74 ;
     75 ;=================================================
     76RDATES(RSDATES,FRDATES,LBBDT,LBEDT,RBDT,REDT) ;Determine the beginning and
     77 ;ending dates.
     78 ;Date precedence: LIST BUILD < RULE SET < FINDING RULE < TERM/REMINDER
     79 S RBDT=$P(FRDATES,U,1),REDT=$P(FRDATES,U,2)
     80 I RBDT="",REDT="" S RBDT=$P(RSDATES,U,1),REDT=$P(RSDATES,U,2)
     81 I RBDT="",REDT="" S RBDT=LBBDT,REDT=LBEDT
     82 I RBDT="" S RBDT=0
     83 I REDT="" S REDT=LBEDT
     84 I REDT=0 S REDT=$$DT^XLFDT
     85 ;Convert RBDT and REDT to FileMan dates.
     86 S RBDT=$$DCONV(RBDT,LBBDT,LBEDT)
     87 S REDT=$$DCONV(REDT,LBBDT,LBEDT)
     88 ;If the month is missing use January for the beginning date and
     89 ;December for the ending date.
     90 I $E(RBDT,4,5)="00" S RBDT=$E(RBDT,1,3)_"01"_$E(RBDT,6,7)
     91 I $E(REDT,4,5)="00" S REDT=$E(REDT,1,3)_"12"_$E(REDT,6,7)
     92 ;If the day is missing use the first for beginning date and the end
     93 ;of the month for ending date.
     94 I $E(RBDT,6,7)="00" S RBDT=$E(RBDT,1,5)_"01"
     95 I $E(REDT,6,7)="00" S REDT=$E(REDT,1,5)_$$DAYSIM(REDT)
     96 Q
     97 ;
     98 ;=================================================
     99REM(IEN,FINDPA,PXRMFVPL,NL,OUTPUT) ;
     100 N DEFARR
     101 D DEF^PXRMLDR(IEN,.DEFARR)
     102 S NL=NL+1,OUTPUT(NL)=" REMINDER DEFINITION "_$P(DEFARR(0),U,1)
     103 D FMULPRT(.DEFARR,.FINDPA,.PXRMFVPL,.NL,.OUTPUT)
     104 Q
     105 ;
     106 ;=================================================
     107TERM(IEN,FINDPA,PXRMFVPL,NL,OUTPUT) ;
     108 N TERMARR
     109 D TERM^PXRMLDR(IEN,.TERMARR)
     110 S NL=NL+1,OUTPUT(NL)=" TERM "_$P(TERMARR(0),U,1)
     111 D FMULPRT(.TERMARR,.FINDPA,.PXRMFVPL,.NL,.OUTPUT)
     112 Q
     113 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEVFI.m

    r613 r623  
    1 PXRMEVFI        ; SLC/PKR - Driver for finding evaluation. ;04/02/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================
    5 EVAL(DFN,DEFARR,FIEVAL) ;Evaluate the findings by group using the "E"
    6         ;index.
    7         N ENODE
    8         S ENODE=""
    9         F  S ENODE=$O(DEFARR("E",ENODE)) Q:ENODE=""  D
    10         . I ENODE="AUTTEDT(" D EVALFI^PXRMEDU(DFN,.DEFARR,ENODE,.FIEVAL) Q
    11         . I ENODE="AUTTEXAM(" D EVALFI^PXRMEXAM(DFN,.DEFARR,ENODE,.FIEVAL) Q
    12         . I ENODE="AUTTHF(" D EVALFI^PXRMHF(DFN,.DEFARR,ENODE,.FIEVAL) Q
    13         . I ENODE="AUTTIMM(" D EVALFI^PXRMIMM(DFN,.DEFARR,ENODE,.FIEVAL) Q
    14         . I ENODE="AUTTSK(" D EVALFI^PXRMSKIN(DFN,.DEFARR,ENODE,.FIEVAL) Q
    15         . I ENODE="GMRD(120.51," D EVALFI^PXRMVITL(DFN,.DEFARR,ENODE,.FIEVAL) Q
    16         . I ENODE="LAB(60," D EVALFI^PXRMLAB(DFN,.DEFARR,ENODE,.FIEVAL) Q
    17         . I ENODE="ORD(101.43," D EVALFI^PXRMORDR(DFN,.DEFARR,ENODE,.FIEVAL) Q
    18         . I ENODE="PXD(811.2," D EVALFI^PXRMTAX(DFN,.DEFARR,ENODE,.FIEVAL) Q
    19         . I ENODE="PXRMD(810.9," D EVALFI^PXRMLOCF(DFN,.DEFARR,ENODE,.FIEVAL) Q
    20         . I ENODE="PXRMD(811.4," D EVALFI^PXRMCF(DFN,.DEFARR,ENODE,.FIEVAL) Q
    21         . I ENODE="PXRMD(811.5," D EVALFI^PXRMTERM(DFN,.DEFARR,ENODE,.FIEVAL) Q
    22         . I ENODE="PS(50.605," D EVALFI^PXRMDRCL(DFN,.DEFARR,ENODE,.FIEVAL) Q
    23         . I ENODE="PSDRUG(" D EVALFI^PXRMDRUG(DFN,.DEFARR,ENODE,.FIEVAL) Q
    24         . I ENODE="PSNDF(50.6," D EVALFI^PXRMDGEN(DFN,.DEFARR,ENODE,.FIEVAL) Q
    25         . I ENODE="RAMIS(71," D EVALFI^PXRMRAD(DFN,.DEFARR,ENODE,.FIEVAL) Q
    26         . I ENODE="YTT(601.71," D EVALFI^PXRMMH(DFN,.DEFARR,ENODE,.FIEVAL) Q
    27         ;Evaluate function findings.
    28         D EVAL^PXRMFF(DFN,.DEFARR,.FIEVAL)
    29         Q
    30         ;
    31         ;=====================================================
    32 EVALPL(DEFARR,FINUM,PLIST)      ;Create a patient list for a regular
    33         ;finding.
    34         N FINDPA,TERMARR
    35         S FINDPA(0)=DEFARR(20,FINUM,0)
    36         S FINDPA(3)=DEFARR(20,FINUM,3)
    37         S FINDPA(10)=DEFARR(20,FINUM,10)
    38         S FINDPA(11)=DEFARR(20,FINUM,11)
    39         D GENTERM^PXRMPLST(FINDPA(0),FINUM,.TERMARR)
    40         D EVALPL^PXRMTERL(.FINDPA,.TERMARR,PLIST)
    41         Q
    42         ;
     1PXRMEVFI ; SLC/PKR - Driver for finding evaluation. ;12/01/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================
     5EVAL(DFN,DEFARR,FIEVAL) ;Evaluate the findings by group using the "E"
     6 ;index.
     7 N ENODE
     8 S ENODE=""
     9 F  S ENODE=$O(DEFARR("E",ENODE)) Q:ENODE=""  D
     10 . I ENODE="AUTTEDT(" D EVALFI^PXRMEDU(DFN,.DEFARR,ENODE,.FIEVAL) Q
     11 . I ENODE="AUTTEXAM(" D EVALFI^PXRMEXAM(DFN,.DEFARR,ENODE,.FIEVAL) Q
     12 . I ENODE="AUTTHF(" D EVALFI^PXRMHF(DFN,.DEFARR,ENODE,.FIEVAL) Q
     13 . I ENODE="AUTTIMM(" D EVALFI^PXRMIMM(DFN,.DEFARR,ENODE,.FIEVAL) Q
     14 . I ENODE="AUTTSK(" D EVALFI^PXRMSKIN(DFN,.DEFARR,ENODE,.FIEVAL) Q
     15 . I ENODE="GMRD(120.51," D EVALFI^PXRMVITL(DFN,.DEFARR,ENODE,.FIEVAL) Q
     16 . I ENODE="LAB(60," D EVALFI^PXRMLAB(DFN,.DEFARR,ENODE,.FIEVAL) Q
     17 . I ENODE="ORD(101.43," D EVALFI^PXRMORDR(DFN,.DEFARR,ENODE,.FIEVAL) Q
     18 . I ENODE="PXD(811.2," D EVALFI^PXRMTAX(DFN,.DEFARR,ENODE,.FIEVAL) Q
     19 . I ENODE="PXRMD(810.9," D EVALFI^PXRMLOCF(DFN,.DEFARR,ENODE,.FIEVAL) Q
     20 . I ENODE="PXRMD(811.4," D EVALFI^PXRMCF(DFN,.DEFARR,ENODE,.FIEVAL) Q
     21 . I ENODE="PXRMD(811.5," D EVALFI^PXRMTERM(DFN,.DEFARR,ENODE,.FIEVAL) Q
     22 . I ENODE="PS(50.605," D EVALFI^PXRMDRCL(DFN,.DEFARR,ENODE,.FIEVAL) Q
     23 . I ENODE="PSDRUG(" D EVALFI^PXRMDRUG(DFN,.DEFARR,ENODE,.FIEVAL) Q
     24 . I ENODE="PSNDF(50.6," D EVALFI^PXRMDGEN(DFN,.DEFARR,ENODE,.FIEVAL) Q
     25 . I ENODE="RAMIS(71," D EVALFI^PXRMRAD(DFN,.DEFARR,ENODE,.FIEVAL) Q
     26 . I ENODE="YTT(601," D EVALFI^PXRMMH(DFN,.DEFARR,ENODE,.FIEVAL) Q
     27 ;Evaluate function findings.
     28 D EVAL^PXRMFF(DFN,.DEFARR,.FIEVAL)
     29 Q
     30 ;
     31 ;=====================================================
     32EVALPL(DEFARR,FINUM,PLIST) ;Create a patient list for a regular
     33 ;finding.
     34 N FINDPA,TERMARR
     35 S FINDPA(0)=DEFARR(20,FINUM,0)
     36 S FINDPA(3)=DEFARR(20,FINUM,3)
     37 S FINDPA(10)=DEFARR(20,FINUM,10)
     38 S FINDPA(11)=DEFARR(20,FINUM,11)
     39 D GENTERM^PXRMPLST(FINDPA(0),FINUM,.TERMARR)
     40 D EVALPL^PXRMTERM(.FINDPA,.TERMARR,PLIST)
     41 Q
     42 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXCF.m

    r613 r623  
    1 PXRMEXCF        ; SLC/PKR - Reminder exchange routines for computed findings. ;06/28/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;==============================================
    4 EXISTS(ROUTINE) ;Return true if routine ROUTINE exists.
    5         I ROUTINE="" Q 0
    6         N RTN
    7         S RTN="^"_ROUTINE
    8         Q $S($T(@RTN)'="":1,1:0)
    9         ;
    10         ;==============================================
    11 GETRACT(ATTR,NEWNAME,NAMECHG,RTN,EXISTS)        ;Get the action for a routine.
    12         N ACTION,CHOICES,CSUM,DIR,DIROUT,DIRUT,DTOUT,DUOUT,ECS,IND,MSG
    13         N PCS,ROUTINE,SAME,TEXT,X,Y
    14         S NEWNAME=""
    15         S ROUTINE=ATTR("NAME")
    16         I EXISTS="" S EXISTS=$$EXISTS^PXRMEXCF(ROUTINE)
    17         S CHOICES=$S(EXISTS:"COQS",1:"CIQS")
    18         I EXISTS D
    19         .;If the routine exists compare the existing routine checksum with the
    20         .;the checksum of the routine in the packed definition.
    21         . S CSUM=$$RTNCS^PXRMEXCS(ROUTINE)
    22         . S SAME=$S(ATTR("CHECKSUM")=CSUM:1,1:0)
    23         . S TEXT(1)="Routine "_ROUTINE_" already exists "
    24         . I SAME D
    25         .. S TEXT(1)=TEXT(1)_"and the packed routine is identical, skipping."
    26         .. W !,TEXT(1),! H 2
    27         .. S ACTION="S"
    28         . I 'SAME D
    29         .. S TEXT(1)=TEXT(1)_"but the packed routine is different,"
    30         .. S TEXT(2)="what do you want to do?"
    31         .. W !,TEXT(1),!,TEXT(2)
    32         .. S DIR("B")="O"
    33         .. S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
    34         E  D
    35         . W !!,"Routine "_ROUTINE_" is new, what do you want to do?"
    36         . S DIR("B")="I"
    37         . S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
    38         ;
    39         I (ACTION="Q")!(ACTION="S") Q ACTION
    40         ;
    41         I ACTION="C" D
    42         . N CDONE
    43         . S CDONE=0
    44         . F  Q:CDONE  D
    45         .. S NEWNAME=$$GETNAME^PXRMEXIU(ATTR("MIN FIELD LENGTH"),ATTR("FIELD LENGTH"))
    46         .. I NEWNAME="" S ACTION="S",CDONE=1 Q
    47         .. S EXISTS=$$EXISTS^PXRMEXCF(NEWNAME)
    48         .. I EXISTS W !,"Routine ",NEWNAME," already exists, try again."
    49         .. E  D  Q
    50         ... S CDONE=1
    51         ... S NAMECHG(ATTR("FILE NUMBER"),ROUTINE)=NEWNAME
    52         ;
    53         I (ACTION="I")&(EXISTS) D
    54         .;If the action is overwrite double check that overwrite is what the
    55         .;user really wants to do.
    56         . K DIR
    57         . S DIR(0)="Y"_U_"A"
    58         . S DIR("A")="Are you sure you want to overwrite"
    59         . S DIR("B")="N"
    60         . D ^DIR
    61         . I $D(DIROUT)!$D(DIRUT) S Y=0
    62         . I $D(DTOUT)!$D(DUOUT) S Y=0
    63         . I 'Y S ACTION="S"
    64         . S NAMECHG(ATTR("FILE NUMBER"),ROUTINE)=NEWNAME
    65         Q ACTION
    66         ;
     1PXRMEXCF ; SLC/PKR - Reminder exchange routines for computed findings. ;12/22/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;==============================================
     4EXISTS(ROUTINE) ;Return true if routine ROUTINE exists.
     5 I ROUTINE="" Q 0
     6 N RTN
     7 S RTN="^"_ROUTINE
     8 Q $S($T(@RTN)'="":1,1:0)
     9 ;
     10 ;==============================================
     11GETRACT(ATTR,NEWNAME,NAMECHG,RTN,EXISTS) ;Get the action for a routine.
     12 N ACTION,CHOICES,DIR,DIROUT,DIRUT,DTOUT,DUOUT,ECS,IND,MSG
     13 N PCS,ROUTINE,SAME,TEXT,X,Y
     14 S NEWNAME=""
     15 ;If the routine exists compare the existing routine checksum with the
     16 ;the checksum of the routine in the packed definition.
     17 S ROUTINE=ATTR("NAME")
     18 I EXISTS="" S EXISTS=$$EXISTS^PXRMEXCF(ROUTINE)
     19 S CHOICES=$S(EXISTS:"COQS",1:"CIQS")
     20 I EXISTS D
     21 . S SAME=$$SAME(.ATTR,.RTN)
     22 . S TEXT(1)="Routine "_ROUTINE_" already exists "
     23 . I SAME S TEXT(1)=TEXT(1)_"and the packed routine is identical,"
     24 . I 'SAME S TEXT(1)=TEXT(1)_"but the packed routine is different,"
     25 . S TEXT(2)="what do you want to do?"
     26 . D EN^DDIOL(.TEXT)
     27 . S DIR("B")="S"
     28 . S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
     29 E  D
     30 . W !!,"Routine "_ROUTINE_" is NEW, what do you want to do?"
     31 . S DIR("B")="I"
     32 . S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
     33 ;
     34 I ACTION="Q" Q ACTION
     35 ;
     36 I ACTION="C" D
     37 . N CDONE
     38 . S CDONE=0
     39 . F  Q:CDONE  D
     40 .. S NEWNAME=$$GETNAME^PXRMEXIU(ATTR("MIN FIELD LENGTH"),ATTR("FIELD LENGTH"))
     41 .. I NEWNAME="" S ACTION="S",CDONE=1 Q
     42 .. S EXISTS=$$EXISTS^PXRMEXCF(NEWNAME)
     43 .. I EXISTS W !,"Routine ",NEWNAME," already exists, try again."
     44 .. E  D  Q
     45 ... S CDONE=1
     46 ... S NAMECHG(ATTR("FILE NUMBER"),ROUTINE)=NEWNAME
     47 ;
     48 I (ACTION="I")&(EXISTS) D
     49 .;If the action is overwrite double check that overwrite is what the
     50 .;user really wants to do.
     51 . K DIR
     52 . S DIR(0)="Y"_U_"A"
     53 . S DIR("A")="Are you sure you want to overwrite"
     54 . S DIR("B")="N"
     55 . D ^DIR
     56 . I $D(DIROUT)!$D(DIRUT) S Y=0
     57 . I $D(DTOUT)!$D(DUOUT) S Y=0
     58 . I 'Y S ACTION="S"
     59 . S NAMECHG(ATTR("FILE NUMBER"),ROUTINE)=NEWNAME
     60 Q ACTION
     61 ;
     62 ;==============================================
     63SAME(ATTR,RTN) ;Compare the existing routine and the new version
     64 ;in RTN to see if they are the same.
     65 N ECS,DIF,NEWCS,RT,SAME,X,XCNP
     66 ;Load the existing routine into RT.
     67 S XCNP=0
     68 S DIF="RT("
     69 S X=ATTR("NAME")
     70 X ^%ZOSF("LOAD")
     71 S ECS=$$ROUTINE^PXRMEXCS(.RT)
     72 K RT
     73 S NEWCS=$$ROUTINE^PXRMEXCS(.RTN)
     74 S SAME=$S(ECS=NEWCS:1,1:0)
     75 Q SAME
     76 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXCS.m

    r613 r623  
    1 PXRMEXCS        ; SLC/PKR - Routines to compute checksums. ;07/27/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;====================================================
    4 CHECKSUM(ATTR,START,END)        ;Get the the checksum for a packed reminder
    5         ;component and load it into the attribute array.
    6         N CS,LINE
    7         ;If checksum is in packed component return it otherwise calculate it.
    8         I ATTR("FILE NUMBER")=0 D
    9         . S LINE=^PXD(811.8,PXRMRIEN,100,START-3,0)
    10         . S CS=$$GETTAGV^PXRMEXU3(LINE,"<CHECKSUM>")
    11         . I CS="" S CS=$$PRTNCS(PXRMRIEN,START,END)
    12         I ATTR("FILE NUMBER")>0 D
    13         . S LINE=^PXD(811.8,PXRMRIEN,100,START-2,0)
    14         . S CS=$$GETTAGV^PXRMEXU3(LINE,"<CHECKSUM>")
    15         . I CS="" S CS=$$PFDACS(PXRMRIEN,START,END)
    16         S ATTR("CHECKSUM")=CS
    17         Q
    18         ;
    19         ;====================================================
    20 DIQOUTCS(DIQOUT)        ;Return checksum for a processed DIQOUT array.
    21         N CS,DATA,FIELD,FNUM,IENS,IND,SFN,STRING,TARGET,TEXT,WP
    22         S FNUM=$O(DIQOUT(""))
    23         D FIELD^DID(FNUM,"EDIT HISTORY","","SPECIFIER","TARGET")
    24         S SFN=+$G(TARGET("SPECIFIER"))
    25         S (CS,FNUM)=0
    26         F  S FNUM=$O(DIQOUT(FNUM)) Q:FNUM=""  D
    27         . I FNUM=SFN Q
    28         . S IENS=""
    29         . F  S IENS=$O(DIQOUT(FNUM,IENS)) Q:IENS=""  D
    30         .. S FIELD=0
    31         .. F  S FIELD=$O(DIQOUT(FNUM,IENS,FIELD)) Q:FIELD=""  D
    32         ... S DATA=DIQOUT(FNUM,IENS,FIELD)
    33         ... S TEXT=FNUM_$L(IENS,",")_FIELD_DATA
    34         ... S CS=$$CRC32^XLFCRC(TEXT,CS)
    35         ... I DATA["WP-start" F IND=1:1:$P(DATA,"~",2) D
    36         .... S TEXT=DIQOUT(FNUM,IENS,FIELD,IND)
    37         .... S CS=$$CRC32^XLFCRC(TEXT,CS)
    38         Q CS
    39         ;
    40         ;====================================================
    41 FILE(FILENUM,IEN)       ;Return checksum for entry IEN in file FILENUM.
    42         N CS,DIQOUT,IENROOT,MSG
    43         D GETS^DIQ(FILENUM,IEN,"**","N","DIQOUT","MSG")
    44         ;Remove edit history from all reminder files.
    45         D RMEH^PXRMEXPU(FILENUM,.DIQOUT,1)
    46         ;Convert the iens to the FDA adding form.
    47         D CONTOFDA^PXRMEXPU(.DIQOUT,.IENROOT)
    48         S CS=$$DIQOUTCS(.DIQOUT)
    49         Q CS
    50         ;
    51         ;====================================================
    52 HFCS(PATH,FILENAME)     ;Return checksum for host file.
    53         N CS,GBL,GBLZISH,SUCCESS
    54         K ^TMP($J,"PXRMHFCS")
    55         S GBL="^TMP($J,""PXRMHFCS"")"
    56         S GBLZISH="^TMP($J,""PXRMHFCS"",1)"
    57         S GBLZISH=$NA(@GBLZISH)
    58         S SUCCESS=$$FTG^%ZISH(PATH,FILENAME,GBLZISH,3)
    59         S CS=$S(SUCCESS:$$HFCSGBL(GBL),1:-1)
    60         K ^TMP($J,"PXRMHFCS")
    61         Q CS
    62         ;
    63         ;====================================================
    64 HFCSGBL(GBL)    ;Return checksum for host file loaded into global GBL.
    65         N CS,IND,LINE
    66         S (CS,IND)=0
    67         F  S IND=$O(@GBL@(IND)) Q:+IND=0  S LINE=@GBL@(IND),CS=$$CRC32^XLFCRC(LINE,CS)
    68         Q CS
    69         ;
    70         ;====================================================
    71 MMCS(XMZ)       ;Return checksum for MailMan message ien XMZ.
    72         N CS,IND,LINE,NLINES
    73         S NLINES=+$P($G(^XMB(3.9,XMZ,2,0)),U,3)
    74         S CS=0
    75         F IND=1:1:NLINES S LINE=$G(^XMB(3.9,XMZ,2,IND,0)),CS=$$CRC32^XLFCRC(LINE,CS)
    76         Q CS
    77         ;
    78         ;====================================================
    79 PFDACS(IEN,FDASTART,FDAEND)     ;Return checksum for FDA array of packed
    80         ;reminder component.
    81         N CS,DATA,IENS,IND,JND,FIELD,FNUM,SFN,TARGET,TEMP,TEXT
    82         S TEMP=^PXD(811.8,IEN,100,FDASTART,0)
    83         S FNUM=$P(TEMP,";",1)
    84         D FIELD^DID(FNUM,"EDIT HISTORY","","SPECIFIER","TARGET")
    85         S SFN=+$G(TARGET("SPECIFIER"))
    86         S CS=0
    87         F IND=FDASTART:1:FDAEND D
    88         . S TEMP=^PXD(811.8,IEN,100,IND,0)
    89         . S DATA=$P(TEMP,"~",2,99)
    90         . S TEMP=$P(TEMP,"~",1)
    91         . S FNUM=$P(TEMP,";",1)
    92         . I FNUM=SFN Q
    93         . I FNUM="Exchange Stub" Q
    94         . S IENS=$P(TEMP,";",2)
    95         . S FIELD=$P(TEMP,";",3)
    96         . S TEXT=FNUM_$L(IENS,",")_FIELD_DATA
    97         . S CS=$$CRC32^XLFCRC(TEXT,CS)
    98         . I DATA["WP-start" F JND=1:1:$P(DATA,"~",2) D
    99         .. S IND=IND+1
    100         .. S TEXT=^PXD(811.8,IEN,100,IND,0)
    101         .. S CS=$$CRC32^XLFCRC(TEXT,CS)
    102         Q CS
    103         ;
    104         ;====================================================
    105 ROUTINE(RA)     ;Return checksum for a routine loaded in array RA. RA has the
    106         ;form created by ^%ZOSF("LOAD") i.e, RA(1,0) ... RA(N,0).
    107         N CS,IND,TEXT
    108         S (CS,IND)=0
    109         ;Get rid of the build number on the second line.
    110         S RA(2,0)=$P(RA(2,0),";",1,6)
    111         F  S IND=$O(RA(IND)) Q:+IND=0  D
    112         . S TEXT=RA(IND,0)
    113         . S CS=$$CRC32^XLFCRC(RA(IND,0),CS)
    114         Q CS
    115         ;
    116         ;====================================================
    117 RTNCS(ROUTINE)  ;Return checksum for a routine ROUTINE.
    118         N CS,DIF,RA,X,XCNP
    119         S XCNP=0
    120         S DIF="RA("
    121         S X=ROUTINE
    122         ;Make sure the routine exists.
    123         X ^%ZOSF("TEST")
    124         I $T D
    125         . X ^%ZOSF("LOAD")
    126         . S CS=$$ROUTINE(.RA)
    127         E  S CS=-1
    128         Q CS
    129         ;
    130         ;====================================================
    131 PRTNCS(IEN,START,END)   ;Return checksum for a packed routine.
    132         N CS,IND,SL,TEXT
    133         S CS=0,SL=START+1
    134         F IND=START:1:END D
    135         . S TEXT=^PXD(811.8,IEN,100,IND,0)
    136         . ;Get rid of the build number on the second line.
    137         . I IND=SL S TEXT=$P(TEXT,";",1,6)
    138         . S CS=$$CRC32^XLFCRC(TEXT,CS)
    139         Q CS
    140         ;
     1PXRMEXCS ; SLC/PKR - Routines to compute checksums. ;12/21/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;====================================================
     4FILE(FILENUM,IEN) ;Return checksum for entry IEN in file FILENUM.
     5 N CS,LC,REF,ROOT,TARGET
     6 D FILE^DID(FILENUM,"","GLOBAL NAME","TARGET")
     7 S ROOT=$$CREF^DILF(TARGET("GLOBAL NAME"))
     8 K ^TMP($J,"PXRMEXCS")
     9 M ^TMP($J,"PXRMEXCS")=@ROOT@(IEN)
     10 S REF="^TMP($J,""PXRMEXCS"")"
     11 S REF=$NA(@REF)
     12 S (CS,LC)=0
     13 F  S REF=$Q(@REF) Q:REF'["PXRMEXCS"  S LC=LC+1,CS=CS+$$LINECS(LC,@REF)
     14 K ^TMP($J,"PXRMEXCS")
     15 Q CS
     16 ;
     17 ;====================================================
     18HFCS(PATH,FILENAME) ;Return checksum for host file.
     19 N CS,GBL,GBLZISH,SUCCESS
     20 K ^TMP($J,"PXRMHFCS")
     21 S GBL="^TMP($J,""PXRMHFCS"")"
     22 S GBLZISH="^TMP($J,""PXRMHFCS"",1)"
     23 S GBLZISH=$NA(@GBLZISH)
     24 S SUCCESS=$$FTG^%ZISH(PATH,FILENAME,GBLZISH,3)
     25 S CS=$S(SUCCESS:$$HFCSGBL(GBL),1:-1)
     26 K ^TMP($J,"PXRMHFCS")
     27 Q CS
     28 ;
     29 ;====================================================
     30HFCSGBL(GBL) ;Return checksum for host file loaded into global GBL.
     31 N CS,IND,LINE
     32 S (CS,IND)=0
     33 F  S IND=$O(@GBL@(IND)) Q:+IND=0  S LINE=@GBL@(IND),CS=CS+$$LINECS(IND,LINE)
     34 Q CS
     35 ;
     36 ;====================================================
     37LINECS(LINENUM,STRING) ;Return checksum of line number LINEUM whose contents
     38 ;is STRING.
     39 N CS,IND,LEN
     40 S CS=0
     41 S LEN=$L(STRING)
     42 F IND=1:1:LEN S CS=CS+($A(STRING,IND)*(LINENUM+IND))
     43 Q CS
     44 ;
     45 ;====================================================
     46MMCS(XMZ) ;Return checksum for MailMan message ien XMZ.
     47 N CS,IND,LINE,NLINES
     48 S NLINES=+$P($G(^XMB(3.9,XMZ,2,0)),U,3)
     49 S CS=0
     50 F IND=1:1:NLINES S LINE=$G(^XMB(3.9,XMZ,2,IND,0)),CS=CS+$$LINECS(IND,LINE)
     51 Q CS
     52 ;
     53 ;====================================================
     54ROUTINE(RA) ;Return checksum for a routine loaded in array RA. RA has the
     55 ;form created by ^%ZOSF("LOAD") i.e, RA(1,0) ... RA(N,0).
     56 N CS,IND,LINE
     57 S (CS,IND)=0
     58 F  S IND=$O(RA(IND)) Q:+IND=0  S CS=CS+$$LINECS(IND,RA(IND,0))
     59 Q CS
     60 ;
     61 ;====================================================
     62RTN(ROUTINE) ;Return checksum for a routine ROUTINE.
     63 N CS,DIF,RA,X,XCNP
     64 S XCNP=0
     65 S DIF="RA("
     66 S X=ROUTINE
     67 ;Make sure the routine exists.
     68 X ^%ZOSF("TEST")
     69 I $T D
     70 . X ^%ZOSF("LOAD")
     71 . S CS=$$ROUTINE(.RA)
     72 E  S CS=-1
     73 Q CS
     74 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXDG.m

    r613 r623  
    1 PXRMEXDG        ;SLC/PJH - Reminder Dialog Exchange index build ;05/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================================
    5 DIALOG(RIEN,DLIST,FLIST,OLIST,TLIST,SPONLIST)   ;
    6         ;
    7         ;Routine to get dialog details for a given reminder
    8         ;
    9         ;Called as DIALOG^PXRMEXDG(RIEN,.DLIST,.FLIST)
    10         ;
    11         ;RIEN   - Reminder IEN
    12         ;DLIST  - List of dialogs (components first)
    13         ;FLIST  - Finding list used by PXRMEXPR
    14         ;OLIST  - List of embedded TIU objects
    15         ;TLIST  - List of embedded TIU templates
    16         ;
    17         ;Initialize
    18         K DLIST
    19         N DARRAY,DCNT,DIALOG,DIEN,FCNT,FINDING,OCNT,RCNT,RESULT,TEMP
    20         ;Check if reminder exists
    21         Q:'$D(^PXD(811.9,RIEN,0))
    22         ;Get dialog ien from reminder definition
    23         S DIEN=$P($G(^PXD(811.9,RIEN,51)),U) Q:'DIEN
    24         ;Check dialog pointer is valid
    25         Q:'$D(^PXRMD(801.41,DIEN))
    26         ;Dialog and Finding count
    27         S DCNT=0,FCNT=0,RCNT=0,TCNT=0
    28         ;Get details
    29         D GETSPON^PXRMEXPR(801.41,DIEN,.SPONLIST)
    30         D DGET(DIEN,.SPONLIST)
    31         ;
    32         ;Now build the dialog list (components first)
    33         S DCNT="",OCNT=0
    34         F  S DCNT=$O(DARRAY(DCNT),-1) Q:'DCNT  D
    35         .;Ignore dialogs previously encountered
    36         .S DIEN=DARRAY(DCNT) Q:$D(DIALOG(DIEN))
    37         .;Save dialog in output array
    38         .S OCNT=OCNT+1,DIALOG(DIEN)="",TEMP("DIALOG",OCNT)=DIEN
    39         ;
    40         ;Save the dialog and result details to DLIST
    41         N CNT,COUNT,DTYP
    42         S COUNT=0
    43         F DTYP="RESULT ELEMENT" D
    44         .S CNT=0 F  S CNT=$O(TEMP(DTYP,CNT)) Q:CNT'>0  D
    45         ..S DIEN=$G(TEMP(DTYP,CNT)) Q:DIEN'>0
    46         ..S COUNT=COUNT+1,DLIST("DIALOG",COUNT,DIEN)=""
    47         ;
    48         F DTYP="RESULT" D
    49         .S CNT=0 F  S CNT=$O(TEMP(DTYP,CNT)) Q:CNT'>0  D
    50         ..S DIEN=$G(TEMP(DTYP,CNT)) Q:DIEN'>0
    51         ..S COUNT=COUNT+1,DLIST("DIALOG",COUNT,DIEN)=""
    52         ;
    53         ;F DTYP="RESULT","DIALOG" D
    54         F DTYP="DIALOG" D
    55         .F CNT=1:1 S DIEN=$G(TEMP(DTYP,CNT)) Q:'DIEN  D
    56         ..S COUNT=COUNT+1,DLIST("DIALOG",COUNT,DIEN)=""
    57         ;
    58         I COUNT>0 S DLIST("DIALOG")=801.41
    59         ;
    60         ;Add Dialog Findings to FLIST if not aready present
    61         N DIC,DO,IEN,FNAME,FNUM,SUB
    62         S SUB=0
    63         F  S SUB=$O(TEMP("FINDING",SUB)) Q:'SUB  D
    64         .S IEN=$P(TEMP("FINDING",SUB),";"),DIC=U_$P(TEMP("FINDING",SUB),";",2)
    65         .K DO D DO^DIC1
    66         .S FNUM=+DO(2),FNAME=$P(DO,U) I ('FNUM)!(FNAME="") Q
    67         .;Check if present in FLIST
    68         .I $D(FLIST(FNAME,"F",IEN)) Q
    69         .;Otherwise add to list
    70         .S:'$D(FLIST(FNAME)) FLIST(FNAME)=FNUM S FLIST(FNAME,"F",IEN)=""
    71         .;Add the Health Factor category to FLIST
    72         .I FNAME="HEALTH FACTORS" D
    73         ..N HFCAT
    74         ..S HFCAT=$P($G(^AUTTHF(IEN,0)),U,3) S:HFCAT FLIST(FNAME,"C",HFCAT)=""
    75         ;
    76         ;Store any TIU components
    77         N GLOB,DIEN,CNT
    78         ;Set global for search
    79         S GLOB="^PXRMD(801.41,"
    80         ;Search through all component dialogs
    81         S CNT=0
    82         F  S CNT=$O(DLIST("DIALOG",CNT)) Q:'CNT  D
    83         .S DIEN=$O(DLIST("DIALOG",CNT,"")) Q:'DIEN
    84         .;Search Dialog Text for TIU Objects and Templates
    85         .D TIUSRCH(GLOB,DIEN,25,.OLIST,.TLIST)
    86         .;Search P/N Text for TIU Objects and Templates
    87         .D TIUSRCH(GLOB,DIEN,35,.OLIST,.TLIST)
    88         ;
    89         Q
    90         ;
    91         ;Get the dialog components
    92         ;-------------------------
    93 DGET(D0,SPONLIST)       ;Save dialog ien
    94         N D1
    95         I $G(D0)=83
    96         I $G(^PXRMD(801.41,D0,49))'="",$P(^PXRMD(801.41,D0,49),U,3)>0 D
    97         .S D1=$P($G(^PXRMD(801.41,D0,49)),U,3) D DGET1(D0,.SPONLIST) D DGET1(D1,.SPONLIST)
    98         E  D DGET1(D0,.SPONLIST)
    99         Q
    100 DGET1(D0,SPONLIST)      ;
    101         S DCNT=DCNT+1,DARRAY(DCNT)=D0
    102         ;And details (except for reminder dialog)
    103         I DCNT>1 D
    104         .D GETSPON^PXRMEXPR(801.41,D0,.SPONLIST)
    105         .;Finding items
    106         .D DFIND(D0)
    107         .;Additional Finding Items
    108         .D DFINDA(D0)
    109         .;Result groups
    110         .D DRESULT(D0)
    111         ;
    112         ;Dialog components
    113         N DCOMP,DCOMP1,DDATA,DSUB
    114         S DSUB=0
    115         F  S DSUB=$O(^PXRMD(801.41,D0,10,DSUB)) Q:'DSUB  D
    116         .;Get any component dialogs
    117         .S DCOMP=$P($G(^PXRMD(801.41,D0,10,DSUB,0)),U,2) Q:'DCOMP
    118         .;If component exists get sub-components
    119         .S DDATA=$G(^PXRMD(801.41,DCOMP,0)) Q:DDATA=""
    120         .;Exclude national PXRM prompts
    121         .I +$G(PXRMINST)=0,$E(DDATA,1,4)="PXRM",$P($G(^PXRMD(801.41,DCOMP,100)),U)="N" Q
    122         .;Sub-components
    123         .D DGET(DCOMP,.SPONLIST)
    124         .;I $G(DCOMP1)'="" D DGET(DCOMP1) S DCOMP1=""
    125         Q
    126         ;
    127         ;Build list of finding items
    128         ;---------------------------
    129 DFIND(DIEN)     ;
    130         N FIND,FIEN,FGLOB,FNAM
    131         ;Finding Item
    132         S FIND=$P($G(^PXRMD(801.41,DIEN,1)),U,5)
    133         ;If a finding item exists check and save
    134 LOOP    ;
    135         I FIND]"" D
    136         .;Finding item defined
    137         .S FIEN=$P(FIND,";"),FGLOB=$P(FIND,";",2) Q:'FIEN  Q:FGLOB=""
    138         .;And finding item exists
    139         .Q:'$D(@(U_FGLOB_FIEN_",0)"))
    140         .;Finding name
    141         .S FNAM=$P($G(@(U_FGLOB_FIEN_",0)")),U) S:FNAM="" FNAM="???"
    142         .;And not previously saved
    143         .I '$D(FINDING(FIND)) D
    144         ..S FCNT=FCNT+1,FINDING(FIND)="",TEMP("FINDING",FCNT)=FIND
    145         I $G(^PXRMD(801.41,DIEN,49))'="",$P(^PXRMD(801.41,DIEN,49),U)>0 D
    146         .S FIND=$P(^PXRMD(801.41,DIEN,49),U)
    147         .I $D(FLIST("REMINDER TERM","F",FIND)) Q
    148         .I '$D(FLIST("REMINDER TERM")) S FLIST("REMINDER TERM")="811.5"
    149         .S FLIST("REMINDER TERM","F",FIND)=""
    150         .D GETTFIND^PXRMEXPR(.FLIST)
    151         Q
    152         ;
    153         ;Build list of additional findings
    154         ;---------------------------------
    155 DFINDA(DIEN)    ;
    156         N FIND,FIEN,FGLOB,FNAM,FSUB
    157         S FSUB=0
    158         F  S FSUB=$O(^PXRMD(801.41,DIEN,3,FSUB)) Q:'FSUB  D
    159         .;Additional Finding Item
    160         .S FIND=$P($G(^PXRMD(801.41,DIEN,3,FSUB,0)),U)
    161         .;If a finding item exists check and save
    162         .I FIND]"" D
    163         ..;Finding item defined
    164         ..S FIEN=$P(FIND,";"),FGLOB=$P(FIND,";",2) Q:'FIEN  Q:FGLOB=""
    165         ..;And finding item exists
    166         ..Q:'$D(@(U_FGLOB_FIEN_",0)"))
    167         ..;Finding name
    168         ..S FNAM=$P($G(@(U_FGLOB_FIEN_",0)")),U) S:FNAM="" FNAM="???"
    169         ..;And not previously saved
    170         ..I '$D(FINDING(FIND)) D
    171         ...S FCNT=FCNT+1,FINDING(FIND)="",TEMP("FINDING",FCNT)=FIND
    172         Q
    173         ;
    174         ;Build list of result groups
    175         ;---------------------------
    176 DRESULT(DIEN)   ;
    177         N CNT,RIEN,RECNT,RGCNT
    178         ;Result Group/Element pointer
    179         S RECNT=$O(TEMP("RESULT ELEMENT",""),-1)
    180         S RGCNT=$O(TEMP("RESULT",""),-1)
    181         S CNT=0
    182         F  S CNT=$O(^PXRMD(801.41,DIEN,51,CNT)) Q:CNT'>0  D
    183         .S RIEN=$P($G(^PXRMD(801.41,DIEN,51,CNT,0)),U) Q:RIEN'>0
    184         .;S RIEN=$P($G(^PXRMD(801.41,DIEN,0)),U,15) Q:'RIEN  Q:$D(RESULT(RIEN))
    185         .;Result group compoments
    186         .N DSUB,REIEN
    187         .S DSUB=0
    188         .F  S DSUB=$O(^PXRMD(801.41,RIEN,10,DSUB)) Q:'DSUB  D
    189         ..;Get result element
    190         ..S REIEN=$P($G(^PXRMD(801.41,RIEN,10,DSUB,0)),U,2) Q:'REIEN
    191         ..Q:'$D(^PXRMD(801.41,REIEN,0))
    192         ..;If element exists get save it
    193         ..S RECNT=RECNT+1,TEMP("RESULT ELEMENT",RECNT)=REIEN
    194         ..;S RCNT=RCNT+1,OUTPUT("RESULT",RCNT)=REIEN
    195         .;
    196         .;Save result group
    197         .S RGCNT=RGCNT+1,TEMP("RESULT",RGCNT)=RIEN
    198         .;S RCNT=RCNT+1,RESULT(RIEN)="",TEMP("RESULT",RCNT)=RIEN
    199         Q
    200         ;
    201         ;Extract TIU Objects/Templates from any WP text
    202         ;----------------------------------------------
    203 TIUSRCH(GLOB,IEN,NODE,OLIST,TLIST)      ;
    204         N OCNT,TCNT,TEXT
    205         ;Add to existing arrays
    206         S OCNT=+$O(OLIST(""),-1),TCNT=+$O(TLIST(""),-1),SUB=0
    207         ;Scan WP fields
    208         F  S SUB=$O(@(GLOB_IEN_","_NODE_","_SUB_")")) Q:'SUB  D
    209         .;Get individual line
    210         .S TEXT=$G(@(GLOB_IEN_","_NODE_","_SUB_",0)")) Q:TEXT=""
    211         .;Most text lines will have no TIU link so ignore them
    212         .I (TEXT'["|")&(TEXT'["{FLD:") Q
    213         .;Templates are in format {FLD:fldname} (only applies to dialogs)
    214         .I GLOB[801.41 D TIUXTR("{FLD:","}",TEXT,.TLIST,.TCNT)
    215         .;Objects are in format |Objectname|
    216         .D TIUXTR("|","|",TEXT,.OLIST,.OCNT)
    217         Q
    218         ;
    219 TIUXTR(SRCH,SRCH1,TEXT,OUTPUT,CNT)      ;
    220         N EXIST,IC,TXT,ONAME
    221         S TXT=TEXT
    222         F  D  Q:TXT'[SRCH
    223         .S TXT=$E(TXT,$F(TXT,SRCH),$L(TXT)) Q:TXT'[SRCH1
    224         .S ONAME=$P(TXT,SRCH1) Q:ONAME=""
    225         .;Check if already selected
    226         .S EXIST=0,IC=0
    227         .F  S IC=$O(OUTPUT(IC)) Q:'IC  Q:EXIST  D
    228         ..I $G(OUTPUT(IC))=ONAME S EXIST=1
    229         .;Save array of object/template names
    230         .I 'EXIST S CNT=CNT+1,OUTPUT(CNT)=ONAME
    231         Q
     1PXRMEXDG ;SLC/PJH - Reminder Dialog Exchange index build ;02/25/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================================
     5DIALOG(RIEN,DLIST,FLIST,OLIST,TLIST) ;
     6 ;
     7 ;Routine to get dialog details for a given reminder
     8 ;
     9 ;Called as DIALOG^PXRMEXDG(RIEN,.DLIST,.FLIST)
     10 ;
     11 ;RIEN   - Reminder IEN
     12 ;DLIST  - List of dialogs (components first)
     13 ;FLIST  - Finding list used by PXRMEXPR
     14 ;OLIST  - List of embedded TIU objects
     15 ;TLIST  - List of embedded TIU templates
     16 ;
     17 ;Initialize
     18 K DLIST
     19 N DARRAY,DCNT,DIALOG,DIEN,FCNT,FINDING,OCNT,RCNT,RESULT,TEMP
     20 ;Check if reminder exists
     21 Q:'$D(^PXD(811.9,RIEN,0))
     22 ;Get dialog ien from reminder definition
     23 S DIEN=$P($G(^PXD(811.9,RIEN,51)),U) Q:'DIEN
     24 ;Check dialog pointer is valid
     25 Q:'$D(^PXRMD(801.41,DIEN))
     26 ;Dialog and Finding count
     27 S DCNT=0,FCNT=0,RCNT=0,TCNT=0
     28 ;Get details
     29 D DGET(DIEN)
     30 ;
     31 ;Now build the dialog list (components first)
     32 S DCNT="",OCNT=0
     33 F  S DCNT=$O(DARRAY(DCNT),-1) Q:'DCNT  D
     34 .;Ignore dialogs previously encountered
     35 .S DIEN=DARRAY(DCNT) Q:$D(DIALOG(DIEN))
     36 .;Save dialog in output array
     37 .S OCNT=OCNT+1,DIALOG(DIEN)="",TEMP("DIALOG",OCNT)=DIEN
     38 ;
     39 ;Save the dialog and result details to DLIST
     40 N CNT,COUNT,DTYP
     41 S COUNT=0
     42 F DTYP="RESULT","DIALOG" D
     43 .F CNT=1:1 S DIEN=$G(TEMP(DTYP,CNT)) Q:'DIEN  D
     44 ..S COUNT=COUNT+1,DLIST("DIALOG",COUNT,DIEN)=""
     45 ;
     46 I COUNT>0 S DLIST("DIALOG")=801.41
     47 ;
     48 ;Add Dialog Findings to FLIST if not aready present
     49 N DIC,DO,IEN,FNAME,FNUM,SUB
     50 S SUB=0
     51 F  S SUB=$O(TEMP("FINDING",SUB)) Q:'SUB  D
     52 .S IEN=$P(TEMP("FINDING",SUB),";"),DIC=U_$P(TEMP("FINDING",SUB),";",2)
     53 .K DO D DO^DIC1
     54 .S FNUM=+DO(2),FNAME=$P(DO,U) I ('FNUM)!(FNAME="") Q
     55 .;Check if present in FLIST
     56 .I $D(FLIST(FNAME,"F",IEN)) Q
     57 .;Otherwise add to list
     58 .S:'$D(FLIST(FNAME)) FLIST(FNAME)=FNUM S FLIST(FNAME,"F",IEN)=""
     59 .;Add the Health Factor category to FLIST
     60 .I FNAME="HEALTH FACTORS" D
     61 ..N HFCAT
     62 ..S HFCAT=$P($G(^AUTTHF(IEN,0)),U,3) S:HFCAT FLIST(FNAME,"C",HFCAT)=""
     63 ;
     64 ;Store any TIU components
     65 N GLOB,DIEN,CNT
     66 ;Set global for search
     67 S GLOB="^PXRMD(801.41,"
     68 ;Search through all component dialogs
     69 S CNT=0
     70 F  S CNT=$O(DLIST("DIALOG",CNT)) Q:'CNT  D
     71 .S DIEN=$O(DLIST("DIALOG",CNT,"")) Q:'DIEN
     72 .;Search Dialog Text for TIU Objects and Templates
     73 .D TIUSRCH(GLOB,DIEN,25,.OLIST,.TLIST)
     74 .;Search P/N Text for TIU Objects and Templates
     75 .D TIUSRCH(GLOB,DIEN,35,.OLIST,.TLIST)
     76 ;
     77 Q
     78 ;
     79 ;Get the dialog components
     80 ;-------------------------
     81DGET(D0) ;Save dialog ien
     82 N D1
     83 I $G(D0)=83
     84 I $G(^PXRMD(801.41,D0,49))'="",$P(^PXRMD(801.41,D0,49),U,3)>0 D
     85 .S D1=$P($G(^PXRMD(801.41,D0,49)),U,3) D DGET1(D0) D DGET1(D1)
     86 E  D DGET1(D0)
     87 Q
     88DGET1(D0) ;
     89 S DCNT=DCNT+1,DARRAY(DCNT)=D0
     90 ;And details (except for reminder dialog)
     91 I DCNT>1 D
     92 .;Finding items
     93 .D DFIND(D0)
     94 .;Additional Finding Items
     95 .D DFINDA(D0)
     96 .;Result groups
     97 .D DRESULT(D0)
     98 ;
     99 ;Dialog components
     100 N DCOMP,DCOMP1,DDATA,DSUB
     101 S DSUB=0
     102 F  S DSUB=$O(^PXRMD(801.41,D0,10,DSUB)) Q:'DSUB  D
     103 .;Get any component dialogs
     104 .S DCOMP=$P($G(^PXRMD(801.41,D0,10,DSUB,0)),U,2) Q:'DCOMP
     105 .;If component exists get sub-components
     106 .S DDATA=$G(^PXRMD(801.41,DCOMP,0)) Q:DDATA=""
     107 .;Exclude national PXRM prompts
     108 .I $E(DDATA,1,4)="PXRM",$P($G(^PXRMD(801.41,DCOMP,100)),U)="N" Q
     109 .;Sub-components
     110 .D DGET(DCOMP)
     111 .;I $G(DCOMP1)'="" D DGET(DCOMP1) S DCOMP1=""
     112 Q
     113 ;
     114 ;Build list of finding items
     115 ;---------------------------
     116DFIND(DIEN) ;
     117 N FIND,FIEN,FGLOB,FNAM
     118 ;Finding Item
     119 S FIND=$P($G(^PXRMD(801.41,DIEN,1)),U,5)
     120 ;If a finding item exists check and save
     121LOOP ;
     122 I FIND]"" D
     123 .;Finding item defined
     124 .S FIEN=$P(FIND,";"),FGLOB=$P(FIND,";",2) Q:'FIEN  Q:FGLOB=""
     125 .;And finding item exists
     126 .Q:'$D(@(U_FGLOB_FIEN_",0)"))
     127 .;Finding name
     128 .S FNAM=$P($G(@(U_FGLOB_FIEN_",0)")),U) S:FNAM="" FNAM="???"
     129 .;And not previously saved
     130 .I '$D(FINDING(FIND)) D
     131 ..S FCNT=FCNT+1,FINDING(FIND)="",TEMP("FINDING",FCNT)=FIND
     132 I $G(^PXRMD(801.41,DIEN,49))'="",$P(^PXRMD(801.41,DIEN,49),U)>0 D
     133 .S FIND=$P(^PXRMD(801.41,DIEN,49),U)
     134 .I $D(FLIST("REMINDER TERM","F",FIND)) Q
     135 .I '$D(FLIST("REMINDER TERM")) S FLIST("REMINDER TERM")="811.5"
     136 .S FLIST("REMINDER TERM","F",FIND)=""
     137 .D GETTFIND^PXRMEXPR(.FLIST)
     138 Q
     139 ;
     140 ;Build list of additional findings
     141 ;---------------------------------
     142DFINDA(DIEN) ;
     143 N FIND,FIEN,FGLOB,FNAM,FSUB
     144 S FSUB=0
     145 F  S FSUB=$O(^PXRMD(801.41,DIEN,3,FSUB)) Q:'FSUB  D
     146 .;Additional Finding Item
     147 .S FIND=$P($G(^PXRMD(801.41,DIEN,3,FSUB,0)),U)
     148 .;If a finding item exists check and save
     149 .I FIND]"" D
     150 ..;Finding item defined
     151 ..S FIEN=$P(FIND,";"),FGLOB=$P(FIND,";",2) Q:'FIEN  Q:FGLOB=""
     152 ..;And finding item exists
     153 ..Q:'$D(@(U_FGLOB_FIEN_",0)"))
     154 ..;Finding name
     155 ..S FNAM=$P($G(@(U_FGLOB_FIEN_",0)")),U) S:FNAM="" FNAM="???"
     156 ..;And not previously saved
     157 ..I '$D(FINDING(FIND)) D
     158 ...S FCNT=FCNT+1,FINDING(FIND)="",TEMP("FINDING",FCNT)=FIND
     159 Q
     160 ;
     161 ;Build list of result groups
     162 ;---------------------------
     163DRESULT(DIEN) ;
     164 N RIEN
     165 ;Result Group/Element pointer
     166 S RIEN=$P($G(^PXRMD(801.41,DIEN,0)),U,15) Q:'RIEN  Q:$D(RESULT(RIEN))
     167 ;Result group compoments
     168 N DSUB,REIEN
     169 S DSUB=0
     170 F  S DSUB=$O(^PXRMD(801.41,RIEN,10,DSUB)) Q:'DSUB  D
     171 .;Get result element
     172 .S REIEN=$P($G(^PXRMD(801.41,RIEN,10,DSUB,0)),U,2) Q:'REIEN
     173 .Q:'$D(^PXRMD(801.41,REIEN,0))
     174 .;If element exists get save it
     175 .S RCNT=RCNT+1,OUTPUT("RESULT",RCNT)=REIEN
     176 ;
     177 ;Save result group
     178 S RCNT=RCNT+1,RESULT(RIEN)="",TEMP("RESULT",RCNT)=RIEN
     179 Q
     180 ;
     181 ;Extract TIU Objects/Templates from any WP text
     182 ;----------------------------------------------
     183TIUSRCH(GLOB,IEN,NODE,OLIST,TLIST) ;
     184 N OCNT,TCNT,TEXT
     185 ;Add to existing arrays
     186 S OCNT=+$O(OLIST(""),-1),TCNT=+$O(TLIST(""),-1),SUB=0
     187 ;Scan WP fields
     188 F  S SUB=$O(@(GLOB_IEN_","_NODE_","_SUB_")")) Q:'SUB  D
     189 .;Get individual line
     190 .S TEXT=$G(@(GLOB_IEN_","_NODE_","_SUB_",0)")) Q:TEXT=""
     191 .;Most text lines will have no TIU link so ignore them
     192 .I (TEXT'["|")&(TEXT'["{FLD:") Q
     193 .;Templates are in format {FLD:fldname} (only applies to dialogs)
     194 .I GLOB[801.41 D TIUXTR("{FLD:","}",TEXT,.TLIST,.TCNT)
     195 .;Objects are in format |Objectname|
     196 .D TIUXTR("|","|",TEXT,.OLIST,.OCNT)
     197 Q
     198 ;
     199TIUXTR(SRCH,SRCH1,TEXT,OUTPUT,CNT) ;
     200 N EXIST,IC,TXT,ONAME
     201 S TXT=TEXT
     202 F  D  Q:TXT'[SRCH
     203 .S TXT=$E(TXT,$F(TXT,SRCH),$L(TXT)) Q:TXT'[SRCH1
     204 .S ONAME=$P(TXT,SRCH1) Q:ONAME=""
     205 .;Check if already selected
     206 .S EXIST=0,IC=0
     207 .F  S IC=$O(OUTPUT(IC)) Q:'IC  Q:EXIST  D
     208 ..I $G(OUTPUT(IC))=ONAME S EXIST=1
     209 .;Save array of object/template names
     210 .I 'EXIST S CNT=CNT+1,OUTPUT(CNT)=ONAME
     211 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXFI.m

    r613 r623  
    1 PXRMEXFI        ; SLC/PKR/PJH - Exchange utilities for file entries.;07/05/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;==============================================
    4 DELALL(FILENUM,NAME)    ;Delete all file entries named NAME.
    5         N IEN,IND,LIST,MSG
    6         D FIND^DIC(FILENUM,"","@","K",NAME,"*","","","","LIST","MSG")
    7         I $P(LIST("DILIST",0),U,1)=0 Q
    8         S IND=0
    9         F  S IND=$O(LIST("DILIST",2,IND)) Q:IND=""  D
    10         . S IEN=LIST("DILIST",2,IND)
    11         . D DELETE(FILENUM,IEN)
    12         Q
    13         ;
    14         ;==============================================
    15 DELETE(FILENUM,DA)      ;Delete a file entry.
    16         N DIK
    17         S DIK=$$ROOT^DILFD(FILENUM)
    18         D ^DIK
    19         Q
    20         ;
    21         ;==============================================
    22 FEIMSG(SAME,ATTR)       ;Output the general file exits install message.
    23         N IND,NOUT,TEXT,TEXTO
    24         S TEXT(1)=ATTR("FILE NAME")_" entry named "_ATTR("NAME")_" already exists"
    25         I SAME D
    26         . S TEXT(2)="and the packed component is identical, skipping."
    27         . S TEXT(3)=" "
    28         . D FORMAT^PXRMTEXT(1,70,3,.TEXT,.NOUT,.TEXTO)
    29         . F IND=1:1:NOUT W !,TEXTO(IND)
    30         . H 2
    31         I 'SAME D
    32         . S TEXT(2)="but the packed component is different, what do you want to do?"
    33         . D FORMAT^PXRMTEXT(1,70,2,.TEXT,.NOUT,.TEXTO)
    34         . F IND=1:1:NOUT W !,TEXTO(IND)
    35         Q
    36         ;
    37         ;==============================================
    38 FOKTI(FILENUM)  ;Check if it is ok to install/transport this FILE.
    39         ;
    40         ;Drugs not allowed.
    41         I FILENUM=50 Q 0
    42         ;
    43         ;VA Generic not allowed.
    44         I FILENUM=50.6 Q 0
    45         ;
    46         ;VA Drug Class not allowed.
    47         I FILENUM=50.605 Q 0
    48         ;
    49         ;Lab tests not allowed.
    50         I FILENUM=60 Q 0
    51         ;
    52         ;Radiology procedures not allowed.
    53         I FILENUM=71 Q 0
    54         ;
    55         ;ICD9 (used in Dialogs) not allowed.
    56         I FILENUM=80 Q 0
    57         ;
    58         ;ICD0 not allowed.
    59         I FILENUM=80.1 Q 0
    60         ;
    61         ;CPT (used in Dialogs) not allowed.
    62         I FILENUM=81 Q 0
    63         ;
    64         ;Order Dialogs not allowed.
    65         I FILENUM=101.41 Q 0
    66         ;
    67         ;Orderable Items not allowed.
    68         I FILENUM=101.43 Q 0
    69         ;
    70         ;Sites cannot create entries in GMRV VITAL TYPE.
    71         I FILENUM=120.51 Q 0
    72         ;
    73         ;Mental Health Instruments not allowed.
    74         I FILENUM=601 Q 0
    75         I FILENUM=601.71 Q 0
    76         ;
    77         I FILENUM=790.404 Q 0
    78         ;
    79         ;If control gets to here then it is an allowed file type.
    80         Q 1
    81         ;
    82         ;==============================================
    83 GETFACT(PT01,ATTR,NEWPT01,NAMECHG,IEN)  ;Get the action for a file.
    84         N ACTION,CHOICES,CSUM,DIR,FILENUM,MSG,RESULT
    85         N SAME,X,Y
    86         ;See if this entry is already defined.
    87 CHK     ;
    88         S NEWPT01=""
    89         S FILENUM=ATTR("FILE NUMBER")
    90         I IEN="" S IEN=$$EXISTS^PXRMEXIU(FILENUM,PT01)
    91         I IEN D
    92         .;If the entry already exists compare the existing entry checksum
    93         .;with the packed entry checksum.
    94         . S CSUM=$$FILE^PXRMEXCS(ATTR("FILE NUMBER"),IEN)
    95         . S SAME=$S(ATTR("CHECKSUM")=CSUM:1,1:0)
    96         . D FEIMSG(SAME,.ATTR)
    97         . I SAME S ACTION="S"
    98         . I 'SAME D
    99         .. S CHOICES=$S(FILENUM=801.41:"CMOQS",FILENUM=811.5:"CMOQS",1:"COQS")
    100         .. S DIR("B")="O"
    101         .. S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
    102         E  D
    103         . W !!,ATTR("FILE NAME")," entry ",PT01," is NEW,"
    104         . W !,"what do you want to do?"
    105         . S CHOICES="CIQS"
    106         . S DIR("B")="I"
    107         . S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
    108         ;
    109         I ACTION="Q" Q ACTION
    110         I ACTION="C" D
    111         . S NEWPT01=$$GETUNAME^PXRMEXIU(.ATTR)
    112         .;Make sure the NEW .01 passes any input transforms.
    113         . I NEWPT01="" S ACTION="S"
    114         . E  D CHK^DIE(ATTR("FILE NUMBER"),.01,"",NEWPT01,.RESULT,"MSG")
    115         I $G(RESULT)="^" D  G CHK
    116         . D AWRITE^PXRMUTIL("MSG")
    117         . K RESULT
    118         ;
    119         I ACTION="O" D
    120         .;If the action is overwrite double check that is what the user
    121         .;really wants to do.
    122         . N DIROUT,DIRUT,DTOUT,DUOUT
    123         . K DIR
    124         . S DIR(0)="Y"_U_"A"
    125         . S DIR("A")="Are you sure you want to overwrite"
    126         . S DIR("B")="N"
    127         . D ^DIR
    128         . I $D(DIROUT)!$D(DIRUT) S Y=0
    129         . I $D(DTOUT)!$D(DUOUT) S Y=0
    130         . S ACTION=$S(Y:"O",1:"S")
    131         ;
    132         I ACTION="P" D
    133         . N DIC,Y
    134         . S DIC=ATTR("FILE NUMBER")
    135         . S DIC(0)="AEMQ"
    136         . D ^DIC
    137         . I Y=-1 S ACTION="S"
    138         . E  S NEWPT01=$P(Y,U,2)
    139         ;
    140         I NEWPT01'="" S NAMECHG(ATTR("FILE NUMBER"),PT01)=NEWPT01
    141         Q ACTION
    142         ;
    143         ;==============================================
    144 SETATTR(ATTR,FILE,PT01) ;Set the file attributes for the file FILE.
    145         N MSG
    146         S ATTR("FILE NUMBER")=FILE
    147         S ATTR("FILE NAME")=$$GET1^DID(FILE,"","","NAME","","MSG")
    148         ;This call gets the field length.
    149         D FIELD^DID(FILE,.01,"","FIELD LENGTH","ATTR","MSG")
    150         S ATTR("MIN FIELD LENGTH")=3
    151         S (ATTR("NAME"),ATTR("PT01"))=PT01
    152         Q
    153         ;
     1PXRMEXFI ; SLC/PKR/PJH - Exchange utilities for file entries.;12/21/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;==============================================
     4DELALL(FILENUM,NAME) ;Delete all file entries named NAME.
     5 N IEN,IND,LIST,MSG
     6 D FIND^DIC(FILENUM,"","@","K",NAME,"*","","","","LIST","MSG")
     7 I $P(LIST("DILIST",0),U,1)=0 Q
     8 S IND=0
     9 F  S IND=$O(LIST("DILIST",2,IND)) Q:IND=""  D
     10 . S IEN=LIST("DILIST",2,IND)
     11 . D DELETE(FILENUM,IEN)
     12 Q
     13 ;
     14 ;==============================================
     15DELETE(FILENUM,DA) ;Delete a file entry.
     16 N DIK
     17 S DIK=$$ROOT^DILFD(FILENUM)
     18 D ^DIK
     19 Q
     20 ;
     21 ;==============================================
     22FOKTI(FILENUM) ;Check if it is ok to install/transport this FILE.
     23 ;
     24 ;Drugs not allowed.
     25 I FILENUM=50 Q 0
     26 ;
     27 ;VA Generic not allowed.
     28 I FILENUM=50.6 Q 0
     29 ;
     30 ;VA Drug Class not allowed.
     31 I FILENUM=50.605 Q 0
     32 ;
     33 ;Lab tests not allowed.
     34 I FILENUM=60 Q 0
     35 ;
     36 ;Radiology procedures not allowed.
     37 I FILENUM=71 Q 0
     38 ;
     39 ;ICD9 (used in Dialogs) not allowed.
     40 I FILENUM=80 Q 0
     41 ;
     42 ;ICD0 not allowed.
     43 I FILENUM=80.1 Q 0
     44 ;
     45 ;CPT (used in Dialogs) not allowed.
     46 I FILENUM=81 Q 0
     47 ;
     48 ;Order Dialogs not allowed.
     49 I FILENUM=101.41 Q 0
     50 ;
     51 ;Orderable Items not allowed.
     52 I FILENUM=101.43 Q 0
     53 ;
     54 ;Sites cannot create entries in GMRV VITAL TYPE.
     55 I FILENUM=120.51 Q 0
     56 ;
     57 ;Mental Health Instruments not allowed.
     58 I FILENUM=601 Q 0
     59 ;
     60 I FILENUM=790.404 Q 0
     61 ;
     62 ;If control gets to here then it is an allowed file type.
     63 Q 1
     64 ;
     65 ;==============================================
     66GETFACT(PT01,ATTR,NEWPT01,NAMECHG,EXISTS) ;Get the action for a file.
     67 N ACTION,CHOICES,DIR,FILENUM,MSG,RESULT,X,Y
     68 ;See if this entry is already defined.
     69CHK ;
     70 S NEWPT01=""
     71 S (ATTR("NAME"),ATTR("PT01"))=PT01
     72 S FILENUM=ATTR("FILE NUMBER")
     73 I EXISTS="" S EXISTS=$$EXISTS^PXRMEXIU(FILENUM,PT01)
     74 ;Check for identical file entry can be made here.
     75 I EXISTS D
     76 . W !!,ATTR("FILE NAME")," entry ",PT01," already EXISTS,"
     77 . W !,"what do you want to do?"
     78 . S CHOICES=$S(FILENUM=801.41:"CMOQS",FILENUM=811.5:"CMOQS",1:"COQS")
     79 . S DIR("B")="S"
     80 . S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
     81 E  D
     82 . W !!,ATTR("FILE NAME")," entry ",PT01," is NEW,"
     83 . W !,"what do you want to do?"
     84 . S CHOICES="CIQS"
     85 . S DIR("B")="I"
     86 . S ACTION=$$GETACT^PXRMEXIU(CHOICES,.DIR)
     87 ;
     88 I ACTION="Q" Q ACTION
     89 I ACTION="C" D
     90 . S NEWPT01=$$GETUNAME^PXRMEXIU(.ATTR)
     91 .;Make sure the NEW .01 passes any input transforms.
     92 . I NEWPT01="" S ACTION="S"
     93 . E  D CHK^DIE(ATTR("FILE NUMBER"),.01,"",NEWPT01,.RESULT,"MSG")
     94 I $G(RESULT)="^" D  G CHK
     95 . D AWRITE^PXRMUTIL("MSG")
     96 . K RESULT
     97 ;
     98 I ACTION="O" D
     99 .;If the action is overwrite double check that is what the user
     100 .;really wants to do.
     101 . N DIROUT,DIRUT,DTOUT,DUOUT
     102 . K DIR
     103 . S DIR(0)="Y"_U_"A"
     104 . S DIR("A")="Are you sure you want to overwrite"
     105 . S DIR("B")="N"
     106 . D ^DIR
     107 . I $D(DIROUT)!$D(DIRUT) S Y=0
     108 . I $D(DTOUT)!$D(DUOUT) S Y=0
     109 . S ACTION=$S(Y:"O",1:"S")
     110 ;
     111 I ACTION="P" D
     112 . N DIC,Y
     113 . S DIC=ATTR("FILE NUMBER")
     114 . S DIC(0)="AEMQ"
     115 . D ^DIC
     116 . I Y=-1 S ACTION="S"
     117 . E  S NEWPT01=$P(Y,U,2)
     118 ;
     119 I NEWPT01'="" S NAMECHG(ATTR("FILE NUMBER"),PT01)=NEWPT01
     120 Q ACTION
     121 ;
     122 ;==============================================
     123SETATTR(ATTR,FILE) ;Set the file attributes for the file FILE.
     124 N MSG
     125 S ATTR("FILE NUMBER")=FILE
     126 S ATTR("FILE NAME")=$$GET1^DID(FILE,"","","NAME","","MSG")
     127 ;This call gets the field length.
     128 D FIELD^DID(FILE,.01,"","FIELD LENGTH","ATTR","MSG")
     129 S ATTR("MIN FIELD LENGTH")=3
     130 Q
     131 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXID.m

    r613 r623  
    1 PXRMEXID        ;SLC/PJH - Reminder Dialog Exchange Install Routine.;08/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;==================================================
    5         ;
    6         ;Install all dialog components in an exchange file entry
    7         ;------------------------------------------------
    8 INSALL  N ALL,DIROUT,DIRUT,DTOUT,DUOUT,IND,PXRMDONE
    9         ;
    10         ;Set the install date and time.
    11         S IND="",PXRMDONE=0
    12         ;
    13         ;Go to full screen mode.
    14         D FULL^VALM1
    15         ;
    16         ;Check if all or none exists - option to install all unchanged
    17         N DNAME
    18         S DNAME=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
    19         D EXIST^PXRMEXIX(.ALL,DNAME,"reminder dialog","")
    20         I ALL=0 D DISP^PXRMEXLD(PXRMMODE) Q
    21         ;
    22         ;Lock the entire file
    23         Q:'$$LOCK
    24         F  S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:(IND="")!(PXRMDONE)  D
    25         .D INSCOM(IND,1)
    26         ;
    27         ;Clear lock
    28         D UNLOCK
    29         ;
    30         ;Rebuild display workfile
    31         D DISP^PXRMEXLD(PXRMMODE)
    32         ;
    33         K PXRMNMCH
    34         Q
    35         ;
    36         ;Build list of descendents names
    37         ;-------------------------------
    38 INSBLD(NAME,INAME)      ;
    39         N DNAME,IDATA,ISEQ
    40         S ISEQ=0
    41         F  S ISEQ=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME,ISEQ)) Q:'ISEQ  D
    42         .S IDATA=$G(^TMP("PXRMEXTMP",$J,"DMAP",NAME,ISEQ)) Q:IDATA=""
    43         .S DNAME=$P(IDATA,U) Q:DNAME=""
    44         .;
    45         .I $D(^TMP("PXRMEXTMP",$J,"DREPL"))>0 D
    46         ..S REPL=$$CHKREPL^PXRMEXD1(NAME) I REPL>0 D INSREPL(NAME,REPL,.INAME)
    47         .S INAME(DNAME)=""
    48         .;Q:$$PXRM(DNAME)  S INAME(DNAME)=""
    49         .;Check for descendants
    50         .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) D INSBLD(DNAME,.INAME)
    51         Q
    52         ;Build list of replacement names
    53         ;-------------------------------
    54 INSREPL(NAME,REPL,INAME)        ;
    55         N DNAME,IDATA,ISEQ
    56         S ISEQ=0
    57         S IDATA=$G(^TMP("PXRMEXTMP",$J,"DREPL",REPL,NAME)) Q:IDATA=""
    58         S DNAME=$P(IDATA,U) Q:DNAME=""  S INAME(DNAME)=""
    59         ;S DNAME=$P(IDATA,U) Q:DNAME=""  Q:$$PXRM(DNAME)  S INAME(DNAME)=""
    60         ;Check for descendants
    61         I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) D INSBLD(DNAME,.INAME)
    62         Q
    63         ;
    64         ;Install component IND
    65         ;---------------------
    66 INSCOM(IND,SILENT)      ;
    67         N ACTION,ATTR,CSUM,DTYP,EXIEN,END,EXISTS,FILENUM,IND120,JND120
    68         N NEWPT01,PT01,START,REPL,SAME,TEMP
    69         S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),FILENUM=$P(TEMP,U,1)
    70         S EXISTS=$P(TEMP,U,4),START=$P(TEMP,U,2),END=$P(TEMP,U,3) Q:START=""
    71         S JND120=$P(TEMP,U,6) Q:'JND120
    72         S IND120=$P(TEMP,U,5) Q:'IND120
    73         S TEMP=^PXD(811.8,PXRMRIEN,100,START,0),PT01=$P(TEMP,"~",2) Q:PT01=""
    74         S DTYP=$G(^TMP("PXRMEXTMP",$J,"DTYP",PT01))
    75         I DTYP="dialog" S DTYP="reminder dialog"
    76         ;
    77         ;Go to full screen mode.
    78         D FULL^VALM1
    79         ;
    80         ;Check for descendents
    81         S REPL=$$CHKREPL^PXRMEXD1(PT01)
    82         I 'SILENT&($$INSDSC(PT01)!(REPL>0)) D  Q:PXRMDONE
    83         .N ANS,INDS,TEXT
    84         .S TEXT(1)=PT01_" ("_DTYP_") contains sub-components."
    85         .S TEXT="Install all sub-components with the "_DTYP_": "
    86         .;Give option to install all descendents
    87         .D ASK^PXRMEXIX(.ANS,.TEXT,1) Q:PXRMDONE
    88         .I $G(ANS)="N" S PXRMDONE=1 Q
    89         .I $G(ANS)="Y" D
    90         ..S INDS=IND
    91         ..N IDATA,INAME,IND
    92         ..I REPL>0 D INSREPL(PT01,REPL,.INAME)
    93         ..;Build list of decendents to install
    94         ..D INSBLD(PT01,.INAME)
    95         ..;Check if all or none exists - option to install all unchanged
    96         ..D EXIST^PXRMEXIX(.ALL,PT01,DTYP,.INAME) Q:PXRMDONE
    97         ..;Start at the end of the list
    98         ..S IND=""
    99         ..F  S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:PXRMDONE!(IND=INDS)  D
    100         ...N PT01,START,TEMP
    101         ...S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),START=$P(TEMP,U,2) Q:START=""
    102         ...S PT01=$P(^PXD(811.8,PXRMRIEN,100,START,0),"~",2) Q:PT01=""
    103         ...;Ignore namechanges
    104         ...I $D(PXRMNMCH(801.41,PT01)) Q
    105         ...;Only install descendents
    106         ...I $D(INAME(PT01)) D INSCOM(IND,1)
    107         ;
    108 SETENTRY        ;
    109         D SETATTR^PXRMEXFI(.ATTR,FILENUM,PT01)
    110         S ACTION=""
    111         ;Double check that it hasn't been installed
    112         S EXIEN=$$EXISTS^PXRMEXIU(801.41,PT01)
    113         I EXIEN,'EXISTS S EXISTS=1
    114         I EXISTS D
    115         . D CHECKSUM^PXRMEXCS(.ATTR,START,END)
    116         . S CSUM=$$FILE^PXRMEXCS(ATTR("FILE NUMBER"),EXIEN)
    117         . S SAME=$S(ATTR("CHECKSUM")=CSUM:1,1:0)
    118         . I SAME D FEIMSG^PXRMEXFI(SAME,.ATTR) S ACTION="S",(PXRMNMCH,NEWPT01)=""
    119         I ACTION="" D
    120         .;If all components installed the default is 'Install or Overwrite'
    121         . S:ALL ACTION=$S(EXISTS:"O",1:"I"),(PXRMNMCH,NEWPT01)=""
    122         . S:'ALL ACTION=$$GETFACT^PXRMEXFI(PT01,.ATTR,.NEWPT01,.PXRMNMCH,EXIEN)
    123         ;Save what was done for the installation summary.
    124         S ^TMP("PXRMEXIAD",$J,IND,ATTR("FILE NAME"),ATTR("PT01"),ACTION)=NEWPT01
    125         ;Clear heading
    126         S VALMHDR(2)=""
    127         ;If the ACTION is Quit then quit the entire install.
    128         I ACTION="Q" S PXRMDONE=1 S VALMHDR(2)="Install not completed" Q
    129         ;If the ACTION is Skip then skip this component.
    130         I ACTION="S" S VALMBCK="R" Q
    131         ;If the ACTION is Replace then skip this component.
    132         I ACTION="P" S VALMBCK="R",VALMHDR(2)=PT01_" replaced with "_NEWPT01 Q
    133         ;Install this component.
    134         D FILE^PXRMEXIC(PXRMRIEN,EXIEN,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
    135         S VALMBCK="R"
    136         I PXRMDONE S VALMHDR(2)="Install aborted" Q
    137         I NEWPT01="" S VALMHDR(2)=PT01_" ("_DTYP_") installed from exchange file."
    138         I NEWPT01'="" S VALMHDR(2)=PT01_" installed as "_NEWPT01_"."
    139         ;If reminder dialog - disable and give option to link
    140         I DTYP="reminder dialog" D
    141         .N DNAME
    142         .S DNAME=PT01
    143         .I NEWPT01'="" S DNAME=NEWPT01
    144         .D INSLNK(DNAME)
    145         Q
    146         ;
    147         ;Check for descendents (either elements or prompts)
    148         ;--------------------------------------------------
    149 INSDSC(NAME)    ;
    150         N DATA,DFOUND,SUB
    151         S DFOUND=0,SUB=0
    152         F  S SUB=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME,SUB)) Q:'SUB  D  Q:DFOUND
    153         .S DATA=$G(^TMP("PXRMEXTMP",$J,"DMAP",NAME,SUB)) Q:DATA=""
    154         .S DFOUND=1
    155         .;I '$$PXRM($P(DATA,U)) S DFOUND=1
    156         Q DFOUND
    157         ;
    158 INSREPL1(NAME)  ;
    159         N DATA,DFOUND,SUB
    160         S DFOUND=0,SUB=0
    161         F  S SUB=$O(^TMP("PXRMEXTMP",$J,"DREPL",NAME,SUB)) Q:'SUB  D  Q:DFOUND
    162         .S DATA=$G(^TMP("PXRMEXTMP",$J,"DREPL",NAME,SUB)) Q:DATA=""
    163         .S DFOUND=1
    164         Q DFOUND
    165         ;Option to link dialog to a reminder
    166         ;-----------------------------------
    167 INSLNK(DNAME)   ;
    168         N DIEN,DISABLE,DSRC,RNAME
    169         N DA,DIE,DR
    170         ;Disable
    171         S DIEN=$O(^PXRMD(801.41,"B",DNAME,"")) Q:'DIEN
    172         ;Set dialog as disabled
    173         S DISABLE="DISABLED IN EXCHANGE"
    174         ;Except for National dialogs
    175         I $P(^PXRMD(801.41,DIEN,100),U)="N" S DISABLE=""
    176         ;
    177         S DR="3///^S X=DISABLE",DIE="^PXRMD(801.41,",DA=$P(DIEN,U)
    178         D ^DIE
    179         ;
    180         ;Quit if already linked
    181         I $D(^PXD(811.9,"AG",DIEN)) Q
    182         ;
    183         S RNAME=""
    184         ;If reminder was renamed use as default
    185         I $D(PXRMNMCH(811.9)) D
    186         .S RNAME=$O(PXRMNMCH(811.9,"")) Q:RNAME=""
    187         .S RNAME=$G(PXRMNMCH(811.9,RNAME))
    188         ;Otherwise use original reminder name as default
    189         I RNAME="" D
    190         .N DATA,FOUND,RIEN,SUB
    191         .;Rebuild ^TMP("PXRMEXLC",$J
    192         .D CDISP^PXRMEXLC(PXRMRIEN)
    193         .;
    194         .S SUB="",FOUND=0
    195         .F  S SUB=$O(^TMP("PXRMEXLC",$J,"SEL",SUB),-1) Q:'SUB  Q:FOUND  D
    196         ..S DATA=$G(^TMP("PXRMEXLC",$J,"SEL",SUB)) Q:$P(DATA,U)'=811.9
    197         ..S RIEN=$P(DATA,U,4),FOUND=1 Q:'RIEN
    198         ..S RNAME=$P($G(^PXD(811.9,RIEN,0)),U)
    199         ;
    200 TAG     W !!,"Reminder Dialog "_DNAME_" is not linked to a reminder.",!
    201         ;Select reminder to link
    202         S IEN=$$SELECT^PXRMINQ("^PXD(811.9,","Select Reminder to Link: ",RNAME)
    203         ;Update reminder link in #811.9
    204         I $P(IEN,U)'=-1 D
    205         .N DA,DIE,DIK,DR
    206         .;Set reminder to dialog pointer
    207         .S DR="51///^S X=DNAME",DIE="^PXD(811.9,",DA=$P(IEN,U)
    208         .D ^DIE
    209         .;If source reminder is null replace with linked reminder
    210         .S DSRC=$P($G(^PXRMD(801.41,DIEN,0)),U,2) Q:DSRC
    211         .S DSRC=$P(IEN,U)
    212         .S DR="2///^S X=DSRC",DIE="^PXRMD(801.41,",DA=$P(DIEN,U)
    213         .D ^DIE
    214         Q
    215         ;
    216         ;Install Selected Components
    217         ;---------------------------
    218 INSSEL  N ALL,IND,PXRMDONE,VALMY
    219         N DIROUT,DIRUT,DTOUT,DUOUT
    220         N VALMBG,VALMLST
    221         S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXLD",$J,"IDX",""),-1)
    222         ;Get the list to install.
    223         D EN^VALM2(XQORNOD(0))
    224         ;
    225         ;Set the install date and time.
    226         S ALL="",PXRMDONE=0
    227         ;
    228         ;Lock the entire file
    229         Q:'$$LOCK
    230         ;
    231         S IND=0
    232         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D INSCOM(IND,0)
    233         ;
    234         ;Clear locks
    235         D UNLOCK
    236         ;
    237         ;Rebuild workfile
    238         D DISP^PXRMEXLD(PXRMMODE)
    239         Q
    240         ;
    241         ;Install the exchange entry PXRMRIEN
    242         ;-----------------------------------
    243 INSTALL N IEN,IND,VALMY
    244         ;Make sure the component list exists for this entry. PXRMRIEN is
    245         ;set in INSTALL^PXRMEXLR.
    246         I '$D(^PXD(811.8,PXRMRIEN,120)) D CLIST^PXRMEXU1(.PXRMRIEN)
    247         I PXRMRIEN=-1 Q
    248         ;Format the component list for display.
    249         D CDISP^PXRMEXLC(PXRMRIEN)
    250         S VALMBCK="R",VALMCNT=$O(^TMP("PXRMEXLD",$J,"IDX"),-1)
    251         Q
    252         ;
    253 PXRM(NAME)      ;Validate prompts
    254         ;
    255         ;Ignore non-PXRM
    256         I $E(NAME,1,4)'="PXRM" Q 0
    257         N DIEN,RESULT
    258         I $G(PXRMINST)=1 D  Q RESULT
    259         .S RESULT=0
    260         .S DIEN=$O(^PXRMD(801.41,"B",NAME,"")) I 'DIEN Q
    261         .I $P($G(^PXRMD(801.41,DIEN,100)),U)'="N" Q
    262         .I ($P($G(^PXRMD(801.41,DIEN,0)),U,4)="P")!($P($G(^PXRMD(801.41,DIEN,0)),U,4)="F") S RESULT=1
    263         ;
    264         ;Check if this is a national code
    265         S DIEN=$O(^PXRMD(801.41,"B",NAME,""))
    266         ;If not found abort
    267         I 'DIEN Q 0
    268         ;if result group/element quit
    269         I $P($G(^PXRMD(801.41,DIEN,0)),U,4)="S"!($P($G(^PXRMD(801.41,DIEN,0)),U,4)="T") Q 0
    270         ;Check class
    271         I $P($G(^PXRMD(801.41,DIEN,100)),U)="N" Q 1
    272         ;Otherwise local
    273         Q 0
    274         ;
    275         ;Lock the dialog file
    276 LOCK()  ;
    277         L +^PXRMD(801.41):0 I  Q 1
    278         E  W !,"Another user is editing this file, try later" H 2
    279         Q 0
    280         ;
    281         ;Clear lock
    282 UNLOCK  L -^PXRMD(801.41)
    283         Q
     1PXRMEXID ;SLC/PJH - Reminder Dialog Exchange Install Routine.;11/14/2003
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;==================================================
     5 ;
     6 ;Install all dialog components in an exchange file entry
     7 ;------------------------------------------------
     8INSALL N ALL,DIROUT,DIRUT,DTOUT,DUOUT,IND,PXRMDONE
     9 K ^TMP("PXRMEXIA",$J)
     10 ;
     11 ;Set the install date and time.
     12 S IND="",PXRMDONE=0,^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
     13 ;
     14 ;Go to full screen mode.
     15 D FULL^VALM1
     16 ;
     17 ;Check if all or none exists - option to install all unchanged
     18 N DNAME
     19 S DNAME=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
     20 D EXIST^PXRMEXIX(.ALL,DNAME,"reminder dialog","")
     21 ;
     22 ;Lock the entire file
     23 Q:'$$LOCK
     24 ;
     25 ;Install all components
     26 F  S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:(+IND=0)!(PXRMDONE)  D
     27 .D INSCOM(IND,1)
     28 ;
     29 ;Clear lock
     30 D UNLOCK
     31 ;
     32 ;Rebuild display workfile
     33 D DISP^PXRMEXLD(PXRMMODE)
     34 ;
     35 K PXRMNMCH
     36 Q
     37 ;
     38 ;Build list of descendents names
     39 ;-------------------------------
     40INSBLD(NAME,INAME) ;
     41 N DNAME,IDATA,ISEQ
     42 S ISEQ=0
     43 F  S ISEQ=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME,ISEQ)) Q:'ISEQ  D
     44 .S IDATA=$G(^TMP("PXRMEXTMP",$J,"DMAP",NAME,ISEQ)) Q:IDATA=""
     45 .S DNAME=$P(IDATA,U) Q:DNAME=""  Q:$$PXRM(DNAME)  S INAME(DNAME)=""
     46 .;Check for descendants
     47 .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) D INSBLD(DNAME,.INAME)
     48 Q
     49 ;
     50 ;Install component IND
     51 ;---------------------
     52INSCOM(IND,SILENT) ;
     53 N ACTION,ATTR,DTYP,EXIEN,END,EXISTS,FILENUM,IND120,JND120
     54 N NEWPT01,PT01,START,TEMP
     55 S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),FILENUM=$P(TEMP,U,1)
     56 S EXISTS=$P(TEMP,U,4),START=$P(TEMP,U,2),END=$P(TEMP,U,3) Q:START=""
     57 S JND120=$P(TEMP,U,6) Q:'JND120
     58 S IND120=$P(TEMP,U,5) Q:'IND120
     59 S TEMP=^PXD(811.8,PXRMRIEN,100,START,0),PT01=$P(TEMP,"~",2) Q:PT01=""
     60 S DTYP=$G(^TMP("PXRMEXTMP",$J,"DTYP",PT01))
     61 I DTYP="dialog" S DTYP="reminder dialog"
     62 ;
     63 ;Go to full screen mode.
     64 D FULL^VALM1
     65 ;
     66 ;Check for descendents
     67 I 'SILENT,$$INSDSC(PT01) D  Q:PXRMDONE
     68 .N ANS,INDS,TEXT
     69 .S TEXT(1)=PT01_" ("_DTYP_") contains sub-components."
     70 .S TEXT="Install all sub-components with the "_DTYP_": "
     71 .;Give option to install all descendents
     72 .D ASK^PXRMEXIX(.ANS,.TEXT,1) Q:PXRMDONE
     73 .I $G(ANS)="Y" D
     74 ..S INDS=IND
     75 ..N IDATA,INAME,IND
     76 ..;Build list of decendents to install
     77 ..D INSBLD(PT01,.INAME)
     78 ..;Check if all or none exists - option to install all unchanged
     79 ..D EXIST^PXRMEXIX(.ALL,PT01,DTYP,.INAME) Q:PXRMDONE
     80 ..;Start at the end of the list
     81 ..S IND=""
     82 ..F  S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:PXRMDONE!(IND=INDS)  D
     83 ...N PT01,START,TEMP
     84 ...S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),START=$P(TEMP,U,2) Q:START=""
     85 ...S PT01=$P(^PXD(811.8,PXRMRIEN,100,START,0),"~",2) Q:PT01=""
     86 ...;Ignore namechanges
     87 ...I $D(PXRMNMCH(801.41,PT01)) Q
     88 ...;Only install descendents
     89 ...I $D(INAME(PT01)) D INSCOM(IND,1)
     90 ;
     91 D SETATTR^PXRMEXFI(.ATTR,FILENUM)
     92 ;Double check that it hasn't been installed
     93 S EXIEN=$$EXISTS^PXRMEXIU(801.41,PT01)
     94 I EXIEN,'EXISTS S EXISTS=1
     95 ;If all components installed the default is 'Install or Overwrite'
     96 S:ALL ACTION=$S(EXISTS:"O",1:"I"),(ATTR("NAME"),ATTR("PT01"))=PT01,PXRMNMCH="",NEWPT01=""
     97 S:'ALL ACTION=$$GETFACT^PXRMEXFI(PT01,.ATTR,.NEWPT01,.PXRMNMCH,EXISTS)
     98 ;Save what was done for the installation summary.
     99 S ^TMP("PXRMEXIA",$J,IND,ATTR("FILE NAME"),ATTR("PT01"),ACTION)=NEWPT01
     100 ;Clear heading
     101 S VALMHDR(2)=""
     102 ;If the ACTION is Quit then quit the entire install.
     103 I ACTION="Q" S PXRMDONE=1 S VALMHDR(2)="Install not completed" Q
     104 ;If the ACTION is Skip then skip this component.
     105 I ACTION="S" S VALMBCK="R" Q
     106 ;If the ACTION is Replace then skip this component.
     107 I ACTION="P" S VALMBCK="R",VALMHDR(2)=PT01_" replaced with "_NEWPT01 Q
     108 ;Install this component.
     109 D FILE^PXRMEXIC(PXRMRIEN,EXIEN,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
     110 S VALMBCK="R"
     111 I PXRMDONE S VALMHDR(2)="Install aborted" Q
     112 I NEWPT01="" S VALMHDR(2)=PT01_" ("_DTYP_") installed from exchange file."
     113 I NEWPT01'="" S VALMHDR(2)=PT01_" installed as "_NEWPT01_"."
     114 ;If reminder dialog - disable and give option to link
     115 I DTYP="reminder dialog" D
     116 .N DNAME
     117 .S DNAME=PT01
     118 .I NEWPT01'="" S DNAME=NEWPT01
     119 .D INSLNK(DNAME)
     120 Q
     121 ;
     122 ;Check for descendents (either elements or prompts)
     123 ;--------------------------------------------------
     124INSDSC(NAME) ;
     125 N DATA,DFOUND,SUB
     126 S DFOUND=0,SUB=0
     127 F  S SUB=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME,SUB)) Q:'SUB  D  Q:DFOUND
     128 .S DATA=$G(^TMP("PXRMEXTMP",$J,"DMAP",NAME,SUB)) Q:DATA=""
     129 .I '$$PXRM($P(DATA,U)) S DFOUND=1
     130 Q DFOUND
     131 ;
     132 ;Option to link dialog to a reminder
     133 ;-----------------------------------
     134INSLNK(DNAME) ;
     135 N DIEN,DISABLE,DSRC,RNAME
     136 N DA,DIE,DR
     137 ;Disable
     138 S DIEN=$O(^PXRMD(801.41,"B",DNAME,"")) Q:'DIEN
     139 ;Set dialog as disabled
     140 S DISABLE="DISABLED IN EXCHANGE"
     141 ;Except for National dialogs
     142 I $P(^PXRMD(801.41,DIEN,100),U)="N" S DISABLE=""
     143 ;
     144 S DR="3///^S X=DISABLE",DIE="^PXRMD(801.41,",DA=$P(DIEN,U)
     145 D ^DIE
     146 ;
     147 ;Quit if already linked
     148 I $D(^PXD(811.9,"AG",DIEN)) Q
     149 ;
     150 S RNAME=""
     151 ;If reminder was renamed use as default
     152 I $D(PXRMNMCH(811.9)) D
     153 .S RNAME=$O(PXRMNMCH(811.9,"")) Q:RNAME=""
     154 .S RNAME=$G(PXRMNMCH(811.9,RNAME))
     155 ;Otherwise use original reminder name as default
     156 I RNAME="" D
     157 .N DATA,FOUND,RIEN,SUB
     158 .;Rebuild ^TMP("PXRMEXLC",$J
     159 .D CDISP^PXRMEXLC(PXRMRIEN)
     160 .;
     161 .S SUB="",FOUND=0
     162 .F  S SUB=$O(^TMP("PXRMEXLC",$J,"SEL",SUB),-1) Q:'SUB  Q:FOUND  D
     163 ..S DATA=$G(^TMP("PXRMEXLC",$J,"SEL",SUB)) Q:$P(DATA,U)'=811.9
     164 ..S RIEN=$P(DATA,U,4),FOUND=1 Q:'RIEN
     165 ..S RNAME=$P($G(^PXD(811.9,RIEN,0)),U)
     166 ;
     167TAG W !!,"Reminder Dialog "_DNAME_" is not linked to a reminder.",!
     168 ;Select reminder to link
     169 S IEN=$$SELECT^PXRMINQ("^PXD(811.9,","Select Reminder to Link: ",RNAME)
     170 ;Update reminder link in #811.9
     171 I $P(IEN,U)'=-1 D
     172 .N DA,DIE,DIK,DR
     173 .;Set reminder to dialog pointer
     174 .S DR="51///^S X=DNAME",DIE="^PXD(811.9,",DA=$P(IEN,U)
     175 .D ^DIE
     176 .;If source reminder is null replace with linked reminder
     177 .S DSRC=$P($G(^PXRMD(801.41,DIEN,0)),U,2) Q:DSRC
     178 .S DSRC=$P(IEN,U)
     179 .S DR="2///^S X=DSRC",DIE="^PXRMD(801.41,",DA=$P(DIEN,U)
     180 .D ^DIE
     181 Q
     182 ;
     183 ;Install Selected Components
     184 ;---------------------------
     185INSSEL N ALL,IND,PXRMDONE,VALMY
     186 N DIROUT,DIRUT,DTOUT,DUOUT
     187 N VALMBG,VALMLST
     188 S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXLD",$J,"IDX",""),-1)
     189 ;Get the list to install.
     190 D EN^VALM2(XQORNOD(0))
     191 ;
     192 K ^TMP("PXRMEXIA",$J)
     193 ;Set the install date and time.
     194 S ALL="",PXRMDONE=0,^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
     195 ;
     196 ;Lock the entire file
     197 Q:'$$LOCK
     198 ;
     199 S IND=0
     200 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     201 .D INSCOM(IND,0)
     202 ;
     203 ;Clear locks
     204 D UNLOCK
     205 ;
     206 ;Rebuild workfile
     207 D DISP^PXRMEXLD(PXRMMODE)
     208 Q
     209 ;
     210 ;Install the exchange entry PXRMRIEN
     211 ;-----------------------------------
     212INSTALL N IEN,IND,VALMY
     213 ;Make sure the component list exists for this entry. PXRMRIEN is
     214 ;set in INSTALL^PXRMEXLR.
     215 I '$D(^PXD(811.8,PXRMRIEN,120)) D CLIST^PXRMEXU1(.PXRMRIEN)
     216 I PXRMRIEN=-1 Q
     217 ;Format the component list for display.
     218 D CDISP^PXRMEXLC(PXRMRIEN)
     219 S VALMBCK="R",VALMCNT=$O(^TMP("PXRMEXLD",$J,"IDX"),-1)
     220 Q
     221 ;
     222PXRM(NAME) ;Validate prompts
     223 ;
     224 ;Ignore non-PXRM
     225 I $E(NAME,1,4)'="PXRM" Q 0
     226 ;
     227 ;Check if this is a national code
     228 N DIEN
     229 S DIEN=$O(^PXRMD(801.41,"B",NAME,""))
     230 ;If not found abort
     231 I 'DIEN Q 0
     232 ;Check class
     233 I $P($G(^PXRMD(801.41,DIEN,100)),U)="N" Q 1
     234 ;Otherwise local
     235 Q 0
     236 ;
     237 ;Lock the dialog file
     238LOCK() ;
     239 L +^PXRMD(801.41):0 I  Q 1
     240 E  W !,"Another user is editing this file, try later" H 2
     241 Q 0
     242 ;
     243 ;Clear lock
     244UNLOCK L -^PXRMD(801.41)
     245 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXIU.m

    r613 r623  
    1 PXRMEXIU        ; SLC/PKR/PJH - Utilities for installing repository entries. ;07/27/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;===============================================
    4 DEF(FDA,NAMECHG)        ;Check the reminder definition to make sure the related
    5         ;reminder exists and all the findings exist.
    6         N ABBR,ALIST,IEN,IENS,FILENUM,FINDING,LRD,OFINDING,PT01
    7         N RRG,SPONSOR,TEXT,VERSN
    8         S IENS=$O(FDA(811.9,""))
    9         ;
    10         ;Related reminder guideline field 1.4.
    11         I $D(FDA(811.9,IENS,1.4)) D
    12         . S RRG=FDA(811.9,IENS,1.4)
    13         . S IEN=$$EXISTS^PXRMEXIU(811.9,RRG)
    14         . I IEN=0 D
    15         ..;Get replacement.
    16         .. N DIC,X,Y
    17         .. S TEXT(1)=" "
    18         .. S TEXT(2)="The Related Reminder Guideline does not exist on your system!"
    19         .. S TEXT(3)="It is "_RRG_" input a replacement or ^ to leave it empty."
    20         .. D MES^XPDUTL(.TEXT)
    21         ..;If this is being called during a KIDS install we need echoing on.
    22         .. I $D(XPDNM) X ^%ZOSF("EON")
    23         .. S DIC=811.9,DIC(0)="AEMQ"
    24         .. D ^DIC
    25         .. I $D(XPDNM) X ^%ZOSF("EOFF")
    26         .. I Y=-1 K FDA(811.9,IENS,1.4)
    27         .. E  S FDA(811.9,IENS,1.4)=$P(Y,U,2)
    28         ;
    29         ;Sponsor field 101.
    30         I $D(FDA(811.9,IENS,101)) D
    31         . S SPONSOR=FDA(811.9,IENS,101)
    32         . S IEN=$$FIND1^DIC(811.6,"","",SPONSOR)
    33         . I IEN=0 D
    34         ..;Get replacement.
    35         .. N DIC,X,Y
    36         .. S TEXT(1)=" "
    37         .. S TEXT(2)="The Sponsor does not exist on your system!"
    38         .. S TEXT(3)="It is "_SPONSOR_" input a replacement or ^ to leave it empty."
    39         .. D MES^XPDUTL(.TEXT)
    40         ..;If this is being called during a KIDS install we need echoing on.
    41         .. I $D(XPDNM) X ^%ZOSF("EON")
    42         .. S DIC=811.6,DIC(0)="AEMQ"
    43         .. D ^DIC
    44         .. I $D(XPDNM) X ^%ZOSF("EOFF")
    45         .. I Y=-1 K FDA(811.9,IENS,101)
    46         .. E  S FDA(811.9,IENS,101)=$P(Y,U,2)
    47         ;
    48         ;Linked reminder dialog field 51.
    49         S LRD=$G(FDA(811.9,IENS,51))
    50         S IEN=$S(LRD="":0,1:+$O(^PXRMD(801.41,"B",LRD,"")))
    51         I IEN=0 K FDA(811.9,IENS,51)
    52         ;
    53         ;Search the finding multiple for replacements and missing findings.
    54         D BLDALIST^PXRMVPTR(811.902,.01,.ALIST)
    55         S IENS=""
    56         F  S IENS=$O(FDA(811.902,IENS)) Q:IENS=""  D
    57         . S (FINDING,OFINDING)=FDA(811.902,IENS,.01)
    58         . S ABBR=$P(FINDING,".",1)
    59         . S PT01=$P(FINDING,".",2)
    60         . S FILENUM=$P(ALIST(ABBR),U,1)
    61         . I $D(NAMECHG(FILENUM,PT01)) D
    62         .. S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
    63         .. S FDA(811.902,IENS,.01)=FINDING
    64         . S IEN=+$$VFIND1(FINDING,.ALIST)
    65         . I IEN>0 S FDA(811.902,IENS,.01)=ABBR_".`"_IEN
    66         . I IEN=0 D
    67         ..;Get replacement
    68         .. N DIC,DUOUT,TEXT,X,Y
    69         .. S TEXT="Finding "_FINDING_" does not exist; input a replacement or ^ to quit the install."
    70         .. W !,TEXT
    71         .. S DIC=FILENUM
    72         .. I DIC="60" S DIC("S")="I $$LABPANEL^PXRMEXIU(Y)"
    73         .. S DIC(0)="AEMNQ"
    74         .. S Y=-1
    75         .. F  Q:+Y'=-1  D
    76         ...;If this is being called during a KIDS install we need echoing on.
    77         ... I $D(XPDNM) X ^%ZOSF("EON")
    78         ... D ^DIC
    79         ... I $D(XPDNM) X ^%ZOSF("EOFF")
    80         ... I $D(DUOUT) S Y="" K FDA
    81         .. I Y="" Q
    82         .. S FINDING=ABBR_"."_$P(Y,U,2),FDA(811.902,IENS,.01)=FINDING
    83         .;Save the finding information for the history.
    84         . S ^TMP("PXRMEXIA",$J,"DEFF",$P(IENS,",",1),OFINDING)=FINDING
    85         .;Save changes to Orderable items for dialog
    86         . I FILENUM=101.43,OFINDING'=FINDING
    87         . S NAMECHG(FILENUM,$P(OFINDING,".",2))=$P(FINDING,".",2)
    88         S VERSN=$$GETTAGV^PXRMEXU3(^PXD(811.8,PXRMRIEN,100,3,0),"<PACKAGE_VERSION>")
    89         I VERSN=1.5 D CEFD^PXRMDATE(.FDA)
    90         Q
    91         ;
    92         ;===============================================
    93 EXISTS(FILENUM,NAME,FLAG)       ;Check for existence of an entry with the
    94         ;same name. Return 0 for null name
    95         I NAME="" Q 0
    96         ;Return the ien if it does, 0 otherwise.
    97         N IEN
    98         I FILENUM=0 S IEN=$$EXISTS^PXRMEXCF(NAME) Q
    99         N FLAGS,RESULT
    100         S RESULT=NAME
    101         ;Special lookup for files 80 and 80.1, they do not have a standard "B"
    102         ;cross-reference.
    103         I (FILENUM=80)!(FILENUM=80.1) D
    104         .;Name may or may not have the necessary space appended, make sure
    105         .;it does.
    106         . S RESULT=$S($E(NAME,$L(NAME))'=" ":NAME_" ",1:NAME)
    107         . S FLAGS="MX"
    108         E  S FLAGS="BX"
    109         I FILENUM=811.6 S FLAGS=FLAGS_"U"
    110         ;File 8927.1 only allows upper case .01s.
    111         I FILENUM=8927.1 S RESULT=$$UP^XLFSTR(NAME)
    112         S IEN=$$FIND1^DIC(FILENUM,"",FLAGS,RESULT)
    113         I +IEN>0 Q IEN
    114         ;If IEN is null then there was an error try FIND^DIC.
    115         N FILENAME,LIST,MSG,NFOUND,TEXT
    116         D FIND^DIC(FILENUM,"","",FLAGS,NAME,"","","","","LIST","MSG")
    117         S NFOUND=+$P(LIST("DILIST",0),U,1)
    118         I NFOUND=0 Q 0
    119         I NFOUND=1 Q LIST("DILIST",2,1)
    120         ;Multiple entries with the same name found.
    121         S FILENAME=$$GET1^DID(FILENUM,"","","NAME")
    122         S TEXT(1)="Warning there are "_NFOUND_" "_FILENAME_" entries with the name "_NAME_"!"
    123         S TEXT(2)="If this is used as a finding, and it is not resolved by FileMan during"
    124         S TEXT(3)="installation, any component using this finding will not install."
    125         D EN^DDIOL(.TEXT)
    126         I $G(FLAG)="W" H 3 Q LIST("DILIST",2,1)
    127         I NFOUND>1 S IEN=$$GETIEN^PXRMEXU0(NFOUND,.LIST)
    128         Q IEN
    129         ;
    130         ;===============================================
    131 GETACT(CHOICES,DIR)     ;Get the action
    132         ;If CHOICES is empty the only action is skip.
    133         I CHOICES="" Q "S"
    134         N DIROUT,DIRUT,DTOUT,DUOUT,X,Y
    135         S DIR(0)="S"_U
    136         I CHOICES["C" S DIR(0)=DIR(0)_"C:Create a new entry by copying to a new name"
    137         I CHOICES["D" S DIR(0)=DIR(0)_";D:Delete (from the reminder/dialog)"
    138         I CHOICES["I" S DIR(0)=DIR(0)_";I:Install"
    139         I CHOICES["M" S DIR(0)=DIR(0)_";M:Merge findings"
    140         I CHOICES["O" S DIR(0)=DIR(0)_";O:Overwrite the current entry"
    141         I CHOICES["P" S DIR(0)=DIR(0)_";P:Replace (in the reminder/dialog) with an existing entry"
    142         I CHOICES["Q" S DIR(0)=DIR(0)_";Q:Quit the install"
    143         I CHOICES["R" S DIR(0)=DIR(0)_";R:Restart"
    144         I CHOICES["S" S DIR(0)=DIR(0)_";S:Skip, do not install this entry"
    145         ;If this is being called during a KIDS install we need echoing on.
    146         I $D(XPDNM) X ^%ZOSF("EON")
    147         D ^DIR
    148         I $D(XPDNM) X ^%ZOSF("EOFF")
    149         I $D(DIROUT)!$D(DIRUT) S Y="S"
    150         I $D(DTOUT)!($D(DUOUT)) S Y="S"
    151         Q Y
    152         ;
    153         ;===============================================
    154 GETNAME(MIN,MAX)        ;Get a name to use.
    155         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
    156         S DIR(0)="FAOU"_U_MIN_":"_MAX
    157         S DIR("A")="Input the new name: "
    158         D ^DIR
    159         I $D(DIROUT)!$D(DIRUT) Q ""
    160         I $D(DTOUT)!$D(DUOUT) Q ""
    161         Q Y
    162         ;
    163         ;===============================================
    164 GETUNAME(ATTR)  ;Get a unique name to use, ATTR holds the attributes.
    165         N IEN,NEWPT01,TEXT
    166 GNEW    S NEWPT01=$$GETNAME(ATTR("MIN FIELD LENGTH"),ATTR("FIELD LENGTH"))
    167         S IEN=+$$EXISTS(ATTR("FILE NUMBER"),NEWPT01)
    168         I IEN>0 D  G GNEW
    169         . S TEXT=ATTR("FILE NAME")_" entry "_NEWPT01_" already exists, what do you want to do?"
    170         . D EN^DDIOL(TEXT)
    171         E  S ATTR("NAME")=NEWPT01
    172         Q NEWPT01
    173         ;
    174         ;===============================================
    175 HF(FDA,NAMECHG) ;Check the health factor to make sure a category does not
    176         ;have a category.
    177         N IENS
    178         S IENS=$O(FDA(9999999.64,""))
    179         I IENS="" Q
    180         I FDA(9999999.64,IENS,.1)="CATEGORY" K FDA(9999999.64,IENS,.03)
    181         Q
    182         ;
    183         ;===============================================
    184 LABPANEL(IEN)   ;
    185         N NODE
    186         S NODE=^LAB(60,IEN,0)
    187         I $P(NODE,U,4)'["CH" Q 1
    188         I $P(NODE,U,5)="" Q 0
    189         Q 1
    190         ;
    191         ;===============================================
    192 REXISTS(NAME,DATEP)     ;See if this Exchange File entry already exists.
    193         N IEN,LUVALUE
    194         S LUVALUE(1)=NAME
    195         S LUVALUE(2)=DATEP
    196         S IEN=+$$FIND1^DIC(811.8,"","KU",.LUVALUE)
    197         Q IEN
    198         ;
    199         ;===============================================
    200 TERM(FDA,NAMECHG)       ;Check the reminder term to make sure all the
    201         ;findings exist.
    202         N ABBR,ALIST,IEN,IENS,FILENUM,FINDING,OFINDING,PT01
    203         ;Search the finding multiple for replacements and missing findings.
    204         D BLDALIST^PXRMVPTR(811.52,.01,.ALIST)
    205         S IENS=""
    206         F  S IENS=$O(FDA(811.52,IENS)) Q:IENS=""  D
    207         . S (FINDING,OFINDING)=FDA(811.52,IENS,.01)
    208         . S ABBR=$P(FINDING,".",1)
    209         . S PT01=$P(FINDING,".",2)
    210         . S FILENUM=$P(ALIST(ABBR),U,1)
    211         . I $D(NAMECHG(FILENUM,PT01)) D
    212         .. S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
    213         .. S FDA(811.52,IENS,.01)=FINDING
    214         . S IEN=+$$VFIND1(FINDING,.ALIST)
    215         . I IEN>0 S FDA(811.52,IENS,.01)=ABBR_".`"_IEN
    216         . I IEN=0 D
    217         ..;Get replacement
    218         .. N DIC,DUOUT,TEXT,X,Y
    219         .. S TEXT="Finding "_FINDING_" does not exist; input a replacement or ^ to quit the install."
    220         .. D BMES^XPDUTL(TEXT)
    221         .. S DIC=FILENUM
    222         .. I DIC="60" S DIC("S")="I $$LABPANEL^PXRMEXIU(Y)"
    223         .. S DIC(0)="AEMNQ"
    224         .. S Y=-1
    225         .. F  Q:+Y'=-1  D
    226         ...;If this is being called during a KIDS install we need echoing on.
    227         ... I $D(XPDNM) X ^%ZOSF("EON")
    228         ... D ^DIC
    229         ... I $D(XPDNM) X ^%ZOSF("EOFF")
    230         ... I $D(DUOUT) D
    231         .... S Y=""
    232         .... K FDA
    233         .. I Y="" K FDA(811.52,IENS)
    234         .. E  D
    235         ... S FINDING=ABBR_"."_$P(Y,U,2)
    236         ... S FDA(811.52,IENS,.01)=FINDING
    237         .;Save the finding information for the history.
    238         . S ^TMP("PXRMEXIA",$J,"TRMF",$P(IENS,",",1),OFINDING)=FINDING
    239         Q
    240         ;
    241         ;===============================================
    242 VFIND1(VPTR,ALIST)      ;Given a variable pointer of the form ABBR.NAME
    243         ;and ALIST which contains the link between abbreviations and files
    244         ;return the IEN if it exists and 0 if no match if found.
    245         N ABBR,IEN,FILENUM,PT01,RESULT
    246         S IEN=0
    247         S ABBR=$P(VPTR,".",1)
    248         S PT01=$P(VPTR,".",2,99)
    249         S FILENUM=$P(ALIST(ABBR),U,1)
    250         S IEN=$$EXISTS(FILENUM,PT01)
    251         Q IEN
    252         ;
     1PXRMEXIU ; SLC/PKR/PJH - Utilities for installing repository entries. ;06/23/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;===============================================
     4DEF(FDA,NAMECHG) ;Check the reminder definition to make sure the related
     5 ;reminder exists and all the findings exist.
     6 N ABBR,ALIST,IEN,IENS,FILENUM,FINDING,LRD,OFINDING,PT01
     7 N RRG,SPONSOR,TEXT,VERSN
     8 S IENS=$O(FDA(811.9,""))
     9 ;
     10 ;Related reminder guideline field 1.4.
     11 I $D(FDA(811.9,IENS,1.4)) D
     12 . S RRG=FDA(811.9,IENS,1.4)
     13 . S IEN=$$EXISTS^PXRMEXIU(811.9,RRG)
     14 . I IEN=0 D
     15 ..;Get replacement.
     16 .. N DIC,X,Y
     17 .. S TEXT(1)=" "
     18 .. S TEXT(2)="The Related Reminder Guideline does not exist on your system!"
     19 .. S TEXT(3)="It is "_RRG_" input a replacement or ^ to leave it empty."
     20 .. D MES^XPDUTL(.TEXT)
     21 ..;If this is being called during a KIDS install we need echoing on.
     22 .. I $D(XPDNM) X ^%ZOSF("EON")
     23 .. S DIC=811.9,DIC(0)="AEMQ"
     24 .. D ^DIC
     25 .. I $D(XPDNM) X ^%ZOSF("EOFF")
     26 .. I Y=-1 K FDA(811.9,IENS,1.4)
     27 .. E  S FDA(811.9,IENS,1.4)=$P(Y,U,2)
     28 ;
     29 ;Sponsor field 101.
     30 I $D(FDA(811.9,IENS,101)) D
     31 . S SPONSOR=FDA(811.9,IENS,101)
     32 . S IEN=$$FIND1^DIC(811.6,"","",SPONSOR)
     33 . I IEN=0 D
     34 ..;Get replacement.
     35 .. N DIC,X,Y
     36 .. S TEXT(1)=" "
     37 .. S TEXT(2)="The Sponsor does not exist on your system!"
     38 .. S TEXT(3)="It is "_SPONSOR_" input a replacement or ^ to leave it empty."
     39 .. D MES^XPDUTL(.TEXT)
     40 ..;If this is being called during a KIDS install we need echoing on.
     41 .. I $D(XPDNM) X ^%ZOSF("EON")
     42 .. S DIC=811.6,DIC(0)="AEMQ"
     43 .. D ^DIC
     44 .. I $D(XPDNM) X ^%ZOSF("EOFF")
     45 .. I Y=-1 K FDA(811.9,IENS,101)
     46 .. E  S FDA(811.9,IENS,101)=$P(Y,U,2)
     47 ;
     48 ;Linked reminder dialog field 51.
     49 S LRD=+$G(FDA(811.9,IENS,51))
     50 S IEN=$$EXISTS^PXRMEXIU(801.41,LRD)
     51 I IEN=0 K FDA(811.9,IENS,51)
     52 ;
     53 ;Search the finding multiple for replacements and missing findings.
     54 D BLDALIST^PXRMVPTR(811.902,.01,.ALIST)
     55 S IENS=""
     56 F  S IENS=$O(FDA(811.902,IENS)) Q:IENS=""  D
     57 . S (FINDING,OFINDING)=FDA(811.902,IENS,.01)
     58 . S ABBR=$P(FINDING,".",1)
     59 . S PT01=$P(FINDING,".",2)
     60 . S FILENUM=$P(ALIST(ABBR),U,1)
     61 . I $D(NAMECHG(FILENUM,PT01)) D
     62 .. S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
     63 .. S FDA(811.902,IENS,.01)=FINDING
     64 . S IEN=+$$VFIND1(FINDING,.ALIST)
     65 . I IEN>0 S FDA(811.902,IENS,.01)=ABBR_".`"_IEN
     66 . I IEN=0 D
     67 ..;Get replacement
     68 .. N DIC,DUOUT,TEXT,X,Y
     69 .. S TEXT="Finding "_FINDING_" does not exist; input a replacement or ^ to quit the install."
     70 .. W !,TEXT
     71 .. S DIC=FILENUM
     72 .. I DIC="60" S DIC("S")="I $$LABPANEL^PXRMEXIU(Y)"
     73 .. S DIC(0)="AEMNQ"
     74 .. S Y=-1
     75 .. F  Q:+Y'=-1  D
     76 ...;If this is being called during a KIDS install we need echoing on.
     77 ... I $D(XPDNM) X ^%ZOSF("EON")
     78 ... D ^DIC
     79 ... I $D(XPDNM) X ^%ZOSF("EOFF")
     80 ... I $D(DUOUT) S Y="" K FDA
     81 .. I Y="" Q
     82 .. S FINDING=ABBR_"."_$P(Y,U,2),FDA(811.902,IENS,.01)=FINDING
     83 .;Save the finding information for the history.
     84 . S ^TMP("PXRMEXIA",$J,"DEFF",$P(IENS,",",1),OFINDING)=FINDING
     85 .;Save changes to Orderable items for dialog
     86 . I FILENUM=101.43,OFINDING'=FINDING
     87 . S NAMECHG(FILENUM,$P(OFINDING,".",2))=$P(FINDING,".",2)
     88 S VERSN=$$GETTAGV^PXRMEXU3(^PXD(811.8,PXRMRIEN,100,3,0),"<PACKAGE_VERSION>")
     89 I VERSN=1.5 D CEFD^PXRMDATE(.FDA)
     90 Q
     91 ;
     92 ;===============================================
     93EXISTS(FILENUM,NAME,FLAG) ;Check for existence of an entry with the
     94 ;same name. Return 0 for null name
     95 I NAME="" Q 0
     96 ;Return the ien if it does, 0 otherwise.
     97 N IEN
     98 I FILENUM=0 S IEN=$$EXISTS^PXRMEXCF(NAME) Q
     99 N FLAGS,RESULT
     100 S RESULT=NAME
     101 ;Special lookup for files 80 and 80.1, they do not have a standard "B"
     102 ;cross-reference.
     103 I (FILENUM=80)!(FILENUM=80.1) D
     104 .;Name may or may not have the necessary space appended, make sure
     105 .;it does.
     106 . S RESULT=$S($E(NAME,$L(NAME))'=" ":NAME_" ",1:NAME)
     107 . S FLAGS="MX"
     108 E  S FLAGS="BX"
     109 I FILENUM=811.6 S FLAGS=FLAGS_"U"
     110 ;File 8927.1 only allows upper case .01s.
     111 I FILENUM=8927.1 S RESULT=$$UP^XLFSTR(NAME)
     112 S IEN=$$FIND1^DIC(FILENUM,"",FLAGS,RESULT)
     113 I +IEN>0 Q IEN
     114 ;If IEN is null then there was an error try FIND^DIC.
     115 N FILENAME,LIST,MSG,NFOUND,TEXT
     116 D FIND^DIC(FILENUM,"","",FLAGS,NAME,"","","","","LIST","MSG")
     117 S NFOUND=+$P(LIST("DILIST",0),U,1)
     118 I NFOUND=0 Q 0
     119 I NFOUND=1 Q LIST("DILIST",2,1)
     120 ;Multiple entries with the same name found.
     121 S FILENAME=$$GET1^DID(FILENUM,"","","NAME")
     122 S TEXT(1)="Warning there are "_NFOUND_" "_FILENAME_" entries with the name "_NAME_"!"
     123 S TEXT(2)="If this is used as a finding, and it is not resolved by FileMan during"
     124 S TEXT(3)="installation, any component using this finding will not install."
     125 D EN^DDIOL(.TEXT)
     126 I $G(FLAG)="W" H 3 Q LIST("DILIST",2,1)
     127 I NFOUND>1 S IEN=$$GETIEN^PXRMEXU0(NFOUND,.LIST)
     128 Q IEN
     129 ;
     130 ;===============================================
     131GETACT(CHOICES,DIR) ;Get the action
     132 ;If CHOICES is empty the only action is skip.
     133 I CHOICES="" Q "S"
     134 N DIROUT,DIRUT,DTOUT,DUOUT,X,Y
     135 S DIR(0)="S"_U
     136 I CHOICES["C" S DIR(0)=DIR(0)_"C:Create a new entry by copying to a new name"
     137 I CHOICES["D" S DIR(0)=DIR(0)_";D:Delete (from the reminder/dialog)"
     138 I CHOICES["I" S DIR(0)=DIR(0)_";I:Install"
     139 I CHOICES["M" S DIR(0)=DIR(0)_";M:Merge findings"
     140 I CHOICES["O" S DIR(0)=DIR(0)_";O:Overwrite the current entry"
     141 I CHOICES["P" S DIR(0)=DIR(0)_";P:Replace (in the reminder/dialog) with an existing entry"
     142 I CHOICES["Q" S DIR(0)=DIR(0)_";Q:Quit the install"
     143 I CHOICES["R" S DIR(0)=DIR(0)_";R:Restart"
     144 I CHOICES["S" S DIR(0)=DIR(0)_";S:Skip, do not install this entry"
     145 ;If this is being called during a KIDS install we need echoing on.
     146 I $D(XPDNM) X ^%ZOSF("EON")
     147 D ^DIR
     148 I $D(XPDNM) X ^%ZOSF("EOFF")
     149 I $D(DIROUT)!$D(DIRUT) S Y="S"
     150 I $D(DTOUT)!($D(DUOUT)) S Y="S"
     151 Q Y
     152 ;
     153 ;===============================================
     154GETNAME(MIN,MAX) ;Get a name to use.
     155 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
     156 S DIR(0)="FAOU"_U_MIN_":"_MAX
     157 S DIR("A")="Input the new name: "
     158 D ^DIR
     159 I $D(DIROUT)!$D(DIRUT) Q ""
     160 I $D(DTOUT)!$D(DUOUT) Q ""
     161 Q Y
     162 ;
     163 ;===============================================
     164GETUNAME(ATTR) ;Get a unique name to use, ATTR holds the attributes.
     165 N IEN,NEWPT01,TEXT
     166GNEW S NEWPT01=$$GETNAME(ATTR("MIN FIELD LENGTH"),ATTR("FIELD LENGTH"))
     167 S IEN=+$$EXISTS(ATTR("FILE NUMBER"),NEWPT01)
     168 I IEN>0 D  G GNEW
     169 . S TEXT=ATTR("FILE NAME")_" entry "_NEWPT01_" already exists, what do you want to do?"
     170 . D EN^DDIOL(TEXT)
     171 E  S ATTR("NAME")=NEWPT01
     172 Q NEWPT01
     173 ;
     174 ;===============================================
     175HF(FDA,NAMECHG) ;Check the health factor to make sure a category does not
     176 ;have a category.
     177 N IENS
     178 S IENS=$O(FDA(9999999.64,""))
     179 I IENS="" Q
     180 I FDA(9999999.64,IENS,.1)="CATEGORY" K FDA(9999999.64,IENS,.03)
     181 Q
     182 ;
     183 ;===============================================
     184LABPANEL(IEN) ;
     185 N NODE
     186 S NODE=^LAB(60,IEN,0)
     187 I $P(NODE,U,4)'["CH" Q 1
     188 I $P(NODE,U,5)="" Q 0
     189 Q 1
     190 ;
     191 ;===============================================
     192REXISTS(NAME,DATEP) ;See if this Exchange File entry already exists.
     193 N IEN,LUVALUE
     194 S LUVALUE(1)=NAME
     195 S LUVALUE(2)=DATEP
     196 S IEN=+$$FIND1^DIC(811.8,"","KU",.LUVALUE)
     197 Q IEN
     198 ;
     199 ;===============================================
     200SAME(ATTR,TA,NAME) ;Check existing entry and entry in packed reminder
     201 ;definition to see if they are identical.
     202 ;Present version only works for computed finding routines, other
     203 ;types of entries can be added later.
     204 N SAME
     205 I ATTR("FILE NAME")="COMPUTED FINDING ROUTINE" S SAME=$$SAME^PXRMEXCF(.ATTR,.TA,NAME)
     206 E  S SAME=1
     207 Q SAME
     208 ;
     209 ;===============================================
     210TERM(FDA,NAMECHG) ;Check the reminder term to make sure all the
     211 ;findings exist.
     212 N ABBR,ALIST,IEN,IENS,FILENUM,FINDING,OFINDING,PT01
     213 ;Search the finding multiple for replacements and missing findings.
     214 D BLDALIST^PXRMVPTR(811.52,.01,.ALIST)
     215 S IENS=""
     216 F  S IENS=$O(FDA(811.52,IENS)) Q:IENS=""  D
     217 . S (FINDING,OFINDING)=FDA(811.52,IENS,.01)
     218 . S ABBR=$P(FINDING,".",1)
     219 . S PT01=$P(FINDING,".",2)
     220 . S FILENUM=$P(ALIST(ABBR),U,1)
     221 . I $D(NAMECHG(FILENUM,PT01)) D
     222 .. S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
     223 .. S FDA(811.52,IENS,.01)=FINDING
     224 . S IEN=+$$VFIND1(FINDING,.ALIST)
     225 . I IEN>0 S FDA(811.52,IENS,.01)=ABBR_".`"_IEN
     226 . I IEN=0 D
     227 ..;Get replacement
     228 .. N DIC,DUOUT,TEXT,X,Y
     229 .. S TEXT="Finding "_FINDING_" does not exist; input a replacement or ^ to quit the install."
     230 .. D BMES^XPDUTL(TEXT)
     231 .. S DIC=FILENUM
     232 .. I DIC="60" S DIC("S")="I $$LABPANEL^PXRMEXIU(Y)"
     233 .. S DIC(0)="AEMNQ"
     234 .. S Y=-1
     235 .. F  Q:+Y'=-1  D
     236 ...;If this is being called during a KIDS install we need echoing on.
     237 ... I $D(XPDNM) X ^%ZOSF("EON")
     238 ... D ^DIC
     239 ... I $D(XPDNM) X ^%ZOSF("EOFF")
     240 ... I $D(DUOUT) D
     241 .... S Y=""
     242 .... K FDA
     243 .. I Y="" K FDA(811.52,IENS)
     244 .. E  D
     245 ... S FINDING=ABBR_"."_$P(Y,U,2)
     246 ... S FDA(811.52,IENS,.01)=FINDING
     247 .;Save the finding information for the history.
     248 . S ^TMP("PXRMEXIA",$J,"TRMF",$P(IENS,",",1),OFINDING)=FINDING
     249 Q
     250 ;
     251 ;===============================================
     252VFIND1(VPTR,ALIST) ;Given a variable pointer of the form ABBR.NAME
     253 ;and ALIST which contains the link between abbreviations and files
     254 ;return the IEN if it exists and 0 if no match if found.
     255 N ABBR,IEN,FILENUM,PT01,RESULT
     256 S IEN=0
     257 S ABBR=$P(VPTR,".",1)
     258 S PT01=$P(VPTR,".",2,99)
     259 S FILENUM=$P(ALIST(ABBR),U,1)
     260 S IEN=$$EXISTS(FILENUM,PT01)
     261 Q IEN
     262 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXIX.m

    r613 r623  
    1 PXRMEXIX        ;SLC/PJH - Reminder Dialog Exchange checks. ;10/10/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================================
    5         ;
    6         ;Yes/No Prompts
    7         ;--------------
    8 ASK(YESNO,TEXT,HELP)    ;
    9         W !
    10         N DIR,X,Y
    11         K DIROUT,DIRUT,DTOUT,DUOUT
    12         S DIR(0)="YA0"
    13         M DIR("A")=TEXT
    14         S DIR("B")="Y"
    15         S DIR("?")="Enter Y or N. For detailed help type ??"
    16         S DIR("??")=U_"D HLP^PXRMEXIX(HELP)"
    17         D ^DIR K DIR
    18         I $D(DIROUT) S DTOUT=1
    19         I $D(DTOUT)!($D(DUOUT)) S PXRMDONE=1 Q
    20         S YESNO=$E(Y(0))
    21         Q
    22         ;
    23         ;Dialog check - all exist, none exist or some exist
    24         ;--------------------------------------------------
    25 EXIST(ALL,DNAME,DTYP,INAME)     ;
    26         ;0 - None exist
    27         ;1 - All exist
    28         ;2 - Some exist
    29         ;
    30         ;Look for component dialogs in DMAP node from PXRMEXIC
    31         N DONE,DOTHER,EXISTS,FILE,MODE
    32         S ALL="",DONE=0,MODE="",NAME=""
    33         ;
    34         I DTYP="reminder dialog" D
    35         .F  S NAME=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME)) Q:NAME=""  D  Q:DONE
    36         ..;Check if dialog exists
    37         ..S EXISTS=$$EXISTS^PXRMEXIU(801.41,NAME)
    38         ..;If exists accumulate list of ancestors
    39         ..I EXISTS D OTHER(NAME,.DOTHER)
    40         ..;Quit if some exist and some don't
    41         ..I MODE=1,'EXISTS S MODE=2,DONE=1 Q
    42         ..I MODE=0,EXISTS S MODE=2,DONE=1 Q
    43         ..;Set all exists flag if dialog found
    44         ..I MODE="",EXISTS S MODE=1
    45         ..;Set none exists flag if dialog not found
    46         ..I MODE="",'EXISTS S MODE=0
    47         ;
    48         I DTYP'="reminder dialog" D
    49         .F  S NAME=$O(INAME(NAME)) Q:NAME=""  D  Q:DONE
    50         ..;Treat namechanges as 'done'
    51         ..I $D(PXRMNMCH(801.41,NAME)) Q
    52         ..;Check if dialog exists
    53         ..S EXISTS=$$EXISTS^PXRMEXIU(801.41,NAME)
    54         ..;If exists accumulate list of ancestors
    55         ..I EXISTS D OTHER(NAME,.DOTHER)
    56         ..;Quit if some exist and some don't
    57         ..I MODE=1,'EXISTS S MODE=2,DONE=1 Q
    58         ..I MODE=0,EXISTS S MODE=2,DONE=1 Q
    59         ..;Set all exists flag if dialog found
    60         ..I MODE="",EXISTS S MODE=1
    61         ..;Set none exists flag if dialog not found
    62         ..I MODE="",'EXISTS S MODE=0
    63         ;
    64         ;If all or none exist give option to install all without prompting
    65         N ANS,TEXT
    66         I MODE=0 D
    67         .S TEXT(1)="All dialog components for "_DNAME_" are new."
    68         I MODE=1 D
    69         .S TEXT(1)="All dialog components for "_DNAME_" already exist."
    70         .S TEXT(2)="",TEXT(4)=""
    71         .S TEXT(3)="Components not used by any other dialogs."
    72         .;Warn if used by other dialogs
    73         .I $D(DOTHER) D
    74         ..S TEXT(3)="WARNING - some components already used by:"
    75         ..N CNT,DLIT,DNAME,DTYP,FIRST,NAME
    76         ..S CNT=4,DNAME="",TEXT(CNT)=""
    77         ..F  S DNAME=$O(DOTHER(DNAME)) Q:DNAME=""  D
    78         ...S NAME="",FIRST=1,CNT=CNT+1
    79         ...S DTYP=DOTHER(DNAME)
    80         ...I DTYP="R" S DTYP="Reminder Dialog"
    81         ...I DTYP="G" S DTYP="Dialog Group"
    82         ...I DTYP="E" S DTYP="Dialog Element"
    83         ...;S CNT=CNT+1,FIRST=0,TEXT(CNT)=DLIT_NAME_" ("_DTYP_")"
    84         ...S CNT=CNT+1,FIRST=0,TEXT(CNT)=DNAME_" ("_DTYP_")"
    85         ..S CNT=CNT+1,TEXT(CNT)=""
    86         S TEXT="Install "_DTYP_" and all components with no further changes: "
    87         ;Give option to install all descendents
    88         D ASK(.ANS,.TEXT,2) I $G(ANS)="Y" S ALL=1
    89         I $G(ANS)="N" S ALL=0
    90         Q
    91         ;
    92         ;Check if used by other dialogs
    93         ;------------------------------
    94 OTHER(NAME,LIST)        ;
    95         N DDATA,DIEN,DNAME,DTYP,IEN
    96         S IEN=$O(^PXRMD(801.41,"B",NAME,0)) Q:'IEN
    97         ;Check if used by other dialogs
    98         I '$D(^PXRMD(801.41,"AD",IEN)) Q
    99         ;Build list of dialogs using this component
    100         S DIEN=0
    101         F  S DIEN=$O(^PXRMD(801.41,"AD",IEN,DIEN)) Q:'DIEN  D
    102         .S DDATA=$G(^PXRMD(801.41,DIEN,0)) Q:DDATA=""
    103         .S DNAME=$P(DDATA,U),DTYP=$P(DDATA,U,4) Q:DNAME=""
    104         .;Include only dialogs that are not part of this reminder dialog
    105         .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) Q
    106         .S LIST(DNAME)=DTYP
    107         Q
    108         ;
    109         ;General help text routine.
    110         ;--------------------------
    111 HLP(CALL)       ;
    112         N HTEXT
    113         N DIWF,DIWL,DIWR,IC
    114         S DIWF="C75",DIWL=0,DIWR=75
    115         ;
    116         I CALL=1 D
    117         .S HTEXT(1)="Enter 'Yes' to install all sub-components or"
    118         .S HTEXT(2)="enter 'No' to install only the selected dialog."
    119         I CALL=2 D
    120         .S HTEXT(1)="Enter 'Yes' to install without changes."
    121         .S HTEXT(2)="Enter 'No' to install with changes."
    122         I CALL=3 D
    123         .S HTEXT(1)="Select IFE to INSTALL reminder or dialog from this exchange"
    124         .S HTEXT(2)="entry. Select DFE to DELETE this entry from the exchange file. "
    125         .S HTEXT(3)="Select IH to view the installation HISTORY for this entry."
    126         K ^UTILITY($J,"W")
    127         S IC=""
    128         F  S IC=$O(HTEXT(IC)) Q:IC=""  D
    129         . S X=HTEXT(IC)
    130         . D ^DIWP
    131         W !
    132         S IC=0
    133         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    134         . W !,^UTILITY($J,"W",0,IC,0)
    135         K ^UTILITY($J,"W")
    136         W !
    137         Q
     1PXRMEXIX ;SLC/PJH - Reminder Dialog Exchange checks. ;12/22/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================================
     5 ;
     6 ;Yes/No Prompts
     7 ;--------------
     8ASK(YESNO,TEXT,HELP) ;
     9 W !
     10 N DIR,X,Y
     11 K DIROUT,DIRUT,DTOUT,DUOUT
     12 S DIR(0)="YA0"
     13 M DIR("A")=TEXT
     14 S DIR("B")="Y"
     15 S DIR("?")="Enter Y or N. For detailed help type ??"
     16 S DIR("??")=U_"D HLP^PXRMEXIX(HELP)"
     17 D ^DIR K DIR
     18 I $D(DIROUT) S DTOUT=1
     19 I $D(DTOUT)!($D(DUOUT)) S PXRMDONE=1 Q
     20 S YESNO=$E(Y(0))
     21 Q
     22 ;
     23 ;Dialog check - all exist, none exist or some exist
     24 ;--------------------------------------------------
     25EXIST(ALL,DNAME,DTYP,INAME) ;
     26 ;0 - None exist
     27 ;1 - All exist
     28 ;2 - Some exist
     29 ;
     30 ;Look for component dialogs in DMAP node from PXRMEXIC
     31 N DONE,DOTHER,EXISTS,FILE,MODE
     32 S ALL="",DONE=0,MODE="",NAME=""
     33 ;
     34 I DTYP="reminder dialog" D
     35 .F  S NAME=$O(^TMP("PXRMEXTMP",$J,"DMAP",NAME)) Q:NAME=""  D  Q:DONE
     36 ..;Check if dialog exists
     37 ..S EXISTS=$$EXISTS^PXRMEXIU(801.41,NAME)
     38 ..;If exists accumulate list of ancestors
     39 ..I EXISTS D OTHER(NAME,.DOTHER)
     40 ..;Quit if some exist and some don't
     41 ..I MODE=1,'EXISTS S MODE=2,DONE=1 Q
     42 ..I MODE=0,EXISTS S MODE=2,DONE=1 Q
     43 ..;Set all exists flag if dialog found
     44 ..I MODE="",EXISTS S MODE=1
     45 ..;Set none exists flag if dialog not found
     46 ..I MODE="",'EXISTS S MODE=0
     47 ;
     48 I DTYP'="reminder dialog" D
     49 .F  S NAME=$O(INAME(NAME)) Q:NAME=""  D  Q:DONE
     50 ..;Treat namechanges as 'done'
     51 ..I $D(PXRMNMCH(801.41,NAME)) Q
     52 ..;Check if dialog exists
     53 ..S EXISTS=$$EXISTS^PXRMEXIU(801.41,NAME)
     54 ..;If exists accumulate list of ancestors
     55 ..I EXISTS D OTHER(NAME,.DOTHER)
     56 ..;Quit if some exist and some don't
     57 ..I MODE=1,'EXISTS S MODE=2,DONE=1 Q
     58 ..I MODE=0,EXISTS S MODE=2,DONE=1 Q
     59 ..;Set all exists flag if dialog found
     60 ..I MODE="",EXISTS S MODE=1
     61 ..;Set none exists flag if dialog not found
     62 ..I MODE="",'EXISTS S MODE=0
     63 ;
     64 ;If all or none exist give option to install all without prompting
     65 N ANS,TEXT
     66 I MODE=0 D
     67 .S TEXT(1)="All dialog components for "_DNAME_" are new."
     68 I MODE=1 D
     69 .S TEXT(1)="All dialog components for "_DNAME_" already exist."
     70 .S TEXT(2)="",TEXT(4)=""
     71 .S TEXT(3)="Components not used by any other dialogs."
     72 .;Warn if used by other dialogs
     73 .I $D(DOTHER) D
     74 ..S TEXT(3)="WARNING - some components already used by:"
     75 ..N CNT,DLIT,DNAME,DTYP,FIRST,NAME
     76 ..S CNT=4,DNAME="",TEXT(CNT)=""
     77 ..F  S DNAME=$O(DOTHER(DNAME)) Q:DNAME=""  D
     78 ...S NAME="",FIRST=1,CNT=CNT+1
     79 ...S DTYP=DOTHER(DNAME)
     80 ...I DTYP="R" S DTYP="Reminder Dialog"
     81 ...I DTYP="G" S DTYP="Dialog Group"
     82 ...I DTYP="E" S DTYP="Dialog Element"
     83 ...;S CNT=CNT+1,FIRST=0,TEXT(CNT)=DLIT_NAME_" ("_DTYP_")"
     84 ...S CNT=CNT+1,FIRST=0,TEXT(CNT)=DNAME_" ("_DTYP_")"
     85 ..S CNT=CNT+1,TEXT(CNT)=""
     86 S TEXT="Install "_DTYP_" and all components with no further changes:"
     87 ;Give option to install all descendents
     88 D ASK(.ANS,.TEXT,2) I $G(ANS)="Y" S ALL=1
     89 Q
     90 ;
     91 ;Check if used by other dialogs
     92 ;------------------------------
     93OTHER(NAME,LIST) ;
     94 N DDATA,DIEN,DNAME,DTYP,IEN
     95 S IEN=$O(^PXRMD(801.41,"B",NAME,0)) Q:'IEN
     96 ;Check if used by other dialogs
     97 I '$D(^PXRMD(801.41,"AD",IEN)) Q
     98 ;Build list of dialogs using this component
     99 S DIEN=0
     100 F  S DIEN=$O(^PXRMD(801.41,"AD",IEN,DIEN)) Q:'DIEN  D
     101 .S DDATA=$G(^PXRMD(801.41,DIEN,0)) Q:DDATA=""
     102 .S DNAME=$P(DDATA,U),DTYP=$P(DDATA,U,4) Q:DNAME=""
     103 .;Include only dialogs that are not part of this reminder dialog
     104 .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) Q
     105 .S LIST(DNAME)=DTYP
     106 Q
     107 ;
     108 ;General help text routine.
     109 ;--------------------------
     110HLP(CALL) ;
     111 N HTEXT
     112 N DIWF,DIWL,DIWR,IC
     113 S DIWF="C75",DIWL=0,DIWR=75
     114 ;
     115 I CALL=1 D
     116 .S HTEXT(1)="Enter 'Yes' to if you are installing all sub-components or"
     117 .S HTEXT(2)="enter 'No' to install only the selected dialog."
     118 I CALL=2 D
     119 .S HTEXT(1)="Enter 'Yes' to if you are installing without changes."
     120 .S HTEXT(2)="enter 'No' to install with changes."
     121 I CALL=3 D
     122 .S HTEXT(1)="Select IFE to INSTALL reminder or dialog from this exchange"
     123 .S HTEXT(2)="entry. Select DFE to DELETE this entry from the exchange file. "
     124 .S HTEXT(3)="Select IH to view the installation HISTORY for this entry."
     125 K ^UTILITY($J,"W")
     126 S IC=""
     127 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     128 . S X=HTEXT(IC)
     129 . D ^DIWP
     130 W !
     131 S IC=0
     132 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     133 . W !,^UTILITY($J,"W",0,IC,0)
     134 K ^UTILITY($J,"W")
     135 W !
     136 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXLB.m

    r613 r623  
    1 PXRMEXLB        ;SLC/PJH - Reminder Dialog Exchange. ;05/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================================
    5         ;
    6         ;Build list of dialog components - called once from PXRMEXLC
    7         ;-------------------------------
    8 DBUILD(IND,NITEMS,FILENUM)      ;
    9         N DARRAY,DDATA,DDLG,DEND,DLOC,DMAP,DNAM,DNODE,DSEQ,DSTRT,DSUB,FILE,JND
    10         N REPCNT,RESGRP,TEMPRESL,CNT
    11         ;
    12         K ^TMP("PXRMEXTMP",$J),^TMP("PXRMEXFND",$J)
    13         ;
    14         ;Scan dialog components in 120 and save name and type
    15         S JND=0
    16         F  S JND=$O(^PXD(811.8,IEN,120,IND,1,JND)) Q:'JND  D
    17         .S DDATA=$G(^PXD(811.8,IEN,120,IND,1,JND,0)) Q:DDATA=""
    18         .S DNAM=$P(DDATA,U),DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3)
    19         .;Extract dialog type and text and findings from exchange file
    20         .D DPARSE
    21         ;Scan dialog components in 120 and save dialog links
    22         S JND="B",REPCNT=0
    23         F  S JND=$O(^PXD(811.8,IEN,120,IND,1,JND),-1) Q:'JND  D
    24         .S DDATA=$G(^PXD(811.8,IEN,120,IND,1,JND,0)) Q:DDATA=""
    25         .S DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3)
    26         .S DDLG=$P(DDATA,U),DSUB=DSTRT+2
    27         .I JND=NITEMS D
    28         ..S ^TMP("PXRMEXTMP",$J,"PXRMDNAM")=DDLG
    29         ..I $P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3)'["100~NATIONAL" Q
    30         ..S ^TMP("PXRMEXTMP",$J,"PXRMDNAT")=""
    31         .F  S DSUB=$O(^PXD(811.8,IEN,100,DSUB)) Q:DSUB>DEND  D
    32         ..S DNODE=$G(^PXD(811.8,IEN,100,DSUB,0))
    33         ..I ($P(DNODE,";")'="801.412")&($P(DNODE,";")'="801.41121")&($P(DNODE,";",3)'["118~") Q
    34         ..S FILE=$P(DNODE,";")
    35         ..S DNODE=$P(DNODE,";",3)
    36         ..;;Modified Exchange to handle dialogs with replacement dialogs
    37         ..I $E(DNODE,1,4)="118~" D
    38         ...S DNAM=$P(DNODE,"~",2) Q:DNAM=""
    39         ...S DLOC=$G(^TMP("PXRMEXTMP",$J,"DLOC",DNAM))
    40         ...S REPCNT=REPCNT+1,^TMP("PXRMEXTMP",$J,"DREPL",REPCNT,DDLG)=DNAM_U_DLOC
    41         ..I $E(DNODE,1,4)'=".01~" Q
    42         ..S DSEQ=$P(DNODE,"~",2) Q:DSEQ=""
    43         ..I FILE="801.41121" D  Q
    44         ...S DNAM=$P(DNODE,"~",2) Q:DNAM=""
    45         ...S DLOC=$G(^TMP("PXRMEXTMP",$J,"DLOC",DNAM))
    46         ...S CNT=0
    47         ...I $D(^TMP("PXRMEXTMP",$J,"DMAP",DDLG))>0 S CNT=$O(^TMP("PXRMEXTMP",$J,"DMAP",DDLG,""),-1)
    48         ...S ^TMP("PXRMEXTMP",$J,"DMAP",DDLG,CNT+1)=DNAM_U_DLOC
    49         ..S DNODE=$G(^PXD(811.8,IEN,100,DSUB+1,0))
    50         ..I ($P(DNODE,";")'="801.412") Q
    51         ..S DNODE=$P(DNODE,";",3) I $E(DNODE,1,2)'="2~" Q
    52         ..S DNAM=$P(DNODE,"~",2) Q:DNAM=""
    53         ..S DLOC=$G(^TMP("PXRMEXTMP",$J,"DLOC",DNAM))
    54         ..S ^TMP("PXRMEXTMP",$J,"DMAP",DDLG,DSEQ)=DNAM_U_DLOC
    55         ;
    56         ;Build index of dialog findings by name
    57         N FDATA,FILENAM,FILENUM,FNAME
    58         S IND=0
    59         F  S IND=$O(^PXD(811.8,IEN,120,IND)) Q:'IND  D
    60         .S FDATA=$G(^PXD(811.8,IEN,120,IND,0)) Q:FDATA=""
    61         .S FILENAM=$P(FDATA,U),FILENUM=$P(FDATA,U,2) Q:FILENAM=""  Q:'FILENUM
    62         .;Ignore reminder dialogs
    63         .I FILENAM="REMINDER DIALOG" Q
    64         .;Ignore reminder terms
    65         .I FILENAM="REMINDER TERM" Q
    66         .;Strip off trailing S in finding file name
    67         .I $E(FILENAM,$L(FILENAM))="S" S $E(FILENAM,$L(FILENAM))=""
    68         .S JND=0
    69         .F  S JND=$O(^PXD(811.8,IEN,120,IND,1,JND)) Q:'JND  D
    70         ..S FNAME=$P($G(^PXD(811.8,IEN,120,IND,1,JND,0)),U) Q:FNAME=""
    71         ..;Save entry
    72         ..S ^TMP("PXRMEXFND",$J,FNAME)=FILENUM_U_FILENAM_U_IND
    73         I $D(TEMPRESL)>0 D
    74         .S DDLG="" F  S DDLG=$O(TEMPRESL(DDLG)) Q:DDLG=""  D
    75         ..;S ^TMP("PXRMEXTMP",$J,"RESULT",DDLG,TEMPRESL(DDLG))=""
    76         ..S DSEQ=$O(^TMP("PXRMEXTMP",$J,"DMAP",DDLG,""),-1)
    77         ..S ^TMP("PXRMEXTMP",$J,"DMAP",DDLG,DSEQ+1)=TEMPRESL(DDLG)_U_RESGRP(TEMPRESL(DDLG))
    78         Q
    79         ;
    80         ;Scan exchange file to get dialog fields
    81         ;---------------------------------------
    82 DPARSE  N DCNT,DFIND,DFIAD,DFNAM,DFQUIT,DLCT,DLINES,DSUB,DTEXT,DTXT,DTYP
    83         ;
    84         ;Find where all the field numbers are kept
    85         N DARRAY,DDATA,DFNUM,DRAW,DSTRING,RESNAM
    86         S DSUB=DSTRT-1,DSTRING=";.01;4;5;15;24;25;55;"
    87         ;S DSUB=DSTRT,DSTRING=";4;5;15;24;25;"
    88         F  S DSUB=$O(^PXD(811.8,IEN,100,DSUB)) Q:'DSUB  D  Q:DSUB>DEND
    89         .S DDATA=$G(^PXD(811.8,IEN,100,DSUB,0)) Q:DDATA=""
    90         .I $P(DDATA,";")'=801.41 Q
    91         .S DFNUM=$P(DDATA,";",3),DFNUM=$P(DFNUM,"~") Q:DFNUM=""
    92         .I DSTRING[(";"_DFNUM_";") S DARRAY(DFNUM)=DSUB
    93         .I $P(DDATA,";")="801.41121" S DARRAY(55)=DSUB
    94         ;
    95         ;Determine dialog component type
    96         S DSUB=DARRAY(4) Q:'DSUB
    97         S DTYP=$P($G(^PXD(811.8,IEN,100,DSUB,0)),"~",2)
    98         I DTYP'["result" S:DTYP[" " DTYP=$P(DTYP," ",2) S:DTYP="value" DTYP="forced"
    99         ;
    100         ;Initialise text and finding fields
    101         S DTXT="*NONE*",DFIND=""
    102         ;Get text appropriate for the type of component
    103         I ((DTYP="element")!(DTYP="group"))&(DTYP'["result") D
    104         .;search for WP text
    105         .S DSUB=$G(DARRAY(25)) D:DSUB
    106         ..S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
    107         ..;Get the line count
    108         ..S DLINES=$P(DTEXT,"~",3),DCNT=0
    109         ..;Get the wp text lines
    110         ..F DLCT=DSUB+1:1:DSUB+DLINES D
    111         ...S DTEXT=$G(^PXD(811.8,IEN,100,DLCT,0))
    112         ...S DCNT=DCNT+1,DTXT(DCNT)=DTEXT
    113         ...;Check for embedded TIU templates
    114         ...D DTIU(DNAM,DTEXT)
    115         ..;Reformat text to 50 characters
    116         ..D DWP(.DTXT)
    117         ..;Search for Result Group/Element
    118         ..S DSUB=$G(DARRAY(55)) I DSUB>0 D
    119         ...S RESNAME=$P($P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3),"~",2)
    120         ...S TEMPRESL(DNAM)=RESNAME
    121         .;Search for finding item
    122         .S DSUB=$G(DARRAY(15)) D:DSUB
    123         ..S DFIND=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DFIND=""
    124         ..;Finding name
    125         ..S DFIND=$P(DFIND,"~",2) Q:DFIND=""
    126         ..I $P(DFIND,".")="ICD9" S DFIND=$P(DFIND," ")
    127         .;
    128         .;Search for additional finding - start after WP text
    129         .S DSUB=+$G(DARRAY(25)) D:DSUB
    130         ..S DCNT=0,DFQUIT=0
    131         ..F DLCT=DSUB+1+DLINES:1 D  Q:DFQUIT  Q:DLCT>DEND
    132         ...S DTEXT=$G(^PXD(811.8,IEN,100,DLCT,0))
    133         ...;Ignore line if this is not an additional finding
    134         ...I $P(DTEXT,";")'=801.4118 S:$P(DTEXT,";")>801.4118 DFQUIT=1 Q
    135         ...S DFNAM=$P(DTEXT,"~",2) Q:DFNAM=""
    136         ...I $P(DFNAM,".")="ICD9" S DFNAM=$P(DFNAM," ")
    137         ...S DCNT=DCNT+1,DFIAD(DCNT)=DFNAM
    138         ;
    139         I DTYP["result" D
    140         .S DSUB=$G(DARRAY(.01)) Q:'DSUB
    141         .S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
    142         .S DTXT=$P(DTEXT,"~",2)
    143         .S RESGRP(DNAM)=DSTRT_U_DEND_U_IND_U_JND
    144         ;
    145         I DTYP="prompt" D
    146         .;search for prompt caption
    147         .S DSUB=$G(DARRAY(24)) Q:'DSUB
    148         .S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
    149         .S DTXT=$P(DTEXT,"~",2)
    150         ;
    151         I DTYP="group" D
    152         .;search for group caption
    153         .S DSUB=$G(DARRAY(5)) Q:'DSUB
    154         .S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
    155         .S DTXT=$P(DTEXT,"~",2)
    156         .Q
    157         ;
    158         ;Save dialog type
    159         S ^TMP("PXRMEXTMP",$J,"DTYP",DNAM)=DTYP
    160         ;Save dialog component text (first line only)
    161         S ^TMP("PXRMEXTMP",$J,"DTXT",DNAM)=DTXT
    162         ;
    163         ;Save main finding
    164         I DFIND]"" S ^TMP("PXRMEXTMP",$J,"DFND",DNAM,1)=$P(DFIND,".",2,99)
    165         ;Save additional findings
    166         S DSUB=0
    167         F   S DSUB=$O(DFIAD(DSUB)) Q:'DSUB  D
    168         .S ^TMP("PXRMEXTMP",$J,"DFND",DNAM,DSUB+1)=$P(DFIAD(DSUB),".",2,99)
    169         ;
    170         ;Save additional WP text lines
    171         S DSUB=0
    172         F   S DSUB=$O(DTXT(DSUB)) Q:'DSUB  D
    173         .S ^TMP("PXRMEXTMP",$J,"DTXT",DNAM,DSUB)=DTXT(DSUB)
    174         ;
    175         ;Save dialog's position in exchange file
    176         S ^TMP("PXRMEXTMP",$J,"DLOC",DNAM)=DSTRT_U_DEND_U_IND_U_JND
    177         Q
    178         ;
    179         ;Extract any TIU templates
    180         ;-------------------------
    181 DTIU(DNAM,TEXT) ;
    182         N IC,TCNT,TLIST,TNAM
    183         ;Templates are in format {FLD:fldname}
    184         S TCNT=0 D TIUXTR^PXRMEXDG("{FLD:","}",TEXT,.TLIST,.TCNT) Q:'TCNT
    185         ;
    186         F IC=1:1:TCNT D
    187         .S TNAM=$G(TLIST(TCNT)) Q:TNAM=""
    188         .S ^TMP("PXRMEXTMP",$J,"DTIU",DNAM,TNAM)=""
    189         Q
    190         ;
    191         ;Process WP fields
    192         ;-----------------
    193 DWP(TEXT)       ;
    194         N DIWF,DIWL,DIWR,IC,X
    195         S DIWF="C50",DIWL=0,DIWR=50
    196         ;
    197         K ^UTILITY($J,"W")
    198         S IC=""
    199         F  S IC=$O(TEXT(IC)) Q:IC=""  D
    200         .S X=TEXT(IC)
    201         .D ^DIWP
    202         ;
    203         K TEXT
    204         S IC=0
    205         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    206         .S DTEXT=$G(^UTILITY($J,"W",0,IC,0))
    207         .I IC=1 S TEXT=DTEXT Q
    208         .S TEXT(IC-1)=DTEXT
    209         ;
    210         K ^UTILITY($J,"W")
    211         Q
     1PXRMEXLB ;SLC/PJH - Reminder Dialog Exchange. ;07/01/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================================
     5 ;
     6 ;Build list of dialog components - called once from PXRMEXLC
     7 ;-------------------------------
     8DBUILD(IND,NITEMS,FILENUM) ;
     9 N DARRAY,DDATA,DDLG,DEND,DLOC,DMAP,DNAM,DNODE,DSEQ,DSTRT,DSUB,JND
     10 ;
     11 K ^TMP("PXRMEXTMP",$J),^TMP("PXRMEXFND",$J)
     12 ;
     13 ;Scan dialog components in 120 and save name and type
     14 S JND=0
     15 F  S JND=$O(^PXD(811.8,IEN,120,IND,1,JND)) Q:'JND  D
     16 .S DDATA=$G(^PXD(811.8,IEN,120,IND,1,JND,0)) Q:DDATA=""
     17 .S DNAM=$P(DDATA,U),DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3)
     18 .;Extract dialog type and text and findings from exchange file
     19 .D DPARSE
     20 ;Scan dialog components in 120 and save dialog links
     21 S JND="B"
     22 F  S JND=$O(^PXD(811.8,IEN,120,IND,1,JND),-1) Q:'JND  D
     23 .S DDATA=$G(^PXD(811.8,IEN,120,IND,1,JND,0)) Q:DDATA=""
     24 .S DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3)
     25 .S DDLG=$P(DDATA,U),DSUB=DSTRT+2
     26 .I JND=NITEMS D
     27 ..S ^TMP("PXRMEXTMP",$J,"PXRMDNAM")=DDLG
     28 ..I $P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3)'["100~NATIONAL" Q
     29 ..S ^TMP("PXRMEXTMP",$J,"PXRMDNAT")=""
     30 .F  S DSUB=$O(^PXD(811.8,IEN,100,DSUB)) Q:DSUB>DEND  D
     31 ..S DNODE=$G(^PXD(811.8,IEN,100,DSUB,0))
     32 ..I $P(DNODE,";")'="801.412"&($P(DNODE,";",3)'["118~") Q
     33 ..S DNODE=$P(DNODE,";",3)
     34 ..;;Modified Exchange to handle dialogs with replacement dialogs
     35 ..I $E(DNODE,1,4)="118~" D
     36 ...S DNAM=$P(DNODE,"~",2) Q:DNAM=""
     37 ...S DLOC=$G(^TMP("PXRMEXTMP",$J,"DLOC",DNAM))
     38 ...S ^TMP("PXRMEXTMP",$J,"DREPL",DDLG)=DNAM_U_DLOC
     39 ..I $E(DNODE,1,4)'=".01~" Q
     40 ..S DSEQ=$P(DNODE,"~",2) Q:DSEQ=""
     41 ..S DNODE=$G(^PXD(811.8,IEN,100,DSUB+1,0)) I $P(DNODE,";")'="801.412" Q
     42 ..S DNODE=$P(DNODE,";",3) I $E(DNODE,1,2)'="2~" Q
     43 ..S DNAM=$P(DNODE,"~",2) Q:DNAM=""
     44 ..S DLOC=$G(^TMP("PXRMEXTMP",$J,"DLOC",DNAM))
     45 ..S ^TMP("PXRMEXTMP",$J,"DMAP",DDLG,DSEQ)=DNAM_U_DLOC
     46 ;
     47 ;Build index of dialog findings by name
     48 ;
     49 ;
     50 N FDATA,FILENAM,FILENUM,FNAME
     51 S IND=0
     52 F  S IND=$O(^PXD(811.8,IEN,120,IND)) Q:'IND  D
     53 .S FDATA=$G(^PXD(811.8,IEN,120,IND,0)) Q:FDATA=""
     54 .S FILENAM=$P(FDATA,U),FILENUM=$P(FDATA,U,2) Q:FILENAM=""  Q:'FILENUM
     55 .;Ignore reminder dialogs
     56 .I FILENAM="REMINDER DIALOG" Q
     57 .;Ignore reminder terms
     58 .I FILENAM="REMINDER TERM" Q
     59 .;Strip off trailing S in finding file name
     60 .I $E(FILENAM,$L(FILENAM))="S" S $E(FILENAM,$L(FILENAM))=""
     61 .S JND=0
     62 .F  S JND=$O(^PXD(811.8,IEN,120,IND,1,JND)) Q:'JND  D
     63 ..S FNAME=$P($G(^PXD(811.8,IEN,120,IND,1,JND,0)),U) Q:FNAME=""
     64 ..;Save entry
     65 ..S ^TMP("PXRMEXFND",$J,FNAME)=FILENUM_U_FILENAM_U_IND
     66 Q
     67 ;
     68 ;Scan exchange file to get dialog fields
     69 ;---------------------------------------
     70DPARSE N DCNT,DFIND,DFIAD,DFNAM,DFQUIT,DLCT,DLINES,DSUB,DTEXT,DTXT,DTYP
     71 ;
     72 ;Find where all the field numbers are kept
     73 N DARRAY,DDATA,DFNUM,DRAW,DSTRING
     74 S DSUB=DSTRT,DSTRING=";4;5;15;24;25;"
     75 F  S DSUB=$O(^PXD(811.8,IEN,100,DSUB)) Q:'DSUB  D  Q:DSUB>DEND
     76 .S DDATA=$G(^PXD(811.8,IEN,100,DSUB,0)) Q:DDATA=""
     77 .I $P(DDATA,";")'=801.41 Q
     78 .S DFNUM=$P(DDATA,";",3),DFNUM=$P(DFNUM,"~") Q:DFNUM=""
     79 .I DSTRING[(";"_DFNUM_";") S DARRAY(DFNUM)=DSUB
     80 ;
     81 ;Determine dialog component type
     82 S DSUB=DARRAY(4) Q:'DSUB
     83 S DTYP=$P($G(^PXD(811.8,IEN,100,DSUB,0)),"~",2)
     84 S:DTYP[" " DTYP=$P(DTYP," ",2) S:DTYP="value" DTYP="forced"
     85 ;
     86 ;Initialise text and finding fields
     87 S DTXT="*NONE*",DFIND=""
     88 ;Get text appropriate for the type of component
     89 I (DTYP="element")!(DTYP="group") D
     90 .;search for WP text
     91 .S DSUB=$G(DARRAY(25)) D:DSUB
     92 ..S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
     93 ..;Get the line count
     94 ..S DLINES=$P(DTEXT,"~",3),DCNT=0
     95 ..;Get the wp text lines
     96 ..F DLCT=DSUB+1:1:DSUB+DLINES D
     97 ...S DTEXT=$G(^PXD(811.8,IEN,100,DLCT,0))
     98 ...S DCNT=DCNT+1,DTXT(DCNT)=DTEXT
     99 ...;Check for embedded TIU templates
     100 ...D DTIU(DNAM,DTEXT)
     101 ..;Reformat text to 50 characters
     102 ..D DWP(.DTXT)
     103 .;
     104 .;Search for finding item
     105 .S DSUB=$G(DARRAY(15)) D:DSUB
     106 ..S DFIND=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DFIND=""
     107 ..;Finding name
     108 ..S DFIND=$P(DFIND,"~",2) Q:DFIND=""
     109 ..I $P(DFIND,".")="ICD9" S DFIND=$P(DFIND," ")
     110 .;
     111 .;Search for additional finding - start after WP text
     112 .S DSUB=+$G(DARRAY(25)) D:DSUB
     113 ..S DCNT=0,DFQUIT=0
     114 ..F DLCT=DSUB+1+DLINES:1 D  Q:DFQUIT  Q:DLCT>DEND
     115 ...S DTEXT=$G(^PXD(811.8,IEN,100,DLCT,0))
     116 ...;Ignore line if this is not an additional finding
     117 ...I $P(DTEXT,";")'=801.4118 S:$P(DTEXT,";")>801.4118 DFQUIT=1 Q
     118 ...S DFNAM=$P(DTEXT,"~",2) Q:DFNAM=""
     119 ...I $P(DFNAM,".")="ICD9" S DFNAM=$P(DFNAM," ")
     120 ...S DCNT=DCNT+1,DFIAD(DCNT)=DFNAM
     121 ;
     122 I DTYP="prompt" D
     123 .;search for prompt caption
     124 .S DSUB=$G(DARRAY(24)) Q:'DSUB
     125 .S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
     126 .S DTXT=$P(DTEXT,"~",2)
     127 ;
     128 I DTYP="group" D
     129 .;search for group caption
     130 .S DSUB=$G(DARRAY(5)) Q:'DSUB
     131 .S DTEXT=$P($G(^PXD(811.8,IEN,100,DSUB,0)),";",3) Q:DTEXT=""
     132 .S DTXT=$P(DTEXT,"~",2)
     133 .Q
     134 ;
     135 ;Save dialog type
     136 S ^TMP("PXRMEXTMP",$J,"DTYP",DNAM)=DTYP
     137 ;Save dialog component text (first line only)
     138 S ^TMP("PXRMEXTMP",$J,"DTXT",DNAM)=DTXT
     139 ;
     140 ;Save main finding
     141 I DFIND]"" S ^TMP("PXRMEXTMP",$J,"DFND",DNAM,1)=$P(DFIND,".",2,99)
     142 ;Save additional findings
     143 S DSUB=0
     144 F   S DSUB=$O(DFIAD(DSUB)) Q:'DSUB  D
     145 .S ^TMP("PXRMEXTMP",$J,"DFND",DNAM,DSUB+1)=$P(DFIAD(DSUB),".",2,99)
     146 ;
     147 ;Save additional WP text lines
     148 S DSUB=0
     149 F   S DSUB=$O(DTXT(DSUB)) Q:'DSUB  D
     150 .S ^TMP("PXRMEXTMP",$J,"DTXT",DNAM,DSUB)=DTXT(DSUB)
     151 ;
     152 ;Save dialog's position in exchange file
     153 S ^TMP("PXRMEXTMP",$J,"DLOC",DNAM)=DSTRT_U_DEND_U_IND_U_JND
     154 Q
     155 ;
     156 ;Extract any TIU templates
     157 ;-------------------------
     158DTIU(DNAM,TEXT) ;
     159 N IC,TCNT,TLIST,TNAM
     160 ;Templates are in format {FLD:fldname}
     161 S TCNT=0 D TIUXTR^PXRMEXDG("{FLD:","}",TEXT,.TLIST,.TCNT) Q:'TCNT
     162 ;
     163 F IC=1:1:TCNT D
     164 .S TNAM=$G(TLIST(TCNT)) Q:TNAM=""
     165 .S ^TMP("PXRMEXTMP",$J,"DTIU",DNAM,TNAM)=""
     166 Q
     167 ;
     168 ;Process WP fields
     169 ;-----------------
     170DWP(TEXT) ;
     171 N DIWF,DIWL,DIWR,IC,X
     172 S DIWF="C50",DIWL=0,DIWR=50
     173 ;
     174 K ^UTILITY($J,"W")
     175 S IC=""
     176 F  S IC=$O(TEXT(IC)) Q:IC=""  D
     177 .S X=TEXT(IC)
     178 .D ^DIWP
     179 ;
     180 K TEXT
     181 S IC=0
     182 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     183 .S DTEXT=$G(^UTILITY($J,"W",0,IC,0))
     184 .I IC=1 S TEXT=DTEXT Q
     185 .S TEXT(IC-1)=DTEXT
     186 ;
     187 K ^UTILITY($J,"W")
     188 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXLC.m

    r613 r623  
    1 PXRMEXLC        ; SLC/PKR/PJH - Routines to display repository entry components. ;08/03/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;======================================================
    4 BLDLIST(FORCE)  ;Build a list of all repository entries.
    5         ;If FORCE is true then force rebuilding of the list.
    6         I FORCE K ^TMP("PXRMEXLR",$J)
    7         I $D(^TMP("PXRMEXLR",$J,"VALMCNT")) S VALMCNT=^TMP("PXRMEXLR",$J,"VALMCNT")
    8         E  D
    9         . D REXL^PXRMLIST("PXRMEXLR")
    10         . S VALMCNT=^TMP("PXRMEXLR",$J,"VALMCNT")
    11         Q
    12         ;
    13         ;======================================================
    14 CDISP(IEN)      ;Format component list for display.
    15         N CAT,CMPNT,END,EOKTI,EXISTS,FILENUM,FOKTI,IND,INDEX,JND,JNDS,KND
    16         N MSG,NCMPNT,NDLINE,NDSEL,NITEMS,NLINE,NSEL,PT01,START,TEMP,TEMP0,TYPE
    17         K ^TMP("PXRMEXLC",$J),^TMP("PXRMEXLD",$J)
    18         S (NDLINE,NLINE)=0
    19         S (NDSEL,NSEL)=1
    20         ;Load the description.
    21         F IND=1:1:$P(^PXD(811.8,IEN,110,0),U,4) D
    22         . S NLINE=NLINE+1
    23         . S ^TMP("PXRMEXLC",$J,NLINE,0)=^PXD(811.8,IEN,110,IND,0)
    24         . S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
    25         S NLINE=NLINE+1
    26         S ^TMP("PXRMEXLC",$J,NLINE,0)=" "
    27         S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
    28         S NCMPNT=^PXD(811.8,IEN,119)
    29         ;Load the text for display.
    30         F IND=1:1:NCMPNT D
    31         . S NLINE=NLINE+1
    32         . S TEMP=^PXD(811.8,IEN,120,IND,0)
    33         . S ^TMP("PXRMEXLC",$J,NLINE,0)=$P(TEMP,U,1)
    34         . S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
    35         . S FILENUM=$P(TEMP,U,2)
    36         . S FOKTI=$$FOKTI^PXRMEXFI(FILENUM)
    37         . S NITEMS=$P(TEMP,U,3)
    38         . I $P(TEMP,U,1)="REMINDER DIALOG" D
    39         ..;Save details of the dialog in ^TMP("PXRMEXTMP")
    40         .. S JNDS=NITEMS D DBUILD^PXRMEXLB(IND,NITEMS,FILENUM)
    41         . E  S JNDS=1
    42         . F JND=JNDS:1:NITEMS D
    43         .. S TEMP=^PXD(811.8,IEN,120,IND,1,JND,0)
    44         .. S EOKTI=FOKTI
    45         .. S PT01=$P(TEMP,U,1)
    46         .. S EXISTS=$S(FILENUM=0:$$EXISTS^PXRMEXCF(PT01),1:$$EXISTS^PXRMEXIU(FILENUM,PT01,"W"))
    47         ..;If this is an education topic and it starts with VA- it
    48         ..;cannot be transported because of PCE's screen.
    49         .. ;I (FILENUM=9999999.09)&(PT01["VA-") S EOKTI=0
    50         ..;If this is a health factor see if it is a category.
    51         .. S CAT=""
    52         .. I (FILENUM=9999999.64) D
    53         ... S TYPE=""
    54         ... S START=$P(TEMP,U,2)
    55         ... S END=$P(TEMP,U,3)
    56         ... F KND=START:1:END D
    57         .... S TEMP0=$P(^PXD(811.8,IEN,100,KND,0),";",3)
    58         .... I $P(TEMP0,"~",1)=.1 S TYPE=$P(TEMP0,"~",2)
    59         ... I TYPE="CATEGORY" S CAT="X"
    60         .. S NLINE=NLINE+1
    61         .. I IND=1,JND=1 S NSEL=1,INDEX=$S(EOKTI:NSEL,1:"")
    62         .. E  D
    63         ...;If entries in this file are ok to install add them to the
    64         ...;selectable list. Make sure the first selectable entry exists
    65         ...;before incrementing NSEL.
    66         ... I EOKTI S NSEL=$S($D(^TMP("PXRMEXLC",$J,"SEL",1)):NSEL+1,1:NSEL),INDEX=NSEL
    67         ... E  S INDEX=""
    68         .. S ^TMP("PXRMEXLC",$J,NLINE,0)=$$FMTDATA(INDEX,PT01,CAT,EXISTS)
    69         .. S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
    70         ..;Store the file number, node 120 indexes and the ien if it exists.
    71         .. I INDEX=NSEL S ^TMP("PXRMEXLC",$J,"SEL",NSEL)=FILENUM_U_IND_U_JND_U_EXISTS
    72         . S NLINE=NLINE+1
    73         . S ^TMP("PXRMEXLC",$J,NLINE,0)=""
    74         . S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
    75         Q
    76         ;
    77         ;======================================================
    78 FMTDATA(NSEL,PT01,CAT,EXISTS)   ;Format items for display.
    79         N NSTI,TEMP
    80         S TEMP=$$RJ^XLFSTR(NSEL,4," ")_"  "_$E(PT01,1,54)
    81         I CAT="X" D
    82         . S NSTI=63-$L(TEMP)
    83         . S TEMP=TEMP_$$INSCHR(NSTI," ")_"X"
    84         I EXISTS D
    85         . S NSTI=75-$L(TEMP)
    86         . S TEMP=TEMP_$$INSCHR(NSTI," ")_"X"
    87         Q TEMP
    88         ;
    89         ;======================================================
    90 INSCHR(NUM,CHR) ;Return a string of NUM characters (CHR).
    91         N IND,TEMP
    92         S TEMP=""
    93         I NUM<1 Q TEMP
    94         F IND=1:1:NUM S TEMP=TEMP_CHR
    95         Q TEMP
    96         ;
    97         ;======================================================
    98 ORDER(STRING,ORDER)     ;Rebuild string in ascending or descending order.
    99         N ARRAY,ITEM,CNT
    100         F CNT=1:1 S ITEM=$P(STRING,",",CNT) Q:'ITEM  S ARRAY(ITEM)=""
    101         K STRING
    102         F CNT=1:1 S ITEM=$O(ARRAY(ITEM),ORDER) Q:'ITEM  D
    103         .S $P(STRING,",",CNT)=ITEM
    104         Q
    105         ;
     1PXRMEXLC ; SLC/PKR/PJH - Routines to display repository entry components. ;06/22/2004
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;======================================================
     4BLDLIST(FORCE) ;Build a list of all repository entries.
     5 ;If FORCE is true then force rebuilding of the list.
     6 I FORCE K ^TMP("PXRMEXLR",$J)
     7 I $D(^TMP("PXRMEXLR",$J,"VALMCNT")) S VALMCNT=^TMP("PXRMEXLR",$J,"VALMCNT")
     8 E  D
     9 . N IEN,RELIST
     10 . D RE^PXRMLIST(.RELIST,.IEN)
     11 . M ^TMP("PXRMEXLR",$J)=RELIST
     12 . S VALMCNT=RELIST("VALMCNT")
     13 . F IND=1:1:VALMCNT S ^TMP("PXRMEXLR",$J,"IDX",IND,IND)=IEN(IND)
     14 Q
     15 ;
     16 ;======================================================
     17CDISP(IEN) ;Format component list for display.
     18 N CAT,CMPNT,END,EOKTI,EXISTS,FILENUM,FOKTI,IND,INDEX,JND,JNDS,KND
     19 N MSG,NCMPNT,NDLINE,NDSEL,NITEMS,NLINE,NSEL,PT01,START,TEMP,TEMP0,TYPE
     20 K ^TMP("PXRMEXLC",$J),^TMP("PXRMEXLD",$J)
     21 S (NDLINE,NLINE)=0
     22 S (NDSEL,NSEL)=1
     23 ;Load the description.
     24 F IND=1:1:$P(^PXD(811.8,IEN,110,0),U,4) D
     25 . S NLINE=NLINE+1
     26 . S ^TMP("PXRMEXLC",$J,NLINE,0)=^PXD(811.8,IEN,110,IND,0)
     27 . S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
     28 S NLINE=NLINE+1
     29 S ^TMP("PXRMEXLC",$J,NLINE,0)=" "
     30 S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
     31 S NCMPNT=^PXD(811.8,IEN,119)
     32 ;Load the text for display.
     33 F IND=1:1:NCMPNT D
     34 . S NLINE=NLINE+1
     35 . S TEMP=^PXD(811.8,IEN,120,IND,0)
     36 . S ^TMP("PXRMEXLC",$J,NLINE,0)=$P(TEMP,U,1)
     37 . S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
     38 . S FILENUM=$P(TEMP,U,2)
     39 . S FOKTI=$$FOKTI^PXRMEXFI(FILENUM)
     40 . S NITEMS=$P(TEMP,U,3)
     41 . I $P(TEMP,U,1)="REMINDER DIALOG" D
     42 ..;Save details of the dialog in ^TMP("PXRMEXTMP")
     43 .. S JNDS=NITEMS D DBUILD^PXRMEXLB(IND,NITEMS,FILENUM)
     44 . E  S JNDS=1
     45 . F JND=JNDS:1:NITEMS D
     46 .. S TEMP=^PXD(811.8,IEN,120,IND,1,JND,0)
     47 .. S EOKTI=FOKTI
     48 .. S PT01=$P(TEMP,U,1)
     49 .. S EXISTS=$S(FILENUM=0:$$EXISTS^PXRMEXCF(PT01),1:$$EXISTS^PXRMEXIU(FILENUM,PT01,"W"))
     50 ..;If this is an education topic and it starts with VA- it
     51 ..;cannot be transported because of PCE's screen.
     52 .. ;I (FILENUM=9999999.09)&(PT01["VA-") S EOKTI=0
     53 ..;If this is a health factor see if it is a category.
     54 .. S CAT=""
     55 .. I (FILENUM=9999999.64) D
     56 ... S TYPE=""
     57 ... S START=$P(TEMP,U,2)
     58 ... S END=$P(TEMP,U,3)
     59 ... F KND=START:1:END D
     60 .... S TEMP0=$P(^PXD(811.8,IEN,100,KND,0),";",3)
     61 .... I $P(TEMP0,"~",1)=.1 S TYPE=$P(TEMP0,"~",2)
     62 ... I TYPE="CATEGORY" S CAT="X"
     63 .. S NLINE=NLINE+1
     64 .. I IND=1,JND=1 S NSEL=1,INDEX=$S(EOKTI:NSEL,1:"")
     65 .. E  D
     66 ...;If entries in this file are ok to install add them to the
     67 ...;selectable list. Make sure the first selectable entry exists
     68 ...;before incrementing NSEL.
     69 ... I EOKTI S NSEL=$S($D(^TMP("PXRMEXLC",$J,"SEL",1)):NSEL+1,1:NSEL),INDEX=NSEL
     70 ... E  S INDEX=""
     71 .. S ^TMP("PXRMEXLC",$J,NLINE,0)=$$FMTDATA(INDEX,PT01,CAT,EXISTS)
     72 .. S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
     73 ..;Store the file number, node 120 indexes and the ien if it exists.
     74 .. I INDEX=NSEL S ^TMP("PXRMEXLC",$J,"SEL",NSEL)=FILENUM_U_IND_U_JND_U_EXISTS
     75 . S NLINE=NLINE+1
     76 . S ^TMP("PXRMEXLC",$J,NLINE,0)=""
     77 . S ^TMP("PXRMEXLC",$J,"IDX",NLINE,NSEL)=""
     78 Q
     79 ;
     80 ;======================================================
     81DDISP(IND,NITEMS,FILENUM) ;Setup dialog display list.
     82 N JND,NLINE,NSEL,TEMP
     83 S (NLINE,NSEL)=0
     84 F JND=1:1:NITEMS D
     85 . S TEMP=^PXD(811.8,IEN,120,IND,1,JND,0)
     86 . S PT01=$P(TEMP,U,1)
     87 . S EXISTS=$$EXISTS^PXRMEXIU(FILENUM,PT01,"W")
     88 . S NLINE=NLINE+1
     89 . S NSEL=NSEL+1
     90 . S ^TMP("PXRMEXLD",$J,NLINE,0)=$$FMTDATA(NSEL,PT01,CAT,EXISTS)
     91 . S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     92 .;Store the file number, start and stop line in the repository.
     93 . S ^TMP("PXRMEXLD",$J,"SEL",NSEL)=FILENUM_U_$P(TEMP,U,2,3)
     94 Q
     95 ;
     96 ;======================================================
     97FMTDATA(NSEL,PT01,CAT,EXISTS) ;Format items for display.
     98 N NSTI,TEMP
     99 S TEMP=$$RJ^XLFSTR(NSEL,4," ")_"  "_$E(PT01,1,54)
     100 I CAT="X" D
     101 . S NSTI=63-$L(TEMP)
     102 . S TEMP=TEMP_$$INSCHR(NSTI," ")_"X"
     103 I EXISTS D
     104 . S NSTI=75-$L(TEMP)
     105 . S TEMP=TEMP_$$INSCHR(NSTI," ")_"X"
     106 Q TEMP
     107 ;
     108 ;======================================================
     109HISTLIST(LIST,VALMCNT) ;Build a list of install histories in
     110 ;^TMP("PXRMEXIH",$J).
     111 N DATE,DC,ENTRY,IHIND,IND,INDONE,NLINE,NSEL,RIEN,SOURCE,TEMP,USER
     112 K ^TMP("PXRMEXIH",$J)
     113 S (NLINE,NSEL)=0
     114 S IND=""
     115 F  S IND=$O(LIST(IND)) Q:IND=""  D
     116 . S RIEN=^TMP("PXRMEXLR",$J,"IDX",IND,IND)
     117 . I $D(^PXD(811.8,RIEN,130)) S INDONE=1
     118 . E  S INDONE=0
     119 . S TEMP=^PXD(811.8,RIEN,0)
     120 . S ENTRY=$P(TEMP,U,1)
     121 . S SOURCE=$P(TEMP,U,2)
     122 . S DATE=$P(TEMP,U,3)
     123 . S NLINE=NLINE+1
     124 . I INDONE S NSEL=NSEL+1
     125 . S ^TMP("PXRMEXIH",$J,NLINE,0)=$$FRE^PXRMLIST(" ",ENTRY,SOURCE,DATE)
     126 . I INDONE S ^TMP("PXRMEXIH",$J,"IDX",NLINE,NSEL)=""
     127 . S NLINE=NLINE+1
     128 . S ^TMP("PXRMEXIH",$J,NLINE,0)="     Installation Date       Installed By"
     129 . I INDONE S ^TMP("PXRMEXIH",$J,"IDX",NLINE,NSEL)=""
     130 . S NLINE=NLINE+1
     131 . S ^TMP("PXRMEXIH",$J,NLINE,0)="     -----------------       ------------"
     132 . I INDONE S ^TMP("PXRMEXIH",$J,"IDX",NLINE,NSEL)=""
     133 . I 'INDONE D  Q
     134 .. S NLINE=NLINE+1
     135 .. S ^TMP("PXRMEXIH",$J,NLINE,0)="      none"
     136 .. S NLINE=NLINE+1
     137 .. S ^TMP("PXRMEXIH",$J,NLINE,0)=" "
     138 . S DATE="",DC=0
     139 . F  S DATE=$O(^PXD(811.8,RIEN,130,"B",DATE)) Q:DATE=""  D
     140 .. S NLINE=NLINE+1
     141 .. S DC=DC+1
     142 .. I DC>1 S NSEL=NSEL+1
     143 .. S IHIND=$O(^PXD(811.8,RIEN,130,"B",DATE,""))
     144 .. S TEMP=^PXD(811.8,RIEN,130,IHIND,0)
     145 .. S ^TMP("PXRMEXIH",$J,NLINE,0)=$$RJ^XLFSTR(NSEL,4," ")_" "_$$FMTE^XLFDT($P(TEMP,U,1),"5Z")_"   "_$P(TEMP,U,2)
     146 .. S ^TMP("PXRMEXIH",$J,"IDX",NLINE,NSEL)=""
     147 .. S ^TMP("PXRMEXIH",$J,"SEL",NSEL)=RIEN_U_IHIND
     148 . S NLINE=NLINE+1
     149 . S ^TMP("PXRMEXIH",$J,NLINE,0)=" "
     150 . S ^TMP("PXRMEXIH",$J,"IDX",NLINE,NSEL)=""
     151 S VALMCNT=NLINE
     152 Q
     153 ;
     154 ;======================================================
     155INSCHR(NUM,CHR) ;Return a string of NUM characters (CHR).
     156 N IND,TEMP
     157 S TEMP=""
     158 I NUM<1 Q TEMP
     159 F IND=1:1:NUM S TEMP=TEMP_CHR
     160 Q TEMP
     161 ;
     162 ;======================================================
     163DREPL ;
     164 N STR,I
     165 K PXRMEXOR
     166 S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     167 S STR="" F I=1:1:30 S STR=STR_"-"
     168 S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J(STR_" REPLACEMENT ITEMS "_STR,79)
     169DREPL1 ;
     170 M ^TMP($J,"PXRMEXREP")=PXRMEXRP
     171 K PXRMEXRP
     172 ;S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)="
     173 N CNT,DLG,DDATA,DDLG,DEND,DNAM,DREP,DSTRT,IND,JND,LEV,TEMP
     174 ;S LEV="" F  S LEV=$O(^TMP($J,"PXRMEXREP",LEV)) Q:LEV=""  D
     175 S LEV=0
     176 S DLG="" F  S DLG=$O(^TMP($J,"PXRMEXREP",DLG)) Q:DLG=""  D
     177 .S DDATA=$G(^TMP("PXRMEXTMP",$J,"DREPL",DLG)) Q:DDATA=""
     178 .S DNAM=$P(DDATA,U),DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3) Q:DNAM=""
     179 .I $D(PXRMEXOR(DNAM))>0 Q
     180 .S PXRMEXOR(DNAM)=""
     181 .S IND=$P(DDATA,U,4),JND=$P(DDATA,U,5)
     182 .;Check if this component has been replaced
     183 .S LEV=LEV+1
     184 .S DREP=$G(PXRMNMCH(FILENUM,DNAM)) I DREP=DNAM S DREP=""
     185 .;Save line in workfile
     186 .S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     187 .S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     188 .D DLINE^PXRMEXLD(DNAM,LEV,"")
     189 .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAM)) D DCMP^PXRMEXLD(DNAM,LEV)
     190 K ^TMP($J,"PXRMEXREP")
     191 I $D(PXRMEXRP)>0 D DREPL1
     192 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXLD.m

    r613 r623  
    1 PXRMEXLD        ;SLC/PJH - Reminder Dialog Exchange Main Routine. ;08/07/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 START   N PXRMBG,PXRMMODE,VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ
    5         S X="IORESET"
    6         D EN^VALM("PXRM EX LIST DIALOG")
    7         ;Rebuild Display
    8         D CDISP^PXRMEXLC(PXRMRIEN)
    9         Q
    10         ;
    11 ENTRY   ; Entry point for List Manager
    12         D FIND Q
    13         ;
    14 DETAIL  ;Detailed display
    15         S PXRMMODE=0 D DISP(PXRMMODE) Q
    16         ;
    17 FIND    ;Display findings
    18         S PXRMMODE=2 D DISP(PXRMMODE) Q
    19         ;
    20 SUM     ;Display dialog summary
    21         S PXRMMODE=3 D DISP(PXRMMODE) Q
    22         ;
    23 USE     ;Display dialog usage
    24         S PXRMMODE=4 D DISP(PXRMMODE) Q
    25         ;
    26 TEXT    ;Display dialog text
    27         S PXRMMODE=1 D DISP(PXRMMODE) Q
    28         ;
    29 EXIT    ;
    30         K ^TMP("PXRMEXLD",$J)
    31         Q
    32         ;
    33 DISP(VIEW)      ;Build the requested view and display it.
    34         D BLDDISP^PXRMEXD1(VIEW)
    35         ;Change header
    36         I VIEW=0 D CHGCAP^VALM("HEADER2","Dialog Details")
    37         I VIEW=1 D CHGCAP^VALM("HEADER2","Dialog Text")
    38         I VIEW=2 D CHGCAP^VALM("HEADER2","Dialog Findings")
    39         I VIEW=3 D CHGCAP^VALM("HEADER2","Dialog Summary")
    40         I VIEW=4 D CHGCAP^VALM("HEADER2","Dialog Usage")
    41         S VALMCNT=^TMP("PXRMEXLD",$J,"VALMCNT"),VALMBG=1,VALMBCK="R"
    42         ;Reset protocol
    43         D XQORM
    44         Q
    45         ;
    46 HELP    ;
    47         N ORU,ORUPRMT,XQORM,PXRMTAG
    48         S PXRMTAG="DLG"
    49         D EN^VALM("PXRM EX DIALOG HELP")
    50         Q
    51         ;
    52 HDR     ;
    53         S VALMHDR(1)="Packed reminder dialog: "
    54         S VALMHDR(1)=VALMHDR(1)_$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
    55         I $D(^TMP("PXRMEXTMP",$J,"PXRMDNAT")) S VALMHDR(1)=VALMHDR(1)_" [NATIONAL DIALOG]"
    56         S VALMHDR("TITLE")=VALMHDR(1)
    57         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    58         Q
    59         ;
    60 PEXIT   ;PXRM EXCH DIALOG MENU protocol exit code
    61         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    62         ;Reset after page up/down etc
    63         D XQORM
    64         Q
    65         ;
    66 VALID(STRING)   ;Validate sequence numbers
    67         N CNT,FOUND,OK
    68         S FOUND=0,OK=1
    69         F CNT=1:1 S SEL=$P(STRING,",",CNT) Q:'SEL  D
    70         .;Invalid selection
    71         .I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    72         ..S OK=0 W $C(7),!,SEL_" is not a valid item number." H 2
    73         .S FOUND=1
    74         Q:OK&FOUND 1
    75         Q 0
    76         ;
    77 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT DIALOG",0))_U_"1:"_VALMCNT
    78         S XQORM("A")="Select Action: "
    79         Q
    80         ;
    81 XSEL    ;PXRM EXCH SELECT DIALOG validation
    82         N ALL,CNT,ERR,IEN,IND,PXRMDONE,SELECT,SEL
    83         S ALL="",PXRMDONE=0,PXRMBG=$G(VALMBG)
    84         ;Invalid selection
    85         S SELECT=$P(XQORNOD(0),"=",2) I '$$VALID(SELECT) S VALMBCK="R" Q
    86         ;
    87         ;Sort the SELECTION into reverse order
    88         D ORDER^PXRMEXLC(.SELECT,-1)
    89         ;
    90         ;Lock the file
    91         I '$$LOCK^PXRMEXID S VALMBCK="R" Q
    92         ;
    93         ;Install dialog component(s)
    94         S CNT=0
    95         F CNT=1:1 S SEL=$P(SELECT,",",CNT) Q:'SEL  D  Q:PXRMDONE
    96         .D INSCOM^PXRMEXID(SEL,0)
    97         ;
    98         ;Unlock file
    99         D UNLOCK^PXRMEXID
    100         ;
    101         ;Rebuild Workfile
    102         D DISP^PXRMEXLD(PXRMMODE)
    103         ;
    104         ;Refresh
    105         S VALMBCK="R" I $D(PXRMBG) S VALMBG=PXRMBG
    106         Q
     1PXRMEXLD ;SLC/PJH - Reminder Dialog Exchange Main Routine. ;7/01/2004
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=====================================================================
     5START N PXRMBG,PXRMMODE,VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ
     6 S X="IORESET"
     7 D EN^VALM("PXRM EX LIST DIALOG")
     8 ;
     9 ;Rebuild Display
     10 D CDISP^PXRMEXLC(PXRMRIEN)
     11 Q
     12 ;
     13ENTRY D FIND Q
     14 ;
     15DETAIL S PXRMMODE=0 D DISP(PXRMMODE) Q
     16 ;
     17 ;Display Findings
     18 ;--------------------------
     19FIND S PXRMMODE=2 D DISP(PXRMMODE) Q
     20 ;
     21 ;Display Dialog Summary
     22 ;----------------------
     23SUM S PXRMMODE=3 D DISP(PXRMMODE) Q
     24 ;
     25 ;Display Dialog Usage
     26 ;--------------------
     27USE S PXRMMODE=4 D DISP(PXRMMODE) Q
     28 ;
     29 ;Display Dialog Text
     30 ;-------------------
     31TEXT S PXRMMODE=1 D DISP(PXRMMODE) Q
     32 ;
     33EXIT K ^TMP("PXRMEXLD",$J) Q
     34 ;
     35PEXIT ;PXRM EXCH DIALOG MENU protocol exit code
     36 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     37 ;Reset after page up/down etc
     38 D XQORM
     39 Q
     40 ;
     41HELP N ORU,ORUPRMT,XQORM,PXRMTAG S PXRMTAG="DLG"
     42 D EN^VALM("PXRM EX DIALOG HELP")
     43 Q
     44 ;
     45HDR S VALMHDR(1)="Packed reminder dialog: "
     46 S VALMHDR(1)=VALMHDR(1)_$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
     47 I $D(^TMP("PXRMEXTMP",$J,"PXRMDNAT")) D
     48 .S VALMHDR(1)=VALMHDR(1)_" [NATIONAL DIALOG]"
     49 S VALMHDR("TITLE")=VALMHDR(1)
     50 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     51 Q
     52 ;
     53 ;Build list manager workfile from ^TMP("PXRMEXTMP" (see ^PXRMEXLB)
     54DISP(VIEW) ;
     55 N OLEV,ODSEQ
     56 K ^TMP("PXRMEXLD",$J)
     57 K PXRMEXRP
     58 K ^TMP($J,"PXRMEXREP")
     59 N DDATA,DDLG,DEND,DREP,DSTRT,IND,JND,NLINE,NSEL
     60 S NLINE=0,NSEL=0,VALMBCK="R",VALMCNT=NLINE
     61 S DDLG=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM")) Q:DDLG=""
     62 ;
     63 ;Save reminder dialog
     64 S DDATA=^TMP("PXRMEXTMP",$J,"DLOC",DDLG)
     65 S DSTRT=$P(DDATA,U,1),DEND=$P(DDATA,U,2)
     66 S IND=$P(DDATA,U,3),JND=$P(DDATA,U,4),DREP=""
     67 D DLINE(DDLG,"","")
     68 S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     69 S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     70 ;Process componentS
     71 D DCMP(DDLG,"")
     72 ;Process replacement elements
     73 ;I $D(^TMP("PXRMEXTMP",$J,"DREPL"))>0 D DREPL^PXRMEXLC
     74 I $D(PXRMEXRP)>0 D DREPL^PXRMEXLC
     75 ;Change header
     76 I VIEW=0 D CHGCAP^VALM("HEADER2","Dialog Details")
     77 I VIEW=1 D CHGCAP^VALM("HEADER2","Dialog Text")
     78 I VIEW=2 D CHGCAP^VALM("HEADER2","Dialog Findings")
     79 I VIEW=3 D CHGCAP^VALM("HEADER2","Dialog Summary")
     80 I VIEW=4 D CHGCAP^VALM("HEADER2","Dialog Usage")
     81 ;
     82 S VALMCNT=NLINE,^TMP("PXRMEXLD",$J,"VALMCNT")=VALMCNT,VALMBG=1
     83 ;
     84 K ^TMP($J,"PXRMEXREP"),PXRMEXRP
     85 ;Reset protocol
     86 D XQORM
     87 Q
     88 ;
     89 ;Update workfile
     90DLINE(DNAM,LEV,DSEQ) ;
     91 ;Check if standard PXRM prompt
     92 N LEVSEQ,TLEV
     93 N DPXRM S DPXRM=$$PXRM^PXRMEXID(DNAM)
     94 ;
     95 ;Ignore PXRM prompts if doing a finding view (DF)
     96 I VIEW>1,DPXRM Q
     97 ;
     98 N DEXIST,DPTX,DTXT,DTYP,EXIST,ITEM,TEMP,SEP
     99 S ITEM=""
     100 I DPXRM=0 S NSEL=NSEL+1,ITEM=NSEL
     101 S NLINE=NLINE+1,SEP=$E(LEV,$L(LEV)),DEXIST=0
     102 S LEVSEQ=LEV_DSEQ
     103 S TEMP=$J(ITEM,3)_$J("",4)_LEV_DSEQ
     104 ;Determine type
     105 S DTYP=$G(^TMP("PXRMEXTMP",$J,"DTYP",DNAM))
     106 ;Dialog component display
     107 I (VIEW'=1) D
     108 .I $L(TEMP)<13 S TEMP=TEMP_$J("",12+$L(SEP)-$L(TEMP))_$E(DNAM,1,50)
     109 .E  S TEMP=TEMP_" "_$E(DNAM,1,50)
     110 I VIEW=1 D
     111 .I DTYP]"" S DTXT=$G(^TMP("PXRMEXTMP",$J,"DTXT",DNAM))
     112 .I DTYP="" S DTXT=DNAM
     113 .I DREP'="" S DTXT=DNAM
     114 .I $L(TEMP)<13 S TEMP=TEMP_$J("",12+$L(SEP)-$L(TEMP))_$E(DTXT,1,50)
     115 .E  S TEMP=TEMP_" "_$E(DTXT,1,50)
     116 ;Check for replacements
     117 I $D(^TMP("PXRMEXTMP",$J,"DREPL",DNAM))>0 D
     118 .S TEMP=TEMP_"*"
     119 .S TLEV=$S($E(LEVSEQ,$L(LEVSEQ))=".":$E(LEVSEQ,1,$L(LEVSEQ)-1),1:LEVSEQ)
     120 .S PXRMEXRP(DNAM)=""
     121 .;S ^TMP($J,"PXRMEXREP",TLEV,DNAM)=""
     122 ;Add Type
     123 S TEMP=TEMP_$J("",65-$L(TEMP))_DTYP
     124 ;Exists flag
     125 I DPXRM=0,$$EXISTS^PXRMEXIU(801.41,DNAM) D
     126 .S TEMP=TEMP_$J("",75-$L(TEMP))_"X",DEXIST=1
     127 S ^TMP("PXRMEXLD",$J,NLINE,0)=TEMP
     128 ;
     129 ;Set up selection index
     130 S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)="" Q:DPXRM=1
     131 ;Store the file number, start and stop line in the exchange file.
     132 S ^TMP("PXRMEXLD",$J,"SEL",NSEL)=FILENUM_U_DSTRT_U_DEND_U_DEXIST_U_IND_U_JND
     133 ;Insert additional text lines
     134 I VIEW=1,DREP="" D
     135 .N DSUB,DTXT,FILENUM
     136 .S DSUB=0,FILENUM=8927.1
     137 .F  S DSUB=$O(^TMP("PXRMEXTMP",$J,"DTXT",DNAM,DSUB)) Q:'DSUB  D
     138 ..S DTXT=$G(^TMP("PXRMEXTMP",$J,"DTXT",DNAM,DSUB)),NLINE=NLINE+1
     139 ..S ^TMP("PXRMEXLD",$J,NLINE,0)=$J("",12+$L(SEP))_$E(DTXT,1,50)
     140 ..S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     141 .;TIU template changes
     142 .I $D(PXRMNMCH(FILENUM)),$D(^TMP("PXRMEXTMP",$J,"DTIU",DNAM)) D
     143 ..N TEMP,TNAM,TNNAM
     144 ..S TNAM=""
     145 ..F  S TNAM=$O(^TMP("PXRMEXTMP",$J,"DTIU",DNAM,TNAM)) Q:TNAM=""  D
     146 ...S TNNAM=$G(PXRMNMCH(FILENUM,TNAM)) Q:TNNAM=""
     147 ...S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     148 ...S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     149 ...S TEMP=$J("",12+$L(SEP))_"(TIU template "_TNAM_" copied to "_TNNAM_")"
     150 ...S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=TEMP
     151 ...S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     152 ...S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     153 ...S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     154 ;Insert finding items
     155 I VIEW=2,("element;group"[DTYP),DREP="" D
     156 .N DSUB,FDATA,FILENUM,FLIT,FLONG,FNAME,FOUND,FREP,FTAB,FTYP,TEMP
     157 .;Findings and additional findings
     158 .S DSUB=0,FOUND=0
     159 .F  S DSUB=$O(^TMP("PXRMEXTMP",$J,"DFND",DNAM,DSUB)) Q:'DSUB  D
     160 ..S FNAME=$G(^TMP("PXRMEXTMP",$J,"DFND",DNAM,DSUB)) Q:FNAME=""
     161 ..S FDATA=$G(^TMP("PXRMEXFND",$J,FNAME))
     162 ..S FILENUM=$P(FDATA,U),FTYP=$P(FDATA,U,2) Q:'FILENUM
     163 ..S FREP=$G(PXRMNMCH(FILENUM,FNAME)) I FREP=FNAME S FREP=""
     164 ..S NLINE=NLINE+1,EXIST=$$EXISTS^PXRMEXIU(FILENUM,FNAME),FOUND=1
     165 ..I DSUB=1 S FLIT="Finding: "
     166 ..I DSUB>1 S FLIT="Add. Finding: "
     167 ..S FLONG=0 I $L(FLIT_FNAME_" ("_FTYP_")")>60 S FLONG=1
     168 ..I 'FLONG S FNAME=FLIT_FNAME_" ("_FTYP_")"
     169 ..I FLONG S FNAME=FLIT_FNAME
     170 ..S TEMP=$J("",12+$L(SEP))_$E(FNAME,1,60)_$J("",60-$L(FNAME))
     171 ..I EXIST S TEMP=TEMP_$J("",75-$L(TEMP))_"X"
     172 ..S ^TMP("PXRMEXLD",$J,NLINE,0)=TEMP
     173 ..S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     174 ..I FLONG D
     175 ...S NLINE=NLINE+1
     176 ...S FTAB=$S(DSUB=1:21,1:26)
     177 ...S ^TMP("PXRMEXLD",$J,NLINE,0)=$J("",FTAB)_"("_FTYP_")"
     178 ...S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     179 ..I FREP'="" D
     180 ...S NLINE=NLINE+1
     181 ...S FTAB=$S(DSUB=1:21,1:26)
     182 ...S ^TMP("PXRMEXLD",$J,NLINE,0)=$J("",FTAB)_"(Replaced by "_FREP_")"
     183 ...S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     184 .;If no findings
     185 .I 'FOUND D
     186 ..S NLINE=NLINE+1
     187 ..S ^TMP("PXRMEXLD",$J,NLINE,0)=$J("",12+$L(SEP))_"Finding: *NONE*"
     188 ..S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     189 ;
     190 ;Usage screen
     191 I VIEW=4,DREP="" D
     192 .N DOTHER,DTXT,DTYPE,OTHER,TYPE
     193 .D OTHER(DNAM,.DOTHER) Q:'$D(DOTHER)
     194 .S OTHER=""
     195 .F  S OTHER=$O(DOTHER(OTHER)) Q:OTHER=""  D
     196 ..S TYPE=DOTHER(OTHER),NLINE=NLINE+1,DTYPE="REMINDER DIALOG"
     197 ..I TYPE="G" S DTYPE="DIALOG GROUP"
     198 ..I TYPE="E" S DTYPE="DIALOG ELEMENT"
     199 ..S DTXT="USED BY: "_OTHER_" ("_DTYPE_")"
     200 ..S ^TMP("PXRMEXLD",$J,NLINE,0)=$J("",12+$L(SEP))_DTXT
     201 ..S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     202 Q
     203 ;
     204 ;Save details of dialog components for display
     205DCMP(DLG,LEV) ;
     206 N DDATA,DDLG,DEND,DNAM,DSEQ,DSTRT,IND,JND,LAST,LEVSEQ,NUM
     207 S DSEQ=0,LAST=0
     208 F  S DSEQ=$O(^TMP("PXRMEXTMP",$J,"DMAP",DLG,DSEQ)) Q:'DSEQ  D
     209 .S DDATA=^TMP("PXRMEXTMP",$J,"DMAP",DLG,DSEQ)
     210 .S DNAM=$P(DDATA,U),DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3) Q:DNAM=""
     211 .S IND=$P(DDATA,U,4),JND=$P(DDATA,U,5)
     212 .;Check if this component has been replaced
     213 .S DREP=$G(PXRMNMCH(FILENUM,DNAM)) I DREP=DNAM S DREP=""
     214 .;Save line in workfile
     215 .S NUM=DSEQ
     216 .;S NUM=$S($G(REPL)["R":"."_DSEQ,1:DSEQ)
     217 .I +LEV>0,NUM>0,$E(LEV,$L(LEV))'="." S LEV=LEV_"."
     218 .D DLINE(DNAM,LEV,NUM) Q:DREP'=""
     219 .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAM)) D DCMP(DNAM,LEV_DSEQ_".")
     220 .;Extra line feed
     221 .I LEV="" D
     222 ..S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     223 ..S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     224 I $G(REPL)["R" D
     225 .S NLINE=NLINE+1,^TMP("PXRMEXLD",$J,NLINE,0)=$J("",79)
     226 .S ^TMP("PXRMEXLD",$J,"IDX",NLINE,NSEL)=""
     227 Q
     228 ;
     229 ;Rebuild string in ascending or descending order
     230ORDER(STRING,ORDER) ;
     231 N ARRAY,ITEM,CNT
     232 F CNT=1:1 S ITEM=$P(STRING,",",CNT) Q:'ITEM  S ARRAY(ITEM)=""
     233 K STRING
     234 F CNT=1:1 S ITEM=$O(ARRAY(ITEM),ORDER) Q:'ITEM  D
     235 .S $P(STRING,",",CNT)=ITEM
     236 Q
     237 ;
     238 ;Check if used by other dialogs
     239OTHER(NAME,LIST) ;
     240 N DDATA,DIEN,DNAME,DTYP,IEN
     241 S IEN=$O(^PXRMD(801.41,"B",NAME,0)) Q:'IEN
     242 ;Check if used by other dialogs
     243 I '$D(^PXRMD(801.41,"AD",IEN)) Q
     244 ;Build list of dialogs using this component
     245 S DIEN=0
     246 F  S DIEN=$O(^PXRMD(801.41,"AD",IEN,DIEN)) Q:'DIEN  D
     247 .S DDATA=$G(^PXRMD(801.41,DIEN,0)) Q:DDATA=""
     248 .S DNAME=$P(DDATA,U),DTYP=$P(DDATA,U,4) Q:DNAME=""
     249 .;Include only dialogs that are not part of this reminder dialog
     250 .I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAME)) Q
     251 .S LIST(DNAME)=DTYP
     252 Q
     253 ;
     254 ;Validate sequence numbers
     255VALID(STRING) ;
     256 N CNT,FOUND,OK
     257 S FOUND=0,OK=1
     258 F CNT=1:1 S SEL=$P(STRING,",",CNT) Q:'SEL  D
     259 .;Invalid selection
     260 .I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
     261 ..S OK=0 W $C(7),!,SEL_" is not a valid item number." H 2
     262 .S FOUND=1
     263 Q:OK&FOUND 1
     264 Q 0
     265 ;
     266XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT DIALOG",0))_U_"1:"_VALMCNT
     267 S XQORM("A")="Select Action: "
     268 Q
     269 ;
     270XSEL ;PXRM EXCH SELECT DIALOG validation
     271 N ALL,CNT,ERR,IEN,IND,PXRMDONE,SELECT,SEL
     272 S ALL="",PXRMDONE=0,PXRMBG=$G(VALMBG)
     273 ;Invalid selection
     274 S SELECT=$P(XQORNOD(0),"=",2) I '$$VALID(SELECT) S VALMBCK="R" Q
     275 ;
     276 ;Sort the SELECTION into reverse order
     277 D ORDER(.SELECT,-1)
     278 ;
     279 ;Lock the file
     280 I '$$LOCK^PXRMEXID S VALMBCK="R" Q
     281 ;
     282 ;Install dialog component(s)
     283 S CNT=0
     284 F CNT=1:1 S SEL=$P(SELECT,",",CNT) Q:'SEL  D  Q:PXRMDONE
     285 .D INSCOM^PXRMEXID(SEL,0)
     286 ;
     287 ;Unlock file
     288 D UNLOCK^PXRMEXID
     289 ;
     290 ;
     291 ;Rebuild Workfile
     292 D DISP^PXRMEXLD(PXRMMODE)
     293 ;
     294 ;Refresh
     295 S VALMBCK="R" I $D(PXRMBG) S VALMBG=PXRMBG
     296 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXLI.m

    r613 r623  
    1 PXRMEXLI        ; SLC/PKR - List Manager routines for repository entry install. ;08/08/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;================================================
    5 INSALL  ;Install all components in a repository entry.
    6         N IND,INSTALL
    7         ;Initialize the name change storage.
    8         K PXRMNMCH
    9         S (IND,INSTALL,PXRMDONE)=0
    10         F  S IND=$O(^TMP("PXRMEXLC",$J,"SEL",IND)) Q:(+IND=0)!(PXRMDONE)  D
    11         . D INSCOM(IND,.INSTALL)
    12         ;
    13         ;If anything was installed rebuild the display.
    14         I INSTALL D CDISP^PXRMEXLC(PXRMRIEN)
    15         ;
    16         ;Save the install history in the repository.
    17         D SAVHIST^PXRMEXU1
    18         Q
    19         ;
    20         ;================================================
    21 INSCOM(IND,INSTALL)     ;Install component IND.
    22         ;PXRMRIEN is not passed because this is invoked by the ListManger
    23         ;action to install a repository entry.
    24         N ACTION,ATTR,END,EXISTS,FIELDNUM,FILENUM,IND120,JND120
    25         N NEWNAME,NEWPT01,PT01,RTN,START,TEMP,TEMP0
    26         S TEMP=^TMP("PXRMEXLC",$J,"SEL",IND)
    27         S FILENUM=$P(TEMP,U,1)
    28         S EXISTS=$P(TEMP,U,4)
    29         ;Dialogs use their own installation screen.
    30         I FILENUM=801.41 D  Q
    31         . D START^PXRMEXLD
    32         . S VALMBCK="R"
    33         S IND120=$P(TEMP,U,2)
    34         S JND120=$P(TEMP,U,3)
    35         S TEMP=^PXD(811.8,PXRMRIEN,120,IND120,1,JND120,0)
    36         S START=$P(TEMP,U,2)
    37         S END=$P(TEMP,U,3)
    38         S TEMP=^PXD(811.8,PXRMRIEN,100,START,0)
    39         ;Go to full screen mode.
    40         D FULL^VALM1
    41         I ((FILENUM=0)!(FILENUM=811.4)),DUZ(0)'="@" D  Q
    42         . I FILENUM=0 W !,"Only programmers can install routines."
    43         . I FILENUM=811.4 W !,"Only programmers can install Reminder Computed Findings."
    44         . H 2
    45         . S VALMBCK="R"
    46         I FILENUM=0 D
    47         . D RTNLD^PXRMEXIC(PXRMRIEN,START,END,.ATTR,.RTN)
    48         . D CHECKSUM^PXRMEXCS(.ATTR,START,END)
    49         . S ACTION=$$GETRACT^PXRMEXCF(.ATTR,.NEWNAME,.PXRMNMCH,.RTN,EXISTS)
    50         .;Save what was done for the installation summary.
    51         . S ^TMP("PXRMEXIA",$J,IND,"ROUTINE",ATTR("NAME"),ACTION)=NEWNAME
    52         E  D
    53         .;Make sure we have the .01, some files have .001.
    54         . S TEMP0=$P(TEMP,";",3)
    55         . S FIELDNUM=$P(TEMP0,"~",1)
    56         . I FIELDNUM=.001 S TEMP=^PXD(811.8,PXRMRIEN,100,(START+1),0)
    57         . S PT01=$P(TEMP,"~",2)
    58         . D SETATTR^PXRMEXFI(.ATTR,FILENUM,PT01)
    59         . D CHECKSUM^PXRMEXCS(.ATTR,START,END)
    60         . S ACTION=$$GETFACT^PXRMEXFI(PT01,.ATTR,.NEWPT01,.PXRMNMCH,EXISTS)
    61         .;Save what was done for the installation summary.
    62         . S ^TMP("PXRMEXIA",$J,IND,ATTR("FILE NAME"),ATTR("PT01"),ACTION)=NEWPT01
    63         ;If the ACTION is Quit then quit the entire install.
    64         I ACTION="Q" S PXRMDONE=1 Q
    65         ;If the ACTION is Skip then skip this component.
    66         I ACTION="S" S VALMBCK="R" Q
    67         ;If the ACTION is rePlace then skip this component.
    68         I ACTION="P" S VALMBCK="R" Q
    69         ;Install this component.
    70         I FILENUM=0 D
    71         . S NEWPT01=$G(PXRMNMCH(ATTR("FILE NUMBER"),ATTR("NAME")))
    72         . I NEWPT01="" S NEWPT01=ATTR("NAME")
    73         . D RTNSAVE^PXRMEXIC(.RTN,NEWPT01)
    74         . S INSTALL=1
    75         E  D
    76         . D FILE^PXRMEXIC(PXRMRIEN,EXISTS,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
    77         . S INSTALL=1
    78         S VALMBCK="R"
    79         Q
    80         ;
    81         ;================================================
    82 INSSEL  ;Get a list of components to install.
    83         N IND,INSTALL,VALMBG,VALMLST,VALMY
    84         ;
    85         S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXLC",$J,"IDX",""),-1)
    86         ;
    87         ;Get the list to install.
    88         D EN^VALM2(XQORNOD(0))
    89         ;If there is no list quit.
    90         I '$D(VALMY) Q
    91         ;
    92         ;Initialize the name change storage.
    93         K PXRMNMCH
    94         S (IND,INSTALL)=0
    95         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D INSCOM(IND,.INSTALL)
    96         ;
    97         ;If anything was installed rebuild the display.
    98         I INSTALL D CDISP^PXRMEXLC(PXRMRIEN)
    99         ;
    100         ;Save the install history in the repository.
    101         D SAVHIST^PXRMEXU1
    102         Q
    103         ;
    104         ;================================================
    105 INSTALL ;Install the repository entry PXRMRIEN.
    106         N IEN,IND,VALMY
    107         ;Make sure the component list exists for this entry. PXRMRIEN is
    108         ;set in INSTALL^PXRMEXLR.
    109         I '$D(^PXD(811.8,PXRMRIEN,120)) D CLIST^PXRMEXU1(.PXRMRIEN)
    110         I PXRMRIEN=-1 Q
    111         K ^TMP("PXRMEXIA",$J),^TMP("PXRMEXIAD",$J)
    112         ;Set the install date and time and type.
    113         S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
    114         S ^TMP("PXRMEXIA",$J,"TYPE")="INTERACTIVE"
    115         ;Format the component list for display.
    116         D CDISP^PXRMEXLC(PXRMRIEN)
    117         S VALMCNT=$O(^TMP("PXRMEXLC",$J,"IDX"),-1)
    118         S VALMBCK="R"
    119         D XQORM
    120         Q
    121         ;
    122         ;================================================
    123         ;Exit action added to PXRM EXCH INSTALL MENU
    124 PEXIT   ;PXRM EXCH INSTALL MENU protocol exit code
    125         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    126         ;Reset after page up/down etc
    127         D XQORM
    128         Q
    129         ;
    130         ;================================================
    131 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT COMPONENT",0))_U_"1:"_VALMCNT
    132         S XQORM("A")="Select Action: "
    133         Q
    134         ;
    135         ;================================================
    136 XSEL    ;PXRM EXCH SELECT COMPONENT validation
    137         N CNT,SELECT,SEL,PXRMDONE
    138         S SELECT=$P(XQORNOD(0),"=",2)
    139         I '$$VALID^PXRMEXLD(SELECT) S VALMBCK="R" Q
    140         ;
    141         ;Sort selections into ascending sequence order
    142         D ORDER^PXRMEXLC(.SELECT,1)
    143         ;
    144         K ^TMP("PXRMEXIA",$J),^TMP("PXRMEXIAD",$J)
    145         ;Set the install date and time and type.
    146         S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
    147         S ^TMP("PXRMEXIA",$J,"TYPE")="INTERACTIVE"
    148         ;
    149         ;Install selected component
    150         N INSTALL
    151         S INSTALL=0,CNT=0,PXRMDONE=0
    152         F CNT=1:1 S SEL=$P(SELECT,",",CNT) Q:'SEL  D  Q:PXRMDONE
    153         . D INSCOM(SEL,.INSTALL)
    154         ;
    155         ;If anything was installed rebuild the display.
    156         I INSTALL D CDISP^PXRMEXLC(PXRMRIEN)
    157         ;
    158         ;Save the install history in the repository.
    159         D SAVHIST^PXRMEXU1
    160         ;
    161         ;Clear any renames made in the last session
    162         K PXRMNMCH
    163         Q
     1PXRMEXLI ; SLC/PKR - List Manager routines for repository entry install. ;01/10/2003
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;================================================
     5INSALL ;Install all components in a repository entry.
     6 N IND,INSTALL
     7 K ^TMP("PXRMEXIA",$J)
     8 ;Set the install date and time.
     9 S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
     10 ;Initialize the name change storage.
     11 K PXRMNMCH
     12 S (IND,INSTALL,PXRMDONE)=0
     13 F  S IND=$O(^TMP("PXRMEXLC",$J,"SEL",IND)) Q:(+IND=0)!(PXRMDONE)  D
     14 . D INSCOM(IND,.INSTALL)
     15 ;
     16 ;If anything was installed rebuild the display.
     17 I INSTALL D CDISP^PXRMEXLC(PXRMRIEN)
     18 ;
     19 ;Save the install history in the repository.
     20 D SAVHIST^PXRMEXU1
     21 Q
     22 ;
     23 ;================================================
     24INSCOM(IND,INSTALL) ;Install component IND.
     25 ;PXRMRIEN is not passed because this is invoked by the ListManger
     26 ;action to install a repository entry.
     27 N ACTION,ATTR,END,EXISTS,FIELDNUM,FILENUM,IND120,JND120
     28 N NEWNAME,NEWPT01,PT01,RTN,START,TEMP,TEMP0
     29 S TEMP=^TMP("PXRMEXLC",$J,"SEL",IND)
     30 S FILENUM=$P(TEMP,U,1)
     31 S EXISTS=$P(TEMP,U,4)
     32 ;Dialogs use their own installation screen.
     33 I FILENUM=801.41 D  Q
     34 . D START^PXRMEXLD
     35 . S VALMBCK="R"
     36 S IND120=$P(TEMP,U,2)
     37 S JND120=$P(TEMP,U,3)
     38 S TEMP=^PXD(811.8,PXRMRIEN,120,IND120,1,JND120,0)
     39 S START=$P(TEMP,U,2)
     40 S END=$P(TEMP,U,3)
     41 S TEMP=^PXD(811.8,PXRMRIEN,100,START,0)
     42 ;Go to full screen mode.
     43 D FULL^VALM1
     44 I ((FILENUM=0)!(FILENUM=811.4)),DUZ(0)'="@" D  Q
     45 . I FILENUM=0 W !,"Only programmers can install routines."
     46 . I FILENUM=811.4 W !,"Only programmers can install Reminder Computed Findings."
     47 . H 2
     48 . S VALMBCK="R"
     49 I FILENUM=0 D
     50 . D RTNLD^PXRMEXIC(PXRMRIEN,START,END,.ATTR,.RTN)
     51 . S ACTION=$$GETRACT^PXRMEXCF(.ATTR,.NEWNAME,.PXRMNMCH,.RTN,EXISTS)
     52 .;Save what was done for the installation summary.
     53 . S ^TMP("PXRMEXIA",$J,IND,"ROUTINE",ATTR("NAME"),ACTION)=NEWNAME
     54 E  D
     55 .;Make sure we have the .01, some files have .001.
     56 . S TEMP0=$P(TEMP,";",3)
     57 . S FIELDNUM=$P(TEMP0,"~",1)
     58 . I FIELDNUM=.001 S TEMP=^PXD(811.8,PXRMRIEN,100,(START+1),0)
     59 . S PT01=$P(TEMP,"~",2)
     60 . D SETATTR^PXRMEXFI(.ATTR,FILENUM)
     61 . S ACTION=$$GETFACT^PXRMEXFI(PT01,.ATTR,.NEWPT01,.PXRMNMCH,EXISTS)
     62 .;Save what was done for the installation summary.
     63 . S ^TMP("PXRMEXIA",$J,IND,ATTR("FILE NAME"),ATTR("PT01"),ACTION)=NEWPT01
     64 ;If the ACTION is Quit then quit the entire install.
     65 I ACTION="Q" S PXRMDONE=1 Q
     66 ;If the ACTION is Skip then skip this component.
     67 I ACTION="S" S VALMBCK="R" Q
     68 ;If the ACTION is rePlace then skip this component.
     69 I ACTION="P" S VALMBCK="R" Q
     70 ;Install this component.
     71 I FILENUM=0 D
     72 . S NEWPT01=$G(PXRMNMCH(ATTR("FILE NUMBER"),ATTR("NAME")))
     73 . I NEWPT01="" S NEWPT01=ATTR("NAME")
     74 . D RTNSAVE^PXRMEXIC(.RTN,NEWPT01)
     75 . S INSTALL=1
     76 E  D
     77 . D FILE^PXRMEXIC(PXRMRIEN,EXISTS,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
     78 . S INSTALL=1
     79 S VALMBCK="R"
     80 Q
     81 ;
     82 ;================================================
     83INSSEL ;Get a list of components to install.
     84 N IND,INSTALL,VALMBG,VALMLST,VALMY
     85 ;
     86 S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXLC",$J,"IDX",""),-1)
     87 ;
     88 ;Get the list to install.
     89 D EN^VALM2(XQORNOD(0))
     90 ;If there is no list quit.
     91 I '$D(VALMY) Q
     92 ;
     93 K ^TMP("PXRMEXIA",$J)
     94 ;Set the install date and time.
     95 S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
     96 ;
     97 ;Initialize the name change storage.
     98 K PXRMNMCH
     99 S (IND,INSTALL)=0
     100 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     101 .D INSCOM(IND,.INSTALL)
     102 ;
     103 ;If anything was installed rebuild the display.
     104 I INSTALL D CDISP^PXRMEXLC(PXRMRIEN)
     105 ;
     106 ;Save the install history in the repository.
     107 D SAVHIST^PXRMEXU1
     108 Q
     109 ;
     110 ;================================================
     111INSTALL ;Install the repository entry PXRMRIEN.
     112 N IEN,IND,VALMY
     113 ;Make sure the component list exists for this entry. PXRMRIEN is
     114 ;set in INSTALL^PXRMEXLR.
     115 I '$D(^PXD(811.8,PXRMRIEN,120)) D CLIST^PXRMEXU1(.PXRMRIEN)
     116 I PXRMRIEN=-1 Q
     117 ;Format the component list for display.
     118 D CDISP^PXRMEXLC(PXRMRIEN)
     119 S VALMCNT=$O(^TMP("PXRMEXLC",$J,"IDX"),-1)
     120 S VALMBCK="R"
     121 D XQORM
     122 Q
     123 ;
     124 ;Exit action added to PXRM EXCH INSTALL MENU
     125PEXIT ;PXRM EXCH INSTALL MENU protocol exit code
     126 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     127 ;Reset after page up/down etc
     128 D XQORM
     129 Q
     130 ;
     131XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT COMPONENT",0))_U_"1:"_VALMCNT
     132 S XQORM("A")="Select Action: "
     133 Q
     134 ;
     135XSEL ;PXRM EXCH SELECT COMPONENT validation
     136 N CNT,SELECT,SEL,PXRMDONE
     137 S SELECT=$P(XQORNOD(0),"=",2)
     138 I '$$VALID^PXRMEXLD(SELECT) S VALMBCK="R" Q
     139 ;
     140 ;Sort selections into ascending sequence order
     141 D ORDER^PXRMEXLD(.SELECT,1)
     142 ;
     143 K ^TMP("PXRMEXIA",$J)
     144 ;Set the install date and time.
     145 S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
     146 ;
     147 ;Install selected component
     148 N INSTALL
     149 S INSTALL=0,CNT=0,PXRMDONE=0
     150 F CNT=1:1 S SEL=$P(SELECT,",",CNT) Q:'SEL  D  Q:PXRMDONE
     151 . D INSCOM(SEL,.INSTALL)
     152 ;
     153 ;If anything was installed rebuild the display.
     154 I INSTALL D CDISP^PXRMEXLC(PXRMRIEN)
     155 ;
     156 ;Save the install history in the repository.
     157 D SAVHIST^PXRMEXU1
     158 ;
     159 ;Clear any renames made in the last session
     160 K PXRMNMCH
     161 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXLM.m

    r613 r623  
    1 PXRMEXLM        ; SLC/PKR/PJH - Clinical Reminder Exchange List Manager routines. ;10/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================
    5 CRE     ;Create a packed reminder and store it in the repository.
    6         N RTP,SUCCESS,TMPIND
    7         K VALMHDR
    8         S RTP=$$GETREM^PXRMEXPU("pack")
    9         I +RTP'>0 D  Q
    10         . S VALMHDR(1)="No reminder selected!"
    11         . S VALMBCK="R"
    12         S TMPIND="PXRMEXPR"
    13         D PACK^PXRMEXPR(RTP,TMPIND)
    14         D STOREPR^PXRMEXU2(.SUCCESS,RTP,TMPIND,"REMINDER")
    15         I SUCCESS D
    16         . S VALMHDR(1)="Packed reminder for "_$P(RTP,U,2)
    17         . S VALMHDR(2)="was saved in Exchange File."
    18         . D BLDLIST^PXRMEXLC(1)
    19         E  D
    20         . S VALMHDR(1)="Creation of packed reminder for "_$P(RTP,U,2)
    21         . S VALMHDR(2)="failed; it was not saved!"
    22         S VALMBCK="R"
    23         Q
    24         ;
    25         ;=====================================================
    26 DEFINQ  ;Reminder definition inquiry.
    27         N GBL,IEN,PXRMROOT,VALMCNT
    28         S GBL="^TMP(""PXRMRINQ"",$J)"
    29         S GBL=$NA(@GBL)
    30         S PXRMROOT="^PXD(811.9,"
    31         S IEN=$$SELECT^PXRMINQ(PXRMROOT,"Select Reminder Definition: ","")
    32         S IEN=$P(IEN,U,1)
    33         I IEN=-1 S VALMBCK="R" Q
    34         K ^TMP("PXRMRINQ",$J)
    35         D REMVAR^PXRMINQ(GBL,IEN)
    36         S VALMCNT=$O(^TMP("PXRMRINQ",$J,""),-1)
    37         D EN^VALM("PXRM EX DEFINITION INQUIRY")
    38         K ^TMP("PXRMRINQ",$J)
    39         S VALMBCK="R"
    40         Q
    41         ;
    42         ;=====================================================
    43 ENTRY   ;Entry code
    44         D BLDLIST^PXRMEXLC(0)
    45         D XQORM
    46         Q
    47         ;
    48         ;=====================================================
    49 EXIT    ;Exit code
    50         K ^TMP("PXRMEXDH",$J)
    51         K ^TMP("PXRMEXHF",$J)
    52         K ^TMP("PXRMEXFND",$J)
    53         K ^TMP("PXRMEXIA",$J)
    54         K ^TMP("PXRMEXIAD",$J)
    55         K ^TMP("PXRMEXID",$J)
    56         K ^TMP("PXRMEXIH",$J)
    57         K ^TMP("PXRMEXLC",$J)
    58         K ^TMP("PXRMEXLD",$J)
    59         K ^TMP("PXRMEXLHF",$J)
    60         K ^TMP("PXRMEXLMM",$J)
    61         K ^TMP("PXRMEXLR",$J)
    62         K ^TMP("PXRMEXMH",$J)
    63         K ^TMP("PXRMEXMM",$J)
    64         K ^TMP("PXRMEXRI",$J)
    65         K ^TMP("PXRMEXTMP",$J)
    66         K ^TMP("PXRMEXTXT",$J)
    67         D CLEAN^VALM10
    68         D FULL^VALM1
    69         S VALMBCK="Q"
    70         Q
    71         ;
    72         ;=====================================================
    73 HDR     ; Header code
    74         S VALMHDR(1)="Exchange File Entries."
    75         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    76         Q
    77         ;
    78         ;=====================================================
    79 HELP    ;Help code
    80         ;The following variables have to be newed so that when we return
    81         ;from the help display they will be defined.
    82         N ORU,ORUPRMT,XQORM
    83         D EN^VALM("PXRM EX MAIN HELP")
    84         Q
    85         ;
    86         ;=====================================================
    87 INIT    ;Init
    88         S VALMCNT=0
    89         Q
    90         ;
    91         ;=====================================================
    92 LDHF    ;Load a host file into the repository.
    93         N IND,FILE,PATH,RBL,SUCCESS,TEMP
    94         ;Select the host file to load.
    95         D CLEAR^VALM1
    96         S TEMP=$$GETEHF^PXRMEXHF
    97         I TEMP="" S VALMBCK="R" Q
    98         S PATH=$P(TEMP,U,1)
    99         S FILE=$P(TEMP,U,2)
    100         D LHF^PXRMEXHF(.SUCCESS,PATH,FILE)
    101         S RBL=SUCCESS
    102         I SUCCESS D
    103         . S VALMHDR(1)="Host file "_PATH_FILE_" successfully loaded."
    104         E  D
    105         . S VALMHDR(1)="There were problems loading host file "_PATH_FILE_"."
    106         . S TEMP=""
    107         . S IND=""
    108         . F  S IND=$O(SUCCESS(IND)) Q:+IND=0  D
    109         .. I SUCCESS(IND) S RBL=1 Q
    110         .. I +$O(SUCCESS(IND))=0 S TEMP=TEMP_IND
    111         .. E  S TEMP=TEMP_IND_", "
    112         . S VALMHDR(2)="Entries with problems were "_TEMP_"."
    113         ;Rebuild the list for display.
    114         D BLDLIST^PXRMEXLC(RBL)
    115         S VALMBCK="R"
    116         Q
    117         ;
    118         ;=====================================================
    119 LDMM    ;Load a MailMan message into the repository.
    120         N IND,RBL,TEMP,XMZ
    121         ;Select the MailMan message to load.
    122         D CLEAR^VALM1
    123         S XMZ=$$GETMESSN^PXRMEXMM
    124         I XMZ=-1 W !,"No packed reminder definitions selected/found!" H 2
    125         I +XMZ'>0 S VALMBCK="R" Q
    126         D LMM^PXRMEXMM(.SUCCESS,XMZ)
    127         S RBL=SUCCESS
    128         I SUCCESS D
    129         . S VALMHDR(1)="MailMan message "_XMZ_" successfully loaded."
    130         .;Rebuild the list for display.
    131         . D BLDLIST^PXRMEXLC(1)
    132         E  D
    133         . S VALMHDR(1)="There were problems loading MailMan message "_XMZ_"."
    134         . S TEMP=""
    135         . S IND=""
    136         . F  S IND=$O(SUCCESS(IND)) Q:+IND=0  D
    137         .. I SUCCESS(IND) S RBL=1 Q
    138         .. I +$O(SUCCESS(IND))=0 S TEMP=TEMP_IND
    139         .. E  S TEMP=TEMP_IND_", "
    140         . S VALMHDR(2)="Entries with problems were "_TEMP_"."
    141         ;Rebuild the list for display.
    142         D BLDLIST^PXRMEXLC(RBL)
    143         S VALMBCK="R"
    144         Q
    145         ;
    146         ;=====================================================
    147 LRDEF   ;List the name and print name of all reminder definitions.
    148         N VALMCNT
    149         I $D(^TMP("PXRMEXLD",$J,"VALMCNT")) S VALMCNT=^TMP("PXRMEXLD",$J,"VALMCNT")
    150         E  D
    151         . N ARO,DEFLIST
    152         . S ARO=$$QUERYAO^PXRMLIST
    153         . S ^TMP("PXRMEXLD",$J,"ARO")=ARO
    154         . D RDEF^PXRMLIST(.DEFLIST,ARO)
    155         . M ^TMP("PXRMEXLD",$J)=DEFLIST
    156         . S VALMCNT=DEFLIST("VALMCNT")
    157         I '$G(^TMP("PXRMEXLD",$J,"ARO")) D CHGCAP^VALM("INACTIVE","Inactive")
    158         D EN^VALM("PXRM EX REMINDER LIST")
    159         Q
    160         ;
    161         ;=====================================================
    162 PEXIT   ;PXRM EXCH MENU protocol exit code
    163         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    164         ;Reset after page up/down etc
    165         D XQORM
    166         Q
    167         ;
    168         ;=====================================================
    169 START   ;Main entry point for PXRM EXCHANGE
    170         N PXRMDONE,PXRMNMCH
    171         ;PXRMDONE is set to true if the user enters an action of Quit.
    172         S PXRMDONE=0
    173         ;PXRMNMCH is used to store name change information. If a finding
    174         ;is copied to a new name or is replaced by another finding the
    175         ;information is stored here. It is used when installing definitions
    176         ;or dialogs so they use the new or replaced finding.
    177         N VALMBCK,VALMSG,X,XMZ
    178         S X="IORESET"
    179         D ENDR^%ZISS
    180         D EN^VALM("PXRM EX REMINDER EXCHANGE")
    181         W IORESET
    182         D KILL^%ZISS
    183         Q
    184         ;
    185         ;=====================================================
    186 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT ENTRY",0))_U_"1:"_VALMCNT
    187         S XQORM("A")="Select Action: "
    188         Q
    189         ;
    190         ;=====================================================
    191 XSEL    ;PXRM EXCH SELECT COMPONENT validation
    192         N SEL,PXRMRIEN
    193         S SEL=$P(XQORNOD(0),"=",2)
    194         ;Remove trailing ,
    195         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    196         ;Invalid selection
    197         I SEL["," D  Q
    198         .W $C(7),!,"Only one item number allowed." H 2
    199         .S VALMBCK="R"
    200         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    201         .W $C(7),!,SEL_" is not a valid item number." H 2
    202         .S VALMBCK="R"
    203         ;
    204         ;Get the repository ien.
    205         S PXRMRIEN=^TMP("PXRMEXLR",$J,"SEL",SEL)
    206         ;
    207         ;Full screen mode
    208         D FULL^VALM1
    209         ;
    210         ;Option to Install, Delete or Install History
    211         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,OPTION,X,Y
    212         S DIR(0)="SBM"_U_"IFE:Install Exchange File Entry;"
    213         S DIR(0)=DIR(0)_"DFE:Delete Exchange File Entry;"
    214         S DIR(0)=DIR(0)_"IH:Installation History;"
    215         S DIR("A")="Select Action: "
    216         S DIR("B")="IFE"
    217         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    218         S DIR("??")=U_"D HLP^PXRMEXIX(3)"
    219         D ^DIR
    220         I $D(DIROUT)!$D(DIRUT) S VALMBCK="R" Q
    221         I $D(DTOUT)!$D(DUOUT) S VALMBCK="R" Q
    222         S OPTION=Y
    223         ;
    224         ;Install
    225         I OPTION="IFE" D
    226         .D EN^VALM("PXRM EX LIST COMPONENTS")
    227         .K ^TMP("PXRMEXLC",$J)
    228         ;
    229         I OPTION="DFE" D
    230         .N COUNT,DELLIST,IEN,IND,RELIST,VALMY
    231         .S DELLIST(PXRMRIEN)=""
    232         .D DELETE^PXRMEXU1(.DELLIST)
    233         .;Rebuild the list for List Manager to display.
    234         .K ^TMP("PXRMEXLR",$J)
    235         .D REXL^PXRMLIST("PXRMEXLR")
    236         .S VALMCNT=^TMP("PXRMEXLR",$J,"VALMCNT")
    237         .S VALMHDR(1)="Deleted 1 exchange file entry",VALMHDR(2)=" ",VALMBCK="R"
    238         ;
    239         I OPTION="IH" D START^PXRMEXIH
    240         ;
    241         S VALMBCK="R"
    242         Q
     1PXRMEXLM ; SLC/PKR/PJH - Clinical Reminder Exchange List Manager routines. ;12/22/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================
     5CRE ;Create a packed reminder and store it in the repository.
     6 N RTP,SUCCESS,TMPIND
     7 K VALMHDR
     8 S RTP=$$GETREM^PXRMEXPU("pack")
     9 I +RTP'>0 D  Q
     10 . S VALMHDR(1)="No reminder selected!"
     11 . S VALMBCK="R"
     12 S TMPIND="PXRMEXPR"
     13 D PACK^PXRMEXPR(RTP,TMPIND)
     14 D STOREPR^PXRMEXU2(.SUCCESS,RTP,TMPIND,"REMINDER")
     15 I SUCCESS D
     16 . S VALMHDR(1)="Packed reminder for "_$P(RTP,U,2)
     17 . S VALMHDR(2)="was saved in Exchange File."
     18 . D BLDLIST^PXRMEXLC(1)
     19 E  D
     20 . S VALMHDR(1)="Creation of packed reminder for "_$P(RTP,U,2)
     21 . S VALMHDR(2)="failed; it was not saved!"
     22 S VALMBCK="R"
     23 Q
     24 ;
     25 ;=====================================================
     26DEFINQ ;Reminder definition inquiry.
     27 N GBL,IEN,PXRMROOT,VALMCNT
     28 S GBL="^TMP(""PXRMRINQ"",$J)"
     29 S GBL=$NA(@GBL)
     30 S PXRMROOT="^PXD(811.9,"
     31 S IEN=$$SELECT^PXRMINQ(PXRMROOT,"Select Reminder Definition: ","")
     32 S IEN=$P(IEN,U,1)
     33 I IEN=-1 S VALMBCK="R" Q
     34 K ^TMP("PXRMRINQ",$J)
     35 D REMVAR^PXRMINQ(GBL,IEN)
     36 S VALMCNT=$O(^TMP("PXRMRINQ",$J,""),-1)
     37 D EN^VALM("PXRM EX DEFINITION INQUIRY")
     38 K ^TMP("PXRMRINQ",$J)
     39 S VALMBCK="R"
     40 Q
     41 ;
     42 ;=====================================================
     43EN ;Main entry point for PXRM EXCHANGE
     44 N PXRMDONE,PXRMNMCH
     45 ;PXRMDONE is set to true if the user enters an action of Quit.
     46 S PXRMDONE=0
     47 ;PXRMNMCH is used to store name change information. If a finding
     48 ;is copied to a new name or is replaced by another finding the
     49 ;information is stored here. It is used when installing definitions
     50 ;or dialogs so they use the new or replaced finding.
     51 N VALMBCK,VALMSG,X,XMZ
     52 S X="IORESET"
     53 D ENDR^%ZISS
     54 D BLDLIST^PXRMEXLC(0)
     55 D EN^VALM("PXRM EX REMINDER EXCHANGE")
     56 W IORESET
     57 D KILL^%ZISS
     58 Q
     59 ;
     60 ;=====================================================
     61ENTRY ;Entry code
     62 D XQORM
     63 Q
     64 ;
     65 ;=====================================================
     66EXIT ;Exit code
     67 K ^TMP("PXRMEXDH",$J)
     68 K ^TMP("PXRMEXHF",$J)
     69 K ^TMP("PXRMEXFND",$J)
     70 K ^TMP("PXRMEXIA",$J)
     71 K ^TMP("PXRMEXID",$J)
     72 K ^TMP("PXRMEXIH",$J)
     73 K ^TMP("PXRMEXLC",$J)
     74 K ^TMP("PXRMEXLD",$J)
     75 K ^TMP("PXRMEXLHF",$J)
     76 K ^TMP("PXRMEXLMM",$J)
     77 K ^TMP("PXRMEXLR",$J)
     78 K ^TMP("PXRMEXMH",$J)
     79 K ^TMP("PXRMEXMM",$J)
     80 K ^TMP("PXRMEXRI",$J)
     81 K ^TMP("PXRMEXTMP",$J)
     82 K ^TMP("PXRMEXTXT",$J)
     83 D CLEAN^VALM10
     84 D FULL^VALM1
     85 S VALMBCK="Q"
     86 Q
     87 ;
     88 ;=====================================================
     89HDR ; Header code
     90 S VALMHDR(1)="Exchange File Entries."
     91 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     92 Q
     93 ;
     94 ;=====================================================
     95HELP ;Help code
     96 ;The following variables have to be newed so that when we return
     97 ;from the help display they will be defined.
     98 N ORU,ORUPRMT,XQORM
     99 D EN^VALM("PXRM EX MAIN HELP")
     100 Q
     101 ;
     102 ;=====================================================
     103INIT ;Init
     104 S VALMCNT=0
     105 Q
     106 ;
     107 ;=====================================================
     108LDHF ;Load a host file into the repository.
     109 N IND,FILE,PATH,RBL,SUCCESS,TEMP
     110 ;Select the host file to load.
     111 D CLEAR^VALM1
     112 S TEMP=$$GETEHF^PXRMEXHF
     113 I TEMP="" S VALMBCK="R" Q
     114 S PATH=$P(TEMP,U,1)
     115 S FILE=$P(TEMP,U,2)
     116 D LHF^PXRMEXHF(.SUCCESS,PATH,FILE)
     117 S RBL=SUCCESS
     118 I SUCCESS D
     119 . S VALMHDR(1)="Host file "_PATH_FILE_" successfully loaded."
     120 E  D
     121 . S VALMHDR(1)="There were problems loading host file "_PATH_FILE_"."
     122 . S TEMP=""
     123 . S IND=""
     124 . F  S IND=$O(SUCCESS(IND)) Q:+IND=0  D
     125 .. I SUCCESS(IND) S RBL=1 Q
     126 .. I +$O(SUCCESS(IND))=0 S TEMP=TEMP_IND
     127 .. E  S TEMP=TEMP_IND_", "
     128 . S VALMHDR(2)="Entries with problems were "_TEMP_"."
     129 ;Rebuild the list for display.
     130 D BLDLIST^PXRMEXLC(RBL)
     131 S VALMBCK="R"
     132 Q
     133 ;
     134 ;=====================================================
     135LDMM ;Load a MailMan message into the repository.
     136 N IND,RBL,TEMP,XMZ
     137 ;Select the MailMan message to load.
     138 D CLEAR^VALM1
     139 S XMZ=$$GETMESSN^PXRMEXMM
     140 I XMZ=-1 W !,"No packed reminder definitions selected/found!" H 2
     141 I +XMZ'>0 S VALMBCK="R" Q
     142 D LMM^PXRMEXMM(.SUCCESS,XMZ)
     143 S RBL=SUCCESS
     144 I SUCCESS D
     145 . S VALMHDR(1)="MailMan message "_XMZ_" successfully loaded."
     146 .;Rebuild the list for display.
     147 . D BLDLIST^PXRMEXLC(1)
     148 E  D
     149 . S VALMHDR(1)="There were problems loading MailMan message "_XMZ_"."
     150 . S TEMP=""
     151 . S IND=""
     152 . F  S IND=$O(SUCCESS(IND)) Q:+IND=0  D
     153 .. I SUCCESS(IND) S RBL=1 Q
     154 .. I +$O(SUCCESS(IND))=0 S TEMP=TEMP_IND
     155 .. E  S TEMP=TEMP_IND_", "
     156 . S VALMHDR(2)="Entries with problems were "_TEMP_"."
     157 ;Rebuild the list for display.
     158 D BLDLIST^PXRMEXLC(RBL)
     159 S VALMBCK="R"
     160 Q
     161 ;
     162 ;=====================================================
     163LRDEF ;List the name and print name of all reminder definitions.
     164 N VALMCNT
     165 I $D(^TMP("PXRMEXLD",$J,"VALMCNT")) S VALMCNT=^TMP("PXRMEXLD",$J,"VALMCNT")
     166 E  D
     167 . N ARO,DEFLIST
     168 . S ARO=$$QUERYAO^PXRMLIST
     169 . S ^TMP("PXRMEXLD",$J,"ARO")=ARO
     170 . D RDEF^PXRMLIST(.DEFLIST,ARO)
     171 . M ^TMP("PXRMEXLD",$J)=DEFLIST
     172 . S VALMCNT=DEFLIST("VALMCNT")
     173 I '$G(^TMP("PXRMEXLD",$J,"ARO")) D CHGCAP^VALM("INACTIVE","Inactive")
     174 D EN^VALM("PXRM EX REMINDER LIST")
     175 Q
     176 ;
     177 ;=====================================================
     178PEXIT ;PXRM EXCH MENU protocol exit code
     179 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     180 ;Reset after page up/down etc
     181 D XQORM
     182 Q
     183 ;
     184XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT ENTRY",0))_U_"1:"_VALMCNT
     185 S XQORM("A")="Select Action: "
     186 Q
     187 ;
     188XSEL ;PXRM EXCH SELECT COMPONENT validation
     189 N SEL,PXRMRIEN
     190 S SEL=$P(XQORNOD(0),"=",2)
     191 ;Remove trailing ,
     192 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     193 ;Invalid selection
     194 I SEL["," D  Q
     195 .W $C(7),!,"Only one item number allowed." H 2
     196 .S VALMBCK="R"
     197 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     198 .W $C(7),!,SEL_" is not a valid item number." H 2
     199 .S VALMBCK="R"
     200 ;
     201 ;Get the repository ien.
     202 S PXRMRIEN=^TMP("PXRMEXLR",$J,"IDX",SEL,SEL)
     203 ;
     204 ;Full screen mode
     205 D FULL^VALM1
     206 ;
     207 ;Option to Install, Delete or Install History
     208 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,OPTION,X,Y
     209 S DIR(0)="SBM"_U_"IFE:Install Exchange File Entry;"
     210 S DIR(0)=DIR(0)_"DFE:Delete Exchange File Entry;"
     211 S DIR(0)=DIR(0)_"IH:Installation History;"
     212 S DIR("A")="Select Action: "
     213 S DIR("B")="IFE"
     214 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     215 S DIR("??")=U_"D HLP^PXRMEXIX(3)"
     216 D ^DIR
     217 I $D(DIROUT)!$D(DIRUT) S VALMBCK="R" Q
     218 I $D(DTOUT)!$D(DUOUT) S VALMBCK="R" Q
     219 S OPTION=Y
     220 ;
     221 ;Install
     222 I OPTION="IFE" D
     223 .D EN^VALM("PXRM EX LIST COMPONENTS")
     224 .K ^TMP("PXRMEXLC",$J)
     225 ;
     226 I OPTION="DFE" D
     227 .N COUNT,DELLIST,IEN,IND,RELIST,VALMY
     228 .S DELLIST(PXRMRIEN)=""
     229 .D DELETE^PXRMEXU1(.DELLIST)
     230 .;Rebuild the list for List Manager to display.
     231 .K ^TMP("PXRMEXLR",$J)
     232 .D RE^PXRMLIST(.RELIST,.IEN)
     233 .M ^TMP("PXRMEXLR",$J)=RELIST
     234 .S VALMCNT=RELIST("VALMCNT")
     235 .F IND=1:1:VALMCNT D
     236 ..S ^TMP("PXRMEXLR",$J,"IDX",IND,IND)=IEN(IND)
     237 .;
     238 .S VALMHDR(1)="Deleted 1 exchange file entry",VALMHDR(2)=" ",VALMBCK="R"
     239 ;
     240 I OPTION="IH" D
     241 .N HISLIST,VALMCNT
     242 .S HISLIST(SEL)=""
     243 .D HISTLIST^PXRMEXLC(.HISLIST,.VALMCNT)
     244 .D EN^VALM("PXRM EX INSTALLATION HISTORY")
     245 .K ^TMP("PXRMEXIH",$J)
     246 ;
     247 S VALMBCK="R"
     248 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXLR.m

    r613 r623  
    1 PXRMEXLR        ; SLC/PKR/PJH - List Manager routines for existing repository entries. ;07/30/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;==================================================
    4 CHF     ;Create a host file containing repository entries.
    5         N IND,FILE,LENH2,PATH,SUCCESS,TEMP,VALMY
    6         ;Get the list to store.
    7         D EN^VALM2(XQORNOD(0))
    8         ;If there is no list quit.
    9         I '$D(VALMY) Q
    10         ;Get the host file to use.
    11         D CLEAR^VALM1
    12         S TEMP=$$GETHFS^PXRMEXHF
    13         I TEMP=0 S VALMBCK="R" Q
    14         S PATH=$P(TEMP,U,1)
    15         S FILE=$P(TEMP,U,2)
    16         D CHF^PXRMEXHF(.SUCCESS,.VALMY,PATH,FILE)
    17         S VALMHDR(1)="Successfully stored entries"
    18         S VALMHDR(2)="Failed to store entries"
    19         S LENH2=$L(VALMHDR(2))
    20         S IND=""
    21         F  S IND=$O(SUCCESS(IND)) Q:+IND=0  D
    22         . I SUCCESS(IND) S VALMHDR(1)=VALMHDR(1)_" "_IND
    23         . E  S VALMHDR(2)=VALMHDR(2)_" "_IND
    24         I $L(VALMHDR(2))=LENH2 K VALMHDR(2)
    25         S VALMBCK="R"
    26         Q
    27         ;
    28         ;==================================================
    29 CMM     ;Create a MailMan message containing packed reminders.
    30         N SUCCESS,TEMP,VALMY
    31         ;Get the list to store.
    32         D EN^VALM2(XQORNOD(0))
    33         ;If there is no list quit.
    34         I '$D(VALMY) Q
    35         ;Get a new message number to store the entries in.
    36         D CMM^PXRMEXMM(.SUCCESS,.VALMY)
    37         I $D(SUCCESS("XMZ")) S VALMHDR(1)="Successfully stored entries in message "_SUCCESS("XMZ")_"."
    38         E  S VALMHDR(1)="Failed to store entries"
    39         S VALMBCK="R"
    40         Q
    41         ;
    42         ;==================================================
    43 DELETE  ;Get a list of repository entries and delete them.
    44         N COUNT,DELLIST,IEN,IND,RELIST,VALMY
    45         ;Get the list to delete.
    46         D MIENLIST(.DELLIST)
    47         S COUNT=+$G(DELLIST("COUNT"))
    48         I COUNT=0 Q
    49         D DELETE^PXRMEXU1(.DELLIST)
    50         ;Rebuild the list for List Manager to display.
    51         K ^TMP("PXRMEXLR",$J)
    52         D REXL^PXRMLIST("PXRMEXLR")
    53         ;
    54         S VALMHDR(1)="Deleted "_DELLIST("COUNT")_" Exchange File"
    55         I COUNT>1 S VALMHDR(1)=VALMHDR(1)_" entries."
    56         I COUNT=1 S VALMHDR(1)=VALMHDR(1)_" entry."
    57         I COUNT=0 S VALMHDR(1)="No entries selected."
    58         S VALMHDR(2)=" "
    59         S VALMBCK="R"
    60         Q
    61         ;
    62         ;==================================================
    63 EXIT    ; Exit code
    64         D CLEAN^VALM10
    65         D FULL^VALM1
    66         S VALMBCK="R"
    67         K ^TMP("PXRMEXLR",$J)
    68         Q
    69         ;
    70         ;==================================================
    71 INSTALL ;Get a list of repository entries and install them.
    72         N IND,PXRMRIEN,VALMY
    73         D EN^VALM2(XQORNOD(0))
    74         ;If there is no list quit.
    75         I '$D(VALMY) Q
    76         ;PXRMDONE is newed in PXRMEXLM
    77         S PXRMDONE=0
    78         S IND=""
    79         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    80         .;Get the repository ien.
    81         . S PXRMRIEN=^TMP("PXRMEXLR",$J,"SEL",IND)
    82         .;The list template calls INSTALL^PXRMEXLI
    83         . D EN^VALM("PXRM EX LIST COMPONENTS")
    84         . K ^TMP("PXRMEXLC",$J)
    85         Q
    86         ;
    87         ;==================================================
    88 HDR     ; Header code
    89         S VALMHDR(1)=""
    90         D CHGCAP^VALM("RNAME","Reminder Name")
    91         D CHGCAP^VALM("PNAME","Date Loaded")
    92         Q
    93         ;
    94         ;==================================================
    95 HELP    ; Help code
    96         S X="?" D DISP^XQORM1 W !!
    97         Q
    98         ;
    99         ;==================================================
    100 MIENLIST(LIST)  ;Get a list of List Manager repository entries and turn it
    101         ;into iens.
    102         N COUNT,IEN,VALMY
    103         D EN^VALM2(XQORNOD(0))
    104         ;If there is no list quit.
    105         I '$D(VALMY) Q
    106         S COUNT=0
    107         S IND=""
    108         F  S IND=$O(VALMY(IND)) Q:+IND=0  D
    109         . S COUNT=COUNT+1
    110         . ;S IEN=^TMP("PXRMEXLR",$J,"IDX",IND,IND)
    111         . S IEN=^TMP("PXRMEXLR",$J,"SEL",IND)
    112         . S LIST(IEN)=""
    113         S LIST("COUNT")=COUNT
    114         Q
    115         ;
    116         ;==================================================
    117 PEXIT   ;PXRM EXCH INSTALLATION MENU protocol exit code
    118         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    119         Q
    120         ;
     1PXRMEXLR ; SLC/PKR/PJH - List Manager routines for existing repository entries. ;01/10/2003
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;==================================================
     4CHF ;Create a host file containing repository entries.
     5 N IND,FILE,LENH2,PATH,SUCCESS,TEMP,VALMY
     6 ;Get the list to store.
     7 D EN^VALM2(XQORNOD(0))
     8 ;If there is no list quit.
     9 I '$D(VALMY) Q
     10 ;Get the host file to use.
     11 D CLEAR^VALM1
     12 S TEMP=$$GETHFS^PXRMEXHF
     13 I TEMP=0 S VALMBCK="R" Q
     14 S PATH=$P(TEMP,U,1)
     15 S FILE=$P(TEMP,U,2)
     16 D CHF^PXRMEXHF(.SUCCESS,.VALMY,PATH,FILE)
     17 S VALMHDR(1)="Successfully stored entries"
     18 S VALMHDR(2)="Failed to store entries"
     19 S LENH2=$L(VALMHDR(2))
     20 S IND=""
     21 F  S IND=$O(SUCCESS(IND)) Q:+IND=0  D
     22 . I SUCCESS(IND) S VALMHDR(1)=VALMHDR(1)_" "_IND
     23 . E  S VALMHDR(2)=VALMHDR(2)_" "_IND
     24 I $L(VALMHDR(2))=LENH2 K VALMHDR(2)
     25 S VALMBCK="R"
     26 Q
     27 ;
     28 ;==================================================
     29CMM ;Create a MailMan message containing packed reminders.
     30 N SUCCESS,TEMP,VALMY
     31 ;Get the list to store.
     32 D EN^VALM2(XQORNOD(0))
     33 ;If there is no list quit.
     34 I '$D(VALMY) Q
     35 ;Get a new message number to store the entries in.
     36 D CMM^PXRMEXMM(.SUCCESS,.VALMY)
     37 I $D(SUCCESS("XMZ")) S VALMHDR(1)="Successfully stored entries in message "_SUCCESS("XMZ")_"."
     38 E  S VALMHDR(1)="Failed to store entries"
     39 S VALMBCK="R"
     40 Q
     41 ;
     42 ;==================================================
     43DELETE ;Get a list of repository entries and delete them.
     44 N COUNT,DELLIST,IEN,IND,RELIST,VALMY
     45 ;Get the list to delete.
     46 D MIENLIST(.DELLIST)
     47 S COUNT=+$G(DELLIST("COUNT"))
     48 I COUNT=0 Q
     49 D DELETE^PXRMEXU1(.DELLIST)
     50 ;Rebuild the list for List Manager to display.
     51 K ^TMP("PXRMEXLR",$J)
     52 D RE^PXRMLIST(.RELIST,.IEN)
     53 M ^TMP("PXRMEXLR",$J)=RELIST
     54 S VALMCNT=RELIST("VALMCNT")
     55 F IND=1:1:VALMCNT S ^TMP("PXRMEXLR",$J,"IDX",IND,IND)=IEN(IND)
     56 ;
     57 S VALMHDR(1)="Deleted "_DELLIST("COUNT")_" Exchange File"
     58 I COUNT>1 S VALMHDR(1)=VALMHDR(1)_" entries."
     59 I COUNT=1 S VALMHDR(1)=VALMHDR(1)_" entry."
     60 I COUNT=0 S VALMHDR(1)="No entries selected."
     61 S VALMHDR(2)=" "
     62 S VALMBCK="R"
     63 Q
     64 ;
     65 ;==================================================
     66DELHIST ;Get a list of repository installation entries and delete them.
     67 ;Save the original list, it contains the selected repository entries.
     68 N VALMYO
     69 M VALMYO=VALMY
     70 N IHIND,IND,RIEN,TEMP,VALMY
     71 N VALMBG,VALMLST
     72 ;
     73 S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXIH",$J,"IDX",""),-1)
     74 ;Get the list to delete.
     75 D EN^VALM2(XQORNOD(0))
     76 ;If there is no list quit.
     77 I '$D(VALMY) Q
     78 S IND=""
     79 F  S IND=$O(VALMY(IND)) Q:IND=""  D
     80 . S TEMP=^TMP("PXRMEXIH",$J,"SEL",IND)
     81 . S RIEN=$P(TEMP,U,1)
     82 . S IHIND=$P(TEMP,U,2)
     83 . D DELHIST^PXRMEXU1(RIEN,IHIND)
     84 ;Rebuild the display list.
     85 D HISTLIST^PXRMEXLC(.VALMYO,.VALMCNT)
     86 S VALMBCK="R"
     87 Q
     88 ;
     89 ;==================================================
     90EXIT ; Exit code
     91 D CLEAN^VALM10
     92 D FULL^VALM1
     93 S VALMBCK="R"
     94 K ^TMP("PXRMEXLR",$J)
     95 Q
     96 ;
     97 ;==================================================
     98IH ;Get a list of repository entries and show their installation history.
     99 N VALMCNT,VALMY
     100 D EN^VALM2(XQORNOD(0))
     101 ;If there is no list quit.
     102 I '$D(VALMY) Q
     103 ;Build a history list.
     104 D HISTLIST^PXRMEXLC(.VALMY,.VALMCNT)
     105 D EN^VALM("PXRM EX INSTALLATION HISTORY")
     106 K ^TMP("PXRMEXIH",$J)
     107 S VALMBCK="R"
     108 Q
     109 ;
     110 ;==================================================
     111INDETAIL ;Output the details of an installation.
     112 N VALMBG,VALMCNT,VALMHDR,VALMLST,VALMY
     113 S VALMBG=1,VALMLST=+$O(^TMP("PXRMEXIH",$J,"IDX",""),-1)
     114 ;Get the list to display.
     115 D EN^VALM2(XQORNOD(0))
     116 ;If there is no list quit.
     117 I '$D(VALMY) Q
     118 D INDISP(.VALMY)
     119 Q
     120 ;
     121 ;==================================================
     122INDISP(ARRAY) ;Display details list
     123 N ACTION,CMPNT,DI,DP,ENTRY,IHIND,IND,INDEX,JND,KND
     124 N NAME,NEWNAME,NLINE,RIEN,TEMP
     125 K ^TMP("PXRMEXID",$J)
     126 ;If there are no items then quit.
     127 I '$D(ARRAY) Q
     128 S (IND,NLINE)=0
     129 F  S IND=$O(ARRAY(IND)) Q:IND=""  D
     130 . S TEMP=^TMP("PXRMEXIH",$J,"SEL",IND)
     131 . S RIEN=$P(TEMP,U,1)
     132 . S IHIND=$P(TEMP,U,2)
     133 . S TEMP=^PXD(811.8,RIEN,0)
     134 . S ENTRY=$E($P(TEMP,U,1),1,38)
     135 . S ENTRY=$$LJ^XLFSTR(ENTRY,38," ")
     136 . S DP=$$FMTE^XLFDT($P(TEMP,U,3),"5Z")
     137 . S DI=$$FMTE^XLFDT(^PXD(811.8,RIEN,130,IHIND,0),"5Z")
     138 . I NLINE>1 D
     139 .. S NLINE=NLINE+1
     140 .. S ^TMP("PXRMEXID",$J,NLINE,0)="------------------------------------------------------------------------------"
     141 . S NLINE=NLINE+1
     142 . S ^TMP("PXRMEXID",$J,NLINE,0)=ENTRY_" "_DP_"  "_DI
     143 .;Write the header line here.
     144 . S NLINE=NLINE+1
     145 . S ^TMP("PXRMEXID",$J,NLINE,0)="     Component                         Action  New Name"
     146 . S CMPNT=""
     147 . S JND=0
     148 . F  S JND=$O(^PXD(811.8,RIEN,130,IHIND,1,JND)) Q:JND=""  D
     149 .. S TEMP=^PXD(811.8,RIEN,130,IHIND,1,JND,0)
     150 .. I $P(TEMP,U,2)'=CMPNT D
     151 ... S NLINE=NLINE+1
     152 ... S ^TMP("PXRMEXID",$J,NLINE,0)=" "
     153 ... S CMPNT=$P(TEMP,U,2)
     154 ... S NLINE=NLINE+1
     155 ... S ^TMP("PXRMEXID",$J,NLINE,0)=CMPNT
     156 .. S INDEX=$$RJ^XLFSTR($P(TEMP,U,1),4," ")
     157 .. S NAME=$E($P(TEMP,U,3),1,36)
     158 .. S NAME=$$LJ^XLFSTR(NAME,36," ")
     159 .. S ACTION=$P(TEMP,U,4)
     160 .. S NEWNAME=$E($P(TEMP,U,5),1,36)
     161 .. S NEWNAME=$$LJ^XLFSTR(NEWNAME,36," ")
     162 .. S NLINE=NLINE+1
     163 .. S ^TMP("PXRMEXID",$J,NLINE,0)=INDEX_" "_NAME_" "_ACTION_"    "_NEWNAME
     164 ..;If there are Additional Details add them to the display.
     165 .. S KND=0
     166 .. F  S KND=$O(^PXD(811.8,RIEN,130,IHIND,1,JND,1,KND)) Q:KND=""  D
     167 ... S NLINE=NLINE+1
     168 ... S ^TMP("PXRMEXID",$J,NLINE,0)=^PXD(811.8,RIEN,130,IHIND,1,JND,1,KND,0)
     169 . S NLINE=NLINE+1
     170 . S ^TMP("PXRMEXID",$J,NLINE,0)=" "
     171 S VALMHDR(1)=^PXD(811.8,RIEN,0)_"  "_^TMP("PXRMEXID",$J,1,0)
     172 S VALMCNT=NLINE
     173 D EN^VALM("PXRM EX INSTALLATION DETAIL")
     174 K ^TMP("PXRMEXID",$J)
     175 S VALMBCK="R"
     176 Q
     177 ;
     178 ;==================================================
     179INSTALL ;Get a list of repository entries and install them.
     180 N IND,PXRMRIEN,VALMY
     181 D EN^VALM2(XQORNOD(0))
     182 ;If there is no list quit.
     183 I '$D(VALMY) Q
     184 ;PXRMDONE is newed in PXRMEXLM
     185 S PXRMDONE=0
     186 S IND=""
     187 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     188 .;Get the repository ien.
     189 . S PXRMRIEN=^TMP("PXRMEXLR",$J,"IDX",IND,IND)
     190 .;The list template calls INSTALL^PXRMEXLI
     191 . D EN^VALM("PXRM EX LIST COMPONENTS")
     192 . K ^TMP("PXRMEXLC",$J)
     193 Q
     194 ;
     195 ;==================================================
     196HDR ; Header code
     197 S VALMHDR(1)=""
     198 D CHGCAP^VALM("RNAME","Reminder Name")
     199 D CHGCAP^VALM("PNAME","Date Loaded")
     200 Q
     201 ;
     202 ;==================================================
     203HELP ; Help code
     204 S X="?" D DISP^XQORM1 W !!
     205 Q
     206 ;
     207 ;==================================================
     208IS ;Get a list of packed reminders and print the installation summary.
     209 N VALMY
     210 D EN^VALM2(XQORNOD(0))
     211 ;If there is no list quit.
     212 I '$D(VALMY) Q
     213 Q
     214 ;
     215 ;==================================================
     216MIENLIST(LIST) ;Get a list of List Manager repository entries and turn it
     217 ;into iens.
     218 N COUNT,IEN,VALMY
     219 D EN^VALM2(XQORNOD(0))
     220 ;If there is no list quit.
     221 I '$D(VALMY) Q
     222 S COUNT=0
     223 S IND=""
     224 F  S IND=$O(VALMY(IND)) Q:+IND=0  D
     225 . S COUNT=COUNT+1
     226 . S IEN=^TMP("PXRMEXLR",$J,"IDX",IND,IND)
     227 . S LIST(IEN)=""
     228 S LIST("COUNT")=COUNT
     229 Q
     230 ;
     231 ;==================================================
     232PEXIT ;PXRM EXCH INSTALLATION MENU protocol exit code
     233 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     234 ;Reset after page up/down etc
     235 D XQORM
     236 Q
     237 ;
     238 ;==================================================
     239XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM EXCH SELECT HISTORY",0))_U_"1:"_VALMCNT
     240 S XQORM("A")="Select Action: "
     241 Q
     242 ;
     243 ;==================================================
     244XSEL ;PXRM EXCH SELECT HISTORY validation
     245 N ARRAY,CNT,SELECT,SEL
     246 S SELECT=$P(XQORNOD(0),"=",2)
     247 I '$$VALID^PXRMEXLD(SELECT) S VALMBCK="R" Q
     248 ;Build array of selected items
     249 F CNT=1:1 S SEL=$P(SELECT,",",CNT) Q:'SEL  D
     250 .S ARRAY(SEL)=""
     251 ;
     252 ;Display Selected Histories
     253 D INDISP(.ARRAY)
     254 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXPR.m

    r613 r623  
    1 PXRMEXPR        ; SLC/PKR/PJH - Routines to create packed reminder definitions. ;12/12/2006
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;===============================================================
    4 ADDFILE(FLIST,ROOT,FILENAME)    ;Add a file to the list of finding files.
    5         N DIC,DO,FILENUM
    6         S DIC="^"_ROOT
    7         K DO
    8         D DO^DIC1
    9         S FILENUM=+DO(2)
    10         S FILENAME=$P(DO,U,1)
    11         S FLIST(FILENAME)=FILENUM
    12         Q
    13         ;
    14         ;===============================================================
    15 ADDFIND(FLIST,FILENAME,IEN)     ;Add a finding to the list of findings.
    16         S FLIST(FILENAME,"F",IEN)=""
    17         ;Make sure categories are included for any health factors and they
    18         ;come first in the list of health factors.
    19         I FILENAME="HEALTH FACTORS" D
    20         . N CAT
    21         . S CAT=$P(^AUTTHF(IEN,0),U,3)
    22         . S FLIST(FILENAME,"C",CAT)=""
    23         Q
    24         ;
    25         ;===============================================================
    26 BLDSPON(RIEN,FINDLIST,SPONLIST) ;Build the sponsor list.
    27         N DIEN,IEN,IND,IND0
    28         ;Start with the definition.
    29         D GETSPON(811.9,RIEN,.SPONLIST)
    30         ;If there is a dialog add it.
    31         ;S DIEN=+$P($G(^PXD(811.9,RIEN,51)),U,1)
    32         ;I DIEN>0 D GETSPON(801.41,DIEN,.SPONLIST)
    33         ;Go through the finding list to find additional sponsors.
    34         S IND=""
    35         F  S IND=$O(FINDLIST(IND)) Q:IND=""  D
    36         . S FILENUM=FINDLIST(IND)
    37         . I (FILENUM'<800)&(FILENUM'>811.9) D
    38         .. S IND0=""
    39         .. F  S IND0=$O(FINDLIST(IND,IND0)) Q:IND0=""  D
    40         ... S IEN=""
    41         ... F  S IEN=+$O(FINDLIST(IND,IND0,IEN)) Q:IEN=0  D
    42         .... D GETSPON(FILENUM,IEN,.SPONLIST)
    43         ;Add any associated sponsors to the begining of the list.
    44         S IND=""
    45         F  S IND=$O(SPONLIST("S",IND)) Q:IND=""  D
    46         . S IND0=0
    47         . F  S IND0=+$O(^PXRMD(811.6,IND,2,IND0)) Q:IND0=0  D
    48         .. S IEN=+^PXRMD(811.6,IND,2,IND0,0)
    49         .. S SPONLIST("A",IEN)=""
    50         Q
    51         ;
    52         ;===============================================================
    53 BLDTEXT(TMPIND) ;Combine the source information and the user's input into the
    54         ;"TEXT" array.
    55         N IC,IND
    56         S (IC,IND)=0
    57         F  S IC=$O(^TMP(TMPIND,$J,"SRC",IC)) Q:+IC=0  D
    58         . S IND=IND+1
    59         . S ^TMP(TMPIND,$J,"TEXT",1,IND)=^TMP(TMPIND,$J,"SRC",IC)
    60         ;
    61         S IC=0
    62         F  S IC=$O(^TMP(TMPIND,$J,"TXT",1,IC)) Q:+IC=0  D
    63         . S IND=IND+1
    64         . S ^TMP(TMPIND,$J,"TEXT",1,IND)=^TMP(TMPIND,$J,"TXT",1,IC,0)
    65         Q
    66         ;
    67         ;===============================================================
    68 GETDFIND(RIEN,FLIST)    ;Build the list of definition findings.
    69         ;FLIST has the format FLIST(FILENAME)=file number, and for each
    70         ;finding from the file FLIST(FILENAME,"F",IEN)="". For Health Factors
    71         ;category entries are FLIST(FILENAME,"C",IEN)="".
    72         N FILENAME,IEN,ROOT
    73         S ROOT=""
    74         F  S ROOT=$O(^PXD(811.9,RIEN,20,"E",ROOT)) Q:ROOT=""  D
    75         . D ADDFILE(.FLIST,ROOT,.FILENAME)
    76         . S IEN=0
    77         . F  S IEN=$O(^PXD(811.9,RIEN,20,"E",ROOT,IEN)) Q:+IEN=0  D
    78         .. D ADDFIND(.FLIST,FILENAME,IEN)
    79         Q
    80         ;
    81         ;===============================================================
    82 GETSPON(FILENUM,IEN,SPONLIST)   ;Add sponsors to the sponsor list.
    83         N ENTRY,ROOT,SPONSOR
    84         S ROOT=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
    85         S ENTRY=ROOT_IEN_",100)"
    86         S ENTRY=$G(@ENTRY)
    87         S SPONSOR=$P(ENTRY,U,2)
    88         I SPONSOR'="" S SPONLIST("S",SPONSOR)=""
    89         Q
    90         ;
    91         ;===============================================================
    92 GETTFIND(FLIST) ;If there are any terms in the list of findings go through
    93         ;them and add the mapped findings to the list of findings.
    94         I '$D(FLIST("REMINDER TERM")) Q
    95         N FILENAME,ROOT,TIEN
    96         S TIEN=0
    97         F  S TIEN=$O(FLIST("REMINDER TERM","F",TIEN)) Q:+TIEN=0  D
    98         . S ROOT=""
    99         . F  S ROOT=$O(^PXRMD(811.5,TIEN,20,"E",ROOT)) Q:ROOT=""  D
    100         .. D ADDFILE(.FLIST,ROOT,.FILENAME)
    101         .. S IEN=0
    102         .. F  S IEN=$O(^PXRMD(811.5,TIEN,20,"E",ROOT,IEN)) Q:+IEN=0  D
    103         ... D ADDFIND(.FLIST,FILENAME,IEN)
    104         Q
    105         ;
    106         ;===============================================================
    107 GETTEXT(RIEN,TMPIND,INDEX)      ;Let the user input some text.
    108         N DIC,DWLW,DWPK
    109         ;If this is the description text, load the reminder description as
    110         ;the default.
    111         S RIEN=+RIEN
    112         I RIEN>0 M ^TMP(TMPIND,$J,INDEX,1)=^PXD(811.9,RIEN,1)
    113         S DIC="^TMP(TMPIND,$J,"""_INDEX_""",1,"
    114         S DWLW=72
    115         S DWPK=1
    116         D EN^DIWE
    117         Q
    118         ;
    119         ;===============================================================
    120 PACK(RTP,TMPIND)        ;Create the packed reminder, store it in
    121         ;^TMP(TMPIND,$J). TMPIND should be namespaced and set by the caller.
    122         ;Save the source information
    123         I +RTP'>0 Q
    124         K ^TMP(TMPIND,$J),^TMP("PXRMEXCS",$J)
    125         D PUTSRC(RTP,TMPIND)
    126         ;
    127         ;Have the user input text that describes the reminder.
    128         W !,"Enter a description of the reminder you are packing." H 3
    129         D GETTEXT(RTP,TMPIND,"DESC")
    130         ;
    131         ;Have the user input keywords for indexing the reminder.
    132         W !,"Enter keywords or phrases to help index the reminder you are packing."
    133         W !,"Separate the keywords or phrases on each line with commas." H 3
    134         D GETTEXT(0,TMPIND,"KEYWORD")
    135         ;
    136         ;Combine the source and input text into the "TEXT" array.
    137         D BLDTEXT(TMPIND)
    138         ;
    139         W !,"Packing the reminder ... "
    140         ;Build lists of the various reminder components.
    141         N CF,IEN,IND0,FINDLIST,FILELIST,FILENAME,FILENUM,DLGLIST
    142         N NUMF,NUMR,OBJLIST,RIEN,ROUTINE,RTNLIST
    143         N SERROR,SPONLIST,TEMLIST
    144         S RIEN=$P(RTP,U,1)
    145         ;
    146         ;Get the list of definition findings and start the sponsor list.
    147         D GETDFIND(RIEN,.FINDLIST)
    148         ;
    149         ;Add term findings to the list.
    150         D GETTFIND(.FINDLIST)
    151         ;
    152         ;If a dialog exists for this reminder add it and its findings to the
    153         ;list. Also collect any embedded TIU objects or templates
    154         D DIALOG^PXRMEXDG(RIEN,.DLGLIST,.FINDLIST,.OBJLIST,.TEMLIST,.SPONLIST)
    155         ;
    156         ;If there were education topics make sure subtopics are included.
    157         D SUB^PXRMEXED(.FINDLIST)
    158         ;
    159         ;The finding list is complete, search the definition, dialog and
    160         ;all the findings for sponsors.
    161         D BLDSPON(RIEN,.FINDLIST,.SPONLIST)
    162         ;
    163         ;Put sponsors first on the file list.
    164         S NUMF=0
    165         S IND0=0
    166         F  S IND0=$O(SPONLIST(IND0)) Q:IND0=""  D
    167         . S IEN=0
    168         . F  S IEN=$O(SPONLIST(IND0,IEN)) Q:IEN=""  D
    169         .. S NUMF=NUMF+1
    170         .. S FILELIST(NUMF)="REMINDER SPONSOR"_U_811.6_U_IEN
    171         ;
    172         ;Look for any computed findings and put the associated routines
    173         ;on the routine list.
    174         S (IEN,NUMR)=0
    175         F  S IEN=$O(FINDLIST("REMINDER COMPUTED FINDINGS","F",IEN)) Q:IEN=""  D
    176         . S ROUTINE=$P(^PXRMD(811.4,IEN,0),U,2)
    177         . S NUMR=NUMR+1
    178         . S RTNLIST(NUMR)=ROUTINE
    179         ;
    180         ;Go through the finding list and create the file list in the same
    181         ;order as the finding list.
    182         S FILENAME=""
    183         F  S FILENAME=$O(FINDLIST(FILENAME)) Q:FILENAME=""  D
    184         . S FILENUM=FINDLIST(FILENAME)
    185         . S IND0=""
    186         . F  S IND0=$O(FINDLIST(FILENAME,IND0)) Q:IND0=""  D
    187         .. S IEN=0
    188         .. F  S IEN=$O(FINDLIST(FILENAME,IND0,IEN)) Q:IEN=""  D
    189         ... S NUMF=NUMF+1
    190         ... S FILELIST(NUMF)=FILENAME_U_FILENUM_U_IEN
    191         ;
    192         ;Add TIU templates to the file list.
    193         S IND0=0
    194         F  S IND0=$O(TEMLIST(IND0)) Q:IND0=""  D
    195         . S IEN=$$EXISTS^PXRMEXIU(8927.1,TEMLIST(IND0))
    196         . S NUMF=NUMF+1
    197         . S FILELIST(NUMF)="TIU TEMPLATE FIELD"_U_8927.1_U_IEN
    198         ;
    199         ;Put the reminder at next to last.
    200         S NUMF=NUMF+1
    201         S FILELIST(NUMF)="REMINDER DEFINITION"_U_811.9_U_RIEN
    202         ;
    203         ;Put dialogs last on the file list.
    204         S FILENUM=$G(DLGLIST("DIALOG"))
    205         S IND0=""
    206         F  S IND0=$O(DLGLIST("DIALOG",IND0)) Q:IND0=""  D
    207         . S IEN=""
    208         . F  S IEN=$O(DLGLIST("DIALOG",IND0,IEN)) Q:IEN=""  D
    209         .. S NUMF=NUMF+1
    210         .. S FILELIST(NUMF)="REMINDER DIALOG"_U_FILENUM_U_IEN
    211         ;
    212         S SERROR=0
    213         ;Put any routines into the ^TMP array.
    214         D GRTN^PXRMEXPU(.RTNLIST,NUMR,TMPIND,.SERROR)
    215         ;Put the GETS^DIQ extracts of the findings, dialogs, and
    216         ;reminder definition into the ^TMP array.
    217         D GDIQF^PXRMEXPU(.FILELIST,NUMF,TMPIND,.SERROR)
    218         ;
    219         ;If there were any errors saving the data kill the ^TMP array.
    220         I SERROR K ^TMP(TMPIND,$J)
    221         Q
    222         ;
    223         ;===============================================================
    224 PUTSRC(RTP,TMPIND)      ;Save the source information
    225         N LOC
    226         S LOC=$$SITE^VASITE
    227         S ^TMP(TMPIND,$J,"SRC","REMINDER")=$P(RTP,U,2)
    228         S ^TMP(TMPIND,$J,"SRC","USER")=$$GET1^DIQ(200,DUZ,.01)
    229         S ^TMP(TMPIND,$J,"SRC","SITE")=$P(LOC,U,2)
    230         S ^TMP(TMPIND,$J,"SRC","DATE")=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    231         Q
    232         ;
     1PXRMEXPR ; SLC/PKR/PJH - Routines to create packed reminder definitions. ;02/25/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;===============================================================
     4ADDFILE(FLIST,ROOT,FILENAME) ;Add a file to the list of finding files.
     5 N DIC,DO,FILENUM
     6 S DIC="^"_ROOT
     7 K DO
     8 D DO^DIC1
     9 S FILENUM=+DO(2)
     10 S FILENAME=$P(DO,U,1)
     11 S FLIST(FILENAME)=FILENUM
     12 Q
     13 ;
     14 ;===============================================================
     15ADDFIND(FLIST,FILENAME,IEN) ;Add a finding to the list of findings.
     16 S FLIST(FILENAME,"F",IEN)=""
     17 ;Make sure categories are included for any health factors and they
     18 ;come first in the list of health factors.
     19 I FILENAME="HEALTH FACTORS" D
     20 . N CAT
     21 . S CAT=$P(^AUTTHF(IEN,0),U,3)
     22 . S FLIST(FILENAME,"C",CAT)=""
     23 Q
     24 ;
     25 ;===============================================================
     26BLDSPON(RIEN,FINDLIST,SPONLIST) ;Build the sponsor list.
     27 N DIEN,IEN,IND,IND0
     28 ;Start with the definition.
     29 D GETSPON(811.9,RIEN,.SPONLIST)
     30 ;If there is a dialog add it.
     31 S DIEN=+$P($G(^PXD(811.9,RIEN,51)),U,1)
     32 I DIEN>0 D GETSPON(801.41,DIEN,.SPONLIST)
     33 ;Go through the finding list to find additional sponsors.
     34 S IND=""
     35 F  S IND=$O(FINDLIST(IND)) Q:IND=""  D
     36 . S FILENUM=FINDLIST(IND)
     37 . I (FILENUM'<800)&(FILENUM'>811.9) D
     38 .. S IND0=""
     39 .. F  S IND0=$O(FINDLIST(IND,IND0)) Q:IND0=""  D
     40 ... S IEN=""
     41 ... F  S IEN=+$O(FINDLIST(IND,IND0,IEN)) Q:IEN=0  D
     42 .... D GETSPON(FILENUM,IEN,.SPONLIST)
     43 ;Add any associated sponsors to the begining of the list.
     44 S IND=""
     45 F  S IND=$O(SPONLIST("S",IND)) Q:IND=""  D
     46 . S IND0=0
     47 . F  S IND0=+$O(^PXRMD(811.6,IND,2,IND0)) Q:IND0=0  D
     48 .. S IEN=+^PXRMD(811.6,IND,2,IND0,0)
     49 .. S SPONLIST("A",IEN)=""
     50 Q
     51 ;
     52 ;===============================================================
     53BLDTEXT(TMPIND) ;Combine the source information and the user's input into the
     54 ;"TEXT" array.
     55 N IC,IND
     56 S (IC,IND)=0
     57 F  S IC=$O(^TMP(TMPIND,$J,"SRC",IC)) Q:+IC=0  D
     58 . S IND=IND+1
     59 . S ^TMP(TMPIND,$J,"TEXT",1,IND)=^TMP(TMPIND,$J,"SRC",IC)
     60 ;
     61 S IC=0
     62 F  S IC=$O(^TMP(TMPIND,$J,"TXT",1,IC)) Q:+IC=0  D
     63 . S IND=IND+1
     64 . S ^TMP(TMPIND,$J,"TEXT",1,IND)=^TMP(TMPIND,$J,"TXT",1,IC,0)
     65 Q
     66 ;
     67 ;===============================================================
     68GETDFIND(RIEN,FLIST) ;Build the list of definition findings.
     69 ;FLIST has the format FLIST(FILENAME)=file number, and for each
     70 ;finding from the file FLIST(FILENAME,"F",IEN)="". For Health Factors
     71 ;category entries are FLIST(FILENAME,"C",IEN)="".
     72 N FILENAME,IEN,ROOT
     73 S ROOT=""
     74 F  S ROOT=$O(^PXD(811.9,RIEN,20,"E",ROOT)) Q:ROOT=""  D
     75 . D ADDFILE(.FLIST,ROOT,.FILENAME)
     76 . S IEN=0
     77 . F  S IEN=$O(^PXD(811.9,RIEN,20,"E",ROOT,IEN)) Q:+IEN=0  D
     78 .. D ADDFIND(.FLIST,FILENAME,IEN)
     79 Q
     80 ;
     81 ;===============================================================
     82GETSPON(FILENUM,IEN,SPONLIST) ;Add sponsors to the sponsor list.
     83 N ENTRY,ROOT,SPONSOR
     84 S ROOT=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
     85 S ENTRY=ROOT_IEN_",100)"
     86 S ENTRY=$G(@ENTRY)
     87 S SPONSOR=$P(ENTRY,U,2)
     88 I SPONSOR'="" S SPONLIST("S",SPONSOR)=""
     89 Q
     90 ;
     91 ;===============================================================
     92GETTFIND(FLIST) ;If there are any terms in the list of findings go through
     93 ;them and add the mapped findings to the list of findings.
     94 I '$D(FLIST("REMINDER TERM")) Q
     95 N FILENAME,ROOT,TIEN
     96 S TIEN=0
     97 F  S TIEN=$O(FLIST("REMINDER TERM","F",TIEN)) Q:+TIEN=0  D
     98 . S ROOT=""
     99 . F  S ROOT=$O(^PXRMD(811.5,TIEN,20,"E",ROOT)) Q:ROOT=""  D
     100 .. D ADDFILE(.FLIST,ROOT,.FILENAME)
     101 .. S IEN=0
     102 .. F  S IEN=$O(^PXRMD(811.5,TIEN,20,"E",ROOT,IEN)) Q:+IEN=0  D
     103 ... D ADDFIND(.FLIST,FILENAME,IEN)
     104 Q
     105 ;
     106 ;===============================================================
     107GETTEXT(RIEN,TMPIND,INDEX) ;Let the user input some text.
     108 N DIC,DWLW,DWPK
     109 ;If this is the description text, load the reminder description as
     110 ;the default.
     111 S RIEN=+RIEN
     112 I RIEN>0 M ^TMP(TMPIND,$J,INDEX,1)=^PXD(811.9,RIEN,1)
     113 S DIC="^TMP(TMPIND,$J,"""_INDEX_""",1,"
     114 S DWLW=72
     115 S DWPK=1
     116 D EN^DIWE
     117 Q
     118 ;
     119 ;===============================================================
     120PACK(RTP,TMPIND) ;Create the packed reminder, store it in
     121 ;^TMP(TMPIND,$J). TMPIND should be namespaced and set by the caller.
     122 ;Save the source information
     123 I +RTP'>0 Q
     124 K ^TMP(TMPIND,$J)
     125 D PUTSRC(RTP,TMPIND)
     126 ;
     127 ;Have the user input text that describes the reminder.
     128 W !,"Enter a description of the reminder you are packing." H 3
     129 D GETTEXT(RTP,TMPIND,"DESC")
     130 ;
     131 ;Have the user input keywords for indexing the reminder.
     132 W !,"Enter keywords or phrases to help index the reminder you are packing."
     133 W !,"Separate the keywords or phrases on each line with commas." H 3
     134 D GETTEXT(0,TMPIND,"KEYWORD")
     135 ;
     136 ;Combine the source and input text into the "TEXT" array.
     137 D BLDTEXT(TMPIND)
     138 ;
     139 W !,"Packing the reminder ... "
     140 ;Build lists of the various reminder components.
     141 N CF,IEN,IND0,FINDLIST,FILELIST,FILENAME,FILENUM,DLGLIST
     142 N NUMF,NUMR,OBJLIST,RIEN,ROUTINE,RTNLIST
     143 N SERROR,SPONLIST,TEMLIST
     144 S RIEN=$P(RTP,U,1)
     145 ;
     146 ;Get the list of definition findings and start the sponsor list.
     147 D GETDFIND(RIEN,.FINDLIST)
     148 ;
     149 ;Add term findings to the list.
     150 D GETTFIND(.FINDLIST)
     151 ;
     152 ;If a dialog exists for this reminder add it and its findings to the
     153 ;list. Also collect any embedded TIU objects or templates
     154 D DIALOG^PXRMEXDG(RIEN,.DLGLIST,.FINDLIST,.OBJLIST,.TEMLIST)
     155 ;
     156 ;If there were education topics make sure subtopics are included.
     157 D SUB^PXRMEXED(.FINDLIST)
     158 ;
     159 ;The finding list is complete, search the definition, dialog and
     160 ;all the findings for sponsors.
     161 D BLDSPON(RIEN,.FINDLIST,.SPONLIST)
     162 ;
     163 ;Put sponsors first on the file list.
     164 S NUMF=0
     165 S IND0=0
     166 F  S IND0=$O(SPONLIST(IND0)) Q:IND0=""  D
     167 . S IEN=0
     168 . F  S IEN=$O(SPONLIST(IND0,IEN)) Q:IEN=""  D
     169 .. S NUMF=NUMF+1
     170 .. S FILELIST(NUMF)="REMINDER SPONSOR"_U_811.6_U_IEN
     171 ;
     172 ;Look for any computed findings and put the associated routines
     173 ;on the routine list.
     174 S (IEN,NUMR)=0
     175 F  S IEN=$O(FINDLIST("REMINDER COMPUTED FINDINGS","F",IEN)) Q:IEN=""  D
     176 . S ROUTINE=$P(^PXRMD(811.4,IEN,0),U,2)
     177 . S NUMR=NUMR+1
     178 . S RTNLIST(NUMR)=ROUTINE
     179 ;
     180 ;Go through the finding list and create the file list in the same
     181 ;order as the finding list.
     182 S FILENAME=""
     183 F  S FILENAME=$O(FINDLIST(FILENAME)) Q:FILENAME=""  D
     184 . S FILENUM=FINDLIST(FILENAME)
     185 . S IND0=""
     186 . F  S IND0=$O(FINDLIST(FILENAME,IND0)) Q:IND0=""  D
     187 .. S IEN=0
     188 .. F  S IEN=$O(FINDLIST(FILENAME,IND0,IEN)) Q:IEN=""  D
     189 ... S NUMF=NUMF+1
     190 ... S FILELIST(NUMF)=FILENAME_U_FILENUM_U_IEN
     191 ;
     192 ;Add TIU templates to the file list.
     193 S IND0=0
     194 F  S IND0=$O(TEMLIST(IND0)) Q:IND0=""  D
     195 . S IEN=$$EXISTS^PXRMEXIU(8927.1,TEMLIST(IND0))
     196 . S NUMF=NUMF+1
     197 . S FILELIST(NUMF)="TIU TEMPLATE FIELD"_U_8927.1_U_IEN
     198 ;
     199 ;Put the reminder at next to last.
     200 S NUMF=NUMF+1
     201 S FILELIST(NUMF)="REMINDER DEFINITION"_U_811.9_U_RIEN
     202 ;
     203 ;Put dialogs last on the file list.
     204 S FILENUM=$G(DLGLIST("DIALOG"))
     205 S IND0=""
     206 F  S IND0=$O(DLGLIST("DIALOG",IND0)) Q:IND0=""  D
     207 . S IEN=""
     208 . F  S IEN=$O(DLGLIST("DIALOG",IND0,IEN)) Q:IEN=""  D
     209 .. S NUMF=NUMF+1
     210 .. S FILELIST(NUMF)="REMINDER DIALOG"_U_FILENUM_U_IEN
     211 ;
     212 S SERROR=0
     213 ;Put any routines into the ^TMP array.
     214 D GRTN^PXRMEXPU(.RTNLIST,NUMR,TMPIND,.SERROR)
     215 ;Put the GETS^DIQ extracts of the findings, dialogs, and
     216 ;reminder definition into the ^TMP array.
     217 D GDIQF^PXRMEXPU(.FILELIST,NUMF,TMPIND,.SERROR)
     218 ;
     219 ;If there were any errors saving the data kill the ^TMP array.
     220 I SERROR K ^TMP(TMPIND,$J)
     221 Q
     222 ;
     223 ;===============================================================
     224PUTSRC(RTP,TMPIND) ;Save the source information
     225 N LOC
     226 S LOC=$$SITE^VASITE
     227 S ^TMP(TMPIND,$J,"SRC","REMINDER")=$P(RTP,U,2)
     228 ;S ^TMP(TMPIND,$J,"SRC","USER")=$P(^VA(200,DUZ,0),U,1)
     229 S ^TMP(TMPIND,$J,"SRC","USER")=$$GET1^DIQ(200,DUZ,.01)
     230 S ^TMP(TMPIND,$J,"SRC","SITE")=$P(LOC,U,2)
     231 S ^TMP(TMPIND,$J,"SRC","DATE")=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     232 Q
     233 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXPU.m

    r613 r623  
    1 PXRMEXPU        ; SLC/PKR - Utilities for packing and unpacking repository entries. ;09/10/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;==================================================
    4 BTTABLE(DIQOUT,IENROOT,TTABLE)  ;Build the DIQOUT to FDA iens translation table.
    5         N FILENUM,IENS,IENT,IND,UP
    6         S FILENUM=$O(DIQOUT(""))
    7         I FILENUM="" Q
    8         ;DBIA #2631
    9         S UP=$G(^DD(FILENUM,0,"UP"))
    10         ;Top level file in DIQOUT should not have an up node.
    11         I UP="" D
    12         . S IENS=$O(DIQOUT(FILENUM,"")),IND=+IENS
    13         . S TTABLE(FILENUM,IENS)="+"_IENS
    14         E  D  Q
    15         . W !,"BTTABLE^PXRMEXPU - DIQOUT problem, do not have correct top level"
    16         ;
    17         F  S FILENUM=$O(DIQOUT(FILENUM)) Q:FILENUM=""  D
    18         . S UP=$G(^DD(FILENUM,0,"UP"))
    19         . S IENS=""
    20         . F  S IENS=$O(DIQOUT(FILENUM,IENS)) Q:IENS=""  D
    21         .. S IND=IND+1
    22         .. S IENT=$P(IENS,",",2,99)
    23         .. S TTABLE(FILENUM,IENS)="+"_IND_","_TTABLE(UP,IENT)
    24         .. S IENROOT(IND)=$P(IENS,",",1)
    25         Q
    26         ;
    27         ;==================================================
    28 CLDIQOUT(DIQOUT)        ;Clean up DIQOUT remove null entries and change .01's
    29         ;to the resolved form.
    30         N ABBR,IENS,INTERNAL,FIELD,FILENUM,LINE
    31         N PTRTO,ROOT,TYPE,WPLCNT,VLIST,VPTRLIST
    32         S FILENUM=""
    33         F  S FILENUM=$O(DIQOUT(FILENUM)) Q:FILENUM=""  D
    34         . K TYPE,VPTRLIST
    35         . S IENS=""
    36         . F  S IENS=$O(DIQOUT(FILENUM,IENS)) Q:IENS=""  D
    37         .. S FIELD=""
    38         .. F  S FIELD=$O(DIQOUT(FILENUM,IENS,FIELD)) Q:FIELD=""  D
    39         ...;If there is no data then don't keep this entry.
    40         ... I DIQOUT(FILENUM,IENS,FIELD)="" K DIQOUT(FILENUM,IENS,FIELD) Q
    41         ...;Get the field type, if it is a variable-pointer then set up
    42         ...;the resolved form.
    43         ... I '$D(TYPE(FILENUM,FIELD)) S TYPE(FILENUM,FIELD)=$$GET1^DID(FILENUM,FIELD,"","TYPE")
    44         ... S PTRTO=$S(TYPE(FILENUM,FIELD)="POINTER":$$GET1^DID(FILENUM,FIELD,"","POINTER"),1:"")
    45         ... ;Remove pointers to file 200.
    46         ... I PTRTO="VA(200," S DIQOUT(FILENUM,IENS,FIELD)="" Q
    47         ...;If the field's type is COMPUTED then don't transport it.
    48         ... I TYPE(FILENUM,FIELD)="COMPUTED" K DIQOUT(FILENUM,IENS,FIELD) Q
    49         ... I TYPE(FILENUM,FIELD)="VARIABLE-POINTER" D
    50         .... I '$D(VPTRLIST(FILENUM,FIELD)) D
    51         ..... K VLIST
    52         ..... D BLDRLIST^PXRMVPTR(FILENUM,FIELD,.VLIST)
    53         ..... M VPTRLIST(FILENUM,FIELD)=VLIST
    54         .... S INTERNAL=$$GET1^DIQ(FILENUM,IENS,FIELD,"I")
    55         .... S (PTRTO,ROOT)=$P(INTERNAL,";",2)
    56         .... S ABBR=$P(VPTRLIST(FILENUM,FIELD,ROOT),U,4)
    57         .... S DIQOUT(FILENUM,IENS,FIELD)=ABBR_"."_DIQOUT(FILENUM,IENS,FIELD)
    58         ... I TYPE(FILENUM,FIELD)="WORD-PROCESSING" D
    59         .... S (LINE,WPLCNT)=0
    60         .... F  S LINE=$O(DIQOUT(FILENUM,IENS,FIELD,LINE)) Q:LINE=""  D
    61         ..... S WPLCNT=WPLCNT+1
    62         .... I WPLCNT>0 S DIQOUT(FILENUM,IENS,FIELD)="WP-start~"_WPLCNT
    63         .... E  K DIQOUT(FILENUM,IENS,FIELD)
    64         ...;For fields that point to files 80 and 80.1 we have to append a space
    65         ...;so FileMan can resolve the pointers when installing a component.
    66         ... I PTRTO["ICD" S DIQOUT(FILENUM,IENS,FIELD)=DIQOUT(FILENUM,IENS,FIELD)_" "
    67         Q
    68         ;
    69         ;==================================================
    70 CONTOFDA(DIQOUT,IENROOT)        ;Convert the iens from the form
    71         ;returned by GETS^DIQ to the FDA laygo form used by UPDATE^DIE.
    72         ;DIQOUT contains the GETS^DIQ output. If any of the fields are
    73         ;variable pointers change them to the resolved form.
    74         N IENS,IENSA,FIELD,FILENUM,TTABLE,TYPE
    75         ;Clean up DIQOUT remove null entries and change .01's to the resolved
    76         ;form.
    77         D CLDIQOUT(.DIQOUT)
    78         ;Convert the iens to the adding FDA form .
    79         D BTTABLE(.DIQOUT,.IENROOT,.TTABLE)
    80         S FILENUM=""
    81         F  S FILENUM=$O(DIQOUT(FILENUM)) Q:FILENUM=""  D
    82         . S IENS=""
    83         . F  S IENS=$O(DIQOUT(FILENUM,IENS)) Q:IENS=""  D
    84         .. S IENSA=TTABLE(FILENUM,IENS)
    85         .. S FIELD=""
    86         .. F  S FIELD=$O(DIQOUT(FILENUM,IENS,FIELD)) Q:FIELD=""  D
    87         ... M DIQOUT(FILENUM,IENSA,FIELD)=DIQOUT(FILENUM,IENS,FIELD)
    88         .. K DIQOUT(FILENUM,IENS)
    89         Q
    90         ;
    91         ;==================================================
    92 GDIQF(LIST,NUM,TMPIND,SERROR)   ;Save file entries into ^TMP(TMPIND,$J).
    93         N CSUM,DIQOUT,IENROOT,IND,FIELD,FILENAME,IENS,MSG,PT01,TEMP
    94         S ^TMP(TMPIND,$J,"NUMF")=NUM
    95         F IND=1:1:NUM D
    96         . S TEMP=LIST(IND)
    97         . S FILENAME=$P(TEMP,U,1)
    98         . S FILENUM=$P(TEMP,U,2)
    99         . S IEN=$P(TEMP,U,3)
    100         . K DIQOUT,IENROOT
    101         .;If the file entry is ok to install then get the entire entry,
    102         .;otherwise just get the .01.
    103         . I $$FOKTI^PXRMEXFI(FILENUM) S FIELD="**"
    104         . E  S FIELD=.01
    105         . D GETS^DIQ(FILENUM,IEN,FIELD,"N","DIQOUT","MSG")
    106         . I $D(MSG) D  Q
    107         .. S SERROR=1,IND=NUM
    108         .. N ETEXT
    109         .. S ETEXT="GETS^DIQ failed for "_FILENAME_", ien="_IEN_";"
    110         .. W !,ETEXT
    111         .. W !,"it returned the following error:"
    112         .. D AWRITE^PXRMUTIL("MSG")
    113         .. H 2
    114         .. K MSG
    115         .;Remove edit history from all reminder files.
    116         . D RMEH(FILENUM,.DIQOUT)
    117         .;Convert the iens to the FDA adding form.
    118         . D CONTOFDA(.DIQOUT,.IENROOT)
    119         . S CSUM=$$DIQOUTCS^PXRMEXCS(.DIQOUT)
    120         . S ^TMP("PXRMEXCS",$J,IND,FILENAME)=CSUM
    121         .;Load the converted DIQOUT into TMP.
    122         . M ^TMP(TMPIND,$J,IND,FILENAME)=DIQOUT
    123         . M ^TMP(TMPIND,$J,IND,FILENAME_"_IENROOT")=IENROOT
    124         Q
    125         ;
    126         ;==================================================
    127 GETREM(ACTION)  ;Get the reminder to save.
    128         N DIC,DUOUT,X,Y
    129         S DIC="^PXD(811.9,"
    130         S DIC(0)="AEMQ"
    131         S DIC("A")="Select Reminder Definition to "_ACTION_": "
    132         D ^DIC
    133         Q Y
    134         ;
    135         ;==================================================
    136 GRTN(LIST,NUM,TMPIND,SERROR)    ;Save routines into ^TMP(TMPIND,$J).
    137         N DIF,IEN,IND,RA,TEMP,X,XCNP
    138         S ^TMP(TMPIND,$J,"NUMR")=NUM
    139         S X=""
    140         F IND=1:1:NUM D
    141         .;Make sure the routine exists.
    142         . S X=LIST(IND)
    143         . X ^%ZOSF("TEST")
    144         . I $T D
    145         .. K RA
    146         .. S DIF="RA("
    147         .. S XCNP=0
    148         .. X ^%ZOSF("LOAD")
    149         .. S ^TMP("PXRMEXCS",$J,"ROUTINE",X)=$$ROUTINE^PXRMEXCS(.RA)
    150         .. M ^TMP(TMPIND,$J,"ROUTINE",X)=RA
    151         . E  D
    152         .. S SERROR=1
    153         .. W !,"Warning could not find routine ",X
    154         .. H 2
    155         Q
    156         ;
    157         ;==================================================
    158 RMEH(FILENUM,DIQOUT,NOSTUB)     ;Clear the edit history from all reminder files.
    159         ;Leave a stub so it can be filled in when the file is installed.
    160         I (FILENUM<800)!(FILENUM>811.9) Q
    161         N IENS,SFN,TARGET
    162         ;Edit History is stored in node 110 for all files, get the
    163         ;subfile number.
    164         D FIELD^DID(FILENUM,110,"","SPECIFIER","TARGET")
    165         S SFN=+$G(TARGET("SPECIFIER"))
    166         I SFN=0 Q
    167         ;Clean out the history.
    168         S IENS=""
    169         F  S IENS=$O(DIQOUT(SFN,IENS)) Q:IENS=""  K DIQOUT(SFN,IENS)
    170         ;Create a stub for the install.
    171         I $G(NOSTUB) Q
    172         S IENS="1,"_$O(DIQOUT(FILENUM,""))
    173         S DIQOUT(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    174         S DIQOUT(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
    175         S DIQOUT(SFN,IENS,2)="DIQOUT("_SFN_","_IENS_"2)"
    176         S DIQOUT(SFN,IENS,2,1)="Exchange Stub"
    177         Q
    178         ;
    179         ;==================================================
    180 UPDATE(SUCCESS,FDA,FDAIEN)      ;Call to add new entries to the repository.
    181         N MSG
    182         ;Try to eliminate gaps in the repository.
    183         S $P(^PXD(811.8,0),U,3)=0
    184         D UPDATE^DIE("E","FDA","FDAIEN","MSG")
    185         I $D(MSG) D
    186         . N DATE,RNAME
    187         . S SUCCESS=0
    188         . W !,"The update failed, UPDATE^DIE returned the following error message:"
    189         . D AWRITE^PXRMUTIL("MSG")
    190         . S RNAME=FDA(811.8,"+1,",.01)
    191         . S DATE=FDA(811.8,"+1,",.03)
    192         . W !!,"Exchange File entry ",RNAME," date packed ",DATE," did not get stored!"
    193         . W !,"Examine the above error message for the reason.",!
    194         . H 2
    195         E  S SUCCESS=1
    196         Q
    197         ;
     1PXRMEXPU ; SLC/PKR - Utilities for packing and unpacking repository entries. ;12/22/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;==================================================
     4BTTABLE(DIQOUT,IENROOT,TTABLE) ;Build the DIQOUT to FDA iens translation table.
     5 N FILENUM,IENS,IENT,IND,UP
     6 S FILENUM=$O(DIQOUT(""))
     7 I FILENUM="" Q
     8 ;DBIA #2631
     9 S UP=$G(^DD(FILENUM,0,"UP"))
     10 ;Top level file in DIQOUT should not have an up node.
     11 I UP="" D
     12 . S IENS=$O(DIQOUT(FILENUM,"")),IND=+IENS
     13 . S TTABLE(FILENUM,IENS)="+"_IENS
     14 E  D  Q
     15 . W !,"BTTABLE^PXRMEXPU - DIQOUT problem do not have correct top level"
     16 ;
     17 F  S FILENUM=$O(DIQOUT(FILENUM)) Q:FILENUM=""  D
     18 . S UP=$G(^DD(FILENUM,0,"UP"))
     19 . S IENS=""
     20 . F  S IENS=$O(DIQOUT(FILENUM,IENS)) Q:IENS=""  D
     21 .. S IND=IND+1
     22 .. S IENT=$P(IENS,",",2,99)
     23 .. S TTABLE(FILENUM,IENS)="+"_IND_","_TTABLE(UP,IENT)
     24 .. S IENROOT(IND)=$P(IENS,",",1)
     25 Q
     26 ;
     27 ;==================================================
     28CLDIQOUT(DIQOUT) ;Clean up DIQOUT remove null entries and change .01's
     29 ;to the resolved form.
     30 N ABBR,IENS,INTERNAL,FIELD,FILENUM,LINE
     31 N PTRTO,ROOT,TYPE,WPLCNT,VLIST,VPTRLIST
     32 S FILENUM=""
     33 F  S FILENUM=$O(DIQOUT(FILENUM)) Q:FILENUM=""  D
     34 . K TYPE,VPTRLIST
     35 . S IENS=""
     36 . F  S IENS=$O(DIQOUT(FILENUM,IENS)) Q:IENS=""  D
     37 .. S FIELD=""
     38 .. F  S FIELD=$O(DIQOUT(FILENUM,IENS,FIELD)) Q:FIELD=""  D
     39 ...;If there is no data then don't keep this entry.
     40 ... I DIQOUT(FILENUM,IENS,FIELD)="" K DIQOUT(FILENUM,IENS,FIELD) Q
     41 ...;Get the field type, if it is a variable-pointer then set up
     42 ...;the resolved form.
     43 ... I '$D(TYPE(FILENUM,FIELD)) S TYPE(FILENUM,FIELD)=$$GET1^DID(FILENUM,FIELD,"","TYPE")
     44 ... S PTRTO=$S(TYPE(FILENUM,FIELD)="POINTER":$$GET1^DID(FILENUM,FIELD,"","POINTER"),1:"")
     45 ...;If the field's type is COMPUTED then don't transport it.
     46 ... I TYPE(FILENUM,FIELD)="COMPUTED" K DIQOUT(FILENUM,IENS,FIELD) Q
     47 ... I TYPE(FILENUM,FIELD)="VARIABLE-POINTER" D
     48 .... I '$D(VPTRLIST(FILENUM,FIELD)) D
     49 ..... K VLIST
     50 ..... D BLDRLIST^PXRMVPTR(FILENUM,FIELD,.VLIST)
     51 ..... M VPTRLIST(FILENUM,FIELD)=VLIST
     52 .... S INTERNAL=$$GET1^DIQ(FILENUM,IENS,FIELD,"I")
     53 .... S (PTRTO,ROOT)=$P(INTERNAL,";",2)
     54 .... S ABBR=$P(VPTRLIST(FILENUM,FIELD,ROOT),U,4)
     55 .... S DIQOUT(FILENUM,IENS,FIELD)=ABBR_"."_DIQOUT(FILENUM,IENS,FIELD)
     56 ... I TYPE(FILENUM,FIELD)="WORD-PROCESSING" D
     57 .... S (LINE,WPLCNT)=0
     58 .... F  S LINE=$O(DIQOUT(FILENUM,IENS,FIELD,LINE)) Q:LINE=""  D
     59 ..... S WPLCNT=WPLCNT+1
     60 .... I WPLCNT>0 S DIQOUT(FILENUM,IENS,FIELD)="WP-start~"_WPLCNT
     61 .... E  K DIQOUT(FILENUM,IENS,FIELD)
     62 ...;For fields that point to files 80 and 80.1 we have to append a space
     63 ...;so FileMan can resolve the pointers when installing a component.
     64 ... I PTRTO["ICD" S DIQOUT(FILENUM,IENS,FIELD)=DIQOUT(FILENUM,IENS,FIELD)_" "
     65 Q
     66 ;
     67 ;==================================================
     68CONTOFDA(DIQOUT,IENROOT) ;Convert the iens from the form
     69 ;returned by GETS^DIQ to the FDA laygo form used by UPDATE^DIE.
     70 ;DIQOUT contains the GETS^DIQ output. If any of the fields are
     71 ;variable pointers change them to the resolved form.
     72 N IENS,IENSA,FIELD,FILENUM,TTABLE,TYPE
     73 ;Clean up DIQOUT remove null entries and change .01's to the resolved
     74 ;form.
     75 D CLDIQOUT(.DIQOUT)
     76 ;Convert the iens to the adding FDA form .
     77 D BTTABLE(.DIQOUT,.IENROOT,.TTABLE)
     78 S FILENUM=""
     79 F  S FILENUM=$O(DIQOUT(FILENUM)) Q:FILENUM=""  D
     80 . S IENS=""
     81 . F  S IENS=$O(DIQOUT(FILENUM,IENS)) Q:IENS=""  D
     82 .. S IENSA=TTABLE(FILENUM,IENS)
     83 .. S FIELD=""
     84 .. F  S FIELD=$O(DIQOUT(FILENUM,IENS,FIELD)) Q:FIELD=""  D
     85 ... M DIQOUT(FILENUM,IENSA,FIELD)=DIQOUT(FILENUM,IENS,FIELD)
     86 .. K DIQOUT(FILENUM,IENS)
     87 Q
     88 ;
     89 ;==================================================
     90GDIQF(LIST,NUM,TMPIND,SERROR) ;Save file entries into ^TMP(TMPIND,$J).
     91 N DIQOUT,IENROOT,IND,FIELD,FILENAME,IENS,MSG,PT01,TEMP
     92 S ^TMP(TMPIND,$J,"NUMF")=NUM
     93 F IND=1:1:NUM D
     94 . S TEMP=LIST(IND)
     95 . S FILENAME=$P(TEMP,U,1)
     96 . S FILENUM=$P(TEMP,U,2)
     97 . S IEN=$P(TEMP,U,3)
     98 . K DIQOUT,IENROOT
     99 .;If the file entry is ok to install then get the entire entry,
     100 .;otherwise just get the .01.
     101 . I $$FOKTI^PXRMEXFI(FILENUM) S FIELD="**"
     102 . E  S FIELD=.01
     103 . D GETS^DIQ(FILENUM,IEN,FIELD,"","DIQOUT","MSG")
     104 . I $D(MSG) D  Q
     105 .. S SERROR=1,IND=NUM
     106 .. N ETEXT
     107 .. S ETEXT="GETS^DIQ failed for "_FILENAME_", ien="_IEN_";"
     108 .. W !,ETEXT
     109 .. W !,"it returned the following error:"
     110 .. D AWRITE^PXRMUTIL("MSG")
     111 .. H 2
     112 .. K MSG
     113 .;Remove edit history from all reminder files.
     114 . D RMEH(FILENUM,.DIQOUT)
     115 .;Convert the iens to the FDA adding form.
     116 . D CONTOFDA(.DIQOUT,.IENROOT)
     117 .;Load the converted DIQOUT into TMP.
     118 . M ^TMP(TMPIND,$J,IND,FILENAME)=DIQOUT
     119 . M ^TMP(TMPIND,$J,IND,FILENAME_"_IENROOT")=IENROOT
     120 Q
     121 ;
     122 ;==================================================
     123GETREM(ACTION) ;Get the reminder to save.
     124 N DIC,DUOUT,X,Y
     125 S DIC="^PXD(811.9,"
     126 S DIC(0)="AEMQ"
     127 S DIC("A")="Select Reminder Definition to "_ACTION_": "
     128 D ^DIC
     129 Q Y
     130 ;
     131 ;==================================================
     132GRTN(LIST,NUM,TMPIND,SERROR) ;Save routines into ^TMP(TMPIND,$J).
     133 N DIF,IEN,IND,TEMP,X,XCNP
     134 S ^TMP(TMPIND,$J,"NUMR")=NUM
     135 S X=""
     136 F IND=1:1:NUM D
     137 .;Make sure the routine exists.
     138 . S X=LIST(IND)
     139 . X ^%ZOSF("TEST")
     140 . I $T D
     141 .. S DIF="^TMP(TMPIND,$J,""ROUTINE"","""_X_""","
     142 .. S XCNP=0
     143 .. X ^%ZOSF("LOAD")
     144 . E  D
     145 .. S SERROR=1
     146 .. W !,"Warning could not find routine ",X
     147 .. H 2
     148 Q
     149 ;
     150 ;==================================================
     151RMEH(FILENUM,DIQOUT) ;Clear the edit history from all reminder files.
     152 ;Leave a stub so it can be filled in when the file is installed.
     153 I (FILENUM<800)!(FILENUM>811.9) Q
     154 N IEN,SFN,TARGET
     155 ;Edit History is stored in node 110 for all files, get the
     156 ;subfile number.
     157 D FIELD^DID(FILENUM,110,"","SPECIFIER","TARGET")
     158 S SFN=+$G(TARGET("SPECIFIER"))
     159 I SFN=0 Q
     160 ;Clean out the history.
     161 S IENS=""
     162 F  S IENS=$O(DIQOUT(SFN,IENS)) Q:IENS=""  K DIQOUT(SFN,IENS)
     163 ;Create a stub for the install.
     164 S IENS="1,"_$O(DIQOUT(FILENUM,""))
     165 S DIQOUT(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     166 S DIQOUT(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
     167 S DIQOUT(SFN,IENS,2)="DIQOUT("_SFN_","_IENS_"2)"
     168 S DIQOUT(SFN,IENS,2,1)="Exchange Stub"
     169 Q
     170 ;
     171 ;==================================================
     172UPDATE(SUCCESS,FDA,FDAIEN) ;Call to add new entries to the repository.
     173 N MSG
     174 ;Try to eliminate gaps in the repository.
     175 S $P(^PXD(811.8,0),U,3)=0
     176 D UPDATE^DIE("E","FDA","FDAIEN","MSG")
     177 I $D(MSG) D
     178 . N DATE,RNAME
     179 . S SUCCESS=0
     180 . W !,"The update failed, UPDATE^DIE returned the following error message:"
     181 . D AWRITE^PXRMUTIL("MSG")
     182 . S RNAME=FDA(811.8,"+1,",.01)
     183 . S DATE=FDA(811.8,"+1,",.03)
     184 . W !!,"Exchange File entry ",RNAME," date packed ",DATE," did not get stored!"
     185 . W !,"Examine the above error message for the reason.",!
     186 . H 2
     187 E  S SUCCESS=1
     188 Q
     189 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXSI.m

    r613 r623  
    1 PXRMEXSI        ; SLC/PKR/PJH - Silent repository entry install. ;09/28/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;===================================================
    5 INITMPG ;Initialize ^TMP arrays.
    6         K ^TMP("PXRMEXFND",$J)
    7         K ^TMP("PXRMEXIA",$J)
    8         K ^TMP("PXRMEXIAD",$J)
    9         K ^TMP("PXRMEXLC",$J)
    10         K ^TMP("PXRMEXLD",$J)
    11         K ^TMP("PXRMEXTMP",$J)
    12         Q
    13         ;
    14         ;===================================================
    15 INSCOM(PXRMRIEN,ACTION,IND,TEMP,REMNAME,HISTSUB)        ;Install component IND
    16         ;of PXRMRIEN.
    17         N ATTR,END,EXISTS,FILENUM,IND120,JND120,NAME
    18         N PT01,RTN,SAME,START,TEXT
    19         S FILENUM=$P(TEMP,U,1),EXISTS=$P(TEMP,U,4)
    20         S IND120=$P(TEMP,U,2),JND120=$P(TEMP,U,3)
    21         I (IND120="")!(JND120="") Q
    22         S TEMP=^PXD(811.8,PXRMRIEN,120,IND120,1,JND120,0)
    23         ;If the component does not exist then the action has to be "I".
    24         ;If the component exists and the action is "I" change it to "O".
    25         ;If the component exists and the action is "M" leave it "M".
    26         ;If the component exists and the action is "O" leave it "O".
    27         S ACTION=$S('EXISTS:"I",ACTION="I":"O",1:ACTION)
    28         S SAME=0
    29         S START=$P(TEMP,U,2)
    30         S END=$P(TEMP,U,3)
    31         I FILENUM=0 D
    32         . D RTNLD^PXRMEXIC(PXRMRIEN,START,END,.ATTR,.RTN)
    33         . I EXISTS D
    34         .. D CHECKSUM^PXRMEXCS(.ATTR,START,END)
    35         .. S CSUM=$$RTNCS^PXRMEXCS(ATTR("NAME"))
    36         .. I ATTR("CHECKSUM")=CSUM S SAME=1,ACTION="S"
    37         . S ^TMP("PXRMEXIA",$J,IND,"ROUTINE",ATTR("NAME"),ACTION)=""
    38         E  D
    39         . S TEMP=^PXD(811.8,PXRMRIEN,100,START,0)
    40         . S PT01=$P(TEMP,"~",2)
    41         .;Save reminder name for dialog install.
    42         . I FILENUM=811.9 S REMNAME=PT01
    43         . D SETATTR^PXRMEXFI(.ATTR,FILENUM,PT01)
    44         . I EXISTS D
    45         .. D CHECKSUM^PXRMEXCS(.ATTR,START,END)
    46         .. S CSUM=$$FILE^PXRMEXCS(ATTR("FILE NUMBER"),EXISTS)
    47         .. I ATTR("CHECKSUM")=CSUM S SAME=1,ACTION="S"
    48         .;Save what was done for the installation summary.
    49         . S ^TMP(HISTSUB,$J,IND,ATTR("FILE NAME"),PT01,ACTION)=""
    50         ;If the packed component and the installed component are the same
    51         ;there is nothing to do.
    52         I SAME Q
    53         ;Install this component.
    54         I FILENUM=0 D RTNSAVE^PXRMEXIC(.RTN,ATTR("NAME"))
    55         E  D FILE^PXRMEXIC(PXRMRIEN,EXISTS,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
    56         Q
    57         ;
    58         ;===================================================
    59 INSDLG(PXRMRIEN,ACTION) ;Install dialog components directly
    60         ;from the "SEL" array.
    61         N IND,FILENUM,ITEMP,NAME,REMNAME,TEMP
    62         ;Build the selection array in ^TMP("PXRMEXLD",$J,"SEL"). For dialogs
    63         ;the selection array is:
    64         ;file no.^FDA start^FDA end^EXISTS^IND120^JND120^NAME
    65         D BLDDISP^PXRMEXD1(0)
    66         ;Work through the selection array installing the dialog parts
    67         ;in reverse order.
    68         S IND=""
    69         F  S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:(IND="")!(PXRMDONE)  D
    70         . S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND)
    71         . S FILENUM=$P(TEMP,U,1),NAME=$P(TEMP,U,7)
    72         .;Dialog elements may be used more than once in a dialog so make sure
    73         .;the element has not already been installed.
    74         . S ITEMP=$P(TEMP,U,1)_U_$P(TEMP,U,5,6)_U_$$EXISTS^PXRMEXIU(FILENUM,NAME)
    75         . D INSCOM(PXRMRIEN,ACTION,IND,ITEMP,.REMNAME,"PXRMEXIAD")
    76         Q
    77         ;
    78         ;===================================================
    79 INSTALL(PXRMRIEN,ACTION,NOR)    ;Install all components in a repository entry.
    80         ;If NOR is true do not install routines.
    81         N DNAME,FILENUM,IND,PXRMDONE,PXRMNMCH,REMNAME,TEMP
    82         S PXRMDONE=0
    83         S NOR=$G(NOR)
    84         ;Initialize ^TMP globals.
    85         D INITMPG
    86         ;Build the component list.
    87         K ^PXD(811.8,PXRMRIEN,100,"B")
    88         K ^PXD(811.8,PXRMRIEN,120)
    89         D CLIST^PXRMEXU1(.PXRMRIEN)
    90         I PXRMRIEN=-1 Q
    91         ;Build the selectable list.
    92         D CDISP^PXRMEXLC(PXRMRIEN)
    93         ;Set the install date and time and type.
    94         S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
    95         S ^TMP("PXRMEXIA",$J,"TYPE")="SILENT"
    96         ;Initialize the name change storage.
    97         K PXRMNMCH
    98         S IND=0
    99         F  S IND=$O(^TMP("PXRMEXLC",$J,"SEL",IND)) Q:(IND="")!(PXRMDONE)  D
    100         . S TEMP=^TMP("PXRMEXLC",$J,"SEL",IND)
    101         . S FILENUM=$P(TEMP,U,1)
    102         .;If NOR is true do not install routines.
    103         . I FILENUM=0,NOR Q
    104         . ;Install dialog components
    105         . I FILENUM=801.41 N PXRMDONE S PXRMDONE=0 D INSDLG(PXRMRIEN,ACTION) Q
    106         . ;Install component
    107         . E  D INSCOM(PXRMRIEN,ACTION,IND,TEMP,.REMNAME,"PXRMEXIA")
    108         ;
    109         ;Get the dialog name
    110         S DNAME=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
    111         ;Link the dialog if it exists
    112         I DNAME'="" D
    113         . N DIEN,RIEN
    114         .;Get the dialog ien
    115         . S DIEN=$$EXISTS^PXRMEXIU(801.41,DNAME) Q:'DIEN
    116         .;Get the reminder ien
    117         . S RIEN=+$$EXISTS^PXRMEXIU(811.9,$G(REMNAME)) Q:'RIEN
    118         . I RIEN>0 D
    119         .. N DA,DIE,DIK,DR
    120         ..;Set reminder to dialog pointer
    121         .. S DR="51///^S X=DNAME",DIE="^PXD(811.9,",DA=RIEN
    122         .. D ^DIE
    123         ;
    124         ;Save the install history.
    125         D SAVHIST^PXRMEXU1
    126         ;If any components were skipped send the message.
    127         I $D(^TMP("PXRMEXNI",$J)) D
    128         . N NE,XMSUB
    129         . S NE=$O(^TMP("PXRMEXNI",$J,""),-1)+1
    130         . S ^TMP("PXRMEXNI",$J,NE,0)="Please review and make changes as necessary."
    131         . K ^TMP("PXRMXMZ",$J)
    132         . M ^TMP("PXRMXMZ",$J)=^TMP("PXRMEXNI",$J)
    133         . S XMSUB="COMPONENTS SKIPPED DURING SILENT MODE INSTALL"
    134         . D SEND^PXRMMSG(XMSUB)
    135         ;Cleanup TMP globals.
    136         D INITMPG
    137         Q
    138         ;
     1PXRMEXSI ; SLC/PKR/PJH - Silent repository entry install. ;12/22/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;===================================================
     5BUILD ;Build list manager workfile from ^TMP("PXRMEXTMP" (see ^PXRMEXLB)
     6 N DDATA,DDLG,IND,JND,NLINE,NSEL
     7 S NLINE=0,NSEL=0
     8 S DDLG=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM")) Q:DDLG=""
     9 ;
     10 ;Save reminder dialog
     11 S DDATA=^TMP("PXRMEXTMP",$J,"DLOC",DDLG)
     12 S IND=$P(DDATA,U,3),JND=$P(DDATA,U,4)
     13 D DSAVE(DDLG,IND,JND)
     14 ;
     15 ;Process sub-components
     16 I $D(^TMP("PXRMEXTMP",$J,"DREPL",DDLG))>0 D DREPL(DDLG)
     17 D DCMP(DDLG)
     18 Q
     19 ;
     20 ;===================================================
     21DCMP(DLG) ;Search for dialog components
     22 N DDLG,DEND,DNAM,DSEQ,DSTRT,IND,JND
     23 S DSEQ=0
     24 F  S DSEQ=$O(^TMP("PXRMEXTMP",$J,"DMAP",DLG,DSEQ)) Q:'DSEQ  D
     25 . S DDATA=^TMP("PXRMEXTMP",$J,"DMAP",DLG,DSEQ)
     26 . S DNAM=$P(DDATA,U),DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3) Q:DNAM=""
     27 . S IND=$P(DDATA,U,4),JND=$P(DDATA,U,5)
     28 .;Save line in workfile
     29 . D DSAVE(DNAM,IND,JND)
     30 .;
     31 . I $D(^TMP("PXRMEXTMP",$J,"DREPL",DNAM))>0 D DREPL(DNAM)
     32 .;Process any sub-components
     33 . I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAM)) D DCMP(DNAM)
     34 Q
     35 ;
     36 ;===================================================
     37DREPL(DLG,LEV) ;
     38 N DDATA,DDLG,DEND,DNAM,DSEQ,DSTRT,IND,JND
     39 S DDATA=^TMP("PXRMEXTMP",$J,"DREPL",DLG)
     40 S DNAM=$P(DDATA,U),DSTRT=$P(DDATA,U,2),DEND=$P(DDATA,U,3) Q:DNAM=""
     41 S IND=$P(DDATA,U,4),JND=$P(DDATA,U,5)
     42 ;Save line in workfile
     43 D DSAVE(DNAM,IND,JND)
     44 I $D(^TMP("PXRMEXTMP",$J,"DMAP",DNAM)) D DCMP(DNAM)
     45 Q
     46 ;===================================================
     47DSAVE(DNAM,IND,JND) ;Update workfile
     48 ;Ignore national prompts
     49 I $$PXRM^PXRMEXID(DNAM) Q
     50 N DEXIST
     51 S NSEL=NSEL+1
     52 ;Check if dialog exists
     53 S DEXIST=$$EXISTS^PXRMEXIU(801.41,DNAM)
     54 ;Store the file number, start and stop line in the exchange file.
     55 S ^TMP("PXRMEXLD",$J,"SEL",NSEL)=FILENUM_U_IND_U_JND_U_DEXIST
     56 Q
     57 ;
     58 ;===================================================
     59INITMPG ;Initialize ^TMP arrays.
     60 K ^TMP("PXRMEXIA",$J)
     61 K ^TMP("PXRMEXLC",$J)
     62 K ^TMP("PXRMEXLD",$J)
     63 K ^TMP("PXRMEXTMP",$J)
     64 Q
     65 ;
     66 ;===================================================
     67INSCOM(PXRMRIEN,IND,TEMP,REMNAME) ;Install component IND of PXRMRIEN.
     68 N ACTION,ATTR,END,EXISTS,FILENUM,IND120,JND120,NAME
     69 N PT01,RTN,START
     70 S FILENUM=$P(TEMP,U,1),EXISTS=$P(TEMP,U,4)
     71 S IND120=$P(TEMP,U,2),JND120=$P(TEMP,U,3)
     72 S TEMP=^PXD(811.8,PXRMRIEN,120,IND120,1,JND120,0)
     73 I (FILENUM=801.41)!(FILENUM=811.5) S ACTION=$S(EXISTS:"M",1:"I")
     74 E  S ACTION=$S(EXISTS:"O",1:"I")
     75 S START=$P(TEMP,U,2)
     76 S END=$P(TEMP,U,3)
     77 S TEMP=^PXD(811.8,PXRMRIEN,100,START,0)
     78 I FILENUM=0 D
     79 . D RTNLD^PXRMEXIC(PXRMRIEN,START,END,.ATTR,.RTN)
     80 .;Save what was done for the installation summary.
     81 . S ^TMP("PXRMEXIA",$J,IND,"ROUTINE",ATTR("NAME"),ACTION)=""
     82 E  D
     83 . S PT01=$P(TEMP,"~",2)
     84 . S (ATTR("NAME"),ATTR("PT01"))=PT01
     85 . D SETATTR^PXRMEXFI(.ATTR,FILENUM)
     86 .;Save what was done for the installation summary.
     87 . S ^TMP("PXRMEXIA",$J,IND,ATTR("FILE NAME"),PT01,ACTION)=""
     88 ;Install this component.
     89 I FILENUM=0 D RTNSAVE^PXRMEXIC(.RTN,ATTR("NAME"))
     90 E  D FILE^PXRMEXIC(PXRMRIEN,EXISTS,IND120,JND120,ACTION,.ATTR,.PXRMNMCH)
     91 ;Save reminder name
     92 I FILENUM=811.9 S REMNAME=PT01
     93 ;If this component was not installed add to the no install message.
     94 Q
     95 ;
     96 ;===================================================
     97INSDLG(PXRMRIEN) ;Install dialog components (in reverse order)
     98 ;
     99 K ^TMP("PXRMEXSI",$J)
     100 N IND,TEMP,JND120,KIDSDONE
     101 ;Build list of components
     102 D BUILD
     103 S IND="",KIDSDONE=0
     104 F  S IND=$O(^TMP("PXRMEXLD",$J,"SEL",IND),-1) Q:'IND!(KIDSDONE=1)  D
     105 . S TEMP=^TMP("PXRMEXLD",$J,"SEL",IND),JND120=$P(TEMP,U,3)
     106 .;Skip install if dialog occurs more than once
     107 . I $D(^TMP("PXRMEXSI",$J,JND120)) Q
     108 . S ^TMP("PXRMEXSI",$J,JND120)=""
     109 .;Silent Dialog Install
     110 . D INSCOM(PXRMRIEN,IND,TEMP,.REMNAME)
     111 K ^TMP("PXRMEXSI",$J)
     112 Q
     113 ;
     114 ;===================================================
     115INSTALL(PXRMRIEN,NOR) ;Install all components in a repository entry.
     116 ;If NOR is true do not install routines.
     117 N DNAME,FILENUM,IND,PXRMNMCH,REMNAME,TEMP
     118 S NOR=$G(NOR)
     119 ;Initialize ^TMP globals.
     120 D INITMPG
     121 ;Build the component list.
     122 K ^PXD(811.8,PXRMRIEN,100,"B")
     123 K ^PXD(811.8,PXRMRIEN,120)
     124 D CLIST^PXRMEXU1(.PXRMRIEN)
     125 I PXRMRIEN=-1 Q
     126 ;Build the selectable list.
     127 D CDISP^PXRMEXLC(PXRMRIEN)
     128 ;Set the install date and time.
     129 S ^TMP("PXRMEXIA",$J,"DT")=$$NOW^XLFDT
     130 ;Initialize the name change storage.
     131 K PXRMNMCH
     132 S IND=0
     133 F  S IND=$O(^TMP("PXRMEXLC",$J,"SEL",IND)) Q:+IND=0  D
     134 . S TEMP=^TMP("PXRMEXLC",$J,"SEL",IND)
     135 . S FILENUM=$P(TEMP,U,1)
     136 .;If NOR is true do not install routines.
     137 . I FILENUM=0,NOR Q
     138 . ;Install dialog components
     139 . I FILENUM=801.41 N PXRMDONE S PXRMDONE=0 D INSDLG(PXRMRIEN) Q
     140 . ;Install component
     141 . E  D INSCOM(PXRMRIEN,IND,TEMP,.REMNAME)
     142 ;
     143 ;Get the dialog name
     144 S DNAME=$G(^TMP("PXRMEXTMP",$J,"PXRMDNAM"))
     145 ;Link the dialog if it exists
     146 I DNAME'="" D
     147 . N DIEN,RIEN
     148 .;Get the dialog ien
     149 . S DIEN=$$EXISTS^PXRMEXIU(801.41,DNAME) Q:'DIEN
     150 .;Get the reminder ien
     151 . S RIEN=+$$EXISTS^PXRMEXIU(811.9,$G(REMNAME)) Q:'RIEN
     152 . I RIEN>0 D
     153 .. N DA,DIE,DIK,DR
     154 ..;Set reminder to dialog pointer
     155 .. S DR="51///^S X=DNAME",DIE="^PXD(811.9,",DA=RIEN
     156 .. D ^DIE
     157 ;
     158 ;Save the install history.
     159 D SAVHIST^PXRMEXU1
     160 ;If any components were skipped send the message.
     161 I $D(^TMP("PXRMEXNI",$J)) D
     162 . N NE,XMSUB
     163 . S NE=$O(^TMP("PXRMEXNI",$J,""),-1)+1
     164 . S ^TMP("PXRMEXNI",$J,NE,0)="Please review and make changes as necessary."
     165 . K ^TMP("PXRMXMZ",$J)
     166 . M ^TMP("PXRMXMZ",$J)=^TMP("PXRMEXNI",$J)
     167 . S XMSUB="COMPONENTS SKIPPED DURING SILENT MODE INSTALL"
     168 . D SEND^PXRMMSG(XMSUB)
     169 ;Cleanup TMP globals.
     170 D INITMPG
     171 Q
     172 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXU1.m

    r613 r623  
    1 PXRMEXU1        ; SLC/PKR/PJH - Reminder exchange repository utilities, #1.;08/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;=====================================================
    4 CLIST(IEN)      ;Build the list of components for the repository
    5         ;entry IEN. EXTYPE is the type of Exchange entry. The default is
    6         ;reminder.
    7         N COMIND,COMORDR,CSTART,CSUM,END,FILENAME,FILENUM
    8         N IND,INDEXAT,JND,LINE,NCMPNT,NCTYPE,NITEMS,NLINES,NUMCMPNT
    9         N PT01,START,TEMP,TAG,TYPE,UCOM,VERSN
    10         S LINE=^PXD(811.8,IEN,100,1,0)
    11         ;Make sure it is XML version 1.
    12         I LINE'["<?xml version=""1.0""" D  Q
    13         . W !,"Exchange file entry not in proper format!"
    14         . S IEN=-1
    15         . H 2
    16         S LINE=^PXD(811.8,IEN,100,2,0)
    17         I LINE'="<REMINDER_EXCHANGE_FILE_ENTRY>" D  Q
    18         . W !,"Not an Exchange File entry!"
    19         . S IEN=-1
    20         . H 2
    21         S LINE=^PXD(811.8,IEN,100,3,0)
    22         S VERSN=$$GETTAGV^PXRMEXU3(LINE,"<PACKAGE_VERSION>")
    23         S LINE=^PXD(811.8,IEN,100,4,0)
    24         S INDEXAT=+$P(LINE,"<INDEX_AT>",2)
    25         S LINE=^PXD(811.8,IEN,100,INDEXAT,0)
    26         I LINE'="<INDEX>" D  Q
    27         . W !,"Index missing, cannot continue!"
    28         . S IEN=-1
    29         . H 2
    30         S JND=INDEXAT+1
    31         S LINE=^PXD(811.8,IEN,100,JND,0)
    32         S NCMPNT=+$$GETTAGV^PXRMEXU3(LINE,"<NUMBER_OF_COMPONENTS>")
    33         K ^TMP($J,"CMPNT")
    34         F IND=1:1:NCMPNT D
    35         . K END,START
    36         . F  S JND=JND+1,LINE=^PXD(811.8,IEN,100,JND,0) Q:LINE="</COMPONENT>"  D
    37         .. S TAG=$$GETTAG^PXRMEXU3(LINE)
    38         .. I TAG["START" S START(TAG)=+$$GETTAGV^PXRMEXU3(LINE,TAG)
    39         .. I TAG["END" S END(TAG)=+$$GETTAGV^PXRMEXU3(LINE,TAG)
    40         . I $D(START("<M_ROUTINE_START>")) D
    41         .. S CSTART=START("<M_ROUTINE_START>")
    42         .. S ^TMP($J,"CMPNT",IND,"TYPE")="ROUTINE"
    43         .. S LINE=^PXD(811.8,IEN,100,CSTART+1,0)
    44         .. S ^TMP($J,"CMPNT",IND,"NAME")=$$GETTAGV^PXRMEXU3(LINE,"<ROUTINE_NAME>")
    45         .. S ^TMP($J,"CMPNT",IND,"FILENUM")=0
    46         ..;Save the actual start and end of the code.
    47         .. S ^TMP($J,"CMPNT",IND,"START")=START("<ROUTINE_CODE_START>")
    48         .. S ^TMP($J,"CMPNT",IND,"END")=END("<ROUTINE_CODE_END>")
    49         . I $D(START("<FILE_START>")) D
    50         .. S CSTART=START("<FILE_START>")
    51         .. S LINE=^PXD(811.8,IEN,100,CSTART+1,0)
    52         .. S (^TMP($J,"CMPNT",IND,"TYPE"),^TMP($J,"CMPNT",IND,"FILENAME"))=$$GETTAGV^PXRMEXU3(LINE,"<FILE_NAME>",1)
    53         .. S LINE=^PXD(811.8,IEN,100,CSTART+2,0)
    54         .. S ^TMP($J,"CMPNT",IND,"FILENUM")=$$GETTAGV^PXRMEXU3(LINE,"<FILE_NUMBER>")
    55         .. S LINE=^PXD(811.8,IEN,100,CSTART+3,0)
    56         .. S (^TMP($J,"CMPNT",IND,"NAME"),^TMP($J,"CMPNT",IND,"POINT_01"))=$$GETTAGV^PXRMEXU3(LINE,"<POINT_01>",1)
    57         ..;Save the actual start and end of the FileMan FDA.
    58         .. S ^TMP($J,"CMPNT",IND,"FDA_START")=START("<FDA_START>")
    59         .. S ^TMP($J,"CMPNT",IND,"FDA_END")=END("<FDA_END>")
    60         .. S ^TMP($J,"CMPNT",IND,"IEN_ROOT_START")=$G(START("<IEN_ROOT_START>"))
    61         .. S ^TMP($J,"CMPNT",IND,"IEN_ROOT_END")=$G(END("<IEN_ROOT_END>"))
    62         ;Build some indexes to order the component list.
    63         F IND=1:1:NCMPNT D
    64         . S TYPE=^TMP($J,"CMPNT",IND,"TYPE")
    65         . S COMIND(TYPE,IND)=""
    66         . S UCOM(TYPE)=""
    67         ;Build the component order for display and install.
    68         D CORDER^PXRMEXCO(IEN,.UCOM,.NUMCMPNT,.COMORDR)
    69         ;Set the 0 node.
    70         S ^PXD(811.8,IEN,120,0)=U_"811.802A"_U_NCMPNT_U_NCMPNT
    71         S NCTYPE=0
    72         S NITEMS=0
    73         F NCTYPE=1:1:NUMCMPNT D
    74         . S TYPE=$O(COMORDR(NCTYPE,""))
    75         . S NITEMS=0
    76         . S IND=""
    77         . F  S IND=$O(COMIND(TYPE,IND)) Q:IND=""  D
    78         .. S NITEMS=NITEMS+1
    79         .. I NITEMS=1 S FILENUM=^TMP($J,"CMPNT",IND,"FILENUM")
    80         .. I TYPE="ROUTINE" S TEMP=^TMP($J,"CMPNT",IND,"NAME")_U_^TMP($J,"CMPNT",IND,"START")_U_^TMP($J,"CMPNT",IND,"END")
    81         .. E  S TEMP=^TMP($J,"CMPNT",IND,"NAME")_U_^TMP($J,"CMPNT",IND,"FDA_START")_U_^TMP($J,"CMPNT",IND,"FDA_END")_U_$G(^TMP($J,"CMPNT",IND,"IEN_ROOT_START"))_U_$G(^TMP($J,"CMPNT",IND,"IEN_ROOT_END"))
    82         .. S ^PXD(811.8,IEN,120,NCTYPE,1,NITEMS,0)=TEMP
    83         . S ^PXD(811.8,IEN,120,NCTYPE,0)=TYPE_U_FILENUM_U_NITEMS
    84         . S ^PXD(811.8,IEN,120,NCTYPE,1,0)=U_"811.8021A"_U_NITEMS_U_NITEMS
    85         ;
    86         ;Save the number of component types.
    87         S ^PXD(811.8,IEN,119)=NCTYPE
    88         K ^TMP($J,"CMPNT")
    89         Q
    90         ;
    91         ;=====================================================
    92 DELETE(LIST)    ;Delete the repository entries in LIST.
    93         N DA,DIK
    94         S DIK="^PXD(811.8,"
    95         S DA=""
    96         F  S DA=$O(LIST(DA)) Q:+DA=0  D ^DIK
    97         Q
    98         ;
    99         ;=====================================================
    100 DELHIST(RIEN,IHIEN)     ;Delete install history IHIEN in repository entry RIEN.
    101         N DA,DIK
    102         S DA=IHIEN,DA(1)=RIEN
    103         S DIK="^PXD(811.8,"_DA(1)_",130,"
    104         D ^DIK
    105         Q
    106         ;
    107         ;=====================================================
    108 DESC(RIEN,DESL,DESC,KEYWORD)    ;Build the description.
    109         N JND,LC,NKEYW
    110         S LC=1
    111         S ^PXD(811.8,RIEN,110,LC,0)="Reminder:    "_DESL("RNAME")
    112         S LC=LC+1
    113         S ^PXD(811.8,RIEN,110,LC,0)="Source:      "_DESL("SOURCE")
    114         S LC=LC+1
    115         S ^PXD(811.8,RIEN,110,LC,0)="Date Packed: "_DESL("DATEP")
    116         S LC=LC+1
    117         S ^PXD(811.8,RIEN,110,LC,0)="Package Version: "_DESL("VRSN")
    118         S LC=LC+1
    119         S ^PXD(811.8,RIEN,110,LC,0)=""
    120         ;Add the user's description.
    121         S LC=LC+1
    122         S ^PXD(811.8,RIEN,110,LC,0)="Description:"
    123         F JND=1:1:+$P($G(@DESC@(1,0)),U,4) D
    124         . S LC=LC+1
    125         . S ^PXD(811.8,RIEN,110,LC,0)=@DESC@(1,JND,0)
    126         S LC=LC+1
    127         S ^PXD(811.8,RIEN,110,LC,0)=""
    128         ;Add the keywords.
    129         S LC=LC+1
    130         S ^PXD(811.8,RIEN,110,LC,0)="Keywords:"
    131         S NKEYW=+$P($G(@KEYWORD@(1,0)),U,4)
    132         I NKEYW=0 D
    133         . S LC=LC+1
    134         . S ^PXD(811.8,RIEN,110,LC,0)="No keywords given"
    135         F JND=1:1:NKEYW D
    136         . S LC=LC+1
    137         . S ^PXD(811.8,RIEN,110,LC,0)=@KEYWORD@(1,JND,0)
    138         S LC=LC+1
    139         S ^PXD(811.8,RIEN,110,LC,0)=""
    140         S LC=LC+1
    141         S ^PXD(811.8,RIEN,110,LC,0)="Components:"
    142         S ^PXD(811.8,RIEN,110,0)=U_811.804_U_LC_U_LC
    143         Q
    144         ;
    145         ;=====================================================
    146 RIEN(LIEN)      ;Given the list ien return the repository ien.
    147         N RIEN
    148         S RIEN=$G(^TMP("PXRMEXLR",$J,"SEL",LIEN))
    149         Q RIEN
    150         ;
    151         ;=====================================================
    152 SAVHIST ;Save the installation history in the repository.
    153         N ACTION,DATE,CMPNT,FTYPE,IND,INDEX,ITEM,JND,NEWNAME
    154         N SUB,TEMP,TOTAL,TYPE,USER
    155         ;Find the first open spot in the Installation History node.
    156         S (IND,JND)=0
    157         F  S IND=+$O(^PXD(811.8,PXRMRIEN,130,IND)) S JND=JND+1 Q:(IND=0)!(IND>JND)
    158         S IND=JND
    159         S JND=0
    160         F SUB="PXRMEXIA","PXRMEXIAD" D
    161         . S INDEX=0
    162         . F  S INDEX=$O(^TMP(SUB,$J,INDEX)) Q:+INDEX=0  D
    163         .. S JND=JND+1
    164         .. S CMPNT=$O(^TMP(SUB,$J,INDEX,""))
    165         .. S ITEM=$O(^TMP(SUB,$J,INDEX,CMPNT,""))
    166         .. S ACTION=$O(^TMP(SUB,$J,INDEX,CMPNT,ITEM,""))
    167         .. S NEWNAME=$G(^TMP(SUB,$J,INDEX,CMPNT,ITEM,ACTION))
    168         .. S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,0)=INDEX_U_CMPNT_U_ITEM_U_ACTION_U_NEWNAME
    169         ..;Set the 0 node.
    170         .. S ^PXD(811.8,PXRMRIEN,130,IND,1,0)=U_"811.8031A"_U_JND_U_JND
    171         ..;Check for finding item changes and save them.
    172         .. S FTYPE=""
    173         .. I CMPNT["DEFINITION" S FTYPE="DEFF"
    174         .. I CMPNT["DIALOG" S FTYPE="DIAF"
    175         .. I CMPNT["TERM" S FTYPE="TRMF"
    176         .. I (FTYPE'=""),($D(^TMP(SUB,$J,FTYPE))) D
    177         ... N FI,FINDING,KND,OFINDING
    178         ... S KND=2
    179         ... S FI=""
    180         ... F  S FI=$O(^TMP(SUB,$J,FTYPE,FI)) Q:FI=""  D
    181         .... S OFINDING=$O(^TMP(SUB,$J,FTYPE,FI,""))
    182         .... S FINDING=^TMP(SUB,$J,FTYPE,FI,OFINDING)
    183         .... I OFINDING=FINDING Q
    184         .... S KND=KND+1
    185         .... S TEMP=$E(OFINDING,1,33)
    186         .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,KND,0)="    "_TEMP_$$INSCHR^PXRMEXLC((35-$L(TEMP))," ")_FINDING
    187         ... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,0)=U_"811.80315A"_U_KND_U_KND
    188         ... I KND>2 D
    189         .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,1,0)="   Finding Changes"
    190         .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,2,0)="     Original"_$$INSCHR^PXRMEXLC(27," ")_"New"
    191         ..;
    192         ..;Check for TIU template replacements and save them.
    193         .. I CMPNT["DIALOG" S FTYPE="DIATIU"
    194         .. E  S FTYPE=""
    195         .. I (FTYPE'=""),($D(^TMP(SUB,$J,FTYPE))) D
    196         ... N KND,OTIUT,TIUT,TYPE
    197         ... S TYPE=""
    198         ... S KND=2
    199         ... F  S TYPE=$O(^TMP(SUB,$J,FTYPE,TYPE)) Q:TYPE=""  D
    200         .... S OTIUT=""
    201         .... F  S OTIUT=$O(^TMP(SUB,$J,FTYPE,TYPE,OTIUT)) Q:OTIUT=""  D
    202         ..... S TIUT=$G(^TMP(SUB,$J,FTYPE,TYPE,OTIUT))
    203         ..... I OTIUT=TIUT Q
    204         ..... I '$D(^TMP(SUB,$J,FTYPE,TYPE,OTIUT,ITEM)) Q
    205         ..... S KND=KND+1
    206         ..... S TEMP=$E(OTIUT,1,33)
    207         ..... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,KND,0)="    "_TEMP_$$INSCHR^PXRMEXLC((35-$L(TEMP))," ")_TIUT
    208         .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,0)=U_"811.80315A"_U_KND_U_KND
    209         .... I KND>2 D
    210         ..... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,1,0)="   "_TYPE
    211         ..... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,2,0)="     Original"_$$INSCHR^PXRMEXLC(27," ")_"New"
    212         ;If JND is still 0 then there was nothing to save.
    213         I JND>0 D
    214         .;Save the header information.
    215         . S DATE=^TMP("PXRMEXIA",$J,"DT")
    216         . S TYPE=^TMP("PXRMEXIA",$J,"TYPE")
    217         . S USER=$$GET1^DIQ(200,DUZ,.01,"")
    218         . S ^PXD(811.8,PXRMRIEN,130,IND,0)=DATE_U_USER_U_TYPE
    219         . S ^PXD(811.8,PXRMRIEN,130,"B",DATE,IND)=""
    220         .;Set the 0 node.
    221         . S (KND,TOTAL)=0
    222         . F  S KND=+$O(^PXD(811.8,PXRMRIEN,130,KND)) Q:KND=0  S TOTAL=TOTAL+1
    223         . S ^PXD(811.8,PXRMRIEN,130,0)=U_"811.803DA"_U_IND_U_TOTAL
    224         K ^TMP("PXRMEXIA",$J)
    225         K ^TMP("PXRMEXIAD",$J)
    226         Q
    227         ;
     1PXRMEXU1 ; SLC/PKR/PJH - Reminder exchange repository utilities, #1. ;09/20/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;=====================================================
     4CLIST(IEN) ;Build the list of components for the repository
     5 ;entry IEN. EXTYPE is the type of Exchange entry. The default is
     6 ;reminder.
     7 N COMIND,COMORDR,CSTART,CSUM,END,FILENAME,FILENUM
     8 N IND,INDEXAT,JND,LINE,NCMPNT,NCTYPE,NITEMS,NLINES,NUMCMPNT
     9 N PT01,START,TEMP,TAG,TYPE,UCOM,VERSN
     10 S LINE=^PXD(811.8,IEN,100,1,0)
     11 ;Make sure it is XML version 1.
     12 I LINE'["<?xml version=""1.0""" D  Q
     13 . W !,"Exchange file entry not in proper format!"
     14 . S IEN=-1
     15 . H 2
     16 S LINE=^PXD(811.8,IEN,100,2,0)
     17 I LINE'="<REMINDER_EXCHANGE_FILE_ENTRY>" D  Q
     18 . W !,"Not an Exchange File entry!"
     19 . S IEN=-1
     20 . H 2
     21 S LINE=^PXD(811.8,IEN,100,3,0)
     22 S VERSN=$$GETTAGV^PXRMEXU3(LINE,"<PACKAGE_VERSION>")
     23 S LINE=^PXD(811.8,IEN,100,4,0)
     24 S INDEXAT=+$P(LINE,"<INDEX_AT>",2)
     25 S LINE=^PXD(811.8,IEN,100,INDEXAT,0)
     26 I LINE'="<INDEX>" D  Q
     27 . W !,"Index missing, cannot continue!"
     28 . S IEN=-1
     29 . H 2
     30 S JND=INDEXAT+1
     31 S LINE=^PXD(811.8,IEN,100,JND,0)
     32 S NCMPNT=+$$GETTAGV^PXRMEXU3(LINE,"<NUMBER_OF_COMPONENTS>")
     33 K ^TMP($J,"CMPNT")
     34 F IND=1:1:NCMPNT D
     35 . K END,START
     36 . F  S JND=JND+1,LINE=^PXD(811.8,IEN,100,JND,0) Q:LINE="</COMPONENT>"  D
     37 .. S TAG=$$GETTAG^PXRMEXU3(LINE)
     38 .. I TAG["START" S START(TAG)=+$$GETTAGV^PXRMEXU3(LINE,TAG)
     39 .. I TAG["END" S END(TAG)=+$$GETTAGV^PXRMEXU3(LINE,TAG)
     40 . I $D(START("<M_ROUTINE_START>")) D
     41 .. S CSTART=START("<M_ROUTINE_START>")
     42 .. S ^TMP($J,"CMPNT",IND,"TYPE")="ROUTINE"
     43 .. S LINE=^PXD(811.8,IEN,100,CSTART+1,0)
     44 .. S ^TMP($J,"CMPNT",IND,"NAME")=$$GETTAGV^PXRMEXU3(LINE,"<ROUTINE_NAME>")
     45 .. S ^TMP($J,"CMPNT",IND,"FILENUM")=0
     46 ..;Save the actual start and end of the code.
     47 .. S ^TMP($J,"CMPNT",IND,"START")=START("<ROUTINE_CODE_START>")
     48 .. S ^TMP($J,"CMPNT",IND,"END")=END("<ROUTINE_CODE_END>")
     49 . I $D(START("<FILE_START>")) D
     50 .. S CSTART=START("<FILE_START>")
     51 .. S LINE=^PXD(811.8,IEN,100,CSTART+1,0)
     52 .. S (^TMP($J,"CMPNT",IND,"TYPE"),^TMP($J,"CMPNT",IND,"FILENAME"))=$$GETTAGV^PXRMEXU3(LINE,"<FILE_NAME>",1)
     53 .. S LINE=^PXD(811.8,IEN,100,CSTART+2,0)
     54 .. S ^TMP($J,"CMPNT",IND,"FILENUM")=$$GETTAGV^PXRMEXU3(LINE,"<FILE_NUMBER>")
     55 .. S LINE=^PXD(811.8,IEN,100,CSTART+3,0)
     56 .. S (^TMP($J,"CMPNT",IND,"NAME"),^TMP($J,"CMPNT",IND,"POINT_01"))=$$GETTAGV^PXRMEXU3(LINE,"<POINT_01>",1)
     57 ..;Save the actual start and end of the FileMan FDA.
     58 .. S ^TMP($J,"CMPNT",IND,"FDA_START")=START("<FDA_START>")
     59 .. S ^TMP($J,"CMPNT",IND,"FDA_END")=END("<FDA_END>")
     60 .. S ^TMP($J,"CMPNT",IND,"IEN_ROOT_START")=$G(START("<IEN_ROOT_START>"))
     61 .. S ^TMP($J,"CMPNT",IND,"IEN_ROOT_END")=$G(END("<IEN_ROOT_END>"))
     62 ;Build some indexes to order the component list.
     63 F IND=1:1:NCMPNT D
     64 . S TYPE=^TMP($J,"CMPNT",IND,"TYPE")
     65 . S COMIND(TYPE,IND)=""
     66 . S UCOM(TYPE)=""
     67 ;Build the component order for display and install.
     68 D CORDER^PXRMEXCO(IEN,.UCOM,.NUMCMPNT,.COMORDR)
     69 ;Set the 0 node.
     70 S ^PXD(811.8,IEN,120,0)=U_"811.802A"_U_NCMPNT_U_NCMPNT
     71 S NCTYPE=0
     72 S NITEMS=0
     73 F NCTYPE=1:1:NUMCMPNT D
     74 . S TYPE=$O(COMORDR(NCTYPE,""))
     75 . S NITEMS=0
     76 . S IND=""
     77 . F  S IND=$O(COMIND(TYPE,IND)) Q:IND=""  D
     78 .. S NITEMS=NITEMS+1
     79 .. I NITEMS=1 S FILENUM=^TMP($J,"CMPNT",IND,"FILENUM")
     80 .. I TYPE="ROUTINE" S TEMP=^TMP($J,"CMPNT",IND,"NAME")_U_^TMP($J,"CMPNT",IND,"START")_U_^TMP($J,"CMPNT",IND,"END")
     81 .. E  S TEMP=^TMP($J,"CMPNT",IND,"NAME")_U_^TMP($J,"CMPNT",IND,"FDA_START")_U_^TMP($J,"CMPNT",IND,"FDA_END")_U_$G(^TMP($J,"CMPNT",IND,"IEN_ROOT_START"))_U_$G(^TMP($J,"CMPNT",IND,"IEN_ROOT_END"))
     82 .. S ^PXD(811.8,IEN,120,NCTYPE,1,NITEMS,0)=TEMP
     83 . S ^PXD(811.8,IEN,120,NCTYPE,0)=TYPE_U_FILENUM_U_NITEMS
     84 . S ^PXD(811.8,IEN,120,NCTYPE,1,0)=U_"811.8021A"_U_NITEMS_U_NITEMS
     85 ;
     86 ;Save the number of component types.
     87 S ^PXD(811.8,IEN,119)=NCTYPE
     88 K ^TMP($J,"CMPNT")
     89 Q
     90 ;
     91 ;=====================================================
     92DELETE(LIST) ;Delete the repository entries in LIST.
     93 N DA,DIK
     94 S DIK="^PXD(811.8,"
     95 S DA=""
     96 F  S DA=$O(LIST(DA)) Q:+DA=0  D ^DIK
     97 Q
     98 ;
     99 ;=====================================================
     100DELHIST(RIEN,IHIND) ;Delete install history IHIND in repository entry RIEN.
     101 N DATE
     102 S DATE=$P(^PXD(811.8,RIEN,130,IHIND,0),U)
     103 K ^PXD(811.8,RIEN,130,IHIND)
     104 K ^PXD(811.8,RIEN,130,"B",DATE)
     105 Q
     106 ;
     107 ;=====================================================
     108DESC(RIEN,DESL,DESC,KEYWORD) ;Build the description.
     109 N JND,LC,NKEYW
     110 S LC=1
     111 S ^PXD(811.8,RIEN,110,LC,0)="Reminder:    "_DESL("RNAME")
     112 S LC=LC+1
     113 S ^PXD(811.8,RIEN,110,LC,0)="Source:      "_DESL("SOURCE")
     114 S LC=LC+1
     115 S ^PXD(811.8,RIEN,110,LC,0)="Date Packed: "_DESL("DATEP")
     116 S LC=LC+1
     117 S ^PXD(811.8,RIEN,110,LC,0)="Package Version: "_DESL("VRSN")
     118 S LC=LC+1
     119 S ^PXD(811.8,RIEN,110,LC,0)=""
     120 ;Add the user's description.
     121 S LC=LC+1
     122 S ^PXD(811.8,RIEN,110,LC,0)="Description:"
     123 F JND=1:1:+$P($G(@DESC@(1,0)),U,4) D
     124 . S LC=LC+1
     125 . S ^PXD(811.8,RIEN,110,LC,0)=@DESC@(1,JND,0)
     126 S LC=LC+1
     127 S ^PXD(811.8,RIEN,110,LC,0)=""
     128 ;Add the keywords.
     129 S LC=LC+1
     130 S ^PXD(811.8,RIEN,110,LC,0)="Keywords:"
     131 S NKEYW=+$P($G(@KEYWORD@(1,0)),U,4)
     132 I NKEYW=0 D
     133 . S LC=LC+1
     134 . S ^PXD(811.8,RIEN,110,LC,0)="No keywords given"
     135 F JND=1:1:NKEYW D
     136 . S LC=LC+1
     137 . S ^PXD(811.8,RIEN,110,LC,0)=@KEYWORD@(1,JND,0)
     138 S LC=LC+1
     139 S ^PXD(811.8,RIEN,110,LC,0)=""
     140 S LC=LC+1
     141 S ^PXD(811.8,RIEN,110,LC,0)="Components:"
     142 S ^PXD(811.8,RIEN,110,0)=U_811.804_U_LC_U_LC
     143 Q
     144 ;
     145 ;=====================================================
     146RIEN(LIEN) ;Given the list ien return the repository ien.
     147 N RIEN
     148 S RIEN=$G(^TMP("PXRMEXLR",$J,"IDX",LIEN,LIEN))
     149 Q RIEN
     150 ;
     151 ;=====================================================
     152SAVHIST ;Save the installation history in the repository.
     153 N ACTION,DATE,CMPNT,FTYPE,IND,INDEX,ITEM,JND,NEWNAME,TEMP,USER
     154 ;Find the first open spot in the Installation History node.
     155 S (IND,JND)=0
     156 F  S IND=+$O(^PXD(811.8,PXRMRIEN,130,IND)) S JND=JND+1 Q:(IND=0)!(JND>IND)
     157 ;Set the 0 node.
     158 S ^PXD(811.8,PXRMRIEN,130,0)=U_"811.803DA"_U_JND_U_JND
     159 S IND=JND
     160 S DATE=^TMP("PXRMEXIA",$J,"DT")
     161 S USER=$$GET1^DIQ(200,DUZ,.01,"")
     162 S ^PXD(811.8,PXRMRIEN,130,IND,0)=DATE_U_USER
     163 S ^PXD(811.8,PXRMRIEN,130,"B",DATE,IND)=""
     164 S (INDEX,JND)=0
     165 F  S INDEX=$O(^TMP("PXRMEXIA",$J,INDEX)) Q:+INDEX=0  D
     166 . S JND=JND+1
     167 . S CMPNT=$O(^TMP("PXRMEXIA",$J,INDEX,""))
     168 . S ITEM=$O(^TMP("PXRMEXIA",$J,INDEX,CMPNT,""))
     169 . S ACTION=$O(^TMP("PXRMEXIA",$J,INDEX,CMPNT,ITEM,""))
     170 . S NEWNAME=$G(^TMP("PXRMEXIA",$J,INDEX,CMPNT,ITEM,ACTION))
     171 . S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,0)=INDEX_U_CMPNT_U_ITEM_U_ACTION_U_NEWNAME
     172 .;Set the 0 node.
     173 . S ^PXD(811.8,PXRMRIEN,130,IND,1,0)=U_"811.8031A"_U_JND_U_JND
     174 .;Check for finding item changes and save them.
     175 . S FTYPE=""
     176 . I CMPNT["DEFINITION" S FTYPE="DEFF"
     177 . I CMPNT["DIALOG" S FTYPE="DIAF"
     178 . I CMPNT["TERM" S FTYPE="TRMF"
     179 . I (FTYPE'=""),($D(^TMP("PXRMEXIA",$J,FTYPE))) D
     180 .. N FI,FINDING,KND,OFINDING
     181 .. S KND=2
     182 .. S FI=""
     183 .. F  S FI=$O(^TMP("PXRMEXIA",$J,FTYPE,FI)) Q:FI=""  D
     184 ... S OFINDING=$O(^TMP("PXRMEXIA",$J,FTYPE,FI,""))
     185 ... S FINDING=^TMP("PXRMEXIA",$J,FTYPE,FI,OFINDING)
     186 ... I OFINDING=FINDING Q
     187 ... S KND=KND+1
     188 ... S TEMP=$E(OFINDING,1,33)
     189 ... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,KND,0)="    "_TEMP_$$INSCHR^PXRMEXLC((35-$L(TEMP))," ")_FINDING
     190 .. S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,0)=U_"811.80315A"_U_KND_U_KND
     191 .. I KND>2 D
     192 ... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,1,0)="   Finding Changes"
     193 ... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,2,0)="     Original"_$$INSCHR^PXRMEXLC(27," ")_"New"
     194 .;
     195 .;Check for TIU template replacements and save them.
     196 . I CMPNT["DIALOG" S FTYPE="DIATIU"
     197 . E  S FTYPE=""
     198 . I (FTYPE'=""),($D(^TMP("PXRMEXIA",$J,FTYPE))) D
     199 .. N KND,OTIUT,TIUT,TYPE
     200 .. S TYPE=""
     201 .. S KND=2
     202 .. F  S TYPE=$O(^TMP("PXRMEXIA",$J,FTYPE,TYPE)) Q:TYPE=""  D
     203 ... S OTIUT=""
     204 ... F  S OTIUT=$O(^TMP("PXRMEXIA",$J,FTYPE,TYPE,OTIUT)) Q:OTIUT=""  D
     205 .... S TIUT=$G(^TMP("PXRMEXIA",$J,FTYPE,TYPE,OTIUT))
     206 .... I OTIUT=TIUT Q
     207 .... I '$D(^TMP("PXRMEXIA",$J,FTYPE,TYPE,OTIUT,ITEM)) Q
     208 .... S KND=KND+1
     209 .... S TEMP=$E(OTIUT,1,33)
     210 .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,KND,0)="    "_TEMP_$$INSCHR^PXRMEXLC((35-$L(TEMP))," ")_TIUT
     211 ... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,0)=U_"811.80315A"_U_KND_U_KND
     212 ... I KND>2 D
     213 .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,1,0)="   "_TYPE
     214 .... S ^PXD(811.8,PXRMRIEN,130,IND,1,JND,1,2,0)="     Original"_$$INSCHR^PXRMEXLC(27," ")_"New"
     215 K ^TMP("PXRMEXIA",$J)
     216 Q
     217 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXU2.m

    r613 r623  
    1 PXRMEXU2        ; SLC/PKR/PJH - Reminder exchange repository utilities, #2. ;11/21/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;=====================================================
    4 FDA(IND,LC,TMPIND,FILENAME)     ;Build the XML FDA output.
    5         N FIELD,FILENUM,INDEX,INDEX0,JND,SIENS,WPC
    6         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILEMAN_FDA>"
    7         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<![CDATA["
    8         ;Get the file number.
    9         S FILENUM=""
    10         F  S FILENUM=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM)) Q:FILENUM=""  D
    11         .;Get the source ien string.
    12         . S SIENS=""
    13         . F  S SIENS=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS)) Q:SIENS=""  D
    14         .. S INDEX0=FILENUM_";"_SIENS
    15         ..;Get the field number and store the data.
    16         .. S FIELD=""
    17         .. F  S FIELD=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD)) Q:FIELD=""  D
    18         ... S INDEX=INDEX0_";"_FIELD
    19         ...;If there is another index past the field then this is a
    20         ...;word-processing field.
    21         ... I $D(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD))=11 D
    22         .... S WPC=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD,""),-1)
    23         .... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=INDEX_"~WP-start~"_WPC
    24         .... F JND=1:1:WPC D
    25         ..... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD,JND)
    26         ... E  S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=INDEX_"~"_^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD)
    27         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]>"
    28         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</FILEMAN_FDA>"
    29         Q
    30         ;
    31         ;=====================================================
    32 IENROOT(IND,LC,TMPIND,FILENAME) ;Build the XML IEN_ROOT output.
    33         N INDEX,VALUE
    34         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<IEN_ROOT>"
    35         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<![CDATA["
    36         S INDEX=0
    37         F  S INDEX=$O(^TMP(TMPIND,$J,IND,FILENAME,INDEX)) Q:INDEX=""  D
    38         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=INDEX_U_^TMP(TMPIND,$J,IND,FILENAME,INDEX)
    39         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]>"
    40         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</IEN_ROOT>"
    41         Q
    42         ;
    43         ;=====================================================
    44 STOREPR(SUCCESS,RTM,TMPIND,EXTYPE)      ;^TMP(TMPIND,$J contains data to be
    45         ;stored in the repository. Routines will be found in
    46         ;^TMP(TMPIND,$J,"ROUTINE",ROUTINE NAME,n) where n is the line number.
    47         ;File entries will be found in ^TMP(TMPIND,$J,N,FILENAME,indexes).
    48         ;This is output from the GETS^DIQ call. There are NUMF file entries.
    49         ;Format and store it as XML in the repository.
    50         N DATE,DTEST,FDA,FILENAME,FILENUM
    51         N IENROOT,IND,JND,LC,LINE,NCMPNT,NEWFILE,NUMF,PT01,RNAME
    52         N SIENS,SOURCE,TEMP,VERSN
    53         ;If anything went wrong in the packing process then ^TMP(TMPIND,$J
    54         ;will not exist.
    55         I '$D(^TMP(TMPIND,$J)) S SUCCESS=0 Q
    56         ;
    57         K ^TMP($J,"CIND")
    58         K ^TMP("PXRMEXRS",$J)
    59         S ^TMP("PXRMEXRS",$J,1,0)="<?xml version=""1.0"" standalone=""yes""?>"
    60         S ^TMP("PXRMEXRS",$J,2,0)="<REMINDER_EXCHANGE_FILE_ENTRY>"
    61         S VERSN=$P(^PXRM(800,1,"VERSION"),U,1)
    62         S ^TMP("PXRMEXRS",$J,3,0)="<PACKAGE_VERSION>"_VERSN_"</PACKAGE_VERSION>"
    63         ;The pointer to the index will be on line 4 so leave room.
    64         S LC=4
    65         ;Save the source information.
    66         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<SOURCE>"
    67         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<NAME>"_$$TOXML^PXRMEXU3(^TMP(TMPIND,$J,"SRC","REMINDER"))_"</NAME>"
    68         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<USER>"_$$TOXML^PXRMEXU3(^TMP(TMPIND,$J,"SRC","USER"))_"</USER>"
    69         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<SITE>"_$$TOXML^PXRMEXU3(^TMP(TMPIND,$J,"SRC","SITE"))_"</SITE>"
    70         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<DATE_PACKED>"_^TMP(TMPIND,$J,"SRC","DATE")_"</DATE_PACKED>"
    71         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</SOURCE>"
    72         ;
    73         ;Save the Exchange Type.
    74         I EXTYPE="" S EXTYPE="REMINDER"
    75         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<EXCHANGE_TYPE>"_$$TOXML^PXRMEXU3(EXTYPE)_"</EXCHANGE_TYPE>"
    76         ;
    77         ;Save the description.
    78         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<DESCRIPTION><![CDATA["
    79         S IND=0
    80         F  S IND=$O(^TMP(TMPIND,$J,"DESC",1,IND)) Q:+IND=0  D
    81         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=^TMP(TMPIND,$J,"DESC",1,IND,0)
    82         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]></DESCRIPTION>"
    83         ;
    84         ;Save the keywords or phrases.
    85         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<KEYWORDS>"
    86         S IND=0
    87         F  S IND=$O(^TMP(TMPIND,$J,"KEYWORD",1,IND)) Q:+IND=0  D
    88         . S TEMP=^TMP(TMPIND,$J,"KEYWORD",1,IND,0)
    89         . I TEMP["," D
    90         .. F JND=1:1:$L(TEMP,",") D
    91         ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<KEYWORD>"_$$TOXML^PXRMEXU3($P(TEMP,",",JND))_"</KEYWORD>"
    92         . E  S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<KEYWORD>"_$$TOXML^PXRMEXU3(TEMP)_"</KEYWORD>"
    93         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</KEYWORDS>"
    94         ;
    95         S NCMPNT=0
    96         ;Do routines first.
    97         S RNAME=""
    98         F  S RNAME=$O(^TMP(TMPIND,$J,"ROUTINE",RNAME)) Q:RNAME=""  D
    99         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<M_ROUTINE>"
    100         . S NCMPNT=NCMPNT+1
    101         . S ^TMP($J,"CIND",NCMPNT,"M_ROUTINE_START")=LC
    102         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<ROUTINE_NAME>"_RNAME_"</ROUTINE_NAME>"
    103         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<CHECKSUM>"_^TMP("PXRMEXCS",$J,"ROUTINE",RNAME)_"</CHECKSUM>"
    104         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<CODE>"
    105         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<![CDATA["
    106         . S ^TMP($J,"CIND",NCMPNT,"ROUTINE_CODE_START")=LC+1
    107         . S LINE=0
    108         . F  S LINE=$O(^TMP(TMPIND,$J,"ROUTINE",RNAME,LINE)) Q:LINE=""  D
    109         .. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=^TMP(TMPIND,$J,"ROUTINE",RNAME,LINE,0)
    110         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]>"
    111         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</CODE>"
    112         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</M_ROUTINE>"
    113         . S ^TMP($J,"CIND",NCMPNT,"ROUTINE_CODE_END")=LC-3
    114         ;
    115         ;Do file entries.
    116         ;For word processing fields the first line is
    117         ;file number;source ien string;field~WP-start~line count
    118         ;The next line count lines are the WP data.
    119         S NUMF=+$G(^TMP(TMPIND,$J,"NUMF"))
    120         S FILENAME=""
    121         F IND=1:1:NUMF D
    122         . F  S FILENAME=$O(^TMP(TMPIND,$J,IND,FILENAME)) Q:FILENAME=""  D
    123         .. I FILENAME["IENROOT" D
    124         ... S NEWFILE=0
    125         ... S IENROOT=1
    126         .. E  D
    127         ... S NEWFILE=1
    128         ... S IENROOT=0
    129         .. I NEWFILE D
    130         ... S FILENUM=$O(^TMP(TMPIND,$J,IND,FILENAME,""))
    131         ... S SIENS=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,""))
    132         ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILEMAN_FILE>"
    133         ... S NCMPNT=NCMPNT+1
    134         ... S ^TMP($J,"CIND",NCMPNT,"FILE_START")=LC
    135         ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILE_NAME>"_$$TOXML^PXRMEXU3(FILENAME)_"</FILE_NAME>"
    136         ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILE_NUMBER>"_FILENUM_"</FILE_NUMBER>"
    137         ... S LC=LC+1,PT01=^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,.01)
    138         ... S ^TMP("PXRMEXRS",$J,LC,0)="<POINT_01>"_$$TOXML^PXRMEXU3(PT01)_"</POINT_01>"
    139         ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<INTERNAL_ENTRY_NUMBER>"_+SIENS_"</INTERNAL_ENTRY_NUMBER>"
    140         ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<CHECKSUM>"_^TMP("PXRMEXCS",$J,IND,FILENAME)_"</CHECKSUM>"
    141         ... S ^TMP($J,"CIND",NCMPNT,"FDA_START")=LC+3
    142         ... D FDA(IND,.LC,TMPIND,FILENAME)
    143         ... S ^TMP($J,"CIND",NCMPNT,"FDA_END")=LC-2
    144         ..;The ien root information always comes after the FDA.
    145         .. I IENROOT D
    146         ... S ^TMP($J,"CIND",NCMPNT,"IEN_ROOT_START")=LC+3
    147         ... D IENROOT(IND,.LC,TMPIND,FILENAME)
    148         ... S ^TMP($J,"CIND",NCMPNT,"IEN_ROOT_END")=LC-2
    149         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</FILEMAN_FILE>"
    150         ;Save the index.
    151         S LC=LC+1,^TMP("PXRMEXRS",$J,4,0)="<INDEX_AT>"_LC_"</INDEX_AT>"
    152         S ^TMP("PXRMEXRS",$J,LC,0)="<INDEX>"
    153         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<NUMBER_OF_COMPONENTS>"_NCMPNT_"</NUMBER_OF_COMPONENTS>"
    154         F IND=1:1:NCMPNT D
    155         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<COMPONENT>"
    156         . S JND=""
    157         . F  S JND=$O(^TMP($J,"CIND",IND,JND)) Q:JND=""  D
    158         .. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<"_JND_">"_^TMP($J,"CIND",IND,JND)_"</"_JND_">"
    159         . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</COMPONENT>"
    160         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</INDEX>"
    161         S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</REMINDER_EXCHANGE_FILE_ENTRY>"
    162         ;Establish the entry in the repository.
    163         S RNAME=$P(RTM,U,2)
    164         S SOURCE=^TMP(TMPIND,$J,"SRC","USER")_" at "_^TMP(TMPIND,$J,"SRC","SITE")
    165         S DATE=^TMP(TMPIND,$J,"SRC","DATE")
    166         S FDA(811.8,"+1,",.01)=RNAME
    167         S FDA(811.8,"+1,",.02)=SOURCE
    168         S FDA(811.8,"+1,",.03)=DATE
    169         S FDA(811.8,"+1,",115)=EXTYPE
    170         D UPDATE^PXRMEXPU(.SUCCESS,.FDA,.IENROOT)
    171         I SUCCESS D
    172         . M ^PXD(811.8,IENROOT(1),100)=^TMP("PXRMEXRS",$J)
    173         .;Set the 0 node.
    174         . S ^PXD(811.8,IENROOT(1),100,0)=U_811.801_U_LC_U_LC
    175         .;Save the Exchange Type.
    176         . S ^PXD(811.8,IENROOT(1),115)=$G(EXTYPE)
    177         .;Create the description for this repository entry.
    178         . N DATEP,DESC,DESL,KEYWORD,RNAME,SOURCE
    179         . S DESL("RNAME")=^TMP(TMPIND,$J,"SRC","REMINDER")
    180         . S DESL("SOURCE")=^TMP(TMPIND,$J,"SRC","USER")_" at "_^TMP(TMPIND,$J,"SRC","SITE")
    181         . S DESL("DATEP")=^TMP(TMPIND,$J,"SRC","DATE")
    182         . S DESL("VRSN")=VERSN
    183         . S DESC="^TMP(TMPIND,$J,""DESC"")"
    184         . S KEYWORD="^TMP(TMPIND,$J,""KEYWORD"")"
    185         . D DESC^PXRMEXU1(IENROOT(1),.DESL,$NA(@DESC),$NA(@KEYWORD))
    186         K ^TMP($J,"CIND"),^TMP("PXRMEXRS",$J)
    187         K ^TMP(TMPIND,$J),^TMP("PXRMEXCS",$J)
    188         Q
    189         ;
    190         ;=====================================================
    191 XMLOUT(IEN)     ;Write out the XML content of repository entry ien.
    192         N LC,NLINES
    193         S NLINES=$O(^PXD(811.8,IEN,100,""),-1)
    194         F LC=1:1:NLINES W !,^PXD(811.8,IEN,100,LC,0)
    195         Q
    196         ;
     1PXRMEXU2 ; SLC/PKR/PJH - Reminder exchange repository utilities, #2. ;09/20/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;=====================================================
     4FDA(IND,LC,TMPIND,FILENAME) ;Build the XML FDA output.
     5 N FIELD,FILENUM,INDEX,INDEX0,JND,SIENS,WPC
     6 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILEMAN_FDA>"
     7 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<![CDATA["
     8 ;Get the file number.
     9 S FILENUM=""
     10 F  S FILENUM=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM)) Q:FILENUM=""  D
     11 .;Get the source ien string.
     12 . S SIENS=""
     13 . F  S SIENS=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS)) Q:SIENS=""  D
     14 .. S INDEX0=FILENUM_";"_SIENS
     15 ..;Get the field number and store the data.
     16 .. S FIELD=""
     17 .. F  S FIELD=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD)) Q:FIELD=""  D
     18 ... S INDEX=INDEX0_";"_FIELD
     19 ...;If there is another index past the field then this is a
     20 ...;word-processing field.
     21 ... I $D(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD))=11 D
     22 .... S WPC=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD,""),-1)
     23 .... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=INDEX_"~WP-start~"_WPC
     24 .... F JND=1:1:WPC D
     25 ..... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD,JND)
     26 ... E  S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=INDEX_"~"_^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,FIELD)
     27 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]>"
     28 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</FILEMAN_FDA>"
     29 Q
     30 ;
     31 ;=====================================================
     32IENROOT(IND,LC,TMPIND,FILENAME) ;Build the XML IEN_ROOT output.
     33 N INDEX,VALUE
     34 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<IEN_ROOT>"
     35 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<![CDATA["
     36 S INDEX=0
     37 F  S INDEX=$O(^TMP(TMPIND,$J,IND,FILENAME,INDEX)) Q:INDEX=""  D
     38 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=INDEX_U_^TMP(TMPIND,$J,IND,FILENAME,INDEX)
     39 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]>"
     40 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</IEN_ROOT>"
     41 Q
     42 ;
     43 ;=====================================================
     44STOREPR(SUCCESS,RTM,TMPIND,EXTYPE) ;^TMP(TMPIND,$J contains data to be
     45 ;stored in the repository. Routines will be found in
     46 ;^TMP(TMPIND,$J,"ROUTINE",ROUTINE NAME,n) where n is the line number.
     47 ;File entries will be found in ^TMP(TMPIND,$J,N,FILENAME,indexes).
     48 ;This is output from the GETS^DIQ call. There are NUMF file entries.
     49 ;Format and store it as XML in the repository.
     50 N DATE,DTEST,FDA,FILENAME,FILENUM
     51 N IENROOT,IND,JND,LC,LINE,NCMPNT,NEWFILE,NUMF,PT01,RNAME
     52 N SIENS,SOURCE,TEMP,VERSN
     53 ;If anything went wrong in the packing process then ^TMP(TMPIND,$J
     54 ;will not exist.
     55 I '$D(^TMP(TMPIND,$J)) S SUCCESS=0 Q
     56 ;
     57 K ^TMP($J,"CIND")
     58 K ^TMP("PXRMEXRS",$J)
     59 S ^TMP("PXRMEXRS",$J,1,0)="<?xml version=""1.0"" standalone=""yes""?>"
     60 S ^TMP("PXRMEXRS",$J,2,0)="<REMINDER_EXCHANGE_FILE_ENTRY>"
     61 S VERSN=^PXRM(800,1,"VERSION")
     62 S ^TMP("PXRMEXRS",$J,3,0)="<PACKAGE_VERSION>"_VERSN_"</PACKAGE_VERSION>"
     63 ;The pointer to the index will be on line 4 so leave room.
     64 S LC=4
     65 ;Save the source information.
     66 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<SOURCE>"
     67 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<NAME>"_$$TOXML^PXRMEXU3(^TMP(TMPIND,$J,"SRC","REMINDER"))_"</NAME>"
     68 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<USER>"_$$TOXML^PXRMEXU3(^TMP(TMPIND,$J,"SRC","USER"))_"</USER>"
     69 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<SITE>"_$$TOXML^PXRMEXU3(^TMP(TMPIND,$J,"SRC","SITE"))_"</SITE>"
     70 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<DATE_PACKED>"_^TMP(TMPIND,$J,"SRC","DATE")_"</DATE_PACKED>"
     71 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</SOURCE>"
     72 ;
     73 ;Save the Exchange Type.
     74 I EXTYPE="" S EXTYPE="REMINDER"
     75 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<EXCHANGE_TYPE>"_$$TOXML^PXRMEXU3(EXTYPE)_"</EXCHANGE_TYPE>"
     76 ;
     77 ;Save the description.
     78 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<DESCRIPTION><![CDATA["
     79 S IND=0
     80 F  S IND=$O(^TMP(TMPIND,$J,"DESC",1,IND)) Q:+IND=0  D
     81 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=^TMP(TMPIND,$J,"DESC",1,IND,0)
     82 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]></DESCRIPTION>"
     83 ;
     84 ;Save the keywords or phrases.
     85 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<KEYWORDS>"
     86 S IND=0
     87 F  S IND=$O(^TMP(TMPIND,$J,"KEYWORD",1,IND)) Q:+IND=0  D
     88 . S TEMP=^TMP(TMPIND,$J,"KEYWORD",1,IND,0)
     89 . I TEMP["," D
     90 .. F JND=1:1:$L(TEMP,",") D
     91 ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<KEYWORD>"_$$TOXML^PXRMEXU3($P(TEMP,",",JND))_"</KEYWORD>"
     92 . E  S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<KEYWORD>"_$$TOXML^PXRMEXU3(TEMP)_"</KEYWORD>"
     93 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</KEYWORDS>"
     94 ;
     95 S NCMPNT=0
     96 ;Do routines first.
     97 S RNAME=""
     98 F  S RNAME=$O(^TMP(TMPIND,$J,"ROUTINE",RNAME)) Q:RNAME=""  D
     99 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<M_ROUTINE>"
     100 . S NCMPNT=NCMPNT+1
     101 . S ^TMP($J,"CIND",NCMPNT,"M_ROUTINE_START")=LC
     102 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<ROUTINE_NAME>"_RNAME_"</ROUTINE_NAME>"
     103 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<CODE>"
     104 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<![CDATA["
     105 . S ^TMP($J,"CIND",NCMPNT,"ROUTINE_CODE_START")=LC+1
     106 . S LINE=0
     107 . F  S LINE=$O(^TMP(TMPIND,$J,"ROUTINE",RNAME,LINE)) Q:LINE=""  D
     108 .. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=^TMP(TMPIND,$J,"ROUTINE",RNAME,LINE,0)
     109 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="]]>"
     110 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</CODE>"
     111 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</M_ROUTINE>"
     112 . S ^TMP($J,"CIND",NCMPNT,"ROUTINE_CODE_END")=LC-3
     113 ;
     114 ;Do file entries.
     115 ;For word processing fields the first line is
     116 ;file number;source ien string;field~WP-start~line count
     117 ;The next line count lines are the WP data.
     118 S NUMF=+$G(^TMP(TMPIND,$J,"NUMF"))
     119 S FILENAME=""
     120 F IND=1:1:NUMF D
     121 . F  S FILENAME=$O(^TMP(TMPIND,$J,IND,FILENAME)) Q:FILENAME=""  D
     122 .. I FILENAME["IENROOT" D
     123 ... S NEWFILE=0
     124 ... S IENROOT=1
     125 .. E  D
     126 ... S NEWFILE=1
     127 ... S IENROOT=0
     128 .. I NEWFILE D
     129 ... S FILENUM=$O(^TMP(TMPIND,$J,IND,FILENAME,""))
     130 ... S SIENS=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,""))
     131 ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILEMAN_FILE>"
     132 ... S NCMPNT=NCMPNT+1
     133 ... S ^TMP($J,"CIND",NCMPNT,"FILE_START")=LC
     134 ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILE_NAME>"_$$TOXML^PXRMEXU3(FILENAME)_"</FILE_NAME>"
     135 ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<FILE_NUMBER>"_FILENUM_"</FILE_NUMBER>"
     136 ... S LC=LC+1,PT01=^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,.01)
     137 ... S ^TMP("PXRMEXRS",$J,LC,0)="<POINT_01>"_$$TOXML^PXRMEXU3(PT01)_"</POINT_01>"
     138 ... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<INTERNAL_ENTRY_NUMBER>"_+SIENS_"</INTERNAL_ENTRY_NUMBER>"
     139 ... S ^TMP($J,"CIND",NCMPNT,"FDA_START")=LC+3
     140 ... D FDA(IND,.LC,TMPIND,FILENAME)
     141 ... S ^TMP($J,"CIND",NCMPNT,"FDA_END")=LC-2
     142 ..;The ien root information always comes after the FDA.
     143 .. I IENROOT D
     144 ... S ^TMP($J,"CIND",NCMPNT,"IEN_ROOT_START")=LC+3
     145 ... D IENROOT(IND,.LC,TMPIND,FILENAME)
     146 ... S ^TMP($J,"CIND",NCMPNT,"IEN_ROOT_END")=LC-2
     147 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</FILEMAN_FILE>"
     148 ;Save the index.
     149 S LC=LC+1,^TMP("PXRMEXRS",$J,4,0)="<INDEX_AT>"_LC_"</INDEX_AT>"
     150 S ^TMP("PXRMEXRS",$J,LC,0)="<INDEX>"
     151 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<NUMBER_OF_COMPONENTS>"_NCMPNT_"</NUMBER_OF_COMPONENTS>"
     152 F IND=1:1:NCMPNT D
     153 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<COMPONENT>"
     154 . S JND=""
     155 . F  S JND=$O(^TMP($J,"CIND",IND,JND)) Q:JND=""  D
     156 .. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<"_JND_">"_^TMP($J,"CIND",IND,JND)_"</"_JND_">"
     157 . S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</COMPONENT>"
     158 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</INDEX>"
     159 S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="</REMINDER_EXCHANGE_FILE_ENTRY>"
     160 ;Establish the entry in the repository.
     161 S RNAME=$P(RTM,U,2)
     162 S SOURCE=^TMP(TMPIND,$J,"SRC","USER")_" at "_^TMP(TMPIND,$J,"SRC","SITE")
     163 S DATE=^TMP(TMPIND,$J,"SRC","DATE")
     164 S FDA(811.8,"+1,",.01)=RNAME
     165 S FDA(811.8,"+1,",.02)=SOURCE
     166 S FDA(811.8,"+1,",.03)=DATE
     167 S FDA(811.8,"+1,",115)=EXTYPE
     168 D UPDATE^PXRMEXPU(.SUCCESS,.FDA,.IENROOT)
     169 I SUCCESS D
     170 . M ^PXD(811.8,IENROOT(1),100)=^TMP("PXRMEXRS",$J)
     171 .;Set the 0 node.
     172 . S ^PXD(811.8,IENROOT(1),100,0)=U_811.801_U_LC_U_LC
     173 .;Save the Exchange Type.
     174 . S ^PXD(811.8,IENROOT(1),115)=$G(EXTYPE)
     175 .;Create the description for this repository entry.
     176 . N DATEP,DESC,DESL,KEYWORD,RNAME,SOURCE
     177 . S DESL("RNAME")=^TMP(TMPIND,$J,"SRC","REMINDER")
     178 . S DESL("SOURCE")=^TMP(TMPIND,$J,"SRC","USER")_" at "_^TMP(TMPIND,$J,"SRC","SITE")
     179 . S DESL("DATEP")=^TMP(TMPIND,$J,"SRC","DATE")
     180 . S DESL("VRSN")=$G(^PXRM(800,1,"VERSION"))
     181 . S DESC="^TMP(TMPIND,$J,""DESC"")"
     182 . S KEYWORD="^TMP(TMPIND,$J,""KEYWORD"")"
     183 . D DESC^PXRMEXU1(IENROOT(1),.DESL,$NA(@DESC),$NA(@KEYWORD))
     184 K ^TMP($J,"CIND")
     185 K ^TMP("PXRMEXRS",$J)
     186 K ^TMP(TMPIND,$J)
     187 Q
     188 ;
     189 ;=====================================================
     190XMLOUT(IEN) ;Write out the XML content of repository entry ien.
     191 N LC,NLINES
     192 S NLINES=$O(^PXD(811.8,IEN,100,""),-1)
     193 F LC=1:1:NLINES W !,^PXD(811.8,IEN,100,LC,0)
     194 Q
     195 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXU4.m

    r613 r623  
    1 PXRMEXU4        ; SLC/PJH,PKR - Reminder Exchange #4, dialog changes. ;05/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;===============================================
    4 DLG(FDA,NAMECHG)        ;Check the dialog for renamed entries, called by
    5         ;silent installer. KIDSDONE is newed in INSDLG^PXRMEXSI.
    6         N ABBR,ACTION,ALIST,DNAM,IEN,IENS,FILENUM,FINDING,NEWNAM,OFINDING
    7         N ORITEM,OORITEM,PT01,RESULT,RRG,SRC,WP
    8         S IENS=$O(FDA(801.41,""))
    9         ;Definition .01
    10         S (PT01,DNAM)=FDA(801.41,IENS,.01)
    11         I $D(NAMECHG(801.41,PT01)) D
    12         .S (FDA(801.41,IENS,.01),DNAM)=NAMECHG(801.41,PT01)
    13         ;
    14         ;Build list of finding types
    15         D BLDALIST^PXRMVPTR(801.4118,.01,.ALIST)
    16         ;Plus field 15 files
    17         ;S ALIST("MH")=601,ALIST("TX")=811.2
    18         S ALIST("MH")=601.71,ALIST("TX")=811.2
    19         S ALIST("WH")=790.404
    20         ;Plus field 17 file
    21         S ALIST("OI")=101.43
    22         ;
    23         ;Process SOURCE REMINDER
    24         S SRC=$G(FDA(801.41,IENS,2))
    25         I SRC]"" D
    26         .S IEN=$$EXISTS^PXRMEXIU(811.9,SRC)
    27         .I IEN=0 K FDA(801.41,IENS,2)
    28         ;
    29         ;Clear RESULT if not defined
    30         S RESULT=$G(FDA(801.41,IENS,55))
    31         I RESULT]"" D
    32         .S IEN=$$EXISTS^PXRMEXIU(801.41,RESULT)
    33         .I IEN=0 K FDA(801.41,IENS,55)
    34         ;
    35         ;Process ORDERABLE ITEM
    36         S (ORITEM,OORITEM)=$G(FDA(801.41,IENS,17)),ACTION=""
    37         I ORITEM'="" D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
    38         .S PT01=ORITEM
    39         .S ABBR="OI",FILENUM=$P(ALIST(ABBR),U)
    40         .I $D(NAMECHG(FILENUM,PT01)) D
    41         ..S ORITEM=NAMECHG(FILENUM,PT01)
    42         ..S FDA(801.41,IENS,17)=ORITEM
    43         .S IEN=+$$VFIND1^PXRMEXIU(ABBR_"."_ORITEM,.ALIST)
    44         .I IEN=0 D
    45         ..;Get replacement
    46         ..N DIC,DIR,DUOUT,MSG,X,Y
    47         ..S MSG(1)=" "
    48         ..S MSG(2)="ORDERABLE ITEM  entry "_ORITEM_" does not exist."
    49         ..D MES^XPDUTL(.MSG)
    50         ..S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR) I ACTION="S" S ACTION="Q"
    51         ..I ACTION="Q" Q
    52         ..I ACTION="D" K FDA(801.41,IENS,17) Q
    53         ..S DIC=FILENUM
    54         ..S DIC(0)="AEMNQ"
    55         ..S Y=-1
    56         ..F  Q:+Y'=-1  D
    57         ...;If this is being called during a KIDS install we need echoing on.
    58         ...I $D(XPDNM) X ^%ZOSF("EON")
    59         ...D ^DIC
    60         ...I $D(XPDNM) X ^%ZOSF("EOFF")
    61         ...;If this is being called during a KIDS install we need echoing on.
    62         ...I $D(DUOUT) S Y="" Q
    63         ...I Y=-1 D BMES^XPDUTL("You must input a replacement!")
    64         ..I Y="" S ACTION="Q" Q
    65         ..S ORITEM=$P(Y,U,2)
    66         ..S FDA(801.41,IENS,17)=ORITEM
    67         .;Save the finding information for the history.
    68         .I ORITEM'=OORITEM D
    69         .. S ^TMP("PXRMEXIA",$J,"DIAF",$P(IENS,",",1),ABBR_"."_OORITEM)=ABBR_"."_ORITEM
    70         ;
    71         ;Process FINDING ITEM
    72         S (FINDING,OFINDING)=$G(FDA(801.41,IENS,15)),ACTION=""
    73         I FINDING'="" D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
    74         .S ABBR=$P(FINDING,".",1)
    75         .S PT01=$P(FINDING,".",2)
    76         .S FILENUM=$P(ALIST(ABBR),U,1)
    77         .I $D(NAMECHG(FILENUM,PT01)) D
    78         ..S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
    79         ..S FDA(801.41,IENS,15)=FINDING
    80         .S IEN=+$$VFIND1^PXRMEXIU(FINDING,.ALIST)
    81         .I IEN=0 D
    82         ..;Get replacement
    83         ..N DIC,DIR,DUOUT,MSG,X,Y
    84         ..S MSG(1)=" "
    85         ..S MSG(2)="FINDING entry "_FINDING_" does not exist."
    86         ..D MES^XPDUTL(.MSG)
    87         ..S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR) I ACTION="S" S ACTION="Q"
    88         ..I ACTION="Q" Q
    89         ..I ACTION="D" K FDA(801.41,IENS,15) Q
    90         ..S DIC=FILENUM
    91         ..S DIC(0)="AEMNQ"
    92         ..S Y=-1
    93         ..F  Q:+Y'=-1  D
    94         ...;If this is being called during a KIDS install we need echoing on.
    95         ...I $D(XPDNM) X ^%ZOSF("EON")
    96         ...D ^DIC
    97         ...I $D(XPDNM) X ^%ZOSF("EOFF")
    98         ...;If this is being called during a KIDS install we need echoing on.
    99         ...I $D(DUOUT) S Y="" Q
    100         ...I Y=-1 D BMES^XPDUTL("You must input a replacement!")
    101         ..I Y="" S ACTION="Q" Q
    102         ..S FINDING=ABBR_"."_$P(Y,U,2)
    103         ..S FDA(801.41,IENS,15)=FINDING
    104         .;Save the finding information for the history.
    105         .I FINDING'=OFINDING D
    106         .. S ^TMP("PXRMEXIA",$J,"DIAF",$P(IENS,",",1),OFINDING)=FINDING
    107         .;Convert ICD9 codes to `ien format
    108         .I $P(FINDING,".")="ICD9" S FDA(801.41,IENS,15)="ICD9."_$$ICD9(FINDING)
    109         ;
    110         ;Look for replacements of TIU templates.
    111         I $D(NAMECHG(8927.1)) D
    112         .S WP=$G(FDA(801.41,IENS,25))
    113         .I WP'="" D TIURPL("{FLD:",WP,.NAMECHG,8927.1)
    114         .S WP=$G(FDA(801.41,IENS,35))
    115         ;
    116         ;Process ADDITIONAL FINDINGS
    117         S IENS="",ACTION=""
    118         F  S IENS=$O(FDA(801.4118,IENS)) Q:IENS=""  D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
    119         . S (FINDING,OFINDING)=FDA(801.4118,IENS,.01)
    120         . S ABBR=$P(FINDING,".",1)
    121         . S PT01=$P(FINDING,".",2)
    122         . S FILENUM=$P(ALIST(ABBR),U,1)
    123         . I $D(NAMECHG(FILENUM,PT01)) D
    124         .. S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
    125         .. S FDA(801.4118,IENS,.01)=FINDING
    126         . S IEN=+$$VFIND1^PXRMEXIU(FINDING,.ALIST)
    127         . I IEN=0 D  Q:ACTION="Q"
    128         ..;Get replacement
    129         .. N DIC,DIR,DUOUT,MSG,X,Y
    130         .. S MSG(1)=" "
    131         .. S MSG(2)="ADDITIONAL FINDING entry "_FINDING_" does not exist."
    132         .. D MES^XPDUTL(.MSG)
    133         .. S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR)
    134         .. I ACTION="S" S ACTION="Q"
    135         .. I ACTION="Q" Q
    136         .. I ACTION="D" K FDA(801.4118,IENS) Q
    137         .. S DIC=FILENUM
    138         .. S DIC(0)="AEMNQ"
    139         .. S Y=-1
    140         .. F  Q:+Y'=-1  D
    141         ...;If this is being called during a KIDS install we need echoing on.
    142         ... I $D(XPDNM) X ^%ZOSF("EON")
    143         ... D ^DIC
    144         ... I $D(XPDNM) X ^%ZOSF("EOFF")
    145         ... I $D(DUOUT) S Y="" Q
    146         ... I Y=-1 D BMES^XPDUTL("You must input a replacement!")
    147         .. I Y="" S ACTION="Q" Q
    148         .. S FINDING=ABBR_"."_$P(Y,U,2)
    149         .. S FDA(801.4118,IENS,.01)=FINDING
    150         . ;Save the finding information for the history.
    151         . I FINDING'=OFINDING D
    152         .. S ^TMP("PXRMEXIA",$J,"DIAF",$P(IENS,",",1),OFINDING)=FINDING
    153         . ;Convert ICD9 codes to `ien format
    154         . I $P(FINDING,".")="ICD9" S FDA(801.4118,IENS,.01)=$$ICD9(FINDING)
    155         ;
    156         I ACTION="Q" S (PXRMDONE,KIDSDONE)=1 Q
    157         ;Process DIALOG COMPONENT
    158         S IENS="",ACTION=""
    159         F  S IENS=$O(FDA(801.412,IENS)) Q:IENS=""  D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
    160         . S PT01=$G(FDA(801.412,IENS,2)) Q:PT01=""
    161         . S FILENUM=801.41,NEWNAM=$G(NAMECHG(FILENUM,PT01))
    162         .I NEWNAM'="" D
    163         .. S FDA(801.412,IENS,2)=NEWNAM,PT01=NEWNAM
    164         .S IEN=$$EXISTS^PXRMEXIU(FILENUM,PT01)
    165         .I IEN=0 D
    166         ..;Get replacement
    167         .. N DIC,DIR,DUOUT,MSG,X,Y
    168         .. S MSG(1)=" "
    169         .. S MSG(2)="COMPONENT DIALOG entry "_PT01_" does not exist."
    170         .. D MES^XPDUTL(.MSG)
    171         .. S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR)
    172         .. I ACTION="S" S ACTION="Q"
    173         .. I ACTION="Q" Q
    174         .. I ACTION="D" K FDA(801.412,IENS) Q
    175         .. S DIC=FILENUM
    176         .. S DIC(0)="AEMNQ"
    177         .. S DIC("S")="I ""EG""[$P(^PXRMD(801.41,Y,0),U,4)"
    178         .. S Y=-1
    179         .. F  Q:+Y'=-1  D
    180         ...;If this is being called during a KIDS install we need echoing on.
    181         ... I $D(XPDNM) X ^%ZOSF("EON")
    182         ... D ^DIC
    183         ... I $D(XPDNM) X ^%ZOSF("EOFF")
    184         ... I $D(DUOUT) S Y="" Q
    185         ... I Y=-1 D BMES^XPDUTL("You must input a replacement!")
    186         .. I Y="" S ACTION="Q" Q
    187         .. I Y'="" S FDA(801.412,IENS,2)=$P(Y,U,2)
    188         ;Process Result Groups
    189         F  S IENS=$O(FDA(801.41121,IENS)) Q:IENS=""  D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
    190         . S PT01=$G(FDA(801.41121,IENS,.01)) Q:PT01=""
    191         . S FILENUM=801.41,NEWNAM=$G(NAMECHG(FILENUM,PT01))
    192         .I NEWNAM'="" D
    193         .. S FDA(801.41121,IENS,2)=NEWNAM,PT01=NEWNAM
    194         .S IEN=$$EXISTS^PXRMEXIU(FILENUM,PT01)
    195         .I IEN=0 D
    196         ..;Get replacement
    197         .. N DIC,DIR,DUOUT,MSG,X,Y
    198         .. S MSG(1)=" "
    199         .. S MSG(2)="RESULT GROUP entry "_PT01_" does not exist."
    200         .. D MES^XPDUTL(.MSG)
    201         .. S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR)
    202         .. I ACTION="S" S ACTION="Q"
    203         .. I ACTION="Q" Q
    204         .. I ACTION="D" K FDA(801.41121,IENS) Q
    205         .. S DIC=FILENUM
    206         .. S DIC(0)="AEMNQ"
    207         .. S DIC("S")="I ""S""[$P(^PXRMD(801.41,Y,0),U,4)"
    208         .. S Y=-1
    209         .. F  Q:+Y'=-1  D
    210         ...;If this is being called during a KIDS install we need echoing on.
    211         ... I $D(XPDNM) X ^%ZOSF("EON")
    212         ... D ^DIC
    213         ... I $D(XPDNM) X ^%ZOSF("EOFF")
    214         ... I $D(DUOUT) S Y="" Q
    215         ... I Y=-1 D BMES^XPDUTL("You must input a replacement!")
    216         .. I Y="" S ACTION="Q" Q
    217         .. I Y'="" S FDA(801.41121,IENS,.01)=$P(Y,U,2)
    218         Q
    219         ;
    220         ;===============================================
    221         ;Convert ICD9 codes to `ien format
    222 ICD9(CODE)      ;
    223         N IEN
    224         S IEN=$$FIND1^DIC(80,"","AMX",$P(CODE,".",2,99))
    225         I 'IEN Q ""
    226         Q "`"_IEN
    227         ;
    228         ;===============================================
    229 TIURPL(SRCH,WP,NAMEGHC,FILENUM) ;Replace TIU templates whose names have
    230         ;changed.
    231         N IND,RS,TEXT,TS,TYPE
    232         I FILENUM=8927.1 S TYPE="TIU TEMPLATE"
    233         E  S TYPE="TIU OBJECT"
    234         S IND=1
    235         F  S TEXT=$G(@WP@(IND)) Q:TEXT=""  D
    236         .I TEXT[SRCH D
    237         ..S TS=""
    238         ..F  S TS=$O(NAMECHG(FILENUM,TS)) Q:TS=""  D
    239         ...S RS=NAMECHG(FILENUM,TS) Q:TEXT'[TS
    240         ...S @WP@(IND)=$$STRREP^PXRMUTIL(TEXT,TS,RS)
    241         ...;Save the replacement information for the history.
    242         ...S ^TMP("PXRMEXIA",$J,"DIATIU",TYPE,TS)=RS
    243         ...S ^TMP("PXRMEXIA",$J,"DIATIU",TYPE,TS,DNAM)=""
    244         .S IND=IND+1
    245         Q
    246         ;
     1PXRMEXU4 ; SLC/PJH,PKR - Reminder Exchange #4, dialog changes. ;01/19/2005
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;===============================================
     4DLG(FDA,NAMECHG) ;Check the dialog for renamed entries, called by
     5 ;silent installer. KIDSDONE is newed in INSDLG^PXRMEXSI.
     6 N ABBR,ACTION,ALIST,DNAM,IEN,IENS,FILENUM,FINDING,NEWNAM,OFINDING
     7 N ORITEM,OORITEM,PT01,RESULT,RRG,SRC,WP
     8 S IENS=$O(FDA(801.41,""))
     9 ;Definition .01
     10 S (PT01,DNAM)=FDA(801.41,IENS,.01)
     11 I $D(NAMECHG(801.41,PT01)) D
     12 .S (FDA(801.41,IENS,.01),DNAM)=NAMECHG(801.41,PT01)
     13 ;
     14 ;Build list of finding types
     15 D BLDALIST^PXRMVPTR(801.4118,.01,.ALIST)
     16 ;Plus field 15 files
     17 S ALIST("MH")=601,ALIST("TX")=811.2
     18 S ALIST("WH")=790.404
     19 ;Plus field 17 file
     20 S ALIST("OI")=101.43
     21 ;
     22 ;Process SOURCE REMINDER
     23 S SRC=$G(FDA(801.41,IENS,2))
     24 I SRC]"" D
     25 .S IEN=$$EXISTS^PXRMEXIU(811.9,SRC)
     26 .I IEN=0 K FDA(801.41,IENS,2)
     27 ;
     28 ;Clear RESULT if not defined
     29 S RESULT=$G(FDA(801.41,IENS,55))
     30 I RESULT]"" D
     31 .S IEN=$$EXISTS^PXRMEXIU(801.41,RESULT)
     32 .I IEN=0 K FDA(801.41,IENS,55)
     33 ;
     34 ;Process ORDERABLE ITEM
     35 S (ORITEM,OORITEM)=$G(FDA(801.41,IENS,17)),ACTION=""
     36 I ORITEM'="" D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
     37 .S PT01=ORITEM
     38 .S ABBR="OI",FILENUM=$P(ALIST(ABBR),U)
     39 .I $D(NAMECHG(FILENUM,PT01)) D
     40 ..S ORITEM=NAMECHG(FILENUM,PT01)
     41 ..S FDA(801.41,IENS,17)=ORITEM
     42 .S IEN=+$$VFIND1^PXRMEXIU(ABBR_"."_ORITEM,.ALIST)
     43 .I IEN=0 D
     44 ..;Get replacement
     45 ..N DIC,DIR,DUOUT,MSG,X,Y
     46 ..S MSG(1)=" "
     47 ..S MSG(2)="ORDERABLE ITEM  entry "_ORITEM_" does not exist."
     48 ..D MES^XPDUTL(.MSG)
     49 ..S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR) I ACTION="S" S ACTION="Q"
     50 ..I ACTION="Q" Q
     51 ..I ACTION="D" K FDA(801.41,IENS,17) Q
     52 ..S DIC=FILENUM
     53 ..S DIC(0)="AEMNQ"
     54 ..S Y=-1
     55 ..F  Q:+Y'=-1  D
     56 ...;If this is being called during a KIDS install we need echoing on.
     57 ...I $D(XPDNM) X ^%ZOSF("EON")
     58 ...D ^DIC
     59 ...I $D(XPDNM) X ^%ZOSF("EOFF")
     60 ...;If this is being called during a KIDS install we need echoing on.
     61 ...I $D(DUOUT) S Y="" Q
     62 ...I Y=-1 D BMES^XPDUTL("You must input a replacement!")
     63 ..I Y="" S ACTION="Q" Q
     64 ..S ORITEM=$P(Y,U,2)
     65 ..S FDA(801.41,IENS,17)=ORITEM
     66 .;Save the finding information for the history.
     67 .I ORITEM'=OORITEM D
     68 .. S ^TMP("PXRMEXIA",$J,"DIAF",$P(IENS,",",1),ABBR_"."_OORITEM)=ABBR_"."_ORITEM
     69 ;
     70 ;Process FINDING ITEM
     71 S (FINDING,OFINDING)=$G(FDA(801.41,IENS,15)),ACTION=""
     72 I FINDING'="" D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
     73 .S ABBR=$P(FINDING,".",1)
     74 .S PT01=$P(FINDING,".",2)
     75 .S FILENUM=$P(ALIST(ABBR),U,1)
     76 .I $D(NAMECHG(FILENUM,PT01)) D
     77 ..S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
     78 ..S FDA(801.41,IENS,15)=FINDING
     79 .S IEN=+$$VFIND1^PXRMEXIU(FINDING,.ALIST)
     80 .I IEN=0 D
     81 ..;Get replacement
     82 ..N DIC,DIR,DUOUT,MSG,X,Y
     83 ..S MSG(1)=" "
     84 ..S MSG(2)="FINDING entry "_FINDING_" does not exist."
     85 ..D MES^XPDUTL(.MSG)
     86 ..S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR) I ACTION="S" S ACTION="Q"
     87 ..I ACTION="Q" Q
     88 ..I ACTION="D" K FDA(801.41,IENS,15) Q
     89 ..S DIC=FILENUM
     90 ..S DIC(0)="AEMNQ"
     91 ..S Y=-1
     92 ..F  Q:+Y'=-1  D
     93 ...;If this is being called during a KIDS install we need echoing on.
     94 ...I $D(XPDNM) X ^%ZOSF("EON")
     95 ...D ^DIC
     96 ...I $D(XPDNM) X ^%ZOSF("EOFF")
     97 ...;If this is being called during a KIDS install we need echoing on.
     98 ...I $D(DUOUT) S Y="" Q
     99 ...I Y=-1 D BMES^XPDUTL("You must input a replacement!")
     100 ..I Y="" S ACTION="Q" Q
     101 ..S FINDING=ABBR_"."_$P(Y,U,2)
     102 ..S FDA(801.41,IENS,15)=FINDING
     103 .;Save the finding information for the history.
     104 .I FINDING'=OFINDING D
     105 .. S ^TMP("PXRMEXIA",$J,"DIAF",$P(IENS,",",1),OFINDING)=FINDING
     106 .;Convert ICD9 codes to `ien format
     107 .I $P(FINDING,".")="ICD9" S FDA(801.41,IENS,15)="ICD9."_$$ICD9(FINDING)
     108 ;
     109 ;Look for replacements of TIU templates.
     110 I $D(NAMECHG(8927.1)) D
     111 .S WP=$G(FDA(801.41,IENS,25))
     112 .I WP'="" D TIURPL("{FLD:",WP,.NAMECHG,8927.1)
     113 .S WP=$G(FDA(801.41,IENS,35))
     114 ;
     115 ;Process ADDITIONAL FINDINGS
     116 S IENS="",ACTION=""
     117 F  S IENS=$O(FDA(801.4118,IENS)) Q:IENS=""  D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
     118 . S (FINDING,OFINDING)=FDA(801.4118,IENS,.01)
     119 . S ABBR=$P(FINDING,".",1)
     120 . S PT01=$P(FINDING,".",2)
     121 . S FILENUM=$P(ALIST(ABBR),U,1)
     122 . I $D(NAMECHG(FILENUM,PT01)) D
     123 .. S FINDING=ABBR_"."_NAMECHG(FILENUM,PT01)
     124 .. S FDA(801.4118,IENS,.01)=FINDING
     125 . S IEN=+$$VFIND1^PXRMEXIU(FINDING,.ALIST)
     126 . I IEN=0 D  Q:ACTION="Q"
     127 ..;Get replacement
     128 .. N DIC,DIR,DUOUT,MSG,X,Y
     129 .. S MSG(1)=" "
     130 .. S MSG(2)="ADDITIONAL FINDING entry "_FINDING_" does not exist."
     131 .. D MES^XPDUTL(.MSG)
     132 .. S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR)
     133 .. I ACTION="S" S ACTION="Q"
     134 .. I ACTION="Q" Q
     135 .. I ACTION="D" K FDA(801.4118,IENS) Q
     136 .. S DIC=FILENUM
     137 .. S DIC(0)="AEMNQ"
     138 .. S Y=-1
     139 .. F  Q:+Y'=-1  D
     140 ...;If this is being called during a KIDS install we need echoing on.
     141 ... I $D(XPDNM) X ^%ZOSF("EON")
     142 ... D ^DIC
     143 ... I $D(XPDNM) X ^%ZOSF("EOFF")
     144 ... I $D(DUOUT) S Y="" Q
     145 ... I Y=-1 D BMES^XPDUTL("You must input a replacement!")
     146 .. I Y="" S ACTION="Q" Q
     147 .. S FINDING=ABBR_"."_$P(Y,U,2)
     148 .. S FDA(801.4118,IENS,.01)=FINDING
     149 . ;Save the finding information for the history.
     150 . I FINDING'=OFINDING D
     151 .. S ^TMP("PXRMEXIA",$J,"DIAF",$P(IENS,",",1),OFINDING)=FINDING
     152 . ;Convert ICD9 codes to `ien format
     153 . I $P(FINDING,".")="ICD9" S FDA(801.4118,IENS,.01)=$$ICD9(FINDING)
     154 ;
     155 I ACTION="Q" S (PXRMDONE,KIDSDONE)=1 Q
     156 ;Process DIALOG COMPONENT
     157 S IENS="",ACTION=""
     158 F  S IENS=$O(FDA(801.412,IENS)) Q:IENS=""  D  I ACTION="Q" K FDA S (PXRMDONE,KIDSDONE)=1 Q
     159 . S PT01=$G(FDA(801.412,IENS,2)) Q:PT01=""
     160 . S FILENUM=801.41,NEWNAM=$G(NAMECHG(FILENUM,PT01))
     161 .I NEWNAM'="" D
     162 .. S FDA(801.412,IENS,2)=NEWNAM,PT01=NEWNAM
     163 .S IEN=$$EXISTS^PXRMEXIU(FILENUM,PT01)
     164 .I IEN=0 D
     165 ..;Get replacement
     166 .. N DIC,DIR,DUOUT,MSG,X,Y
     167 .. S MSG(1)=" "
     168 .. S MSG(2)="COMPONENT DIALOG entry "_PT01_" does not exist."
     169 .. D MES^XPDUTL(.MSG)
     170 .. S ACTION=$$GETACT^PXRMEXIU("DPQ",.DIR)
     171 .. I ACTION="S" S ACTION="Q"
     172 .. I ACTION="Q" Q
     173 .. I ACTION="D" K FDA(801.412,IENS) Q
     174 .. S DIC=FILENUM
     175 .. S DIC(0)="AEMNQ"
     176 .. S DIC("S")="I ""EG""[$P(^PXRMD(801.41,Y,0),U,4)"
     177 .. S Y=-1
     178 .. F  Q:+Y'=-1  D
     179 ...;If this is being called during a KIDS install we need echoing on.
     180 ... I $D(XPDNM) X ^%ZOSF("EON")
     181 ... D ^DIC
     182 ... I $D(XPDNM) X ^%ZOSF("EOFF")
     183 ... I $D(DUOUT) S Y="" Q
     184 ... I Y=-1 D BMES^XPDUTL("You must input a replacement!")
     185 .. I Y="" S ACTION="Q" Q
     186 .. I Y'="" S FDA(801.412,IENS,2)=$P(Y,U,2)
     187 Q
     188 ;
     189 ;===============================================
     190 ;Convert ICD9 codes to `ien format
     191ICD9(CODE) ;
     192 N IEN
     193 S IEN=$$FIND1^DIC(80,"","AMX",$P(CODE,".",2,99))
     194 I 'IEN Q ""
     195 Q "`"_IEN
     196 ;
     197 ;===============================================
     198TIURPL(SRCH,WP,NAMEGHC,FILENUM) ;Replace TIU templates whose names have
     199 ;changed.
     200 N IND,RS,TEXT,TS,TYPE
     201 I FILENUM=8927.1 S TYPE="TIU TEMPLATE"
     202 E  S TYPE="TIU OBJECT"
     203 S IND=1
     204 F  S TEXT=$G(@WP@(IND)) Q:TEXT=""  D
     205 .I TEXT[SRCH D
     206 ..S TS=""
     207 ..F  S TS=$O(NAMECHG(FILENUM,TS)) Q:TS=""  D
     208 ...S RS=NAMECHG(FILENUM,TS) Q:TEXT'[TS
     209 ...S @WP@(IND)=$$STRREP^PXRMUTIL(TEXT,TS,RS)
     210 ...;Save the replacement information for the history.
     211 ...S ^TMP("PXRMEXIA",$J,"DIATIU",TYPE,TS)=RS
     212 ...S ^TMP("PXRMEXIA",$J,"DIATIU",TYPE,TS,DNAM)=""
     213 .S IND=IND+1
     214 Q
     215 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMFF.m

    r613 r623  
    1 PXRMFF  ;SLC/PKR - Clinical Reminders function finding evaluation. ;3/29/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;===========================================
    4 EVAL(DFN,DEFARR,FIEVAL) ;Evaluate function findings.
    5         N FFIND,FFN,FILIST,FN,FUN,FUNIND,FUNN,FVALUE,JND
    6         N LOGIC,NL,ROUTINE,TEMP
    7         I '$D(DEFARR(25)) Q
    8         S FFN="FF"
    9         F  S FFN=$O(DEFARR(25,FFN)) Q:FFN'["FF"  D
    10         . K FN
    11         . S FUNIND=0
    12         . F  S FUNIND=+$O(DEFARR(25,FFN,5,FUNIND)) Q:FUNIND=0  D
    13         .. S FUNN=$P(DEFARR(25,FFN,5,FUNIND,0),U,1)
    14         .. S FUN=$P(DEFARR(25,FFN,5,FUNIND,0),U,2)
    15         .. S TEMP=^PXRMD(802.4,FUN,0)
    16         .. S ROUTINE=$P(TEMP,U,2,3)_"(.FILIST,.FIEVAL,.FVALUE)"
    17         .. K FILIST
    18         .. S (JND,NL)=0
    19         .. F  S JND=+$O(DEFARR(25,FFN,5,FUNIND,20,JND)) Q:JND=0  D
    20         ... S NL=NL+1
    21         ... S FILIST(NL)=DEFARR(25,FFN,5,FUNIND,20,JND,0)
    22         .. S FILIST(0)=NL
    23         .. D @ROUTINE
    24         .. S FN(FUNIND)=FVALUE
    25         . S LOGIC=$G(DEFARR(25,FFN,10))
    26         . S LOGIC=$S(LOGIC'="":LOGIC,1:0)
    27         . I @LOGIC
    28         . S FIEVAL(FFN)=$T
    29         . S FIEVAL(FFN,"NUMBER")=$P(FFN,"FF",2)
    30         . S FIEVAL(FFN,"FINDING")=$G(FUN)_";PXRMD(802.4,"
    31         Q
    32         ;
    33         ;===========================================
    34 EVALPL(DEFARR,FFIND,PLIST)      ;Build a list of patients based on a function
    35         ;finding.
    36         N COUNT,DAS,DATE,DFN
    37         N FI,FIEVAL,FIEVT,FIL,FILIST,FILENUM,FINDPA,FN
    38         N FUN,FUNNM,FUNN,FUNNUM,FVALUE
    39         N IND,ITEM,JND,LOGIC,LNAME,NFI,NFUN,ROUTINE,TEMP,TERMARR,UNIQFIL
    40         S LOGIC=DEFARR(25,FFIND,10)
    41         I LOGIC="" Q
    42         ;Build the list of functions and findings used by the function finding.
    43         S (FUNNUM,NFUN)=0
    44         F  S FUNNUM=+$O(DEFARR(25,FFIND,5,FUNNUM)) Q:FUNNUM=0  D
    45         . S NFUN=NFUN+1
    46         . S FUNN=$P(DEFARR(25,FFIND,5,FUNNUM,0),U,1)
    47         . S FUN=$P(DEFARR(25,FFIND,5,FUNNUM,0),U,2)
    48         . S TEMP=^PXRMD(802.4,FUN,0)
    49         . S ROUTINE(NFUN)=$P(TEMP,U,2,3)_"(.FIL,.FIEVAL,.FVALUE)"
    50         . S (FI,NFI)=0
    51         . F  S FI=+$O(DEFARR(25,FFIND,5,FUNNUM,20,FI)) Q:FI=0  D
    52         .. S NFI=NFI+1,FILIST(NFUN,NFI)=DEFARR(25,FFIND,5,FUNNUM,20,FI,0)
    53         . S FILIST(NFUN,0)=NFI
    54         ;A finding may be used in more than one function in the function
    55         ;finding so build a list of the unique findings.
    56         F IND=1:1:NFUN D
    57         . F JND=1:1:FILIST(IND,0) D
    58         .. S TEMP=$P(DEFARR(20,FILIST(IND,JND),0),U,1)
    59         .. S ITEM=$P(TEMP,";",1)
    60         .. S FILENUM=$$GETFNUM^PXRMDATA($P(TEMP,";",2))
    61         .. S UNIQFIL(FILIST(IND,JND))=""
    62         K ^TMP($J,"PXRMFFDFN")
    63         S IND=0
    64         F  S IND=$O(UNIQFIL(IND)) Q:IND=""  D
    65         . S FINDPA(0)=DEFARR(20,IND,0)
    66         . S FINDPA(3)=DEFARR(20,IND,3)
    67         . S FINDPA(10)=DEFARR(20,IND,10)
    68         . S FINDPA(11)=DEFARR(20,IND,11)
    69         . D GENTERM^PXRMPLST(FINDPA(0),IND,.TERMARR)
    70         . S LNAME(IND)="PXRMFF"_IND
    71         . K ^TMP($J,LNAME(IND))
    72         . D EVALPL^PXRMTERL(.FINDPA,.TERMARR,LNAME(IND))
    73         .;Get rid of the false part of the list.
    74         . K ^TMP($J,LNAME(IND),0)
    75         .;Build a complete list of patients.
    76         . S DFN=0
    77         . F  S DFN=$O(^TMP($J,LNAME(IND),1,DFN)) Q:DFN=""  S ^TMP($J,"PXRMFFDFN",DFN)=""
    78         ;Evaluate the function finding for each patient. If the function
    79         ;finding is true then add the patient to PLIST.
    80         S DFN=0
    81         F  S DFN=$O(^TMP($J,"PXRMFFDFN",DFN)) Q:DFN=""  D
    82         . K FIEVAL
    83         . S IND=""
    84         . F  S IND=$O(UNIQFIL(IND)) Q:IND=""  D
    85         .. S FIEVAL(IND)=0
    86         .. S ITEM=""
    87         .. F  S ITEM=$O(^TMP($J,LNAME(IND),1,DFN,ITEM)) Q:ITEM=""  D
    88         ... S COUNT=0
    89         ... F  S COUNT=$O(^TMP($J,LNAME(IND),1,DFN,ITEM,COUNT)) Q:COUNT=""  D
    90         .... S FILENUM=$O(^TMP($J,LNAME(IND),1,DFN,ITEM,COUNT,""))
    91         .... S TEMP=^TMP($J,LNAME(IND),1,DFN,ITEM,COUNT,FILENUM)
    92         .... S DAS=$P(TEMP,U,1)
    93         .... S DATE=$P(TEMP,U,2)
    94         .... K FIEVT
    95         .... D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVT)
    96         .... M FIEVAL(IND,COUNT)=FIEVT
    97         .... S FIEVAL(IND,COUNT,"DATE")=DATE,FIEVAL(IND,COUNT)=1
    98         .;Save the top level results for each finding.
    99         . S IND=0
    100         . F  S IND=$O(FIEVAL(IND)) Q:IND=""  D
    101         .. K FIEVT M FIEVT=FIEVAL(IND)
    102         .. S NFI=+$O(FIEVT(""),-1)
    103         .. D SFRES^PXRMUTIL(-1,NFI,.FIEVT)
    104         .. K FIEVAL(IND) M FIEVAL(IND)=FIEVT
    105         .;Evaluate the function finding for this patient.
    106         . K FN
    107         . F IND=1:1:NFUN D
    108         .. K FIL M FIL=FILIST(IND)
    109         .. D @ROUTINE(IND)
    110         .. S FN(IND)=FVALUE
    111         . I @LOGIC S ^TMP($J,PLIST,1,DFN,1,FFIND)=""
    112         ;Clean up.
    113         K ^TMP($J,"PXRMFFDFN")
    114         S IND=""
    115         F  S IND=$O(UNIQFIL(IND)) Q:IND=""  K ^TMP($J,LNAME(IND))
    116         Q
    117         ;
    118         ;===========================================
    119 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    120         ;None currently defined.
    121         Q
    122         ;
    123         ;===========================================
    124 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    125         ;maintenance output. None currently defined.
    126         Q
    127         ;
     1PXRMFF ;SLC/PKR - Clinical Reminders function finding evaluation. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;===========================================
     4EVAL(DFN,DEFARR,FIEVAL) ;Evaluate function findings.
     5 N FFIND,FFN,FILIST,FN,FUN,FUNIND,FUNN,FVALUE,JND
     6 N LOGIC,NL,ROUTINE,TEMP
     7 I '$D(DEFARR(25)) Q
     8 S FFN="FF"
     9 F  S FFN=$O(DEFARR(25,FFN)) Q:FFN'["FF"  D
     10 . K FN
     11 . S FUNIND=0
     12 . F  S FUNIND=+$O(DEFARR(25,FFN,5,FUNIND)) Q:FUNIND=0  D
     13 .. S FUNN=$P(DEFARR(25,FFN,5,FUNIND,0),U,1)
     14 .. S FUN=$P(DEFARR(25,FFN,5,FUNIND,0),U,2)
     15 .. S TEMP=^PXRMD(802.4,FUN,0)
     16 .. S ROUTINE=$P(TEMP,U,2,3)_"(.FILIST,.FIEVAL,.FVALUE)"
     17 .. K FILIST
     18 .. S (JND,NL)=0
     19 .. F  S JND=+$O(DEFARR(25,FFN,5,FUNIND,20,JND)) Q:JND=0  D
     20 ... S NL=NL+1
     21 ... S FILIST(NL)=DEFARR(25,FFN,5,FUNIND,20,JND,0)
     22 .. S FILIST(0)=NL
     23 .. D @ROUTINE
     24 .. S FN(FUNIND)=FVALUE
     25 . S LOGIC=$G(DEFARR(25,FFN,10))
     26 . S LOGIC=$S(LOGIC'="":LOGIC,1:0)
     27 . I @LOGIC
     28 . S FIEVAL(FFN)=$T
     29 . S FIEVAL(FFN,"NUMBER")=$P(FFN,"FF",2)
     30 . S FIEVAL(FFN,"FINDING")=$G(FUN)_";PXRMD(802.4,"
     31 Q
     32 ;
     33 ;===========================================
     34EVALPL(DEFARR,FFIND,PLIST) ;Build a list of patients based on a function
     35 ;finding.
     36 N COUNT,DAS,DATE,DFN
     37 N FI,FIEVAL,FIEVT,FIL,FILIST,FILENUM,FINDPA,FN
     38 N FUN,FUNNM,FUNN,FUNNUM,FVALUE
     39 N IND,ITEM,JND,LOGIC,LNAME,NFI,NFUN,ROUTINE,TEMP,TERMARR,UNIQFIL
     40 S LOGIC=DEFARR(25,FFIND,10)
     41 I LOGIC="" Q
     42 ;Build the list of functions and findings used by the function finding.
     43 S (FUNNUM,NFUN)=0
     44 F  S FUNNUM=+$O(DEFARR(25,FFIND,5,FUNNUM)) Q:FUNNUM=0  D
     45 . S NFUN=NFUN+1
     46 . S FUNN=$P(DEFARR(25,FFIND,5,FUNNUM,0),U,1)
     47 . S FUN=$P(DEFARR(25,FFIND,5,FUNNUM,0),U,2)
     48 . S TEMP=^PXRMD(802.4,FUN,0)
     49 . S ROUTINE(NFUN)=$P(TEMP,U,2,3)_"(.FIL,.FIEVAL,.FVALUE)"
     50 . S (FI,NFI)=0
     51 . F  S FI=+$O(DEFARR(25,FFIND,5,FUNNUM,20,FI)) Q:FI=0  D
     52 .. S NFI=NFI+1,FILIST(NFUN,NFI)=DEFARR(25,FFIND,5,FUNNUM,20,FI,0)
     53 . S FILIST(NFUN,0)=NFI
     54 ;A finding may be used in more than one function in the function
     55 ;finding so build a list of the unique findings.
     56 F IND=1:1:NFUN D
     57 . F JND=1:1:FILIST(IND,0) D
     58 .. S TEMP=$P(DEFARR(20,FILIST(IND,JND),0),U,1)
     59 .. S ITEM=$P(TEMP,";",1)
     60 .. S FILENUM=$$GETFNUM^PXRMDATA($P(TEMP,";",2))
     61 .. S UNIQFIL(FILIST(IND,JND))=""
     62 K ^TMP($J,"PXRMFFDFN")
     63 S IND=0
     64 F  S IND=$O(UNIQFIL(IND)) Q:IND=""  D
     65 . S FINDPA(0)=DEFARR(20,IND,0)
     66 . S FINDPA(3)=DEFARR(20,IND,3)
     67 . S FINDPA(10)=DEFARR(20,IND,10)
     68 . S FINDPA(11)=DEFARR(20,IND,11)
     69 . D GENTERM^PXRMPLST(FINDPA(0),IND,.TERMARR)
     70 . S LNAME(IND)="PXRMFF"_IND
     71 . K ^TMP($J,LNAME(IND))
     72 . D EVALPL^PXRMTERM(.FINDPA,.TERMARR,LNAME(IND))
     73 .;Get rid of the false part of the list.
     74 . K ^TMP($J,LNAME(IND),0)
     75 .;Build a complete list of patients.
     76 . S DFN=0
     77 . F  S DFN=$O(^TMP($J,LNAME(IND),1,DFN)) Q:DFN=""  S ^TMP($J,"PXRMFFDFN",DFN)=""
     78 ;Evaluate the function finding for each patient. If the function
     79 ;finding is true then add the patient to PLIST.
     80 S DFN=0
     81 F  S DFN=$O(^TMP($J,"PXRMFFDFN",DFN)) Q:DFN=""  D
     82 . K FIEVAL
     83 . S IND=""
     84 . F  S IND=$O(UNIQFIL(IND)) Q:IND=""  D
     85 .. S FIEVAL(IND)=0
     86 .. S ITEM=""
     87 .. F  S ITEM=$O(^TMP($J,LNAME(IND),1,DFN,ITEM)) Q:ITEM=""  D
     88 ... S COUNT=0
     89 ... F  S COUNT=$O(^TMP($J,LNAME(IND),1,DFN,ITEM,COUNT)) Q:COUNT=""  D
     90 .... S FILENUM=$O(^TMP($J,LNAME(IND),1,DFN,ITEM,COUNT,""))
     91 .... S TEMP=^TMP($J,LNAME(IND),1,DFN,ITEM,COUNT,FILENUM)
     92 .... S DAS=$P(TEMP,U,1)
     93 .... S DATE=$P(TEMP,U,2)
     94 .... K FIEVT
     95 .... D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVT)
     96 .... M FIEVAL(IND,COUNT)=FIEVT
     97 .... S FIEVAL(IND,COUNT,"DATE")=DATE,FIEVAL(IND,COUNT)=1
     98 .;Save the top level results for each finding.
     99 . S IND=0
     100 . F  S IND=$O(FIEVAL(IND)) Q:IND=""  D
     101 .. K FIEVT M FIEVT=FIEVAL(IND)
     102 .. S NFI=+$O(FIEVT(""),-1)
     103 .. D SFRES^PXRMUTIL(-1,NFI,.FIEVT)
     104 .. K FIEVAL(IND) M FIEVAL(IND)=FIEVT
     105 .;Evaluate the function finding for this patient.
     106 . K FN
     107 . F IND=1:1:NFUN D
     108 .. K FIL M FIL=FILIST(IND)
     109 .. D @ROUTINE(IND)
     110 .. S FN(IND)=FVALUE
     111 . I @LOGIC S ^TMP($J,PLIST,1,DFN,1,FFIND)=""
     112 ;Clean up.
     113 K ^TMP($J,"PXRMFFDFN")
     114 S IND=""
     115 F  S IND=$O(UNIQFIL(IND)) Q:IND=""  K ^TMP($J,LNAME(IND))
     116 Q
     117 ;
     118 ;===========================================
     119MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     120 ;None currently defined.
     121 Q
     122 ;
     123 ;===========================================
     124OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     125 ;maintenance output. None currently defined.
     126 Q
     127 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMFF0.m

    r613 r623  
    1 PXRMFF0 ;SLC/PKR - Clinical Reminders function finding routines. ;09/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;============================================
    5 COUNT(LIST,FIEVAL,COUNT)        ;
    6         N IND,JND,KND
    7         S COUNT=0
    8         F IND=1:1:LIST(0) D
    9         . S JND=LIST(IND),KND=0
    10         . F  S KND=+$O(FIEVAL(JND,KND)) Q:KND=0  D
    11         .. I FIEVAL(JND,KND) S COUNT=COUNT+1
    12         Q
    13         ;
    14         ;===========================================
    15 DIFFDATE(LIST,FIEVAL,DIFF)      ;Return the difference in days between the
    16         ;first two findings in the list.
    17         I LIST(0)<2 S DIFF=2 Q
    18         N DATE1,DATE2,DAYS,IND,JND
    19         S DATE1=+$G(FIEVAL(LIST(1),"DATE"))
    20         S DATE2=+$G(FIEVAL(LIST(2),"DATE"))
    21         S DAYS=$$FMDIFF^XLFDT(DATE1,DATE2)
    22         S DIFF=$S(DAYS<0:-DAYS,1:DAYS)
    23         Q
    24         ;
    25         ;===========================================
    26 DUR(LIST,FIEVAL,DUR)    ;
    27         N EDT,IND,JND,KND,SDT
    28         F IND=1:1:LIST(0) D
    29         . S JND=LIST(IND)
    30         . I FIEVAL(JND)=0 S (EDT,SDT)=0 Q
    31         .;Check for finding with start and stop date.
    32         . I $D(FIEVAL(JND,"START DATE")) D
    33         .. S SDT=+$G(FIEVAL(JND,"START DATE"))
    34         .. S EDT=+$G(FIEVAL(JND,"STOP DATE"))
    35         .. I EDT=0 S EDT=+$G(FIEVAL(JND,"DATE"))
    36         . E  D
    37         ..;Get start and stop for multiple occurrences.
    38         .. S KND=$O(FIEVAL(JND,"A"),-1)
    39         .. S EDT=$S(KND="":0,1:$G(FIEVAL(JND,KND,"DATE")))
    40         .. S KND=+$O(FIEVAL(JND,""))
    41         .. S SDT=$S(KND=0:0,1:$G(FIEVAL(JND,KND,"DATE")))
    42         ;Return the duration in days.
    43         S DUR=$$FMDIFF^XLFDT(EDT,SDT)
    44         I DUR<0 S DUR=-DUR
    45         Q
    46         ;
    47         ;============================================
    48 FI(LIST,FIEVAL,LV)      ;Given a regular finding return its true/false value.
    49         S LV=FIEVAL(LIST(1))
    50         Q
    51         ;
    52         ;============================================
    53 MAXDATE(LIST,FIEVAL,MAXDATE)    ;Given a list of findings return the maximum
    54         ;date. This will be the newest date.
    55         N DATE,IND
    56         S MAXDATE=0
    57         F IND=1:1:LIST(0) D
    58         . S DATE=$G(FIEVAL(LIST(IND),"DATE"))
    59         . I DATE>MAXDATE S MAXDATE=DATE
    60         Q
    61         ;
    62         ;============================================
    63 MINDATE(LIST,FIEVAL,MINDATE)    ;Given a list of findings return the minimum
    64         ;date. This will be the oldest non-null or zero date.
    65         N DATE,IND
    66         S MINDATE=9991231
    67         F IND=1:1:LIST(0) D
    68         . S DATE=$G(FIEVAL(LIST(IND),"DATE"))
    69         . I DATE<MINDATE S MINDATE=DATE
    70         I MINDATE=9991231 S MINDATE=0
    71         Q
    72         ;
    73         ;============================================
    74 MRD(LIST,FIEVAL,MRD)    ;Given a list of findings return the most recent
    75         ;finding date from the list.
    76         N DATE,IND
    77         S MRD=0
    78         F IND=1:1:LIST(0) D
    79         . S DATE=$G(FIEVAL(LIST(IND),"DATE"))
    80         . I DATE>MRD S MRD=DATE
    81         Q
    82         ;
    83         ;============================================
    84 NUMERIC(LIST,FIEVAL,VALUE)      ;Given a finding, return the first numeric
    85         ;portion of one of the "CSUB" values. Based on original work
    86         ;by R. Silverman.
    87         S VALUE=$G(FIEVAL(LIST(1),LIST(2),LIST(3)))
    88         S VALUE=$$FIRSTNUM(VALUE)
    89         Q
    90         ;
    91 FIRSTNUM(STRING)        ;return the first numeric portion of a string.
    92         N CHAR,DONE,IND,NUMBER,NUMERIC
    93         S NUMERIC="+-.1234567890"
    94         S STRING=$TR(STRING," ")
    95         S DONE=0,IND=0,NUMBER=""
    96         F  Q:DONE  D
    97         . S IND=IND+1,CHAR=$E(STRING,IND)
    98         . I CHAR="" S DONE=1 Q
    99         . I NUMERIC[CHAR S NUMBER=NUMBER_CHAR
    100         . I NUMBER'="",NUMERIC'[CHAR S DONE=1
    101         Q +NUMBER
    102         ;
    103         ;============================================
    104 VALUE(LIST,FIEVAL,VALUE)        ;Given a finding return one of its "CSUB"
    105         ;values.
    106         S VALUE=$G(FIEVAL(LIST(1),LIST(2),LIST(3)))
    107         Q
    108         ;
     1PXRMFF0 ;SLC/PKR - Clinical Reminders function finding routines. ;06/23/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;============================================
     5COUNT(LIST,FIEVAL,COUNT) ;
     6 N IND,JND,KND
     7 S COUNT=0
     8 F IND=1:1:LIST(0) D
     9 . S JND=LIST(IND),KND=0
     10 . F  S KND=+$O(FIEVAL(JND,KND)) Q:KND=0  D
     11 .. I FIEVAL(JND,KND) S COUNT=COUNT+1
     12 Q
     13 ;
     14 ;===========================================
     15DIFFDATE(LIST,FIEVAL,DIFF) ;Return the difference in days between the
     16 ;first two findings in the list.
     17 I LIST(0)<2 S DIFF=2 Q
     18 N DATE1,DATE2,DAYS,IND,JND
     19 S DATE1=+$G(FIEVAL(LIST(1),"DATE"))
     20 S DATE2=+$G(FIEVAL(LIST(2),"DATE"))
     21 S DAYS=$$FMDIFF^XLFDT(DATE1,DATE2)
     22 S DIFF=$S(DAYS<0:-DAYS,1:DAYS)
     23 Q
     24 ;
     25 ;===========================================
     26DUR(LIST,FIEVAL,DUR) ;
     27 N EDT,IND,JND,KND,SDT
     28 F IND=1:1:LIST(0) D
     29 . S JND=LIST(IND)
     30 . I FIEVAL(JND)=0 S (EDT,SDT)=0 Q
     31 .;Check for finding with start and stop date.
     32 . I $D(FIEVAL(JND,"START DATE")) D
     33 .. S SDT=+$G(FIEVAL(JND,"START DATE"))
     34 .. S EDT=+$G(FIEVAL(JND,"STOP DATE"))
     35 .. I EDT=0 S EDT=+$G(FIEVAL(JND,"DATE"))
     36 . E  D
     37 ..;Get start and stop for multiple occurrences.
     38 .. S KND=$O(FIEVAL(JND,"A"),-1)
     39 .. S EDT=$S(KND="":0,1:$G(FIEVAL(JND,KND,"DATE")))
     40 .. S KND=+$O(FIEVAL(JND,""))
     41 .. S SDT=$S(KND=0:0,1:$G(FIEVAL(JND,KND,"DATE")))
     42 ;Return the duration in days.
     43 S DUR=$$FMDIFF^XLFDT(EDT,SDT)
     44 I DUR<0 S DUR=-DUR
     45 Q
     46 ;
     47 ;============================================
     48FI(LIST,FIEVAL,LV) ;Given a regular finding return its true/false value.
     49 S LV=FIEVAL(LIST(1))
     50 Q
     51 ;
     52 ;============================================
     53MAXDATE(LIST,FIEVAL,MAXDATE) ;Given a list of findings return the maximum
     54 ;date. This will be the newest date.
     55 N DATE,IND
     56 S MAXDATE=0
     57 F IND=1:1:LIST(0) D
     58 . S DATE=$G(FIEVAL(LIST(IND),"DATE"))
     59 . I DATE>MAXDATE S MAXDATE=DATE
     60 Q
     61 ;
     62 ;============================================
     63MINDATE(LIST,FIEVAL,MINDATE) ;Given a list of findings return the minimum
     64 ;date. This will be the oldest non-null or zero date.
     65 N DATE,IND
     66 S MINDATE=9991231
     67 F IND=1:1:LIST(0) D
     68 . S DATE=$G(FIEVAL(LIST(IND),"DATE"))
     69 . I DATE<MINDATE S MINDATE=DATE
     70 I MINDATE=9991231 S MINDATE=0
     71 Q
     72 ;
     73 ;============================================
     74MRD(LIST,FIEVAL,MRD) ;Given a list of findings return the most recent
     75 ;finding date from the list.
     76 N DATE,IND
     77 S MRD=0
     78 F IND=1:1:LIST(0) D
     79 . S DATE=$G(FIEVAL(LIST(IND),"DATE"))
     80 . I DATE>MRD S MRD=DATE
     81 Q
     82 ;
     83 ;============================================
     84VALUE(LIST,FIEVAL,VALUE) ;Given a finding return one of its "CSUB"
     85 ;values.
     86 S VALUE=$G(FIEVAL(LIST(1),LIST(2),LIST(3)))
     87 Q
     88 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMFFAT.m

    r613 r623  
    1 PXRMFFAT        ;SLC/PKR - Function Finding argument type routines. ;09/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;============================================
    5 ARGTYPE(FUNCTION,AN)    ;Given a FUNCTION and argument number return the
    6         ;corresponding argument type. Possible argument types are:
    7         ; F - finding
    8         ; N - number
    9         ; S - string
    10         ; U - undefined
    11         N ROUTINE
    12         ;The routine for any function is the same as the name of the
    13         ;function except for functions with "_" in the name. In that
    14         ;case the "_" is removed.
    15         S ROUTINE="$$"_$TR(FUNCTION,"_","")_"(AN)"
    16         Q @ROUTINE
    17         ;
    18         ;============================================
    19 COUNT(AN)       ;
    20         Q $S(AN=1:"F",1:"U")
    21         ;
    22         ;===========================================
    23 DIFFDATE(AN)    ;
    24         Q $S(AN=1:"F",AN=2:"F",1:"U")
    25         ;
    26         ;===========================================
    27 DUR(AN) ;
    28         Q $S(AN=1:"F",1:"U")
    29         ;
    30         ;============================================
    31 FI(AN)  ;
    32         Q $S(AN=1:"F",1:"U")
    33         ;
    34         ;============================================
    35 MAXDATE(AN)     ;
    36         I AN>0,AN<100 Q "F"
    37         E  Q "U"
    38         ;
    39         ;============================================
    40 MINDATE(AN)     ;
    41         I AN>0,AN<100 Q "F"
    42         E  Q "U"
    43         ;
    44         ;============================================
    45 MRD(AN) ;
    46         I AN>0,AN<100 Q "F"
    47         E  Q "U"
    48         ;
    49         ;============================================
    50 NUMERIC(AN)     ;
    51         Q $S(AN=1:"F",AN=2:"N",AN=3:"S",1:"U")
    52         ;
    53         ;============================================
    54 VALUE(AN)       ;
    55         Q $S(AN=1:"F",AN=2:"N",AN=3:"S",1:"U")
    56         ;
     1PXRMFFAT ;SLC/PKR - Function Finding argument type routines. ;08/03/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;============================================
     5ARGTYPE(FUNCTION,AN) ;Given a FUNCTION and argument number return the
     6 ;corresponding argument type. Possible argument types are:
     7 ; F - finding
     8 ; N - number
     9 ; S - string
     10 ; U - undefined
     11 N ROUTINE
     12 ;The routine for any function is the same as the name of the
     13 ;function except for functions with "_" in the name. In that
     14 ;case the "_" is removed.
     15 S ROUTINE="$$"_$TR(FUNCTION,"_","")_"(AN)"
     16 Q @ROUTINE
     17 ;
     18 ;============================================
     19COUNT(AN) ;
     20 Q $S(AN=1:"F",1:"U")
     21 ;
     22 ;===========================================
     23DIFFDATE(AN) ;
     24 Q $S(AN=1:"F",AN=2:"F",1:"U")
     25 ;
     26 ;===========================================
     27DUR(AN) ;
     28 Q $S(AN=1:"F",1:"U")
     29 ;
     30 ;============================================
     31FI(AN) ;
     32 Q $S(AN=1:"F",1:"U")
     33 ;
     34 ;============================================
     35MAXDATE(AN) ;
     36 I AN>0,AN<100 Q "F"
     37 E  Q "U"
     38 ;
     39 ;============================================
     40MINDATE(AN) ;
     41 I AN>0,AN<100 Q "F"
     42 E  Q "U"
     43 ;
     44 ;============================================
     45MRD(AN) ;
     46 I AN>0,AN<100 Q "F"
     47 E  Q "U"
     48 ;
     49 ;============================================
     50VALUE(AN) ;
     51 Q $S(AN=1:"F",AN=2:"N",AN=3:"S",1:"U")
     52 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMFFDB.m

    r613 r623  
    1 PXRMFFDB        ;SLC/PKR - Function finding data structure builder. ;10/31/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;===========================================
    5 BASE2(NUM)      ;Convert a base 10 integer to base 2.
    6         N BD,BIN
    7         S BIN=""
    8         F  Q:NUM=0  D
    9         . S BD=$S((NUM\2)=(NUM/2):0,1:1)
    10         . S BIN=BD_BIN,NUM=NUM\2
    11         Q BIN
    12         ;
    13         ;===========================================
    14 CRESLOG(NUM,FLIST,RESLOG)       ;Check the resolution logic to see if
    15         ;it can be made true solely by function findings. If that is the case
    16         ;warn the user. Called by BLDRESLS^PXRMLOGX
    17         N AGEFI,BP,FI,FF,FFL,IND,JND,KND,LE,LEN,LND,NFF,NTC,SEXFI,TEMP,VALUE
    18         S (AGEFI,SEXFI)=0
    19         S NFF=0
    20         F IND=1:1:NUM D
    21         . S JND=$P(FLIST,";",IND)
    22         . I +JND=JND S FI(JND)=0 Q
    23         . I JND["FF" S NFF=NFF+1,FF=$P(JND,"FF",2),FFL(NFF)=FF
    24         I NFF=0 Q
    25         ;Generate and test all combinations of true and false FFs.
    26         S VALUE=0
    27         S NTC=$$PWR^XLFMTH(2,NFF)-1
    28         F IND=1:1:NTC Q:VALUE  D
    29         . S BIN=$$BASE2(IND)
    30         . S LEN=$L(BIN)
    31         . S LE=NFF-LEN
    32         .;Fill in the values for the implied preceeding 0s.
    33         . F JND=1:1:LE S KND=FFL(JND),FF(KND)=0
    34         . S LND=0
    35         . F JND=LE+1:1:NFF D
    36         .. S KND=FFL(JND),LND=LND+1
    37         .. S FF(KND)=$E(BIN,LND)
    38         . I @RESLOG
    39         . S VALUE=$T
    40         I VALUE D
    41         . N RESLSTR
    42         . S RESLSTR=RESLOG
    43         . F IND=1:1:NUM D
    44         .. S JND=$P(FLIST,";",IND)
    45         .. S TEMP=$S(JND["FF":"FF("_$P(JND,"FF",2)_")",1:"FI("_JND_")")
    46         .. S RESLOG=$$STRREP^PXRMUTIL(RESLOG,TEMP,@TEMP)
    47         . S RESLOG=$$STRREP^PXRMUTIL(RESLOG,"AGE",AGEFI)
    48         . S RESLOG=$$STRREP^PXRMUTIL(RESLOG,"SEX",SEXFI)
    49         . W !!,"Warning - your resolution logic can be satisfied by function findings only."
    50         . W !,"If this happens it will not be possible to calculate a resolution date and"
    51         . W !,"the reminder will not be resolved. Here is a case where the logic evaluates"
    52         . W !,"to true:"
    53         . W !,RESLSTR
    54         . W !,RESLOG
    55         . W !
    56         Q
    57         ;
    58         ;=============================================================
    59 FFBUILD(X,DA)   ;Given a function finding logical string build the data
    60         ;structure. This is called by a new-style cross-reference after
    61         ;the function string has passed the input transform so we don't need
    62         ;to validate the elements.
    63         ;Do not execute as part of a verify fields.
    64         I $G(DIUTIL)="VERIFY FIELDS" Q
    65         ;Do not execute as part of exchange.
    66         I $G(PXRMEXCH) Q
    67         N FDA,FUNNUM,FUNP,IENB,IENS,IND,JND,L2,L3,LEN,LIST,LOGIC,OPER,MSG
    68         N PFSTACK,REPL,RS,TEMP,TS,XS
    69         S IENB=DA_","_DA(1)_","
    70         S OPER="!&-+<>='"
    71         S XS=$$PSPACE(X)
    72         D POSTFIX^PXRMSTAC(XS,OPER,.PFSTACK)
    73         S (FUNNUM,L2)=0
    74         F IND=1:1:PFSTACK(0) D
    75         . S TEMP=PFSTACK(IND)
    76         . I $D(^PXRMD(802.4,"B",TEMP)) D
    77         .. S FUNP=$O(^PXRMD(802.4,"B",TEMP,""))
    78         .. S FUNNUM=FUNNUM+1,L2=L2+1
    79         .. S IENS="+"_L2_","_IENB
    80         .. S FDA(811.9255,IENS,.01)=FUNNUM
    81         .. S FDA(811.9255,IENS,.02)=FUNP
    82         .. S IND=IND+1
    83         .. S LIST=$TR(PFSTACK(IND),"~"," ")
    84         .. S REPL(FUNNUM)=TEMP_"("_LIST_")"_U_"FN("_FUNNUM_")"
    85         .. S L3=L2
    86         .. S LEN=$L(LIST,",")
    87         .. F JND=1:1:LEN D
    88         ... S L3=L3+1
    89         ... S IENS="+"_L3_",+"_L2_","_IENB
    90         ... S TS=$P(LIST,",",JND)
    91         ... S TS=$TR(TS,"""","")
    92         ... S FDA(811.9256,IENS,.01)=TS
    93         .. S L2=L3
    94         ;Build the logic string
    95         S LOGIC=X
    96         F IND=1:1:FUNNUM D
    97         . S TS=$P(REPL(IND),U,1)
    98         . S RS=$P(REPL(IND),U,2)
    99         . S LOGIC=$$STRREP^PXRMUTIL(LOGIC,TS,RS)
    100         S FDA(811.925,IENB,10)=LOGIC
    101         D UPDATE^DIE("","FDA","IENB","MSG")
    102         I $D(MSG) D
    103         . W !,"The update failed, UPDATE^DIE returned the following error message:"
    104         . D AWRITE^PXRMUTIL("MSG")
    105         Q
    106         ;
    107         ;=============================================================
    108 FFKILL(X,DA)    ;This is the kill logic for the function string.
    109         ;Do not execute as part of a verify fields.
    110         I $G(DIUTIL)="VERIFY FIELDS" Q
    111         ;Do not execute as part of exchange.
    112         I $G(PXRMEXCH) Q
    113         K ^PXD(811.9,DA(1),25,DA,5),^PXD(811.9,DA(1),25,DA,10)
    114         Q
    115         ;
    116         ;=============================================================
    117 ISGRV(VAR)      ;Return true if VAR is a global reminder variable.
    118         I VAR="PXRMAGE" Q 1
    119         I VAR="PXRMDOB" Q 1
    120         I VAR="PXRMLAD" Q 1
    121         I VAR="PXRMSEX" Q 1
    122         Q 0
    123         ;
    124         ;=============================================================
    125 ISSTR(STRING)   ;Return true if STRING really is a string and it is not
    126         ;executable Mumps code.
    127         N VALID,X
    128         S VALID=0
    129         ;Valid strings are "text" or because of $P ,"text" or ",U".
    130         I $E(STRING,1)="""",$E(STRING,$L(STRING))="""" S VALID=1
    131         I 'VALID,$E(STRING,1)=",",$E(STRING,2)="""",$E(STRING,$L(STRING))="""" S VALID=1
    132         I 'VALID,STRING=",U" S VALID=1
    133         I 'VALID Q VALID
    134         S X=STRING
    135         D ^DIM
    136         S VALID=$S($D(X)=0:1,1:0)
    137         Q VALID
    138         ;
    139         ;=============================================================
    140 PSPACE(OPR)     ;OPR is an operand in a function finding, if some portion
    141         ;of OPR is a string translate a space into "~" so it is preserved.
    142         ;Note this will work for the entire function string.
    143         N DONE,END,START,TNS,TS
    144         S DONE=0,END=1
    145         F  Q:DONE  D
    146         . S START=$F(OPR,"""",END)
    147         . I START=0 S DONE=1 Q
    148         . S END=$F(OPR,"""",START)
    149         . S TS=$E(OPR,START,END-2)
    150         . S TNS=$TR(TS," ","~")
    151         . S OPR=$$STRREP^PXRMUTIL(OPR,TS,TNS)
    152         Q OPR
    153         ;
    154         ;=============================================================
    155 VFFORM(TEMP,X)  ;Make sure the function has a valid form, i.e., function
    156         ;followed by an argument list.
    157         N DONE,LP,RP,START,VALID
    158         S DONE=0,VALID=1,START=0
    159         F  Q:DONE  D
    160         . S START=$F(X,TEMP,START)
    161         . I START=0 S DONE=1 Q
    162         . S LP=$E(X,START)
    163         . I LP'="(" S VALID=0,DONE=1 Q
    164         . S START=$F(X,")",START)
    165         . S RP=$E(X,START-1)
    166         . I RP'=")" S VALID=0
    167         I 'VALID D
    168         . N TEXT
    169         . S TEXT="Function "_TEMP_" must be followed by an argument list!"
    170         . D EN^DDIOL(.TEXT)
    171         Q VALID
    172         ;
    173         ;=============================================================
    174 VFINDING(X,DAI) ;Make sure a finding number is a valid member of the
    175         ;definition finding multiple. Input transform for function
    176         ;finding finding number.
    177         ;Do not execute as part of a verify fields.
    178         I $G(DIUTIL)="VERIFY FIELDS" Q 1
    179         ;Do not execute as part of exchange.
    180         I $G(PXRMEXCH) Q 1
    181         I '$D(DAI) Q 1
    182         ;If X is not numeric it is not a finding number.
    183         I +X'=X Q 1
    184         I $D(^PXD(811.9,DAI,20,X,0)) Q 1
    185         E  D  Q 0
    186         . N TEXT
    187         . S TEXT="Finding number "_X_" does not exist!"
    188         . D EN^DDIOL(TEXT)
    189         ;
    190         ;=============================================================
    191 VFSTRING(FFSTRING,DA)   ;Make sure a function finding string is valid.
    192         ;The elements can be functions, operators, and numbers.
    193         ;Do not execute as part of a verify fields.
    194         I $G(DIUTIL)="VERIFY FIELDS" Q 1
    195         ;Do not execute as part of exchange.
    196         I $G(PXRMEXCH) Q 1
    197         I '$D(DA) Q 1
    198         N DAI,DATE,FUNIEN,IND,LIST,MFUN,OPER,PFSTACK,TEMP,TEXT,VALID
    199         S DAI=DA(1)
    200         S OPER="!&-+<>='"
    201         ;Define the allowed M functions.
    202         S MFUN("$P")=""
    203         D POSTFIX^PXRMSTAC(FFSTRING,OPER,.PFSTACK)
    204         S VALID=1
    205         F IND=1:1:PFSTACK(0) Q:'VALID  D
    206         . S TEMP=PFSTACK(IND)
    207         . I $D(^PXRMD(802.4,"B",TEMP)) D  Q
    208         .. S VALID=$$VFFORM(TEMP,X)
    209         .. I 'VALID Q
    210         .. S FUNIEN=$O(^PXRMD(802.4,"B",TEMP,""))
    211         .. S IND=IND+1
    212         .. S LIST=$G(PFSTACK(IND))
    213         .. S VALID=$$VLIST(LIST,DAI,TEMP,FUNIEN)
    214         .;Check for operator
    215         . I OPER[TEMP Q
    216         .;Check for number
    217         . I TEMP=+TEMP Q
    218         .;Check for allowed M function.
    219         . I $D(MFUN(TEMP)) Q
    220         .;Check for a global reminder variable
    221         . I $$ISGRV(TEMP) Q
    222         .;Check for a non-executable string.
    223         . I $$ISSTR(TEMP) Q
    224         . S VALID=0
    225         . S TEXT=TEMP_" is not a valid Function Finding element!"
    226         . D EN^DDIOL(TEXT)
    227         I VALID D
    228         . N X
    229         . S X="I "_FFSTRING
    230         . D ^DIM
    231         . I $D(X)=0 S VALID=0
    232         I 'VALID D
    233         . S TEMP=FFSTRING_" is not a valid function string"
    234         . D EN^DDIOL(TEMP)
    235         Q VALID
    236         ;
    237         ;=============================================================
    238 VLIST(LIST,DAI,FUNCTION,FUNIEN) ;Make sure the function argument list
    239         ;is valid.
    240         N AT,IND,LEN,PATTERN,VALID,X
    241         S LEN=$L(LIST,",")
    242         I LEN=0 D  Q 0
    243         . N TEXT
    244         . S TEXT="The argument list is not defined!"
    245         . D EN^DDIOL(TEXT)
    246         S PATTERN=$P(^PXRMD(802.4,FUNIEN,0),U,5)
    247         S VALID=$S(LIST?@PATTERN:1,1:0)
    248         I 'VALID D  Q 0
    249         . N TEXT
    250         . S TEXT="Argument list "_LIST_" is not correct for function "_$P(^PXRMD(802.4,FUNIEN,0),U,1)
    251         . D EN^DDIOL(TEXT)
    252         F IND=1:1:LEN D
    253         . S X=$P(LIST,",",IND)
    254         . S AT=$$ARGTYPE^PXRMFFAT(FUNCTION,IND)
    255         . I AT="U" S VALID=0 Q
    256         . I AT="F",'$$VFINDING(X,DAI) S VALID=0
    257         Q VALID
    258         ;
     1PXRMFFDB ;SLC/PKR - Function finding data structure builder. ;06/22/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;===========================================
     5BASE2(NUM) ;Convert a base 10 integer to base 2.
     6 N BD,BIN
     7 S BIN=""
     8 F  Q:NUM=0  D
     9 . S BD=$S((NUM\2)=(NUM/2):0,1:1)
     10 . S BIN=BD_BIN,NUM=NUM\2
     11 Q BIN
     12 ;
     13 ;===========================================
     14CRESLOG(NUM,FLIST,RESLOG) ;Check the resolution logic to see if
     15 ;it can be made true solely by function findings. If that is the case
     16 ;warn the user. Called by BLDRESLS^PXRMLOGX
     17 N AGEFI,BP,FI,FF,FFL,IND,JND,KND,LE,LEN,LND,NFF,NTC,SEXFI,TEMP,VALUE
     18 S (AGEFI,SEXFI)=0
     19 S NFF=0
     20 F IND=1:1:NUM D
     21 . S JND=$P(FLIST,";",IND)
     22 . I +JND=JND S FI(JND)=0 Q
     23 . I JND["FF" S NFF=NFF+1,FF=$P(JND,"FF",2),FFL(NFF)=FF
     24 I NFF=0 Q
     25 ;Generate and test all combinations of true and false FFs.
     26 S VALUE=0
     27 S NTC=$$PWR^XLFMTH(2,NFF)-1
     28 F IND=1:1:NTC Q:VALUE  D
     29 . S BIN=$$BASE2(IND)
     30 . S LEN=$L(BIN)
     31 . S LE=NFF-LEN
     32 .;Fill in the values for the implied preceeding 0s.
     33 . F JND=1:1:LE S KND=FFL(JND),FF(KND)=0
     34 . S LND=0
     35 . F JND=LE+1:1:NFF D
     36 .. S KND=FFL(JND),LND=LND+1
     37 .. S FF(KND)=$E(BIN,LND)
     38 . I @RESLOG
     39 . S VALUE=$T
     40 I VALUE D
     41 . N RESLSTR
     42 . S RESLSTR=RESLOG
     43 . F IND=1:1:NUM D
     44 .. S JND=$P(FLIST,";",IND)
     45 .. S TEMP=$S(JND["FF":"FF("_$P(JND,"FF",2)_")",1:"FI("_JND_")")
     46 .. S RESLOG=$$STRREP^PXRMUTIL(RESLOG,TEMP,@TEMP)
     47 . S RESLOG=$$STRREP^PXRMUTIL(RESLOG,"AGE",AGEFI)
     48 . S RESLOG=$$STRREP^PXRMUTIL(RESLOG,"SEX",SEXFI)
     49 . W !!,"Warning - your resolution logic can be satisfied by function findings only."
     50 . W !,"If this happens it will not be possible to calculate a resolution date and"
     51 . W !,"the reminder will not be resolved. Here is a case where the logic evaluates"
     52 . W !,"to true:"
     53 . W !,RESLSTR
     54 . W !,RESLOG
     55 . W !
     56 Q
     57 ;
     58 ;=============================================================
     59FFBUILD(X,DA) ;Given a function finding logical string build the data
     60 ;structure. This is called by a new-style cross-reference after
     61 ;the function string has passed the input transform so we don't need
     62 ;to validate the elements.
     63 ;Do not execute as part of a verify fields.
     64 I $G(DIUTIL)="VERIFY FIELDS" Q
     65 ;Do not execute as part of exchange.
     66 I $G(PXRMEXCH) Q
     67 N FDA,FUNNUM,FUNP,IENB,IENS,IND,JND,L2,L3,LEN,LIST,LOGIC,OPER,MSG
     68 N PFSTACK,REPL,RS,TEMP,TS,XS
     69 S IENB=DA_","_DA(1)_","
     70 S OPER="!&<>='"
     71 S XS=$$PSPACE(X)
     72 D POSTFIX^PXRMSTAC(XS,OPER,.PFSTACK)
     73 S (FUNNUM,L2)=0
     74 F IND=1:1:PFSTACK(0) D
     75 . S TEMP=PFSTACK(IND)
     76 . I $D(^PXRMD(802.4,"B",TEMP)) D
     77 .. S FUNP=$O(^PXRMD(802.4,"B",TEMP,""))
     78 .. S FUNNUM=FUNNUM+1,L2=L2+1
     79 .. S IENS="+"_L2_","_IENB
     80 .. S FDA(811.9255,IENS,.01)=FUNNUM
     81 .. S FDA(811.9255,IENS,.02)=FUNP
     82 .. S IND=IND+1
     83 .. S LIST=$TR(PFSTACK(IND),"~"," ")
     84 .. S REPL(FUNNUM)=TEMP_"("_LIST_")"_U_"FN("_FUNNUM_")"
     85 .. S L3=L2
     86 .. S LEN=$L(LIST,",")
     87 .. F JND=1:1:LEN D
     88 ... S L3=L3+1
     89 ... S IENS="+"_L3_",+"_L2_","_IENB
     90 ... S TS=$P(LIST,",",JND)
     91 ... S TS=$TR(TS,"""","")
     92 ... S FDA(811.9256,IENS,.01)=TS
     93 .. S L2=L3
     94 ;Build the logic string
     95 S LOGIC=X
     96 F IND=1:1:FUNNUM D
     97 . S TS=$P(REPL(IND),U,1)
     98 . S RS=$P(REPL(IND),U,2)
     99 . S LOGIC=$$STRREP^PXRMUTIL(LOGIC,TS,RS)
     100 S FDA(811.925,IENB,10)=LOGIC
     101 D UPDATE^DIE("","FDA","IENB","MSG")
     102 I $D(MSG) D
     103 . W !,"The update failed, UPDATE^DIE returned the following error message:"
     104 . D AWRITE^PXRMUTIL("MSG")
     105 Q
     106 ;
     107 ;=============================================================
     108FFKILL(X,DA) ;This is the kill logic for the function string.
     109 ;Do not execute as part of a verify fields.
     110 I $G(DIUTIL)="VERIFY FIELDS" Q
     111 ;Do not execute as part of exchange.
     112 I $G(PXRMEXCH) Q
     113 K ^PXD(811.9,DA(1),25,DA,5),^PXD(811.9,DA(1),25,DA,10)
     114 Q
     115 ;
     116 ;=============================================================
     117ISGRV(VAR) ;Return true if VAR is a global reminder variable.
     118 I VAR="PXRMAGE" Q 1
     119 I VAR="PXRMDOB" Q 1
     120 I VAR="PXRMLAD" Q 1
     121 I VAR="PXRMSEX" Q 1
     122 Q 0
     123 ;
     124 ;=============================================================
     125ISSTR(STRING) ;Return true if STRING really is a string and it is not
     126 ;executable Mumps code.
     127 N VALID,X
     128 S VALID=0
     129 ;Valid strings are "text" or because of $P ,"text" or ",U".
     130 I $E(STRING,1)="""",$E(STRING,$L(STRING))="""" S VALID=1
     131 I 'VALID,$E(STRING,1)=",",$E(STRING,2)="""",$E(STRING,$L(STRING))="""" S VALID=1
     132 I 'VALID,STRING=",U" S VALID=1
     133 I 'VALID Q VALID
     134 S X=STRING
     135 D ^DIM
     136 S VALID=$S($D(X)=0:1,1:0)
     137 Q VALID
     138 ;
     139 ;=============================================================
     140PSPACE(OPR) ;OPR is an operand in a function finding, if some portion
     141 ;of OPR is a string translate a space into "~" so it is preserved.
     142 N END,START,TNS,TS
     143 S START=$F(OPR,"""")
     144 I START=0 Q OPR
     145 S END=$F(OPR,"""",START)-2
     146 S TS=$E(OPR,START,END)
     147 S TNS=$TR(TS," ","~")
     148 S OPR=$$STRREP^PXRMUTIL(OPR,TS,TNS)
     149 Q OPR
     150 ;
     151 ;=============================================================
     152VFFORM(TEMP,X) ;Make sure the function has a valid form, i.e., function
     153 ;followed by an argument list.
     154 N DONE,LP,RP,START,VALID
     155 S DONE=0,VALID=1,START=0
     156 F  Q:DONE  D
     157 . S START=$F(X,TEMP,START)
     158 . I START=0 S DONE=1 Q
     159 . S LP=$E(X,START)
     160 . I LP'="(" S VALID=0,DONE=1 Q
     161 . S START=$F(X,")",START)
     162 . S RP=$E(X,START-1)
     163 . I RP'=")" S VALID=0
     164 I 'VALID D
     165 . N TEXT
     166 . S TEXT="Function "_TEMP_" must be followed by an argument list!"
     167 . D EN^DDIOL(.TEXT)
     168 Q VALID
     169 ;
     170 ;=============================================================
     171VFINDING(X,DAI) ;Make sure a finding number is a valid member of the
     172 ;definition finding multiple. Input transform for function
     173 ;finding finding number.
     174 ;Do not execute as part of a verify fields.
     175 I $G(DIUTIL)="VERIFY FIELDS" Q 1
     176 ;Do not execute as part of exchange.
     177 I $G(PXRMEXCH) Q 1
     178 I '$D(DAI) Q 1
     179 ;If X is not numeric it is not a finding number.
     180 I +X'=X Q 1
     181 I $D(^PXD(811.9,DAI,20,X,0)) Q 1
     182 E  D  Q 0
     183 . N TEXT
     184 . S TEXT="Finding number "_X_" does not exist!"
     185 . D EN^DDIOL(TEXT)
     186 ;
     187 ;=============================================================
     188VFSTRING(FFSTRING,DA) ;Make sure a function finding string is valid.
     189 ;The elements can be functions, operators, and numbers.
     190 ;Do not execute as part of a verify fields.
     191 I $G(DIUTIL)="VERIFY FIELDS" Q 1
     192 ;Do not execute as part of exchange.
     193 I $G(PXRMEXCH) Q 1
     194 I '$D(DA) Q 1
     195 N DAI,DATE,FUNIEN,IND,LIST,MFUN,OPER,PFSTACK,TEMP,TEXT,VALID
     196 S DAI=DA(1)
     197 S OPER="!&<>='"
     198 ;Define the allowed M functions.
     199 S MFUN("$P")=""
     200 D POSTFIX^PXRMSTAC(FFSTRING,OPER,.PFSTACK)
     201 S VALID=1
     202 F IND=1:1:PFSTACK(0) Q:'VALID  D
     203 . S TEMP=PFSTACK(IND)
     204 . I $D(^PXRMD(802.4,"B",TEMP)) D  Q
     205 .. S VALID=$$VFFORM(TEMP,X)
     206 .. I 'VALID Q
     207 .. S FUNIEN=$O(^PXRMD(802.4,"B",TEMP,""))
     208 .. S IND=IND+1
     209 .. S LIST=$G(PFSTACK(IND))
     210 .. S VALID=$$VLIST(LIST,DAI,TEMP,FUNIEN)
     211 .;Check for operator
     212 . I OPER[TEMP Q
     213 .;Check for number
     214 . I TEMP=+TEMP Q
     215 .;Check for allowed M function.
     216 . I $D(MFUN(TEMP)) Q
     217 .;Check for a global reminder variable
     218 . I $$ISGRV(TEMP) Q
     219 .;Check for a non-executable string.
     220 . I $$ISSTR(TEMP) Q
     221 . S VALID=0
     222 . S TEXT=TEMP_" is not a valid Function Finding element!"
     223 . D EN^DDIOL(TEXT)
     224 I VALID D
     225 . N X
     226 . S X="I "_FFSTRING
     227 . D ^DIM
     228 . I $D(X)=0 S VALID=0
     229 I 'VALID D
     230 . S TEMP=FFSTRING_" is not a valid function string"
     231 . D EN^DDIOL(TEMP)
     232 Q VALID
     233 ;
     234 ;=============================================================
     235VLIST(LIST,DAI,FUNCTION,FUNIEN) ;Make sure the function argument list
     236 ;is valid.
     237 N AT,IND,LEN,PATTERN,VALID,X
     238 S LEN=$L(LIST,",")
     239 I LEN=0 D  Q 0
     240 . N TEXT
     241 . S TEXT="The argument list is not defined!"
     242 . D EN^DDIOL(TEXT)
     243 S PATTERN=$P(^PXRMD(802.4,FUNIEN,0),U,5)
     244 S VALID=$S(LIST?@PATTERN:1,1:0)
     245 I 'VALID D  Q 0
     246 . N TEXT
     247 . S TEXT="Argument list "_LIST_" is not correct for function "_$P(^PXRMD(802.4,FUNIEN,0),U,1)
     248 . D EN^DDIOL(TEXT)
     249 F IND=1:1:LEN D
     250 . S X=$P(LIST,",",IND)
     251 . S AT=$$ARGTYPE^PXRMFFAT(FUNCTION,IND)
     252 . I AT="U" S VALID=0 Q
     253 . I AT="F",'$$VFINDING(X,DAI) S VALID=0
     254 Q VALID
     255 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMGECN.m

    r613 r623  
    1 PXRMGECN        ;SLC/JVS GEC-Score Reports-cont'd ;06/01/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         Q
    4 SUM     ;By Summary by Patient
    5         N CAT,HF,DATE,DFN,Y,HFN,CNTREF,X,REFNUM,SUM,GSUM,CATDANA
    6         N DATER,SDATE,SCNT
    7         D E^PXRMGECV("HS1",1,BDT,EDT,"F",DFNONLY)
    8         I FORMAT="D" S FOR=0
    9         I FORMAT="F" S FOR=1
    10         W @IOF
    11         S CATDANA("GEC REFERRAL BASIC ADL")=""
    12         S CATDANA("GEC REFERRAL IADL")=""
    13         S CATDANA("GEC REFERRAL SKILLED CARE")=""
    14         S CATDANA("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")=""
    15         ;
    16         S Y=1,SUM=0,DATER=0,GSUM=0
    17         S DFN="" F  S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN=""!(Y=0)  D
    18         .S CNTREF="",REFNUM=0 F  S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF=""!(Y=0)  D
    19         ..S REFNUM=REFNUM+1
    20         ..S SDATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,0)) D
    21         ...S DATER=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,SDATE,0))
    22         ..S DATE=0 F  S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE=""!(Y=0)  D
    23         ...S VDT=0 F  S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT=""!(Y=0)  D
    24         ....S CAT=0 F  S CAT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT)) Q:CAT=""!(Y=0)  D
    25         .....Q:'$D(CATDANA(CAT))
    26         .....S SUM=0
    27         .....S DATEV=0 F  S DATEV=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV)) Q:DATEV=""!(Y=0)  D
    28         ......S DA=0 F  S DA=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV,DA)) Q:DA=""!(Y=0)  D
    29         .......S HFN=$$HFNAME^PXRMGECR(DA)
    30         .......S SUM=SUM+$$VALUE($P($G(^AUPNVHF(DA,0)),"^",1))
    31         .......S CATSUM(CAT)=SUM
    32         ..S GSUM=+$G(CATSUM("GEC REFERRAL IADL"))+(+$G(CATSUM("GEC REFERRAL BASIC ADL")))+(+$G(CATSUM("GEC REFERRAL SKILLED CARE")))+(+$G(CATSUM("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")))
    33         ..S ^TMP("PXRMGEC",$J,"S",DFN,SDATE,DATER,+$G(CATSUM("GEC REFERRAL IADL")),+$G(CATSUM("GEC REFERRAL BASIC ADL")),+$G(CATSUM("GEC REFERRAL SKILLED CARE")),+$G(CATSUM("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")),GSUM)=""
    34         ..K CATSUM
    35         ;
    36 DIS     ;Start of Display
    37         S REF="^TMP(""PXRMGEC"",$J,""S"")"
    38         W !,"=============================================================================="
    39         W !,"GEC Patient-Summary (Score)"
    40         W !,"Data on Complete Referrals Only"
    41         W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
    42         W !
    43         I FOR W !,?33,"Finished",?49,"Basic",?55,"Skilled",?63,"Patient",?73,"TOTAL"
    44         I FOR W !,"Name",?22,"SSN",?33,"Date",?44,"IADL",?49,"ADL",?55,"Care",?63,"Behaviors",?73,"ACROSS"
    45         I 'FOR W !,"Name^SSN^Referral Date^IADL^Basic ADL^Skilled Care^Behaviors^Totals"
    46         W !,"=============================================================================="
    47         N S1,S2,S3,S4,S5,S1T,S2T,S3T,S4T,S5T
    48         S (S1T,S2T,S3T,S4T,S5T,CNT)=0
    49         S DFN="" F  S DFN=$O(@REF@(DFN)) Q:DFN=""  D
    50         .S SDATE="" F  S SDATE=$O(@REF@(DFN,SDATE)) Q:SDATE=""  D
    51         ..S DATER="" F  S DATER=$O(@REF@(DFN,SDATE,DATER)) Q:DATER=""  D
    52         ...S CNT=CNT+1
    53         ...S S1="" F  S S1=$O(@REF@(DFN,SDATE,DATER,S1)) Q:S1=""  D
    54         ....S S1T=S1T+S1
    55         ....S S2="" F  S S2=$O(@REF@(DFN,SDATE,DATER,S1,S2)) Q:S2=""  D
    56         .....S S2T=S2T+S2
    57         .....S S3="" F  S S3=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3)) Q:S3=""  D
    58         ......S S3T=S3T+S3
    59         ......S S4="" F  S S4=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4)) Q:S4=""  D
    60         .......S S4T=S4T+S4
    61         .......S S5="" F  S S5=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4,S5)) Q:S5=""  D
    62         ........S S5T=S5T+S5
    63         ........I FOR W !,$E($P(DFN," ",1,$L(DFN," ")-1),1,19),?20," ("_$P(DFN," ",$L(DFN," "))_")",?33,$P($$FMTE^XLFDT(DATER,"5ZM"),"@",1),?44,$J(S1,3),?49,$J(S2,3),?55,$J(S3,3),?63,$J(S4,3),?73,$J(S5,3)
    64         ........D PB Q:Y=0
    65         ........I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," ")),"^",$P($$FMTE^XLFDT(DATER,"5ZM"),"@",1),"^",S1,"^",S2,"^",S3,"^",S4,"^",S5
    66         Q:CNT=0
    67         I FOR W !,?44,"_________________________________" D PB Q:Y=0
    68         I FOR W !,?33,"Totals > >",?44,$J(S1T,3),?49,$J(S2T,3),?55,$J(S3T,3),?63,$J(S4T,3),?72,$J(S5T,4) D PB Q:Y=0
    69         I FOR W !,?34,"Means > >",?44,$J($FN(S1T/CNT,"",1),3),?49,$J($FN(S2T/CNT,"",1),3),?55,$J($FN(S3T/CNT,"",1),3),?63,$J($FN(S4T/CNT,"",1),3),?72,$J($FN(S5T/CNT,"",1),4)
    70         D PB Q:Y=0
    71         S (S1T,S2T,S3T,S4T,S5T,SCNT)=0
    72         N S1TDEV,S1TDEVT,S2TDEV,S2TDEVT,S3TDEV,S3TDEVT,S4TDEV,S4TDEVT,S5TDEV,S5TDEVT
    73         S (S1TDEVT,S2TDEVT,S3TDEVT,S4TDEVT,S5TDEVT)=0
    74         S DFN="" F  S DFN=$O(@REF@(DFN)) Q:DFN=""  D
    75         .S SDATE="" F  S SDATE=$O(@REF@(DFN,SDATE)) Q:SDATE=""  D
    76         ..S DATER="" F  S DATER=$O(@REF@(DFN,SDATE,DATER)) Q:DATER=""  D
    77         ...S S1="" F  S S1=$O(@REF@(DFN,SDATE,DATER,S1)) Q:S1=""  D
    78         ....S S1TDEV=(S1-(S1T/CNT))*(S1-(S1T/CNT)) S S1TDEVT=S1TDEVT+S1TDEV
    79         ....S S2="" F  S S2=$O(@REF@(DFN,SDATE,DATER,S1,S2)) Q:S2=""  D
    80         .....S S2TDEV=(S2-(S2T/CNT))*(S2-(S2T/CNT)) S S2TDEVT=S2TDEVT+S2TDEV
    81         .....S S3="" F  S S3=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3)) Q:S3=""  D
    82         ......S S3TDEV=(S3-(S3T/CNT))*(S3-(S3T/CNT)) S S3TDEVT=S3TDEVT+S3TDEV
    83         ......S S4="" F  S S4=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4)) Q:S4=""  D
    84         .......S S4TDEV=(S4-(S4T/CNT))*(S4-(S4T/CNT)) S S4TDEVT=S4TDEVT+S4TDEV
    85         .......S S5="" F  S S5=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4,S5)) Q:S5=""  D
    86         ........S S5TDEV=(S5-(S5T/CNT))*(S5-(S5T/CNT)) S S5TDEVT=S5TDEVT+S5TDEV
    87         I FOR W !,?20,"Standard Deviations > >"
    88         I CNT<2 S CNT=CNT+1
    89         I FOR W ?44,$J($FN($$SQROOT(S1TDEVT/(CNT-1)),"",1),3),?49,$J($FN($$SQROOT(S2TDEVT/(CNT-1)),"",1),3),?55,$J($FN($$SQROOT(S3TDEVT/(CNT-1)),"",1),3),?63,$J($FN($$SQROOT(S4TDEVT/(CNT-1)),"",1),3),?72,$J($FN($$SQROOT(S5TDEVT/(CNT-1)),"",1),4)
    90         D PB Q:Y=0
    91         W ! D PB Q:Y=0
    92         K ^TMP("PXRMGEC",$J)
    93         D KILL^%ZISS
    94         Q
    95         ;
    96 SQROOT(NUM)     ;Calculat Square Root
    97         N PREC,ROOT S ROOT=0 GOTO SQROOTX:NUM=0
    98         S:NUM<0 NUM=-NUM S ROOT=$S(NUM>1:NUM\1,1:1/NUM)
    99         S ROOT=$E(ROOT,1,$L(ROOT)+1\2) S:NUM'>1 ROOT=1/ROOT
    100         F PREC=1:1:6 S ROOT=NUM/ROOT+ROOT*.5
    101 SQROOTX Q ROOT
    102         ;
    103 VALUE(DA)       ;Return value for score
    104         N CAT,SYN,VALUE,PICE
    105         S SYN=$P($G(^AUTTHF(DA,0)),"^",9)
    106         Q:$E(SYN,5,5)'="F" VALUE
    107         Q:SYN="" VALUE
    108         Q:$E(SYN,5,5)="C" VALUE
    109         S VALUE=$P(SYN," ",$L(SYN," "))
    110         Q VALUE
    111         ;
    112         ;
    113 PB      ;PAGE BREAK
    114         S Y=""
    115         I $Y=(IOSL-2) D
    116         .K DIR
    117         .S DIR(0)="E"
    118         .D ^DIR
    119         .I Y=1 W @IOF S $Y=0
    120         K DIR
    121         Q
    122         ;
     1PXRMGECN ;SLC/JVS GEC-Score Reports-cont'd ;6/19/03  20:58
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 Q
     4SUM ;By Summary by Patient
     5 N CAT,HF,DATE,DFN,Y,HFN,CNTREF,X,REFNUM,SUM,GSUM,CATDANA
     6 N DATER,SDATE
     7 D E^PXRMGECV("HS1",1,BDT,EDT,"F",DFNONLY)
     8 I FORMAT="D" S FOR=0
     9 I FORMAT="F" S FOR=1
     10 W @IOF
     11 S CATDANA("GEC REFERRAL BASIC ADL")=""
     12 S CATDANA("GEC REFERRAL IADL")=""
     13 S CATDANA("GEC REFERRAL SKILLED CARE")=""
     14 S CATDANA("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")=""
     15 ;
     16 S Y=1,SUM=0,DATER=0,GSUM=0
     17 S DFN="" F  S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN=""!(Y=0)  D
     18 .S CNTREF="",REFNUM=0 F  S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF=""!(Y=0)  D
     19 ..S REFNUM=REFNUM+1
     20 ..S SDATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,0)) D
     21 ...S DATER=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,SDATE,0))
     22 ..S DATE=0 F  S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE=""!(Y=0)  D
     23 ...S VDT=0 F  S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT=""!(Y=0)  D
     24 ....S CAT=0 F  S CAT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT)) Q:CAT=""!(Y=0)  D
     25 .....Q:'$D(CATDANA(CAT))
     26 .....S SUM=0
     27 .....S DATEV=0 F  S DATEV=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV)) Q:DATEV=""!(Y=0)  D
     28 ......S DA=0 F  S DA=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV,DA)) Q:DA=""!(Y=0)  D
     29 .......S HFN=$$HFNAME^PXRMGECR(DA)
     30 .......S SUM=SUM+$$VALUE($P($G(^AUPNVHF(DA,0)),"^",1))
     31 .......S CATSUM(CAT)=SUM
     32 ..S GSUM=+$G(CATSUM("GEC REFERRAL IADL"))+(+$G(CATSUM("GEC REFERRAL BASIC ADL")))+(+$G(CATSUM("GEC REFERRAL SKILLED CARE")))+(+$G(CATSUM("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")))
     33 ..S ^TMP("PXRMGEC",$J,"S",DFN,SDATE,DATER,+$G(CATSUM("GEC REFERRAL IADL")),+$G(CATSUM("GEC REFERRAL BASIC ADL")),+$G(CATSUM("GEC REFERRAL SKILLED CARE")),+$G(CATSUM("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")),GSUM)=""
     34 ..K CATSUM
     35 ;
     36DIS ;Start of Display
     37 S REF="^TMP(""PXRMGEC"",$J,""S"")"
     38 W !,"=============================================================================="
     39 W !,"GEC Patient-Summary (Score)"
     40 W !,"Data on Complete Referrals Only"
     41 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
     42 W !
     43 I FOR W !,?33,"Finished",?49,"Basic",?55,"Skilled",?63,"Patient",?73,"TOTAL"
     44 I FOR W !,"Name",?22,"SSN",?33,"Date",?44,"IADL",?49,"ADL",?55,"Care",?63,"Behaviors",?73,"ACROSS"
     45 I 'FOR W !,"Name^SSN^Referral Date^IADL^Basic ADL^Skilled Care^Behaviors^Totals"
     46 W !,"=============================================================================="
     47 N S1,S2,S3,S4,S5,S1T,S2T,S3T,S4T,S5T
     48 S (S1T,S2T,S3T,S4T,S5T,CNT)=0
     49 S DFN="" F  S DFN=$O(@REF@(DFN)) Q:DFN=""  D
     50 .S SDATE="" F  S SDATE=$O(@REF@(DFN,SDATE)) Q:SDATE=""  D
     51 ..S DATER="" F  S DATER=$O(@REF@(DFN,SDATE,DATER)) Q:DATER=""  D
     52 ...S CNT=CNT+1
     53 ...S S1="" F  S S1=$O(@REF@(DFN,SDATE,DATER,S1)) Q:S1=""  D
     54 ....S S1T=S1T+S1
     55 ....S S2="" F  S S2=$O(@REF@(DFN,SDATE,DATER,S1,S2)) Q:S2=""  D
     56 .....S S2T=S2T+S2
     57 .....S S3="" F  S S3=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3)) Q:S3=""  D
     58 ......S S3T=S3T+S3
     59 ......S S4="" F  S S4=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4)) Q:S4=""  D
     60 .......S S4T=S4T+S4
     61 .......S S5="" F  S S5=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4,S5)) Q:S5=""  D
     62 ........S S5T=S5T+S5
     63 ........I FOR W !,$E($P(DFN," ",1,$L(DFN," ")-1),1,19),?20," ("_$P(DFN," ",$L(DFN," "))_")",?33,$P($$FMTE^XLFDT(DATER,"5ZM"),"@",1),?44,$J(S1,3),?49,$J(S2,3),?55,$J(S3,3),?63,$J(S4,3),?73,$J(S5,3)
     64 ........D PB Q:Y=0
     65 ........I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," ")),"^",$P($$FMTE^XLFDT(DATER,"5ZM"),"@",1),"^",S1,"^",S2,"^",S3,"^",S4,"^",S5
     66 Q:CNT=0
     67 I FOR W !,?44,"_________________________________" D PB Q:Y=0
     68 I FOR W !,?33,"Totals > >",?44,$J(S1T,3),?49,$J(S2T,3),?55,$J(S3T,3),?63,$J(S4T,3),?72,$J(S5T,4) D PB Q:Y=0
     69 I FOR W !,?34,"Means > >",?44,$J($FN(S1T/CNT,"",1),3),?49,$J($FN(S2T/CNT,"",1),3),?55,$J($FN(S3T/CNT,"",1),3),?63,$J($FN(S4T/CNT,"",1),3),?72,$J($FN(S5T/CNT,"",1),4)
     70 D PB Q:Y=0
     71 S (S1T,S2T,S3T,S4T,S5T,SCNT)=0
     72 N S1TDEV,S1TDEVT,S2TDEV,S2TDEVT,S3TDEV,S3TDEVT,S4TDEV,S4TDEVT,S5TDEV,S5TDEVT
     73 S (S1TDEVT,S2TDEVT,S3TDEVT,S4TDEVT,S5TDEVT)=0
     74 S DFN="" F  S DFN=$O(@REF@(DFN)) Q:DFN=""  D
     75 .S SDATE="" F  S SDATE=$O(@REF@(DFN,SDATE)) Q:SDATE=""  D
     76 ..S DATER="" F  S DATER=$O(@REF@(DFN,SDATE,DATER)) Q:DATER=""  D
     77 ...S S1="" F  S S1=$O(@REF@(DFN,SDATE,DATER,S1)) Q:S1=""  D
     78 ....S S1TDEV=(S1-(S1T/CNT))*(S1-(S1T/CNT)) S S1TDEVT=S1TDEVT+S1TDEV
     79 ....S S2="" F  S S2=$O(@REF@(DFN,SDATE,DATER,S1,S2)) Q:S2=""  D
     80 .....S S2TDEV=(S2-(S2T/CNT))*(S2-(S2T/CNT)) S S2TDEVT=S2TDEVT+S2TDEV
     81 .....S S3="" F  S S3=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3)) Q:S3=""  D
     82 ......S S3TDEV=(S3-(S3T/CNT))*(S3-(S3T/CNT)) S S3TDEVT=S3TDEVT+S3TDEV
     83 ......S S4="" F  S S4=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4)) Q:S4=""  D
     84 .......S S4TDEV=(S4-(S4T/CNT))*(S4-(S4T/CNT)) S S4TDEVT=S4TDEVT+S4TDEV
     85 .......S S5="" F  S S5=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4,S5)) Q:S5=""  D
     86 ........S S5TDEV=(S5-(S5T/CNT))*(S5-(S5T/CNT)) S S5TDEVT=S5TDEVT+S5TDEV
     87 I FOR W !,?20,"Standard Deviations > >"
     88 I CNT<2 S CNT=CNT+1
     89 I FOR W ?44,$J($FN($$SQROOT(S1TDEVT/(CNT-1)),"",1),3),?49,$J($FN($$SQROOT(S2TDEVT/(CNT-1)),"",1),3),?55,$J($FN($$SQROOT(S3TDEVT/(CNT-1)),"",1),3),?63,$J($FN($$SQROOT(S4TDEVT/(CNT-1)),"",1),3),?72,$J($FN($$SQROOT(S5TDEVT/(CNT-1)),"",1),4)
     90 D PB Q:Y=0
     91 W ! D PB Q:Y=0
     92 K ^TMP("PXRMGEC",$J)
     93 D KILL^%ZISS
     94 Q
     95 ;
     96SQROOT(NUM) ;Calculat Square Root
     97 N PREC,ROOT S ROOT=0 GOTO SQROOTX:NUM=0
     98 S:NUM<0 NUM=-NUM S ROOT=$S(NUM>1:NUM\1,1:1/NUM)
     99 S ROOT=$E(ROOT,1,$L(ROOT)+1\2) S:NUM'>1 ROOT=1/ROOT
     100 F PREC=1:1:6 S ROOT=NUM/ROOT+ROOT*.5
     101SQROOTX Q ROOT
     102 ;
     103VALUE(DA) ;Return value for score
     104 N CAT,SYN,VALUE,PICE
     105 S SYN=$P($G(^AUTTHF(DA,0)),"^",9)
     106 Q:$E(SYN,5,5)'="F" VALUE
     107 Q:SYN="" VALUE
     108 Q:$E(SYN,5,5)="C" VALUE
     109 S VALUE=$P(SYN," ",$L(SYN," "))
     110 Q VALUE
     111 ;
     112 ;
     113PB ;PAGE BREAK
     114 S Y=""
     115 I $Y=(IOSL-2) D
     116 .K DIR
     117 .S DIR(0)="E"
     118 .D ^DIR
     119 .I Y=1 W @IOF S $Y=0
     120 K DIR
     121 Q
     122 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMHF.m

    r613 r623  
    1 PXRMHF  ; SLC/PKR - Handle Health Factor findings. ;06/01/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=====================================================
    5 CATSORT(FIEVAL,FIND0,FARR)      ;Sort all the true health factor findings
    6         ;according to the category criteria. FIND0 will be defined only
    7         ;for terms.
    8         N CAT,CATLIST,DATE,IND,FI,HFIEN,LDATE,NTRUE,WCR
    9         S HFIEN=""
    10         F  S HFIEN=$O(FARR("E","AUTTHF(",HFIEN)) Q:HFIEN=""  D
    11         . S FI=0
    12         . F  S FI=$O(FARR("E","AUTTHF(",HFIEN,FI)) Q:FI=""  D
    13         .. I 'FIEVAL(FI) Q
    14         ..;Get the Within Category Rank
    15         .. S WCR=$P(FARR(20,FI,0),U,10)
    16         .. I WCR="" S WCR=$P(FIND0,U,10)
    17         .. I WCR="" S WCR=9999
    18         ..;If Within Category Rank is 0 ignore the category and treat it like
    19         ..;regular finding (exclude it from the list).
    20         .. I WCR>0 D
    21         ... S CAT=$P(^AUTTHF(HFIEN,0),U,3)
    22         ...;If the category is null then send a warning.
    23         ... I CAT="" D WARN(^AUTTHF(HFIEN,0))  Q
    24         ... S CATLIST(CAT,FIEVAL(FI,"DATE"),WCR,FI)=""
    25         ... I $G(PXRMDEBG) S FIEVAL(FI,"CAT^WCR")=CAT_U_WCR
    26         ;No health factors to categorize then quit.
    27         I '$D(CATLIST) Q
    28         ;Only the most recent HF in a category can be true.
    29         S CAT=""
    30         F  S CAT=$O(CATLIST(CAT)) Q:CAT=""  D
    31         . S LDATE=$O(CATLIST(CAT,""),-1)
    32         .;For each category set all but the most recent HF false.
    33         . S DATE=""
    34         . F  S DATE=$O(CATLIST(CAT,DATE)) Q:DATE=LDATE  D
    35         .. S WCR=""
    36         .. F  S WCR=$O(CATLIST(CAT,DATE,WCR)) Q:WCR=""  D
    37         ... S FI=""
    38         ... F  S FI=$O(CATLIST(CAT,DATE,WCR,FI)) Q:FI=""  D
    39         .... S FIEVAL(FI)=0
    40         ....;If there are multiple occurrences set them all false.
    41         .... S IND=0
    42         .... F  S IND=+$O(FIEVAL(FI,IND)) Q:IND=0  S FIEVAL(FI,IND)=0
    43         .;
    44         .;If there is more than on HF on the most recent date then only the
    45         .;one with the highest WCR can be true. The highest possible WCR is 1.
    46         .;Set all with lower WCRs false.
    47         .;If the most recent health factor has multiple occurrences only
    48         .;the first occurrence can be true.
    49         . S (NTRUE,WCR)=0
    50         . F  S WCR=$O(CATLIST(CAT,LDATE,WCR)) Q:WCR=""  D
    51         .. S FI=""
    52         .. F  S FI=$O(CATLIST(CAT,LDATE,WCR,FI)) Q:FI=""  D
    53         ... I NTRUE=0 D  Q
    54         ....;If there are multiple sub-occurrences set them all false.
    55         .... S (IND,NTRUE)=1
    56         .... F  S IND=+$O(FIEVAL(FI,IND)) Q:IND=0  S FIEVAL(FI,IND)=0
    57         ... S FIEVAL(FI)=0
    58         ...;If there are multiple sub-occurrences set them all false.
    59         ... S IND=0
    60         ... F  S IND=+$O(FIEVAL(FI,IND)) Q:IND=0  S FIEVAL(FI,IND)=0
    61         Q
    62         ;
    63         ;=====================================================
    64 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate health factor findings.
    65         N FIEVT,FILENUM,FINDPA,FINDING,HFIEN,NOINDEX
    66         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    67         I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D
    68         . D NOINDEX^PXRMERRH("D",PXRMITEM,FILENUM)
    69         . S NOINDEX=1
    70         E  S NOINDEX=0
    71         S HFIEN=""
    72         F  S HFIEN=$O(DEFARR("E",ENODE,HFIEN)) Q:+HFIEN=0  D
    73         . S FINDING=""
    74         . F  S FINDING=$O(DEFARR("E",ENODE,HFIEN,FINDING)) Q:+FINDING=0  D
    75         .. I NOINDEX S FIEVAL(FINDING)=0 Q
    76         .. K FINDPA
    77         .. M FINDPA=DEFARR(20,FINDING)
    78         .. K FIEVT
    79         .. D FIEVAL^PXRMINDX(FILENUM,"PI",DFN,HFIEN,.FINDPA,.FIEVT)
    80         .. M FIEVAL(FINDING)=FIEVT
    81         .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
    82         ;Sort all the true true findings by category.
    83         D CATSORT(.FIEVAL,"",.DEFARR)
    84         Q
    85         ;
    86         ;=====================================================
    87 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Evaluate health factor term findings
    88         ;for patient lists.
    89         D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
    90         Q
    91         ;
    92         ;=====================================================
    93 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate health factor terms.
    94         N BDT,EDT,FIEVT,HFIEN,NOINDEX,PFINDPA
    95         N TFINDPA,TFINDING
    96         I $G(^PXRMINDX(9000010.23,"DATE BUILT"))="" D
    97         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),9000010.23)
    98         . S NOINDEX=1
    99         E  S NOINDEX=0
    100         S HFIEN=""
    101         F  S HFIEN=$O(TERMARR("E",ENODE,HFIEN)) Q:+HFIEN=0  D
    102         . S TFINDING=""
    103         . F  S TFINDING=$O(TERMARR("E",ENODE,HFIEN,TFINDING)) Q:+TFINDING=0  D
    104         .. I NOINDEX S TFIEVAL(TFINDING)=0 Q
    105         .. K FIEVT,PFINDPA,TFINDPA
    106         .. M TFINDPA=TERMARR(20,TFINDING)
    107         ..;Set the finding parameters.
    108         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    109         .. D FIEVAL^PXRMINDX(9000010.23,"PI",DFN,HFIEN,.PFINDPA,.FIEVT)
    110         .. M TFIEVAL(TFINDING)=FIEVT
    111         .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
    112         ;Sort all the true true findings by category.
    113         D CATSORT(.TFIEVAL,FINDPA(0),.TERMARR)
    114         Q
    115         ;
    116         ;=====================================================
    117 GETDATA(DAS,FIEVT)      ;Return data for a specified V Health Factor entry.
    118         ;DBIA #4250
    119         D VHF^PXPXRM(DAS,.FIEVT)
    120         Q
    121         ;
    122         ;=====================================================
    123 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    124         N EM,FIEN,IND,JND,LVL,NAME,NOUT,PNAME,TEMP,TEXTOUT,VDATE
    125         S FIEN=$P(IFIEVAL("FINDING"),";",1)
    126         S PNAME=$P(^AUTTHF(FIEN,0),U,1)
    127         S NAME="Health Factor: "_PNAME_" = "
    128         S IND=0
    129         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    130         . S LVL=$G(IFIEVAL(IND,"VALUE"))
    131         . I LVL'="" S LVL=$$EXTERNAL^DILFD(9000010.23,.04,"",LVL,.EM)
    132         . S VDATE=IFIEVAL(IND,"DATE")
    133         . S TEMP=NAME_LVL_" ("_$$EDATE^PXRMDATE(VDATE)_")"
    134         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    135         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    136         S NLINES=NLINES+1,TEXT(NLINES)=""
    137         Q
    138         ;
    139         ;=====================================================
    140 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    141         ;maintenance output.
    142         N EM,FIEN,IND,JND,LVL,NOUT,PNAME,TEMP,TEXTOUT,VDATE
    143         S FIEN=$P(IFIEVAL("FINDING"),";",1)
    144         ;DBIA #3083
    145         S PNAME=$P(^AUTTHF(FIEN,0),U,1)
    146         S NLINES=NLINES+1
    147         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Health Factor: "_PNAME
    148         S IND=0
    149         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    150         . S VDATE=IFIEVAL(IND,"DATE")
    151         . S TEMP=$$EDATE^PXRMDATE(VDATE)
    152         . S LVL=$G(IFIEVAL(IND,"VALUE"))
    153         . I LVL'="" D
    154         .. S TEMP=TEMP_" level/severity - "
    155         .. S TEMP=TEMP_$$EXTERNAL^DILFD(9000010.23,.04,"",LVL,.EM)
    156         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    157         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    158         . I IFIEVAL(IND,"COMMENTS")'="" D
    159         .. S TEMP="Comments: "_IFIEVAL(IND,"COMMENTS")
    160         .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    161         .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    162         S NLINES=NLINES+1,TEXT(NLINES)=""
    163         Q
    164         ;
    165         ;=====================================================
    166 WARN(HF0)       ;Issue a warning if a health factor is missing its category.
    167         N XMSUB
    168         K ^TMP("PXRMXMZ",$J)
    169         S XMSUB="CLINICAL REMINDER DATA PROBLEM, HEALTH FACTOR"
    170         S ^TMP("PXRMXMZ",$J,1,0)="Health Factor "_$P(HF0,U,1)
    171         S ^TMP("PXRMXMZ",$J,2,0)="does not have a category, this is a required field."
    172         S ^TMP("PXRMXMZ",$J,3,0)="This health factor will be ignored for all patients until the problem is fixed."
    173         D SEND^PXRMMSG(XMSUB)
    174         Q
    175         ;
     1PXRMHF ; SLC/PKR - Handle Health Factor findings. ;12/23/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;=====================================================
     5CATSORT(FIEVAL,FIND0,FARR) ;Sort all the true health factor findings
     6 ;according to the category criteria. FIND0 will be defined only
     7 ;for terms.
     8 N CAT,CATLIST,DATE,IND,FI,HFIEN,LDATE,NTRUE,WCR
     9 S HFIEN=""
     10 F  S HFIEN=$O(FARR("E","AUTTHF(",HFIEN)) Q:HFIEN=""  D
     11 . S FI=0
     12 . F  S FI=$O(FARR("E","AUTTHF(",HFIEN,FI)) Q:FI=""  D
     13 .. I 'FIEVAL(FI) Q
     14 ..;Get the Within Category Rank
     15 .. S WCR=$P(FARR(20,FI,0),U,10)
     16 .. I WCR="" S WCR=$P(FIND0,U,10)
     17 .. I WCR="" S WCR=9999
     18 ..;If Within Category Rank is 0 ignore the category and treat it like
     19 ..;regular finding (exclude it from the list).
     20 .. I WCR>0 D
     21 ... S CAT=$P(^AUTTHF(HFIEN,0),U,3)
     22 ...;If the category is null then send a warning.
     23 ... I CAT="" D WARN(^AUTTHF(HFIEN,0))  Q
     24 ... S CATLIST(CAT,FIEVAL(FI,"DATE"),WCR,FI)=""
     25 ... I $G(PXRMDEBG) S FIEVAL(FI,"CAT^WCR")=CAT_U_WCR
     26 ;No health factors to categorize then quit.
     27 I '$D(CATLIST) Q
     28 ;Only the most recent HF in a category can be true.
     29 S CAT=""
     30 F  S CAT=$O(CATLIST(CAT)) Q:CAT=""  D
     31 . S LDATE=$O(CATLIST(CAT,""),-1)
     32 .;For each category set all but the most recent HF false.
     33 . S DATE=""
     34 . F  S DATE=$O(CATLIST(CAT,DATE)) Q:DATE=LDATE  D
     35 .. S WCR=""
     36 .. F  S WCR=$O(CATLIST(CAT,DATE,WCR)) Q:WCR=""  D
     37 ... S FI=""
     38 ... F  S FI=$O(CATLIST(CAT,DATE,WCR,FI)) Q:FI=""  D
     39 .... S FIEVAL(FI)=0
     40 ....;If there are multiple occurrences set them all false.
     41 .... S IND=0
     42 .... F  S IND=+$O(FIEVAL(FI,IND)) Q:IND=0  S FIEVAL(FI,IND)=0
     43 .;
     44 .;If there is more than on HF on the most recent date then only the
     45 .;one with the highest WCR can be true. The highest possible WCR is 1.
     46 .;Set all with lower WCRs false.
     47 .;If the most recent health factor has multiple occurrences only
     48 .;the first occurrence can be true.
     49 . S (NTRUE,WCR)=0
     50 . F  S WCR=$O(CATLIST(CAT,LDATE,WCR)) Q:WCR=""  D
     51 .. S FI=""
     52 .. F  S FI=$O(CATLIST(CAT,LDATE,WCR,FI)) Q:FI=""  D
     53 ... I NTRUE=0 D  Q
     54 ....;If there are multiple sub-occurrences set them all false.
     55 .... S (IND,NTRUE)=1
     56 .... F  S IND=+$O(FIEVAL(FI,IND)) Q:IND=0  S FIEVAL(FI,IND)=0
     57 ... S FIEVAL(FI)=0
     58 ...;If there are multiple sub-occurrences set them all false.
     59 ... S IND=0
     60 ... F  S IND=+$O(FIEVAL(FI,IND)) Q:IND=0  S FIEVAL(FI,IND)=0
     61 Q
     62 ;
     63 ;=====================================================
     64EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate health factor findings.
     65 N FIEVT,FILENUM,FINDPA,FINDING,HFIEN,NOINDEX
     66 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     67 I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D
     68 . D NOINDEX^PXRMERRH("D",PXRMITEM,FILENUM)
     69 . S NOINDEX=1
     70 E  S NOINDEX=0
     71 S HFIEN=""
     72 F  S HFIEN=$O(DEFARR("E",ENODE,HFIEN)) Q:+HFIEN=0  D
     73 . S FINDING=""
     74 . F  S FINDING=$O(DEFARR("E",ENODE,HFIEN,FINDING)) Q:+FINDING=0  D
     75 .. I NOINDEX S FIEVAL(FINDING)=0 Q
     76 .. K FINDPA
     77 .. M FINDPA=DEFARR(20,FINDING)
     78 .. K FIEVT
     79 .. D FIEVAL^PXRMINDX(FILENUM,"PI",DFN,HFIEN,.FINDPA,.FIEVT)
     80 .. M FIEVAL(FINDING)=FIEVT
     81 .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
     82 ;Sort all the true true findings by category.
     83 D CATSORT(.FIEVAL,"",.DEFARR)
     84 Q
     85 ;
     86 ;=====================================================
     87EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate health factor term findings
     88 ;for patient lists.
     89 D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
     90 Q
     91 ;
     92 ;=====================================================
     93EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate health factor terms.
     94 N BDT,EDT,FIEVT,HFIEN,NOINDEX,PFINDPA
     95 N TFINDPA,TFINDING
     96 I $G(^PXRMINDX(9000010.23,"DATE BUILT"))="" D
     97 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),9000010.23)
     98 . S NOINDEX=1
     99 E  S NOINDEX=0
     100 S HFIEN=""
     101 F  S HFIEN=$O(TERMARR("E",ENODE,HFIEN)) Q:+HFIEN=0  D
     102 . S TFINDING=""
     103 . F  S TFINDING=$O(TERMARR("E",ENODE,HFIEN,TFINDING)) Q:+TFINDING=0  D
     104 .. I NOINDEX S TFIEVAL(TFINDING)=0 Q
     105 .. K FIEVT,PFINDPA,TFINDPA
     106 .. M TFINDPA=TERMARR(20,TFINDING)
     107 ..;Set the finding parameters.
     108 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     109 .. D FIEVAL^PXRMINDX(9000010.23,"PI",DFN,HFIEN,.PFINDPA,.FIEVT)
     110 .. M TFIEVAL(TFINDING)=FIEVT
     111 .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
     112 ;Sort all the true true findings by category.
     113 D CATSORT(.TFIEVAL,FINDPA(0),.TERMARR)
     114 Q
     115 ;
     116 ;=====================================================
     117GETDATA(DAS,FIEVT) ;Return data for a specified V Health Factor entry.
     118 ;DBIA #4250
     119 D VHF^PXPXRM(DAS,.FIEVT)
     120 Q
     121 ;
     122 ;=====================================================
     123MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     124 N EM,FIEN,IND,JND,LVL,NAME,NOUT,PNAME,TEMP,TEXTOUT,VDATE
     125 S FIEN=$P(IFIEVAL("FINDING"),";",1)
     126 S PNAME=$P(^AUTTHF(FIEN,0),U,1)
     127 S NAME="Health Factor: "_PNAME_" = "
     128 S IND=0
     129 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     130 . S LVL=$G(IFIEVAL(IND,"VALUE"))
     131 . I LVL'="" S LVL=$$EXTERNAL^DILFD(9000010.23,.04,"",LVL,.EM)
     132 . S VDATE=IFIEVAL(IND,"DATE")
     133 . S TEMP=NAME_LVL_" ("_$$EDATE^PXRMDATE(VDATE)_")"
     134 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     135 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     136 S NLINES=NLINES+1,TEXT(NLINES)=""
     137 Q
     138 ;
     139 ;=====================================================
     140OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     141 ;maintenance output.
     142 N EM,FIEN,IND,JND,LVL,NOUT,PNAME,TEMP,TEXTOUT,VDATE
     143 S FIEN=$P(IFIEVAL("FINDING"),";",1)
     144 S PNAME=$P(^AUTTHF(FIEN,0),U,1)
     145 S NLINES=NLINES+1
     146 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Health Factor: "_PNAME
     147 S IND=0
     148 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     149 . S VDATE=IFIEVAL(IND,"DATE")
     150 . S TEMP=$$EDATE^PXRMDATE(VDATE)
     151 . S LVL=$G(IFIEVAL(IND,"VALUE"))
     152 . I LVL'="" D
     153 .. S TEMP=TEMP_" level/severity - "
     154 .. S TEMP=TEMP_$$EXTERNAL^DILFD(9000010.23,.04,"",LVL,.EM)
     155 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     156 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     157 . I IFIEVAL(IND,"COMMENTS")'="" D
     158 .. S TEMP="Comments: "_IFIEVAL(IND,"COMMENTS")
     159 .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     160 .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     161 S NLINES=NLINES+1,TEXT(NLINES)=""
     162 Q
     163 ;
     164 ;=====================================================
     165WARN(HF0) ;Issue a warning if a health factor is missing its category.
     166 N XMSUB
     167 K ^TMP("PXRMXMZ",$J)
     168 S XMSUB="CLINICAL REMINDER DATA PROBLEM, HEALTH FACTOR"
     169 S ^TMP("PXRMXMZ",$J,1,0)="Health Factor "_$P(HF0,U,1)
     170 S ^TMP("PXRMXMZ",$J,2,0)="does not have a category, this is a required field."
     171 S ^TMP("PXRMXMZ",$J,3,0)="This health factor will be ignored for all patients until the problem is fixed."
     172 D SEND^PXRMMSG(XMSUB)
     173 Q
     174 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMINDC.m

    r613 r623  
    1 PXRMINDC        ; SLC/PKR - Index counting routines. ;03/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;========================================================
    5 CNT5(FILENUM,COUNT)     ;Get date counts for indexes where the date
    6         ;is at subscript 5. Works for file numbers:
    7         ;63, 70, 120.5, 601.2, 601.84,
    8         ;9000010.11, 9000010.12, 9000010.13, 9000010.16, 9000010.23
    9         N DAS,DATE,DFN,IND,ITEM,YEAR
    10         I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
    11         S IND=0
    12         S DFN=""
    13         F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
    14         . S IND=IND+1
    15         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    16         . S ITEM=""
    17         . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
    18         .. S DATE=""
    19         .. F  S DATE=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE)) Q:DATE=""  D
    20         ... S YEAR=$E(DATE,1,3)
    21         ... S DAS=""
    22         ... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE,DAS)) Q:DAS=""  D
    23         .... S COUNT(YEAR)=$G(COUNT(YEAR))+1
    24         Q
    25         ;
    26         ;========================================================
    27 CNT6(FILENUM,COUNT)     ;Get date counts for indexes where the date
    28         ;is at subscript 6. Works for file numbers:
    29         ;9000010.07, 9000010.18
    30         N DAS,DATE,DFN,IND,ITEM,TYPE,YEAR
    31         I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
    32         S IND=0
    33         S DFN=""
    34         F  S DFN=$O(^PXRMINDX(FILENUM,"PPI",DFN)) Q:DFN=""  D
    35         . S IND=IND+1
    36         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    37         . S TYPE=""
    38         . F  S TYPE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE)) Q:TYPE=""  D
    39         .. S ITEM=""
    40         .. F  S ITEM=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM)) Q:ITEM=""  D
    41         ... S DATE=""
    42         ... F  S DATE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE)) Q:DATE=""  D
    43         .... S YEAR=$E(DATE,1,3)
    44         .... S DAS=""
    45         .... F  S DAS=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE,DAS)) Q:DAS=""  D
    46         ..... S COUNT(YEAR)=$G(COUNT(YEAR))+1
    47         Q
    48         ;
    49         ;========================================================
    50 CNTPL(FILENUM,COUNT)    ;Get date counts for Problem List indexes where the
    51         ;date is at subscript 7. Works for file numbers:
    52         ;9000011
    53         N DAS,DATE,DFN,IND,ITEM,PRIORITY,STATUS,TYPE,YEAR
    54         I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
    55         S IND=0
    56         S DFN=""
    57         F  S DFN=$O(^PXRMINDX(FILENUM,"PSPI",DFN)) Q:DFN=""  D
    58         . S IND=IND+1
    59         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    60         . S STATUS=""
    61         . F  S STATUS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS)) Q:STATUS=""  D
    62         .. S PRIORITY=""
    63         .. F  S PRIORITY=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY)) Q:PRIORITY=""  D
    64         ... S ITEM=""
    65         ... F  S ITEM=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM)) Q:ITEM=""  D
    66         .... S DATE=""
    67         .... F  S DATE=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE)) Q:DATE=""  D
    68         ..... S YEAR=$E(DATE,1,3)
    69         ..... S DAS=""
    70         ..... F  S DAS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE,DAS)) Q:DAS=""  D
    71         ...... S COUNT(YEAR)=$G(COUNT(YEAR))+1
    72         Q
    73         ;
    74         ;========================================================
    75 CNTPTF(FILENUM,COUNT)   ;Get date counts for PTF indexes where the
    76         ;date is at subscript 7. Works for file numbers:
    77         ;45
    78         N DAS,DATE,DFN,IND,ITEM,NODE,TYPE,YEAR
    79         I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
    80         S IND=0
    81         F TYPE="ICD0","ICD9" D
    82         . S DFN=""
    83         . F  S DFN=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN)) Q:DFN=""  D
    84         .. S IND=IND+1
    85         .. I '$D(ZTQUEUED),(IND#10000=0) W "."
    86         .. S NODE=""
    87         .. F  S NODE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE)) Q:NODE=""  D
    88         ... S ITEM=""
    89         ... F  S ITEM=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM)) Q:ITEM=""  D
    90         .... S DATE=""
    91         .... F  S DATE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE)) Q:DATE=""  D
    92         ..... S YEAR=$E(DATE,1,3)
    93         ..... S DAS=""
    94         ..... F  S DAS=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE,DAS)) Q:DAS=""  D
    95         ...... S COUNT(YEAR)=$G(COUNT(YEAR))+1
    96         Q
    97         ;
    98         ;========================================================
    99 CNTSS(FILENUM,COUNT)    ;Get date counts for indexes where the start date
    100         ;is at subscript 5 and the stop date is at subscript 6.
    101         ;Works for file numbers: 52, 55, 100
    102         N DAS,DFN,IND,ITEM,START,STOP,YEAR
    103         I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
    104         S IND=0
    105         S DFN=""
    106         F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
    107         . S IND=IND+1
    108         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    109         . S ITEM=""
    110         . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
    111         .. S START=""
    112         .. F  S START=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START)) Q:START=""  D
    113         ... S YEAR=$E(START,1,3)
    114         ... S STOP=""
    115         ... F  S STOP=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP)) Q:STOP=""  D
    116         .... S DAS=""
    117         .... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP,DAS)) Q:DAS=""  D
    118         ..... S COUNT(YEAR)=$G(COUNT(YEAR))+1
    119         Q
    120         ;
    121         ;========================================================
    122 COUNT   ;Driver for making index counts.
    123         N GBL,LIST,TASKIT
    124         W !,"Which indexes do you want to count?"
    125         D SEL^PXRMSXRM(.LIST,.GBL)
    126         I LIST="" Q
    127         ;See if this should be tasked.
    128         S TASKIT=$$ASKTASK^PXRMSXRM
    129         I TASKIT D
    130         . W !,"Queue the Clinical Reminders Index count."
    131         . D TASKIT(LIST,.GBL,.ROUTINE)
    132         E  D RUNNOW(LIST,.GBL)
    133         Q
    134         ;
    135         ;========================================================
    136 MESSAGE(FILENUM,COUNT,TOTAL,START,END)  ;Build the MailMan message giving the
    137         ;count breakdown.
    138         N COFF,ML,NAME,NL,PERC,TEXT,YEAR,XMSUB
    139         K ^TMP("PXRMXMZ",$J)
    140         S ML=$$MAX^XLFMTH($L(TOTAL)+2,8)
    141         S COFF=ML-5
    142         S NAME=$$GET1^DID(FILENUM,"","","NAME")
    143         S XMSUB="Yearly data distribution for global "_NAME
    144         S ^TMP("PXRMXMZ",$J,1,0)="File name: "_NAME
    145         S ^TMP("PXRMXMZ",$J,2,0)="Count finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    146         S ^TMP("PXRMXMZ",$J,3,0)=$$ETIME^PXRMSXRM(START,END)
    147         S ^TMP("PXRMXMZ",$J,4,0)=" "
    148         S ^TMP("PXRMXMZ",$J,5,0)="Year"_$$INSCHR^PXRMEXLC(COFF," ")_"Count"_$J("%",8)
    149         S ^TMP("PXRMXMZ",$J,6,0)="----"_$$INSCHR^PXRMEXLC(COFF," ")_"-----"_$J("-----",10)
    150         S NL=6,YEAR=0
    151         F  S YEAR=$O(COUNT(YEAR)) Q:YEAR=""  D
    152         . S PERC=100*COUNT(YEAR)/TOTAL
    153         . S TEXT=YEAR_$J(COUNT(YEAR),ML,0)_$J(PERC,10,2)
    154         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
    155         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "
    156         S TEXT="Total entries: "_TOTAL
    157         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
    158         I TOTAL=0 D
    159         . I '$D(^PXRMINDX(FILENUM)) S TEXT="The index for file "_NAME_" does not exist!"
    160         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
    161         I TOTAL>0,'$D(^PXRMINDX(FILENUM,"DATE BUILT")) D
    162         . S TEXT="Warning, the index for file "_NAME_" may be incomplete or corrupted!"
    163         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
    164         D SEND^PXRMMSG(XMSUB)
    165         K ^TMP("PXRMXMZ",$J)
    166         Q
    167         ;
    168         ;===============================================================
    169 RUNNOW(LIST,GBL)        ;Run the routines now.
    170         N COUNT,END,FN,IND,LI,NUM,ROUTINE,RTN,START,TOTAL
    171         S ROUTINE(45)="CNTPTF^PXRMINDC"
    172         S ROUTINE(52)="CNTSS^PXRMINDC"
    173         S ROUTINE(55)="CNTSS^PXRMINDC"
    174         S ROUTINE(63)="CNT5^PXRMINDC"
    175         S ROUTINE(70)="CNT5^PXRMINDC"
    176         S ROUTINE(100)="CNTSS^PXRMINDC"
    177         S ROUTINE(120.5)="CNT5^PXRMINDC"
    178         S ROUTINE(601.2)="CNT5^PXRMINDC"
    179         S ROUTINE(601.84)="CNT5^PXRMINDC"
    180         S ROUTINE(9000011)="CNTPL^PXRMINDC"
    181         S ROUTINE(9000010.07)="CNT6^PXRMINDC"
    182         S ROUTINE(9000010.11)="CNT5^PXRMINDC"
    183         S ROUTINE(9000010.12)="CNT5^PXRMINDC"
    184         S ROUTINE(9000010.13)="CNT5^PXRMINDC"
    185         S ROUTINE(9000010.16)="CNT5^PXRMINDC"
    186         S ROUTINE(9000010.18)="CNT6^PXRMINDC"
    187         S ROUTINE(9000010.23)="CNT5^PXRMINDC"
    188         S NUM=$L(LIST,",")-1
    189         F IND=1:1:NUM D
    190         . S LI=$P(LIST,",",IND)
    191         . S FN=GBL(LI)
    192         . S RTN=ROUTINE(FN)
    193         . S RTN=RTN_"("_FN_",.COUNT)"
    194         . S START=$H
    195         . K COUNT
    196         . I $D(^PXRMINDX(FN)) D @RTN
    197         . S END=$H
    198         . D TOTAL(.COUNT,.TOTAL)
    199         . D MESSAGE(FN,.COUNT,TOTAL,START,END)
    200         Q
    201         ;
    202         ;===============================================================
    203 TASKIT(LIST,GBL,ROUTINE)        ;Count the indexes as a tasked job.
    204         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
    205         S MINDT=$$NOW^XLFDT
    206         S DIR("A",1)="Enter the date and time you want the job to start."
    207         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    208         S DIR("A")="Start the task at: "
    209         S DIR(0)="DAU"_U_MINDT_"::RSX"
    210         D ^DIR
    211         I $D(DIROUT)!$D(DIRUT) Q
    212         I $D(DTOUT)!$D(DUOUT) Q
    213         S SDTIME=Y
    214         K DIR
    215         ;Put the task into the queue.
    216         K ZTSAVE
    217         S ZTSAVE("LIST")=""
    218         S ZTSAVE("GBL(")=""
    219         S ZTRTN="TASKJOB^PXRMINDC"
    220         S ZTDESC="Clinical Reminders Index count"
    221         S ZTDTH=SDTIME
    222         S ZTIO=""
    223         D ^%ZTLOAD
    224         W !,"Task number ",ZTSK," queued."
    225         Q
    226         ;
    227         ;===============================================================
    228 TASKJOB ;Execute as tasked job. LIST and GBL come through ZTSAVE.
    229         N IND,LI,NUM
    230         S ZTREQ="@"
    231         S ZTSTOP=0
    232         S NUM=$L(LIST,",")-1
    233         F IND=1:1:NUM D
    234         .;Check to see if the task has had a stop request
    235         . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
    236         . S LI=$P(LIST,",",IND)_","
    237         . D RUNNOW^PXRMINDC(LI,.GBL)
    238         Q
    239         ;
    240         ;========================================================
    241 TOTAL(COUNT,TOTAL)      ;Convert the FileMan years in COUNT to regular
    242         ;years get the total number of entries in count.
    243         N TC,YEAR
    244         S (TOTAL,YEAR)=0
    245         F  S YEAR=$O(COUNT(YEAR)) Q:YEAR=""  D
    246         . S TOTAL=TOTAL+COUNT(YEAR)
    247         . S TC(YEAR+1700)=COUNT(YEAR)
    248         K COUNT
    249         M COUNT=TC
    250         Q
    251         ;
     1PXRMINDC ; SLC/PKR - Index counting routines. ;04/20/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;========================================================
     5CNT5(FILENUM,COUNT) ;Get date counts for indexes where the date
     6 ;is at subscript 5. Works for file numbers:
     7 ;63, 70, 120.5, 601.2,
     8 ;9000010.11, 9000010.12, 9000010.13, 9000010.16, 9000010.23
     9 N DAS,DATE,DFN,IND,ITEM,YEAR
     10 I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
     11 S IND=0
     12 S DFN=""
     13 F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
     14 . S IND=IND+1
     15 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     16 . S ITEM=""
     17 . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
     18 .. S DATE=""
     19 .. F  S DATE=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE)) Q:DATE=""  D
     20 ... S YEAR=$E(DATE,1,3)
     21 ... S DAS=""
     22 ... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE,DAS)) Q:DAS=""  D
     23 .... S COUNT(YEAR)=$G(COUNT(YEAR))+1
     24 Q
     25 ;
     26 ;========================================================
     27CNT6(FILENUM,COUNT) ;Get date counts for indexes where the date
     28 ;is at subscript 6. Works for file numbers:
     29 ;9000010.07, 9000010.18
     30 N DAS,DATE,DFN,IND,ITEM,TYPE,YEAR
     31 I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
     32 S IND=0
     33 S DFN=""
     34 F  S DFN=$O(^PXRMINDX(FILENUM,"PPI",DFN)) Q:DFN=""  D
     35 . S IND=IND+1
     36 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     37 . S TYPE=""
     38 . F  S TYPE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE)) Q:TYPE=""  D
     39 .. S ITEM=""
     40 .. F  S ITEM=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM)) Q:ITEM=""  D
     41 ... S DATE=""
     42 ... F  S DATE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE)) Q:DATE=""  D
     43 .... S YEAR=$E(DATE,1,3)
     44 .... S DAS=""
     45 .... F  S DAS=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE,DAS)) Q:DAS=""  D
     46 ..... S COUNT(YEAR)=$G(COUNT(YEAR))+1
     47 Q
     48 ;
     49 ;========================================================
     50CNTPL(FILENUM,COUNT) ;Get date counts for Problem List indexes where the
     51 ;date is at subscript 7. Works for file numbers:
     52 ;9000011
     53 N DAS,DATE,DFN,IND,ITEM,PRIORITY,STATUS,TYPE,YEAR
     54 I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
     55 S IND=0
     56 S DFN=""
     57 F  S DFN=$O(^PXRMINDX(FILENUM,"PSPI",DFN)) Q:DFN=""  D
     58 . S IND=IND+1
     59 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     60 . S STATUS=""
     61 . F  S STATUS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS)) Q:STATUS=""  D
     62 .. S PRIORITY=""
     63 .. F  S PRIORITY=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY)) Q:PRIORITY=""  D
     64 ... S ITEM=""
     65 ... F  S ITEM=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM)) Q:ITEM=""  D
     66 .... S DATE=""
     67 .... F  S DATE=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE)) Q:DATE=""  D
     68 ..... S YEAR=$E(DATE,1,3)
     69 ..... S DAS=""
     70 ..... F  S DAS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE,DAS)) Q:DAS=""  D
     71 ...... S COUNT(YEAR)=$G(COUNT(YEAR))+1
     72 Q
     73 ;
     74 ;========================================================
     75CNTPTF(FILENUM,COUNT) ;Get date counts for PTF indexes where the
     76 ;date is at subscript 7. Works for file numbers:
     77 ;45
     78 N DAS,DATE,DFN,IND,ITEM,NODE,TYPE,YEAR
     79 I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
     80 S IND=0
     81 F TYPE="ICD0","ICD9" D
     82 . S DFN=""
     83 . F  S DFN=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN)) Q:DFN=""  D
     84 .. S IND=IND+1
     85 .. I '$D(ZTQUEUED),(IND#10000=0) W "."
     86 .. S NODE=""
     87 .. F  S NODE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE)) Q:NODE=""  D
     88 ... S ITEM=""
     89 ... F  S ITEM=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM)) Q:ITEM=""  D
     90 .... S DATE=""
     91 .... F  S DATE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE)) Q:DATE=""  D
     92 ..... S YEAR=$E(DATE,1,3)
     93 ..... S DAS=""
     94 ..... F  S DAS=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE,DAS)) Q:DAS=""  D
     95 ...... S COUNT(YEAR)=$G(COUNT(YEAR))+1
     96 Q
     97 ;
     98 ;========================================================
     99CNTSS(FILENUM,COUNT) ;Get date counts for indexes where the start date
     100 ;is at subscript 5 and the stop date is at subscript 6.
     101 ;Works for file numbers: 52, 55, 100
     102 N DAS,DFN,IND,ITEM,START,STOP,YEAR
     103 I '$D(ZTQUEUED) W !,"Counting file number "_FILENUM
     104 S IND=0
     105 S DFN=""
     106 F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
     107 . S IND=IND+1
     108 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     109 . S ITEM=""
     110 . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
     111 .. S START=""
     112 .. F  S START=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START)) Q:START=""  D
     113 ... S YEAR=$E(START,1,3)
     114 ... S STOP=""
     115 ... F  S STOP=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP)) Q:STOP=""  D
     116 .... S DAS=""
     117 .... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP,DAS)) Q:DAS=""  D
     118 ..... S COUNT(YEAR)=$G(COUNT(YEAR))+1
     119 Q
     120 ;
     121 ;========================================================
     122COUNT ;Driver for making index counts.
     123 N GBL,LIST,TASKIT
     124 W !,"Which indexes do you want to count?"
     125 D SEL^PXRMSXRM(.LIST,.GBL)
     126 I LIST="" Q
     127 ;See if this should be tasked.
     128 S TASKIT=$$ASKTASK^PXRMSXRM
     129 I TASKIT D
     130 . W !,"Queue the Clinical Reminders Index count."
     131 . D TASKIT(LIST,.GBL,.ROUTINE)
     132 E  D RUNNOW(LIST,.GBL)
     133 Q
     134 ;
     135 ;========================================================
     136MESSAGE(FILENUM,COUNT,TOTAL,START,END) ;Build the MailMan message giving the
     137 ;count breakdown.
     138 N COFF,ML,NAME,NL,PERC,TEXT,YEAR,XMSUB
     139 K ^TMP("PXRMXMZ",$J)
     140 S ML=$$MAX^XLFMTH($L(TOTAL)+2,8)
     141 S COFF=ML-5
     142 S NAME=$$GET1^DID(FILENUM,"","","NAME")
     143 S XMSUB="Yearly data distribution for global "_NAME
     144 S ^TMP("PXRMXMZ",$J,1,0)="File name: "_NAME
     145 S ^TMP("PXRMXMZ",$J,2,0)="Count finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     146 S ^TMP("PXRMXMZ",$J,3,0)=$$ETIME^PXRMSXRM(START,END)
     147 S ^TMP("PXRMXMZ",$J,4,0)=" "
     148 S ^TMP("PXRMXMZ",$J,5,0)="Year"_$$INSCHR^PXRMEXLC(COFF," ")_"Count"_$J("%",8)
     149 S ^TMP("PXRMXMZ",$J,6,0)="----"_$$INSCHR^PXRMEXLC(COFF," ")_"-----"_$J("-----",10)
     150 S NL=6,YEAR=0
     151 F  S YEAR=$O(COUNT(YEAR)) Q:YEAR=""  D
     152 . S PERC=100*COUNT(YEAR)/TOTAL
     153 . S TEXT=YEAR_$J(COUNT(YEAR),ML,0)_$J(PERC,10,2)
     154 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
     155 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "
     156 S TEXT="Total entries: "_TOTAL
     157 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
     158 I TOTAL=0 D
     159 . I '$D(^PXRMINDX(FILENUM)) S TEXT="The index for file "_NAME_" does not exist!"
     160 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
     161 I TOTAL>0,'$D(^PXRMINDX(FILENUM,"DATE BUILT")) D
     162 . S TEXT="Warning, the index for file "_NAME_" may be incomplete or corrupted!"
     163 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=TEXT
     164 D SEND^PXRMMSG(XMSUB)
     165 K ^TMP("PXRMXMZ",$J)
     166 Q
     167 ;
     168 ;===============================================================
     169RUNNOW(LIST,GBL) ;Run the routines now.
     170 N COUNT,END,FN,IND,LI,NUM,ROUTINE,RTN,START,TOTAL
     171 S ROUTINE(45)="CNTPTF^PXRMINDC"
     172 S ROUTINE(52)="CNTSS^PXRMINDC"
     173 S ROUTINE(55)="CNTSS^PXRMINDC"
     174 S ROUTINE(63)="CNT5^PXRMINDC"
     175 S ROUTINE(70)="CNT5^PXRMINDC"
     176 S ROUTINE(100)="CNTSS^PXRMINDC"
     177 S ROUTINE(120.5)="CNT5^PXRMINDC"
     178 S ROUTINE(601.2)="CNT5^PXRMINDC"
     179 S ROUTINE(9000011)="CNTPL^PXRMINDC"
     180 S ROUTINE(9000010.07)="CNT6^PXRMINDC"
     181 S ROUTINE(9000010.11)="CNT5^PXRMINDC"
     182 S ROUTINE(9000010.12)="CNT5^PXRMINDC"
     183 S ROUTINE(9000010.13)="CNT5^PXRMINDC"
     184 S ROUTINE(9000010.16)="CNT5^PXRMINDC"
     185 S ROUTINE(9000010.18)="CNT6^PXRMINDC"
     186 S ROUTINE(9000010.23)="CNT5^PXRMINDC"
     187 S NUM=$L(LIST,",")-1
     188 F IND=1:1:NUM D
     189 . S LI=$P(LIST,",",IND)
     190 . S FN=GBL(LI)
     191 . S RTN=ROUTINE(FN)
     192 . S RTN=RTN_"("_FN_",.COUNT)"
     193 . S START=$H
     194 . K COUNT
     195 . I $D(^PXRMINDX(FN)) D @RTN
     196 . S END=$H
     197 . D TOTAL(.COUNT,.TOTAL)
     198 . D MESSAGE(FN,.COUNT,TOTAL,START,END)
     199 Q
     200 ;
     201 ;===============================================================
     202TASKIT(LIST,GBL,ROUTINE) ;Count the indexes as a tasked job.
     203 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
     204 S MINDT=$$NOW^XLFDT
     205 S DIR("A",1)="Enter the date and time you want the job to start."
     206 S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
     207 S DIR("A")="Start the task at: "
     208 S DIR(0)="DAU"_U_MINDT_"::RSX"
     209 D ^DIR
     210 I $D(DIROUT)!$D(DIRUT) Q
     211 I $D(DTOUT)!$D(DUOUT) Q
     212 S SDTIME=Y
     213 K DIR
     214 ;Put the task into the queue.
     215 K ZTSAVE
     216 S ZTSAVE("LIST")=""
     217 S ZTSAVE("GBL(")=""
     218 S ZTRTN="TASKJOB^PXRMINDC"
     219 S ZTDESC="Clinical Reminders Index count"
     220 S ZTDTH=SDTIME
     221 S ZTIO=""
     222 D ^%ZTLOAD
     223 W !,"Task number ",ZTSK," queued."
     224 Q
     225 ;
     226 ;===============================================================
     227TASKJOB ;Execute as tasked job. LIST and GBL come through ZTSAVE.
     228 N IND,LI,NUM
     229 S ZTREQ="@"
     230 S ZTSTOP=0
     231 S NUM=$L(LIST,",")-1
     232 F IND=1:1:NUM D
     233 .;Check to see if the task has had a stop request
     234 . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
     235 . S LI=$P(LIST,",",IND)_","
     236 . D RUNNOW^PXRMINDC(LI,.GBL)
     237 Q
     238 ;
     239 ;========================================================
     240TOTAL(COUNT,TOTAL) ;Convert the FileMan years in COUNT to regular
     241 ;years get the total number of entries in count.
     242 N TC,YEAR
     243 S (TOTAL,YEAR)=0
     244 F  S YEAR=$O(COUNT(YEAR)) Q:YEAR=""  D
     245 . S TOTAL=TOTAL+COUNT(YEAR)
     246 . S TC(YEAR+1700)=COUNT(YEAR)
     247 K COUNT
     248 M COUNT=TC
     249 Q
     250 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMINDD.m

    r613 r623  
    1 PXRMINDD        ; SLC/PKR - Index string date checking routines. ;03/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;========================================================
    5 CNT5(FILENUM,NSD)       ;Check for string dates for indexes where the date
    6         ;is at subscript 5. Works for file numbers:
    7         ;63, 70, 120.5, 601.2, 601.84
    8         ;9000010.11, 9000010.12, 9000010.13, 9000010.16, 9000010.23
    9         N DAS,DATE,DFN,IND,ITEM
    10         I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
    11         S IND=0
    12         S DFN=""
    13         F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
    14         . S IND=IND+1
    15         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    16         . S ITEM=""
    17         . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
    18         .. S DATE=""
    19         .. F  S DATE=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE)) Q:DATE=""  D
    20         ... I +DATE=DATE Q
    21         ... S DAS=""
    22         ... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE,DAS)) Q:DAS=""  D
    23         .... S NSD=NSD+1
    24         .... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PI"","_DFN_","_ITEM_","""_DATE_""","_DAS_")"
    25         Q
    26         ;
    27         ;========================================================
    28 CNT6(FILENUM,NSD)       ;Check for string dates for indexes where the date
    29         ;is at subscript 6. Works for file numbers:
    30         ;9000010.07, 9000010.18
    31         N DAS,DATE,DFN,IND,ITEM,TYPE
    32         I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
    33         S IND=0
    34         S DFN=""
    35         F  S DFN=$O(^PXRMINDX(FILENUM,"PPI",DFN)) Q:DFN=""  D
    36         . S IND=IND+1
    37         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    38         . S TYPE=""
    39         . F  S TYPE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE)) Q:TYPE=""  D
    40         .. S ITEM=""
    41         .. F  S ITEM=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM)) Q:ITEM=""  D
    42         ... S DATE=""
    43         ... F  S DATE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE)) Q:DATE=""  D
    44         .... I +DATE=DATE Q
    45         .... S DAS=""
    46         .... F  S DAS=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE,DAS)) Q:DAS=""  D
    47         ..... S NSD=NSD+1
    48         ..... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PPI"","_DFN_","_TYPE_","_ITEM_","""_DATE_""","_DAS_")"
    49         Q
    50         ;
    51         ;========================================================
    52 CNTPL(FILENUM,NSD)      ;Check for string date for Problem List indexes where the
    53         ;date is at subscript 7. Works for file numbers:
    54         ;9000011
    55         N DAS,DATE,DFN,IND,ITEM,PRIORITY,STATUS,TYPE
    56         I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
    57         S IND=0
    58         S DFN=""
    59         F  S DFN=$O(^PXRMINDX(FILENUM,"PSPI",DFN)) Q:DFN=""  D
    60         . S IND=IND+1
    61         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    62         . S STATUS=""
    63         . F  S STATUS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS)) Q:STATUS=""  D
    64         .. S PRIORITY=""
    65         .. F  S PRIORITY=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY)) Q:PRIORITY=""  D
    66         ... S ITEM=""
    67         ... F  S ITEM=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM)) Q:ITEM=""  D
    68         .... S DATE=""
    69         .... F  S DATE=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE)) Q:DATE=""  D
    70         ..... I +DATE=DATE Q
    71         ..... S DAS=""
    72         ..... F  S DAS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE,DAS)) Q:DAS=""  D
    73         ...... S NSD=NSD+1
    74         ...... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PSPI"","_DFN_","_STATUS_","_PRIORITY_","_ITEM_","""_DATE_""","_DAS_")"
    75         Q
    76         ;
    77         ;========================================================
    78 CNTPTF(FILENUM,NSD)     ;Check for string dates for PTF indexes where the
    79         ;date is at subscript 7. Works for file numbers:
    80         ;45
    81         N DAS,DATE,DFN,IND,ITEM,NODE,TYPE
    82         I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
    83         S IND=0
    84         F TYPE="ICD0","ICD9" D
    85         . S DFN=""
    86         . F  S DFN=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN)) Q:DFN=""  D
    87         .. S IND=IND+1
    88         .. I '$D(ZTQUEUED),(IND#10000=0) W "."
    89         .. S NODE=""
    90         .. F  S NODE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE)) Q:NODE=""  D
    91         ... S ITEM=""
    92         ... F  S ITEM=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM)) Q:ITEM=""  D
    93         .... S DATE=""
    94         .... F  S DATE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE)) Q:DATE=""  D
    95         ..... I +DATE=DATE Q
    96         ..... S DAS=""
    97         ..... F  S DAS=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE,DAS)) Q:DAS=""  D
    98         ...... S NSD=NSD+1
    99         ...... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_","_TYPE_",""PNI"","_DFN_","_NODE_","_ITEM_","""_DATE_""","_DAS_")"
    100         Q
    101         ;
    102         ;========================================================
    103 CNTSS(FILENUM,NSD)      ;Check for string dates for indexes where the start date
    104         ;is at subscript 5 and the stop date is at subscript 6.
    105         ;Works for file numbers: 52, 55, 100
    106         N DAS,DFN,IND,ITEM,START,STOP
    107         I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
    108         S IND=0
    109         S DFN=""
    110         F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
    111         . S IND=IND+1
    112         . I '$D(ZTQUEUED),(IND#10000=0) W "."
    113         . S ITEM=""
    114         . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
    115         .. S START=""
    116         .. F  S START=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START)) Q:START=""  D
    117         ... I +START=START Q
    118         ... S STOP=""
    119         ... F  S STOP=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP)) Q:STOP=""  D
    120         .... S DAS=""
    121         .... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP,DAS)) Q:DAS=""  D
    122         ..... S NSD=NSD+1
    123         ..... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PI"","_DFN_","_ITEM_","""_START_""","_STOP_","_DAS_")"
    124         Q
    125         ;
    126         ;========================================================
    127 CHECK   ;Driver for making index date checks.
    128         N GBL,LIST,TASKIT
    129         W !,"Which indexes do you want to check?"
    130         D SEL^PXRMSXRM(.LIST,.GBL)
    131         I LIST="" Q
    132         ;See if this should be tasked.
    133         S TASKIT=$$ASKTASK^PXRMSXRM
    134         I TASKIT D
    135         . W !,"Queue the Clinical Reminders Index date check."
    136         . D TASKIT(LIST,.GBL,.ROUTINE)
    137         E  D RUNNOW(LIST,.GBL)
    138         Q
    139         ;
    140         ;========================================================
    141 MESSAGE(FILENUM,NSD,START,END)  ;Build the MailMan message giving the
    142         ;list of entries with string dates.
    143         N IND,NAME,NL,TEXT,XMSUB
    144         K ^TMP("PXRMXMZ",$J)
    145         S XMSUB="CR Index string date check for file #"_FILENUM
    146         S NAME=$$GET1^DID(FILENUM,"","","NAME")_", file #"_FILENUM
    147         I NSD=0 S TEXT="No string dates were found for "_NAME_"."
    148         I NSD>0 S TEXT="A total of "_NSD_" string dates were found for "_NAME_"."
    149         S ^TMP("PXRMXMZ",$J,1,0)=TEXT
    150         S ^TMP("PXRMXMZ",$J,2,0)="Check finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    151         S ^TMP("PXRMXMZ",$J,3,0)=$$ETIME^PXRMSXRM(START,END)
    152         S ^TMP("PXRMXMZ",$J,4,0)=" "
    153         I NSD=0,'$D(^PXRMINDX(FILENUM)) D
    154         . S ^TMP("PXRMXMZ",$J,5,0)="The index for file number "_FILENUM_" does not exist."
    155         . S ^TMP("PXRMXMZ",$J,6,0)=" "
    156         I NSD>0 D
    157         . S ^TMP("PXRMXMZ",$J,5,0)="The following entries with string dates were found:"
    158         . S NL=5
    159         . F IND=1:1:NSD D
    160         .. S NL=NL+1
    161         .. S ^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP($J,"SDATE",IND)
    162         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "
    163         D SEND^PXRMMSG(XMSUB)
    164         K ^TMP($J,"SDATE"),^TMP("PXRMXMZ",$J)
    165         Q
    166         ;
    167         ;===============================================================
    168 RUNNOW(LIST,GBL)        ;Run the routines now.
    169         N END,FN,IND,LI,NSD,NUM,ROUTINE,RTN,START,TOTAL
    170         K ^TMP($J,"SDATE")
    171         S ROUTINE(45)="CNTPTF^PXRMINDD"
    172         S ROUTINE(52)="CNTSS^PXRMINDD"
    173         S ROUTINE(55)="CNTSS^PXRMINDD"
    174         S ROUTINE(63)="CNT5^PXRMINDD"
    175         S ROUTINE(70)="CNT5^PXRMINDD"
    176         S ROUTINE(100)="CNTSS^PXRMINDD"
    177         S ROUTINE(120.5)="CNT5^PXRMINDD"
    178         S ROUTINE(601.2)="CNT5^PXRMINDD"
    179         S ROUTINE(601.84)="CNT5^PXRMINDD"
    180         S ROUTINE(9000011)="CNTPL^PXRMINDD"
    181         S ROUTINE(9000010.07)="CNT6^PXRMINDD"
    182         S ROUTINE(9000010.11)="CNT5^PXRMINDD"
    183         S ROUTINE(9000010.12)="CNT5^PXRMINDD"
    184         S ROUTINE(9000010.13)="CNT5^PXRMINDD"
    185         S ROUTINE(9000010.16)="CNT5^PXRMINDD"
    186         S ROUTINE(9000010.18)="CNT6^PXRMINDD"
    187         S ROUTINE(9000010.23)="CNT5^PXRMINDD"
    188         S NUM=$L(LIST,",")-1
    189         F IND=1:1:NUM D
    190         . S LI=$P(LIST,",",IND)
    191         . S NSD=0
    192         . S FN=GBL(LI)
    193         . S RTN=ROUTINE(FN)
    194         . S RTN=RTN_"("_FN_",.NSD)"
    195         . S START=$H
    196         . I $D(^PXRMINDX(FN)) D @RTN
    197         . S END=$H
    198         . D MESSAGE(FN,NSD,START,END)
    199         Q
    200         ;
    201         ;===============================================================
    202 TASKIT(LIST,GBL,ROUTINE)        ;Check the indexes as a tasked job.
    203         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
    204         S MINDT=$$NOW^XLFDT
    205         S DIR("A",1)="Enter the date and time you want the job to start."
    206         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    207         S DIR("A")="Start the task at: "
    208         S DIR(0)="DAU"_U_MINDT_"::RSX"
    209         D ^DIR
    210         I $D(DIROUT)!$D(DIRUT) Q
    211         I $D(DTOUT)!$D(DUOUT) Q
    212         S SDTIME=Y
    213         K DIR
    214         ;Put the task into the queue.
    215         K ZTSAVE
    216         S ZTSAVE("LIST")=""
    217         S ZTSAVE("GBL(")=""
    218         S ZTRTN="TASKJOB^PXRMINDD"
    219         S ZTDESC="Clinical Reminders Index string date check"
    220         S ZTDTH=SDTIME
    221         S ZTIO=""
    222         D ^%ZTLOAD
    223         W !,"Task number ",ZTSK," queued."
    224         Q
    225         ;
    226         ;===============================================================
    227 TASKJOB ;Execute as tasked job. LIST and GBL come through ZTSAVE.
    228         N IND,LI,NUM
    229         S ZTREQ="@"
    230         S ZTSTOP=0
    231         S NUM=$L(LIST,",")-1
    232         F IND=1:1:NUM D
    233         .;Check to see if the task has had a stop request
    234         . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
    235         . S LI=$P(LIST,",",IND)_","
    236         . D RUNNOW^PXRMINDD(LI,.GBL)
    237         Q
    238         ;
     1PXRMINDD ; SLC/PKR - Index string date checking routines. ;05/02/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;========================================================
     5CNT5(FILENUM,NSD) ;Check for string dates for indexes where the date
     6 ;is at subscript 5. Works for file numbers:
     7 ;63, 70, 120.5, 601.2,
     8 ;9000010.11, 9000010.12, 9000010.13, 9000010.16, 9000010.23
     9 N DAS,DATE,DFN,IND,ITEM
     10 I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
     11 S IND=0
     12 S DFN=""
     13 F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
     14 . S IND=IND+1
     15 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     16 . S ITEM=""
     17 . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
     18 .. S DATE=""
     19 .. F  S DATE=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE)) Q:DATE=""  D
     20 ... I +DATE=DATE Q
     21 ... S DAS=""
     22 ... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,DATE,DAS)) Q:DAS=""  D
     23 .... S NSD=NSD+1
     24 .... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PI"","_DFN_","_ITEM_","""_DATE_""","_DAS_")"
     25 Q
     26 ;
     27 ;========================================================
     28CNT6(FILENUM,NSD) ;Check for string dates for indexes where the date
     29 ;is at subscript 6. Works for file numbers:
     30 ;9000010.07, 9000010.18
     31 N DAS,DATE,DFN,IND,ITEM,TYPE
     32 I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
     33 S IND=0
     34 S DFN=""
     35 F  S DFN=$O(^PXRMINDX(FILENUM,"PPI",DFN)) Q:DFN=""  D
     36 . S IND=IND+1
     37 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     38 . S TYPE=""
     39 . F  S TYPE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE)) Q:TYPE=""  D
     40 .. S ITEM=""
     41 .. F  S ITEM=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM)) Q:ITEM=""  D
     42 ... S DATE=""
     43 ... F  S DATE=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE)) Q:DATE=""  D
     44 .... I +DATE=DATE Q
     45 .... S DAS=""
     46 .... F  S DAS=$O(^PXRMINDX(FILENUM,"PPI",DFN,TYPE,ITEM,DATE,DAS)) Q:DAS=""  D
     47 ..... S NSD=NSD+1
     48 ..... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PPI"","_DFN_","_TYPE_","_ITEM_","""_DATE_""","_DAS_")"
     49 Q
     50 ;
     51 ;========================================================
     52CNTPL(FILENUM,NSD) ;Check for string date for Problem List indexes where the
     53 ;date is at subscript 7. Works for file numbers:
     54 ;9000011
     55 N DAS,DATE,DFN,IND,ITEM,PRIORITY,STATUS,TYPE
     56 I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
     57 S IND=0
     58 S DFN=""
     59 F  S DFN=$O(^PXRMINDX(FILENUM,"PSPI",DFN)) Q:DFN=""  D
     60 . S IND=IND+1
     61 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     62 . S STATUS=""
     63 . F  S STATUS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS)) Q:STATUS=""  D
     64 .. S PRIORITY=""
     65 .. F  S PRIORITY=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY)) Q:PRIORITY=""  D
     66 ... S ITEM=""
     67 ... F  S ITEM=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM)) Q:ITEM=""  D
     68 .... S DATE=""
     69 .... F  S DATE=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE)) Q:DATE=""  D
     70 ..... I +DATE=DATE Q
     71 ..... S DAS=""
     72 ..... F  S DAS=$O(^PXRMINDX(FILENUM,"PSPI",DFN,STATUS,PRIORITY,ITEM,DATE,DAS)) Q:DAS=""  D
     73 ...... S NSD=NSD+1
     74 ...... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PSPI"","_DFN_","_STATUS_","_PRIORITY_","_ITEM_","""_DATE_""","_DAS_")"
     75 Q
     76 ;
     77 ;========================================================
     78CNTPTF(FILENUM,NSD) ;Check for string dates for PTF indexes where the
     79 ;date is at subscript 7. Works for file numbers:
     80 ;45
     81 N DAS,DATE,DFN,IND,ITEM,NODE,TYPE
     82 I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
     83 S IND=0
     84 F TYPE="ICD0","ICD9" D
     85 . S DFN=""
     86 . F  S DFN=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN)) Q:DFN=""  D
     87 .. S IND=IND+1
     88 .. I '$D(ZTQUEUED),(IND#10000=0) W "."
     89 .. S NODE=""
     90 .. F  S NODE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE)) Q:NODE=""  D
     91 ... S ITEM=""
     92 ... F  S ITEM=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM)) Q:ITEM=""  D
     93 .... S DATE=""
     94 .... F  S DATE=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE)) Q:DATE=""  D
     95 ..... I +DATE=DATE Q
     96 ..... S DAS=""
     97 ..... F  S DAS=$O(^PXRMINDX(FILENUM,TYPE,"PNI",DFN,NODE,ITEM,DATE,DAS)) Q:DAS=""  D
     98 ...... S NSD=NSD+1
     99 ...... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_","_TYPE_",""PNI"","_DFN_","_NODE_","_ITEM_","""_DATE_""","_DAS_")"
     100 Q
     101 ;
     102 ;========================================================
     103CNTSS(FILENUM,NSD) ;Check for string dates for indexes where the start date
     104 ;is at subscript 5 and the stop date is at subscript 6.
     105 ;Works for file numbers: 52, 55, 100
     106 N DAS,DFN,IND,ITEM,START,STOP
     107 I '$D(ZTQUEUED) W !,"Checking file number "_FILENUM
     108 S IND=0
     109 S DFN=""
     110 F  S DFN=$O(^PXRMINDX(FILENUM,"PI",DFN)) Q:DFN=""  D
     111 . S IND=IND+1
     112 . I '$D(ZTQUEUED),(IND#10000=0) W "."
     113 . S ITEM=""
     114 . F  S ITEM=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM)) Q:ITEM=""  D
     115 .. S START=""
     116 .. F  S START=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START)) Q:START=""  D
     117 ... I +START=START Q
     118 ... S STOP=""
     119 ... F  S STOP=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP)) Q:STOP=""  D
     120 .... S DAS=""
     121 .... F  S DAS=$O(^PXRMINDX(FILENUM,"PI",DFN,ITEM,START,STOP,DAS)) Q:DAS=""  D
     122 ..... S NSD=NSD+1
     123 ..... S ^TMP($J,"SDATE",NSD)="^PXRMINDX("_FILENUM_",""PI"","_DFN_","_ITEM_","""_START_""","_STOP_","_DAS_")"
     124 Q
     125 ;
     126 ;========================================================
     127CHECK ;Driver for making index date checks.
     128 N GBL,LIST,TASKIT
     129 W !,"Which indexes do you want to check?"
     130 D SEL^PXRMSXRM(.LIST,.GBL)
     131 I LIST="" Q
     132 ;See if this should be tasked.
     133 S TASKIT=$$ASKTASK^PXRMSXRM
     134 I TASKIT D
     135 . W !,"Queue the Clinical Reminders Index date check."
     136 . D TASKIT(LIST,.GBL,.ROUTINE)
     137 E  D RUNNOW(LIST,.GBL)
     138 Q
     139 ;
     140 ;========================================================
     141MESSAGE(FILENUM,NSD,START,END) ;Build the MailMan message giving the
     142 ;list of entries with string dates.
     143 N IND,NAME,NL,TEXT,XMSUB
     144 K ^TMP("PXRMXMZ",$J)
     145 S XMSUB="CR Index string date check for file #"_FILENUM
     146 S NAME=$$GET1^DID(FILENUM,"","","NAME")_", file #"_FILENUM
     147 I NSD=0 S TEXT="No string dates were found for "_NAME_"."
     148 I NSD>0 S TEXT="A total of "_NSD_" string dates were found for "_NAME_"."
     149 S ^TMP("PXRMXMZ",$J,1,0)=TEXT
     150 S ^TMP("PXRMXMZ",$J,2,0)="Check finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     151 S ^TMP("PXRMXMZ",$J,3,0)=$$ETIME^PXRMSXRM(START,END)
     152 S ^TMP("PXRMXMZ",$J,4,0)=" "
     153 I NSD=0,'$D(^PXRMINDX(FILENUM)) D
     154 . S ^TMP("PXRMXMZ",$J,5,0)="The index for file number "_FILENUM_" does not exist."
     155 . S ^TMP("PXRMXMZ",$J,6,0)=" "
     156 I NSD>0 D
     157 . S ^TMP("PXRMXMZ",$J,5,0)="The following entries with string dates were found:"
     158 . S NL=5
     159 . F IND=1:1:NSD D
     160 .. S NL=NL+1
     161 .. S ^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP($J,"SDATE",IND)
     162 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "
     163 D SEND^PXRMMSG(XMSUB)
     164 K ^TMP($J,"SDATE"),^TMP("PXRMXMZ",$J)
     165 Q
     166 ;
     167 ;===============================================================
     168RUNNOW(LIST,GBL) ;Run the routines now.
     169 N END,FN,IND,LI,NSD,NUM,ROUTINE,RTN,START,TOTAL
     170 K ^TMP($J,"SDATE")
     171 S ROUTINE(45)="CNTPTF^PXRMINDD"
     172 S ROUTINE(52)="CNTSS^PXRMINDD"
     173 S ROUTINE(55)="CNTSS^PXRMINDD"
     174 S ROUTINE(63)="CNT5^PXRMINDD"
     175 S ROUTINE(70)="CNT5^PXRMINDD"
     176 S ROUTINE(100)="CNTSS^PXRMINDD"
     177 S ROUTINE(120.5)="CNT5^PXRMINDD"
     178 S ROUTINE(601.2)="CNT5^PXRMINDD"
     179 S ROUTINE(9000011)="CNTPL^PXRMINDD"
     180 S ROUTINE(9000010.07)="CNT6^PXRMINDD"
     181 S ROUTINE(9000010.11)="CNT5^PXRMINDD"
     182 S ROUTINE(9000010.12)="CNT5^PXRMINDD"
     183 S ROUTINE(9000010.13)="CNT5^PXRMINDD"
     184 S ROUTINE(9000010.16)="CNT5^PXRMINDD"
     185 S ROUTINE(9000010.18)="CNT6^PXRMINDD"
     186 S ROUTINE(9000010.23)="CNT5^PXRMINDD"
     187 S NUM=$L(LIST,",")-1
     188 F IND=1:1:NUM D
     189 . S LI=$P(LIST,",",IND)
     190 . S NSD=0
     191 . S FN=GBL(LI)
     192 . S RTN=ROUTINE(FN)
     193 . S RTN=RTN_"("_FN_",.NSD)"
     194 . S START=$H
     195 . I $D(^PXRMINDX(FN)) D @RTN
     196 . S END=$H
     197 . D MESSAGE(FN,NSD,START,END)
     198 Q
     199 ;
     200 ;===============================================================
     201TASKIT(LIST,GBL,ROUTINE) ;Check the indexes as a tasked job.
     202 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
     203 S MINDT=$$NOW^XLFDT
     204 S DIR("A",1)="Enter the date and time you want the job to start."
     205 S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
     206 S DIR("A")="Start the task at: "
     207 S DIR(0)="DAU"_U_MINDT_"::RSX"
     208 D ^DIR
     209 I $D(DIROUT)!$D(DIRUT) Q
     210 I $D(DTOUT)!$D(DUOUT) Q
     211 S SDTIME=Y
     212 K DIR
     213 ;Put the task into the queue.
     214 K ZTSAVE
     215 S ZTSAVE("LIST")=""
     216 S ZTSAVE("GBL(")=""
     217 S ZTRTN="TASKJOB^PXRMINDD"
     218 S ZTDESC="Clinical Reminders Index string date check"
     219 S ZTDTH=SDTIME
     220 S ZTIO=""
     221 D ^%ZTLOAD
     222 W !,"Task number ",ZTSK," queued."
     223 Q
     224 ;
     225 ;===============================================================
     226TASKJOB ;Execute as tasked job. LIST and GBL come through ZTSAVE.
     227 N IND,LI,NUM
     228 S ZTREQ="@"
     229 S ZTSTOP=0
     230 S NUM=$L(LIST,",")-1
     231 F IND=1:1:NUM D
     232 .;Check to see if the task has had a stop request
     233 . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
     234 . S LI=$P(LIST,",",IND)_","
     235 . D RUNNOW^PXRMINDD(LI,.GBL)
     236 Q
     237 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMINDL.m

    r613 r623  
    1 PXRMINDL        ; SLC/PKR - List building routines. ;07/26/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;================================================
    4 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;General patient list term evaluator.
    5         ;Return the list in ^TMP($J,PLIST)
    6         N ITEM,FILENUM,PFINDPA
    7         N SSFIND,TEMP,TFINDING,TFINDPA
    8         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    9         I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D  Q
    10         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),FILENUM)
    11         S ITEM=""
    12         F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:ITEM=""  D
    13         . S TFINDING=""
    14         . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
    15         .. K PFINDPA,TFINDPA
    16         .. M TFINDPA=TERMARR(20,TFINDING)
    17         ..;Set the finding parameters.
    18         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    19         .. D GPLIST(FILENUM,"IP",ITEM,.PFINDPA,PLIST)
    20         Q
    21         ;
    22         ;================================================
    23 FPLIST(FILENUM,SNODE,ITEM,NOCC,BDT,EDT,PLIST)   ;Find patient list data for
    24         ;regular files. Return the list in ^TMP($J,PLIST).
    25         N DAS,DATE,DFN,DS,NFOUND
    26         K ^TMP($J,PLIST)
    27         I FILENUM=601.84 D SEVALPL^PXRMMH(ITEM,NOCC,BDT,EDT,PLIST) Q
    28         S DS=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
    29         S DFN=0
    30         F  S DFN=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN)) Q:DFN=""  D
    31         . S NFOUND=0
    32         . S DATE=DS
    33         . F  S DATE=+$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,DATE),-1) Q:(DATE=0)!(DATE<BDT)!(NFOUND=NOCC)  D
    34         .. S NFOUND=NFOUND+1
    35         .. S DAS=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,DATE,""))
    36         .. S ^TMP($J,PLIST,DFN,NFOUND)=DAS_U_DATE
    37         Q
    38         ;
    39         ;================================================
    40 FPLISTSS(FILENUM,SNODE,ITEM,NGET,BDT,EDT,USESTRT,PLIST) ;Find patient list
    41         ;data for a finding with a start and stop date.
    42         ;Return the list in ^TMP($J,PLIST).
    43         N DAS,DFN,DONE,EDTT,NFOUND,OVERLAP,SDATE,START,STOP,TDATE,TIND,TLIST
    44         K ^TMP($J,PLIST)
    45         S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
    46         S DFN=0
    47         F  S DFN=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN)) Q:DFN=""  D
    48         . S (DONE,NFOUND)=0
    49         . S START=EDTT
    50         . K TLIST
    51         . F  S START=+$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,START),-1) Q:(START=0)!(DONE)  D
    52         .. S STOP=""
    53         .. F  S STOP=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,START,STOP),-1) Q:(STOP="")!(DONE)  D
    54         ... S SDATE=$S(USESTRT:START,STOP["U":$$NOW^PXRMDATE_"U",1:STOP)
    55         ... S OVERLAP=$$OVERLAP^PXRMINDX(START,SDATE,BDT,EDTT)
    56         ... I OVERLAP="O" D
    57         .... S DAS=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,START,STOP,""))
    58         .... S NFOUND=NFOUND+1,TLIST(SDATE,NFOUND)=DAS_U_START_U_SDATE
    59         ... I FILENUM="55NVA" Q
    60         ... I FILENUM=100 Q
    61         ... I OVERLAP="L" S DONE=1 Q
    62         .;Return up to NGET of the most recent entries.
    63         . S NFOUND=0,TDATE=""
    64         . F  S TDATE=$O(TLIST(TDATE)) Q:(TDATE="")!(NFOUND=NGET)  D
    65         .. S TIND=0
    66         .. F  S TIND=$O(TLIST(TDATE,TIND)) Q:(TIND="")!(NFOUND=NGET)  D
    67         ... S NFOUND=NFOUND+1,^TMP($J,PLIST,DFN,NFOUND)=TLIST(TDATE,TIND)
    68         Q
    69         ;
    70         ;================================================
    71 GPLIST(FILENUM,SNODE,ITEM,PFINDPA,PLIST)        ;Add to the patient list
    72         ;for a regular file. Return the list in ^TMP($J,PLIST):
    73         ;^TMP($J,PLIST,T/F,DFN,ITEM,COUNT,FILENUM)=DAS^DATE^VALUE
    74         N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,DFN,FIEVD,FLIST,GPLIST
    75         N ICOND,IND,INVFD,IPLIST,NOCC,NFOUND,NGET
    76         N SAVE,SSFIND,STATOK,STATUSA,TEMP,TGLIST,TPLIST
    77         N UCIFS,USESTRT,VALUE,VSLIST
    78         S TGLIST="GPLIST_PXRMINDL"
    79         ;Determine if this is a finding with a start and stop date.
    80         S SSFIND=$S(FILENUM=52:1,FILENUM[55:1,FILENUM=100:1,1:0)
    81         S USESTRT=$S(SSFIND:$P(PFINDPA(0),U,15),1:0)
    82         I FILENUM=100,USESTRT="" S USESTRT=1
    83         ;Set the finding search parameters.
    84         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    85         S INVFD=$P(PFINDPA(0),U,16)
    86         D GETSTATI^PXRMSTAT(FILENUM,.PFINDPA,.STATUSA)
    87         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    88         ;Ignore any negative occurrence counts, date reversal not allowed
    89         ;in patient lists.
    90         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    91         S NGET=$S(UCIFS:50,$D(STATUSA):50,1:NOCC)
    92         I SSFIND D FPLISTSS(FILENUM,SNODE,ITEM,NGET,BDT,EDT,USESTRT,TGLIST)
    93         I 'SSFIND D FPLIST(FILENUM,SNODE,ITEM,NGET,BDT,EDT,TGLIST)
    94         S DFN=""
    95         F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
    96         . K GPLIST
    97         . M GPLIST=^TMP($J,TGLIST,DFN)
    98         . S (IND,NFOUND)=0
    99         . K IPLIST
    100         . F  S IND=$O(GPLIST(IND)) Q:(IND="")!(NFOUND=NOCC)  D
    101         .. S TEMP=GPLIST(IND)
    102         .. S DAS=$P(TEMP,U,1)
    103         ..;If this a Lab finding attach the item to the DAS.
    104         .. I PFINDPA(0)["LAB(60" S DAS=ITEM_"~"_DAS
    105         ..;If this is a Mental Health finding attach the scale to DAS.
    106         .. I PFINDPA(0)["YTT(601.71" S DAS=DAS_"S"_$P(PFINDPA(0),U,12)
    107         .. D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
    108         .. S VALUE=$G(FIEVD("VALUE"))
    109         .. I INVFD D GETDATA^PXRMVSIT(FIEVD("VISIT"),.FIEVD,0)
    110         ..;If there is a status list make sure the finding has a status on
    111         ..;the list.
    112         .. S STATOK=$S($D(STATUSA):$$STATUSOK^PXRMINDX(.STATUSA,.FIEVD),1:1)
    113         .. I 'STATOK Q
    114         .. S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
    115         .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    116         .. I SAVE D
    117         ... S NFOUND=NFOUND+1
    118         ... S IPLIST(CONVAL,DFN,ITEM,NFOUND,FILENUM)=TEMP_U_VALUE
    119         . M ^TMP($J,PLIST)=IPLIST
    120         K ^TMP($J,TGLIST)
    121         Q
    122         ;
     1PXRMINDL ; SLC/PKR - List building routines. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;================================================
     4EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;General patient list term evaluator.
     5 ;Return the list in ^TMP($J,PLIST)
     6 N ITEM,FILENUM,PFINDPA
     7 N SSFIND,TEMP,TFINDING,TFINDPA
     8 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     9 I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D  Q
     10 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),FILENUM)
     11 S ITEM=""
     12 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:ITEM=""  D
     13 . S TFINDING=""
     14 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
     15 .. K PFINDPA,TFINDPA
     16 .. M TFINDPA=TERMARR(20,TFINDING)
     17 ..;Set the finding parameters.
     18 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     19 .. D GPLIST(FILENUM,"IP",ITEM,.PFINDPA,PLIST)
     20 Q
     21 ;
     22 ;================================================
     23FPLIST(FILENUM,SNODE,ITEM,NOCC,BDT,EDT,PLIST) ;Find patient list data for
     24 ;regular files. Return the list in ^TMP($J,PLIST).
     25 N DAS,DATE,DFN,DS,NFOUND
     26 K ^TMP($J,PLIST)
     27 I FILENUM=601.2 D SEVALPL^PXRMMH(ITEM,NOCC,BDT,EDT,PLIST) Q
     28 S DS=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
     29 S DFN=0
     30 F  S DFN=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN)) Q:DFN=""  D
     31 . S NFOUND=0
     32 . S DATE=DS
     33 . F  S DATE=+$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,DATE),-1) Q:(DATE=0)!(DATE<BDT)!(NFOUND=NOCC)  D
     34 .. S NFOUND=NFOUND+1
     35 .. S DAS=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,DATE,""))
     36 .. S ^TMP($J,PLIST,DFN,NFOUND)=DAS_U_DATE
     37 Q
     38 ;
     39 ;================================================
     40FPLISTSS(FILENUM,SNODE,ITEM,NGET,BDT,EDT,USESTRT,PLIST) ;Find patient list
     41 ;data for a finding with a start and stop date.
     42 ;Return the list in ^TMP($J,PLIST).
     43 N DAS,DFN,DONE,EDTT,NFOUND,OVERLAP,SDATE,START,STOP,TDATE,TIND,TLIST
     44 K ^TMP($J,PLIST)
     45 S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
     46 S DFN=0
     47 F  S DFN=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN)) Q:DFN=""  D
     48 . S (DONE,NFOUND)=0
     49 . S START=EDTT
     50 . K TLIST
     51 . F  S START=+$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,START),-1) Q:(START=0)!(DONE)  D
     52 .. S STOP=""
     53 .. F  S STOP=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,START,STOP),-1) Q:(STOP="")!(DONE)  D
     54 ... S SDATE=$S(USESTRT:START,STOP["U":$$NOW^PXRMDATE_"U",1:STOP)
     55 ... S OVERLAP=$$OVERLAP^PXRMINDX(START,SDATE,BDT,EDTT)
     56 ... I OVERLAP="O" D
     57 .... S DAS=$O(^PXRMINDX(FILENUM,SNODE,ITEM,DFN,START,STOP,""))
     58 .... S NFOUND=NFOUND+1,TLIST(SDATE,NFOUND)=DAS_U_START_U_SDATE
     59 ... I FILENUM="55NVA" Q
     60 ... I FILENUM=100 Q
     61 ... I OVERLAP="L" S DONE=1 Q
     62 .;Return up to NGET of the most recent entries.
     63 . S NFOUND=0,TDATE=""
     64 . F  S TDATE=$O(TLIST(TDATE)) Q:(TDATE="")!(NFOUND=NGET)  D
     65 .. S TIND=0
     66 .. F  S TIND=$O(TLIST(TDATE,TIND)) Q:(TIND="")!(NFOUND=NGET)  D
     67 ... S NFOUND=NFOUND+1,^TMP($J,PLIST,DFN,NFOUND)=TLIST(TDATE,TIND)
     68 Q
     69 ;
     70 ;================================================
     71GPLIST(FILENUM,SNODE,ITEM,PFINDPA,PLIST) ;Add to the patient list
     72 ;for a regular file. Return the list in ^TMP($J,PLIST):
     73 ;^TMP($J,PLIST,T/F,DFN,ITEM,COUNT,FILENUM)=DAS^DATE^VALUE
     74 N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,DFN,FIEVD,FLIST,GPLIST
     75 N ICOND,IND,INVFD,IPLIST,NOCC,NFOUND,NGET
     76 N SAVE,SSFIND,STATOK,STATUSA,TEMP,TGLIST,TPLIST
     77 N UCIFS,USESTRT,VALUE,VSLIST
     78 S TGLIST="GPLIST_PXRMINDL"
     79 ;Determine if this is a finding with a start and stop date.
     80 S SSFIND=$S(FILENUM=52:1,FILENUM[55:1,FILENUM=100:1,1:0)
     81 S USESTRT=$S(SSFIND:$P(PFINDPA(0),U,15),1:0)
     82 I FILENUM=100,USESTRT="" S USESTRT=1
     83 ;Set the finding search parameters.
     84 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     85 S INVFD=$P(PFINDPA(0),U,16)
     86 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     87 D GETSTATI^PXRMSTAT(FILENUM,.PFINDPA,.STATUSA)
     88 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     89 S NGET=$S(UCIFS:"*",$D(STATUSA):"*",1:NOCC)
     90 I SSFIND D FPLISTSS(FILENUM,SNODE,ITEM,NGET,BDT,EDT,USESTRT,TGLIST)
     91 I 'SSFIND D FPLIST(FILENUM,SNODE,ITEM,NGET,BDT,EDT,TGLIST)
     92 S DFN=""
     93 F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
     94 . K GPLIST
     95 . M GPLIST=^TMP($J,TGLIST,DFN)
     96 . S (IND,NFOUND)=0
     97 . K IPLIST
     98 . F  S IND=$O(GPLIST(IND)) Q:(IND="")!(NFOUND=NOCC)  D
     99 .. S TEMP=GPLIST(IND)
     100 .. S DAS=$P(TEMP,U,1)
     101 ..;If this a Lab finding attach the item to the DAS.
     102 .. I PFINDPA(0)["LAB(60" S DAS=ITEM_"~"_DAS
     103 ..;If this is a Mental Health finding attach the scale to DAS.
     104 .. I PFINDPA(0)["YTT(601" S DAS=DAS_"S"_$P(PFINDPA(0),U,12)
     105 .. D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
     106 .. S VALUE=$G(FIEVD("VALUE"))
     107 .. I INVFD D GETDATA^PXRMVSIT(FIEVD("VISIT"),.FIEVD,0)
     108 ..;If there is a status list make sure the finding has a status on
     109 ..;the list.
     110 .. S STATOK=$S($D(STATUSA):$$STATUSOK^PXRMINDX(.STATUSA,.FIEVD),1:1)
     111 .. I 'STATOK Q
     112 .. S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
     113 .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     114 .. I SAVE D
     115 ... S NFOUND=NFOUND+1
     116 ... S IPLIST(CONVAL,DFN,ITEM,NFOUND,FILENUM)=TEMP_U_VALUE
     117 . M ^TMP($J,PLIST)=IPLIST
     118 K ^TMP($J,TGLIST)
     119 Q
     120 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMINDX.m

    r613 r623  
    1 PXRMINDX        ; SLC/PKR - Routines for utilizing the index. ;10/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;Code for patient findings.
    4         ;================================================================
    5 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;General finding evaluator.
    6         N BDT,EDT,FIEVT,FILENUM,FINDING,FINDPA,ITEM,NOINDEX
    7         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    8         I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D
    9         . D NOINDEX^PXRMERRH("D",PXRMITEM,FILENUM)
    10         . S NOINDEX=1
    11         E  S NOINDEX=0
    12         S ITEM=""
    13         F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:ITEM=""  D
    14         . S FINDING=""
    15         . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
    16         .. I NOINDEX S FIEVAL(FINDING)=0 Q
    17         .. K FINDPA
    18         .. M FINDPA=DEFARR(20,FINDING)
    19         .. K FIEVT
    20         .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.FINDPA,.FIEVT)
    21         .. M FIEVAL(FINDING)=FIEVT
    22         .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
    23         Q
    24         ;
    25         ;================================================================
    26 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;General term
    27         ;evaluator.
    28         N FIEVT,FILENUM,ITEM,NOINDEX,PFINDPA
    29         N TFINDING,TFINDPA
    30         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    31         I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D
    32         . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),FILENUM)
    33         . S NOINDEX=1
    34         E  S NOINDEX=0
    35         S ITEM=""
    36         F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    37         . S TFINDING=""
    38         . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
    39         .. I NOINDEX S TFIEVAL(TFINDING)=0 Q
    40         .. K FIEVT,PFINDPA,TFINDPA
    41         .. M TFINDPA=TERMARR(20,TFINDING)
    42         ..;Set the finding parameters.
    43         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    44         .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.PFINDPA,.FIEVT)
    45         .. M TFIEVAL(TFINDING)=FIEVT
    46         .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
    47         Q
    48         ;
    49         ;================================================================
    50 FIEVAL(FILENUM,SNODE,DFN,ITEM,PFINDPA,FIEVAL)   ;
    51         ;Evaluate regular patient findings.
    52         N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,FIEVD,FLIST,ICOND,IEN,IND,INVFD
    53         N NFOUND,NGET,NOCC,NP
    54         N SAVE,SDIR,SSFIND,STATOK,STATUSA,UCIFS,USESTRT,VSLIST
    55         ;Set the finding search parameters.
    56         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    57         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    58         S SDIR=$S(NOCC<0:+1,1:-1)
    59         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    60         S NGET=$S(UCIFS:50,1:NOCC)
    61         ;Determine if this is a finding with a start and stop date.
    62         S SSFIND=$S(FILENUM=52:1,FILENUM["55":1,FILENUM=100:1,1:0)
    63         S USESTRT=$S(SSFIND:$P(PFINDPA(0),U,15),1:0)
    64         I FILENUM=100,USESTRT="" S USESTRT=1
    65         ;Get the status list.
    66         D GETSTATI^PXRMSTAT(FILENUM,.PFINDPA,.STATUSA)
    67         I SSFIND D FPDATSS(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,USESTRT,.NFOUND,.FLIST)
    68         I 'SSFIND D FPDAT(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,.NFOUND,.FLIST)
    69         I NFOUND=0 S FIEVAL=0 Q
    70         S INVFD=$P(PFINDPA(0),U,16)
    71         S NP=0
    72         F IND=1:1:NFOUND Q:NP=NOCC  D
    73         . S DAS=$P(FLIST(IND),U,1)
    74         .;If this a Lab finding attach the item to the DAS.
    75         . I PFINDPA(0)["LAB(60" S DAS=ITEM_"~"_DAS
    76         .;If this is a Mental Health finding attach the scale to DAS.
    77         . I PFINDPA(0)["YTT(601.71" S DAS=DAS_"S"_$P(PFINDPA(0),U,12)
    78         . D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
    79         . I INVFD D GETDATA^PXRMVSIT(FIEVD("VISIT"),.FIEVD,0)
    80         .;If there is a status list make sure the finding has one on the list.
    81         . S STATOK=$S($D(STATUSA):$$STATUSOK(.STATUSA,.FIEVD),1:1)
    82         . I 'STATOK Q
    83         . S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
    84         . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    85         . I SAVE D
    86         .. S NP=NP+1
    87         .. S FIEVAL(NP)=CONVAL
    88         .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
    89         .. S FIEVAL(NP,"DAS")=$P(FLIST(IND),U,1)
    90         .. S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
    91         .. M FIEVAL(NP)=FIEVD
    92         .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVD
    93         ;
    94         ;Save the finding result.
    95         D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
    96         S FIEVAL("FILE NUMBER")=FILENUM
    97         Q
    98         ;
    99         ;================================================================
    100 FPDAT(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,NFOUND,FLIST)    ;Find patient
    101         ;data for regular files. FLIST is returned in date order, i.e.,
    102         ;FLIST(1) is the most recent SDIR=-1, oldest SDIR=+1.
    103         I FILENUM=601.84 D SEVALFI^PXRMMH(DFN,ITEM,NGET,SDIR,BDT,EDT,.NFOUND,.FLIST) Q
    104         N DAS,DATE,DONE,EDTT
    105         S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
    106         S (DONE,NFOUND)=0
    107         S DATE=$S(SDIR=+1:BDT-.000001,1:EDTT)
    108         F  S DATE=+$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,DATE),SDIR) Q:(DATE=0)!(DONE)  D
    109         . I DATE<BDT,SDIR=-1 S DONE=1 Q
    110         . I DATE>EDTT,SDIR=1 S DONE=1 Q
    111         . S DAS=$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,DATE,""))
    112         . S NFOUND=NFOUND+1
    113         . S FLIST(NFOUND)=DAS_U_DATE
    114         . I NFOUND=NGET S DONE=1 Q
    115         Q
    116         ;
    117         ;================================================================
    118 FPDATSS(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,USESTRT,NFOUND,FLIST)  ;Find
    119         ;patient data for findings that have a start and stop date. FLIST
    120         ;is returned in date order, i.e., FLIST(1) is the most recent.
    121         N DAS,DONE,EDTT,OVERLAP,SDATE,START,STOP,TDATE,TIND,TLIST
    122         S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
    123         S (DONE,NFOUND)=0
    124         S START=$S(SDIR=+1:0,1:EDTT)
    125         F  S START=+$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,START),SDIR) Q:(START=0)!(DONE)!(START>EDTT)  D
    126         . S STOP=""
    127         . F  S STOP=$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,START,STOP),SDIR) Q:(STOP="")!(DONE)  D
    128         ..;Items that do not have a stop date are flagged by "U".
    129         .. S SDATE=$S(USESTRT:START,STOP["U":$$NOW^PXRMDATE_"U",1:STOP)
    130         .. S OVERLAP=$$OVERLAP(START,SDATE,BDT,EDT)
    131         .. I OVERLAP="O" D
    132         ... S DAS=$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,START,STOP,""))
    133         ... S NFOUND=NFOUND+1,TLIST(SDATE,NFOUND)=DAS_U_SDATE
    134         ..;Some orders and non-VA meds may not have a Stop Date so we have
    135         ..;to check all entries.
    136         .. I FILENUM="55NVA" Q
    137         .. I FILENUM=100 Q
    138         .. I OVERLAP="L",SDIR=-1 S DONE=1 Q
    139         .. I OVERLAP="R",SDIR=1 S DONE=1 Q
    140         ;Return up to NGET of the most recent/oldest entries.
    141         S NFOUND=0,TDATE=""
    142         F  S TDATE=$O(TLIST(TDATE),SDIR) Q:(TDATE="")!(NFOUND=NGET)  D
    143         . S TIND=0
    144         . F  S TIND=$O(TLIST(TDATE,TIND)) Q:(TIND="")!(NFOUND=NGET)  D
    145         .. S NFOUND=NFOUND+1,FLIST(NFOUND)=TLIST(TDATE,TIND)
    146         Q
    147         ;
    148         ;================================================================
    149 OVERLAP(START,STOP,BDT,EDT)     ;Determine if the date range defined by START and
    150         ;STOP overlaps with the date range defined by BDT and EDT. The return
    151         ;value "O" means they overlap, "L" means START, STOP is to the
    152         ;left of BDT, EDT and "R" means it is to the right.
    153         I EDT<START Q "R"
    154         I STOP<BDT Q "L"
    155         Q "O"
    156         ;
    157         ;================================================================
    158 STATUSOK(STATUSA,FIEVD) ;Return true if the status in FIEVD matches one in
    159         ;the list in STATUSA.
    160         I '$D(FIEVD("STATUS")) Q 1
    161         N JND,OK
    162         S OK=0
    163         F JND=1:1:STATUSA(0) Q:OK  D
    164         . I STATUSA(JND)="*" S OK=1 Q
    165         . I STATUSA(JND)=FIEVD("STATUS") S OK=1 Q
    166         Q OK
    167         ;
     1PXRMINDX ; SLC/PKR - Routines for utilizing the index. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;Code for patient findings.
     4 ;================================================================
     5EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;General finding evaluator.
     6 N BDT,EDT,FIEVT,FILENUM,FINDING,FINDPA,ITEM,NOINDEX
     7 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     8 I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D
     9 . D NOINDEX^PXRMERRH("D",PXRMITEM,FILENUM)
     10 . S NOINDEX=1
     11 E  S NOINDEX=0
     12 S ITEM=""
     13 F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:ITEM=""  D
     14 . S FINDING=""
     15 . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
     16 .. I NOINDEX S FIEVAL(FINDING)=0 Q
     17 .. K FINDPA
     18 .. M FINDPA=DEFARR(20,FINDING)
     19 .. K FIEVT
     20 .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.FINDPA,.FIEVT)
     21 .. M FIEVAL(FINDING)=FIEVT
     22 .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
     23 Q
     24 ;
     25 ;================================================================
     26EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;General term
     27 ;evaluator.
     28 N FIEVT,FILENUM,ITEM,NOINDEX,PFINDPA
     29 N TFINDING,TFINDPA
     30 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     31 I $G(^PXRMINDX(FILENUM,"DATE BUILT"))="" D
     32 . D NOINDEX^PXRMERRH("TR",TERMARR("IEN"),FILENUM)
     33 . S NOINDEX=1
     34 E  S NOINDEX=0
     35 S ITEM=""
     36 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     37 . S TFINDING=""
     38 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
     39 .. I NOINDEX S TFIEVAL(TFINDING)=0 Q
     40 .. K FIEVT,PFINDPA,TFINDPA
     41 .. M TFINDPA=TERMARR(20,TFINDING)
     42 ..;Set the finding parameters.
     43 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     44 .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.PFINDPA,.FIEVT)
     45 .. M TFIEVAL(TFINDING)=FIEVT
     46 .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
     47 Q
     48 ;
     49 ;================================================================
     50FIEVAL(FILENUM,SNODE,DFN,ITEM,PFINDPA,FIEVAL) ;
     51 ;Evaluate regular patient findings.
     52 N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,FIEVD,FLIST,ICOND,IEN,IND,INVFD
     53 N NFOUND,NGET,NOCC,NP
     54 N SAVE,SDIR,SSFIND,STATOK,STATUSA,UCIFS,USESTRT,VSLIST
     55 ;Set the finding search parameters.
     56 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     57 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     58 S SDIR=$S(NOCC<0:+1,1:-1)
     59 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     60 S NGET=$S(UCIFS:"*",1:NOCC)
     61 ;Determine if this is a finding with a start and stop date.
     62 S SSFIND=$S(FILENUM=52:1,FILENUM["55":1,FILENUM=100:1,1:0)
     63 S USESTRT=$S(SSFIND:$P(PFINDPA(0),U,15),1:0)
     64 I FILENUM=100,USESTRT="" S USESTRT=1
     65 ;Get the status list.
     66 D GETSTATI^PXRMSTAT(FILENUM,.PFINDPA,.STATUSA)
     67 I SSFIND D FPDATSS(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,USESTRT,.NFOUND,.FLIST)
     68 I 'SSFIND D FPDAT(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,.NFOUND,.FLIST)
     69 I NFOUND=0 S FIEVAL=0 Q
     70 S INVFD=$P(PFINDPA(0),U,16)
     71 S NP=0
     72 F IND=1:1:NFOUND Q:NP=NOCC  D
     73 . S DAS=$P(FLIST(IND),U,1)
     74 .;If this a Lab finding attach the item to the DAS.
     75 . I PFINDPA(0)["LAB(60" S DAS=ITEM_"~"_DAS
     76 .;If this is a Mental Health finding attach the scale to DAS.
     77 . I PFINDPA(0)["YTT(601" S DAS=DAS_"S"_$P(PFINDPA(0),U,12)
     78 . D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
     79 . I INVFD D GETDATA^PXRMVSIT(FIEVD("VISIT"),.FIEVD,0)
     80 .;If there is a status list make sure the finding has one on the list.
     81 . S STATOK=$S($D(STATUSA):$$STATUSOK(.STATUSA,.FIEVD),1:1)
     82 . I 'STATOK Q
     83 . S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
     84 . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     85 . I SAVE D
     86 .. S NP=NP+1
     87 .. S FIEVAL(NP)=CONVAL
     88 .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
     89 .. S FIEVAL(NP,"DAS")=$P(FLIST(IND),U,1)
     90 .. S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
     91 .. M FIEVAL(NP)=FIEVD
     92 .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVD
     93 ;
     94 ;Save the finding result.
     95 D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
     96 S FIEVAL("FILE NUMBER")=FILENUM
     97 Q
     98 ;
     99 ;================================================================
     100FPDAT(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,NFOUND,FLIST) ;Find patient
     101 ;data for regular files. FLIST is returned in date order, i.e.,
     102 ;FLIST(1) is the most recent SDIR=-1, oldest SDIR=+1.
     103 I FILENUM=601.2 D SEVALFI^PXRMMH(DFN,ITEM,NGET,SDIR,BDT,EDT,.NFOUND,.FLIST) Q
     104 N DAS,DATE,DONE,EDTT
     105 S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
     106 S (DONE,NFOUND)=0
     107 S DATE=$S(SDIR=+1:BDT-.000001,1:EDTT)
     108 F  S DATE=+$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,DATE),SDIR) Q:(DATE=0)!(DONE)  D
     109 . I DATE<BDT,SDIR=-1 S DONE=1 Q
     110 . I DATE>EDTT,SDIR=1 S DONE=1 Q
     111 . S DAS=$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,DATE,""))
     112 . S NFOUND=NFOUND+1
     113 . S FLIST(NFOUND)=DAS_U_DATE
     114 . I NFOUND=NGET S DONE=1 Q
     115 Q
     116 ;
     117 ;================================================================
     118FPDATSS(FILENUM,SNODE,DFN,ITEM,NGET,SDIR,BDT,EDT,USESTRT,NFOUND,FLIST) ;Find
     119 ;patient data for findings that have a start and stop date. FLIST
     120 ;is returned in date order, i.e., FLIST(1) is the most recent.
     121 N DAS,DONE,EDTT,OVERLAP,SDATE,START,STOP,TDATE,TIND,TLIST
     122 S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
     123 S (DONE,NFOUND)=0
     124 S START=$S(SDIR=+1:0,1:EDTT)
     125 F  S START=+$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,START),SDIR) Q:(START=0)!(DONE)!(START>EDTT)  D
     126 . S STOP=""
     127 . F  S STOP=$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,START,STOP),SDIR) Q:(STOP="")!(DONE)  D
     128 ..;Items that do not have a stop date are flagged by "U".
     129 .. S SDATE=$S(USESTRT:START,STOP["U":$$NOW^PXRMDATE_"U",1:STOP)
     130 .. S OVERLAP=$$OVERLAP(START,SDATE,BDT,EDT)
     131 .. I OVERLAP="O" D
     132 ... S DAS=$O(^PXRMINDX(FILENUM,SNODE,DFN,ITEM,START,STOP,""))
     133 ... S NFOUND=NFOUND+1,TLIST(SDATE,NFOUND)=DAS_U_SDATE
     134 ..;Some orders and non-VA meds may not have a Stop Date so we have
     135 ..;to check all entries.
     136 .. I FILENUM="55NVA" Q
     137 .. I FILENUM=100 Q
     138 .. I OVERLAP="L",SDIR=-1 S DONE=1 Q
     139 .. I OVERLAP="R",SDIR=1 S DONE=1 Q
     140 ;Return up to NGET of the most recent/oldest entries.
     141 S NFOUND=0,TDATE=""
     142 F  S TDATE=$O(TLIST(TDATE),SDIR) Q:(TDATE="")!(NFOUND=NGET)  D
     143 . S TIND=0
     144 . F  S TIND=$O(TLIST(TDATE,TIND)) Q:(TIND="")!(NFOUND=NGET)  D
     145 .. S NFOUND=NFOUND+1,FLIST(NFOUND)=TLIST(TDATE,TIND)
     146 Q
     147 ;
     148 ;================================================================
     149OVERLAP(START,STOP,BDT,EDT) ;Determine if the date range defined by START and
     150 ;STOP overlaps with the date range defined by BDT and EDT. The return
     151 ;value "O" means they overlap, "L" means START, STOP is to the
     152 ;left of BDT, EDT and "R" means it is to the right.
     153 I EDT<START Q "R"
     154 I STOP<BDT Q "L"
     155 Q "O"
     156 ;
     157 ;================================================================
     158STATUSOK(STATUSA,FIEVD) ;Return true if the status in FIEVD matches one in
     159 ;the list in STATUSA.
     160 I '$D(FIEVD("STATUS")) Q 1
     161 N JND,OK
     162 S OK=0
     163 F JND=1:1:STATUSA(0) Q:OK  D
     164 . I STATUSA(JND)="*" S OK=1 Q
     165 . I STATUSA(JND)=FIEVD("STATUS") S OK=1 Q
     166 Q OK
     167 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMISE.m

    r613 r623  
    1 PXRMISE ; SLC/PKR - Index size estimating routines. ;03/13/2006
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;========================================================
    5 EST     ;Driver for making index counts.
    6         N BLOCKS,FUNCTION,GBL,GLIST,IND,NE,NL,NUMGBL,RTN
    7         N SF,TASKIT,TBLOCKS,XMSUB
    8         D SETDATA(.GBL,.GLIST,.NUMGBL,.RTN,.SF)
    9         I +SF=-1 D ERRORMSG^PXRMISF(SF)  Q
    10         S (NL,TBLOCKS)=0
    11         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Start time "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    12         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
    13         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Size Estimate for ^PXRMINDX"
    14         F IND=1:1:NUMGBL D
    15         . S FUNCTION="S NE=$$"_RTN(GBL(IND))
    16         . X FUNCTION
    17         . S BLOCKS=NE*SF(GBL(IND))
    18         . S BLOCKS=$FN(BLOCKS,"","")+1
    19         . S TBLOCKS=TBLOCKS+BLOCKS
    20         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
    21         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Estimates for "_GLIST(IND)
    22         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" Number of entries: "_NE
    23         . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" Number of blocks: "_BLOCKS
    24         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
    25         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Total estimated blocks: "_TBLOCKS
    26         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
    27         S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="End time "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    28         S XMSUB="Size estimate for index global"
    29         D SEND^PXRMMSG(XMSUB)
    30         S ZTREQ="@"
    31         Q
    32         ;
    33         ;===============================================================
    34 ESTTASK ;Task the index size estimation.
    35         N DIR,DTOUT,DUOUT,MINDT,SDTIME,X,Y
    36         S MINDT=$$NOW^XLFDT
    37         W !,"Queue the Clinical Reminders index size estimation."
    38         S DIR("A",1)="Enter the date and time you want the job to start."
    39         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    40         S DIR("A")="Start the task at: "
    41         S DIR(0)="DAU"_U_MINDT_"::RSX"
    42         D ^DIR
    43         I $D(DTOUT)!$D(DUOUT) Q
    44         S SDTIME=Y
    45         K DIR
    46         ;Put the task into the queue.
    47         S ZTRTN="EST^PXRMISE"
    48         S ZTDESC="Clinical Reminders index size estimation"
    49         S ZTDTH=SDTIME
    50         S ZTIO=""
    51         D ^%ZTLOAD
    52         W !,"Task number ",ZTSK," queued."
    53         Q
    54         ;
    55         ;===============================================================
    56 NEOR()  ;Return number of entries in OR.
    57         ;DBIA #4180
    58         Q $P(^OR(100,0),U,4)
    59         ;
    60         ;===============================================================
    61 NEPROB()        ;Return number of entries in PROBLEM LIST.
    62         ;DBIA #3837
    63         Q $P(^AUPNPROB(0),U,4)
    64         ;
    65         ;===============================================================
    66 NEPS()  ;Return number of entries in PS(55).
    67         N ADD,DA,DA1,DFN,DRUG,IND,NE,SDATE,SOL,STARTD,TEMP
    68         ;DBIA #4181
    69         S (DFN,IND,NE)=0
    70         F  S DFN=+$O(^PS(55,DFN)) Q:DFN=0  D
    71         .;Process Unit Dose.
    72         . S DA=0
    73         . F  S DA=+$O(^PS(55,DFN,5,DA)) Q:DA=0  D
    74         .. S TEMP=$G(^PS(55,DFN,5,DA,2))
    75         .. S STARTD=$P(TEMP,U,2)
    76         .. I STARTD="" Q
    77         ..;If the order is purged then SDATE is 1.
    78         .. S SDATE=$P(TEMP,U,4)
    79         .. I SDATE=1 Q
    80         .. S DA1=0
    81         .. F  S DA1=+$O(^PS(55,DFN,5,DA,1,DA1)) Q:DA1=0  D
    82         ... S DRUG=$P(^PS(55,DFN,5,DA,1,DA1,0),U,1)
    83         ... I DRUG="" Q
    84         ... S NE=NE+1
    85         .;Process the IV mutiple.
    86         . S DA=0
    87         . F  S DA=+$O(^PS(55,DFN,"IV",DA)) Q:DA=0  D
    88         .. S TEMP=$G(^PS(55,DFN,"IV",DA,0))
    89         .. S STARTD=$P(TEMP,U,2)
    90         .. I STARTD="" Q
    91         .. S SDATE=$P(TEMP,U,3)
    92         .. I SDATE=1 Q
    93         ..;Process Additives
    94         .. S DA1=0
    95         .. F  S DA1=+$O(^PS(55,DFN,"IV",DA,"AD",DA1)) Q:DA1=0  D
    96         ... S ADD=$P(^PS(55,DFN,"IV",DA,"AD",DA1,0),U,1)
    97         ... I ADD="" Q
    98         ... S DRUG=$P($G(^PS(52.6,ADD,0)),U,2)
    99         ... I DRUG="" Q
    100         ... S NE=NE+1
    101         ..;Process Solutions
    102         .. S DA1=0
    103         .. F  S DA1=+$O(^PS(55,DFN,"IV",DA,"SOL",DA1)) Q:DA1=0  D
    104         ... S SOL=$P(^PS(55,DFN,"IV",DA,"SOL",DA1,0),U,1)
    105         ... I SOL="" Q
    106         ... S DRUG=$P($G(^PS(52.7,SOL,0)),U,2)
    107         ... I DRUG="" Q
    108         ... S NE=NE+1
    109         Q NE
    110         ;
    111         ;===============================================================
    112 NEPSRX()        ;Return number of entries in PSRX
    113         N DA,DA1,DATE,DSUP,DFN,DRUG,NE,RDATE,TEMP
    114         ;DBIA #4182
    115         S (DA,NE)=0
    116         F  S DA=+$O(^PSRX(DA)) Q:DA=0  D
    117         . S TEMP=$G(^PSRX(DA,0))
    118         . S DFN=$P(TEMP,U,2)
    119         . I DFN="" Q
    120         . S DRUG=$P(TEMP,U,6)
    121         . I DRUG="" Q
    122         . S DSUP=$P(TEMP,U,8)
    123         . I DSUP="" Q
    124         . S RDATE=+$P($G(^PSRX(DA,2)),U,13)
    125         . I RDATE>0 S NE=NE+1
    126         .;Process the refill mutiple.
    127         . S DA1=0
    128         . F  S DA1=+$O(^PSRX(DA,1,DA1)) Q:DA1=0  D
    129         .. S TEMP=$G(^PSRX(DA,1,DA1,0))
    130         .. S DSUP=+$P(TEMP,U,10)
    131         .. S RDATE=+$P(TEMP,U,18)
    132         .. I RDATE>0 S NE=NE+1
    133         .;Process the partial fill multiple.
    134         . S DA1=0
    135         . F  S DA1=+$O(^PSRX(DA,"P",DA1)) Q:DA1=0  D
    136         .. S TEMP=$G(^PSRX(DA,"P",DA1,0))
    137         .. S DSUP=+$P(TEMP,U,10)
    138         .. S RDATE=+$P(TEMP,U,19)
    139         .. I RDATE>0 S NE=NE+1
    140         Q NE
    141         ;
    142         ;===============================================================
    143 NEPTF() ;Return number of entries in PTF.
    144         N D1,DA,DATE,DFN,ICD0,ICD9,JND,NE0,NE9,TEMP70,TEMP0,TEMPP,TEMPS
    145         ;DBIA #4177
    146         S (DA,NE0,NE9)=0
    147         F  S DA=+$O(^DGPT(DA)) Q:DA=0  D
    148         . S TEMP0=$G(^DGPT(DA,0))
    149         . S DFN=$P(TEMP0,U,1)
    150         . I DFN="" Q
    151         . S D1=0
    152         . F  S D1=+$O(^DGPT(DA,"S",D1)) Q:D1=0  D
    153         .. S TEMPS=$G(^DGPT(DA,"S",D1,0))
    154         .. S DATE=$P(TEMPS,U,1)
    155         .. I DATE="" Q
    156         .. F JND=8,9,10,11,12 D
    157         ... S ICD0=$P(TEMPS,U,JND)
    158         ... I (ICD0'=""),$D(^ICD0(ICD0)) S NE0=NE0+1
    159         .;
    160         . S D1=0
    161         . F  S D1=+$O(^DGPT(DA,"P",D1)) Q:D1=0  D
    162         .. S TEMPP=$G(^DGPT(DA,"P",D1,0))
    163         .. S DATE=$P(TEMPP,U,1)
    164         .. I DATE="" Q
    165         .. F JND=5,6,7,8,9 D
    166         ... S ICD0=$P(TEMPP,U,JND)
    167         ... I (ICD0'=""),$D(^ICD0(ICD0)) S NE0=NE0+1
    168         .;
    169         .;Discharge ICD9 codes
    170         . I $D(^DGPT(DA,70)) D
    171         .. S TEMP70=$G(^DGPT(DA,70))
    172         .. F JND=10,11,16,17,18,19,20,21,22,23,24 D
    173         ... S ICD9=$P(TEMP70,U,JND)
    174         ... I (ICD9'=""),$D(^ICD9(ICD9)) S NE9=NE9+1
    175         .;
    176         .;Movement ICD9 codes
    177         . I '$D(^DGPT(DA,"M")) Q
    178         . S D1=0
    179         . F  S D1=$O(^DGPT(DA,"M",D1)) Q:+D1=0  D
    180         .. S TEMPS=$G(^DGPT(DA,"M",D1,0))
    181         .. S DATE=$P(TEMPS,U,10)
    182         .. I DATE="" Q
    183         .. F JND=5,6,7,8,9,11,12,13,14,15 D
    184         ... S ICD9=$P(TEMPS,U,JND)
    185         ... I (ICD9'=""),$D(^ICD9(ICD9)) S NE9=NE9+1
    186         Q NE0+NE9
    187         ;
    188         ;===============================================================
    189 NERAD() ;Return number of entries in RAD/NUC MED PATIENT.
    190         N IEN,NE
    191         ;DBIA #4183
    192         S (IEN,NE)=0
    193         F  S IEN=$O(^RADPT(IEN)) Q:+IEN=0  S NE=NE+$P($G(^RADPT(IEN,"DT",0)),U,4)
    194         Q NE
    195         ;
    196         ;===============================================================
    197 NEVCPT()        ;Return number of entries in V CPT.
    198         ;DBIA #4176
    199         Q $P(^AUPNVCPT(0),U,4)
    200         ;
    201         ;===============================================================
    202 NEVHF() ;Return number of entries in V HEALTH FACTORS.
    203         ;DBIA #4176
    204         Q $P(^AUPNVHF(0),U,4)
    205         ;
    206         ;===============================================================
    207 NEVIMM()        ;Return number of entries in V IMMUNIZATION
    208         ;DBIA #4176
    209         Q $P(^AUPNVIMM(0),U,4)
    210         ;
    211         ;===============================================================
    212 NEVIT() ;Return number of entries in GMRV VITAL MEASUREMENT
    213         ;DBIA #4178
    214         Q $P(^GMR(120.5,0),U,4)
    215         ;
    216         ;===============================================================
    217 NEVPED()        ;Return number of entries in V PATIENT ED.
    218         ;DBIA #4176
    219         Q $P(^AUPNVPED(0),U,4)
    220         ;
    221         ;===============================================================
    222 NEVPOV()        ;Return number of entries in V POV.
    223         ;DBIA #4176
    224         Q $P(^AUPNVPOV(0),U,4)
    225         ;
    226         ;===============================================================
    227 NEVSK() ;Return number of entries in V SKIN TEST.
    228         ;DBIA #4176
    229         Q $P(^AUPNVSK(0),U,4)
    230         ;
    231         ;===============================================================
    232 NEVXAM()        ;Return number of entries in V EXAM.
    233         ;DBIA #4176
    234         Q $P(^AUPNVXAM(0),U,4)
    235         ;
    236         ;===============================================================
    237 NEYTD() ;Return number of entries in PSYCH INSTRUMENT PATIENT
    238         N DATE,DFN,NE,TEST
    239         ;DBIA #4184
    240         S (DFN,NE)=0
    241         F  S DFN=$O(^YTD(601.2,DFN)) Q:+DFN=0  D
    242         . S TEST=0
    243         . F  S TEST=$O(^YTD(601.2,DFN,1,TEST)) Q:+TEST=0  D
    244         .. S DATE=0
    245         .. F  S DATE=$O(^YTD(601.2,DFN,1,TEST,1,DATE)) Q:+DATE=0  S NE=NE+1
    246         Q NE
    247         ;
    248         ;===============================================================
    249 SETDATA(GBL,GLIST,NUMGBL,RTN,SF)        ;
    250         S NUMGBL=16
    251         S GLIST(1)="LABORATORY TEST (CH, Anatomic Path, Micro)",GBL(1)=63
    252         S GLIST(2)="MENTAL HEALTH",GBL(2)=601.2
    253         S GLIST(3)="ORDER",GBL(3)=100
    254         S GLIST(4)="PTF",GBL(4)=45
    255         S GLIST(5)="PHARMACY PATIENT",GBL(5)=55
    256         S GLIST(6)="PRESCRIPTION",GBL(6)=52
    257         S GLIST(7)="PROBLEM LIST",GBL(7)=9000011
    258         S GLIST(8)="RADIOLOGY",GBL(8)=70
    259         S GLIST(9)="V CPT",GBL(9)=9000010.18
    260         S GLIST(10)="V EXAM",GBL(10)=9000010.13
    261         S GLIST(11)="V HEALTH FACTORS",GBL(11)=9000010.23
    262         S GLIST(12)="V IMMUNIZATION",GBL(12)=9000010.11
    263         S GLIST(13)="V PATIENT ED",GBL(13)=9000010.16
    264         S GLIST(14)="V POV",GBL(14)=9000010.07
    265         S GLIST(15)="V SKIN TEST",GBL(15)=9000010.12
    266         S GLIST(16)="VITAL MEASUREMENT",GBL(16)=120.5
    267         S RTN(45)="NEPTF^PXRMISE"
    268         S RTN(52)="NEPSRX^PXRMISE"
    269         S RTN(55)="NEPS^PXRMISE"
    270         S RTN(63)="NELR^PXRMLABS"
    271         S RTN(70)="NERAD^PXRMISE"
    272         S RTN(100)="NEOR^PXRMISE"
    273         S RTN(120.5)="NEVIT^PXRMISE"
    274         S RTN(601.2)="NEYTD^PXRMISE"
    275         S RTN(9000011)="NEPROB^PXRMISE"
    276         S RTN(9000010.07)="NEVPOV^PXRMISE"
    277         S RTN(9000010.11)="NEVIMM^PXRMISE"
    278         S RTN(9000010.12)="NEVSK^PXRMISE"
    279         S RTN(9000010.13)="NEVXAM^PXRMISE"
    280         S RTN(9000010.16)="NEVPED^PXRMISE"
    281         S RTN(9000010.18)="NEVCPT^PXRMISE"
    282         S RTN(9000010.23)="NEVHF^PXRMISE"
    283         D LSF^PXRMISF(.SF)
    284         Q
    285         ;
     1PXRMISE ; SLC/PKR - Index size estimating routines. ;01/12/2005
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;========================================================
     5EST ;Driver for making index counts.
     6 N BLOCKS,FUNCTION,GBL,GLIST,IND,NE,NL,NUMGBL,RTN
     7 N SF,TASKIT,TBLOCKS,XMSUB
     8 D SETDATA(.GBL,.GLIST,.NUMGBL,.RTN,.SF)
     9 I +SF=-1 D ERRORMSG^PXRMISF(SF)  Q
     10 S (NL,TBLOCKS)=0
     11 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Start time "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     12 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
     13 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Size Estimate for ^PXRMINDX"
     14 F IND=1:1:NUMGBL D
     15 . S FUNCTION="S NE=$$"_RTN(GBL(IND))
     16 . X FUNCTION
     17 . S BLOCKS=NE*SF(GBL(IND))
     18 . S BLOCKS=$FN(BLOCKS,"","")+1
     19 . S TBLOCKS=TBLOCKS+BLOCKS
     20 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
     21 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Estimates for "_GLIST(IND)
     22 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" Number of entries: "_NE
     23 . S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" Number of blocks: "_BLOCKS
     24 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
     25 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="Total estimated blocks: "_TBLOCKS
     26 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=""
     27 S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="End time "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     28 S XMSUB="Size estimate for index global"
     29 D SEND^PXRMMSG(XMSUB)
     30 S ZTREQ="@"
     31 Q
     32 ;
     33 ;===============================================================
     34ESTTASK ;Task the index size estimation.
     35 N DIR,DTOUT,DUOUT,MINDT,SDTIME,X,Y
     36 S MINDT=$$NOW^XLFDT
     37 W !,"Queue the Clinical Reminders index size estimation."
     38 S DIR("A",1)="Enter the date and time you want the job to start."
     39 S DIR("A")="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")_" "
     40 S DIR(0)="DAU"_U_MINDT_"::RSX"
     41 D ^DIR
     42 I $D(DTOUT)!$D(DUOUT) Q
     43 S SDTIME=Y
     44 K DIR
     45 ;Put the task into the queue.
     46 S ZTRTN="EST^PXRMISE"
     47 S ZTDESC="Clinical Reminders index size estimation"
     48 S ZTDTH=SDTIME
     49 S ZTIO=""
     50 D ^%ZTLOAD
     51 W !,"Task number ",ZTSK," queued."
     52 Q
     53 ;
     54 ;===============================================================
     55NEOR() ;Return number of entries in OR.
     56 ;DBIA #4180
     57 Q $P(^OR(100,0),U,4)
     58 ;
     59 ;===============================================================
     60NEPROB() ;Return number of entries in PROBLEM LIST.
     61 ;DBIA #3837
     62 Q $P(^AUPNPROB(0),U,4)
     63 ;
     64 ;===============================================================
     65NEPS() ;Return number of entries in PS(55).
     66 N ADD,DA,DA1,DFN,DRUG,IND,NE,SDATE,SOL,STARTD,TEMP
     67 ;DBIA #4181
     68 S (DFN,IND,NE)=0
     69 F  S DFN=+$O(^PS(55,DFN)) Q:DFN=0  D
     70 .;Process Unit Dose.
     71 . S DA=0
     72 . F  S DA=+$O(^PS(55,DFN,5,DA)) Q:DA=0  D
     73 .. S TEMP=$G(^PS(55,DFN,5,DA,2))
     74 .. S STARTD=$P(TEMP,U,2)
     75 .. I STARTD="" Q
     76 ..;If the order is purged then SDATE is 1.
     77 .. S SDATE=$P(TEMP,U,4)
     78 .. I SDATE=1 Q
     79 .. S DA1=0
     80 .. F  S DA1=+$O(^PS(55,DFN,5,DA,1,DA1)) Q:DA1=0  D
     81 ... S DRUG=$P(^PS(55,DFN,5,DA,1,DA1,0),U,1)
     82 ... I DRUG="" Q
     83 ... S NE=NE+1
     84 .;Process the IV mutiple.
     85 . S DA=0
     86 . F  S DA=+$O(^PS(55,DFN,"IV",DA)) Q:DA=0  D
     87 .. S TEMP=$G(^PS(55,DFN,"IV",DA,0))
     88 .. S STARTD=$P(TEMP,U,2)
     89 .. I STARTD="" Q
     90 .. S SDATE=$P(TEMP,U,3)
     91 .. I SDATE=1 Q
     92 ..;Process Additives
     93 .. S DA1=0
     94 .. F  S DA1=+$O(^PS(55,DFN,"IV",DA,"AD",DA1)) Q:DA1=0  D
     95 ... S ADD=$P(^PS(55,DFN,"IV",DA,"AD",DA1,0),U,1)
     96 ... I ADD="" Q
     97 ... S DRUG=$P($G(^PS(52.6,ADD,0)),U,2)
     98 ... I DRUG="" Q
     99 ... S NE=NE+1
     100 ..;Process Solutions
     101 .. S DA1=0
     102 .. F  S DA1=+$O(^PS(55,DFN,"IV",DA,"SOL",DA1)) Q:DA1=0  D
     103 ... S SOL=$P(^PS(55,DFN,"IV",DA,"SOL",DA1,0),U,1)
     104 ... I SOL="" Q
     105 ... S DRUG=$P($G(^PS(52.7,SOL,0)),U,2)
     106 ... I DRUG="" Q
     107 ... S NE=NE+1
     108 Q NE
     109 ;
     110 ;===============================================================
     111NEPSRX() ;Return number of entries in PSRX
     112 N DA,DA1,DATE,DSUP,DFN,DRUG,NE,RDATE,TEMP
     113 ;DBIA #4182
     114 S (DA,NE)=0
     115 F  S DA=+$O(^PSRX(DA)) Q:DA=0  D
     116 . S TEMP=$G(^PSRX(DA,0))
     117 . S DFN=$P(TEMP,U,2)
     118 . I DFN="" Q
     119 . S DRUG=$P(TEMP,U,6)
     120 . I DRUG="" Q
     121 . S DSUP=$P(TEMP,U,8)
     122 . I DSUP="" Q
     123 . S RDATE=+$P($G(^PSRX(DA,2)),U,13)
     124 . I RDATE>0 S NE=NE+1
     125 .;Process the refill mutiple.
     126 . S DA1=0
     127 . F  S DA1=+$O(^PSRX(DA,1,DA1)) Q:DA1=0  D
     128 .. S TEMP=$G(^PSRX(DA,1,DA1,0))
     129 .. S DSUP=+$P(TEMP,U,10)
     130 .. S RDATE=+$P(TEMP,U,18)
     131 .. I RDATE>0 S NE=NE+1
     132 .;Process the partial fill multiple.
     133 . S DA1=0
     134 . F  S DA1=+$O(^PSRX(DA,"P",DA1)) Q:DA1=0  D
     135 .. S TEMP=$G(^PSRX(DA,"P",DA1,0))
     136 .. S DSUP=+$P(TEMP,U,10)
     137 .. S RDATE=+$P(TEMP,U,19)
     138 .. I RDATE>0 S NE=NE+1
     139 Q NE
     140 ;
     141 ;===============================================================
     142NEPTF() ;Return number of entries in PTF.
     143 N D1,DA,DATE,DFN,ICD0,ICD9,JND,NE0,NE9,TEMP70,TEMP0,TEMPP,TEMPS
     144 ;DBIA #4177
     145 S (DA,NE0,NE9)=0
     146 F  S DA=+$O(^DGPT(DA)) Q:DA=0  D
     147 . S TEMP0=$G(^DGPT(DA,0))
     148 . S DFN=$P(TEMP0,U,1)
     149 . I DFN="" Q
     150 . S D1=0
     151 . F  S D1=+$O(^DGPT(DA,"S",D1)) Q:D1=0  D
     152 .. S TEMPS=$G(^DGPT(DA,"S",D1,0))
     153 .. S DATE=$P(TEMPS,U,1)
     154 .. I DATE="" Q
     155 .. F JND=8,9,10,11,12 D
     156 ... S ICD0=$P(TEMPS,U,JND)
     157 ... I (ICD0'=""),$D(^ICD0(ICD0)) S NE0=NE0+1
     158 .;
     159 . S D1=0
     160 . F  S D1=+$O(^DGPT(DA,"P",D1)) Q:D1=0  D
     161 .. S TEMPP=$G(^DGPT(DA,"P",D1,0))
     162 .. S DATE=$P(TEMPP,U,1)
     163 .. I DATE="" Q
     164 .. F JND=5,6,7,8,9 D
     165 ... S ICD0=$P(TEMPP,U,JND)
     166 ... I (ICD0'=""),$D(^ICD0(ICD0)) S NE0=NE0+1
     167 .;
     168 .;Discharge ICD9 codes
     169 . I $D(^DGPT(DA,70)) D
     170 .. S TEMP70=$G(^DGPT(DA,70))
     171 .. F JND=10,11,16,17,18,19,20,21,22,23,24 D
     172 ... S ICD9=$P(TEMP70,U,JND)
     173 ... I (ICD9'=""),$D(^ICD9(ICD9)) S NE9=NE9+1
     174 .;
     175 .;Movement ICD9 codes
     176 . I '$D(^DGPT(DA,"M")) Q
     177 . S D1=0
     178 . F  S D1=$O(^DGPT(DA,"M",D1)) Q:+D1=0  D
     179 .. S TEMPS=$G(^DGPT(DA,"M",D1,0))
     180 .. S DATE=$P(TEMPS,U,10)
     181 .. I DATE="" Q
     182 .. F JND=5,6,7,8,9,11,12,13,14,15 D
     183 ... S ICD9=$P(TEMPS,U,JND)
     184 ... I (ICD9'=""),$D(^ICD9(ICD9)) S NE9=NE9+1
     185 Q NE0+NE9
     186 ;
     187 ;===============================================================
     188NERAD() ;Return number of entries in RAD/NUC MED PATIENT.
     189 N IEN,NE
     190 ;DBIA #4183
     191 S (IEN,NE)=0
     192 F  S IEN=$O(^RADPT(IEN)) Q:+IEN=0  S NE=NE+$P($G(^RADPT(IEN,"DT",0)),U,4)
     193 Q NE
     194 ;
     195 ;===============================================================
     196NEVCPT() ;Return number of entries in V CPT.
     197 ;DBIA #4176
     198 Q $P(^AUPNVCPT(0),U,4)
     199 ;
     200 ;===============================================================
     201NEVHF() ;Return number of entries in V HEALTH FACTORS.
     202 ;DBIA #4176
     203 Q $P(^AUPNVHF(0),U,4)
     204 ;
     205 ;===============================================================
     206NEVIMM() ;Return number of entries in V IMMUNIZATION
     207 ;DBIA #4176
     208 Q $P(^AUPNVIMM(0),U,4)
     209 ;
     210 ;===============================================================
     211NEVIT() ;Return number of entries in GMRV VITAL MEASUREMENT
     212 ;DBIA #4178
     213 Q $P(^GMR(120.5,0),U,4)
     214 ;
     215 ;===============================================================
     216NEVPED() ;Return number of entries in V PATIENT ED.
     217 ;DBIA #4176
     218 Q $P(^AUPNVPED(0),U,4)
     219 ;
     220 ;===============================================================
     221NEVPOV() ;Return number of entries in V POV.
     222 ;DBIA #4176
     223 Q $P(^AUPNVPOV(0),U,4)
     224 ;
     225 ;===============================================================
     226NEVSK() ;Return number of entries in V SKIN TEST.
     227 ;DBIA #4176
     228 Q $P(^AUPNVSK(0),U,4)
     229 ;
     230 ;===============================================================
     231NEVXAM() ;Return number of entries in V EXAM.
     232 ;DBIA #4176
     233 Q $P(^AUPNVXAM(0),U,4)
     234 ;
     235 ;===============================================================
     236NEYTD() ;Return number of entries in PSYCH INSTRUMENT PATIENT
     237 N DATE,DFN,NE,TEST
     238 ;DBIA #4184
     239 S (DFN,NE)=0
     240 F  S DFN=$O(^YTD(601.2,DFN)) Q:+DFN=0  D
     241 . S TEST=0
     242 . F  S TEST=$O(^YTD(601.2,DFN,1,TEST)) Q:+TEST=0  D
     243 .. S DATE=0
     244 .. F  S DATE=$O(^YTD(601.2,DFN,1,TEST,1,DATE)) Q:+DATE=0  S NE=NE+1
     245 Q NE
     246 ;
     247 ;===============================================================
     248SETDATA(GBL,GLIST,NUMGBL,RTN,SF) ;
     249 S NUMGBL=16
     250 S GLIST(1)="LABORATORY TEST (CH, Anatomic Path, Micro)",GBL(1)=63
     251 S GLIST(2)="MENTAL HEALTH",GBL(2)=601.2
     252 S GLIST(3)="ORDER",GBL(3)=100
     253 S GLIST(4)="PTF",GBL(4)=45
     254 S GLIST(5)="PHARMACY PATIENT",GBL(5)=55
     255 S GLIST(6)="PRESCRIPTION",GBL(6)=52
     256 S GLIST(7)="PROBLEM LIST",GBL(7)=9000011
     257 S GLIST(8)="RADIOLOGY",GBL(8)=70
     258 S GLIST(9)="V CPT",GBL(9)=9000010.18
     259 S GLIST(10)="V EXAM",GBL(10)=9000010.13
     260 S GLIST(11)="V HEALTH FACTORS",GBL(11)=9000010.23
     261 S GLIST(12)="V IMMUNIZATION",GBL(12)=9000010.11
     262 S GLIST(13)="V PATIENT ED",GBL(13)=9000010.16
     263 S GLIST(14)="V POV",GBL(14)=9000010.07
     264 S GLIST(15)="V SKIN TEST",GBL(15)=9000010.12
     265 S GLIST(16)="VITAL MEASUREMENT",GBL(16)=120.5
     266 S RTN(45)="NEPTF^PXRMISE"
     267 S RTN(52)="NEPSRX^PXRMISE"
     268 S RTN(55)="NEPS^PXRMISE"
     269 S RTN(63)="NELR^PXRMLABS"
     270 S RTN(70)="NERAD^PXRMISE"
     271 S RTN(100)="NEOR^PXRMISE"
     272 S RTN(120.5)="NEVIT^PXRMISE"
     273 S RTN(601.2)="NEYTD^PXRMISE"
     274 S RTN(9000011)="NEPROB^PXRMISE"
     275 S RTN(9000010.07)="NEVPOV^PXRMISE"
     276 S RTN(9000010.11)="NEVIMM^PXRMISE"
     277 S RTN(9000010.12)="NEVSK^PXRMISE"
     278 S RTN(9000010.13)="NEVXAM^PXRMISE"
     279 S RTN(9000010.16)="NEVPED^PXRMISE"
     280 S RTN(9000010.18)="NEVCPT^PXRMISE"
     281 S RTN(9000010.23)="NEVHF^PXRMISE"
     282 D LSF^PXRMISF(.SF)
     283 Q
     284 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLCD.m

    r613 r623  
    1 PXRMLCD ; SLC/PKR - Reminder Patient List Patients ;11/02/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Display list creation documentation.
    5         ;===========================================================
    6 DCDOC   ;Display creation documentation.
    7         N IND,LISTIEN,VALMY
    8         D EN^VALM2(XQORNOD(0))
    9         ;If there is no list quit.
    10         I '$D(VALMY) Q
    11         ;PXRMDONE is newed in PXRMLPU
    12         S IND="",PXRMDONE=0
    13         F  S IND=$O(VALMY(IND)) Q:(IND="")!(PXRMDONE)  D
    14         . S LISTIEN=^TMP("PXRMLPU",$J,"SEL",IND)
    15         . D EN^PXRMLCD(LISTIEN)
    16         S VALMBCK="R"
    17         Q
    18         ;
    19         ;===========================================================
    20 EN(LISTIEN)     ;
    21         N VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    22         K ^TMP("PXRMLCD",$J)
    23         I $D(^PXRMXP(810.5,LISTIEN,200)) D
    24         . M ^TMP("PXRMLCD",$J)=^PXRMXP(810.5,LISTIEN,200)
    25         . S VALMCNT=$P(^PXRMXP(810.5,LISTIEN,200,0),U,4)
    26         I '$D(^PXRMXP(810.5,LISTIEN,200)) D
    27         . S ^TMP("PXRMLCD",$J,1,0)="No documentation is available."
    28         . S VALMCNT=1
    29         D EN^VALM("PXRM PATIENT LIST CREATION DOC")
    30         Q
    31         ;
    32         ;===========================================================
    33 EXIT    ;Exit code
    34         K ^TMP("PXRMLCD",$J)
    35         D CLEAN^VALM10
    36         D FULL^VALM1
    37         S VALMBCK="R"
    38         Q
    39         ;
    40         ;===========================================================
    41 HDR     ; Header code
    42         S VALMHDR(1)="Documentation for creation of patient list:"
    43         S VALMHDR(2)=" "_$P(^PXRMXP(810.5,LISTIEN,0),U,1)
    44         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    45         Q
    46         ;
    47         ;===========================================================
    48 HELP    ;Help code
    49         S X="?" D DISP^XQORM1 W !!
    50         Q
    51         ;
     1PXRMLCD ; SLC/PKR - Reminder Patient List Patients ;06/30/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Display list creation documentation.
     5 ;===========================================================
     6DCDOC ;Display creation documentation.
     7 N IND,LISTIEN,VALMY
     8 D EN^VALM2(XQORNOD(0))
     9 ;If there is no list quit.
     10 I '$D(VALMY) Q
     11 ;PXRMDONE is newed in PXRMLPU
     12 S IND="",PXRMDONE=0
     13 F  S IND=$O(VALMY(IND)) Q:(IND="")!(PXRMDONE)  D
     14 . S LISTIEN=^TMP("PXRMLPU",$J,"IDX",IND,IND)
     15 . D EN^PXRMLCD(LISTIEN)
     16 S VALMBCK="R"
     17 Q
     18 ;
     19 ;===========================================================
     20EN(LISTIEN) ;
     21 N VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     22 K ^TMP("PXRMLCD",$J)
     23 I $D(^PXRMXP(810.5,LISTIEN,200)) D
     24 . M ^TMP("PXRMLCD",$J)=^PXRMXP(810.5,LISTIEN,200)
     25 . S VALMCNT=$P(^PXRMXP(810.5,LISTIEN,200,0),U,4)
     26 I '$D(^PXRMXP(810.5,LISTIEN,200)) D
     27 . S ^TMP("PXRMLCD",$J,1,0)="No documentation is available."
     28 . S VALMCNT=1
     29 D EN^VALM("PXRM PATIENT LIST CREATION DOC")
     30 Q
     31 ;
     32 ;===========================================================
     33EXIT ;Exit code
     34 K ^TMP("PXRMLCD",$J)
     35 D CLEAN^VALM10
     36 D FULL^VALM1
     37 S VALMBCK="R"
     38 Q
     39 ;
     40 ;===========================================================
     41HDR ; Header code
     42 S VALMHDR(1)="Documentation for creation of patient list "_$P(^PXRMXP(810.5,LISTIEN,0),U,1)
     43 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     44 Q
     45 ;
     46 ;===========================================================
     47HELP ;Help code
     48 S X="?" D DISP^XQORM1 W !!
     49 Q
     50 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLCR.m

    r613 r623  
    1 PXRMLCR ; SLC/PJH - Create Patient List from individual finding rule; 10/18/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRM PATIENT LIST CREATE protocol
    5         ;
    6 START   N BEG,DUOUT,DTOUT,END,LIT,PXRMDPAT,PXRMLIST,PXRMNODE,PXRMRULE,PXRMTPAT
    7         N TEXT
    8         ;Initialise
    9         K ^TMP("PXRMLCR",$J)
    10         ;Node for ^TMP lists created in PXRMRULE
    11         S PXRMNODE="PXRMRULE",LIT="Patient List"
    12         ;Reset screen mode
    13         W IORESET
    14         ;Set prompt text
    15         S TEXT="Select PATIENT LIST name: "
    16         ;Select Patient List
    17 LIST    D PLIST(.PXRMLIST,TEXT,"") I $D(DUOUT)!$D(DTOUT) D  Q
    18         . I $G(PXRMLIST)="" Q
    19         . I $P($G(^PXRMXP(810.5,PXRMLIST,0)),U,4)'="" Q
    20         . S DA=PXRMLIST,DIK="^PXRMXP(810.5," D ^DIK
    21         ;
    22 SECURE  ;option to secure the list
    23         K PATCREAT
    24         I $D(PATCREAT)=0 S PATCREAT="N" D ASK^PXRMXD(.PATCREAT,"Secure list?: ",2) Q:$D(DTOUT)  G:$D(DUOUT) START
    25         ;
    26 PURGE   ;Option to purge the list
    27         K PLISTPUG
    28         S PLISTPUG="N" D ASK^PXRMXD(.PLISTPUG,"Purge Patient List after 5 years?: ",5) Q:$D(DTOUT)  G:$D(DUOUT) SECURE
    29         ;Select rule set.
    30 RULE    D LRULE(.PXRMRULE) Q:$D(DTOUT)  G:$D(DUOUT) LIST
    31         ;Select Date Range
    32 DATE    D DATES^PXRMEUT(.BEG,.END,LIT) Q:$D(DTOUT)  G:$D(DUOUT) RULE
    33         ;
    34         ;Ask whether to include deceased and test patients.
    35 DPAT    S PXRMDPAT=$$ASKYN^PXRMEUT("N","Include deceased patients on the list")
    36         Q:$D(DTOUT)  G:$D(DUOUT) DATE
    37 TPAT    S PXRMTPAT=$$ASKYN^PXRMEUT("N","Include test patients on the list")
    38         Q:$D(DTOUT)  G:$D(DUOUT) DPAT
    39         I $G(PXRMDEBG) D RUN^PXRMLCR(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,PXRMDPAT,PXRMTPAT) Q
    40         ;Build patient list in background
    41         N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
    42         S ZTDESC="CREATE PATIENT LIST"
    43         S ZTRTN="RUN^PXRMLCR(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,PXRMDPAT,PXRMTPAT)"
    44         S ZTSAVE("BEG")=""
    45         S ZTSAVE("END")=""
    46         S ZTSAVE("PATCREAT")=""
    47         S ZTSAVE("PXRMDPAT")=""
    48         S ZTSAVE("PXRMLIST")=""
    49         S ZTSAVE("PXRMNODE")=""
    50         S ZTSAVE("PXRMRULE")=""
    51         S ZTSAVE("PXRMTPAT")=""
    52         S ZTSAVE("PLISTPUG")=""
    53         S ZTIO=""
    54         ;
    55         ;Select and verify start date/time for task
    56         N DIR,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
    57         S MINDT=$$NOW^XLFDT
    58         W !,"Queue the "_ZTDESC_" for "_$P($G(^PXRMXP(810.5,PXRMLIST,0)),U)_": "
    59         S DIR("A",1)="Enter the date and time you want the job to start."
    60         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    61         S DIR("A")="Start the task at: "
    62         S DIR(0)="DAU"_U_MINDT_"::RSX"
    63         D ^DIR
    64         I $D(DTOUT)!$D(DUOUT) Q
    65         S SDTIME=Y
    66         ;
    67         ;Put the task into the queue.
    68         S ZTDTH=SDTIME
    69         D ^%ZTLOAD
    70         W !,"Task number ",ZTSK," queued." H 2
    71 EXIT    Q
    72         ;
    73 HELP(CALL)      ;General help text routine
    74         N HTEXT
    75         I CALL=1 D
    76         .S HTEXT(1)="Enter 'Y' to overwrite this existing list. Enter 'N' to"
    77         .S HTEXT(2)="use a different patient list name."
    78         ;
    79         I CALL=2 D
    80         .S HTEXT(1)="Enter 'Y' to make the list private or 'N' to make it public."
    81         .S HTEXT(2)="You can give other users access to your private lists in the Patient List Menu screens."
    82         ;
    83         I CALL=3 D
    84         .S HTEXT(1)="Enter Y to save the patient to a Reminder Patient List. Enter N to not save the output."
    85         ;
    86         I CALL=4 D
    87         .S HTEXT(1)="Enter Y to turn on debug output."
    88         .S HTEXT(2)="The debug output will send a series of MailMan messages to the requestor of the report"
    89         .S HTEXT(3)="-**WARNING**- the reminder report will take longer to run if you turn on this option!"
    90         D HELP^PXRMEUT(.HTEXT)
    91         Q
    92         ;
    93 PLIST(LIST,TEXT,IENO)   ;Select Patient List
    94         N X,Y,DIC,DLAYGO
    95 PL1     S DIC=810.5,DLAYGO=DIC,DIC(0)="QAEMZL"
    96         S DIC("A")=TEXT
    97         S DIC("S")="I $P($G(^(100)),U)'=""N"""
    98         ;If this is a new entry save the creator, make the TYPE public and
    99         ;CLASS local.
    100         S DIC("DR")=".07///`"_DUZ_";.08///PUB;100///L"
    101         W !
    102         D ^DIC
    103         I X="" W !,"A patient list name must be entered" G PL1
    104         I X=(U_U) S DTOUT=1
    105         I Y=-1 S DUOUT=1
    106         I $D(DTOUT)!$D(DUOUT) Q
    107         ;
    108         ;I copy mode dissallow copy to same list
    109         I IENO=$P(Y,U) W !,"A patient list cannot be copied to itself." G PL1
    110         ;
    111         I ($P(Y,U,3)=1) S LIST=$P(Y,U) Q
    112         ;Check if OK to overwrite
    113         N OWRITE
    114         S OWRITE=$$ASKYN^PXRMEUT("N","Okay to overwite "_$P(Y,U,2),"PXRMLCR",1)
    115         Q:$D(DTOUT)  G:$D(DUOUT)!('OWRITE) PL1
    116         S OWRITE=$$LDELOK^PXRMEUT($P(Y,U,1))
    117         I 'OWRITE D  G PL1
    118         . W !,"In order to overwrite a list you must be the creator or a Reminder Manager!"
    119         ;Return list ien
    120         S LIST=$P(Y,U)
    121         Q
    122         ;
    123 LRULE(RULE)     ;Select List Rule
    124         N X,Y,DIC
    125 LR1     S DIC=810.4,DIC(0)="QAEMZ"
    126         S DIC("A")="Select LIST RULE SET: "
    127         ;Only allow rule sets with components
    128         S DIC("S")="I $P(^(0),U,3)=3"
    129         W !
    130         D ^DIC
    131         I X="" W !,"A list rule set name must be entered" G LR1
    132         I X=(U_U) S DTOUT=1
    133         I Y=-1 S DUOUT=1
    134         I $D(DTOUT)!$D(DUOUT) Q
    135         ;Return rule ien
    136         S RULE=$P(Y,U)
    137         ;Check that rule set is valid
    138         N ERROR,LR,LRTYPE,NL,OP,SEQ,SUB,TEMP,TEXT
    139         S SUB=$O(^PXRM(810.4,RULE,30,0))
    140         I SUB="" W !,"Rule set has no component rules" G LR1
    141         S (ERROR,SUB)=0,NL=1
    142         F  S SUB=$O(^PXRM(810.4,RULE,30,SUB)) Q:'SUB  D  Q:ERROR
    143         .S TEMP=$G(^PXRM(810.4,RULE,30,SUB,0))
    144         .S SEQ=$P(TEMP,U,1),LR=$P(TEMP,U,2),OP=$P(TEMP,U,3)
    145         .I SEQ="" S NL=NL+1,TEXT(NL)=" Sequence is missing.",ERROR=1
    146         .I LR="" S NL=NL+1,TEXT(NL)=" List rule is missing.",ERROR=1
    147         .I OP="" S NL=NL+1,TEXT(NL)=" Operation is missing.",ERROR=1
    148         .;The Insert operation can only be used with finding rules.
    149         .I OP="F",LR'="" D
    150         ..S LRTYPE=$P(^PXRM(810.4,LR,0),U,3)
    151         ..I LRTYPE'=1 S NL=NL+1,TEXT(NL)=" Insert operation can only be used with finding rules.",ERROR=1
    152         I ERROR D  G LR1
    153         .S TEXT(1)="The rule set is incomplete or incorrect:"
    154         .D EN^DDIOL(.TEXT)
    155         Q
    156         ;
    157         ;Build list and clear ^TMP files
    158 RUN(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,PXRMDPAT,PXRMTPAT)       ;
    159         ;Process rule set and update final patient list
    160         D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,"","","",PXRMDPAT,PXRMTPAT,"")
    161         ;Clear ^TMP lists created for rule
    162         D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
    163         Q
    164         ;
    165 REMOVE(IEN)     ;
    166         S $P(^PXRM(810.4,IEN,0),U,10)=""
    167         Q "@1"
    168         ;
     1PXRMLCR ; SLC/PJH - Create Patient List from individual finding rule; 08/03/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRM PATIENT LIST CREATE protocol
     5 ;
     6START N BEG,DUOUT,DTOUT,END,LIT,PXRMDPAT,PXRMLIST,PXRMNODE,PXRMRULE,PXRMTPAT
     7 N TEXT
     8 ;Initialise
     9 K ^TMP("PXRMLCR",$J)
     10 ;Node for ^TMP lists created in PXRMRULE
     11 S PXRMNODE="PXRMRULE",LIT="Patient List"
     12 ;Reset screen mode
     13 W IORESET
     14 ;Set prompt text
     15 S TEXT="Select PATIENT LIST name: "
     16 ;Select Patient List
     17LIST D PLIST(.PXRMLIST,TEXT,"") I $D(DUOUT)!$D(DTOUT) D  Q
     18 . I $G(PXRMLIST)="" Q
     19 . I $P($G(^PXRMXP(810.5,PXRMLIST,0)),U,4)'="" Q
     20 . S DA=PXRMLIST,DIK="^PXRMXP(810.5," D ^DIK
     21 ;
     22SECURE ;option to secure the list
     23 K PATCREAT
     24 I $D(PATCREAT)=0 S PATCREAT="N" D ASK^PXRMXD(.PATCREAT,"Secure list?: ",2) Q:$D(DTOUT)  G:$D(DUOUT) START
     25 ;
     26PURGE ;Option to purge the list
     27 K PLISTPUG
     28 S PLISTPUG="N" D ASK^PXRMXD(.PLISTPUG,"Purge Patient List after 5 years?: ",5) Q:$D(DTOUT)  G:$D(DUOUT) SECURE
     29 ;Select rule set.
     30RULE D LRULE(.PXRMRULE) Q:$D(DTOUT)  G:$D(DUOUT) LIST
     31 ;Select Date Range
     32DATE D DATES^PXRMEUT(.BEG,.END,LIT) Q:$D(DTOUT)  G:$D(DUOUT) RULE
     33 ;
     34 ;Ask whether to include deceased and test patients.
     35DPAT S PXRMDPAT=$$ASKYN^PXRMEUT("N","Include deceased patients on the list")
     36 Q:$D(DTOUT)  G:$D(DUOUT) DATE
     37TPAT S PXRMTPAT=$$ASKYN^PXRMEUT("N","Include test patients on the list")
     38 Q:$D(DTOUT)  G:$D(DUOUT) DPAT
     39 ;Build patient list in background
     40 N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
     41 S ZTDESC="CREATE PATIENT LIST"
     42 S ZTRTN="RUN^PXRMLCR(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,PXRMDPAT,PXRMTPAT)"
     43 S ZTSAVE("BEG")=""
     44 S ZTSAVE("END")=""
     45 S ZTSAVE("PATCREAT")=""
     46 S ZTSAVE("PXRMDPAT")=""
     47 S ZTSAVE("PXRMLIST")=""
     48 S ZTSAVE("PXRMNODE")=""
     49 S ZTSAVE("PXRMRULE")=""
     50 S ZTSAVE("PXRMTPAT")=""
     51 S ZTSAVE("PLISTPUG")=""
     52 S ZTIO=""
     53 ;
     54 ;Select and verify start date/time for task
     55 N DIR,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
     56 S MINDT=$$NOW^XLFDT
     57 W !,"Queue the "_ZTDESC_" for "_$P($G(^PXRMXP(810.5,PXRMLIST,0)),U)_": "
     58 S DIR("A",1)="Enter the date and time you want the job to start."
     59 S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
     60 S DIR("A")="Start the task at: "
     61 S DIR(0)="DAU"_U_MINDT_"::RSX"
     62 D ^DIR
     63 I $D(DTOUT)!$D(DUOUT) Q
     64 S SDTIME=Y
     65 ;
     66 ;Put the task into the queue.
     67 S ZTDTH=SDTIME
     68 D ^%ZTLOAD
     69 W !,"Task number ",ZTSK," queued." H 2
     70EXIT Q
     71 ;
     72HELP(CALL) ;General help text routine
     73 N HTEXT
     74 I CALL=1 D
     75 .S HTEXT(1)="Enter 'Y' to overwrite this existing list. Enter 'N' to"
     76 .S HTEXT(2)="use a different patient list name."
     77 ;
     78 I CALL=2 D
     79 .S HTEXT(1)="Enter 'Y' to make the list private or 'N' to make it public."
     80 .S HTEXT(2)="You can give other users access to your private lists in the Patient List Menu screens."
     81 ;
     82 I CALL=3 D
     83 .S HTEXT(1)="Enter Y to save the patient to a Reminder Patient List. Enter N to not save the output."
     84 ;
     85 I CALL=4 D
     86 .S HTEXT(1)="Enter Y to turn on Debug output."
     87 .S HTEXT(2)="The debug output will send a series of mailman message to the requestor of the report"
     88 .S HTEXT(3)="**WARNING** the reminder report will take longer to run if you turn on this option!"
     89 D HELP^PXRMEUT(.HTEXT)
     90 Q
     91 ;
     92PLIST(LIST,TEXT,IENO) ;Select Patient List
     93 N X,Y,DIC,DLAYGO
     94PL1 S DIC=810.5,DLAYGO=DIC,DIC(0)="QAEMZL"
     95 S DIC("A")=TEXT
     96 S DIC("S")="I $P($G(^(100)),U)'=""N"""
     97 S DIC("DR")="100///L"
     98 W !
     99 D ^DIC
     100 I X="" W !,"A patient list name must be entered" G PL1
     101 I X=(U_U) S DTOUT=1
     102 I Y=-1 S DUOUT=1
     103 I $D(DTOUT)!$D(DUOUT) Q
     104 ;
     105 ;I copy mode dissallow copy to same list
     106 I IENO=$P(Y,U) W !,"A patient list cannot be copied to itself." G PL1
     107 ;
     108 I ($P(Y,U,3)=1) S LIST=$P(Y,U) Q
     109 ;Check if OK to overwrite
     110 N OWRITE
     111 S OWRITE=$$ASKYN^PXRMEUT("N","Okay to overwite "_$P(Y,U,2),"PXRMLCR",1)
     112 Q:$D(DTOUT)  G:$D(DUOUT)!('OWRITE) PL1
     113 S OWRITE=$$LDELOK^PXRMEUT($P(Y,U,1))
     114 I 'OWRITE D  G PL1
     115 . W !,"In order to overwrite a list you must be the creator or a Reminder Manager!"
     116 ;Return list ien
     117 S LIST=$P(Y,U)
     118 Q
     119 ;
     120LRULE(RULE) ;Select List Rule
     121 N X,Y,DIC
     122LR1 S DIC=810.4,DIC(0)="QAEMZ"
     123 S DIC("A")="Select LIST RULE SET: "
     124 ;Only allow rule sets with components
     125 S DIC("S")="I $P(^(0),U,3)=3"
     126 W !
     127 D ^DIC
     128 I X="" W !,"A list rule set name must be entered" G LR1
     129 I X=(U_U) S DTOUT=1
     130 I Y=-1 S DUOUT=1
     131 I $D(DTOUT)!$D(DUOUT) Q
     132 ;Return rule ien
     133 S RULE=$P(Y,U)
     134 ;Check that rule set is valid
     135 N ERROR,LR,LRTYPE,NL,OP,SEQ,SUB,TEMP,TEXT
     136 S SUB=$O(^PXRM(810.4,RULE,30,0))
     137 I SUB="" W !,"Rule set has no component rules" G LR1
     138 S (ERROR,SUB)=0,NL=1
     139 F  S SUB=$O(^PXRM(810.4,RULE,30,SUB)) Q:'SUB  D  Q:ERROR
     140 .S TEMP=$G(^PXRM(810.4,RULE,30,SUB,0))
     141 .S SEQ=$P(TEMP,U,1),LR=$P(TEMP,U,2),OP=$P(TEMP,U,3)
     142 .I SEQ="" S NL=NL+1,TEXT(NL)=" Sequence is missing.",ERROR=1
     143 .I LR="" S NL=NL+1,TEXT(NL)=" List rule is missing.",ERROR=1
     144 .I OP="" S NL=NL+1,TEXT(NL)=" Operation is missing.",ERROR=1
     145 .;The Insert operation can only be used with finding rules.
     146 .I OP="F",LR'="" D
     147 ..S LRTYPE=$P(^PXRM(810.4,LR,0),U,3)
     148 ..I LRTYPE'=1 S NL=NL+1,TEXT(NL)=" Insert operation can only be used with finding rules.",ERROR=1
     149 I ERROR D  G LR1
     150 .S TEXT(1)="The rule set is incomplete or incorrect:"
     151 .D EN^DDIOL(.TEXT)
     152 Q
     153 ;
     154 ;Build list and clear ^TMP files
     155RUN(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,PXRMDPAT,PXRMTPAT) ;
     156 ;Process rule set and update final patient list
     157 D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,BEG,END,"","","",PXRMDPAT,PXRMTPAT)
     158 ;Clear ^TMP lists created for rule
     159 D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
     160 Q
     161 ;
     162REMOVE(IEN) ;
     163 S $P(^PXRM(810.4,IEN,0),U,10)=""
     164 Q "@1"
     165 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLIST.m

    r613 r623  
    1 PXRMLIST        ; SLC/PKR/PJH - Clinical Reminders list functions. ;07/17/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;Used in the reminder exchange utility for building lists of
    4         ;reminders, Exchange File entries, etc.
    5         ;=======================================================
    6 FRDEF(NAME,PNAME)       ;Format the reminder name and print name.
    7         N IND,TEMP
    8         S TEMP=$$LJ^XLFSTR(NAME,40," ")
    9         S TEMP=TEMP_PNAME
    10         Q TEMP
    11         ;
    12         ;=======================================================
    13 FMT(NUMBER,NAME,SOURCE,DATE,FMTSTR,NL,OUTPUT)   ;Format  entry number, name,
    14         ;source, and date packed for LM display.
    15         N TEMP,TSOURCE
    16         S TEMP=NUMBER_U_NAME
    17         S TSOURCE=$E($P(SOURCE,",",1),1,12)_"@"_$E($P(SOURCE," at ",2),1,12)
    18         S TEMP=TEMP_U_TSOURCE
    19         S DATE=$$FMTE^XLFDT(DATE,"5Z")
    20         S TEMP=TEMP_U_DATE
    21         D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NL,.OUTPUT)
    22         Q
    23         ;
    24         ;=======================================================
    25 LIST    ;Print a list of location lists.
    26         N BY,DIC,FLDS,FR,L,PXRMEDOK
    27         S PXRMEDOK=1
    28         S BY=".01"
    29         S DIC="^PXRMD(810.9,"
    30         S FLDS="[PXRM LOCATION LIST LIST]"
    31         S FR=""
    32         S L=0
    33         D EN1^DIP
    34         Q
    35         ;
    36         ;=======================================================
    37 MRKINACT(TEXT)  ;Append the inactive mark to TEXT in column 77.
    38         N IC,NSPA
    39         S NSPA=77-$L(TEXT)
    40         F IC=1:1:NSPA S TEXT=TEXT_" "
    41         S TEXT=TEXT_"X"
    42         Q TEXT
    43         ;
    44         ;=======================================================
    45 QUERYAO()       ;See if the user wants only active reminders listed.
    46         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
    47         S DIR(0)="YA"
    48         S DIR("A")="List active reminders only? "
    49         S DIR("B")="Y"
    50         W !
    51         D ^DIR
    52         Q Y
    53         ;
    54         ;=======================================================
    55 RDEF(DEFLIST,ARO)       ;Build a list of the name and print name of all
    56         ;reminder definitions.
    57         N INACTIVE,IEN,NAME,PNAME,REMINDER
    58         S INACTIVE=""
    59         ;Build the list of reminders in alphabetical order.
    60         S VALMCNT=0
    61         S NAME=""
    62         F  S NAME=$O(^PXD(811.9,"B",NAME)) Q:NAME=""  D
    63         . S IEN=$O(^PXD(811.9,"B",NAME,""))
    64         . S REMINDER=^PXD(811.9,IEN,0)
    65         . S INACTIVE=$P(REMINDER,U,6)
    66         . I (ARO)&(INACTIVE) Q
    67         . S VALMCNT=VALMCNT+1
    68         . S PNAME=$P(REMINDER,U,3)
    69         . S DEFLIST(VALMCNT,0)=$$FRDEF(NAME,PNAME)
    70         . I INACTIVE D
    71         .. S DEFLIST(VALMCNT,0)=$$MRKINACT(DEFLIST(VALMCNT,0))
    72         S DEFLIST("VALMCNT")=VALMCNT
    73         Q
    74         ;
    75         ;=======================================================
    76 REXL(RLIST)     ;Build a list of exchange repository entries.
    77         N DATE,EXIEN,FMTSTR,IND,NAME,NL,NUM,OUTPUT,SOURCE,STR
    78         ;Build the list in alphabetical order.
    79         S FMTSTR=$$LMFMTSTR^PXRMTEXT(.VALMDDF,"RLLL")
    80         S (NUM,VALMCNT)=0
    81         S NAME=""
    82         F  S NAME=$O(^PXD(811.8,"B",NAME)) Q:NAME=""  D
    83         . S DATE=""
    84         . F  S DATE=$O(^PXD(811.8,"B",NAME,DATE)) Q:DATE=""  D
    85         .. S EXIEN=$O(^PXD(811.8,"B",NAME,DATE,""))
    86         .. S SOURCE=$P(^PXD(811.8,EXIEN,0),U,2)
    87         .. S NUM=NUM+1
    88         .. S ^TMP(RLIST,$J,"SEL",NUM)=EXIEN
    89         .. D FMT(NUM,NAME,SOURCE,DATE,FMTSTR,.NL,.OUTPUT)
    90         .. F IND=1:1:NL D
    91         ... S VALMCNT=VALMCNT+1,^TMP(RLIST,$J,VALMCNT,0)=OUTPUT(IND)
    92         ... S ^TMP(RLIST,$J,"IDX",VALMCNT,NUM)=""
    93         S ^TMP(RLIST,$J,"VALMCNT")=VALMCNT
    94         Q
    95         ;
    96         ;=======================================================
    97 SPONSOR ;Print a list of Sponsors.
    98         N BY,DIC,FLDS,FR,L,PXRMEDOK
    99         S PXRMEDOK=1
    100         S BY=".01"
    101         S DIC="^PXRMD(811.6,"
    102         S FLDS="[PXRM SPONSOR LIST]"
    103         S FR=""
    104         S L=0
    105         D EN1^DIP
    106         Q
    107         ;
     1PXRMLIST ; SLC/PKR/PJH - Clinical Reminders list functions. ;10/04/2000
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;Used in the reminder exchange utility for building lists of
     4 ;reminders, Exchange File entries, etc.
     5 ;=======================================================
     6FRDEF(NAME,PNAME) ;Format the reminder name and print name.
     7 N IND,TEMP
     8 S TEMP=$$LJ^XLFSTR(NAME,40," ")
     9 S TEMP=TEMP_PNAME
     10 Q TEMP
     11 ;
     12 ;=======================================================
     13FRE(NUMBER,NAME,SOURCE,DATE) ;Format  entry number, name, source,
     14 ;and date packed.
     15 N TEMP,TNAME,TSOURCE
     16 S TEMP=$$RJ^XLFSTR(NUMBER,4," ")
     17 S TNAME=$E(NAME,1,27)
     18 S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,29," ")
     19 S TSOURCE=$E($P(SOURCE,",",1),1,12)_"@"_$E($P(SOURCE," at ",2),1,12)
     20 S TEMP=TEMP_$$LJ^XLFSTR(TSOURCE,23," ")
     21 S DATE=$$FMTE^XLFDT(DATE,"5Z")
     22 S TEMP=TEMP_"  "_$$LJ^XLFSTR(DATE,30," ")
     23 Q TEMP
     24 ;
     25 ;=======================================================
     26LIST ;Print a list of location lists.
     27 N BY,DIC,FLDS,FR,L,PXRMEDOK
     28 S PXRMEDOK=1
     29 S BY=".01"
     30 S DIC="^PXRMD(810.9,"
     31 S FLDS="[PXRM LOCATION LIST LIST]"
     32 S FR=""
     33 S L=0
     34 D EN1^DIP
     35 Q
     36 ;
     37 ;=======================================================
     38MRKINACT(TEXT) ;Append the inactive mark to TEXT in column 77.
     39 N IC,NSPA
     40 S NSPA=77-$L(TEXT)
     41 F IC=1:1:NSPA S TEXT=TEXT_" "
     42 S TEXT=TEXT_"X"
     43 Q TEXT
     44 ;
     45 ;=======================================================
     46QUERYAO() ;See if the user wants only active reminders listed.
     47 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
     48 S DIR(0)="YA"
     49 S DIR("A")="List active reminders only? "
     50 S DIR("B")="Y"
     51 W !
     52 D ^DIR
     53 Q Y
     54 ;
     55 ;=======================================================
     56RDEF(DEFLIST,ARO) ;Build a list of the name and print name of all
     57 ;reminder definitions.
     58 N INACTIVE,IEN,NAME,PNAME,REMINDER
     59 S INACTIVE=""
     60 ;Build the list of reminders in alphabetical order.
     61 S VALMCNT=0
     62 S NAME=""
     63 F  S NAME=$O(^PXD(811.9,"B",NAME)) Q:NAME=""  D
     64 . S IEN=$O(^PXD(811.9,"B",NAME,""))
     65 . S REMINDER=^PXD(811.9,IEN,0)
     66 . S INACTIVE=$P(REMINDER,U,6)
     67 . I (ARO)&(INACTIVE) Q
     68 . S VALMCNT=VALMCNT+1
     69 . S PNAME=$P(REMINDER,U,3)
     70 . S DEFLIST(VALMCNT,0)=$$FRDEF(NAME,PNAME)
     71 . I INACTIVE D
     72 .. S DEFLIST(VALMCNT,0)=$$MRKINACT(DEFLIST(VALMCNT,0))
     73 S DEFLIST("VALMCNT")=VALMCNT
     74 Q
     75 ;
     76 ;=======================================================
     77RE(RLIST,IEN) ;Build a list of repository entries.
     78 N DATE,IND,NAME,SOURCE
     79 ;Build the list in alphabetical order.
     80 S VALMCNT=0
     81 S NAME=""
     82 F  S NAME=$O(^PXD(811.8,"B",NAME)) Q:NAME=""  D
     83 . S DATE=""
     84 . F  S DATE=$O(^PXD(811.8,"B",NAME,DATE)) Q:DATE=""  D
     85 .. S IND=$O(^PXD(811.8,"B",NAME,DATE,""))
     86 .. S SOURCE=$P(^PXD(811.8,IND,0),U,2)
     87 .. S VALMCNT=VALMCNT+1
     88 .. S RLIST(VALMCNT,0)=$$FRE(VALMCNT,NAME,SOURCE,DATE)
     89 .. S IEN(VALMCNT)=IND
     90 S RLIST("VALMCNT")=VALMCNT
     91 Q
     92 ;
     93 ;=======================================================
     94SPONSOR ;Print a list of Sponsors.
     95 N BY,DIC,FLDS,FR,L,PXRMEDOK
     96 S PXRMEDOK=1
     97 S BY=".01"
     98 S DIC="^PXRMD(811.6,"
     99 S FLDS="[PXRM SPONSOR LIST]"
     100 S FR=""
     101 S L=0
     102 D EN1^DIP
     103 Q
     104 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLLED.m

    r613 r623  
    1 PXRMLLED        ; SLC/PJH - Edit a location list. ;06/25/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;================================================================
    5         N CS1,CS2,DA,DIC,DLAYGO,DTOUT,DUOUT,FILEA,IENA,NUM,Y
    6 GETNAME ;Get the name of the location list to edit.
    7         K DA,DIC,DLAYGO,DTOUT,DUOUT,Y
    8         S DIC="^PXRMD(810.9,"
    9         S DIC(0)="AEMQL"
    10         S DIC("A")="Select Location List: "
    11         S DIC("S")="I $$VEDIT^PXRMUTIL(DIC,Y)"
    12         S DLAYGO=810.9
    13         ;Set the starting place for additions.
    14         D SETSTART^PXRMCOPY(DIC)
    15         W !
    16         D ^DIC
    17         I ($D(DTOUT))!($D(DUOUT)) Q
    18         I Y=-1 G END
    19         S DA=$P(Y,U,1)
    20         S CS1=$$FILE^PXRMEXCS(810.9,DA)
    21         D EDIT(DIC,DA)
    22         ;See if any changes have been made, if so do the edit history.
    23         S CS2=$$FILE^PXRMEXCS(810.9,DA)
    24         I CS2'=0,CS2'=CS1 D SEHIST^PXRMUTIL(810.9,DIC,DA)
    25         G GETNAME
    26 END     ;
    27         Q
    28         ;
    29         ;================================================================
    30 EDIT(ROOT,DA)   ;
    31         N DIE,DR,DIDEL,X,Y
    32         S DIE=ROOT,DIDEL=810.9
    33 NAME    S DR=".01"
    34         D ^DIE
    35         I '$D(DA) Q
    36         I $D(Y) Q
    37 CLASS   ;
    38         ;Class
    39 RETRY   W !!
    40         S DR="100"
    41         D ^DIE
    42         I $D(Y) G NAME
    43         ;Sponsor
    44         S DR="101"
    45         D ^DIE
    46         I $D(Y) G RETRY
    47         ;Make sure Class and Sponsor Class are in synch.
    48         S RESULT=$$VSPONSOR^PXRMINTR(X)
    49         I RESULT=0 S DIE("NO^")="Other value" G RETRY
    50         I RESULT=1 K DIE("NO^")
    51         ;Review date
    52 RD      W !!
    53         S DR="102"
    54         D ^DIE
    55         I $D(Y) G RETRY
    56         ;
    57         ;Description
    58 DES     S DR="1"
    59         D ^DIE
    60         I $D(Y) G RD
    61         ;
    62         ;Clinic Stops
    63 CS      S DR="40.7"
    64         S DR(2,810.9001)=".01;1"
    65         D ^DIE
    66         I $D(Y) G RD
    67         ;
    68         ;Hospital Locations
    69 HL      S DR="44"
    70         D ^DIE
    71         I $D(Y) G CS
    72         Q
    73         ;
    74         ;================================================================
    75 KAMIS(X,DA)     ;Kill the AMIS Reporting Stop Code.
    76         ;Do not execute as part of a verify fields.
    77         I $G(DIUTIL)="VERIFY FIELDS" Q
    78         ;Do not execute as part of exchange.
    79         I $G(PXRMEXCH) Q
    80         S $P(^PXRMD(810.9,DA(1),40.7,DA,0),U,2)=""
    81         Q
    82         ;
    83         ;================================================================
    84 SAMIS(X,DA)     ;Set the AMIS Reporting Stop Code.
    85         ;Do not execute as part of a verify fields.
    86         I $G(DIUTIL)="VERIFY FIELDS" Q
    87         ;Do not execute as part of exchange.
    88         I $G(PXRMEXCH) Q
    89         N AMIS
    90         S AMIS=$P(^DIC(40.7,X,0),U,2)
    91         S $P(^PXRMD(810.9,DA(1),40.7,DA,0),U,2)=AMIS
    92         Q
    93         ;
     1PXRMLLED ; SLC/PJH - Edit a location list. ;12/23/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;================================================================
     5 N CS1,CS2,DA,DIC,DLAYGO,DTOUT,DUOUT,FILEA,IENA,NUM,Y
     6GETNAME ;Get the name of the location list to edit.
     7 K DA,DIC,DLAYGO,DTOUT,DUOUT,Y
     8 S DIC="^PXRMD(810.9,"
     9 S DIC(0)="AEMQL"
     10 S DIC("A")="Select Location List: "
     11 S DIC("S")="I $$VEDIT^PXRMUTIL(DIC,Y)"
     12 S DLAYGO=810.9
     13 ;Set the starting place for additions.
     14 D SETSTART^PXRMCOPY(DIC)
     15 W !
     16 D ^DIC
     17 I ($D(DTOUT))!($D(DUOUT)) Q
     18 I Y=-1 G END
     19 S DA=$P(Y,U,1)
     20 S CS1=$$FILE^PXRMEXCS(810.9,DA)
     21 D EDIT(DIC,DA)
     22 ;See if any changes have been made, if so do the edit history.
     23 S CS2=$$FILE^PXRMEXCS(810.9,DA)
     24 I CS2'=0,CS2'=CS1 D SEHIST^PXRMUTIL(810.9,DIC,DA)
     25 G GETNAME
     26END ;
     27 Q
     28 ;
     29 ;================================================================
     30EDIT(ROOT,DA) ;
     31 N DIE,DR,DIDEL,X,Y
     32 S DIE=ROOT,DIDEL=810.9
     33NAME S DR=".01"
     34 D ^DIE
     35 I '$D(DA) Q
     36 I $D(Y) Q
     37CLASS ;
     38 ;Class
     39RETRY W !!
     40 S DR="100"
     41 D ^DIE
     42 I $D(Y) G NAME
     43 ;Sponsor
     44 S DR="101"
     45 D ^DIE
     46 I $D(Y) G RETRY
     47 ;Make sure Class and Sponsor Class are in synch.
     48 S RESULT=$$VSPONSOR^PXRMINTR(X)
     49 I RESULT=0 S DIE("NO^")="Other value" G RETRY
     50 I RESULT=1 K DIE("NO^")
     51 ;Review date
     52RD W !!
     53 S DR="102"
     54 D ^DIE
     55 I $D(Y) G RETRY
     56 ;
     57 ;Description
     58DES S DR="1"
     59 D ^DIE
     60 I $D(Y) G RD
     61 ;
     62 ;Clinic Stops
     63CS S DR="40.7"
     64 S DR(2,810.9001)=".01;1"
     65 D ^DIE
     66 I $D(Y) G DES
     67 ;
     68 ;Hospital Locations
     69HL S DR="44"
     70 D ^DIE
     71 I $D(Y) G CS
     72 Q
     73 ;
     74 ;================================================================
     75KAMIS(X,DA) ;Kill the AMIS Reporting Stop Code.
     76 ;Do not execute as part of a verify fields.
     77 I $G(DIUTIL)="VERIFY FIELDS" Q
     78 ;Do not execute as part of exchange.
     79 I $G(PXRMEXCH) Q
     80 S $P(^PXRMD(810.9,DA(1),40.7,DA,0),U,2)=""
     81 Q
     82 ;
     83 ;================================================================
     84SAMIS(X,DA) ;Set the AMIS Reporting Stop Code.
     85 ;Do not execute as part of a verify fields.
     86 I $G(DIUTIL)="VERIFY FIELDS" Q
     87 ;Do not execute as part of exchange.
     88 I $G(PXRMEXCH) Q
     89 N AMIS
     90 S AMIS=$P(^DIC(40.7,X,0),U,2)
     91 S $P(^PXRMD(810.9,DA(1),40.7,DA,0),U,2)=AMIS
     92 Q
     93 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLOCF.m

    r613 r623  
    1 PXRMLOCF        ; SLC/PKR - Handle location findings. ;10/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;This routine is for location list patient findings.
    4         ;=================================================
    5 ALL(FILENUM,DFN,PFINDPA,FIEVAL) ;Get all Visits with a location
    6         ;for a patient.
    7         N BDT,BTIME,CASESEN,COND,CONVAL,DAS,DATE,DEND,DONE,DS,EDT,FIEVD
    8         N ICOND,INVBD,INVDATE,INVDT,INVED,NFOUND,NOCC
    9         N SAVE,SDIR,TEMP,TIME,UCIFS
    10         ;Set the finding search parameters.
    11         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    12         S SDIR=$S(NOCC<0:-1,1:1)
    13         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    14         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    15         S (DONE,NFOUND)=0
    16         S DEND=$S(EDT[".":EDT,1:EDT+.235959)
    17         S INVBD=9999999-$P(BDT,".",1),BTIME="."_$P(BDT,".",2)
    18         S INVED=9999999-$P(DEND,".",1),ETIME="."_$P(DEND,".",2)
    19         I SDIR=1 S DS=INVED-.000001
    20         I SDIR=-1 S DS=INVBD+.000001
    21         S INVDT=DS,(DONE,NFOUND)=0
    22         ;DBIA 2028
    23         F  S INVDT=$O(^AUPNVSIT("AA",DFN,INVDT),SDIR) Q:(DONE)!(INVDT="")  D
    24         . S INVDATE=$P(INVDT,".",1)
    25         . I (SDIR=1),INVDATE>INVBD S DONE=1 Q
    26         . I (SDIR=-1),INVDATE<INVED S DONE=1 Q
    27         . S TIME="."_$P(INVDT,".",2)
    28         . I INVDATE=INVED,TIME>ETIME Q
    29         . I INVDATE=INVBD,TIME<BTIME Q
    30         . S DAS=0
    31         . F  S DAS=$O(^AUPNVSIT("AA",DFN,INVDT,DAS)) Q:(DAS="")!(DONE)  D
    32         .. D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
    33         .. S CONVAL=$S(COND="":1,1:$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD))
    34         .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    35         .. I SAVE D
    36         ... S TEMP=^AUPNVSIT(DAS,0)
    37         ... S NFOUND=NFOUND+1
    38         ... S FIEVAL(NFOUND)=CONVAL
    39         ... I COND'="" S FIEVAL(NFOUND,"CONDITION")=CONVAL
    40         ... S FIEVAL(NFOUND,"DAS")=DAS
    41         ... S FIEVAL(NFOUND,"DATE")=$P(TEMP,U,1)
    42         ... M FIEVAL(NFOUND)=FIEVD
    43         ... I $G(PXRMDEBG) M FIEVAL(NFOUND,"CSUB")=FIEVD
    44         ... I NFOUND=NOCC S DONE=1
    45         ;Save the finding result.
    46         D SFRES^PXRMUTIL(-SDIR,NFOUND,.FIEVAL)
    47         S FIEVAL("FILE NUMBER")=FILENUM
    48         Q
    49         ;
    50         ;=================================================
    51 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate location findings.
    52         N BDT,EDT,FIEVT,FILENUM,FINDING,FINDPA,ITEM
    53         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    54         S ITEM=""
    55         F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    56         . S FINDING=""
    57         . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
    58         .. K FINDPA
    59         .. M FINDPA=DEFARR(20,FINDING)
    60         .. K FIEVT
    61         .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.FINDPA,.FIEVT)
    62         .. M FIEVAL(FINDING)=FIEVT
    63         .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
    64         Q
    65         ;
    66         ;=================================================
    67 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate location terms.
    68         N FIEVT,FILENUM,ITEM,PFINDPA
    69         N TEMP,TFINDING,TFINDPA
    70         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    71         S ITEM=""
    72         F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    73         . S TFINDING=""
    74         . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
    75         .. K FIEVT,PFINDPA,TFINDPA
    76         .. M TFINDPA=TERMARR(20,TFINDING)
    77         ..;Set the finding parameters.
    78         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    79         .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.PFINDPA,.FIEVT)
    80         .. M TFIEVAL(TFINDING)=FIEVT
    81         .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
    82         Q
    83         ;
    84         ;=================================================
    85 FIEVAL(FILENUM,SNODE,DFN,ITEM,PFINDPA,FIEVAL)   ;
    86         ;Evaluate regular patient findings.
    87         N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,FIEVD,FLIST,HLOC
    88         N ICOND,IND,LNAME,NFOUND,NGET,NOCC,NP
    89         N SAVE,SDIR,STATUSA,TEMP,UCIFS,VSLIST
    90         S LNAME=$P(^PXRMD(810.9,ITEM,0),U,1)
    91         I LNAME="VA-ALL LOCATIONS" D ALL(FILENUM,DFN,.PFINDPA,.FIEVAL) Q
    92         ;Set the finding search parameters.
    93         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    94         S SDIR=$S(NOCC<0:-1,1:1)
    95         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    96         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    97         S NGET=$S(UCIFS:50,$D(STATUSA):50,1:NOCC)
    98         ;Get a list of unique locations.
    99         D LOCLIST(ITEM,"HLOCL")
    100         D FPDAT(DFN,"HLOCL",NGET,SDIR,BDT,EDT,.NFOUND,.FLIST)
    101         I NFOUND=0 S FIEVAL=0 Q
    102         S NP=0
    103         F IND=1:1:NFOUND Q:NP=NOCC  D
    104         . S DAS=$P(FLIST(IND),U,1)
    105         . D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
    106         . S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
    107         . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    108         . I SAVE D
    109         .. S NP=NP+1
    110         .. S FIEVAL(NP)=CONVAL
    111         .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
    112         .. S FIEVAL(NP,"DAS")=$P(FLIST(IND),U,1)
    113         .. S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
    114         .. M FIEVAL(NP)=FIEVD
    115         .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVD
    116         ;
    117         ;Save the finding result.
    118         D SFRES^PXRMUTIL(NOCC,NP,.FIEVAL)
    119         S FIEVAL("FILE NUMBER")=FILENUM
    120         Q
    121         ;
    122         ;=================================================
    123 FPDAT(DFN,HLOCL,NOCC,SDIR,BDT,EDT,NFOUND,FLIST) ;Find patient data for
    124         ;visits at a specified hospital location. Return up to NOCC most
    125         ;recent entries in FLIST where FLIST(1) is the most recent.
    126         ;"AA" in Visit file is inverse date_.time instead of a full inverse
    127         ;date and time. For example if the date/time is 3030704.104449 then
    128         ;"AA" has 6969295.104449 instead of 6969295.89555
    129         N BTIME,DAS,DATE,DEND,DLIST,DONE,DS,ETIME,HLOC
    130         N INVBD,INVDATE,INVDT,INVED,NF,TEMP,TIME
    131         S DEND=$S(EDT[".":EDT,1:EDT+.235959)
    132         S INVBD=9999999-$P(BDT,".",1),BTIME="."_$P(BDT,".",2)
    133         S INVED=9999999-$P(DEND,".",1),ETIME="."_$P(DEND,".",2)
    134         I SDIR=1 S DS=INVED-.000001
    135         I SDIR=-1 S DS=INVBD+.000001
    136         ;DBIA #2028
    137         S INVDT=DS,(DONE,NFOUND)=0
    138         F  S INVDT=$O(^AUPNVSIT("AA",DFN,INVDT),SDIR) Q:(INVDT="")!(DONE)  D
    139         . S NF=0
    140         . S INVDATE=$P(INVDT,".",1)
    141         . I (SDIR=1),INVDATE>INVBD S DONE=1 Q
    142         . I (SDIR=-1),INVDATE<INVED S DONE=1 Q
    143         . S TIME="."_$P(INVDT,".",2)
    144         . I INVDATE=INVED,TIME>ETIME Q
    145         . I INVDATE=INVBD,TIME<BTIME Q
    146         . S DAS=0
    147         . F  S DAS=$O(^AUPNVSIT("AA",DFN,INVDT,DAS)) Q:(DAS="")!(DONE)  D
    148         .. S TEMP=^AUPNVSIT(DAS,0)
    149         .. S HLOC=$P(TEMP,U,22)
    150         .. I HLOC="" Q
    151         .. I '$D(^TMP($J,HLOCL,HLOC)) Q
    152         ..;Check the associated appointment for a valid status.
    153         .. I '$$VAPSTAT^PXRMVSIT(DAS) Q
    154         .. S DATE=$P(TEMP,U,1)
    155         .. S NF=NF+1,NFOUND=NFOUND+1
    156         .. I NFOUND=NOCC S DONE=1
    157         .. S DLIST(INVDT,NF)=DAS_U_DATE
    158         S INVDT="",NFOUND=0
    159         F  S INVDT=$O(DLIST(INVDT)) Q:INVDT=""  D
    160         . S NF=0
    161         . F  S NF=$O(DLIST(INVDT,NF)) Q:NF=""  D
    162         .. S NFOUND=NFOUND+1
    163         .. S FLIST(NFOUND)=DLIST(INVDT,NF)
    164         K ^TMP($J,"HLOCL")
    165         Q
    166         ;
    167         ;=================================================
    168 LOCLIST(ITEM,SUB)       ;Build a list of unique locations based on stop code
    169         ;and/or hospital location. Reads of ^SC covered by DBIA #4482.
    170         N CS,EXCL,IND,JND,HLOC,SC
    171         K ^TMP($J,SUB)
    172         ;Process stop codes. EXCL is the list of credit stops to exclude.
    173         S IND=0
    174         F  S IND=+$O(^PXRMD(810.9,ITEM,40.7,IND)) Q:IND=0  D
    175         . S SC=$P(^PXRMD(810.9,ITEM,40.7,IND,0),U,1)
    176         . K EXCL
    177         . S JND=0
    178         . F  S JND=+$O(^PXRMD(810.9,ITEM,40.7,IND,1,JND)) Q:JND=0  D
    179         .. S EXCL=^PXRMD(810.9,ITEM,40.7,IND,1,JND,0)
    180         .. S EXCL(EXCL)=""
    181         . S HLOC=""
    182         . F  S HLOC=$O(^SC("AST",SC,HLOC)) Q:HLOC=""  D
    183         .. ;See if there are any to exclude.
    184         .. S CS=$P(^SC(HLOC,0),U,18)
    185         .. I CS'="",$D(EXCL(CS)) Q
    186         .. S ^TMP($J,SUB,HLOC)=""
    187         ;Process locations.
    188         S IND=0
    189         F  S IND=+$O(^PXRMD(810.9,ITEM,44,IND)) Q:IND=0  D
    190         . S HLOC=^PXRMD(810.9,ITEM,44,IND,0)
    191         . S ^TMP($J,SUB,HLOC)=""
    192         Q
    193         ;
    194         ;=================================================
    195 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    196         ;DBIAs (^DIC(4: #10090), (^DIC(40.7: #557), (^SC: #10040)
    197         N HLOC,IND,JND,LOC,NAME,NIN,NOUT,SC,TEMP,TEXTIN,TEXTOUT,VDATE
    198         S NAME="Outpatient Encounter = "
    199         S IND=0
    200         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    201         . S NIN=0
    202         . S VDATE=IFIEVAL(IND,"DATE")
    203         . S LOC=$G(IFIEVAL(IND,"LOC. OF ENCOUNTER"))
    204         . S LOC=$S(LOC="":"?",1:$P($G(^DIC(4,LOC,0)),U,1))
    205         . S SC=$G(IFIEVAL(IND,"DSS ID"))
    206         . S SC=$S(SC="":"?",1:" "_$P($G(^DIC(40.7,SC,0)),U,1))
    207         . S HLOC=$G(IFIEVAL(IND,"HOSPITAL LOCATION"))
    208         . S HLOC=$S(HLOC="":"?",1:" "_$P($G(^SC(HLOC,0)),U,1))
    209         . S TEMP=NAME_LOC_HLOC_SC_" ("_$$EDATE^PXRMDATE(VDATE)_")"
    210         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    211         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    212         S NLINES=NLINES+1,TEXT(NLINES)=""
    213         Q
    214         ;
    215         ;=================================================
    216 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    217         ;maintenance output.
    218         ;DBIAs (^DIC(4: #10090), (^DIC(40.7: #557), (^SC: #10040)
    219         N EM,HLOC,IND,JND,LOC,NIN,NOUT,SC,STATUS,TEMP,TEXTIN,TEXTOUT,VDATE
    220         S NLINES=NLINES+1
    221         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"PCE Encounter:"
    222         S IND=0
    223         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    224         . S NIN=0
    225         . S VDATE=IFIEVAL(IND,"DATE")
    226         . S TEMP=$$EDATE^PXRMDATE(VDATE)
    227         . S LOC=$G(IFIEVAL(IND,"LOC. OF ENCOUNTER"))
    228         . S LOC=$S(LOC="":"?",1:$P($G(^DIC(4,LOC,0)),U,1))
    229         . S TEMP=TEMP_" Facility - "_LOC
    230         . D FORMATS^PXRMTEXT(INDENT+1,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    231         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    232         . S HLOC=$G(IFIEVAL(IND,"HLOC"))
    233         . I HLOC="" S HLOC="?"
    234         . S TEMP="Hospital Location: "_HLOC
    235         . S SC=$G(IFIEVAL(IND,"STOP CODE"))
    236         . I SC="" S SC="?"
    237         . S TEMP=TEMP_"; Clinic Stop: "_SC
    238         . S NIN=NIN+1,TEXTIN(NIN)=TEMP_"\\"
    239         . S SC=$G(IFIEVAL(IND,"SERVICE CATEGORY"))
    240         . S TEMP="Service Category: "_SC_"="_$$EXTERNAL^DILFD(9000010,.07,"",SC,.EM)
    241         . S NIN=NIN+1,TEXTIN(NIN)=TEMP_"\\"
    242         . S STATUS=$P($G(IFIEVAL(IND,"STATUS")),U,2)
    243         . I STATUS="" S STATUS="?"
    244         . S TEMP="Appointment Status: "_STATUS
    245         . S NIN=NIN+1,TEXTIN(NIN)=TEMP_"\\"
    246         . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,NIN,.TEXTIN,.NOUT,.TEXTOUT)
    247         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    248         . I IFIEVAL(IND,"COMMENTS")'="" D
    249         .. S TEMP="Comments: "_IFIEVAL(IND,"COMMENTS")
    250         .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    251         .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    252         S NLINES=NLINES+1,TEXT(NLINES)=""
    253         Q
    254         ;
     1PXRMLOCF ; SLC/PKR - Handle location findings. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;This routine is for location list patient findings.
     4 ;=================================================
     5ALL(FILENUM,DFN,PFINDPA,FIEVAL) ;Get all Visits with a location
     6 ;for a patient.
     7 N BDT,CASESEN,COND,CONVAL,DAS,DATE,DONE,EDT,ENTYPE,FIEVD,HLOC
     8 N ICOND,IND,NFOUND,NOCC
     9 N SAVE,SDIR,TEMP,UCIFS,VDATE
     10 ;Set the finding search parameters.
     11 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     12 S SDIR=$S(NOCC<0:+1,1:-1)
     13 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     14 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     15 S (DONE,NFOUND)=0
     16 I SDIR=1 S VDATE=BDT-.0000001
     17 I SDIR=-1 S VDATE=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
     18 ;DBIA 2028
     19 F  S VDATE=+$O(^AUPNVSIT("AET",DFN,VDATE),SDIR) Q:(VDATE=0)!(DONE)  D
     20 . I SDIR=1,VDATE>EDT S DONE=1 Q
     21 . I SDIR=-1,VDATE<BDT S DONE=1 Q
     22 . S HLOC=""
     23 . F  S HLOC=$O(^AUPNVSIT("AET",DFN,VDATE,HLOC)) Q:(HLOC="")!(DONE)  D
     24 .. S ENTYPE=""
     25 .. F  S ENTYPE=$O(^AUPNVSIT("AET",DFN,VDATE,HLOC,ENTYPE)) Q:(ENTYPE="")!(DONE)  D
     26 ... S DAS=0
     27 ... F  S DAS=$O(^AUPNVSIT("AET",DFN,VDATE,HLOC,ENTYPE,DAS)) Q:(DAS="")!(DONE)  D
     28 .... D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
     29 .... S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
     30 .... S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     31 .... I SAVE D
     32 ..... S NFOUND=NFOUND+1
     33 ..... S FIEVAL(NFOUND)=CONVAL
     34 ..... I COND'="" S FIEVAL(NFOUND,"CONDITION")=CONVAL
     35 ..... S FIEVAL(NFOUND,"DAS")=DAS
     36 ..... S FIEVAL(NFOUND,"DATE")=VDATE
     37 ..... M FIEVAL(NFOUND)=FIEVD
     38 ..... I $G(PXRMDEBG) M FIEVAL(NFOUND,"CSUB")=FIEVD
     39 ..... I NFOUND=NOCC S DONE=1
     40 ;Save the finding result.
     41 D SFRES^PXRMUTIL(SDIR,NFOUND,.FIEVAL)
     42 S FIEVAL("FILE NUMBER")=FILENUM
     43 Q
     44 ;
     45 ;=================================================
     46EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate location findings.
     47 N BDT,EDT,FIEVT,FILENUM,FINDING,FINDPA,ITEM
     48 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     49 S ITEM=""
     50 F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     51 . S FINDING=""
     52 . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
     53 .. K FINDPA
     54 .. M FINDPA=DEFARR(20,FINDING)
     55 .. K FIEVT
     56 .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.FINDPA,.FIEVT)
     57 .. M FIEVAL(FINDING)=FIEVT
     58 .. S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
     59 Q
     60 ;
     61 ;=================================================
     62EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate location terms.
     63 N FIEVT,FILENUM,ITEM,PFINDPA
     64 N TEMP,TFINDING,TFINDPA
     65 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     66 S ITEM=""
     67 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     68 . S TFINDING=""
     69 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
     70 .. K FIEVT,PFINDPA,TFINDPA
     71 .. M TFINDPA=TERMARR(20,TFINDING)
     72 ..;Set the finding parameters.
     73 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     74 .. D FIEVAL(FILENUM,"PI",DFN,ITEM,.PFINDPA,.FIEVT)
     75 .. M TFIEVAL(TFINDING)=FIEVT
     76 .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
     77 Q
     78 ;
     79 ;=================================================
     80FIEVAL(FILENUM,SNODE,DFN,ITEM,PFINDPA,FIEVAL) ;
     81 ;Evaluate regular patient findings.
     82 N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,FIEVD,FLIST,HLOC
     83 N ICOND,IND,LNAME,NFOUND,NGET,NOCC,NP
     84 N SAVE,SDIR,STATUSA,TEMP,UCIFS,VSLIST
     85 S LNAME=$P(^PXRMD(810.9,ITEM,0),U,1)
     86 I LNAME="VA-ALL LOCATIONS" D ALL(FILENUM,DFN,.PFINDPA,.FIEVAL) Q
     87 ;Set the finding search parameters.
     88 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     89 S SDIR=$S(NOCC<0:+1,1:-1)
     90 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     91 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     92 S NGET=$S(UCIFS:"*",$D(STATUSA):"*",1:NOCC)
     93 ;Get a list of unique locations.
     94 D LOCLIST(ITEM,"HLOCL")
     95 D FPDAT(DFN,"HLOCL",NGET,BDT,EDT,.NFOUND,.FLIST)
     96 I NFOUND=0 S FIEVAL=0 Q
     97 S NP=0
     98 F IND=1:1:NFOUND Q:NP=NOCC  D
     99 . S DAS=$P(FLIST(IND),U,1)
     100 . D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
     101 . S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
     102 . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     103 . I SAVE D
     104 .. S NP=NP+1
     105 .. S FIEVAL(NP)=CONVAL
     106 .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
     107 .. S FIEVAL(NP,"DAS")=$P(FLIST(IND),U,1)
     108 .. S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
     109 .. M FIEVAL(NP)=FIEVD
     110 .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVD
     111 ;
     112 ;Save the finding result.
     113 D SFRES^PXRMUTIL(NOCC,NP,.FIEVAL)
     114 S FIEVAL("FILE NUMBER")=FILENUM
     115 Q
     116 ;
     117 ;=================================================
     118FPDAT(DFN,HLOCL,NOCC,BDT,EDT,NFOUND,FLIST) ;Find patient data for
     119 ;visits at a specified hospital location. Return up to NOCC most
     120 ;recent entries in FLIST where FLIST(1) is the most recent.
     121 N DAS,DATE,DLIST,ENTYPE,HLOC,NF
     122 S NFOUND=0
     123 S DATE=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
     124 ;DBIA 2028
     125 F  S DATE=+$O(^AUPNVSIT("AET",DFN,DATE),-1) Q:(DATE=0)!(DATE<BDT)!(NFOUND=NOCC)  D
     126 . S HLOC=""
     127 . F  S HLOC=$O(^TMP($J,HLOCL,HLOC)) Q:(HLOC="")!(NFOUND=NOCC)  D
     128 .. I '$D(^AUPNVSIT("AET",DFN,DATE,HLOC)) Q
     129 .. S NF=0
     130 .. S ENTYPE=""
     131 .. F  S ENTYPE=$O(^AUPNVSIT("AET",DFN,DATE,HLOC,ENTYPE)) Q:(ENTYPE="")!(NFOUND=NOCC)  D
     132 ... S DAS=0
     133 ... F  S DAS=$O(^AUPNVSIT("AET",DFN,DATE,HLOC,ENTYPE,DAS)) Q:(DAS="")!(NFOUND=NOCC)  D
     134 ....;Check the associated appointment for a valid status.
     135 .... I '$$VAPSTAT^PXRMVSIT(DAS) Q
     136 .... S NF=NF+1,NFOUND=NFOUND+1
     137 .... S DLIST(DATE,NF)=DAS
     138 S NFOUND=0
     139 S DATE=""
     140 F  S DATE=$O(DLIST(DATE),-1) Q:DATE=""  D
     141 . S NF=0
     142 . F  S NF=$O(DLIST(DATE,NF)) Q:NF=""  D
     143 .. S NFOUND=NFOUND+1
     144 .. S FLIST(NFOUND)=DLIST(DATE,NF)_U_DATE
     145 K ^TMP($J,"HLOCL")
     146 Q
     147 ;
     148 ;=================================================
     149LOCLIST(ITEM,SUB) ;Build a list of unique locations based on stop code
     150 ;and/or hospital location. Reads of ^SC covered by DBIA #4482.
     151 N CS,EXCL,IND,JND,HLOC,SC
     152 K ^TMP($J,SUB)
     153 ;Process stop codes. EXCL is the list of credit stops to exclude.
     154 S IND=0
     155 F  S IND=+$O(^PXRMD(810.9,ITEM,40.7,IND)) Q:IND=0  D
     156 . S SC=$P(^PXRMD(810.9,ITEM,40.7,IND,0),U,1)
     157 . K EXCL
     158 . S JND=0
     159 . F  S JND=+$O(^PXRMD(810.9,ITEM,40.7,IND,1,JND)) Q:JND=0  D
     160 .. S EXCL=^PXRMD(810.9,ITEM,40.7,IND,1,JND,0)
     161 .. S EXCL(EXCL)=""
     162 . S HLOC=""
     163 . F  S HLOC=$O(^SC("AST",SC,HLOC)) Q:HLOC=""  D
     164 .. ;See if there are any to exclude.
     165 .. S CS=$P(^SC(HLOC,0),U,18)
     166 .. I CS'="",$D(EXCL(CS)) Q
     167 .. S ^TMP($J,SUB,HLOC)=""
     168 ;Process locations.
     169 S IND=0
     170 F  S IND=+$O(^PXRMD(810.9,ITEM,44,IND)) Q:IND=0  D
     171 . S HLOC=^PXRMD(810.9,ITEM,44,IND,0)
     172 . S ^TMP($J,SUB,HLOC)=""
     173 Q
     174 ;
     175 ;=================================================
     176MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     177 ;DBIAs (^DIC(4: #10090), (^DIC(40.7: #557), (^SC: #10040)
     178 N HLOC,IND,JND,LOC,NAME,NIN,NOUT,SC,TEMP,TEXTIN,TEXTOUT,VDATE
     179 S NAME="Outpatient Encounter = "
     180 S IND=0
     181 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     182 . S NIN=0
     183 . S VDATE=IFIEVAL(IND,"DATE")
     184 . S LOC=$G(IFIEVAL(IND,"LOC. OF ENCOUNTER"))
     185 . S LOC=$S(LOC="":"?",1:$P($G(^DIC(4,LOC,0)),U,1))
     186 . S SC=$G(IFIEVAL(IND,"DSS ID"))
     187 . S SC=$S(SC="":"?",1:" "_$P($G(^DIC(40.7,SC,0)),U,1))
     188 . S HLOC=$G(IFIEVAL(IND,"HOSPITAL LOCATION"))
     189 . S HLOC=$S(HLOC="":"?",1:" "_$P($G(^SC(HLOC,0)),U,1))
     190 . S TEMP=NAME_LOC_HLOC_SC_" ("_$$EDATE^PXRMDATE(VDATE)_")"
     191 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     192 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     193 S NLINES=NLINES+1,TEXT(NLINES)=""
     194 Q
     195 ;
     196 ;=================================================
     197OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     198 ;maintenance output.
     199 ;DBIAs (^DIC(4: #10090), (^DIC(40.7: #557), (^SC: #10040)
     200 N EM,HLOC,IND,JND,LOC,NIN,NOUT,SC,STATUS,TEMP,TEXTIN,TEXTOUT,VDATE
     201 S NLINES=NLINES+1
     202 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"PCE Encounter:"
     203 S IND=0
     204 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     205 . S NIN=0
     206 . S VDATE=IFIEVAL(IND,"DATE")
     207 . S TEMP=$$EDATE^PXRMDATE(VDATE)
     208 . S LOC=$G(IFIEVAL(IND,"LOC. OF ENCOUNTER"))
     209 . S LOC=$S(LOC="":"?",1:$P($G(^DIC(4,LOC,0)),U,1))
     210 . S TEMP=TEMP_" Facility - "_LOC
     211 . D FORMATS^PXRMTEXT(INDENT+1,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     212 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     213 . S HLOC=$G(IFIEVAL(IND,"HLOC"))
     214 . I HLOC="" S HLOC="?"
     215 . S TEMP="Hospital Location: "_HLOC
     216 . S SC=$G(IFIEVAL(IND,"STOP CODE"))
     217 . I SC="" S SC="?"
     218 . S TEMP=TEMP_"; Clinic Stop: "_SC
     219 . S NIN=NIN+1,TEXTIN(NIN)=TEMP_"\\"
     220 . S SC=$G(IFIEVAL(IND,"SERVICE CATEGORY"))
     221 . S TEMP="Service Category: "_SC_"="_$$EXTERNAL^DILFD(9000010,.07,"",SC,.EM)
     222 . S NIN=NIN+1,TEXTIN(NIN)=TEMP_"\\"
     223 . S STATUS=$P($G(IFIEVAL(IND,"STATUS")),U,2)
     224 . I STATUS="" S STATUS="?"
     225 . S TEMP="Appointment Status: "_STATUS
     226 . S NIN=NIN+1,TEXTIN(NIN)=TEMP_"\\"
     227 . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,NIN,.TEXTIN,.NOUT,.TEXTOUT)
     228 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     229 . I IFIEVAL(IND,"COMMENTS")'="" D
     230 .. S TEMP="Comments: "_IFIEVAL(IND,"COMMENTS")
     231 .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     232 .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     233 S NLINES=NLINES+1,TEXT(NLINES)=""
     234 Q
     235 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLOCL.m

    r613 r623  
    1 PXRMLOCL        ; SLC/PKR - Handle location findings. ;07/26/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;This routine is for location list patient lists.
    4         ;=============================================
    5 ALLLOCS(SUB)    ;Build a list of all hospital locations associated
    6         ;with Visit file entries.
    7         N HLOC
    8         K ^TMP($J,SUB)
    9         S HLOC=""
    10         ;DBIA #2028
    11         F  S HLOC=$O(^AUPNVSIT("AHL",HLOC)) Q:HLOC=""  S ^TMP($J,SUB,HLOC)=""
    12         Q
    13         ;
    14         ;=============================================
    15 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Evaluate location term findings
    16         ;for patient lists. Return the list in ^TMP($J,PLIST)
    17         N BDT,EDT,ITEM,FILENUM,PFINDPA
    18         N STATUSA,TEMP,TFINDING,TFINDPA
    19         S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
    20         S ITEM=""
    21         F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
    22         . S TFINDING=""
    23         . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
    24         .. K PFINDPA,TFINDPA
    25         .. M TFINDPA=TERMARR(20,TFINDING)
    26         ..;Set the finding parameters.
    27         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    28         .. D GPLIST(FILENUM,"IP",ITEM,.PFINDPA,PLIST)
    29         Q
    30         ;
    31         ;=============================================
    32 FPLIST(FILENUM,HLOCL,NOCC,BDT,EDT,PLIST)        ;Find patient list data for
    33         ;a visit to a hospital location. Return the list in ^TMP($J,PLIST).
    34         N BTIME,DAS,DATE,DEND,DFN,DONE,DS,ETIME,HLOC,INVBD,INVDATE,INVDT,INVED
    35         N NFOUND,SC,TEMP,TGLIST,TIME
    36         S TGLIST="FPLIST_PXRMLOCL"
    37         K ^TMP($J,TGLIST)
    38         S DEND=$S(EDT[".":EDT,1:EDT+.235959)
    39         ;"AHL" in Visit file is inverse date_.time instead of a full inverse
    40         ;date and time. For example if the date/time is 3030704.104449 then
    41         ;"AHL" has 6969295.104449 instead of 6969295.89555
    42         S INVBD=9999999-$P(BDT,".",1),BTIME="."_$P(BDT,".",2)
    43         S INVED=9999999-$P(DEND,".",1),ETIME="."_$P(DEND,".",2)
    44         S DS=INVED-.000001
    45         S HLOC=""
    46         F  S HLOC=$O(^TMP($J,HLOCL,HLOC)) Q:HLOC=""  D
    47         . S INVDT=DS,DONE=0
    48         .;DBIA #2028
    49         . F  S INVDT=$O(^AUPNVSIT("AHL",HLOC,INVDT)) Q:(DONE)!(INVDT="")  D
    50         .. S INVDATE=$P(INVDT,".",1)
    51         .. I INVDATE>INVBD S DONE=1 Q
    52         .. S TIME="."_$P(INVDT,".",2)
    53         .. I INVDATE=INVED,TIME>ETIME Q
    54         .. I INVDATE=INVBD,TIME<BTIME Q
    55         .. S DAS=0
    56         .. F  S DAS=$O(^AUPNVSIT("AHL",HLOC,INVDT,DAS)) Q:DAS=""  D
    57         ...;Check the associated appointment for a valid status.
    58         ... I '$$VAPSTAT^PXRMVSIT(DAS) Q
    59         ... S TEMP=^AUPNVSIT(DAS,0)
    60         ... S DATE=$P(TEMP,U,1)
    61         ... S DFN=$P(TEMP,U,5)
    62         ... S SC=$P(TEMP,U,7)
    63         ... S ^TMP($J,TGLIST,DFN,INVDT,DAS)=DATE_U_HLOC_U_SC
    64         ;Return the NOCC most recent for each patient.
    65         S DFN=0
    66         F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
    67         . S (INVDT,NFOUND)=0
    68         . F  S INVDT=$O(^TMP($J,TGLIST,DFN,INVDT)) Q:(NFOUND=NOCC)!(INVDT="")  D
    69         .. S DAS=""
    70         .. F  S DAS=$O(^TMP($J,TGLIST,DFN,INVDT,DAS)) Q:(NFOUND=NOCC)!(DAS="")  D
    71         ... S NFOUND=NFOUND+1
    72         ... S ^TMP($J,PLIST,DFN,NFOUND)=DAS_U_^TMP($J,TGLIST,DFN,INVDT,DAS)
    73         K ^TMP($J,TGLIST)
    74         Q
    75         ;
    76         ;=============================================
    77 FTEST(FILENUM,HLOCL,NOCC,BDT,EDT,PLIST) ;Find patient list data for
    78         ;a visit to a hospital location. Return the list in ^TMP($J,PLIST).
    79         N BTIME,DAS,DATE,DEND,DFN,DONE,DS,ETIME,HLOC,INVBD,INVDATE,INVDT,INVED
    80         N NFOUND,TEMP,TGLIST,TIME
    81         S TGLIST="FPLIST_PXRMLOCL"
    82         K ^TMP($J,TGLIST)
    83         S DS=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
    84         S HLOC=""
    85         F  S HLOC=$O(^TMP($J,HLOCL,HLOC)) Q:HLOC=""  D
    86         . S DATE=DS
    87         . F  S DATE=+$O(^AUPNVSIT("AHDP",HLOC,DATE),-1) Q:(DATE=0)!(DATE<BDT)  D
    88         .. S DFN=""
    89         .. F  S DFN=$O(^AUPNVSIT("AHDP",HLOC,DATE,DFN)) Q:DFN=""  D
    90         ... S SC=""
    91         ... F  S SC=$O(^AUPNVSIT("AHDP",HLOC,DATE,DFN,SC)) Q:SC=""  D
    92         .... S DAS=$O(^AUPNVSIT("AHDP",HLOC,DATE,DFN,SC,""))
    93         .... I '$$VAPSTAT^PXRMVSIT(DAS) Q
    94         .... S ^TMP($J,TGLIST,DFN,DATE,DAS)=HLOC
    95         ;Return the NOCC most recent for each patient.
    96         S DFN=0
    97         F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
    98         . S DATE="",NFOUND=0
    99         . F  S DATE=$O(^TMP($J,TGLIST,DFN,DATE),-1) Q:(NFOUND=NOCC)!(DATE="")  D
    100         .. S DAS=""
    101         .. F  S DAS=$O(^TMP($J,TGLIST,DFN,DATE,DAS)) Q:(NFOUND=NOCC)!(DAS="")  D
    102         ... S NFOUND=NFOUND+1
    103         ... S ^TMP($J,PLIST,DFN,NFOUND)=DAS_U_DATE_U_^TMP($J,TGLIST,DFN,DATE,DAS)
    104         K ^TMP($J,TGLIST)
    105         Q
    106         ;
    107         ;=============================================
    108 GPLIST(FILENUM,SNODE,ITEM,PFINDPA,PLIST)        ;Add to the patient list.
    109         ; Return the list in ^TMP($J,PLIST).
    110         ;^TMP($J,PLIST,T/F,DFN,IND,FILENUM)=DAS^DATE^HLOC^VALUE
    111         N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,DFN,FIEVD,FLIST
    112         N ICOND,IEN,IND,IPLIST,LNAME,NOCC,NFOUND,NGET,NP,SAVE,STATUSA
    113         N TEMP,TGLIST,TPLIST,UCIFS,VALUE,VSLIST
    114         S TGLIST="GPLIST_PXRMLOCL"
    115         ;Set the finding search parameters.
    116         D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
    117         ;Ignore negative occurrence count, date reversal not allowed in
    118         ;patient lists.
    119         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    120         D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    121         S NGET=$S(UCIFS:50,$D(STATUSA):50,1:NOCC)
    122         ;Get a list of unique locations.
    123         S LNAME=$P(^PXRMD(810.9,ITEM,0),U,1)
    124         I LNAME="VA-ALL LOCATIONS" D ALLLOCS("HLOCL")
    125         I LNAME'="VA-ALL LOCATIONS" D LOCLIST^PXRMLOCF(ITEM,"HLOCL")
    126         D FPLIST(FILENUM,"HLOCL",NGET,BDT,EDT,TGLIST)
    127         S DFN=""
    128         F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
    129         . K TPLIST
    130         . M TPLIST=^TMP($J,TGLIST,DFN)
    131         . S (IND,NFOUND)=0
    132         . K IPLIST
    133         . F  S IND=$O(TPLIST(IND)) Q:(IND="")!(NFOUND=NOCC)  D
    134         .. S TEMP=TPLIST(IND)
    135         .. S DAS=$P(TEMP,U,1)
    136         .. D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
    137         .. S VALUE=$G(FIEVD("VALUE"))
    138         .. S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
    139         .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    140         .. I SAVE D
    141         ... S NFOUND=NFOUND+1
    142         ... S IPLIST(CONVAL,DFN,NFOUND,FILENUM)=TEMP_U_VALUE
    143         . M ^TMP($J,PLIST)=IPLIST
    144         K ^TMP($J,"HLOCL"),^TMP($J,TGLIST)
    145         Q
    146         ;
    147         ;=============================================
    148 PCSTOPL ;Print the Clinic Stop list. Called by the print template PXRM
    149         ;LOCATION LIST INQUIRY.
    150         N AMIS,CSTOP,IND,JND,SKIP,TEMP
    151         S (IND,SKIP)=0
    152         F  S IND=+$O(^PXRMD(810.9,D0,40.7,IND)) Q:IND=0  D
    153         . S TEMP=^PXRMD(810.9,D0,40.7,IND,0)
    154         . S CSTOP=$P(TEMP,U,1)
    155         .; DBIA #557
    156         . S CSTOP=$P(^DIC(40.7,CSTOP,0),U,1)
    157         . S AMIS=$P(TEMP,U,2)
    158         . I SKIP W ! S SKIP=0
    159         . W !,?2,CSTOP,?34,AMIS
    160         . I '$D(^PXRMD(810.9,D0,40.7,IND,1)) Q
    161         . S SKIP=1
    162         . W !,?4,"Credit Stops to Exclude:"
    163         . S JND=0
    164         . F  S JND=+$O(^PXRMD(810.9,D0,40.7,IND,1,JND)) Q:JND=0  D
    165         .. S TEMP=^PXRMD(810.9,D0,40.7,IND,1,JND,0)
    166         .. S TEMP=$P(^DIC(40.7,TEMP,0),U,1,2)
    167         .. S CSTOP=$P(TEMP,U,1)
    168         .. S AMIS=$P(TEMP,U,2)
    169         .. W !,?6,CSTOP,?38,AMIS
    170         Q
    171         ;
     1PXRMLOCL ; SLC/PKR - Handle location findings. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;This routine is for location list patient lists.
     4 ;=============================================
     5ALLLOCS(SUB) ;Build a list of all hospital locations associated
     6 ;with Visit file entries.
     7 N HLOC
     8 K ^TMP($J,SUB)
     9 S HLOC=""
     10 ;DBIA #2028
     11 F  S HLOC=$O(^AUPNVSIT("AHL",HLOC)) Q:HLOC=""  S ^TMP($J,SUB,HLOC)=""
     12 Q
     13 ;
     14 ;=============================================
     15EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate location term findings
     16 ;for patient lists. Return the list in ^TMP($J,PLIST)
     17 N BDT,EDT,ITEM,FILENUM,PFINDPA
     18 N STATUSA,TEMP,TFINDING,TFINDPA
     19 S FILENUM=$$GETFNUM^PXRMDATA(ENODE)
     20 S ITEM=""
     21 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
     22 . S TFINDING=""
     23 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
     24 .. K PFINDPA,TFINDPA
     25 .. M TFINDPA=TERMARR(20,TFINDING)
     26 ..;Set the finding parameters.
     27 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     28 .. D GPLIST(FILENUM,"IP",ITEM,.PFINDPA,PLIST)
     29 Q
     30 ;
     31 ;=============================================
     32FPLIST(FILENUM,HLOCL,NOCC,BDT,EDT,PLIST) ;Find patient list data for
     33 ;a visit to a hospital location. Return the list in ^TMP($J,PLIST).
     34 N BTIME,DAS,DATE,DEND,DFN,DONE,DS,ETIME,HLOC,INVBD,INVDATE,INVDT,INVED
     35 N NFOUND,TEMP,TGLIST,TIME
     36 S TGLIST="FPLIST_PXRMLOCL"
     37 K ^TMP($J,TGLIST)
     38 S DEND=$S(EDT[".":EDT,1:EDT+.240001)
     39 ;"AHL" in Visit file is inverse date_.time instead of a full inverse
     40 ;date and time. For example if the date/time is 3030704.104449 then
     41 ;"AHL" has 6969295.104449 instead of 6969295.89555
     42 S INVBD=9999999-$P(BDT,".",1),BTIME=+("."_$P(BDT,".",2))
     43 S INVED=9999999-$P(DEND,".",1),ETIME=+("."_$P(DEND,".",2))
     44 S DS=INVED-1
     45 S HLOC=""
     46 F  S HLOC=$O(^TMP($J,HLOCL,HLOC)) Q:HLOC=""  D
     47 . S INVDT=DS,DONE=0
     48 .;DBIA #2028
     49 . F  S INVDT=$O(^AUPNVSIT("AHL",HLOC,INVDT)) Q:(DONE)!(INVDT="")  D
     50 .. S INVDATE=$P(INVDT,".",1)
     51 .. I INVDATE>INVBD S DONE=1 Q
     52 .. S TIME=+("."_$P(INVDT,".",2))
     53 .. I INVDATE=INVED,TIME>ETIME Q
     54 .. I INVDATE=INVBD,BTIME>TIME S DONE=1 Q
     55 .. S DAS=0
     56 .. F  S DAS=$O(^AUPNVSIT("AHL",HLOC,INVDT,DAS)) Q:DAS=""  D
     57 ...;Check the associated appointment for a valid status.
     58 ... I '$$VAPSTAT^PXRMVSIT(DAS) Q
     59 ... S TEMP=^AUPNVSIT(DAS,0)
     60 ... S DFN=$P(TEMP,U,5)
     61 ... S DATE=$P(TEMP,U,1)
     62 ... S ^TMP($J,TGLIST,DFN,INVDT,DAS)=DATE_U_HLOC
     63 ;Return the NOCC most recent for each patient.
     64 S DFN=0
     65 F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
     66 . S (INVDT,NFOUND)=0
     67 . F  S INVDT=$O(^TMP($J,TGLIST,DFN,INVDT)) Q:(NFOUND=NOCC)!(INVDT="")  D
     68 .. S DAS=""
     69 .. F  S DAS=$O(^TMP($J,TGLIST,DFN,INVDT,DAS)) Q:(NFOUND=NOCC)!(DAS="")  D
     70 ... S NFOUND=NFOUND+1
     71 ... S ^TMP($J,PLIST,DFN,NFOUND)=DAS_U_^TMP($J,TGLIST,DFN,INVDT,DAS)
     72 K ^TMP($J,TGLIST)
     73 Q
     74 ;
     75 ;=============================================
     76GPLIST(FILENUM,SNODE,ITEM,PFINDPA,PLIST) ;Add to the patient list.
     77 ; Return the list in ^TMP($J,PLIST).
     78 ;^TMP($J,PLIST,T/F,DFN,IND,FILENUM)=DAS^DATE^HLOC^VALUE
     79 N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,DFN,FIEVD,FLIST
     80 N ICOND,IEN,IND,IPLIST,LNAME,NOCC,NFOUND,NGET,NP,SAVE,STATUSA
     81 N TEMP,TGLIST,TPLIST,UCIFS,VALUE,VSLIST
     82 S TGLIST="GPLIST_PXRMLOCL"
     83 ;Set the finding search parameters.
     84 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
     85 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     86 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     87 S NGET=$S(UCIFS:"*",$D(STATUSA):"*",1:NOCC)
     88 ;Get a list of unique locations.
     89 S LNAME=$P(^PXRMD(810.9,ITEM,0),U,1)
     90 I LNAME="VA-ALL LOCATIONS" D ALLLOCS("HLOCL")
     91 I LNAME'="VA-ALL LOCATIONS" D LOCLIST^PXRMLOCF(ITEM,"HLOCL")
     92 D FPLIST(FILENUM,"HLOCL",NGET,BDT,EDT,TGLIST)
     93 S DFN=""
     94 F  S DFN=$O(^TMP($J,TGLIST,DFN)) Q:DFN=""  D
     95 . K TPLIST
     96 . M TPLIST=^TMP($J,TGLIST,DFN)
     97 . S (IND,NFOUND)=0
     98 . K IPLIST
     99 . F  S IND=$O(TPLIST(IND)) Q:(IND="")!(NFOUND=NOCC)  D
     100 .. S TEMP=TPLIST(IND)
     101 .. S DAS=$P(TEMP,U,1)
     102 .. D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVD)
     103 .. S VALUE=$G(FIEVD("VALUE"))
     104 .. S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVD),1:1)
     105 .. S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     106 .. I SAVE D
     107 ... S NFOUND=NFOUND+1
     108 ... S IPLIST(CONVAL,DFN,NFOUND,FILENUM)=TEMP_U_VALUE
     109 . M ^TMP($J,PLIST)=IPLIST
     110 K ^TMP($J,"HLOCL"),^TMP($J,TGLIST)
     111 Q
     112 ;
     113 ;=============================================
     114PCSTOPL ;Print the Clinic Stop list. Called by the print template PXRM
     115 ;LOCATION LIST INQUIRY.
     116 N AMIS,CSTOP,IND,JND,SKIP,TEMP
     117 S (IND,SKIP)=0
     118 F  S IND=+$O(^PXRMD(810.9,D0,40.7,IND)) Q:IND=0  D
     119 . S TEMP=^PXRMD(810.9,D0,40.7,IND,0)
     120 . S CSTOP=$P(TEMP,U,1)
     121 .; DBIA #557
     122 . S CSTOP=$P(^DIC(40.7,CSTOP,0),U,1)
     123 . S AMIS=$P(TEMP,U,2)
     124 . I SKIP W ! S SKIP=0
     125 . W !,?2,CSTOP,?34,AMIS
     126 . I '$D(^PXRMD(810.9,D0,40.7,IND,1)) Q
     127 . S SKIP=1
     128 . W !,?4,"Credit Stops to Exclude:"
     129 . S JND=0
     130 . F  S JND=+$O(^PXRMD(810.9,D0,40.7,IND,1,JND)) Q:JND=0  D
     131 .. S TEMP=^PXRMD(810.9,D0,40.7,IND,1,JND,0)
     132 .. S TEMP=$P(^DIC(40.7,TEMP,0),U,1,2)
     133 .. S CSTOP=$P(TEMP,U,1)
     134 .. S AMIS=$P(TEMP,U,2)
     135 .. W !,?6,CSTOP,?38,AMIS
     136 Q
     137 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLPAU.m

    r613 r623  
    1 PXRMLPAU        ; SLC/AGP - Reminder Patient List ;09/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM PATIENT LIST
    5 START(IEN)      ;
    6         N PXRMDONE,VALMBCK,VALMSG,X,XMZ
    7         S X="IORESET"
    8         S VALMCNT=0
    9         D EN^VALM("PXRM PATIENT LIST AUTH USERS")
    10         W IORESET
    11         Q
    12         ;
    13 BLDLIST ;
    14         N PLIST,PIEN
    15         K ^TMP("PXRMLPAU",$J)
    16         K ^TMP("PXRMLPAH",$J)
    17         D LIST(.PLIST,.PIEN)
    18         I $D(PLIST)=0 G EXIT
    19         M ^TMP("PXRMLPAU",$J)=PLIST
    20         S VALMCNT=PLIST("VALMCNT")
    21         F IND=1:1:VALMCNT D
    22         .S ^TMP("PXRMLPAU",$J,"IDX",IND,IND)=PIEN(IND)
    23         Q
    24         ;
    25 LIST(RLIST,PIEN)        ;Build a list of patient list users.
    26         N ACCESS,ARRAY,COUNT,DATE,DFN,IND,SIEN,FNAME,NAME,NODE,LEVEL
    27         ;Build the list in alphabetical order.
    28         S VALMCNT=0
    29         S DFN=""
    30         F  S DFN=$O(^PXRMXP(810.5,IEN,40,"B",DFN)) Q:DFN=""  D
    31         .S IND=""
    32         .F  S IND=$O(^PXRMXP(810.5,IEN,40,"B",DFN,IND)) Q:'IND  D
    33         ..S ACCESS=$P($G(^PXRMXP(810.5,IEN,40,IND,0)),U,2)
    34         ..S FNAME=$$GET1^DIQ(200,DFN,.01) Q:$G(FNAME)=""
    35         ..S ARRAY(FNAME)=$G(IND)_U_$G(ACCESS)
    36         I $D(ARRAY)=0 Q
    37         S NAME="" F  S NAME=$O(ARRAY(NAME)) Q:NAME=""  D
    38         .S VALMCNT=VALMCNT+1
    39         .S RLIST(VALMCNT,0)=$$FRE(VALMCNT,NAME,$P($G(ARRAY(NAME)),U,2))
    40         .S PIEN(VALMCNT)=$P($G(ARRAY(NAME)),U)
    41         S RLIST("VALMCNT")=VALMCNT
    42         Q
    43         ;
    44 FRE(NUMBER,NAME,ACCESS) ;Format  entry number, name, source,
    45         ;and date packed.
    46         N TEMP,TNAME,TSOURCE
    47         S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
    48         S TNAME=$E(NAME,1,45)
    49         S TEMP=TEMP_"  "_TNAME
    50         S TEMP=$$LJ^XLFSTR(TEMP,40," ")_ACCESS
    51         Q TEMP
    52         ;
    53 ENTRY   ;Entry code
    54         D BLDLIST,XQORM
    55         Q
    56         ;
    57 EXIT    ;Exit code
    58         K ^TMP("PXRMLPAU",$J)
    59         K ^TMP("PXRMLPAH",$J)
    60         D CLEAN^VALM10
    61         D FULL^VALM1
    62         Q
    63         ;
    64 HDR     ; Header code
    65         S VALMHDR(1)="Available Patient Lists."
    66         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    67         Q
    68         ;
    69 HLP     ;Help code
    70         N ORU,ORUPRMT,SUB,XQORM
    71         S SUB="PXRMLPAH"
    72         D EN^VALM("PXRM PATIENT LIST HELP")
    73         Q
    74         ;
    75 INIT    ;Init
    76         S VALMCNT=0
    77         Q
    78         ;
    79 PEXIT   ;PXRM MENU protocol exit code
    80         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    81         ;Reset after page up/down etc
    82         D XQORM
    83         Q
    84         ;
    85 ADD     ;add a user
    86         N CREAT,CNT,DIC,DIE,FDA,MSG,USER,Y
    87         S CREAT=$P($G(^PXRMXP(810.5,IEN,0)),U,7)
    88         I $G(CREAT)'=DUZ D  G ADDE
    89         . W !,"Only the creator of this list can add an user." H 2
    90         D FULL^VALM1
    91         S DIC="^VA(200,"
    92         S DIC(0)="QAEB"
    93         S DIC("A")="Select Users: "
    94         D ^DIC
    95         I Y=-1 Q
    96         S USER=+Y
    97         K Y
    98         K DIROUT,DIRUT,DTOUT,DUOUT
    99         S DIR(0)="S^F:Full Control;V:View Only"
    100         S DIR("A")="Select level of control: "
    101         S DIR("B")="V"
    102         S DIR("?")="Enter F or V. For detailed help type ??"
    103         W !
    104         D ^DIR K DIR
    105         I $D(DIROUT) S DTOUT=1
    106         I $D(DTOUT)!($D(DUOUT)) Q
    107         I $G(Y)="" W !,"A level of control must be entered." H 2 Q
    108         S YESNO=$E(Y(0))
    109         S FDA(810.54,"+2,"_IEN_",",.01)=USER
    110         S FDA(810.54,"+2,"_IEN_",",1)=Y
    111         D UPDATE^DIE("","FDA","","MSG")
    112         I $D(MSG)>0 D AWRITE^PXRMUTIL("MSG") H 2
    113 ADDE    ;
    114         D BLDLIST
    115         S VALMBCK="R"
    116         Q
    117         ;
    118 XQORM   ;
    119         S XQORM("#")=$O(^ORD(101,"B","PXRM PATIENT LIST AUTH USER SELECT",0))_U_"1:"_VALMCNT
    120         S XQORM("A")="Select Item: "
    121         Q
    122         ;
    123 XSEL    ;PXRM SELECT COMPONENT validation
    124         N EPIEN,LISTIEN,LRIEN,SEL
    125         S SEL=$P(XQORNOD(0),"=",2)
    126         ;Remove trailing ,
    127         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    128         ;Invalid selection
    129         I SEL["," D  Q
    130         .W $C(7),!,"Only one item number allowed." H 2
    131         .S VALMBCK="R"
    132         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
    133         .W $C(7),!,SEL_" is not a valid item number." H 2
    134         .S VALMBCK="R"
    135         ;Get the patient list ien
    136         S LISTIEN=^TMP("PXRMLPAU",$J,"IDX",SEL,SEL)
    137         ;Full screen mode
    138         D FULL^VALM1
    139         D PDELETE
    140         ;
    141         ;Option to Install, Delete or Install History
    142         ;
    143         S VALMBCK="R"
    144         Q
    145         ;
    146 HELP(CALL)      ;General help text routine
    147         N HTEXT
    148         I CALL=1 D
    149         .S HTEXT(1)="Select CO to copy the patient list.\\"
    150         .S HTEXT(2)="Select COE to copy the patient list to an OE/RR Team.\\"
    151         .S HTEXT(3)="Select DE to delete the patient list.\\"
    152         .S HTEXT(4)="Select DSP to display the patient list.\\"
    153         D HELP^PXRMEUT(.HTEXT)
    154         Q
    155         ;
    156 PDELETE ;Patient list delete
    157         ;
    158         ;Full Screen
    159         W IORESET
    160         ;
    161         N CREAT,IND,LISTIEN,NODE
    162         I DUZ'=$P($G(^PXRMXP(810.5,IEN,0)),U,7) D  G PDELEX
    163         .W !,"Only the creator of this list can delete it." H 2
    164         D EN^VALM2(XQORNOD(0))
    165         ;If there is no list quit.
    166         I '$D(VALMY) D BLDLIST S VALMBCK="R" Q
    167         S IND="",PXRMDONE=0
    168         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    169         .;Get the patient list ien.
    170         .S LISTIEN=^TMP("PXRMLPAU",$J,"IDX",IND,IND)
    171         .S DA(1)=IEN,DA=LISTIEN,DIK="^PXRMXP(810.5,"_DA(1)_",40," D ^DIK
    172         .W !,"Patient list deleted"
    173         ;
    174 PDELEX  ;
    175         D BLDLIST
    176         ;
    177         S VALMBCK="R"
    178         Q
    179         ;
     1PXRMLPAU ; SLC/AGP - Reminder Patient List ;07/29/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;Main entry point for PXRM PATIENT LIST
     5START(IEN) ;
     6 N PXRMDONE,VALMBCK,VALMSG,X,XMZ
     7 S X="IORESET"
     8 S VALMCNT=0
     9 D EN^VALM("PXRM PATIENT LIST AUTH USERS")
     10 W IORESET
     11 Q
     12 ;
     13BLDLIST ;
     14 N PLIST,PIEN
     15 K ^TMP("PXRMLPAU",$J)
     16 K ^TMP("PXRMLPAH",$J)
     17 D LIST(.PLIST,.PIEN)
     18 I $D(PLIST)=0 G EXIT
     19 M ^TMP("PXRMLPAU",$J)=PLIST
     20 S VALMCNT=PLIST("VALMCNT")
     21 F IND=1:1:VALMCNT D
     22 .S ^TMP("PXRMLPAU",$J,"IDX",IND,IND)=PIEN(IND)
     23 Q
     24 ;
     25LIST(RLIST,PIEN) ;Build a list of patient list users.
     26 N ACCESS,ARRAY,COUNT,DATE,DFN,IND,SIEN,FNAME,NAME,NODE,LEVEL
     27 ;Build the list in alphabetical order.
     28 S VALMCNT=0
     29 S DFN=""
     30 F  S DFN=$O(^PXRMXP(810.5,IEN,40,"B",DFN)) Q:DFN=""  D
     31 .S IND=""
     32 .F  S IND=$O(^PXRMXP(810.5,IEN,40,"B",DFN,IND)) Q:'IND  D
     33 ..S ACCESS=$P($G(^PXRMXP(810.5,IEN,40,IND,0)),U,2)
     34 ..S FNAME=$$GET1^DIQ(200,DFN,.01) Q:$G(FNAME)=""
     35 ..S ARRAY(FNAME)=$G(IND)_U_$G(ACCESS)
     36 I $D(ARRAY)=0 Q
     37 S NAME="" F  S NAME=$O(ARRAY(NAME)) Q:NAME=""  D
     38 .S VALMCNT=VALMCNT+1
     39 .S RLIST(VALMCNT,0)=$$FRE(VALMCNT,NAME,$P($G(ARRAY(NAME)),U,2))
     40 .S PIEN(VALMCNT)=$P($G(ARRAY(NAME)),U)
     41 S RLIST("VALMCNT")=VALMCNT
     42 Q
     43 ;
     44FRE(NUMBER,NAME,ACCESS) ;Format  entry number, name, source,
     45 ;and date packed.
     46 N TEMP,TNAME,TSOURCE
     47 S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
     48 S TNAME=$E(NAME,1,45)
     49 S TEMP=TEMP_"  "_TNAME
     50 S TEMP=$$LJ^XLFSTR(TEMP,40," ")_ACCESS
     51 Q TEMP
     52 ;
     53ENTRY ;Entry code
     54 D BLDLIST,XQORM
     55 Q
     56 ;
     57EXIT ;Exit code
     58 K ^TMP("PXRMLPAU",$J)
     59 K ^TMP("PXRMLPAH",$J)
     60 D CLEAN^VALM10
     61 D FULL^VALM1
     62 Q
     63 ;
     64HDR ; Header code
     65 S VALMHDR(1)="Available Patient Lists."
     66 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     67 Q
     68 ;
     69HLP ;Help code
     70 N ORU,ORUPRMT,SUB,XQORM
     71 S SUB="PXRMLPAH"
     72 D EN^VALM("PXRM PATIENT LIST HELP")
     73 Q
     74 ;
     75INIT ;Init
     76 S VALMCNT=0
     77 Q
     78 ;
     79PEXIT ;PXRM MENU protocol exit code
     80 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     81 ;Reset after page up/down etc
     82 D XQORM
     83 Q
     84 ;
     85ADD ;add a users
     86 N CREAT,CNT,DIC,DIE,FDA,MSG,USER,Y
     87 S CREAT=$P($G(^PXRMXP(810.5,IEN,0)),U,7)
     88 I $G(CREAT)'=DUZ D  G ADDE
     89 . W !,"Only the creator of this list can add an user." H 2
     90 D FULL^VALM1
     91 S DIC="^VA(200,"
     92 S DIC(0)="QAEB"
     93 S DIC("A")="Select Users: "
     94 D ^DIC
     95 I Y=-1 Q
     96 S USER=+Y
     97 K Y
     98 K DIROUT,DIRUT,DTOUT,DUOUT
     99 S DIR(0)="S^F:Full Control;V:View Only"
     100 S DIR("A")="Select level of control: "
     101 S DIR("B")="V"
     102 S DIR("?")="Enter F or V. For detailed help type ??"
     103 W !
     104 D ^DIR K DIR
     105 I $D(DIROUT) S DTOUT=1
     106 I $D(DTOUT)!($D(DUOUT)) Q
     107 I $G(Y)="" W !,"A status must be enter" H 2 Q
     108 S YESNO=$E(Y(0))
     109 S FDA(810.54,"+2,"_IEN_",",.01)=USER
     110 S FDA(810.54,"+2,"_IEN_",",1)=Y
     111 D UPDATE^DIE("","FDA","","MSG")
     112 I $D(MSG)>0 D AWRITE^PXRMUTIL("MSG") H 2
     113ADDE ;
     114 D BLDLIST
     115 S VALMBCK="R"
     116 Q
     117 ;
     118XQORM ;
     119 S XQORM("#")=$O(^ORD(101,"B","PXRM PATIENT LIST AUTH USER SELECT",0))_U_"1:"_VALMCNT
     120 S XQORM("A")="Select Item: "
     121 Q
     122 ;
     123XSEL ;PXRM SELECT COMPONENT validation
     124 N EPIEN,LISTIEN,LRIEN,SEL
     125 S SEL=$P(XQORNOD(0),"=",2)
     126 ;Remove trailing ,
     127 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     128 ;Invalid selection
     129 I SEL["," D  Q
     130 .W $C(7),!,"Only one item number allowed." H 2
     131 .S VALMBCK="R"
     132 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     133 .W $C(7),!,SEL_" is not a valid item number." H 2
     134 .S VALMBCK="R"
     135 ;Get the patient list ien
     136 S LISTIEN=^TMP("PXRMLPAU",$J,"IDX",SEL,SEL)
     137 ;Full screen mode
     138 D FULL^VALM1
     139 D PDELETE
     140 ;
     141 ;Option to Install, Delete or Install History
     142 ;
     143 S VALMBCK="R"
     144 Q
     145 ;
     146HELP(CALL) ;General help text routine
     147 N HTEXT
     148 ;
     149 I CALL=1 D
     150 .S HTEXT(1)="Select CO to copy patient list."
     151 .S HTEXT(2)="Select COE to copy patient list to OE/RR Team."
     152 .S HTEXT(3)="Select CR to delete patient list."
     153 .S HTEXT(4)="Select DSP to display patient list."
     154 ;
     155 D HELP^PXRMEUT(.HTEXT)
     156 Q
     157 ;
     158PDELETE ;Patient list delete
     159 ;
     160 ;Full Screen
     161 W IORESET
     162 ;
     163 N CREAT,IND,LISTIEN,NODE
     164 I DUZ'=$P($G(^PXRMXP(810.5,IEN,0)),U,7) D  G PDELEX
     165 .W !,"Only the creator of this list can delete an user." H 2
     166 D EN^VALM2(XQORNOD(0))
     167 ;If there is no list quit.
     168 I '$D(VALMY) D BLDLIST S VALMBCK="R" Q
     169 S IND="",PXRMDONE=0
     170 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     171 .;Get the patient list ien.
     172 .S LISTIEN=^TMP("PXRMLPAU",$J,"IDX",IND,IND)
     173 .S DA(1)=IEN,DA=LISTIEN,DIK="^PXRMXP(810.5,"_DA(1)_",40," D ^DIK
     174 .W !,"PATIENT DELETED"
     175 ;
     176PDELEX ;
     177 D BLDLIST
     178 ;
     179 S VALMBCK="R"
     180 Q
     181 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLPHS.m

    r613 r623  
    1 PXRMLPHS        ; SLC/PJH,PKR - Run Health Summaries from Patient List ;03/26/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;External Ref DBIA #398
    5         ;
    6 HSA(LISTIEN)    ;Run health summary for all patients on this patient list.
    7         N HSIEN,PLNODE
    8         ;Initialise
    9         D FULL^VALM1
    10         ;Reset screen mode
    11         W IORESET
    12         ;
    13         ;Select Health Summary
    14         D HSEL(.HSIEN) Q:$D(DTOUT)!$D(DUOUT)
    15         ;
    16         S PLNODE="PXRMLPHS"_$J_$$NOW^XLFDT
    17         K ^XTMP(PLNODE)
    18         S ^XTMP(PLNODE,0)=$$FMADD^XLFDT(DT,2)_U_DT_"HSI LIST"
    19         D SORT(LISTIEN,PLNODE)
    20         D QUE(HSIEN,PLNODE)
    21         Q
    22         ;
    23 HSEL(IEN)       ;Select Health Summary Type
    24         N X,Y,DIC
    25 HS1     S DIC=142,DIC(0)="QAEMZ"
    26         S DIC("A")="Select HEALTH SUMMARY TYPE: "
    27         W !
    28         D ^DIC
    29         I X="" W !,"A health summary type name must be entered" G HS1
    30         I X=(U_U) S DTOUT=1
    31         I Y=-1 S DUOUT=1
    32         I $D(DTOUT)!$D(DUOUT) Q
    33         ;Return HS ien
    34         S IEN=$P(Y,U)
    35         Q
    36         ;
    37 HSI(PLNODE)     ;Print health summary for selected patients.
    38         N HSIEN
    39         ;Initialise
    40         D FULL^VALM1
    41         ;Reset screen mode
    42         W IORESET
    43         ;
    44         ;Select Health Summary
    45         D HSEL(.HSIEN) Q:$D(DTOUT)!$D(DUOUT)
    46         D QUE(HSIEN,PLNODE)
    47         Q
    48         ;
    49 PRINT(HSIEN,PLNODE)     ;Print HS for Patient List IEN
    50         N DFN,DIROUT,SUB
    51         ;Print HS for each patient
    52         S SUB=0
    53         F  S SUB=$O(^XTMP(PLNODE,SUB)) Q:(SUB="")!$D(DIROUT)  D
    54         .S DFN=^XTMP(PLNODE,SUB)
    55         .D ENX^GMTSDVR(DFN,HSIEN,"","") ; DBIA #398
    56         ;
    57         ;Clear workfile
    58         K ^XTMP(PLNODE)
    59         Q
    60         ;
    61 QUE(HSIEN,PLNODE)       ;Determine whether the report should be queued.
    62         N PXRMQUE,%ZIS,ZTDESC,ZTRTN,ZTSK,ZTSAVE
    63         S %ZIS="M"
    64         S ZTDESC="Patient List Health Summaries - print"
    65         S ZTRTN="PRINT^PXRMLPHS(HSIEN,PLNODE)"
    66         S ZTSAVE("HSIEN")=""
    67         S ZTSAVE("PLNODE")=""
    68         S PXRMQUE=$$DEVICE^PXRMXQUE(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS,1)
    69         S VALMBCK="R"
    70         Q
    71         ;
    72 SORT(LISTIEN,PLNODE)    ;Sort workfile as required
    73         N DATA,DFN,IND,PNAME
    74         ;Build the list in alphabetical order.
    75         S IND=0
    76         F  S IND=$O(^PXRMXP(810.5,LISTIEN,30,IND)) Q:'IND  D
    77         .S DATA=$G(^PXRMXP(810.5,LISTIEN,30,IND,0)) Q:DATA=""
    78         .S DFN=$P(DATA,U) Q:'DFN
    79         .;DBIA #10035
    80         .S PNAME=$P(^DPT(DFN,0),U,1) Q:PNAME=""
    81         .S ^XTMP(PLNODE,PNAME)=DFN
    82         Q
    83         ;
     1PXRMLPHS ; SLC/PJH,PKR - Run Health Summaries from Patient List ;08/08/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;External Ref DBIA #398
     5 ;
     6HSA(LISTIEN) ;Run health summary for all patients on this patient list.
     7 N HSIEN,PLNODE
     8 ;Initialise
     9 D FULL^VALM1
     10 ;Reset screen mode
     11 W IORESET
     12 ;
     13 ;Select Health Summary
     14 D HSEL(.HSIEN) Q:$D(DTOUT)!$D(DUOUT)
     15 ;
     16 S PLNODE="PXRMLPHS"_$J_$$NOW^XLFDT
     17 K ^XTMP(PLNODE)
     18 S ^XTMP(PLNODE,0)=$$FMADD^XLFDT(DT,2)_U_DT_"HSI LIST"
     19 D SORT(LISTIEN,PLNODE)
     20 D QUE(HSIEN,PLNODE)
     21 Q
     22 ;
     23HSEL(IEN) ;Select Health Summary Type
     24 N X,Y,DIC
     25HS1 S DIC=142,DIC(0)="QAEMZ"
     26 S DIC("A")="Select HEALTH SUMMARY TYPE: "
     27 W !
     28 D ^DIC
     29 I X="" W !,"A health summary type name must be entered" G HS1
     30 I X=(U_U) S DTOUT=1
     31 I Y=-1 S DUOUT=1
     32 I $D(DTOUT)!$D(DUOUT) Q
     33 ;Return HS ien
     34 S IEN=$P(Y,U)
     35 Q
     36 ;
     37HSI(PLNODE) ;Print health summary for selected patients.
     38 N HSIEN
     39 ;Initialise
     40 D FULL^VALM1
     41 ;Reset screen mode
     42 W IORESET
     43 ;
     44 ;Select Health Summary
     45 D HSEL(.HSIEN) Q:$D(DTOUT)!$D(DUOUT)
     46 D QUE(HSIEN,PLNODE)
     47 Q
     48 ;
     49PRINT(HSIEN,PLNODE) ;Print HS for Patient List IEN
     50 N DFN,DIROUT,SUB
     51 ;Print HS for each patient
     52 S SUB=0
     53 F  S SUB=$O(^XTMP(PLNODE,SUB)) Q:(SUB="")!$D(DIROUT)  D
     54 .S DFN=^XTMP(PLNODE,SUB)
     55 .D ENX^GMTSDVR(DFN,HSIEN,"","") ; DBIA #398
     56 ;
     57 ;Clear workfile
     58 K ^XTMP(PLNODE)
     59 Q
     60 ;
     61QUE(HSIEN,PLNODE) ;Determine whether the report should be queued.
     62 N PXRMQUE,RETZTSK,%ZIS,ZTDESC,ZTRTN,ZTSK,ZTSAVE
     63 S %ZIS="M"
     64 S ZTDESC="Patient List Health Summaries - print"
     65 S ZTRTN="PRINT^PXRMLPHS(HSIEN,PLNODE)"
     66 S ZTSAVE("HSIEN")=""
     67 S ZTSAVE("PLNODE")=""
     68 S RETZTSK=1
     69 S PXRMQUE=$$DEVICE^PXRMXQUE(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS,.RETZTSK)
     70 S VALMBCK="R"
     71 Q
     72 ;
     73SORT(LISTIEN,PLNODE) ;Sort workfile as required
     74 N DATA,DFN,IND,PNAME
     75 ;Build the list in alphabetical order.
     76 S IND=0
     77 F  S IND=$O(^PXRMXP(810.5,LISTIEN,30,IND)) Q:'IND  D
     78 .S DATA=$G(^PXRMXP(810.5,LISTIEN,30,IND,0)) Q:DATA=""
     79 .S DFN=$P(DATA,U) Q:'DFN
     80 .;DBIA #10035
     81 .S PNAME=$P(^DPT(DFN,0),U,1) Q:PNAME=""
     82 .S ^XTMP(PLNODE,PNAME)=DFN
     83 Q
     84 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLPP.m

    r613 r623  
    1 PXRMLPP ; SLC/PKR/PJH - Reminder Patient List Patients ;04/04/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM PATIENT LIST
    5 START(IEN)      ;
    6         N CDATE,CLASS,CREATOR,INDP,INTP,LDATA,LNAME,PXRMVIEW,SNAME,SOURCE,TYPE
    7         N VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    8         ;Get Patient List record and associated data.
    9         S LDATA=$G(^PXRMXP(810.5,IEN,0))
    10         S LNAME=$P(LDATA,U,1)
    11         S CDATE=$P(LDATA,U,4)
    12         S SOURCE=$P(LDATA,U,5),SNAME=""
    13         ;Check if generated from #810.2
    14         I SOURCE S SNAME="Extract Parameter - "_$P($G(^PXRM(810.2,SOURCE,0)),U)
    15         ;If not check if generated from #810.4
    16         I SNAME="" D
    17         . S SOURCE=$P(LDATA,U,6)
    18         . I SOURCE'="" S SNAME="List Rule - "_$P($G(^PXRM(810.4,SOURCE,0)),U)
    19         ;If still no source check for created from Reminder Due Report.
    20         I SNAME="" D
    21         . S SOURCE=$P(LDATA,U,9)
    22         . I SOURCE'="" S SNAME="Reminder Due Report"
    23         ;If there still is no source then assume it was generated in the
    24         ;past by a Reminder Due Report.
    25         I SNAME="" S SNAME="Reminder Due Report"
    26         ;Creator
    27         S CREATOR=+$P(LDATA,U,7)
    28         S CREATOR=$S(CREATOR>0:$$GET1^DIQ(200,CREATOR,.01),1:"None")
    29         ;Type
    30         S TYPE=$P(LDATA,U,8)
    31         S TYPE=$$EXTERNAL^DILFD(810.5,.08,"",TYPE,.EM)
    32         ;Class
    33         S CLASS=$P($G(^PXRMXP(810.5,IEN,100)),U)
    34         S CLASS=$S(CLASS="N":"National",CLASS="V":"VISN",1:"Local")
    35         S INDP=$P(LDATA,U,11)
    36         S INTP=$P(LDATA,U,12)
    37         ;Default view by name.
    38         S PXRMVIEW="N"
    39         S VALMCNT=0
    40         D EN^VALM("PXRM PATIENT LIST PATIENTS")
    41         Q
    42         ;
    43 BLDLIST(IEN)    ;Build a list of all patients
    44         N IND,INCINST
    45         S INCINST=+$P(^PXRMXP(810.5,IEN,0),U,10)
    46         I 'INCINST D CHGCAP^VALM("HEADER3","")
    47         K ^TMP("PXRMLPP",$J),^TMP("PXRMLPPA",$J),^TMP("PXRMLPPI",$J)
    48         D LIST(.VALMCNT,.IEN,INCINST)
    49         F IND=1:1:VALMCNT D
    50         .S ^TMP("PXRMLPP",$J,"IDX",IND,IND)=^TMP("PXRMLPPI",$J,IND)
    51         K ^TMP("PXRMLPPI",$J)
    52         Q
    53 DEM     ;
    54         D FULL^VALM1
    55         D EN^PXRMPDR(IEN)
    56         S VALMBCK="R"
    57         Q
    58         ;
    59 EDIT    ;Edit selected patient list fields.
    60         N DA,DIE,DR,TEMP
    61         S DA=IEN,DIE="^PXRMXP(810.5,"
    62         S DR=".01;.08"
    63         I $D(^XUSEC("PXRM MANAGER",DUZ)) S DR=DR_";.07"
    64         D ^DIE
    65         S TEMP=^PXRMXP(810.5,IEN,0)
    66         S LNAME=$P(TEMP,U,1),CREATOR=$P(TEMP,U,7),TYPE=$P(TEMP,U,8)
    67         S CREATOR=$P(^VA(200,CREATOR,0),U,1)
    68         D HDR^PXRMLPP
    69         S VALMBCK="R"
    70         Q
    71         ;
    72 EDITOK(IEN)     ;Screen for protocol PXRM PATIENT LIST EDIT, return true if
    73         ;the user is permitted to edit the selected patient list.
    74         I $D(^XUSEC("PXRM MANAGER",DUZ)) Q 1
    75         N CREATOR
    76         S CREATOR=$P(^PXRMXP(810.5,IEN,0),U,7)
    77         Q $S(CREATOR=DUZ:1,1:0)
    78         ;
    79 ENTRY   ;Entry code
    80         D BLDLIST(IEN)
    81         D XQORM
    82         Q
    83         ;
    84 EXIT    ;Exit code
    85         K ^TMP("PXRMLPP",$J)
    86         K ^TMP("PXRMLPPH",$J)
    87         D CLEAN^VALM10
    88         D FULL^VALM1
    89         S VALMBCK="R"
    90         Q
    91         ;
    92 FRE(NUMBER,PNAME,DFN,DECEASED,TESTP,INST)       ;Format  entry number, name, primary
    93         ;station and deceased, test information.
    94         N TEMP,TEXT,TNAME,TSOURCE
    95         S TEXT=$$RJ^XLFSTR(NUMBER,5," ")
    96         S TEXT=$$SETFLD^VALM1(PNAME,TEXT,"HEADER1")
    97         S TEXT=TEXT_"  "_$$LJ^XLFSTR(DFN,15," ")
    98         S TEMP=""
    99         I DECEASED S TEMP=" (D)"
    100         I TESTP S TEMP=" (T)"
    101         I DECEASED,TESTP S TEMP=" (DP)"
    102         S TEXT=TEXT_TEMP
    103         I INST'="" S TEXT=$$SETFLD^VALM1(INST,TEXT,"HEADER3")
    104         Q TEXT
    105         ;
    106 HDR     ; Header code
    107         N TEXT
    108         S VALMHDR(1)="List Name: "_LNAME
    109         S VALMHDR(2)=" Created: "_$$FMTE^XLFDT(CDATE,"5Z")
    110         S VALMHDR(2)=$$LJ^XLFSTR(VALMHDR(2),40)_"Creator: "_CREATOR
    111         S VALMHDR(3)=" Class: "_CLASS
    112         S VALMHDR(3)=$$LJ^XLFSTR(VALMHDR(3),40)_"Type: "_TYPE
    113         S VALMHDR(4)=" Source: "_SNAME
    114         S VALMHDR(5)=" Number of patients: "_VALMCNT
    115         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    116         S TEXT=""
    117         I INDP S TEXT=" (D=deceased)"
    118         I INTP S TEXT=" (T=test)"
    119         I INDP,INTP S TEXT=" (D=deceased, T=test)"
    120         S TEXT="DFN"_TEXT
    121         D CHGCAP^VALM("HEADER2",TEXT)
    122         Q
    123         ;
    124 HLP     ;Help code
    125         N ORU,ORUPRMT,SUB,XQORM
    126         S SUB="PXRMLPPH"
    127         D EN^VALM("PXRM PATIENT LIST HELP")
    128         Q
    129 HSA     ;Print Health Summary for all patients on list
    130         D HSA^PXRMLPHS(IEN)
    131         S VALMBCK="R"
    132         Q
    133         ;
    134 HSI     ;Print Health Summary for selected patients.
    135         ;Full Screen
    136         W IORESET
    137         N IND,DFN,PLNODE,PNAME,VALMY
    138         D EN^VALM2(XQORNOD(0))
    139         ;If there is no list quit.
    140         I '$D(VALMY) Q
    141         S PLNODE="PXRMLPHS"_$J_$$NOW^XLFDT
    142         K ^XTMP(PLNODE)
    143         S ^XTMP(PLNODE,0)=$$FMADD^XLFDT(DT,2)_U_DT_"HSI LIST"
    144         S IND="",PXRMDONE=0
    145         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    146         .;Get the patient list ien.
    147         .S DFN=^TMP("PXRMLPP",$J,"IDX",IND,IND)
    148         .;DBIA #10035
    149         .S PNAME=$P(^DPT(DFN,0),U,1)
    150         .I PNAME="" S PNAME=DFN_" does not exist"
    151         .S ^XTMP(PLNODE,PNAME)=DFN
    152         D HSI^PXRMLPHS(PLNODE)
    153         S VALMBCK="R"
    154         Q
    155         ;
    156 INIT    ;Init
    157         S VALMCNT=0
    158         Q
    159         ;
    160 LIST(VALMCNT,IEN,INCINST)       ;Build a list of patients.
    161         N DATA,DECEASED,DFN,IND,INST,NEXT,PNAME,SUB,TESTP
    162         ;Build the ordered list.
    163         S IND=0,SUB="NAME"
    164         F  S IND=$O(^PXRMXP(810.5,IEN,30,IND)) Q:'IND  D
    165         .S DATA=$G(^PXRMXP(810.5,IEN,30,IND,0)) Q:DATA=""
    166         .S DFN=$P(DATA,U) Q:'DFN
    167         .S DECEASED=$P(DATA,U,4)
    168         .S TESTP=$P(DATA,U,5)
    169         .;#DBIA 10035
    170         .S PNAME=$P($G(^DPT(DFN,0)),U,1)
    171         .I PNAME="" S PNAME=DFN_" does not exist"
    172         .S INSTNUM=$P(DATA,U,2) S:INSTNUM="" INSTNUM="NONE"
    173         .S INST=$P(DATA,U,3)
    174         .;Lists built before PXRM*2*4 will only have the Institution ien.
    175         .I INST="" S INST=$P(DATA,U,2)
    176         .I INST="" S INST="NONE"
    177         .I PXRMVIEW="I" S SUB=INST
    178         .S ^TMP("PXRMLPPA",$J,SUB,PNAME,DFN)=DECEASED_U_TESTP_U_INST
    179         ;Transfer to list manager array
    180         S SUB="",VALMCNT=0
    181         F  S SUB=$O(^TMP("PXRMLPPA",$J,SUB)) Q:SUB=""  D
    182         .S (INST,PNAME)=""
    183         .F  S PNAME=$O(^TMP("PXRMLPPA",$J,SUB,PNAME)) Q:PNAME=""  D
    184         ..S DFN=""
    185         ..F  S DFN=$O(^TMP("PXRMLPPA",$J,SUB,PNAME,DFN)) Q:DFN=""  D
    186         ...S DATA=^TMP("PXRMLPPA",$J,SUB,PNAME,DFN)
    187         ...S DECEASED=$P(DATA,U,1)
    188         ...S TESTP=$P(DATA,U,2)
    189         ...I INCINST S INST=$P(DATA,U,3)
    190         ...S VALMCNT=VALMCNT+1
    191         ...S ^TMP("PXRMLPP",$J,VALMCNT,0)=$$FRE(VALMCNT,PNAME,DFN,DECEASED,TESTP,INST)
    192         ...S ^TMP("PXRMLPPI",$J,VALMCNT)=DFN
    193         K ^TMP("PXRMLPPA",$J)
    194         Q
    195         ;
    196 PEXIT   ;PXRM PATIENT LIST PATIENTS MENU protocol exit code
    197         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    198         D XQORM
    199         Q
    200         ;
    201 USER    ;
    202         I $P($G(^PXRMXP(810.5,IEN,0)),U,8)="PUB" D FULL^VALM1 W !,"This option is locked for Public Lists." H 2 Q
    203         D FULL^VALM1
    204         D START^PXRMLPAU(IEN)
    205         S VALMBCK="R"
    206         Q
    207         ;
    208 USR(IEN)        ;Screen for protocol PXRM PATIENT LIST AUTH USER
    209         N TYPE
    210         S TYPE=$P(^PXRMXP(810.5,IEN,0),U,8)
    211         ;Public lists cannot have individual user access.
    212         I TYPE="PUB" Q "N"
    213         Q $$ACCESS^PXRMLPU(IEN)
    214         ;
    215 VIEW    ;Select view
    216         W IORESET
    217         S VALMBCK="R",VALMBG=1
    218         N X,Y,CODE,DIR
    219         K DIROUT,DIRUT,DTOUT,DUOUT
    220         S DIR(0)="S"_U_"I:Sort by Institution and Name;"
    221         S DIR(0)=DIR(0)_"N:Sort by Name;"
    222         S DIR("A")="TYPE OF VIEW"
    223         S DIR("B")=$S(PXRMVIEW="N":"I",1:"N")
    224         S DIR("?")="Select from the codes displayed."
    225         D ^DIR K DIR
    226         I $D(DIROUT) S DTOUT=1
    227         I $D(DTOUT)!($D(DUOUT)) Q
    228         ;Change display type
    229         S PXRMVIEW=Y
    230         ;Rebuild Workfile
    231         D BLDLIST^PXRMLPP(IEN),HDR
    232         Q
    233         ;
    234 XSEL    ;PXRM PATIENT LIST PATIENT SELECT validation
    235         N EPIEN,DFN,SEL
    236         S SEL=$P(XQORNOD(0),"=",2)
    237         ;Remove trailing ,
    238         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    239         ;Invalid selection
    240         I SEL["," D  Q
    241         .W $C(7),!,"Only one item number allowed." H 2
    242         .S VALMBCK="R"
    243         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
    244         .W $C(7),!,SEL_" is not a valid item number." H 2
    245         .S VALMBCK="R"
    246         ;
    247         ;Get the patient list ien
    248         S DFN=^TMP("PXRMLPP",$J,"IDX",SEL,SEL)
    249         ;Full screen mode
    250         D FULL^VALM1
    251         ;Print individual Health Summary
    252         D HSI^PXRMLPHS(DFN)
    253         S VALMBCK="R"
    254         Q
    255         ;
    256 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM PATIENT LIST PATIENT SELECT",0))_U_"1:"_VALMCNT
    257         S XQORM("A")="Select Item: "
    258         Q
    259         ;
     1PXRMLPP ; SLC/PKR/PJH - Reminder Patient List Patients ;01/06/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM PATIENT LIST
     5START(IEN) ;
     6 N CDATE,CLASS,CREATOR,LDATA,LNAME,PXRMVIEW,SNAME,SOURCE,TYPE
     7 N VALMBCK,VALMBG,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     8 ;Get Patient List record and associated data.
     9 S LDATA=$G(^PXRMXP(810.5,IEN,0))
     10 S LNAME=$P(LDATA,U,1)
     11 S CDATE=$P(LDATA,U,4)
     12 S SOURCE=$P(LDATA,U,5),SNAME=""
     13 ;Check if generated from #810.2
     14 I SOURCE S SNAME="Extract Parameter - "_$P($G(^PXRM(810.2,SOURCE,0)),U)
     15 ;If not check if generated from #810.4
     16 I SNAME="" D
     17 . S SOURCE=$P(LDATA,U,6)
     18 . I SOURCE'="" S SNAME="List Rule - "_$P($G(^PXRM(810.4,SOURCE,0)),U)
     19 ;If still no source check for created from Reminder Due Report.
     20 I SNAME="" D
     21 . S SOURCE=$P(LDATA,U,9)
     22 . I SOURCE'="" S SNAME="Reminder Due Report"
     23 ;If there still is no source then assume it was generated in the
     24 ;past by a Reminder Due Report.
     25 I SNAME="" S SNAME="Reminder Due Report"
     26 ;Creator
     27 S CREATOR=+$P(LDATA,U,7)
     28 S CREATOR=$S(CREATOR>0:$$GET1^DIQ(200,CREATOR,.01),1:"None")
     29 ;Type
     30 S TYPE=$P(LDATA,U,8)
     31 S TYPE=$$EXTERNAL^DILFD(810.5,.08,"",TYPE,.EM)
     32 ;Class
     33 S CLASS=$P($G(^PXRMXP(810.5,IEN,100)),U)
     34 S CLASS=$S(CLASS="N":"National",CLASS="V":"VISN",1:"Local")
     35 ;Default view by name.
     36 S PXRMVIEW="N"
     37 S VALMCNT=0
     38 D EN^VALM("PXRM PATIENT LIST PATIENTS")
     39 Q
     40 ;
     41BLDLIST(IEN) ;Build a list of all patients
     42 N IND,INCINST
     43 S INCINST=+$P(^PXRMXP(810.5,IEN,0),U,10)
     44 I 'INCINST D CHGCAP^VALM("HEADER3","")
     45 K ^TMP("PXRMLPP",$J),^TMP("PXRMLPPA",$J),^TMP("PXRMLPPI",$J)
     46 D LIST(.VALMCNT,.IEN,INCINST)
     47 F IND=1:1:VALMCNT D
     48 .S ^TMP("PXRMLPP",$J,"IDX",IND,IND)=^TMP("PXRMLPPI",$J,IND)
     49 K ^TMP("PXRMLPPI",$J)
     50 Q
     51DEM ;
     52 D FULL^VALM1
     53 D EN^PXRMPDR(IEN)
     54 S VALMBCK="R"
     55 Q
     56 ;
     57EDIT ;Edit selected patient list fields.
     58 N DA,DIE,DR,TEMP
     59 S DA=IEN,DIE="^PXRMXP(810.5,"
     60 S DR=".01;.08"
     61 I $D(^XUSEC("PXRM MANAGER",DUZ)) S DR=DR_";.07"
     62 D ^DIE
     63 S TEMP=^PXRMXP(810.5,IEN,0)
     64 S LNAME=$P(TEMP,U,1),CREATOR=$P(TEMP,U,7),TYPE=$P(TEMP,U,8)
     65 S CREATOR=$P(^VA(200,CREATOR,0),U,1)
     66 D HDR^PXRMLPP
     67 S VALMBCK="R"
     68 Q
     69 ;
     70EDITOK(IEN) ;Screen for protocol PXRM PATIENT LIST EDIT, return true if
     71 ;the user is permitted to edit the selected patient list.
     72 I $D(^XUSEC("PXRM MANAGER",DUZ)) Q 1
     73 N CREATOR
     74 S CREATOR=$P(^PXRMXP(810.5,IEN,0),U,7)
     75 Q $S(CREATOR=DUZ:1,1:0)
     76 ;
     77ENTRY ;Entry code
     78 D BLDLIST(IEN)
     79 D XQORM
     80 Q
     81 ;
     82EXIT ;Exit code
     83 K ^TMP("PXRMLPP",$J)
     84 K ^TMP("PXRMLPPH",$J)
     85 D CLEAN^VALM10
     86 D FULL^VALM1
     87 S VALMBCK="R"
     88 Q
     89 ;
     90FRE(NUMBER,NAME,INST,DFN) ;Format  entry number, name and primary station
     91 N TEMP,TNAME,TSOURCE
     92 S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
     93 S TNAME=$E(NAME,1,30)
     94 S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,32," ")
     95 S TEMP=TEMP_"  "_$$LJ^XLFSTR(DFN,15," ")
     96 I INST'="" S TEMP=TEMP_"  "_INST
     97 Q TEMP
     98 ;
     99HDR ; Header code
     100 S VALMHDR(1)="List Name: "_LNAME_" ("_VALMCNT_" patients)"
     101 S VALMHDR(2)=" Created: "_$$FMTE^XLFDT(CDATE,"5Z")
     102 S VALMHDR(2)=$$LJ^XLFSTR(VALMHDR(2),40)_"Creator: "_CREATOR
     103 S VALMHDR(3)=" Class: "_CLASS
     104 S VALMHDR(3)=$$LJ^XLFSTR(VALMHDR(3),40)_"Type: "_TYPE
     105 S VALMHDR(4)=" Source: "_SNAME
     106 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     107 Q
     108 ;
     109HLP ;Help code
     110 N ORU,ORUPRMT,SUB,XQORM
     111 S SUB="PXRMLPPH"
     112 D EN^VALM("PXRM PATIENT LIST HELP")
     113 Q
     114HSA ;Print Health Summary for all patients on list
     115 D HSA^PXRMLPHS(IEN)
     116 S VALMBCK="R"
     117 Q
     118 ;
     119HSI ;Print Health Summary for selected patients.
     120 ;Full Screen
     121 W IORESET
     122 N IND,DFN,PLNODE,PNAME,VALMY
     123 D EN^VALM2(XQORNOD(0))
     124 ;If there is no list quit.
     125 I '$D(VALMY) Q
     126 S PLNODE="PXRMLPHS"_$J_$$NOW^XLFDT
     127 K ^XTMP(PLNODE)
     128 S ^XTMP(PLNODE,0)=$$FMADD^XLFDT(DT,2)_U_DT_"HSI LIST"
     129 S IND="",PXRMDONE=0
     130 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     131 .;Get the patient list ien.
     132 .S DFN=^TMP("PXRMLPP",$J,"IDX",IND,IND)
     133 .;DBIA #10035
     134 .S PNAME=$P(^DPT(DFN,0),U,1)
     135 .S ^XTMP(PLNODE,PNAME)=DFN
     136 D HSI^PXRMLPHS(PLNODE)
     137 S VALMBCK="R"
     138 Q
     139 ;
     140INIT ;Init
     141 S VALMCNT=0
     142 Q
     143 ;
     144LIST(VALMCNT,IEN,INCINST) ;Build a list of patients.
     145 N DATA,DFN,IND,INST,NEXT,PNAME,SUB
     146 ;Build the ordered list.
     147 S IND=0,SUB="NAME"
     148 F  S IND=$O(^PXRMXP(810.5,IEN,30,IND)) Q:'IND  D
     149 .S DATA=$G(^PXRMXP(810.5,IEN,30,IND,0)) Q:DATA=""
     150 .S DFN=$P(DATA,U) Q:'DFN
     151 .;#DBIA 10035
     152 .S PNAME=$P($G(^DPT(DFN,0)),U,1)
     153 .S INSTNUM=$P(DATA,U,2) S:INSTNUM="" INSTNUM="NONE"
     154 .S INST=$P(DATA,U,3)
     155 .;Lists built before PXRM*2*4 will only have the Institution ien.
     156 .I INST="" S INST=$P(DATA,U,2)
     157 .I INST="" S INST="NONE"
     158 .I PXRMVIEW="I" S SUB=INST
     159 .S ^TMP("PXRMLPPA",$J,SUB,PNAME,DFN)=INST
     160 ;Transfer to list manager array
     161 S SUB="",VALMCNT=0
     162 F  S SUB=$O(^TMP("PXRMLPPA",$J,SUB)) Q:SUB=""  D
     163 .S (INST,PNAME)=""
     164 .F  S PNAME=$O(^TMP("PXRMLPPA",$J,SUB,PNAME)) Q:PNAME=""  D
     165 ..S DFN=""
     166 ..F  S DFN=$O(^TMP("PXRMLPPA",$J,SUB,PNAME,DFN)) Q:DFN=""  D
     167 ...I INCINST S INST=^TMP("PXRMLPPA",$J,SUB,PNAME,DFN)
     168 ...S VALMCNT=VALMCNT+1
     169 ...S ^TMP("PXRMLPP",$J,VALMCNT,0)=$$FRE(VALMCNT,PNAME,INST,DFN)
     170 ...S ^TMP("PXRMLPPI",$J,VALMCNT)=DFN
     171 K ^TMP("PXRMLPPA",$J)
     172 Q
     173 ;
     174PEXIT ;PXRM PATIENT LIST PATIENTS MENU protocol exit code
     175 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     176 D XQORM
     177 Q
     178 ;
     179USER ;
     180 I $P($G(^PXRMXP(810.5,IEN,0)),U,8)="PUB" D FULL^VALM1 W !,"This option is locked for Public Lists." H 2 Q
     181 D FULL^VALM1
     182 D START^PXRMLPAU(IEN)
     183 S VALMBCK="R"
     184 Q
     185 ;
     186USR(IEN) ;Screen for protocol PXRM PATIENT LIST AUTH USER
     187 N TYPE
     188 S TYPE=$P(^PXRMXP(810.5,IEN,0),U,8)
     189 ;Public lists cannot have individual user access.
     190 I TYPE="PUB" Q "N"
     191 Q $$ACCESS^PXRMLPU(IEN)
     192 ;
     193VIEW ;Select view
     194 W IORESET
     195 S VALMBCK="R",VALMBG=1
     196 N X,Y,CODE,DIR
     197 K DIROUT,DIRUT,DTOUT,DUOUT
     198 S DIR(0)="S"_U_"I:Sort by Institution and Name;"
     199 S DIR(0)=DIR(0)_"N:Sort by Name;"
     200 S DIR("A")="TYPE OF VIEW"
     201 S DIR("B")=$S(PXRMVIEW="N":"I",1:"N")
     202 S DIR("?")="Select from the codes displayed."
     203 D ^DIR K DIR
     204 I $D(DIROUT) S DTOUT=1
     205 I $D(DTOUT)!($D(DUOUT)) Q
     206 ;Change display type
     207 S PXRMVIEW=Y
     208 ;Rebuild Workfile
     209 D BLDLIST^PXRMLPP(IEN),HDR
     210 Q
     211 ;
     212XSEL ;PXRM PATIENT LIST PATIENT SELECT validation
     213 N EPIEN,DFN,SEL
     214 S SEL=$P(XQORNOD(0),"=",2)
     215 ;Remove trailing ,
     216 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     217 ;Invalid selection
     218 I SEL["," D  Q
     219 .W $C(7),!,"Only one item number allowed." H 2
     220 .S VALMBCK="R"
     221 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     222 .W $C(7),!,SEL_" is not a valid item number." H 2
     223 .S VALMBCK="R"
     224 ;
     225 ;Get the patient list ien
     226 S DFN=^TMP("PXRMLPP",$J,"IDX",SEL,SEL)
     227 ;Full screen mode
     228 D FULL^VALM1
     229 ;Print individual Health Summary
     230 D HSI^PXRMLPHS(DFN)
     231 S VALMBCK="R"
     232 Q
     233 ;
     234XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM PATIENT LIST PATIENT SELECT",0))_U_"1:"_VALMCNT
     235 S XQORM("A")="Select Item: "
     236 Q
     237 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLPU.m

    r613 r623  
    1 PXRMLPU ; SLC/PKR/PJH - Reminder Patient List ;10/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM PATIENT LIST
    5 START(MODE)     ;
    6         N PXRMDONE,VALMBCK,VALMSG,X,XMZ,MODE1
    7         S X="IORESET"
    8         D ENDR^%ZISS
    9         S VALMCNT=0
    10         D EN^VALM("PXRM PATIENT LIST USER")
    11         W IORESET
    12         D KILL^%ZISS
    13         Q
    14         ;
    15 ACCESS(IEN,NODE)        ;
    16         ;Holders of the PXRM MANAGER key have full access to all lists.
    17         ;DBIA #10076
    18         I $D(^XUSEC("PXRM MANAGER",DUZ)) Q "F"
    19         N ACCESS,TYPE
    20         I $G(NODE)="" S NODE=$G(^PXRMXP(810.5,IEN,0))
    21         S TYPE=$P(NODE,U,8)
    22         I TYPE="" Q "F"
    23         I TYPE="PUB" Q "F"
    24         I $P(NODE,U,7)=DUZ Q "F"
    25         S ACCESS="N"
    26         I TYPE="PVT",$D(^PXRMXP(810.5,IEN,40,"B",DUZ)) D
    27         . N USIEN,STATUS
    28         . S USIEN=$O(^PXRMXP(810.5,IEN,40,"B",DUZ,""))
    29         . S ACCESS=$S(USIEN="":"N",1:$P(^PXRMXP(810.5,IEN,40,USIEN,0),U,2))
    30         Q ACCESS
    31         ;
    32 BLDLIST ;
    33         N PLIST
    34         K ^TMP("PXRMLPU",$J)
    35         K ^TMP("PXRMLPUH",$J)
    36         S PLIST="PXRMLPU"
    37         D LIST(MODE,PLIST)
    38         S VALMCNT=+$G(^TMP("PXRMLPU",$J,"VALMCNT"))
    39         Q
    40         ;
    41 ENTRY   ;Entry code
    42         ;MODE=0 ORDER BY NAME
    43         ;MODE=1 ORDER BY TYPE
    44         I $G(MODE)'>0 S MODE=0
    45         D BLDLIST,XQORM
    46         Q
    47         ;
    48 EXIT    ;Exit code
    49         K ^TMP("PXRMLPU",$J)
    50         K ^TMP("PXRMLPUH",$J)
    51         D CLEAN^VALM10
    52         D FULL^VALM1
    53         S VALMBCK="R"
    54         Q
    55         ;
    56 HDR     ; Header code
    57         N NAME
    58         S VALMHDR(1)="Available Patient Lists."
    59         Q
    60         ;
    61 HELP(CALL)      ;General help text routine
    62         N HTEXT
    63         I CALL=1 D
    64         .S HTEXT(1)="Select CO to copy the patient list.\\"
    65         .S HTEXT(2)="Select COE to copy the patient list to an OE/RR Team.\\"
    66         .S HTEXT(3)="Select DE to delete the patient list.\\"
    67         .S HTEXT(4)="Select DCD to display creation documentation.\\"
    68         .S HTEXT(5)="Select DSP to display the patient list.\\"
    69         D HELP^PXRMEUT(.HTEXT)
    70         Q
    71         ;
    72 HLP     ;Help code
    73         N ORU,ORUPRMT,SUB,XQORM
    74         S SUB="PXRMLPUH"
    75         D EN^VALM("PXRM PATIENT LIST HELP")
    76         Q
    77         ;
    78 INIT    ;Init
    79         S VALMCNT=0
    80         Q
    81         ;
    82 LIST(MODE,PLIST)        ;Build a list of patient list entries.
    83         N ACCESS,COUNT,DATA,DATE,IND,FMTSTR,FNAME,OUTPUT,NAME,NL,NUM
    84         N STR,SUB,TYPE
    85         S FMTSTR=$$LMFMTSTR^PXRMTEXT(.VALMDDF,"RLLRRC")
    86         ;MODE=0 build list in alphabetical order
    87         ;MODE=1 build list by type of list.
    88         K ^TMP($J,PLIST),^TMP(PLIST,$J)
    89         S VALMCNT=0,NAME="",NUM=0,TYPE=""
    90         F  S NAME=$O(^PXRMXP(810.5,"B",NAME)) Q:NAME=""  D
    91         .S IND="" F  S IND=$O(^PXRMXP(810.5,"B",NAME,IND)) Q:'IND  D
    92         ..S DATA=$G(^PXRMXP(810.5,IND,0))
    93         ..S ACCESS=$$ACCESS(IND,DATA)
    94         ..I ACCESS="N" Q
    95         ..S FNAME=$P($G(DATA),U),DATE=$P($G(DATA),U,4)
    96         ..S COUNT=+$P($G(^PXRMXP(810.5,IND,30,0)),U,4)
    97         ..S TYPE=$P(DATA,U,8)
    98         ..S SUB=$S(MODE=0:"NAME",1:TYPE)
    99         ..S ^TMP($J,PLIST,SUB,FNAME)=IND_U_DATE_U_COUNT_U_TYPE_U_ACCESS
    100         I '$D(^TMP($J,PLIST)) Q
    101         ;Loop through ARRAY to populate the output list
    102         ;sub is either the type of list or 'NAME'. If sort is
    103         ;by TYPE show PVT lists first.
    104         S SUB=""
    105         F  S SUB=$O(^TMP($J,PLIST,SUB),-1) Q:SUB=""  D
    106         . S FNAME=""
    107         . F  S FNAME=$O(^TMP($J,PLIST,SUB,FNAME)) Q:FNAME=""  D
    108         .. S DATA=^TMP($J,PLIST,SUB,FNAME),NUM=NUM+1
    109         .. S ^TMP("PXRMLPU",$J,"SEL",NUM)=$P(DATA,U,1)
    110         .. S DATE=$P(DATA,U,2),DATE=$$FMTE^XLFDT(DATE,2)
    111         .. S $P(DATA,U,2)=DATE
    112         .. S STR=NUM_U_FNAME_U_$P(DATA,U,2,5)
    113         .. D COLFMT^PXRMTEXT(FMTSTR,STR," ",.NL,.OUTPUT)
    114         .. F IND=1:1:NL D
    115         ... S VALMCNT=VALMCNT+1,^TMP(PLIST,$J,VALMCNT,0)=OUTPUT(IND)
    116         ... S ^TMP("PXRMLPU",$J,"IDX",VALMCNT,NUM)=""
    117         S ^TMP(PLIST,$J,"VALMCNT")=VALMCNT
    118         K ^TMP($J,PLIST)
    119         Q
    120         ;
    121 PCOPY   ;Patient list copy
    122         S SUB="PXRMLPU"
    123         D PCOPY1(SUB)
    124         D BLDLIST
    125         S VALMBCK="R"
    126         Q
    127         ;
    128 PCOPY1(SUB)     ;
    129         ;Full Screen
    130         W IORESET
    131         N IND,LISTIEN,VALMY
    132         D EN^VALM2(XQORNOD(0))
    133         ;If there is no list quit.
    134         I '$D(VALMY) Q
    135         S IND="",PXRMDONE=0
    136         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    137         .;Get the patient list ien.
    138         .S LISTIEN=^TMP(SUB,$J,"SEL",IND)
    139         .D COPY^PXRMRUL1(LISTIEN)
    140         Q
    141         ;
    142 PDELETE ;Patient list delete
    143         ;Full Screen
    144         W IORESET
    145         N DELOK,IND,LISTIEN,NODE,VALMY
    146         D EN^VALM2(XQORNOD(0))
    147         ;If there is no list quit.
    148         I '$D(VALMY) Q
    149         S IND="",PXRMDONE=0
    150         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    151         .;Get the patient list ien.
    152         .S LISTIEN=^TMP("PXRMLPU",$J,"SEL",IND)
    153         .S NODE=$G(^PXRMXP(810.5,LISTIEN,0))
    154         .S DELOK=$$LDELOK^PXRMEUT(LISTIEN)
    155         .I DELOK D DELETE^PXRMRUL1(LISTIEN) Q
    156         .E  D  Q
    157         ..W !,"In order to delete a list you must be the creator or a Reminder Manager!"
    158         ..S PXRMDONE=1 H 2
    159         D BLDLIST
    160         S VALMBCK="R"
    161         Q
    162         ;
    163 PEXIT   ;Protocol exit code
    164         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    165         ;Reset after page up/down etc
    166         D XQORM
    167         Q
    168         ;
    169 POERR   ;Patient list copy to OERR Team (#101.21)
    170         ;Full Screen
    171         W IORESET
    172         N ACCESS,IND,LISTIEN,NODE,USIEN,VALMY
    173         D EN^VALM2(XQORNOD(0))
    174         ;If there is no list quit.
    175         I '$D(VALMY) Q
    176         S IND="",PXRMDONE=0
    177         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    178         .;Get the patient list ien.
    179         .S LISTIEN=^TMP("PXRMLPU",$J,"SEL",IND)
    180         .S NODE=$G(^PXRMXP(810.5,LISTIEN,0))
    181         .S ACCESS=$$ACCESS^PXRMLPU(LISTIEN,NODE)
    182         .I ACCESS="F" D OERR^PXRMLPOE(LISTIEN)
    183         .I ACCESS="N" D
    184         ..W !,"The list cannot be copied; you must have full access to copy the list to an OE/RR team!"
    185         ..S PXRMDONE=1 H 2
    186         S VALMBCK="R"
    187         Q
    188         ;
    189 PLIST   ;Patient list inquiry.
    190         N CREAT,NAME,IND,LISTIEN,USIEN,VALMY,CREAT,NODE,TRUE
    191         D EN^VALM2(XQORNOD(0))
    192         ;If there is no list quit.
    193         I '$D(VALMY) Q
    194         ;PXRMDONE is newed in PXRMLPU
    195         S PXRMDONE=0
    196         S IND=""
    197         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    198         .S LISTIEN=^TMP("PXRMLPU",$J,"SEL",IND)
    199         .D START^PXRMLPP(LISTIEN)
    200         D BLDLIST
    201         S VALMBCK="R"
    202         Q
    203         ;
    204 VIEW    ;
    205         D FULL^VALM1
    206         N DIR,DTOUT,DUOUT,DIROUT,DIROUT,Y
    207         S DIR(0)="SO^N:NAME;T:TYPE"
    208         S DIR("A")="Select View Type"
    209         D ^DIR
    210         I $D(DTOUT),$D(DUOUT),$D(DIROUT) Q
    211         I Y="N" S MODE=0 D ENTRY
    212         I Y="T" S MODE=1 D ENTRY
    213         Q
    214         ;
    215 XQORM   ;
    216         S XQORM("#")=$O(^ORD(101,"B","PXRM PATIENT LIST USER SELECT ENTRY",0))_U_"1:"_VALMCNT
    217         S XQORM("A")="Select Item: "
    218         Q
    219         ;
    220 XSEL    ;SELECT validation
    221         N EPIEN,LEVEL,LISTIEN,LRIEN,NODE,SEL
    222         S SEL=$P(XQORNOD(0),"=",2)
    223         ;Remove trailing ,
    224         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    225         ;Invalid selection
    226         I SEL["," D  Q
    227         .W $C(7),!,"Only one item number allowed." H 2
    228         .S VALMBCK="R"
    229         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("SEL",SEL))) D  Q
    230         .W $C(7),!,SEL_" is not a valid item number." H 2
    231         .S VALMBCK="R"
    232         ;
    233         ;Get the patient list ien
    234         S LISTIEN=^TMP("PXRMLPU",$J,"SEL",SEL)
    235         ;Get extract definition ien (if present)
    236         S EPIEN=$P($G(^PXRMXP(810.5,LISTIEN,0)),U,5)
    237         ;Get list rule ien
    238         S LRIEN=$P($G(^PXRMXP(810.5,LISTIEN,0)),U,6)
    239         S NODE=$G(^PXRMXP(810.5,LISTIEN,0))
    240         ;
    241         ;Full screen mode
    242         D FULL^VALM1
    243         ;
    244         ;Option to Install, Delete or Install History
    245         N ACCESS,DELOK,DIR,OPTION,RIEN,X,Y
    246         K DIROUT,DIRUT,DTOUT,DUOUT
    247         S ACCESS=$$ACCESS(LISTIEN,NODE)
    248         S DELOK=$$LDELOK^PXRMEUT(LISTIEN)
    249         S DIR(0)="SBM"_U_"CO:Copy Patient List;"
    250         S DIR(0)=DIR(0)_"COE:Copy to OE/RR Team;"
    251         I DELOK S DIR(0)=DIR(0)_"DE:Delete Patient List;"
    252         S DIR(0)=DIR(0)_"DCD:Display Creation Documentation;"
    253         S DIR(0)=DIR(0)_"DSP:Display Patient List;"
    254         S DIR("A")="Select Action: "
    255         S DIR("B")="DSP"
    256         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    257         S DIR("??")=U_"D HELP^PXRMLPU(1)"
    258         D ^DIR K DIR
    259         I $D(DIROUT) S DTOUT=1
    260         I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
    261         S OPTION=Y
    262         ;
    263         I $G(OPTION)="" G XSELE
    264         ;
    265         ;Copy patient list
    266         I OPTION="CO" D COPY^PXRMRUL1(LISTIEN)
    267         Q:$D(DUOUT)!$D(DTOUT)
    268         ;
    269         ;Copy to OE/RR Team
    270         I OPTION="COE" D OERR^PXRMLPOE(LISTIEN)
    271         Q:$D(DUOUT)!$D(DTOUT)
    272         ;
    273         ;Delete patient list
    274         I OPTION="DE" D PDELETE
    275         ;
    276         ;Display creation documentation
    277         I OPTION="DCD" D EN^PXRMLCD(LISTIEN)
    278         ;
    279         ;Display patient list
    280         I OPTION="DSP" D START^PXRMLPP(LISTIEN)
    281         ;
    282 XSELE   ;
    283         D CLEAN^VALM10
    284         D BLDLIST,XQORM
    285         S VALMBCK="R"
    286         Q
     1PXRMLPU ; SLC/PKR/PJH - Reminder Patient List ;08/07/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM PATIENT LIST
     5START(MODE) ;
     6 N PXRMDONE,VALMBCK,VALMSG,X,XMZ,MODE1
     7 S X="IORESET"
     8 D ENDR^%ZISS
     9 S VALMCNT=0
     10 D EN^VALM("PXRM PATIENT LIST USER")
     11 W IORESET
     12 D KILL^%ZISS
     13 Q
     14 ;
     15ACCESS(IEN,NODE) ;
     16 ;Holders of the PXRM MANAGER key have full access to all lists.
     17 ;DBIA #10076
     18 I $D(^XUSEC("PXRM MANAGER",DUZ)) Q "F"
     19 N ACCESS,TYPE
     20 I $G(NODE)="" S NODE=$G(^PXRMXP(810.5,IEN,0))
     21 S TYPE=$P(NODE,U,8)
     22 I TYPE="" Q "F"
     23 I TYPE="PUB" Q "F"
     24 I $P(NODE,U,7)=DUZ Q "F"
     25 S ACCESS="N"
     26 I TYPE="PVT",$D(^PXRMXP(810.5,IEN,40,"B",DUZ)) D
     27 . N USIEN,STATUS
     28 . S USIEN=$O(^PXRMXP(810.5,IEN,40,"B",DUZ,""))
     29 . S ACCESS=$S(USIEN="":"N",1:$P(^PXRMXP(810.5,IEN,40,USIEN,0),U,2))
     30 Q ACCESS
     31 ;
     32BLDLIST ;
     33 N IEN,PLIST
     34 K ^TMP("PXRMLPU",$J)
     35 K ^TMP("PXRMLPUH",$J)
     36 S PLIST="PXRMLPU"
     37 D LIST(MODE,PLIST,.IEN)
     38 S VALMCNT=+$G(^TMP("PXRMLPU",$J,"VALMCNT"))
     39 F IND=1:1:VALMCNT D
     40 .S ^TMP("PXRMLPU",$J,"IDX",IND,IND)=IEN(IND)
     41 Q
     42 ;
     43ENTRY ;Entry code
     44 ;MODE=0 ORDER BY NAME
     45 ;MODE=1 ORDER BY TYPE
     46 I $G(MODE)'>0 S MODE=0
     47 D BLDLIST,XQORM
     48 Q
     49 ;
     50EXIT ;Exit code
     51 K ^TMP("PXRMLPU",$J)
     52 K ^TMP("PXRMLPUH",$J)
     53 D CLEAN^VALM10
     54 D FULL^VALM1
     55 S VALMBCK="R"
     56 Q
     57 ;
     58FORMAT(NUMBER,NAME,NODE) ;Format  entry number, name, source,
     59 ;and date packed.
     60 N ACCESS,DATE,COUNT,TEMP,TYPE
     61 S DATE=$P(NODE,U,2),COUNT=$P(NODE,U,3)
     62 S TYPE=$P(NODE,U,4),ACCESS=$P(NODE,U,5)
     63 S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
     64 S NAME=$E(NAME,1,45)
     65 S TEMP=TEMP_"  "_$$LJ^XLFSTR(NAME,45," ")
     66 S DATE=$$FMTE^XLFDT(DATE,2)
     67 S TEMP=TEMP_"  "_$$LJ^XLFSTR(DATE,17," ")
     68 S TEMP=TEMP_"  "_$$RJ^XLFSTR(COUNT,6," ")
     69 S TEMP=TEMP_"  "_$$RJ^XLFSTR(TYPE,4," ")
     70 S TEMP=TEMP_"  "_$$RJ^XLFSTR(ACCESS,3," ")
     71 Q TEMP
     72 ;
     73HDR ; Header code
     74 N NAME
     75 S VALMHDR(1)="Available Patient Lists."
     76 Q
     77 ;
     78HELP(CALL) ;General help text routine
     79 N HTEXT
     80 I CALL=1 D
     81 .S HTEXT(1)="Select CO to copy patient list."
     82 .S HTEXT(2)="Select COE to copy patient list to OE/RR Team."
     83 .S HTEXT(3)="Select CR to delete patient list."
     84 .S HTEXT(4)="Select DCD to display creation documentation."
     85 .S HTEXT(5)="Select DSP to display patient list."
     86 D HELP^PXRMEUT(.HTEXT)
     87 Q
     88 ;
     89HLP ;Help code
     90 N ORU,ORUPRMT,SUB,XQORM
     91 S SUB="PXRMLPUH"
     92 D EN^VALM("PXRM PATIENT LIST HELP")
     93 Q
     94 ;
     95INIT ;Init
     96 S VALMCNT=0
     97 Q
     98 ;
     99LIST(MODE,PLIST,IEN) ;Build a list of patient list entries.
     100 N ACCESS,COUNT,DATE,IND,FNAME,NAME,NODE,SUB,TYPE
     101 ;MODE=0 build list in alphabetical order
     102 ;MODE=1 build list by type of list.
     103 K ^TMP($J,PLIST),^TMP(PLIST,$J)
     104 S VALMCNT=0,NAME="",TYPE=""
     105 F  S NAME=$O(^PXRMXP(810.5,"B",NAME)) Q:NAME=""  D
     106 .S IND="" F  S IND=$O(^PXRMXP(810.5,"B",NAME,IND)) Q:'IND  D
     107 ..S NODE=$G(^PXRMXP(810.5,IND,0))
     108 ..S ACCESS=$$ACCESS(IND,NODE)
     109 ..I ACCESS="N" Q
     110 ..S FNAME=$P($G(NODE),U),DATE=$P($G(NODE),U,4)
     111 ..S COUNT=+$P($G(^PXRMXP(810.5,IND,30,0)),U,4)
     112 ..S TYPE=$P(NODE,U,8)
     113 ..S SUB=$S(MODE=0:"NAME",1:TYPE)
     114 ..S ^TMP($J,PLIST,SUB,FNAME)=IND_U_DATE_U_COUNT_U_TYPE_U_ACCESS
     115 I '$D(^TMP($J,PLIST)) Q
     116 ;Loop through ARRAY to populate the output list
     117 ;sub is either the type of list or 'NAME'. If sort is
     118 ;by TYPE show PVT lists first.
     119 S SUB=""
     120 F  S SUB=$O(^TMP($J,PLIST,SUB),-1) Q:SUB=""  D
     121 .S FNAME=""
     122 .F  S FNAME=$O(^TMP($J,PLIST,SUB,FNAME)) Q:FNAME=""  D
     123 ..S NODE=^TMP($J,PLIST,SUB,FNAME),VALMCNT=VALMCNT+1
     124 ..S ^TMP(PLIST,$J,VALMCNT,0)=$$FORMAT(VALMCNT,FNAME,NODE)
     125 ..S IEN(VALMCNT)=$P(NODE,U,1)
     126 S ^TMP(PLIST,$J,"VALMCNT")=VALMCNT
     127 K ^TMP($J,PLIST)
     128 Q
     129 ;
     130PCOPY ;Patient list copy
     131 S SUB="PXRMLPU"
     132 D PCOPY1(SUB)
     133 D BLDLIST
     134 S VALMBCK="R"
     135 Q
     136 ;
     137PCOPY1(SUB) ;
     138 ;Full Screen
     139 W IORESET
     140 N IND,LISTIEN,VALMY
     141 D EN^VALM2(XQORNOD(0))
     142 ;If there is no list quit.
     143 I '$D(VALMY) Q
     144 S IND="",PXRMDONE=0
     145 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     146 .;Get the patient list ien.
     147 .S LISTIEN=^TMP(SUB,$J,"IDX",IND,IND)
     148 .D COPY^PXRMRULE(LISTIEN)
     149 Q
     150 ;
     151PDELETE ;Patient list delete
     152 ;Full Screen
     153 W IORESET
     154 N DELOK,IND,LISTIEN,NODE,VALMY
     155 D EN^VALM2(XQORNOD(0))
     156 ;If there is no list quit.
     157 I '$D(VALMY) Q
     158 S IND="",PXRMDONE=0
     159 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     160 .;Get the patient list ien.
     161 .S LISTIEN=^TMP("PXRMLPU",$J,"IDX",IND,IND)
     162 .S NODE=$G(^PXRMXP(810.5,LISTIEN,0))
     163 .S DELOK=$$LDELOK^PXRMEUT(LISTIEN)
     164 .I DELOK D DELETE^PXRMRULE(LISTIEN) Q
     165 .E  D  Q
     166 ..W !,"In order to delete a list you must be the creator or a Reminder Manager!"
     167 ..S PXRMDONE=1 H 2
     168 D BLDLIST
     169 S VALMBCK="R"
     170 Q
     171 ;
     172PEXIT ;Protocol exit code
     173 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     174 ;Reset after page up/down etc
     175 D XQORM
     176 Q
     177 ;
     178POERR ;Patient list copy to OERR Team (#101.21)
     179 ;Full Screen
     180 W IORESET
     181 N ACCESS,IND,LISTIEN,NODE,USIEN,VALMY
     182 D EN^VALM2(XQORNOD(0))
     183 ;If there is no list quit.
     184 I '$D(VALMY) Q
     185 S IND="",PXRMDONE=0
     186 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     187 .;Get the patient list ien.
     188 .S LISTIEN=^TMP("PXRMLPU",$J,"IDX",IND,IND)
     189 .S NODE=$G(^PXRMXP(810.5,LISTIEN,0))
     190 .S ACCESS=$$ACCESS^PXRMLPU(LISTIEN,NODE)
     191 .I ACCESS="F" D OERR^PXRMLPOE(LISTIEN)
     192 .I ACCESS="N" D
     193 ..W !,"The list cannot be copied; you must have full access to copy the list to an OE/RR team!"
     194 ..S PXRMDONE=1 H 2
     195 S VALMBCK="R"
     196 Q
     197 ;
     198PLIST ;Patient list inquiry.
     199 N CREAT,NAME,IND,LISTIEN,USIEN,VALMY,CREAT,NODE,TRUE
     200 D EN^VALM2(XQORNOD(0))
     201 ;If there is no list quit.
     202 I '$D(VALMY) Q
     203 ;PXRMDONE is newed in PXRMLPU
     204 S PXRMDONE=0
     205 S IND=""
     206 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     207 .S LISTIEN=^TMP("PXRMLPU",$J,"IDX",IND,IND)
     208 .D START^PXRMLPP(LISTIEN)
     209 D BLDLIST
     210 S VALMBCK="R"
     211 Q
     212 ;
     213VIEW ;
     214 D FULL^VALM1
     215 N DIR,DTOUT,DUOUT,DIROUT,DIROUT,Y
     216 S DIR(0)="SO^N:NAME;T:TYPE"
     217 S DIR("A")="Select View Type"
     218 D ^DIR
     219 I $D(DTOUT),$D(DUOUT),$D(DIROUT) Q
     220 I Y="N" S MODE=0 D ENTRY
     221 I Y="T" S MODE=1 D ENTRY
     222 Q
     223 ;
     224XQORM ;
     225 S XQORM("#")=$O(^ORD(101,"B","PXRM PATIENT LIST USER SELECT ENTRY",0))_U_"1:"_VALMCNT
     226 S XQORM("A")="Select Item: "
     227 Q
     228 ;
     229XSEL ;SELECT validation
     230 N EPIEN,LEVEL,LISTIEN,LRIEN,NODE,SEL
     231 S SEL=$P(XQORNOD(0),"=",2)
     232 ;Remove trailing ,
     233 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     234 ;Invalid selection
     235 I SEL["," D  Q
     236 .W $C(7),!,"Only one item number allowed." H 2
     237 .S VALMBCK="R"
     238 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     239 .W $C(7),!,SEL_" is not a valid item number." H 2
     240 .S VALMBCK="R"
     241 ;
     242 ;Get the patient list ien
     243 S LISTIEN=^TMP("PXRMLPU",$J,"IDX",SEL,SEL)
     244 ;Get extract definition ien (if present)
     245 S EPIEN=$P($G(^PXRMXP(810.5,LISTIEN,0)),U,5)
     246 ;Get list rule ien
     247 S LRIEN=$P($G(^PXRMXP(810.5,LISTIEN,0)),U,6)
     248 S NODE=$G(^PXRMXP(810.5,LISTIEN,0))
     249 ;
     250 ;Full screen mode
     251 D FULL^VALM1
     252 ;
     253 ;Option to Install, Delete or Install History
     254 N ACCESS,DELOK,DIR,OPTION,RIEN,X,Y
     255 K DIROUT,DIRUT,DTOUT,DUOUT
     256 S ACCESS=$$ACCESS(LISTIEN,NODE)
     257 S DELOK=$$LDELOK^PXRMEUT(LISTIEN)
     258 S DIR(0)="SBM"_U_"CO:Copy Patient List;"
     259 S DIR(0)=DIR(0)_"COE:Copy to OE/RR Team;"
     260 I DELOK S DIR(0)=DIR(0)_"DE:Delete Patient List;"
     261 S DIR(0)=DIR(0)_"DCD:Display Creation Documentation;"
     262 S DIR(0)=DIR(0)_"DSP:Display Patient List;"
     263 S DIR("A")="Select Action: "
     264 S DIR("B")="DSP"
     265 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     266 S DIR("??")=U_"D HELP^PXRMLPM(1)"
     267 D ^DIR K DIR
     268 I $D(DIROUT) S DTOUT=1
     269 I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
     270 S OPTION=Y
     271 ;
     272 I $G(OPTION)="" G XSELE
     273 ;
     274 ;Copy patient list
     275 I OPTION="CO" D COPY^PXRMRULE(LISTIEN)
     276 Q:$D(DUOUT)!$D(DTOUT)
     277 ;
     278 ;Copy to OE/RR Team
     279 I OPTION="COE" D OERR^PXRMLPOE(LISTIEN)
     280 Q:$D(DUOUT)!$D(DTOUT)
     281 ;
     282 ;Delete patient list
     283 I OPTION="DE" D PDELETE
     284 ;
     285 ;Display creation documentation
     286 I OPTION="DCD" D EN^PXRMLCD(LISTIEN)
     287 ;
     288 ;Display patient list
     289 I OPTION="DSP" D START^PXRMLPP(LISTIEN)
     290 ;
     291XSELE ;
     292 D CLEAN^VALM10
     293 D BLDLIST,XQORM
     294 S VALMBCK="R"
     295 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMLRM.m

    r613 r623  
    1 PXRMLRM ; SLC/PJH/PKR - List Rule Management ; 09/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Main entry point for PXRM LIST RULE MANAGEMENT
    5 START   N PXRMDONE,PXRMTYP,VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
    6         S X="IORESET"
    7         D ENDR^%ZISS
    8         S VALMCNT=0
    9         ;Default view is Rule Sets
    10         S PXRMTYP=3
    11         D EN^VALM("PXRM LIST RULE MANAGEMENT")
    12         Q
    13         ;
    14 BLDLIST ;Build workfile
    15         K ^TMP("PXRMLRM",$J)
    16         N IEN,IND,PLIST
    17         D LIST(.PLIST,.IEN,PXRMTYP)
    18         M ^TMP("PXRMLRM",$J)=PLIST
    19         S VALMCNT=PLIST("VALMCNT")
    20         F IND=1:1:VALMCNT D
    21         .S ^TMP("PXRMLRM",$J,"IDX",IND,IND)=IEN(IND)
    22         I PXRMTYP=1 D CHGCAP^VALM("HEADER2","Finding Rule Name")
    23         I PXRMTYP=2 D CHGCAP^VALM("HEADER2","Reminder Rule Name")
    24         I PXRMTYP=3 D CHGCAP^VALM("HEADER2","Rule Set Name")
    25         I PXRMTYP=4 D CHGCAP^VALM("HEADER2","Report Output Rule Name")
    26         I PXRMTYP=5 D CHGCAP^VALM("HEADER2","Patient List Rule Name")
    27         Q
    28         ;
    29 ENTRY   ;Entry code
    30         D BLDLIST,XQORM
    31         Q
    32         ;
    33 EXIT    ;Exit code
    34         K ^TMP("PXRMLRM",$J)
    35         K ^TMP("PXRMLRMH",$J)
    36         D CLEAN^VALM10
    37         D FULL^VALM1
    38         S VALMBCK="Q"
    39         Q
    40         ;
    41 FRE(NUMBER,NAME,CLASS)  ;Format  entry number, name
    42         ;and date packed.
    43         N TCLASS,TEMP,TNAME,TSOURCE
    44         S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
    45         S TNAME=$E(NAME,1,60)
    46         S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,60," ")
    47         S TCLASS=$S(CLASS="N":"NATIONAL",CLASS="V":"VISN",1:"LOCAL")
    48         S TEMP=TEMP_"  "_TCLASS
    49         Q TEMP
    50         ;
    51 HDR     ; Header code
    52         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    53         Q
    54         ;
    55 HELP(CALL)      ;General help text routine
    56         N HTEXT
    57         I CALL=1 D
    58         .S HTEXT(1)="Select DE to display or edit a rule.\\"
    59         .S HTEXT(2)="Select ED to edit a rule.\\"
    60         ;
    61         I CALL=2 D
    62         .S HTEXT(1)="Select F to edit term based finding rules.\\"
    63         .S HTEXT(2)="Select P to edit patient list based finding rules.\\"
    64         .S HTEXT(3)="Select R to edit reminder rules.\\"
    65         .S HTEXT(4)="Select S to edit rule sets. A rule set may contain"
    66         .S HTEXT(5)="any of the following:\\"
    67         .S HTEXT(6)=" finding list rules, patient list rules, reminder rules\\"
    68         .S HTEXT(7)="These component list rules must be created before the rule set"
    69         .S HTEXT(8)="can be constructed."
    70         ;
    71         D HELP^PXRMEUT(.HTEXT)
    72         Q
    73         ;
    74 HLP     ;Help code
    75         N ORU,ORUPRMT,SUB,XQORM
    76         S SUB="PXRMLRMH"
    77         D EN^VALM("PXRM LIST RULE HELP")
    78         Q
    79         ;
    80 INIT    ;Init
    81         S VALMCNT=0
    82         Q
    83         ;
    84 LIST(RLIST,IEN,LRTYP)   ;Build a list of list rule entries.
    85         N DATA,IND,LRCLASS,LRNAME,NAME
    86         ;Build the list in alphabetical order.
    87         S VALMCNT=0
    88         S NAME=""
    89         F  S NAME=$O(^PXRM(810.4,"B",NAME)) Q:NAME=""  D
    90         .S IND=$O(^PXRM(810.4,"B",NAME,"")) Q:'IND
    91         .S DATA=$G(^PXRM(810.4,IND,0))
    92         .I $P(DATA,U,3)'=LRTYP Q
    93         .S LRNAME=$P(DATA,U)
    94         .S LRCLASS=$P($G(^PXRM(810.4,IND,100)),U)
    95         .S VALMCNT=VALMCNT+1
    96         .S RLIST(VALMCNT,0)=$$FRE(VALMCNT,LRNAME,LRCLASS)
    97         .S IEN(VALMCNT)=IND
    98         S RLIST("VALMCNT")=VALMCNT
    99         Q
    100         ;
    101 LRADD   ;Add Rule Option
    102         ;
    103         ;Reset Screen Mode
    104         W IORESET
    105         ;
    106         ;Add Rule
    107         D ADD^PXRMLRED
    108         ;
    109         ;Rebuild Workfile
    110         D BLDLIST
    111         S VALMBCK="R"
    112         Q
    113         ;
    114 LRINQ   ;Rule Inquiry - PXRM LIST RULE DISPLAY/EDIT entry
    115         N IND,LRIEN,VALMY
    116         D EN^VALM2(XQORNOD(0))
    117         ;If there is no list quit.
    118         I '$D(VALMY) Q
    119         S PXRMDONE=0
    120         S IND=""
    121         F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
    122         .;Get the ien.
    123         .S LRIEN=^TMP("PXRMLRM",$J,"IDX",IND,IND)
    124         .D START^PXRMLRED(LRIEN,PXRMTYP)
    125         D BLDLIST
    126         S VALMBCK="R"
    127         Q
    128         ;
    129 PEXIT   ;Protocol exit code
    130         S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
    131         ;Reset after page up/down etc
    132         D XQORM
    133         Q
    134         ;
    135 VIEW    ;Select view
    136         W IORESET
    137         S VALMBCK="R"
    138         N X,Y,CODE,DIR
    139         K DIROUT,DIRUT,DTOUT,DUOUT
    140         S DIR(0)="S"_U_"F:Finding Rule;"
    141         S DIR(0)=DIR(0)_"P:Patient List Rule;"
    142         S DIR(0)=DIR(0)_"R:Reminder Rule;"
    143         S DIR(0)=DIR(0)_"S:Rule Set;"
    144         S DIR("A")="TYPE OF VIEW"
    145         S DIR("B")="F"
    146         S DIR("?")="Select from the codes displayed. For detailed help type ??"
    147         S DIR("??")=U_"D HELP^PXRMLRM(2)"
    148         D ^DIR K DIR
    149         I $D(DIROUT) S DTOUT=1
    150         I $D(DTOUT)!($D(DUOUT)) Q
    151         ;Change display type
    152         S PXRMTYP=$S(Y="F":1,Y="P":5,Y="S":3,1:4)
    153         S PXRMTYP=$S(Y="F":1,Y="P":5,Y="S":3,Y="R":2,1:4)
    154         ;Rebuild Workfile
    155         D BLDLIST,HDR
    156         Q
    157         ;
    158 XSEL    ;PXRM LIST RULE MANAGEMENT SELECT ENTRY validation
    159         N SEL,IEN
    160         S SEL=$P(XQORNOD(0),"=",2)
    161         ;Remove trailing ,
    162         I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
    163         ;Invalid selection
    164         I SEL["," D  Q
    165         .W $C(7),!,"Only one item number allowed." H 2
    166         .S VALMBCK="R"
    167         I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
    168         .W $C(7),!,SEL_" is not a valid item number." H 2
    169         .S VALMBCK="R"
    170         ;
    171         ;Get the list ien.
    172         S IEN=^TMP("PXRMLRM",$J,"IDX",SEL,SEL)
    173         ;
    174         ;Option to Display/Edit or Test Rule Set.
    175         N DIR,OPTION,RIEN,X,Y
    176         K DIROUT,DIRUT,DTOUT,DUOUT
    177         S DIR(0)="SBM"_U_"DR:Display/Edit Rule;"
    178         I $G(PXRMTYP)=3 S DIR(0)=DIR(0)_"TEST:Test Rule Set"
    179         S DIR("A")="Select Action: "
    180         S DIR("B")="DR"
    181         S DIR("?")="Select from the codes displayed."
    182         D ^DIR K DIR
    183         I $D(DIROUT) S DTOUT=1
    184         I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
    185         S OPTION=Y
    186         I $G(OPTION)="" G XSELE
    187         ;
    188         ;Display/Edit
    189         I OPTION="DR"   D START^PXRMLRED(IEN,PXRMTYP)
    190         Q:$D(DUOUT)!$D(DTOUT)
    191         ;
    192         ;Rule set test
    193         I OPTION="TEST" D RSTEST^PXRMRST(IEN)
    194         Q:$D(DUOUT)!$D(DTOUT)
    195         ;
    196 XSELE   ;
    197         D CLEAN^VALM10
    198         D BLDLIST,XQORM
    199         S VALMBCK="R"
    200         Q
    201         ;
    202 XQORM   S XQORM("#")=$O(^ORD(101,"B","PXRM LIST RULE MANAGEMENT SELECT ENTRY",0))_U_"1:"_VALMCNT
    203         S XQORM("A")="Select Item: "
    204         Q
    205         ;
     1PXRMLRM ; SLC/PJH/PKR - List Rule Management ; 05/15/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Main entry point for PXRM LIST RULE MANAGEMENT
     5START N PXRMDONE,PXRMTYP,VALMBCK,VALMCNT,VALMSG,X,XMZ,XQORM,XQORNOD
     6 S X="IORESET"
     7 D ENDR^%ZISS
     8 S VALMCNT=0
     9 ;Default view is Rule Sets
     10 S PXRMTYP=3
     11 D EN^VALM("PXRM LIST RULE MANAGEMENT")
     12 Q
     13 ;
     14BLDLIST ;Build workfile
     15 K ^TMP("PXRMLRM",$J)
     16 N IEN,IND,PLIST
     17 D LIST(.PLIST,.IEN,PXRMTYP)
     18 M ^TMP("PXRMLRM",$J)=PLIST
     19 S VALMCNT=PLIST("VALMCNT")
     20 F IND=1:1:VALMCNT D
     21 .S ^TMP("PXRMLRM",$J,"IDX",IND,IND)=IEN(IND)
     22 I PXRMTYP=1 D CHGCAP^VALM("HEADER2","Finding Rule Name")
     23 I PXRMTYP=2 D CHGCAP^VALM("HEADER2","Reminder Rule Name")
     24 I PXRMTYP=3 D CHGCAP^VALM("HEADER2","Rule Set Name")
     25 I PXRMTYP=4 D CHGCAP^VALM("HEADER2","Report Output Rule Name")
     26 I PXRMTYP=5 D CHGCAP^VALM("HEADER2","Patient List Rule Name")
     27 Q
     28 ;
     29ENTRY ;Entry code
     30 D BLDLIST,XQORM
     31 Q
     32 ;
     33EXIT ;Exit code
     34 K ^TMP("PXRMLRM",$J)
     35 K ^TMP("PXRMLRMH",$J)
     36 D CLEAN^VALM10
     37 D FULL^VALM1
     38 S VALMBCK="Q"
     39 Q
     40 ;
     41FRE(NUMBER,NAME,CLASS) ;Format  entry number, name
     42 ;and date packed.
     43 N TCLASS,TEMP,TNAME,TSOURCE
     44 S TEMP=$$RJ^XLFSTR(NUMBER,5," ")
     45 S TNAME=$E(NAME,1,60)
     46 S TEMP=TEMP_"  "_$$LJ^XLFSTR(TNAME,60," ")
     47 S TCLASS=$S(CLASS="N":"NATIONAL",CLASS="V":"VISN",1:"LOCAL")
     48 S TEMP=TEMP_"  "_TCLASS
     49 Q TEMP
     50 ;
     51HDR ; Header code
     52 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     53 Q
     54 ;
     55HELP(CALL) ;General help text routine
     56 N HTEXT
     57 I CALL=1 D
     58 .S HTEXT(1)="Select DE to display or edit a rule."
     59 .S HTEXT(2)="Select ED to edit a rule"
     60 ;
     61 I CALL=2 D
     62 .S HTEXT(1)=" Select F to edit term based finding rules."
     63 .S HTEXT(2)=" Select P to edit patient list based finding rules."
     64 .S HTEXT(3)=" Select R to edit reminder rules."
     65 .S HTEXT(4)=" Select S to edit rule sets. A rule set may contain either "
     66 .S HTEXT(5)="finding list rules or patient list rules or both. These "
     67 .S HTEXT(6)="component list rules must be created before the rule set "
     68 .S HTEXT(7)="can be constructed."
     69 ;
     70 D HELP^PXRMEUT(.HTEXT)
     71 Q
     72 ;
     73HLP ;Help code
     74 N ORU,ORUPRMT,SUB,XQORM
     75 S SUB="PXRMLRMH"
     76 D EN^VALM("PXRM LIST RULE HELP")
     77 Q
     78 ;
     79INIT ;Init
     80 S VALMCNT=0
     81 Q
     82 ;
     83LIST(RLIST,IEN,LRTYP) ;Build a list of list rule entries.
     84 N DATA,IND,LRCLASS,LRNAME,NAME
     85 ;Build the list in alphabetical order.
     86 S VALMCNT=0
     87 S NAME=""
     88 F  S NAME=$O(^PXRM(810.4,"B",NAME)) Q:NAME=""  D
     89 .S IND=$O(^PXRM(810.4,"B",NAME,"")) Q:'IND
     90 .S DATA=$G(^PXRM(810.4,IND,0))
     91 .I $P(DATA,U,3)'=LRTYP Q
     92 .S LRNAME=$P(DATA,U)
     93 .S LRCLASS=$P($G(^PXRM(810.4,IND,100)),U)
     94 .S VALMCNT=VALMCNT+1
     95 .S RLIST(VALMCNT,0)=$$FRE(VALMCNT,LRNAME,LRCLASS)
     96 .S IEN(VALMCNT)=IND
     97 S RLIST("VALMCNT")=VALMCNT
     98 Q
     99 ;
     100LRADD ;Add Rule Option
     101 ;
     102 ;Reset Screen Mode
     103 W IORESET
     104 ;
     105 ;Add Rule
     106 D ADD^PXRMLRED
     107 ;
     108 ;Rebuild Workfile
     109 D BLDLIST
     110 S VALMBCK="R"
     111 Q
     112 ;
     113LRINQ ;Rule Inquiry - PXRM LIST RULE DISPLAY/EDIT entry
     114 N IND,LRIEN,VALMY
     115 D EN^VALM2(XQORNOD(0))
     116 ;If there is no list quit.
     117 I '$D(VALMY) Q
     118 S PXRMDONE=0
     119 S IND=""
     120 F  S IND=$O(VALMY(IND)) Q:(+IND=0)!(PXRMDONE)  D
     121 .;Get the ien.
     122 .S LRIEN=^TMP("PXRMLRM",$J,"IDX",IND,IND)
     123 .D START^PXRMLRED(LRIEN,PXRMTYP)
     124 D BLDLIST
     125 S VALMBCK="R"
     126 Q
     127 ;
     128PEXIT ;Protocol exit code
     129 S VALMSG="+ Next Screen   - Prev Screen   ?? More Actions"
     130 ;Reset after page up/down etc
     131 D XQORM
     132 Q
     133 ;
     134VIEW ;Select view
     135 W IORESET
     136 S VALMBCK="R"
     137 N X,Y,CODE,DIR
     138 K DIROUT,DIRUT,DTOUT,DUOUT
     139 S DIR(0)="S"_U_"F:Finding Rule;"
     140 S DIR(0)=DIR(0)_"P:Patient List Rule;"
     141 S DIR(0)=DIR(0)_"R:Reminder Rule;"
     142 S DIR(0)=DIR(0)_"S:Rule Set;"
     143 S DIR("A")="TYPE OF VIEW"
     144 S DIR("B")="F"
     145 S DIR("?")="Select from the codes displayed. For detailed help type ??"
     146 S DIR("??")=U_"D HELP^PXRMLRM(2)"
     147 D ^DIR K DIR
     148 I $D(DIROUT) S DTOUT=1
     149 I $D(DTOUT)!($D(DUOUT)) Q
     150 ;Change display type
     151 S PXRMTYP=$S(Y="F":1,Y="P":5,Y="S":3,1:4)
     152 S PXRMTYP=$S(Y="F":1,Y="P":5,Y="S":3,Y="R":2,1:4)
     153 ;Rebuild Workfile
     154 D BLDLIST,HDR
     155 Q
     156 ;
     157XSEL ;PXRM LIST RULE MANAGEMENT SELECT ENTRY validation
     158 N SEL,IEN
     159 S SEL=$P(XQORNOD(0),"=",2)
     160 ;Remove trailing ,
     161 I $E(SEL,$L(SEL))="," S SEL=$E(SEL,1,$L(SEL)-1)
     162 ;Invalid selection
     163 I SEL["," D  Q
     164 .W $C(7),!,"Only one item number allowed." H 2
     165 .S VALMBCK="R"
     166 I ('SEL)!(SEL>VALMCNT)!('$D(@VALMAR@("IDX",SEL))) D  Q
     167 .W $C(7),!,SEL_" is not a valid item number." H 2
     168 .S VALMBCK="R"
     169 ;
     170 ;Get the list ien.
     171 S IEN=^TMP("PXRMLRM",$J,"IDX",SEL,SEL)
     172 ;
     173 ;Option to Display/Edit or Test Rule Set.
     174 N DIR,OPTION,RIEN,X,Y
     175 K DIROUT,DIRUT,DTOUT,DUOUT
     176 S DIR(0)="SBM"_U_"DR:Display/Edit Rule;"
     177 I $G(PXRMTYP)=3 S DIR(0)=DIR(0)_"TEST:Test Rule Set"
     178 S DIR("A")="Select Action: "
     179 S DIR("B")="DR"
     180 S DIR("?")="Select from the codes displayed."
     181 D ^DIR K DIR
     182 I $D(DIROUT) S DTOUT=1
     183 I $D(DTOUT)!($D(DUOUT)) S VALMBCK="R" Q
     184 S OPTION=Y
     185 I $G(OPTION)="" G XSELE
     186 ;
     187 ;Display/Edit
     188 I OPTION="DR"   D START^PXRMLRED(IEN,PXRMTYP)
     189 Q:$D(DUOUT)!$D(DTOUT)
     190 ;
     191 ;Rule set test
     192 I OPTION="TEST" D RSTEST^PXRMRST(IEN)
     193 Q:$D(DUOUT)!$D(DTOUT)
     194 ;
     195XSELE ;
     196 D CLEAN^VALM10
     197 D BLDLIST,XQORM
     198 S VALMBCK="R"
     199 Q
     200 ;
     201XQORM S XQORM("#")=$O(^ORD(101,"B","PXRM LIST RULE MANAGEMENT SELECT ENTRY",0))_U_"1:"_VALMCNT
     202 S XQORM("A")="Select Item: "
     203 Q
     204 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMMH.m

    r613 r623  
    1 PXRMMH  ; SLC/PKR - Handle mental health findings. ;11/23/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=======================================================
    5 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate mental health findings.
    6         D EVALFI^PXRMINDX(DFN,.DEFARR,ENODE,.FIEVAL)
    7         Q
    8         ;
    9         ;=======================================================
    10 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Evaluate mental health term findings
    11         ;for patient lists.
    12         D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
    13         Q
    14         ;
    15         ;=======================================================
    16 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate mental
    17         ;health instrument terms.
    18         D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
    19         Q
    20         ;
    21         ;=======================================================
    22 GETDATA(DASP,FIEVT)     ;Return the data for a MH Administrations entry.
    23         ;Some tests require the YSP key in order to get a score.
    24         N DAS,DATA,IND,SCALE
    25         S DAS=$P(DASP,"S",1)
    26         S SCALE=+$P(DASP,"S",2)
    27         ;DBIA #5043
    28         D ENDAS71^YTQPXRM6(.DATA,DAS)
    29         I $G(DATA(1))="[ERROR]" Q
    30         I SCALE=0 S SCALE=+$O(DATA("SI",""))
    31         S FIEVT("MH TEST")=$P(DATA(2),U,3)
    32         S IND=0
    33         F  S IND=$O(DATA("SI",IND)) Q:IND=""  S FIEVT("S",IND)=$P(DATA("SI",IND),U,3,4)
    34         S IND=0
    35         F  S IND=$O(DATA("R",IND)) Q:IND=""  S FIEVT("R",IND)=$P(DATA("R",IND),U,6)
    36         I $D(DATA("SI",SCALE)) S FIEVT("VALUE")=FIEVT("S",SCALE),FIEVT("SCALE NAME")=$P(DATA("SI",SCALE),U,2)
    37         Q
    38         ;
    39         ;=======================================================
    40 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    41         N DATE,IND,JND,MHTEST,NOUT,SCALE,SNAME,SCORE,TEXTOUT
    42         S MHTEST="Mental Health Test: "_IFIEVAL("MH TEST")_" = "
    43         S IND=0
    44         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    45         . S DATE="("_$$EDATE^PXRMDATE(IFIEVAL(IND,"DATE"))_")"
    46         . S TEMP=MHTEST_DATE
    47         . S SNAME=$G(IFIEVAL(IND,"SCALE NAME"))
    48         . I SNAME'="" S TEMP=TEMP_" scale: "_SNAME_" -"
    49         . S SCORE=$G(IFIEVAL(IND,"VALUE"))
    50         . I SCORE'="" S TEMP=TEMP_"  raw score: "_$P(SCORE,U,1)_", transformed score: "_$P(SCORE,U,2)
    51         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    52         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    53         S NLINES=NLINES+1,TEXT(NLINES)=""
    54         Q
    55         ;
    56         ;=======================================================
    57 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    58         ;maintenance output.
    59         N IND,JND,MHTEST,NOUT,SCALE,SNAME,SCORE,TEXTOUT
    60         S MHTEST=IFIEVAL("MH TEST")
    61         S NLINES=NLINES+1
    62         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Mental Health Test: "_MHTEST
    63         S IND=0
    64         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    65         . S TEMP=$$EDATE^PXRMDATE(IFIEVAL(IND,"DATE"))
    66         . S SNAME=$G(IFIEVAL(IND,"SCALE NAME"))
    67         . I SNAME'="" S TEMP=TEMP_" scale: "_SNAME_" -"
    68         . S SCORE=$G(IFIEVAL(IND,"VALUE"))
    69         . I SCORE'="" S TEMP=TEMP_"  raw score: "_$P(SCORE,U,1)_", transformed score: "_$P(SCORE,U,2)
    70         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    71         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    72         S NLINES=NLINES+1,TEXT(NLINES)=""
    73         Q
    74         ;
    75         ;=======================================================
    76 SCHELP(MHIEN)   ;Xecutable help for MH SCALE
    77         N DATA,IND,JND,NUM,SCALE,SNUM
    78         I MHIEN=0 D  Q
    79         . S SCALE(1)="This is not a valid Mental Health finding, selecting an MH scale does"
    80         . S SCALE(2)="not make sense"
    81         . D EN^DDIOL(.SCALE)
    82         ;DBIA #5053
    83         D SCALES^YTQPXRM5(.DATA,MHIEN)
    84         I DATA(1)="ERROR" D  Q
    85         . S SCALE(1)="There are no scales for this test."
    86         . D EN^DDIOL(.SCALE)
    87         S SCALE(1)="Valid scales are:"
    88         S SCALE(2)="SCALE NUMBER  SCALE NAME"
    89         S SCALE(3)="------------------------"
    90         S IND=0,JND=3
    91         F  S IND=$O(DATA("S",IND)) Q:IND=""  D
    92         . S JND=JND+1
    93         . S NUM=6-$L(IND)
    94         . S SCALE(JND)=$$INSCHR^PXRMEXLC(NUM," ")_(IND)_"        "_$P(DATA("S",IND),U,1)
    95         D EN^DDIOL(.SCALE)
    96         Q
    97         ;
    98         ;=======================================================
    99 SCHELPD(DA)     ;Xecutable help for MH SCALE in Result Group file 801.41
    100         N MHIEN
    101         S MHIEN=+$P($G(^PXRMD(801.41,DA,50)),U)
    102         D SCHELP^PXRMMH(MHIEN)
    103         Q
    104         ;=======================================================
    105 SCHELPF ;Xecutable help for MH SCALE in 811.9 findings.
    106         N FIND0,MHIEN
    107         S FIND0=^PXD(811.9,DA(1),20,DA,0)
    108         I FIND0["YTT(601.71" S MHIEN=$P(FIND0,";",1)
    109         E  S MHIEN=0
    110         D SCHELP(MHIEN)
    111         Q
    112         ;
    113         ;=======================================================
    114 SCHELPT ;Xecutable help for MH SCALE in 811.5 findings.
    115         N MHIEN,TFIND0
    116         S TFIND0=^PXRMD(811.5,DA(1),20,DA,0)
    117         I TFIND0["YTT(601.71" S MHIEN=$P(TFIND0,";",1)
    118         E  S MHIEN=0
    119         D SCHELP(MHIEN)
    120         Q
    121         ;
    122         ;=======================================================
    123 SCNAME(TEST,SCNUM)      ;Given the test ien and scale number return the
    124         ;scale name.
    125         N DATA,SCNAME
    126         D SCALES^YTQPXRM5(.DATA,TEST)
    127         Q $G(DATA("S",SCNUM))
    128         ;
    129         ;=======================================================
    130 SEVALFI(DFN,ITEM,NGET,SDIR,BDT,EDT,NFOUND,FLIST)        ;
    131         N FIEV,FINDING,IND,YS,DATA
    132         S YS("CODE")=ITEM,YS("DFN")=DFN
    133         S YS("BEGIN")=BDT,YS("END")=EDT
    134         ;PTTEST^YTQPXRM2 does not understand "*" for a limit so use 99.
    135         I NGET="*" S NGET=99
    136         S YS("LIMIT")=$S(SDIR=-1:NGET,1:-NGET)
    137         ;DBIA #5035
    138         D PTTEST^YTQPXRM2(.DATA,.YS)
    139         S NFOUND=$P(DATA(1),U,2)
    140         I NFOUND=0 Q
    141         F IND=1:1:NFOUND S FLIST(IND)=DATA(IND+1)
    142         Q
    143         ;
    144         ;=======================================================
    145 SEVALPL(ITEM,NOCC,BDT,EDT,PLIST)        ;Use MH API to get patient list. Called
    146         ;from PXRMINDL.
    147         N YS
    148         ;YTAPI10A does not understand "*" for a limit so use 99.
    149         ;OCCUR^YTQPXRM1 does not understand "*" for a limit so use 99.
    150         I NOCC="*" S NOCC=99
    151         S YS("CODE")=ITEM,YS("BEGIN")=BDT,YS("END")=EDT,YS("LIMIT")=NOCC
    152         ;DBIA #5034
    153         D OCCUR^YTQPXRM1(PLIST,.YS)
    154         Q
    155         ;
    156         ;=======================================================
    157 VSCALE(X,FIND0) ;Make sure that the mental health scale is valid.
    158         ;Either the scale number or the scale name can be used.
    159         N DATA,IND,MHIEN,MHTEST,SCALE,VALID
    160         S MHTEST=$P(FIND0,U,1)
    161         S MHIEN=$P(MHTEST,";",1)
    162         D SCALES^YTQPXRM5(.DATA,MHIEN)
    163         I +X>0 S VALID=$S($D(DATA("S",X)):1,1:0)
    164         E  D
    165         . S IND=1,VALID=0
    166         . F  S IND=$O(DATA("S",IND)) Q:(VALID)!(IND="")  D
    167         .. I X=$P(DATA("S",IND),U,1) S VALID=1 Q
    168         I 'VALID D EN^DDIOL(X_" is not a valid scale for this test!")
    169         I $O(DATA(""),-1)>20 H 1
    170         Q VALID
    171         ;
    172         ;=======================================================
    173 VSCALED(X,DA)   ;Make sure that the mental health scale is valid for a result
    174         ;group.
    175         I X="" Q 1
    176         ;Do not execute as part of a verify fields.
    177         I $G(DIUTIL)="VERIFY FIELDS" Q 1
    178         ;Do not execute as part of exchange.
    179         I $G(PXRMEXCH) Q 1
    180         N MHTEST
    181         S MHTEST=$P($G(^PXRMD(801.41,DA,50)),U)
    182         Q $$VSCALE(X,MHTEST)
    183         ;
    184         ;=======================================================
    185 VSCALEF(X)      ;Make sure that the mental health scale is valid for a finding.
    186         I X="" Q 1
    187         ;Do not execute as part of a verify fields.
    188         I $G(DIUTIL)="VERIFY FIELDS" Q 1
    189         ;Do not execute as part of exchange.
    190         I $G(PXRMEXCH) Q 1
    191         N FIND0
    192         S FIND0=^PXD(811.9,DA(1),20,DA,0)
    193         Q $$VSCALE(X,FIND0)
    194         ;
    195         ;=======================================================
    196 VSCALET(X)      ;Make sure that the mental health scale is valid for a
    197         ;term finding.
    198         I X="" Q 1
    199         ;Do not execute as part of a verify fields.
    200         I $G(DIUTIL)="VERIFY FIELDS" Q 1
    201         ;Do not execute as part of exchange.
    202         I $G(PXRMEXCH) Q 1
    203         N TFIND0
    204         S TFIND0=^PXRMD(811.5,DA(1),20,DA,0)
    205         Q $$VSCALE(X,TFIND0)
    206         ;
    207         ;=======================================================
    208 WARN    ;Warn the user that they must select a scale if they intend to use
    209         ;a condition.
    210         W !,"Remember that the score is returned as raw score^transformed score,"
    211         W !,"so if your Condition uses the raw score use +V or $P(V,U,1) and if"
    212         W !,"it uses the transformed score use $P(V,U,2)."
    213         Q
    214         ;
     1PXRMMH ; SLC/PKR - Handle mental health findings. ;04/05/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=======================================================
     5EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate mental health findings.
     6 D EVALFI^PXRMINDX(DFN,.DEFARR,ENODE,.FIEVAL)
     7 Q
     8 ;
     9 ;=======================================================
     10EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate mental health term findings
     11 ;for patient lists.
     12 D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
     13 Q
     14 ;=======================================================
     15EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate mental
     16 ;health instrument terms.
     17 D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
     18 Q
     19 ;
     20 ;=======================================================
     21GETDATA(DAS,FIEVT) ;Return the data for a Psych Instrument Patient entry.
     22 ;Some tests require the YSP key in order to get a score.
     23 N DASP,IND,SCALE,YSDATA
     24 ;DBIA #4442
     25 S DASP=$P(DAS,"S",1)
     26 S SCALE=$P(DAS,"S",2)
     27 D ENDAS^YTAPI10(.YSDATA,DASP)
     28 I $G(YSDATA(0))="[ERROR]" Q
     29 S FIEVT("MH TEST")=$P(YSDATA(2),U,3)
     30 I FIEVT("MH TEST")["GAF" S FIEVT("RATING")=$P(YSDATA(3),U,2) Q
     31 ;If no scale is specified use the first set of results.
     32 S IND=$S(SCALE="":6,1:SCALE+5)
     33 S FIEVT("YSDATA")=$G(YSDATA(IND))
     34 S FIEVT("SCALE NAME")=$P(FIEVT("YSDATA"),U,2)
     35 S (FIEVT("RAW SCORE"),FIEVT("VALUE"))=$P(FIEVT("YSDATA"),U,3)
     36 S FIEVT("TRANSFORMED SCORE")=$P(FIEVT("YSDATA"),U,4)
     37 Q
     38 ;
     39 ;=======================================================
     40MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     41 N DATE,IND,JND,MHTEST,NAME,NOUT,RATING,RSCORE,SCORE,TEXTOUT,TSCORE
     42 S MHTEST=IFIEVAL("MH TEST")
     43 ;Remove the dashes surrounding the name.
     44 S MHTEST=$TR(MHTEST,"-","")
     45 S NAME="Mental Health Test: "_MHTEST_" = "
     46 S IND=0
     47 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     48 . S DATE=IFIEVAL(IND,"DATE")
     49 . S RSCORE=$G(IFIEVAL(IND,"RAW SCORE"))
     50 . S TSCORE=$G(IFIEVAL(IND,"TRANSFORMED SCORE"))
     51 . S RATING=$G(IFIEVAL(IND,"RATING"))
     52 . S SCORE=$S(RATING'="":RATING,TSCORE'="":TSCORE,RSCORE'="":RSCORE,1:"")
     53 . S TEMP=NAME_SCORE_" ("_$$EDATE^PXRMDATE(IFIEVAL(IND,"DATE"))_")"
     54 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     55 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     56 S NLINES=NLINES+1,TEXT(NLINES)=""
     57 Q
     58 ;
     59 ;=======================================================
     60OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     61 ;maintenance output.
     62 N DATE,IND,JND,MHTEST,NOUT,RATING,RSCORE,TEXTOUT,TSCORE
     63 S MHTEST=IFIEVAL("MH TEST")
     64 ;Remove the dashes surrounding the name.
     65 S MHTEST=$TR(MHTEST,"-","")
     66 S NLINES=NLINES+1
     67 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Mental Health Test: "_MHTEST
     68 S IND=0
     69 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     70 . S DATE=IFIEVAL(IND,"DATE")
     71 . S TEMP=$$EDATE^PXRMDATE(IFIEVAL(IND,"DATE"))
     72 . S RSCORE=$G(IFIEVAL(IND,"RAW SCORE"))
     73 . I RSCORE'="" S TEMP=TEMP_" raw score - "_RSCORE
     74 . S TSCORE=$G(IFIEVAL(IND,"TRANSFORMED SCORE"))
     75 . I TSCORE'="" S TEMP=TEMP_"; transformed score - "_TSCORE
     76 . S RATING=$G(IFIEVAL(IND,"RATING"))
     77 . I RATING'="" S TEMP=TEMP_" Rating: "_RATING
     78 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     79 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     80 S NLINES=NLINES+1,TEXT(NLINES)=""
     81 Q
     82 ;
     83 ;=======================================================
     84SCHELP(MHIEN) ;Xecutable help for MH SCALE
     85 N IND,JND,NUM,SCALE,TEMP,TEMP1
     86 I MHIEN=0 D  Q
     87 . S SCALE(1)="This is not a valid Mental Health finding, selecting an MH scale does"
     88 . S SCALE(2)="not make sense"
     89 . D EN^DDIOL(.SCALE)
     90 S SCALE(1)="SCALE NUMBER  SCALE NAME"
     91 S SCALE(2)="------------------------"
     92 S IND=0
     93 S JND=2
     94 F  S IND=$O(^YTT(601,MHIEN,"S",IND)) Q:+IND=0  D
     95 . S TEMP=^YTT(601,MHIEN,"S",IND,0)
     96 . S JND=JND+1
     97 . S TEMP1=$P(TEMP,U,1)
     98 . S NUM=6-$L(TEMP1)
     99 . S SCALE(JND)=$$INSCHR^PXRMEXLC(NUM," ")_TEMP1_"        "_$P(TEMP,U,2)
     100 D EN^DDIOL(.SCALE)
     101 Q
     102 ;
     103 ;=======================================================
     104SCHELPF ;Xecutable help for MH SCALE in 811.9 findings.
     105 N FIND0,MHIEN
     106 S FIND0=^PXD(811.9,DA(1),20,DA,0)
     107 I FIND0["YTT(601" S MHIEN=$P(FIND0,";",1)
     108 E  S MHIEN=0
     109 D SCHELP(MHIEN)
     110 Q
     111 ;
     112 ;=======================================================
     113SCHELPT ;Xecutable help for MH SCALE in 811.5 findings.
     114 N MHIEN,TFIND0
     115 S TFIND0=^PXRMD(811.5,DA(1),20,DA,0)
     116 I TFIND0["YTT(601" S MHIEN=$P(TFIND0,";",1)
     117 E  S MHIEN=0
     118 D SCHELP(MHIEN)
     119 Q
     120 ;
     121 ;=======================================================
     122SEVALFI(DFN,ITEM,NGET,SDIR,BDT,EDT,NFOUND,FLIST) ;
     123 N FIEV,FINDING,IND,YS,YSDATA
     124 S YS("CODE")=ITEM,YS("DFN")=DFN
     125 S YS("BEGIN")=BDT,YS("END")=EDT
     126 ;YTAPI10A does not understand "*" for a limit so use 99.
     127 I NGET="*" S NGET=99
     128 S YS("LIMIT")=$S(SDIR=-1:NGET,1:-NGET)
     129 ;DBIA #4458
     130 D PTTEST^YTAPI10A(.YSDATA,.YS)
     131 S NFOUND=$P(YSDATA(1),U,2)
     132 I NFOUND=0 Q
     133 F IND=1:1:NFOUND S FLIST(IND)=YSDATA(IND+1)
     134 Q
     135 ;
     136 ;=======================================================
     137SEVALPL(ITEM,NOCC,BDT,EDT,PLIST) ;Use MH API to get patient list. Called
     138 ;from PXRMINDL.
     139 N YS
     140 ;YTAPI10A does not understand "*" for a limit so use 99.
     141 I NOCC="*" S NOCC=99
     142 S YS("CODE")=ITEM,YS("BEGIN")=BDT,YS("END")=EDT,YS("LIMIT")=NOCC
     143 ;DBIA #4458
     144 D OCCUR^YTAPI10A(PLIST,.YS)
     145 Q
     146 ;
     147 ;=======================================================
     148VSCALE(X,FIND0) ;Make sure that the mental health scale is valid.
     149 ;Either the scale number or the scale name can be used.
     150 N MHIEN,MHTEST,SCALE,VALID
     151 S MHTEST=$P(FIND0,U,1)
     152 S MHIEN=$P(MHTEST,";",1)
     153 I +X>0 D  Q VALID
     154 . S VALID=$S($D(^YTT(601,MHIEN,"S",X)):1,1:0)
     155 E  D
     156 . S SCALE=$O(^YTT(601,MHIEN,"S","C",X,""))
     157 . S VALID=$S(SCALE="":0,1:1)
     158 Q VALID
     159 ;
     160 ;=======================================================
     161VSCALEF(X) ;Make sure that the mental health scale is valid for a finding.
     162 I X="" Q 1
     163 ;Do not execute as part of a verify fields.
     164 I $G(DIUTIL)="VERIFY FIELDS" Q 1
     165 ;Do not execute as part of exchange.
     166 I $G(PXRMEXCH) Q 1
     167 N FIND0
     168 S FIND0=^PXD(811.9,DA(1),20,DA,0)
     169 Q $$VSCALE(X,FIND0)
     170 ;
     171 ;=======================================================
     172VSCALET(X) ;Make sure that the mental health scale is valid for a
     173 ;term finding.
     174 I X="" Q 1
     175 ;Do not execute as part of a verify fields.
     176 I $G(DIUTIL)="VERIFY FIELDS" Q 1
     177 ;Do not execute as part of exchange.
     178 I $G(PXRMEXCH) Q 1
     179 N TFIND0
     180 S TFIND0=^PXRMD(811.5,DA(1),20,DA,0)
     181 Q $$VSCALE(X,TFIND0)
     182 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMMST.m

    r613 r623  
    1 PXRMMST ; SLC/PKR - Routines for dealing with MST. ;03/29/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;Use of DGMSTAPI supported by DBIA #2716.
    4         ;====================================================
    5 GSYINFO(TYPE)   ;Return the Clinical Reminders MST synchronization date
    6         ;and the number of updates made. The format is an up-arrow delimited
    7         ;string. The first piece is the date and the second is the number
    8         ;of updates. If TYPE is "I" then the data for the initial
    9         ;synchronization is returned. For any other value the data for the
    10         ;last daily synchronization is returned.
    11         I $G(TYPE)="I" Q $P($G(^PXRM(800,1,"MST")),U,1,2) Q
    12         Q $P($G(^PXRM(800,1,"MST")),U,3,4)
    13         ;
    14         ;====================================================
    15 QUE     ;Queue the MST synchronization job.
    16         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
    17         S MINDT=$$NOW^XLFDT
    18         W !,"Queue the Clinical Reminders MST synchronization."
    19         S DIR("A",1)="Enter the date and time you want the job to start."
    20         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    21         S DIR("A")="Start the task at: "
    22         S DIR(0)="DAU"_U_MINDT_"::RSX"
    23         D ^DIR
    24         I $D(DIROUT)!$D(DIRUT) Q
    25         I $D(DTOUT)!$D(DUOUT) Q
    26         S SDTIME=Y
    27         K DIR
    28         S DIR(0)="YA"
    29         S DIR("A")="Do you want to run the MST synchronization at the same time every day? "
    30         S DIR("B")="Y"
    31         D ^DIR
    32         I $D(DIROUT)!$D(DIRUT) Q
    33         I $D(DTOUT)!$D(DUOUT) Q
    34         S STIME=$S(Y:"1."_$P(SDTIME,".",2),1:-1)
    35         ;
    36         ;Put the task into the queue.
    37         K ZTSAVE
    38         S ZTSAVE("STIME")=STIME
    39         S ZTRTN="SYNCH^PXRMMST"
    40         S ZTDESC="Clinical Reminders MST synchronization job"
    41         S ZTDTH=SDTIME
    42         S ZTIO=""
    43         D ^%ZTLOAD
    44         W !,"Task number ",ZTSK," queued."
    45         Q
    46         ;
    47         ;====================================================
    48 STATUS(DFN,TEST,DATE,VALUE,TEXT)        ;Computed finding for checking a
    49         ;patient's MST status.
    50         N IEN,TEMP
    51         S TEMP=$$GETSTAT^DGMSTAPI(DFN)
    52         S IEN=$P(TEMP,U,1)
    53         I IEN=-1 D  Q
    54         . S TEST=0,VALUE="",DATE=$$NOW^PXRMDATE
    55         I IEN=0 D  Q
    56         . S TEST=0
    57         . S VALUE=$P(TEMP,U,2)
    58         . S DATE=$P(TEMP,U,3)
    59         . S TEXT="No MST status found"
    60         ;If we get to here then a valid entry was found.
    61         S TEST=1
    62         S VALUE=$P(TEMP,U,2)
    63         S DATE=$P(TEMP,U,3)
    64         Q
    65         ;
    66         ;====================================================
    67 STCODE(TERM)    ;Return the MST status code based on the term name.
    68         N STCODE
    69         S STCODE=$S(TERM="VA-MST DECLINES REPORT":"D",TERM="VA-MST NEGATIVE REPORT":"N",TERM="VA-MST POSITIVE REPORT":"Y",1:"U")
    70         Q STCODE
    71         ;
    72         ;====================================================
    73 SYNCH   ;Synchronize the MST history file.
    74         N INID,LTIME,NUMUPD,START,TEMP
    75         ;STIME is passed from QUE via ZTSAVE.
    76         D UPDSTAT(.NUMUPD,.START)
    77         ;If the initial sync data has been stored then update the daily
    78         ;data.
    79         S INID=+$P($G(^PXRM(800,1,"MST")),U,1)
    80         I INID>0 D
    81         . S $P(^PXRM(800,1,"MST"),U,3)=$$NOW^XLFDT
    82         . S $P(^PXRM(800,1,"MST"),U,4)=NUMUPD
    83         . S $P(^PXRM(800,1,"MST"),U,6)=START
    84         E  D
    85         . S $P(^PXRM(800,1,"MST"),U,1)=$$NOW^XLFDT
    86         . S $P(^PXRM(800,1,"MST"),U,2)=NUMUPD
    87         . S $P(^PXRM(800,1,"MST"),U,5)=START
    88         ;
    89         ;Cleanup the task stuff.
    90         I STIME=-1 S ZTREQ="@" Q
    91         E  D
    92         . S TEMP=$G(^PXRM(800,1,"MST"))
    93         . S LTIME=+$P(TEMP,U,3)
    94         . I LTIME=0 S LTIME=+$P(TEMP,U,1)
    95         .;Adding STIME sets the new starting time at exactly one day following
    96         .;the previous starting time.
    97         . S $P(ZTREQ,U,1)=$P(LTIME,".",1)+STIME
    98         Q
    99         ;
    100         ;====================================================
    101 SYNREP  ;Provide a report of the synchronization data.
    102         N EDTIME,EITIME,IDATE,LDATE,NIUPD,NLUPD,TEMP
    103         S TEMP=$G(^PXRM(800,1,"MST"))
    104         S IDATE=$$FMTE^XLFDT($P(TEMP,U,1))
    105         I IDATE=0 S IDATE="none"
    106         S NIUPD=$P(TEMP,U,2)
    107         S EITIME=$$FMDIFF^XLFDT($P(TEMP,U,1),$P(TEMP,U,5),2)
    108         S LDATE=$$FMTE^XLFDT($P(TEMP,U,3))
    109         I LDATE=0 S LDATE="none"
    110         S NLUPD=$P(TEMP,U,4)
    111         S EDTIME=$$FMDIFF^XLFDT($P(TEMP,U,3),$P(TEMP,U,6),2)
    112         W !!,"Clinical Reminders MST Synchronization Report"
    113         W !,"---------------------------------------------"
    114         W !,"Initial synchronization date: ",IDATE
    115         W !,"Number of updates made: ",NIUPD
    116         I EITIME>60 D
    117         . S EITIME=$$FMDIFF^XLFDT($P(TEMP,U,1),$P(TEMP,U,5),3)
    118         . W !,"Elapsed time: ",EITIME
    119         E  W !,"Elapsed time: ",EITIME," secs"
    120         W !!,"Last daily synchronization date: ",LDATE
    121         W !,"Number of updates made: ",NLUPD
    122         I EDTIME>60 D
    123         . S EDTIME=$$FMDIFF^XLFDT($P(TEMP,U,3),$P(TEMP,U,6),3)
    124         . W !,"Elapsed time: ",EDTIME
    125         E  W !,"Elapsed time: ",EDTIME," secs"
    126         Q
    127         ;
    128         ;====================================================
    129 UPDATE(DFN,VISIT,SOURCE,STCODE,TYPE)    ;Make an update to the MST History file.
    130         N DATE,MSTDATE,PROV,STAT,TEMP,UPDSTAT,VPRVIEN
    131         S UPDSTAT=-1
    132         ;If the update is because of a protocol event use NOW for the
    133         ;date/time. If it is being done as part of a synchronization use
    134         ;the date the visit was created.
    135         S DATE=$S(TYPE="PROTOCOL":$$NOW^XLFDT,1:$P($G(^AUPNVSIT(VISIT,0)),U,2))
    136         ;If the date does not contain the time use noon.
    137         I DATE'["." S DATE=DATE_".12"
    138         S STAT=$$GETSTAT^DGMSTAPI(DFN)
    139         S MSTDATE=$S($P(STAT,U,1)>0:$P(STAT,U,3),1:0)
    140         I DATE>MSTDATE D
    141         .;Determine the provider.
    142         . S TEMP=$P(SOURCE,";",2)_$P(SOURCE,";",1)_",12)"
    143         . S PROV=$P($G(@TEMP),U,4)
    144         . I PROV="" D
    145         ..;DBIA #2316
    146         .. S VPRVIEN=+$O(^AUPNVPRV("AD",VISIT,""))
    147         .. I VPRVIEN>0 S PROV=$P(^AUPNVPRV(VPRVIEN,0),U,1)
    148         . S UPDSTAT=$$NEWSTAT^DGMSTAPI(DFN,STCODE,DATE,PROV)
    149         . I +UPDSTAT=-1 D
    150         .. N FN,GBL,IEN,NAME,TARGET,XMSUB,VADM
    151         .. K ^TMP("PXRMXMZ",$J)
    152         .. S XMSUB="CLINICAL REMINDER MST UPDATE PROBLEM"
    153         .. S ^TMP("PXRMXMZ",$J,1,0)="NEWSTAT^DGMSTAPI returned the following error:"
    154         .. S ^TMP("PXRMXMZ",$J,2,0)=$P(UPDSTAT,U,2)
    155         .. S ^TMP("PXRMXMZ",$J,3,0)="The following data was passed to NEWSTAT^DGMSTAPI"
    156         .. S ^TMP("PXRMXMZ",$J,4,0)="DFN = "_DFN
    157         .. S ^TMP("PXRMXMZ",$J,5,0)="Status code = "_STCODE
    158         .. S ^TMP("PXRMXMZ",$J,6,0)="Date = "_DATE
    159         .. S ^TMP("PXRMXMZ",$J,7,0)="Provider = "_PROV
    160         .. S ^TMP("PXRMXMZ",$J,8,0)="Data source = "_SOURCE
    161         .. S ^TMP("PXRMXMZ",$J,9,0)="This corresponds to the following:"
    162         .. D DEM^VADPT
    163         .. S ^TMP("PXRMXMZ",$J,10,0)="Patient = "_VADM(1)
    164         .. S ^TMP("PXRMXMZ",$J,11,0)="SSN = "_$P(VADM(2),U,2)
    165         .. S ^TMP("PXRMXMZ",$J,12,0)="MST Status = "_$$EXTERNAL^DILFD(29.11,3,"",STCODE)
    166         .. S ^TMP("PXRMXMZ",$J,13,0)="Date = "_$$FMTE^XLFDT(DATE,"5Z")
    167         .. S TEMP=$S(PROV="":"Unknown",1:TEMP=$$GET1^DIQ(200,PROV,.01,"","",""))
    168         .. I TEMP="" S TEMP="Unknown"
    169         .. S ^TMP("PXRMXMZ",$J,14,0)="Provider = "_TEMP
    170         .. S GBL=$P($P(SOURCE,";",2),"(",1)
    171         .. S TEMP=GBL_"(0)"
    172         .. S FN=+$P(@TEMP,U,2)
    173         .. S TEMP=GBL_"("_$P(SOURCE,";",1)_",0)"
    174         .. S TEMP=$G(@TEMP)
    175         .. S IEN=$P(TEMP,U,1)
    176         .. D FIELD^DID(FN,.01,"N","POINTER","TARGET")
    177         .. S GBL="^"_$P(TARGET("POINTER"),"(",1)
    178         .. S TEMP=GBL_"(0)"
    179         .. S FN=$P(@TEMP,U,1)
    180         .. S TEMP=GBL_"("_IEN_",0)"
    181         .. S NAME=$P(@TEMP,U,1)
    182         .. S ^TMP("PXRMXMZ",$J,14,0)="Data type = "_FN
    183         .. S ^TMP("PXRMXMZ",$J,15,0)="Name = "_NAME
    184         .. D SEND^PXRMMSG(XMSUB)
    185         Q UPDSTAT
    186         ;
    187         ;====================================================
    188 UPDPAT(DFN,VISIT,VFL)   ;Update the MST history file for a single patient
    189         ;using term mappings. Called from DATACHG^PXRMPINF which is invoked
    190         ;by the protocol PXK VISIT DATA EVENT.
    191         N AFTER,BEFORE,DGBL,SP,STCODE,SIEN,SOURCE
    192         N TEMP,TERM,TERMIEN,VF
    193         ;Search all the MST terms to build patient lists.
    194         F TERM="VA-MST DECLINES REPORT","VA-MST NEGATIVE REPORT","VA-MST POSITIVE REPORT" D
    195         . S TERMIEN=$O(^PXRMD(811.5,"B",TERM,""))
    196         . S VF=""
    197         . F  S VF=$O(VFL(VF)) Q:VF=""  D
    198         .. I VFL(VF)=U Q
    199         .. S DGBL=$P(VFL(VF),U,1)
    200         .. I '$D(^PXRMD(811.5,TERMIEN,20,"E",DGBL)) Q
    201         .. S SIEN=""
    202         .. F  S SIEN=$O(^TMP("PXKCO",$J,VISIT,VF,SIEN)) Q:SIEN=""  D
    203         ... S AFTER=$G(^TMP("PXKCO",$J,VISIT,VF,SIEN,0,"AFTER"))
    204         ... S BEFORE=$G(^TMP("PXKCO",$J,VISIT,VF,SIEN,0,"BEFORE"))
    205         ... I AFTER=BEFORE Q
    206         ... S SP=$P(AFTER,U,1)
    207         ... I SP="" Q
    208         ... I '$D(^PXRMD(811.5,TERMIEN,20,"E",DGBL,SP)) Q
    209         ... S SOURCE=SIEN_";^"_$P(VFL(VF),U,2)
    210         ...;The status code depends on the term name.
    211         ... S STCODE=$$STCODE(TERM)
    212         ... S TEMP=$$UPDATE(DFN,VISIT,SOURCE,STCODE,"PROTOCOL")
    213         Q
    214         ;
    215         ;====================================================
    216 UPDSTAT(NUMUPD,START)   ;Update the MST history file using term mappings.
    217         N DAS,DATA,DFN,FILENUM,FINDPA,INDEX,ITEM,NOCC,STCODE,SOURCE
    218         N TEMP,TERM,TERMARR,TERMIEN,UPDSTAT,VDATE,VISIT
    219         S FINDPA=""
    220         ;Set the start time for the synchronization.
    221         S START=$$NOW^XLFDT
    222         S INDEX="PXRM_MST_LIST"
    223         S NUMUPD=0
    224         ;Search all the MST terms to build patient lists. Only V file data
    225         ;is used for the update.
    226         F TERM="VA-MST DECLINES REPORT","VA-MST NEGATIVE REPORT","VA-MST POSITIVE REPORT" D
    227         . K TERMARR,^TMP($J,INDEX)
    228         .;The status code depends on the term name.
    229         . S STCODE=$$STCODE(TERM)
    230         . S TERMIEN=$O(^PXRMD(811.5,"B",TERM,""))
    231         . I TERMIEN="" Q
    232         . D TERM^PXRMLDR(TERMIEN,.TERMARR)
    233         . D EVALPL^PXRMTERL(.FINDPA,.TERMARR,INDEX)
    234         . S DFN=0
    235         . F  S DFN=+$O(^TMP($J,INDEX,1,DFN)) Q:DFN=0  D
    236         .. S ITEM=""
    237         .. F  S ITEM=$O(^TMP($J,INDEX,1,DFN,ITEM)) Q:ITEM=""  D
    238         ... S NOCC=0
    239         ... F  S NOCC=$O(^TMP($J,INDEX,1,DFN,ITEM,NOCC)) Q:NOCC=""  D
    240         .... S FILENUM=""
    241         .... F  S FILENUM=$O(^TMP($J,INDEX,1,DFN,ITEM,NOCC,FILENUM)) Q:FILENUM=""  D
    242         ..... S TEMP=^TMP($J,INDEX,1,DFN,ITEM,NOCC,FILENUM)
    243         ..... S DAS=$P(TEMP,U,1)
    244         ..... K DATA
    245         ..... D GETDATA^PXRMDATA(FILENUM,DAS,.DATA)
    246         ..... S VISIT=$G(DATA("VISIT"))
    247         ..... I VISIT="" Q
    248         ..... S SOURCE=DAS_";"_^PXRMINDX(FILENUM,"GLOBAL NAME")
    249         ..... S UPDSTAT=$$UPDATE(DFN,VISIT,SOURCE,STCODE,"SYNCH")
    250         ..... I UPDSTAT'=-1 S NUMUPD=NUMUPD+1
    251         K ^TMP($J,INDEX)
    252         Q
    253         ;
     1PXRMMST ; SLC/PKR - Routines for dealing with MST. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;Use of DGMSTAPI supported by DBIA #2716.
     4 ;====================================================
     5GSYINFO(TYPE) ;Return the Clinical Reminders MST synchronization date
     6 ;and the number of updates made. The format is an up-arrow delimited
     7 ;string. The first piece is the date and the second is the number
     8 ;of updates. If TYPE is "I" then the data for the initial
     9 ;synchronization is returned. For any other value the data for the
     10 ;last daily synchronization is returned.
     11 I $G(TYPE)="I" Q $P($G(^PXRM(800,1,"MST")),U,1,2) Q
     12 Q $P($G(^PXRM(800,1,"MST")),U,3,4)
     13 ;
     14 ;====================================================
     15QUE ;Queue the MST synchronization job.
     16 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,STIME,X,Y
     17 S MINDT=$$NOW^XLFDT
     18 W !,"Queue the Clinical Reminders MST synchronization."
     19 S DIR("A",1)="Enter the date and time you want the job to start."
     20 S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
     21 S DIR("A")="Start the task at: "
     22 S DIR(0)="DAU"_U_MINDT_"::RSX"
     23 D ^DIR
     24 I $D(DIROUT)!$D(DIRUT) Q
     25 I $D(DTOUT)!$D(DUOUT) Q
     26 S SDTIME=Y
     27 K DIR
     28 S DIR(0)="YA"
     29 S DIR("A")="Do you want to run the MST synchronization at the same time every day? "
     30 S DIR("B")="Y"
     31 D ^DIR
     32 I $D(DIROUT)!$D(DIRUT) Q
     33 I $D(DTOUT)!$D(DUOUT) Q
     34 S STIME=$S(Y:"1."_$P(SDTIME,".",2),1:-1)
     35 ;
     36 ;Put the task into the queue.
     37 K ZTSAVE
     38 S ZTSAVE("STIME")=STIME
     39 S ZTRTN="SYNCH^PXRMMST"
     40 S ZTDESC="Clinical Reminders MST synchronization job"
     41 S ZTDTH=SDTIME
     42 S ZTIO=""
     43 D ^%ZTLOAD
     44 W !,"Task number ",ZTSK," queued."
     45 Q
     46 ;
     47 ;====================================================
     48STATUS(DFN,TEST,DATE,VALUE,TEXT) ;Computed finding for checking a
     49 ;patient's MST status.
     50 N IEN,TEMP
     51 S TEMP=$$GETSTAT^DGMSTAPI(DFN)
     52 S IEN=$P(TEMP,U,1)
     53 I IEN=-1 D  Q
     54 . S TEST=0,VALUE="",DATE=$$NOW^PXRMDATE
     55 I IEN=0 D  Q
     56 . S TEST=0
     57 . S VALUE=$P(TEMP,U,2)
     58 . S DATE=$P(TEMP,U,3)
     59 . S TEXT="No MST status found"
     60 ;If we get to here then a valid entry was found.
     61 S TEST=1
     62 S VALUE=$P(TEMP,U,2)
     63 S DATE=$P(TEMP,U,3)
     64 Q
     65 ;
     66 ;====================================================
     67STCODE(TERM) ;Return the MST status code based on the term name.
     68 N STCODE
     69 S STCODE=$S(TERM="VA-MST DECLINES REPORT":"D",TERM="VA-MST NEGATIVE REPORT":"N",TERM="VA-MST POSITIVE REPORT":"Y",1:"U")
     70 Q STCODE
     71 ;
     72 ;====================================================
     73SYNCH ;Synchronize the MST history file.
     74 N INID,LTIME,NUMUPD,START,TEMP
     75 ;STIME is passed from QUE via ZTSAVE.
     76 D UPDSTAT(.NUMUPD,.START)
     77 ;If the initial sync data has been stored then update the daily
     78 ;data.
     79 S INID=+$P($G(^PXRM(800,1,"MST")),U,1)
     80 I INID>0 D
     81 . S $P(^PXRM(800,1,"MST"),U,3)=$$NOW^XLFDT
     82 . S $P(^PXRM(800,1,"MST"),U,4)=NUMUPD
     83 . S $P(^PXRM(800,1,"MST"),U,6)=START
     84 E  D
     85 . S $P(^PXRM(800,1,"MST"),U,1)=$$NOW^XLFDT
     86 . S $P(^PXRM(800,1,"MST"),U,2)=NUMUPD
     87 . S $P(^PXRM(800,1,"MST"),U,5)=START
     88 ;
     89 ;Cleanup the task stuff.
     90 I STIME=-1 S ZTREQ="@" Q
     91 E  D
     92 . S TEMP=$G(^PXRM(800,1,"MST"))
     93 . S LTIME=+$P(TEMP,U,3)
     94 . I LTIME=0 S LTIME=+$P(TEMP,U,1)
     95 .;Adding STIME sets the new starting time at exactly one day following
     96 .;the previous starting time.
     97 . S $P(ZTREQ,U,1)=$P(LTIME,".",1)+STIME
     98 Q
     99 ;
     100 ;====================================================
     101SYNREP ;Provide a report of the synchronization data.
     102 N EDTIME,EITIME,IDATE,LDATE,NIUPD,NLUPD,TEMP
     103 S TEMP=$G(^PXRM(800,1,"MST"))
     104 S IDATE=$$FMTE^XLFDT($P(TEMP,U,1))
     105 I IDATE=0 S IDATE="none"
     106 S NIUPD=$P(TEMP,U,2)
     107 S EITIME=$$FMDIFF^XLFDT($P(TEMP,U,1),$P(TEMP,U,5),2)
     108 S LDATE=$$FMTE^XLFDT($P(TEMP,U,3))
     109 I LDATE=0 S LDATE="none"
     110 S NLUPD=$P(TEMP,U,4)
     111 S EDTIME=$$FMDIFF^XLFDT($P(TEMP,U,3),$P(TEMP,U,6),2)
     112 W !!,"Clinical Reminders MST Synchronization Report"
     113 W !,"---------------------------------------------"
     114 W !,"Initial synchronization date: ",IDATE
     115 W !,"Number of updates made: ",NIUPD
     116 I EITIME>60 D
     117 . S EITIME=$$FMDIFF^XLFDT($P(TEMP,U,1),$P(TEMP,U,5),3)
     118 . W !,"Elapsed time: ",EITIME
     119 E  W !,"Elapsed time: ",EITIME," secs"
     120 W !!,"Last daily synchronization date: ",LDATE
     121 W !,"Number of updates made: ",NLUPD
     122 I EDTIME>60 D
     123 . S EDTIME=$$FMDIFF^XLFDT($P(TEMP,U,3),$P(TEMP,U,6),3)
     124 . W !,"Elapsed time: ",EDTIME
     125 E  W !,"Elapsed time: ",EDTIME," secs"
     126 Q
     127 ;
     128 ;====================================================
     129UPDATE(DFN,VISIT,SOURCE,STCODE,TYPE) ;Make an update to the MST History file.
     130 N DATE,MSTDATE,PROV,STAT,TEMP,UPDSTAT,VPRVIEN
     131 S UPDSTAT=-1
     132 ;If the update is because of a protocol event use NOW for the
     133 ;date/time. If it is being done as part of a synchronization use
     134 ;the date the visit was created.
     135 S DATE=$S(TYPE="PROTOCOL":$$NOW^XLFDT,1:$P($G(^AUPNVSIT(VISIT,0)),U,2))
     136 ;If the date does not contain the time use noon.
     137 I DATE'["." S DATE=DATE_".12"
     138 S STAT=$$GETSTAT^DGMSTAPI(DFN)
     139 S MSTDATE=$S($P(STAT,U,1)>0:$P(STAT,U,3),1:0)
     140 I DATE>MSTDATE D
     141 .;Determine the provider.
     142 . S TEMP=$P(SOURCE,";",2)_$P(SOURCE,";",1)_",12)"
     143 . S PROV=$P($G(@TEMP),U,4)
     144 . I PROV="" D
     145 ..;DBIA #2316
     146 .. S VPRVIEN=+$O(^AUPNVPRV("AD",VISIT,""))
     147 .. I VPRVIEN>0 S PROV=$P(^AUPNVPRV(VPRVIEN,0),U,1)
     148 . S UPDSTAT=$$NEWSTAT^DGMSTAPI(DFN,STCODE,DATE,PROV)
     149 . I +UPDSTAT=-1 D
     150 .. N FN,GBL,IEN,NAME,TARGET,XMSUB,VADM
     151 .. K ^TMP("PXRMXMZ",$J)
     152 .. S XMSUB="CLINICAL REMINDER MST UPDATE PROBLEM"
     153 .. S ^TMP("PXRMXMZ",$J,1,0)="NEWSTAT^DGMSTAPI returned the following error:"
     154 .. S ^TMP("PXRMXMZ",$J,2,0)=$P(UPDSTAT,U,2)
     155 .. S ^TMP("PXRMXMZ",$J,3,0)="The following data was passed to NEWSTAT^DGMSTAPI"
     156 .. S ^TMP("PXRMXMZ",$J,4,0)="DFN = "_DFN
     157 .. S ^TMP("PXRMXMZ",$J,5,0)="Status code = "_STCODE
     158 .. S ^TMP("PXRMXMZ",$J,6,0)="Date = "_DATE
     159 .. S ^TMP("PXRMXMZ",$J,7,0)="Provider = "_PROV
     160 .. S ^TMP("PXRMXMZ",$J,8,0)="Data source = "_SOURCE
     161 .. S ^TMP("PXRMXMZ",$J,9,0)="This corresponds to the following:"
     162 .. D DEM^VADPT
     163 .. S ^TMP("PXRMXMZ",$J,10,0)="Patient = "_VADM(1)
     164 .. S ^TMP("PXRMXMZ",$J,11,0)="SSN = "_$P(VADM(2),U,2)
     165 .. S ^TMP("PXRMXMZ",$J,12,0)="MST Status = "_$$EXTERNAL^DILFD(29.11,3,"",STCODE)
     166 .. S ^TMP("PXRMXMZ",$J,13,0)="Date = "_$$FMTE^XLFDT(DATE,"5Z")
     167 .. S TEMP=$S(PROV="":"Unknown",1:TEMP=$$GET1^DIQ(200,PROV,.01,"","",""))
     168 .. I TEMP="" S TEMP="Unknown"
     169 .. S ^TMP("PXRMXMZ",$J,14,0)="Provider = "_TEMP
     170 .. S GBL=$P($P(SOURCE,";",2),"(",1)
     171 .. S TEMP=GBL_"(0)"
     172 .. S FN=+$P(@TEMP,U,2)
     173 .. S TEMP=GBL_"("_$P(SOURCE,";",1)_",0)"
     174 .. S TEMP=$G(@TEMP)
     175 .. S IEN=$P(TEMP,U,1)
     176 .. D FIELD^DID(FN,.01,"N","POINTER","TARGET")
     177 .. S GBL="^"_$P(TARGET("POINTER"),"(",1)
     178 .. S TEMP=GBL_"(0)"
     179 .. S FN=$P(@TEMP,U,1)
     180 .. S TEMP=GBL_"("_IEN_",0)"
     181 .. S NAME=$P(@TEMP,U,1)
     182 .. S ^TMP("PXRMXMZ",$J,14,0)="Data type = "_FN
     183 .. S ^TMP("PXRMXMZ",$J,15,0)="Name = "_NAME
     184 .. D SEND^PXRMMSG(XMSUB)
     185 Q UPDSTAT
     186 ;
     187 ;====================================================
     188UPDPAT(DFN,VISIT,VFL) ;Update the MST history file for a single patient
     189 ;using term mappings. Called from DATACHG^PXRMPINF which is invoked
     190 ;by the protocol PXK VISIT DATA EVENT.
     191 N AFTER,BEFORE,DGBL,SP,STCODE,SIEN,SOURCE
     192 N TEMP,TERM,TERMIEN,VF
     193 ;Search all the MST terms to build patient lists.
     194 F TERM="VA-MST DECLINES REPORT","VA-MST NEGATIVE REPORT","VA-MST POSITIVE REPORT" D
     195 . S TERMIEN=$O(^PXRMD(811.5,"B",TERM,""))
     196 . S VF=""
     197 . F  S VF=$O(VFL(VF)) Q:VF=""  D
     198 .. I VFL(VF)=U Q
     199 .. S DGBL=$P(VFL(VF),U,1)
     200 .. I '$D(^PXRMD(811.5,TERMIEN,20,"E",DGBL)) Q
     201 .. S SIEN=""
     202 .. F  S SIEN=$O(^TMP("PXKCO",$J,VISIT,VF,SIEN)) Q:SIEN=""  D
     203 ... S AFTER=$G(^TMP("PXKCO",$J,VISIT,VF,SIEN,0,"AFTER"))
     204 ... S BEFORE=$G(^TMP("PXKCO",$J,VISIT,VF,SIEN,0,"BEFORE"))
     205 ... I AFTER=BEFORE Q
     206 ... S SP=$P(AFTER,U,1)
     207 ... I SP="" Q
     208 ... I '$D(^PXRMD(811.5,TERMIEN,20,"E",DGBL,SP)) Q
     209 ... S SOURCE=SIEN_";^"_$P(VFL(VF),U,2)
     210 ...;The status code depends on the term name.
     211 ... S STCODE=$$STCODE(TERM)
     212 ... S TEMP=$$UPDATE(DFN,VISIT,SOURCE,STCODE,"PROTOCOL")
     213 Q
     214 ;
     215 ;====================================================
     216UPDSTAT(NUMUPD,START) ;Update the MST history file using term mappings.
     217 N DAS,DATA,DFN,FILENUM,FINDPA,INDEX,ITEM,NOCC,STCODE,SOURCE
     218 N TEMP,TERM,TERMARR,TERMIEN,UPDSTAT,VDATE,VISIT
     219 S FINDPA=""
     220 ;Set the start time for the synchronization.
     221 S START=$$NOW^XLFDT
     222 S INDEX="PXRM_MST_LIST"
     223 S NUMUPD=0
     224 ;Search all the MST terms to build patient lists. Only V file data
     225 ;is used for the update.
     226 F TERM="VA-MST DECLINES REPORT","VA-MST NEGATIVE REPORT","VA-MST POSITIVE REPORT" D
     227 . K TERMARR,^TMP($J,INDEX)
     228 .;The status code depends on the term name.
     229 . S STCODE=$$STCODE(TERM)
     230 . S TERMIEN=$O(^PXRMD(811.5,"B",TERM,""))
     231 . I TERMIEN="" Q
     232 . D TERM^PXRMLDR(TERMIEN,.TERMARR)
     233 . D EVALPL^PXRMTERM(.FINDPA,.TERMARR,INDEX)
     234 . S DFN=0
     235 . F  S DFN=+$O(^TMP($J,INDEX,1,DFN)) Q:DFN=0  D
     236 .. S ITEM=""
     237 .. F  S ITEM=$O(^TMP($J,INDEX,1,DFN,ITEM)) Q:ITEM=""  D
     238 ... S NOCC=0
     239 ... F  S NOCC=$O(^TMP($J,INDEX,1,DFN,ITEM,NOCC)) Q:NOCC=""  D
     240 .... S FILENUM=""
     241 .... F  S FILENUM=$O(^TMP($J,INDEX,1,DFN,ITEM,NOCC,FILENUM)) Q:FILENUM=""  D
     242 ..... S TEMP=^TMP($J,INDEX,1,DFN,ITEM,NOCC,FILENUM)
     243 ..... S DAS=$P(TEMP,U,1)
     244 ..... K DATA
     245 ..... D GETDATA^PXRMDATA(FILENUM,DAS,.DATA)
     246 ..... S VISIT=$G(DATA("VISIT"))
     247 ..... I VISIT="" Q
     248 ..... S SOURCE=DAS_";"_^PXRMINDX(FILENUM,"GLOBAL NAME")
     249 ..... S UPDSTAT=$$UPDATE(DFN,VISIT,SOURCE,STCODE,"SYNCH")
     250 ..... I UPDSTAT'=-1 S NUMUPD=NUMUPD+1
     251 K ^TMP($J,INDEX)
     252 Q
     253 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMOUTC.m

    r613 r623  
    1 PXRMOUTC        ; SLC/PKR - Clinical Maintenance output. ;07/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;================================================
    4 CM(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL)     ;Prepare the
    5         ;clinical maintenance output.
    6         N IND,JND,FIDATA,FINDING,FLIST,FTYPE
    7         N HDR,NHDR,IFIEVAL,LIST,NFLINES,NTXT,NUM
    8         N TEMP,TEXT
    9         S NTXT=0
    10         ;Check for a dead patient
    11         I +$G(PXRMPDEM("DOD"))>0 D
    12         . S TEMP=$$FMTE^XLFDT(PXRMPDEM("DOD"),"5DZ")
    13         . S TEXT="Patient is deceased, date of death: "_TEMP
    14         . D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
    15         ;Display the frequency information only if there is resolution logic.
    16         I RESLOGIC'="" D FREQ(.DEFARR,.NTXT,.TEXT)
    17         ;Output the AGE match/no match text.
    18         D AGE^PXRMFNFT(PXRMPDEM("DFN"),.DEFARR,.FIEVAL,.NTXT)
    19         ;Process the findings in the order: patient cohort, resolution,
    20         ;age, and informational.
    21         M FIDATA=FIEVAL
    22         F FTYPE="PCL","RES","AGE","INFO" D
    23         . S LIST=$S(FTYPE="PCL":DEFARR(32),FTYPE="RES":DEFARR(36),FTYPE="AGE":DEFARR(40),FTYPE="INFO":DEFARR(42))
    24         .;Output the general logic text.
    25         . I FTYPE="PCL" D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),PCLOGIC,FTYPE,"D",.DEFARR,.NTXT)
    26         . I FTYPE="RES",$P(PCLOGIC,U,1) D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),RESLOGIC,FTYPE,"D",.DEFARR,.NTXT)
    27         .;Process the findings for each type.
    28         . K TEXT
    29         . S (NHDR,NFLINES)=0
    30         . S NUM=+$P(LIST,U,1)
    31         . S FLIST=$P(LIST,U,2)
    32         . F IND=1:1:NUM D
    33         .. S FINDING=$P(FLIST,";",IND)
    34         ..;No output for age or sex findings.
    35         .. I (FINDING="AGE")!(FINDING="SEX") Q
    36         ..;Make sure each finding is processed only once.
    37         .. I '$D(FIDATA(FINDING)) Q
    38         .. K IFIEVAL
    39         .. ;I FIEVAL(FINDING) M IFIEVAL=FIEVAL(FINDING)
    40         .. ;E  S IFIEVAL=0
    41         .. I FIEVAL(FINDING) D
    42         ... M IFIEVAL=FIEVAL(FINDING)
    43         ...;Remove any false occurrences so they are not displayed.
    44         ... S JND=0
    45         ... F  S JND=+$O(IFIEVAL(JND)) Q:JND=0  K:'IFIEVAL(JND) IFIEVAL(JND)
    46         .. E  S IFIEVAL=0
    47         ..;If the finding is false all we need to do is process the not found
    48         ..;text. If it is true we also need to output the finding information.
    49         .. I IFIEVAL D FOUT(1,.IFIEVAL,.NFLINES,.TEXT)
    50         ..;Output the found/not found text for the finding.
    51 FNF     .. D FINDING^PXRMFNFT(3,PXRMPDEM("DFN"),FINDING,.IFIEVAL,.NFLINES,.TEXT)
    52         ..;Make sure each finding is processed only once.
    53         .. K FIDATA(FINDING)
    54         .;
    55         .;If there was any text for this finding type create a header.
    56         . D HEADER(FTYPE,NFLINES,RESDATE,.NHDR,.HDR)
    57         .;Output the header and the finding text.
    58         . D ADDTXTA^PXRMOUTU(1,PXRMRM,.NTXT,NHDR,.HDR)
    59         . D COPYTXT^PXRMOUTU(.NTXT,NFLINES,.TEXT)
    60         ;Output INFO nodes
    61         D INFO^PXRMOUTU(PXRMITEM,.NTXT)
    62         Q
    63         ;
    64         ;================================================
    65 FOUT(INDENT,IFIEVAL,NLINES,TEXT)        ;Do output for individual findings
    66         ;in the FINDING array.
    67         I $D(IFIEVAL("TERM")) D OUTPUT^PXRMTERM(1,.IFIEVAL,.NFLINES,.TEXT) Q
    68         N FTYPE
    69         S FTYPE=$P(IFIEVAL("FINDING"),U,1)
    70         S FTYPE=$P(FTYPE,";",2)
    71         I FTYPE="AUTTEDT(" D OUTPUT^PXRMEDU(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    72         I FTYPE="AUTTEXAM(" D OUTPUT^PXRMEXAM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    73         I FTYPE="AUTTHF(" D OUTPUT^PXRMHF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    74         I FTYPE="AUTTIMM(" D OUTPUT^PXRMIMM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    75         I FTYPE="AUTTSK(" D OUTPUT^PXRMSKIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    76         I FTYPE="GMRD(120.51," D OUTPUT^PXRMVITL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    77         I FTYPE="LAB(60," D OUTPUT^PXRMLAB(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    78         I FTYPE="ORD(101.43," D OUTPUT^PXRMORDR(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    79         I FTYPE="PS(50.605," D OUTPUT^PXRMDRCL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    80         I FTYPE="PSDRUG(" D OUTPUT^PXRMDRUG(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    81         I FTYPE="PSNDF(50.6," D OUTPUT^PXRMDGEN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    82         I FTYPE="PS(55," D OUTPUT^PXRMDIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    83         I FTYPE="PS(55NVA," D OUTPUT^PXRMDNVA(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    84         I FTYPE="PSRX(" D OUTPUT^PXRMDOUT(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    85         I FTYPE="PXD(811.2," D OUTPUT^PXRMTAX(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    86         I FTYPE="PXRMD(802.4," D OUTPUT^PXRMFF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    87         I FTYPE="PXRMD(810.9," D OUTPUT^PXRMLOCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    88         I FTYPE="PXRMD(811.4," D OUTPUT^PXRMCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    89         I FTYPE="RAMIS(71," D OUTPUT^PXRMRAD(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    90         I FTYPE="YTT(601.71," D OUTPUT^PXRMMH(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    91         Q
    92         ;
    93         ;================================================
    94 FREQ(DEFARR,NTXT,TEXT)  ;Display the frequency information.
    95         N FREQ,TEMP
    96         ;If there was a custom date due print out that information.
    97         I $D(^TMP(PXRMPID,$J,PXRMITEM,"zCDUE")) D
    98         . S TEMP=^TMP(PXRMPID,$J,PXRMITEM,"zCDUE")
    99         . S TEXT=$$OUTPUT^PXRMCDUE(TEMP,.DEFARR)
    100         . I DEFARR(31)["AGE" D
    101         .. S TEMP=$G(^TMP(PXRMPID,$J,PXRMITEM,"zFREQARNG"))
    102         .. I TEMP'="" S TEXT=TEXT_" Applicable"_$$FMTAGE^PXRMAGE($P(TEMP,U,2),$P(TEMP,U,3))_"."
    103         . D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
    104         E  D
    105         . S TEMP=$G(^TMP(PXRMPID,$J,PXRMITEM,"zFREQARNG"))
    106         . I TEMP'="" D
    107         .. S FREQ=$P(TEMP,U,1)
    108         .. S TEXT=$$FMTFREQ^PXRMAGE(FREQ)
    109         .. I FREQ=-1 S TEXT=TEXT_" for this patient."
    110         .. I DEFARR(31)["AGE",FREQ'=-1 S TEXT=TEXT_$$FMTAGE^PXRMAGE($P(TEMP,U,2),$P(TEMP,U,3))_"."
    111         .. D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
    112         Q
    113         ;
    114         ;================================================
    115 HEADER(FTYPE,NLINES,RESDATE,NHDR,HDR)   ;Create a finding header.
    116         I FTYPE="RES" D  Q
    117         . I +RESDATE'=0 D  Q
    118         .. S HDR(2)="Resolution: Last done "_$$EDATE^PXRMDATE(RESDATE)
    119         .. S NHDR=2
    120         .. S HDR(1)="\\"
    121         . I '$D(HDR(2)),NLINES>0 D
    122         .. S HDR(2)="Resolution:"
    123         .. S NHDR=2
    124         .. S HDR(1)="\\"
    125         ;
    126         I NLINES=0 Q
    127         I FTYPE="PCL" D  Q
    128         . S NHDR=2
    129         . S HDR(1)="\\"
    130         . S HDR(2)="Cohort:"
    131         ;
    132         I FTYPE="AGE" D  Q
    133         . S NHDR=2
    134         . S HDR(1)="\\"
    135         . S HDR(2)="Age/Frequency:"
    136         ;
    137         I FTYPE="INFO" D  Q
    138         . S NHDR=2
    139         . S HDR(1)="\\"
    140         . S HDR(2)="Information:"
    141         Q
    142         ;
     1PXRMOUTC ; SLC/PKR - Clinical Maintenance output. ;10/07/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;================================================
     4CM(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL) ;Prepare the
     5 ;clinical maintenance output.
     6 N IND,FIDATA,FINDING,FLIST,FTYPE
     7 N HDR,NHDR,IFIEVAL,LIST,NFLINES,NTXT,NUM
     8 N TEMP,TEXT
     9 S NTXT=0
     10 ;Check for a dead patient
     11 I +$G(PXRMPDEM("DOD"))>0 D
     12 . S TEMP=$$FMTE^XLFDT(PXRMPDEM("DOD"),"5DZ")
     13 . S TEXT="Patient is deceased, date of death: "_TEMP
     14 . D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
     15 ;Display the frequency information only if there is resolution logic.
     16 I RESLOGIC'="" D FREQ(.DEFARR,.NTXT,.TEXT)
     17 ;Output the AGE match/no match text.
     18 D AGE^PXRMFNFT(PXRMPDEM("DFN"),.DEFARR,.FIEVAL,.NTXT)
     19 ;Process the findings in the order: patient cohort, resolution,
     20 ;age, and informational.
     21 M FIDATA=FIEVAL
     22 F FTYPE="PCL","RES","AGE","INFO" D
     23 . S LIST=$S(FTYPE="PCL":DEFARR(32),FTYPE="RES":DEFARR(36),FTYPE="AGE":DEFARR(40),FTYPE="INFO":DEFARR(42))
     24 .;Output the general logic text.
     25 . I FTYPE="PCL" D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),PCLOGIC,FTYPE,"D",.DEFARR,.NTXT)
     26 . I FTYPE="RES",$P(PCLOGIC,U,1) D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),RESLOGIC,FTYPE,"D",.DEFARR,.NTXT)
     27 .;Process the findings for each type.
     28 . K TEXT
     29 . S (NHDR,NFLINES)=0
     30 . S NUM=+$P(LIST,U,1)
     31 . S FLIST=$P(LIST,U,2)
     32 . F IND=1:1:NUM D
     33 .. S FINDING=$P(FLIST,";",IND)
     34 ..;No output for age or sex findings.
     35 .. I (FINDING="AGE")!(FINDING="SEX") Q
     36 ..;Make sure each finding is processed only once.
     37 .. I '$D(FIDATA(FINDING)) Q
     38 .. K IFIEVAL
     39 .. I FIEVAL(FINDING) M IFIEVAL=FIEVAL(FINDING)
     40 .. E  S IFIEVAL=0
     41 ..;If the finding is false all we need to do is process the not found
     42 ..;text. If it is true we also need to output the finding information.
     43 .. I IFIEVAL D FOUT(1,.IFIEVAL,.NFLINES,.TEXT)
     44 ..;Output the found/not found text for the finding.
     45FNF .. D FINDING^PXRMFNFT(3,PXRMPDEM("DFN"),FINDING,.IFIEVAL,.NFLINES,.TEXT)
     46 ..;Make sure each finding is processed only once.
     47 .. K FIDATA(FINDING)
     48 .;
     49 .;If there was any text for this finding type create a header.
     50 . D HEADER(FTYPE,NFLINES,RESDATE,.NHDR,.HDR)
     51 .;Output the header and the finding text.
     52 . D ADDTXTA^PXRMOUTU(1,PXRMRM,.NTXT,NHDR,.HDR)
     53 . D COPYTXT^PXRMOUTU(.NTXT,NFLINES,.TEXT)
     54 ;Output INFO nodes
     55 D INFO^PXRMOUTU(PXRMITEM,.NTXT)
     56 Q
     57 ;
     58 ;================================================
     59FOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Do output for individual findings
     60 ;in the FINDING array.
     61 I $D(IFIEVAL("TERM")) D OUTPUT^PXRMTERM(1,.IFIEVAL,.NFLINES,.TEXT) Q
     62 N FTYPE
     63 S FTYPE=$P(IFIEVAL("FINDING"),U,1)
     64 S FTYPE=$P(FTYPE,";",2)
     65 I FTYPE="AUTTEDT(" D OUTPUT^PXRMEDU(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     66 I FTYPE="AUTTEXAM(" D OUTPUT^PXRMEXAM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     67 I FTYPE="AUTTHF(" D OUTPUT^PXRMHF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     68 I FTYPE="AUTTIMM(" D OUTPUT^PXRMIMM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     69 I FTYPE="AUTTSK(" D OUTPUT^PXRMSKIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     70 I FTYPE="GMRD(120.51," D OUTPUT^PXRMVITL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     71 I FTYPE="LAB(60," D OUTPUT^PXRMLAB(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     72 I FTYPE="ORD(101.43," D OUTPUT^PXRMORDR(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     73 I FTYPE="PS(50.605," D OUTPUT^PXRMDRCL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     74 I FTYPE="PSDRUG(" D OUTPUT^PXRMDRUG(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     75 I FTYPE="PSNDF(50.6," D OUTPUT^PXRMDGEN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     76 I FTYPE="PS(55," D OUTPUT^PXRMDIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     77 I FTYPE="PS(55NVA," D OUTPUT^PXRMDNVA(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     78 I FTYPE="PSRX(" D OUTPUT^PXRMDOUT(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     79 I FTYPE="PXD(811.2," D OUTPUT^PXRMTAX(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     80 I FTYPE="PXRMD(802.4," D OUTPUT^PXRMFF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     81 I FTYPE="PXRMD(810.9," D OUTPUT^PXRMLOCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     82 I FTYPE="PXRMD(811.4," D OUTPUT^PXRMCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     83 I FTYPE="RAMIS(71," D OUTPUT^PXRMRAD(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     84 I FTYPE="YTT(601," D OUTPUT^PXRMMH(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     85 Q
     86 ;
     87 ;================================================
     88FREQ(DEFARR,NTXT,TEXT) ;Display the frequency information.
     89 N FREQ,TEMP
     90 ;If there was a custom date due print out that information.
     91 I $D(^TMP(PXRMPID,$J,PXRMITEM,"zCDUE")) D
     92 . S TEMP=^TMP(PXRMPID,$J,PXRMITEM,"zCDUE")
     93 . S TEXT=$$OUTPUT^PXRMCDUE(TEMP,.DEFARR)
     94 . I DEFARR(31)["AGE" D
     95 .. S TEMP=$G(^TMP(PXRMPID,$J,PXRMITEM,"zFREQARNG"))
     96 .. I TEMP'="" S TEXT=TEXT_" Applicable"_$$FMTAGE^PXRMAGE($P(TEMP,U,2),$P(TEMP,U,3))_"."
     97 . D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
     98 E  D
     99 . S TEMP=$G(^TMP(PXRMPID,$J,PXRMITEM,"zFREQARNG"))
     100 . I TEMP'="" D
     101 .. S FREQ=$P(TEMP,U,1)
     102 .. S TEXT=$$FMTFREQ^PXRMAGE(FREQ)
     103 .. I FREQ=-1 S TEXT=TEXT_" for this patient."
     104 .. I DEFARR(31)["AGE",FREQ'=-1 S TEXT=TEXT_$$FMTAGE^PXRMAGE($P(TEMP,U,2),$P(TEMP,U,3))_"."
     105 .. D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
     106 Q
     107 ;
     108 ;================================================
     109HEADER(FTYPE,NLINES,RESDATE,NHDR,HDR) ;Create a finding header.
     110 I FTYPE="RES" D  Q
     111 . I +RESDATE'=0 D  Q
     112 .. S HDR(2)="Resolution: Last done "_$$EDATE^PXRMDATE(RESDATE)
     113 .. S NHDR=2
     114 .. S HDR(1)="\\"
     115 . I '$D(HDR(2)),NLINES>0 D
     116 .. S HDR(2)="Resolution:"
     117 .. S NHDR=2
     118 .. S HDR(1)="\\"
     119 ;
     120 I NLINES=0 Q
     121 I FTYPE="PCL" D  Q
     122 . S NHDR=2
     123 . S HDR(1)="\\"
     124 . S HDR(2)="Cohort:"
     125 ;
     126 I FTYPE="AGE" D  Q
     127 . S NHDR=2
     128 . S HDR(1)="\\"
     129 . S HDR(2)="Age/Frequency:"
     130 ;
     131 I FTYPE="INFO" D  Q
     132 . S NHDR=2
     133 . S HDR(1)="\\"
     134 . S HDR(2)="Information:"
     135 Q
     136 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMOUTM.m

    r613 r623  
    1 PXRMOUTM        ; SLC/PKR - MyHealtheVet output. ;07/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;================================================
    5 FOUT(INDENT,IFIEVAL,NLINES,TEXT)        ;Do output for individual findings
    6         ;in the FINDING array.
    7         I $D(IFIEVAL("TERM")) D MHVOUT^PXRMTERM(1,.IFIEVAL,.NFLINES,.TEXT) Q
    8         N FTYPE
    9         S FTYPE=$P(IFIEVAL("FINDING"),U,1)
    10         S FTYPE=$P(FTYPE,";",2)
    11         I FTYPE="AUTTEDT(" D MHVOUT^PXRMEDU(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    12         I FTYPE="AUTTEXAM(" D MHVOUT^PXRMEXAM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    13         I FTYPE="AUTTHF(" D MHVOUT^PXRMHF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    14         I FTYPE="AUTTIMM(" D MHVOUT^PXRMIMM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    15         I FTYPE="AUTTSK(" D MHVOUT^PXRMSKIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    16         I FTYPE="GMRD(120.51," D MHVOUT^PXRMVITL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    17         I FTYPE="LAB(60," D MHVOUT^PXRMLAB(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    18         I FTYPE="ORD(101.43," D MHVOUT^PXRMORDR(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    19         I FTYPE="PS(50.605," D MHVOUT^PXRMDRCL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    20         I FTYPE="PSDRUG(" D MHVOUT^PXRMDRUG(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    21         I FTYPE="PS(55," D MHVOUT^PXRMDIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    22         I FTYPE="PS(55NVA," D MHVOUT^PXRMDNVA(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    23         I FTYPE="PSRX(" D MHVOUT^PXRMDOUT(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    24         I FTYPE="PSNDF(50.6," D MHVOUT^PXRMDGEN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    25         I FTYPE="PXD(811.2," D MHVOUT^PXRMTAX(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    26         I FTYPE="PXRMD(802.4," D MHVOUT^PXRMFF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    27         I FTYPE="PXRMD(810.9," D MHVOUT^PXRMLOCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    28         I FTYPE="PXRMD(811.4," D MHVOUT^PXRMCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    29         I FTYPE="RAMIS(71," D MHVOUT^PXRMRAD(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    30         I FTYPE="YTT(601.71," D MHVOUT^PXRMMH(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
    31         Q
    32         ;
    33         ;================================================
    34 MHVC(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL)   ;Prepare the
    35         ;MyHealtheVet combined output.
    36         N PNAME,RIEN
    37         S RIEN=DEFARR("IEN")
    38         S PNAME=$O(^TMP("PXRHM",$J,RIEN,""))
    39         S ^TMP("PXRMMHVC",$J,RIEN,"STATUS")=^TMP("PXRHM",$J,RIEN,PNAME)
    40         D MHVD(.DEFARR,.PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,.FIEVAL,0)
    41         M ^TMP("PXRMMHVC",$J,RIEN,"DETAIL")=^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
    42         K ^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
    43         D MHVS(.DEFARR,.PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,.FIEVAL,0)
    44         M ^TMP("PXRMMHVC",$J,RIEN,"SUMMARY")=^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
    45         K ^TMP("PXRHM",$J,RIEN,PNAME)
    46         Q
    47         ;
    48         ;================================================
    49 MHVD(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL,WEB)       ;Prepare the
    50         ;MyHealtheVet detailed output.
    51         N IND,JND,FIDATA,FINDING,FLIST,FTYPE
    52         N HDR,NHDR,IFIEVAL,LIST,NFLINES,NTXT,NUM
    53         N TEXT
    54         S NTXT=0
    55         ;Output the AGE match/no match text.
    56         D AGE^PXRMFNFT(PXRMPDEM("DFN"),.DEFARR,.FIEVAL,.NTXT)
    57         ;Process the findings in the order: patient cohort, resolution,
    58         ;age, and informational.
    59         M FIDATA=FIEVAL
    60         F FTYPE="PCL","RES","AGE","INFO" D
    61         . S LIST=$S(FTYPE="PCL":DEFARR(32),FTYPE="RES":DEFARR(36),FTYPE="AGE":DEFARR(40),FTYPE="INFO":DEFARR(42))
    62         .;Output the general logic text.
    63         . I FTYPE="PCL" D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),PCLOGIC,FTYPE,"D",.DEFARR,.NTXT)
    64         . I FTYPE="RES",$P(PCLOGIC,U,1) D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),RESLOGIC,FTYPE,"D",.DEFARR,.NTXT)
    65         .;Process the findings for each type.
    66         . K TEXT
    67         . S (NHDR,NFLINES)=0
    68         . S NUM=+$P(LIST,U,1)
    69         . S FLIST=$P(LIST,U,2)
    70         . F IND=1:1:NUM D
    71         .. S FINDING=$P(FLIST,";",IND)
    72         ..;No output for age or sex findings.
    73         .. I (FINDING="AGE")!(FINDING="SEX") Q
    74         ..;Make sure each finding is processed only once.
    75         .. I '$D(FIDATA(FINDING)) Q
    76         .. K IFIEVAL
    77         .. ;I FIEVAL(FINDING) M IFIEVAL=FIEVAL(FINDING)
    78         .. ;E  S IFIEVAL=0
    79         .. I FIEVAL(FINDING) D
    80         ... M IFIEVAL=FIEVAL(FINDING)
    81         ...;Remove any false occurrences so they are not displayed.
    82         ... S JND=0
    83         ... F  S JND=+$O(IFIEVAL(JND)) Q:JND=0  K:'IFIEVAL(JND) IFIEVAL(JND)
    84         .. E  S IFIEVAL=0
    85         ..;Output the found/not found text for the finding.
    86         .. D FINDING^PXRMFNFT(3,PXRMPDEM("DFN"),FINDING,.IFIEVAL,.NFLINES,.TEXT)
    87         ..;If the finding is true output the finding information.
    88         .. I IFIEVAL D FOUT(1,.IFIEVAL,.NFLINES,.TEXT)
    89         ..;Make sure each finding is processed only once.
    90         .. K FIDATA(FINDING)
    91         .;
    92         .;If there was any text for this finding type create a header.
    93         .;Output the header and the finding text.
    94         . D COPYTXT^PXRMOUTU(.NTXT,NFLINES,.TEXT)
    95         I WEB D WEB(DEFARR("IEN"),.NTXT)
    96         Q
    97         ;
    98         ;================================================
    99 MHVS(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL,WEB)       ;Prepare the
    100         ;MyHealtheVet summary output.
    101         N NTXT
    102         S NTXT=0
    103         D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),PCLOGIC,"PCL","S",.DEFARR,.NTXT)
    104         I $P(PCLOGIC,U,1) D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),RESLOGIC,"RES","S",.DEFARR,.NTXT)
    105         I WEB D WEB(DEFARR("IEN"),.NTXT)
    106         Q
    107         ;
    108         ;================================================
    109 WEB(RIEN,NTXT)  ;Output the web site information.
    110         N DES,IEN,IND,NL,TEXT,TITLE,URL
    111         I '$D(^PXD(811.9,RIEN,50)) Q
    112         S TEXT="\\ Please check these web sites for more information:\\"
    113         D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
    114         S IEN=0
    115         F  S IEN=+$O(^PXD(811.9,RIEN,50,IEN)) Q:IEN=0  D
    116         . S TEXT=$G(^PXD(811.9,RIEN,50,IEN,0))
    117         . S URL=$P(TEXT,U,1)
    118         . I URL="" Q
    119         . S TITLE=$P(TEXT,U,2)
    120         . S DES=$D(^PXD(811.9,RIEN,50,IEN,1))
    121         . S TEXT(1)="Web Site: "_TITLE_"\\"
    122         . S TEXT(2)="URL: "_URL_$S('DES:"\\",1:"")
    123         . D ADDTXTA^PXRMOUTU(2,PXRMRM,.NTXT,2,.TEXT)
    124         .;If there is a description output it.
    125         . I 'DES Q
    126         . K TEXT
    127         . S (IND,NL)=0
    128         .  F  S IND=+$O(^PXD(811.9,RIEN,50,IEN,1,IND)) Q:IND=0  D
    129         .. S NL=NL+1
    130         .. S TEXT(NL)=^PXD(811.9,RIEN,50,IEN,1,IND,0)
    131         . S TEXT(NL)=TEXT(NL)_"\\"
    132         . D ADDTXTA^PXRMOUTU(3,PXRMRM,.NTXT,NL,.TEXT)
    133         Q
    134         ;
     1PXRMOUTM ; SLC/PKR - MyHealtheVet output. ;10/12/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;================================================
     5FOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Do output for individual findings
     6 ;in the FINDING array.
     7 I $D(IFIEVAL("TERM")) D MHVOUT^PXRMTERM(1,.IFIEVAL,.NFLINES,.TEXT) Q
     8 N FTYPE
     9 S FTYPE=$P(IFIEVAL("FINDING"),U,1)
     10 S FTYPE=$P(FTYPE,";",2)
     11 I FTYPE="AUTTEDT(" D MHVOUT^PXRMEDU(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     12 I FTYPE="AUTTEXAM(" D MHVOUT^PXRMEXAM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     13 I FTYPE="AUTTHF(" D MHVOUT^PXRMHF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     14 I FTYPE="AUTTIMM(" D MHVOUT^PXRMIMM(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     15 I FTYPE="AUTTSK(" D MHVOUT^PXRMSKIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     16 I FTYPE="GMRD(120.51," D MHVOUT^PXRMVITL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     17 I FTYPE="LAB(60," D MHVOUT^PXRMLAB(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     18 I FTYPE="ORD(101.43," D MHVOUT^PXRMORDR(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     19 I FTYPE="PS(50.605," D MHVOUT^PXRMDRCL(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     20 I FTYPE="PSDRUG(" D MHVOUT^PXRMDRUG(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     21 I FTYPE="PS(55," D MHVOUT^PXRMDIN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     22 I FTYPE="PS(55NVA," D MHVOUT^PXRMDNVA(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     23 I FTYPE="PSRX(" D MHVOUT^PXRMDOUT(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     24 I FTYPE="PSNDF(50.6," D MHVOUT^PXRMDGEN(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     25 I FTYPE="PXD(811.2," D MHVOUT^PXRMTAX(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     26 I FTYPE="PXRMD(802.4," D MHVOUT^PXRMFF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     27 I FTYPE="PXRMD(810.9," D MHVOUT^PXRMLOCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     28 I FTYPE="PXRMD(811.4," D MHVOUT^PXRMCF(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     29 I FTYPE="RAMIS(71," D MHVOUT^PXRMRAD(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     30 I FTYPE="YTT(601," D MHVOUT^PXRMMH(INDENT,.IFIEVAL,.NLINES,.TEXT) Q
     31 Q
     32 ;
     33 ;================================================
     34MHVC(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL) ;Prepare the
     35 ;MyHealtheVet combined output.
     36 N PNAME,RIEN
     37 S RIEN=DEFARR("IEN")
     38 S PNAME=$O(^TMP("PXRHM",$J,RIEN,""))
     39 S ^TMP("PXRMMHVC",$J,RIEN,"STATUS")=^TMP("PXRHM",$J,RIEN,PNAME)
     40 D MHVD(.DEFARR,.PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,.FIEVAL,0)
     41 M ^TMP("PXRMMHVC",$J,RIEN,"DETAIL")=^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
     42 K ^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
     43 D MHVS(.DEFARR,.PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,.FIEVAL,0)
     44 M ^TMP("PXRMMHVC",$J,RIEN,"SUMMARY")=^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
     45 K ^TMP("PXRHM",$J,RIEN,PNAME)
     46 Q
     47 ;
     48 ;================================================
     49MHVD(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL,WEB) ;Prepare the
     50 ;MyHealtheVet detailed output.
     51 N IND,FIDATA,FINDING,FLIST,FTYPE
     52 N HDR,NHDR,IFIEVAL,LIST,NFLINES,NTXT,NUM
     53 N TEXT
     54 S NTXT=0
     55 ;Output the AGE match/no match text.
     56 D AGE^PXRMFNFT(PXRMPDEM("DFN"),.DEFARR,.FIEVAL,.NTXT)
     57 ;Process the findings in the order: patient cohort, resolution,
     58 ;age, and informational.
     59 M FIDATA=FIEVAL
     60 F FTYPE="PCL","RES","AGE","INFO" D
     61 . S LIST=$S(FTYPE="PCL":DEFARR(32),FTYPE="RES":DEFARR(36),FTYPE="AGE":DEFARR(40),FTYPE="INFO":DEFARR(42))
     62 .;Output the general logic text.
     63 . I FTYPE="PCL" D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),PCLOGIC,FTYPE,"D",.DEFARR,.NTXT)
     64 . I FTYPE="RES",$P(PCLOGIC,U,1) D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),RESLOGIC,FTYPE,"D",.DEFARR,.NTXT)
     65 .;Process the findings for each type.
     66 . K TEXT
     67 . S (NHDR,NFLINES)=0
     68 . S NUM=+$P(LIST,U,1)
     69 . S FLIST=$P(LIST,U,2)
     70 . F IND=1:1:NUM D
     71 .. S FINDING=$P(FLIST,";",IND)
     72 ..;No output for age or sex findings.
     73 .. I (FINDING="AGE")!(FINDING="SEX") Q
     74 ..;Make sure each finding is processed only once.
     75 .. I '$D(FIDATA(FINDING)) Q
     76 .. K IFIEVAL
     77 .. I FIEVAL(FINDING) M IFIEVAL=FIEVAL(FINDING)
     78 .. E  S IFIEVAL=0
     79 ..;Output the found/not found text for the finding.
     80 .. D FINDING^PXRMFNFT(3,PXRMPDEM("DFN"),FINDING,.IFIEVAL,.NFLINES,.TEXT)
     81 ..;If the finding is true output the finding information.
     82 .. I IFIEVAL D FOUT(1,.IFIEVAL,.NFLINES,.TEXT)
     83 ..;Make sure each finding is processed only once.
     84 .. K FIDATA(FINDING)
     85 .;
     86 .;If there was any text for this finding type create a header.
     87 .;Output the header and the finding text.
     88 . D COPYTXT^PXRMOUTU(.NTXT,NFLINES,.TEXT)
     89 I WEB D WEB(DEFARR("IEN"),.NTXT)
     90 Q
     91 ;
     92 ;================================================
     93MHVS(DEFARR,PXRMPDEM,PCLOGIC,RESLOGIC,RESDATE,FIEVAL,WEB) ;Prepare the
     94 ;MyHealtheVet summary output.
     95 N NTXT
     96 S NTXT=0
     97 D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),PCLOGIC,"PCL","S",.DEFARR,.NTXT)
     98 I $P(PCLOGIC,U,1) D LOGIC^PXRMFNFT(PXRMPDEM("DFN"),RESLOGIC,"RES","S",.DEFARR,.NTXT)
     99 I WEB D WEB(DEFARR("IEN"),.NTXT)
     100 Q
     101 ;
     102 ;================================================
     103WEB(RIEN,NTXT) ;Output the web site information.
     104 N DES,IEN,IND,NL,TEXT,TITLE,URL
     105 I '$D(^PXD(811.9,RIEN,50)) Q
     106 S TEXT="\\ Please check these web sites for more information:\\"
     107 D ADDTXT^PXRMOUTU(1,PXRMRM,.NTXT,TEXT)
     108 S IEN=0
     109 F  S IEN=+$O(^PXD(811.9,RIEN,50,IEN)) Q:IEN=0  D
     110 . S TEXT=$G(^PXD(811.9,RIEN,50,IEN,0))
     111 . S URL=$P(TEXT,U,1)
     112 . I URL="" Q
     113 . S TITLE=$P(TEXT,U,2)
     114 . S DES=$D(^PXD(811.9,RIEN,50,IEN,1))
     115 . S TEXT(1)="Web Site: "_TITLE_"\\"
     116 . S TEXT(2)="URL: "_URL_$S('DES:"\\",1:"")
     117 . D ADDTXTA^PXRMOUTU(2,PXRMRM,.NTXT,2,.TEXT)
     118 .;If there is a description output it.
     119 . I 'DES Q
     120 . K TEXT
     121 . S (IND,NL)=0
     122 .  F  S IND=+$O(^PXD(811.9,RIEN,50,IEN,1,IND)) Q:IND=0  D
     123 .. S NL=NL+1
     124 .. S TEXT(NL)=^PXD(811.9,RIEN,50,IEN,1,IND,0)
     125 . S TEXT(NL)=TEXT(NL)_"\\"
     126 . D ADDTXTA^PXRMOUTU(3,PXRMRM,.NTXT,NL,.TEXT)
     127 Q
     128 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPARS.m

    r613 r623  
    1 PXRMPARS        ; SLC/PJH - Edit PXRM(800 reminder parameters. ;04/02/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;called by protocol PXRM EDIT SITE DISCLAIMER
    5         ;
    6 DISC(DA)        ;Edit default disclaimer
    7         Q:'$$LOCK(DA)
    8         N DIC,DIE,DR,Y
    9         ;Edit
    10         S DIC="^PXRM(800,",DIE=800,DR=2
    11         D ^DIE
    12         D FORMAT^PXRMDISC
    13         Q
    14         ;
    15 MH(DA)  ;Edit MH default Question Value
    16         Q:'$$LOCK(DA)
    17         N DIC,DIE,DR,Y
    18         ;Edit
    19         S DIE="^PXRM(800,",DR=17
    20         D ^DIE
    21         Q
    22         ;
    23         ;called by protocol PXRM EDIT WEB SITE
    24         ;
    25 WEB(DA) ;Edit default web site
    26         Q:'$$LOCK(DA)
    27         ;Edit
    28         N DTOUT,DUOUT
    29         F  D  Q:$D(DUOUT)!$D(DTOUT)
    30         .D WLIST,WSET,WURL(DA)
    31         Q
    32         ;
    33 WLIST   ;Display web sites
    34         N FIRST,SUB,SUB1
    35         S FIRST=1,SUB=""
    36         F  S SUB=$O(^PXRM(800,DA,1,"B",SUB)) Q:SUB=""  D
    37         .S SUB1=0
    38         .F  S SUB1=$O(^PXRM(800,DA,1,"B",SUB,SUB1)) Q:'SUB1  D
    39         ..I FIRST S FIRST=0 W !!,"Choose from:",!
    40         ..W ?8,$P($G(^PXRM(800,DA,1,SUB1,0)),U),!
    41         I FIRST W !!,"No default web sites defined",!
    42         Q
    43         ;
    44 WSET    ;Set node if not defined
    45         S:'$D(^PXRM(800,DA,1,0)) ^PXRM(800,DA,1,0)="^800.04"
    46         Q
    47         ;
    48 WURL(IEN)       ;Edit individual URL
    49         N DA,DIC,DIE,DR,Y
    50         S DA(1)=IEN
    51         S DIC="^PXRM(800,"_IEN_",1,"
    52         S DIC(0)="QEAL"
    53         S DIC("A")="Select URL: "
    54         S DIC("P")="800.04"
    55         D ^DIC I Y=-1 S DTOUT=1 Q
    56         S DIE=DIC K DIC
    57         S DA=+Y
    58         ;Finding record fields
    59         S DR=".01;.02;1"
    60         ;Edit finding record
    61         D ^DIE
    62         I $D(Y) S DTOUT=1 Q
    63         ;Check if deleted
    64         I '$D(DA) Q
    65         Q
    66         ;
    67 LOCK(DA)        ;Lock the record
    68         L +^PXRM(800,DA):0 I  Q 1
    69         E  W !!,?5,"Another user is editing this file, try later" H 2 Q 0
    70         ;
    71 UNLOCK(DA)      ;Unlock the record
    72         L -^PXRM(800,DA)
    73         Q
     1PXRMPARS ; SLC/PJH - Edit PXRM(800 reminder parameters. ;06/14/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;called by protocol PXRM EDIT SITE DISCLAIMER
     5 ;
     6DISC(DA) ;Edit default disclaimer
     7 Q:'$$LOCK(DA)
     8 N DIC,DIE,DR,Y
     9 ;Edit
     10 S DIC="^PXRM(800,",DIE=800,DR=2
     11 D ^DIE
     12 D FORMAT^PXRMDISC
     13 Q
     14 ;
     15 ;called by protocol PXRM EDIT WEB SITE
     16 ;
     17WEB(DA) ;Edit default web site
     18 Q:'$$LOCK(DA)
     19 ;Edit
     20 N DTOUT,DUOUT
     21 F  D  Q:$D(DUOUT)!$D(DTOUT)
     22 .D WLIST,WSET,WURL(DA)
     23 Q
     24 ;
     25WLIST ;Display web sites
     26 N FIRST,SUB,SUB1
     27 S FIRST=1,SUB=""
     28 F  S SUB=$O(^PXRM(800,DA,1,"B",SUB)) Q:SUB=""  D
     29 .S SUB1=0
     30 .F  S SUB1=$O(^PXRM(800,DA,1,"B",SUB,SUB1)) Q:'SUB1  D
     31 ..I FIRST S FIRST=0 W !!,"Choose from:",!
     32 ..W ?8,$P($G(^PXRM(800,DA,1,SUB1,0)),U),!
     33 I FIRST W !!,"No default web sites defined",!
     34 Q
     35 ;
     36WSET ;Set node if not defined
     37 S:'$D(^PXRM(800,DA,1,0)) ^PXRM(800,DA,1,0)="^800.04"
     38 Q
     39 ;
     40WURL(IEN) ;Edit individual URL
     41 N DA,DIC,DIE,DR,Y
     42 S DA(1)=IEN
     43 S DIC="^PXRM(800,"_IEN_",1,"
     44 S DIC(0)="QEAL"
     45 S DIC("A")="Select URL: "
     46 S DIC("P")="800.04"
     47 D ^DIC I Y=-1 S DTOUT=1 Q
     48 S DIE=DIC K DIC
     49 S DA=+Y
     50 ;Finding record fields
     51 S DR=".01;.02;1"
     52 ;Edit finding record
     53 D ^DIE
     54 I $D(Y) S DTOUT=1 Q
     55 ;Check if deleted
     56 I '$D(DA) Q
     57 Q
     58 ;
     59LOCK(DA) ;Lock the record
     60 L +^PXRM(800,DA):0 I  Q 1
     61 E  W !!,?5,"Another user is editing this file, try later" H 2 Q 0
     62 ;
     63UNLOCK(DA) ;Unlock the record
     64 L -^PXRM(800,DA)
     65 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPDR.m

    r613 r623  
    1 PXRMPDR ;SLC/AGP,PKR - Patient List Demographic report main routine ;11/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 EN(PLIEN)       ; -- main entry point for PXRM PATIENT LIST DEMOGRAPHIC
    5         N ARRAY,DC,DDATA,DELIM,DTOUT,DUOUT
    6         W @IOF
    7         K ^TMP("PXRMPLD",$J),^TMP("PXRMPLN",$J)
    8         S DELIM=0
    9 OPTION  ;
    10         W !,"Select the items to include on the report."
    11 ADDSEL  D ADDSEL^PXRMPDRS(.DDATA,"ADD")
    12         I $D(DTOUT)!$D(DUOUT) Q
    13 APPSEL  D APPSEL^PXRMPDRS(.DDATA,"APP")
    14         I $D(DTOUT)!$D(DUOUT) G ADDSEL
    15 DEMSEL  D DEMSEL^PXRMPDRS(.DDATA,"DEM")
    16         I $D(DTOUT)!$D(DUOUT) G APPSEL
    17 PFACSEL S DDATA("PFAC",0)=$$ASKYN^PXRMEUT("N","Include the patient's preferred facility")
    18         I $D(DTOUT)!$D(DUOUT) G DEMSEL
    19         S DDATA("PFAC","LEN")=$S(DDATA("PFAC",0)=1:1,1:0)
    20 ELIGSEL D ELIGSEL^PXRMPDRS(.DDATA,"ELIG")
    21         I $D(DTOUT)!$D(DUOUT) G PFACSEL
    22 DATASEL D DATASEL^PXRMPDRS(PLIEN,.DDATA,"FIND")
    23         I $D(DTOUT)!$D(DUOUT) G ELIGSEL
    24 INPSEL  D INPSEL^PXRMPDRS(.DDATA,"INP")
    25         I $D(DTOUT)!$D(DUOUT) G DATASEL
    26 REMDATA D REMSEL^PXRMPDRS(PLIEN,.DDATA,"REM")
    27         I $D(DTOUT)!$D(DUOUT) G INPSEL
    28         S DELIM=$$ASKYN^PXRMEUT("Y","Delimited Report:")
    29         I $D(DTOUT)!$D(DUOUT) G REMDATA
    30         S DC=$S(DELIM:$$DELIMSEL^PXRMXSD,1:U)
    31         I $D(DTOUT)!$D(DUOUT) G OPTION
    32 DEVICE  ;
    33         N DESC,DIR,PXRMQUE,RTN,SAVE,%ZIS
    34         S %ZIS="M"
    35         S DESC="Patient List Demographic Report"
    36         S RTN="GETPDATA^PXRMPDR(DELIM,DC,PLIEN,.DDATA)"
    37         S SAVE("DELIM")="",SAVE("DC")="",SAVE("PLIEN")=""
    38         S SAVE("DDATA(")=""
    39         S PXRMQUE=$$DEVICE^PXRMXQUE(RTN,DESC,.SAVE,.%ZIS,1)
    40         I PXRMQUE'="" G EXIT
    41         I $D(DTOUT)!$D(DUOUT) G EXIT
    42         S DIR(0)="E" D ^DIR
    43 EXIT    D KVA^VADPT
    44         K ^TMP("PXRMPLD",$J),^TMP("PXRMPLN",$J)
    45         Q
    46         ;
    47 GETPDATA(DELIM,DC,PLIEN,DDATA)  ;
    48         N DATA,DATE,DCREAT,DFN,DTYPE,ERRMSG
    49         N GETADD,GETAPP,GETDEM,GETELIG,GETFIND,GETINP,GETREM
    50         N IEN,IND,JND,KND,LND
    51         N LISTNAME,PIECE
    52         N PDATA,PNAME,RIEN,TDATA
    53         K ^TMP("PXRMPD",$J)
    54         S LISTNAME=$P(^PXRMXP(810.5,PLIEN,0),U,1)
    55         S DCREAT=$P(^PXRMXP(810.5,PLIEN,0),U,4)
    56         S GETDEM=$S(DDATA("DEM","LEN")>0:1,1:0)
    57         S GETADD=$S(DDATA("ADD","LEN")>0:1,1:0)
    58         S GETINP=$S(DDATA("INP","LEN")>0:1,1:0)
    59         S GETELIG=$S(DDATA("ELIG","LEN")>0:1,1:0)
    60         S GETAPP=$S(DDATA("APP","LEN")>0:1,1:0)
    61         S GETFIND=$S(DDATA("FIND","LEN")>0:1,1:0)
    62         S GETREM=$S(DDATA("REM","LEN")>0:1,1:0)
    63         S IEN=0
    64         F  S IEN=+$O(^PXRMXP(810.5,PLIEN,30,IEN)) Q:IEN=0  D
    65         . S DFN=$P(^PXRMXP(810.5,PLIEN,30,IEN,0),U,1) I DFN="" Q
    66         .;#DBIA 10035
    67         . S PNAME=$P($G(^DPT(DFN,0)),U,1)
    68         . I PNAME="" S PNAME="UNDEFINED"_DFN
    69         . S ^TMP("PXRMPLN",$J,PNAME,DFN)=""
    70         . S PDATA=""
    71         . I GETDEM D
    72         .. N VADM
    73         .. D DEM^VADPT
    74         .. F IND=1:1:DDATA("DEM","LEN") D
    75         ... S JND=$P(DDATA("DEM"),",",IND)
    76         ... S KND=0
    77         ... F  S KND=$O(DDATA("DEM",JND,KND)) Q:KND=""  D
    78         .... S PIECE=$P(DDATA("DEM",JND,KND),U,2)
    79         .... S TDATA=$P(VADM(KND),U,PIECE)
    80         .... S LND=""
    81         .... F  S LND=$O(VADM(KND,LND)) Q:LND=""  D
    82         ..... I TDATA'="" S TDATA=TDATA_"~"
    83         ..... S TDATA=TDATA_$P(VADM(KND,LND),U,PIECE)
    84         .... I KND=2,'DDATA("DEM","FULLSSN") S TDATA=$E(TDATA,8,11)
    85         .... S $P(PDATA,U,KND)=TDATA
    86         .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"DEM")=PDATA,PDATA=""
    87         . I DDATA("PFAC",0)=1 D
    88         ..;DBIA #1850
    89         .. S TDATA=$$GET1^DIQ(2,DFN,27.02,"E","","ERRMSG")
    90         .. I TDATA="" S TDATA="NONE"
    91         .. S ^TMP("PXRMPLD",$J,DFN,"PFAC")=TDATA
    92         . I GETADD D
    93         .. N VAPA
    94         .. D ADD^VADPT
    95         .. F IND=1:1:DDATA("ADD","LEN") D
    96         ... S JND=$P(DDATA("ADD"),",",IND)
    97         ... S KND=0
    98         ... F  S KND=$O(DDATA("ADD",JND,KND)) Q:KND=""  D
    99         .... S PIECE=$P(DDATA("ADD",JND,KND),U,2)
    100         .... S TDATA=$P(VAPA(KND),U,PIECE)
    101         .... S $P(PDATA,U,KND)=TDATA
    102         .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"ADD")=PDATA,PDATA=""
    103         . I GETINP D
    104         .. N VAIP
    105         .. D INP^VADPT
    106         .. F IND=1:1:DDATA("INP","LEN") D
    107         ... S JND=$P(DDATA("INP"),",",IND)
    108         ... S KND=0
    109         ... F  S KND=$O(DDATA("INP",JND,KND)) Q:KND=""  D
    110         .... S PIECE=$P(DDATA("INP",JND,KND),U,2)
    111         .... S TDATA=$P(VAIN(KND),U,PIECE)
    112         .... S $P(PDATA,U,KND)=TDATA
    113         .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"INP")=PDATA,PDATA=""
    114         . I GETELIG D
    115         .. N VAEL
    116         .. D ELIG^VADPT
    117         .. F IND=1:1:DDATA("ELIG","LEN") D
    118         ... S JND=$P(DDATA("ELIG"),",",IND)
    119         ... S KND=0
    120         ... F  S KND=$O(DDATA("ELIG",JND,KND)) Q:KND=""  D
    121         .... S PIECE=$P(DDATA("ELIG",JND,KND),U,2)
    122         .... S TDATA=$P(VAEL(KND),U,PIECE)
    123         .... I KND=4 S TDATA=$S(TDATA=1:"YES",1:"NO")
    124         .... S $P(PDATA,U,KND)=TDATA
    125         .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"ELIG")=PDATA,PDATA=""
    126         . D KVA^VADPT
    127         . I GETREM D
    128         .. S IND=0
    129         .. F  S IND=$O(DDATA("REM","IEN",IND)) Q:IND=""  D
    130         ... S PDATA=$G(^PXRMXP(810.5,PLIEN,30,IEN,"REM",IND,0))
    131         ... I PDATA="" Q
    132         ... S RIEN=$P(PDATA,U,1)
    133         ... S ^TMP("PXRMPLD",$J,DFN,"REM",RIEN)=PDATA,PDATA=""
    134         . I GETFIND D
    135         .. N DL
    136         .. F IND=1:1:DDATA("FIND","LEN") D
    137         ... S JND=$P(DDATA("FIND"),",",IND)
    138         ... S DTYPE=DDATA("FIND",JND,JND)
    139         ... S KND=$O(^PXRMXP(810.5,PLIEN,30,IEN,"DATA","B",DTYPE,""))
    140         ... S DL=$S(KND="":0,1:$L(^PXRMXP(810.5,PLIEN,30,IEN,"DATA",KND,0),U))
    141         ... S DATA=$S(KND="":"",1:$P(^PXRMXP(810.5,PLIEN,30,IEN,"DATA",KND,0),U,2,DL))
    142         ... S ^TMP("PXRMPLD",$J,DFN,"FIND",JND)=DATA
    143         ;Get appointment data for all patients on the list.
    144         I GETAPP D
    145         . N ARRAY,COUNT
    146         . S ARRAY(1)=DT,ARRAY(3)="I;R"
    147         . S ARRAY(4)="^TMP($J,""PXRMPL""",ARRAY("FLDS")=""
    148         . F IND=1:1:DDATA("APP","LEN") D
    149         .. S JND=$P(DDATA("APP"),",",IND)
    150         .. S KND=0
    151         .. F  S KND=$O(DDATA("APP",JND,KND)) Q:KND=""  S ARRAY("FLDS")=ARRAY("FLDS")_KND_";"
    152         . K ^TMP($J,"PXRMPL"),^TMP($J,"SDAMA301")
    153         . S IND=0
    154         . F  S IND=+$O(^PXRMXP(810.5,PLIEN,30,IND)) Q:IND=0  D
    155         .. S DFN=$P(^PXRMXP(810.5,PLIEN,30,IND,0),U,1)
    156         .. I DFN'="" S ^TMP($J,"PXRMPL",DFN)=""
    157         . S COUNT=$$SDAPI^SDAMA301(.ARRAY)
    158         . I COUNT=-1 D  Q
    159         .. D APPERR^PXRMPDRS
    160         .. S DDATA("APP","ERROR")=""
    161         .. K ^TMP($J,"PXRMPL"),^TMP($J,"SDAMA301")
    162         . F IND=1:1:COUNT D
    163         .. S DFN=""
    164         .. F  S DFN=$O(^TMP($J,"SDAMA301",DFN)) Q:DFN=""  D
    165         ... S (JND,KND)=0
    166         ... F  S JND=$O(^TMP($J,"SDAMA301",DFN,JND)) Q:JND=""  D
    167         .... S DATE=0
    168         .... F  S DATE=$O(^TMP($J,"SDAMA301",DFN,JND,DATE)) Q:DATE=""  D
    169         ..... S KND=KND+1
    170         ..... S TDATA=^TMP($J,"SDAMA301",DFN,JND,DATE)
    171         ..... S PDATA=$$FMTE^XLFDT($P(TDATA,U,1))
    172         ..... S TDATA=$P(TDATA,U,2),TDATA=$P(TDATA,";",2)
    173         ..... S PDATA=PDATA_U_TDATA
    174         ..... S ^TMP("PXRMPLD",$J,DFN,"APP",KND)=PDATA
    175         . K ^TMP($J,"PXRMPL"),^TMP($J,"SDAMA301")
    176         I DELIM=1 D DELIMPR^PXRMPDRP(DC,PLIEN,.DDATA)
    177         I DELIM=0 D REGPR^PXRMPDRP(PLIEN,.DDATA)
    178         Q
    179         ;
    180 LENGTH(STR,STR1)        ;
    181         I ($L(STR)+$L(STR1))>245 W !,STR S STR=STR1
    182         E  S STR=STR_U_STR1,STR1=""
    183         Q
    184         ;
    185 PAGE    ;
    186         I ($E(IOST,1,2)="C-")&(IO=IO(0)) D
    187         .S DIR(0)="E"
    188         .W !
    189         .D ^DIR K DIR
    190         I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
    191         W:$D(IOF) @IOF
    192         S PAGE=PAGE+1
    193         I ($E(IOST,1,2)="C-")&(IO=IO(0)) W @IOF
    194         Q
    195         ;
     1PXRMPDR ;SLC/AGP,PKR - Patient List Demographic report main routine ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4EN(PLIEN) ; -- main entry point for PXRM PATIENT LIST DEMOGRAPHIC
     5 N ADDDATA,APPDATA,ARRAY,BACK,CNT,DC,DEMDATA,DELIM,DIC,DIR,DTOUT,DUOUT
     6 N ELIGDATA,IEN,INPDATA
     7 N FINDDATA,NAME,NODE,PFACDATA,PTIEN
     8 N QUIT,REMDATA
     9 N X,Y,YESNO
     10 W @IOF
     11 K ^TMP("PXRMPLD",$J),^TMP("PXRMPLN",$J)
     12 S BACK=0,DELIM=0,QUIT=0
     13OPTION ;
     14 W !,"Select the items to include on the report."
     15ADDSEL D ADDSEL^PXRMPDRS(.ADDDATA)
     16 I $D(DTOUT)!$D(DUOUT) Q
     17APPSEL D APPSEL^PXRMPDRS(.APPDATA)
     18 I $D(DTOUT)!$D(DUOUT) G ADDSEL
     19DEMSEL D DEMSEL^PXRMPDRS(.DEMDATA)
     20 I $D(DTOUT)!$D(DUOUT) G APPSEL
     21PFACSEL S PFACDATA(0)=$$ASKYN^PXRMEUT("N","Include the patient's preferred facility")
     22 I $D(DTOUT)!$D(DUOUT) G DEMSEL
     23 S PFACDATA("LEN")=$S(PFACDATA(0)=1:1,1:0)
     24ELIGSEL D ELIGSEL^PXRMPDRS(.ELIGDATA)
     25 I $D(DTOUT)!$D(DUOUT) G PFACSEL
     26DATASEL D DATASEL^PXRMPDRS(PLIEN,.FINDDATA)
     27 I $D(DTOUT)!$D(DUOUT) G ELIGSEL
     28INPSEL D INPSEL^PXRMPDRS(.INPDATA)
     29 I $D(DTOUT)!$D(DUOUT) G DATASEL
     30REMDATA D REMSEL^PXRMPDRS(PLIEN,.REMDATA)
     31 I $D(DTOUT)!$D(DUOUT) G INPSEL
     32 S DELIM=$$ASKYN^PXRMEUT("Y","Delimited Report:")
     33 I $D(DTOUT)!$D(DUOUT) G REMDATA
     34 I DELIM S DC=$$DELIMSEL^PXRMXSD
     35 I $D(DTOUT)!$D(DUOUT) G OPTION
     36DEVICE ;
     37 N DIR,PXRMQUE,%ZIS,ZTDESC,ZTRTN,ZTSAVE
     38 S %ZIS="M"
     39 S ZTDESC="Patient List Demographic"
     40 S ZTRTN="GETDATA^PXRMPDR(DELIM,PLIEN,.DEMDATA,.PFACDATA,.ADDDATA,.INPDATA,.APPDATA,.FINDDATA,.REMDATA)"
     41 S ZTSAVE("*")=""
     42 S PXRMQUE=0
     43 S PXRMQUE=$$DEVICE^PXRMXQUE(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS,.ZTSK)
     44 I PXRMQUE=1 G EXIT
     45 I $D(DTOUT)!$D(DUOUT) G EXIT
     46 ;
     47 S DIR(0)="E" D ^DIR
     48EXIT D KVA^VADPT
     49 K ^TMP("PXRMPLD",$J),^TMP("PXRMPLN",$J)
     50 Q
     51 ;
     52GETDATA(DELIM,PLIEN,DEMDATA,PFACDATA,ADDDATA,INPDATA,APPDATA,FINDDATA,REMDATA) ;
     53 N DATA,DATE,DCREAT,DFN,DTYPE,ERRMSG
     54 N GETADD,GETAPP,GETDEM,GETELIG,GETFIND,GETINP,GETREM
     55 N IEN,IND,JND,KND,LND
     56 N LISTNAME,PIECE
     57 N PDATA,PNAME,RIEN,TDATA
     58 K ^TMP("PXRMPD",$J)
     59 S LISTNAME=$P(^PXRMXP(810.5,PLIEN,0),U,1)
     60 S DCREAT=$P(^PXRMXP(810.5,PLIEN,0),U,4)
     61 S GETDEM=$S(DEMDATA("LEN")>0:1,1:0)
     62 S GETADD=$S(ADDDATA("LEN")>0:1,1:0)
     63 S GETINP=$S(INPDATA("LEN")>0:1,1:0)
     64 S GETELIG=$S(ELIGDATA("LEN")>0:1,1:0)
     65 S GETAPP=$S(APPDATA("LEN")>0:1,1:0)
     66 S GETFIND=$S(FINDDATA("LEN")>0:1,1:0)
     67 S GETREM=$S(REMDATA("LEN")>0:1,1:0)
     68 S IEN=0
     69 F  S IEN=+$O(^PXRMXP(810.5,PLIEN,30,IEN)) Q:IEN=0  D
     70 . S DFN=$P(^PXRMXP(810.5,PLIEN,30,IEN,0),U,1) I DFN="" Q
     71 .;#DBIA 10035
     72 . S PNAME=$P($G(^DPT(DFN,0)),U,1)
     73 . I PNAME="" S PNAME="UNDEFINED"_DFN
     74 . S ^TMP("PXRMPLN",$J,PNAME,DFN)=""
     75 . S PDATA=""
     76 . I GETDEM D
     77 .. N VADM
     78 .. D DEM^VADPT
     79 .. F IND=1:1:DEMDATA("LEN") D
     80 ... S JND=$P(DEMDATA,",",IND)
     81 ... S KND=0
     82 ... F  S KND=$O(DEMDATA(JND,KND)) Q:KND=""  D
     83 .... S PIECE=$P(DEMDATA(JND,KND),U,2)
     84 .... S TDATA=$P(VADM(KND),U,PIECE)
     85 .... S LND=""
     86 .... F  S LND=$O(VADM(KND,LND)) Q:LND=""  D
     87 ..... I TDATA'="" S TDATA=TDATA_"~"
     88 ..... S TDATA=TDATA_$P(VADM(KND,LND),U,PIECE)
     89 .... I KND=2,'DEMDATA("FULLSSN") S TDATA=$E(TDATA,8,11)
     90 .... S $P(PDATA,U,KND)=TDATA
     91 .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"DEMDATA")=PDATA,PDATA=""
     92 . I PFACDATA(0)=1 D
     93 ..;DBIA #1850
     94 .. S TDATA=$$GET1^DIQ(2,DFN,27.02,"E","","ERRMSG")
     95 .. I TDATA="" S TDATA="NONE"
     96 .. S ^TMP("PXRMPLD",$J,DFN,"PFACDATA")=TDATA
     97 . I GETADD D
     98 .. N VAPA
     99 .. D ADD^VADPT
     100 .. F IND=1:1:ADDDATA("LEN") D
     101 ... S JND=$P(ADDDATA,",",IND)
     102 ... S KND=0
     103 ... F  S KND=$O(ADDDATA(JND,KND)) Q:KND=""  D
     104 .... S PIECE=$P(ADDDATA(JND,KND),U,2)
     105 .... S TDATA=$P(VAPA(KND),U,PIECE)
     106 .... S $P(PDATA,U,KND)=TDATA
     107 .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"ADDDATA")=PDATA,PDATA=""
     108 . I GETINP D
     109 .. N VAIP
     110 .. D INP^VADPT
     111 .. F IND=1:1:INPDATA("LEN") D
     112 ... S JND=$P(INPDATA,",",IND)
     113 ... S KND=0
     114 ... F  S KND=$O(INPDATA(JND,KND)) Q:KND=""  D
     115 .... S PIECE=$P(INPDATA(JND,KND),U,2)
     116 .... S TDATA=$P(VAIN(KND),U,PIECE)
     117 .... S $P(PDATA,U,KND)=TDATA
     118 .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"INPDATA")=PDATA,PDATA=""
     119 . I GETELIG D
     120 .. N VAEL
     121 .. D ELIG^VADPT
     122 .. F IND=1:1:ELIGDATA("LEN") D
     123 ... S JND=$P(ELIGDATA,",",IND)
     124 ... S KND=0
     125 ... F  S KND=$O(ELIGDATA(JND,KND)) Q:KND=""  D
     126 .... S PIECE=$P(ELIGDATA(JND,KND),U,2)
     127 .... S TDATA=$P(VAEL(KND),U,PIECE)
     128 .... I KND=4 S TDATA=$S(TDATA=1:"YES",1:"NO")
     129 .... S $P(PDATA,U,KND)=TDATA
     130 .. I PDATA'="" S ^TMP("PXRMPLD",$J,DFN,"ELIGDATA")=PDATA,PDATA=""
     131 . D KVA^VADPT
     132 . I GETREM D
     133 .. S IND=0
     134 .. F  S IND=$O(REMDATA("IEN",IND)) Q:IND=""  D
     135 ... S PDATA=$G(^PXRMXP(810.5,PLIEN,30,IEN,"REM",IND,0))
     136 ... I PDATA="" Q
     137 ... S RIEN=$P(PDATA,U,1)
     138 ... S ^TMP("PXRMPLD",$J,DFN,"REMDATA",RIEN)=PDATA,PDATA=""
     139 . I GETFIND D
     140 .. N DL
     141 .. F IND=1:1:FINDDATA("LEN") D
     142 ... S JND=$P(FINDDATA,",",IND)
     143 ... S DTYPE=FINDDATA(JND,JND)
     144 ... S KND=$O(^PXRMXP(810.5,PLIEN,30,IEN,"DATA","B",DTYPE,""))
     145 ... S DL=$S(KND="":0,1:$L(^PXRMXP(810.5,PLIEN,30,IEN,"DATA",KND,0),U))
     146 ... S DATA=$S(KND="":"",1:$P(^PXRMXP(810.5,PLIEN,30,IEN,"DATA",KND,0),U,2,DL))
     147 ... S ^TMP("PXRMPLD",$J,DFN,"FINDDATA",JND)=DATA
     148 ;Get appointment data for all patients on the list.
     149 I GETAPP D
     150 . N ARRAY,COUNT
     151 . S ARRAY(1)=DT,ARRAY(3)="I;R"
     152 . S ARRAY(4)="^TMP($J,""PXRMPL""",ARRAY("FLDS")=""
     153 . F IND=1:1:APPDATA("LEN") D
     154 .. S JND=$P(APPDATA,",",IND)
     155 .. S KND=0
     156 .. F  S KND=$O(APPDATA(JND,KND)) Q:KND=""  S ARRAY("FLDS")=ARRAY("FLDS")_KND_";"
     157 . K ^TMP($J,"PXRMPL"),^TMP($J,"SDAMA301")
     158 . S IND=0
     159 . F  S IND=+$O(^PXRMXP(810.5,PLIEN,30,IND)) Q:IND=0  D
     160 .. S DFN=$P(^PXRMXP(810.5,PLIEN,30,IND,0),U,1)
     161 .. I DFN'="" S ^TMP($J,"PXRMPL",DFN)=""
     162 . S COUNT=$$SDAPI^SDAMA301(.ARRAY)
     163 . I COUNT=-1 D  Q
     164 .. D APPERR^PXRMPDRS
     165 .. S APPDATA("ERROR")=""
     166 .. K ^TMP($J,"PXRMPL"),^TMP($J,"SDAMA301")
     167 . F IND=1:1:COUNT D
     168 .. S DFN=""
     169 .. F  S DFN=$O(^TMP($J,"SDAMA301",DFN)) Q:DFN=""  D
     170 ... S (JND,KND)=0
     171 ... F  S JND=$O(^TMP($J,"SDAMA301",DFN,JND)) Q:JND=""  D
     172 .... S DATE=0
     173 .... F  S DATE=$O(^TMP($J,"SDAMA301",DFN,JND,DATE)) Q:DATE=""  D
     174 ..... S KND=KND+1
     175 ..... S TDATA=^TMP($J,"SDAMA301",DFN,JND,DATE)
     176 ..... S PDATA=$$FMTE^XLFDT($P(TDATA,U,1))
     177 ..... S TDATA=$P(TDATA,U,2),TDATA=$P(TDATA,";",2)
     178 ..... S PDATA=PDATA_U_TDATA
     179 ..... S ^TMP("PXRMPLD",$J,DFN,"APPDATA",KND)=PDATA
     180 . K ^TMP($J,"PXRMPL"),^TMP($J,"SDAMA301")
     181 I DELIM=1 D DELIMPR^PXRMPDRP(DC,PLIEN,.ADDDATA,.APPDATA,.DEMDATA,.FINDDATA,.INPDATA,.PFACDATA,.REMDATA)
     182 I DELIM=0 D REGPR^PXRMPDRP(PLIEN,.ADDDATA,.APPDATA,.DEMDATA,.FINDDATA,.INPDATA,.PFACDATA,.REMDATA)
     183 Q
     184 ;
     185LENGTH(STR,STR1) ;
     186 I ($L(STR)+$L(STR1))>245 W !,STR S STR=STR1
     187 E  S STR=STR_U_STR1,STR1=""
     188 Q
     189 ;
     190PAGE ;
     191 I ($E(IOST)="C")&(IO=IO(0)) D
     192 .S DIR(0)="E"
     193 .W !
     194 .D ^DIR K DIR
     195 I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
     196 W:$D(IOF) @IOF
     197 S PAGE=PAGE+1
     198 I $E(IOST)="C",IO=IO(0) W @IOF
     199 Q
     200 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPDRP.m

    r613 r623  
    1 PXRMPDRP        ;SLC/AGP,PKR - Patient List Demographic report print routine ;11/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 ADDTXT(TEXT)    ;Accumulate text in ^TMP.
    5         S LINCNT=LINCNT+1
    6         S ^TMP("PXRMPDEM",$J,LINCNT)=TEXT
    7         Q
    8         ;
    9 APPHDR(DC,DDATA,SUB)    ;Build the appointment header.
    10         I DDATA(SUB,"LEN")'>0 Q
    11         N HDR,IND,JND,KND,LND,TEMP
    12         S IND=0,HDR=""
    13         F IND=1:1:DDATA(SUB,"MAX") D
    14         . F JND=1:1:DDATA(SUB,"LEN") D
    15         .. S KND=$P(DDATA(SUB),",",JND)
    16         .. S LND=""
    17         .. F  S LND=$O(DDATA(SUB,KND,LND)) Q:LND=""  D
    18         ... S TEMP=$P(DDATA(SUB,KND,LND),U,1)
    19         ... S HDR=HDR_TEMP_IND_DC
    20         S DDATA(SUB,"HDR")=HDR
    21         Q
    22         ;
    23 APPPRINT(DFN,DDATA,SUB) ;Print appointment data.
    24         N CLINIC,COUNT,DATE,HDR,IND,JND,KND,LINE,PCLINIC,PDATE,TEMP
    25         S (PCLINIC,PDATE)=0
    26         F IND=1:1:DDATA(SUB,"LEN") D
    27         . S JND=$P(DDATA(SUB),",",IND)
    28         . I JND=1 S PDATE=1
    29         . I JND=2 S PCLINIC=1
    30         S HDR=""
    31         I PDATE S HDR=" "_$P(DDATA(SUB,1,1),U,1)
    32         I PCLINIC S HDR=HDR_"   "_$P(DDATA(SUB,2,2),U,1)
    33         D ADDTXT(" ")
    34         D ADDTXT("Appointment Data")
    35         D ADDTXT(HDR)
    36         S COUNT=0
    37         F  S COUNT=$O(^TMP("PXRMPLD",$J,DFN,"APP",COUNT)) Q:COUNT=""  D
    38         . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"APP",COUNT))
    39         . S LINE=""
    40         . I PDATE S LINE=LINE_$P(TEMP,U,1)
    41         . I PCLINIC S LINE=LINE_"  "_$P(TEMP,U,2)
    42         . D ADDTXT(LINE)
    43         Q
    44         ;
    45 DELIMHDR(DC,DDATA,SUB)  ;Build the delimited header for a data type.
    46         I DDATA(SUB,"LEN")'>0 Q
    47         N HDR,IND,JND,KND,LND,MAX,TEMP
    48         S IND=0,HDR=""
    49         F IND=1:1:DDATA(SUB,"LEN") D
    50         . S JND=$P(DDATA(SUB),",",IND)
    51         . S KND=""
    52         . F  S KND=$O(DDATA(SUB,JND,KND)) Q:KND=""  D
    53         .. S TEMP=$P(DDATA(SUB,JND,KND),U,1)
    54         .. S MAX=$P(DDATA(SUB,JND,KND),U,3)
    55         .. I MAX="" S HDR=HDR_TEMP_DC
    56         .. I +MAX>0 F LND=1:1:MAX S HDR=HDR_TEMP_LND_DC
    57         S DDATA(SUB,"HDR")=HDR
    58         Q
    59         ;
    60 DELIMPR(DC,PLIEN,DDATA) ;
    61         ;Print the delimited report.
    62         N DATALIST,DFN,IND,NDT,PNAME
    63         S NDT=0
    64         I DDATA("ADD","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="ADD"
    65         I DDATA("APP","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="APP"
    66         I DDATA("DEM","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="DEM"
    67         I DDATA("ELIG","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="ELIG"
    68         I DDATA("FIND","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="FIND"
    69         I DDATA("INP","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="INP"
    70         I DDATA("PFAC","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="PFAC"
    71         I DDATA("REM","LEN")>0 S NDT=NDT+1,DATALIST(NDT)="REM"
    72         S DATALIST(0)=NDT
    73         D TITLE(PLIEN,1)
    74         ;Create the delimited header.
    75         F IND=1:1:NDT D
    76         . I DATALIST(IND)="ADD" D DELIMHDR(DC,.DDATA,"ADD") Q
    77         . I DATALIST(IND)="APP" D APPHDR(DC,.DDATA,"APP") Q
    78         . I DATALIST(IND)="DEM" D DELIMHDR(DC,.DDATA,"DEM") Q
    79         . I DATALIST(IND)="ELIG" D DELIMHDR(DC,.DDATA,"ELIG") Q
    80         . I DATALIST(IND)="FIND" D DELIMHDR(DC,.DDATA,"FIND") Q
    81         . I DATALIST(IND)="INP" D DELIMHDR(DC,.DDATA,"INP") Q
    82         . I DATALIST(IND)="PFAC" D PFACHDR(.DDATA,"PFAC")
    83         . I DATALIST(IND)="REM" D REMHDR(DC,.DDATA,"REM") Q
    84         D DELTITLE(DC,.DATALIST,.DDATA)
    85         S PNAME=":"
    86         F  S PNAME=$O(^TMP("PXRMPLN",$J,PNAME)) Q:PNAME=""  D
    87         . S DFN=""
    88         . F  S DFN=$O(^TMP("PXRMPLN",$J,PNAME,DFN)) Q:DFN=""  D
    89         .. W !,PNAME_DC
    90         .. F IND=1:1:NDT D
    91         ... I DATALIST(IND)="ADD" D PDELDATA(DFN,DC,DATALIST(IND),.DDATA,"ADD") Q
    92         ... I DATALIST(IND)="APP" D PAPPDATA(DFN,DC,.DDATA,"APP") Q
    93         ... I DATALIST(IND)="DEM" D PDELDATA(DFN,DC,DATALIST(IND),.DDATA,"DEM") Q
    94         ... I DATALIST(IND)="ELIG" D PDELDATA(DFN,DC,DATALIST(IND),.DDATA,"ELIG") Q
    95         ... I DATALIST(IND)="FIND" D PFINDATA(DFN,DC,.DDATA,"FIND") Q
    96         ... I DATALIST(IND)="INP" D PDELDATA(DFN,DC,DATALIST(IND),.DDATA,"INP") Q
    97         ... I DATALIST(IND)="PFAC" D PFACDATA(DFN,.DDATA,"PFAC") Q
    98         ... I DATALIST(IND)="REM" D PREMDATA(DFN,DC,.DDATA,"REM") Q
    99         .. W "\\"
    100         Q
    101         ;
    102 DELTITLE(DC,DATALIST,DDATA)     ;Combine all the headers to create the delimited title.
    103         W !,"PATIENT"_DC
    104         N IND
    105         F IND=1:1:DATALIST(0) W DDATA(DATALIST(IND),"HDR")
    106         W "\\"
    107         Q
    108         ;
    109 FINDPR(DFN,DDATA,SUB)   ;Print finding information.
    110         N IND,JND,LINE,TEMP
    111         D ADDTXT(" ")
    112         S LINE="Finding Data"
    113         D ADDTXT(LINE)
    114         F IND=1:1:DDATA(SUB,"LEN") D
    115         . S JND=$P(DDATA(SUB),",",IND)
    116         . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"FIND",JND))
    117         . I TEMP="" Q
    118         . S LINE=" "_$P(DDATA(SUB,JND,JND),U,1)_": "_TEMP
    119         . D ADDTXT(LINE)
    120         Q
    121         ;
    122 OUTPUT  ;Output the text.
    123         N IND,LC,LO,VSIZE
    124         S VSIZE=IOSL-2
    125         S (LC,LO)=0
    126         F IND=1:1:LINCNT D
    127         . S LC=LC+1,LO=LO+1
    128         . W !,^TMP("PXRMPDEM",$J,LC)
    129         . I LO=VSIZE D
    130         .. D PAGE
    131         .. I $D(DTOUT)!$D(DUOUT) S IND=LINCNT Q
    132         .. S LO=0
    133         Q
    134         ;
    135 PAGE    ;
    136         I ($E(IOST,1,2)="C-")&(IO=IO(0)) D
    137         . N DIR
    138         . S DIR(0)="E"
    139         . W !
    140         . D ^DIR K DIR
    141         I $D(DUOUT)!$D(DTOUT) Q
    142         W:$D(IOF) @IOF
    143         I ($E(IOST,1,2)="C-")&(IO=IO(0)) W @IOF
    144         Q
    145         ;
    146 PAPPDATA(DFN,DC,DDATA,SUB)      ;Print the delimited appointment data.
    147         N IND,JND,KND,LINE,LND,PIECE,TEMP
    148         I DDATA(SUB,"LEN")'>0 Q
    149         S LINE=""
    150         F IND=1:1:DDATA(SUB,"MAX") D
    151         . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"APP",IND))
    152         . F JND=1:1:DDATA(SUB,"LEN") D
    153         .. S KND=$P(DDATA(SUB),",",JND)
    154         .. S LND=""
    155         .. F  S LND=$O(DDATA(SUB,KND,LND)) Q:LND=""  D
    156         ... S PIECE=$P(DDATA(SUB,KND,KND),U,2)
    157         ... S LINE=LINE_$P(TEMP,U,PIECE)_DC
    158         W LINE
    159         Q
    160         ;
    161 PDELDATA(DFN,DC,DTYPE,DDATA,SUB)        ;Print the delimited data.
    162         N IND,JND,KND,LINE,LND,TEMP,TTEMP
    163         S TEMP=$G(^TMP("PXRMPLD",$J,DFN,DTYPE))
    164         S LINE=""
    165         F IND=1:1:DDATA(DTYPE,"LEN") D
    166         . S JND=$P(DDATA(DTYPE),",",IND)
    167         . S KND=""
    168         . F  S KND=$O(DDATA(DTYPE,JND,KND)) Q:KND=""  D
    169         .. S MAX=$P(DDATA(DTYPE,JND,KND),U,3)
    170         .. I MAX="" S LINE=LINE_$P(TEMP,U,KND)_DC Q
    171         .. I +MAX>1 S TTEMP=$P(TEMP,U,KND) F LND=1:1:MAX S LINE=LINE_$P(TTEMP,"~",LND)_DC
    172         W LINE
    173         Q
    174         ;
    175 PFACHDR(DDATA,SUB)      ;Build the preferred facility header.
    176         I DDATA(SUB,0)=1 S DDATA(SUB,"HDR")="PATIENT'S PREFERRED FACILITY"
    177         Q
    178         ;
    179 PFACDATA(DFN,DDATA,SUB) ;Print the patient's preferred facility data, delimited.
    180         I DDATA(SUB,0)=0 Q
    181         W ^TMP("PXRMPLD",$J,DFN,"PFAC")
    182         Q
    183         ;
    184 PFACPR(DFN,DDATA,SUB)   ;Print the patient's preferred facility.
    185         I DDATA(SUB,0)=0 Q
    186         D ADDTXT("Patient's Preferred Facility")
    187         D ADDTXT(" "_$G(^TMP("PXRMPLD",$J,DFN,"PFAC")))
    188         Q
    189         ;
    190 PFINDATA(DFN,DC,DDATA,SUB)      ;Print the finding data.
    191         N IND,JND,LINE,TEMP
    192         I DDATA(SUB,"LEN")'>0 Q
    193         S LINE=""
    194         F IND=1:1:DDATA(SUB,"LEN") D
    195         . S JND=$P(DDATA(SUB),",",IND)
    196         . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"FIND",JND))
    197         . S LINE=LINE_TEMP_DC
    198         W LINE
    199         Q
    200         ;
    201 PREMDATA(DFN,DC,DDATA,SUB)      ;Print the reminder data.
    202         N IND,JND,LINE,TEMP
    203         I DDATA(SUB,"LEN")'>0 Q
    204         S LINE=""
    205         F IND=1:1:DDATA(SUB,"LEN") D
    206         . S JND=$P(DDATA(SUB),",",IND)
    207         . S LINE=LINE_DDATA(SUB,"RNAME",JND)_DC
    208         . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"REM",DDATA(SUB,"IEN",JND)))
    209         . S LINE=LINE_$P(TEMP,U,2)_DC_$P(TEMP,U,3)_"^"_$P(TEMP,U,4)_DC
    210         W LINE
    211         Q
    212         ;
    213 REGPR(PLIEN,DDATA,SUB)  ;
    214         ;Print the regular report..
    215         N DATATYPE,DFN,PNAME,LINCNT
    216         K ^TMP("PXRMPDEM",$J)
    217         S LINCNT=0
    218         D TITLE(PLIEN,0)
    219         S PNAME=":"
    220         F  S PNAME=$O(^TMP("PXRMPLN",$J,PNAME)) Q:PNAME=""  D
    221         . S DFN=0
    222         . F  S DFN=$O(^TMP("PXRMPLN",$J,PNAME,DFN)) Q:DFN=""  D
    223         .. D ADDTXT(" ")
    224         .. D ADDTXT("---------- "_PNAME_" DFN="_DFN_" ----------")
    225         .. S DATATYPE=""
    226         .. F  S DATATYPE=$O(^TMP("PXRMPLD",$J,DFN,DATATYPE)) Q:DATATYPE=""  D
    227         ... I DATATYPE="ADD" D VADPTPR(DFN,"Address Data",DATATYPE,.DDATA,"ADD") Q
    228         ... I DATATYPE="APP" D APPPRINT(DFN,.DDATA,"APP") Q
    229         ... I DATATYPE="DEM" D VADPTPR(DFN,"Demographic Data",DATATYPE,.DDATA,"DEM") Q
    230         ... I DATATYPE="ELIG" D VADPTPR(DFN,"Eligibility Data",DATATYPE,.DDATA,"ELIG") Q
    231         ... I DATATYPE="FIND" D FINDPR(DFN,.DDATA,"FIND") Q
    232         ... I DATATYPE="INP" D VADPTPR(DFN,"Inpatient Data",DATATYPE,.DDATA,"INP") Q
    233         ... I DATATYPE="PFAC" D PFACPR(DFN,.DDATA,"PFAC") Q
    234         ... I DATATYPE="REM" D REMPR(DFN,.DDATA,"REM") Q
    235         D OUTPUT
    236         K ^TMP("PXRMPDEM",$J)
    237         Q
    238         ;
    239 REMHDR(DC,DDATA,SUB)    ;Build the reminder data delimited header.
    240         N HDR,IND,JND
    241         S HDR=""
    242         F IND=1:1:DDATA(SUB,"LEN") D
    243         . S JND=$P(DDATA(SUB),",",IND)
    244         . S HDR=HDR_"REMINDER"_JND_DC_"STATUS"_JND_DC_"DUE DATE"_JND_DC_"LAST DONE"_JND_DC
    245         S DDATA(SUB,"HDR")=HDR
    246         Q
    247         ;
    248 REMPR(DFN,DDATA,SUB)    ;Print reminder status information.
    249         N DUE,IND,JND,LAST,LINE,NSP,STATUS,TEMP
    250         D ADDTXT(" ")
    251         S LINE="Reminder:"_$$INSCHR^PXRMEXLC(27," ")_"--STATUS--  --DUE DATE--  --LAST DONE--"
    252         D ADDTXT(LINE)
    253         F IND=1:1:DDATA(SUB,"LEN") D
    254         . S JND=$P(DDATA(SUB),",",IND)
    255         . S RIEN=DDATA(SUB,"IEN",JND)
    256         . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"REM",RIEN))
    257         . I TEMP="" Q
    258         . S STATUS=$P(TEMP,U,2)
    259         . S DUE=$P(TEMP,U,3),DUE=$$EDATE^PXRMDATE(DUE)
    260         . S LAST=$P(TEMP,U,4),LAST=$$EDATE^PXRMDATE(LAST)
    261         . S NSP=38-$L(DDATA(SUB,"RNAME",JND))
    262         . S LINE=DDATA(SUB,"RNAME",JND)_$$INSCHR^PXRMEXLC(NSP," ")_STATUS
    263         . S NSP=54-$L(LINE)-($L(DUE)/2)
    264         . S LINE=LINE_$$INSCHR^PXRMEXLC(NSP," ")_DUE
    265         . S NSP=69-$L(LINE)-($L(LAST)/2)
    266         . S LINE=LINE_$$INSCHR^PXRMEXLC(NSP," ")_LAST
    267         . D ADDTXT(LINE)
    268         Q
    269         ;
    270 TITLE(PLIEN,DELIM)      ;Print the report title.
    271         N LISTNAME
    272         S LISTNAME=$P(^PXRMXP(810.5,PLIEN,0),U,1)
    273         I DELIM D
    274         . W @IOF
    275         . W !,"Patient Demographic Report"
    276         . W !,"   Patient List: "_LISTNAME
    277         . W !,"   Created on "_$$FMTE^XLFDT(DCREAT)
    278         I 'DELIM D
    279         . D ADDTXT("Patient Demographic Report")
    280         . D ADDTXT("   Patient List: "_LISTNAME)
    281         . D ADDTXT("   Created on "_$$FMTE^XLFDT(DCREAT))
    282         Q
    283         ;
    284 VADPTPR(DFN,DNAME,DTYPE,DDATA,SUB)      ;Print data returned by a VADPT call.
    285         N IND,JND,KND,LINE,LND,MAX,TEMP,TTEMP
    286         D ADDTXT(" ")
    287         D ADDTXT(DNAME)
    288         S TEMP=$G(^TMP("PXRMPLD",$J,DFN,DTYPE))
    289         F IND=1:1:DDATA(SUB,"LEN") D
    290         . S JND=$P(DDATA(SUB),",",IND)
    291         . S KND=""
    292         . F  S KND=$O(DDATA(SUB,JND,KND)) Q:KND=""  D
    293         .. S TTEMP=$P(TEMP,U,KND)
    294         .. S MAX=+$P(DDATA(SUB,JND,KND),U,3)
    295         .. I MAX=0 S MAX=1
    296         .. F LND=1:1:MAX D
    297         ... S LINE=" "_$P(DDATA(SUB,JND,KND),U,1)_": "_$P(TTEMP,"~",LND)
    298         ... D ADDTXT(LINE)
    299         Q
    300         ;
     1PXRMPDRP ;SLC/AGP,PKR - Patient List Demographic report print routine ;06/20/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4ADDTXT(TEXT) ;Accumulate text in ^TMP.
     5 S LINCNT=LINCNT+1
     6 S ^TMP("PXRMPDEM",$J,LINCNT)=TEXT
     7 Q
     8 ;
     9APPHDR(DC,APPDATA) ;Build the appointment header.
     10 I APPDATA("LEN")'>0 Q
     11 N HDR,IND,JND,KND,LND,TEMP
     12 S IND=0,HDR=""
     13 F IND=1:1:APPDATA("MAX") D
     14 . F JND=1:1:APPDATA("LEN") D
     15 .. S KND=$P(APPDATA,",",JND)
     16 .. S LND=""
     17 .. F  S LND=$O(APPDATA(KND,LND)) Q:LND=""  D
     18 ... S TEMP=$P(APPDATA(KND,LND),U,1)
     19 ... S HDR=HDR_TEMP_IND_DC
     20 S APPDATA("HDR")=HDR
     21 Q
     22 ;
     23APPPRINT(DFN,APPDATA) ;Print appointment data.
     24 N CLINIC,COUNT,DATE,HDR,IND,JND,KND,LINE,PCLINIC,PDATE,TEMP
     25 S (PCLINIC,PDATE)=0
     26 F IND=1:1:APPDATA("LEN") D
     27 . S JND=$P(APPDATA,",",IND)
     28 . I JND=1 S PDATE=1
     29 . I JND=2 S PCLINIC=1
     30 S HDR=""
     31 I PDATE S HDR=" "_$P(APPDATA(1,1),U,1)
     32 I PCLINIC S HDR=HDR_"   "_$P(APPDATA(2,2),U,1)
     33 D ADDTXT(" ")
     34 D ADDTXT("Appointment Data")
     35 D ADDTXT(HDR)
     36 S COUNT=0
     37 F  S COUNT=$O(^TMP("PXRMPLD",$J,DFN,"APPDATA",COUNT)) Q:COUNT=""  D
     38 . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"APPDATA",COUNT))
     39 . S LINE=""
     40 . I PDATE S LINE=LINE_$P(TEMP,U,1)
     41 . I PCLINIC S LINE=LINE_"  "_$P(TEMP,U,2)
     42 . D ADDTXT(LINE)
     43 Q
     44 ;
     45DELIMHDR(DC,DATA) ;Build the delimited header for a data type.
     46 I DATA("LEN")'>0 Q
     47 N HDR,IND,JND,KND,LND,MAX,TEMP
     48 S IND=0,HDR=""
     49 F IND=1:1:DATA("LEN") D
     50 . S JND=$P(DATA,",",IND)
     51 . S KND=""
     52 . F  S KND=$O(DATA(JND,KND)) Q:KND=""  D
     53 .. S TEMP=$P(DATA(JND,KND),U,1)
     54 .. S MAX=$P(DATA(JND,KND),U,3)
     55 .. I MAX="" S HDR=HDR_TEMP_DC
     56 .. I +MAX>0 F LND=1:1:MAX S HDR=HDR_TEMP_LND_DC
     57 S DATA("HDR")=HDR
     58 Q
     59 ;
     60DELIMPR(DC,PLIEN,ADDDATA,APPDATA,DEMDATA,FINDDATA,INPDATA,PFACDATA,REMDATA) ;
     61 ;Print the delimited report.
     62 N DATALIST,DFN,IND,NDT,PNAME
     63 S NDT=0
     64 I ADDDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="ADDDATA"
     65 I APPDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="APPDATA"
     66 I DEMDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="DEMDATA"
     67 I ELIGDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="ELIGDATA"
     68 I FINDDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="FINDDATA"
     69 I INPDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="INPDATA"
     70 I PFACDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="PFACDATA"
     71 I REMDATA("LEN")>0 S NDT=NDT+1,DATALIST(NDT)="REMDATA"
     72 D TITLE(PLIEN,1)
     73 ;Output the delimited header.
     74 F IND=1:1:NDT D
     75 . I DATALIST(IND)="ADDDATA" D DELIMHDR(DC,.ADDDATA) Q
     76 . I DATALIST(IND)="APPDATA" D APPHDR(DC,.APPDATA) Q
     77 . I DATALIST(IND)="DEMDATA" D DELIMHDR(DC,.DEMDATA) Q
     78 . I DATALIST(IND)="ELIGDATA" D DELIMHDR(DC,.ELIGDATA) Q
     79 . I DATALIST(IND)="FINDDATA" D DELIMHDR(DC,.FINDDATA) Q
     80 . I DATALIST(IND)="INPDATA" D DELIMHDR(DC,.INPDATA) Q
     81 . I DATALIST(IND)="PFACDATA" D PFACHDR(.PFACDATA)
     82 . I DATALIST(IND)="REMDATA" D REMHDR(DC,.REMDATA) Q
     83 D DELTITLE(DC,.ADDDATA,.APPDATA,.DEMDATA,.FINDDATA,.INPDATA,.PFACDATA,.REMDATA)
     84 S PNAME=":"
     85 F  S PNAME=$O(^TMP("PXRMPLN",$J,PNAME)) Q:PNAME=""  D
     86 . S DFN=""
     87 . F  S DFN=$O(^TMP("PXRMPLN",$J,PNAME,DFN)) Q:DFN=""  D
     88 .. W !,PNAME_DC
     89 .. F IND=1:1:NDT D
     90 ... I DATALIST(IND)="ADDDATA" D PDELDATA(DFN,DC,DATALIST(IND),.ADDDATA) Q
     91 ... I DATALIST(IND)="APPDATA" D PAPPDATA(DFN,DC,.APPDATA) Q
     92 ... I DATALIST(IND)="DEMDATA" D PDELDATA(DFN,DC,DATALIST(IND),.DEMDATA) Q
     93 ... I DATALIST(IND)="ELIGDATA" D PDELDATA(DFN,DC,DATALIST(IND),.ELIGDATA) Q
     94 ... I DATALIST(IND)="FINDDATA" D PFINDATA(DFN,DC,.FINDDATA) Q
     95 ... I DATALIST(IND)="INPDATA" D PDELDATA(DFN,DC,DATALIST(IND),.INPDATA) Q
     96 ... I DATALIST(IND)="PFACDATA" D PFACDATA(DFN,.PFACDATA) Q
     97 ... I DATALIST(IND)="REMDATA" D PREMDATA(DFN,DC,.REMDATA) Q
     98 .. W "\\"
     99 Q
     100 ;
     101DELTITLE(DC,ADDDATA,APPDATA,DEMDATA,FINDDATA,INPDATA,PFACDATA,REMDATA) ;Combine
     102 ;all the headers to create the delimited title.
     103 W !,"PATIENT"_DC
     104 W $G(ADDDATA("HDR"))
     105 W $G(APPDATA("HDR"))
     106 W $G(DEMDATA("HDR"))
     107 W $G(ELIGDATA("HDR"))
     108 W $G(FINDDATA("HDR"))
     109 W $G(INPDATA("HDR"))
     110 W $G(PFACDATA("HDR"))
     111 W $G(REMDATA("HDR"))
     112 W "\\"
     113 Q
     114 ;
     115FINDPR(DFN,FINDDATA) ;Print finding information.
     116 N IND,JND,LINE,TEMP
     117 D ADDTXT(" ")
     118 S LINE="Finding Data"
     119 D ADDTXT(LINE)
     120 F IND=1:1:FINDDATA("LEN") D
     121 . S JND=$P(FINDDATA,",",IND)
     122 . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"FINDDATA",JND))
     123 . I TEMP="" Q
     124 . S LINE=" "_$P(FINDDATA(JND,JND),U,1)_": "_TEMP
     125 . D ADDTXT(LINE)
     126 Q
     127 ;
     128OUTPUT ;Output the text.
     129 N IND,LC,LO,VSIZE
     130 S VSIZE=IOSL-2
     131 S (LC,LO)=0
     132 F IND=1:1:LINCNT D
     133 . S LC=LC+1,LO=LO+1
     134 . W !,^TMP("PXRMPDEM",$J,LC)
     135 . I LO=VSIZE D
     136 .. D PAGE
     137 .. I $D(DTOUT)!$D(DUOUT) S IND=LINCNT Q
     138 .. S LO=0
     139 Q
     140 ;
     141PAGE ;
     142 I ($E(IOST)="C")&(IO=IO(0)) D
     143 . N DIR
     144 . S DIR(0)="E"
     145 . W !
     146 . D ^DIR K DIR
     147 I $D(DUOUT)!$D(DTOUT) Q
     148 W:$D(IOF) @IOF
     149 I $E(IOST)="C",IO=IO(0) W @IOF
     150 Q
     151 ;
     152PAPPDATA(DFN,DC,APPDATA) ;Print the delimited appointment data.
     153 N IND,JND,KND,LINE,LND,PIECE,TEMP
     154 I APPDATA("LEN")'>0 Q
     155 S LINE=""
     156 F IND=1:1:APPDATA("MAX") D
     157 . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"APPDATA",IND))
     158 . F JND=1:1:APPDATA("LEN") D
     159 .. S KND=$P(APPDATA,",",JND)
     160 .. S LND=""
     161 .. F  S LND=$O(APPDATA(KND,LND)) Q:LND=""  D
     162 ... S PIECE=$P(APPDATA(KND,KND),U,2)
     163 ... S LINE=LINE_$P(TEMP,U,PIECE)_DC
     164 W LINE
     165 Q
     166 ;
     167PDELDATA(DFN,DC,DTYPE,DATA) ;Print the delimited data.
     168 N IND,JND,KND,LINE,LND,TEMP,TTEMP
     169 I DATA("LEN")'>0 Q
     170 S TEMP=$G(^TMP("PXRMPLD",$J,DFN,DTYPE))
     171 S LINE=""
     172 F IND=1:1:DATA("LEN") D
     173 . S JND=$P(DATA,",",IND)
     174 . S KND=""
     175 . F  S KND=$O(DATA(JND,KND)) Q:KND=""  D
     176 .. S MAX=$P(DATA(JND,KND),U,3)
     177 .. I MAX="" S LINE=LINE_$P(TEMP,U,KND)_DC Q
     178 .. I +MAX>1 S TTEMP=$P(TEMP,U,KND) F LND=1:1:MAX S LINE=LINE_$P(TTEMP,"~",LND)_DC
     179 W LINE
     180 Q
     181 ;
     182PFACHDR(PFACDATA) ;Build the preferred facility header.
     183 I PFACDATA(0)=1 S PFACDATA("HDR")="PATIENT'S PREFERRED FACILITY"
     184 Q
     185 ;
     186PFACDATA(DFN,PFACDATA) ;Print the patient's preferred facility data, delimited.
     187 I PFACDATA(0)=0 Q
     188 W ^TMP("PXRMPLD",$J,DFN,"PFACDATA")
     189 Q
     190 ;
     191PFACPR(DFN,PFACDATA) ;Print the patient's preferred facility.
     192 I PFACDATA(0)=0 Q
     193 D ADDTXT("Patient's Preferred Facility")
     194 D ADDTXT(" "_$G(^TMP("PXRMPLD",$J,DFN,"PFACDATA")))
     195 Q
     196 ;
     197PFINDATA(DFN,DC,FINDDATA) ;Print the finding data.
     198 N IND,JND,LINE,TEMP
     199 I FINDDATA("LEN")'>0 Q
     200 S LINE=""
     201 F IND=1:1:FINDDATA("LEN") D
     202 . S JND=$P(FINDDATA,",",IND)
     203 . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"FINDDATA",JND))
     204 . S LINE=LINE_TEMP_DC
     205 W LINE
     206 Q
     207 ;
     208PREMDATA(DFN,DC,REMDATA) ;Print the reminder data.
     209 N IND,JND,LINE,TEMP
     210 I REMDATA("LEN")'>0 Q
     211 S LINE=""
     212 F IND=1:1:REMDATA("LEN") D
     213 . S JND=$P(REMDATA,",",IND)
     214 . S LINE=LINE_REMDATA("RNAME",JND)_DC
     215 . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"REMDATA",REMDATA("IEN",JND)))
     216 . S LINE=LINE_$P(TEMP,U,2)_DC_$P(TEMP,U,3)_"^"_$P(TEMP,U,4)_DC
     217 W LINE
     218 Q
     219 ;
     220REGPR(PLIEN,ADDDATA,APPDATA,DEMDATA,FINDDATA,INPDATA,PFACDATA,REMDATA) ;
     221 ;Print the regular report..
     222 N DATATYPE,DFN,PNAME,LINCNT
     223 K ^TMP("PXRMPDEM",$J)
     224 S LINCNT=0
     225 D TITLE(PLIEN,0)
     226 S PNAME=":"
     227 F  S PNAME=$O(^TMP("PXRMPLN",$J,PNAME)) Q:PNAME=""  D
     228 . S DFN=0
     229 . F  S DFN=$O(^TMP("PXRMPLN",$J,PNAME,DFN)) Q:DFN=""  D
     230 .. D ADDTXT(" ")
     231 .. D ADDTXT("---------- "_PNAME_" DFN="_DFN_" ----------")
     232 .. S DATATYPE=""
     233 .. F  S DATATYPE=$O(^TMP("PXRMPLD",$J,DFN,DATATYPE)) Q:DATATYPE=""  D
     234 ... I DATATYPE="ADDDATA" D VADPTPR(DFN,"Address Data",DATATYPE,.ADDDATA) Q
     235 ... I DATATYPE="APPDATA" D APPPRINT(DFN,.APPDATA) Q
     236 ... I DATATYPE="DEMDATA" D VADPTPR(DFN,"Demographic Data",DATATYPE,.DEMDATA) Q
     237 ... I DATATYPE="ELIGDATA" D VADPTPR(DFN,"Eligibility Data",DATATYPE,.ELIGDATA) Q
     238 ... I DATATYPE="FINDDATA" D FINDPR(DFN,.FINDDATA) Q
     239 ... I DATATYPE="INPDATA" D VADPTPR(DFN,"Inpatient Data",DATATYPE,.INPDATA) Q
     240 ... I DATATYPE="PFACDATA" D PFACPR(DFN,.PFACDATA) Q
     241 ... I DATATYPE="REMDATA" D REMPR(DFN,.REMDATA) Q
     242 D OUTPUT
     243 K ^TMP("PXRMPDEM",$J)
     244 Q
     245 ;
     246REMHDR(DC,REMDATA) ;Build the reminder data delimited header.
     247 N HDR,IND,JND
     248 S HDR=""
     249 F IND=1:1:REMDATA("LEN") D
     250 . S JND=$P(REMDATA,",",IND)
     251 . S HDR=HDR_"REMINDER"_JND_DC_"STATUS"_JND_DC_"DUE DATE"_JND_DC_"LAST DONE"_JND_DC
     252 S REMDATA("HDR")=HDR
     253 Q
     254 ;
     255REMPR(DFN,REMDATA) ;Print reminder status information.
     256 N DUE,IND,JND,LAST,LINE,NSP,STATUS,TEMP
     257 D ADDTXT(" ")
     258 S LINE="Reminder:"_$$INSCHR^PXRMEXLC(27," ")_"--STATUS--  --DUE DATE--  --LAST DONE--"
     259 D ADDTXT(LINE)
     260 F IND=1:1:REMDATA("LEN") D
     261 . S JND=$P(REMDATA,",",IND)
     262 . S RIEN=REMDATA("IEN",JND)
     263 . S TEMP=$G(^TMP("PXRMPLD",$J,DFN,"REMDATA",RIEN))
     264 . I TEMP="" Q
     265 . S STATUS=$P(TEMP,U,2)
     266 . S DUE=$P(TEMP,U,3),DUE=$$EDATE^PXRMDATE(DUE)
     267 . S LAST=$P(TEMP,U,4),LAST=$$EDATE^PXRMDATE(LAST)
     268 . S NSP=38-$L(REMDATA("RNAME",JND))
     269 . S LINE=REMDATA("RNAME",JND)_$$INSCHR^PXRMEXLC(NSP," ")_STATUS
     270 . S NSP=54-$L(LINE)-($L(DUE)/2)
     271 . S LINE=LINE_$$INSCHR^PXRMEXLC(NSP," ")_DUE
     272 . S NSP=69-$L(LINE)-($L(LAST)/2)
     273 . S LINE=LINE_$$INSCHR^PXRMEXLC(NSP," ")_LAST
     274 . D ADDTXT(LINE)
     275 Q
     276 ;
     277TITLE(PLIEN,DELIM) ;Print the report title.
     278 N LISTNAME
     279 S LISTNAME=$P(^PXRMXP(810.5,PLIEN,0),U,1)
     280 I DELIM D
     281 . W @IOF
     282 . W !,"Patient Demographic Report"
     283 . W !,"   Patient List: "_LISTNAME
     284 . W !,"   Created on "_$$FMTE^XLFDT(DCREAT)
     285 I 'DELIM D
     286 . D ADDTXT("Patient Demographic Report")
     287 . D ADDTXT("   Patient List: "_LISTNAME)
     288 . D ADDTXT("   Created on "_$$FMTE^XLFDT(DCREAT))
     289 Q
     290 ;
     291VADPTPR(DFN,DNAME,DTYPE,DATA) ;Print data returned by a VADPT call.
     292 N IND,JND,KND,LINE,LND,MAX,TEMP,TTEMP
     293 D ADDTXT(" ")
     294 D ADDTXT(DNAME)
     295 S TEMP=$G(^TMP("PXRMPLD",$J,DFN,DTYPE))
     296 F IND=1:1:DATA("LEN") D
     297 . S JND=$P(DATA,",",IND)
     298 . S KND=""
     299 . F  S KND=$O(DATA(JND,KND)) Q:KND=""  D
     300 .. S TTEMP=$P(TEMP,U,KND)
     301 .. S MAX=+$P(DATA(JND,KND),U,3)
     302 .. I MAX=0 S MAX=1
     303 .. F LND=1:1:MAX D
     304 ... S LINE=" "_$P(DATA(JND,KND),U,1)_": "_$P(TTEMP,"~",LND)
     305 ... D ADDTXT(LINE)
     306 Q
     307 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPDRS.m

    r613 r623  
    1 PXRMPDRS        ;SLC/PKR - Patient List Demographic Report data selection. ;03/22/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 ADDSEL(DATA,SUB)        ;Let the user select the address information they want.
    5         N ADDLIST,LIST
    6         S ADDLIST("A",1)=" 1 - CURRENT ADDRESS",DATA(SUB,1,1)="STREET ADDRESS #1"_U_1
    7         S DATA(SUB,1,2)="STREET ADDRESS #2"_U_1,DATA(SUB,1,3)="STREET ADDRESS #3"_U_1
    8         S DATA(SUB,1,4)="CITY"_U_1,DATA(SUB,1,5)="STATE"_U_2,DATA(SUB,1,6)="ZIP"_U_1
    9         S DATA(SUB,1,7)="COUNTY"_U_2
    10         S ADDLIST("A",2)=" 2 - PHONE NUMBER",DATA(SUB,2,8)="PHONE NUMBER"_U_1
    11         S ADDLIST("A")="Enter your selection(s)"
    12         S ADDLIST("?")="^D HELP^PXRMPDRS"
    13         W !!,"Select from the following address items:"
    14         S LIST=$$SEL^PXRMPDRS(.ADDLIST,2)
    15         I $D(DTOUT)!$D(DUOUT) Q
    16         S DATA(SUB)=LIST
    17         S DATA(SUB,"LEN")=$L(LIST,",")-1
    18         Q
    19         ;
    20 APPERR  ;
    21         N ECODE
    22         I $D(ZTQUEUED) D  Q
    23         . N NL,TIME
    24         . S TIME=$$NOW^XLFDT
    25         . S TIME=$$FMTE^XLFDT(TIME)
    26         . K ^TMP("PXRMXMZ",$J)
    27         . S ^TMP("PXRMXMZ",$J,1,0)="The Patient Demographic Report requested by "_$$GET1^DIQ(200,DBDUZ,.01)_" on "
    28         . S ^TMP("PXRMXMZ",$J,2,0)=TIME_" was supposed to include appointment data."
    29         . S ^TMP("PXRMXMZ",$J,3,0)="Appointment data could not be obtained from the Scheduling database due to the"
    30         . S ^TMP("PXRMXMZ",$J,4,0)="following error(s):"
    31         . S ECODE=0,NL=4
    32         . F  S ECODE=$O(^TMP($J,"SDAMA301",ECODE)) Q:ECODE=""  D
    33         .. S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP($J,"SDAMA301",ECODE)
    34         . D SEND^PXRMMSG("Scheduling database error(s)",1)
    35         . S ZTSTOP=1
    36         ;
    37         I '$D(ZTQUEUED) D  Q
    38         . W @IOF
    39         . W !,"Appointment data could not be obtained from the Scheduling database due to the"
    40         . W !,"following error(s):"
    41         . S ECODE=0
    42         . F  S ECODE=$O(^TMP($J,"SDAMA301",ECODE)) Q:ECODE=""  D
    43         .. W !," ",^TMP($J,"SDAMA301",ECODE)
    44         Q
    45         ;
    46 APPSEL(DATA,SUB)        ;Let the user select the appointment information they want.
    47         ;The first subscript of APPDATA is the selection number and the
    48         ;the second subscript is the subscript where the data is returned
    49         ;in VAPA. The first piece of APPDATA is the name of the data and the
    50         ;second piece is the piece of VAPA this is displayed.
    51         N APPLIST,LIST,MAX
    52         S APPLIST("A",1)=" 1 - APPOINTMENT DATE",DATA(SUB,1,1)="APPOINTMENT DATE"_U_1
    53         S APPLIST("A",2)=" 2 - CLINIC",DATA(SUB,2,2)="CLINIC"_U_2
    54         S APPLIST("A")="Enter your selection(s)"
    55         S APPLIST("?")="^D HELP^PXRMPDRS"
    56         W !!,"Select from the following future appointment items:"
    57         S LIST=$$SEL^PXRMPDRS(.APPLIST,2)
    58         I $D(DTOUT)!$D(DUOUT) Q
    59         S DATA(SUB)=LIST
    60         S DATA(SUB,"LEN")=$L(LIST,",")-1
    61         I DATA(SUB,"LEN")=0 Q
    62         S DATA(SUB,"MAX")=$$ASKNUM^PXRMEUT("Maximum number of appointments to display",1,25)
    63         Q
    64         ;
    65 DATASEL(LISTIEN,DATA,SUB)       ; Build a list of data that is availble for
    66         ;this patient list and let the user select what they want.
    67         N IND,DATALIST,DTYPE
    68         S DTYPE="",IND=0
    69         F  S DTYPE=$O(^PXRMXP(810.5,LISTIEN,35,"B",DTYPE)) Q:DTYPE=""  D
    70         . S IND=IND+1,DATALIST("A",IND)=" "_IND_" - "_DTYPE
    71         . S DATA(SUB,IND,IND)=DTYPE
    72         ;If there is no data quit.
    73         I IND=0 S DATA(SUB,"LEN")=0 Q
    74         S DATALIST("A")="Enter your selections(s)"
    75         S DATALIST("?")="^D HELP^PXRMPDRS"
    76         W !!,"Select from the following patient data:"
    77         S LIST=$$SEL^PXRMPDRS(.DATALIST,IND)
    78         I $D(DTOUT)!$D(DUOUT) Q
    79         S DATA(SUB)=LIST
    80         S DATA(SUB,"LEN")=$L(LIST,",")-1
    81         Q
    82         ;
    83 DEMSEL(DATA,SUB)        ;Let the user select the demographic information they want.
    84         ;The first subscript of DATA is the selection number and the
    85         ;the second subscript is the subscript where the data is returned
    86         ;in VADM. The first piece of DEMDATA is the name of the data and the
    87         ;second piece is the piece of VADM this is displayed.
    88         N DEMLIST,DTOUT,DUOUT,IND,ITEM,JND,KND,LIST,TEMP
    89         S DEMLIST("A",1)=" 1 - SSN",DATA(SUB,1,2)="SSN"_U_2
    90         S DEMLIST("A",2)=" 2 - DATE OF BIRTH",DATA(SUB,2,3)="DOB"_U_2
    91         S DEMLIST("A",3)=" 3 - AGE",DATA(SUB,3,4)="AGE"_U_1
    92         S DEMLIST("A",4)=" 4 - SEX",DATA(SUB,4,5)="SEX"_U_2
    93         S DEMLIST("A",5)=" 5 - DATE OF DEATH",DATA(SUB,5,6)="DOD"_U_2
    94         S DEMLIST("A",6)=" 6 - REMARKS",DATA(SUB,6,7)="REMARKS"_U_1
    95         S DEMLIST("A",7)=" 7 - HISTORIC RACE",DATA(SUB,7,8)="HISTORIC RACE"_U_2
    96         S DEMLIST("A",8)=" 8 - RELIGION",DATA(SUB,8,9)="RELIGION"_U_2
    97         S DEMLIST("A",9)=" 9 - MARITAL STATUS",DATA(SUB,9,10)="MARTIAL STATUS"_U_2
    98         S DEMLIST("A",10)="10 - ETHNICITY",DATA(SUB,10,11)="ETHNICITY"_U_2
    99         S DEMLIST("A",11)="11 - RACE",DATA(SUB,11,12)="RACE"_U_2
    100         S DEMLIST("A")="Enter your selection(s)"
    101         S DEMLIST("?")="^D HELP^PXRMPDRS"
    102 DSEL    W !!,"Select from the following demographic items:"
    103         S LIST=$$SEL^PXRMPDRS(.DEMLIST,11)
    104         I $D(DTOUT)!$D(DUOUT) Q
    105         S DATA(SUB)=LIST
    106         S DATA(SUB,"LEN")=$L(LIST,",")-1
    107         F IND=1:1:DATA(SUB,"LEN") D
    108         . S JND=$P(LIST,",",IND)
    109         . S KND=$O(DATA(SUB,JND,""))
    110         . S TEMP=$P(DATA(SUB,JND,KND),U,1)
    111         . I TEMP="SSN" D
    112         .. N FULLSSN
    113         .. D SSN^PXRMXSD(.FULLSSN)
    114         .. S DATA(SUB,"FULLSSN")=$S($G(FULLSSN)="Y":1,1:0)
    115         . I $D(DTOUT)!$D(DUOUT) S IND=DATA(SUB,"LEN")+1 Q
    116         . I TEMP="ETHNICITY" S $P(DATA(SUB,10,11),U,3)=$$ASKNUM^PXRMEUT("Maximum number of ethnicity entries to display",1,10)
    117         . I TEMP="RACE" S $P(DATA(SUB,11,12),U,3)=$$ASKNUM^PXRMEUT("Maximum number of race entries to display",1,10)
    118         I $D(DTOUT)!$D(DUOUT) K DTOUT,DUOUT G DSEL
    119         Q
    120         ;
    121 ELIGSEL(DATA,SUB)       ;Let the user select the eligibility data they want.
    122         ;The first subscript of ELIGDATA is the selection number and the
    123         ;the second subscript is the subscript where the data is returned
    124         ;in VAEL. The first piece of ELIGDATA is the name of the data and the
    125         ;second piece is the piece of VAEL this is displayed.
    126         N ELIGLIST,ITEM,LIST
    127         S ELIGLIST("A",1)=" 1 - PRIMARY ELGIBILITY CODE",DATA(SUB,1,1)="PRIMARY ELGIBILITY CODE"_U_2
    128         S ELIGLIST("A",2)=" 2 - PERIOD OF SERVICE",DATA(SUB,2,2)="PERIOD OF SERVICE"_U_2
    129         S ELIGLIST("A",3)=" 3 - % SERVICE CONNECTED",DATA(SUB,3,3)="% SERVICE CONNECTED"_U_2
    130         S ELIGLIST("A",4)=" 4 - VETERAN",DATA(SUB,4,4)="VETERAN"_U_1
    131         S ELIGLIST("A",5)=" 5 - TYPE",DATA(SUB,5,6)="TYPE"_U_2
    132         S ELIGLIST("A",6)=" 6 - ELIGIBILITY STATUS",DATA(SUB,6,8)="ELIGIBILITY STATUS"_U_2
    133         S ELIGLIST("A",7)=" 7 - CURRENT MEANS TEST",DATA(SUB,7,9)="CURRENT MEANS TEST"_U_2
    134         S ELIGLIST("A")="Enter your selection(s)"
    135         S ELIGLIST("?")="^D HELP^PXRMPDRS"
    136         W !!,"Select from the following eligibility items:"
    137         S LIST=$$SEL^PXRMPDRS(.ELIGLIST,7)
    138         I $D(DTOUT)!$D(DUOUT) Q
    139         S DATA(SUB)=LIST
    140         S DATA(SUB,"LEN")=$L(LIST,",")-1
    141         Q
    142         ;
    143 HELP    ; -- help code.
    144         W !!,"You can choose any combination of numbers i.e., 1-4 or 1,3-5"
    145         W !!,"See the Clinical Reminders Managers manual for detailed explanations of each"
    146         W !,"of the selection items."
    147         Q
    148         ;
    149 INPSEL(DATA,SUB)        ;Let the user select the inpatient information they want.
    150         ;The first subscript of INPDATA is the selection number and the
    151         ;the second subscript is the subscript where the data is returned
    152         ;in VAIN. The first piece of INPDATA is the name of the data and the
    153         ;second piece is the piece of VAIN this is displayed.
    154         N INPLIST,ITEM,LIST
    155         S INPLIST("A",1)=" 1 - WARD LOCATION",DATA(SUB,1,4)="WARD"_U_2
    156         S INPLIST("A",2)=" 2 - ROOM-BED",DATA(SUB,2,5)="ROOM-BED"_U_1
    157         S INPLIST("A",3)=" 3 - ADMISSION DATE/TIME",DATA(SUB,3,7)="ADMISSION DATE/TIME"_U_2
    158         S INPLIST("A",4)=" 4 - ATTENDING PHYSICIAN",DATA(SUB,4,11)="ATTENDING"_U_2
    159         S INPLIST("A")="Enter your selection(s)"
    160         S INPLIST("?")="^D HELP^PXRMPDRS"
    161         W !!,"Select from the following inpatient items:"
    162         S LIST=$$SEL^PXRMPDRS(.INPLIST,5)
    163         I $D(DTOUT)!$D(DUOUT) Q
    164         S DATA(SUB)=LIST
    165         S DATA(SUB,"LEN")=$L(LIST,",")-1
    166         Q
    167         ;
    168 REMSEL(PLIEN,DATA,SUB)  ;If the list was generated from a reminder report
    169         ;let the user select the reminder data they want.
    170         I '$P(^PXRMXP(810.5,PLIEN,0),U,9) S DATA(SUB,"LEN")=0 Q
    171         N IEN,IND,REMLIST,RNAME
    172         S (IEN,IND)=0
    173         F  S IEN=$O(^PXRMXP(810.5,PLIEN,45,"B",IEN)) Q:IEN=""  D
    174         . S RNAME=$P(^PXD(811.9,IEN,0),U,3)
    175         . I RNAME="" S RNAME=$P(^PXD(811.9,IEN,0),U,1)
    176         . S IND=IND+1
    177         . S DATA(SUB,"RNAME",IND)=RNAME
    178         . S DATA(SUB,"IEN",IND)=IEN
    179         . S REMLIST("A",IND)=" "_IND_" - "_RNAME
    180         S REMLIST("A")="Enter your selection(s)"
    181         S REMLIST("?")="^D HELP^PXRMPDRS"
    182         W !!,"Include due status information for the following reminder(s):"
    183         S LIST=$$SEL^PXRMPDRS(.REMLIST,IND)
    184         I $D(DTOUT)!$D(DUOUT) Q
    185         S DATA(SUB)=LIST
    186         S DATA(SUB,"LEN")=$L(LIST,",")-1
    187         Q
    188         ;
    189 SEL(SELLIST,LEN)        ;Select global list
    190         N DIR,X,Y
    191         M DIR=SELLIST
    192         S DIR(0)="LO^1:"_LEN
    193         D ^DIR
    194         Q Y
    195         ;
     1PXRMPDRS ;SLC/PKR - Patient List Demographic Report data selection. ;07/18/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4ADDSEL(ADDDATA) ;Let the user select the address information they want.
     5 N ADDLIST,LIST
     6 S ADDLIST("A",1)=" 1 - CURRENT ADDRESS",ADDDATA(1,1)="STREET ADDRESS #1"_U_1
     7 S ADDDATA(1,2)="STREET ADDRESS #2"_U_1,ADDDATA(1,3)="STREET ADDRESS #3"_U_1
     8 S ADDDATA(1,4)="CITY"_U_1,ADDDATA(1,5)="STATE"_U_2,ADDDATA(1,6)="ZIP"_U_1
     9 S ADDDATA(1,7)="COUNTY"_U_2
     10 S ADDLIST("A",2)=" 2 - PHONE NUMBER",ADDDATA(2,8)="PHONE NUMBER"_U_1
     11 S ADDLIST("A")="Enter your selection(s)"
     12 S ADDLIST("?")="^D HELP^PXRMPDRS"
     13 W !!,"Select from the following address items:"
     14 S LIST=$$SEL^PXRMPDRS(.ADDLIST,2)
     15 I $D(DTOUT)!$D(DUOUT) Q
     16 S ADDDATA=LIST
     17 S ADDDATA("LEN")=$L(LIST,",")-1
     18 Q
     19 ;
     20APPERR ;
     21 N ECODE
     22 I $D(ZTQUEUED) D  Q
     23 . N NL,TIME
     24 . S TIME=$$NOW^XLFDT
     25 . S TIME=$$FMTE^XLFDT(TIME)
     26 . K ^TMP("PXRMXMZ",$J)
     27 . S ^TMP("PXRMXMZ",$J,1,0)="The Patient Demographic Report requested by "_$$GET1^DIQ(200,DBDUZ,.01)_" on "
     28 . S ^TMP("PXRMXMZ",$J,2,0)=TIME_" was supposed to include appointment data."
     29 . S ^TMP("PXRMXMZ",$J,3,0)="Appointment data could not be obtained from the Scheduling database due to the"
     30 . S ^TMP("PXRMXMZ",$J,4,0)="following error(s):"
     31 . S ECODE=0,NL=4
     32 . F  S ECODE=$O(^TMP($J,"SDAMA301",ECODE)) Q:ECODE=""  D
     33 .. S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP($J,"SDAMA301",ECODE)
     34 . D SEND^PXRMMSG("Scheduling database error(s)",1)
     35 . S ZTSTOP=1
     36 ;
     37 I '$D(ZTQUEUED) D  Q
     38 . W @IOF
     39 . W !,"Appointment data could not be obtained from the Scheduling database due to the"
     40 . W !,"following error(s):"
     41 . S ECODE=0
     42 . F  S ECODE=$O(^TMP($J,"SDAMA301",ECODE)) Q:ECODE=""  D
     43 .. W !," ",^TMP($J,"SDAMA301",ECODE)
     44 Q
     45 ;
     46APPSEL(APPDATA) ;Let the user select the appointment information they want.
     47 ;The first subscript of APPDATA is the selection number and the
     48 ;the second subscript is the subscript where the data is returned
     49 ;in VAPA. The first piece of APPDATA is the name of the data and the
     50 ;second piece is the piece of VAPA this is displayed.
     51 N APPLIST,LIST,MAX
     52 S APPLIST("A",1)=" 1 - APPOINTMENT DATE",APPDATA(1,1)="APPOINTMENT DATE"_U_1
     53 S APPLIST("A",2)=" 2 - CLINIC",APPDATA(2,2)="CLINIC"_U_2
     54 S APPLIST("A")="Enter your selection(s)"
     55 S APPLIST("?")="^D HELP^PXRMPDRS"
     56 W !!,"Select from the following future appointment items:"
     57 S LIST=$$SEL^PXRMPDRS(.APPLIST,2)
     58 I $D(DTOUT)!$D(DUOUT) Q
     59 S APPDATA=LIST
     60 S APPDATA("LEN")=$L(LIST,",")-1
     61 I APPDATA("LEN")=0 Q
     62 S APPDATA("MAX")=$$ASKNUM^PXRMEUT("Maximum number of appointments to display",1,25)
     63 Q
     64 ;
     65DATASEL(LISTIEN,FINDDATA) ; Build a list of data that is availble for
     66 ;this patient list and let the user select what they want.
     67 N IND,DATALIST,DTYPE
     68 S DTYPE="",IND=0
     69 F  S DTYPE=$O(^PXRMXP(810.5,LISTIEN,35,"B",DTYPE)) Q:DTYPE=""  D
     70 . S IND=IND+1,DATALIST("A",IND)=" "_IND_" - "_DTYPE
     71 . S FINDDATA(IND,IND)=DTYPE
     72 ;If there is no data quit.
     73 I IND=0 S FINDDATA("LEN")=0 Q
     74 S DATALIST("A")="Enter your selections(s)"
     75 S DATALIST("?")="^D HELP^PXRMPDRS"
     76 W !!,"Select from the following patient data:"
     77 S LIST=$$SEL^PXRMPDRS(.DATALIST,IND)
     78 I $D(DTOUT)!$D(DUOUT) Q
     79 S FINDDATA=LIST
     80 S FINDDATA("LEN")=$L(LIST,",")-1
     81 Q
     82 ;
     83DEMSEL(DEMDATA) ;Let the user select the demographic information they want.
     84 ;The first subscript of DEMDATA is the selection number and the
     85 ;the second subscript is the subscript where the data is returned
     86 ;in VADM. The first piece of DEMDATA is the name of the data and the
     87 ;second piece is the piece of VADM this is displayed.
     88 N DEMLIST,DTOUT,DUOUT,IND,ITEM,JND,KND,LIST,TEMP
     89 S DEMLIST("A",1)=" 1 - SSN",DEMDATA(1,2)="SSN"_U_2
     90 S DEMLIST("A",2)=" 2 - DATE OF BIRTH",DEMDATA(2,3)="DOB"_U_2
     91 S DEMLIST("A",3)=" 3 - AGE",DEMDATA(3,4)="AGE"_U_1
     92 S DEMLIST("A",4)=" 4 - SEX",DEMDATA(4,5)="SEX"_U_2
     93 S DEMLIST("A",5)=" 5 - DATE OF DEATH",DEMDATA(5,6)="DOD"_U_2
     94 S DEMLIST("A",6)=" 6 - REMARKS",DEMDATA(6,7)="REMARKS"_U_1
     95 S DEMLIST("A",7)=" 7 - HISTORIC RACE",DEMDATA(7,8)="HISTORIC RACE"_U_2
     96 S DEMLIST("A",8)=" 8 - RELIGION",DEMDATA(8,9)="RELIGION"_U_2
     97 S DEMLIST("A",9)=" 9 - MARITAL STATUS",DEMDATA(9,10)="MARTIAL STATUS"_U_2
     98 S DEMLIST("A",10)="10 - ETHNICITY",DEMDATA(10,11)="ETHNICITY"_U_2
     99 S DEMLIST("A",11)="11 - RACE",DEMDATA(11,12)="RACE"_U_2
     100 S DEMLIST("A")="Enter your selection(s)"
     101 S DEMLIST("?")="^D HELP^PXRMPDRS"
     102DSEL W !!,"Select from the following demographic items:"
     103 S LIST=$$SEL^PXRMPDRS(.DEMLIST,11)
     104 I $D(DTOUT)!$D(DUOUT) Q
     105 S DEMDATA=LIST
     106 S DEMDATA("LEN")=$L(LIST,",")-1
     107 F IND=1:1:DEMDATA("LEN") D
     108 . S JND=$P(LIST,",",IND)
     109 . S KND=$O(DEMDATA(JND,""))
     110 . S TEMP=$P(DEMDATA(JND,KND),U,1)
     111 . I TEMP="SSN" D
     112 .. N FULLSSN
     113 .. D SSN^PXRMXSD(.FULLSSN)
     114 .. S DEMDATA("FULLSSN")=$S($G(FULLSSN)="Y":1,1:0)
     115 . I $D(DTOUT)!$D(DUOUT) S IND=DEMDATA("LEN")+1 Q
     116 . I TEMP="ETHNICITY" S $P(DEMDATA(10,11),U,3)=$$ASKNUM^PXRMEUT("Maximum number of ethnicity entries to display",1,10)
     117 . I TEMP="RACE" S $P(DEMDATA(11,12),U,3)=$$ASKNUM^PXRMEUT("Maximum number of race entries to display",1,10)
     118 I $D(DTOUT)!$D(DUOUT) K DTOUT,DUOUT G DSEL
     119 Q
     120 ;
     121ELIGSEL(ELIGDATA) ;Let the user select the eligibility data they want.
     122 ;The first subscript of ELIGDATA is the selection number and the
     123 ;the second subscript is the subscript where the data is returned
     124 ;in VAEL. The first piece of ELIGDATA is the name of the data and the
     125 ;second piece is the piece of VAEL this is displayed.
     126 N ELIGLIST,ITEM,LIST
     127 S ELIGLIST("A",1)=" 1 - PRIMARY ELGIBILITY CODE",ELIGDATA(1,1)="PRIMARY ELGIBILITY CODE"_U_2
     128 S ELIGLIST("A",2)=" 2 - PERIOD OF SERVICE",ELIGDATA(2,2)="PERIOD OF SERVICE"_U_2
     129 S ELIGLIST("A",3)=" 3 - % SERVICE CONNECTED",ELIGDATA(3,3)="% SERVICE CONNECTED"_U_2
     130 S ELIGLIST("A",4)=" 4 - VETERAN",ELIGDATA(4,4)="VETERAN"_U_1
     131 S ELIGLIST("A",5)=" 5 - TYPE",ELIGDATA(5,6)="TYPE"_U_2
     132 S ELIGLIST("A",6)=" 6 - ELIGIBILITY STATUS",ELIGDATA(6,8)="ELIGIBILITY STATUS"_U_2
     133 S ELIGLIST("A",7)=" 7 - CURRENT MEANS TEST",ELIGDATA(7,9)="CURRENT MEANS TEST"_U_2
     134 S ELIGLIST("A")="Enter your selection(s)"
     135 S ELIGLIST("?")="^D HELP^PXRMPDRS"
     136 W !!,"Select from the following eligibility items:"
     137 S LIST=$$SEL^PXRMPDRS(.ELIGLIST,7)
     138 I $D(DTOUT)!$D(DUOUT) Q
     139 S ELIGDATA=LIST
     140 S ELIGDATA("LEN")=$L(LIST,",")-1
     141 Q
     142 ;
     143HELP ; -- help code.
     144 W !!,"You can choose any combination of numbers i.e., 1-4 or 1,3-5"
     145 W !!,"See the Clinical Reminders Managers manual for detailed explanations of each"
     146 W !,"of the selection items."
     147 Q
     148 ;
     149INPSEL(INPDATA) ;Let the user select the inpatient information they want.
     150 ;The first subscript of INPDATA is the selection number and the
     151 ;the second subscript is the subscript where the data is returned
     152 ;in VAIN. The first piece of INPDATA is the name of the data and the
     153 ;second piece is the piece of VAIN this is displayed.
     154 N INPLIST,ITEM,LIST
     155 S INPLIST("A",1)=" 1 - WARD LOCATION",INPDATA(1,4)="WARD"_U_2
     156 S INPLIST("A",2)=" 2 - ROOM-BED",INPDATA(2,5)="ROOM-BED"_U_1
     157 S INPLIST("A",3)=" 3 - ADMISSION DATE/TIME",INPDATA(3,7)="ADMISSION DATE/TIME"_U_2
     158 S INPLIST("A",4)=" 4 - ATTENDING PHYSICIAN",INPDATA(4,11)="ATTENDING"_U_2
     159 S INPLIST("A")="Enter your selection(s)"
     160 S INPLIST("?")="^D HELP^PXRMPDRS"
     161 W !!,"Select from the following inpatient items:"
     162 S LIST=$$SEL^PXRMPDRS(.INPLIST,5)
     163 I $D(DTOUT)!$D(DUOUT) Q
     164 S INPDATA=LIST
     165 S INPDATA("LEN")=$L(LIST,",")-1
     166 Q
     167 ;
     168REMSEL(PLIEN,REMDATA) ;If the list was generated from a reminder report
     169 ;let the user select the reminder data they want.
     170 I '$P(^PXRMXP(810.5,PLIEN,0),U,9) S REMDATA("LEN")=0 Q
     171 N IEN,IND,REMLIST,RNAME
     172 S (IEN,IND)=0
     173 F  S IEN=$O(^PXRMXP(810.5,PLIEN,45,"B",IEN)) Q:IEN=""  D
     174 . S RNAME=$P(^PXD(811.9,IEN,0),U,3)
     175 . I RNAME="" S RNAME=$P(^PXD(811.9,IEN,0),U,1)
     176 . S IND=IND+1
     177 . S REMDATA("RNAME",IND)=RNAME
     178 . S REMDATA("IEN",IND)=IEN
     179 . S REMLIST("A",IND)=" "_IND_" - "_RNAME
     180 S REMLIST("A")="Enter your selection(s)"
     181 S REMLIST("?")="^D HELP^PXRMPDRS"
     182 W !!,"Include due status information for the following reminder(s):"
     183 S LIST=$$SEL^PXRMPDRS(.REMLIST,IND)
     184 I $D(DTOUT)!$D(DUOUT) Q
     185 S REMDATA=LIST
     186 S REMDATA("LEN")=$L(LIST,",")-1
     187 Q
     188 ;
     189SEL(SELLIST,LEN) ;Select global list
     190 N DIR,X,Y
     191 M DIR=SELLIST
     192 S DIR(0)="LO^1:"_LEN
     193 D ^DIR
     194 Q Y
     195 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPLST.m

    r613 r623  
    1 PXRMPLST        ; SLC/PKR - Build a patient list from a reminder definition. ;01/24/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Input  :  RIEN     - Reminder IEN
    5         ;          PLIST    - List returned in ^TMP($J,PLIST,DFN)
    6         ;          DFNONLY  - If true list contains only DFN information
    7         ;          PXRMDATE - Evaluation date
    8         ;===================================================
    9 BLDPLST(DEFARR,PLIST,DFNONLY)   ;
    10         N DFN,DOBE,DOBS,ELE,ERROR,ERRSTR,IND,FNUM
    11         N LIST1,LIST2,LNAME,LSP,LSTACK
    12         N NDR,NOT,OPER,PCLOG,PFSTACK,SEX,TYPE
    13         ;
    14         ;Get the cohort logic string. This has passed a validation before
    15         ;it can be selected for building patient lists so we don't need to
    16         ;check it here.
    17         S PCLOG=DEFARR(31)
    18         I PCLOG="" Q
    19         S OPER="!&~"
    20         ;Get the sex field, if PCLOG does not contain SEX set it to null.
    21         S SEX=$S(PCLOG["SEX":$P(DEFARR(0),U,9),1:"")
    22         ;If PCLOG contains age build the corresponding date of birth range(s).
    23         I PCLOG["AGE" D DOBR(.DEFARR,.NDR,.DOBS,.DOBE)
    24         ;Replace &' with ~ so the stack will be built properly.
    25         S PCLOG=$$STRREP^PXRMUTIL(PCLOG,"&'","~")
    26         D POSTFIX^PXRMSTAC(PCLOG,OPER,.PFSTACK)
    27         ;Process the logic.
    28         D CFSAA(.PFSTACK)
    29         S (IND,ERROR,LSP,LSTACK(0),NOT)=0
    30         F  Q:(IND'<PFSTACK(0))!(ERROR)  D
    31         . S IND=IND+1,ELE=PFSTACK(IND)
    32         . I ELE["'" S NOT=1
    33         . S TYPE=$S(ELE="'":"NOT",ELE["AGE":"A",ELE["FI":"FI",ELE["FF":"FF",ELE="SAA":"SAA",ELE["SEX":"S",OPER[ELE:"OP",1:"")
    34         .;
    35         . I TYPE="A" D  Q
    36         .. S LNAME="LIST"_IND
    37         .. D LSA("",NDR,.DOBS,.DOBE,LNAME)
    38         .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
    39         .. D AGEFI(.DEFARR,LNAME,SEX,"")
    40         .;
    41         . I TYPE="FI" D  Q
    42         .. S IND=IND+1,FNUM=PFSTACK(IND)
    43         .. I +FNUM'=FNUM S ERROR=1,ERRSTR="Error - having a finding not followed by a number" Q
    44         .. S LNAME="LIST"_IND
    45         .. D EVALPL^PXRMEVFI(.DEFARR,FNUM,LNAME)
    46         .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
    47         .;
    48         . I TYPE="FF" D  Q
    49         .. S IND=IND+1,FNUM=PFSTACK(IND)
    50         .. I +FNUM'=FNUM S ERROR=1,ERRSTR="Error - having a function finding not followed by a number"
    51         .. S LNAME="LIST"_IND
    52         .. D EVALPL^PXRMFF(.DEFARR,"FF"_FNUM,LNAME)
    53         .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
    54         .;
    55         . I TYPE="NOT" S NOT=1 Q
    56         .;
    57         . I TYPE="OP" D  Q
    58         .. S LIST2=$$POP^PXRMSTAC(.LSTACK)
    59         .. S LIST1=$$POP^PXRMSTAC(.LSTACK)
    60         .. I NOT S ELE=ELE_"'",NOT=0
    61         .. D LOGOP(LIST1,LIST2,ELE)
    62         .. D PUSH^PXRMSTAC(.LSTACK,LIST1)
    63         .. K ^TMP($J,LIST2)
    64         .;
    65         . I TYPE="S" D  Q
    66         .. S LNAME="LIST"_IND
    67         .. D LSEX(SEX,LNAME,.LSTACK)
    68         .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
    69         .;
    70         . I TYPE="SAA" D  Q
    71         .. S LNAME="LIST"_IND
    72         .. D LSA(SEX,NDR,.DOBS,.DOBE,LNAME)
    73         .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
    74         .. D AGEFI(.DEFARR,LNAME,SEX,"")
    75         .;
    76         S LIST1=$$POP^PXRMSTAC(.LSTACK)
    77         ;If AGE is not in the cohort logic look for any findings that set the
    78         ;frequency to 0Y and therefore remove the patient from the cohort.
    79         I PCLOG'["AGE" D AGEFI(.DEFARR,LIST1,"","0Y")
    80         ;
    81         I $G(DFNONLY) D
    82         . S DFN=0
    83         . F  S DFN=$O(^TMP($J,LIST1,1,DFN)) Q:DFN=""  D
    84         .. S ^TMP($J,PLIST,DFN)=""
    85         E  M ^TMP($J,PLIST)=^TMP($J,LIST1)
    86         K ^TMP($J,LIST1)
    87         Q
    88         ;
    89         ;==================================================
    90 AGEFI(DEFARR,LNAME,SEX,ONLYFREQ)        ;Check for patients that need to be
    91         ;added or removed because of a finding that changes the age range.
    92         N DEL,DFN,DOB,DOBE,DOBS,FILIST,FINUM,FREQ,IND,JND,LOGOP
    93         N MINAGE,MAXAGE,NUMAFI,PSEX,RANK,RANKARR,RF,TEMP,TGLIST
    94         S NUMAFI=$P(DEFARR(40),U,1)
    95         I NUMAFI=0 Q
    96         S FILIST=$P(DEFARR(40),U,2)
    97         F IND=1:1:NUMAFI D
    98         . S FINUM=$P(FILIST,";",IND)
    99         . S TEMP=$S(FINUM["FF":DEFARR(25,FINUM,0),1:DEFARR(20,FINUM,0))
    100         . S RANK=+$P(TEMP,U,5)
    101         . I RANK=0 S RANK=9999
    102         . S FREQ=$$FRQINDAY^PXRMDATE($P(TEMP,U,4))
    103         .;If there is no frequency with this rank ignore it.
    104         . I FREQ]"" S RANKARR(RANK,FREQ,FINUM)=""
    105         S IND=0,RANK=""
    106         F  S RANK=$O(RANKARR(RANK)) Q:RANK=""  D
    107         . S FREQ=""
    108         . F  S FREQ=$O(RANKARR(RANK,FREQ)) Q:FREQ=""  D
    109         .. S FINUM=0
    110         .. F  S FINUM=$O(RANKARR(RANK,FREQ,FINUM)) Q:FINUM=""  D
    111         ... S IND=IND+1,RF(IND)=FINUM
    112         I IND'=NUMAFI W !,"Error in AGEFI^PXRMPLST - Ranking failed!"
    113         ;Build a list for each age finding.
    114         F IND=1:1:NUMAFI D
    115         . S FINUM=RF(IND)
    116         . S TGLIST="AGEFI"_FINUM
    117         . S TEMP=$S(FINUM["FF":DEFARR(25,FINUM,0),1:DEFARR(20,FINUM,0))
    118         . S FREQ=$P(TEMP,U,4)
    119         . I ONLYFREQ="0Y",FREQ'="0Y" S LOGOP(IND)="~" Q
    120         . S LOGOP(IND)=$S(FREQ="0Y":"~",FREQ="":"~",1:"!")
    121         . S MINAGE=$P(TEMP,U,2)
    122         . S MAXAGE=$P(TEMP,U,3)
    123         . S DOBE=$S(MINAGE="":$$NOW^PXRMDATE,1:$$GETDOB(MINAGE,"MIN"))
    124         . S DOBS=$S(MAXAGE="":0,1:$$GETDOB(MAXAGE,"MAX"))
    125         . K ^TMP($J,TGLIST)
    126         . I FINUM=+FINUM D EVALPL^PXRMEVFI(.DEFARR,FINUM,TGLIST)
    127         . I FINUM["FF" D EVALPL^PXRMFF(.DEFARR,FINUM,TGLIST)
    128         .;Filter TGLIST based on the age range.
    129         . S DFN=$S(FREQ="0Y":$O(^TMP($J,TGLIST,1,""),-1),1:0)
    130         . F  S DFN=$O(^TMP($J,TGLIST,1,DFN)) Q:DFN=""  D
    131         .. S DEL=0
    132         ..;Reference to ^DPT DBIA #10035
    133         .. S PSEX=$P(^DPT(DFN,0),U,2),DOB=$P(^DPT(DFN,0),U,3)
    134         .. I SEX'="",PSEX'=SEX S DEL=1
    135         .. I (DOB<DOBS)!(DOB>DOBE) S DEL=1
    136         .. I DEL K ^TMP($J,TGLIST,0,DFN),^TMP($J,TGLIST,1,DFN)
    137         ;Remove patients on a list with a higher rank from all lists with
    138         ;a lower rank.
    139         F IND=1:1:NUMAFI D
    140         . F JND=IND+1:1:NUMAFI D LOGOP("AGEFI"_RF(JND),"AGEFI"_RF(IND),"~")
    141         F IND=1:1:NUMAFI D
    142         . D LOGOP(LNAME,"AGEFI"_RF(IND),LOGOP(IND))
    143         . K ^TMP($J,"AGEFI"_RF(IND))
    144         Q
    145         ;
    146         ;==================================================
    147 CFSAA(STACK)    ;Check for the first three elements on the stack being
    148         ;SEX, AGE, and &. If that is the case replace the with the "special"
    149         ;finding SAA.
    150         N EL1,EL2,EL3,SAA
    151         S SAA=0
    152         S EL1=$G(STACK(1)),EL2=$G(STACK(2)),EL3=$G(STACK(3))
    153         I EL1="SEX",EL2="AGE",EL3="&" S SAA=1
    154         I EL1="AGE",EL2="SEX",EL3="&" S SAA=1
    155         I 'SAA Q
    156         ;Create a new pseudo-element for SEX&AGE.
    157         S EL1=$$POP^PXRMSTAC(.STACK)
    158         S EL1=$$POP^PXRMSTAC(.STACK)
    159         S EL1=$$POP^PXRMSTAC(.STACK)
    160         D PUSH^PXRMSTAC(.STACK,"SAA")
    161         Q
    162         ;
    163         ;==================================================
    164 DOBR(DEFARR,NDR,DOBS,DOBE)      ;Build the date of birth range.
    165         N IND,FREQ,MINAGE,MAXAGE,TEMP
    166         S (IND,NDR)=0
    167         F  S IND=+$O(DEFARR(7,IND)) Q:IND=0  D
    168         . S TEMP=DEFARR(7,IND,0)
    169         . S FREQ=$P(TEMP,U,1)
    170         . I (FREQ="0Y")!(FREQ="") Q
    171         . S MINAGE=$P(TEMP,U,2)
    172         . S MAXAGE=$P(TEMP,U,3)
    173         . S NDR=NDR+1
    174         . S DOBE(NDR)=$S(MINAGE="":$$NOW^PXRMDATE,1:$$GETDOB(MINAGE,"MIN"))
    175         . S DOBS(NDR)=$S(MAXAGE="":0,1:$$GETDOB(MAXAGE,"MAX"))
    176         Q
    177         ;
    178         ;==================================================
    179 GENTERM(FINDING,FINUM,TERMARR)  ;Given a reminder finding generate a term
    180         ;for patient list evaluation.
    181         N IEN,IND,TEMP,TYPE
    182         S TEMP=$P(FINDING,U,1)
    183         S IEN=$P(TEMP,";",1)
    184         S TYPE=$P(TEMP,";",2)
    185         ;If the finding is a term just load the term.
    186         I TYPE="PXRMD(811.5," D TERM^PXRMLDR(IEN,.TERMARR) Q
    187         S TERMARR(0)="GENERATED"
    188         S TERMARR("IEN")=0
    189         M TERMARR(20,1)=DEFARR(20,FINUM)
    190         S TERMARR("E",TYPE,IEN,1)=""
    191         Q
    192         ;
    193         ;==================================================
    194 GETDOB(AGE,TYPE)        ;Given an age in years return the corresponding date of
    195         ;birth. If TYPE is MIN then find the date of birth that will make them
    196         ;that age. If TYPE is MAX find the last day that will make them
    197         ;that age, i.e., the next day is their birthday.
    198         N DATE,DOB
    199         S DATE=$$NOW^PXRMDATE
    200         I TYPE="MIN" S DOB=DATE-(10000*AGE)
    201         I TYPE="MAX" S DOB=DATE-(10000*(AGE+1)),DOB=$$FMADD^XLFDT(DOB,1)
    202         Q DOB
    203         ;
    204         ;==================================================
    205 LOGOP(LIST1,LIST2,LOGOP)        ;Given LIST1 and LIST2 apply the logical
    206         ;operator LOGOP to generate a new list and return it in LIST1
    207         N DFN1,DFN2
    208         I LOGOP="&" D  Q
    209         . S DFN1=""
    210         . F  S DFN1=$O(^TMP($J,LIST1,1,DFN1)) Q:DFN1=""  D
    211         .. I $D(^TMP($J,LIST2,1,DFN1)) M ^TMP($J,LIST1,1,DFN1)=^TMP($J,LIST2,1,DFN1) Q
    212         .. K ^TMP($J,LIST1,1,DFN1)
    213         ;
    214         ;"~" represents "&'".
    215         I LOGOP="~" D  Q
    216         . S DFN1=""
    217         . F  S DFN1=$O(^TMP($J,LIST1,1,DFN1)) Q:DFN1=""  D
    218         .. I $D(^TMP($J,LIST2,1,DFN1)) K ^TMP($J,LIST1,1,DFN1)
    219         ;
    220         I LOGOP="!" D
    221         . S DFN2=""
    222         . F  S DFN2=$O(^TMP($J,LIST2,1,DFN2)) Q:DFN2=""  D
    223         .. M ^TMP($J,LIST1,1,DFN2)=^TMP($J,LIST2,1,DFN2)
    224         Q
    225         ;
    226         ;==================================================
    227 LSA(SEX,NDR,DOBS,DOBE,LNAME)    ;Build a list from a SEX & AGE finding.
    228         ;Reference to ^DPT DBIA #10035
    229         N DFN,DS,IND,SEXOK
    230         F IND=1:1:NDR D
    231         . S DS=DOBS(IND)-.000001
    232         . F  S DS=$O(^DPT("ADOB",DS)) Q:(DS>DOBE(IND))!(DS="")  D
    233         .. S DFN=""
    234         .. F  S DFN=$O(^DPT("ADOB",DS,DFN)) Q:DFN=""  D
    235         ... S SEXOK=$S(SEX="":1,$D(^DPT("ASX",SEX,DFN)):1,1:0)
    236         ... I SEXOK S ^TMP($J,LNAME,1,DFN,1,"SAA")=""
    237         Q
    238         ;
    239         ;==================================================
    240 LSEX(SEX,LNAME,LSTACK)  ;Build a list from a SEX finding.
    241         ;Reference to ^DPT DBIA #10035
    242         N ELIST
    243         ;Start with the existing list to build a list based on sex.
    244         S ELIST=$$POP^PXRMSTAC(.LSTACK)
    245         D PUSH^PXRMSTAC(.LSTACK,ELIST)
    246         S DFN=0
    247         F  S DFN=$O(^TMP($J,ELIST,1,DFN)) Q:DFN=""  D
    248         . I $D(^DPT("ASX",SEX,DFN)) S ^TMP($J,LNAME,1,DFN,SEX,1)=""
    249         Q
    250         ;
     1PXRMPLST ; SLC/PKR - Build a patient list from a reminder definition. ;06/09/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Input  :  RIEN     - Reminder IEN
     5 ;          PLIST    - List returned in ^TMP($J,PLIST,DFN)
     6 ;          DFNONLY  - If true list contains only DFN information
     7 ;          PXRMDATE - Evaluation date
     8 ;===================================================
     9BLDPLST(RIEN,PLIST,DFNONLY,PXRMDATE) ;
     10 N DEFARR,DFN,DOBE,DOBS,ELE,ERROR,ERRSTR,IND,FNUM
     11 N LIST1,LIST2,LNAME,LSP,LSTACK
     12 N NDR,NOT,OPER,PCLOG,PFSTACK,SEX,TYPE
     13 ;
     14 D DEF^PXRMLDR(RIEN,.DEFARR)
     15 ;Get the cohort logic string. This has passed a validation before
     16 ;it can be selected for building patient lists so we don't need to
     17 ;check it here.
     18 S PCLOG=DEFARR(31)
     19 I PCLOG="" Q
     20 S OPER="!&~"
     21 ;Get the sex field, if PCLOG does not contain SEX set it to null.
     22 S SEX=$S(PCLOG["SEX":$P(DEFARR(0),U,9),1:"")
     23 ;If PCLOG contains age build the corresponding date of birth range(s).
     24 I PCLOG["AGE" D DOBR(.DEFARR,.NDR,.DOBS,.DOBE)
     25 ;Replace &' with ~ so the stack will be built properly.
     26 S PCLOG=$$STRREP^PXRMUTIL(PCLOG,"&'","~")
     27 D POSTFIX^PXRMSTAC(PCLOG,OPER,.PFSTACK)
     28 ;Process the logic.
     29 D CFSAA(.PFSTACK)
     30 S (IND,ERROR,LSP,LSTACK(0),NOT)=0
     31 F  Q:(IND'<PFSTACK(0))!(ERROR)  D
     32 . S IND=IND+1,ELE=PFSTACK(IND)
     33 . I ELE["'" S NOT=1
     34 . S TYPE=$S(ELE="'":"NOT",ELE["AGE":"A",ELE["FI":"FI",ELE["FF":"FF",ELE="SAA":"SAA",ELE["SEX":"S",OPER[ELE:"OP",1:"")
     35 .;
     36 . I TYPE="A" D  Q
     37 .. S LNAME="LIST"_IND
     38 .. D LSA("",NDR,.DOBS,.DOBE,LNAME)
     39 .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
     40 .. D AGEFI(.DEFARR,LNAME,SEX,"")
     41 .;
     42 . I TYPE="FI" D  Q
     43 .. S IND=IND+1,FNUM=PFSTACK(IND)
     44 .. I +FNUM'=FNUM S ERROR=1,ERRSTR="Error - having a finding not followed by a number" Q
     45 .. S LNAME="LIST"_IND
     46 .. D EVALPL^PXRMEVFI(.DEFARR,FNUM,LNAME)
     47 .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
     48 .;
     49 . I TYPE="FF" D  Q
     50 .. S IND=IND+1,FNUM=PFSTACK(IND)
     51 .. I +FNUM'=FNUM S ERROR=1,ERRSTR="Error - having a function finding not followed by a number"
     52 .. S LNAME="LIST"_IND
     53 .. D EVALPL^PXRMFF(.DEFARR,"FF"_FNUM,LNAME)
     54 .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
     55 .;
     56 . I TYPE="NOT" S NOT=1 Q
     57 .;
     58 . I TYPE="OP" D  Q
     59 .. S LIST2=$$POP^PXRMSTAC(.LSTACK)
     60 .. S LIST1=$$POP^PXRMSTAC(.LSTACK)
     61 .. I NOT S ELE=ELE_"'",NOT=0
     62 .. D LOGOP(LIST1,LIST2,ELE)
     63 .. D PUSH^PXRMSTAC(.LSTACK,LIST1)
     64 .. K ^TMP($J,LIST2)
     65 .;
     66 . I TYPE="S" D  Q
     67 .. S LNAME="LIST"_IND
     68 .. D LSEX(SEX,LNAME,.LSTACK)
     69 .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
     70 .;
     71 . I TYPE="SAA" D  Q
     72 .. S LNAME="LIST"_IND
     73 .. D LSA(SEX,NDR,.DOBS,.DOBE,LNAME)
     74 .. D PUSH^PXRMSTAC(.LSTACK,LNAME)
     75 .. D AGEFI(.DEFARR,LNAME,SEX,"")
     76 .;
     77 S LIST1=$$POP^PXRMSTAC(.LSTACK)
     78 ;If AGE is not in the cohort logic look for any findings that set the
     79 ;frequency to 0Y and therefore remove the patient from the cohort.
     80 I PCLOG'["AGE" D AGEFI(.DEFARR,LIST1,"","0Y")
     81 ;
     82 I $G(DFNONLY) D
     83 . S DFN=0
     84 . F  S DFN=$O(^TMP($J,LIST1,1,DFN)) Q:DFN=""  D
     85 .. S ^TMP($J,PLIST,DFN)=""
     86 E  M ^TMP($J,PLIST)=^TMP($J,LIST1)
     87 K ^TMP($J,LIST1)
     88 Q
     89 ;
     90 ;==================================================
     91AGEFI(DEFARR,LNAME,SEX,ONLYFREQ) ;Check for patients that need to be
     92 ;added or removed because of a finding that changes the age range.
     93 N DEL,DFN,DOB,DOBE,DOBS,FILIST,FINUM,FREQ,IND,JND,LOGOP
     94 N MINAGE,MAXAGE,NUMAFI,PSEX,RANK,RANKARR,RF,TEMP,TGLIST
     95 S NUMAFI=$P(DEFARR(40),U,1)
     96 I NUMAFI=0 Q
     97 S FILIST=$P(DEFARR(40),U,2)
     98 F IND=1:1:NUMAFI D
     99 . S FINUM=$P(FILIST,";",IND)
     100 . S TEMP=$S(FINUM["FF":DEFARR(25,FINUM,0),1:DEFARR(20,FINUM,0))
     101 . S RANK=+$P(TEMP,U,5)
     102 . I RANK=0 S RANK=9999
     103 . S FREQ=$$FRQINDAY^PXRMDATE($P(TEMP,U,4))
     104 .;If there is no frequency with this rank ignore it.
     105 . I FREQ]"" S RANKARR(RANK,FREQ,FINUM)=""
     106 S IND=0,RANK=""
     107 F  S RANK=$O(RANKARR(RANK)) Q:RANK=""  D
     108 . S FREQ=""
     109 . F  S FREQ=$O(RANKARR(RANK,FREQ)) Q:FREQ=""  D
     110 .. S FINUM=0
     111 .. F  S FINUM=$O(RANKARR(RANK,FREQ,FINUM)) Q:FINUM=""  D
     112 ... S IND=IND+1,RF(IND)=FINUM
     113 I IND'=NUMAFI W !,"Error in AGEFI^PXRMPLST - Ranking failed!"
     114 ;Build a list for each age finding.
     115 F IND=1:1:NUMAFI D
     116 . S FINUM=RF(IND)
     117 . S TGLIST="AGEFI"_FINUM
     118 . S TEMP=$S(FINUM["FF":DEFARR(25,FINUM,0),1:DEFARR(20,FINUM,0))
     119 . S FREQ=$P(TEMP,U,4)
     120 . I ONLYFREQ="0Y",FREQ'="0Y" S LOGOP(IND)="~" Q
     121 . S LOGOP(IND)=$S(FREQ="0Y":"~",FREQ="":"~",1:"!")
     122 . S MINAGE=$P(TEMP,U,2)
     123 . S MAXAGE=$P(TEMP,U,3)
     124 . S DOBE=$S(MINAGE="":$$NOW^PXRMDATE,1:$$GETDOB(MINAGE,"MIN"))
     125 . S DOBS=$S(MAXAGE="":0,1:$$GETDOB(MAXAGE,"MAX"))
     126 . K ^TMP($J,TGLIST)
     127 . I FINUM=+FINUM D EVALPL^PXRMEVFI(.DEFARR,FINUM,TGLIST)
     128 . I FINUM["FF" D EVALPL^PXRMFF(.DEFARR,FINUM,TGLIST)
     129 .;Filter TGLIST based on the age range.
     130 . S DFN=$S(FREQ="0Y":$O(^TMP($J,TGLIST,1,""),-1),1:0)
     131 . F  S DFN=$O(^TMP($J,TGLIST,1,DFN)) Q:DFN=""  D
     132 .. S DEL=0
     133 ..;Reference to ^DPT DBIA #10035
     134 .. S PSEX=$P(^DPT(DFN,0),U,2),DOB=$P(^DPT(DFN,0),U,3)
     135 .. I SEX'="",PSEX'=SEX S DEL=1
     136 .. I (DOB<DOBS)!(DOB>DOBE) S DEL=1
     137 .. I DEL K ^TMP($J,TGLIST,0,DFN),^TMP($J,TGLIST,1,DFN)
     138 ;Remove patients on a list with a higher rank from all lists with
     139 ;a lower rank.
     140 F IND=1:1:NUMAFI D
     141 . F JND=IND+1:1:NUMAFI D LOGOP("AGEFI"_RF(JND),"AGEFI"_RF(IND),"~")
     142 F IND=1:1:NUMAFI D
     143 . D LOGOP(LNAME,"AGEFI"_RF(IND),LOGOP(IND))
     144 . K ^TMP($J,"AGEFI"_RF(IND))
     145 Q
     146 ;
     147 ;==================================================
     148CFSAA(STACK) ;Check for the first three elements on the stack being
     149 ;SEX, AGE, and &. If that is the case replace the with the "special"
     150 ;finding SAA.
     151 N EL1,EL2,EL3,SAA
     152 S SAA=0
     153 S EL1=$G(STACK(1)),EL2=$G(STACK(2)),EL3=$G(STACK(3))
     154 I EL1="SEX",EL2="AGE",EL3="&" S SAA=1
     155 I EL1="AGE",EL2="SEX",EL3="&" S SAA=1
     156 I 'SAA Q
     157 ;Create a new pseudo-element for SEX&AGE.
     158 S EL1=$$POP^PXRMSTAC(.STACK)
     159 S EL1=$$POP^PXRMSTAC(.STACK)
     160 S EL1=$$POP^PXRMSTAC(.STACK)
     161 D PUSH^PXRMSTAC(.STACK,"SAA")
     162 Q
     163 ;
     164 ;==================================================
     165DOBR(DEFARR,NDR,DOBS,DOBE) ;Build the date of birth range.
     166 N IND,FREQ,MINAGE,MAXAGE,TEMP
     167 S (IND,NDR)=0
     168 F  S IND=+$O(DEFARR(7,IND)) Q:IND=0  D
     169 . S TEMP=DEFARR(7,IND,0)
     170 . S FREQ=$P(TEMP,U,1)
     171 . I (FREQ="0Y")!(FREQ="") Q
     172 . S MINAGE=$P(TEMP,U,2)
     173 . S MAXAGE=$P(TEMP,U,3)
     174 . S NDR=NDR+1
     175 . S DOBE(NDR)=$S(MINAGE="":$$NOW^PXRMDATE,1:$$GETDOB(MINAGE,"MIN"))
     176 . S DOBS(NDR)=$S(MAXAGE="":0,1:$$GETDOB(MAXAGE,"MAX"))
     177 Q
     178 ;
     179 ;==================================================
     180GENTERM(FINDING,FINUM,TERMARR) ;Given a reminder finding generate a term
     181 ;for patient list evaluation.
     182 N IEN,IND,TEMP,TYPE
     183 S TEMP=$P(FINDING,U,1)
     184 S IEN=$P(TEMP,";",1)
     185 S TYPE=$P(TEMP,";",2)
     186 ;If the finding is a term just load the term.
     187 I TYPE="PXRMD(811.5," D TERM^PXRMLDR(IEN,.TERMARR) Q
     188 S TERMARR(0)="GENERATED"
     189 S TERMARR("IEN")=0
     190 M TERMARR(20,1)=DEFARR(20,FINUM)
     191 S TERMARR("E",TYPE,IEN,1)=""
     192 Q
     193 ;
     194 ;==================================================
     195GETDOB(AGE,TYPE) ;Given an age in years return the corresponding date of
     196 ;birth. If TYPE is MIN then find the date of birth that will make them
     197 ;that age. If TYPE is MAX find the last day that will make them
     198 ;that age, i.e., the next day is their birthday.
     199 N DATE,DOB
     200 S DATE=$$NOW^PXRMDATE
     201 I TYPE="MIN" S DOB=DATE-(10000*AGE)
     202 I TYPE="MAX" S DOB=DATE-(10000*(AGE+1)),DOB=$$FMADD^XLFDT(DOB,1)
     203 Q DOB
     204 ;
     205 ;==================================================
     206LOGOP(LIST1,LIST2,LOGOP) ;Given LIST1 and LIST2 apply the logical
     207 ;operator LOGOP to generate a new list and return it in LIST1
     208 N DFN1,DFN2
     209 I LOGOP="&" D  Q
     210 . S DFN1=""
     211 . F  S DFN1=$O(^TMP($J,LIST1,1,DFN1)) Q:DFN1=""  D
     212 .. I $D(^TMP($J,LIST2,1,DFN1)) M ^TMP($J,LIST1,1,DFN1)=^TMP($J,LIST2,1,DFN1) Q
     213 .. K ^TMP($J,LIST1,1,DFN1)
     214 ;
     215 ;"~" represents "&'".
     216 I LOGOP="~" D  Q
     217 . S DFN1=""
     218 . F  S DFN1=$O(^TMP($J,LIST1,1,DFN1)) Q:DFN1=""  D
     219 .. I $D(^TMP($J,LIST2,1,DFN1)) K ^TMP($J,LIST1,1,DFN1)
     220 ;
     221 I LOGOP="!" D
     222 . S DFN2=""
     223 . F  S DFN2=$O(^TMP($J,LIST2,1,DFN2)) Q:DFN2=""  D
     224 .. M ^TMP($J,LIST1,1,DFN2)=^TMP($J,LIST2,1,DFN2)
     225 Q
     226 ;
     227 ;==================================================
     228LSA(SEX,NDR,DOBS,DOBE,LNAME) ;Build a list from a SEX & AGE finding.
     229 ;Reference to ^DPT DBIA #10035
     230 N DFN,DS,IND,SEXOK
     231 F IND=1:1:NDR D
     232 . S DS=DOBS(IND)-.1
     233 . F  S DS=$O(^DPT("ADOB",DS)) Q:(DS>DOBE(IND))!(DS="")  D
     234 .. S DFN=""
     235 .. F  S DFN=$O(^DPT("ADOB",DS,DFN)) Q:DFN=""  D
     236 ... S SEXOK=$S(SEX="":1,$D(^DPT("ASX",SEX,DFN)):1,1:0)
     237 ... I SEXOK S ^TMP($J,LNAME,1,DFN,1,"SAA")=""
     238 Q
     239 ;
     240 ;==================================================
     241LSEX(SEX,LNAME,LSTACK) ;Build a list from a SEX finding.
     242 ;Reference to ^DPT DBIA #10035
     243 N ELIST
     244 ;Start with the existing list to build a list based on sex.
     245 S ELIST=$$POP^PXRMSTAC(.LSTACK)
     246 D PUSH^PXRMSTAC(.LSTACK,ELIST)
     247 S DFN=0
     248 F  S DFN=$O(^TMP($J,ELIST,1,DFN)) Q:DFN=""  D
     249 . I $D(^DPT("ASX",SEX,DFN)) S ^TMP($J,LNAME,1,DFN,SEX,1)=""
     250 Q
     251 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPTD2.m

    r613 r623  
    1 PXRMPTD2        ; SLC/PKR/PJH - Reminder Inquiry print template routines.;03/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;================================================
    4 DATE(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD,FILENUM,FLG)      ;Standard DATE
    5         N DATE,X
    6         S DATE=$P($G(FIND0),U,PIECE)
    7         I DATE'="" D
    8         .S DATE=$$FMTE^XLFDT(DATE,"5Z"),X=$$RJ^XLFSTR(TITLE,RJC,PAD),X=X_" "_DATE
    9         .D ^DIWP
    10         Q
    11         ;
    12         ;================================================
    13 ENTRYNAM(VPTR)  ;Given the variable pointer return the entry name. The
    14         ;variable pointer list contains the information necessary to do the
    15         ;look up.
    16         N IEN,FILENUM,NAME,ROOT
    17         I VPTR="" Q ""
    18         S IEN=$P(VPTR,";",1),ROOT=$P(VPTR,";",2),FILENUM=$P(PXRMFVPL(ROOT),U,1)
    19         S NAME=$$GET1^DIQ(FILENUM,IEN,.01,"","","")
    20         Q NAME
    21         ;
    22         ;================================================
    23 FREQ(FREQ)      ;Format frequency.
    24         I FREQ=-1 Q "Cannot be determined"
    25         I +FREQ=0 Q FREQ_" - Not indicated"
    26         I FREQ="99Y" Q "99Y - Once"
    27         Q +FREQ_($S(FREQ?1N.N1"D":" day",FREQ?1N.N1"M":" month",FREQ?1N.N1"Y":" year",1:""))_$S(+FREQ>1:"s",1:"")
    28         ;
    29         ;================================================
    30 FTYPE(VPTR,CNT) ;Return finding type.
    31         N FTYPE,ROOT
    32         I VPTR="" Q "UNDEFINED?"
    33         S ROOT=$P(VPTR,";",2)
    34         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
    35         S FTYPE=$S(CNT=1:$P(PXRMFVPL(ROOT),U,4),1:$P(PXRMFVPL(ROOT),U,2))
    36         Q FTYPE
    37         ;
    38         ;================================================
    39 GENFREQ(PXF0)   ;Print age range frequency set for findings.
    40         N PXF,PXW,PXAMIN,PXAMAX
    41         S PXF=$P(PXF0,U,4)
    42         I PXF="" Q ""
    43         S PXAMIN=$P(PXF0,U,2),PXAMAX=$P(PXF0,U,3)
    44         S PXW=$$FREQ(PXF)
    45         S PXW=PXW_$$FMTAGE^PXRMAGE(PXAMIN,PXAMAX)
    46         Q PXW
    47         ;
    48         ;================================================
    49 GENIEN(FINDING) ;Return internal entry number for findings.
    50         N F0,IEN,PREFIX,ROOT,VPTR
    51         S ROOT="^PXD(811.9,D0,20,FINDING,0)"
    52         S F0=@ROOT
    53         S VPTR=$P(F0,U,1)
    54         I VPTR="" Q "UNDEFINED"
    55         S IEN=$P(VPTR,";",1),ROOT=$P(VPTR,";",2)
    56         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
    57         S VPTR=PXRMFVPL(ROOT)
    58         S PREFIX=$P(VPTR,U,4)
    59         Q " (FI("_+FINDING_")="_PREFIX_"("_IEN_"))"
    60         ;
     1PXRMPTD2 ; SLC/PKR/PJH - Reminder Inquiry print template routines.;10/07/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;================================================
     4DATE(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD,FILENUM,FLG) ;Standard DATE
     5 N DATE,X
     6 S DATE=$P($G(FIND0),U,PIECE)
     7 I DATE'="" D
     8 .S DATE=$$FMTE^XLFDT(DATE,"D"),X=$$RJ^XLFSTR(TITLE,RJC,PAD),X=X_" "_DATE
     9 .D ^DIWP
     10 Q
     11 ;
     12 ;================================================
     13ENTRYNAM(VPTR) ;Given the variable pointer return the entry name. The
     14 ;variable pointer list contains the information necessary to do the
     15 ;look up.
     16 N IEN,FILENUM,NAME,ROOT
     17 I VPTR="" Q ""
     18 S IEN=$P(VPTR,";",1),ROOT=$P(VPTR,";",2),FILENUM=$P(PXRMFVPL(ROOT),U,1)
     19 S NAME=$$GET1^DIQ(FILENUM,IEN,.01,"","","")
     20 Q NAME
     21 ;
     22 ;================================================
     23FREQ(FREQ) ;Format frequency.
     24 I FREQ=-1 Q "Cannot be determined"
     25 I +FREQ=0 Q FREQ_" - Not indicated"
     26 I FREQ="99Y" Q "99Y - Once"
     27 Q +FREQ_($S(FREQ?1N.N1"D":" day",FREQ?1N.N1"M":" month",FREQ?1N.N1"Y":" year",1:""))_$S(+FREQ>1:"s",1:"")
     28 ;
     29 ;================================================
     30FTYPE(VPTR,CNT) ;Return finding type.
     31 N FTYPE,ROOT
     32 I VPTR="" Q "UNDEFINED?"
     33 S ROOT=$P(VPTR,";",2)
     34 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
     35 S FTYPE=$S(CNT=1:$P(PXRMFVPL(ROOT),U,4),1:$P(PXRMFVPL(ROOT),U,2))
     36 Q FTYPE
     37 ;
     38 ;================================================
     39GENFREQ(PXF0) ;Print age range frequency set for findings.
     40 N PXF,PXW,PXAMIN,PXAMAX
     41 S PXF=$P(PXF0,U,4)
     42 I PXF="" Q ""
     43 S PXAMIN=$P(PXF0,U,2),PXAMAX=$P(PXF0,U,3)
     44 S PXW=$$FREQ(PXF)
     45 S PXW=PXW_$$FMTAGE^PXRMAGE(PXAMIN,PXAMAX)
     46 Q PXW
     47 ;
     48 ;================================================
     49GENIEN(FINDING) ;Return internal entry number for findings.
     50 N F0,IEN,PREFIX,ROOT,VPTR
     51 S ROOT="^PXD(811.9,D0,20,FINDING,0)"
     52 S F0=@ROOT
     53 S VPTR=$P(F0,U,1)
     54 I VPTR="" Q "UNDEFINED"
     55 S IEN=$P(VPTR,";",1),ROOT=$P(VPTR,";",2)
     56 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
     57 S VPTR=PXRMFVPL(ROOT)
     58 S PREFIX=$P(VPTR,U,4)
     59 Q " (FI("_+FINDING_")="_PREFIX_"("_IEN_"))"
     60 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPTDF.m

    r613 r623  
    1 PXRMPTDF        ; SLC/PKR/PJH - Reminder Inquiry print template routines. ;06/07/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;================================================
    5 PFIND   ;Print the reminder definition finding multiple.
    6         N DIWF,FIELD,FILENUM,FINDING,FIND0,FIND3,FINDNAM,FL,HFCAT,HFIEN
    7         N IEN1,IND,INT,LEN,PAD,PADS,PARRAY,RJC,RFIND,RTERM,SCNT,SIEN,STAT0
    8         ;If called by a FileMan print build the variable pointer list.
    9         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
    10         ;No printing is done by PFIND it accumulates all output using ^DIWP.
    11         ;The print template outputs the text with ^DIWW.
    12         ;Because of the way DIWP works we need to format all the found and
    13         ;not found text first and store it in ^TMP.
    14         K ^TMP($J,"W")
    15         S FILENUM="811.902"
    16         S RJC=30,PAD=" ",PADS=""
    17         F IND=1:1:(RJC+2) S PADS=PADS_PAD
    18         S FINDING=0
    19         F  S FINDING=$O(^PXD(811.9,D0,20,FINDING)) Q:+FINDING=0  D
    20         .D WPFORMAT(FINDING,20,RJC,1)
    21         .D WPFORMAT(FINDING,20,RJC,2)
    22         K ^UTILITY($J,"W")
    23         S FINDING=0
    24         F  S FINDING=$O(^PXD(811.9,D0,25,FINDING)) Q:+FINDING=0  D
    25         .D WPFORMAT(FINDING,25,RJC,1)
    26         .D WPFORMAT(FINDING,25,RJC,2)
    27         S DIWF="C80",DIWL=2
    28         K ^UTILITY($J,"W")
    29         S FINDING=0
    30         F  S FINDING=$O(^PXD(811.9,D0,20,FINDING)) Q:+FINDING=0  D
    31         .S FIND0=^PXD(811.9,D0,20,FINDING,0)
    32         .S FIELD=$P(FIND0,U,1)
    33         .S RTERM=FIELD
    34         .S X=" "
    35         .D ^DIWP
    36         .S FINDNAM=$$ENTRYNAM^PXRMPTD2(FIELD)
    37         .I FINDNAM="" S FINDNAM="?"
    38         .S X=$$RJ^XLFSTR("---- Begin:",12,PAD)
    39         .S X=X_" "_FINDNAM
    40         .S RFIND=$$GENIEN^PXRMPTD2(FINDING)
    41         .S X=X_" "_RFIND_" "
    42         .S LEN=(75-$L(X))
    43         .F INT=1:1:LEN S X=X_"-"
    44         .D ^DIWP
    45         .;
    46         .S X=$$RJ^XLFSTR("Finding Type:",RJC,PAD)
    47         .S X=X_" "_$$FTYPE^PXRMPTD2(FIELD,0)
    48         .D ^DIWP
    49         .I RFIND["HF" D
    50         ..S HFIEN=$P($P($P(RFIND,"HF",2),"(",2),")")
    51         ..S HFCAT=$P($G(^AUTTHF(HFIEN,0)),U,3)
    52         ..S HFCAT=$S(HFCAT="":"UNDEFINED",1:$P($G(^AUTTHF(HFCAT,0)),U,1))
    53         ..S X=$$RJ^XLFSTR("Health Factor Category:",RJC,PAD)
    54         ..S X=X_" "_HFCAT
    55         ..D ^DIWP
    56         .;
    57         .S FIELD=$P(FIND0,U,4)
    58         .I $L(FIELD)>0 D
    59         ..S X=$$RJ^XLFSTR("Match Frequency/Age:",RJC,PAD)
    60         ..S X=X_" "_$$GENFREQ^PXRMPTD2(FIND0)
    61         ..D ^DIWP
    62         .;
    63         .D SFDISP(FIND0,5,6,"Rank Frequency:",RJC,PAD,FILENUM)
    64         .D SFDISP(FIND0,6,7,"Use in Resolution Logic:",RJC,PAD,FILENUM)
    65         .D SFDISP(FIND0,7,8,"Use in Patient Cohort Logic:",RJC,PAD,FILENUM)
    66         .D DATE^PXRMPTD2(FIND0,8,9,"Beginning Date/Time:",RJC,PAD,FILENUM)
    67         .D DATE^PXRMPTD2(FIND0,11,12,"Ending Date/Time:",RJC,PAD,FILENUM)
    68         .D SFDISP(FIND0,14,17,"Occurrence Count:",RJC,PAD,FILENUM)
    69         .D SFDISP(FIND0,9,10,"Use Inactive Problems:",RJC,PAD,FILENUM)
    70         .D SFDISP(FIND0,10,11,"Within Category Rank:",RJC,PAD,FILENUM)
    71         .D SFDISP(FIND0,16,28,"Include Visit Data:",RJC,PAD,FILENUM)
    72         .D SFDISP(FIND0,12,13,"MH Scale:",RJC,PAD,FILENUM)
    73         .D SFDISP(FIND0,13,16,"Rx Type:",RJC,PAD,FILENUM)
    74         .D SFDISP(FIND0,15,27,"Use Start Date:",RJC,PAD,FILENUM)
    75         .I $D(^PXD(811.9,D0,20,FINDING,5,0))=1 D
    76         ..S (SCNT,SIEN)=0
    77         ..F  S SIEN=$O(^PXD(811.9,D0,20,FINDING,5,SIEN)) Q:SIEN=""  D
    78         ...S STAT0=$G(^PXD(811.9,D0,20,FINDING,5,SIEN,0))
    79         ...D STATUS(STAT0,"Status List:",RJC) S SCNT=SCNT+1
    80         .S FIND0=$G(^PXD(811.9,D0,20,FINDING,3))
    81         .D SFDISP(FIND0,1,14,"Condition:",RJC,PAD,FILENUM)
    82         .D SFDISP(FIND0,2,15,"Condition Case Sensitive:",RJC,PAD,FILENUM)
    83         .D SFDISP(FIND0,3,18,"Use Status/Cond in Search:",RJC,PAD,FILENUM)
    84         .I $G(^PXD(811.9,D0,20,FINDING,15))'="" D
    85         ..S X=$$RJ^XLFSTR("Computed Finding Parameter:",RJC,PAD)
    86         ..S X=X_" "_$G(^PXD(811.9,D0,20,FINDING,15))
    87         ..D ^DIWP
    88         .D WPOUT(FINDING,20,"Found Text:",RJC,PAD,PADS,1)
    89         .D WPOUT(FINDING,20,"Not Found Text:",RJC,PAD,PADS,2)
    90         .I RTERM["PXRMD(811.5" S IEN1=$P(RTERM,";") D RTERM
    91         .S X=$$RJ^XLFSTR("---- End:",10,PADS)
    92         .S X=X_" "_FINDNAM_" "
    93         .S LEN=(75-$L(X))
    94         .F INT=1:1:(LEN) S X=X_"-"
    95         .D ^DIWP
    96         .S X=" "
    97         .D ^DIWP
    98         ;
    99         ;Function Findings
    100         I +$P($G(^PXD(811.9,D0,25,0)),U,4)>0 D
    101         .S X=" "
    102         .D ^DIWP
    103         .S X="Function Findings:"
    104         .D ^DIWP
    105         .;Build the list of findings for this reminder.
    106         .D BLDFLST^PXRMPTL(D0,.FL)
    107         .S FILENUM="811.925",FINDING=0
    108         .F  S FINDING=$O(^PXD(811.9,D0,25,FINDING)) Q:+FINDING=0  D
    109         ..S FIND0=$G(^PXD(811.9,D0,25,FINDING,0))
    110         ..S FIND3=$G(^PXD(811.9,D0,25,FINDING,3))
    111         ..I FIND3="" Q
    112         ..S FIELD=$P(FIND0,U,1)
    113         ..S FINDNAM="FF("_FIELD_")"
    114         ..S X=" "
    115         ..D ^DIWP
    116         ..S X=$$RJ^XLFSTR("---- Begin:",12,PAD)
    117         ..S X=X_" "_FINDNAM
    118         ..S LEN=(75-$L(X))
    119         ..F INT=1:1:LEN S X=X_"-"
    120         ..D ^DIWP
    121         ..;
    122         ..D SFDISP(FIND3,1,3,"Function String:",RJC,PAD,FILENUM)
    123         ..S X="     Expanded Function String:" D ^DIWP
    124         ..D DISLOGF^PXRMPTL(D0,FINDING,.FL,.PARRAY)
    125         ..S INT=0
    126         ..F  S INT=$O(PARRAY(INT)) Q:'INT  D
    127         ...S X=$J("",6)_PARRAY(INT) D ^DIWP
    128         ..;
    129         ..S FIELD=$P(FIND0,U,4)
    130         ..I $L(FIELD)>0 D
    131         ...S X=$$RJ^XLFSTR("Match Frequency/Age:",RJC,PAD)
    132         ...S X=X_" "_$$GENFREQ^PXRMPTD2(FIND0)
    133         ...D ^DIWP
    134         ..;
    135         ..D SFDISP(FIND0,5,10,"Rank Frequency:",RJC,PAD,FILENUM)
    136         ..D SFDISP(FIND0,6,11,"Use in Resolution Logic:",RJC,PAD,FILENUM)
    137         ..D SFDISP(FIND0,7,12,"Use in Patient Cohort Logic:",RJC,PAD,FILENUM)
    138         ..;
    139         ..D WPOUT(FINDING,25,"Found Text:",RJC,PAD,PADS,1)
    140         ..D WPOUT(FINDING,25,"Not Found Text:",RJC,PAD,PADS,2)
    141         ..S X=$$RJ^XLFSTR("---- End:",10,PADS)
    142         ..S X=X_" "_FINDNAM_" "
    143         ..S LEN=(75-$L(X))
    144         ..F INT=1:1:(LEN) S X=X_"-"
    145         ..D ^DIWP
    146         ..S X=" "
    147         ..D ^DIWP
    148         ;
    149         K ^TMP($J,"W")
    150         ;^UTILITY($J,"W") will be killed by ^DIWW in the print template.
    151         Q
    152         ;
    153         ;================================================
    154 RTERM   ;Reminder Term
    155         N CNT,RJT,SCNT,SIEN,STAT0,TERM,TERM3,TERMNUM,TERMS
    156         S CNT=0,RJT=RJC+10,TERMNUM="811.52"
    157         S TERMS=0 F  S TERMS=$O(^PXRMD(811.5,IEN1,20,TERMS)) Q:+TERMS=0  D
    158         .S TERM=$G(^PXRMD(811.5,IEN1,20,TERMS,0))
    159         .S TERM3=$G(^PXRMD(811.5,IEN1,20,TERMS,3))
    160         .D SFDISP(TERM,1,.01,"Mapped Finding Item:",RJT,PAD,TERMNUM,CNT)
    161         .D SFDISP(TERM,8,9,"Beginning Date/Time:",RJT,PAD,TERMNUM)
    162         .D SFDISP(TERM,9,10,"Use Inactive Problems:",RJT,PAD,TERMNUM)
    163         .D SFDISP(TERM,11,12,"Ending Date/Time:",RJT,PAD,TERMNUM)
    164         .D SFDISP(TERM,10,11,"Within Category Rank:",RJT,PAD,TERMNUM)
    165         .D SFDISP(TERM,12,13,"MH Scale:",RJT,PAD,TERMNUM)
    166         .D SFDISP(TERM,13,16,"RX Type:",RJT,PAD,TERMNUM)
    167         .D SFDISP(TERM,14,17,"Occurrence Count:",RJT,PAD,TERMNUM)
    168         .I $D(^PXRMD(811.5,IEN1,20,TERMS,5,0))=1 D
    169         ..S (SCNT,SIEN)=0
    170         ..F  S SIEN=$O(^PXRMD(811.5,IEN1,20,TERMS,5,SIEN)) Q:SIEN=""  D
    171         ...S STAT0=$G(^PXRMD(811.5,IEN1,20,TERMS,5,SIEN,0))
    172         ...D STATUS(STAT0,"Status List:",RJT) S SCNT=SCNT+1
    173         .D SFDISP(TERM3,1,14,"Condition:",RJT,PAD,TERMNUM,1)
    174         .D SFDISP(TERM3,2,15,"Condition Case Sensitive:",RJT,PAD,TERMNUM)
    175         .D SFDISP(TERM3,3,18,"Use Status/Cond in Search:",RJT,PAD,TERMNUM)
    176         .I $G(^PXRMD(811.5,IEN1,20,TERMS,15))'="" D
    177         ..S X=$$RJ^XLFSTR("Computed Finding Parameter:",RJT,PAD)
    178         ..S X=X_" "_$G(^PXRMD(811.5,IEN1,20,TERMS,15))
    179         ..D ^DIWP
    180         .S X=""
    181         .D ^DIWP
    182         .S CNT=CNT+1
    183         I CNT=0 D  Q
    184         .S X=$$RJ^XLFSTR("RT Mapped Finding:",RJC,PAD)
    185         .S X=X_" No Reminder Finding Found"
    186         .D ^DIWP
    187         Q
    188         ;
    189         ;================================================
    190 SFDISP(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD,FILENUM,FLG)    ;Standard finding
    191         ;multiple field display.
    192         N FIELD,HFCAT,HFIEN,NAME,TYPE,X
    193         S NAME=""
    194         S FIELD=$P(FIND0,U,PIECE)
    195         I (PIECE=1)&(FLDNUM=".01")&(FILENUM="811.52") D
    196         .I FLG=0 D
    197         ..S X=""
    198         ..D ^DIWP
    199         ..S RTERM=$P($P(RFIND,"=",2),")")_")"
    200         ..S X=$$RJ^XLFSTR("Mapped Findings:",40)
    201         ..D ^DIWP
    202         .S TYPE=$$FTYPE^PXRMPTD2(FIELD,1),NAME=$$ENTRYNAM^PXRMPTD2(FIELD)
    203         .S X=$$RJ^XLFSTR(TITLE,RJC,PAD)
    204         .S X=X_" "_TYPE_"."_NAME
    205         .D ^DIWP
    206         .I TYPE="HF" D
    207         ..S HFIEN=$P(TERM,";")
    208         ..S HFCAT=$P($G(^AUTTHF(HFIEN,0)),U,3)
    209         ..S HFCAT=$P($G(^AUTTHF(HFCAT,0)),U)
    210         ..S X=$$RJ^XLFSTR("Health Factor Category:",RJC,PAD)
    211         ..S X=X_" "_HFCAT
    212         ..D ^DIWP
    213         I NAME'="" Q
    214         I $L(FIELD)>0 D
    215         .S X=$$RJ^XLFSTR(TITLE,RJC,PAD)
    216         .S X=X_" "_$$EXTERNAL^DILFD(FILENUM,FLDNUM,"",FIELD,"")
    217         .I FLDNUM=13 S X=X_" - "_$$SPECIAL(FIND0,FIELD)
    218         .D ^DIWP
    219         Q
    220         ;
    221         ;================================================
    222 SPECIAL(FIND0,FIELD)    ;Special output for certain fields.
    223         N FINDING,GLOBAL,IEN
    224         S FINDING=$P(FIND0,U,1)
    225         S IEN=$P(FINDING,";",1)
    226         S GLOBAL=$P(FINDING,";",2)
    227         I GLOBAL="YTT(601.71," Q $$SCNAME^PXRMMH(IEN,FIELD)
    228         Q ""
    229         ;
    230         ;================================================
    231 STATUS(STAT0,TITLE,SPACE)       ;
    232         I $L(STAT0)>0 D
    233         .I SCNT=0 S X=$$RJ^XLFSTR(TITLE,SPACE,PAD)
    234         .I SCNT>0 S X=$$RJ^XLFSTR("",SPACE,PAD)
    235         .S X=X_" "_STAT0
    236         .D ^DIWP
    237         Q
    238         ;
    239         ;================================================
    240 WPFORMAT(FINDING,NODE,RJC,INDEX)        ;Format found/not found word processing text.
    241         I '$D(^PXD(811.9,D0,NODE,FINDING,INDEX,1,0)) Q
    242         ;Save the title using the current format for DIWP.
    243         N DIWF,DIWL,DIWR,IND,NLINES,SC,X
    244         K ^UTILITY($J,"W")
    245         S DIWF="|",DIWL=RJC+2,DIWR=78
    246         S IND=0
    247         F  S IND=$O(^PXD(811.9,D0,NODE,FINDING,INDEX,IND)) Q:+IND=0  D
    248         .S X=$G(^PXD(811.9,D0,NODE,FINDING,INDEX,IND,0))
    249         .D ^DIWP
    250         ;Find where this stuff went.
    251         S SC=$O(^UTILITY($J,"W",""))
    252         ;Save into ^TMP.
    253         S NLINES=^UTILITY($J,"W",SC)
    254         S ^TMP($J,"W",FINDING,NODE,INDEX)=NLINES
    255         F IND=1:1:NLINES D
    256         .S ^TMP($J,"W",FINDING,NODE,INDEX,IND)=^UTILITY($J,"W",SC,IND,0)
    257         K ^UTILITY($J,"W")
    258         Q
    259         ;
    260         ;================================================
    261 WPOUT(FINDING,NODE,TITLE,RJC,PAD,PADS,INDEX)    ;Output found/not found word processing
    262         ;text.
    263         I $D(^TMP($J,"W",FINDING,NODE,INDEX)) D
    264         .N IND,X
    265         .S X=$$RJ^XLFSTR(TITLE,RJC,PAD)_" "_^TMP($J,"W",FINDING,NODE,INDEX,1)
    266         .D ^DIWP
    267         .F IND=2:1:^TMP($J,"W",FINDING,NODE,INDEX) D
    268         ..S X=PADS_^TMP($J,"W",FINDING,NODE,INDEX,IND)
    269         ..D ^DIWP
    270         Q
    271         ;
     1PXRMPTDF ; SLC/PKR/PJH - Reminder Inquiry print template routines. ;01/30/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;================================================
     5PFIND ;Print the reminder definition finding multiple.
     6 N DIWF,FIELD,FILENUM,FINDING,FIND0,FIND3,FINDNAM,FL,HFCAT,HFIEN
     7 N IEN1,IND,INT,LEN,PAD,PADS,PARRAY,RJC,RFIND,RTERM,SCNT,SIEN,STAT0
     8 ;If called by a FileMan print build the variable pointer list.
     9 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.902,.01,.PXRMFVPL)
     10 ;No printing is done by PFIND it accumulates all output using ^DIWP.
     11 ;The print template outputs the text with ^DIWW.
     12 ;Because of the way DIWP works we need to format all the found and
     13 ;not found text first and store it in ^TMP.
     14 K ^TMP($J,"W")
     15 S FILENUM="811.902"
     16 S RJC=30,PAD=" ",PADS=""
     17 F IND=1:1:(RJC+2) S PADS=PADS_PAD
     18 S FINDING=0
     19 F  S FINDING=$O(^PXD(811.9,D0,20,FINDING)) Q:+FINDING=0  D
     20 .D WPFORMAT(FINDING,20,RJC,1)
     21 .D WPFORMAT(FINDING,20,RJC,2)
     22 K ^UTILITY($J,"W")
     23 S FINDING=0
     24 F  S FINDING=$O(^PXD(811.9,D0,25,FINDING)) Q:+FINDING=0  D
     25 .D WPFORMAT(FINDING,25,RJC,1)
     26 .D WPFORMAT(FINDING,25,RJC,2)
     27 S DIWF="C80",DIWL=2
     28 K ^UTILITY($J,"W")
     29 S FINDING=0
     30 F  S FINDING=$O(^PXD(811.9,D0,20,FINDING)) Q:+FINDING=0  D
     31 .S FIND0=^PXD(811.9,D0,20,FINDING,0)
     32 .S FIELD=$P(FIND0,U,1)
     33 .S RTERM=FIELD
     34 .S X=" "
     35 .D ^DIWP
     36 .S FINDNAM=$$ENTRYNAM^PXRMPTD2(FIELD)
     37 .I FINDNAM="" S FINDNAM="?"
     38 .S X=$$RJ^XLFSTR("---- Begin:",12,PAD)
     39 .S X=X_" "_FINDNAM
     40 .S RFIND=$$GENIEN^PXRMPTD2(FINDING)
     41 .S X=X_" "_RFIND_" "
     42 .S LEN=(75-$L(X))
     43 .F INT=1:1:LEN S X=X_"-"
     44 .D ^DIWP
     45 .;
     46 .S X=$$RJ^XLFSTR("Finding Type:",RJC,PAD)
     47 .S X=X_" "_$$FTYPE^PXRMPTD2(FIELD,0)
     48 .D ^DIWP
     49 .I RFIND["HF" D
     50 ..S HFIEN=$P($P($P(RFIND,"HF",2),"(",2),")")
     51 ..S HFCAT=$P($G(^AUTTHF(HFIEN,0)),U,3)
     52 ..S HFCAT=$S(HFCAT="":"UNDEFINED",1:$P($G(^AUTTHF(HFCAT,0)),U,1))
     53 ..S X=$$RJ^XLFSTR("Health Factor Category:",RJC,PAD)
     54 ..S X=X_" "_HFCAT
     55 ..D ^DIWP
     56 .;
     57 .S FIELD=$P(FIND0,U,4)
     58 .I $L(FIELD)>0 D
     59 ..S X=$$RJ^XLFSTR("Match Frequency/Age:",RJC,PAD)
     60 ..S X=X_" "_$$GENFREQ^PXRMPTD2(FIND0)
     61 ..D ^DIWP
     62 .;
     63 .D SFDISP(FIND0,5,6,"Rank Frequency:",RJC,PAD,FILENUM)
     64 .D SFDISP(FIND0,6,7,"Use in Resolution Logic:",RJC,PAD,FILENUM)
     65 .D SFDISP(FIND0,7,8,"Use in Patient Cohort Logic:",RJC,PAD,FILENUM)
     66 .D DATE^PXRMPTD2(FIND0,8,9,"Beginning Date/Time:",RJC,PAD,FILENUM)
     67 .D DATE^PXRMPTD2(FIND0,11,12,"Ending Date/Time:",RJC,PAD,FILENUM)
     68 .D SFDISP(FIND0,14,17,"Occurrence Count:",RJC,PAD,FILENUM)
     69 .D SFDISP(FIND0,9,10,"Use Inactive Problems:",RJC,PAD,FILENUM)
     70 .D SFDISP(FIND0,10,11,"Within Category Rank:",RJC,PAD,FILENUM)
     71 .D SFDISP(FIND0,16,28,"Include Visit Data:",RJC,PAD,FILENUM)
     72 .D SFDISP(FIND0,12,13,"MH Scale:",RJC,PAD,FILENUM)
     73 .D SFDISP(FIND0,13,16,"Rx Type:",RJC,PAD,FILENUM)
     74 .D SFDISP(FIND0,15,27,"Use Start Date:",RJC,PAD,FILENUM)
     75 .I $D(^PXD(811.9,D0,20,FINDING,5,0))=1 D
     76 ..S (SCNT,SIEN)=0
     77 ..F  S SIEN=$O(^PXD(811.9,D0,20,FINDING,5,SIEN)) Q:SIEN=""  D
     78 ...S STAT0=$G(^PXD(811.9,D0,20,FINDING,5,SIEN,0))
     79 ...D STATUS(STAT0,"Status List:",RJC) S SCNT=SCNT+1
     80 .S FIND0=$G(^PXD(811.9,D0,20,FINDING,3))
     81 .D SFDISP(FIND0,1,14,"Condition:",RJC,PAD,FILENUM)
     82 .D SFDISP(FIND0,2,15,"Condition Case Sensitive:",RJC,PAD,FILENUM)
     83 .D SFDISP(FIND0,3,18,"Use Cond in Finding Search:",RJC,PAD,FILENUM)
     84 .I $G(^PXD(811.9,D0,20,FINDING,15))'="" D
     85 ..S X=$$RJ^XLFSTR("Computed Finding Parameter:",RJC,PAD)
     86 ..S X=X_" "_$G(^PXD(811.9,D0,20,FINDING,15))
     87 ..D ^DIWP
     88 .D WPOUT(FINDING,20,"Found Text:",RJC,PAD,PADS,1)
     89 .D WPOUT(FINDING,20,"Not Found Text:",RJC,PAD,PADS,2)
     90 .I RTERM["PXRMD(811.5" S IEN1=$P(RTERM,";") D RTERM
     91 .S X=$$RJ^XLFSTR("---- End:",10,PADS)
     92 .S X=X_" "_FINDNAM_" "
     93 .S LEN=(75-$L(X))
     94 .F INT=1:1:(LEN) S X=X_"-"
     95 .D ^DIWP
     96 .S X=" "
     97 .D ^DIWP
     98 ;
     99 ;Function Findings
     100 I +$P($G(^PXD(811.9,D0,25,0)),U,4)>0 D
     101 .S X=" "
     102 .D ^DIWP
     103 .S X="Function Findings:"
     104 .D ^DIWP
     105 .;Build the list of findings for this reminder.
     106 .D BLDFLST^PXRMPTL(D0,.FL)
     107 .S FILENUM="811.925",FINDING=0
     108 .F  S FINDING=$O(^PXD(811.9,D0,25,FINDING)) Q:+FINDING=0  D
     109 ..S FIND0=$G(^PXD(811.9,D0,25,FINDING,0))
     110 ..S FIND3=$G(^PXD(811.9,D0,25,FINDING,3))
     111 ..I FIND3="" Q
     112 ..S FIELD=$P(FIND0,U,1)
     113 ..S FINDNAM="FF("_FIELD_")"
     114 ..S X=" "
     115 ..D ^DIWP
     116 ..S X=$$RJ^XLFSTR("---- Begin:",12,PAD)
     117 ..S X=X_" "_FINDNAM
     118 ..S LEN=(75-$L(X))
     119 ..F INT=1:1:LEN S X=X_"-"
     120 ..D ^DIWP
     121 ..;
     122 ..D SFDISP(FIND3,1,3,"Function String:",RJC,PAD,FILENUM)
     123 ..S X="     Expanded Function String:" D ^DIWP
     124 ..D DISLOGF^PXRMPTL(D0,FINDING,.FL,.PARRAY)
     125 ..S INT=0
     126 ..F  S INT=$O(PARRAY(INT)) Q:'INT  D
     127 ...S X=$J("",6)_PARRAY(INT) D ^DIWP
     128 ..;
     129 ..S FIELD=$P(FIND0,U,4)
     130 ..I $L(FIELD)>0 D
     131 ...S X=$$RJ^XLFSTR("Match Frequency/Age:",RJC,PAD)
     132 ...S X=X_" "_$$GENFREQ^PXRMPTD2(FIND0)
     133 ...D ^DIWP
     134 ..;
     135 ..D SFDISP(FIND0,5,10,"Rank Frequency:",RJC,PAD,FILENUM)
     136 ..D SFDISP(FIND0,6,11,"Use in Resolution Logic:",RJC,PAD,FILENUM)
     137 ..D SFDISP(FIND0,7,12,"Use in Patient Cohort Logic:",RJC,PAD,FILENUM)
     138 ..;
     139 ..D WPOUT(FINDING,25,"Found Text:",RJC,PAD,PADS,1)
     140 ..D WPOUT(FINDING,25,"Not Found Text:",RJC,PAD,PADS,2)
     141 ..S X=$$RJ^XLFSTR("---- End:",10,PADS)
     142 ..S X=X_" "_FINDNAM_" "
     143 ..S LEN=(75-$L(X))
     144 ..F INT=1:1:(LEN) S X=X_"-"
     145 ..D ^DIWP
     146 ..S X=" "
     147 ..D ^DIWP
     148 ;
     149 K ^TMP($J,"W")
     150 ;^UTILITY($J,"W") will be killed by ^DIWW in the print template.
     151 Q
     152 ;
     153 ;================================================
     154RTERM ;Reminder Term
     155 N CNT,RJT,SCNT,SIEN,STAT0,TERM,TERM3,TERMNUM,TERMS
     156 S CNT=0,RJT=RJC+10,TERMNUM="811.52"
     157 S TERMS=0 F  S TERMS=$O(^PXRMD(811.5,IEN1,20,TERMS)) Q:+TERMS=0  D
     158 .S TERM=$G(^PXRMD(811.5,IEN1,20,TERMS,0))
     159 .S TERM3=$G(^PXRMD(811.5,IEN1,20,TERMS,3))
     160 .D SFDISP(TERM,1,.01,"Mapped Finding Item:",RJT,PAD,TERMNUM,CNT)
     161 .D SFDISP(TERM,8,9,"Beginning Date/Time:",RJT,PAD,TERMNUM)
     162 .D SFDISP(TERM,9,10,"Use Inactive Problems:",RJT,PAD,TERMNUM)
     163 .D SFDISP(TERM,11,12,"Ending Date/Time:",RJT,PAD,TERMNUM)
     164 .D SFDISP(TERM,10,11,"Within Category Rank:",RJT,PAD,TERMNUM)
     165 .D SFDISP(TERM,12,13,"MH Scale:",RJT,PAD,TERMNUM)
     166 .D SFDISP(TERM,13,16,"RX Type:",RJT,PAD,TERMNUM)
     167 .D SFDISP(TERM,14,17,"Occurrence Count:",RJT,PAD,TERMNUM)
     168 .I $D(^PXRMD(811.5,IEN1,20,TERMS,5,0))=1 D
     169 ..S (SCNT,SIEN)=0
     170 ..F  S SIEN=$O(^PXRMD(811.5,IEN1,20,TERMS,5,SIEN)) Q:SIEN=""  D
     171 ...S STAT0=$G(^PXRMD(811.5,IEN1,20,TERMS,5,SIEN,0))
     172 ...D STATUS(STAT0,"Status List:",RJT) S SCNT=SCNT+1
     173 .D SFDISP(TERM3,1,14,"Condition:",RJT,PAD,TERMNUM,1)
     174 .D SFDISP(TERM3,2,15,"Condition Case Sensitive:",RJT,PAD,TERMNUM)
     175 .D SFDISP(TERM3,3,18,"Use Cond in Finding Search:",RJT,PAD,TERMNUM)
     176 .I $G(^PXRMD(811.5,IEN1,20,TERMS,15))'="" D
     177 ..S X=$$RJ^XLFSTR("Computed Finding Parameter:",RJT,PAD)
     178 ..S X=X_" "_$G(^PXRMD(811.5,IEN1,20,TERMS,15))
     179 ..D ^DIWP
     180 .S X=""
     181 .D ^DIWP
     182 .S CNT=CNT+1
     183 I CNT=0 D  Q
     184 .S X=$$RJ^XLFSTR("RT Mapped Finding:",RJC,PAD)
     185 .S X=X_" No Reminder Finding Found"
     186 .D ^DIWP
     187 Q
     188 ;
     189 ;================================================
     190SFDISP(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD,FILENUM,FLG) ;Standard finding
     191 ;multiple field display.
     192 N FIELD,HFCAT,HFIEN,NAME,TYPE,X
     193 S NAME=""
     194 S FIELD=$P(FIND0,U,PIECE)
     195 I (PIECE=1)&(FLDNUM=".01")&(FILENUM="811.52") D
     196 .I FLG=0 D
     197 ..S X=""
     198 ..D ^DIWP
     199 ..S RTERM=$P($P(RFIND,"=",2),")")_")"
     200 ..S X=$$RJ^XLFSTR("Mapped Findings:",40)
     201 ..D ^DIWP
     202 .S TYPE=$$FTYPE^PXRMPTD2(FIELD,1),NAME=$$ENTRYNAM^PXRMPTD2(FIELD)
     203 .S X=$$RJ^XLFSTR(TITLE,RJC,PAD)
     204 .S X=X_" "_TYPE_"."_NAME
     205 .D ^DIWP
     206 .I TYPE="HF" D
     207 ..S HFIEN=$P(TERM,";")
     208 ..S HFCAT=$P($G(^AUTTHF(HFIEN,0)),U,3)
     209 ..S HFCAT=$P($G(^AUTTHF(HFCAT,0)),U)
     210 ..S X=$$RJ^XLFSTR("Health Factor Category:",RJC,PAD)
     211 ..S X=X_" "_HFCAT
     212 ..D ^DIWP
     213 I NAME'="" Q
     214 I $L(FIELD)>0 D
     215 .S X=$$RJ^XLFSTR(TITLE,RJC,PAD)
     216 .S X=X_" "_$$EXTERNAL^DILFD(FILENUM,FLDNUM,"",FIELD,"")
     217 .D ^DIWP
     218 Q
     219 ;
     220 ;================================================
     221STATUS(STAT0,TITLE,SPACE) ;
     222 I $L(STAT0)>0 D
     223 .I SCNT=0 S X=$$RJ^XLFSTR(TITLE,SPACE,PAD)
     224 .I SCNT>0 S X=$$RJ^XLFSTR("",SPACE,PAD)
     225 .S X=X_" "_STAT0
     226 .D ^DIWP
     227 Q
     228 ;
     229 ;================================================
     230WPFORMAT(FINDING,NODE,RJC,INDEX) ;Format found/not found word processing text.
     231 I '$D(^PXD(811.9,D0,NODE,FINDING,INDEX,1,0)) Q
     232 ;Save the title using the current format for DIWP.
     233 N DIWF,DIWL,DIWR,IND,NLINES,SC,X
     234 K ^UTILITY($J,"W")
     235 S DIWF="|",DIWL=RJC+2,DIWR=78
     236 S IND=0
     237 F  S IND=$O(^PXD(811.9,D0,NODE,FINDING,INDEX,IND)) Q:+IND=0  D
     238 .S X=$G(^PXD(811.9,D0,NODE,FINDING,INDEX,IND,0))
     239 .D ^DIWP
     240 ;Find where this stuff went.
     241 S SC=$O(^UTILITY($J,"W",""))
     242 ;Save into ^TMP.
     243 S NLINES=^UTILITY($J,"W",SC)
     244 S ^TMP($J,"W",FINDING,NODE,INDEX)=NLINES
     245 F IND=1:1:NLINES D
     246 .S ^TMP($J,"W",FINDING,NODE,INDEX,IND)=^UTILITY($J,"W",SC,IND,0)
     247 K ^UTILITY($J,"W")
     248 Q
     249 ;
     250 ;================================================
     251WPOUT(FINDING,NODE,TITLE,RJC,PAD,PADS,INDEX) ;Output found/not found word processing
     252 ;text.
     253 I $D(^TMP($J,"W",FINDING,NODE,INDEX)) D
     254 .N IND,X
     255 .S X=$$RJ^XLFSTR(TITLE,RJC,PAD)_" "_^TMP($J,"W",FINDING,NODE,INDEX,1)
     256 .D ^DIWP
     257 .F IND=2:1:^TMP($J,"W",FINDING,NODE,INDEX) D
     258 ..S X=PADS_^TMP($J,"W",FINDING,NODE,INDEX,IND)
     259 ..D ^DIWP
     260 Q
     261 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMPTTR.m

    r613 r623  
    1 PXRMPTTR        ;SLC/PKR - Routines for term print templates ;06/01/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;====================================================
    5 DATE(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD,FILENUM,FLG)      ;Standard DATE
    6         N DATE,TEXT
    7         S DATE=$P($G(FIND0),U,PIECE)
    8         I DATE'="" D
    9         . S DATE=$$FMTE^XLFDT(DATE,"D")
    10         . S TEXT=$$RJ^XLFSTR(TITLE,RJC,PAD)
    11         . S TEXT=TEXT_" "_DATE
    12         . W !,TEXT
    13         Q
    14         ;
    15         ;====================================================
    16 GENIEN(FINDING) ;Return internal entry number for findings.
    17         N F0,IEN,PREFIX,ROOT,VPTR
    18         S ROOT="^PXRMD(811.5,D0,20,FINDING,0)"
    19         S F0=@ROOT
    20         S VPTR=$P(F0,U,1)
    21         S IEN=$P(VPTR,";",1)
    22         S ROOT=$P(VPTR,";",2)
    23         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
    24         S VPTR=PXRMFVPL(ROOT)
    25         S PREFIX=$P(VPTR,U,4)
    26         Q " (FI("_+FINDING_")="_PREFIX_"("_IEN_"))"
    27         ;
    28         ;====================================================
    29 ENTRYNAM(VPTR)  ;Given the variable pointer return the entry name. The
    30         ;variable pointer list contains the information necessary to do the
    31         ;look up.
    32         N IEN,FILENUM,NAME,ROOT
    33         S IEN=$P(VPTR,";",1)
    34         S ROOT=$P(VPTR,";",2)
    35         S FILENUM=$P(PXRMFVPL(ROOT),U,1)
    36         S NAME=$$GET1^DIQ(FILENUM,IEN,.01,"","","")
    37         Q NAME
    38         ;
    39         ;====================================================
    40 PFIND   ;Print the reminder term finding multiple.
    41         N CFP,FIELD,FINDING,FIND0,HFCAT,HFIEN,PAD,PXRMFVPL
    42         N RJC,SCNT,SIEN,STAT0,TEXT
    43         ;If called by a FileMan print build the variable pointer list.
    44         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
    45         S PAD=" ",RJC=31
    46         S FINDING=0
    47         F  S FINDING=$O(^PXRMD(811.5,D0,20,FINDING)) Q:+FINDING=0  D
    48         . S FIND0=^PXRMD(811.5,D0,20,FINDING,0)
    49         . S FIELD=$P(FIND0,U,1)
    50         . S TEXT=$$RJ^XLFSTR("Finding Item:",RJC,PAD)
    51         . S TEXT=TEXT_"  "_$$ENTRYNAM(FIELD)
    52         . S TEXT=TEXT_" "_$$TRMIEN(FINDING)
    53         . W !!,TEXT
    54         .;
    55         . S TEXT=$$RJ^XLFSTR("Finding Type:",RJC,PAD)
    56         . S TEXT=TEXT_"  "_$$TFTYPE(FIELD)
    57         . W !,TEXT
    58         . I FIND0["AUTTHF" D
    59         .. S HFIEN=$P($P(FIND0,U),";")
    60         .. S HFCAT=$P($G(^AUTTHF(HFIEN,0)),U,3)
    61         .. S HFCAT=$P($G(^AUTTHF(HFCAT,0)),U)
    62         .. S TEXT=$$RJ^XLFSTR("Health Factor Category:",RJC,PAD)
    63         .. S TEXT=TEXT_"  "_HFCAT
    64         .. W !,TEXT
    65         .;
    66         . S FIELD=$P(FIND0,U,4)
    67         . I $L(FIELD)>0 D
    68         .. S TEXT=$$RJ^XLFSTR("Match Frequency/Age:",RJC,PAD)
    69         .. S TEXT=TEXT_"  "_$$GENFREQ^PXRMPTD2(FIND0)
    70         .. W !,TEXT
    71         .;
    72         . D DATE(FIND0,8,9,"Beginning Date/Time:",RJC,PAD)
    73         . D DATE(FIND0,11,12,"Ending Date/Time Date:",RJC,PAD)
    74         . D SFDISP(FIND0,14,17,"Occurrence Count:",RJC,PAD)
    75         . D SFDISP(FIND0,9,10,"Use Inactive Problems:",RJC,PAD)
    76         . D SFDISP(FIND0,10,11,"Within Category Rank:",RJC,PAD)
    77         . D SFDISP(FIND0,12,13,"MH Scale:",RJC,PAD)
    78         . D SFDISP(FIND0,16,28,"Include Visit Data:",RJC,PAD)
    79         . D SFDISP(FIND0,13,16,"Rx Type:",RJC,PAD)
    80         . D SFDISP(FIND0,15,27,"Use Start Date:",RJC,PAD)
    81         . I $D(^PXRMD(811.5,D0,20,FINDING,5,0))=1 D
    82         .. S (SCNT,SIEN)=0
    83         .. F  S SIEN=$O(^PXRMD(811.5,D0,20,FINDING,5,SIEN)) Q:SIEN=""  D
    84         ... S STAT0=$G(^PXRMD(811.5,D0,20,FINDING,5,SIEN,0))
    85         ... D STATUS(STAT0,"Status List:") S SCNT=SCNT+1
    86         .;
    87         . S FIND0=$G(^PXRMD(811.5,D0,20,FINDING,3))
    88         . D SFDISP(FIND0,1,14,"Condition:",RJC,PAD)
    89         . D SFDISP(FIND0,2,15,"Condition Case Sensitive:",RJC,PAD)
    90         . D SFDISP(FIND0,3,18,"Use Status/Cond in Search:",RJC,PAD)
    91         . I $G(^PXRMD(811.5,D0,20,FINDING,15))'="" D
    92         .. S CFP=$$RJ^XLFSTR("Computed Finding Parameter:",RJC,PAD)
    93         .. S CFP=CFP_"  "_$G(^PXRMD(811.5,D0,20,FINDING,15))
    94         .. W !,CFP
    95         Q
    96         ;
    97         ;====================================================
    98 SFDISP(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD)        ;Standard finding multiple
    99         ;field display.
    100         N FIELD,TEXT
    101         S FIELD=$P(FIND0,U,PIECE)
    102         I $L(FIELD)>0 D
    103         . S TEXT=$$RJ^XLFSTR(TITLE,RJC,PAD)
    104         . S TEXT=TEXT_"  "_$$EXTERNAL^DILFD(811.52,FLDNUM,"",FIELD,"")
    105         . I FLDNUM=13 S TEXT=TEXT_" - "_$$SPECIAL^PXRMPTDF(FIND0,FIELD)
    106         . W !,TEXT
    107         Q
    108         ;
    109         ;====================================================
    110 STATUS(STAT0,TITLE)     ; Status display
    111         I $L(STAT0)>0 D
    112         . N STATUS
    113         . I SCNT=0 S STATUS=$$RJ^XLFSTR(TITLE,RJC,PAD)
    114         . I SCNT>0 S STATUS=$$RJ^XLFSTR("",RJC,PAD)
    115         . S STATUS=STATUS_"  "_STAT0
    116         . W !,STATUS
    117         Q
    118         ;
    119         ;====================================================
    120 TFTYPE(VPTR)    ;Return Term finding type
    121         N ROOT,TFTYPE
    122         S ROOT=$P(VPTR,";",2)
    123         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
    124         S TFTYPE=$P(PXRMFVPL(ROOT),U,2)
    125         Q TFTYPE
    126         ;
    127         ;====================================================
    128 TRMIEN(FINDING) ;Return internal entry number for TERM findings.
    129         N F0,IEN,PREFIX,ROOT,VPTR
    130         S ROOT="^PXRMD(811.5,D0,20,FINDING,0)"
    131         S F0=@ROOT
    132         S VPTR=$P(F0,U,1)
    133         S IEN=$P(VPTR,";",1)
    134         S ROOT=$P(VPTR,";",2)
    135         I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
    136         S VPTR=PXRMFVPL(ROOT)
    137         S PREFIX=$P(VPTR,U,4)
    138         Q " (FI("_+FINDING_")="_PREFIX_"("_IEN_"))"
    139         ;
     1PXRMPTTR ;SLC/PKR - Routines for term print templates ;01/30/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;====================================================
     5DATE(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD,FILENUM,FLG) ;Standard DATE
     6 N DATE,TEXT
     7 S DATE=$P($G(FIND0),U,PIECE)
     8 I DATE'="" D
     9 . S DATE=$$FMTE^XLFDT(DATE,"D")
     10 . S TEXT=$$RJ^XLFSTR(TITLE,RJC,PAD)
     11 . S TEXT=TEXT_" "_DATE
     12 . W !,TEXT
     13 Q
     14 ;
     15 ;====================================================
     16GENIEN(FINDING) ;Return internal entry number for findings.
     17 N F0,IEN,PREFIX,ROOT,VPTR
     18 S ROOT="^PXRMD(811.5,D0,20,FINDING,0)"
     19 S F0=@ROOT
     20 S VPTR=$P(F0,U,1)
     21 S IEN=$P(VPTR,";",1)
     22 S ROOT=$P(VPTR,";",2)
     23 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
     24 S VPTR=PXRMFVPL(ROOT)
     25 S PREFIX=$P(VPTR,U,4)
     26 Q " (FI("_+FINDING_")="_PREFIX_"("_IEN_"))"
     27 ;
     28 ;====================================================
     29ENTRYNAM(VPTR) ;Given the variable pointer return the entry name. The
     30 ;variable pointer list contains the information necessary to do the
     31 ;look up.
     32 N IEN,FILENUM,NAME,ROOT
     33 S IEN=$P(VPTR,";",1)
     34 S ROOT=$P(VPTR,";",2)
     35 S FILENUM=$P(PXRMFVPL(ROOT),U,1)
     36 S NAME=$$GET1^DIQ(FILENUM,IEN,.01,"","","")
     37 Q NAME
     38 ;
     39 ;====================================================
     40PFIND ;Print the reminder term finding multiple.
     41 N CFP,FIELD,FINDING,FIND0,HFCAT,HFIEN,PAD,PXRMFVPL
     42 N RJC,SCNT,SIEN,STAT0,TEXT
     43 ;If called by a FileMan print build the variable pointer list.
     44 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
     45 S PAD=" ",RJC=31
     46 S FINDING=0
     47 F  S FINDING=$O(^PXRMD(811.5,D0,20,FINDING)) Q:+FINDING=0  D
     48 . S FIND0=^PXRMD(811.5,D0,20,FINDING,0)
     49 . S FIELD=$P(FIND0,U,1)
     50 . S TEXT=$$RJ^XLFSTR("Finding Item:",RJC,PAD)
     51 . S TEXT=TEXT_"  "_$$ENTRYNAM(FIELD)
     52 . S TEXT=TEXT_" "_$$TRMIEN(FINDING)
     53 . W !!,TEXT
     54 .;
     55 . S TEXT=$$RJ^XLFSTR("Finding Type:",RJC,PAD)
     56 . S TEXT=TEXT_"  "_$$TFTYPE(FIELD)
     57 . W !,TEXT
     58 . I FIND0["AUTTHF" D
     59 .. S HFIEN=$P($P(FIND0,U),";")
     60 .. S HFCAT=$P($G(^AUTTHF(HFIEN,0)),U,3)
     61 .. S HFCAT=$P($G(^AUTTHF(HFCAT,0)),U)
     62 .. S TEXT=$$RJ^XLFSTR("Health Factor Category:",RJC,PAD)
     63 .. S TEXT=TEXT_"  "_HFCAT
     64 .. W !,TEXT
     65 .;
     66 . S FIELD=$P(FIND0,U,4)
     67 . I $L(FIELD)>0 D
     68 .. S TEXT=$$RJ^XLFSTR("Match Frequency/Age:",RJC,PAD)
     69 .. S TEXT=TEXT_"  "_$$GENFREQ^PXRMPTD2(FIND0)
     70 .. W !,TEXT
     71 .;
     72 . D DATE(FIND0,8,9,"Beginning Date/Time:",RJC,PAD)
     73 . D DATE(FIND0,11,12,"Ending Date/Time Date:",RJC,PAD)
     74 . D SFDISP(FIND0,14,17,"Occurrence Count:",RJC,PAD)
     75 . D SFDISP(FIND0,9,10,"Use Inactive Problems:",RJC,PAD)
     76 . D SFDISP(FIND0,10,11,"Within Category Rank:",RJC,PAD)
     77 . D SFDISP(FIND0,12,13,"MH Scale:",RJC,PAD)
     78 . D SFDISP(FIND0,16,28,"Include Visit Data:",RJC,PAD)
     79 . D SFDISP(FIND0,13,16,"Rx Type:",RJC,PAD)
     80 . D SFDISP(FIND0,15,27,"Use Start Date:",RJC,PAD)
     81 . I $D(^PXRMD(811.5,D0,20,FINDING,5,0))=1 D
     82 .. S (SCNT,SIEN)=0
     83 .. F  S SIEN=$O(^PXRMD(811.5,D0,20,FINDING,5,SIEN)) Q:SIEN=""  D
     84 ... S STAT0=$G(^PXRMD(811.5,D0,20,FINDING,5,SIEN,0))
     85 ... D STATUS(STAT0,"Status List:") S SCNT=SCNT+1
     86 .;
     87 . S FIND0=$G(^PXRMD(811.5,D0,20,FINDING,3))
     88 . D SFDISP(FIND0,1,14,"Condition:",RJC,PAD)
     89 . D SFDISP(FIND0,2,15,"Condition Case Sensitive:",RJC,PAD)
     90 . D SFDISP(FIND0,3,18,"Use Cond in Finding Search:",RJC,PAD)
     91 . I $G(^PXRMD(811.5,D0,20,FINDING,15))'="" D
     92 .. S CFP=$$RJ^XLFSTR("Computed Finding Parameter:",RJC,PAD)
     93 .. S CFP=CFP_"  "_$G(^PXRMD(811.5,D0,20,FINDING,15))
     94 .. W !,CFP
     95 Q
     96 ;
     97 ;====================================================
     98SFDISP(FIND0,PIECE,FLDNUM,TITLE,RJC,PAD) ;Standard finding multiple
     99 ;field display.
     100 N FIELD,TEXT
     101 S FIELD=$P(FIND0,U,PIECE)
     102 I $L(FIELD)>0 D
     103 . S TEXT=$$RJ^XLFSTR(TITLE,RJC,PAD)
     104 . S TEXT=TEXT_"  "_$$EXTERNAL^DILFD(811.52,FLDNUM,"",FIELD,"")
     105 . W !,TEXT
     106 Q
     107 ;
     108 ;====================================================
     109STATUS(STAT0,TITLE) ; Status display
     110 I $L(STAT0)>0 D
     111 . N STATUS
     112 . I SCNT=0 S STATUS=$$RJ^XLFSTR(TITLE,RJC,PAD)
     113 . I SCNT>0 S STATUS=$$RJ^XLFSTR("",RJC,PAD)
     114 . S STATUS=STATUS_"  "_STAT0
     115 . W !,STATUS
     116 Q
     117 ;
     118 ;====================================================
     119TFTYPE(VPTR) ;Return Term finding type
     120 N ROOT,TFTYPE
     121 S ROOT=$P(VPTR,";",2)
     122 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
     123 S TFTYPE=$P(PXRMFVPL(ROOT),U,2)
     124 Q TFTYPE
     125 ;
     126 ;====================================================
     127TRMIEN(FINDING) ;Return internal entry number for TERM findings.
     128 N F0,IEN,PREFIX,ROOT,VPTR
     129 S ROOT="^PXRMD(811.5,D0,20,FINDING,0)"
     130 S F0=@ROOT
     131 S VPTR=$P(F0,U,1)
     132 S IEN=$P(VPTR,";",1)
     133 S ROOT=$P(VPTR,";",2)
     134 I '$D(PXRMFVPL) N PXRMFVPL D BLDRLIST^PXRMVPTR(811.52,.01,.PXRMFVPL)
     135 S VPTR=PXRMFVPL(ROOT)
     136 S PREFIX=$P(VPTR,U,4)
     137 Q " (FI("_+FINDING_")="_PREFIX_"("_IEN_"))"
     138 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMREDF.m

    r613 r623  
    1 PXRMREDF        ; SLC/PJH - Edit PXRM reminder findings. ;01/09/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called by PXRMREDT which newes and initialized DEF, DEF1, DEF2.
    5         ;
    6 SET     S:'$D(^PXD(811.9,DA,20,0)) ^PXD(811.9,DA,20,0)="^811.902V" Q
    7         ;Display ALL findings
    8         ;
    9         ;--------------------
    10 DSPALL(TYPE,NODE,DA,LIST)       ;
    11         N FIRST,SUB,SUB1,SUB2
    12         S FIRST=1,SUB="",SUB1="",SUB2=""
    13         F  S SUB=$O(LIST(SUB)) Q:SUB=""  D
    14         .S SUB1=0
    15         .F  S SUB1=$O(LIST(SUB,SUB1)) Q:SUB1=""  D
    16         ..S SUB2=0 F  S SUB2=$O(LIST(SUB,SUB1,SUB2)) Q:SUB2=""  D
    17         ...I FIRST S FIRST=0 W !!,"Choose from:",!
    18         ...W SUB
    19         ...W ?5,SUB1,?65,"Finding #: "_SUB2,!
    20         I FIRST,TYPE="D" W !!,"Reminder has no findings",!
    21         I FIRST,TYPE="T" W !!,"Reminder Term has no findings",!
    22         ;Update
    23         D LIST^PXRMREDT(NODE,DA,.LIST)
    24         Q
    25         ;
    26         ;Edit individual FINDING entry
    27         ;-----------------------------
    28 FEDIT(IEN)      ;
    29         N CFIEN,DA,DIC,DIE,DR,ETYPE,GLOB
    30         N STATUS,TERMSTAT,TIEN,TERMTYPE,VF,WPIEN,Y
    31         S DA(1)=IEN
    32         S DIC="^PXD(811.9,"_IEN_",20,"
    33         I $P(^PXD(811.9,IEN,100),U)="N",$G(PXRMINST)'=1 S DIC(0)="QEA"
    34         E  S DIC(0)="QEAL"
    35         S DIC("A")="Select FINDING: "
    36         S DIC("P")="811.902V"
    37         D ^DIC I Y=-1 S DTOUT=1 Q
    38         S DIE=DIC K DIC
    39         S DIE("NO^")="OUTOK"
    40         S DA=+Y,GLOB=$P($P(Y,U,2),";",2) Q:GLOB=""
    41         S TYPE=$G(DEF1(GLOB))
    42         S SDA(2)=DA(1),SDA(1)=DA
    43         ;Save term IEN
    44         S STATUS=0
    45         I TYPE="CF" S CFIEN=$P($P(Y,U,2),";",1) D
    46         .I $D(^PXRMD(811.4,CFIEN,1))>0 D
    47         ..W !!,"Computed Finding Description:" S WPIEN=0
    48         ..F  S WPIEN=$O(^PXRMD(811.4,CFIEN,1,WPIEN)) Q:+WPIEN'>0  D
    49         ...W !,$G(^PXRMD(811.4,CFIEN,1,WPIEN,0))
    50         .E  W !!,"No description defined for this computed finding"
    51         I TYPE="MH" D WARN^PXRMMH
    52         I TYPE="RT" S TIEN=$P($P(Y,U,2),";",1)
    53         ;Finding record fields
    54         W !!,"Editing Finding Number: "_$G(DA)
    55         S DR=".01;3;I X=""0Y"" S Y=6;1;2;6;7;8;9;12;17"
    56         ;Taxonomy - use inactive problems
    57         I TYPE="TX" D
    58         .S TERMSTAT=$$TAXNODE^PXRMSTA1($P($P(Y,U,2),";"),"H")
    59         .I TERMSTAT="P" S DR=DR_";10" Q
    60         .I TERMSTAT'=0 S DR=DR_";10",STATUS=1
    61         I TYPE="RT" D
    62         .S TERMTYPE=$$TERMTYPE(TIEN)
    63         .I TERMTYPE["H" S DR=DR_";11"
    64         ;Health Factor - within category rank
    65         I TYPE="HF" S DR=DR_";11"
    66         ;If V file INCLUDE VISIT DATA
    67         S VF=$S(TYPE="ED":1,TYPE="EX":1,TYPE="HF":1,TYPE="IM":1,TYPE="ST":1,TYPE="TX":1,1:0)
    68         I TYPE="RT",$P(TERMTYPE,U,2)="VF" S VF=1
    69         I VF S DR=DR_";28"
    70         ;
    71         ;Mental Health - scale
    72         I TYPE="MH" S DR=DR_";13"
    73         ;Radiology procedure.
    74         I TYPE="RP" S STATUS=1
    75         ;Orderable Item
    76         I TYPE="OI" S DR=DR_";27",STATUS=1
    77         ;Rx Type
    78         I (TYPE="DC")!(TYPE="DG")!(TYPE="DR") S DR=DR_";16;27",STATUS=1
    79         ;Condition
    80         S DR=DR_";14;15;18"
    81         I TYPE="CF" S DR=DR_";26"
    82         ;Found/not found text
    83         S DR=DR_";4;5"
    84         ;
    85         I TYPE="RT" D
    86         . I TERMTYPE["D" S DR=DR_";16;27",STATUS=1
    87         . I TERMTYPE["O" S DR=DR_";27",STATUS=1
    88         . I TERMTYPE["R" S STATUS=1
    89         . I TERMTYPE["T" S STATUS=1
    90         .I TERMTYPE[2 D
    91         .. N MSG
    92         .. S MSG(1)="Cannot set a status since the term contains multiple types of findings"
    93         .. S MSG(2)="Edit the status field at the term level for each finding" H 2
    94         .. D EN^DDIOL(.MSG)
    95         ;Edit finding record
    96         D ^DIE
    97         S $P(^PXD(811.9,IEN,20,0),U,3)=0
    98         I $D(Y) S DTOUT=1 Q
    99         ;Check if deleted
    100         I '$D(DA) Q
    101         I STATUS=1,$D(Y)=0 D STATUS^PXRMSTA1(.DA,"D")
    102         ;
    103         S ETYPE=$P(^PXD(811.9,IEN,20,SDA(1),0),U,1)
    104         ;Option to edit term findings
    105         I $P(ETYPE,";",2)="PXRMD(811.5," D
    106         . S TIEN=$P(ETYPE,";",1)
    107         . D TMAP(IEN,TIEN)
    108         Q
    109         ;
    110         ;Edit individual function finding entry
    111         ;-----------------------------
    112 FFEDIT(IEN)     ;
    113         N DA,DIC,DIE,DR,Y
    114         S DA(1)=IEN
    115         S DIC="^PXD(811.9,"_IEN_",25,"
    116         S DIC(0)="QEAL"
    117         S DIC("A")="Select FUNCTION FINDING: "
    118         D ^DIC
    119         I Y=-1 S DTOUT=1 Q
    120         S DIE=DIC K DIC
    121         S DA=+Y
    122         ;Finding record fields
    123         S DR=".01;3"
    124         ;Edit finding record
    125         D ^DIE
    126         I $D(Y) S DTOUT=1 Q
    127         I '$D(DA) Q
    128         ;If the function string is null don't do the rest of the fields.
    129         I $G(^PXD(811.9,IEN,25,DA,3))="" Q
    130         S DR="1;2;11;12;15;I X=""0Y"" S Y=16;13;14;16"
    131         D ^DIE
    132         I $D(Y) S DTOUT=1 Q
    133         I '$D(DA) Q
    134         ;Check if deleted
    135         Q
    136         ;
    137         ;Edit Reminder Function Findings
    138         ;----------------------
    139 FFIND   ;
    140         N DTOUT,DUOUT
    141         F  D  Q:$D(DUOUT)!$D(DTOUT)
    142         .D FFEDIT(DA) I $D(DUOUT)!$D(DTOUT) Q
    143         K DUOUT,DTOUT
    144         Q
    145         ;
    146         ;Edit Reminder Findings
    147         ;----------------------
    148 FIND(LIST)      ;
    149         N DTOUT,DUOUT,NODE,SDA
    150         D SET ; Check if node defined
    151         S NODE="^PXD(811.9)"
    152         F  D  Q:$D(DUOUT)!$D(DTOUT)
    153         .;Display list of existing reminder findings
    154         .W !!,"Reminder Definition Findings"
    155         .D DSPALL("D",NODE,DA,.LIST)
    156         .;Edit findings
    157         .D FEDIT(DA) I $D(DUOUT)!$D(DTOUT) D LIST^PXRMREDT(NODE,DA,.LIST) Q
    158         .;Update list with finding changes
    159         .D LIST^PXRMREDT(NODE,DA,.LIST)
    160         Q
    161         ;
    162         ;General help text routine
    163         ;-------------------------
    164 HELP(CALL)      ;
    165         N HTEXT
    166         N DIWF,DIWL,DIWR,IC
    167         S DIWF="C70",DIWL=0,DIWR=70
    168         ;
    169         I CALL=1 D
    170         .S HTEXT(1)="Select the type of finding you wish to change or add."
    171         .S HTEXT(2)="Type '?' for a list of the available finding types."
    172         I CALL=2 D
    173         .S HTEXT(1)="Select section of the reminder you wish to edit or 'All'"
    174         .S HTEXT(2)="to step through all sections of the reminder definition."
    175         I CALL=3 D
    176         .S HTEXT(1)="Select 'Y' to edit the findings mapped to this term"
    177         .S HTEXT(2)="or 'N' to return to select another reminder finding."
    178         ;
    179         K ^UTILITY($J,"W")
    180         S IC=""
    181         F  S IC=$O(HTEXT(IC)) Q:IC=""  D
    182         . S X=HTEXT(IC)
    183         . D ^DIWP
    184         W !
    185         S IC=0
    186         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    187         . W !,^UTILITY($J,"W",0,IC,0)
    188         K ^UTILITY($J,"W")
    189         W !
    190         Q
    191         ;
    192         ;Display TERM findings
    193         ;--------------------
    194 TDSP(DA)        ;
    195         N FIRST,SUB,TLST S FIRST=1,SUB="",SUB1=""
    196         ;Build list of term findings
    197         D TLST(.TLST,DA)
    198         ;Display list
    199         F  S SUB=$O(TLST(SUB)) Q:SUB=""  D
    200         .S SUB1=0
    201         .F  S SUB1=$O(TLST(SUB,SUB1)) Q:SUB1=""  D
    202         ..I FIRST S FIRST=0 W !!,"Reminder Term Findings:",!!
    203         ..W SUB
    204         ..W ?8,SUB1,!
    205         I FIRST W !!,"Term has no mapped findings",!!
    206         Q
    207         ;
    208         ;List Reminders using this term
    209         ;------------------------------
    210 TERMS(TIEN,RIEN)        ;
    211         ;RIEN will be the reminder ien if called from reminder edit
    212         ;or zero if called from term edit
    213         N ARRAY,FIND,IEN,SUB,TCNT,RNAME
    214         ;Scan all reminders in file #811.9
    215         S IEN=0,FIND="PXRMD(811.5,",TCNT=0
    216         F  S IEN=$O(^PXD(811.9,IEN)) Q:'IEN  D
    217         .;Exclude current reminder called in reminder edit
    218         .I RIEN,IEN=RIEN Q
    219         .;Check the term findings
    220         .I '$D(^PXD(811.9,IEN,20,"E",FIND,TIEN)) Q
    221         .;Add to reminder array
    222         .S RNAME=$P($G(^PXD(811.9,IEN,0)),U)
    223         .I RNAME="" S RNAME=IEN
    224         .I '$D(ARRAY(RNAME)) S TCNT=TCNT+1
    225         .S ARRAY(RNAME)=""
    226         ;
    227         ;Display list of reminders using the term
    228         I TCNT D
    229         .N TXT
    230         .S TXT="This Reminder Term is" S:RIEN TXT=TXT_" also"
    231         .S TXT=TXT_" used by the following Reminder Definition"
    232         .I TCNT>1 S TXT=TXT_"s"
    233         .W !!,TXT_":"
    234         .S RNAME="" F  S RNAME=$O(ARRAY(RNAME)) Q:RNAME=""  W !," ",RNAME
    235         Q
    236         ;
    237         ;------------------------------
    238         ;Check term for finding item to edit status item
    239 TERMTYPE(TIEN)  ;
    240         N DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,TYPE,VF
    241         S (DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,VF)=0
    242         S TYPE="" F  S TYPE=$O(^PXRMD(811.5,TIEN,20,"B",TYPE)) Q:TYPE=""  D
    243         . I TYPE["AUTTEDT(" S (OTHER,VF)=1 Q
    244         . I TYPE["AUTTHF(" S (HF,OTHER,VF)=1 Q
    245         . I TYPE["AUTTIMM(" S (OTHER,VF)=1 Q
    246         . I TYPE["AUTTSK(" S (OTHER,VF)=1 Q
    247         . I TYPE["ORD" S (ORD,FOUND)=1 Q
    248         . I TYPE["PS" S (DRUG,FOUND)=1 Q
    249         . I TYPE["PXD(811.2" S (FOUND,TAX,VF)=1 Q
    250         . I TYPE["RAMIS" S (FOUND,RAD)=1 Q
    251         . S OTHER=1
    252         I RAD=1,ORD=0,TAX=0,DRUG=0,OTHER=0 S RESULT="R"
    253         I RAD=0,ORD=1,TAX=0,DRUG=0,OTHER=0 S RESULT="O"
    254         I RAD=0,ORD=0,TAX=1,DRUG=0,OTHER=0 S RESULT="T"
    255         I RAD=0,ORD=0,TAX=0,DRUG=1,OTHER=0 S RESULT="D"
    256         I OTHER=1 S RESULT=1 I FOUND=1 S RESULT=2
    257         I RESULT="T" S RESULT=$$TAXTYPE^PXRMSTA1(TIEN,"")
    258         I HF=1 S RESULT="H"_RESULT
    259         I VF=1 S RESULT=RESULT_U_"VF"
    260         Q RESULT
    261         ;
    262         ;Build list of mapped findings for term
    263         ;--------------------------------------
    264 TLST(ARRAY,DA)  ;
    265         N TYPE,DATA,GLOB,IEN,NAME,NODE,SUB
    266         ;Clear passed arrays
    267         K ARRAY
    268         ;Build cross reference global to file number
    269         ;Get each finding
    270         S SUB=0 F  S SUB=$O(^PXRMD(811.5,DA,20,SUB)) Q:'SUB  D
    271         .S DATA=$G(^PXRMD(811.5,DA,20,SUB,0)) I DATA="" Q
    272         .;Determine global and global ien
    273         .S NODE=$P(DATA,U),GLOB=$P(NODE,";",2),IEN=$P(NODE,";")
    274         .;Ignore null entries
    275         .I (GLOB="")!(IEN="") Q
    276         .;Work out the file type
    277         .S TYPE=$G(DEF1(GLOB)) Q:TYPE=""
    278         .S NAME=$P($G(@(U_GLOB_IEN_",0)")),U)
    279         .S ARRAY(TYPE,NAME)=""
    280         Q
    281         ;
    282         ;Map Term findings
    283         ;-----------------
    284 TMAP(RIEN,TIEN) ;
    285         N TOPT,TNAM
    286         ;Display any other reminders using this term
    287         D TERMS(TIEN,RIEN)
    288         ;Term name
    289         S TNAM=$P($G(^PXRMD(811.5,TIEN,0)),U)
    290         ;Give option to edit mapped findings (Y/N)
    291         D TMASK(.TOPT,TNAM) Q:$D(DUOUT)!($D(DTOUT))
    292         ;Edit term findings
    293         I TOPT="Y" D TRMED(TIEN)
    294         Q
    295         ;
    296         ;Option to edit term findings
    297         ;----------------------------
    298 TMASK(YESNO,TNAM)       ;
    299         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
    300         S DIR(0)="YA0"
    301         S DIR("A")="Do you want to edit mapped findings for "_TNAM_": "
    302         S (DIR("B"),YESNO)="N"
    303         S DIR("?")="Enter Y or N. For detailed help type ??"
    304         S DIR("??")=U_"D HELP^PXRMREDF(3)"
    305         W !
    306         D ^DIR K DIR
    307         I $D(DIROUT)!$D(DIRUT) Q
    308         I $D(DTOUT)!$D(DUOUT) Q
    309         S YESNO=$E(Y(0))
    310         Q
    311         ;
    312         ;Term edit
    313         ;---------
    314 TRMED(DA)       ;
    315         N CS1,CS2,DIC,DLAYGO,DTOUT,DUOUT,Y
    316         K DLAYGO,DTOUT,DUOUT,Y
    317         ;Display term findings
    318         D TDSP(DA)
    319         ;Initialize change history
    320         S CS1=$$FILE^PXRMEXCS(811.5,DA)
    321         ;Edit term findings
    322         S DIC="^PXRMD(811.5,"
    323         D EDIT^PXRMTMED(DIC,DA)
    324         ;Update change history
    325         S CS2=$$FILE^PXRMEXCS(811.5,DA)
    326         I CS2=0 Q
    327         I CS2'=CS1 D SEHIST^PXRMUTIL(811.5,DIC,DA)
    328         Q
    329         ;
     1PXRMREDF ; SLC/PJH - Edit PXRM reminder findings. ;02/09/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called by PXRMREDT which newes and initialized DEF, DEF1, DEF2.
     5 ;
     6SET S:'$D(^PXD(811.9,DA,20,0)) ^PXD(811.9,DA,20,0)="^811.902V" Q
     7 ;Display ALL findings
     8 ;
     9 ;--------------------
     10DSPALL(TYPE,NODE,DA,LIST) ;
     11 N FIRST,SUB,SUB1,SUB2
     12 S FIRST=1,SUB="",SUB1="",SUB2=""
     13 F  S SUB=$O(LIST(SUB)) Q:SUB=""  D
     14 .S SUB1=0
     15 .F  S SUB1=$O(LIST(SUB,SUB1)) Q:SUB1=""  D
     16 ..S SUB2=0 F  S SUB2=$O(LIST(SUB,SUB1,SUB2)) Q:SUB2=""  D
     17 ...I FIRST S FIRST=0 W !!,"Choose from:",!
     18 ...W SUB
     19 ...W ?5,SUB1,?65,"Finding #: "_SUB2,!
     20 I FIRST,TYPE="D" W !!,"Reminder has no findings",!
     21 I FIRST,TYPE="T" W !!,"Reminder Term has no findings",!
     22 ;Update
     23 D LIST^PXRMREDT(NODE,DA,.LIST)
     24 Q
     25 ;
     26 ;Edit individual FINDING entry
     27 ;-----------------------------
     28FEDIT(IEN) ;
     29 N CFIEN,DA,DIC,DIE,DR,ETYPE,GLOB
     30 N STATUS,TERMSTAT,TIEN,TERMTYPE,VF,WPIEN,Y
     31 S DA(1)=IEN
     32 S DIC="^PXD(811.9,"_IEN_",20,"
     33 I $P(^PXD(811.9,IEN,100),U)="N",$G(PXRMINST)'=1 S DIC(0)="QEA"
     34 E  S DIC(0)="QEAL"
     35 S DIC("A")="Select FINDING: "
     36 S DIC("P")="811.902V"
     37 D ^DIC I Y=-1 S DTOUT=1 Q
     38 S DIE=DIC K DIC
     39 S DA=+Y,GLOB=$P($P(Y,U,2),";",2) Q:GLOB=""
     40 S TYPE=$G(DEF1(GLOB))
     41 S SDA(2)=DA(1),SDA(1)=DA
     42 ;Save term IEN
     43 S STATUS=0
     44 I TYPE="RT" S TIEN=$P($P(Y,U,2),";",1)
     45 I TYPE="CF" S CFIEN=$P($P(Y,U,2),";",1) D
     46 .I $D(^PXRMD(811.4,CFIEN,1))>0 D
     47 ..W !!,"Computed Finding Description:" S WPIEN=0
     48 ..F  S WPIEN=$O(^PXRMD(811.4,CFIEN,1,WPIEN)) Q:+WPIEN'>0  D
     49 ...W !,$G(^PXRMD(811.4,CFIEN,1,WPIEN,0))
     50 .E  W !!,"No description defined for this computed finding"
     51 ;Finding record fields
     52 W !!,"Editing Finding Number: "_$G(DA)
     53 S DR=".01;3;I X=""0Y"" S Y=6;1;2;6;7;8;9;12;17"
     54 ;Taxonomy - use inactive problems
     55 I TYPE="TX" D
     56 .S TERMSTAT=$$TAXNODE^PXRMSTA1($P($P(Y,U,2),";"),"H")
     57 .I TERMSTAT="P" S DR=DR_";10" Q
     58 .I TERMSTAT'=0 S DR=DR_";10",STATUS=1
     59 I TYPE="RT" D
     60 .S TERMTYPE=$$TERMTYPE(TIEN)
     61 .I TERMTYPE["H" S DR=DR_";11"
     62 ;Health Factor - within category rank
     63 I TYPE="HF" S DR=DR_";11"
     64 ;If V file INCLUDE VISIT DATA
     65 S VF=$S(TYPE="ED":1,TYPE="EX":1,TYPE="HF":1,TYPE="IM":1,TYPE="ST":1,TYPE="TX":1,1:0)
     66 I TYPE="RT",$P(TERMTYPE,U,2)="VF" S VF=1
     67 I VF S DR=DR_";28"
     68 ;
     69 ;Mental Health - scale
     70 I TYPE="MH" S DR=DR_";13"
     71 ;Radiology procedure.
     72 I TYPE="RP" S STATUS=1
     73 ;Orderable Item
     74 I TYPE="OI" S DR=DR_";27",STATUS=1
     75 ;Rx Type
     76 I (TYPE="DC")!(TYPE="DG")!(TYPE="DR") S DR=DR_";16;27",STATUS=1
     77 ;Condition
     78 S DR=DR_";14;15;18"
     79 I TYPE="CF" S DR=DR_";26"
     80 ;Found/not found text
     81 S DR=DR_";4;5"
     82 ;
     83 I TYPE="RT" D
     84 . I TERMTYPE["D" S DR=DR_";16;27",STATUS=1
     85 . I TERMTYPE["O" S DR=DR_";27",STATUS=1
     86 . I TERMTYPE["R" S STATUS=1
     87 . I TERMTYPE["T" S STATUS=1
     88 .I TERMTYPE[2 D
     89 .. N MSG
     90 .. S MSG(1)="Cannot set a status since the term contains multiple types of findings"
     91 .. S MSG(2)="Edit the status field at the term level for each finding" H 2
     92 .. D EN^DDIOL(.MSG)
     93 ;Edit finding record
     94 D ^DIE
     95 S $P(^PXD(811.9,IEN,20,0),U,3)=0
     96 I $D(Y) S DTOUT=1 Q
     97 ;Check if deleted
     98 I '$D(DA) Q
     99 I STATUS=1 D STATUS^PXRMSTA1(.DA,"D")
     100 ;
     101 S ETYPE=$P(^PXD(811.9,IEN,20,SDA(1),0),U,1)
     102 ;Option to edit term findings
     103 I $P(ETYPE,";",2)="PXRMD(811.5," D
     104 . S TIEN=$P(ETYPE,";",1)
     105 . D TMAP(IEN,TIEN)
     106 Q
     107 ;
     108 ;Edit individual function finding entry
     109 ;-----------------------------
     110FFEDIT(IEN) ;
     111 N DA,DIC,DIE,DR,Y
     112 S DA(1)=IEN
     113 S DIC="^PXD(811.9,"_IEN_",25,"
     114 S DIC(0)="QEAL"
     115 S DIC("A")="Select FUNCTION FINDING: "
     116 D ^DIC
     117 I Y=-1 S DTOUT=1 Q
     118 S DIE=DIC K DIC
     119 S DA=+Y
     120 ;Finding record fields
     121 S DR=".01;3"
     122 ;Edit finding record
     123 D ^DIE
     124 I $D(Y) S DTOUT=1 Q
     125 I '$D(DA) Q
     126 ;If the function string is null don't do the rest of the fields.
     127 I $G(^PXD(811.9,IEN,25,DA,3))="" Q
     128 S DR="1;2;11;12;15;I X=""0Y"" S Y=16;13;14;16"
     129 D ^DIE
     130 I $D(Y) S DTOUT=1 Q
     131 I '$D(DA) Q
     132 ;Check if deleted
     133 Q
     134 ;
     135 ;Edit Reminder Function Findings
     136 ;----------------------
     137FFIND ;
     138 N DTOUT,DUOUT
     139 F  D  Q:$D(DUOUT)!$D(DTOUT)
     140 .D FFEDIT(DA) I $D(DUOUT)!$D(DTOUT) Q
     141 K DUOUT,DTOUT
     142 Q
     143 ;
     144 ;Edit Reminder Findings
     145 ;----------------------
     146FIND(LIST) ;
     147 N DTOUT,DUOUT,NODE,SDA
     148 D SET ; Check if node defined
     149 S NODE="^PXD(811.9)"
     150 F  D  Q:$D(DUOUT)!$D(DTOUT)
     151 .;Display list of existing reminder findings
     152 .W !!,"Reminder Definition Findings"
     153 .D DSPALL("D",NODE,DA,.LIST)
     154 .;Edit findings
     155 .D FEDIT(DA) I $D(DUOUT)!$D(DTOUT) D LIST^PXRMREDT(NODE,DA,.LIST) Q
     156 .;Update list with finding changes
     157 .D LIST^PXRMREDT(NODE,DA,.LIST)
     158 Q
     159 ;
     160 ;General help text routine
     161 ;-------------------------
     162HELP(CALL) ;
     163 N HTEXT
     164 N DIWF,DIWL,DIWR,IC
     165 S DIWF="C70",DIWL=0,DIWR=70
     166 ;
     167 I CALL=1 D
     168 .S HTEXT(1)="Select the type of finding you wish to change or add."
     169 .S HTEXT(2)="Type '?' for a list of the available finding types."
     170 I CALL=2 D
     171 .S HTEXT(1)="Select section of the reminder you wish to edit or 'All'"
     172 .S HTEXT(2)="to step through all sections of the reminder definition."
     173 I CALL=3 D
     174 .S HTEXT(1)="Select 'Y' to edit the findings mapped to this term"
     175 .S HTEXT(2)="or 'N' to return to select another reminder finding."
     176 ;
     177 K ^UTILITY($J,"W")
     178 S IC=""
     179 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     180 . S X=HTEXT(IC)
     181 . D ^DIWP
     182 W !
     183 S IC=0
     184 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     185 . W !,^UTILITY($J,"W",0,IC,0)
     186 K ^UTILITY($J,"W")
     187 W !
     188 Q
     189 ;
     190 ;Display TERM findings
     191 ;--------------------
     192TDSP(DA) ;
     193 N FIRST,SUB,TLST S FIRST=1,SUB="",SUB1=""
     194 ;Build list of term findings
     195 D TLST(.TLST,DA)
     196 ;Display list
     197 F  S SUB=$O(TLST(SUB)) Q:SUB=""  D
     198 .S SUB1=0
     199 .F  S SUB1=$O(TLST(SUB,SUB1)) Q:SUB1=""  D
     200 ..I FIRST S FIRST=0 W !!,"Reminder Term Findings:",!!
     201 ..W SUB
     202 ..W ?8,SUB1,!
     203 I FIRST W !!,"Term has no mapped findings",!!
     204 Q
     205 ;
     206 ;List Reminders using this term
     207 ;------------------------------
     208TERMS(TIEN,RIEN) ;
     209 ;RIEN will be the reminder ien if called from reminder edit
     210 ;or zero if called from term edit
     211 N ARRAY,FIND,IEN,SUB,TCNT,RNAME
     212 ;Scan all reminders in file #811.9
     213 S IEN=0,FIND="PXRMD(811.5,",TCNT=0
     214 F  S IEN=$O(^PXD(811.9,IEN)) Q:'IEN  D
     215 .;Exclude current reminder called in reminder edit
     216 .I RIEN,IEN=RIEN Q
     217 .;Check the term findings
     218 .I '$D(^PXD(811.9,IEN,20,"E",FIND,TIEN)) Q
     219 .;Add to reminder array
     220 .S RNAME=$P($G(^PXD(811.9,IEN,0)),U)
     221 .I RNAME="" S RNAME=IEN
     222 .I '$D(ARRAY(RNAME)) S TCNT=TCNT+1
     223 .S ARRAY(RNAME)=""
     224 ;
     225 ;Display list of reminders using the term
     226 I TCNT D
     227 .N TXT
     228 .S TXT="This Reminder Term is" S:RIEN TXT=TXT_" also"
     229 .S TXT=TXT_" used by the following Reminder Definition"
     230 .I TCNT>1 S TXT=TXT_"s"
     231 .W !!,TXT_":"
     232 .S RNAME="" F  S RNAME=$O(ARRAY(RNAME)) Q:RNAME=""  W !," ",RNAME
     233 Q
     234 ;
     235 ;------------------------------
     236 ;Check term for finding item to edit status item
     237TERMTYPE(TIEN) ;
     238 N DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,TYPE,VF
     239 S (DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,VF)=0
     240 S TYPE="" F  S TYPE=$O(^PXRMD(811.5,TIEN,20,"B",TYPE)) Q:TYPE=""  D
     241 . I TYPE["AUTTEDT(" S (OTHER,VF)=1 Q
     242 . I TYPE["AUTTHF(" S (HF,OTHER,VF)=1 Q
     243 . I TYPE["AUTTIMM(" S (OTHER,VF)=1 Q
     244 . I TYPE["AUTTSK(" S (OTHER,VF)=1 Q
     245 . I TYPE["ORD" S (ORD,FOUND)=1 Q
     246 . I TYPE["PS" S (DRUG,FOUND)=1 Q
     247 . I TYPE["PXD(811.2" S (FOUND,TAX,VF)=1 Q
     248 . I TYPE["RAMIS" S (FOUND,RAD)=1 Q
     249 . S OTHER=1
     250 I RAD=1,ORD=0,TAX=0,DRUG=0,OTHER=0 S RESULT="R"
     251 I RAD=0,ORD=1,TAX=0,DRUG=0,OTHER=0 S RESULT="O"
     252 I RAD=0,ORD=0,TAX=1,DRUG=0,OTHER=0 S RESULT="T"
     253 I RAD=0,ORD=0,TAX=0,DRUG=1,OTHER=0 S RESULT="D"
     254 I OTHER=1 S RESULT=1 I FOUND=1 S RESULT=2
     255 I RESULT="T" S RESULT=$$TAXTYPE^PXRMSTA1(TIEN,"")
     256 I HF=1 S RESULT="H"_RESULT
     257 I VF=1 S RESULT=RESULT_U_"VF"
     258 Q RESULT
     259 ;
     260 ;Build list of mapped findings for term
     261 ;--------------------------------------
     262TLST(ARRAY,DA) ;
     263 N TYPE,DATA,GLOB,IEN,NAME,NODE,SUB
     264 ;Clear passed arrays
     265 K ARRAY
     266 ;Build cross reference global to file number
     267 ;Get each finding
     268 S SUB=0 F  S SUB=$O(^PXRMD(811.5,DA,20,SUB)) Q:'SUB  D
     269 .S DATA=$G(^PXRMD(811.5,DA,20,SUB,0)) I DATA="" Q
     270 .;Determine global and global ien
     271 .S NODE=$P(DATA,U),GLOB=$P(NODE,";",2),IEN=$P(NODE,";")
     272 .;Ignore null entries
     273 .I (GLOB="")!(IEN="") Q
     274 .;Work out the file type
     275 .S TYPE=$G(DEF1(GLOB)) Q:TYPE=""
     276 .S NAME=$P($G(@(U_GLOB_IEN_",0)")),U)
     277 .S ARRAY(TYPE,NAME)=""
     278 Q
     279 ;
     280 ;Map Term findings
     281 ;-----------------
     282TMAP(RIEN,TIEN) ;
     283 N TOPT,TNAM
     284 ;Display any other reminders using this term
     285 D TERMS(TIEN,RIEN)
     286 ;Term name
     287 S TNAM=$P($G(^PXRMD(811.5,TIEN,0)),U)
     288 ;Give option to edit mapped findings (Y/N)
     289 D TMASK(.TOPT,TNAM) Q:$D(DUOUT)!($D(DTOUT))
     290 ;Edit term findings
     291 I TOPT="Y" D TRMED(TIEN)
     292 Q
     293 ;
     294 ;Option to edit term findings
     295 ;----------------------------
     296TMASK(YESNO,TNAM) ;
     297 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
     298 S DIR(0)="YA0"
     299 S DIR("A")="Do you want to edit mapped findings for "_TNAM_": "
     300 S (DIR("B"),YESNO)="N"
     301 S DIR("?")="Enter Y or N. For detailed help type ??"
     302 S DIR("??")=U_"D HELP^PXRMREDF(3)"
     303 W !
     304 D ^DIR K DIR
     305 I $D(DIROUT)!$D(DIRUT) Q
     306 I $D(DTOUT)!$D(DUOUT) Q
     307 S YESNO=$E(Y(0))
     308 Q
     309 ;
     310 ;Term edit
     311 ;---------
     312TRMED(DA) ;
     313 N CS1,CS2,DIC,DLAYGO,DTOUT,DUOUT,Y
     314 K DLAYGO,DTOUT,DUOUT,Y
     315 ;Display term findings
     316 D TDSP(DA)
     317 ;Initialize change history
     318 S CS1=$$FILE^PXRMEXCS(811.5,DA)
     319 ;Edit term findings
     320 S DIC="^PXRMD(811.5,"
     321 D EDIT^PXRMTMED(DIC,DA)
     322 ;Update change history
     323 S CS2=$$FILE^PXRMEXCS(811.5,DA)
     324 I CS2=0 Q
     325 I CS2'=CS1 D SEHIST^PXRMUTIL(811.5,DIC,DA)
     326 Q
     327 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMREDT.m

    r613 r623  
    1 PXRMREDT        ; SLC/PKR,PJH - Edit PXRM reminder definition. ;10/04/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=======================================================
    5 EEDIT   ;Entry point for PXRM DEFINITION EDIT option.
    6         ;Build list of finding file definitions.
    7         N DEF,DEF1,DEF2
    8         D DEF^PXRMRUTL("811.902",.DEF,.DEF1,.DEF2)
    9         ;
    10         N DA,DIC,DLAYGO,DTOUT,DUOUT,Y
    11         S DIC="^PXD(811.9,"
    12         S DIC(0)="AEMQL"
    13         S DIC("A")="Select Reminder Definition: "
    14         S DLAYGO=811.9
    15 GETNAME ;Get the name of the reminder definition to edit.
    16         ;Set the starting place for additions.
    17         D SETSTART^PXRMCOPY(DIC)
    18         W !
    19         S DIC("W")="W $$LUDISP^PXRMREDT(Y)"
    20         D ^DIC
    21         I ($D(DTOUT))!($D(DUOUT)) Q
    22         I Y=-1 G END
    23         S DA=$P(Y,U,1)
    24         D ALL(DIC,DA)
    25         G GETNAME
    26 END     ;
    27         Q
    28         ;
    29         ;=======================================================
    30         ;Select section of reminder to edit, also called at ALL by PXRMEDIT.
    31         ;----------------------------------
    32 ALL(DIC,DA)     ;
    33         ;Get list of findings/terms for reminder
    34         N BLDLOGIC,CS1,CS2,LIST,NODE,OPTION,TYPE
    35         S BLDLOGIC=0
    36         ;Save the original checksum.
    37         S CS1=$$FILE^PXRMEXCS(811.9,DA)
    38         ;Build finding list
    39         S NODE="^PXD(811.9)"
    40         D LIST(NODE,DA,.LIST)
    41         ;If this is a new reminder enter all fields
    42         I $P(Y,U,3)=1 D EDIT(DIC,DA) Q
    43         ;National reminder allows editing of term findings only
    44         I '$$VEDIT^PXRMUTIL(DIC,DA) D  Q:$D(DUOUT)!$D(DTOUT)
    45         .S TYPE=""
    46         .F  S TYPE=$O(LIST(TYPE)) Q:TYPE=""  D
    47         .. I TYPE="RT" Q
    48         .. K LIST(TYPE)
    49         .I '$D(LIST) S DUOUT=1 Q
    50         .S BLDLOGIC=1
    51         .D TFIND(DA,.LIST)
    52         .I $D(Y) S DUOUT=1
    53         ;Otherwise choose fields to edit
    54         I $$VEDIT^PXRMUTIL(DIC,DA) F  D  Q:$D(DUOUT)!$D(DTOUT)
    55         .D OPTION Q:$D(DUOUT)!$D(DTOUT)
    56         .;All details
    57         .I OPTION="A" D
    58         .. S BLDLOGIC=1
    59         .. D EDIT(DIC,DA)
    60         .;Set up local variables
    61         .N DIE,DR S DIE=DIC N DIC
    62         .;Descriptions
    63         .I OPTION="G" D
    64         ..D GEN
    65         .;Baseline Frequency
    66         .I OPTION="B" D
    67         ..S BLDLOGIC=1
    68         ..D BASE
    69         .;Findings
    70         .I OPTION="F"  D
    71         ..S BLDLOGIC=1
    72         ..D FIND(.LIST)
    73         .;Function findings
    74         .I OPTION="FF"  D
    75         ..S BLDLOGIC=1
    76         ..D FFIND
    77         .;Logic
    78         .I OPTION="L" D
    79         ..S BLDLOGIC=1
    80         ..D LOGIC
    81         .;Custom date due
    82         . I OPTION="C" D
    83         ..S BLDLOGIC=1
    84         ..D CDUE
    85         .;Dialog
    86         .I OPTION="D" D
    87         ..D DIALOG
    88         .;Web addresses
    89         .I OPTION="W" D
    90         ..D WEB
    91         .;If necessary build the internal logic strings.
    92         .I BLDLOGIC D BLDALL^PXRMLOGX(DA,"","")
    93         ;See if any changes have been made.
    94         S CS2=$$FILE^PXRMEXCS(811.9,DA)
    95         I CS2=0 Q
    96         ;If the file has been edited, do the edit history.
    97         I CS2'=CS1 D SEHIST^PXRMUTIL(811.9,DIC,DA)
    98         Q
    99         ;
    100         ;Reminder Edit
    101         ;-------------
    102 EDIT(ROOT,DA)   ;
    103         N DIC,DIDEL,DIE,DR,RESULT
    104         S DIE=ROOT,DIDEL=811.9
    105         ;Edit the fields in the same order they are printed by a reminder
    106         ;inquiry.
    107         ;Reminder name
    108         W !!
    109         S DR=".01"
    110         D ^DIE
    111         ;If DA is undefined then the entry was deleted and we are done.
    112         I '$D(DA) S DTOUT=1 Q
    113         I $D(Y) S DTOUT=1 Q
    114         ;
    115         ;Other fields
    116         D GEN Q:$D(Y)
    117         D BASE Q:$D(Y)
    118         D FIND(.LIST) Q:$D(Y)
    119         D FFIND Q:$D(Y)
    120         D LOGIC Q:$D(Y)
    121         D DIALOG Q:$D(Y)
    122         D WEB Q:$D(Y)
    123         Q
    124         ;
    125 GEN     ;Print name
    126         W !!
    127         S DR="1.2"
    128         D ^DIE
    129         I $D(Y) Q
    130         ;
    131 CLASS   ;
    132         ;Class
    133         W !!
    134         S DR="100"
    135         D ^DIE
    136         I $D(Y) Q
    137         ;Sponsor
    138         S DR="101"
    139         D ^DIE
    140         I $D(Y) Q
    141         ;Make sure Class and Sponsor Class are in synch.
    142         S RESULT=$$VSPONSOR^PXRMINTR(X)
    143         I RESULT=0 G CLASS
    144         ;Review date, Usage
    145         S DR="102;103"
    146         D ^DIE
    147         I $D(Y) Q
    148         ;
    149         ;Related VA-* reminder
    150         W !!
    151         S DR="1.4"
    152         D ^DIE
    153         I $D(Y) Q
    154         ;
    155         ;Inactive flag
    156         W !!
    157         S DR="1.6"
    158         D ^DIE
    159         I $D(Y) Q
    160         ;Ignore on N/A
    161         S DR=1.8
    162         D ^DIE
    163         I $D(Y) Q
    164         ;
    165         ;Recision Date
    166         S DR="69"
    167         D ^DIE
    168         I $D(Y) Q
    169         ;
    170         ;Reminder description
    171         W !!
    172         S DR="2"
    173         D ^DIE
    174         I $D(Y) Q
    175         ;
    176         ;Technical description
    177         W !!
    178         S DR="3"
    179         D ^DIE
    180         ;
    181         ;Priority
    182         W !!
    183         S DR="1.91"
    184         D ^DIE
    185         Q
    186         ;
    187 BASE    W !!,"Baseline Frequency"
    188         ;Do in advance time frame
    189         S DR=1.3
    190         D ^DIE
    191         I $D(Y) Q
    192         ;
    193         ;Sex specific
    194         S DR=1.9
    195         D ^DIE
    196         I $D(Y) Q
    197 FARS    ;
    198         W !!,"Baseline frequency age range set"
    199         S DR="7"
    200         S DR(2,811.97)=".01;1;2;3;4"
    201         D ^DIE
    202         I $$OVLAP^PXRMAGE G FARS
    203         D SNMLA^PXRMFNFT(DA)
    204         Q
    205         ;
    206 FIND(LIST)      ;Edit findings (multiple)
    207         D FIND^PXRMREDF(.LIST)
    208         D SNMLF^PXRMFNFT(DA,20)
    209         Q
    210         ;
    211 FFIND   W !!,"Function Findings"
    212         D FFIND^PXRMREDF
    213         D SNMLF^PXRMFNFT(DA,25)
    214         Q
    215         ;
    216 LOGIC   W !!,"Patient Cohort and Resolution Logic"
    217         S DR="30T;60T;61T;70T;71T;34T;65T;66T;75T;76T"
    218         D ^DIE
    219         ;Make sure the Patient Cohort Logic at least contains the default.
    220         I $G(^PXD(811.9,DA,31))="" D
    221         . S ^PXD(811.9,DA,31)="(SEX)&(AGE)"
    222         . S ^PXD(811.9,DA,32)="2"_U_"SEX;AGE"
    223         D SNMLL^PXRMFNFT(DA)
    224         Q
    225 CDUE    W !!,"Custom Date Due"
    226         S DR=45
    227         D ^DIE
    228         Q
    229         ;
    230 DIALOG  W !!,"Reminder Dialog"
    231         S DR="51"
    232         D ^DIE
    233         Q
    234         ;
    235 WEB     W !!,"Web Addresses for Reminder Information"
    236         S DR="50"
    237         D ^DIE
    238         Q
    239         ;
    240         ;Get full list of findings
    241         ;-------------------------
    242 LIST(GBL,DA,ARRAY)      ;
    243         N CNT,DATA,GLOB,IEN,NAME,NODE,SUB,TYPE
    244         ;Clear passed arrays
    245         K ARRAY
    246         S CNT=0
    247         ;Build cross reference global to file number
    248         ;Get each finding
    249         S SUB=0 F  S SUB=$O(@GBL@(DA,20,SUB)) Q:'SUB  D
    250         .S DATA=$G(@GBL@(DA,20,SUB,0)) I DATA="" Q
    251         .;Determine global and global ien
    252         .S NODE=$P(DATA,U),GLOB=$P(NODE,";",2),IEN=$P(NODE,";")
    253         .;Ignore null entries
    254         .I (GLOB="")!(IEN="") Q
    255         .;Work out the file type
    256         .S TYPE=$G(DEF1(GLOB)) Q:TYPE=""
    257         .S CNT=CNT+1
    258         .I $P($G(@(U_GLOB_IEN_",0)")),U)="" D
    259         ..W !,"**WARNING** Finding #"_SUB_" does not exist, select finding `"_SUB_" to edit it." Q
    260         .E  S NAME=$P($G(@(U_GLOB_IEN_",0)")),U) S ARRAY(TYPE,NAME,SUB)=IEN
    261         .;E  S NAME=$P($G(@(U_GLOB_IEN_",0)")),U) S ARRAY(TYPE,NAME,SUB)=$G(SUB)
    262         Q
    263         ;
    264         ;Choose which part of Reminder to edit
    265         ;-------------------------------------
    266 OPTION  N DIR,X,Y
    267         ;Display warning message if un-mapped terms exist
    268         K DIROUT,DIRUT,DTOUT,DUOUT
    269         S DIR(0)="SO"_U
    270         S DIR(0)=DIR(0)_"A:All reminder details;"
    271         S DIR(0)=DIR(0)_"G:General;"
    272         S DIR(0)=DIR(0)_"B:Baseline Frequency;"
    273         S DIR(0)=DIR(0)_"F:Findings;"
    274         S DIR(0)=DIR(0)_"FF:Function Findings;"
    275         S DIR(0)=DIR(0)_"L:Logic;"
    276         S DIR(0)=DIR(0)_"C:Custom date due;"
    277         S DIR(0)=DIR(0)_"D:Reminder Dialog;"
    278         S DIR(0)=DIR(0)_"W:Web Addresses;"
    279         S DIR("A")="Select section to edit"
    280         S DIR("?")="Select which section of the reminder you wish to edit."
    281         S DIR("??")="^D HELP^PXRMREDF(2)"
    282         D ^DIR K DIR
    283         I Y="" S DUOUT=1 Q
    284         I $D(DIROUT) S DTOUT=1
    285         I $D(DTOUT)!$D(DUOUT) Q
    286         S OPTION=Y
    287         Q
    288         ;
    289         ;-------------------------------------
    290 LUDISP(IEN)     ;Use for DIC("W") to augment look-up display.
    291         N CLASS,EM,INACTIVE,TEXT
    292         S INACTIVE=$P(^PXD(811.9,IEN,0),U,6)
    293         S CLASS=$P(^PXD(811.9,IEN,100),U,1)
    294         I INACTIVE'="" S INACTIVE="("_$$EXTERNAL^DILFD(811.9,1.6,"",INACTIVE,.EM)_")"
    295         S CLASS=$$EXTERNAL^DILFD(811.9,100,"",CLASS,.EM)
    296         S TEXT="  "_CLASS_" "_INACTIVE
    297         Q TEXT
    298         ;
    299         ;-------------------------------------
    300 TFIND(DA,LIST)  ;Allow edit of term findings for national reminders.
    301         N DIR,IENLIST,IND,JND,NAME,NAMELIST,SUB,X,Y
    302         S IND=0,NAME=""
    303         F  S NAME=$O(LIST("RT",NAME)) Q:NAME=""  D
    304         . S IND=IND+1
    305         . S NAMELIST(IND)=$$RJ^XLFSTR(IND,3)_" "_NAME
    306         . S SUB=$O(LIST("RT",NAME,""))
    307         . S IENLIST(IND)=LIST("RT",NAME,SUB)
    308         M DIR("A")=NAMELIST
    309         S DIR("A")="Enter your list"
    310         S DIR(0)="LO^1:"_IND
    311         W !!,"Select term(s) for finding edit:"
    312         D ^DIR
    313         I $D(DIROUT)!$D(DIRUT) S LIST="" Q
    314         I $D(DUOUT)!$D(DTOUT) S LIST="" Q
    315         F IND=1:1:$L(Y,",")-1 D
    316         . S JND=$P(Y,",",IND)
    317         . S NAME=$P(NAMELIST(JND),JND,2)
    318         . W !!,"Reminder Term:",NAME
    319         . D TMAP^PXRMREDF(DA,IENLIST(JND))
    320         Q
    321         ;
     1PXRMREDT ; SLC/PKR,PJH - Edit PXRM reminder definition. ;02/09/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=======================================================
     5EEDIT ;Entry point for PXRM DEFINITION EDIT option.
     6 ;Build list of finding file definitions.
     7 N DEF,DEF1,DEF2
     8 D DEF^PXRMRUTL("811.902",.DEF,.DEF1,.DEF2)
     9 ;
     10 N DA,DIC,DLAYGO,DTOUT,DUOUT,Y
     11 S DIC="^PXD(811.9,"
     12 S DIC(0)="AEMQL"
     13 S DIC("A")="Select Reminder Definition: "
     14 S DLAYGO=811.9
     15GETNAME ;Get the name of the reminder definition to edit.
     16 ;Set the starting place for additions.
     17 D SETSTART^PXRMCOPY(DIC)
     18 W !
     19 D ^DIC
     20 I ($D(DTOUT))!($D(DUOUT)) Q
     21 I Y=-1 G END
     22 S DA=$P(Y,U,1)
     23 D ALL(DIC,DA)
     24 G GETNAME
     25END ;
     26 Q
     27 ;
     28 ;=======================================================
     29 ;Select section of reminder to edit, also called at ALL by PXRMEDIT.
     30 ;----------------------------------
     31ALL(DIC,DA) ;
     32 ;Get list of findings/terms for reminder
     33 N BLDLOGIC,CS1,CS2,LIST,NODE,OPTION,TYPE
     34 S BLDLOGIC=0
     35 ;Save the original checksum.
     36 S CS1=$$FILE^PXRMEXCS(811.9,DA)
     37 ;Build finding list
     38 S NODE="^PXD(811.9)"
     39 D LIST(NODE,DA,.LIST)
     40 ;If this is a new reminder enter all fields
     41 I $P(Y,U,3)=1 D EDIT(DIC,DA) Q
     42 ;National reminder allows editing of term findings only
     43 I '$$VEDIT^PXRMUTIL(DIC,DA) D  Q:$D(DUOUT)!$D(DTOUT)
     44 .S TYPE=""
     45 .F  S TYPE=$O(LIST(TYPE)) Q:TYPE=""  D
     46 .. I TYPE="RT" Q
     47 .. K LIST(TYPE)
     48 .I '$D(LIST) S DUOUT=1 Q
     49 .S BLDLOGIC=1
     50 .D TFIND(DA,.LIST)
     51 .I $D(Y) S DUOUT=1
     52 ;Otherwise choose fields to edit
     53 I $$VEDIT^PXRMUTIL(DIC,DA) F  D  Q:$D(DUOUT)!$D(DTOUT)
     54 .D OPTION Q:$D(DUOUT)!$D(DTOUT)
     55 .;All details
     56 .I OPTION="A" D
     57 .. S BLDLOGIC=1
     58 .. D EDIT(DIC,DA)
     59 .;Set up local variables
     60 .N DIE,DR S DIE=DIC N DIC
     61 .;Descriptions
     62 .I OPTION="G" D
     63 ..D GEN
     64 .;Baseline Frequency
     65 .I OPTION="B" D
     66 ..S BLDLOGIC=1
     67 ..D BASE
     68 .;Findings
     69 .I OPTION="F"  D
     70 ..S BLDLOGIC=1
     71 ..D FIND(.LIST)
     72 .;Function findings
     73 .I OPTION="FF"  D
     74 ..S BLDLOGIC=1
     75 ..D FFIND
     76 .;Logic
     77 .I OPTION="L" D
     78 ..S BLDLOGIC=1
     79 ..D LOGIC
     80 .;Custom date due
     81 . I OPTION="C" D
     82 ..S BLDLOGIC=1
     83 ..D CDUE
     84 .;Dialog
     85 .I OPTION="D" D
     86 ..D DIALOG
     87 .;Web addresses
     88 .I OPTION="W" D
     89 ..D WEB
     90 .;If necessary build the internal logic strings.
     91 .I BLDLOGIC D BLDALL^PXRMLOGX(DA,"","")
     92 ;See if any changes have been made.
     93 S CS2=$$FILE^PXRMEXCS(811.9,DA)
     94 I CS2=0 Q
     95 ;If the file has been edited, do the edit history.
     96 I CS2'=CS1 D SEHIST^PXRMUTIL(811.9,DIC,DA)
     97 Q
     98 ;
     99 ;Reminder Edit
     100 ;-------------
     101EDIT(ROOT,DA) ;
     102 N DIC,DIDEL,DIE,DR,RESULT
     103 S DIE=ROOT,DIDEL=811.9
     104 ;Edit the fields in the same order they are printed by a reminder
     105 ;inquiry.
     106 ;Reminder name
     107 W !!
     108 S DR=".01"
     109 D ^DIE
     110 ;If DA is undefined then the entry was deleted and we are done.
     111 I '$D(DA) S DTOUT=1 Q
     112 I $D(Y) S DTOUT=1 Q
     113 ;
     114 ;Other fields
     115 D GEN Q:$D(Y)
     116 D BASE Q:$D(Y)
     117 D FIND(.LIST) Q:$D(Y)
     118 D FFIND Q:$D(Y)
     119 D LOGIC Q:$D(Y)
     120 D DIALOG Q:$D(Y)
     121 D WEB Q:$D(Y)
     122 Q
     123 ;
     124GEN ;Print name
     125 W !!
     126 S DR="1.2"
     127 D ^DIE
     128 I $D(Y) Q
     129 ;
     130CLASS ;
     131 ;Class
     132 W !!
     133 S DR="100"
     134 D ^DIE
     135 I $D(Y) Q
     136 ;Sponsor
     137 S DR="101"
     138 D ^DIE
     139 I $D(Y) Q
     140 ;Make sure Class and Sponsor Class are in synch.
     141 S RESULT=$$VSPONSOR^PXRMINTR(X)
     142 I RESULT=0 G CLASS
     143 ;Review date, Usage
     144 S DR="102;103"
     145 D ^DIE
     146 I $D(Y) Q
     147 ;
     148 ;Related VA-* reminder
     149 W !!
     150 S DR="1.4"
     151 D ^DIE
     152 I $D(Y) Q
     153 ;
     154 ;Inactive flag
     155 W !!
     156 S DR="1.6"
     157 D ^DIE
     158 I $D(Y) Q
     159 ;Ignore on N/A
     160 S DR=1.8
     161 D ^DIE
     162 I $D(Y) Q
     163 ;
     164 ;Recision Date
     165 S DR="69"
     166 D ^DIE
     167 I $D(Y) Q
     168 ;
     169 ;Reminder description
     170 W !!
     171 S DR="2"
     172 D ^DIE
     173 I $D(Y) Q
     174 ;
     175 ;Technical description
     176 W !!
     177 S DR="3"
     178 D ^DIE
     179 ;
     180 ;Priority
     181 W !!
     182 S DR="1.91"
     183 D ^DIE
     184 Q
     185 ;
     186BASE W !!,"Baseline Frequency"
     187 ;Do in advance time frame
     188 S DR=1.3
     189 D ^DIE
     190 I $D(Y) Q
     191 ;
     192 ;Sex specific
     193 S DR=1.9
     194 D ^DIE
     195 I $D(Y) Q
     196FARS ;
     197 W !!,"Baseline frequency age range set"
     198 S DR="7"
     199 S DR(2,811.97)=".01;1;2;3;4"
     200 D ^DIE
     201 I $$OVLAP^PXRMAGE G FARS
     202 D SNMLA^PXRMFNFT(DA)
     203 Q
     204 ;
     205FIND(LIST) ;Edit findings (multiple)
     206 D FIND^PXRMREDF(.LIST)
     207 D SNMLF^PXRMFNFT(DA,20)
     208 Q
     209 ;
     210FFIND W !!,"Function Findings"
     211 D FFIND^PXRMREDF
     212 D SNMLF^PXRMFNFT(DA,25)
     213 Q
     214 ;
     215LOGIC W !!,"Patient Cohort and Resolution Logic"
     216 S DR="30T;60T;61T;70T;71T;34T;65T;66T;75T;76T"
     217 D ^DIE
     218 ;Make sure the Patient Cohort Logic at least contains the default.
     219 I $G(^PXD(811.9,DA,31))="" D
     220 . S ^PXD(811.9,DA,31)="(SEX)&(AGE)"
     221 . S ^PXD(811.9,DA,32)="2"_U_"SEX;AGE"
     222 D SNMLL^PXRMFNFT(DA)
     223 Q
     224CDUE W !!,"Custom Date Due"
     225 S DR=45
     226 D ^DIE
     227 Q
     228 ;
     229DIALOG W !!,"Reminder Dialog"
     230 S DR="51"
     231 D ^DIE
     232 Q
     233 ;
     234WEB W !!,"Web Addresses for Reminder Information"
     235 S DR="50"
     236 D ^DIE
     237 Q
     238 ;
     239 ;Get full list of findings
     240 ;-------------------------
     241LIST(GBL,DA,ARRAY) ;
     242 N CNT,DATA,GLOB,IEN,NAME,NODE,SUB,TYPE
     243 ;Clear passed arrays
     244 K ARRAY
     245 S CNT=0
     246 ;Build cross reference global to file number
     247 ;Get each finding
     248 S SUB=0 F  S SUB=$O(@GBL@(DA,20,SUB)) Q:'SUB  D
     249 .S DATA=$G(@GBL@(DA,20,SUB,0)) I DATA="" Q
     250 .;Determine global and global ien
     251 .S NODE=$P(DATA,U),GLOB=$P(NODE,";",2),IEN=$P(NODE,";")
     252 .;Ignore null entries
     253 .I (GLOB="")!(IEN="") Q
     254 .;Work out the file type
     255 .S TYPE=$G(DEF1(GLOB)) Q:TYPE=""
     256 .S CNT=CNT+1
     257 .I $P($G(@(U_GLOB_IEN_",0)")),U)="" D
     258 ..W !,"**WARNING** Finding #"_SUB_" does not exist, select finding `"_SUB_" to edit it." Q
     259 .E  S NAME=$P($G(@(U_GLOB_IEN_",0)")),U) S ARRAY(TYPE,NAME,SUB)=IEN
     260 .;E  S NAME=$P($G(@(U_GLOB_IEN_",0)")),U) S ARRAY(TYPE,NAME,SUB)=$G(SUB)
     261 Q
     262 ;
     263 ;Choose which part of Reminder to edit
     264 ;-------------------------------------
     265OPTION N DIR,X,Y
     266 ;Display warning message if un-mapped terms exist
     267 K DIROUT,DIRUT,DTOUT,DUOUT
     268 S DIR(0)="SO"_U
     269 S DIR(0)=DIR(0)_"A:All reminder details;"
     270 S DIR(0)=DIR(0)_"G:General;"
     271 S DIR(0)=DIR(0)_"B:Baseline Frequency;"
     272 S DIR(0)=DIR(0)_"F:Findings;"
     273 S DIR(0)=DIR(0)_"FF:Function Findings;"
     274 S DIR(0)=DIR(0)_"L:Logic;"
     275 S DIR(0)=DIR(0)_"C:Custom date due;"
     276 S DIR(0)=DIR(0)_"D:Reminder Dialog;"
     277 S DIR(0)=DIR(0)_"W:Web Addresses;"
     278 S DIR("A")="Select section to edit"
     279 S DIR("?")="Select which section of the reminder you wish to edit."
     280 S DIR("??")="^D HELP^PXRMREDF(2)"
     281 D ^DIR K DIR
     282 I Y="" S DUOUT=1 Q
     283 I $D(DIROUT) S DTOUT=1
     284 I $D(DTOUT)!$D(DUOUT) Q
     285 S OPTION=Y
     286 Q
     287 ;
     288 ;-------------------------------------
     289TFIND(DA,LIST) ;Allow edit of term findings for national reminders.
     290 N DIR,IENLIST,IND,NAME,NAMELIST,SUB,X,Y
     291 S IND=0,NAME=""
     292 F  S NAME=$O(LIST("RT",NAME)) Q:NAME=""  D
     293 . S IND=IND+1
     294 . S NAMELIST(IND)=$$RJ^XLFSTR(IND,3)_" "_NAME
     295 . S SUB=$O(LIST("RT",NAME,""))
     296 . S IENLIST(IND)=LIST("RT",NAME,SUB)
     297 M DIR("A")=NAMELIST
     298 S DIR("A")="Enter your list"
     299 S DIR(0)="LO^1:"_IND
     300 W !!,"Select term(s) for finding edit:"
     301 D ^DIR
     302 I $D(DIROUT)!$D(DIRUT) S LIST="" Q
     303 I $D(DUOUT)!$D(DTOUT) S LIST="" Q
     304 S LIST=Y
     305 F IND=1:1:$L(Y,",")-1 D
     306 . S NAME=$P(NAMELIST(IND),IND,2)
     307 . W !!,"Reminder Term:",NAME
     308 . D TMAP^PXRMREDF(DA,IENLIST(IND))
     309 Q
     310 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMRPCC.m

    r613 r623  
    1 PXRMRPCC        ;SLC/PJH - PXRM REMINDER DIALOG ;11/26/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4 ACTIVE(ORY,ORREM)       ;Check if active dialog exist for reminders
    5         ;
    6         ; input parameter ORREM is array of reminder ien [.01#811.9]
    7         N DDIS,DIEN,OCNT,RIEN,RSTA
    8         S OCNT=0,RIEN=0
    9         ;Get reminder ien from array
    10         F  S RIEN=$O(ORREM(RIEN)) Q:'RIEN  D
    11         .;Dialog ien for reminder
    12         .S DIEN=$P($G(^PXD(811.9,RIEN,51)),U),RSTA=0
    13         .;Dialog status
    14         .I DIEN S DDIS=$P($G(^PXRMD(801.41,DIEN,0)),U,3)
    15         .;If dialog and dialog not disabled
    16         .I DIEN,DDIS="" S RSTA=1
    17         .;Return reminder and if active dialog exists
    18         .S OCNT=OCNT+1,ORY(OCNT)=RIEN_U_RSTA
    19         Q
    20         ;
    21         ;
    22 DIALOG(ORY,ORREM,DFN)   ;Load reminder dialog associated with the reminder
    23         ;
    24         ; input parameter ORREM - reminder ien [.01,#811.9]
    25         ;
    26         S RIEN=ORREM
    27         N DATA,DIEN
    28         S DIEN=$G(^PXD(811.9,ORREM,51))
    29         ;
    30         ;Quit if no dialog for this reminder
    31         I 'DIEN S ORY(1)="-1^no dialog for this reminder" Q
    32         ;
    33         ;Check if a reminder dialog and enabled
    34         S DATA=$G(^PXRMD(801.41,DIEN,0))
    35         ;
    36         I $P(DATA,U,4)'="R" S ORY(1)="-1^reminder dialog invalid" Q
    37         ;
    38         I $P(DATA,U,3) S ORY(1)="-1^reminder dialog disabled" Q
    39         ;
    40         ;Load dialog lines into local array
    41         S ORY(0)=0_U_+$P($G(^PXRMD(801.41,DIEN,0)),U,17)
    42         D LOAD^PXRMDLL(DIEN,$G(DFN))
    43         Q
    44         ;
    45 HDR(ORY,ORLOC)  ;Progress Note Header by location/service/user
    46         N ORSRV,PASS
    47         ;S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
    48         S ORSRV=$$GET1^DIQ(200,DUZ,29,"I")
    49         S PASS=DUZ_";VA(200,"
    50         I +$G(ORLOC) S PASS=PASS_"^LOC.`"_ORLOC
    51         I ORSRV>0 S PASS=PASS_"^SRV.`"_+$G(ORSRV)
    52         S ORY=$$GET^XPAR(PASS_"^DIV^SYS^PKG","PXRM PROGRESS NOTE HEADERS",1,"Q")
    53         Q
    54         ;
    55 PROMPT(ORY,ORDLG,ORDCUR,ORFTYP) ;Load additional prompts for a dialog element
    56         ;
    57         ; input parameters
    58         ;
    59         ; ORDLG  - dialog element ien [.01,#801.41]
    60         ; ORDCUR - 0 = current, 1 = Historical for taxonomies only
    61         ; ORFTYP - finding type (CPT/POV) for taxonomies only
    62         ;
    63         ; These fields can be found in the output array of DIALOG^PXRMRPCC
    64         ;
    65         D LOAD^PXRMDLLA(ORDLG,ORDCUR,$G(ORFTYP))
    66         Q
    67         ;
    68 RES(ORY,ORREM)  ; Reminder Resources/Inquiry
    69         ;
    70         ; input parameter ORREM - reminder ien [.01,#811.9]
    71         ;
    72         D REMVAR^PXRMINQ(.ORY,ORREM)
    73         Q
    74         ;
    75 MH(ORY,OTEST)   ; Mental Health dialog
    76         ;
    77         ; Input mental health instrument NAME
    78         ;
    79         K ^TMP($J,"YSQU")
    80         N ARRAY,CNT,CNT1,FNODE,FSUB,IC,NODE,OCNT,SUB,YS
    81         ;DBIA #5056
    82         S YS("CODE")=OTEST D SHOWALL^YTQPXRM5(.ARRAY,.YS)
    83         S OCNT=0,CNT=0
    84         S SUB="ARRAY",OCNT=0
    85         F  S SUB=$Q(@SUB) Q:SUB=""  D
    86         .S FSUB=$P($P(SUB,"(",2),")"),FNODE=""
    87         .F IC=1:1 S NODE=$P(FSUB,",",IC) Q:NODE=""  D
    88         ..I $E(NODE)="""" S NODE=$P(NODE,"""",2)
    89         ..S $P(FNODE,";",IC)=NODE
    90         .Q:FNODE=""
    91         .S OCNT=OCNT+1,ORY(OCNT)=FNODE_U_@SUB
    92         Q
    93         ;
    94 MHR(ORY,RESULT,ORES)    ; Mental Health score and P/N text
    95         ;
    96         ; Input MH result IEN and mental health instrument response
    97         ;
    98         D START^PXRMDLR(.ORY,RESULT,.ORES)
    99         ;
    100         Q
    101         ;
    102 MHS(ORY,YS)     ; Mental Health save response
    103         ;
    104         ; Input mental health instrument response
    105         N ANS,ARRAY,X
    106         S ANS=$G(YS("R1")) K YS("R1")
    107         S YS("ADATE")=YS("ADATE")_"."_$P($$NOW^XLFDT,".",2)
    108         F X=1:1:$L(ANS) I $E(ANS,X)'="X" S YS(X)=X_U_$E(ANS,X)
    109         ;DBIA #4463
    110         D SAVECR^YTQPXRM4(.ARRAY,.YS)
    111         Q
    112         ;
    113 MST(ORY,DFN,DGMSTDT,DGMSTSC,DGMSTPR,FTYP,FIEN,RESULT)   ; File MST status
    114         ;This is obsolete and can be removed when the GUI is changed not
    115         ;to use it.
    116         Q
    117         ;
    118 WH(ORY,RESULT)  ;
    119         N CNT,CNT1,CNT2,NODE,PIECNT,PUR,TYPE,TYP1,WVIEN,WVRESULT,WVNOT,WVPURIEN
    120         N PRINT
    121         K ^TMP("WV RPT",$J)
    122         I '$D(RESULT) Q
    123         S (CNT2,WVPURIEN,PUR)=0
    124         S CNT=0 F  S CNT=$O(RESULT(CNT)) Q:CNT=""  D
    125         . I $P($G(RESULT(CNT)),U)["WHIEN" D
    126         . . S CNT2=CNT2+1
    127         . . S WVIEN=$P($P($G(RESULT(CNT)),U),":",2),WVRESULT(CNT2)=$G(WVIEN)
    128         . . S WVRESULT(CNT2)=WVRESULT(CNT2)_U_$P($P($G(RESULT(CNT)),U,3),":",2)
    129         . I $P($G(RESULT(CNT)),U)["WHPur" D
    130         . . S NODE=$G(RESULT(CNT)),PUR=$P($P($G(NODE),U),":",2)
    131         . . S CNT1=1,TYPE=$P($G(NODE),U,2)
    132         . . I TYPE'[":" D
    133         ...S WVNOT(PUR,CNT1)=$P($G(NODE),U,5)_U_$P($G(NODE),U,2)_U_$P($G(NODE),U,3)_U_$P($P($G(NODE),U,4),":",2)
    134         ..I TYPE[":" D
    135         ...S PIECNT=0
    136         ...F X=1:1:$L(TYPE) I $E(TYPE,X)=":" S PIECNT=PIECNT+1 I PIECNT>0 D
    137         ....S PRINT=""
    138         ....S TYP1=$P($G(TYPE),":",PIECNT)
    139         ....I TYP1="L" S PRINT=$P($G(NODE),U,3)
    140         ....S WVNOT(PUR,CNT1)=$P($G(NODE),U,5)_U_$G(TYP1)_U_$G(PRINT)_U_$P($P($G(NODE),U,4),":",2),CNT1=CNT1+1
    141         ...S PIECNT=PIECNT+1
    142         ...S PRINT=""
    143         ...S TYP1=$P($G(TYPE),":",PIECNT)
    144         ...I TYP1="L" S PRINT=$P($G(NODE),U,3)
    145         ...S WVNOT(PUR,CNT1)=$P($G(NODE),U,5)_U_$G(TYP1)_U_$G(PRINT)_U_$P($P($G(NODE),U,4),":",2)
    146         K WHMUFIND,WHFIND,WHNAME
    147         ;DBIA #4104
    148         D NEW^WVRPCNO(.WVRESULT,.WVNOT)
    149         Q
    150         ;
     1PXRMRPCC ;SLC/PJH - PXRM REMINDER DIALOG ;04/12/2002
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4ACTIVE(ORY,ORREM) ;Check if active dialog exist for reminders
     5 ;
     6 ; input parameter ORREM is array of reminder ien [.01#811.9]
     7 N DDIS,DIEN,OCNT,RIEN,RSTA
     8 S OCNT=0,RIEN=0
     9 ;Get reminder ien from array
     10 F  S RIEN=$O(ORREM(RIEN)) Q:'RIEN  D
     11 .;Dialog ien for reminder
     12 .S DIEN=$P($G(^PXD(811.9,RIEN,51)),U),RSTA=0
     13 .;Dialog status
     14 .I DIEN S DDIS=$P($G(^PXRMD(801.41,DIEN,0)),U,3)
     15 .;If dialog and dialog not disabled
     16 .I DIEN,DDIS="" S RSTA=1
     17 .;Return reminder and if active dialog exists
     18 .S OCNT=OCNT+1,ORY(OCNT)=RIEN_U_RSTA
     19 Q
     20 ;
     21 ;
     22DIALOG(ORY,ORREM,DFN) ;Load reminder dialog associated with the reminder
     23 ;
     24 ; input parameter ORREM - reminder ien [.01,#811.9]
     25 ;
     26 S RIEN=ORREM
     27 N DATA,DIEN
     28 S DIEN=$G(^PXD(811.9,ORREM,51))
     29 ;
     30 ;Quit if no dialog for this reminder
     31 I 'DIEN S ORY(1)="-1^no dialog for this reminder" Q
     32 ;
     33 ;Check if a reminder dialog and enabled
     34 S DATA=$G(^PXRMD(801.41,DIEN,0))
     35 ;
     36 I $P(DATA,U,4)'="R" S ORY(1)="-1^reminder dialog invalid" Q
     37 ;
     38 I $P(DATA,U,3) S ORY(1)="-1^reminder dialog disabled" Q
     39 ;
     40 ;Load dialog lines into local array
     41 D LOAD^PXRMDLL(DIEN,$G(DFN))
     42 Q
     43 ;
     44HDR(ORY,ORLOC) ;Progress Note Header by location/service/user
     45 N ORSRV,PASS
     46 ;S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
     47 S ORSRV=$$GET1^DIQ(200,DUZ,29,"I")
     48 S PASS=DUZ_";VA(200,"
     49 I +$G(ORLOC) S PASS=PASS_"^LOC.`"_ORLOC
     50 I ORSRV>0 S PASS=PASS_"^SRV.`"_+$G(ORSRV)
     51 S ORY=$$GET^XPAR(PASS_"^DIV^SYS^PKG","PXRM PROGRESS NOTE HEADERS",1,"Q")
     52 Q
     53 ;
     54PROMPT(ORY,ORDLG,ORDCUR,ORFTYP) ;Load additional prompts for a dialog element
     55 ;
     56 ; input parameters
     57 ;
     58 ; ORDLG  - dialog element ien [.01,#801.41]
     59 ; ORDCUR - 0 = current, 1 = Historical for taxonomies only
     60 ; ORFTYP - finding type (CPT/POV) for taxonomies only
     61 ;
     62 ; These fields can be found in the output array of DIALOG^PXRMRPCC
     63 ;
     64 D LOAD^PXRMDLLA(ORDLG,ORDCUR,$G(ORFTYP))
     65 Q
     66 ;
     67RES(ORY,ORREM) ; Reminder Resources/Inquiry
     68 ;
     69 ; input parameter ORREM - reminder ien [.01,#811.9]
     70 ;
     71 D REMVAR^PXRMINQ(.ORY,ORREM)
     72 Q
     73 ;
     74MH(ORY,OTEST) ; Mental Health dialog
     75 ;
     76 ; Input mental health instrument NAME
     77 ;
     78 N YS,ARRAY S YS("CODE")=OTEST D SHOWALL^YTAPI3(.ARRAY,.YS) ; DBIA #2895
     79 ;
     80 N FNODE,FSUB,IC,NODE,OCNT,SUB
     81 S SUB="ARRAY",OCNT=0
     82 F  S SUB=$Q(@SUB) Q:SUB=""  D
     83 .S FSUB=$P($P(SUB,"(",2),")"),FNODE=""
     84 .F IC=1:1 S NODE=$P(FSUB,",",IC) Q:NODE=""  D
     85 ..I $E(NODE)="""" S NODE=$P(NODE,"""",2)
     86 ..S $P(FNODE,";",IC)=NODE
     87 .Q:FNODE=""
     88 .S OCNT=OCNT+1,ORY(OCNT)=FNODE_U_@SUB
     89 Q
     90 ;
     91MHR(ORY,RESULT,ORES) ; Mental Health score and P/N text
     92 ;
     93 ; Input MH result IEN and mental health instrument response
     94 ;
     95 D ^PXRMDLR
     96 ;
     97 Q
     98 ;
     99MHS(ORY,YS) ; Mental Health save response
     100 ;
     101 ; Input mental health instrument response
     102 N ARRAY
     103 D SAVEIT^YTAPI1(.ARRAY,.YS) ; DBIA #2893
     104 I ARRAY(1)'="[DATA]" S ORY(1)="-1^"_ARRAY(1)_ARRAY(2)
     105 I ARRAY(1)="[DATA]" S ORY(1)=ARRAY(1)_ARRAY(2)
     106 Q
     107 ;
     108MST(ORY,DFN,DGMSTDT,DGMSTSC,DGMSTPR,FTYP,FIEN,RESULT) ; File MST status
     109 ;This is obsolete and can be removed when the GUI is changed not
     110 ;to use it.
     111 Q
     112 ;
     113WH(ORY,RESULT) ;
     114 N CNT,CNT1,CNT2,NODE,PIECNT,PUR,TYPE,TYP1,WVIEN,WVRESULT,WVNOT,WVPURIEN
     115 N PRINT
     116 K ^TMP("WV RPT",$J)
     117 I '$D(RESULT) Q
     118 S (CNT2,WVPURIEN,PUR)=0
     119 S CNT=0 F  S CNT=$O(RESULT(CNT)) Q:CNT=""  D
     120 . I $P($G(RESULT(CNT)),U)["WHIEN" D
     121 . . S CNT2=CNT2+1
     122 . . S WVIEN=$P($P($G(RESULT(CNT)),U),":",2),WVRESULT(CNT2)=$G(WVIEN)
     123 . . S WVRESULT(CNT2)=WVRESULT(CNT2)_U_$P($P($G(RESULT(CNT)),U,3),":",2)
     124 . I $P($G(RESULT(CNT)),U)["WHPur" D
     125 . . S NODE=$G(RESULT(CNT)),PUR=$P($P($G(NODE),U),":",2)
     126 . . S CNT1=1,TYPE=$P($G(NODE),U,2)
     127 . . I TYPE'[":" D
     128 ...S WVNOT(PUR,CNT1)=$P($G(NODE),U,5)_U_$P($G(NODE),U,2)_U_$P($G(NODE),U,3)_U_$P($P($G(NODE),U,4),":",2)
     129 ..I TYPE[":" D
     130 ...S PIECNT=0
     131 ...F X=1:1:$L(TYPE) I $E(TYPE,X)=":" S PIECNT=PIECNT+1 I PIECNT>0 D
     132 ....S PRINT=""
     133 ....S TYP1=$P($G(TYPE),":",PIECNT)
     134 ....I TYP1="L" S PRINT=$P($G(NODE),U,3)
     135 ....S WVNOT(PUR,CNT1)=$P($G(NODE),U,5)_U_$G(TYP1)_U_$G(PRINT)_U_$P($P($G(NODE),U,4),":",2),CNT1=CNT1+1
     136 ...S PIECNT=PIECNT+1
     137 ...S PRINT=""
     138 ...S TYP1=$P($G(TYPE),":",PIECNT)
     139 ...I TYP1="L" S PRINT=$P($G(NODE),U,3)
     140 ...S WVNOT(PUR,CNT1)=$P($G(NODE),U,5)_U_$G(TYP1)_U_$G(PRINT)_U_$P($P($G(NODE),U,4),":",2)
     141 K WHMUFIND,WHFIND,WHNAME
     142 ;DBIA #4104
     143 D NEW^WVRPCNO(.WVRESULT,.WVNOT)
     144 Q
     145 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMRUL1.m

    r613 r623  
    1 PXRMRUL1        ; SLC/AGP,PKR - Patient list routines. ; 03/29/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;
    5 ASK(PLIEN,OPT)  ;Verify patient list name
    6         N X,Y,TEXT
    7         K DIROUT,DIRUT,DTOUT,DUOUT
    8         S DIR(0)="YA0"
    9         S DIR("A")=OPT_" patient list "_$P($G(^PXRMXP(810.5,PLIEN,0)),U)_"?: "
    10         S DIR("B")="N"
    11         S DIR("?")="Enter Y or N. For detailed help type ??"
    12         W !
    13         D ^DIR K DIR
    14         I $D(DIROUT) S DTOUT=1
    15         I $D(DTOUT)!($D(DUOUT)) Q
    16         I $E(Y(0))="N" S DUOUT=1 Q
    17         Q
    18         ;
    19 COPY(IENO)      ;Copy patient list
    20         ;Check if OK to copy
    21         D ASK(IENO,"Copy") Q:$D(DUOUT)!$D(DTOUT)
    22         N FDA,IENN,IND,MSG,NNAME,ODATA,OEPIEN,ONAME,ORULE,PATCREAT,TEXT,X,Y
    23         ;Select list to copy to
    24         S TEXT="Select PATIENT LIST name to copy to: "
    25         D PLIST^PXRMLCR(.IENN,TEXT,IENO) Q:$D(DUOUT)!$D(DTOUT)  Q:'IENN
    26         S NNAME=$P($G(^PXRMXP(810.5,IENN,0)),U)
    27         ;
    28         ;Get original Patient List record
    29         S ODATA=$G(^PXRMXP(810.5,IENO,0))
    30         S ONAME=$P(ODATA,U),OEPIEN=$P(ODATA,U,5),ORULE=$P(ODATA,U,6)
    31         ;
    32         M ^PXRMXP(810.5,IENN)=^PXRMXP(810.5,IENO)
    33         D ASK^PXRMXD(.PATCREAT,"Secure list?: ",2)
    34         ;Update header info
    35         S TYPE=$S($G(PATCREAT)="Y":"PVT",1:"PUB")
    36         S IND=IENN_","
    37         S FDA(810.5,IND,.01)=NNAME
    38         S FDA(810.5,IND,.04)=$$NOW^XLFDT
    39         S FDA(810.5,IND,.05)=OEPIEN
    40         S FDA(810.5,IND,.06)=ORULE
    41         S FDA(810.5,IND,.07)=$G(DUZ)
    42         S FDA(810.5,IND,.08)=TYPE
    43         D UPDATE^DIE("","FDA","","MSG")
    44         ;Error
    45         I $D(MSG) D ERR
    46         ;
    47         W !!,"Completed copy of '"_ONAME_"'"
    48         W !,"into '"_NNAME_"'",! H 2
    49         K ^TMP($J,"PXRMRULE")
    50         Q
    51         ;
    52 CRLST(NAME,CLASS)       ;Create new patient list
    53         N IEN
    54         ;Check if name exists
    55         S IEN=$O(^PXRMXP(810.5,"B",NAME,"")) I IEN Q IEN
    56         ;Otherwise create national entry
    57         N FDA,FDAIEN,MSG
    58         S FDA(810.5,"+1,",.01)=NAME
    59         S FDA(810.5,"+1,",100)=CLASS
    60         S FDA(810.5,"+1,",.07)=$G(DUZ)
    61         ;Make stub public
    62         S FDA(810.5,"+1,",.08)="PUB"
    63         D UPDATE^DIE("","FDA","FDAIEN","MSG")
    64         ;Error
    65         I $D(MSG) Q 0
    66         ;Otherwise list ien
    67         Q FDAIEN(1)
    68         ;
    69 COUNT(NODE)     ;Count the number of entries.
    70         N DFN,NUM
    71         S (DFN,NUM)=0
    72         F  S DFN=$O(^TMP($J,NODE,DFN)) Q:DFN=""  S NUM=NUM+1
    73         Q NUM
    74         ;
    75 DELETE(LIST)    ;Delete Patient list
    76         I '$$VEDIT^PXRMUTIL("^PXRMXP(810.5,",LIST) D  Q
    77         .W !!,?5,"VA- and national class patient lists may not be deleted" H 2
    78         .S DUOUT=1
    79         ;Check if this is the right list
    80         D ASK(LIST,"Delete") Q:$D(DUOUT)!$D(DTOUT)
    81         ;
    82         N DA,DIK,DUOUT
    83         ;Lock patient list
    84         D LOCK Q:$D(DUOUT)
    85         ;Kill List
    86         S DA=LIST,DIK="^PXRMXP(810.5,"
    87         D ^DIK
    88         ;Unlock patient list
    89         D UNLOCK
    90         Q
    91         ;
    92 DATECHK(DATE)   ;
    93         I DATE=0 Q 1
    94         S DATE=$$STRREP^PXRMUTIL(DATE,"BDT","T")
    95         Q $$VDT^PXRMINTR(DATE)
    96         ;
    97 DATES(LBBDT,LBEDT,RBDT,REDT,FARR)       ;Set the dates in the finding array to
    98         ;FileMan dates.
    99         N FI,PXRMDATE,TBDT,TEDT
    100         S FI=0
    101         F  S FI=+$O(FARR(20,FI)) Q:FI=0  D
    102         . S TBDT=$P(FARR(20,FI,0),U,8),TEDT=$P(FARR(20,FI,0),U,11)
    103         . I TBDT="",TEDT="" D
    104         .. S $P(FARR(20,FI,0),U,8)=RBDT,$P(FARR(20,FI,0),U,11)=REDT
    105         . E  D
    106         .. S PXRMDATE=$S(TBDT["BDT":LBBDT,1:LBEDT)
    107         .. S TBDT=$S(TBDT="":0,TBDT=0:0,TBDT="BDT":LBBDT,1:$$CTFMD^PXRMDATE(TBDT))
    108         .. S PXRMDATE=$S(TEDT["BDT":LBBDT,1:LBEDT)
    109         .. S TEDT=$S(TEDT="":"T",TEDT=0:"T",TEDT="BDT":LBBDT,1:TEDT)
    110         .. S TEDT=$$CTFMD^PXRMDATE(TEDT)
    111         .. S $P(FARR(20,FI,0),U,8)=TBDT,$P(FARR(20,FI,0),U,11)=TEDT
    112         Q
    113         ;
    114 ERR     ;Error Handler
    115         N ERROR,IC,REF
    116         S ERROR(1)="Unable to build patient list : "
    117         S ERROR(2)=NAME
    118         S ERROR(3)="Error in UPDATE^DIE, needs further investigation"
    119         ; Move MSG into Error
    120         S REF="MSG"
    121         F IC=4:1 S REF=$Q(@REF) Q:REF=""  S ERROR(IC)=REF_"="_@REF
    122         ;Screen message
    123         D EN^DDIOL(.ERROR)
    124         Q
    125         ;
    126 INSERT(FROUT,DFN,TNAME,TFIEV,RSTOP)     ;Save patient data.
    127         I TFIEV(1)=0 Q
    128         N DATA,DONE,IND,LEN,REF,ROOT,START,SUB,TEMP
    129         S REF="TFIEV(1,""CSUB"")"
    130         S PROOT=$P(REF,")",1)
    131         ;Build the root so we can tell when we are done.
    132         S TEMP=$NA(@REF)
    133         S ROOT=$P(TEMP,")",1)
    134         S REF=$Q(@REF)
    135         I REF'[ROOT Q
    136         S DONE=0
    137         F  Q:(REF="")!(DONE)  D
    138         . S START=$F(REF,ROOT)
    139         . S LEN=$L(REF)-1
    140         . S IND=$E(REF,START,LEN)
    141         . S DATA(TNAME_IND)=@REF
    142         . S REF=$Q(@REF)
    143         . I REF'[ROOT S DONE=1
    144         I $D(DATA) M ^TMP($J,FROUT,DFN,"DATA")=DATA
    145         Q
    146         ;
    147 INST(DFN)       ;Get the PCMM Institution.
    148         N DATE,INST
    149         ;Check PCMM
    150         S DATE=$S($G(PXRMDATE)'="":$P(PXRMDATE,"."),1:DT)
    151         ;DBIA #1916
    152         S INST=$P($$INSTPCTM^SCAPMC(DFN,DATE),U,3,4)
    153         Q INST
    154         ;
    155 LOCK    L +^PXRMXP(810.5,LIST):0
    156         E  W !!?5,"Another user is using this patient list" S DUOUT=1
    157         Q
    158         ;
    159 LOGOP(LIST1,LIST2,LOGOP)        ;Given LIST1 and LIST2 apply the logical
    160         ;operator LOGOP to generate a new list and return it in LIST1
    161         N DFN1,DFN2
    162         I LOGOP="&" D  Q
    163         . S DFN1=""
    164         . F  S DFN1=$O(^TMP($J,LIST1,DFN1)) Q:DFN1=""  D
    165         .. I $D(^TMP($J,LIST2,DFN1)) M ^TMP($J,LIST1,DFN1)=^TMP($J,LIST2,DFN1) Q
    166         .. K ^TMP($J,LIST1,DFN1)
    167         ;
    168         ;"~" represents "&'".
    169         I LOGOP="~" D  Q
    170         . S DFN1=""
    171         . F  S DFN1=$O(^TMP($J,LIST1,DFN1)) Q:DFN1=""  D
    172         .. I $D(^TMP($J,LIST2,DFN1)) K ^TMP($J,LIST1,DFN1)
    173         ;
    174         I LOGOP="!" D
    175         . S DFN2=""
    176         . F  S DFN2=$O(^TMP($J,LIST2,DFN2)) Q:DFN2=""  D
    177         .. M ^TMP($J,LIST1,DFN2)=^TMP($J,LIST2,DFN2)
    178         Q
    179         ;
    180 REM(FRACT,RIEN,LBBDT,LBEDT,RSTART,RSTOP,PNODE)  ;Process reminder finding rule
    181         N DEFFARR,PXRMDATE
    182         D DEF^PXRMLDR(RIEN,.DEFARR)
    183         D DATES(LBBDT,LBEDT,RSTART,RSTOP,.DEFARR)
    184         S PXRMDATE=RSTOP
    185         D BLDPLST^PXRMPLST(.DEFARR,PNODE,1)
    186         ;Remove, Select or Add Findings operations
    187         I FRACT="A" D LOGOP(FROUT,PNODE,"!") Q
    188         I FRACT="D" D LOGOP(FROUT,PNODE,"~") Q
    189         I FRACT="S" D LOGOP(FROUT,PNODE,"&") Q
    190         Q
    191         ;
    192 TERM(FRACT,FRTIEN,LBBDT,LBEDT,RSTART,RSTOP,PNODE,INST)  ;Process TERM finding
    193         ;rules
    194         N FINDPA,FINDING,FNAME,PLIST,PXRMDATE,PXRMDEBG
    195         N TERMARR,TFIEV,TNAME
    196         ;Get term definition array
    197         D TERM^PXRMLDR(FRTIEN,.TERMARR)
    198         S TNAME=$P(TERMARR(0),U,1)
    199         S INST=$S(FRACT'="F":0,TNAME="VA-PCMM INSTITUTION":1,TNAME="VA-IHD STATION CODE":1,1:0)
    200         ;Set begin and end dates in the term.
    201         D DATES(LBBDT,LBEDT,RSTART,RSTOP,.TERMARR)
    202         S $P(FINDPA(0),U,8)=RSTART,$P(FINDPA(0),U,11)=RSTOP,PXRMDATE=RSTOP
    203         ;
    204         ;Add operation
    205         I FRACT="A" D  Q
    206         .;Process term for date range
    207         .D EVALPL^PXRMTERL(.FINDPA,.TERMARR,PNODE)
    208         .;Merge lists if operation is add
    209         .M ^TMP($J,FROUT)=^TMP($J,PNODE,1)
    210         ;Remove, Select or Insert Findings operations
    211         I FRACT="F" S PXRMDEBG=1
    212         S DFN=0
    213         F  S DFN=$O(^TMP($J,FROUT,DFN)) Q:'DFN  D
    214         .I INST S ^TMP($J,FROUT,DFN,"INST")=$$INST(DFN) Q
    215         .;Evaluate term
    216         .K TFIEV D IEVALTER^PXRMTERM(DFN,.FINDPA,.TERMARR,1,.TFIEV)
    217         .;Delete any ^TMP patient in PLIST if action is remove
    218         .I FRACT="R",TFIEV(1) K ^TMP($J,FROUT,DFN) Q
    219         .;Delete any ^TMP patient not in PLIST if action is select
    220         .I FRACT="S",'TFIEV(1) K ^TMP($J,FROUT,DFN) Q
    221         .I FRACT="F",TFIEV(1) D
    222         .. S FINDING=TFIEV(1,"FINDING")
    223         .. I '$D(FNAME(FINDING)) S FNAME(FINDING)=$$GETFNAME^PXRMDATA(FINDING)
    224         .. S TFIEV(1,"CSUB","FINDING NAME")=FNAME(FINDING)
    225         .. D INSERT(FROUT,DFN,TNAME,.TFIEV,RSTOP)
    226         Q
    227         ;
    228 UNLOCK  L -^PXRMXP(810.5,LIST) Q
    229         ;
     1PXRMRUL1 ; SLC/AGP,PKR - Patient list routines. ; 08/11/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4DATECHK(DATE) ;
     5 I DATE=0 Q 1
     6 S DATE=$$STRREP^PXRMUTIL(DATE,"BDT","T")
     7 Q $$VDT^PXRMINTR(DATE)
     8 ;
     9INSERT(FROUT,DFN,TNAME,TFIEV,RSTOP) ;Save patient data.
     10 I TFIEV(1)=0 Q
     11 N DATA,DONE,IND,LEN,REF,ROOT,START,SUB,TEMP
     12 S REF="TFIEV(1,""CSUB"")"
     13 S PROOT=$P(REF,")",1)
     14 ;Build the root so we can tell when we are done.
     15 S TEMP=$NA(@REF)
     16 S ROOT=$P(TEMP,")",1)
     17 S REF=$Q(@REF)
     18 I REF'[ROOT Q
     19 S DONE=0
     20 F  Q:(REF="")!(DONE)  D
     21 . S START=$F(REF,ROOT)
     22 . S LEN=$L(REF)-1
     23 . S IND=$E(REF,START,LEN)
     24 . S DATA(TNAME_IND)=@REF
     25 . S REF=$Q(@REF)
     26 . I REF'[ROOT S DONE=1
     27 I $D(DATA) M ^TMP($J,FROUT,DFN,"DATA")=DATA
     28 Q
     29 ;
     30INST(DFN) ;Get the PCMM Institution.
     31 N DATE,INST
     32 ;Check PCMM
     33 S DATE=$S($G(PXRMDATE)'="":$P(PXRMDATE,"."),1:DT)
     34 ;DBIA #1916
     35 S INST=$P($$INSTPCTM^SCAPMC(DFN,DATE),U,3,4)
     36 Q INST
     37 ;
     38LOGOP(LIST1,LIST2,LOGOP) ;Given LIST1 and LIST2 apply the logical
     39 ;operator LOGOP to generate a new list and return it in LIST1
     40 N DFN1,DFN2
     41 I LOGOP="&" D  Q
     42 . S DFN1=""
     43 . F  S DFN1=$O(^TMP($J,LIST1,DFN1)) Q:DFN1=""  D
     44 .. I $D(^TMP($J,LIST2,DFN1)) M ^TMP($J,LIST1,DFN1)=^TMP($J,LIST2,DFN1) Q
     45 .. K ^TMP($J,LIST1,DFN1)
     46 ;
     47 ;"~" represents "&'".
     48 I LOGOP="~" D  Q
     49 . S DFN1=""
     50 . F  S DFN1=$O(^TMP($J,LIST1,DFN1)) Q:DFN1=""  D
     51 .. I $D(^TMP($J,LIST2,DFN1)) K ^TMP($J,LIST1,DFN1)
     52 ;
     53 I LOGOP="!" D
     54 . S DFN2=""
     55 . F  S DFN2=$O(^TMP($J,LIST2,DFN2)) Q:DFN2=""  D
     56 .. M ^TMP($J,LIST1,DFN2)=^TMP($J,LIST2,DFN2)
     57 Q
     58 ;
     59REM(FRACT,RIEN,RSTART,RSTOP,PNODE) ;Process reminder finding rule
     60 D BLDPLST^PXRMPLST(RIEN,PNODE,1,RSTOP)
     61 ;Remove, Select or Add Findings operations
     62 I FRACT="A" D LOGOP(FROUT,PNODE,"!") Q
     63 I FRACT="D" D LOGOP(FROUT,PNODE,"~") Q
     64 I FRACT="S" D LOGOP(FROUT,PNODE,"&") Q
     65 Q
     66 ;
     67TERM(FRACT,FRTIEN,RSTART,RSTOP,PNODE,INST) ;Process TERM finding rule
     68 N FINDPA,FINDING,FNAME,PLIST,PXRMDATE,PXRMDEBG,TERMARR,TFIEV,TNAME
     69 ;Get term definition array
     70 D TERM^PXRMLDR(FRTIEN,.TERMARR)
     71 S TNAME=$P(TERMARR(0),U,1)
     72 S INST=$S(FRACT'="F":0,TNAME="VA-PCMM INSTITUTION":1,TNAME="VA-IHD STATION CODE":1,1:0)
     73 ;Set start and end dates
     74 S $P(FINDPA(0),U,8)=RSTART,$P(FINDPA(0),U,11)=RSTOP,PXRMDATE=RSTOP
     75 ;
     76 ;Add operation
     77 I FRACT="A" D  Q
     78 .;Process term for date range
     79 .D EVALPL^PXRMTERM(.FINDPA,.TERMARR,PNODE)
     80 .;Merge lists if operation is add
     81 .M ^TMP($J,FROUT)=^TMP($J,PNODE,1)
     82 ;Remove, Select or Insert Findings operations
     83 I FRACT="F" S PXRMDEBG=1
     84 S DFN=0
     85 F  S DFN=$O(^TMP($J,FROUT,DFN)) Q:'DFN  D
     86 .I INST S ^TMP($J,FROUT,DFN,"INST")=$$INST(DFN) Q
     87 .;Evaluate term
     88 .K TFIEV D IEVALTER^PXRMTERM(DFN,.FINDPA,.TERMARR,1,.TFIEV)
     89 .;Delete any ^TMP patient in PLIST if action is remove
     90 .I FRACT="R",TFIEV(1) K ^TMP($J,FROUT,DFN) Q
     91 .;Delete any ^TMP patient not in PLIST if action is select
     92 .I FRACT="S",'TFIEV(1) K ^TMP($J,FROUT,DFN) Q
     93 .I FRACT="F",TFIEV(1) D
     94 .. S FINDING=TFIEV(1,"FINDING")
     95 .. I '$D(FNAME(FINDING)) S FNAME(FINDING)=$$GETFNAME^PXRMDATA(FINDING)
     96 .. S TFIEV(1,"CSUB","FINDING NAME")=FNAME(FINDING)
     97 .. D INSERT(FROUT,DFN,TNAME,.TFIEV,RSTOP)
     98 Q
     99 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMRULE.m

    r613 r623  
    1 PXRMRULE        ; SLC/PJH - Build Patient list from Rule Set ;03/27/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRM PATIENT LIST CREATE protocol
    5         ;
    6 CLEAR(RULE,NODE)        ;Clear workfile entries
    7         N SEQ
    8         S SEQ=""
    9         F  S SEQ=$O(^PXRM(810.4,RULE,30,"B",SEQ)) Q:'SEQ  D
    10         .K ^TMP($J,NODE_SEQ)
    11         ;clear FDA array
    12         K ^TMP($J,"PXRMFDA")
    13         Q
    14         ;
    15 INTR    ;Input transform for #810.4 fields
    16         Q
    17         ;
    18 LOAD(NODE,LIEN) ;Load Patient List
    19         N DATA,DFN,SUB
    20         S SUB=0
    21         F  S SUB=$O(^PXRMXP(810.5,LIEN,30,SUB)) Q:'SUB  D
    22         .S DATA=$G(^PXRMXP(810.5,LIEN,30,SUB,0)),DFN=$P(DATA,U) Q:'DFN
    23         .;Store the patient IEN and institution in ^TMP
    24         .S ^TMP($J,NODE,DFN)=$P(DATA,U,2)_U_$P($G(DATA),U,3)_U_$P($G(DATA),U,4)
    25         Q
    26         ;
    27 PATS(FRACT,FROUT,PNODE,LIST)    ;Process Patient List finding rule
    28         ;
    29         N LIEN,LUVALUE
    30         ;Insert year and period into extract list name
    31         I YEAR]"",LIST["yyyy" S LIST=$P(LIST,"yyyy")_YEAR_$P(LIST,"yyyy",2)
    32         I PERIOD]"",LIST["nn" S LIST=$P(LIST,"nn")_$E(PERIOD,2,10)_$P(LIST,"nn",2)
    33         ;
    34         S LUVALUE(1)=LIST
    35         S LIEN=+$$FIND1^DIC(810.5,"","KUX",.LUVALUE) Q:'LIEN
    36         ;
    37         ;Add operation Load list
    38         I FRACT="A" D LOAD(FROUT,LIEN) Q
    39         ;
    40         ;Remove or Select operations
    41         ;Load List
    42         D LOAD(PNODE,LIEN)
    43         ;Check each patient
    44         S DFN=0
    45         F  S DFN=$O(^TMP($J,FROUT,DFN)) Q:'DFN  D
    46         .;Delete any ^TMP patient in PLIST if action is remove
    47         .I FRACT="R",$D(^TMP($J,PNODE,DFN)) K ^TMP($J,FROUT,DFN) Q
    48         .;Delete any ^TMP patient not in PLIST if action is select
    49         .I FRACT="S",'$D(^TMP($J,PNODE,DFN)) K ^TMP($J,FROUT,DFN)
    50         Q
    51         ;
    52 START(RULESET,LIST,NODE,LBBDT,LBEDT,PAR,YEAR,PERIOD,INDP,INTP,EXTITR)   ;
    53         ;Process rule set
    54         ;Clear ^TMP
    55         D CLEAR(RULESET,NODE)
    56         ;
    57         N CLASS,FRACT,FRDATA,FRDATES,FRIEN,FRLST,FRLIEN,FROLST,FROUT,FRPAT
    58         N FRPERM,FRSTRT,FRTIEN,FRTYP,FSEQ,INC,INST,PXRMDATE,PXRMDDOC
    59         N RBDT,REDT,RRIEN,RSDATA,RSDATES,SEQ,SUB
    60         ;Get class from extract parameter
    61         I PAR S CLASS=$P($G(^PXRM(810.2,PAR,100)),U)
    62         ;Otherwise default to local
    63         I $G(CLASS)="" S CLASS="L"
    64         ;PXRMDDOC=1 save list rule evaluation dates in ^TMP("PXRMDDOC",$J)
    65         S PXRMDDOC=1
    66         K ^TMP("PXRMDDOC",$J)
    67         ;Get each finding rule in sequence
    68         S SEQ="",INC=0,INST=0
    69         F  S SEQ=$O(^PXRM(810.4,RULESET,30,"B",SEQ)) Q:'SEQ  D
    70         .;Save first sequence as default
    71         .I INC=0 S INC=1,FSEQ=SEQ
    72         .S SUB=$O(^PXRM(810.4,RULESET,30,"B",SEQ,"")) Q:'SUB
    73         .S RSDATA=$G(^PXRM(810.4,RULESET,30,SUB,0)) Q:RSDATA=""
    74         .S RSDATES=$G(^PXRM(810.4,RULESET,30,SUB,1))
    75         .;Finding rule ien and action
    76         .S FRIEN=$P(RSDATA,U,2),FRACT=$P(RSDATA,U,3) Q:'FRIEN  Q:FRACT=""
    77         .;Check if entry is a finding rule (not a set or reminder rule)
    78         .S FRDATA=$G(^PXRM(810.4,FRIEN,0)),FRTYP=$P(FRDATA,U,3) Q:FRTYP=3
    79         .S FRDATES=$P(FRDATA,U,4,5)
    80         .;Get term IEN for finding rule
    81         .I FRTYP=1 S FRTIEN=$P(FRDATA,U,7) Q:'FRTIEN
    82         .;Get Reminder definition IEN for Reminder rule
    83         .I FRTYP=2 S RRIEN=$P(FRDATA,U,10) Q:'RRIEN
    84         .;Get Extract Patient List name for patient list rule
    85         .I FRTYP=5 S FRLST=$P($G(^PXRM(810.4,FRIEN,1)),U) D  Q:FRLST=""
    86         ..I +EXTITR>0 S FRLST=FRLST_"/"_EXTITR
    87         ..S FROLST=$P(FRDATA,U,8)
    88         ..I +FROLST>0 S FRLST=$P($G(^PXRMXP(810.5,FROLST,0)),U)
    89         .;Determine RBDT and REDT
    90         .D RDATES^PXRMEUT1(RSDATES,FRDATES,LBBDT,LBEDT,.RBDT,.REDT)
    91         .S PXRMDATE=LBEDT
    92         .;Get start sequence or start patient list
    93         .S FRSTRT=$P(RSDATA,U,4),FRPAT=$P(RSDATA,U,5)
    94         .;If sequence is defined use it
    95         .I FRSTRT S FROUT=NODE_FRSTRT
    96         .;If neither exist use first as default
    97         .I FRSTRT="",FRPAT="" S FROUT=NODE_FSEQ
    98         .;If start is patient list load patient list into workfile
    99         .I FRSTRT="",FRPAT]"" S FROUT=NODE_SEQ D LOAD(FROUT,FRPAT)
    100         .;Name of permanent list
    101         .S FRPERM=$P(RSDATA,U,6)
    102         .;
    103         .;Build patient list in TMP
    104         .N DFN,PNODE,TLIST
    105         .S PNODE="PXRMEVAL"
    106         .K ^TMP($J,PNODE)
    107         .;Term finding rules
    108         .I FRTYP=1 D TERM^PXRMRUL1(FRACT,FRTIEN,LBBDT,LBEDT,RBDT,REDT,PNODE,.INST)
    109         .;Reminder Definition List Rule
    110         .I FRTYP=2 D REM^PXRMRUL1(FRACT,RRIEN,LBBDT,LBEDT,RBDT,REDT,PNODE)
    111         .;Patient list finding rules
    112         .I FRTYP=5 D PATS(FRACT,FROUT,PNODE,FRLST)
    113         .;Clear results file
    114         .K ^TMP($J,PNODE)
    115         .;
    116         .;Build permanent list if required
    117         .I FRPERM]"" D
    118         ..N FRPIEN
    119         ..;Get patient list IEN or create new patient list
    120         ..S FRPIEN=$$CRLST^PXRMRUL1(FRPERM,CLASS) Q:'FRPIEN
    121         ..;Update patient list
    122         ..D UPDLST(FROUT,FRPIEN,PAR,RULESET,INST,INDP,INTP)
    123         ;
    124         ;Save final results to patient list
    125         I LIST'="",FROUT'="" D
    126         . D RMPAT^PXRMEUT(FROUT,INDP,INTP)
    127         . D UPDLST(FROUT,LIST,PAR,RULESET,INST,INDP,INTP)
    128         .;PXRMDDOC=2 compare saved dates with those generated in
    129         .;DOCUMENT^PXRMEUT.
    130         . S PXRMDDOC=2
    131         . D DOCUMENT^PXRMEUT(LIST,RULESET,INDP,INTP,LBBDT,LBEDT)
    132         K ^TMP("PXRMDDOC",$J)
    133         Q
    134         ;
    135 UPDLST(NODE,LIST,EPIEN,RULE,INST,INDP,INTP)     ;Update patient list
    136         N CNT,DA,DATA,DCNT,DECEASED,DFN,DNAME,DNAMEL,DOD,DUE,DUOUT,FDA
    137         N INSTNAM,INSTNUM,LAST,MSG,NAME,ONODE
    138         N RCNT,RIEN,RNAMEL,RNCNT,SUB,TEMP,TEST,TYPE,VALUE
    139         ;Lock patient list
    140         D LOCK^PXRMRUL1 Q:$D(DUOUT)
    141         S TEMP=^PXRMXP(810.5,LIST,0)
    142         S NAME=$P(TEMP,U,1)
    143         S $P(^PXRMXP(810.5,LIST,0),U,11)=INDP
    144         S $P(^PXRMXP(810.5,LIST,0),U,12)=INTP
    145         ;
    146         ;Clear existing list.
    147         K ^PXRMXP(810.5,LIST,30),^PXRMXP(810.5,LIST,35),^PXRMXP(810.5,LIST,45),^PXRMXP(810.5,LIST,200)
    148         ;
    149         ;Merge ^TMP into Patient List
    150         S (DECEASED,TESTP)=""
    151         S (CNT,DFN)=0
    152         F  S DFN=$O(^TMP($J,NODE,DFN)) Q:'DFN  D
    153         .S ONODE=$G(^TMP($J,NODE,DFN,"INST"))
    154         .S INSTNUM=$P(ONODE,U,1),INSTNAM=$P(ONODE,U,2)
    155         .S TEMP=DFN_U_INSTNUM_U_INSTNAM
    156         .I INDP D
    157         ..;DBIA #10035
    158         ..S DOD=+$P($G(^DPT(DFN,.35)),U,1)
    159         ..S DECEASED=$S(DOD=0:0,1:1)
    160         .;DBIA #3744
    161         .I INTP S TESTP=$$TESTPAT^VADPT(DFN)
    162         .S CNT=CNT+1,^PXRMXP(810.5,LIST,30,CNT,0)=DFN_U_INSTNUM_U_INSTNAM_U_DECEASED_U_TESTP
    163         .S ^PXRMXP(810.5,LIST,30,"B",DFN,CNT)=""
    164         .;
    165         .;Save the reminder evaluation information only from Reports
    166         .I $D(^TMP($J,NODE,DFN,"REM"))>0 D
    167         ..S (RIEN,RCNT,RNCNT)=0
    168         ..F  S RIEN=$O(^TMP($J,NODE,DFN,"REM",RIEN)) Q:RIEN'>0  D
    169         ...S RNAMEL(RIEN)=""
    170         ...S VALUE=^TMP($J,NODE,DFN,"REM",RIEN)
    171         ...S RCNT=RCNT+1
    172         ...S ^PXRMXP(810.5,LIST,30,CNT,"REM",RCNT,0)=VALUE
    173         ...S ^PXRMXP(810.5,LIST,30,CNT,"REM","B",RIEN,RCNT)=""
    174         ..S ^PXRMXP(810.5,LIST,30,CNT,1,0)=U_"810.532A"_U_RCNT_U_RCNT
    175         .;
    176         .I '$D(^TMP($J,NODE,DFN,"DATA")) Q
    177         .S DCNT=0,DNAME=""
    178         .F  S DNAME=$O(^TMP($J,NODE,DFN,"DATA",DNAME)) Q:DNAME=""  D
    179         ..S DNAMEL(DNAME)=""
    180         ..S VALUE=^TMP($J,NODE,DFN,"DATA",DNAME)
    181         ..S DCNT=DCNT+1
    182         ..S ^PXRMXP(810.5,LIST,30,CNT,"DATA",DCNT,0)=DNAME_U_VALUE
    183         ..S ^PXRMXP(810.5,LIST,30,CNT,"DATA","B",DNAME,DCNT)=""
    184         .S ^PXRMXP(810.5,LIST,30,CNT,1,0)=U_"810.531A"_U_DCNT_U_DCNT
    185         S ^PXRMXP(810.5,LIST,30,0)=U_"810.53P"_U_CNT_U_CNT
    186         ;
    187         ;Save the reminder information
    188         S RNCNT=0,RIEN=0
    189         F  S RIEN=$O(RNAMEL(RIEN)) Q:RIEN'>0  D
    190         .S RNCNT=RNCNT+1
    191         .S ^PXRMXP(810.5,LIST,45,RCNT,0)=RIEN
    192         .S ^PXRMXP(810.5,LIST,45,"B",RIEN,RNCNT)=""
    193         I RNCNT>0 S ^PXRMXP(810.5,LIST,45,0)=U_"810.545P"_U_RNCNT_U_RNCNT
    194         ;
    195         ;Save the data types.
    196         S DCNT=0,DNAME=""
    197         F  S DNAME=$O(DNAMEL(DNAME)) Q:DNAME=""  D
    198         .S DCNT=DCNT+1
    199         .S ^PXRMXP(810.5,LIST,35,DCNT,0)=DNAME
    200         .S ^PXRMXP(810.5,LIST,35,"B",DNAME,DCNT)=""
    201         I DCNT>0 S ^PXRMXP(810.5,LIST,35,0)=U_"810.535A"_U_DCNT_U_DCNT
    202         S ^PXRMXP(810.5,LIST,30,0)=U_"810.53P"_U_CNT_U_CNT
    203         ;
    204         ;Update header info
    205         S TYPE=$S($G(PATCREAT)="Y":"PVT",1:"PUB")
    206         K PATCREAT
    207         S FDA(810.5,"?+1,",.01)=NAME
    208         S FDA(810.5,"?+1,",.04)=$$NOW^XLFDT
    209         S FDA(810.5,"?+1,",.05)=EPIEN
    210         S FDA(810.5,"?+1,",.06)=RULE
    211         S FDA(810.5,"?+1,",.07)=$G(DUZ)
    212         S FDA(810.5,"?+1,",.08)=TYPE
    213         I $G(INST)=1 S FDA(810.5,"?+1,",.1)=1
    214         S FDA(810.5,"?+1,",50)=$S($G(PLISTPUG)="Y":1,1:0)
    215         D UPDATE^DIE("","FDA","","MSG")
    216         ;Error
    217         I $D(MSG) D ERR^PXRMRUL1
    218         ;Unlock patient list
    219         D UNLOCK^PXRMRUL1
    220         Q
    221         ;
     1PXRMRULE ; SLC/PJH - Build Patient list from Rule Set ;08/11/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRM PATIENT LIST CREATE protocol
     5 ;
     6ASK(PLIEN,OPT) ;Verify patient list name
     7 N X,Y,TEXT
     8 K DIROUT,DIRUT,DTOUT,DUOUT
     9 S DIR(0)="YA0"
     10 S DIR("A")=OPT_" patient list "_$P($G(^PXRMXP(810.5,PLIEN,0)),U)_"?: "
     11 S DIR("B")="N"
     12 S DIR("?")="Enter Y or N. For detailed help type ??"
     13 W !
     14 D ^DIR K DIR
     15 I $D(DIROUT) S DTOUT=1
     16 I $D(DTOUT)!($D(DUOUT)) Q
     17 I $E(Y(0))="N" S DUOUT=1 Q
     18 Q
     19 ;
     20CLEAR(RULE,NODE) ;Clear workfile entries
     21 N SEQ
     22 S SEQ=""
     23 F  S SEQ=$O(^PXRM(810.4,RULE,30,"B",SEQ)) Q:'SEQ  D
     24 .K ^TMP($J,NODE_SEQ)
     25 ;clear FDA array
     26 K ^TMP($J,"PXRMFDA")
     27 Q
     28 ;
     29COPY(IENO) ;Copy patient list
     30 ;Check if OK to copy
     31 D ASK(IENO,"Copy") Q:$D(DUOUT)!$D(DTOUT)
     32 N FDA,IENN,IND,MSG,NNAME,ODATA,OEPIEN,ONAME,ORULE,PATCREAT,TEXT,X,Y
     33 ;Select list to copy to
     34 S TEXT="Select PATIENT LIST name to copy to: "
     35 D PLIST^PXRMLCR(.IENN,TEXT,IENO) Q:$D(DUOUT)!$D(DTOUT)  Q:'IENN
     36 S NNAME=$P($G(^PXRMXP(810.5,IENN,0)),U)
     37 ;
     38 ;Get original Patient List record
     39 S ODATA=$G(^PXRMXP(810.5,IENO,0))
     40 S ONAME=$P(ODATA,U),OEPIEN=$P(ODATA,U,5),ORULE=$P(ODATA,U,6)
     41 ;
     42 M ^PXRMXP(810.5,IENN)=^PXRMXP(810.5,IENO)
     43 D ASK^PXRMXD(.PATCREAT,"Secure list?: ",2)
     44 ;Update header info
     45 S TYPE=$S($G(PATCREAT)="Y":"PVT",1:"PUB")
     46 S IND=IENN_","
     47 S FDA(810.5,IND,.01)=NNAME
     48 S FDA(810.5,IND,.04)=$$NOW^XLFDT
     49 S FDA(810.5,IND,.05)=OEPIEN
     50 S FDA(810.5,IND,.06)=ORULE
     51 S FDA(810.5,IND,.07)=$G(DUZ)
     52 S FDA(810.5,IND,.08)=TYPE
     53 D UPDATE^DIE("","FDA","","MSG")
     54 ;Error
     55 I $D(MSG) D ERR
     56 ;
     57 W !!,"Completed copy of '"_ONAME_"'"
     58 W !,"into '"_NNAME_"'",! H 2
     59 K ^TMP($J,"PXRMRULE")
     60 Q
     61 ;
     62CRLST(NAME,CLASS) ;Create new patient list
     63 N IEN
     64 ;Check if name exists
     65 S IEN=$O(^PXRMXP(810.5,"B",NAME,"")) I IEN Q IEN
     66 ;Otherwise create national entry
     67 N FDA,FDAIEN,MSG
     68 S FDA(810.5,"+1,",.01)=NAME
     69 S FDA(810.5,"+1,",100)=CLASS
     70 D UPDATE^DIE("","FDA","FDAIEN","MSG")
     71 ;Error
     72 I $D(MSG) Q 0
     73 ;Otherwise list ien
     74 Q FDAIEN(1)
     75 ;
     76DELETE(LIST) ;Delete Patient list
     77 I '$$VEDIT^PXRMUTIL("^PXRMXP(810.5,",LIST) D  Q
     78 .W !!,?5,"VA- and national class patient lists may not be deleted" H 2
     79 .S DUOUT=1
     80 ;Check if this is the right list
     81 D ASK(LIST,"Delete") Q:$D(DUOUT)!$D(DTOUT)
     82 ;
     83 N DA,DIK,DUOUT
     84 ;Lock patient list
     85 D LOCK Q:$D(DUOUT)
     86 ;Kill List
     87 S DA=LIST,DIK="^PXRMXP(810.5,"
     88 D ^DIK
     89 ;Unlock patient list
     90 D UNLOCK
     91 Q
     92 ;
     93ERR ;Error Handler
     94 N ERROR,IC,REF
     95 S ERROR(1)="Unable to build patient list : "
     96 S ERROR(2)=NAME
     97 S ERROR(3)="Error in UPDATE^DIE, needs further investigation"
     98 ; Move MSG into Error
     99 S REF="MSG"
     100 F IC=4:1 S REF=$Q(@REF) Q:REF=""  S ERROR(IC)=REF_"="_@REF
     101 ;Screen message
     102 D EN^DDIOL(.ERROR)
     103 Q
     104 ;
     105INTR ;Input transform for #810.4 fields
     106 Q
     107 ;
     108LOAD(NODE,LIEN) ;Load Patient List
     109 N DATA,DFN,SUB
     110 S SUB=0
     111 F  S SUB=$O(^PXRMXP(810.5,LIEN,30,SUB)) Q:'SUB  D
     112 .S DATA=$G(^PXRMXP(810.5,LIEN,30,SUB,0)),DFN=$P(DATA,U) Q:'DFN
     113 .;Store the patient IEN and institution in ^TMP
     114 .S ^TMP($J,NODE,DFN)=$P(DATA,U,2)_U_$P($G(DATA),U,3)_U_$P($G(DATA),U,4)
     115 Q
     116 ;
     117LOCK L +^PXRMXP(810.5,LIST):0
     118 E  W !!?5,"Another user is using this patient list" S DUOUT=1
     119 Q
     120 ;
     121PATS(LIST) ;Process Patient List finding rule
     122 ;
     123 N LIEN,LUVALUE
     124 ;Insert year and period into extract list name
     125 I YEAR]"",LIST["yyyy" S LIST=$P(LIST,"yyyy")_YEAR_$P(LIST,"yyyy",2)
     126 I PERIOD]"",LIST["nn" S LIST=$P(LIST,"nn")_$E(PERIOD,2,10)_$P(LIST,"nn",2)
     127 ;
     128 S LUVALUE(1)=LIST
     129 S LIEN=+$$FIND1^DIC(810.5,"","KUX",.LUVALUE) Q:'LIEN
     130 ;
     131 ;Add operation Load list
     132 I FRACT="A" D LOAD(FROUT,LIEN) Q
     133 ;
     134 ;Remove, Select or Add Findings operations
     135 I FRACT'="A" D  Q
     136 .;Load List
     137 .D LOAD(PNODE,LIEN)
     138 .;Check each patient
     139 .S DFN=0
     140 .F  S DFN=$O(^TMP($J,FROUT,DFN)) Q:'DFN  D
     141 ..;Delete any ^TMP patient in PLIST if action is remove
     142 ..I FRACT="R",$D(^TMP($J,PNODE,DFN)) K ^TMP($J,FROUT,DFN) Q
     143 ..;Delete any ^TMP patient not in PLIST if action is select
     144 ..I FRACT="S",'$D(^TMP($J,PNODE,DFN)) K ^TMP($J,FROUT,DFN)
     145 Q
     146 ;
     147START(RULESET,LIST,NODE,LBBDT,LBEDT,PAR,YEAR,PERIOD,INDP,INTP) ;
     148 ;Process rule set
     149 ;Clear ^TMP
     150 D CLEAR(RULESET,NODE)
     151 ;
     152 N CLASS,FRACT,FRDATA,FRDATES,FRIEN,FRLST,FRLIEN,FROLST,FROUT,FRPAT
     153 N FRPERM,FRSTRT,FRTIEN,FRTYP,FSEQ,INC,INST,PXRMDATE
     154 N RBDT,REDT,RRIEN,RSDATA,RSDATES,SEQ,SUB
     155 ;Get class from extract parameter
     156 I PAR S CLASS=$P($G(^PXRM(810.2,PAR,100)),U)
     157 ;Otherwise default to local
     158 I $G(CLASS)="" S CLASS="L"
     159 ;Get each finding rule in sequence
     160 S SEQ="",INC=0
     161 F  S SEQ=$O(^PXRM(810.4,RULESET,30,"B",SEQ)) Q:'SEQ  D
     162 .;Save first sequence as default
     163 .I INC=0 S INC=1,FSEQ=SEQ
     164 .S SUB=$O(^PXRM(810.4,RULESET,30,"B",SEQ,"")) Q:'SUB
     165 .S RSDATA=$G(^PXRM(810.4,RULESET,30,SUB,0)) Q:RSDATA=""
     166 .S RSDATES=$G(^PXRM(810.4,RULESET,30,SUB,1))
     167 .;Finding rule ien and action
     168 .S FRIEN=$P(RSDATA,U,2),FRACT=$P(RSDATA,U,3) Q:'FRIEN  Q:FRACT=""
     169 .;Check if entry is a finding rule (not a set or reminder rule)
     170 .S FRDATA=$G(^PXRM(810.4,FRIEN,0)),FRTYP=$P(FRDATA,U,3) Q:FRTYP=3
     171 .S FRDATES=$P(FRDATA,U,4,5)
     172 .;Get term IEN for finding rule
     173 .I FRTYP=1 S FRTIEN=$P(FRDATA,U,7) Q:'FRTIEN
     174 .;Get Reminder definition IEN for Reminder rule
     175 .I FRTYP=2 S RRIEN=$P(FRDATA,U,10) Q:'RRIEN
     176 .;Get Extract Patient List name for patient list rule
     177 .I FRTYP=5 S FRLST=$P($G(^PXRM(810.4,FRIEN,1)),U) D  Q:FRLST=""
     178 ..S FROLST=$P(FRDATA,U,8)
     179 ..I +FROLST>0 S FRLST=$P($G(^PXRMXP(810.5,FROLST,0)),U)
     180 .;Determine RBDT and REDT
     181 .D RDATES^PXRMEUT1(RSDATES,FRDATES,LBBDT,LBEDT,.RBDT,.REDT)
     182 .S PXRMDATE=LBEDT
     183 .;Get start sequence or start patient list
     184 .S FRSTRT=$P(RSDATA,U,4),FRPAT=$P(RSDATA,U,5)
     185 .;If sequence is defined use it
     186 .I FRSTRT S FROUT=NODE_FRSTRT
     187 .;If neither exist use first as default
     188 .I FRSTRT="",FRPAT="" S FROUT=NODE_FSEQ
     189 .;If start is patient list load patient list into workfile
     190 .I FRSTRT="",FRPAT]"" S FROUT=NODE_SEQ D LOAD(FROUT,FRPAT)
     191 .;Name of permanent list
     192 .S FRPERM=$P(RSDATA,U,6)
     193 .;
     194 .;Build patient list in TMP
     195 .N DFN,PNODE,TLIST
     196 .S PNODE="PXRMEVAL"
     197 .K ^TMP($J,PNODE)
     198 .;Term finding rules
     199 .I FRTYP=1 D TERM^PXRMRUL1(FRACT,FRTIEN,RBDT,REDT,PNODE,.INST)
     200 .;Reminder Definition List Rule
     201 .I FRTYP=2 D REM^PXRMRUL1(FRACT,RRIEN,RBDT,REDT,PNODE)
     202 .;Patient list finding rules
     203 .I FRTYP=5 D PATS(FRLST)
     204 .;Clear results file
     205 .K ^TMP($J,PNODE)
     206 .;
     207 .;Build permanent list if required
     208 .I FRPERM]"" D
     209 ..N FRPIEN
     210 ..;Get patient list IEN or create new patient list
     211 ..S FRPIEN=$$CRLST(FRPERM,CLASS) Q:'FRPIEN
     212 ..;Update patient list
     213 ..D UPDLST(FROUT,FRPIEN,PAR,RULESET,INST)
     214 ;
     215 ;Save final results to patient list
     216 I LIST'="",FROUT'="" D
     217 . D RMPAT^PXRMEUT(FROUT,INDP,INTP)
     218 . D UPDLST(FROUT,LIST,PAR,RULESET,INST)
     219 . D DOCUMENT^PXRMEUT(LIST,RULESET,INDP,INTP,LBBDT,LBEDT)
     220 Q
     221 ;
     222UPDLST(NODE,LIST,EPIEN,RULE,INST) ;Update patient list
     223 N CNT,DA,DATA,DCNT,DFN,DNAME,DNAMEL,DUE,DUOUT,FDA,INST,INSTNAM,INSTNUM
     224 N LAST,MSG,NAME,ONODE,RCNT,RIEN,RNAMEL,RNCNT,SUB,TEMP,TYPE,VALUE
     225 ;Lock patient list
     226 D LOCK Q:$D(DUOUT)
     227 ;
     228 ;Clear existing list.
     229 K ^PXRMXP(810.5,LIST,30),^PXRMXP(810.5,LIST,35),^PXRMXP(810.5,LIST,45),^PXRMXP(810.5,LIST,200)
     230 S NAME=$P($G(^PXRMXP(810.5,LIST,0)),U)
     231 ;
     232 ;Merge ^TMP into Patient List
     233 S (CNT,DFN,INST)=0
     234 F  S DFN=$O(^TMP($J,NODE,DFN)) Q:'DFN  D
     235 .S ONODE=$G(^TMP($J,NODE,DFN,"INST"))
     236 .S INSTNUM=$P(ONODE,U,1),INSTNAM=$P(ONODE,U,2)
     237 .S CNT=CNT+1,^PXRMXP(810.5,LIST,30,CNT,0)=DFN_U_INSTNUM_U_INSTNAM
     238 .S ^PXRMXP(810.5,LIST,30,"B",DFN,CNT)=""
     239 .;
     240 .;Save the reminder evaluation information only from Reports
     241 .I $D(^TMP($J,NODE,DFN,"REM"))>0 D
     242 ..S (RIEN,RCNT,RNCNT)=0
     243 ..F  S RIEN=$O(^TMP($J,NODE,DFN,"REM",RIEN)) Q:RIEN'>0  D
     244 ...S RNAMEL(RIEN)=""
     245 ...S VALUE=^TMP($J,NODE,DFN,"REM",RIEN)
     246 ...S RCNT=RCNT+1
     247 ...S ^PXRMXP(810.5,LIST,30,CNT,"REM",RCNT,0)=VALUE
     248 ...S ^PXRMXP(810.5,LIST,30,CNT,"REM","B",RIEN,RCNT)=""
     249 ..S ^PXRMXP(810.5,LIST,30,CNT,1,0)=U_"810.532A"_U_RCNT_U_RCNT
     250 .;
     251 .I '$D(^TMP($J,NODE,DFN,"DATA")) Q
     252 .S DCNT=0,DNAME=""
     253 .F  S DNAME=$O(^TMP($J,NODE,DFN,"DATA",DNAME)) Q:DNAME=""  D
     254 ..S DNAMEL(DNAME)=""
     255 ..S VALUE=^TMP($J,NODE,DFN,"DATA",DNAME)
     256 ..S DCNT=DCNT+1
     257 ..S ^PXRMXP(810.5,LIST,30,CNT,"DATA",DCNT,0)=DNAME_U_VALUE
     258 ..S ^PXRMXP(810.5,LIST,30,CNT,"DATA","B",DNAME,DCNT)=""
     259 .S ^PXRMXP(810.5,LIST,30,CNT,1,0)=U_"810.531A"_U_DCNT_U_DCNT
     260 S ^PXRMXP(810.5,LIST,30,0)=U_"810.53P"_U_CNT_U_CNT
     261 ;
     262 ;Save the reminder information
     263 S RNCNT=0,RIEN=0
     264 F  S RIEN=$O(RNAMEL(RIEN)) Q:RIEN'>0  D
     265 .S RNCNT=RNCNT+1
     266 .S ^PXRMXP(810.5,LIST,45,RCNT,0)=RIEN
     267 .S ^PXRMXP(810.5,LIST,45,"B",RIEN,RNCNT)=""
     268 I RNCNT>0 S ^PXRMXP(810.5,LIST,45,0)=U_"810.545P"_U_RNCNT_U_RNCNT
     269 ;
     270 ;Save the data types.
     271 S DCNT=0,DNAME=""
     272 F  S DNAME=$O(DNAMEL(DNAME)) Q:DNAME=""  D
     273 .S DCNT=DCNT+1
     274 .S ^PXRMXP(810.5,LIST,35,DCNT,0)=DNAME
     275 .S ^PXRMXP(810.5,LIST,35,"B",DNAME,DCNT)=""
     276 I DCNT>0 S ^PXRMXP(810.5,LIST,35,0)=U_"810.535A"_U_DCNT_U_DCNT
     277 S ^PXRMXP(810.5,LIST,30,0)=U_"810.53P"_U_CNT_U_CNT
     278 ;
     279 ;Update header info
     280 S TYPE=$S($G(PATCREAT)="Y":"PVT",1:"PUB")
     281 K PATCREAT
     282 S FDA(810.5,"?+1,",.01)=NAME
     283 S FDA(810.5,"?+1,",.04)=$$NOW^XLFDT
     284 S FDA(810.5,"?+1,",.05)=EPIEN
     285 S FDA(810.5,"?+1,",.06)=RULE
     286 S FDA(810.5,"?+1,",.07)=$G(DUZ)
     287 S FDA(810.5,"?+1,",.08)=TYPE
     288 I $G(INST)=1 S FDA(810.5,"?+1,",.1)=1
     289 S FDA(810.5,"?+1,",50)=$S($G(PLISTPUG)="Y":1,1:0)
     290 D UPDATE^DIE("","FDA","","MSG")
     291 ;Error
     292 I $D(MSG) D ERR
     293 ;Unlock patient list
     294 D UNLOCK
     295 Q
     296 ;
     297UNLOCK L -^PXRMXP(810.5,LIST) Q
     298 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMSTA1.m

    r613 r623  
    1 PXRMSTA1        ; SLC/AGP - Routines for building status list. ;09/06/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;This routine and PXRMSTA2 will allow users to select the
    5         ;approriate status for Orders, Medication, Taxonomy, Problem List,
    6         ;and Radiology Procedure findings items.
    7         ;
    8 CLEAR(GBL,FILE,DA)      ;
    9         N IEN,NODE,DIK,TEMP
    10         I FILE="D" S DIK="^PXD(811.9,"_DA(2)_",20,"_DA(1)_",5,"
    11         I FILE="T" S DIK="^PXRMD(811.5,"_DA(2)_",20,"_DA(1)_",5,"
    12         S DA=0 F  S DA=$O(@GBL@(DA(2),20,DA(1),5,DA)) Q:DA'>0  S TEMP(DA)=""
    13         S DA=0 F  S DA=$O(TEMP(DA)) Q:DA'>0  D ^DIK
    14         Q
    15         ;
    16 STATUS(DA,FILE) ;
    17         N ANS,DELSTS,DELALL,GBL,NODE,PXRMRX,STATUS,STS,TAXIEN,TERMIEN,TAXTYPE,TTYPE,TYPE
    18         N RXTYPE,TAXNODE,TERMTYPE,Y
    19         N CSTATUS,UPDATE,HTEXT,OSTAUS,WILD
    20         S DA(2)=DA(1),DA(1)=DA,DA="",UPDATE=0,DELALL=0
    21         I FILE="D" S GBL="^PXD(811.9)"
    22         I FILE="T" S GBL="^PXRMD(811.5)"
    23         S NODE=$G(@GBL@(DA(2),20,DA(1),0))
    24         S TYPE=$P($G(@GBL@(DA(2),20,DA(1),0)),U)
    25         S WILD=0
    26         ;check for current defined statuses if none set the default values
    27         I FILE="D",$P($G(@GBL@(DA(2),20,DA(1),5,0)),U,4)'>0 D DEFAULT(GBL,TYPE,NODE,FILE,0,.DA)
    28         ;I FILE="T",$P($G(@GBL@(DA(2),20,DA(1),5,0)),U,4)>0 D
    29         ;.S STS="" F  S STS=$O(@GBL@(DA(2),20,DA(1),5,"B",STS)) Q:STS=""  S DELSTS(STS)=""
    30         ;display the current status
    31         D DISPLAY(GBL,UPDATE,.WILD,DELALL)
    32         ;do inital prompt
    33         D ADDDEL($G(ANS),GBL,FILE,TYPE,NODE,WILD,.DA,.UPDATE,.DELALL)
    34         Q
    35         ;
    36 ADDDEL(ANS,GBL,FILE,TYPE,NODE,WILD,DA,UPDATE,DELALL)    ;
    37         I $G(ANS)="" S ANS=$$PROMPT("S^A:ADD STATUS;D:DELETE A STATUS;S:SAVE AND QUIT;Q:QUIT WITHOUT SAVING CHANGES")
    38         I "ADDASQ"'[ANS Q
    39         I ANS="A",WILD=1 D
    40         .W !,"Wildcard is already on the status list all possible statuses will be evaluated."
    41         .W !,"To add a specific status please remove the wildcard first."
    42         .S UPDATE=0 H 1
    43         I ANS="A",WILD=0 D ADD(GBL,FILE,.CSTATUS,TYPE,.WILD,.DA,.UPDATE)
    44         I ANS="D" D DELETE(GBL,FILE,.CSTATUS,NODE,.WILD,.DA,.UPDATE,.DELALL)
    45         I ANS="S" S UPDATE="S"
    46         I ANS="Q" S UPDATE="Q"
    47         I UPDATE'="S",UPDATE'="Q" S DELALL=0 D ADDDEL("",GBL,FILE,TYPE,NODE,.WILD,.DA,.UPDATE,.DELALL)
    48         ; only update the new record if the action is Save
    49         I UPDATE="S" D UPDATE(FILE,.UPDATE,.CSTATUS,.DA,.DELALL)
    50         Q
    51         ;
    52 ADD(GBL,FILE,CSTATUS,TYPE,WILD,DA,UPDATE)       ;
    53         N ANS,STATUS,TERMIEN
    54         ;Find what types of finding is in the term
    55         I TYPE["PXRMD(811.5," D
    56         .S TERMIEN=$P($G(TYPE),";")
    57         .S TYPE=$$TERMSTAT(TERMIEN) I TYPE=0 Q
    58         .I TYPE["PXD" S TAXTYPE=$$TAXTYPE(TERMIEN,"")
    59         I TYPE=0 Q
    60         ;find out what is in the taxonomy
    61         I TYPE["PXD(811.2,",$G(TAXTYPE)="" S TAXTYPE=$$TAXNODE($P(TYPE,";"),"")
    62         I TYPE[";" S TYPE=$P($G(TYPE),";",2)
    63         I TYPE="PXD(811.2," D  G ADDEX
    64         .I $G(TAXTYPE)="R"!($G(TAXTYPE)="B") D DATA^PXRMSTA2(FILE,.DA,"RAMIS(71,","",.STATUS)
    65         .;I $G(TAXTYPE)="P" D DATA^PXRMSTA2(FILE,.DA,"PROB","",.STATUS)
    66         .;I $G(TAXTYPE)="B" D DATA^PXRMSTA2(FILE,.DA,"TAX","",.STATUS)
    67         ; handle drug finding items
    68         I TYPE["PSDRUG("!(TYPE["PS(50.605")!(TYPE["PSNDF") D  G ADDEX
    69         .D SRXTYL^PXRMRXTY(NODE,.RXTYPE)
    70         .D DATA^PXRMSTA2(FILE,.DA,"DRUG",.RXTYPE,.STATUS)
    71         ;radiology and orderable item finding item
    72         D DATA^PXRMSTA2(FILE,.DA,TYPE,"",.STATUS)
    73 ADDEX   ;
    74         I '$D(STATUS) S UPDATE=0 Q
    75         S STAT="" F  S STAT=$O(STATUS(STAT)) Q:STAT=""!(WILD)=1  D
    76         .I STAT["*" S WILD=1 Q
    77         .S CSTATUS(STAT)=""
    78         I WILD=1 K CSTATUS S CSTATUS("*")=""
    79         S UPDATE=1 D DISPLAY(GBL,UPDATE,.WILD,0)
    80         Q
    81         ;
    82 DEFAULT(GBL,TYPE,NODE,RFILE,DELETE,DA)  ;
    83         N ANS,FDA,FILE,IND,MSG,STATUS,TERMIEN
    84         S FILE=""
    85         I TYPE["PXRMD(811.5," D
    86         .S TERMIEN=$P($G(TYPE),";")
    87         .S TYPE=$$TERMSTAT(TERMIEN) I TYPE=0 S STATUS="" Q
    88         .I TYPE["PXD" S TAXTYPE=$$TAXTYPE(TERMIEN,"")
    89         I TYPE=0 Q
    90         I TYPE["PXD(811.2,",$G(TAXTYPE)="" S TAXTYPE=$$TAXNODE($P(TYPE,";"),"")
    91         I TYPE[";" S TYPE=$P($G(TYPE),";",2)
    92         I TYPE="PXD(811.2," D
    93         .I $G(TAXTYPE)="R"!($G(TAXTYPE)="B") S FILE=70
    94         .;I $G(TAXTYPE)="P" S FILE=9000011
    95         I FILE="",TYPE="ORD(101.43," S FILE=100
    96         I FILE="",TYPE="RAMIS(71," S FILE=70
    97         I FILE="",TYPE["PSDRUG("!(TYPE["PS(50.605")!(TYPE["PSNDF") D
    98         .N DSTATUS,NAME,STATUSI,STATUSN,STATUSO,RXTYPE
    99         .D SRXTYL^PXRMRXTY(NODE,.RXTYPE)
    100         .I $D(RXTYPE("O")) D DEFAULT^PXRMSTAT(52,.STATUSO) D
    101         ..F IND=1:1:STATUSO(0) S DSTATUS(STATUSO(IND))=""
    102         .I $D(RXTYPE("I")) D DEFAULT^PXRMSTAT(55,.STATUSI) D
    103         ..F IND=1:1:STATUSI(0) S DSTATUS(STATUSI(IND))=""
    104         .I $D(RXTYPE("N")) D DEFAULT^PXRMSTAT("55NVA",.STATUSN) D
    105         ..F IND=1:1:STATUSN(0) S DSTATUS(STATUSN(IND))=""
    106         .S NAME="",IND=0 F  S NAME=$O(DSTATUS(NAME)) Q:NAME=""  D
    107         ..S IND=IND+1 S STATUS(IND)=NAME
    108         .S STATUS(0)=IND
    109         I '$D(STATUS) D DEFAULT^PXRMSTAT(FILE,.STATUS)
    110         F IND=1:1:STATUS(0) Q:$D(MSG)>0  D
    111         .I DELETE=1 S CSTATUS(STATUS(IND))="" Q
    112         .I $D(@GBL@(DA(2),20,DA(1),5,"B",STATUS(IND))) Q
    113         .I RFILE="D" S FDA(811.90221,"+3,"_DA(1)_","_DA(2)_",",.01)=STATUS(IND)
    114         .I RFILE="T" S FDA(811.54,"+3,"_DA(1)_","_DA(2)_",",.01)=STATUS(IND)
    115         .D UPDATE^DIE("","FDA","","MSG")
    116         I $D(MSG)>0 D AWRITE^PXRMUTIL("MSG") H 2
    117         Q
    118         ;
    119 DELETE(GBL,FILE,CSTATUS,NODE,WILD,DA,UPDATE,DELALL)     ;
    120         N ANS,CNT,DIK,NUM,NAME,DIR,TMP,TMPARR,Y
    121         S CNT=0,NAME="" F  S NAME=$O(CSTATUS(NAME)) Q:NAME=""  D
    122         .S CNT=CNT+1 S TMPARR(CNT)=CNT_" - "_NAME,TMP(CNT)=NAME
    123         S DIR(0)="LO^1:"_CNT_""
    124         M DIR("A")=TMPARR
    125         S DIR("A")="Select which status to be deleted"
    126         ;S DIR("?")=HELP
    127         D ^DIR
    128         I $D(DTOUT)!($D(DUOUT))!($G(Y)="") Q
    129         S CNT=0 F X=1:1:$L(Y(0)) D
    130         .I $E(Y(0),X)="," S CNT=CNT+1,NUM=$P(Y(0),",",CNT) S NAME=TMP(NUM) K CSTATUS(NAME) I NAME["*" S WILD=0
    131         S UPDATE=1
    132         I FILE="T",$D(CSTATUS)'>0 S DELALL=1
    133         ;.S DIK="^PXRMD(811.5,"_DA(2)_",20,"_DA(1)_",5,"
    134         ;D CLEAR(GBL,FILE,.DA)
    135         ;I $D(CSTATUS)'>0 S DA=0 F  S DA=$O(^PXRMD(811.5,DA(2),20,DA(1),5,DA)) Q:DA'>0  D ^DIK
    136         ;I '$D(CSTATUS) D CLEAR(GBL,FILE,.DA) D DEFAULT(GBL,TYPE,NODE,FILE,1,.DA)
    137         ;I '$D(CSTATUS),FILE="D" D DEFAULT(GBL,TYPE,NODE,FILE,1,.DA)
    138         D DISPLAY(GBL,UPDATE,.WILD,DELALL)
    139         Q
    140         ;
    141 DISPLAY(GBL,UPDATE,WILD,DELALL) ;
    142         ;display statuses defined in the 5 node or display statuses if CStatus
    143         ;array has been loaded
    144         N NAME
    145         S NAME=""
    146         I ((UPDATE=1)&(DELALL=1))!(($D(CSTATUS)'>0)&(UPDATE=0)&(GBL["811.5")&('$D(@GBL@(DA(2),20,DA(1),5)))) W !!,"No statuses defined for this finding item" W ! Q
    147         W !!,"Statuses already defined for this finding item:"
    148         ;I $D(CSTATUS)'>0,UPDATE=1 D
    149         ;.F  S NAME=$O(@GBL@(DA(2),20,DA(1),5,"B",NAME)) Q:NAME=""  D
    150         ;..S CSTATUS(NAME)=$O(^PXD(811.9,DA(2),20,DA(1),5,"B","NAME",""))
    151         I $D(CSTATUS)'>0,UPDATE=0 D
    152         .F  S NAME=$O(@GBL@(DA(2),20,DA(1),5,"B",NAME)) Q:NAME=""  D
    153         ..I NAME["*" S WILD=1
    154         ..W !,NAME S CSTATUS(NAME)=$O(^PXD(811.9,DA(2),20,DA(1),5,"B","NAME",""))
    155         I UPDATE=1 F  S NAME=$O(CSTATUS(NAME)) Q:NAME=""  W !,NAME I NAME["*" S WILD=1
    156         W !
    157         Q
    158         ;
    159         ;
    160 UPDATE(FILE,UPDATE,CSTATUS,DA,DELALL)   ;
    161         N FDA,MSG,NAME
    162         I UPDATE="S" S UPDATE=1
    163         I UPDATE=0,$D(CSTATUS) G EXIT
    164         D CLEAR(GBL,FILE,.DA)
    165         I $D(CSTATUS)'>0 S UPDATE=0,DELALL=0 G EXIT
    166         I $D(CSTATUS)'>0 S UPDATE=1,DELALL=1 G EXIT
    167         S NAME="" F  S NAME=$O(CSTATUS(NAME)) Q:NAME=""!($D(MSG)>0)  D
    168         .I FILE="D" S FDA(811.90221,"+3,"_DA(1)_","_DA(2)_",",.01)=NAME
    169         .I FILE="T" S FDA(811.54,"+3,"_DA(1)_","_DA(2)_",",.01)=NAME
    170         .D UPDATE^DIE("","FDA","","MSG")
    171         I $D(MSG)>0 D AWRITE^PXRMUTIL("MSG") H 2
    172 EXIT    ;
    173         Q
    174         ;
    175 PROMPT(STR)     ;
    176         N DIR,HTEXT
    177         S HTEXT(1)="Select 'A' to add a status to the current status list.\\Select 'D' to"
    178         S HTEXT(2)="delete a status from the list.\\Select 'S' to save your changes and quit. "
    179         S HTEXT(3)="\\Select 'Q' to quit without saving your changes."
    180         S DIR(0)=STR
    181         S DIR("B")="S"
    182         S DIR("?")="Select one of the above option or '^' to quit. Enter ?? for detail help."
    183         S DIR("??")=U_"D HELP^PXRMEUT(.HTEXT)"
    184         D ^DIR
    185         I $G(Y)="" S Y=U
    186         Q Y
    187         ;
    188 ASK(STR,HTEXT)  ;
    189         N DIR,HTEXT
    190         I '$D(HTEXT) D
    191         .S HTEXT(1)="Enter 'Y' to continue editing the Status List or '^' to Quit"
    192         S DIR(0)="YA0"
    193         S DIR("A")=STR
    194         S DIR("B")="N"
    195         S DIR("?")="Select either 'Y' or 'N' or '^' to quit. Enter ?? for detail help."
    196         S DIR("??")=U_"D HELP^PXRMEUT(.HTEXT)"
    197         D ^DIR
    198         Q Y
    199         ;
    200 TAXTYPE(TERMIEN,HELP)   ;
    201         ;use to determine the Rx type of the term and the type of taxonomy
    202         N ARRAY,BOTH,CNT,IEN,TAXNODE,RAD,PL,RESULT,TYPE
    203         S (BOTH,PL,RAD,RESULT)=0
    204         S IEN=0 F  S IEN=$O(^PXRMD(811.5,TERMIEN,20,IEN)) Q:+IEN'>0  D
    205         .S TAXNODE=$G(^PXRMD(811.5,TERMIEN,20,IEN,0))
    206         .S ARRAY($P($P($G(TAXNODE),U),";"))=""
    207         I $D(ARRAY)>0 S IEN=0 F  S IEN=$O(ARRAY(IEN)) Q:IEN'>0  D
    208         .S TYPE=$$TAXNODE(IEN,$G(HELP))
    209         .I TYPE="R" S RAD=1
    210         .I TYPE="P" S PL=1
    211         .I TYPE="B" S BOTH=1
    212         I RAD=1,PL=1 S RESULT="B" Q
    213         I RAD=1,PL=0,BOTH=0 S RESULT="R"
    214         I RAD=0,PL=1,BOTH=0 S RESULT="P"
    215         Q RESULT
    216         ;
    217 TAXNODE(TAXIEN,HELP)    ;
    218         ;use to determine the type of taxonomy
    219         N TAXNODE,ICD,CPT,ARRAY,RAD,PL,BOTH,RADM,PLM,RESULT
    220         S (BOTH,PL,PLM,RAD,RADM,RESULT)=0
    221         D CHECK^PXRMBXTL(TAXIEN,"")
    222         I $D(^PXD(811.3,TAXIEN,71,"RCPTP"))>0 S RAD=1
    223         I $D(^PXD(811.3,TAXIEN,"PDS",9000011))>0 S PL=1
    224         I RAD=1,PL=1 S RESULT="B"
    225         I RAD=1,PL=0 S RESULT="R"
    226         I RAD=0,PL=1 S RESULT="P"
    227         Q RESULT
    228         ;
    229         ;
    230 TERMSTAT(TIEN)  ;
    231         N CNT,FIEN,NODE
    232         S (CNT,FIEN)=0
    233         S TYPE=0 F  S FIEN=$O(^PXRMD(811.5,TIEN,20,FIEN)) Q:+FIEN=0!(CNT=1)  D
    234         . S NODE=$G(^PXRMD(811.5,TIEN,20,FIEN,0)),TYPE=$P(NODE,U),CNT=CNT+1
    235         Q TYPE
    236         ;
    237 WARN    ;
    238         ;If the whole entry is being deleted don't give the warning.
    239         I $G(PXRMDEFD) Q
    240         I $G(PXRMTMD) Q
    241         ;Do not execute as part of exchange.
    242         I $G(PXRMEXCH) Q
    243         N TEXT
    244         S TEXT(1)=""
    245         S TEXT(2)="Since you changed the value of Rx Type, you should review the status list"
    246         S TEXT(3)="for the finding to make sure it is still appropriate."
    247         S TEXT(4)=""
    248         D EN^DDIOL(.TEXT)
    249         Q
    250         ;
    251         ;
     1PXRMSTA1 ; SLC/AGP - Routines for building status list. ;06/20/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;This routine and PXRMSTA2 will allow users to select the
     5 ;approriate status for Orders, Medication, Taxonomy, Problem List,
     6 ;and Radiology Procedure findings items.
     7 ;
     8CLEAR(GBL,FILE,DA) ;
     9 N IEN,NODE,DIK,TEMP
     10 I FILE="D" S DIK="^PXD(811.9,"_DA(2)_",20,"_DA(1)_",5,"
     11 I FILE="T" S DIK="^PXRMD(811.5,"_DA(2)_",20,"_DA(1)_",5,"
     12 S DA=0 F  S DA=$O(@GBL@(DA(2),20,DA(1),5,DA)) Q:DA'>0  S TEMP(DA)=""
     13 S DA=0 F  S DA=$O(TEMP(DA)) Q:DA'>0  D ^DIK
     14 Q
     15 ;
     16STATUS(DA,FILE) ;
     17 N ANS,DELSTS,DELALL,GBL,NODE,PXRMRX,STATUS,STS,TAXIEN,TERMIEN,TAXTYPE,TTYPE,TYPE
     18 N RXTYPE,TAXNODE,TERMTYPE,Y
     19 N CSTATUS,UPDATE,HTEXT,OSTAUS,WILD
     20 S DA(2)=DA(1),DA(1)=DA,DA="",UPDATE=0,DELALL=0
     21 I FILE="D" S GBL="^PXD(811.9)"
     22 I FILE="T" S GBL="^PXRMD(811.5)"
     23 S NODE=$G(@GBL@(DA(2),20,DA(1),0))
     24 S TYPE=$P($G(@GBL@(DA(2),20,DA(1),0)),U)
     25 S WILD=0
     26 ;check for current defined statuses if none set the default values
     27 I FILE="D",$P($G(@GBL@(DA(2),20,DA(1),5,0)),U,4)'>0 D DEFAULT(GBL,TYPE,NODE,FILE,0,.DA)
     28 ;I FILE="T",$P($G(@GBL@(DA(2),20,DA(1),5,0)),U,4)>0 D
     29 ;.S STS="" F  S STS=$O(@GBL@(DA(2),20,DA(1),5,"B",STS)) Q:STS=""  S DELSTS(STS)=""
     30 ;display the current status
     31 D DISPLAY(GBL,UPDATE,.WILD,DELALL)
     32 ;do inital prompt
     33 D ADDDEL($G(ANS),GBL,FILE,TYPE,NODE,WILD,.DA,.UPDATE,.DELALL)
     34 Q
     35 ;
     36ADDDEL(ANS,GBL,FILE,TYPE,NODE,WILD,DA,UPDATE,DELALL) ;
     37 I $G(ANS)="" S ANS=$$PROMPT("S^A:ADD STATUS;D:DELETE A STATUS;S:SAVE AND QUIT;Q:QUIT WITHOUT SAVING CHANGES","S")
     38 I "ADDASQ"'[ANS Q
     39 I ANS="A",WILD=1 D
     40 .W !,"Wildcard is already on the status list all possible statuses will be evaluated."
     41 .W !,"To add a specific status please remove the wildcard first."
     42 .S UPDATE=0 H 1
     43 I ANS="A",WILD=0 D ADD(GBL,FILE,.CSTATUS,TYPE,.WILD,.DA,.UPDATE)
     44 I ANS="D" D DELETE(GBL,FILE,.CSTATUS,NODE,.WILD,.DA,.UPDATE,.DELALL)
     45 I ANS="S" S UPDATE="S"
     46 I ANS="Q" S UPDATE="Q"
     47 I UPDATE'="S",UPDATE'="Q" S DELALL=0 D ADDDEL("",GBL,FILE,TYPE,NODE,.WILD,.DA,.UPDATE,.DELALL)
     48 ; only update the new record if the action is Save
     49 I UPDATE="S" D UPDATE(FILE,.UPDATE,.CSTATUS,.DA,.DELALL)
     50 Q
     51 ;
     52ADD(GBL,FILE,CSTATUS,TYPE,WILD,DA,UPDATE) ;
     53 N ANS,STATUS,TERMIEN
     54 ;Find what types of finding is in the term
     55 I TYPE["PXRMD(811.5," D
     56 .S TERMIEN=$P($G(TYPE),";")
     57 .S TYPE=$$TERMSTAT(TERMIEN) I TYPE=0 Q
     58 .I TYPE["PXD" S TAXTYPE=$$TAXTYPE(TERMIEN,"")
     59 I TYPE=0 Q
     60 ;find out what is in the taxonomy
     61 I TYPE["PXD(811.2,",$G(TAXTYPE)="" S TAXTYPE=$$TAXNODE($P(TYPE,";"),"")
     62 I TYPE[";" S TYPE=$P($G(TYPE),";",2)
     63 I TYPE="PXD(811.2," D  G ADDEX
     64 .I $G(TAXTYPE)="R" D DATA^PXRMSTA2(FILE,.DA,"RAMIS(71,","",.STATUS)
     65 .;I $G(TAXTYPE)="P" D DATA^PXRMSTA2(FILE,.DA,"PROB","",.STATUS)
     66 .I $G(TAXTYPE)="B" D DATA^PXRMSTA2(FILE,.DA,"TAX","",.STATUS)
     67 ; handle drug finding items
     68 I TYPE["PSDRUG("!(TYPE["PS(50.605")!(TYPE["PSNDF") D  G ADDEX
     69 .D SRXTYL^PXRMRXTY(NODE,.RXTYPE)
     70 .D DATA^PXRMSTA2(FILE,.DA,"DRUG",.RXTYPE,.STATUS)
     71 ;radiology and orderable item finding item
     72 D DATA^PXRMSTA2(FILE,.DA,TYPE,"",.STATUS)
     73ADDEX ;
     74 I '$D(STATUS) S UPDATE=0 Q
     75 S STAT="" F  S STAT=$O(STATUS(STAT)) Q:STAT=""!(WILD)=1  D
     76 .I STAT["*" S WILD=1 Q
     77 .S CSTATUS(STAT)=""
     78 I WILD=1 K CSTATUS S CSTATUS("*")=""
     79 S UPDATE=1 D DISPLAY(GBL,UPDATE,.WILD,0)
     80 Q
     81 ;
     82DEFAULT(GBL,TYPE,NODE,RFILE,DELETE,DA) ;
     83 N ANS,FDA,FILE,IND,MSG,STATUS,TERMIEN
     84 S FILE=""
     85 I TYPE["PXRMD(811.5," D
     86 .S TERMIEN=$P($G(TYPE),";")
     87 .S TYPE=$$TERMSTAT(TERMIEN) I TYPE=0 S STATUS="" Q
     88 .I TYPE["PXD" S TAXTYPE=$$TAXTYPE(TERMIEN,"")
     89 I TYPE=0 Q
     90 I TYPE["PXD(811.2,",$G(TAXTYPE)="" S TAXTYPE=$$TAXNODE($P(TYPE,";"),"")
     91 I TYPE[";" S TYPE=$P($G(TYPE),";",2)
     92 I TYPE="PXD(811.2," D
     93 .I $G(TAXTYPE)="R" S FILE=70
     94 .I $G(TAXTYPE)="P" S FILE=9000011
     95 I FILE="",TYPE="ORD(101.43," S FILE=100
     96 I FILE="",TYPE="RAMIS(71," S FILE=70
     97 I FILE="",TYPE["PSDRUG("!(TYPE["PS(50.605")!(TYPE["PSNDF") D
     98 .N DSTATUS,NAME,STATUSI,STATUSN,STATUSO,RXTYPE
     99 .D SRXTYL^PXRMRXTY(NODE,.RXTYPE)
     100 .I $D(RXTYPE("O")) D DEFAULT^PXRMSTAT(52,.STATUSO) D
     101 ..F IND=1:1:STATUSO(0) S DSTATUS(STATUSO(IND))=""
     102 .I $D(RXTYPE("I")) D DEFAULT^PXRMSTAT(55,.STATUSI) D
     103 ..F IND=1:1:STATUSI(0) S DSTATUS(STATUSI(IND))=""
     104 .I $D(RXTYPE("N")) D DEFAULT^PXRMSTAT("55NVA",.STATUSN) D
     105 ..F IND=1:1:STATUSN(0) S DSTATUS(STATUSN(IND))=""
     106 .S NAME="",IND=0 F  S NAME=$O(DSTATUS(NAME)) Q:NAME=""  D
     107 ..S IND=IND+1 S STATUS(IND)=NAME
     108 .S STATUS(0)=IND
     109 I '$D(STATUS) D DEFAULT^PXRMSTAT(FILE,.STATUS)
     110 F IND=1:1:STATUS(0) Q:$D(MSG)>0  D
     111 .I DELETE=1 S CSTATUS(STATUS(IND))="" Q
     112 .I $D(@GBL@(DA(2),20,DA(1),5,"B",STATUS(IND))) Q
     113 .I RFILE="D" S FDA(811.90221,"+3,"_DA(1)_","_DA(2)_",",.01)=STATUS(IND)
     114 .I RFILE="T" S FDA(811.54,"+3,"_DA(1)_","_DA(2)_",",.01)=STATUS(IND)
     115 .D UPDATE^DIE("","FDA","","MSG")
     116 I $D(MSG)>0 D AWRITE^PXRMUTIL("MSG") H 2
     117 Q
     118 ;
     119DELETE(GBL,FILE,CSTATUS,NODE,WILD,DA,UPDATE,DELALL) ;
     120 N ANS,CNT,DIK,NUM,NAME,DIR,TMP,TMPARR,Y
     121 S CNT=0,NAME="" F  S NAME=$O(CSTATUS(NAME)) Q:NAME=""  D
     122 .S CNT=CNT+1 S TMPARR(CNT)=CNT_" - "_NAME,TMP(CNT)=NAME
     123 S DIR(0)="LO^1:"_CNT_""
     124 M DIR("A")=TMPARR
     125 S DIR("A")="Select which status to be deleted"
     126 ;S DIR("?")=HELP
     127 D ^DIR
     128 I $D(DTOUT)!($D(DUOUT))!($G(Y)="") Q
     129 S CNT=0 F X=1:1:$L(Y(0)) D
     130 .I $E(Y(0),X)="," S CNT=CNT+1,NUM=$P(Y(0),",",CNT) S NAME=TMP(NUM) K CSTATUS(NAME) I NAME["*" S WILD=0
     131 S UPDATE=1
     132 I FILE="T",$D(CSTATUS)'>0 S DELALL=1
     133 ;.S DIK="^PXRMD(811.5,"_DA(2)_",20,"_DA(1)_",5,"
     134 ;D CLEAR(GBL,FILE,.DA)
     135 ;I $D(CSTATUS)'>0 S DA=0 F  S DA=$O(^PXRMD(811.5,DA(2),20,DA(1),5,DA)) Q:DA'>0  D ^DIK
     136 ;I '$D(CSTATUS) D CLEAR(GBL,FILE,.DA) D DEFAULT(GBL,TYPE,NODE,FILE,1,.DA)
     137 ;I '$D(CSTATUS),FILE="D" D DEFAULT(GBL,TYPE,NODE,FILE,1,.DA)
     138 D DISPLAY(GBL,UPDATE,.WILD,DELALL)
     139 Q
     140 ;
     141DISPLAY(GBL,UPDATE,WILD,DELALL) ;
     142 ;display statuses defined in the 5 node or display statuses if CStatus
     143 ;array has been loaded
     144 N NAME
     145 S NAME=""
     146 I ((UPDATE=1)&(DELALL=1))!(($D(CSTATUS)'>0)&(UPDATE=0)&(GBL["811.5")&('$D(@GBL@(DA(2),20,DA(1),5)))) W !!,"No statuses defined for this finding item" W ! Q
     147 W !!,"Statuses already defined for this finding item:"
     148 ;I $D(CSTATUS)'>0,UPDATE=1 D
     149 ;.F  S NAME=$O(@GBL@(DA(2),20,DA(1),5,"B",NAME)) Q:NAME=""  D
     150 ;..S CSTATUS(NAME)=$O(^PXD(811.9,DA(2),20,DA(1),5,"B","NAME",""))
     151 I $D(CSTATUS)'>0,UPDATE=0 D
     152 .F  S NAME=$O(@GBL@(DA(2),20,DA(1),5,"B",NAME)) Q:NAME=""  D
     153 ..I NAME["*" S WILD=1
     154 ..W !,NAME S CSTATUS(NAME)=$O(^PXD(811.9,DA(2),20,DA(1),5,"B","NAME",""))
     155 I UPDATE=1 F  S NAME=$O(CSTATUS(NAME)) Q:NAME=""  W !,NAME I NAME["*" S WILD=1
     156 W !
     157 Q
     158 ;
     159 ;
     160UPDATE(FILE,UPDATE,CSTATUS,DA,DELALL) ;
     161 N FDA,MSG,NAME
     162 I UPDATE="S" S UPDATE=1
     163 I UPDATE=0,$D(CSTATUS) G EXIT
     164 D CLEAR(GBL,FILE,.DA)
     165 I $D(CSTATUS)'>0 S UPDATE=0,DELALL=0 G EXIT
     166 I $D(CSTATUS)'>0 S UPDATE=1,DELALL=1 G EXIT
     167 S NAME="" F  S NAME=$O(CSTATUS(NAME)) Q:NAME=""!($D(MSG)>0)  D
     168 .I FILE="D" S FDA(811.90221,"+3,"_DA(1)_","_DA(2)_",",.01)=NAME
     169 .I FILE="T" S FDA(811.54,"+3,"_DA(1)_","_DA(2)_",",.01)=NAME
     170 .D UPDATE^DIE("","FDA","","MSG")
     171 I $D(MSG)>0 D AWRITE^PXRMUTIL("MSG") H 2
     172EXIT ;
     173 Q
     174 ;
     175PROMPT(STR,DEFAULT) ;
     176 N DIR,HTEXT
     177 S HTEXT(1)="Select 'A' to add a status to the current status list. Select 'D' to "
     178 S HTEXT(2)="delete a status from the list. Select 'S' to save your changes and quit. "
     179 S HTEXT(3)="Select 'Q' to quit without saving your changes."
     180 S DIR(0)=STR
     181 S DIR("B")="S"
     182 S DIR("?")="Select one of the above option or '^' to quit. Enter ?? for detail help."
     183 S DIR("??")=U_"D HELP^PXRMEUT(.HTEXT)"
     184 D ^DIR
     185 I $G(Y)="" S Y=U
     186 Q Y
     187 ;
     188ASK(STR,HTEXT) ;
     189 N DIR,HTEXT
     190 I '$D(HTEXT) D
     191 .S HTEXT(1)="Enter 'Y' to continue editing the Status List or '^' to Quit"
     192 S DIR(0)="YA0"
     193 S DIR("A")=STR
     194 S DIR("B")="N"
     195 S DIR("?")="Select either 'Y' or 'N' or '^' to quit. Enter ?? for detail help."
     196 S DIR("??")=U_"D HELP^PXRMEUT(.HTEXT)"
     197 D ^DIR
     198 Q Y
     199 ;
     200TAXTYPE(TERMIEN,HELP) ;
     201 ;use to determine the Rx type of the term and the type of taxonomy
     202 N ARRAY,BOTH,CNT,IEN,TAXNODE,RAD,PL,RESULT,TYPE
     203 S (BOTH,PL,RAD,RESULT)=0
     204 S IEN=0 F  S IEN=$O(^PXRMD(811.5,TERMIEN,20,IEN)) Q:+IEN'>0  D
     205 .S TAXNODE=$G(^PXRMD(811.5,TERMIEN,20,IEN,0))
     206 .S ARRAY($P($P($G(TAXNODE),U),";"))=""
     207 I $D(ARRAY)>0 S IEN=0 F  S IEN=$O(ARRAY(IEN)) Q:IEN'>0  D
     208 .S TYPE=$$TAXNODE(IEN,$G(HELP))
     209 .I TYPE="R" S RAD=1
     210 .I TYPE="P" S PL=1
     211 .I TYPE="B" S BOTH=1
     212 I RAD=1,PL=1 S RESULT="B" Q
     213 I RAD=1,PL=0,BOTH=0 S RESULT="R"
     214 I RAD=0,PL=1,BOTH=0 S RESULT="P"
     215 Q RESULT
     216 ;
     217TAXNODE(TAXIEN,HELP) ;
     218 ;use to determine the type of taxonomy
     219 N TAXNODE,ICD,CPT,ARRAY,RAD,PL,BOTH,RADM,PLM,RESULT
     220 S (BOTH,PL,PLM,RAD,RADM,RESULT)=0
     221 D CHECK^PXRMBXTL(TAXIEN,"")
     222 I $D(^PXD(811.3,TAXIEN,71,"RCPTP"))>0 S RAD=1
     223 I $D(^PXD(811.3,TAXIEN,"PDS",9000011))>0 S PL=1
     224 I RAD=1,PL=1 S RESULT="B"
     225 I RAD=1,PL=0 S RESULT="R"
     226 I RAD=0,PL=1 S RESULT="P"
     227 Q RESULT
     228 ;
     229 ;
     230TERMSTAT(TIEN) ;
     231 N CNT,FIEN,NODE
     232 S (CNT,FIEN)=0
     233 S TYPE=0 F  S FIEN=$O(^PXRMD(811.5,TIEN,20,FIEN)) Q:+FIEN=0!(CNT=1)  D
     234 . S NODE=$G(^PXRMD(811.5,TIEN,20,FIEN,0)),TYPE=$P(NODE,U),CNT=CNT+1
     235 Q TYPE
     236 ;
     237WARN ;
     238 ;If the whole entry is being deleted don't give the warning.
     239 I $G(PXRMDEFD) Q
     240 I $G(PXRMTMD) Q
     241 ;Do not execute as part of exchange.
     242 I $G(PXRMEXCH) Q
     243 N TEXT
     244 S TEXT(1)=""
     245 S TEXT(2)="Since you changed the value of Rx Type, you should review the status list"
     246 S TEXT(3)="for the finding to make sure it is still appropriate."
     247 S TEXT(4)=""
     248 D EN^DDIOL(.TEXT)
     249 Q
     250 ;
     251 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMSTA2.m

    r613 r623  
    1 PXRMSTA2        ; SLC/AGP - Routines for building status list. ;03/27/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 DATA(FILE,DA,TYPE,RXTYPE,STATUS)        ;
    5         ; this sub routine get the list of statuses from the apporiate global
    6         ;
    7         N ARRAY,ARRAY1,CNT,CODE,DEF,OUTPUT,SARRAY,STAT
    8 LOOP    ;
    9         ;get build status list into a local array from each pharmacy type of
    10         ;finding item
    11         I TYPE="DRUG" D
    12         .I $D(RXTYPE("I"))>0 D
    13         . . D STATUS^PSS55MIS(55.06,28,"SARRAY")
    14         . . ;D FIELD^DID(55.06,28,"","POINTER","SARRAY")
    15         . . D ARRAYFOR(.SARRAY,.ARRAY,"I") K CODE
    16         . . D STATUS^PSS55MIS(55.01,100,"SARRAY")
    17         . . ;D FIELD^DID(55.01,100,"","POINTER","SARRAY")
    18         . . D ARRAYFOR(.SARRAY,.ARRAY1,"I") K CODE
    19         . . D COMPARE(.ARRAY,.ARRAY1,"I",.OUTPUT)
    20         . I $D(RXTYPE("O"))>0 D
    21         . . K ARRAY,ARRAY1,CODE
    22         . . D STATUS^PSODI(52,100,"SARRAY")
    23         . . ;D FIELD^DID(52,100,"","POINTER","SARRAY")
    24         . . D ARRAYFOR(.SARRAY,.ARRAY,"O") K CODE
    25         . . I $D(OUTPUT)>0 K ARRAY1 M ARRAY1=OUTPUT K OUTPUT D COMPARE(.ARRAY,.ARRAY1,"",.OUTPUT)
    26         . . E  M OUTPUT=ARRAY
    27         . I $D(RXTYPE("N"))>0 D
    28         . . K ARRAY,ARRAY1,CODE
    29         . . D STATUS^PSS55MIS(55.05,5,"SARRAY")
    30         . . ;D FIELD^DID(55.05,5,"","POINTER","SARRAY")
    31         . . S SARRAY("POINTER")=SARRAY("POINTER")_"0:ACTIVE;"
    32         . . D ARRAYFOR(.SARRAY,.ARRAY,"N") K CODE
    33         . . I $D(OUTPUT)>0 K ARRAY1 M ARRAY1=OUTPUT K OUTPUT D COMPARE(.ARRAY,.ARRAY1,"",.OUTPUT)
    34         . . E  M OUTPUT=ARRAY
    35         ;
    36         I TYPE="PROB" S OUTPUT("ACTIVE")="ACTIVE",OUTPUT("INACTIVE")="INACTIVE"
    37         I TYPE="ORD(101.43," D
    38         . S CNT=0,STAT="" F  S STAT=$O(^ORD(100.01,"B",STAT)) Q:STAT=""  D
    39         . . S CNT=CNT+1 S OUTPUT(STAT)=STAT
    40         I TYPE="RAMIS(71,"!(TYPE="TAX") D
    41         . S TYPE="RAMIS(71,"
    42         . S CNT=0,STAT="" F  S STAT=$O(^RA(72,"B",STAT)) Q:STAT=""  D
    43         . . S CNT=CNT+1 S OUTPUT(STAT)=STAT
    44         .;I TYPE'="TAX" Q
    45         .;I '$D(OUTPUT("ACTIVE")) S OUTPUT("ACTIVE")="ACTIVE"
    46         .;I '$D(OUTPUT("INACTIVE")) S OUTPUT("INACTIVE")="INACTIVE"
    47         D SELECT(.OUTPUT,FILE,TYPE,.STATUS,.DA)
    48         ;
    49         Q
    50         ;
    51 COMPARE(ARRAY,ARRAY1,TYPE,OUTPUT)       ;
    52         ; this sub routine is use to combine the InPatient and
    53         ; Both Pharmacy type into one array
    54         N ARY,CNT,COMP,NODE
    55         K OUTPUT
    56         S COMP=""
    57         ;
    58         ;inpatient pharmacy list is built from two seperated fields in file #55
    59         ;this is used to combined the two fields into one array
    60         I $G(TYPE)="I" D
    61         . F  S COMP=$O(ARRAY(COMP)) Q:COMP=""  D
    62         . . S OUTPUT(COMP)=ARRAY(COMP)
    63         . S (COMP)="" F  S COMP=$O(ARRAY1(COMP)) Q:COMP=""  D
    64         . . I '$D(OUTPUT(COMP)) S OUTPUT(COMP)=ARRAY1(COMP)
    65         ;
    66         ;this section is uses to combine the different RX Types into one array
    67         I $G(TYPE)'="I" D
    68         . F  S COMP=$O(ARRAY(COMP)) Q:COMP=""  D
    69         . . S NODE=$G(ARRAY(COMP))
    70         . . S OUTPUT(COMP)=NODE
    71         . S COMP="" F  S COMP=$O(ARRAY1(COMP)) Q:COMP=""  D
    72         . . S NODE=$G(ARRAY1(COMP))
    73         . . I '$D(OUTPUT(COMP)) S OUTPUT(COMP)=NODE Q
    74         . . I $D(OUTPUT(COMP)) S $P(OUTPUT(COMP),U,2)=$P(OUTPUT(COMP),U,2)_$P(NODE,U,2)
    75         Q
    76         ;
    77 ARRAYFOR(ARRAY,OUTPUT,DEF)      ;
    78         ;this sub routine is use to format the array data into a standard
    79         ;format
    80         ;
    81         N CNT,COMP,PIECE,STR,TYPE
    82         S PIECE=0
    83         ;
    84         ;determine the number of pieces minus one in the string
    85         F CNT=1:1:$L(ARRAY("POINTER")) I $E(ARRAY("POINTER"),CNT)=";" S PIECE=PIECE+1 I PIECE>0 D
    86         . S STR=$P($P($G(ARRAY("POINTER")),";",PIECE),":",2)
    87         . S OUTPUT($P($P($G(ARRAY("POINTER")),";",PIECE),":",2))=STR_U_$G(DEF)
    88         ;
    89         ;add last piece in the string to the array
    90         I PIECE>0 S PIECE=PIECE+1 D
    91         . I $P($G(ARRAY("POINTER")),";",PIECE)'="" D
    92         . . S OUTPUT($P($P($G(ARRAY("POINTER")),";",PIECE),":",2))=$P($P($G(ARRAY("POINTER")),";",PIECE),":",2)_U_$G(DEF)
    93         Q
    94         ;
    95 SELECT(ARRAY,FILE,TYPE,STATUS,DA)       ;
    96         ; this sub routine is use to sort through the formated array and
    97         ; set up the DIR call
    98         ;
    99         N CHECK,CNT,CNT1,DIR,DUOUT,DTOUT,EMPTY,EXTR
    100         N HELP,LENGTH,NODE,STAT,STR,TEXT,TMP,X,Y
    101         N TMPARR,NUM
    102 DISPLAY ;
    103         I TYPE="DRUG" S TEXT="Select a Medication Status or enter '^' to Quit",HELP="Select a status from the Medication Status list or '^' to Quit"
    104         I TYPE="ORD(101.43," S TEXT="Select a Order Status from or enter '^' to Quit",HELP="Select a Order Status from the status list or '^' to Quit"
    105         I TYPE="RAMIS(71," S TEXT="Select a Radiology Procedure Status or enter '^' to Quit",HELP="Select a Radiology Procedure Status from the status list or '^' to Quit"
    106         ;I TYPE="TAX" S TEXT="Select a Taxonomy Status or enter '^' to Quit",HELP="Select a Taxonomy Status from the status list or '^' to Quit"
    107         ;I TYPE="PROB" S TEXT="Select a Problem Status or enter '^' to Quit",HELP="Select a Taxonomy Status from the status list or '^' to Quit"
    108         ;
    109         S CNT=0,CNT1=0,STAT=""
    110         ;if text is not entered into the prompt or no match is found display
    111         ;entire list of statuses for this finding item
    112         ;
    113         ;Add wildcard character
    114         S CNT=CNT+1,CNT1=CNT1+1,TMP(CNT)=CNT_" - * (WildCard)",TMPARR(CNT)="*"
    115         ;Add status from file to the selectable list
    116         F  S STAT=$O(ARRAY(STAT)) Q:STAT=""  D
    117         . S NODE=$G(ARRAY(STAT))
    118         . S STR=$P(NODE,U)
    119         . S CNT=CNT+1,CNT1=CNT1+1
    120         . I TYPE="DRUG" S TMP(CNT)=CNT_" - "_STR_"("_$P(NODE,U,2)_")",TMPARR(CNT)=STR
    121         . E  S TMP(CNT)=CNT_" - "_STR,TMPARR(CNT)=STR
    122         ;
    123         S DIR(0)="LO^1:"_CNT_""
    124         M DIR("A")=TMP
    125         S DIR("A")=TEXT
    126         S DIR("?")=HELP
    127         D ^DIR
    128         I $D(DTOUT)!($D(DUOUT))!($G(Y)="") K STATUS Q
    129         S CNT=0 F X=1:1:$L(Y(0)) D
    130         .I $E(Y(0),X)="," S CNT=CNT+1,NUM=$P(Y(0),",",CNT),STATUS(TMPARR(NUM))=""
    131         ;S STATUS=Y(0)
    132         ;I STATUS="WildCard" S STATUS="*"
    133         Q
    134         ;
     1PXRMSTA2 ; SLC/AGP - Routines for building status list. ;9/26/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4DATA(FILE,DA,TYPE,RXTYPE,STATUS) ;
     5 ; this sub routine get the list of statuses from the apporiate global
     6 ;
     7 N ARRAY,ARRAY1,CNT,CODE,DEF,OUTPUT,SARRAY,STAT
     8LOOP ;
     9 ;get build status list into a local array from each pharmacy type of
     10 ;finding item
     11 I TYPE="DRUG" D
     12 .I $D(RXTYPE("I"))>0 D
     13 . . D FIELD^DID(55.06,28,"","POINTER","SARRAY")
     14 . . D ARRAYFOR(.SARRAY,.ARRAY,"I") K CODE
     15 . . D FIELD^DID(55.01,100,"","POINTER","SARRAY")
     16 . . D ARRAYFOR(.SARRAY,.ARRAY1,"I") K CODE
     17 . . D COMPARE(.ARRAY,.ARRAY1,"I",.OUTPUT)
     18 . I $D(RXTYPE("O"))>0 D
     19 . . K ARRAY,ARRAY1,CODE
     20 . . D FIELD^DID(52,100,"","POINTER","SARRAY")
     21 . . D ARRAYFOR(.SARRAY,.ARRAY,"O") K CODE
     22 . . I $D(OUTPUT)>0 K ARRAY1 M ARRAY1=OUTPUT K OUTPUT D COMPARE(.ARRAY,.ARRAY1,"",.OUTPUT)
     23 . . E  M OUTPUT=ARRAY
     24 . I $D(RXTYPE("N"))>0 D
     25 . . K ARRAY,ARRAY1,CODE
     26 . . D FIELD^DID(55.05,5,"","POINTER","SARRAY")
     27 . . S SARRAY("POINTER")=SARRAY("POINTER")_"0:ACTIVE;"
     28 . . D ARRAYFOR(.SARRAY,.ARRAY,"N") K CODE
     29 . . I $D(OUTPUT)>0 K ARRAY1 M ARRAY1=OUTPUT K OUTPUT D COMPARE(.ARRAY,.ARRAY1,"",.OUTPUT)
     30 . . E  M OUTPUT=ARRAY
     31 ;
     32 I TYPE="PROB" S OUTPUT("ACTIVE")="ACTIVE",OUTPUT("INACTIVE")="INACTIVE"
     33 I TYPE="ORD(101.43," D
     34 . S CNT=0,STAT="" F  S STAT=$O(^ORD(100.01,"B",STAT)) Q:STAT=""  D
     35 . . S CNT=CNT+1 S OUTPUT(STAT)=STAT
     36 I TYPE="RAMIS(71,"!(TYPE="TAX") D
     37 . S TYPE="RAMIS(71,"
     38 . S CNT=0,STAT="" F  S STAT=$O(^RA(72,"B",STAT)) Q:STAT=""  D
     39 . . S CNT=CNT+1 S OUTPUT(STAT)=STAT
     40 .;I TYPE'="TAX" Q
     41 .;I '$D(OUTPUT("ACTIVE")) S OUTPUT("ACTIVE")="ACTIVE"
     42 .;I '$D(OUTPUT("INACTIVE")) S OUTPUT("INACTIVE")="INACTIVE"
     43 D SELECT(.OUTPUT,FILE,TYPE,.STATUS,.DA)
     44 ;
     45 Q
     46 ;
     47COMPARE(ARRAY,ARRAY1,TYPE,OUTPUT) ;
     48 ; this sub routine is use to combine the InPatient and
     49 ; Both Pharmacy type into one array
     50 N ARY,CNT,COMP,NODE
     51 K OUTPUT
     52 S COMP=""
     53 ;
     54 ;inpatient pharmacy list is built from two seperated fields in file #55
     55 ;this is used to combined the two fields into one array
     56 I $G(TYPE)="I" D
     57 . F  S COMP=$O(ARRAY(COMP)) Q:COMP=""  D
     58 . . S OUTPUT(COMP)=ARRAY(COMP)
     59 . S (COMP)="" F  S COMP=$O(ARRAY1(COMP)) Q:COMP=""  D
     60 . . I '$D(OUTPUT(COMP)) S OUTPUT(COMP)=ARRAY1(COMP)
     61 ;
     62 ;this section is uses to combine the different RX Types into one array
     63 I $G(TYPE)'="I" D
     64 . F  S COMP=$O(ARRAY(COMP)) Q:COMP=""  D
     65 . . S NODE=$G(ARRAY(COMP))
     66 . . S OUTPUT(COMP)=NODE
     67 . S COMP="" F  S COMP=$O(ARRAY1(COMP)) Q:COMP=""  D
     68 . . S NODE=$G(ARRAY1(COMP))
     69 . . I '$D(OUTPUT(COMP)) S OUTPUT(COMP)=NODE Q
     70 . . I $D(OUTPUT(COMP)) S $P(OUTPUT(COMP),U,2)=$P(OUTPUT(COMP),U,2)_$P(NODE,U,2)
     71 Q
     72 ;
     73ARRAYFOR(ARRAY,OUTPUT,DEF) ;
     74 ;this sub routine is use to format that array data into a standard
     75 ;format
     76 ;
     77 N CNT,COMP,PIECE,STR,TYPE
     78 S PIECE=0
     79 ;
     80 ;determine the number of pieces minus one in the string
     81 F CNT=1:1:$L(ARRAY("POINTER")) I $E(ARRAY("POINTER"),CNT)=";" S PIECE=PIECE+1 I PIECE>0 D
     82 . S STR=$P($P($G(ARRAY("POINTER")),";",PIECE),":",2)
     83 . S OUTPUT($P($P($G(ARRAY("POINTER")),";",PIECE),":",2))=STR_U_$G(DEF)
     84 ;
     85 ;add last piece in the string to the array
     86 I PIECE>0 S PIECE=PIECE+1 D
     87 . I $P($G(ARRAY("POINTER")),";",PIECE)'="" D
     88 . . S OUTPUT($P($P($G(ARRAY("POINTER")),";",PIECE),":",2))=$P($P($G(ARRAY("POINTER")),";",PIECE),":",2)_U_$G(DEF)
     89 Q
     90 ;
     91SELECT(ARRAY,FILE,TYPE,STATUS,DA) ;
     92 ; this sub routine is use to sort through the formated array and
     93 ; set up the DIR call
     94 ;
     95 N CHECK,CNT,CNT1,DIR,DUOUT,DTOUT,EMPTY,EXTR
     96 N HELP,LENGTH,NODE,STAT,STR,TEXT,TMP,X,Y
     97 N TMPARR,NUM
     98DISPLAY ;
     99 I TYPE="DRUG" S TEXT="Select a Medication Status or enter '^' to Quit",HELP="Select a status from the Medication Status list or '^' to Quit"
     100 I TYPE="ORD(101.43," S TEXT="Select a Order Status from or enter '^' to Quit",HELP="Select a Order Status from the status list or '^' to Quit"
     101 I TYPE="RAMIS(71," S TEXT="Select a Radiology Procedure Status or enter '^' to Quit",HELP="Select a Radiology Procedure Status from the status list or '^' to Quit"
     102 ;I TYPE="TAX" S TEXT="Select a Taxonomy Status or enter '^' to Quit",HELP="Select a Taxonomy Status from the status list or '^' to Quit"
     103 ;I TYPE="PROB" S TEXT="Select a Problem Status or enter '^' to Quit",HELP="Select a Taxonomy Status from the status list or '^' to Quit"
     104 ;
     105 S CNT=0,CNT1=0,STAT=""
     106 ;if text is not entered into the prompt or no match is found display
     107 ;entire list of statuses for this finding item
     108 ;
     109 ;Add wildcard character
     110 S CNT=CNT+1,CNT1=CNT1+1,TMP(CNT)=CNT_" - * (WildCard)",TMPARR(CNT)="*"
     111 ;Add status from file to the selectable list
     112 F  S STAT=$O(ARRAY(STAT)) Q:STAT=""  D
     113 . S NODE=$G(ARRAY(STAT))
     114 . S STR=$P(NODE,U)
     115 . S CNT=CNT+1,CNT1=CNT1+1
     116 . I TYPE="DRUG" S TMP(CNT)=CNT_" - "_STR_"("_$P(NODE,U,2)_")",TMPARR(CNT)=STR
     117 . E  S TMP(CNT)=CNT_" - "_STR,TMPARR(CNT)=STR
     118 ;
     119 S DIR(0)="LO^1:"_CNT_""
     120 M DIR("A")=TMP
     121 S DIR("A")=TEXT
     122 S DIR("?")=HELP
     123 D ^DIR
     124 I $D(DTOUT)!($D(DUOUT))!($G(Y)="") K STATUS Q
     125 S CNT=0 F X=1:1:$L(Y(0)) D
     126 .I $E(Y(0),X)="," S CNT=CNT+1,NUM=$P(Y(0),",",CNT),STATUS(TMPARR(NUM))=""
     127 ;S STATUS=Y(0)
     128 ;I STATUS="WildCard" S STATUS="*"
     129 Q
     130 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMSXRM.m

    r613 r623  
    1 PXRMSXRM        ; SLC/PKR - Main driver for building indexes. ;11/23/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;==========================================
    5 ADDERROR(GLOBAL,IDEN,NERROR)    ;Add to the error list.
    6         S NERROR=NERROR+1
    7         S ^TMP("PXRMERROR",$J,NERROR,0)="GLOBAL: "_GLOBAL_" ENTRY: "_IDEN
    8         Q
    9         ;
    10         ;==========================================
    11 ASKTASK()       ;See if this should be tasked.
    12         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
    13         S DIR(0)="YO"
    14         S DIR("A")="Do you want this to be tasked"
    15         S DIR("B")="Y"
    16         D ^DIR
    17         I $D(DIROUT)!$D(DIRUT) Q ""
    18         I $D(DUOUT)!$D(DTOUT) Q ""
    19         Q Y
    20         ;
    21         ;==========================================
    22 COMMSG(GLOBAL,START,END,NE,NERROR)      ;Send a MailMan message providing
    23         ;notification that the indexing completed.
    24         N XMSUB
    25         K ^TMP("PXRMXMZ",$J)
    26         S XMSUB="Index for global "_GLOBAL_" sucessfully built"
    27         S ^TMP("PXRMXMZ",$J,1,0)="Build of Clinical Reminders index for global "_GLOBAL_" completed."
    28         S ^TMP("PXRMXMZ",$J,2,0)="Build finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    29         S ^TMP("PXRMXMZ",$J,3,0)=NE_" entries were created."
    30         S ^TMP("PXRMXMZ",$J,4,0)=$$ETIME(START,END)
    31         S ^TMP("PXRMXMZ",$J,5,0)=NERROR_" errors were encountered."
    32         I NERROR>0 S ^TMP("PXRMXMZ",$J,6,0)="Another MailMan message will contain the error information."
    33         D SEND^PXRMMSG(XMSUB)
    34         Q
    35         ;
    36         ;==========================================
    37 DETIME(START,END)       ;Write out the elapsed time.
    38         ;START and END are $H times.
    39         N TEXT
    40         S TEXT=$$ETIME(START,END)
    41         D MES^XPDUTL(TEXT)
    42         Q
    43         ;
    44         ;==========================================
    45 ERRMSG(NERROR,GLOBAL)   ;If there were errors send an error message.
    46         N END,IND,MAXERR,NE,XMSUB
    47         I NERROR=0 Q
    48         ;Return the last MAXERR errors
    49         S MAXERR=+$G(^PXRM(800,1,"MIERR"))
    50         I MAXERR=0 S MAXERR=200
    51         K ^TMP("PXRMXMZ",$J)
    52         S END=$S(NERROR'>MAXERR:NERROR,1:MAXERR)
    53         S NE=NERROR+1
    54         F IND=1:1:END S NE=NE-1,^TMP("PXRMXMZ",$J,IND,0)=^TMP("PXRMERROR",$J,NE,0)
    55         I END=MAXERR S ^TMP("PXRMXMZ",$J,MAXERR+1,0)="GLOBAL: "_GLOBAL_"- Maximum number of errors reached, will not report any more."
    56         K ^TMP("PXRMERROR",$J)
    57         S XMSUB="CLINICAL REMINDER INDEX BUILD ERROR(S) FOR GLOBAL "_GLOBAL
    58         D SEND^PXRMMSG(XMSUB)
    59         Q
    60         ;
    61         ;==========================================
    62 ETIME(START,END)        ;Calculate and format the elapsed time.
    63         ;START and END are $H times.
    64         N ETIME,TEXT
    65         S ETIME=$$HDIFF^XLFDT(END,START,2)
    66         I ETIME>90 D
    67         . S ETIME=$$HDIFF^XLFDT(END,START,3)
    68         . S TEXT="Elapsed time: "_ETIME
    69         E  S TEXT="Elapsed time: "_ETIME_" secs"
    70         Q TEXT
    71         ;
    72         ;==========================================
    73 INDEX   ;Driver for building the various indexes.
    74         N GBL,LIST,ROUTINE,TASKIT
    75         S ROUTINE(45)="INDEX^DGPTDDCR" ;DBIA #4521
    76         S ROUTINE(52)="PSRX^PSOPXRMI"  ;DBIA #4522
    77         S ROUTINE(55)="PSPA^PSSSXRD"   ;DBIA #4172
    78         S ROUTINE(63)="LAB^LRPXSXRL"   ;DBIA #4247
    79         S ROUTINE(70)="RAD^RAPXRM"     ;DBIA #3731
    80         S ROUTINE(100)="INDEX^ORPXRM"  ;DBIA #4498
    81         S ROUTINE(120.5)="VITALS^GMVPXRM"  ;DBIA #3647
    82         S ROUTINE(601.2)="INDEX^YTPXRM" ;DBIA #4523
    83         S ROUTINE(601.84)="INDEX^YTQPXRM" ;DBIA #5055
    84         S ROUTINE(9000011)="INDEX^GMPLPXRM" ;DBIA #4516
    85         S ROUTINE(9000010.07)="VPOV^PXPXRMI2" ;DBIA #4520
    86         S ROUTINE(9000010.11)="VIMM^PXPXRMI1" ;DBIA #4519
    87         S ROUTINE(9000010.12)="VSK^PXPXRMI2"  ;DBIA #4520
    88         S ROUTINE(9000010.13)="VXAM^PXPXRMI2" ;DBIA #4520
    89         S ROUTINE(9000010.16)="VPED^PXPXRMI2" ;DBIA #4520
    90         S ROUTINE(9000010.18)="VCPT^PXPXRMI1" ;DBIA #4519
    91         S ROUTINE(9000010.23)="VHF^PXPXRMI1"  ;DBIA #4519
    92         ;Get the list
    93         W !,"Which indexes do you want to (re)build?"
    94         D SEL(.LIST,.GBL)
    95         I LIST="" Q
    96         ;See if this should be tasked.
    97         S TASKIT=$$ASKTASK
    98         I TASKIT="" Q
    99         I TASKIT D
    100         . W !,"Queue the Clinical Reminders index job."
    101         . D TASKIT(LIST,.GBL,.ROUTINE)
    102         E  D RUNNOW(LIST,.GBL,.ROUTINE)
    103         Q
    104         ;
    105         ;==========================================
    106 RUNNOW(LIST,GBL,ROUTINE)        ;Run the routines now.
    107         N IND,LI,NUM,RTN
    108         S NUM=$L(LIST,",")-1
    109         F IND=1:1:NUM D
    110         . S LI=$P(LIST,",",IND)
    111         . S RTN=ROUTINE(GBL(LI))
    112         . D @RTN
    113         Q
    114         ;
    115         ;==========================================
    116 SEL(LIST,GBL)   ;Select global list
    117         N ALIST,DIR,DIROUT,DIRUT,DTOUT,DUOUT,INUM,X,Y
    118         S INUM=1,ALIST(INUM)="  "_INUM_" - LABORATORY TEST (CH, Anatomic Path, Micro)",GBL(INUM)=63
    119         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - MENTAL HEALTH",GBL(INUM)=601.2
    120         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - MENTAL HEALTH (MHA3)",GBL(INUM)=601.84
    121         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - ORDER",GBL(INUM)=100
    122         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - PTF",GBL(INUM)=45
    123         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - PHARMACY PATIENT",GBL(INUM)=55
    124         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - PRESCRIPTION",GBL(INUM)=52
    125         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - PROBLEM LIST",GBL(INUM)=9000011
    126         S INUM=INUM+1,ALIST(INUM)="  "_INUM_" - RADIOLOGY",GBL(INUM)=70
    127         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V CPT",GBL(INUM)=9000010.18
    128         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V EXAM",GBL(INUM)=9000010.13
    129         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V HEALTH FACTORS",GBL(INUM)=9000010.23
    130         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V IMMUNIZATION",GBL(INUM)=9000010.11
    131         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V PATIENT ED",GBL(INUM)=9000010.16
    132         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V POV",GBL(INUM)=9000010.07
    133         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - V SKIN TEST",GBL(INUM)=9000010.12
    134         S INUM=INUM+1,ALIST(INUM)=" "_INUM_" - VITAL MEASUREMENT",GBL(INUM)=120.5
    135         M DIR("A")=ALIST
    136         S DIR("A")="Enter your list"
    137         S DIR(0)="LO^1:"_INUM
    138         D ^DIR
    139         I $D(DIROUT)!$D(DIRUT) S LIST="" Q
    140         I $D(DUOUT)!$D(DTOUT) S LIST="" Q
    141         S LIST=Y
    142         Q
    143         ;
    144         ;==========================================
    145 TASKIT(LIST,GBL,ROUTINE)        ;Build the indexes as a tasked job.
    146         N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
    147         S MINDT=$$NOW^XLFDT
    148         S DIR("A",1)="Enter the date and time you want the job to start."
    149         S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
    150         S DIR("A")="Start the task at: "
    151         S DIR(0)="DAU"_U_MINDT_"::RSX"
    152         D ^DIR
    153         I $D(DIROUT)!$D(DIRUT) Q
    154         I $D(DUOUT)!$D(DTOUT) Q
    155         S SDTIME=Y
    156         ;Put the task into the queue.
    157         K ZTSAVE
    158         S ZTSAVE("LIST")=""
    159         S ZTSAVE("GBL(")=""
    160         S ZTSAVE("ROUTINE(")=""
    161         S ZTRTN="TASKJOB^PXRMSXRM"
    162         S ZTDESC="Clinical Reminders index build"
    163         S ZTDTH=SDTIME
    164         S ZTIO=""
    165         D ^%ZTLOAD
    166         W !,"Task number ",ZTSK," queued."
    167         Q
    168         ;
    169         ;==========================================
    170 TASKJOB ;Execute as tasked job. LIST, GBL, and ROUTINE come through
    171         ;ZTSAVE.
    172         N IND,LI,NUM,RTN
    173         S ZTREQ="@"
    174         S ZTSTOP=0
    175         S NUM=$L(LIST,",")-1
    176         F IND=1:1:NUM D
    177         .;Check to see if the task has had a stop request
    178         . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
    179         . S LI=$P(LIST,",",IND)
    180         . S RTN=ROUTINE(GBL(LI))
    181         . D @RTN
    182         Q
    183         ;
     1PXRMSXRM ; SLC/PKR - Main driver for building indexes. ;12/20/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;==========================================
     5ADDERROR(GLOBAL,IDEN,NERROR) ;Add to the error list.
     6 S NERROR=NERROR+1
     7 S ^TMP("PXRMERROR",$J,NERROR,0)="GLOBAL: "_GLOBAL_" ENTRY: "_IDEN
     8 Q
     9 ;
     10 ;==========================================
     11ASKTASK() ;See if this should be tasked.
     12 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
     13 S DIR(0)="YO"
     14 S DIR("A")="Do you want this to be tasked"
     15 S DIR("B")="Y"
     16 D ^DIR
     17 I $D(DIROUT)!$D(DIRUT) Q ""
     18 I $D(DUOUT)!$D(DTOUT) Q ""
     19 Q Y
     20 ;
     21 ;==========================================
     22COMMSG(GLOBAL,START,END,NE,NERROR) ;Send a MailMan message providing
     23 ;notification that the indexing completed.
     24 N XMSUB
     25 K ^TMP("PXRMXMZ",$J)
     26 S XMSUB="Index for global "_GLOBAL_" sucessfully built"
     27 S ^TMP("PXRMXMZ",$J,1,0)="Build of Clinical Reminders index for global "_GLOBAL_" completed."
     28 S ^TMP("PXRMXMZ",$J,2,0)="Build finished at "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     29 S ^TMP("PXRMXMZ",$J,3,0)=NE_" entries were created."
     30 S ^TMP("PXRMXMZ",$J,4,0)=$$ETIME(START,END)
     31 S ^TMP("PXRMXMZ",$J,5,0)=NERROR_" errors were encountered."
     32 I NERROR>0 S ^TMP("PXRMXMZ",$J,6,0)="Another MailMan message will contain the error information."
     33 D SEND^PXRMMSG(XMSUB)
     34 Q
     35 ;
     36 ;==========================================
     37DETIME(START,END) ;Write out the elapsed time.
     38 ;START and END are $H times.
     39 N TEXT
     40 S TEXT=$$ETIME(START,END)
     41 D MES^XPDUTL(TEXT)
     42 Q
     43 ;
     44 ;==========================================
     45ERRMSG(NERROR,GLOBAL) ;If there were errors send an error message.
     46 N END,IND,MAXERR,NE,XMSUB
     47 I NERROR=0 Q
     48 ;Return the last MAXERR errors
     49 S MAXERR=+$G(^PXRM(800,1,"MIERR"))
     50 I MAXERR=0 S MAXERR=200
     51 K ^TMP("PXRMXMZ",$J)
     52 S END=$S(NERROR'>MAXERR:NERROR,1:MAXERR)
     53 S NE=NERROR+1
     54 F IND=1:1:END S NE=NE-1,^TMP("PXRMXMZ",$J,IND,0)=^TMP("PXRMERROR",$J,NE,0)
     55 I END=MAXERR S ^TMP("PXRMXMZ",$J,MAXERR+1,0)="GLOBAL: "_GLOBAL_"- Maximum number of errors reached, will not report any more."
     56 K ^TMP("PXRMERROR",$J)
     57 S XMSUB="CLINICAL REMINDER INDEX BUILD ERROR(S) FOR GLOBAL "_GLOBAL
     58 D SEND^PXRMMSG(XMSUB)
     59 Q
     60 ;
     61 ;==========================================
     62ETIME(START,END) ;Calculate and format the elapsed time.
     63 ;START and END are $H times.
     64 N ETIME,TEXT
     65 S ETIME=$$HDIFF^XLFDT(END,START,2)
     66 I ETIME>90 D
     67 . S ETIME=$$HDIFF^XLFDT(END,START,3)
     68 . S TEXT="Elapsed time: "_ETIME
     69 E  S TEXT="Elapsed time: "_ETIME_" secs"
     70 Q TEXT
     71 ;
     72 ;==========================================
     73INDEX ;Driver for building the various indexes.
     74 N GBL,LIST,ROUTINE,TASKIT
     75 S ROUTINE(45)="INDEX^DGPTDDCR" ;DBIA #4521
     76 S ROUTINE(52)="PSRX^PSOPXRMI"  ;DBIA #4522
     77 S ROUTINE(55)="PSPA^PSSSXRD"   ;DBIA #4172
     78 S ROUTINE(63)="LAB^LRPXSXRL"   ;DBIA #4247
     79 S ROUTINE(70)="RAD^RAPXRM"     ;DBIA #3731
     80 S ROUTINE(100)="INDEX^ORPXRM"  ;DBIA #4498
     81 S ROUTINE(120.5)="VITALS^GMVPXRM"  ;DBIA #3647
     82 S ROUTINE(601.2)="INDEX^YTPXRM" ;DBIA #4523
     83 S ROUTINE(9000011)="INDEX^GMPLPXRM" ;DBIA #4516
     84 S ROUTINE(9000010.07)="VPOV^PXPXRMI2" ;DBIA #4520
     85 S ROUTINE(9000010.11)="VIMM^PXPXRMI1" ;DBIA #4519
     86 S ROUTINE(9000010.12)="VSK^PXPXRMI2"  ;DBIA #4520
     87 S ROUTINE(9000010.13)="VXAM^PXPXRMI2" ;DBIA #4520
     88 S ROUTINE(9000010.16)="VPED^PXPXRMI2" ;DBIA #4520
     89 S ROUTINE(9000010.18)="VCPT^PXPXRMI1" ;DBIA #4519
     90 S ROUTINE(9000010.23)="VHF^PXPXRMI1"  ;DBIA #4519
     91 ;Get the list
     92 W !,"Which indexes do you want to (re)build?"
     93 D SEL(.LIST,.GBL)
     94 I LIST="" Q
     95 ;See if this should be tasked.
     96 S TASKIT=$$ASKTASK
     97 I TASKIT="" Q
     98 I TASKIT D
     99 . W !,"Queue the Clinical Reminders index job."
     100 . D TASKIT(LIST,.GBL,.ROUTINE)
     101 E  D RUNNOW(LIST,.GBL,.ROUTINE)
     102 Q
     103 ;
     104 ;==========================================
     105RUNNOW(LIST,GBL,ROUTINE) ;Run the routines now.
     106 N IND,LI,NUM,RTN
     107 S NUM=$L(LIST,",")-1
     108 F IND=1:1:NUM D
     109 . S LI=$P(LIST,",",IND)
     110 . S RTN=ROUTINE(GBL(LI))
     111 . D @RTN
     112 Q
     113 ;
     114 ;==========================================
     115SEL(LIST,GBL) ;Select global list
     116 N ALIST,DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
     117 S ALIST(1)="  1 - LABORATORY TEST (CH, Anatomic Path, Micro)",GBL(1)=63
     118 S ALIST(2)="  2 - MENTAL HEALTH",GBL(2)=601.2
     119 S ALIST(3)="  3 - ORDER",GBL(3)=100
     120 S ALIST(4)="  4 - PTF",GBL(4)=45
     121 S ALIST(5)="  5 - PHARMACY PATIENT",GBL(5)=55
     122 S ALIST(6)="  6 - PRESCRIPTION",GBL(6)=52
     123 S ALIST(7)="  7 - PROBLEM LIST",GBL(7)=9000011
     124 S ALIST(8)="  8 - RADIOLOGY",GBL(8)=70
     125 S ALIST(9)="  9 - V CPT",GBL(9)=9000010.18
     126 S ALIST(10)=" 10 - V EXAM",GBL(10)=9000010.13
     127 S ALIST(11)=" 11 - V HEALTH FACTORS",GBL(11)=9000010.23
     128 S ALIST(12)=" 12 - V IMMUNIZATION",GBL(12)=9000010.11
     129 S ALIST(13)=" 13 - V PATIENT ED",GBL(13)=9000010.16
     130 S ALIST(14)=" 14 - V POV",GBL(14)=9000010.07
     131 S ALIST(15)=" 15 - V SKIN TEST",GBL(15)=9000010.12
     132 S ALIST(16)=" 16 - VITAL MEASUREMENT",GBL(16)=120.5
     133 M DIR("A")=ALIST
     134 S DIR("A")="Enter your list"
     135 S DIR(0)="LO^1:16"
     136 D ^DIR
     137 I $D(DIROUT)!$D(DIRUT) S LIST="" Q
     138 I $D(DUOUT)!$D(DTOUT) S LIST="" Q
     139 S LIST=Y
     140 Q
     141 ;
     142 ;==========================================
     143TASKIT(LIST,GBL,ROUTINE) ;Build the indexes as a tasked job.
     144 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MINDT,SDTIME,X,Y
     145 S MINDT=$$NOW^XLFDT
     146 S DIR("A",1)="Enter the date and time you want the job to start."
     147 S DIR("A",2)="It must be after "_$$FMTE^XLFDT(MINDT,"5Z")
     148 S DIR("A")="Start the task at: "
     149 S DIR(0)="DAU"_U_MINDT_"::RSX"
     150 D ^DIR
     151 I $D(DIROUT)!$D(DIRUT) Q
     152 I $D(DUOUT)!$D(DTOUT) Q
     153 S SDTIME=Y
     154 ;Put the task into the queue.
     155 K ZTSAVE
     156 S ZTSAVE("LIST")=""
     157 S ZTSAVE("GBL(")=""
     158 S ZTSAVE("ROUTINE(")=""
     159 S ZTRTN="TASKJOB^PXRMSXRM"
     160 S ZTDESC="Clinical Reminders index build"
     161 S ZTDTH=SDTIME
     162 S ZTIO=""
     163 D ^%ZTLOAD
     164 W !,"Task number ",ZTSK," queued."
     165 Q
     166 ;
     167 ;==========================================
     168TASKJOB ;Execute as tasked job. LIST, GBL, and ROUTINE come through
     169 ;ZTSAVE.
     170 N IND,LI,NUM,RTN
     171 S ZTREQ="@"
     172 S ZTSTOP=0
     173 S NUM=$L(LIST,",")-1
     174 F IND=1:1:NUM D
     175 .;Check to see if the task has had a stop request
     176 . I $$S^%ZTLOAD S ZTSTOP=1,IND=NUM Q
     177 . S LI=$P(LIST,",",IND)
     178 . S RTN=ROUTINE(GBL(LI))
     179 . D @RTN
     180 Q
     181 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMTAX.m

    r613 r623  
    1 PXRMTAX ; SLC/PKR - Handle taxonomy finding. ;10/11/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;==================================================
    5 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate taxonomy findings.
    6         N FIEVT,FINDPA,FINDING
    7         N TAXIEN
    8         S TAXIEN=""
    9         F  S TAXIEN=$O(DEFARR("E",ENODE,TAXIEN)) Q:+TAXIEN=0  D
    10         . S FINDING=""
    11         . F  S FINDING=$O(DEFARR("E",ENODE,TAXIEN,FINDING)) Q:+FINDING=0  D
    12         .. K FINDPA
    13         .. M FINDPA=DEFARR(20,FINDING)
    14         .. K FIEVT
    15         .. D FIEVAL(DFN,TAXIEN,.FINDPA,.FIEVT)
    16         .. M FIEVAL(FINDING)=FIEVT
    17         Q
    18         ;
    19         ;==================================================
    20 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Evaluate taxonomy terms for
    21         ;building patient lists.
    22         N PFIND3,PFIND4,PFINDPA,TAXIEN
    23         N TFINDPA,TFINDING
    24         S TAXIEN=""
    25         F  S TAXIEN=$O(TERMARR("E",ENODE,TAXIEN)) Q:+TAXIEN=0  D
    26         . S TFINDING=""
    27         . F  S TFINDING=$O(TERMARR("E",ENODE,TAXIEN,TFINDING)) Q:+TFINDING=0  D
    28         .. K PFINDPA,TFINDPA
    29         .. M TFINDPA=TERMARR(20,TFINDING)
    30         ..;Set the finding parameters.
    31         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    32         .. D GPLIST(TAXIEN,.PFINDPA,PLIST)
    33         Q
    34         ;
    35         ;==================================================
    36 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate taxonomy
    37         ;terms.
    38         N FIEVT,PFINDPA
    39         N TAXIEN,TFINDPA,TFINDING
    40         S TAXIEN=""
    41         F  S TAXIEN=$O(TERMARR("E",ENODE,TAXIEN)) Q:+TAXIEN=0  D
    42         . S TFINDING=""
    43         . F  S TFINDING=$O(TERMARR("E",ENODE,TAXIEN,TFINDING)) Q:+TFINDING=0  D
    44         .. K FIEVT,PFINDPA,TFINDPA
    45         .. M TFINDPA=TERMARR(20,TFINDING)
    46         ..;Set the finding parameters.
    47         .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
    48         .. D FIEVAL(DFN,TAXIEN,.PFINDPA,.FIEVT)
    49         .. M TFIEVAL(TFINDING)=FIEVT
    50         Q
    51         ;
    52         ;==================================================
    53 FIEVAL(DFN,TAXIEN,FINDPA,FIEVAL)        ;
    54         N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,ENS,FIEVT,FILENUM,FLIST
    55         N ICOND,IND,INS,INVFD
    56         N NFOUND,NGET,NICD0,NICD9,NCPT,NOCC,NP,NRCPT,PLS
    57         N RAS,SAVE,SDIR,STATUSA,TAXARR,TLIST,UCIFS,USEINP,VSLIST
    58         ;Set the finding search parameters.
    59         D SSPAR^PXRMUTIL(FINDPA(0),.NOCC,.BDT,.EDT)
    60         S INVFD=$P(FINDPA(0),U,16)
    61         D TAX^PXRMLDR(TAXIEN,.TAXARR)
    62         I TAXARR(0)["NO LOCK" S FIEVAL(1)=0 Q
    63         D SETVAR^PXRMTAXS(.TAXARR,.ENS,.INS,.NICD0,.NICD9,.NCPT,.NRCPT,.PLS,.RAS)
    64         D SCPAR^PXRMCOND(.FINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
    65         S SDIR=$S(NOCC<0:+1,1:-1)
    66         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    67         S NGET=$S(UCIFS:50,1:NOCC)
    68         ;
    69         I (NICD0>0),INS D FPDAT^PXRMDGPT(DFN,.TAXARR,NGET,SDIR,BDT,EDT,"ICD0",.TLIST)
    70         ;
    71         I (NICD9>0),INS D FPDAT^PXRMDGPT(DFN,.TAXARR,NGET,SDIR,BDT,EDT,"ICD9",.TLIST)
    72         I (NICD9>0),ENS D FPDAT^PXRMVPOV(DFN,.TAXARR,NGET,SDIR,BDT,EDT,.TLIST)
    73         I (NICD9>0),PLS D
    74         . K STATUSA
    75         . D GETSTATI^PXRMSTAT(9000011,.FINDPA,.STATUSA)
    76         . D FPDAT^PXRMPROB(DFN,.TAXARR,NGET,SDIR,BDT,EDT,.STATUSA,.TLIST)
    77         ;
    78         I (NCPT>0),(ENS) D FPDAT^PXRMVCPT(DFN,.TAXARR,NGET,SDIR,BDT,EDT,.TLIST)
    79         ;
    80         I (NRCPT>0),(RAS) D
    81         . K STATUSA
    82         . D GETSTATI^PXRMSTAT(70,.FINDPA,.STATUSA)
    83         . D FPDAT^PXRMRCPT(DFN,.TAXARR,NOCC,BDT,EDT,.STATUSA,.TLIST)
    84         ;
    85         ;Process the found list, returning the NOCC most recent results.
    86         S NFOUND=0
    87         S DATE=""
    88         F  S DATE=$O(TLIST(DATE),SDIR) Q:(DATE="")!(NFOUND=NOCC)  D
    89         . S IND=0
    90         . F  S IND=$O(TLIST(DATE,IND)) Q:(IND="")!(NFOUND=NOCC)  D
    91         .. S FILENUM=0
    92         .. F  S FILENUM=$O(TLIST(DATE,IND,FILENUM)) Q:FILENUM=""  D
    93         ... S NFOUND=NFOUND+1
    94         ... S DAS=$P(TLIST(DATE,IND,FILENUM),U,1)
    95         ... S FLIST(NFOUND)=TLIST(DATE,IND,FILENUM)
    96         ... S FLIST(NFOUND)=DAS_U_DATE_U_FILENUM_U_$P(TLIST(DATE,IND,FILENUM),U,2,10)
    97         I NFOUND=0 S FIEVAL=0 Q
    98         S NP=0
    99         F IND=1:1:NFOUND Q:NP=NOCC  D
    100         . S DAS=$P(FLIST(IND),U,1)
    101         . S FILENUM=$P(FLIST(IND),U,3)
    102         . D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVT)
    103         . I $D(FIEVT("VISIT")) D GETDATA^PXRMVSIT(FIEVT("VISIT"),.FIEVT,0)
    104         . S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVT),1:1)
    105         . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
    106         . I SAVE D
    107         .. S NP=NP+1
    108         .. S FIEVAL(NP)=CONVAL
    109         .. S FIEVAL(NP,"CONDITION")=CONVAL
    110         .. S FIEVAL(NP,"CODEP")=$P(FLIST(IND),U,4)
    111         .. S FIEVAL(NP,"DAS")=DAS
    112         .. S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
    113         .. S FIEVAL(NP,"FILE NUMBER")=FILENUM
    114         .. S FIEVAL(NP,"FILE SPECIFIC")=$P(FLIST(IND),U,5,10)
    115         .. S FIEVAL(NP,"FINDING")=TAXIEN_";PXD(811.2,"
    116         .. M FIEVAL(NP)=FIEVT
    117         .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVT
    118         ;Save the finding result.
    119         D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
    120         Q
    121         ;
    122         ;==================================================
    123 GPLIST(TAXIEN,FINDPA,PLIST)     ;Get the list of patients with
    124         ;taxonomy TAXIEN. Return the list as:
    125         ; ^TMP($J,PLIST,T/F,DFN,TAXIEN,COUNT,FILE NUMBER)
    126         ; =DAS^DATE^CODE^TYPE^file specific. TAXIEN is like the item for
    127         ;non-taxonomy findings.
    128         N BDT,COND,DATE,DFN,DLIST,EDT,ENS,FILENUM
    129         N ICOND,IND,INS,IPLIST
    130         N NF,NFOUND,NICD0,NICD9,NCPT,NF,NGET,NOCC,NRCPT
    131         N PLS,RAS,STATUSA,UCIFS,USEINP,TAXARR,TF,TLIST,VSLIST
    132         ;Set the finding search parameters.
    133         S TLIST="GPLIST_PXRMTAX"
    134         K ^TMP($J,TLIST)
    135         D SSPAR^PXRMUTIL(FINDPA(0),.NOCC,.BDT,.EDT)
    136         D TAX^PXRMLDR(TAXIEN,.TAXARR)
    137         D SETVAR^PXRMTAXS(.TAXARR,.ENS,.INS,.NICD0,.NICD9,.NCPT,.NRCPT,.PLS,.RAS)
    138         D SCPAR^PXRMCOND(.FINDPA,.COND,.UCIFS,.ICOND,.VSLIST)
    139         ;
    140         I (NICD0>0),INS D GPLIST^PXRMDGPT(.TAXARR,NOCC,BDT,EDT,"ICD0",TLIST)
    141         ;
    142         I (NICD9>0),INS D GPLIST^PXRMDGPT(.TAXARR,NOCC,BDT,EDT,"ICD9",TLIST)
    143         I (NICD9>0),PLS D
    144         . K STATUSA
    145         . D GETSTATI^PXRMSTAT(9000011,.FINDPA,.STATUSA)
    146         . D GPLIST^PXRMPROB(.TAXARR,NOCC,BDT,EDT,.STATUSA,TLIST)
    147         I (NICD9>0),ENS D GPLIST^PXRMVPOV(.TAXARR,NOCC,BDT,EDT,TLIST)
    148         ;
    149         I (NCPT>0),ENS D GPLIST^PXRMVCPT(.TAXARR,NOCC,BDT,EDT,TLIST)
    150         ;
    151         I (NRCPT>0),RAS D GPLIST^PXRMRCPT(.TAXARR,.FINDPA,TLIST)
    152         ;Conditions for taxonomies only apply to radiology findings, this
    153         ;is taken care of in PXRMRCPT.
    154         ;Process the found list, return up to NOCC of the most recent entries.
    155         F TF=0,1 D
    156         . I '$D(^TMP($J,TLIST,TF)) Q
    157         . S DFN=""
    158         . F  S DFN=$O(^TMP($J,TLIST,TF,DFN)) Q:DFN=""  D
    159         .. K DLIST,IPLIST
    160         .. S NFOUND=0
    161         .. S NF=""
    162         .. F  S NF=$O(^TMP($J,TLIST,TF,DFN,NF),-1) Q:NF=""  D
    163         ... S FILENUM=0
    164         ... F  S FILENUM=$O(^TMP($J,TLIST,TF,DFN,NF,FILENUM)) Q:FILENUM=""  D
    165         .... S NFOUND=NFOUND+1
    166         .... S DATE=$P(^TMP($J,TLIST,TF,DFN,NF,FILENUM),U,2)
    167         .... S DLIST(DATE,NFOUND)=NF_U_FILENUM
    168         ..;
    169         .. S DATE="",NFOUND=0
    170         .. F  S DATE=$O(DLIST(DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
    171         ... S NF=0
    172         ... F  S NF=$O(DLIST(DATE,NF)) Q:(NF="")!(NFOUND=NOCC)  D
    173         .... S NFOUND=NFOUND+1
    174         .... S IND=$P(DLIST(DATE,NF),U,1)
    175         .... S FILENUM=$P(DLIST(DATE,NF),U,2)
    176         .... S IPLIST(TF,DFN,TAXIEN,NFOUND,FILENUM)=^TMP($J,TLIST,TF,DFN,IND,FILENUM)
    177         .. M ^TMP($J,PLIST)=IPLIST
    178         K ^TMP($J,TLIST)
    179         Q
    180         ;
    181         ;==================================================
    182 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    183         N IND,FILENUM,FNA,OCCLIST,TIFIEVAL
    184         S IND=0
    185         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  S FILENUM=IFIEVAL(IND,"FILE NUMBER"),FNA(FILENUM,IND)=""
    186         S FILENUM=""
    187         F  S FILENUM=$O(FNA(FILENUM)) Q:FILENUM=""  D
    188         . K OCCLIST
    189         . M OCCLIST=FNA(FILENUM)
    190         . I FILENUM=45 D MHVOUT^PXRMDGPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    191         . I FILENUM=70 D MHVOUT^PXRMRCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    192         . I FILENUM=9000010.07 D MHVOUT^PXRMVPOV(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    193         . I FILENUM=9000010.18 D MHVOUT^PXRMVCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    194         . I FILENUM=9000011 D MHVOUT^PXRMPROB(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT)
    195         Q
    196         ;
    197         ;==================================================
    198 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    199         ;maintenance output.
    200         N IND,FILENUM,FNA,OCCLIST,TIFIEVAL
    201         S IND=0
    202         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  S FILENUM=IFIEVAL(IND,"FILE NUMBER"),FNA(FILENUM,IND)=""
    203         S FILENUM=""
    204         F  S FILENUM=$O(FNA(FILENUM)) Q:FILENUM=""  D
    205         . K OCCLIST
    206         . M OCCLIST=FNA(FILENUM)
    207         . I FILENUM=45 D OUTPUT^PXRMDGPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    208         . I FILENUM=70 D OUTPUT^PXRMRCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    209         . I FILENUM=9000010.07 D OUTPUT^PXRMVPOV(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    210         . I FILENUM=9000010.18 D OUTPUT^PXRMVCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
    211         . I FILENUM=9000011 D OUTPUT^PXRMPROB(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT)
    212         Q
    213         ;
     1PXRMTAX ; SLC/PKR - Handle taxonomy finding. ;07/17/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;==================================================
     5EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate taxonomy findings.
     6 N FIEVT,FINDPA,FINDING
     7 N TAXIEN
     8 S TAXIEN=""
     9 F  S TAXIEN=$O(DEFARR("E",ENODE,TAXIEN)) Q:+TAXIEN=0  D
     10 . S FINDING=""
     11 . F  S FINDING=$O(DEFARR("E",ENODE,TAXIEN,FINDING)) Q:+FINDING=0  D
     12 .. K FINDPA
     13 .. M FINDPA=DEFARR(20,FINDING)
     14 .. K FIEVT
     15 .. D FIEVAL(DFN,TAXIEN,.FINDPA,.FIEVT)
     16 .. M FIEVAL(FINDING)=FIEVT
     17 Q
     18 ;
     19 ;==================================================
     20EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate taxonomy terms for
     21 ;building patient lists.
     22 N PFIND3,PFIND4,PFINDPA,TAXIEN
     23 N TFINDPA,TFINDING
     24 S TAXIEN=""
     25 F  S TAXIEN=$O(TERMARR("E",ENODE,TAXIEN)) Q:+TAXIEN=0  D
     26 . S TFINDING=""
     27 . F  S TFINDING=$O(TERMARR("E",ENODE,TAXIEN,TFINDING)) Q:+TFINDING=0  D
     28 .. K PFINDPA,TFINDPA
     29 .. M TFINDPA=TERMARR(20,TFINDING)
     30 ..;Set the finding parameters.
     31 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     32 .. D GPLIST(TAXIEN,.PFINDPA,PLIST)
     33 Q
     34 ;
     35 ;==================================================
     36EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate taxonomy
     37 ;terms.
     38 N FIEVT,PFINDPA
     39 N TAXIEN,TFINDPA,TFINDING
     40 S TAXIEN=""
     41 F  S TAXIEN=$O(TERMARR("E",ENODE,TAXIEN)) Q:+TAXIEN=0  D
     42 . S TFINDING=""
     43 . F  S TFINDING=$O(TERMARR("E",ENODE,TAXIEN,TFINDING)) Q:+TFINDING=0  D
     44 .. K FIEVT,PFINDPA,TFINDPA
     45 .. M TFINDPA=TERMARR(20,TFINDING)
     46 ..;Set the finding parameters.
     47 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
     48 .. D FIEVAL(DFN,TAXIEN,.PFINDPA,.FIEVT)
     49 .. M TFIEVAL(TFINDING)=FIEVT
     50 Q
     51 ;
     52 ;==================================================
     53FIEVAL(DFN,TAXIEN,FINDPA,FIEVAL) ;
     54 N BDT,CASESEN,COND,CONVAL,DAS,DATE,EDT,ENS,FIEVT,FILENUM,FLIST
     55 N ICOND,IND,INS,INVFD
     56 N NFOUND,NGET,NICD0,NICD9,NCPT,NOCC,NP,NRCPT,PLS
     57 N RAS,SAVE,SDIR,STATUSA,TAXARR,TLIST,UCIFS,USEINP,VSLIST
     58 ;Set the finding search parameters.
     59 D SSPAR^PXRMUTIL(FINDPA(0),.NOCC,.BDT,.EDT)
     60 S INVFD=$P(FINDPA(0),U,16)
     61 D TAX^PXRMLDR(TAXIEN,.TAXARR)
     62 I TAXARR(0)["NO LOCK" S FIEVAL(1)=0 Q
     63 D SETVAR^PXRMTAXS(.TAXARR,.ENS,.INS,.NICD0,.NICD9,.NCPT,.NRCPT,.PLS,.RAS)
     64 D SCPAR^PXRMCOND(.FINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
     65 S SDIR=$S(NOCC<0:+1,1:-1)
     66 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     67 S NGET=$S(UCIFS:"*",1:NOCC)
     68 ;
     69 I (NICD0>0),INS D FPDAT^PXRMDGPT(DFN,.TAXARR,NGET,SDIR,BDT,EDT,"ICD0",.TLIST)
     70 ;
     71 I (NICD9>0),INS D FPDAT^PXRMDGPT(DFN,.TAXARR,NGET,SDIR,BDT,EDT,"ICD9",.TLIST)
     72 I (NICD9>0),ENS D FPDAT^PXRMVPOV(DFN,.TAXARR,NGET,SDIR,BDT,EDT,.TLIST)
     73 I (NICD9>0),PLS D
     74 . K STATUSA
     75 . D GETSTATI^PXRMSTAT(9000011,.FINDPA,.STATUSA)
     76 . D FPDAT^PXRMPROB(DFN,.TAXARR,NGET,SDIR,BDT,EDT,.STATUSA,.TLIST)
     77 ;
     78 I (NCPT>0),(ENS) D FPDAT^PXRMVCPT(DFN,.TAXARR,NGET,SDIR,BDT,EDT,.TLIST)
     79 ;
     80 I (NRCPT>0),(RAS) D
     81 . K STATUSA
     82 . D GETSTATI^PXRMSTAT(70,.FINDPA,.STATUSA)
     83 . D FPDAT^PXRMRCPT(DFN,.TAXARR,NOCC,BDT,EDT,.STATUSA,.TLIST)
     84 ;
     85 ;Process the found list, returning the NOCC most recent results.
     86 S NFOUND=0
     87 S DATE=""
     88 F  S DATE=$O(TLIST(DATE),SDIR) Q:(DATE="")!(NFOUND=NOCC)  D
     89 . S IND=0
     90 . F  S IND=$O(TLIST(DATE,IND)) Q:(IND="")!(NFOUND=NOCC)  D
     91 .. S FILENUM=0
     92 .. F  S FILENUM=$O(TLIST(DATE,IND,FILENUM)) Q:FILENUM=""  D
     93 ... S NFOUND=NFOUND+1
     94 ... S DAS=$P(TLIST(DATE,IND,FILENUM),U,1)
     95 ... S FLIST(NFOUND)=TLIST(DATE,IND,FILENUM)
     96 ... S FLIST(NFOUND)=DAS_U_DATE_U_FILENUM_U_$P(TLIST(DATE,IND,FILENUM),U,2,10)
     97 I NFOUND=0 S FIEVAL=0 Q
     98 S NP=0
     99 F IND=1:1:NFOUND Q:NP=NOCC  D
     100 . S DAS=$P(FLIST(IND),U,1)
     101 . S FILENUM=$P(FLIST(IND),U,3)
     102 . D GETDATA^PXRMDATA(FILENUM,DAS,.FIEVT)
     103 . I $D(FIEVT("VISIT")) D GETDATA^PXRMVSIT(FIEVT("VISIT"),.FIEVT,0)
     104 . S CONVAL=$S(COND'="":$$COND^PXRMCOND(CASESEN,ICOND,VSLIST,.FIEVT),1:1)
     105 . S SAVE=$S('UCIFS:1,(UCIFS&CONVAL):1,1:0)
     106 . I SAVE D
     107 .. S NP=NP+1
     108 .. S FIEVAL(NP)=CONVAL
     109 .. S FIEVAL(NP,"CONDITION")=CONVAL
     110 .. S FIEVAL(NP,"CODEP")=$P(FLIST(IND),U,4)
     111 .. S FIEVAL(NP,"DAS")=DAS
     112 .. S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
     113 .. S FIEVAL(NP,"FILE NUMBER")=FILENUM
     114 .. S FIEVAL(NP,"FILE SPECIFIC")=$P(FLIST(IND),U,5,10)
     115 .. S FIEVAL(NP,"FINDING")=TAXIEN_";PXD(811.2,"
     116 .. M FIEVAL(NP)=FIEVT
     117 .. I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVT
     118 ;Save the finding result.
     119 D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
     120 Q
     121 ;
     122 ;==================================================
     123GPLIST(TAXIEN,FINDPA,PLIST) ;Get the list of patients with
     124 ;taxonomy TAXIEN. Return the list as:
     125 ; ^TMP($J,PLIST,T/F,DFN,TAXIEN,COUNT,FILE NUMBER)
     126 ; =DAS^DATE^CODE^TYPE^file specific. TAXIEN is like the item for
     127 ;non-taxonomy findings.
     128 N BDT,COND,DATE,DFN,DLIST,EDT,ENS,FILENUM
     129 N ICOND,IND,INS,IPLIST
     130 N NF,NFOUND,NICD0,NICD9,NCPT,NF,NGET,NOCC,NRCPT
     131 N PLS,RAS,STATUSA,UCIFS,USEINP,TAXARR,TF,TLIST,VSLIST
     132 ;Set the finding search parameters.
     133 S TLIST="GPLIST_PXRMTAX"
     134 K ^TMP($J,TLIST)
     135 D SSPAR^PXRMUTIL(FINDPA(0),.NOCC,.BDT,.EDT)
     136 D TAX^PXRMLDR(TAXIEN,.TAXARR)
     137 D SETVAR^PXRMTAXS(.TAXARR,.ENS,.INS,.NICD0,.NICD9,.NCPT,.NRCPT,.PLS,.RAS)
     138 D SCPAR^PXRMCOND(.FINDPA,.COND,.UCIFS,.ICOND,.VSLIST)
     139 ;
     140 I (NICD0>0),INS D GPLIST^PXRMDGPT(.TAXARR,NOCC,BDT,EDT,"ICD0",TLIST)
     141 ;
     142 I (NICD9>0),INS D GPLIST^PXRMDGPT(.TAXARR,NOCC,BDT,EDT,"ICD9",TLIST)
     143 I (NICD9>0),PLS D
     144 . K STATUSA
     145 . D GETSTATI^PXRMSTAT(9000011,.FINDPA,.STATUSA)
     146 . D GPLIST^PXRMPROB(.TAXARR,NOCC,BDT,EDT,.STATUSA,TLIST)
     147 I (NICD9>0),ENS D GPLIST^PXRMVPOV(.TAXARR,NOCC,BDT,EDT,TLIST)
     148 ;
     149 I (NCPT>0),ENS D GPLIST^PXRMVCPT(.TAXARR,NOCC,BDT,EDT,TLIST)
     150 ;
     151 I (NRCPT>0),RAS D GPLIST^PXRMRCPT(.TAXARR,.FINDPA,TLIST)
     152 ;Conditions for taxonomies only apply to radiology findings, this
     153 ;is taken care of in PXRMRCPT.
     154 ;Process the found list, return up to NOCC of the most recent entries.
     155 F TF=0,1 D
     156 . I '$D(^TMP($J,TLIST,TF)) Q
     157 . S DFN=""
     158 . F  S DFN=$O(^TMP($J,TLIST,TF,DFN)) Q:DFN=""  D
     159 .. K DLIST,IPLIST
     160 .. S NFOUND=0
     161 .. S NF=""
     162 .. F  S NF=$O(^TMP($J,TLIST,TF,DFN,NF),-1) Q:NF=""  D
     163 ... S FILENUM=0
     164 ... F  S FILENUM=$O(^TMP($J,TLIST,TF,DFN,NF,FILENUM)) Q:FILENUM=""  D
     165 .... S NFOUND=NFOUND+1
     166 .... S DATE=$P(^TMP($J,TLIST,TF,DFN,NF,FILENUM),U,2)
     167 .... S DLIST(DATE,NFOUND)=NF_U_FILENUM
     168 ..;
     169 .. S DATE="",NFOUND=0
     170 .. F  S DATE=$O(DLIST(DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
     171 ... S NF=0
     172 ... F  S NF=$O(DLIST(DATE,NF)) Q:(NF="")!(NFOUND=NOCC)  D
     173 .... S NFOUND=NFOUND+1
     174 .... S IND=$P(DLIST(DATE,NF),U,1)
     175 .... S FILENUM=$P(DLIST(DATE,NF),U,2)
     176 .... S IPLIST(TF,DFN,TAXIEN,NFOUND,FILENUM)=^TMP($J,TLIST,TF,DFN,IND,FILENUM)
     177 .. M ^TMP($J,PLIST)=IPLIST
     178 K ^TMP($J,TLIST)
     179 Q
     180 ;
     181 ;==================================================
     182MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     183 N IND,FILENUM,FNA,OCCLIST,TIFIEVAL
     184 S IND=0
     185 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  S FILENUM=IFIEVAL(IND,"FILE NUMBER"),FNA(FILENUM,IND)=""
     186 S FILENUM=""
     187 F  S FILENUM=$O(FNA(FILENUM)) Q:FILENUM=""  D
     188 . K OCCLIST
     189 . M OCCLIST=FNA(FILENUM)
     190 . I FILENUM=45 D MHVOUT^PXRMDGPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     191 . I FILENUM=70 D MHVOUT^PXRMRCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     192 . I FILENUM=9000010.07 D MHVOUT^PXRMVPOV(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     193 . I FILENUM=9000010.18 D MHVOUT^PXRMVCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     194 . I FILENUM=9000011 D MHVOUT^PXRMPROB(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT)
     195 Q
     196 ;
     197 ;==================================================
     198OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     199 ;maintenance output.
     200 N IND,FILENUM,FNA,OCCLIST,TIFIEVAL
     201 S IND=0
     202 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  S FILENUM=IFIEVAL(IND,"FILE NUMBER"),FNA(FILENUM,IND)=""
     203 S FILENUM=""
     204 F  S FILENUM=$O(FNA(FILENUM)) Q:FILENUM=""  D
     205 . K OCCLIST
     206 . M OCCLIST=FNA(FILENUM)
     207 . I FILENUM=45 D OUTPUT^PXRMDGPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     208 . I FILENUM=70 D OUTPUT^PXRMRCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     209 . I FILENUM=9000010.07 D OUTPUT^PXRMVPOV(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     210 . I FILENUM=9000010.18 D OUTPUT^PXRMVCPT(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT) Q
     211 . I FILENUM=9000011 D OUTPUT^PXRMPROB(INDENT,.OCCLIST,.IFIEVAL,.NLINES,.TEXT)
     212 Q
     213 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMTERM.m

    r613 r623  
    1 PXRMTERM        ; SLC/PKR - Handle reminder terms. ;04/23/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=============================================
    5 COPY(NOCC,SDIR,TFIEVAL,DATEORDR,FINDING,FIEVAL) ;Copy the NOCC date ordered
    6         ;findings from TFIEVAL to FIEVAL(FINDING).
    7         N DATE,IND,JND,MRS,NFOUND,TFI
    8         ;Start with most recent and go to oldest finding.
    9         S MRS=1
    10         S NFOUND=0
    11         S DATE=""
    12         F  S DATE=$O(DATEORDR(DATE),SDIR) Q:(NFOUND=NOCC)!(DATE="")  D
    13         . S TFI=0
    14         . F  S TFI=$O(DATEORDR(DATE,TFI)) Q:(NFOUND=NOCC)!(TFI="")  D
    15         .. I MRS D
    16         ...;Save the main result node.
    17         ... S FIEVAL(FINDING)=TFIEVAL(TFI)
    18         ... S MRS=0
    19         ... I 'FIEVAL(FINDING) Q
    20         ... S JND="@"
    21         ... F  S JND=$O(TFIEVAL(TFI,JND)) Q:JND=""  M FIEVAL(FINDING,JND)=TFIEVAL(TFI,JND)
    22         .. I 'FIEVAL(FINDING) Q
    23         .. S IND=0
    24         .. F  S IND=$O(DATEORDR(DATE,TFI,IND)) Q:(NFOUND=NOCC)!(IND="")  D
    25         ...;Only save true sub-results.
    26         ... I 'TFIEVAL(TFI,IND) Q
    27         ... S NFOUND=NFOUND+1
    28         ... M FIEVAL(FINDING,NFOUND)=TFIEVAL(TFI,IND)
    29         ... S FIEVAL(FINDING,NFOUND,"FILE NUMBER")=TFIEVAL(TFI,"FILE NUMBER")
    30         ... S FIEVAL(FINDING,NFOUND,"FINDING")=TFIEVAL(TFI,"FINDING")
    31         ... S JND=0
    32         ... F  S JND=$O(TFIEVAL(TFI,IND,JND)) Q:JND=""  M FIEVAL(FINDING,NFOUND,JND)=TFIEVAL(TFI,IND,JND)
    33         Q
    34         ;
    35         ;=============================================
    36 DORDER(TFIEVAL,DATEORDR)        ;Order term findings by date, term finding,
    37         ;and term finding occurrence.
    38         N DATE,FI,IND
    39         K DATEORDR
    40         S FI=0
    41         F  S FI=+$O(TFIEVAL(FI)) Q:FI=0  D
    42         . S IND=0
    43         . F  S IND=+$O(TFIEVAL(FI,IND)) Q:IND=0  D
    44         .. S DATE=$G(TFIEVAL(FI,IND,"DATE"))
    45         .. I DATE'="" S DATEORDR(DATE,FI,IND)=""
    46         Q
    47         ;
    48         ;=============================================
    49 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate all reminder terms in a
    50         ;definition.
    51         N CASESEN,CONVAL,DATE,DATEORDR
    52         N FIEVT,FINDING,FINDPA,IND,NOCC
    53         N SDIR,TFIND3,TFIND4,TERMARR,TERMIEN,TFI,TFIEVAL,UCIFS
    54         S TERMIEN=""
    55         F  S TERMIEN=$O(DEFARR("E",ENODE,TERMIEN)) Q:+TERMIEN=0  D
    56         . I '$D(^PXRMD(811.5,TERMIEN,20,"E")) D  Q
    57         .. S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","NOFI",TERMIEN)="Warning no findings items in reminder term "_$P(^PXRMD(811.5,TERMIEN,0),U,1)
    58         .. S FINDING=""
    59         .. F  S FINDING=$O(DEFARR("E",ENODE,TERMIEN,FINDING)) Q:FINDING=""  S FIEVAL(FINDING)=0
    60         . D TERM^PXRMLDR(TERMIEN,.TERMARR)
    61         . S FINDING=""
    62         . F  S FINDING=$O(DEFARR("E",ENODE,TERMIEN,FINDING)) Q:+FINDING=0  D
    63         .. S FIEVAL(FINDING)=0
    64         .. S FIEVAL(FINDING,"TERM")=TERMARR(0)
    65         .. S FIEVAL(FINDING,"TERM IEN")=TERMIEN
    66         .. K FINDPA,TFIEVAL
    67         .. M FINDPA=DEFARR(20,FINDING)
    68         .. D EVALTERM(DFN,.FINDPA,.TERMARR,.TFIEVAL)
    69         .. I $G(PXRMTDEB) M ^TMP("PXRMTDEB",$J,FINDING)=TFIEVAL
    70         ..;Set NOCC and SDIR.
    71         .. S NOCC=$P(FINDPA(0),U,14)
    72         .. I NOCC="" S NOCC=1
    73         .. S SDIR=$S(NOCC<0:+1,1:-1)
    74         .. S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    75         ..;Order the term findings by date.
    76         .. D DORDER(.TFIEVAL,.DATEORDR)
    77         .. D COPY(NOCC,SDIR,.TFIEVAL,.DATEORDR,FINDING,.FIEVAL)
    78         Q
    79         ;
    80         ;=============================================
    81 EVALTERM(DFN,FINDPA,TERMARR,TFIEVAL)    ;Evaluate all the findings in
    82         ;a term. Use the "E" cross-reference just like the finding evaluation.
    83         N ENODE
    84         S ENODE=""
    85         F  S ENODE=$O(TERMARR("E",ENODE)) Q:ENODE=""  D
    86         . I ENODE="AUTTEDT(" D EVALTERM^PXRMEDU(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    87         . I ENODE="AUTTEXAM(" D EVALTERM^PXRMEXAM(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    88         . I ENODE="AUTTHF(" D EVALTERM^PXRMHF(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    89         . I ENODE="AUTTIMM(" D EVALTERM^PXRMIMM(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    90         . I ENODE="AUTTSK(" D EVALTERM^PXRMSKIN(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    91         . I ENODE="GMRD(120.51," D EVALTERM^PXRMVITL(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    92         . I ENODE="LAB(60," D EVALTERM^PXRMLAB(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    93         . I ENODE="ORD(101.43," D EVALTERM^PXRMORDR(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    94         . I ENODE="PXD(811.2," D EVALTERM^PXRMTAX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    95         . I ENODE="PXRMD(810.9," D EVALTERM^PXRMLOCF(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    96         . I ENODE="PXRMD(811.4," D EVALTERM^PXRMCF(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    97         . I ENODE="PS(50.605," D EVALTERM^PXRMDRCL(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    98         . I ENODE="PS(55," D EVALTERM^PXRMDIN(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    99         . I ENODE="PS(55NVA," D EVALTERM^PXRMDNVA(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    100         . I ENODE="PSDRUG(" D EVALTERM^PXRMDRUG(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    101         . I ENODE="PSRX(" D EVALTERM^PXRMDOUT(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    102         . I ENODE="PSNDF(50.6," D EVALTERM^PXRMDGEN(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    103         . I ENODE="RAMIS(71," D EVALTERM^PXRMRAD(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    104         . I ENODE="YTT(601.71," D EVALTERM^PXRMMH(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
    105         Q
    106         ;
    107         ;=============================================
    108 IEVALTER(DFN,FINDPA,TERMARR,FINDING,FIEVAL)     ;Evaluate an individual term
    109         ;put the result in FIEVAL(FINDING).
    110         N DATEORDR,NOCC,SDIR,TFIEVAL
    111         I $D(PXRMPDEM) G DEMOK
    112         N PXRMPDEM D DEM^PXRMPINF(DFN,DT,.PXRMPDEM)
    113         ;Create the local demographic variables for use in Condition.
    114         N PXRMAGE,PXRMDOB,PXRMDOD,PXRMLAD,PXRMSEX
    115         S PXRMAGE=PXRMPDEM("AGE"),PXRMDOB=PXRMPDEM("DOB"),PXRMDOD=PXRMPDEM("DOD")
    116         S PXRMLAD=PXRMPDEM("LAD"),PXRMSEX=PXRMPDEM("SEX")
    117 DEMOK   S FIEVAL(FINDING)=0
    118         D EVALTERM(DFN,.FINDPA,.TERMARR,.TFIEVAL)
    119         ;Set NOCC and SDIR.
    120         S NOCC=$P(FINDPA(0),U,14)
    121         I NOCC="" S NOCC=1
    122         S SDIR=$S(NOCC<0:+1,1:-1)
    123         S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
    124         ;Order the term findings by date.
    125         D DORDER(.TFIEVAL,.DATEORDR)
    126         D COPY(NOCC,SDIR,.TFIEVAL,.DATEORDR,FINDING,.FIEVAL)
    127         Q
    128         ;
    129         ;=============================================
    130 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    131         D OPT(INDENT,.IFIEVAL,.NLINES,.TEXT,"MHV")
    132         Q
    133         ;
    134         ;=============================================
    135 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    136         ;maintenance output.
    137         D OPT(INDENT,.IFIEVAL,.NLINES,.TEXT,"CM")
    138         Q
    139         ;
    140         ;=============================================
    141 OPT(INDENT,IFIEVAL,NLINES,TEXT,TYPE)    ;General output.
    142         N DG,DGL,DGN,IEN,IND,JND,KND,INDENTT,FILENUM,TEMP,TIFIEVAL
    143         ;Build the display grouping.
    144         S FILENUM=IFIEVAL(1,"FILE NUMBER")
    145         S IEN=$P(IFIEVAL(1,"FINDING"),";",1)
    146         S DG(FILENUM,IEN)=1,DGL(1)=FILENUM_U_IEN,DGL(1,1)=""
    147         S (DGN,IND)=1
    148         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    149         . S FILENUM=IFIEVAL(IND,"FILE NUMBER")
    150         . S IEN=$P(IFIEVAL(IND,"FINDING"),";",1)
    151         . I '$D(DG(FILENUM,IEN)) D
    152         .. S DGN=DGN+1,DG(FILENUM,IEN)=DGN
    153         .. S DGL(DGN)=FILENUM_U_IEN,DGL(DGN,IND)=""
    154         . I $D(DG(FILENUM,IEN)) D
    155         .. S TEMP=DG(FILENUM,IEN),DGL(TEMP,IND)=""
    156         S INDENTT=INDENT+1
    157         S TEMP=$$INSCHR^PXRMEXLC(INDENT," ")_"Reminder Term: "_$P(FIEVAL(FINDING,"TERM"),U,1)
    158         S NLINES=NLINES+1,TEXT(NLINES)=TEMP
    159         F IND=1:1:DGN D
    160         . K TIFIEVAL
    161         . S (JND,KND)=0
    162         . F  S JND=$O(DGL(IND,JND)) Q:JND=""  D
    163         .. S KND=KND+1
    164         .. I KND=1 M TIFIEVAL=IFIEVAL(JND)
    165         .. M TIFIEVAL(KND)=IFIEVAL(JND)
    166         . I TYPE="CM" D FOUT^PXRMOUTC(INDENTT,.TIFIEVAL,.NLINES,.TEXT)
    167         . I TYPE="MHV" D FOUT^PXRMOUTM(INDENTT,.TIFIEVAL,.NLINES,.TEXT)
    168         Q
    169         ;
    170         ;=============================================
    171 SPFINDPA(FINDPA,TFINDPA,PFINDPA)        ;Set the finding parameter array
    172         ;for terms.
    173         N FIND0,PIECE,PFIND0,TFIND0,VAL
    174         S FIND0=$G(FINDPA(0))
    175         S (PFIND0,TFIND0)=TFINDPA(0)
    176         ;Set the 0 node.
    177         F PIECE=9,10,12,13,14,15,16 D
    178         . S VAL=$P(TFIND0,U,PIECE)
    179         . I VAL="" S VAL=$P(FIND0,U,PIECE)
    180         . S $P(PFIND0,U,PIECE)=VAL
    181         ;BDT and EDT are treated as a pair.
    182         I $P(TFIND0,U,8)="",$P(TFIND0,U,11)="" F PIECE=8,11 S $P(PFIND0,U,PIECE)=$P(FIND0,U,PIECE)
    183         E  F PIECE=8,11 S $P(PFIND0,U,PIECE)=$P(TFIND0,U,PIECE)
    184         S PFINDPA(0)=PFIND0
    185         I $P($G(TFINDPA(3)),U,1)'="" S PFINDPA(3)=TFINDPA(3),PFINDPA(10)=TFINDPA(10),PFINDPA(11)=TFINDPA(11)
    186         E  S PFINDPA(3)=$G(FINDPA(3)),PFINDPA(10)=$G(FINDPA(10)),PFINDPA(11)=$G(FINDPA(11))
    187         ;Get the status list.
    188         I $D(TFINDPA(5)) M PFINDPA(5)=TFINDPA(5)
    189         E  M PFINDPA(5)=FINDPA(5)
    190         I $D(TFINDPA(15)) S PFINDPA(15)=TFINDPA(15)
    191         E  S PFINDPA(15)=$G(FINDPA(15))
    192         Q
    193         ;
     1PXRMTERM ; SLC/PKR - Handle reminder terms. ;06/29/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=============================================
     5COPY(NOCC,SDIR,TFIEVAL,DATEORDR,FINDING,FIEVAL) ;Copy the NOCC date ordered
     6 ;findings from TFIEVAL to FIEVAL(FINDING).
     7 N DATE,IND,JND,MRS,NFOUND,TFI
     8 ;Start with most recent and go to oldest finding.
     9 S MRS=1
     10 S NFOUND=0
     11 S DATE=""
     12 F  S DATE=$O(DATEORDR(DATE),SDIR) Q:(NFOUND=NOCC)!(DATE="")  D
     13 . S TFI=0
     14 . F  S TFI=$O(DATEORDR(DATE,TFI)) Q:(NFOUND=NOCC)!(TFI="")  D
     15 .. I MRS D
     16 ...;Save the main result node.
     17 ... S FIEVAL(FINDING)=TFIEVAL(TFI)
     18 ... S MRS=0
     19 ... I 'FIEVAL(FINDING) Q
     20 ... S JND="@"
     21 ... F  S JND=$O(TFIEVAL(TFI,JND)) Q:JND=""  D
     22 .... M FIEVAL(FINDING,JND)=TFIEVAL(TFI,JND)
     23 .. I 'FIEVAL(FINDING) Q
     24 .. S IND=0
     25 .. F  S IND=$O(DATEORDR(DATE,TFI,IND)) Q:(NFOUND=NOCC)!(IND="")  D
     26 ...;Only save true sub-results.
     27 ... I 'TFIEVAL(TFI,IND) Q
     28 ... S NFOUND=NFOUND+1
     29 ... M FIEVAL(FINDING,NFOUND)=TFIEVAL(TFI,IND)
     30 ... S FIEVAL(FINDING,NFOUND,"FILE NUMBER")=TFIEVAL(TFI,"FILE NUMBER")
     31 ... S FIEVAL(FINDING,NFOUND,"FINDING")=TFIEVAL(TFI,"FINDING")
     32 ... S JND=0
     33 ... F  S JND=$O(TFIEVAL(TFI,IND,JND)) Q:JND=""  M FIEVAL(FINDING,NFOUND,JND)=TFIEVAL(TFI,IND,JND)
     34 Q
     35 ;
     36 ;=============================================
     37DORDER(TFIEVAL,DATEORDR) ;Order term findings by date, term finding,
     38 ;and term finding occurrence.
     39 N DATE,FI,IND
     40 K DATEORDR
     41 S FI=0
     42 F  S FI=+$O(TFIEVAL(FI)) Q:FI=0  D
     43 . S IND=0
     44 . F  S IND=+$O(TFIEVAL(FI,IND)) Q:IND=0  D
     45 .. S DATE=$G(TFIEVAL(FI,IND,"DATE"))
     46 .. I DATE'="" S DATEORDR(DATE,FI,IND)=""
     47 Q
     48 ;
     49 ;=============================================
     50EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate all reminder terms in a
     51 ;definition.
     52 N CASESEN,CONVAL,DATE,DATEORDR
     53 N FIEVT,FINDING,FINDPA,IND,NOCC
     54 N SDIR,TFIND3,TFIND4,TERMARR,TERMIEN,TFI,TFIEVAL,UCIFS
     55 S TERMIEN=""
     56 F  S TERMIEN=$O(DEFARR("E",ENODE,TERMIEN)) Q:+TERMIEN=0  D
     57 . I '$D(^PXRMD(811.5,TERMIEN,20,"E")) D  Q
     58 .. S ^TMP(PXRMPID,$J,PXRMITEM,"WARNING","NOFI",TERMIEN)="Warning no findings items in reminder term "_$P(^PXRMD(811.5,TERMIEN,0),U,1)
     59 .. S FINDING=""
     60 .. F  S FINDING=$O(DEFARR("E",ENODE,TERMIEN,FINDING)) Q:FINDING=""  S FIEVAL(FINDING)=0
     61 . D TERM^PXRMLDR(TERMIEN,.TERMARR)
     62 . S FINDING=""
     63 . F  S FINDING=$O(DEFARR("E",ENODE,TERMIEN,FINDING)) Q:+FINDING=0  D
     64 .. S FIEVAL(FINDING)=0
     65 .. S FIEVAL(FINDING,"TERM")=TERMARR(0)
     66 .. S FIEVAL(FINDING,"TERM IEN")=TERMIEN
     67 .. K FINDPA,TFIEVAL
     68 .. M FINDPA=DEFARR(20,FINDING)
     69 .. D EVALTERM(DFN,.FINDPA,.TERMARR,.TFIEVAL)
     70 .. I $G(PXRMTDEB) M ^TMP("PXRMTDEB",$J,FINDING)=TFIEVAL
     71 ..;Set NOCC and SDIR.
     72 .. S NOCC=$P(FINDPA(0),U,14)
     73 .. I NOCC="" S NOCC=1
     74 .. S SDIR=$S(NOCC<0:+1,1:-1)
     75 .. S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     76 ..;Order the term findings by date.
     77 .. D DORDER(.TFIEVAL,.DATEORDR)
     78 .. D COPY(NOCC,SDIR,.TFIEVAL,.DATEORDR,FINDING,.FIEVAL)
     79 Q
     80 ;
     81 ;=============================================
     82EVALPL(FINDPA,TERMARR,PLIST) ;Build a list of patients based on a
     83 ;term. The list is returned in:
     84 ;^TMP($J,PLIST,T/F,DFN,ITEM,NFOUND,FILENUM)=DAS_U_DATE_U_VALUE
     85 ;for findings with a start and stop date the list is
     86 ;^TMP($J,PLIST,T/F,DFN,ITEM,NFOUND,FILENUM)=DAS_U_START_U_STOP_U_VALUE
     87 N ENODE
     88 K ^TMP($J,PLIST)
     89 S ENODE=""
     90 F  S ENODE=$O(TERMARR("E",ENODE)) Q:ENODE=""  D
     91 . I ENODE="AUTTEDT(" D EVALPL^PXRMEDU(.FINDPA,ENODE,.TERMARR,PLIST) Q
     92 . I ENODE="AUTTEXAM(" D EVALPL^PXRMEXAM(.FINDPA,ENODE,.TERMARR,PLIST) Q
     93 . I ENODE="AUTTHF(" D EVALPL^PXRMHF(.FINDPA,ENODE,.TERMARR,PLIST) Q
     94 . I ENODE="AUTTIMM(" D EVALPL^PXRMIMM(.FINDPA,ENODE,.TERMARR,PLIST) Q
     95 . I ENODE="AUTTSK(" D EVALPL^PXRMSKIN(.FINDPA,ENODE,.TERMARR,PLIST) Q
     96 . I ENODE="GMRD(120.51," D EVALPL^PXRMVITL(.FINDPA,ENODE,.TERMARR,PLIST) Q
     97 . I ENODE="LAB(60," D EVALPL^PXRMLAB(.FINDPA,ENODE,.TERMARR,PLIST) Q
     98 . I ENODE="ORD(101.43," D EVALPL^PXRMORDR(.FINDPA,ENODE,.TERMARR,PLIST) Q
     99 . I ENODE="PXRMD(810.9," D EVALPL^PXRMLOCL(.FINDPA,ENODE,.TERMARR,PLIST) Q
     100 . I ENODE="PXD(811.2," D EVALPL^PXRMTAX(.FINDPA,ENODE,.TERMARR,PLIST) Q
     101 . I ENODE="PXRMD(811.4," D EVALPL^PXRMCF(.FINDPA,ENODE,.TERMARR,PLIST) Q
     102 . I ENODE="PS(50.605," D EVALPL^PXRMDRCL(.FINDPA,ENODE,.TERMARR,PLIST) Q
     103 . I ENODE="PSDRUG(" D EVALPL^PXRMDRUG(.FINDPA,ENODE,.TERMARR,PLIST) Q
     104 . I ENODE="PSNDF(50.6," D EVALPL^PXRMDGEN(.FINDPA,ENODE,.TERMARR,PLIST) Q
     105 . I ENODE="RAMIS(71," D EVALPL^PXRMRAD(.FINDPA,ENODE,.TERMARR,PLIST) Q
     106 . I ENODE="YTT(601," D EVALPL^PXRMMH(.FINDPA,ENODE,.TERMARR,PLIST) Q
     107 Q
     108 ;
     109 ;=============================================
     110EVALTERM(DFN,FINDPA,TERMARR,TFIEVAL) ;Evaluate all the findings in
     111 ;a term. Use the "E" cross-reference just like the finding evaluation.
     112 N ENODE
     113 S ENODE=""
     114 F  S ENODE=$O(TERMARR("E",ENODE)) Q:ENODE=""  D
     115 . I ENODE="AUTTEDT(" D EVALTERM^PXRMEDU(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     116 . I ENODE="AUTTEXAM(" D EVALTERM^PXRMEXAM(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     117 . I ENODE="AUTTHF(" D EVALTERM^PXRMHF(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     118 . I ENODE="AUTTIMM(" D EVALTERM^PXRMIMM(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     119 . I ENODE="AUTTSK(" D EVALTERM^PXRMSKIN(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     120 . I ENODE="GMRD(120.51," D EVALTERM^PXRMVITL(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     121 . I ENODE="LAB(60," D EVALTERM^PXRMLAB(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     122 . I ENODE="ORD(101.43," D EVALTERM^PXRMORDR(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     123 . I ENODE="PXD(811.2," D EVALTERM^PXRMTAX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     124 . I ENODE="PXRMD(810.9," D EVALTERM^PXRMLOCF(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     125 . I ENODE="PXRMD(811.4," D EVALTERM^PXRMCF(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     126 . I ENODE="PS(50.605," D EVALTERM^PXRMDRCL(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     127 . I ENODE="PS(55," D EVALTERM^PXRMDIN(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     128 . I ENODE="PS(55NVA," D EVALTERM^PXRMDNVA(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     129 . I ENODE="PSDRUG(" D EVALTERM^PXRMDRUG(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     130 . I ENODE="PSRX(" D EVALTERM^PXRMDOUT(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     131 . I ENODE="PSNDF(50.6," D EVALTERM^PXRMDGEN(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     132 . I ENODE="RAMIS(71," D EVALTERM^PXRMRAD(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     133 . I ENODE="YTT(601," D EVALTERM^PXRMMH(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL) Q
     134 Q
     135 ;
     136 ;=============================================
     137IEVALTER(DFN,FINDPA,TERMARR,FINDING,FIEVAL) ;Evaluate an individual term
     138 ;put the result in FIEVAL(FINDING).
     139 N DATEORDR,NOCC,SDIR,TFIEVAL
     140 I $D(PXRMPDEM) G DEMOK
     141 N PXRMPDEM D DEM^PXRMPINF(DFN,DT,.PXRMPDEM)
     142 ;Create the local demographic variables for use in Condition.
     143 N PXRMAGE,PXRMDOB,PXRMDOD,PXRMLAD,PXRMSEX
     144 S PXRMAGE=PXRMPDEM("AGE"),PXRMDOB=PXRMPDEM("DOB"),PXRMDOD=PXRMPDEM("DOD")
     145 S PXRMLAD=PXRMPDEM("LAD"),PXRMSEX=PXRMPDEM("SEX")
     146DEMOK S FIEVAL(FINDING)=0
     147 D EVALTERM(DFN,.FINDPA,.TERMARR,.TFIEVAL)
     148 ;Set NOCC and SDIR.
     149 S NOCC=$P(FINDPA(0),U,14)
     150 I NOCC="" S NOCC=1
     151 S SDIR=$S(NOCC<0:+1,1:-1)
     152 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
     153 ;Order the term findings by date.
     154 D DORDER(.TFIEVAL,.DATEORDR)
     155 D COPY(NOCC,SDIR,.TFIEVAL,.DATEORDR,FINDING,.FIEVAL)
     156 Q
     157 ;
     158 ;=============================================
     159MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     160 D OPT(INDENT,.IFIEVAL,.NLINES,.TEXT,"MHV")
     161 Q
     162 ;
     163 ;=============================================
     164OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     165 ;maintenance output.
     166 D OPT(INDENT,.IFIEVAL,.NLINES,.TEXT,"CM")
     167 Q
     168 ;
     169 ;=============================================
     170OPT(INDENT,IFIEVAL,NLINES,TEXT,TYPE) ;General output.
     171 N DG,DGL,DGN,DRUG,IEN,IND,JND,KND,INDENTT,FILENUM,TEMP,TIFIEVAL
     172 ;If there is a drug make it available for display.
     173 S DRUG=$S($D(IFIEVAL("DISPENSE DRUG")):IFIEVAL("DISPENSE DRUG"),1:"")
     174 ;DBIA #10043
     175 I DRUG'="" S DRUG=$P(^PSDRUG(DRUG,0),U,1)
     176 ;Build the display grouping.
     177 S FILENUM=IFIEVAL(1,"FILE NUMBER")
     178 S IEN=$P(IFIEVAL(1,"FINDING"),";",1)
     179 S DG(FILENUM,IEN)=1,DGL(1)=FILENUM_U_IEN,DGL(1,1)=""
     180 S (DGN,IND)=1
     181 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     182 . S FILENUM=IFIEVAL(IND,"FILE NUMBER")
     183 . S IEN=$P(IFIEVAL(IND,"FINDING"),";",1)
     184 . I '$D(DG(FILENUM,IEN)) D
     185 .. S DGN=DGN+1,DG(FILENUM,IEN)=DGN
     186 .. S DGL(DGN)=FILENUM_U_IEN,DGL(DGN,IND)=""
     187 . I $D(DG(FILENUM,IEN)) D
     188 .. S TEMP=DG(FILENUM,IEN),DGL(TEMP,IND)=""
     189 S INDENTT=INDENT+1
     190 S TEMP=$$INSCHR^PXRMEXLC(INDENT," ")_"Reminder Term: "_$P(FIEVAL(FINDING,"TERM"),U,1)
     191 S NLINES=NLINES+1,TEXT(NLINES)=TEMP
     192 F IND=1:1:DGN D
     193 . K TIFIEVAL
     194 . S (JND,KND)=0
     195 . F  S JND=$O(DGL(IND,JND)) Q:JND=""  D
     196 .. S KND=KND+1
     197 .. I KND=1 M TIFIEVAL=IFIEVAL(JND)
     198 .. M TIFIEVAL(KND)=IFIEVAL(JND)
     199 .. I DRUG'="" S TIFIEVAL("DISPENSE DRUG")=DRUG
     200 . I TYPE="CM" D FOUT^PXRMOUTC(INDENTT,.TIFIEVAL,.NLINES,.TEXT)
     201 . I TYPE="MHV" D FOUT^PXRMOUTM(INDENTT,.TIFIEVAL,.NLINES,.TEXT)
     202 Q
     203 ;
     204 ;=============================================
     205SPFINDPA(FINDPA,TFINDPA,PFINDPA) ;Set the finding parameter array
     206 ;for terms.
     207 N FIND0,PIECE,PFIND0,TFIND0,VAL
     208 S FIND0=$G(FINDPA(0))
     209 S (PFIND0,TFIND0)=TFINDPA(0)
     210 ;Set the 0 node.
     211 F PIECE=9,10,12,13,14,15,16 D
     212 . S VAL=$P(TFIND0,U,PIECE)
     213 . I VAL="" S VAL=$P(FIND0,U,PIECE)
     214 . S $P(PFIND0,U,PIECE)=VAL
     215 ;BDT and EDT are treated as a pair.
     216 I $P(TFIND0,U,8)="",$P(TFIND0,U,11)="" F PIECE=8,11 S $P(PFIND0,U,PIECE)=$P(FIND0,U,PIECE)
     217 E  F PIECE=8,11 S $P(PFIND0,U,PIECE)=$P(TFIND0,U,PIECE)
     218 S PFINDPA(0)=PFIND0
     219 I $P($G(TFINDPA(3)),U,1)'="" S PFINDPA(3)=TFINDPA(3),PFINDPA(10)=TFINDPA(10),PFINDPA(11)=TFINDPA(11)
     220 E  S PFINDPA(3)=$G(FINDPA(3)),PFINDPA(10)=$G(FINDPA(10)),PFINDPA(11)=$G(FINDPA(11))
     221 ;Get the status list.
     222 I $D(TFINDPA(5)) M PFINDPA(5)=TFINDPA(5)
     223 E  M PFINDPA(5)=FINDPA(5)
     224 I $D(TFINDPA(15)) S PFINDPA(15)=TFINDPA(15)
     225 E  S PFINDPA(15)=$G(FINDPA(15))
     226 Q
     227 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMTEXT.m

    r613 r623  
    1 PXRMTEXT        ; SLC/PKR - Text formatting utility routines. ;07/19/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;============================================
    5 NEWLINE ;Put TEXT on a new line to the output, make sure it does not end
    6         ;with a " ".
    7         N TLEN
    8         ;If there is no text in TEXT don't do anything.
    9         I TEXT=INDSTR Q
    10         S TLEN=$L(TEXT)
    11         I $E(TEXT,TLEN)=" " S TEXT=$E(TEXT,1,TLEN-1)
    12         S NOUT=NOUT+1,TEXTOUT(NOUT)=TEXT
    13         S TEXT=INDSTR,CLEN=0
    14         Q
    15         ;
    16         ;============================================
    17 BLANK   ;Add a blank line (line containing just " ") to the output.
    18         S NOUT=NOUT+1,TEXTOUT(NOUT)=" "
    19         S TEXT=INDSTR,CLEN=0
    20         Q
    21         ;
    22         ;============================================
    23 CHECKLEN(WORD)  ;Check to see if adding the next word makes the line too long.
    24         ;If it does add it to the output and start a new line.
    25         N LENWORD
    26         S LENWORD=$L(WORD)
    27         I (CLEN+LENWORD)>WIDTH D
    28         . D NEWLINE
    29         . I WORD'[" " S WORD=WORD_" ",LENWORD=LENWORD+1
    30         . S TEXT=INDSTR_WORD,CLEN=LENWORD
    31         E  D
    32         . I WORD'[" " S WORD=WORD_" ",LENWORD=LENWORD+1
    33         . S TEXT=TEXT_WORD,CLEN=CLEN+LENWORD
    34         Q
    35         ;
    36         ;============================================
    37 COLFMT(FMTSTR,TEXTSTR,PC,NL,OUTPUT)     ;Columnar text formatter.
    38         ;FMTSTR - format string; ^ separated string for each column in the
    39         ;output. 35R2 defines a right justified column 35 characters wide
    40         ;with 2 blank spaces following. Columns can be centered (C) left
    41         ;justified (L) or right justified (R).
    42         ;TEXTSTR - string to be formated
    43         ;PC - the pad character
    44         ;NL - number of lines of output
    45         ;OUTPUT - array containing output lines.
    46         N COLOUT,ENTRY,FMT,JND,JUS,IND,LEN,NCOL,NLO,NROW,SP,TEMP,TEXT,WIDTH,WPSP
    47         S NCOL=$L(FMTSTR,U),NROW=1
    48         F IND=1:1:NCOL D
    49         . S FMT=$P(FMTSTR,U,IND)
    50         . S JUS(IND)=$S(FMT["C":"C",FMT["L":"L",FMT["R":"R",1:"C")
    51         . S WIDTH(IND)=$P(FMT,JUS(IND),1)
    52         . S SP(IND)=$P(FMT,JUS(IND),2)
    53         . S WPSP(IND)=WIDTH(IND)+SP(IND)
    54         F IND=1:1:NCOL D
    55         . S ENTRY=$S(JUS(IND)="C":"CJ",JUS(IND)="L":"LJ",JUS(IND)="R":"RJ")
    56         . S TEMP=$P(TEXTSTR,U,IND)
    57         . S LEN=$L(TEMP)
    58         . I LEN'>WIDTH(IND) D
    59         .. S TEMP=$$@ENTRY^XLFSTR(TEMP,WIDTH(IND),PC)
    60         .. S COLOUT(1,IND)=TEMP_$$LJ^XLFSTR("",SP(IND)," ")
    61         . I LEN>WIDTH(IND) D
    62         .. D FORMATS(1,WIDTH(IND),TEMP,.NLO,.TEXTOUT)
    63         .. F JND=1:1:NLO D
    64         ... S TEMP=$$@ENTRY^XLFSTR(TEXTOUT(JND),WIDTH(IND),PC)
    65         ... S COLOUT(JND,IND)=TEMP_$$LJ^XLFSTR("",SP(IND)," ")
    66         .. I NLO>NROW S NROW=NLO
    67         F IND=1:1:NROW D
    68         . S TEXT=""
    69         . F JND=1:1:NCOL D
    70         .. I $D(COLOUT(IND,JND)) S TEXT=TEXT_COLOUT(IND,JND)
    71         .. E  S TEXT=TEXT_$$LJ^XLFSTR("",(WPSP(JND))," ")
    72         . S OUTPUT(IND)=TEXT
    73         S NL=NROW
    74         Q
    75         ;
    76         ;============================================
    77 COLFMTA(FMTSTR,INPUT,PC,NL,OUTPUT)      ;Columnar text formatter.
    78         ;Array version of COLFMT. Input array is ^TMP($J,INPUT,M) and
    79         ;output is ^TMP(OUTPUT,$J,N,0).
    80         N COLOUT,ENTRY,FMT,JND,JUS,IND,LEN,NCOL,NLO,NROW,NUM
    81         N SP,TEMP,TEXT,WIDTH,WPSP
    82         S NCOL=$L(FMTSTR,U)
    83         F IND=1:1:NCOL D
    84         . S FMT=$P(FMTSTR,U,IND)
    85         . S JUS(IND)=$S(FMT["C":"C",FMT["L":"L",FMT["R":"R",1:"C")
    86         . S WIDTH(IND)=$P(FMT,JUS(IND),1)
    87         . S SP(IND)=$P(FMT,JUS(IND),2)
    88         . S WPSP(IND)=WIDTH(IND)+SP(IND)
    89         S NL=0,NUM=""
    90         F  S NUM=$O(^TMP($J,INPUT,NUM)) Q:NUM=""  D
    91         . K COLOUT
    92         . S NROW=1
    93         . F IND=1:1:NCOL D
    94         .. S ENTRY=$S(JUS(IND)="C":"CJ",JUS(IND)="L":"LJ",JUS(IND)="R":"RJ")
    95         .. S TEMP=$P(^TMP($J,INPUT,NUM),U,IND)
    96         .. S LEN=$L(TEMP)
    97         .. I LEN'>WIDTH(IND) D
    98         ... S TEMP=$$@ENTRY^XLFSTR(TEMP,WIDTH(IND),PC)
    99         ... S COLOUT(1,IND)=TEMP_$$LJ^XLFSTR("",SP(IND)," ")
    100         .. I LEN>WIDTH(IND) D
    101         ... D FORMATS(1,WIDTH(IND),TEMP,.NLO,.TEXTOUT)
    102         ... F JND=1:1:NLO D
    103         .... S TEMP=$$@ENTRY^XLFSTR(TEXTOUT(JND),WIDTH(IND),PC)
    104         .... S COLOUT(JND,IND)=TEMP_$$LJ^XLFSTR("",SP(IND)," ")
    105         ... I NLO>NROW S NROW=NLO
    106         . F IND=1:1:NROW D
    107         .. S TEXT=""
    108         .. F JND=1:1:NCOL D
    109         ... I $D(COLOUT(IND,JND)) S TEXT=TEXT_COLOUT(IND,JND)
    110         ... E  S TEXT=TEXT_$$LJ^XLFSTR("",(WPSP(JND))," ")
    111         .. S NL=NL+1,^TMP(OUTPUT,$J,NL,0)=TEXT
    112         Q
    113         ;
    114         ;============================================
    115 FORMAT(LM,RM,NIN,TEXTIN,NOUT,TEXTOUT)   ;Format the text in TEXTIN so it has
    116         ;a left margin of LM and a right margin of RM. The formatted text
    117         ;is in TEXTOUT. "\\" is the end of line marker. Lines ending with
    118         ;"\\" will not have anything appended to them. A blank line can
    119         ;be created by creating a line containing just "\\". Lines containing
    120         ;nothing but whitespace will also act like a "\\".
    121         I NIN=0 S NOUT=0 Q
    122         N ACHAR,ALLWSP,CHAR,CLEN,END,IND,INDENT,INDSTR,JND
    123         N LWSP,NWSP,START,TEMP,TEXT,TLEN,WIDTH,W1,W2,WORD
    124         ;Catalog the whitespace so we have places to break and look for
    125         ;end of line markers.
    126         F IND=1:1:NIN D
    127         . S TEMP=TEXTIN(IND)
    128         . S TLEN=$L(TEMP)
    129         . S ALLWSP=1,NWSP=0
    130         . F JND=1:1:TLEN D
    131         .. S CHAR=$E(TEMP,JND)
    132         .. S ACHAR=$A(CHAR)
    133         .. I ACHAR>32 S ALLWSP=0
    134         .. E  S NWSP=NWSP+1,LWSP(IND,NWSP)=JND
    135         .;Mark the end of the line.
    136         . S NWSP=NWSP+1,LWSP(IND,NWSP)=TLEN,LWSP(IND)=NWSP
    137         . I ALLWSP S LWSP(IND,"ALLWSP")=""
    138         I LM<1 S LM=1
    139         S WIDTH=RM-LM+1
    140         S INDENT=LM-1
    141         S INDSTR=""
    142         F IND=1:1:INDENT S INDSTR=INDSTR_" "
    143         S NOUT=0
    144         S TEXT=INDSTR,CLEN=0
    145         F IND=1:1:NIN D
    146         .;If there is a blank line force whatever is in TEXT to be output by
    147         .;calling NEWLINE and then add the blank.
    148         . I $D(LWSP(IND,"ALLWSP")) D NEWLINE,BLANK Q
    149         . S TEMP=TEXTIN(IND)
    150         . S (END,NWSP)=0
    151         . F NWSP=1:1:LWSP(IND) D
    152         .. S START=END+1,END=LWSP(IND,NWSP)
    153         .. S WORD=$E(TEMP,START,END)
    154         .. I WORD["\\" D  Q
    155         ... S W1=$P(WORD,"\\",1)
    156         ... D CHECKLEN(W1)
    157         ... D NEWLINE
    158         ... S W2=$P(WORD,"\\",2)
    159         ... I W2'="" D CHECKLEN(W2)
    160         .. D CHECKLEN(WORD)
    161         ;Output the last line.
    162         D NEWLINE
    163         Q
    164         ;
    165         ;============================================
    166 FORMATS(LM,RM,TEXTLINE,NOUT,TEXTOUT)    ;Take a single line of input text
    167         ;and format it.
    168         N TEXTIN
    169         S TEXTIN(1)=TEXTLINE
    170         D FORMAT(LM,RM,1,.TEXTIN,.NOUT,.TEXTOUT)
    171         Q
    172         ;
    173         ;============================================
    174 LMFMTSTR(VALMDDF,JSTR)  ;The List Manager variable VALMDDF contains the
    175         ;list template caption column formatting information. It contains
    176         ;the starting column and the width if the form
    177         ;VALMDDF(COLUMN NAME)=COLUMN NAME^COLUMN^WIDTH^CAPTION^VIDEO^SCROLL
    178         ;LOCK. JUSSTR, which is optional,is the justification for each column;
    179         ;(L=left, C=center, R=right) the default is center. Use this information
    180         ;to build the format string for the column formatter COLFMT.
    181         N CN,COL,FMTSTR,IND,JC,JUSSTR,PLCOL,SCOL,SP,TEMP,WIDTH
    182         ;Sort by columns
    183         S IND=""
    184         F  S IND=$O(VALMDDF(IND)) Q:IND=""  D
    185         . S TEMP=VALMDDF(IND)
    186         . S COL($P(TEMP,U,2))=$P(TEMP,U,3)
    187         S JUSSTR=$G(JSTR)
    188         S (CN,PLCOL,SCOL,SP)=0
    189         S FMTSTR=""
    190         S SCOL=0
    191         F  S SCOL=$O(COL(SCOL)) Q:SCOL=""  D
    192         . S CN=CN+1
    193         . S WIDTH=COL(SCOL)
    194         . I CN=1 S PLCOL=WIDTH
    195         . E  S SP=SCOL-PLCOL-1,FMTSTR=FMTSTR_SP_U,PLCOL=SCOL+WIDTH-1
    196         . S JC=$E(JUSSTR,CN)
    197         . I JC="" S JC="C"
    198         . S TEMP=WIDTH_JC
    199         . S FMTSTR=FMTSTR_TEMP
    200         Q FMTSTR
    201         ;
     1PXRMTEXT ; SLC/PKR - Text formatting utility routines. ;11/03/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;================================================================
     5NEWLINE ;Put TEXT on a new line to the output, make sure it does not end
     6 ;with a " ".
     7 N TLEN
     8 ;If there is no text in TEXT don't do anything.
     9 I TEXT=INDSTR Q
     10 S TLEN=$L(TEXT)
     11 I $E(TEXT,TLEN)=" " S TEXT=$E(TEXT,1,TLEN-1)
     12 S NOUT=NOUT+1,TEXTOUT(NOUT)=TEXT
     13 S TEXT=INDSTR,CLEN=0
     14 Q
     15 ;
     16 ;================================================================
     17BLANK ;Add a blank line (line containing just " ") to the output.
     18 S NOUT=NOUT+1,TEXTOUT(NOUT)=" "
     19 S TEXT=INDSTR,CLEN=0
     20 Q
     21 ;
     22 ;================================================================
     23CHECKLEN(WORD) ;Check to see if adding the next word makes the line too long.
     24 ;If it does add it to the output and start a new line.
     25 N LENWORD
     26 S LENWORD=$L(WORD)
     27 I (CLEN+LENWORD)>WIDTH D
     28 . D NEWLINE
     29 . I WORD'[" " S WORD=WORD_" ",LENWORD=LENWORD+1
     30 . S TEXT=INDSTR_WORD,CLEN=LENWORD
     31 E  D
     32 . I WORD'[" " S WORD=WORD_" ",LENWORD=LENWORD+1
     33 . S TEXT=TEXT_WORD,CLEN=CLEN+LENWORD
     34 Q
     35 ;
     36 ;================================================================
     37FORMAT(LM,RM,NIN,TEXTIN,NOUT,TEXTOUT) ;Format the text in TEXTIN so it has
     38 ;a left margin of LM and a right margin of RM. The formatted text
     39 ;is in TEXTOUT. "\\" is the end of line marker. Lines ending with
     40 ;"\\" will not have anything appended to them. A blank line can
     41 ;be created by creating a line containing just "\\". Lines containing
     42 ;nothing but whitespace will also act like a "\\".
     43 I NIN=0 S NOUT=0 Q
     44 N ACHAR,ALLWSP,CHAR,CLEN,END,IND,INDENT,INDSTR,JND
     45 N LWSP,NWSP,START,TEMP,TEXT,TLEN,WIDTH,W1,W2,WORD
     46 ;Catalog the whitespace so we have places to break and look for
     47 ;end of line markers.
     48 F IND=1:1:NIN D
     49 . S TEMP=TEXTIN(IND)
     50 . S TLEN=$L(TEMP)
     51 . S ALLWSP=1,NWSP=0
     52 . F JND=1:1:TLEN D
     53 .. S CHAR=$E(TEMP,JND)
     54 .. S ACHAR=$A(CHAR)
     55 .. I ACHAR>32 S ALLWSP=0
     56 .. E  S NWSP=NWSP+1,LWSP(IND,NWSP)=JND
     57 .;Mark the end of the line.
     58 . S NWSP=NWSP+1,LWSP(IND,NWSP)=TLEN,LWSP(IND)=NWSP
     59 . I ALLWSP S LWSP(IND,"ALLWSP")=""
     60 I LM<1 S LM=1
     61 S WIDTH=RM-LM+1
     62 S INDENT=LM-1
     63 S INDSTR=""
     64 F IND=1:1:INDENT S INDSTR=INDSTR_" "
     65 S NOUT=0
     66 S TEXT=INDSTR,CLEN=0
     67 F IND=1:1:NIN D
     68 .;If there is a blank line force whatever is in TEXT to be output by
     69 .;calling NEWLINE and then add the blank.
     70 . I $D(LWSP(IND,"ALLWSP")) D NEWLINE,BLANK Q
     71 . S TEMP=TEXTIN(IND)
     72 . S (END,NWSP)=0
     73 . F NWSP=1:1:LWSP(IND) D
     74 .. S START=END+1,END=LWSP(IND,NWSP)
     75 .. S WORD=$E(TEMP,START,END)
     76 .. I WORD["\\" D  Q
     77 ... S W1=$P(WORD,"\\",1)
     78 ... D CHECKLEN(W1)
     79 ... D NEWLINE
     80 ... S W2=$P(WORD,"\\",2)
     81 ... I W2'="" D CHECKLEN(W2)
     82 .. D CHECKLEN(WORD)
     83 ;Output the last line.
     84 D NEWLINE
     85 Q
     86 ;
     87 ;================================================================
     88FORMATS(LM,RM,TEXTLINE,NOUT,TEXTOUT) ;Take a single line of input text
     89 ;and format it.
     90 N TEXTIN
     91 S TEXTIN(1)=TEXTLINE
     92 D FORMAT(LM,RM,1,.TEXTIN,.NOUT,.TEXTOUT)
     93 Q
     94 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMTMED.m

    r613 r623  
    1 PXRMTMED        ; SLC/PKR/PJH - Edit a reminder term. ;04/18/2007
    2         ;;2.0;CLINICAL REMINDERS;**1,4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=======================================================
    5         N CS1,CS2,DA,DIC,DLAYGO,DTOUT,DUOUT,Y
    6 GETNAME ;Get the name of the term to edit.
    7         K DA,DIC,DLAYGO,DTOUT,DUOUT,Y
    8         S DIC="^PXRMD(811.5,"
    9         S DIC(0)="AEMQL"
    10         S DIC("A")="Select Reminder Term: "
    11         S DLAYGO=811.5
    12         ;Set the starting place for additions.
    13         D SETSTART^PXRMCOPY(DIC)
    14         W !
    15         D ^DIC
    16         I ($D(DTOUT))!($D(DUOUT)) Q
    17         I Y=-1 G END
    18         S DA=$P(Y,U,1)
    19         S CS1=$$FILE^PXRMEXCS(811.5,DA)
    20         D EDIT(DIC,DA)
    21         I $G(DA)="" G GETNAME
    22         S CS2=$$FILE^PXRMEXCS(811.5,DA)
    23         I CS2=0 G GETNAME
    24         I CS2'=CS1 D SEHIST^PXRMUTIL(811.5,DIC,DA)
    25         G GETNAME
    26 END     ;
    27         Q
    28         ;
    29         ;=======================================================
    30 CLASS(DA,DIE)   ;
    31         N DR,RESULT,X,Y
    32 RETRY   W !
    33         S DR="100" D ^DIE I $D(Y) Q
    34         ;Sponsor
    35         S DR="101" D ^DIE I $D(Y) Q
    36         ;Make sure Class and Sponsor Class are in synch.
    37         S RESULT=$$VSPONSOR^PXRMINTR(X)
    38         I RESULT=0 S DIE("NO^")="Other value" G RETRY
    39         I RESULT=1 K DIE("NO^")
    40         ;Review date, Usage
    41         S DR="102;1" D ^DIE I $D(Y) Q
    42         Q
    43         ;
    44         ;=======================================================
    45 EDIT(ROOT,DA)   ;
    46         N CLASS,DIC,DIE,DR,DIDEL,PXRMTMD,RESULT,TCONT,Y
    47         ;PXRMTMD is set by a xref on the .01 as a flag that the entire
    48         ;entry is being deleted.
    49         S CLASS=$P($G(^PXRMD(811.5,DA,100)),U,1)
    50         S DIE=ROOT
    51         I CLASS'="N"!(($G(PXRMINST)=1)&($G(DUZ(0))="@")) D
    52         . S DR=".01"
    53         . D ^DIE
    54         . I $G(DA)'="" D CLASS(DA,DIE)
    55         I $G(DA)="" Q
    56         S TCONT=1
    57         F  D FINDING(DIE,DA)  Q:TCONT=0
    58         Q
    59         ;
    60         ;=======================================================
    61 FINDING(DIE,DA,LIST)    ;
    62         N CFIEN,GLOB,IEN,LIST,NODE,TERMSTAT,VF,WPIEN
    63         N DEF,DEF1,DEF2,STATUS
    64         S DIE("NO^")="OUTOK"
    65         S STATUS=0
    66         D DEF^PXRMRUTL("811.52",.DEF,.DEF1,.DEF2)
    67         S NODE="^PXRMD(811.5)"
    68         D LIST^PXRMREDT(NODE,DA,.LIST)
    69         D DSPALL^PXRMREDF("T",NODE,DA,.LIST)
    70         S DA(1)=DA
    71         S IEN=DA
    72         S DIC=DIE_DA(1)_",20,"
    73         S DIC(0)="QEAL"
    74         S DIC("A")="Select Finding: "
    75         D ^DIC I Y=-1 S DTOUT=1,TCONT=0 Q
    76         S DIE=DIC
    77         S DA=+Y,GLOB=$P($P(Y,U,2),";",2) Q:GLOB=""
    78         I GLOB="PXRMD(811.4," S CFIEN=$P($P(Y,U,2),";",1) D
    79         . I $D(^PXRMD(811.4,CFIEN,1))>0 D
    80         .. W !!,"Computed Finding Description:" S WPIEN=0
    81         .. F  S WPIEN=$O(^PXRMD(811.4,CFIEN,1,WPIEN)) Q:+WPIEN'>0  D
    82         ... W !,$G(^PXRMD(811.4,CFIEN,1,WPIEN,0))
    83         . E  W !!,"No description defined for this computed finding"
    84         . W !
    85         I GLOB="YTT(601.71," D WARN^PXRMMH
    86         W !,"Editing Finding Number: "_$G(DA)
    87         ;Finding record fields
    88         S DR=".01;9;12;17"
    89         I GLOB="PXRMD(811.4," S DR=DR_";26"
    90         ;Taxonomy - use inactive problems
    91         I GLOB="PXD(811.2," D
    92         .S TERMSTAT=$$TAXNODE^PXRMSTA1($P($P(Y,U,2),";"),"H")
    93         .I TERMSTAT="P" S DR=DR_";10" Q
    94         .I TERMSTAT'=0 S DR=DR_";10",STATUS=1
    95         ;Health Factor - within category rank
    96         I GLOB="AUTTHF(" S DR=DR_";11"
    97         ;If V file INCLUDE VISIT DATA
    98         S VF=$S(GLOB["AUTTEDT":1,GLOB["AUTTEXAM":1,GLOB["AUTTHF":1,GLOB["AUTTIMM":1,GLOB="AUTTSK":1,GLOB["PXD(811.2":1,1:0)
    99         I VF S DR=DR_";28"
    100         ;Mental Health - scale
    101         I GLOB="YTT(601.71," S DR=DR_";13"
    102         ;Radiology procedure
    103         I GLOB="RAMIS(71," S STATUS=1
    104         ;Orderable item
    105         I GLOB="ORD(101.43," S DR=DR_";27",STATUS=1
    106         ;Rx Type
    107         I GLOB="PSDRUG("!(GLOB="PS(50.605,")!(GLOB="PSNDF(50.6,") S DR=DR_";16;27",STATUS=1
    108         ;Condition
    109         S DR=DR_";14;15;18"
    110         ;
    111         ;Edit finding record
    112         D ^DIE
    113         I STATUS=1,$D(DA)>0,$D(Y)=0 D STATUS^PXRMSTA1(.DA,"T")
    114         S $P(^PXRMD(811.5,IEN,20,0),U,3)=0
    115         Q
    116         ;
     1PXRMTMED ; SLC/PKR/PJH - Edit a reminder term. ;01/30/2006
     2 ;;2.0;CLINICAL REMINDERS;**1,4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=======================================================
     5 N CS1,CS2,DA,DIC,DLAYGO,DTOUT,DUOUT,Y
     6GETNAME ;Get the name of the term to edit.
     7 K DA,DIC,DLAYGO,DTOUT,DUOUT,Y
     8 S DIC="^PXRMD(811.5,"
     9 S DIC(0)="AEMQL"
     10 S DIC("A")="Select Reminder Term: "
     11 S DLAYGO=811.5
     12 ;Set the starting place for additions.
     13 D SETSTART^PXRMCOPY(DIC)
     14 W !
     15 D ^DIC
     16 I ($D(DTOUT))!($D(DUOUT)) Q
     17 I Y=-1 G END
     18 S DA=$P(Y,U,1)
     19 S CS1=$$FILE^PXRMEXCS(811.5,DA)
     20 D EDIT(DIC,DA)
     21 I $G(DA)="" G GETNAME
     22 S CS2=$$FILE^PXRMEXCS(811.5,DA)
     23 I CS2=0 G GETNAME
     24 I CS2'=CS1 D SEHIST^PXRMUTIL(811.5,DIC,DA)
     25 G GETNAME
     26END ;
     27 Q
     28 ;
     29 ;=======================================================
     30CLASS(DA,DIE) ;
     31 N DR,RESULT,X,Y
     32RETRY W !
     33 S DR="100" D ^DIE I $D(Y) Q
     34 ;Sponsor
     35 S DR="101" D ^DIE I $D(Y) Q
     36 ;Make sure Class and Sponsor Class are in synch.
     37 S RESULT=$$VSPONSOR^PXRMINTR(X)
     38 I RESULT=0 S DIE("NO^")="Other value" G RETRY
     39 I RESULT=1 K DIE("NO^")
     40 ;Review date, Usage
     41 S DR="102;1" D ^DIE I $D(Y) Q
     42 Q
     43 ;
     44 ;=======================================================
     45EDIT(ROOT,DA) ;
     46 N CLASS,DIC,DIE,DR,DIDEL,PXRMTMD,RESULT,TCONT,Y
     47 ;PXRMTMD is set by a xref on the .01 as a flag that the entire
     48 ;entry is being deleted.
     49 S CLASS=$P($G(^PXRMD(811.5,DA,100)),U,1)
     50 S DIE=ROOT
     51 I CLASS'="N"!(($G(PXRMINST)=1)&($G(DUZ(0))="@")) D
     52 . S DR=".01"
     53 . D ^DIE
     54 . I $G(DA)'="" D CLASS(DA,DIE)
     55 I $G(DA)="" Q
     56 S TCONT=1
     57 F  D FINDING(DIE,DA)  Q:TCONT=0
     58 Q
     59 ;
     60 ;=======================================================
     61FINDING(DIE,DA,LIST) ;
     62 N CFIEN,GLOB,IEN,LIST,NODE,TERMSTAT,VF,WPIEN
     63 N DEF,DEF1,DEF2,STATUS
     64 S STATUS=0
     65 D DEF^PXRMRUTL("811.52",.DEF,.DEF1,.DEF2)
     66 S NODE="^PXRMD(811.5)"
     67 D LIST^PXRMREDT(NODE,DA,.LIST)
     68 D DSPALL^PXRMREDF("T",NODE,DA,.LIST)
     69 S DA(1)=DA
     70 S IEN=DA
     71 S DIC=DIE_DA(1)_",20,"
     72 S DIC(0)="QEAL"
     73 S DIC("A")="Select Finding: "
     74 D ^DIC I Y=-1 S DTOUT=1,TCONT=0 Q
     75 S DIE=DIC
     76 S DA=+Y,GLOB=$P($P(Y,U,2),";",2) Q:GLOB=""
     77 I GLOB="PXRMD(811.4," S CFIEN=$P($P(Y,U,2),";",1) D
     78 .I $D(^PXRMD(811.4,CFIEN,1))>0 D
     79 ..W !!,"Computed Finding Description:" S WPIEN=0
     80 ..F  S WPIEN=$O(^PXRMD(811.4,CFIEN,1,WPIEN)) Q:+WPIEN'>0  D
     81 ...W !,$G(^PXRMD(811.4,CFIEN,1,WPIEN,0))
     82 .E  W !!,"No description defined for this computed finding"
     83 .W !
     84 W !,"Editing Finding Number: "_$G(DA)
     85 ;Finding record fields
     86 S DR=".01;9;12;17"
     87 I GLOB="PXRMD(811.4," S DR=DR_";26"
     88 ;Taxonomy - use inactive problems
     89 I GLOB="PXD(811.2," D
     90 .S TERMSTAT=$$TAXNODE^PXRMSTA1($P($P(Y,U,2),";"),"H")
     91 .I TERMSTAT="P" S DR=DR_";10" Q
     92 .I TERMSTAT'=0 S DR=DR_";10",STATUS=1
     93 ;Health Factor - within category rank
     94 I GLOB="AUTTHF(" S DR=DR_";11"
     95 ;If V file INCLUDE VISIT DATA
     96 S VF=$S(GLOB["AUTTEDT":1,GLOB["AUTTEXAM":1,GLOB["AUTTHF":1,GLOB["AUTTIMM":1,GLOB="AUTTSK":1,GLOB["PXD(811.2":1,1:0)
     97 I VF S DR=DR_";28"
     98 ;Mental Health - scale
     99 I GLOB="YTT(601," S DR=DR_";13"
     100 ;Radiology procedure
     101 I GLOB="RAMIS(71," S STATUS=1
     102 ;Orderable item
     103 I GLOB="ORD(101.43," S DR=DR_";27",STATUS=1
     104 ;Rx Type
     105 I GLOB="PSDRUG("!(GLOB="PS(50.605,")!(GLOB="PSNDF(50.6,") S DR=DR_";16;27",STATUS=1
     106 ;Condition
     107 S DR=DR_";14;15;18"
     108 ;
     109 ;Edit finding record
     110 D ^DIE
     111 I STATUS=1,$D(DA)>0 D STATUS^PXRMSTA1(.DA,"T")
     112 S $P(^PXRMD(811.5,IEN,20,0),U,3)=0
     113 Q
     114 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMUTIL.m

    r613 r623  
    1 PXRMUTIL        ; SLC/PKR/PJH - Utility routines for use by PXRM. ;10/02/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=================================
    5 ATTVALUE(STRING,ATTR,SEP,AVSEP) ;STRING contains a list of attribute value
    6         ;pairs. Each pair is separated by SEP and the attribute value pair
    7         ;is separated by AVSEP. Return the value for the attribute ATTR.
    8         N AVPAIR,IND,NUMAVP,VALUE
    9         S NUMAVP=$L(STRING,SEP)
    10         S VALUE=""
    11         F IND=1:1:NUMAVP Q:VALUE'=""  D
    12         . S AVPAIR=$P(STRING,SEP,IND)
    13         . I AVPAIR[ATTR S VALUE=$P(AVPAIR,AVSEP,2)
    14         Q VALUE
    15         ;
    16         ;=================================
    17 ACOPY(REF,OUTPUT)       ;Copy all the descendants of the array reference into a linear
    18         ;array. REF is the starting array reference, for example A or
    19         ;^TMP("PXRM",$J). OUTPUT is the linear array for the output. It
    20         ;should be in the form of a closed root, i.e., A() or ^TMP($J,).
    21         ;Note OUTPUT cannot be used as the name of the output array.
    22         N DONE,IND,LEN,NL,OROOT,OUT,PROOT,ROOT,START,TEMP
    23         I REF="" Q
    24         S NL=0
    25         S OROOT=$P(OUTPUT,")",1)
    26         S PROOT=$P(REF,")",1)
    27         ;Build the root so we can tell when we are done.
    28         S TEMP=$NA(@REF)
    29         S ROOT=$P(TEMP,")",1)
    30         S REF=$Q(@REF)
    31         I REF'[ROOT Q
    32         S DONE=0
    33         F  Q:(REF="")!(DONE)  D
    34         . S START=$F(REF,ROOT)
    35         . S LEN=$L(REF)
    36         . S IND=$E(REF,START,LEN)
    37         . S NL=NL+1
    38         . S OUT=OROOT_NL_")"
    39         . S @OUT=PROOT_IND_"="_@REF
    40         . S REF=$Q(@REF)
    41         . I REF'[ROOT S DONE=1
    42         Q
    43         ;
    44         ;=================================
    45 AWRITE(REF)     ;Write all the descendants of the array reference.
    46         ;REF is the starting array reference, for example A or ^TMP("PXRM",$J).
    47         N DONE,IND,LEN,PROOT,ROOT,START,TEMP
    48         I REF="" Q
    49         S PROOT=$P(REF,")",1)
    50         ;Build the root so we can tell when we are done.
    51         S TEMP=$NA(@REF)
    52         S ROOT=$P(TEMP,")",1)
    53         S REF=$Q(@REF)
    54         I REF'[ROOT Q
    55         S DONE=0
    56         F  Q:(REF="")!(DONE)  D
    57         . S START=$F(REF,ROOT)
    58         . S LEN=$L(REF)
    59         . S IND=$E(REF,START,LEN)
    60         . W !,PROOT_IND,"=",@REF
    61         . S REF=$Q(@REF)
    62         . I REF'[ROOT S DONE=1
    63         Q
    64         ;
    65         ;=================================
    66 DIP(VAR,IEN,PXRMROOT,FLDS)      ;Do general inquiry for IEN return formatted
    67         ;output in VAR. VAR can be either a local variable or a global.
    68         ;If it is a local it is indexed for the broker. If it is a global
    69         ;it should be passed in closed form i.e., ^TMP("PXRMTEST",$J).
    70         ;It will be returned formatted for ListMan i.e.,
    71         ;^TMP("PXRMTEST",$J,N,0).
    72         N %ZIS,ARRAY,BY,DC,DHD,DIC,DONE,FF,FILENAME,FILESPEC,FR,GBL,HFNAME
    73         N IND,IOP,L,NOW,PATH,SUCCESS,TO,UNIQN
    74         S BY="NUMBER",(FR,TO)=+$P(IEN,U,1),DHD="@@"
    75         ;Make sure the PXRM WORKSTATION device exists.
    76         D MKWSDEV^PXRMHOST
    77         ;Set up the output file before DIP is called.
    78         S PATH=$$PWD^%ZISH
    79         S NOW=$$NOW^XLFDT
    80         S NOW=$TR(NOW,".","")
    81         S UNIQN=$J_NOW
    82         S FILENAME="PXRMWSD"_UNIQN_".DAT"
    83         S HFNAME=PATH_FILENAME
    84         S IOP="PXRM WORKSTATION;80"
    85         S %ZIS("HFSMODE")="W"
    86         S %ZIS("HFSNAME")=HFNAME
    87         S L=0,DIC=PXRMROOT
    88         D EN1^DIP
    89         ;Move the host file into a global.
    90         S GBL="^TMP(""PXRMUTIL"",$J,1,0)"
    91         S GBL=$NA(@GBL)
    92         K ^TMP("PXRMUTIL",$J)
    93         S SUCCESS=$$FTG^%ZISH(PATH,FILENAME,GBL,3)
    94         ;Look for a form feed, remove it and all subsequent lines.
    95         S FF=$C(12)
    96         I $G(VAR)["^" D
    97         . S VAR=$NA(@VAR)
    98         . S VAR=$P(VAR,")",1)
    99         . S VAR=VAR_",IND,0)"
    100         . S (DONE,IND)=0
    101         . F  Q:DONE  S IND=$O(^TMP("PXRMUTIL",$J,IND)) Q:+IND=0  D
    102         .. I ^TMP("PXRMUTIL",$J,IND,0)=FF S DONE=1 Q
    103         .. S @VAR=^TMP("PXRMUTIL",$J,IND,0)
    104         E  D
    105         . S (DONE,IND)=0
    106         . F  Q:DONE  S IND=$O(^TMP("PXRMUTIL",$J,IND)) Q:+IND=0  D
    107         .. S VAR(IND)=^TMP("PXRMUTIL",$J,IND,0)
    108         .. I VAR(IND)=FF K ARRAY(IND) S DONE=1
    109         K ^TMP("PXRMUTIL",$J)
    110         ;Delete the host file.
    111         S FILESPEC(FILENAME)=""
    112         S SUCCESS=$$DEL^%ZISH(PATH,$NA(FILESPEC))
    113         Q
    114         ;
    115         ;=================================
    116 FNFR(ROOT)      ;Given the root of a file return the file number.
    117         Q +$P(@(ROOT_"0)"),U,2)
    118         ;
    119         ;=================================
    120 NTOAN(NUMBER)   ;Given an integer N return an alphabetic string that can be
    121         ;used for sorting. This will be modulus 26. For example N=0 returns
    122         ;A, N=26 returns BA etc.
    123         N ALPH
    124         S ALPH(0)="A",ALPH(1)="B",ALPH(2)="C",ALPH(3)="D",ALPH(4)="E"
    125         S ALPH(5)="F",ALPH(6)="G",ALPH(7)="H",ALPH(8)="I",ALPH(9)="J"
    126         S ALPH(10)="K",ALPH(11)="L",ALPH(12)="M",ALPH(13)="N",ALPH(14)="O"
    127         S ALPH(15)="P",ALPH(16)="Q",ALPH(17)="R",ALPH(18)="S",ALPH(19)="T"
    128         S ALPH(20)="U",ALPH(21)="V",ALPH(22)="W",ALPH(23)="X",ALPH(24)="Y"
    129         S ALPH(25)="Z"
    130         ;
    131         N ANUM,DIGIT,NUM,P26,PC,PWR
    132         S ANUM="",NUM=NUMBER,PWR=0
    133         S P26(PWR)=1
    134         F PWR=1:1 S P26(PWR)=26*P26(PWR-1) I P26(PWR)>NUMBER Q
    135         S PWR=PWR-1
    136         F PC=PWR:-1:0 D
    137         . S DIGIT=NUM\P26(PC)
    138         . S ANUM=ANUM_ALPH(DIGIT)
    139         . S NUM=NUM-(DIGIT*P26(PC))
    140         Q ANUM
    141         ;
    142         ;=================================
    143 RMEHIST(FILENUM,IEN)    ;Remove the edit history for a reminder file.
    144         I (FILENUM<800)!(FILENUM>811.9)!(FILENUM=811.8) Q
    145         N DA,DIK,GLOBAL,ROOT
    146         S GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
    147         ;Edit History is stored in node 110 for all files.
    148         S DA(1)=IEN
    149         S DIK=GLOBAL_IEN_",110,"
    150         S ROOT=GLOBAL_IEN_",110,DA)"
    151         S DA=0
    152         F  S DA=+$O(@ROOT) Q:DA=0  D ^DIK
    153         Q
    154         ;
    155         ;=================================
    156 SEHIST(FILENUM,ROOT,IEN)        ;Set the edit date and edit by and prompt the
    157         ;user for the edit comment.
    158         N DIC,DIR,DWLW,DWPK,ENTRY,FDA,FDAIEN,IENS,IND,MSG,SFN,TARGET,X,Y
    159         K ^TMP("PXRMWP",$J)
    160         D FIELD^DID(FILENUM,"EDIT HISTORY","","SPECIFIER","TARGET")
    161         S SFN=+$G(TARGET("SPECIFIER"))
    162         I SFN=0 Q
    163         S ENTRY=ROOT_IEN_",110)"
    164         S IND=$O(@ENTRY@("B"),-1)
    165         S IND=IND+1
    166         S IENS="+"_IND_","_IEN_","
    167         S FDAIEN(IEN)=IEN
    168         S FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
    169         S FDA(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
    170         ;Prompt the user for edit comments.
    171         S DIC="^TMP(""PXRMWP"",$J,"
    172         S DWLW=72
    173         S DWPK=1
    174         W !,"Input your edit comments."
    175         S DIR(0)="Y"_U_"AO"
    176         S DIR("A")="Edit"
    177         S DIR("B")="NO"
    178         D ^DIR
    179         I Y D
    180         . D EN^DIWE
    181         . K ^TMP("PXRMWP",$J,0)
    182         . I $D(^TMP("PXRMWP",$J)) S FDA(SFN,IENS,2)="^TMP(""PXRMWP"",$J)"
    183         D UPDATE^DIE("E","FDA","FDAIEN","MSG")
    184         I $D(MSG) D AWRITE^PXRMUTIL("MSG")
    185         K ^TMP("PXRMWP",$J)
    186         Q
    187         ;
    188         ;=================================
    189 SFRES(SDIR,NRES,FIEVAL) ;Save the finding result.
    190         I NRES=0 S FIEVAL=0 Q
    191         N DATE,IND,OA,SUB,TF
    192         F IND=1:1:NRES S OA(FIEVAL(IND,"DATE"),FIEVAL(IND),IND)=""
    193         ;If SDIR is positive get the oldest date otherwise get the most
    194         ;recent date.
    195         S DATE=$S(SDIR>0:$O(OA("")),1:$O(OA(""),-1))
    196         ;If there is a true finding on DATE get it.
    197         S TF=$O(OA(DATE,""),-1)
    198         S IND=$O(OA(DATE,TF,""))
    199         S FIEVAL=TF
    200         S SUB=""
    201         F  S SUB=$O(FIEVAL(IND,SUB)) Q:SUB=""  M FIEVAL(SUB)=FIEVAL(IND,SUB)
    202         Q
    203         ;
    204         ;=================================
    205 SSPAR(FIND0,NOCC,BDT,EDT)       ;Set the finding search parameters.
    206         S BDT=$P(FIND0,U,8),EDT=$P(FIND0,U,11),NOCC=$P(FIND0,U,14)
    207         I +NOCC=0 S NOCC=1
    208         ;Convert the dates to FileMan dates.
    209         S BDT=$S(BDT="":0,BDT=0:0,1:$$CTFMD^PXRMDATE(BDT))
    210         I EDT="" S EDT="T"
    211         S EDT=$$CTFMD^PXRMDATE(EDT)
    212         ;If EDT does not contain a time set it to the end of the day.
    213         I EDT'["." S EDT=EDT_".235959"
    214         I $G(PXRMDDOC)'=1 Q
    215         S ^TMP("PXRMDDOC",$J,$P(FIND0,U,1,11))=BDT_U_EDT
    216         Q
    217         ;
    218         ;=================================
    219 STRREP(STRING,TS,RS)    ;Replace every occurrence of the target string (TS)
    220         ;in STRING with the replacement string (RS).
    221         ;Example 9.19 (page 220) in "The Complete Mumps" by John Lewkowicz:
    222         ;  F  Q:STRING'[TS  S STRING=$P(STRING,TS)_RS_$P(STRING,TS,2,999)
    223         ;fails if any portion of the target string is contained in the with
    224         ;string. Therefore a more elaborate version is required.
    225         ;
    226         N IND,NPCS,STR
    227         I STRING'[TS Q STRING
    228         ;Count the number of pieces using the target string as the delimiter.
    229         S NPCS=$L(STRING,TS)
    230         ;Extract the pieces and concatenate RS
    231         S STR=""
    232         F IND=1:1:NPCS-1 S STR=STR_$P(STRING,TS,IND)_RS
    233         S STR=STR_$P(STRING,TS,NPCS)
    234         Q STR
    235         ;
    236         ;=================================
    237 VEDIT(ROOT,IEN) ;This is used as a DIC("S") screen to select which entries
    238         ;a user can edit.
    239         N CLASS,ENTRY,VALID
    240         S ENTRY=ROOT_IEN_")"
    241         S CLASS=$P($G(@ENTRY@(100)),U,1)
    242         I CLASS="N" D
    243         . I ($G(PXRMINST)=1),(DUZ(0)="@") S VALID=1
    244         . E  S VALID=0
    245         E  S VALID=1
    246         Q VALID
    247         ;
     1PXRMUTIL ; SLC/PKR/PJH - Utility routines for use by PXRM. ;05/25/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;===========================================================
     5ATTVALUE(STRING,ATTR,SEP,AVSEP) ;STRING contains a list of attribute value
     6 ;pairs. Each pair is separated by SEP and the attribute value pair
     7 ;is separated by AVSEP. Return the value for the attribute ATTR.
     8 N AVPAIR,IND,NUMAVP,VALUE
     9 S NUMAVP=$L(STRING,SEP)
     10 S VALUE=""
     11 F IND=1:1:NUMAVP Q:VALUE'=""  D
     12 . S AVPAIR=$P(STRING,SEP,IND)
     13 . I AVPAIR[ATTR S VALUE=$P(AVPAIR,AVSEP,2)
     14 Q VALUE
     15 ;
     16 ;===========================================================
     17AWRITE(REF) ;Write all the descendants of the array reference.
     18 ;REF is the starting array reference, for example A or ^TMP("PXRM",$J).
     19 N DONE,IND,LEN,PROOT,ROOT,START,TEMP
     20 I REF="" Q
     21 S PROOT=$P(REF,")",1)
     22 ;Build the root so we can tell when we are done.
     23 S TEMP=$NA(@REF)
     24 S ROOT=$P(TEMP,")",1)
     25 S REF=$Q(@REF)
     26 I REF'[ROOT Q
     27 S DONE=0
     28 F  Q:(REF="")!(DONE)  D
     29 . S START=$F(REF,ROOT)
     30 . S LEN=$L(REF)
     31 . S IND=$E(REF,START,LEN)
     32 . W !,PROOT_IND,"=",@REF
     33 . S REF=$Q(@REF)
     34 . I REF'[ROOT S DONE=1
     35 Q
     36 ;
     37 ;===========================================================
     38DIP(VAR,IEN,PXRMROOT,FLDS) ;Do general inquiry for IEN return formatted
     39 ;output in VAR. VAR can be either a local variable or a global.
     40 ;If it is a local it is indexed for the broker. If it is a global
     41 ;it should be passed in closed form i.e., ^TMP("PXRMTEST",$J).
     42 ;It will be returned formatted for ListMan i.e.,
     43 ;^TMP("PXRMTEST",$J,N,0).
     44 N %ZIS,ARRAY,BY,DC,DHD,DIC,DONE,FF,FILENAME,FILESPEC,FR,GBL,HFNAME
     45 N IND,IOP,L,NOW,PATH,SUCCESS,TO,UNIQN
     46 S BY="NUMBER",(FR,TO)=+$P(IEN,U,1),DHD="@@"
     47 ;Make sure the PXRM WORKSTATION device exists.
     48 D MKWSDEV^PXRMHOST
     49 ;Set up the output file before DIP is called.
     50 S PATH=$$PWD^%ZISH
     51 S NOW=$$NOW^XLFDT
     52 S NOW=$TR(NOW,".","")
     53 S UNIQN=$J_NOW
     54 S FILENAME="PXRMWSD"_UNIQN_".DAT"
     55 S HFNAME=PATH_FILENAME
     56 S IOP="PXRM WORKSTATION;80"
     57 S %ZIS("HFSMODE")="W"
     58 S %ZIS("HFSNAME")=HFNAME
     59 S L=0,DIC=PXRMROOT
     60 D EN1^DIP
     61 ;Move the host file into a global.
     62 S GBL="^TMP(""PXRMUTIL"",$J,1,0)"
     63 S GBL=$NA(@GBL)
     64 K ^TMP("PXRMUTIL",$J)
     65 S SUCCESS=$$FTG^%ZISH(PATH,FILENAME,GBL,3)
     66 ;Look for a form feed, remove it and all subsequent lines.
     67 S FF=$C(12)
     68 I $G(VAR)["^" D
     69 . S VAR=$NA(@VAR)
     70 . S VAR=$P(VAR,")",1)
     71 . S VAR=VAR_",IND,0)"
     72 . S (DONE,IND)=0
     73 . F  Q:DONE  S IND=$O(^TMP("PXRMUTIL",$J,IND)) Q:+IND=0  D
     74 .. I ^TMP("PXRMUTIL",$J,IND,0)=FF S DONE=1 Q
     75 .. S @VAR=^TMP("PXRMUTIL",$J,IND,0)
     76 E  D
     77 . S (DONE,IND)=0
     78 . F  Q:DONE  S IND=$O(^TMP("PXRMUTIL",$J,IND)) Q:+IND=0  D
     79 .. S VAR(IND)=^TMP("PXRMUTIL",$J,IND,0)
     80 .. I VAR(IND)=FF K ARRAY(IND) S DONE=1
     81 K ^TMP("PXRMUTIL",$J)
     82 ;Delete the host file.
     83 S FILESPEC(FILENAME)=""
     84 S SUCCESS=$$DEL^%ZISH(PATH,$NA(FILESPEC))
     85 Q
     86 ;
     87 ;===========================================================
     88FNFR(ROOT) ;Given the root of a file return the file number.
     89 Q +$P(@(ROOT_"0)"),U,2)
     90 ;
     91 ;===========================================================
     92NTOAN(NUMBER) ;Given an integer N return an alphabetic string that can be
     93 ;used for sorting. This will be modulus 26. For example N=0 returns
     94 ;A, N=26 returns BA etc.
     95 N ALPH
     96 S ALPH(0)="A",ALPH(1)="B",ALPH(2)="C",ALPH(3)="D",ALPH(4)="E"
     97 S ALPH(5)="F",ALPH(6)="G",ALPH(7)="H",ALPH(8)="I",ALPH(9)="J"
     98 S ALPH(10)="K",ALPH(11)="L",ALPH(12)="M",ALPH(13)="N",ALPH(14)="O"
     99 S ALPH(15)="P",ALPH(16)="Q",ALPH(17)="R",ALPH(18)="S",ALPH(19)="T"
     100 S ALPH(20)="U",ALPH(21)="V",ALPH(22)="W",ALPH(23)="X",ALPH(24)="Y"
     101 S ALPH(25)="Z"
     102 ;
     103 N ANUM,DIGIT,NUM,P26,PC,PWR
     104 S ANUM="",NUM=NUMBER,PWR=0
     105 S P26(PWR)=1
     106 F PWR=1:1 S P26(PWR)=26*P26(PWR-1) I P26(PWR)>NUMBER Q
     107 S PWR=PWR-1
     108 F PC=PWR:-1:0 D
     109 . S DIGIT=NUM\P26(PC)
     110 . S ANUM=ANUM_ALPH(DIGIT)
     111 . S NUM=NUM-(DIGIT*P26(PC))
     112 Q ANUM
     113 ;
     114 ;===========================================================
     115SEHIST(FILENUM,ROOT,IEN) ;Set the edit date and edit by and prompt the
     116 ;user for the edit comment.
     117 N DIC,DIR,DWLW,DWPK,ENTRY,FDA,FDAIEN,IENS,IND,MSG,SFN,TARGET,X,Y
     118 K ^TMP("PXRMWP",$J)
     119 D FIELD^DID(FILENUM,"EDIT HISTORY","","SPECIFIER","TARGET")
     120 S SFN=+$G(TARGET("SPECIFIER"))
     121 I SFN=0 Q
     122 S ENTRY=ROOT_IEN_",110)"
     123 S IND=$O(@ENTRY@("B"),-1)
     124 S IND=IND+1
     125 S IENS="+"_IND_","_IEN_","
     126 S FDAIEN(IEN)=IEN
     127 S FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
     128 S FDA(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
     129 ;Prompt the user for edit comments.
     130 S DIC="^TMP(""PXRMWP"",$J,"
     131 S DWLW=72
     132 S DWPK=1
     133 W !,"Input your edit comments."
     134 S DIR(0)="Y"_U_"AO"
     135 S DIR("A")="Edit"
     136 S DIR("B")="NO"
     137 D ^DIR
     138 I Y D
     139 . D EN^DIWE
     140 . K ^TMP("PXRMWP",$J,0)
     141 . I $D(^TMP("PXRMWP",$J)) S FDA(SFN,IENS,2)="^TMP(""PXRMWP"",$J)"
     142 D UPDATE^DIE("E","FDA","FDAIEN","MSG")
     143 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
     144 K ^TMP("PXRMWP",$J)
     145 Q
     146 ;
     147 ;===========================================================
     148SFRES(SDIR,NRES,FIEVAL) ;Save the finding result.
     149 I NRES=0 S FIEVAL=0 Q
     150 N DATE,IND,OA,SUB,TF
     151 F IND=1:1:NRES S OA(FIEVAL(IND,"DATE"),FIEVAL(IND),IND)=""
     152 ;If SDIR is positive get the oldest date otherwise get the most
     153 ;recent date.
     154 S DATE=$S(SDIR>0:$O(OA("")),1:$O(OA(""),-1))
     155 ;If there is a true finding on DATE get it.
     156 S TF=$O(OA(DATE,""),-1)
     157 S IND=$O(OA(DATE,TF,""))
     158 S FIEVAL=TF
     159 S SUB=""
     160 F  S SUB=$O(FIEVAL(IND,SUB)) Q:SUB=""  M FIEVAL(SUB)=FIEVAL(IND,SUB)
     161 Q
     162 ;
     163 ;===========================================================
     164SSPAR(FIND0,NOCC,BDT,EDT) ;Set the finding search parameters.
     165 S BDT=$P(FIND0,U,8),EDT=$P(FIND0,U,11),NOCC=$P(FIND0,U,14)
     166 I NOCC="" S NOCC=1
     167 ;Convert the dates to FileMan dates.
     168 S BDT=$S(BDT="":0,BDT=0:0,1:$$CTFMD^PXRMDATE(BDT))
     169 I EDT="" S EDT="T"
     170 S EDT=$$CTFMD^PXRMDATE(EDT)
     171 ;If EDT does not contain a time set it to the end of the day.
     172 I EDT'["." S EDT=EDT_".235959"
     173 Q
     174 ;
     175 ;===========================================================
     176STRREP(STRING,TS,RS) ;Replace every occurrence of the target string (TS)
     177 ;in STRING with the replacement string (RS).
     178 ;Example 9.19 (page 220) in "The Complete Mumps" by John Lewkowicz:
     179 ;  F  Q:STRING'[TS  S STRING=$P(STRING,TS)_RS_$P(STRING,TS,2,999)
     180 ;fails if any portion of the target string is contained in the with
     181 ;string. Therefore a more elaborate version is required.
     182 ;
     183 N IND,NPCS,STR
     184 I STRING'[TS Q STRING
     185 ;Count the number of pieces using the target string as the delimiter.
     186 S NPCS=$L(STRING,TS)
     187 ;Extract the pieces and concatenate RS
     188 S STR=""
     189 F IND=1:1:NPCS-1 S STR=STR_$P(STRING,TS,IND)_RS
     190 S STR=STR_$P(STRING,TS,NPCS)
     191 Q STR
     192 ;
     193 ;===========================================================
     194VEDIT(ROOT,IEN) ;This is used as a DIC("S") screen to select which entries
     195 ;a user can edit.
     196 N CLASS,ENTRY,VALID
     197 S ENTRY=ROOT_IEN_")"
     198 S CLASS=$P($G(@ENTRY@(100)),U,1)
     199 I CLASS="N" D
     200 . I ($G(PXRMINST)=1),(DUZ(0)="@") S VALID=1
     201 . E  S VALID=0
     202 E  S VALID=1
     203 Q VALID
     204 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMVITL.m

    r613 r623  
    1 PXRMVITL        ; SLC/PKR - Handle vitals findings. ;09/20/2007
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;===========================================================
    5 EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate vital measurement findings.
    6         D EVALFI^PXRMINDX(DFN,.DEFARR,ENODE,.FIEVAL)
    7         Q
    8         ;
    9         ;===========================================================
    10 EVALPL(FINDPA,ENODE,TERMARR,PLIST)      ;Evaluate vital measurement
    11         ;term findings for patient lists.
    12         D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
    13         Q
    14         ;
    15         ;===========================================================
    16 EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL)      ;Evaluate vital measurement
    17         ;terms.
    18         D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
    19         Q
    20         ;
    21         ;===========================================================
    22 GETDATA(DAS,FIEVT)      ;Return data for a GMRV Vital Measurement entry.
    23         N EM,IND,GMRVDATA,STOP,TEMP,TYPE
    24         ;DBIA #3647
    25         D EN^GMVPXRM(.GMRVDATA,DAS,"I")
    26         I $P(GMRVDATA(1),U,1)=-1 D  Q
    27         . S ^TMP("PXRMXMZ",$J,1,0)="Found GMRV entry "_DAS_" in the index, but it does not exist in ^GMR(120.5"
    28         . D SEND^PXRMMSG("Bad entry in Vitals index.")
    29         S FIEVT("TYPE")=$$EXTERNAL^DILFD(120.5,.03,"",GMRVDATA(3),.EM)
    30         ;DBIA #10040
    31         S TEMP=$S(+GMRVDATA(5)'=0:^SC(GMRVDATA(5),0),1:"")
    32         S FIEVT("HOSPITAL LOCATION")=$P(TEMP,U,1)
    33         S FIEVT("LOCATION TYPE")=$P(TEMP,U,3)
    34         S STOP=$P(TEMP,U,7)
    35         S FIEVT("ENTERED BY")=$P(^VA(200,GMRVDATA(6),0),U,1)
    36         S (FIEVT("RATE"),FIEVT("VALUE"))=$P(GMRVDATA(7),U,1)
    37         S IND=0
    38         ;Load the external form of the qualifiers.
    39         F  S IND=$O(GMRVDATA(12,IND)) Q:IND=""  D
    40         . S TEMP=$P(GMRVDATA(12,IND),U,1)
    41         .;DBIA #4504
    42         . I TEMP'="" S FIEVT("QUALIFIER",IND)=$P($G(^GMRD(120.52,+TEMP,0)),U,1)
    43         ;DBIA #557
    44         I STOP'="" S FIEVT("STOP CODE")=$P(^DIC(40.7,STOP,0),U,1,2)
    45         E  S FIEVT("STOP CODE")=""
    46         Q
    47         ;
    48         ;===========================================================
    49 MHVOUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the MHV output.
    50         N DATE,EM,IND,JND,NAME,NOUT,RATE,TEMP,TEXTOUT,TYPE
    51         S TYPE=$$EXTERNAL^DILFD(120.5,.03,"",IFIEVAL("TYPE"),.EM)
    52         S NAME="Vital Measurement: "_TYPE_" = "
    53         S IND=0
    54         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    55         . S RATE=$G(IFIEVAL(IND,"VALUE"))
    56         . I RATE="" S RATE="MISSING"
    57         . S DATE=IFIEVAL(IND,"DATE")
    58         . S TEMP=NAME_RATE_" ("_$$EDATE^PXRMDATE(DATE)_")"
    59         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    60         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    61         S NLINES=NLINES+1,TEXT(NLINES)=""
    62         Q
    63         ;
    64         ;===========================================================
    65 OUTPUT(INDENT,IFIEVAL,NLINES,TEXT)      ;Produce the clinical
    66         ;maintenance output.
    67         N DATE,EM,IND,JND,NOUT,RATE,TEMP,TEXTOUT,TYPE
    68         S NLINES=NLINES+1
    69         S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Vital Measurement: "_IFIEVAL("TYPE")
    70         S IND=0
    71         F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
    72         . S DATE=IFIEVAL(IND,"DATE")
    73         . S TEMP=$$EDATE^PXRMDATE(DATE)
    74         . S RATE=$G(IFIEVAL(IND,"VALUE"))
    75         . I RATE="" S RATE="MISSING"
    76         . S TEMP=TEMP_"; rate - "_RATE
    77         . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    78         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    79         .;If there are qualifiers display them.
    80         . I $D(IFIEVAL(IND,"QUALIFIER")) D
    81         .. S TEMP="Qualifiers:"
    82         .. N QIND S QIND=0
    83         .. S QIND=$O(IFIEVAL(IND,"QUALIFIER",QIND)) S TEMP=TEMP_" "_IFIEVAL(IND,"QUALIFIER",QIND)
    84         .. F  S QIND=$O(IFIEVAL(IND,"QUALIFIER",QIND)) Q:QIND=""  S TEMP=TEMP_", "_IFIEVAL(IND,"QUALIFIER",QIND)
    85         .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
    86         .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    87         S NLINES=NLINES+1,TEXT(NLINES)=""
    88         Q
    89         ;
     1PXRMVITL ; SLC/PKR - Handle vitals findings. ;10/21/2004
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;===========================================================
     5EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate vital measurement findings.
     6 D EVALFI^PXRMINDX(DFN,.DEFARR,ENODE,.FIEVAL)
     7 Q
     8 ;
     9 ;===========================================================
     10EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate vital measurement
     11 ;term findings for patient lists.
     12 D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
     13 Q
     14 ;
     15 ;===========================================================
     16EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate vital measurement
     17 ;terms.
     18 D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
     19 Q
     20 ;
     21 ;===========================================================
     22GETDATA(DAS,FIEVT) ;Return the value, which is Rate, for a specified
     23 ;GMRV Vital Measurement entry.
     24 N IND,GMRVDATA,TEMP
     25 ;DBIA #3647
     26 D EN^GMVPXRM(.GMRVDATA,DAS,"I")
     27 I $P(GMRVDATA(1),U,1)=-1 D  Q
     28 . S ^TMP("PXRMXMZ",$J,1,0)="Found GMRV entry "_DAS_" in the index, but it does not exist in ^GMRV(120.5"
     29 . D SEND^PXRMMSG("Bad entry in Vitals index.")
     30 S FIEVT("TYPE")=$P(GMRVDATA(3),U,1)
     31 S (FIEVT("RATE"),FIEVT("VALUE"))=$P(GMRVDATA(7),U,1)
     32 S IND=0
     33 ;Load the external form of the qualifiers.
     34 F  S IND=$O(GMRVDATA(12,IND)) Q:IND=""  D
     35 . S TEMP=$P(GMRVDATA(12,IND),U,1)
     36 .;DBIA #4504
     37 . I TEMP'="" S FIEVT("QUALIFIER",IND)=$P($G(^GMRD(120.52,+TEMP,0)),U,1)
     38 Q
     39 ;
     40 ;===========================================================
     41MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
     42 N DATE,EM,IND,JND,NAME,NOUT,RATE,TEMP,TEXTOUT,TYPE
     43 S TYPE=$$EXTERNAL^DILFD(120.5,.03,"",IFIEVAL("TYPE"),.EM)
     44 S NAME="Vital Measurement: "_TYPE_" = "
     45 S IND=0
     46 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     47 . S RATE=$G(IFIEVAL(IND,"VALUE"))
     48 . I RATE="" S RATE="MISSING"
     49 . S DATE=IFIEVAL(IND,"DATE")
     50 . S TEMP=NAME_RATE_" ("_$$EDATE^PXRMDATE(DATE)_")"
     51 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     52 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     53 S NLINES=NLINES+1,TEXT(NLINES)=""
     54 Q
     55 ;
     56 ;===========================================================
     57OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
     58 ;maintenance output.
     59 N DATE,EM,IND,JND,NOUT,RATE,TEMP,TEXTOUT,TYPE
     60 S TYPE=$$EXTERNAL^DILFD(120.5,.03,"",IFIEVAL("TYPE"),.EM)
     61 S NLINES=NLINES+1
     62 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Vital Measurement: "_TYPE
     63 S IND=0
     64 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
     65 . S DATE=IFIEVAL(IND,"DATE")
     66 . S TEMP=$$EDATE^PXRMDATE(DATE)
     67 . S RATE=$G(IFIEVAL(IND,"VALUE"))
     68 . I RATE="" S RATE="MISSING"
     69 . S TEMP=TEMP_"; rate - "_RATE
     70 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     71 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     72 .;If there are qualifiers display them.
     73 . I $D(IFIEVAL(IND,"QUALIFIER")) D
     74 .. S TEMP="Qualifiers:"
     75 .. N QIND S QIND=0
     76 .. S QIND=$O(IFIEVAL(IND,"QUALIFIER",QIND)) S TEMP=TEMP_" "_IFIEVAL(IND,"QUALIFIER",QIND)
     77 .. F  S QIND=$O(IFIEVAL(IND,"QUALIFIER",QIND)) Q:QIND=""  S TEMP=TEMP_", "_IFIEVAL(IND,"QUALIFIER",QIND)
     78 .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
     79 .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     80 S NLINES=NLINES+1,TEXT(NLINES)=""
     81 Q
     82 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMVPTR.m

    r613 r623  
    1 PXRMVPTR        ; SLC/PKR - Routines for dealing with variable pointers. ; 02/06/2001
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ;==================================================
    5 BLDALIST(FILE,FIELD,LIST)       ;Build a list of variable pointer information
    6         ;indexed by the abbreviation.
    7         N ABBR,FN,IND,ROOT,TEMP
    8         S IND=0
    9         F  S IND=$O(^DD(FILE,FIELD,"V",IND)) Q:+IND=0  D
    10         . S TEMP=^DD(FILE,FIELD,"V",IND,0)
    11         . S FN=$P(TEMP,U,1)
    12         . S ROOT=$$ROOT^DILFD(FN)
    13         . S ROOT=$P(ROOT,"^",2)
    14         . S ABBR=$P(TEMP,U,4)
    15         . S LIST(ABBR)=TEMP
    16         Q
    17         ;
    18         ;==================================================
    19 BLDNLIST(FILE,FIELD,LIST)       ;Build a list of variable pointer information
    20         ;indexed by the file number.
    21         N FN,IND,ROOT,TEMP
    22         ;DBIA #2991
    23         S IND=0
    24         F  S IND=$O(^DD(FILE,FIELD,"V",IND)) Q:+IND=0  D
    25         . S TEMP=^DD(FILE,FIELD,"V",IND,0)
    26         . S FN=$P(TEMP,U,1)
    27         . S ROOT=$$ROOT^DILFD(FN)
    28         . S ROOT=$P(ROOT,"^",2)
    29         . S LIST(FN)=TEMP
    30         Q
    31         ;
    32         ;==================================================
    33 BLDRLIST(FILE,FIELD,LIST)       ;Build a list of variable pointer information
    34         ;indexed by the root.
    35         N FN,IND,ROOT,TEMP
    36         S IND=0
    37         F  S IND=$O(^DD(FILE,FIELD,"V",IND)) Q:+IND=0  D
    38         . S TEMP=^DD(FILE,FIELD,"V",IND,0)
    39         . S FN=$P(TEMP,U,1)
    40         . S ROOT=$$ROOT^DILFD(FN)
    41         . S ROOT=$P(ROOT,"^",2)
    42         . S LIST(ROOT)=TEMP
    43         Q
    44         ;
     1PXRMVPTR ; SLC/PKR - Routines for dealing with variable pointers. ; 02/06/2001
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ;==================================================
     5BLDALIST(FILE,FIELD,LIST) ;Build a list of variable pointer information
     6 ;indexed by the abbreviation.
     7 N ABBR,FN,IND,ROOT,TEMP
     8 S IND=0
     9 F  S IND=$O(^DD(FILE,FIELD,"V",IND)) Q:+IND=0  D
     10 . S TEMP=^DD(FILE,FIELD,"V",IND,0)
     11 . S FN=$P(TEMP,U,1)
     12 . S ROOT=$$ROOT^DILFD(FN)
     13 . S ROOT=$P(ROOT,"^",2)
     14 . S ABBR=$P(TEMP,U,4)
     15 . S LIST(ABBR)=TEMP
     16 Q
     17 ;
     18 ;==================================================
     19BLDNLIST(FILE,FIELD,LIST) ;Build a list of variable pointer information
     20 ;indexed by the file number.
     21 N FN,IND,ROOT,TEMP
     22 S IND=0
     23 F  S IND=$O(^DD(FILE,FIELD,"V",IND)) Q:+IND=0  D
     24 . S TEMP=^DD(FILE,FIELD,"V",IND,0)
     25 . S FN=$P(TEMP,U,1)
     26 . S ROOT=$$ROOT^DILFD(FN)
     27 . S ROOT=$P(ROOT,"^",2)
     28 . S LIST(FN)=TEMP
     29 Q
     30 ;
     31 ;==================================================
     32BLDRLIST(FILE,FIELD,LIST) ;Build a list of variable pointer information
     33 ;indexed by the root.
     34 N FN,IND,ROOT,TEMP
     35 S IND=0
     36 F  S IND=$O(^DD(FILE,FIELD,"V",IND)) Q:+IND=0  D
     37 . S TEMP=^DD(FILE,FIELD,"V",IND,0)
     38 . S FN=$P(TEMP,U,1)
     39 . S ROOT=$$ROOT^DILFD(FN)
     40 . S ROOT=$P(ROOT,"^",2)
     41 . S LIST(ROOT)=TEMP
     42 Q
     43 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMVSIT.m

    r613 r623  
    1 PXRMVSIT        ; SLC/PKR - Visit related info for reminders. ;02/22/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;======================================================
    5 GETDATA(DA,DATA,SVALUE) ;Return data for a specific Visit file entry.
    6         ;DBIA #2028 for Visit file.
    7         N DONE,IEN,HTEMP,LOE,TEMP
    8         S TEMP=^AUPNVSIT(DA,0)
    9         S DATA("VISIT")=DA
    10         S DATA("DATE VISIT CREATED")=$P(TEMP,U,2)
    11         S DATA("DFN")=$P(TEMP,U,5)
    12         S (DATA("LOC. OF ENCOUNTER"),LOE)=$P(TEMP,U,6)
    13         ;DBIA #10090
    14         S DATA("STATION NUMBER")=$$GET1^DIQ(4,LOE,99)
    15         S DATA("OFFICAL VA NAME")=$$GET1^DIQ(4,LOE,100)
    16         S DATA("SERVICE CATEGORY")=$P(TEMP,U,7)
    17         I $G(SVALUE) S DATA("VALUE")=$P(TEMP,U,7)
    18         S DATA("HOSPITAL LOCATION")=$P(TEMP,U,22)
    19         ;DBIA #10040, #2804
    20         I $G(DATA("HOSPITAL LOCATION"))="" S HTEMP=""
    21         E  S HTEMP=^SC(DATA("HOSPITAL LOCATION"),0)
    22         S DATA("HLOC")=$P(HTEMP,U,1)
    23         S DATA("DSS ID")=$P(TEMP,U,8)
    24         I DATA("DSS ID")="" S DATA("DSS ID")=$P(HTEMP,U,7)
    25         ;DBIA #557
    26         I DATA("DSS ID")'="" S DATA("STOP CODE")=$P(^DIC(40.7,DATA("DSS ID"),0),U,2)
    27         S DATA("OUTSIDE LOCATION")=$G(^AUPNVSIT(DA,21))
    28         S DATA("COMMENTS")=$G(^AUPNVSIT(DA,811))
    29         ;DBIA #4850
    30         S DATA("STATUS")=$$STATUS^SDPCE(DA)
    31         ;Get the primary provider.
    32         ;DBIA #3455 for V PROVIDER
    33         S DATA("PRIMARY PROVIDER")="",IEN="",DONE=0
    34         F  S IEN=$O(^AUPNVPRV("AD",DA,IEN)) Q:(DONE)!(IEN="")  D
    35         . S TEMP=^AUPNVPRV(IEN,0)
    36         . I $P(TEMP,U,4)="P" S DATA("PRIMARY PROVIDER")=$P(TEMP,U,1),DONE=1
    37         Q
    38         ;
    39         ;======================================================
    40 GAPSTAT(VIEN)   ;Return the status of the appointment associated with the
    41         ;visit.
    42         ;DBIA #4850
    43         Q $$STATUS^SDPCE(VIEN)
    44         ;
    45         ;======================================================
    46 HENC(VIEN,INDENT,NLINES,TEXT)   ;Display location and comment for historical
    47         ;encounters associated with the V files.
    48         N COMMENT,HLOC,LOCATION,OLOC,NIN,TEXTIN,VDATA
    49         D GETDATA(VIEN,.VDATA) I VDATA("SERVICE CATEGORY")'="E" Q
    50         S NIN=0
    51         S LOCATION=VDATA("LOC. OF ENCOUNTER")
    52         I LOCATION'="" D
    53         . S LOCATION=$$GET1^DIQ(4,LOCATION,.01)_" "_$$GET1^DIQ(4,LOCATION,99)
    54         . S NIN=NIN+1,TEXTIN(NIN)="Location of Encounter: "_LOCATION_"\\"
    55         S HLOC=VDATA("HOSPITAL LOCATION")
    56         I HLOC'="" D
    57         . S HLOC=$$GET1^DIQ(44,HLOC,.01)
    58         . S NIN=NIN+1,TEXTIN(NIN)="Hospital Location: "_HLOC_"\\"
    59         S OLOC=VDATA("OUTSIDE LOCATION")
    60         I OLOC'="" D
    61         . S NIN=NIN+1,TEXTIN(NIN)="Outside Location: "_OLOC_"\\"
    62         S COMMENT=VDATA("COMMENT")
    63         I COMMENT'="" D
    64         . S NIN=NIN+1,TEXTIN(NIN)="Comment: "_COMMENT
    65         I NIN>0 D
    66         . N JND,NOUT,TEXTOUT
    67         . S NLINES=NLINES+1
    68         . S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Historical Encounter Information:"
    69         . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,NIN,.TEXTIN,.NOUT,.TEXTOUT)
    70         . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
    71         Q
    72         ;
    73         ;======================================================
    74 ISHIST(VIEN)    ;Return true if the encounter was historical.
    75         ;DBIA #2028
    76         I $P($G(^AUPNVSIT(VIEN,0)),U,7)="E" Q 1
    77         Q 0
    78         ;
    79         ;======================================================
    80 VAPSTAT(VIEN)   ;Return true if the appointment associated with
    81         ;the visit has a valid appointment status.
    82         ;Return false if the status is one of the following:
    83         ;CANCELLED BY CLINIC
    84         ;CANCELLED BY CLINIC & AUTO RE-BOOK
    85         ;CANCELLED BY PATIENT
    86         ;CANCELLED BY PATIENT & AUTO-REBOOK
    87         ;DELETED
    88         ;NO ACTION TAKEN
    89         ;NO-SHOW
    90         ;NO-SHOW & AUTO RE-BOOK
    91         ;NULL
    92         N STATUS,VALID
    93         ;DBIA #4850
    94         S STATUS=$P($$STATUS^SDPCE(VIEN),U,2)
    95         S VALID=$S(STATUS["CANCELLED":0,STATUS["DELETED":0,STATUS["NO ACTION":0,STATUS["NO-SHOW":0,STATUS="":0,1:1)
    96         Q VALID
    97         ;
     1PXRMVSIT ; SLC/PKR - Visit related info for reminders. ;07/06/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;======================================================
     5GETDATA(DA,FIEVT,SVALUE) ;Return data for a specific Visit file entry.
     6 ;DBIA #2028 for Visit file.
     7 N HTEMP,TEMP
     8 S TEMP=^AUPNVSIT(DA,0)
     9 S FIEVT("VISIT")=DA
     10 S FIEVT("DATE VISIT CREATED")=$P(TEMP,U,2)
     11 S FIEVT("DFN")=$P(TEMP,U,5)
     12 S FIEVT("LOC. OF ENCOUNTER")=$P(TEMP,U,6)
     13 S FIEVT("SERVICE CATEGORY")=$P(TEMP,U,7)
     14 I $G(SVALUE) S FIEVT("VALUE")=$P(TEMP,U,7)
     15 S FIEVT("HOSPITAL LOCATION")=$P(TEMP,U,22)
     16 ;DBIA #10040, #2804
     17 I $G(FIEVT("HOSPITAL LOCATION"))="" S HTEMP=""
     18 E  S HTEMP=^SC(FIEVT("HOSPITAL LOCATION"),0)
     19 S FIEVT("HLOC")=$P(HTEMP,U,1)
     20 S FIEVT("DSS ID")=$P(TEMP,U,8)
     21 I FIEVT("DSS ID")="" S FIEVT("DSS ID")=$P(HTEMP,U,7)
     22 ;DBIA #557
     23 I FIEVT("DSS ID")'="" S FIEVT("STOP CODE")=$P(^DIC(40.7,FIEVT("DSS ID"),0),U,2)
     24 S FIEVT("OUTSIDE LOCATION")=$G(^AUPNVSIT(DA,21))
     25 S FIEVT("COMMENTS")=$G(^AUPNVSIT(DA,811))
     26 ;DBIA #4850
     27 S FIEVT("STATUS")=$$STATUS^SDPCE(DA)
     28 Q
     29 ;
     30 ;======================================================
     31GAPSTAT(VIEN) ;Return the status of the appointment associated with the
     32 ;visit.
     33 ;DBIA #4850
     34 Q $$STATUS^SDPCE(VIEN)
     35 ;
     36 ;======================================================
     37HENC(VIEN,INDENT,NLINES,TEXT) ;Display location and comment for historical
     38 ;encounters associated with the V files.
     39 N COMMENT,HLOC,LOCATION,OLOC,NIN,TEXTIN,VDATA
     40 D GETDATA(VIEN,.VDATA) I VDATA("SERVICE CATEGORY")'="E" Q
     41 S NIN=0
     42 S LOCATION=VDATA("LOC. OF ENCOUNTER")
     43 I LOCATION'="" D
     44 . S LOCATION=$$GET1^DIQ(4,LOCATION,.01)_" "_$$GET1^DIQ(4,LOCATION,99)
     45 . S NIN=NIN+1,TEXTIN(NIN)="Location of Encounter: "_LOCATION_"\\"
     46 S HLOC=VDATA("HOSPITAL LOCATION")
     47 I HLOC'="" D
     48 . S HLOC=$$GET1^DIQ(44,HLOC,.01)
     49 . S NIN=NIN+1,TEXTIN(NIN)="Hospital Location: "_HLOC_"\\"
     50 S OLOC=VDATA("OUTSIDE LOCATION")
     51 I OLOC'="" D
     52 . S NIN=NIN+1,TEXTIN(NIN)="Outside Location: "_OLOC_"\\"
     53 S COMMENT=VDATA("COMMENT")
     54 I COMMENT'="" D
     55 . S NIN=NIN+1,TEXTIN(NIN)="Comment: "_COMMENT
     56 I NIN>0 D
     57 . N JND,NOUT,TEXTOUT
     58 . S NLINES=NLINES+1
     59 . S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Historical Encounter Information:"
     60 . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,NIN,.TEXTIN,.NOUT,.TEXTOUT)
     61 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
     62 Q
     63 ;
     64 ;======================================================
     65ISHIST(VIEN) ;Return true if the encounter was historical.
     66 ;DBIA #2028
     67 I $P($G(^AUPNVSIT(VIEN,0)),U,7)="E" Q 1
     68 Q 0
     69 ;
     70 ;======================================================
     71VAPSTAT(VIEN) ;Return true if the appointment associated with
     72 ;the visit has a valid appointment status.
     73 ;Return false if the status is one of the following:
     74 ;CANCELLED BY CLINIC
     75 ;CANCELLED BY CLINIC & AUTO RE-BOOK
     76 ;CANCELLED BY PATIENT
     77 ;CANCELLED BY PATIENT & AUTO-REBOOK
     78 ;DELETED
     79 ;NO ACTION TAKEN
     80 ;NO-SHOW
     81 ;NO-SHOW & AUTO RE-BOOK
     82 N STATUS,VALID
     83 ;DBIA #4850
     84 S STATUS=$P($$STATUS^SDPCE(VIEN),U,2)
     85 S VALID=$S(STATUS["CANCELLED":0,STATUS["DELETED":0,STATUS["NO ACTION":0,STATUS["NO-SHOW":0,1:1)
     86 Q VALID
     87 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXD.m

    r613 r623  
    1 PXRMXD  ; SLC/PJH - Reminder Due reports DRIVER ;11/27/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 START   ; Arrays and strings
    5         N PXRMIOD,PXRMXST,PXRMOPT,PXRMQUE,PXRMXTMP,PXRMSEL
    6         N PXRMFAC,PXRMFACN,PXRMSCAT,PXRMSRT,PXRMTYP
    7         N REMINDER,PXRMINP,PXRMFCMB,PXRMLCMB,PXRMTCMB,PXRMTOT
    8         ; Addenda
    9         N PXRMOTM,PXRMPAT,PXRMPCM,PXRMPRV,PXRMTMP,PXRMRCAT,PXRMREM
    10         N PXRMCS,PXRMCSN,PXRMLOCN,PXRMLCHL,PXRMLCSC,PXRMCGRP,PXRMCGRN
    11         N PXRMLIS
    12         ; Counters
    13         N NCAT,NFAC,NLOC,NPAT,NPCM,NOTM,NPRV,NREM,NCS,NHL,NCGRP
    14         ; Flags and Dates
    15         N PXRMFD,PXRMSDT,PXRMBDT,PXRMEDT,PXRMREP,PXRMPRIM,PXRMFUT,PXRMDLOC
    16         N PXRMRT,PXRMSSN,PXRMTABC,PXRMTABS,PXRMTMP,TITLE,VALUE
    17         N DBDOWN,DBDUZ,DBERR,PXRMLIST,PXRMLIS1,Y
    18         N PLISTPUG
    19         N PXRMTPAT,PXRMDPAT,PXRMPML
    20         ;
    21         S PXRMRT="PXRMX",PXRMTYP="X",PXRMFCMB="N",PXRMLCMB="N",PXRMTCMB="N"
    22         ;
    23         I '$D(PXRMUSER) N PXRMUSER S PXRMUSER=0
    24         ;
    25         ;Guarantee the timestamp is unique.
    26         H 1
    27         S PXRMXST=$$NOW^XLFDT
    28         S PXRMXTMP=PXRMRT_PXRMXST
    29         S ^XTMP(PXRMXTMP,0)=$$FMADD^XLFDT(DT,7)_U_DT_U_"PXRM Reminder Due Report"
    30         ;
    31         ;Check for existing report templates
    32 REP     ;
    33         S PXRMINP=0
    34         D:PXRMUSER ^PXRMXTB D:'PXRMUSER ^PXRMXT I $D(DTOUT)!$D(DUOUT) G EXIT
    35         ;Run report from template details
    36         I PXRMTMP'="" D  G:$D(DUOUT)&'$D(DTOUT) REP Q
    37         .D START^PXRMXTA("JOB^PXRMXQUE") K DUOUT,DIRUT,DTOUT
    38         ;
    39         ;Select sample criteria
    40 SEL     ;
    41         D SELECT^PXRMXSD(.PXRMSEL) I $D(DTOUT) G EXIT
    42         I $D(DUOUT) G:PXRMTMP="" EXIT G REP
    43         ;
    44 FAC     ;Get the facility list.
    45         I "IRPO"'[PXRMSEL D  G:$D(DTOUT) EXIT G:$D(DUOUT) SEL
    46         .D FACILITY^PXRMXSU(.PXRMFAC) Q:$D(DTOUT)!$D(DUOUT)
    47         ;
    48         ;Check if combined facility report is required
    49 COMB    I "IRPO"'[PXRMSEL,NFAC>1 D  G:$D(DTOUT) EXIT G:$D(DUOUT) FAC
    50         .D COMB^PXRMXSD(.PXRMFCMB,"Facilities","N")
    51         ;
    52 OPT     ;Variable prompts
    53         ;
    54         ;Get Individual Patient list
    55         I PXRMSEL="I" K PXRMPAT D PAT^PXRMXSU(.PXRMPAT)
    56         ;Get Patient list #810.5
    57         I PXRMSEL="R" K PXRMLIST D LIST^PXRMXSU(.PXRMLIST)
    58         ;Get OE/RRteam list
    59         I PXRMSEL="O" K PXRMOTM D OERR^PXRMXSU(.PXRMOTM)
    60         ;Get PCMM team
    61         I PXRMSEL="T" K PXRMPCM D PCMM^PXRMXSU(.PXRMPCM)
    62         ;Get provider list
    63         I PXRMSEL="P" K PXRMPRV D PROV^PXRMXSU(.PXRMPRV)
    64         ;Get the location list.
    65         I PXRMSEL="L" K PXRMCS,PXRMCSN,PXRMLOCN,PXRMLCHL,PXRMCGRP,PXRMCGRN D
    66         .D LOC^PXRMXSU("Determine encounter counts for","HS")
    67         I $D(DTOUT) G EXIT
    68         I $D(DUOUT) G:"IRPO"[PXRMSEL SEL G:NFAC>1 COMB G FAC
    69         ;
    70         ;Check if inpatient location report
    71         S PXRMINP=$$INP
    72         ;
    73         ; Primary Provider or All (PCMM Provider only)
    74 PRIME   I PXRMSEL="P" D  G:$D(DTOUT) EXIT G:$D(DUOUT) OPT
    75         .D PRIME^PXRMXSD(.PXRMPRIM)
    76         ;
    77 DR      ; Get the date range.
    78         S PXRMFD="P"
    79         ; No prompt if individual patients selected
    80         ; Single dates only if PCMM teams/providers and OE/RR teams selected
    81         ; Choice of previous/future date range if location selected
    82         ;
    83         ; Prior encounters/future appointments (location only)
    84 PREV    I PXRMSEL="L" D PREV^PXRMXSD(.PXRMFD) G:$D(DTOUT) EXIT G:$D(DUOUT) OPT
    85         ; Date range input (location only)
    86         I PXRMSEL="L" D  G:$D(DTOUT) EXIT G:$D(DUOUT) PREV
    87         .I PXRMFD="P" D PDR^PXRMXDUT(.PXRMBDT,.PXRMEDT,"ENCOUNTER")
    88         .I PXRMFD="F" D FDR^PXRMXDUT(.PXRMBDT,.PXRMEDT,"APPOINTMENT")
    89         .I PXRMFD="A" D PDR^PXRMXDUT(.PXRMBDT,.PXRMEDT,"ADMISSION")
    90         .I PXRMFD="C" S PXRMBDT=DT,PXRMEDT=DT
    91         ; Due Effective Date
    92 DUE     D SDR^PXRMXDUT(.PXRMSDT) G:$D(DTOUT) EXIT
    93         I $D(DUOUT) G:PXRMSEL="L" PREV G OPT
    94         ;
    95 SCAT    ;Get the service categories.
    96         I PXRMSEL="L",PXRMFD="P" D
    97         .D SCAT^PXRMXSC
    98         .I $D(DTOUT)!$D(DUOUT) Q
    99         I $D(DTOUT) G EXIT
    100         I $D(DUOUT) G DUE
    101         ;
    102 TYP     ;Determine type of report (detail/summary)
    103         S PXRMREP="S"
    104         D REP^PXRMXSD(.PXRMREP) I $D(DTOUT) G EXIT
    105         I $D(DUOUT) G SCAT
    106         ;
    107         ;Check if combined location report is required
    108 LCOMB   S NLOC=0
    109         I PXRMREP="D",PXRMSEL="L" D  G:$D(DTOUT) EXIT G:$D(DUOUT) TYP
    110         .N DEFAULT,TEXT
    111         .D NLOC
    112         .I NLOC>1 D COMB^PXRMXSD(.PXRMLCMB,TEXT,DEFAULT)
    113         ;
    114         ;Check if combined OE/RR team report is required
    115 TCOMB   I PXRMREP="D",PXRMSEL="O",$G(NOTM)>1 D  G:$D(DTOUT) EXIT G:$D(DUOUT) TYP
    116         .N DEFAULT,TEXT
    117         .S DEFAULT="N",TEXT="OE/RR teams"
    118         .D COMB^PXRMXSD(.PXRMTCMB,TEXT,DEFAULT)
    119         ;
    120 FUT     ;For detailed report give option to display future appointments
    121         S PXRMFUT="N"
    122         I PXRMREP="D",'PXRMINP D  G:$D(DTOUT) EXIT I $D(DUOUT) G:(PXRMSEL="L")&(NLOC>1) LCOMB G:(PXRMSEL="O")&($G(NOTM)>1) TCOMB G TYP
    123         .D FUTURE^PXRMXSD(.PXRMFUT,"Display All Future Appointments: ",5)
    124         .I PXRMFUT="Y" D  Q:$D(DTOUT)!$D(DUOUT)
    125         ..D FUTURE^PXRMXSD(.PXRMDLOC,"Display Appointment Location: ",15)
    126         ;
    127 SRT     ;For detailed report give option to sort by appointment date
    128         S PXRMSRT="N"
    129         I PXRMREP="D",("RI"'[PXRMSEL) D  G:$D(DTOUT) EXIT I $D(DUOUT) G:(PXRMSEL="L")&(PXRMINP)&(NLOC>1) LCOMB G:PXRMINP TYP G:(PXRMSEL="O")&($G(NOTM)>1) TCOMB G FUT
    130         .;Option to sort by Bed for inpatients
    131         .I PXRMSEL="L",PXRMINP D BED^PXRMXSD(.PXRMSRT) Q
    132         .;Otherwise option to sort by appt. date
    133         .D SRT^PXRMXSD(.PXRMSRT)
    134         ;
    135         ;Option to print full SSN
    136 SSN     I PXRMREP="D" D  G:$D(DTOUT) EXIT I $D(DUOUT) G:"IR"[PXRMSEL FUT G SRT
    137         .D SSN^PXRMXSD(.PXRMSSN)
    138         ;
    139         ;Option to print without totals, with totals or totals only
    140 TOT     I PXRMREP="S" D  G:$D(DTOUT) EXIT I $D(DUOUT) G TYP
    141         .;Default is normal report
    142         .S PXRMTOT="I"
    143         .;Ignore patient and patient list reports
    144         .I "RI"[PXRMSEL Q
    145         .;Only prompt if more than one location, team or provider is selected
    146         .I PXRMSEL="P",NPRV<2 Q
    147         .I "OT"[PXRMSEL,NOTM<2 Q
    148         .;Ignore reports for all locations
    149         .I PXRMSEL="L",PXRMLCMB="Y" Q
    150         .I PXRMSEL="L" N DEFAULT,TEXT D NLOC Q:NLOC<2
    151         .;Prompt for options
    152         .N LIT1,LIT2,LIT3
    153         .D LIT,TOTALS^PXRMXSD(.PXRMTOT,LIT1,LIT2,LIT3)
    154         ;
    155 MLOC        ;Print Locations empty location at the end of the report
    156         W !
    157         S DIR(0)="Y",DIR("B")="YES",DIR("A")="Print locations with no patients"
    158         D ^DIR
    159         I Y="^^" G EXIT
    160         I Y=U G:PXRMREP="D" SSN G TOT
    161         S PXRMPML=Y
    162         ;
    163         ;Reminder Category/Individual Reminder Selection
    164 RCAT    ;
    165         D RCAT^PXRMXSU(.PXRMRCAT,.PXRMREM) I $D(DTOUT) G EXIT
    166         ;I $D(DUOUT) G:PXRMREP="D" SSN G TOT
    167         I $D(DUOUT) G MLOC
    168         ;
    169         ;Create combined reminder list
    170         D MERGE^PXRMXS1
    171         ;
    172 SAV     ;Option to create a new report template
    173         I PXRMTMP="" D ^PXRMXTU G:$D(DTOUT) EXIT I $D(DUOUT) G RCAT
    174         ;
    175         ;Option to print delimiter separated output
    176 TABS    D  G:$D(DTOUT) EXIT I $D(DUOUT) G SAV
    177         .D TABS^PXRMXSD(.PXRMTABS)
    178         ;Select chracter
    179 TCHAR   I PXRMTABS="Y" D  G:$D(DTOUT) EXIT G:$D(DUOUT) TABS
    180         .S PXRMTABC=$$DELIMSEL^PXRMXSD
    181         ;
    182 DPAT    ;Ask whether to include deceased and test patients.
    183         S PXRMDPAT=$$ASKYN^PXRMEUT("N","Include deceased patients on the list")
    184         N PXRMIDOD I PXRMDPAT>0 S PXRMIDOD=1
    185         Q:$D(DTOUT)  G:$D(DUOUT) TABS
    186 TPAT    ;
    187         S PXRMTPAT=$$ASKYN^PXRMEUT("N","Include test patients on the list")
    188         Q:$D(DTOUT)  G:$D(DUOUT) DPAT
    189 PATLIST ;
    190         K PATCREAT
    191         N PATLST
    192         I PXRMSEL'="I"&(PXRMUSER'="Y") D
    193         . D ASK(.PATLST,"Save due patients to a patient list: ",3)
    194         . I $G(PATLST)="" Q
    195         . I $G(PATLST)="N" S PXRMLIS1="" Q
    196         . I $G(PATLST)="Y" D
    197         ..S PATCREAT="N"
    198         ..D ASK(.PATCREAT,"Secure list?: ",3) I $D(DTOUT)!($D(DUOUT)) Q
    199         ..K PLISTPUG
    200         ..S PLISTPUG="N" D ASK^PXRMXD(.PLISTPUG,"Purge Patient List after 5 years?: ",5)
    201         I $G(PATLST)="" G:$D(DTOUT) EXIT I $D(DUOUT) G TPAT
    202         G:$D(DTOUT) EXIT I $D(DUOUT) G PATLIST
    203         I $G(PATLST)="Y" S TEXT="Select PATIENT LIST name: " D PLIST^PXRMLCR(.PXRMLIS1,TEXT,"") Q:$D(DUOUT)!$D(DTOUT)
    204         ;Determine whether the report should be queued.
    205 JOB     ;
    206         D JOB^PXRMXQUE
    207         Q
    208         ;
    209         ;Option PXRM REMINDERS DUE (USER)
    210 USER    N PXRMUSER
    211         S PXRMUSER=+$G(DUZ)
    212         G START
    213         ;
    214         ;
    215 EXIT    ;Clean things up.
    216         D EXIT^PXRMXGUT
    217         Q
    218         ;
    219         ;Check if inpatient report
    220 INP()   ;Applies to location reports only
    221         I PXRMSEL'="L" Q 0
    222         ;For all inpatient locations default is automatic
    223         I $P(PXRMLCSC,U)="HAI" Q 1
    224         ;For selected locations check if all locations are wards
    225         I $P(PXRMLCSC,U)="HS" Q $$INP^PXRMXAP(PXRMLCSC,.PXRMLOCN)
    226         ;Otherwise
    227         Q 0
    228         ;
    229         ;Prompt text
    230 LIT     N LIT
    231         S LIT=$S(PXRMSEL="P":"Provider","OT"[PXRMSEL:"Team",1:"Location")
    232         I PXRMFCMB="N" D
    233         .S LIT1="Individual "_LIT_"s only"
    234         .S LIT2="Individual "_LIT_"s plus Totals by Facility"
    235         .S LIT3="Totals by Facility only"
    236         I PXRMFCMB="Y" D
    237         .S LIT1="Individual "_LIT_"s only"
    238         .S LIT2="Individual "_LIT_"s plus Overall Total"
    239         .S LIT3="Overall Total only"
    240         Q
    241         ;
    242         ;Check if multiple locations
    243 NLOC    S DEFAULT="N",NLOC=1,TEXT="Locations"
    244         I $P(PXRMLCSC,U)["HA" S DEFAULT="Y",NLOC=999
    245         I $P(PXRMLCSC,U)="CA" S DEFAULT="Y",NCS=999
    246         I $E(PXRMLCSC)="C" S TEXT="Clinic Stops",NLOC=NCS
    247         I $E(PXRMLCSC)="G" S TEXT="Clinic Groups",NLOC=NCGRP
    248         I $P(PXRMLCSC,U)="HS" S NLOC=NHL S:$$INP TEXT="Inpatient Locations"
    249         ;Special coding if more than one facility and location
    250         I $P(PXRMLCSC,U)="HS",NFAC>1,NLOC>1 D
    251         .N FAC,HLOCIEN,HLNAME,IC,MULT
    252         .S IC=0 S:PXRMFCMB="Y" FAC="COMBINED"
    253         .;Build list of locations by facility
    254         .F  S IC=$O(PXRMLCHL(IC)) Q:'IC  D
    255         ..S HLOCIEN=$P(PXRMLCHL(IC),U,2),FAC=$$FACL^PXRMXAP(HLOCIEN) Q:'FAC
    256         ..S HLNAME=$P(PXRMLCHL(IC),U) Q:HLNAME=""
    257         ..S MULT(FAC,HLNAME)=""
    258         .S MULT=0,FAC=0
    259         .;Count locations in each facility
    260         .F  S FAC=$O(MULT(FAC)) Q:'FAC  D  Q:MULT
    261         ..S IC=0,HLNAME=""
    262         ..F  S HLNAME=$O(MULT(FAC,HLNAME)) Q:HLNAME=""  S IC=IC+1
    263         ..I IC>1 S MULT=1
    264         .;If only one location per facility suppress combined location option
    265         .I 'MULT S NLOC=1
    266         Q
    267         ;
    268 ASK(YESNO,PROMPT,NUM)        ;
    269         N X,Y,TEXT
    270         K DIROUT,DIRUT,DTOUT,DUOUT
    271         S DIR(0)="YA0"
    272         S DIR("A")=PROMPT
    273         S DIR("B")="N"
    274         S DIR("?")="Enter Y or N. For detailed help type ??"
    275         S DIR("??")=U_"D HELP^PXRMLCR("_NUM_")"
    276         W !
    277         D ^DIR K DIR
    278         I $D(DIROUT) S DTOUT=1
    279         I $D(DTOUT)!($D(DUOUT)) Q
    280         S YESNO=$E(Y(0))
    281         Q
    282         ;
     1PXRMXD ; SLC/PJH - Reminder Due reports DRIVER ;06/20/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4START ; Arrays and strings
     5 N PXRMIOD,PXRMXST,PXRMOPT,PXRMQUE,PXRMXTMP,PXRMSEL
     6 N PXRMFAC,PXRMFACN,PXRMSCAT,PXRMSRT,PXRMTYP
     7 N REMINDER,PXRMINP,PXRMFCMB,PXRMLCMB,PXRMTCMB,PXRMTOT
     8 ; Addenda
     9 N PXRMOTM,PXRMPAT,PXRMPCM,PXRMPRV,PXRMTMP,PXRMRCAT,PXRMREM
     10 N PXRMCS,PXRMCSN,PXRMLOCN,PXRMLCHL,PXRMLCSC,PXRMCGRP,PXRMCGRN
     11 N PXRMLIS
     12 ; Counters
     13 N NCAT,NFAC,NLOC,NPAT,NPCM,NOTM,NPRV,NREM,NCS,NHL,NCGRP
     14 ; Flags and Dates
     15 N PXRMFD,PXRMSDT,PXRMBDT,PXRMEDT,PXRMREP,PXRMPRIM,PXRMFUT,PXRMDLOC
     16 N PXRMRT,PXRMSSN,PXRMTABC,PXRMTABS,PXRMTMP,TITLE,VALUE
     17 N DBDOWN,DBDUZ,DBERR,PXRMLIST,PXRMLIS1,Y
     18 N PLISTPUG
     19 N PXRMTPAT,PXRMDPAT
     20 ;
     21 S PXRMRT="PXRMX",PXRMTYP="X",PXRMFCMB="N",PXRMLCMB="N",PXRMTCMB="N"
     22 ;
     23 I '$D(PXRMUSER) N PXRMUSER S PXRMUSER=0
     24 ;
     25 ;Guarantee the timestamp is unique.
     26 H 1
     27 S PXRMXST=$$NOW^XLFDT
     28 S PXRMXTMP=PXRMRT_PXRMXST
     29 S ^XTMP(PXRMXTMP,0)=$$FMADD^XLFDT(DT,7)_U_DT_U_"PXRM Reminder Due Report"
     30 ;
     31 ;Check for existing report templates
     32REP ;
     33 S PXRMINP=0
     34 D:PXRMUSER ^PXRMXTB D:'PXRMUSER ^PXRMXT I $D(DTOUT)!$D(DUOUT) G EXIT
     35 ;Run report from template details
     36 I PXRMTMP'="" D  G:$D(DUOUT)&'$D(DTOUT) REP Q
     37 .D START^PXRMXTA("JOB^PXRMXQUE") K DUOUT,DIRUT,DTOUT
     38 ;
     39 ;Select sample criteria
     40SEL ;
     41 D SELECT^PXRMXSD(.PXRMSEL) I $D(DTOUT) G EXIT
     42 I $D(DUOUT) G:PXRMTMP="" EXIT G REP
     43 ;
     44FAC ;Get the facility list.
     45 I "IRPO"'[PXRMSEL D  G:$D(DTOUT) EXIT G:$D(DUOUT) SEL
     46 .D FACILITY^PXRMXSU(.PXRMFAC) Q:$D(DTOUT)!$D(DUOUT)
     47 ;
     48 ;Check if combined facility report is required
     49COMB I "IRPO"'[PXRMSEL,NFAC>1 D  G:$D(DTOUT) EXIT G:$D(DUOUT) FAC
     50 .D COMB^PXRMXSD(.PXRMFCMB,"Facilities","N")
     51 ;
     52OPT ;Variable prompts
     53 ;
     54 ;Get Individual Patient list
     55 I PXRMSEL="I" K PXRMPAT D PAT^PXRMXSU(.PXRMPAT)
     56 ;Get Patient list #810.5
     57 I PXRMSEL="R" K PXRMLIST D LIST^PXRMXSU(.PXRMLIST)
     58 ;Get OE/RRteam list
     59 I PXRMSEL="O" K PXRMOTM D OERR^PXRMXSU(.PXRMOTM)
     60 ;Get PCMM team
     61 I PXRMSEL="T" K PXRMPCM D PCMM^PXRMXSU(.PXRMPCM)
     62 ;Get provider list
     63 I PXRMSEL="P" K PXRMPRV D PROV^PXRMXSU(.PXRMPRV)
     64 ;Get the location list.
     65 I PXRMSEL="L" K PXRMCS,PXRMCSN,PXRMLOCN,PXRMLCHL,PXRMCGRP,PXRMCGRN D
     66 .D LOC^PXRMXSU("Determine encounter counts for","HS")
     67 I $D(DTOUT) G EXIT
     68 I $D(DUOUT) G:"IRPO"[PXRMSEL SEL G:NFAC>1 COMB G FAC
     69 ;
     70 ;Check if inpatient location report
     71 S PXRMINP=$$INP
     72 ;
     73 ; Primary Provider or All (PCMM Provider only)
     74PRIME I PXRMSEL="P" D  G:$D(DTOUT) EXIT G:$D(DUOUT) OPT
     75 .D PRIME^PXRMXSD(.PXRMPRIM)
     76 ;
     77DR ; Get the date range.
     78 S PXRMFD="P"
     79 ; No prompt if individual patients selected
     80 ; Single dates only if PCMM teams/providers and OE/RR teams selected
     81 ; Choice of previous/future date range if location selected
     82 ;
     83 ; Prior encounters/future appointments (location only)
     84PREV I PXRMSEL="L" D PREV^PXRMXSD(.PXRMFD) G:$D(DTOUT) EXIT G:$D(DUOUT) OPT
     85 ; Date range input (location only)
     86 I PXRMSEL="L" D  G:$D(DTOUT) EXIT G:$D(DUOUT) PREV
     87 .I PXRMFD="P" D PDR^PXRMXDUT(.PXRMBDT,.PXRMEDT,"ENCOUNTER")
     88 .I PXRMFD="F" D FDR^PXRMXDUT(.PXRMBDT,.PXRMEDT,"APPOINTMENT")
     89 .I PXRMFD="A" D PDR^PXRMXDUT(.PXRMBDT,.PXRMEDT,"ADMISSION")
     90 .I PXRMFD="C" S PXRMBDT=DT,PXRMEDT=DT
     91 ; Due Effective Date
     92DUE D SDR^PXRMXDUT(.PXRMSDT) G:$D(DTOUT) EXIT
     93 I $D(DUOUT) G:PXRMSEL="L" PREV G OPT
     94 ;
     95SCAT ;Get the service categories.
     96 I PXRMSEL="L",PXRMFD="P" D
     97 .D SCAT^PXRMXSC
     98 .I $D(DTOUT)!$D(DUOUT) Q
     99 I $D(DTOUT) G EXIT
     100 I $D(DUOUT) G DUE
     101 ;
     102TYP ;Determine type of report (detail/summary)
     103 S PXRMREP="S"
     104 D REP^PXRMXSD(.PXRMREP) I $D(DTOUT) G EXIT
     105 I $D(DUOUT) G SCAT
     106 ;
     107 ;Check if combined location report is required
     108LCOMB S NLOC=0
     109 I PXRMREP="D",PXRMSEL="L" D  G:$D(DTOUT) EXIT G:$D(DUOUT) TYP
     110 .N DEFAULT,TEXT
     111 .D NLOC
     112 .I NLOC>1 D COMB^PXRMXSD(.PXRMLCMB,TEXT,DEFAULT)
     113 ;
     114 ;Check if combined OE/RR team report is required
     115TCOMB I PXRMREP="D",PXRMSEL="O",$G(NOTM)>1 D  G:$D(DTOUT) EXIT G:$D(DUOUT) TYP
     116 .N DEFAULT,TEXT
     117 .S DEFAULT="N",TEXT="OE/RR teams"
     118 .D COMB^PXRMXSD(.PXRMTCMB,TEXT,DEFAULT)
     119 ;
     120FUT ;For detailed report give option to display future appointments
     121 S PXRMFUT="N"
     122 I PXRMREP="D",'PXRMINP D  G:$D(DTOUT) EXIT I $D(DUOUT) G:(PXRMSEL="L")&(NLOC>1) LCOMB G:(PXRMSEL="O")&($G(NOTM)>1) TCOMB G TYP
     123 .D FUTURE^PXRMXSD(.PXRMFUT,"Display All Future Appointments: ",5)
     124 .I PXRMFUT="Y" D  Q:$D(DTOUT)!$D(DUOUT)
     125 ..D FUTURE^PXRMXSD(.PXRMDLOC,"Display Appointment Location: ",15)
     126 ;
     127SRT ;For detailed report give option to sort by appointment date
     128 S PXRMSRT="N"
     129 I PXRMREP="D",("RI"'[PXRMSEL) D  G:$D(DTOUT) EXIT I $D(DUOUT) G:(PXRMSEL="L")&(PXRMINP)&(NLOC>1) LCOMB G:PXRMINP TYP G:(PXRMSEL="O")&($G(NOTM)>1) TCOMB G FUT
     130 .;Option to sort by Bed for inpatients
     131 .I PXRMSEL="L",PXRMINP D BED^PXRMXSD(.PXRMSRT) Q
     132 .;Otherwise option to sort by appt. date
     133 .D SRT^PXRMXSD(.PXRMSRT)
     134 ;
     135 ;Option to print full SSN
     136SSN I PXRMREP="D" D  G:$D(DTOUT) EXIT I $D(DUOUT) G:"IR"[PXRMSEL FUT G SRT
     137 .D SSN^PXRMXSD(.PXRMSSN)
     138 ;
     139 ;Option to print without totals, with totals or totals only
     140TOT I PXRMREP="S" D  G:$D(DTOUT) EXIT I $D(DUOUT) G TYP
     141 .;Default is normal report
     142 .S PXRMTOT="I"
     143 .;Ignore patient and patient list reports
     144 .I "RI"[PXRMSEL Q
     145 .;Only prompt if more than one location, team or provider is selected
     146 .I PXRMSEL="P",NPRV<2 Q
     147 .I "OT"[PXRMSEL,NOTM<2 Q
     148 .;Ignore reports for all locations
     149 .I PXRMSEL="L",PXRMLCMB="Y" Q
     150 .I PXRMSEL="L" N DEFAULT,TEXT D NLOC Q:NLOC<2
     151 .;Prompt for options
     152 .N LIT1,LIT2,LIT3
     153 .D LIT,TOTALS^PXRMXSD(.PXRMTOT,LIT1,LIT2,LIT3)
     154 ;
     155 ;Reminder Category/Individual Reminder Selection
     156RCAT ;
     157 D RCAT^PXRMXSU(.PXRMRCAT,.PXRMREM) I $D(DTOUT) G EXIT
     158 I $D(DUOUT) G:PXRMREP="D" SSN G TOT
     159 ;
     160 ;Create combined reminder list
     161 D MERGE^PXRMXS1
     162 ;
     163SAV ;Option to create a new report template
     164 I PXRMTMP="" D ^PXRMXTU G:$D(DTOUT) EXIT I $D(DUOUT) G RCAT
     165 ;
     166 ;Option to print delimiter separated output
     167TABS D  G:$D(DTOUT) EXIT I $D(DUOUT) G SAV
     168 .D TABS^PXRMXSD(.PXRMTABS)
     169 ;Select chracter
     170TCHAR I PXRMTABS="Y" D  G:$D(DTOUT) EXIT G:$D(DUOUT) TABS
     171 .S PXRMTABC=$$DELIMSEL^PXRMXSD
     172 ;
     173DPAT ;Ask whether to include deceased and test patients.
     174 S PXRMDPAT=$$ASKYN^PXRMEUT("N","Include deceased patients on the list")
     175 N PXRMIDOD I PXRMDPAT>0 S PXRMIDOD=1
     176 Q:$D(DTOUT)  G:$D(DUOUT) TABS
     177TPAT ;
     178 S PXRMTPAT=$$ASKYN^PXRMEUT("N","Include test patients on the list")
     179 Q:$D(DTOUT)  G:$D(DUOUT) DPAT
     180PATLIST ;
     181 K PATCREAT
     182 N PATLST
     183 I PXRMSEL'="I"&(PXRMUSER'="Y") D
     184 . D ASK(.PATLST,"Save due patients to a patient list: ",3)
     185 . I $G(PATLST)="" Q
     186 . I $G(PATLST)="N" S PXRMLIS1="" Q
     187 . I $G(PATLST)="Y" D
     188 ..S PATCREAT="N"
     189 ..D ASK(.PATCREAT,"Secure list?: ",3) I $D(DTOUT)!($D(DUOUT)) Q
     190 ..K PLISTPUG
     191 ..S PLISTPUG="N" D ASK^PXRMXD(.PLISTPUG,"Purge Patient List after 5 years?: ",5)
     192 I $G(PATLST)="" G:$D(DTOUT) EXIT I $D(DUOUT) G TPAT
     193 G:$D(DTOUT) EXIT I $D(DUOUT) G PATLIST
     194 I $G(PATLST)="Y" S TEXT="Select PATIENT LIST name: " D PLIST^PXRMLCR(.PXRMLIS1,TEXT,"") Q:$D(DUOUT)!$D(DTOUT)
     195 ;Determine whether the report should be queued.
     196JOB ;
     197 D JOB^PXRMXQUE
     198 Q
     199 ;
     200 ;Option PXRM REMINDERS DUE (USER)
     201USER N PXRMUSER
     202 S PXRMUSER=+$G(DUZ)
     203 G START
     204 ;
     205 ;
     206EXIT ;Clean things up.
     207 D EXIT^PXRMXGUT
     208 Q
     209 ;
     210 ;Check if inpatient report
     211INP() ;Applies to location reports only
     212 I PXRMSEL'="L" Q 0
     213 ;For all inpatient locations default is automatic
     214 I $P(PXRMLCSC,U)="HAI" Q 1
     215 ;For selected locations check if all locations are wards
     216 I $P(PXRMLCSC,U)="HS" Q $$INP^PXRMXAP(PXRMLCSC,.PXRMLOCN)
     217 ;Otherwise
     218 Q 0
     219 ;
     220 ;Prompt text
     221LIT N LIT
     222 S LIT=$S(PXRMSEL="P":"Provider","OT"[PXRMSEL:"Team",1:"Location")
     223 I PXRMFCMB="N" D
     224 .S LIT1="Individual "_LIT_"s only"
     225 .S LIT2="Individual "_LIT_"s plus Totals by Facility"
     226 .S LIT3="Totals by Facility only"
     227 I PXRMFCMB="Y" D
     228 .S LIT1="Individual "_LIT_"s only"
     229 .S LIT2="Individual "_LIT_"s plus Overall Total"
     230 .S LIT3="Overall Total only"
     231 Q
     232 ;
     233 ;Check if multiple locations
     234NLOC S DEFAULT="N",NLOC=1,TEXT="Locations"
     235 I $P(PXRMLCSC,U)["HA" S DEFAULT="Y",NLOC=999
     236 I $P(PXRMLCSC,U)="CA" S DEFAULT="Y",NCS=999
     237 I $E(PXRMLCSC)="C" S TEXT="Clinic Stops",NLOC=NCS
     238 I $E(PXRMLCSC)="G" S TEXT="Clinic Groups",NLOC=NCGRP
     239 I $P(PXRMLCSC,U)="HS" S NLOC=NHL S:$$INP TEXT="Inpatient Locations"
     240 ;Special coding if more than one facility and location
     241 I $P(PXRMLCSC,U)="HS",NFAC>1,NLOC>1 D
     242 .N FAC,HLOCIEN,HLNAME,IC,MULT
     243 .S IC=0 S:PXRMFCMB="Y" FAC="COMBINED"
     244 .;Build list of locations by facility
     245 .F  S IC=$O(PXRMLCHL(IC)) Q:'IC  D
     246 ..S HLOCIEN=$P(PXRMLCHL(IC),U,2),FAC=$$FACL^PXRMXAP(HLOCIEN) Q:'FAC
     247 ..S HLNAME=$P(PXRMLCHL(IC),U) Q:HLNAME=""
     248 ..S MULT(FAC,HLNAME)=""
     249 .S MULT=0,FAC=0
     250 .;Count locations in each facility
     251 .F  S FAC=$O(MULT(FAC)) Q:'FAC  D  Q:MULT
     252 ..S IC=0,HLNAME=""
     253 ..F  S HLNAME=$O(MULT(FAC,HLNAME)) Q:HLNAME=""  S IC=IC+1
     254 ..I IC>1 S MULT=1
     255 .;If only one location per facility suppress combined location option
     256 .I 'MULT S NLOC=1
     257 Q
     258 ;
     259ASK(YESNO,PROMPT,NUM)      ;
     260 N X,Y,TEXT
     261 K DIROUT,DIRUT,DTOUT,DUOUT
     262 S DIR(0)="YA0"
     263 S DIR("A")=PROMPT
     264 S DIR("B")="N"
     265 S DIR("?")="Enter Y or N. For detailed help type ??"
     266 S DIR("??")=U_"D HELP^PXRMLCR("_NUM_")"
     267 W !
     268 D ^DIR K DIR
     269 I $D(DIROUT) S DTOUT=1
     270 I $D(DTOUT)!($D(DUOUT)) Q
     271 S YESNO=$E(Y(0))
     272 Q
     273 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXDT1.m

    r613 r623  
    1 PXRMXDT1        ; SLC/PJH - Build Patient list SUBROUTINES;08/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called by label from PXRMXSEO,PXRMXSE
    5         ;
    6         ;Combined report duplicate check (Summary report)
    7 NEW(SUB,SUB1,SUB2)      ;
    8         ;Existing entry
    9         I $D(^TMP("PXRMCMB",$J,SUB,SUB1,SUB2)) Q 0
    10         ;New entry
    11         S ^TMP("PXRMCMB",$J,SUB,SUB1,SUB2)=""
    12         Q 1
    13         ;
    14         ;Individual patient report duplicate patient check
    15 NEWIP(DFN)      ;
    16         ;Existing entry
    17         I $D(^TMP("PXRMCMB3",$J,DFN)) Q 0
    18         ;New entry
    19         S ^TMP("PXRMCMB3",$J,DFN)=""
    20         Q 1
    21         ;Combined report duplicate check (Detail report)
    22 NEWP(SUB,DFN)   ;
    23         ;Existing entry
    24         I $D(^TMP("PXRMCMB1",$J,SUB,DFN)) Q 0
    25         ;New entry
    26         S ^TMP("PXRMCMB1",$J,SUB,DFN)=""
    27         Q 1
    28         ;
    29         ;Combined report duplicate check (Patient totals)
    30 NEWT(FACILITY,DFN)      ;
    31         ;Existing entry
    32         I $D(^TMP("PXRMCMB2",$J,FACILITY,DFN)) Q 0
    33         ;New entry
    34         S ^TMP("PXRMCMB2",$J,FACILITY,DFN)=""
    35         Q 1
    36         ;
    37         ;Detailed report
    38 SDET(DFN,STATUS,NAM,FACILITY,INP)       ;
    39         I $G(^XTMP(PXRMXTMP,PX,FACILITY,NAM))="" D
    40         .S ^XTMP(PXRMXTMP,PX,FACILITY,NAM)=NAM
    41         ;Applicable
    42         S DDAT="N/A"
    43         N APPL,FAPPTDT,DEFARR,DNEXT,DNEXT1,FIEV,PXRMDATE,BID,TMPSUB
    44         S APPL=0,FAPPTDT=0
    45         ;Add any that aren't N/A, Ignore on N/A or NEVER to applicable total
    46         I ($P(STATUS,U)'="")&(STATUS'["NEVER")&(STATUS'["N/A")&(STATUS'["ERROR")&(STATUS'["CNBD") S APPL=1
    47         ;If DUE NOW save details
    48         I $G(STATUS)'["DUE NOW" S PNAM=" "
    49         I $G(STATUS)["DUE NOW" D
    50         .N BED
    51         .S DDUE=$P($G(STATUS),U,2)
    52         .S DLAST=$P($G(STATUS),U,3)
    53         .;Demographics
    54         .S PNAM=$P($G(^DPT(DFN,0)),U),BID=$P($G(^DPT(DFN,0)),U,9)
    55         .I PNAM="" S PNAM=" "
    56         .E  S PNAM=PNAM_U_BID
    57         .;Next appointment for location or clinic
    58         .;For detailed provider report get next appoint. for assoc. clinic
    59         .S DNEXT=""
    60         .I PXRMSEL="L"!(PXRMSEL="P") S TMPSUB="PXRM FUTURE APPT"
    61         .E  S TMPSUB="SDAMA301"
    62         .I PXRMFCMB="Y",PXRMLCMB="Y",$D(^TMP($J,TMPSUB,DFN))>0 D
    63         ..N APPTCNT,LOC
    64         ..S LOC=0,APPTCNT=0
    65         ..F  S LOC=$O(^TMP($J,TMPSUB,DFN,LOC)) Q:(LOC'>0)!(APPTCNT=1)  D
    66         ...S DNEXT=$O(^TMP($J,TMPSUB,DFN,LOC,"")) I +DNEXT>0 S APPTCNT=1 Q
    67         .S DNEXT=$O(^TMP($J,TMPSUB,DFN,$G(INP),""))
    68         .I PXRMFCMB="N",PXRMLCMB="Y" D
    69         ..S DNEXT1=$O(^TMP($J,"PXRM FACILITY FUTURE APPT",DFN,FACILITY,"")) Q:DNEXT1'>0
    70         ..I +DNEXT=0!(DNEXT>DNEXT1) S DNEXT=DNEXT1
    71         .S BED=$G(^DPT(DFN,.101)) S:BED="" BED="NONE"
    72         .;Sort by next appointment date
    73         .I PXRMSRT="Y" S DDAT=$P(DNEXT,".") S:DDAT="" DDAT="NONE"
    74         .;Patient ward/bed used only for inpatient reports
    75         .I PXRMFUT="Y" S DNEXT=""
    76         .N TXT
    77         .S TXT=DFN_U_DDUE_U_DLAST_U_$G(DNEXT)_$S($G(BED)'="":U_BED,1:"")
    78         .I $G(BED)'="",BED'="NONE" S DDAT=BED
    79         .N BED
    80         .S BED=""
    81         .I $G(PXRMINP) D
    82         ..S BED=$G(^DPT(DFN,.101)) S:BED="" BED="NONE"
    83         ..S TXT=TXT_U_BED
    84         ..;Sort by bed
    85         ..I PXRMSRT="B" S DDAT=BED
    86         .;Duplicate check for combined report
    87         .I PXRMFCMB="Y",'$$NEW(NAM,DDAT,PNAM) Q
    88         .;I PXRMFCMB'="Y",PXRMLCMB="Y",'$$NEW^PXRMXSEO(NAM,DDAT,PNAM) Q
    89         .;Save entry in ^XTMP
    90         .S ^XTMP(PXRMXTMP,PX,FACILITY,NAM,DDAT,PNAM)=TXT
    91         .;Total of reminders overdue
    92         .N CNT
    93         .S CNT=$P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,2)
    94         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,2)=CNT+1
    95         ;Total of patients checked/applicable
    96         N CNT,NEW
    97         S NEW=1 I PXRMFCMB="Y" S NEW=$$NEWP(NAM,DFN)
    98         I NEW=1 D
    99         .S CNT=$P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,3)
    100         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,3)=CNT+1
    101         .S CNT=$P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,4)
    102         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,4)=CNT+APPL
    103         I PXRMFUT="Y"&($G(STATUS)["DUE NOW") D
    104         .N APPTARY,APPTDT,CIEN,CNT,NODE,SUB
    105         .S SUB="" I $D(^TMP($J,"PXRM FUTURE APPT",DFN))>0 S SUB="PXRM FUTURE APPT"
    106         .I SUB="",$D(^TMP($J,"SDAMA301",DFN))>0 S SUB="SDAMA301"
    107         .I SUB="" Q
    108         .S CNT=0
    109         .S CIEN=0 F  S CIEN=$O(^TMP($J,SUB,DFN,CIEN)) Q:CIEN'>0  D
    110         ..S APPTDT=0
    111         ..F  S APPTDT=$O(^TMP($J,SUB,DFN,CIEN,APPTDT)) Q:APPTDT'>0  D
    112         ...S NODE=$G(^TMP($J,SUB,DFN,CIEN,APPTDT))
    113         ...S APPTARY(APPTDT)=APPTDT_U_$P($P(NODE,U,2),";",2)_U_$P($P(NODE,U,22),";",2)
    114         .S APPTDT=0 F  S APPTDT=$O(APPTARY(APPTDT)) Q:APPTDT'>0  S CNT=CNT+1,^XTMP(PXRMXTMP,PX,FACILITY,NAM,DDAT,PNAM,CNT,0)=APPTARY(APPTDT)
    115         Q
    116         ;
    117 SUM(DFN,STATUS,FACILITY,NAM)    ;
    118         N DUE,EVAL
    119         S (DUE,EVAL)=0
    120         ;Add dues to totals of reminders due and reminders applicable
    121         I STATUS["DUE NOW" D
    122         .S DUE=1,EVAL=1
    123         ;Add any that aren't N/A, Ignore on N/A,ERROR or NEVER to applicable total
    124         S STATUS=$P(STATUS,U)
    125         I (STATUS'=" ")&(STATUS'["NEVER")&(STATUS'="N/A")&(STATUS'["ERROR")&(STATUS'["CNBD") S EVAL=1
    126         ;Update XTMP - Total of reminders due
    127         I "IR"[PXRMTOT D
    128         .;Combined facility duplicate check
    129         .I PXRMFCMB="Y",'$$NEW(NAM,DFN,ITEM) Q
    130         .N CNT
    131         .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM)),U,1)
    132         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM),U,1)=CNT+EVAL
    133         .;Total of reminders evaluated
    134         .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM)),U,2)
    135         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM),U,2)=CNT+DUE
    136         ;
    137         ;Totals
    138         I "RT"[PXRMTOT D
    139         .;Check for duplicate patient at FACILITY level
    140         .I $D(^TMP("PXRMDUP",$J,FACILITY,DFN,ITEM)) Q
    141         .;Set duplicate check
    142         .S ^TMP("PXRMDUP",$J,FACILITY,DFN,ITEM)=""
    143         .I $G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL"))="" D
    144         ..S ^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL")="TOTAL"
    145         .N CNT
    146         .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM)),U,1)
    147         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM),U,1)=CNT+EVAL
    148         .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM)),U,2)
    149         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM),U,2)=CNT+DUE
    150         ;
    151         ;Total of patients
    152         I "IR"[PXRMTOT D
    153         .I PXRMSEL="I",$$NEWIP(DFN)<1 Q
    154         .I $$NEWP(@SUB,DFN)=0 Q
    155         .I $G(^XTMP(PXRMXTMP,PX,FACILITY,@SUB))="" S ^XTMP(PXRMXTMP,PX,FACILITY,@SUB)=NAM
    156         .N CNT S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,@SUB)),U,3)
    157         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,@SUB),U,3)=CNT+1
    158         ;
    159         ;Total reports
    160         I "TR"[PXRMTOT D
    161         .I '$$NEWT(FACILITY,DFN) Q
    162         .I $G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL"))="" D
    163         ..S ^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL")=NAM
    164         .N CNT
    165         .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL")),U,3)
    166         .S $P(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL"),U,3)=CNT+1
    167         Q
    168         ;
    169 ERRMSG(TYPE)    ;
    170         N CNT,CNT1,CNT2,STR,NLINES,OUTPUT,TIME
    171         K ^TMP("PXRMXMZ",$J)
    172         S NLINES=0,CNT=0,CNT1=2
    173         I TYPE="C" D  Q
    174         .M ^TMP("PXRMXMZ",$J)=^TMP($J,"PXRM CNBD")
    175         .D SEND^PXRMMSG("REMINDER REPORTS CNBD PATIENT LIST ("_$$FMTE^XLFDT($$NOW^XLFDT)_")",1)
    176         I 'PXRMQUE D
    177         .S STR(1)="The Reminders Due Report "_$G(TITLE)_" requested by "_$$GET1^DIQ(200,DUZ,.01)_" on "_$$FMTE^XLFDT($G(PXRMXST))_" for the following reason(s):"
    178         .F  S CNT=$O(DBERR(CNT)) Q:CNT'>0  S STR(CNT1)="\\"_DBERR(CNT),CNT1=CNT1+1
    179         .D FORMAT^PXRMTEXT(1,80,2,.STR,.NLINES,.OUTPUT)
    180         .F CNT=1:1:NLINES W !,OUTPUT(CNT)
    181         I PXRMQUE D
    182         .S ^TMP("PXRMXMZ",$J,1,0)="The Reminders Due Report "_$G(TITLE)_" requested by "_$$GET1^DIQ(200,DUZ,.01)_" on "_$$FMTE^XLFDT($G(PXRMXST))_"was cancelled for the following reason(s):"
    183         .F  S CNT=$O(DBERR(CNT)) Q:CNT'>0  S ^TMP("PXRMXMZ",$J,CNT1,0)=DBERR(CNT),CNT1=CNT1+1
    184         .D SEND^PXRMMSG("Cancelled Reminders Due Report ("_$$FMTE^XLFDT($$NOW^XLFDT)_")",1)
    185         .S ZTSTOP=1
    186         Q
     1PXRMXDT1 ; SLC/PJH - Build Patient list SUBROUTINES;07/10/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called by label from PXRMXSEO,PXRMXSE
     5 ;
     6 ;Combined report duplicate check (Summary report)
     7NEW(SUB,SUB1,SUB2) ;
     8 ;Existing entry
     9 I $D(^TMP("PXRMCMB",$J,SUB,SUB1,SUB2)) Q 0
     10 ;New entry
     11 S ^TMP("PXRMCMB",$J,SUB,SUB1,SUB2)=""
     12 Q 1
     13 ;
     14 ;Individual patient report duplicate patient check
     15NEWIP(DFN) ;
     16 ;Existing entry
     17 I $D(^TMP("PXRMCMB3",$J,DFN)) Q 0
     18 ;New entry
     19 S ^TMP("PXRMCMB3",$J,DFN)=""
     20 Q 1
     21 ;Combined report duplicate check (Detail report)
     22NEWP(SUB,DFN) ;
     23 ;Existing entry
     24 I $D(^TMP("PXRMCMB1",$J,SUB,DFN)) Q 0
     25 ;New entry
     26 S ^TMP("PXRMCMB1",$J,SUB,DFN)=""
     27 Q 1
     28 ;
     29 ;Combined report duplicate check (Patient totals)
     30NEWT(FACILITY,DFN) ;
     31 ;Existing entry
     32 I $D(^TMP("PXRMCMB2",$J,FACILITY,DFN)) Q 0
     33 ;New entry
     34 S ^TMP("PXRMCMB2",$J,FACILITY,DFN)=""
     35 Q 1
     36 ;
     37 ;Detailed report
     38SDET(DFN,STATUS,NAM,FACILITY,INP) ;
     39 I $G(^XTMP(PXRMXTMP,PX,FACILITY,NAM))="" D
     40 .S ^XTMP(PXRMXTMP,PX,FACILITY,NAM)=NAM
     41 ;Applicable
     42 S DDAT="N/A"
     43 N APPL,FAPPTDT,DEFARR,DNEXT,DNEXT1,FIEV,PXRMDATE,BID,TMPSUB
     44 S APPL=0,FAPPTDT=0
     45 ;Add any that aren't N/A, Ignore on N/A or NEVER to applicable total
     46 I ($P(STATUS,U)'="")&(STATUS'["NEVER")&(STATUS'["N/A")&(STATUS'["ERROR")&(STATUS'["CNBD") S APPL=1
     47 ;If DUE NOW save details
     48 I $G(STATUS)'["DUE NOW" S PNAM=" "
     49 I $G(STATUS)["DUE NOW" D
     50 .N BED
     51 .S DDUE=$P($G(STATUS),U,2)
     52 .S DLAST=$P($G(STATUS),U,3)
     53 .;Demographics
     54 .S PNAM=$P($G(^DPT(DFN,0)),U),BID=$P($G(^DPT(DFN,0)),U,9)
     55 .I PNAM="" S PNAM=" "
     56 .E  S PNAM=PNAM_U_BID
     57 .;Next appointment for location or clinic
     58 .;For detailed provider report get next appoint. for assoc. clinic
     59 .S DNEXT=""
     60 .I PXRMSEL="L"!(PXRMSEL="P") S TMPSUB="PXRM FUTURE APPT"
     61 .E  S TMPSUB="SDAMA301"
     62 .I PXRMFCMB="Y",PXRMLCMB="Y",$D(^TMP($J,TMPSUB,DFN))>0 D
     63 ..N APPTCNT,LOC
     64 ..S LOC=0,APPTCNT=0
     65 ..F  S LOC=$O(^TMP($J,TMPSUB,DFN,LOC)) Q:(LOC'>0)!(APPTCNT=1)  D
     66 ...S DNEXT=$O(^TMP($J,TMPSUB,DFN,LOC,"")) I +DNEXT>0 S APPTCNT=1 Q
     67 .S DNEXT=$O(^TMP($J,TMPSUB,DFN,$G(INP),""))
     68 .I PXRMFCMB="N",PXRMLCMB="Y" D
     69 ..S DNEXT1=$O(^TMP($J,"PXRM FACILITY FUTURE APPT",DFN,FACILITY,"")) Q:DNEXT1'>0
     70 ..I +DNEXT=0!(DNEXT>DNEXT1) S DNEXT=DNEXT1
     71 .S BED=$G(^DPT(DFN,.101)) S:BED="" BED="NONE"
     72 .;Sort by next appointment date
     73 .I PXRMSRT="Y" S DDAT=$P(DNEXT,".") S:DDAT="" DDAT="NONE"
     74 .;Patient ward/bed used only for inpatient reports
     75 .I PXRMFUT="Y" S DNEXT=""
     76 .N TXT
     77 .S TXT=DFN_U_DDUE_U_DLAST_U_$G(DNEXT)_$S($G(BED)'="":U_BED,1:"")
     78 .I $G(BED)'="",BED'="NONE" S DDAT=BED
     79 .N BED
     80 .S BED=""
     81 .I $G(PXRMINP) D
     82 ..S BED=$G(^DPT(DFN,.101)) S:BED="" BED="NONE"
     83 ..S TXT=TXT_U_BED
     84 ..;Sort by bed
     85 ..I PXRMSRT="B" S DDAT=BED
     86 .;Duplicate check for combined report
     87 .I PXRMFCMB="Y",'$$NEW(NAM,DDAT,PNAM) Q
     88 .;I PXRMFCMB'="Y",PXRMLCMB="Y",'$$NEW^PXRMXSEO(NAM,DDAT,PNAM) Q
     89 .;Save entry in ^XTMP
     90 .S ^XTMP(PXRMXTMP,PX,FACILITY,NAM,DDAT,PNAM)=TXT
     91 .;Total of reminders overdue
     92 .N CNT
     93 .S CNT=$P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,2)
     94 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,2)=CNT+1
     95 ;Total of patients checked/applicable
     96 N CNT,NEW
     97 S NEW=1 I PXRMFCMB="Y" S NEW=$$NEWP(NAM,DFN)
     98 I NEW=1 D
     99 .S CNT=$P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,3)
     100 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,3)=CNT+1
     101 .S CNT=$P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,4)
     102 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM),U,4)=CNT+APPL
     103 I PXRMFUT="Y"&($G(STATUS)["DUE NOW") D
     104 .N APPTARY,APPTDT,CIEN,CNT,NODE,SUB
     105 .S SUB="" I $D(^TMP($J,"PXRM FUTURE APPT",DFN))>0 S SUB="PXRM FUTURE APPT"
     106 .I SUB="",$D(^TMP($J,"SDAMA301",DFN))>0 S SUB="SDAMA301"
     107 .I SUB="" Q
     108 .S CNT=0
     109 .S CIEN=0 F  S CIEN=$O(^TMP($J,SUB,DFN,CIEN)) Q:CIEN'>0  D
     110 ..S APPTDT=0
     111 ..F  S APPTDT=$O(^TMP($J,SUB,DFN,CIEN,APPTDT)) Q:APPTDT'>0  D
     112 ...S NODE=$G(^TMP($J,SUB,DFN,CIEN,APPTDT))
     113 ...S APPTARY(APPTDT)=APPTDT_U_$P($P(NODE,U,2),";",2)_U_$P($P(NODE,U,22),";",2)
     114 .S APPTDT=0 F  S APPTDT=$O(APPTARY(APPTDT)) Q:APPTDT'>0  S CNT=CNT+1,^XTMP(PXRMXTMP,PX,FACILITY,NAM,DDAT,PNAM,CNT,0)=APPTARY(APPTDT)
     115 Q
     116 ;
     117SUM(DFN,STATUS,FACILITY,NAM) ;
     118 N DUE,EVAL
     119 S (DUE,EVAL)=0
     120 ;Add dues to totals of reminders due and reminders applicable
     121 I STATUS["DUE NOW" D
     122 .S DUE=1,EVAL=1
     123 ;Add any that aren't N/A, Ignore on N/A,ERROR or NEVER to applicable total
     124 S STATUS=$P(STATUS,U)
     125 I (STATUS'=" ")&(STATUS'["NEVER")&(STATUS'="N/A")&(STATUS'["ERROR")&(STATUS'["CNBD") S EVAL=1
     126 ;Update XTMP - Total of reminders due
     127 I "IR"[PXRMTOT D
     128 .;Combined facility duplicate check
     129 .I PXRMFCMB="Y",'$$NEW(NAM,DFN,ITEM) Q
     130 .N CNT
     131 .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM)),U,1)
     132 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM),U,1)=CNT+EVAL
     133 .;Total of reminders evaluated
     134 .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM)),U,2)
     135 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,NAM,ITEM),U,2)=CNT+DUE
     136 ;
     137 ;Totals
     138 I "RT"[PXRMTOT D
     139 .;Check for duplicate patient at FACILITY level
     140 .I $D(^TMP("PXRMDUP",$J,FACILITY,DFN,ITEM)) Q
     141 .;Set duplicate check
     142 .S ^TMP("PXRMDUP",$J,FACILITY,DFN,ITEM)=""
     143 .I $G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL"))="" D
     144 ..S ^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL")="TOTAL"
     145 .N CNT
     146 .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM)),U,1)
     147 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM),U,1)=CNT+EVAL
     148 .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM)),U,2)
     149 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL",ITEM),U,2)=CNT+DUE
     150 ;
     151 ;Total of patients
     152 I "IR"[PXRMTOT D
     153 .I PXRMSEL="I",$$NEWIP(DFN)<1 Q
     154 .I $$NEWP(@SUB,DFN)=0 Q
     155 .I $G(^XTMP(PXRMXTMP,PX,FACILITY,@SUB))="" S ^XTMP(PXRMXTMP,PX,FACILITY,@SUB)=NAM
     156 .N CNT S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,@SUB)),U,3)
     157 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,@SUB),U,3)=CNT+1
     158 ;
     159 ;Total reports
     160 I "TR"[PXRMTOT D
     161 .I '$$NEWT(FACILITY,DFN) Q
     162 .I $G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL"))="" D
     163 ..S ^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL")=NAM
     164 .N CNT
     165 .S CNT=$P($G(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL")),U,3)
     166 .S $P(^XTMP(PXRMXTMP,PX,FACILITY,"TOTAL"),U,3)=CNT+1
     167 Q
     168 ;
     169DBDOWN(TYPE) ;
     170 N CNT,CNT1,CNT2,STR,NLINES,OUTPUT,TIME
     171 K ^TMP("PXRMXMZ",$J)
     172 S NLINES=0,CNT=0,CNT1=2
     173 I TYPE="C" D  Q
     174 .M ^TMP("PXRMXMZ",$J)=^TMP($J,"PXRM CNBD")
     175 .D SEND^PXRMMSG("COULD NOT BE DETERMINED PATIENTS("_$$FMTE^XLFDT($$NOW^XLFDT)_")",1)
     176 I 'PXRMQUE D
     177 .S STR(1)="The Reminders Due Report "_$G(TITLE)_" requested by "_$$GET1^DIQ(200,DUZ,.01)_" on "_$$FMTE^XLFDT($G(PXRMXST))_" for the following reason(s):"
     178 .F  S CNT=$O(DBERR(CNT)) Q:CNT'>0  S STR(CNT1)="\\"_DBERR(CNT),CNT1=CNT1+1
     179 .D FORMAT^PXRMTEXT(1,80,2,.STR,.NLINES,.OUTPUT)
     180 .F CNT=1:1:NLINES W !,OUTPUT(CNT)
     181 I PXRMQUE D
     182 .S ^TMP("PXRMXMZ",$J,1,0)="The Reminders Due Report "_$G(TITLE)_" requested by "_$$GET1^DIQ(200,DUZ,.01)_" on "_$$FMTE^XLFDT($G(PXRMXST))_" for the following reason(s):"
     183 .F  S CNT=$O(DBERR(CNT)) Q:CNT'>0  S ^TMP("PXRMXMZ",$J,CNT1,0)=DBERR(CNT),CNT1=CNT1+1
     184 .D SEND^PXRMMSG("Cancelled Reminders Due Report("_$$FMTE^XLFDT($$NOW^XLFDT)_")",1)
     185 .S ZTSTOP=1
     186 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXGPR.m

    r613 r623  
    1 PXRMXGPR        ; SLC/PJH - Reminder Due print calls ;11/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Called from PXRMXPR
    5         ;
    6         ;Print Selection criteria
    7 HEAD(PSTART)    ;
    8         I SUB="TOTAL" N NAM S NAM="TOTAL REPORT"
    9         I PXRMTABS="Y" D  Q
    10         .N FFAC,FNAM
    11         .S FNAM=NAM
    12         .I "CES"[PXRMTABC S FNAM=$TR(FNAM,SEP,"_")
    13         .I PXRMFCMB="N","LT"[PXRMSEL D  Q
    14         ..S FFAC=$TR(FACPNAME,SEP,"_")
    15         ..W !,"0"_SEP_FFAC_"_"_FNAM_SEP_SEP
    16         .I PXRMFCMB="N","LT"'[PXRMSEL W !,"0"_SEP_FNAM_SEP_SEP Q
    17         .I PXRMFCMB="Y" W !,"0"_SEP_"COMBINED_REPORT_"_FNAM_SEP_SEP Q
    18         I "LT"[PXRMSEL D
    19         .I PXRMFCMB="N" W !,?PSTART,"Facility: ",FACPNAME Q
    20         .W !,?PSTART,"Combined Report: "
    21         .N FACN,LENGTH,TEXT
    22         .S FACN=0,LENGTH=17+PSTART
    23         .F  S FACN=$O(PXRMFACN(FACN)) Q:'FACN  D
    24         ..S TEXT=$P(PXRMFACN(FACN),U)_" ("_FACN_")"
    25         ..I $O(PXRMFACN(FACN)) S TEXT=TEXT_", "
    26         ..I (LENGTH+$L(TEXT))>80 S LENGTH=17+PSTART W !,?(17+PSTART)
    27         ..W TEXT S LENGTH=LENGTH+$L(TEXT)
    28         I "PTO"[PXRMSEL D
    29         .I SUB="TOTAL" W !,?PSTART,NAM Q
    30         .W !,?PSTART,"Reminders "_PXRMTX_" for ",NAM
    31         I PXRMSEL="L" W !,?PSTART,"Reminders "_PXRMTX_" "_SD_" - ",NAM
    32         I PXRMSEL="L" D
    33         .I "PF"[PXRMFD W " for ",BD," to ",ED
    34         .I PXRMFD="A" W " admissions from ",BD," to ",ED
    35         .I PXRMFD="C" W " for current inpatients"
    36         I PXRMSEL'="L" W " for ",SD
    37         W:PXRMSEL="I" !
    38         ;
    39         Q
    40         ;
    41         ;Output the provider report criteria
    42 CRIT(PSTART,PLSTCRIT)   ;
    43         N CNT,RCCNT,RCDES,RICNT,RIDES,UNDL
    44         S CNT=0
    45         S UNDL=$TR($J("",79)," ","_") D LITS^PXRMXPR1
    46         S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART-8)_"Report Criteria:",CNT=CNT+1
    47         I PXRMTMP'="" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Report Title:",22)_$P(PXRMTMP,U,3),CNT=CNT+1
    48         S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Patient Sample:",22)_PXRMFLD,CNT=CNT+1
    49         I PXRMSEL'="L" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR(PXRMFLD_":",22) D DISP(.CNT,.PLSTCRIT)
    50         I PXRMSEL="L" D
    51         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR(PXRMFLD_":",22)_DES,CNT=CNT+1
    52         .I $E(PXRMLCSC,2)'="A" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",10) D DISP(.CNT,.PLSTCRIT)
    53         I $D(PXRMRCAT) D
    54         .S RCCNT=0
    55         .F  S RCCNT=$O(PXRMRCAT(RCCNT)) Q:'RCCNT  D
    56         ..S RCDES=$P(PXRMRCAT(RCCNT),U,2)
    57         ..I RCCNT=1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Reminder Category:",22)_RCDES_U_6,CNT=CNT+1
    58         ..I RCCNT>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",22)_RCDES
    59         .S RICNT=0
    60         .F  S RICNT=$O(PXRMREM(RICNT)) Q:'RICNT  D
    61         ..S RIDES=$P(PXRMREM(RICNT),U,2)
    62         ..I RICNT=1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Individual Reminder:",22)_RIDES_U_6,CNT=CNT+1
    63         ..I RICNT>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",22)_RIDES,CNT=CNT+1
    64         S PLSTCRIT(CNT)=U_6,CNT=CNT+1
    65         I PXRMREP="D" D
    66         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Reminder:",22)_RDES,CNT=CNT+1
    67         .;Display future appointments for Reminder Due report only
    68         .I PXRMRT="PXRMX" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_"Appointments:" D
    69         ..I PXRMFUT="Y" S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$$LJ^XLFSTR(" ",32-$L(PLSTCRIT(CNT)))_"All Future Appointments",CNT=CNT+1
    70         ..I PXRMFUT="N" S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$$LJ^XLFSTR(" ",32-$L(PLSTCRIT(CNT)))_"Next Appointment only",CNT=CNT+1
    71         I PXRMSEL="P" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("All/Primary:",22)_CDES,CNT=CNT+1
    72         I PXRMSEL="L" D  S CNT=CNT+1
    73         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Date Range:",22)
    74         .I "PAF"[PXRMFD S PLSTCRIT(CNT)=PLSTCRIT(CNT)_BD_" to "_ED Q
    75         .I PXRMFD="C" S PLSTCRIT(CNT)=PLSTCRIT(CNT)_"not applicable" Q
    76         S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Effective Due Date:",22)_SD,CNT=CNT+1
    77         S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Date run:",22)_RD,CNT=CNT+1
    78         I PXRMTMP'="" D
    79         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Template Name:",22)_$P(PXRMTMP,U,2),CNT=CNT+1
    80         .I PXRMUSER S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Requested by:",22)_$$GET1^DIQ(200,DUZ,.01)_U_3,CNT=CNT+1
    81         I (PXRMFCMB="Y")!(PXRMLCMB="Y")!(PXRMTCMB="Y") D
    82         .N LIT,TEXT
    83         .S LIT=$S(PXRMSEL="P":"Providers","OT"[PXRMSEL:"Teams",1:"Locations")
    84         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Combined report:",22)
    85         .I PXRMFCMB="Y",PXRMLCMB="Y" S TEXT="Combined Facility and Combined "_LIT
    86         .I PXRMFCMB="Y",PXRMLCMB="N" S TEXT="Combined Facility by Individual "_LIT
    87         .I PXRMLCMB="Y",PXRMFCMB="N" S TEXT="Combined "_LIT
    88         .I PXRMTCMB="Y" S TEXT="Combined "_LIT
    89         .S PLSTCRIT(CNT)=PLSTCRIT(CNT)_TEXT,CNT=CNT+1
    90         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    91         I PXRMREP="S","IRT"[PXRMTOT,"IR"'[PXRMSEL D
    92         .N LIT1,LIT2,LIT3,TEXT
    93         .D LIT^PXRMXD
    94         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Summary report:",22)
    95         .I PXRMTOT="I" S TEXT=LIT1
    96         .I PXRMTOT="R" S TEXT=LIT2
    97         .I PXRMTOT="T" S TEXT=LIT3
    98         .S PLSTCRIT(CNT)=PLSTCRIT(CNT)_TEXT,CNT=CNT+1
    99         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    100         I $D(PXRMSCAT),PXRMSCAT]"",PXRMFD="P" D OSCAT(PXRMSCAT,PSTART,.CNT,.PLSTCRIT)
    101         N CHECK,CNT,NODE,STR
    102         S CNT=0 F  S CNT=$O(PLSTCRIT(CNT)) Q:CNT'>0  D
    103         .S NODE=$G(PLSTCRIT(CNT)),CHECK=$P(NODE,U,2),STR=$P(NODE,U)
    104         .I CHECK>0 D CHECK(CHECK) I STR="" Q
    105         .W !,STR
    106         W !,UNDL,!
    107         Q
    108         ;
    109         ;Display selected teams/providers
    110 DISP(CNT,PLSTCRIT)      ;
    111         N IC
    112         S IC=""
    113         I PXRMSEL="P" F  S IC=$O(PXRMPRV(IC)) Q:IC=""  D
    114         .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMPRV(IC),U,2),CNT=CNT+1
    115         .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMPRV(IC),U,2),CNT=CNT+1
    116         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    117         I PXRMSEL="T" F  S IC=$O(PXRMPCM(IC)) Q:IC=""  D
    118         .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMPCM(IC),U,2),CNT=CNT+1
    119         .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMPCM(IC),U,2),CNT=CNT+1
    120         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    121         I PXRMSEL="O" F  S IC=$O(PXRMOTM(IC)) Q:IC=""  D
    122         .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMOTM(IC),U,3),CNT=CNT+1
    123         .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMOTM(IC),U,2),CNT=CNT+1
    124         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    125         I PXRMSEL="I" F  S IC=$O(PXRMPAT(IC)) Q:IC=""  D
    126         .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMPAT(IC),U,2),CNT=CNT+1
    127         .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMPAT(IC),U,2),CNT=CNT+1
    128         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    129         I PXRMSEL="R" F  S IC=$O(PXRMLIST(IC)) Q:IC=""  D
    130         .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMLIST(IC),U,2),CNT=CNT+1
    131         .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMLIST(IC),U,2),CNT=CNT+1
    132         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    133         I PXRMSEL="L" D
    134         .I $E(PXRMLCSC)="H" F  S IC=$O(^XTMP(PXRMXTMP,"HLOC",IC)) Q:IC=""  D
    135         ..S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(^XTMP(PXRMXTMP,"HLOC",IC),U,2),CNT=CNT+1
    136         ..S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    137         .I $E(PXRMLCSC)="C" F  S IC=$O(PXRMCS(IC)) Q:IC=""  D
    138         ..S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMCS(IC),U,1)_" "_$P(PXRMCS(IC),U,3),CNT=CNT+1
    139         ..S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    140         .I $E(PXRMLCSC)="G" F  S IC=$O(PXRMCGRP(IC)) Q:IC=""  D
    141         ..S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMCGRP(IC),U,2),CNT=CNT+1
    142         ..S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    143         Q
    144         ;
    145         ;Output the service categories
    146 OSCAT(SCL,PSTART,CNT,PLSTCRIT)  ;
    147         N IC,CSTART,EM,SC,SCTEXT
    148         S CSTART=PSTART+3
    149         S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Service categories:",22)_SCL,CNT=CNT+1
    150         F IC=1:1:$L(SCL,",") D
    151         .S SC=$P(SCL,",",IC)
    152         .S SCTEXT=$$EXTERNAL^DILFD(9000010,.07,"",SC,.EM)
    153         .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
    154         .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",CSTART)_SC_" - "_SCTEXT,CNT=CNT+1
    155         Q
    156         ;
    157         ;If necessary, write the header
    158 COL(NEWPAGE)    ;
    159         I NEWPAGE D  Q:DONE
    160         .I PXRMTABS="N" D PAGE
    161         .I PXRMTABS="Y" W !!
    162         D CHECK(0) Q:DONE
    163         D HEAD(0)
    164         S HEAD=0
    165         I PXRMTABS="Y" Q
    166         I PXRMREP="D" D
    167         .N PNAM
    168         .S PNAM=$P(PXRMREM(1),U,4) I PNAM="" S PNAM=$P(PXRMREM(1),U,2)
    169         .W !!,PNAM,":  ",COUNT
    170         .W:COUNT>1 " patients have the reminder "_PXRMTX
    171         .W:COUNT=1 " patient has the reminder "_PXRMTX
    172         N IC F IC=0:1:2 W !,?PXRMT(IC),PXRMH(IC)
    173         Q
    174         ;
    175         ;form feed to new page
    176 PAGE    I ($E(IOST,1,2)="C-")&(IO=IO(0))&(PAGE>0) D
    177         .S DIR(0)="E"
    178         .W !
    179         .D ^DIR K DIR
    180         I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
    181         W:$D(IOF)&(PAGE>0) @IOF
    182         S PAGE=PAGE+1,FIRST=0
    183         I $E(IOST,1,2)="C-",IO=IO(0) W @IOF
    184         E  W !
    185         N TEMP,TEXTLEN
    186         S TEMP=$$NOW^XLFDT,TEMP=$$FMTE^XLFDT(TEMP,"P")
    187         S TEMP=TEMP_"  Page "_PAGE
    188         S TEXTLEN=$L(TEMP)
    189         W ?(IOM-TEXTLEN),TEMP
    190         S TEXTLEN=$L(PXRMOPT)
    191         I TEXTLEN>0 D
    192         .W !!
    193         .W ?((IOM-TEXTLEN)/2),PXRMOPT
    194         Q
    195         ;
    196         ;count of patients in sample
    197 TOTAL   N LIT
    198         I PXRMTABS="Y" D  Q
    199         .I PXRMREP="D" W !,"0"_SEP_"PATIENTS"_SEP_TOTAL_SEP_"APPLICABLE"_SEP_APPL Q
    200         .I PXRMREP="S" W !,"0"_SEP_"PATIENTS"_SEP_TOTAL_SEP_SEP_$TR(SUB,SEP,"_") Q
    201         I (PXRMRT="PXRMX")!(PXRMREP="S") W !
    202         ;S LIT=" patient."
    203         ;I TOTAL>1 S LIT=" patients."
    204         S LIT=$S(TOTAL=0:" patients.",TOTAL=1:" patient.",1:" patients.")
    205         W !,"Report run on "_TOTAL_LIT
    206         I PXRMREP="D" D
    207         .S LIT=$S(APPL=0:" patients.",APPL=1:" patient.",1:" patients.")
    208         .W !,"Applicable to "_APPL_LIT
    209         Q
    210         ;
    211         ;Null report prints if no patients found
    212 NULL    I PXRMSEL="L" D
    213         .I PXRMFD="P" W !!,"No patient visits found"
    214         .I PXRMFD="A" W !!,"No patient admissions found"
    215         .I PXRMFD="C" W !!,"No current inpatient found"
    216         .I PXRMFD="F" W !!,"No patient appointments found"
    217         I PXRMSEL="P" W !!,"No patients found for provider(s) selected"
    218         I "OT"[PXRMSEL W !!,"No patients found for team(s) selected"
    219         Q
    220         ;
    221         ;Null report if no patients due/satisfied - detailed report only
    222 NONE    D PAGE
    223         D HEAD(0)
    224         W !!,"No patients with reminders "_PXRMTX
    225         Q
    226         ;
    227 SPACER(TEXT,LENGTH)     ;
    228         Q
    229         ;
    230         ;Check for page throw
    231 CHECK(CNT)      ;
    232         I PXRMTABS="N",$Y>(IOSL-BMARG-CNT) D PAGE
    233         Q
     1PXRMXGPR ; SLC/PJH - Reminder Due print calls ;01/09/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Called from PXRMXPR
     5 ;
     6 ;Print Selection criteria
     7HEAD(PSTART) ;
     8 I SUB="TOTAL" N NAM S NAM="TOTAL REPORT"
     9 I PXRMTABS="Y" D  Q
     10 .N FFAC,FNAM
     11 .S FNAM=NAM
     12 .I "CES"[PXRMTABC S FNAM=$TR(FNAM,SEP,"_")
     13 .I PXRMFCMB="N","LT"[PXRMSEL D  Q
     14 ..S FFAC=$TR(FACPNAME,SEP,"_")
     15 ..W !,"0"_SEP_FFAC_"_"_FNAM_SEP_SEP
     16 .I PXRMFCMB="N","LT"'[PXRMSEL W !,"0"_SEP_FNAM_SEP_SEP Q
     17 .I PXRMFCMB="Y" W !,"0"_SEP_"COMBINED_REPORT_"_FNAM_SEP_SEP Q
     18 I "LT"[PXRMSEL D
     19 .I PXRMFCMB="N" W !,?PSTART,"Facility: ",FACPNAME Q
     20 .W !,?PSTART,"Combined Report: "
     21 .N FACN,LENGTH,TEXT
     22 .S FACN=0,LENGTH=17+PSTART
     23 .F  S FACN=$O(PXRMFACN(FACN)) Q:'FACN  D
     24 ..S TEXT=$P(PXRMFACN(FACN),U)_" ("_FACN_")"
     25 ..I $O(PXRMFACN(FACN)) S TEXT=TEXT_", "
     26 ..I (LENGTH+$L(TEXT))>80 S LENGTH=17+PSTART W !,?(17+PSTART)
     27 ..W TEXT S LENGTH=LENGTH+$L(TEXT)
     28 I "PTO"[PXRMSEL D
     29 .I SUB="TOTAL" W !,?PSTART,NAM Q
     30 .W !,?PSTART,"Reminders "_PXRMTX_" for ",NAM
     31 I PXRMSEL="L" W !,?PSTART,"Reminders "_PXRMTX_" "_SD_" - ",NAM
     32 I PXRMSEL="L" D
     33 .I "PF"[PXRMFD W " for ",BD," to ",ED
     34 .I PXRMFD="A" W " admissions from ",BD," to ",ED
     35 .I PXRMFD="C" W " for current inpatients"
     36 I PXRMSEL'="L" W " for ",SD
     37 W:PXRMSEL="I" !
     38 ;
     39 Q
     40 ;
     41 ;Output the provider report criteria
     42CRIT(PSTART,PLSTCRIT) ;
     43 N CNT,RCCNT,RCDES,RICNT,RIDES,UNDL
     44 S CNT=0
     45 S UNDL=$TR($J("",79)," ","_") D LITS^PXRMXPR1
     46 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART-8)_"Report Criteria:",CNT=CNT+1
     47 I PXRMTMP'="" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Report Title:",22)_$P(PXRMTMP,U,3),CNT=CNT+1
     48 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Patient Sample:",22)_PXRMFLD,CNT=CNT+1
     49 I PXRMSEL'="L" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR(PXRMFLD_":",22) D DISP(.CNT,.PLSTCRIT)
     50 I PXRMSEL="L" D
     51 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR(PXRMFLD_":",22)_DES,CNT=CNT+1
     52 .I $E(PXRMLCSC,2)'="A" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",10) D DISP(.CNT,.PLSTCRIT)
     53 I $D(PXRMRCAT) D
     54 .S RCCNT=0
     55 .F  S RCCNT=$O(PXRMRCAT(RCCNT)) Q:'RCCNT  D
     56 ..S RCDES=$P(PXRMRCAT(RCCNT),U,2)
     57 ..I RCCNT=1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Reminder Category:",22)_RCDES_U_6,CNT=CNT+1
     58 ..I RCCNT>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",22)_RCDES
     59 .S RICNT=0
     60 .F  S RICNT=$O(PXRMREM(RICNT)) Q:'RICNT  D
     61 ..S RIDES=$P(PXRMREM(RICNT),U,2)
     62 ..I RICNT=1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Individual Reminder:",22)_RIDES_U_6,CNT=CNT+1
     63 ..I RICNT>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",22)_RIDES,CNT=CNT+1
     64 S PLSTCRIT(CNT)=U_6,CNT=CNT+1
     65 I PXRMREP="D" D
     66 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Reminder:",22)_RDES,CNT=CNT+1
     67 .;Display future appointments for Reminder Due report only
     68 .I PXRMRT="PXRMX" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_"Appointments:" D
     69 ..I PXRMFUT="Y" S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$$LJ^XLFSTR(" ",32-$L(PLSTCRIT(CNT)))_"All Future Appointments",CNT=CNT+1
     70 ..I PXRMFUT="N" S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$$LJ^XLFSTR(" ",32-$L(PLSTCRIT(CNT)))_"Next Appointment only",CNT=CNT+1
     71 I PXRMSEL="P" S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("All/Primary:",22)_CDES,CNT=CNT+1
     72 I PXRMSEL="L" D  S CNT=CNT+1
     73 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Date Range:",22)
     74 .I "PAF"[PXRMFD S PLSTCRIT(CNT)=PLSTCRIT(CNT)_BD_" to "_ED Q
     75 .I PXRMFD="C" S PLSTCRIT(CNT)=PLSTCRIT(CNT)_"not applicable" Q
     76 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Effective Due Date:",22)_SD,CNT=CNT+1
     77 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Date run:",22)_RD,CNT=CNT+1
     78 I PXRMTMP'="" D
     79 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Template Name:",22)_$P(PXRMTMP,U,2),CNT=CNT+1
     80 .I PXRMUSER S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Requested by:",22)_$$GET1^DIQ(200,DUZ,.01)_U_3,CNT=CNT+1
     81 I (PXRMFCMB="Y")!(PXRMLCMB="Y")!(PXRMTCMB="Y") D
     82 .N LIT,TEXT
     83 .S LIT=$S(PXRMSEL="P":"Providers","OT"[PXRMSEL:"Teams",1:"Locations")
     84 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Combined report:",22)
     85 .I PXRMFCMB="Y",PXRMLCMB="Y" S TEXT="Combined Facility and Combined "_LIT
     86 .I PXRMFCMB="Y",PXRMLCMB="N" S TEXT="Combined Facility by Individual "_LIT
     87 .I PXRMLCMB="Y",PXRMFCMB="N" S TEXT="Combined "_LIT
     88 .I PXRMTCMB="Y" S TEXT="Combined "_LIT
     89 .S PLSTCRIT(CNT)=PLSTCRIT(CNT)_TEXT,CNT=CNT+1
     90 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     91 I PXRMREP="S","IRT"[PXRMTOT,"IR"'[PXRMSEL D
     92 .N LIT1,LIT2,LIT3,TEXT
     93 .D LIT^PXRMXD
     94 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Summary report:",22)
     95 .I PXRMTOT="I" S TEXT=LIT1
     96 .I PXRMTOT="R" S TEXT=LIT2
     97 .I PXRMTOT="T" S TEXT=LIT3
     98 .S PLSTCRIT(CNT)=PLSTCRIT(CNT)_TEXT,CNT=CNT+1
     99 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     100 I $D(PXRMSCAT),PXRMSCAT]"",PXRMFD="P" D OSCAT(PXRMSCAT,PSTART,.CNT,.PLSTCRIT)
     101 N CHECK,CNT,NODE,STR
     102 S CNT=0 F  S CNT=$O(PLSTCRIT(CNT)) Q:CNT'>0  D
     103 .S NODE=$G(PLSTCRIT(CNT)),CHECK=$P(NODE,U,2),STR=$P(NODE,U)
     104 .I CHECK>0 D CHECK(CHECK) I STR="" Q
     105 .W !,STR
     106 W !,UNDL,!
     107 Q
     108 ;
     109 ;Display selected teams/providers
     110DISP(CNT,PLSTCRIT) ;
     111 N IC
     112 S IC=""
     113 I PXRMSEL="P" F  S IC=$O(PXRMPRV(IC)) Q:IC=""  D
     114 .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMPRV(IC),U,2),CNT=CNT+1
     115 .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMPRV(IC),U,2),CNT=CNT+1
     116 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     117 I PXRMSEL="T" F  S IC=$O(PXRMPCM(IC)) Q:IC=""  D
     118 .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMPCM(IC),U,2),CNT=CNT+1
     119 .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMPCM(IC),U,2),CNT=CNT+1
     120 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     121 I PXRMSEL="O" F  S IC=$O(PXRMOTM(IC)) Q:IC=""  D
     122 .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMOTM(IC),U,3),CNT=CNT+1
     123 .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMOTM(IC),U,2),CNT=CNT+1
     124 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     125 I PXRMSEL="I" F  S IC=$O(PXRMPAT(IC)) Q:IC=""  D
     126 .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMPAT(IC),U,2),CNT=CNT+1
     127 .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMPAT(IC),U,2),CNT=CNT+1
     128 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     129 I PXRMSEL="R" F  S IC=$O(PXRMLIST(IC)) Q:IC=""  D
     130 .I IC=1 S PLSTCRIT(CNT)=PLSTCRIT(CNT)_$P(PXRMLIST(IC),U,2),CNT=CNT+1
     131 .I IC>1 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMLIST(IC),U,2),CNT=CNT+1
     132 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     133 I PXRMSEL="L" D
     134 .I $E(PXRMLCSC)="H" F  S IC=$O(^XTMP(PXRMXTMP,"HLOC",IC)) Q:IC=""  D
     135 ..S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(^XTMP(PXRMXTMP,"HLOC",IC),U,2),CNT=CNT+1
     136 ..S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     137 .I $E(PXRMLCSC)="C" F  S IC=$O(PXRMCS(IC)) Q:IC=""  D
     138 ..S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMCS(IC),U,1)_" "_$P(PXRMCS(IC),U,3),CNT=CNT+1
     139 ..S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     140 .I $E(PXRMLCSC)="G" F  S IC=$O(PXRMCGRP(IC)) Q:IC=""  D
     141 ..S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",32)_$P(PXRMCGRP(IC),U,2),CNT=CNT+1
     142 ..S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     143 Q
     144 ;
     145 ;Output the service categories
     146OSCAT(SCL,PSTART,CNT,PLSTCRIT) ;
     147 N IC,CSTART,EM,SC,SCTEXT
     148 S CSTART=PSTART+3
     149 S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",PSTART)_$$LJ^XLFSTR("Service categories:",22)_SCL,CNT=CNT+1
     150 F IC=1:1:$L(SCL,",") D
     151 .S SC=$P(SCL,",",IC)
     152 .S SCTEXT=$$EXTERNAL^DILFD(9000010,.07,"",SC,.EM)
     153 .S PLSTCRIT(CNT)=U_3,CNT=CNT+1
     154 .S PLSTCRIT(CNT)=$$RJ^XLFSTR(" ",CSTART)_SC_" - "_SCTEXT,CNT=CNT+1
     155 Q
     156 ;
     157 ;If necessary, write the header
     158COL(NEWPAGE) ;
     159 I NEWPAGE D  Q:DONE
     160 .I PXRMTABS="N" D PAGE
     161 .I PXRMTABS="Y" W !!
     162 D CHECK(0) Q:DONE
     163 D HEAD(0)
     164 S HEAD=0
     165 I PXRMTABS="Y" Q
     166 I PXRMREP="D" D
     167 .N PNAM
     168 .S PNAM=$P(PXRMREM(1),U,4) I PNAM="" S PNAM=$P(PXRMREM(1),U,2)
     169 .W !!,PNAM,":  ",COUNT
     170 .W:COUNT>1 " patients have the reminder "_PXRMTX
     171 .W:COUNT=1 " patient has the reminder "_PXRMTX
     172 N IC F IC=0:1:2 W !,?PXRMT(IC),PXRMH(IC)
     173 Q
     174 ;
     175 ;form feed to new page
     176PAGE I ($E(IOST)="C")&(IO=IO(0))&(PAGE>0) D
     177 .S DIR(0)="E"
     178 .W !
     179 .D ^DIR K DIR
     180 I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
     181 W:$D(IOF)&(PAGE>0) @IOF
     182 S PAGE=PAGE+1,FIRST=0
     183 I $E(IOST)="C",IO=IO(0) W @IOF
     184 E  W !
     185 N TEMP,TEXTLEN
     186 S TEMP=$$NOW^XLFDT,TEMP=$$FMTE^XLFDT(TEMP,"P")
     187 S TEMP=TEMP_"  Page "_PAGE
     188 S TEXTLEN=$L(TEMP)
     189 W ?(IOM-TEXTLEN),TEMP
     190 S TEXTLEN=$L(PXRMOPT)
     191 I TEXTLEN>0 D
     192 .W !!
     193 .W ?((IOM-TEXTLEN)/2),PXRMOPT
     194 Q
     195 ;
     196 ;count of patients in sample
     197TOTAL N LIT
     198 I PXRMTABS="Y" D  Q
     199 .I PXRMREP="D" W !,"0"_SEP_"PATIENTS"_SEP_TOTAL_SEP_"APPLICABLE"_SEP_APPL Q
     200 .I PXRMREP="S" W !,"0"_SEP_"PATIENTS"_SEP_TOTAL_SEP_SEP_$TR(SUB,SEP,"_") Q
     201 I (PXRMRT="PXRMX")!(PXRMREP="S") W !
     202 ;S LIT=" patient."
     203 ;I TOTAL>1 S LIT=" patients."
     204 S LIT=$S(TOTAL=0:" patients.",TOTAL=1:" patient.",1:" patients.")
     205 W !,"Report run on "_TOTAL_LIT
     206 I PXRMREP="D" D
     207 .S LIT=$S(APPL=0:" patients.",APPL=1:" patient.",1:" patients.")
     208 .W !,"Applicable to "_APPL_LIT
     209 Q
     210 ;
     211 ;Null report prints if no patients found
     212NULL I PXRMSEL="L" D
     213 .I PXRMFD="P" W !!,"No patient visits found"
     214 .I PXRMFD="A" W !!,"No patient admissions found"
     215 .I PXRMFD="C" W !!,"No current inpatient found"
     216 .I PXRMFD="F" W !!,"No patient appointments found"
     217 I PXRMSEL="P" W !!,"No patients found for provider(s) selected"
     218 I "OT"[PXRMSEL W !!,"No patients found for team(s) selected"
     219 Q
     220 ;
     221 ;Null report if no patients due/satisfied - detailed report only
     222NONE D PAGE
     223 D HEAD(0)
     224 W !!,"No patients with reminders "_PXRMTX
     225 Q
     226 ;
     227SPACER(TEXT,LENGTH) ;
     228 Q
     229 ;
     230 ;Check for page throw
     231CHECK(CNT) ;
     232 I PXRMTABS="N",$Y>(IOSL-BMARG-CNT) D PAGE
     233 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXGUT.m

    r613 r623  
    1 PXRMXGUT        ; SLC/PJH - General utilities for reminder reports; 11/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;=======================================
    5 EOR     ;End of report display.
    6         I $E(IOST,1,2)="C-",IO=IO(0) D
    7         . S DIR(0)="EA"
    8         . S DIR("A")="End of the report. Press ENTER/RETURN to continue..."
    9         . W !
    10         . D ^DIR K DIR
    11         Q
    12         ;
    13         ;=======================================
    14 EXIT    ;Clean things up.
    15         D ^%ZISC
    16         D HOME^%ZIS
    17         K IO("Q")
    18         K DIRUT,DTOUT,DUOUT,POP
    19         K ^TMP(PXRMXTMP)
    20         K ^XTMP(PXRMXTMP)
    21         K ^TMP("PXRMX",$J)
    22         K ^TMP($J,"PXRM PATIENT LIST")
    23         K ^TMP($J,"PXRM PATIENT EVAL")
    24         K ^TMP($J,"PXRM FUTURE APPT")
    25         K ^TMP($J,"PXRM FACILITY FUTURE APPT")
    26         K ^TMP($J,"SDAMA301")
    27         K ^TMP($J,"SORT")
    28         Q
    29         ;
    30         ;=======================================
    31 TIMING  ;Print report timing data.
    32         N IND
    33         W !!,"Report timing data:"
    34         S IND=""
    35         F  S IND=$O(^XTMP(PXRMXTMP,"TIMING",IND)) Q:IND=""  W !," ",^XTMP(PXRMXTMP,"TIMING",IND)
    36         Q
    37         ;
    38         ;=======================================
    39 USTRINS(STRING,CHAR)    ;Given a string, which is assumed to be in alphabetical
    40         ;order and a character which is not already in the string insert the
    41         ;character into the string in alphabetical order. For example:
    42         ;STRING CHAR RETURNS
    43         ;CEQ     A    ACEQ
    44         ;CEQ     E    CEQ
    45         ;CEQ     F    CEFQ
    46         ;CEQ     T    CEQT
    47         ;
    48         N CH1,CH2,DONE,IC,LEN,STR
    49         S LEN=$L(STRING)
    50         ;Special case of empty STRING.
    51         I LEN=0 Q CHAR
    52         ;
    53         S DONE=0
    54         S STR=""
    55         S CH1=$E(STRING,1,1)
    56         I (CH1]CHAR) S STR=STR_CHAR_CH1,DONE=1
    57         E  S STR=STR_CH1
    58         I CH1=CHAR S DONE=1
    59         ;
    60         ;Special case of STRING of length 1.
    61         I (LEN=1)&('DONE) S STR=STR_CHAR,DONE=1
    62         ;
    63         F IC=2:1:LEN D
    64         . S CH2=$E(STRING,IC,IC)
    65         . I DONE S STR=STR_CH2
    66         . E  D
    67         .. I (CHAR]CH1)&(CH2]CHAR) S STR=STR_CHAR_CH2,DONE=1
    68         .. E  S STR=STR_CH2
    69         .. I CH2=CHAR S DONE=1
    70         .. S CH1=CH2
    71         ;
    72         ;If we made it all the way through the loop and we are still not
    73         ;done then append CHAR.
    74         I ('DONE) S STR=STR_CHAR
    75         Q STR
    76         ;
    77         ;=======================================
    78 VLIST(SLIST,LIST,MESSAGE)       ;Make sure all the elements of LIST are in
    79         ;SLIST.  If they are, then LIST is valid.  The elements of LIST can be
    80         ;separated by commas and spaces.
    81         N IC,LE,LEN,VALID
    82         S LIST=$TR(LIST,",","")
    83         S LIST=$TR(LIST," ","")
    84         ;Make the test case insensitive.
    85         S SLIST=$$UP^XLFSTR(SLIST)
    86         S LIST=$$UP^XLFSTR(LIST)
    87         S VALID=1
    88         S LEN=$L(LIST)
    89         I LEN=0 D
    90         . W !,"The list is empty!"
    91         . S VALID=0
    92         F IC=1:1:LEN D
    93         . S LE=$E(LIST,IC,IC)
    94         . I SLIST'[LE D
    95         .. W !,LE,MESSAGE
    96         .. S VALID=0
    97         Q VALID
    98         ;
     1PXRMXGUT ; SLC/PJH - General utilities for reminder reports; 05/31/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;=======================================
     5EOR ;End of report display.
     6 I $E(IOST)="C",IO=IO(0) D
     7 . S DIR(0)="EA"
     8 . S DIR("A")="End of the report. Press ENTER/RETURN to continue..."
     9 . W !
     10 . D ^DIR K DIR
     11 Q
     12 ;
     13 ;=======================================
     14EXIT ;Clean things up.
     15 D ^%ZISC
     16 D HOME^%ZIS
     17 K IO("Q")
     18 K DIRUT,DTOUT,DUOUT,POP
     19 K ^TMP(PXRMXTMP)
     20 K ^XTMP(PXRMXTMP)
     21 K ^TMP("PXRMX",$J)
     22 K ^TMP($J,"PXRM PATIENT LIST")
     23 K ^TMP($J,"PXRM PATIENT EVAL")
     24 K ^TMP($J,"PXRM FUTURE APPT")
     25 K ^TMP($J,"PXRM FACILITY FUTURE APPT")
     26 K ^TMP($J,"SDAMA301")
     27 K ^TMP($J,"SORT")
     28 Q
     29 ;
     30 ;=======================================
     31VLIST(SLIST,LIST,MESSAGE) ;Make sure all the elements of LIST are in
     32 ;SLIST.  If they are, then LIST is valid.  The elements of LIST can be
     33 ;separated by commas and spaces.
     34 N IC,LE,LEN,VALID
     35 S LIST=$TR(LIST,",","")
     36 S LIST=$TR(LIST," ","")
     37 ;Make the test case insensitive.
     38 S SLIST=$$UP^XLFSTR(SLIST)
     39 S LIST=$$UP^XLFSTR(LIST)
     40 S VALID=1
     41 S LEN=$L(LIST)
     42 I LEN=0 D
     43 . W !,"The list is empty!"
     44 . S VALID=0
     45 F IC=1:1:LEN D
     46 . S LE=$E(LIST,IC,IC)
     47 . I SLIST'[LE D
     48 .. W !,LE,MESSAGE
     49 .. S VALID=0
     50 Q VALID
     51 ;
     52 ;=======================================
     53USTRINS(STRING,CHAR) ;Given a string, which is assumed to be in alphabetical
     54 ;order and a character which is not already in the string insert the
     55 ;character into the string in alphabetical order. For example:
     56 ;STRING CHAR RETURNS
     57 ;CEQ     A    ACEQ
     58 ;CEQ     E    CEQ
     59 ;CEQ     F    CEFQ
     60 ;CEQ     T    CEQT
     61 ;
     62 N CH1,CH2,DONE,IC,LEN,STR
     63 S LEN=$L(STRING)
     64 ;Special case of empty STRING.
     65 I LEN=0 Q CHAR
     66 ;
     67 S DONE=0
     68 S STR=""
     69 S CH1=$E(STRING,1,1)
     70 I (CH1]CHAR) S STR=STR_CHAR_CH1,DONE=1
     71 E  S STR=STR_CH1
     72 I CH1=CHAR S DONE=1
     73 ;
     74 ;Special case of STRING of length 1.
     75 I (LEN=1)&('DONE) S STR=STR_CHAR,DONE=1
     76 ;
     77 F IC=2:1:LEN D
     78 . S CH2=$E(STRING,IC,IC)
     79 . I DONE S STR=STR_CH2
     80 . E  D
     81 .. I (CHAR]CH1)&(CH2]CHAR) S STR=STR_CHAR_CH2,DONE=1
     82 .. E  S STR=STR_CH2
     83 .. I CH2=CHAR S DONE=1
     84 .. S CH1=CH2
     85 ;
     86 ;If we made it all the way through the loop and we are still not
     87 ;done then append CHAR.
     88 I ('DONE) S STR=STR_CHAR
     89 Q STR
     90 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXPR.m

    r613 r623  
    1 PXRMXPR ; SLC/PJH - Print Reminder Due report. ;11/27/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called/Jobbed after PXRMXSE1
    5         ;
    6 START   N BMARG,CRITERIA,C1S,C2S,C3S,C1HS,C2HS,C3HS,DONE,FIRST,HEAD
    7         N INDENT,PAGE,MOD,DES,ADES,CDES,RDES,SDES,MISSED,SEP
    8         N PLSTCRIT,PXRMOPT,PXRMFLD,PXRMHDR,PXRMHDRS,PXRMT,PXRMH
    9         N BD,ED,EMPCHK,SD,RD
    10         N PXRMTX
    11         S PXRMTX="due"
    12         ;
    13         I PXRMREP="D" D
    14         .S EMPCHK=$P($G(^PXRM(800,1,"TRUNCATE EMPLOYEE SSN")),U)
    15         .I EMPCHK="" S EMPCHK="Y"
    16         ;
    17         ; Format Date Range
    18         I PXRMSEL="L" D
    19         .S BD=$$FMTE^XLFDT(PXRMBDT,"5D")
    20         .S ED=$$FMTE^XLFDT(PXRMEDT,"5D")
    21         ; Format due effective date
    22         S SD=$$FMTE^XLFDT(PXRMSDT,"5P")
    23         ; Format run date
    24         S RD=$$FMTE^XLFDT(PXRMXST,"5P")
    25         ;
    26         U IO
    27         S DONE=0
    28         ;
    29         ;Delimited report.
    30         S SEP=$S(PXRMTABS="Y":PXRMTABC,1:"")
    31         ;
    32         ;Setup initial formatting parameters.
    33         S INDENT=3
    34         S BMARG=2,PAGE=0,HEAD=1
    35         ;
    36         I +$G(XQY)>0 N XQOPT D OP^XQCHK
    37         S PXRMOPT=$P($G(XQOPT),U,2)
    38         I ($L(PXRMOPT)>0)&(PXRMOPT'["Clinical") S PXRMOPT="Clinical "_PXRMOPT
    39         I PXRMREP="D" D
    40         .S RDES=$P(REMINDER(1),U,2)
    41         .S PXRMOPT=PXRMOPT_" - Detailed Report"
    42         .N IC F IC=0,3,4 S PXRMH(IC)="",PXRMT(IC)=0
    43         .S PXRMH(1)="Date Due    Last Done   Next Appt"
    44         .S PXRMH(2)="--------    ---------   ---------"
    45         .I $G(PXRMINP) D
    46         ..S PXRMH(1)="Date Due    Last Done   Ward/Bed"
    47         ..S PXRMH(2)="--------    ---------   --------"
    48         .F IC=1,2 S PXRMT(IC)=40
    49         .S ADES="Next Appointment only"
    50         .I PXRMFUT="Y" S ADES="All Future Appointments"
    51         .S SDES="Sorted by Patient Name"
    52         .I PXRMSRT="Y" S SDES="Sorted by Appointment Date"
    53         I PXRMREP="S" D
    54         .S PXRMOPT=PXRMOPT_" - Summary Report"
    55         .S PXRMH(0)="# Patients with Reminders",PXRMT(0)=50
    56         .S PXRMH(1)="Applicable           Due"
    57         .S PXRMH(2)="----------           ---"
    58         .N IC F IC=1,2 S PXRMT(IC)=50
    59         .S PXRMH(3)="Denominator"
    60         .S PXRMH(4)="-----------"
    61         .F IC=3,4 S PXRMT(IC)=0
    62         ;
    63         ;Print Criteria Page if normal report
    64         S CRITERIA=0 I PXRMTABS="N" S CRITERIA=1
    65         ;or delimited report with notemplate
    66         I PXRMTABS="Y",PXRMTMP="" S CRITERIA=1
    67         ;
    68         ;Build array of locations/providers with no patients selected in
    69         ;MISSED.
    70         D NOPATS^PXRMXPR1(.MISSED)
    71         ;
    72         ;Print either criteria page or summary header
    73         I CRITERIA D  G:DONE EXIT
    74         .D PAGE^PXRMXGPR Q:DONE
    75         .D CRIT^PXRMXGPR(10,.PLSTCRIT) Q:DONE
    76         ;Header if delimited output from a template
    77         I 'CRITERIA D
    78         .N HDR1,HDR2,HDR3
    79         .S HDR1="",HDR2="",HDR3=""
    80         .I PXRMTMP]"" S HDR1="TITLE:"_$P(PXRMTMP,U,2)_U_"TEMPLATE:"_$P(PXRMTMP,U,3)
    81         .I PXRMTMP="" D
    82         ..N PXRMFLD,DES,CDES D LITS^PXRMXPR1 S HDR1=PXRMFLD_U_$G(DES)_U_$G(CDES)
    83         .I PXRMSEL="L" S HDR2="START:"_BD_U_"END:"_ED
    84         .S HDR2=HDR2_U_"RUN:"_RD_"Effective Date:"_SD
    85         .I PXRMFCMB="Y" S HDR3="COMBINED FACILITY"
    86         .I PXRMLCMB="Y" S $P(HDR3,SEP,2)="COMBINED LOCATION"
    87         .I PXRMTCMB="Y" S $P(HDR3,SEP,2)="COMBINED OE/RR TEAMS"
    88         .I PXRMREP="S" D
    89         ..N LIT1,LIT2,LIT3
    90         ..D LIT^PXRMXD
    91         ..I PXRMTOT="I" S $P(HDR3,SEP,3)=$$UP^XLFSTR(LIT1)
    92         ..I PXRMTOT="R" S $P(HDR3,SEP,3)=$$UP^XLFSTR(LIT2)
    93         ..I PXRMTOT="T" S $P(HDR3,SEP,3)=$$UP^XLFSTR(LIT3)
    94         .S PLSTCRIT(1)=HDR1,PLSTCRIT(2)=HDR2,PLSTCRIT(3)=HDR3
    95         .W !,HDR1,!,HDR2,!,HDR3,!
    96         ;
    97         ;Kill items marked as found
    98         K ^XTMP(PXRMXTMP,"MARKED AS FOUND")
    99         ;
    100         ;Setup the final formatting parameters.
    101         S C1HS=INDENT+3
    102         S C1S=0
    103         S C2HS=C1S+2
    104         S C2S=C2HS
    105         S C3HS=C2HS+5
    106         S C3S=C3HS
    107         S HEAD=1
    108         S INDENT=10
    109         ;
    110         ; Update last run date
    111         I $G(PXRMTMP)'="" D UPD^PXRMXTU
    112         ;
    113         ; Get report detail from ^XTMP
    114         N PNAM,SUB,DFN,BID,NAM,FAC,MOD,SRT,TOTAL,APPL,FACPNAME,PX,TTOTAL
    115         S TTOTAL=0
    116         ; Set subroutine label from report format
    117         S MOD="SUMARY" I PXRMREP="D" S MOD="DETAIL"
    118         ;
    119         S FAC=0,PX="PXRM"
    120         F  S FAC=$O(^XTMP(PXRMXTMP,PX,FAC)) Q:FAC=""  Q:DONE  D
    121         .;Get facility name for Location and PCMM team report
    122         .I "TL"[PXRMSEL,PXRMFCMB="N" D
    123         ..S FACPNAME=$P(PXRMFACN(FAC),U,1)_"  "_$P(PXRMFACN(FAC),U,2)
    124         .;Report from ^XTMP - label MOD is DETAIL/SUMARY
    125         .S (PNAM,SUB,NAM,SRT)=""
    126         .I PXRMSEL="I" S SUB="INDIVIDUAL PATIENTS" D @MOD Q:DONE
    127         .I PXRMSEL'="I" D
    128         ..;Sort internal IENs into alpha order
    129         ..D XSORT
    130         ..F  S SRT=$O(^TMP($J,"SORT",SRT)) Q:SRT=""  Q:DONE  D
    131         ...S SUB=$G(^TMP($J,"SORT",SRT)) D @MOD
    132         ..I MOD="SUMARY","RT"[PXRMTOT S SUB="TOTAL" D @MOD
    133         ;
    134         ; Null report if no patients selected
    135         I ('DONE),$O(^XTMP(PXRMXTMP,PX,""))="" D NULL^PXRMXGPR G EXIT
    136         ; Report selected patient sample with no patients
    137         I $D(MISSED),PXRMPML=1 D MISSED^PXRMXPR1(0,.MISSED)
    138         ;
    139         ;Print Patient List
    140         I $G(PATLST)="Y" D FOOTER^PXRMXPR1(.PLSTCRIT)
    141         ;
    142         ;Print Error message
    143         I $D(^XTMP(PXRMXTMP,"ERROR"))>0!($D(^XTMP(PXRMXTMP,"CNBD"))>0) D ERROR^PXRMXBSY
    144 EXIT    ;
    145         D TIMING^PXRMXGUT
    146         D EXIT^PXRMXGUT
    147         ;
    148         ;Allow the task to be cleaned up upon successful completion.
    149         I $D(ZTQUEUED) S ZTREQ="@"
    150         ;
    151         D EOR^PXRMXGUT
    152         Q
    153         ;
    154         ;Report by Patient
    155 DETAIL  N JJ,VA,DATE,COUNT,DDAT,EMP
    156         N BED,DDUE,DDONE,DNEXT,FDAT1,FDAT2,FDAT3,FNAM,FTXT
    157         S NAM=$G(^XTMP(PXRMXTMP,PX,FAC,SUB)),HEAD=1
    158         S COUNT=$P(NAM,U,2),TOTAL=$P(NAM,U,3),APPL=$P(NAM,U,4),NAM=$P(NAM,U,1)
    159         S DDAT="",JJ=0
    160         ; Get list of patients for each appointment date
    161         F  S DDAT=$O(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT)) Q:DDAT=""  Q:DONE  D PAT
    162         ; No patients due
    163         I JJ=0 D:'DONE NONE^PXRMXGPR
    164         ; Total patients
    165         D:'DONE TOTAL^PXRMXGPR
    166         S TTOTAL=TTOTAL+TOTAL
    167         Q
    168         ;
    169 PAT     ;Extract and print patient detail
    170         N DNEXT1,NODE,PNUM
    171         F  S PNAM=$O(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM)) Q:PNAM=""  Q:DONE  D
    172         .S JJ=JJ+1
    173         .;Format print line
    174         .S (BID,DNEXT1,FDAT1,FDAT2,FDAT3,DNEXT1)="" I PNAM'["No patients found" D
    175         ..S FDAT2="N/A",FDAT3="None"
    176         ..S NODE=$G(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM))
    177         ..S DDUE=$P(NODE,U,2),DDONE=$P(NODE,U,3),DNEXT=$P(NODE,U,4)
    178         ..S BED=$P(NODE,U,5)
    179         ..S DFN=$P(NODE,U) S BID=$P($G(PNAM),U,2)
    180         ..I PXRMSSN="N" S BID=$E(BID,6,9)
    181         ..I PXRMSSN="Y",EMPCHK="Y" D EMP S:EMP BID=$E(BID,6,9)
    182         ..S BID="("_BID_")"
    183         ..S FDAT1=$$FMTE^XLFDT(DDUE,"5D")
    184         ..I DDONE S FDAT2=$$FMTE^XLFDT(DDONE,"5D")
    185         ..I BED'="NONE" S FDAT3=$P(NODE,U,5),DNEXT1=$$FMTE^XLFDT(DNEXT,"5D")
    186         ..I DNEXT,FDAT3="None" S FDAT3=$$FMTE^XLFDT(DNEXT,"5D")
    187         .;Print
    188         .D CHECK Q:DONE
    189         .;Normal output
    190         .I PXRMTABS="N" D
    191         ..S PNUM=JJ#10000
    192         ..S PNUM=$$RJ^XLFSTR(PNUM,4)
    193         ..W !,PNUM,?5,$E($P($G(PNAM),U),1,33-$L(BID))," ",BID,?40,FDAT1,?52,FDAT2
    194         ..I ('$G(PXRMINP)),PXRMFUT'="Y" W ?64,$S(BED'="NONE":BED_" (Inp.)",1:FDAT3)
    195         ..I $G(PXRMINP) W ?64,BED
    196         ..I DNEXT1'="",PXRMFUT'="Y" W !,?64,DNEXT1
    197         .;Delimited report
    198         .I PXRMTABS="Y" D
    199         ..N FNAM
    200         ..S FNAM=$P($G(PNAM),U)
    201         ..I FNAM'["No patients found" S FNAM=$E(FNAM,1,33-$L(BID))_" "_BID
    202         ..I "CES"[PXRMTABC S FNAM=$TR(FNAM,SEP,"_"),FDAT1=$TR(FDAT1,SEP,"_")
    203         ..I BED="NONE" S BED=" "
    204         ..W !,JJ_SEP_FNAM_SEP_FDAT1_SEP_FDAT2 I $G(PXRMINP) W SEP_BED
    205         ..I ('$G(PXRMINP)),PXRMFUT'="Y" W SEP_FDAT3_SEP_BED
    206         .;---
    207         .; Future Appointments
    208         .I PXRMFUT="Y" D
    209         ..N CNT,ADAT,ALOC,ATYP,FIRST,NONE
    210         ..S CNT=0,NONE=1,FIRST=1
    211         ..I '$D(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM)) Q
    212         ..F  S CNT=$O(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT)) Q:CNT'>0  D
    213         ...S ADAT=$P(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT,0),U)
    214         ...I PXRMDLOC="Y" D
    215         ....S ALOC=$P(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT,0),U,2)
    216         ....S ATYP=$P(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT,0),U,3)
    217         ...S ADAT=$$FMTE^XLFDT(ADAT,"2P")
    218         ...I FIRST D  S FIRST=0,NONE=0
    219         ....I PXRMTABS="N" W ?64,$S(BED'="NONE":BED_" (Inp.)",1:"")
    220         ...D CHECK
    221         ...I PXRMDLOC="Y" D
    222         ....I PXRMTABS="N" W !,?8,ADAT,?30,$E(ALOC,1,25),?60,$E(ATYP,1,20)
    223         ....I PXRMTABS="Y" W SEP_ADAT_SEP_$E(ALOC,1,25)_SEP_$E(ATYP,1,20)
    224         ...I PXRMDLOC="N" D
    225         ....I PXRMTABS="N" W !,?10,ADAT
    226         ....I PXRMTABS="Y" W SEP_ADAT
    227         ..I NONE,PXRMTABS="N" W ?64,FDAT3
    228         ..I NONE,PXRMTABS="Y" W SEP_FDAT3
    229         ..I PXRMTABS="Y" W $S(BED'="NONE":SEP_BED_" (Inp.)",1:"")
    230         ..K ^UTILITY("VASD",$J)
    231         Q
    232         ;
    233         ;Summary by Reminder
    234 SUMARY  N JJ,EVAL,DUE,RNAM,RNUM,ITEM,COUNT,FTXT
    235         S NAM=$G(^XTMP(PXRMXTMP,PX,FAC,SUB)),HEAD=1
    236         S TOTAL=$P(NAM,U,3),COUNT=$P(NAM,U,2),NAM=$P(NAM,U,1)
    237         S RNUM=$O(REMINDER(""),-1)
    238         ;Get reminders in alpha order
    239         F JJ=1:1:RNUM D  Q:DONE
    240         .S ITEM=$P(REMINDER(JJ),U,1),RNAM=$P(REMINDER(JJ),U,4)
    241         .S:RNAM="" RNAM=$P(REMINDER(JJ),U,2)
    242         .; zero lines will be printed
    243         .S DUE=$G(^XTMP(PXRMXTMP,PX,FAC,SUB,ITEM))
    244         .S EVAL=+$P(DUE,U,1),DUE=+$P(DUE,U,2)
    245         .;Print
    246         .D CHECK Q:DONE
    247         .;Normal Report
    248         .I PXRMTABS="N" W !,JJ,?5,RNAM,?48,$J(EVAL,10),?63,$J(DUE,10)
    249         .;Condensed Report
    250         .I PXRMTABS="Y" D
    251         ..I "CES"[PXRMTABC S RNAM=$TR(RNAM,SEP,"_")
    252         ..W !,JJ_SEP_RNAM_SEP_EVAL_SEP_DUE_SEP_$TR(NAM,SEP,"_")
    253         D:'DONE TOTAL^PXRMXGPR
    254         I $G(SUB)'="TOTAL",PXRMTOT'="T" S TTOTAL=TTOTAL+TOTAL
    255         I $G(SUB)="TOTAL",PXRMTOT="T" S TTOTAL=TTOTAL+TOTAL
    256         Q
    257         ;
    258         ;Check line count before writing line
    259 CHECK   I ((PXRMTABS="N")&($Y>(IOSL-BMARG-3)))!(HEAD=1) D COL^PXRMXGPR(1)
    260         Q
    261         ;
    262         ;Check if employee
    263 EMP     N VAEL
    264         D ELIG^VADPT
    265         ;Check TYPE (#391) field
    266         I $P($G(VAEL(6)),U,2)="EMPLOYEE" S EMP=1 Q
    267         ;Check PATIENT ELIGABILITY (#361) field
    268         N ELIG
    269         S ELIG=0,EMP=0
    270         F  S ELIG=$O(VAEL(1,ELIG)) Q:'ELIG  D  Q:EMP
    271         .I $P($G(VAEL(1,ELIG)),U,2)="EMPLOYEE" S EMP=1
    272         Q
    273         ;
    274         ;Sort internal numbers into Alpha order
    275 XSORT   N SUB,NAM
    276         K ^TMP($J,"SORT")
    277         S SUB=""
    278         F  S SUB=$O(^XTMP(PXRMXTMP,PX,FAC,SUB)) Q:SUB=""  D
    279         .Q:SUB="TOTAL"
    280         .S NAM=$P(^XTMP(PXRMXTMP,PX,FAC,SUB),U)
    281         .I NAM="" S NAM=SUB
    282         .S ^TMP($J,"SORT",NAM)=SUB
    283         Q
    284         ;
     1PXRMXPR ; SLC/PJH - Print Reminder Due report. ;01/14/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called/Jobbed after PXRMXSE1
     5 ;
     6START N BMARG,CRITERIA,C1S,C2S,C3S,C1HS,C2HS,C3HS,DONE,FIRST,HEAD
     7 N INDENT,PAGE,MOD,DES,ADES,CDES,RDES,SDES,MISSED,SEP
     8 N PLSTCRIT,PXRMOPT,PXRMFLD,PXRMHDR,PXRMHDRS,PXRMT,PXRMH
     9 N BD,ED,EMPCHK,SD,RD
     10 N PXRMTX
     11 S PXRMTX="due"
     12 ;
     13 I PXRMREP="D" D
     14 .S EMPCHK=$P($G(^PXRM(800,1,"TRUNCATE EMPLOYEE SSN")),U)
     15 .I EMPCHK="" S EMPCHK="Y"
     16 ;
     17 ; Format Date Range
     18 I PXRMSEL="L" D
     19 .S BD=$$FMTE^XLFDT(PXRMBDT,"5D")
     20 .S ED=$$FMTE^XLFDT(PXRMEDT,"5D")
     21 ; Format due effective date
     22 S SD=$$FMTE^XLFDT(PXRMSDT,"5P")
     23 ; Format run date
     24 S RD=$$FMTE^XLFDT(PXRMXST,"5P")
     25 ;
     26 U IO
     27 S DONE=0
     28 ;
     29 ;Delimited report.
     30 S SEP=$S(PXRMTABS="Y":PXRMTABC,1:"")
     31 ;
     32 ;Setup initial formatting parameters.
     33 S INDENT=3
     34 S BMARG=2,PAGE=0,HEAD=1
     35 ;
     36 I +$G(XQY)>0 N XQOPT D OP^XQCHK
     37 S PXRMOPT=$P($G(XQOPT),U,2)
     38 I ($L(PXRMOPT)>0)&(PXRMOPT'["Clinical") S PXRMOPT="Clinical "_PXRMOPT
     39 I PXRMREP="D" D
     40 .S RDES=$P(REMINDER(1),U,2)
     41 .S PXRMOPT=PXRMOPT_" - Detailed Report"
     42 .N IC F IC=0,3,4 S PXRMH(IC)="",PXRMT(IC)=0
     43 .S PXRMH(1)="Date Due    Last Done   Next Appt"
     44 .S PXRMH(2)="--------    ---------   ---------"
     45 .I $G(PXRMINP) D
     46 ..S PXRMH(1)="Date Due    Last Done   Ward/Bed"
     47 ..S PXRMH(2)="--------    ---------   --------"
     48 .F IC=1,2 S PXRMT(IC)=40
     49 .S ADES="Next Appointment only"
     50 .I PXRMFUT="Y" S ADES="All Future Appointments"
     51 .S SDES="Sorted by Patient Name"
     52 .I PXRMSRT="Y" S SDES="Sorted by Appointment Date"
     53 I PXRMREP="S" D
     54 .S PXRMOPT=PXRMOPT_" - Summary Report"
     55 .S PXRMH(0)="# Patients with Reminders",PXRMT(0)=50
     56 .S PXRMH(1)="Applicable           Due"
     57 .S PXRMH(2)="----------           ---"
     58 .N IC F IC=1,2 S PXRMT(IC)=50
     59 .S PXRMH(3)="Denominator"
     60 .S PXRMH(4)="-----------"
     61 .F IC=3,4 S PXRMT(IC)=0
     62 ;
     63 ;Print Criteria Page if normal report
     64 S CRITERIA=0 I PXRMTABS="N" S CRITERIA=1
     65 ;or delimited report with notemplate
     66 I PXRMTABS="Y",PXRMTMP="" S CRITERIA=1
     67 ;
     68 ;Build array of locations/providers with no patients selected in
     69 ;MISSED.
     70 D NOPATS^PXRMXPR1(.MISSED)
     71 ;
     72 ;Print either criteria page or summary header
     73 I CRITERIA D  G:DONE EXIT
     74 .D PAGE^PXRMXGPR Q:DONE
     75 .D CRIT^PXRMXGPR(10,.PLSTCRIT) Q:DONE
     76 ;Header if delimited output from a template
     77 I 'CRITERIA D
     78 .N HDR1,HDR2,HDR3
     79 .S HDR1="",HDR2="",HDR3=""
     80 .I PXRMTMP]"" S HDR1="TITLE:"_$P(PXRMTMP,U,2)_U_"TEMPLATE:"_$P(PXRMTMP,U,3)
     81 .I PXRMTMP="" D
     82 ..N PXRMFLD,DES,CDES D LITS^PXRMXPR1 S HDR1=PXRMFLD_U_$G(DES)_U_$G(CDES)
     83 .I PXRMSEL="L" S HDR2="START:"_BD_U_"END:"_ED
     84 .S HDR2=HDR2_U_"RUN:"_RD_"Effective Date:"_SD
     85 .I PXRMFCMB="Y" S HDR3="COMBINED FACILITY"
     86 .I PXRMLCMB="Y" S $P(HDR3,SEP,2)="COMBINED LOCATION"
     87 .I PXRMTCMB="Y" S $P(HDR3,SEP,2)="COMBINED OE/RR TEAMS"
     88 .I PXRMREP="S" D
     89 ..N LIT1,LIT2,LIT3
     90 ..D LIT^PXRMXD
     91 ..I PXRMTOT="I" S $P(HDR3,SEP,3)=$$UP^XLFSTR(LIT1)
     92 ..I PXRMTOT="R" S $P(HDR3,SEP,3)=$$UP^XLFSTR(LIT2)
     93 ..I PXRMTOT="T" S $P(HDR3,SEP,3)=$$UP^XLFSTR(LIT3)
     94 .S PLSTCRIT(1)=HDR1,PLSTCRIT(2)=HDR2,PLSTCRIT(3)=HDR3
     95 .W !,HDR1,!,HDR2,!,HDR3,!
     96 ;
     97 ;Kill items marked as found
     98 K ^XTMP(PXRMXTMP,"MARKED AS FOUND")
     99 ;
     100 ;Setup the final formatting parameters.
     101 S C1HS=INDENT+3
     102 S C1S=0
     103 S C2HS=C1S+2
     104 S C2S=C2HS
     105 S C3HS=C2HS+5
     106 S C3S=C3HS
     107 S HEAD=1
     108 S INDENT=10
     109 ;
     110 ; Update last run date
     111 I $G(PXRMTMP)'="" D UPD^PXRMXTU
     112 ;
     113 ; Get report detail from ^XTMP
     114 N PNAM,SUB,DFN,BID,NAM,FAC,MOD,SRT,TOTAL,APPL,FACPNAME,PX,TTOTAL
     115 S TTOTAL=0
     116 ; Set subroutine label from report format
     117 S MOD="SUMARY" I PXRMREP="D" S MOD="DETAIL"
     118 ;
     119 S FAC=0,PX="PXRM"
     120 F  S FAC=$O(^XTMP(PXRMXTMP,PX,FAC)) Q:FAC=""  Q:DONE  D
     121 .;Get facility name for Location and PCMM team report
     122 .I "TL"[PXRMSEL,PXRMFCMB="N" D
     123 ..S FACPNAME=$P(PXRMFACN(FAC),U,1)_"  "_$P(PXRMFACN(FAC),U,2)
     124 .;Report from ^XTMP - label MOD is DETAIL/SUMARY
     125 .S (PNAM,SUB,NAM,SRT)=""
     126 .I PXRMSEL="I" S SUB="INDIVIDUAL PATIENTS" D @MOD Q:DONE
     127 .I PXRMSEL'="I" D
     128 ..;Sort internal IENs into alpha order
     129 ..D XSORT
     130 ..F  S SRT=$O(^TMP($J,"SORT",SRT)) Q:SRT=""  Q:DONE  D
     131 ...S SUB=$G(^TMP($J,"SORT",SRT)) D @MOD
     132 ..I MOD="SUMARY","RT"[PXRMTOT S SUB="TOTAL" D @MOD
     133 ;
     134 ; Null report if no patients selected
     135 I ('DONE),$O(^XTMP(PXRMXTMP,PX,""))="" D NULL^PXRMXGPR G EXIT
     136 ; Report selected patient sample with no patients
     137 I $D(MISSED) D MISSED^PXRMXPR1(0,.MISSED)
     138 ;
     139 ;Print Patient List
     140 I $G(PATLST)="Y" D FOOTER^PXRMXPR1(.PLSTCRIT)
     141 ;
     142 ;Print Error message
     143 I $D(^XTMP(PXRMXTMP,"ERROR"))>0!($D(^XTMP(PXRMXTMP,"CNBD"))>0) D ERROR^PXRMXBSY
     144EXIT ;
     145 D EXIT^PXRMXGUT
     146 ;
     147 ;Allow the task to be cleaned up upon successful completion.
     148 I $D(ZTQUEUED) S ZTREQ="@"
     149 ;
     150 D EOR^PXRMXGUT
     151 Q
     152 ;
     153 ;Report by Patient
     154DETAIL N JJ,VA,DATE,COUNT,DDAT,EMP
     155 N BED,DDUE,DDONE,DNEXT,FDAT1,FDAT2,FDAT3,FNAM,FTXT
     156 S NAM=$G(^XTMP(PXRMXTMP,PX,FAC,SUB)),HEAD=1
     157 S COUNT=$P(NAM,U,2),TOTAL=$P(NAM,U,3),APPL=$P(NAM,U,4),NAM=$P(NAM,U,1)
     158 S DDAT="",JJ=0
     159 ; Get list of patients for each appointment date
     160 F  S DDAT=$O(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT)) Q:DDAT=""  Q:DONE  D PAT
     161 ; No patients due
     162 I JJ=0 D:'DONE NONE^PXRMXGPR
     163 ; Total patients
     164 D:'DONE TOTAL^PXRMXGPR
     165 S TTOTAL=TTOTAL+TOTAL
     166 Q
     167 ;
     168PAT ;Extract and print patient detail
     169 N DNEXT1,NODE,PNUM
     170 F  S PNAM=$O(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM)) Q:PNAM=""  Q:DONE  D
     171 .S JJ=JJ+1
     172 .;Format print line
     173 .S (BID,DNEXT1,FDAT1,FDAT2,FDAT3,DNEXT1)="" I PNAM'["No patients found" D
     174 ..S FDAT2="N/A",FDAT3="None"
     175 ..S NODE=$G(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM))
     176 ..S DDUE=$P(NODE,U,2),DDONE=$P(NODE,U,3),DNEXT=$P(NODE,U,4)
     177 ..S BED=$P(NODE,U,5)
     178 ..S DFN=$P(NODE,U) S BID=$P($G(PNAM),U,2)
     179 ..I PXRMSSN="N" S BID=$E(BID,6,9)
     180 ..I PXRMSSN="Y",EMPCHK="Y" D EMP S:EMP BID=$E(BID,6,9)
     181 ..S BID="("_BID_")"
     182 ..S FDAT1=$$FMTE^XLFDT(DDUE,"5D")
     183 ..I DDONE S FDAT2=$$FMTE^XLFDT(DDONE,"5D")
     184 ..I BED'="NONE" S FDAT3=$P(NODE,U,5),DNEXT1=$$FMTE^XLFDT(DNEXT,"5D")
     185 ..I DNEXT,FDAT3="None" S FDAT3=$$FMTE^XLFDT(DNEXT,"5D")
     186 .;Print
     187 .D CHECK Q:DONE
     188 .;Normal output
     189 .I PXRMTABS="N" D
     190 ..S PNUM=JJ#10000
     191 ..S PNUM=$$RJ^XLFSTR(PNUM,4)
     192 ..W !,PNUM,?5,$E($P($G(PNAM),U),1,33-$L(BID))," ",BID,?40,FDAT1,?52,FDAT2
     193 ..I ('$G(PXRMINP)),PXRMFUT'="Y" W ?64,$S(BED'="NONE":BED_" (Inp.)",1:FDAT3)
     194 ..I $G(PXRMINP) W ?64,BED
     195 ..I DNEXT1'="",PXRMFUT'="Y" W !,?64,DNEXT1
     196 .;Delimited report
     197 .I PXRMTABS="Y" D
     198 ..N FNAM
     199 ..S FNAM=$P($G(PNAM),U)
     200 ..I FNAM'["No patients found" S FNAM=$E(FNAM,1,33-$L(BID))_" "_BID
     201 ..I "CES"[PXRMTABC S FNAM=$TR(FNAM,SEP,"_"),FDAT1=$TR(FDAT1,SEP,"_")
     202 ..I BED="NONE" S BED=" "
     203 ..W !,JJ_SEP_FNAM_SEP_FDAT1_SEP_FDAT2 I $G(PXRMINP) W SEP_BED
     204 ..I ('$G(PXRMINP)),PXRMFUT'="Y" W SEP_FDAT3_SEP_BED
     205 .;---
     206 .; Future Appointments
     207 .I PXRMFUT="Y" D
     208 ..N CNT,ADAT,ALOC,ATYP,FIRST,NONE
     209 ..S CNT=0,NONE=1,FIRST=1
     210 ..I '$D(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM)) Q
     211 ..F  S CNT=$O(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT)) Q:CNT'>0  D
     212 ...S ADAT=$P(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT,0),U)
     213 ...I PXRMDLOC="Y" D
     214 ....S ALOC=$P(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT,0),U,2)
     215 ....S ATYP=$P(^XTMP(PXRMXTMP,PX,FAC,SUB,DDAT,PNAM,CNT,0),U,3)
     216 ...S ADAT=$$FMTE^XLFDT(ADAT,"2P")
     217 ...I FIRST D  S FIRST=0,NONE=0
     218 ....I PXRMTABS="N" W ?64,$S(BED'="NONE":BED_" (Inp.)",1:"")
     219 ...D CHECK
     220 ...I PXRMDLOC="Y" D
     221 ....I PXRMTABS="N" W !,?8,ADAT,?30,$E(ALOC,1,25),?60,$E(ATYP,1,20)
     222 ....I PXRMTABS="Y" W SEP_ADAT_SEP_$E(ALOC,1,25)_SEP_$E(ATYP,1,20)
     223 ...I PXRMDLOC="N" D
     224 ....I PXRMTABS="N" W !,?10,ADAT
     225 ....I PXRMTABS="Y" W SEP_ADAT
     226 ..I NONE,PXRMTABS="N" W ?64,FDAT3
     227 ..I NONE,PXRMTABS="Y" W SEP_FDAT3
     228 ..I PXRMTABS="Y" W $S(BED'="NONE":SEP_BED_" (Inp.)",1:"")
     229 ..K ^UTILITY("VASD",$J)
     230 Q
     231 ;
     232 ;Summary by Reminder
     233SUMARY N JJ,EVAL,DUE,RNAM,RNUM,ITEM,COUNT,FTXT
     234 S NAM=$G(^XTMP(PXRMXTMP,PX,FAC,SUB)),HEAD=1
     235 S TOTAL=$P(NAM,U,3),COUNT=$P(NAM,U,2),NAM=$P(NAM,U,1)
     236 S RNUM=$O(REMINDER(""),-1)
     237 ;Get reminders in alpha order
     238 F JJ=1:1:RNUM D  Q:DONE
     239 .S ITEM=$P(REMINDER(JJ),U,1),RNAM=$P(REMINDER(JJ),U,4)
     240 .S:RNAM="" RNAM=$P(REMINDER(JJ),U,2)
     241 .; zero lines will be printed
     242 .S DUE=$G(^XTMP(PXRMXTMP,PX,FAC,SUB,ITEM))
     243 .S EVAL=+$P(DUE,U,1),DUE=+$P(DUE,U,2)
     244 .;Print
     245 .D CHECK Q:DONE
     246 .;Normal Report
     247 .I PXRMTABS="N" W !,JJ,?5,RNAM,?48,$J(EVAL,10),?63,$J(DUE,10)
     248 .;Condensed Report
     249 .I PXRMTABS="Y" D
     250 ..I "CES"[PXRMTABC S RNAM=$TR(RNAM,SEP,"_")
     251 ..W !,JJ_SEP_RNAM_SEP_EVAL_SEP_DUE_SEP_$TR(NAM,SEP,"_")
     252 D:'DONE TOTAL^PXRMXGPR
     253 I $G(SUB)'="TOTAL",PXRMTOT'="T" S TTOTAL=TTOTAL+TOTAL
     254 I $G(SUB)="TOTAL",PXRMTOT="T" S TTOTAL=TTOTAL+TOTAL
     255 Q
     256 ;
     257 ;Check line count before writing line
     258CHECK I ((PXRMTABS="N")&($Y>(IOSL-BMARG-3)))!(HEAD=1) D COL^PXRMXGPR(1)
     259 Q
     260 ;
     261 ;Check if employee
     262EMP N VAEL
     263 D ELIG^VADPT
     264 ;Check TYPE (#391) field
     265 I $P($G(VAEL(6)),U,2)="EMPLOYEE" S EMP=1 Q
     266 ;Check PATIENT ELIGABILITY (#361) field
     267 N ELIG
     268 S ELIG=0,EMP=0
     269 F  S ELIG=$O(VAEL(1,ELIG)) Q:'ELIG  D  Q:EMP
     270 .I $P($G(VAEL(1,ELIG)),U,2)="EMPLOYEE" S EMP=1
     271 Q
     272 ;
     273 ;Sort internal numbers into Alpha order
     274XSORT N SUB,NAM
     275 K ^TMP($J,"SORT")
     276 S SUB=""
     277 F  S SUB=$O(^XTMP(PXRMXTMP,PX,FAC,SUB)) Q:SUB=""  D
     278 .Q:SUB="TOTAL"
     279 .S NAM=$P(^XTMP(PXRMXTMP,PX,FAC,SUB),U)
     280 .I NAM="" S NAM=SUB
     281 .S ^TMP($J,"SORT",NAM)=SUB
     282 Q
     283 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXPR1.m

    r613 r623  
    1 PXRMXPR1        ; SLC/AGP - Print Reminder Due report carryover code. ;01/05/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Patient list display
    5 FOOTER(PLSTCRIT)        ;
    6         N CNT,CNT1,COUNT,TEXT
    7         ;Count patients in list
    8         S COUNT=+$O(^PXRMXP(810.5,PXRMLIS1,30,"A"),-1)
    9         ;
    10         I COUNT=0 W !!!,"No patients due. Patient List not created" Q
    11         W !!!,"Patient List "_$P($G(^PXRMXP(810.5,PXRMLIS1,0)),U)_" created by "_$$GET1^DIQ(200,DUZ,.01)_" on "_$$FMTE^XLFDT($P($G(^PXRMXP(810.5,PXRMLIS1,0)),U,4),1)
    12         W !!,"List contains "_COUNT_" patients, report run on "_TTOTAL_" patients."
    13         ;
    14         ;Screen out formatting lines and second piece of criteria array
    15         S (CNT,CNT1)=0 F  S CNT=$O(PLSTCRIT(CNT)) Q:CNT'>0  D
    16         .I $P($G(PLSTCRIT(CNT)),U)="",$P($G(PLSTCRIT(CNT)),U,2)>0 Q
    17         .S CNT1=CNT1+1 S TEXT(CNT1)=$P($G(PLSTCRIT(CNT)),U)
    18         ;Store Report Criteria in the document multiple of the patient list
    19         F CNT1=1:1:CNT1 S ^PXRMXP(810.5,PXRMLIS1,200,CNT1,0)=TEXT(CNT1)
    20         S ^PXRMXP(810.5,PXRMLIS1,200,0)=U_"810.51"_U_CNT1_U_CNT1
    21         Q
    22         ;
    23         ;Set up literals for display
    24 LITS    ;
    25         I PXRMSEL="I" S PXRMFLD="Individual Patients"
    26         I PXRMSEL="R" S PXRMFLD="Patient List"
    27         I PXRMSEL="P" S PXRMFLD="PCMM Provider"
    28         I PXRMSEL="O" S PXRMFLD="OE/RR Team"
    29         I PXRMSEL="T" S PXRMFLD="PCMM Team"
    30         I PXRMSEL="L" D
    31         .S PXRMFLD="Location"
    32         .I $P(PXRMLCSC,U)="HS" S DES="Selected Hospital Locations"
    33         .I $P(PXRMLCSC,U)="HA" S DES="All Outpatient Locations"
    34         .I $P(PXRMLCSC,U)="HAI" S DES="All Inpatient Locations"
    35         .I $P(PXRMLCSC,U)="CS" S DES="Selected Clinic Stops"
    36         .I $P(PXRMLCSC,U)="CA" S DES="All Clinic Stops"
    37         .I $P(PXRMLCSC,U)="GS" S DES="Selected Clinic Groups"
    38         .I PXRMFD="P" S DES=DES_" (Prior Encounters)"
    39         .I PXRMFD="F" S DES=DES_" (Future Appoints.)"
    40         .I PXRMFD="A" S DES=DES_" (Admissions)"
    41         .I PXRMFD="C" S DES=DES_" (Current Inpatients)"
    42         I PXRMSEL="P" D
    43         .I PXRMPRIM="A" S CDES="All patients on list"
    44         .I PXRMPRIM="P" S CDES="Primary care assigned patients only"
    45         Q
    46         ;
    47         ;Report missed locations if report is partially successful
    48 MISSED(PSTART,MISSED)   ;
    49         ;Delimited report from template
    50         I PXRMTABS="Y",PXRMTMP'="" D  Q
    51         .W !!?PSTART,"The following had no patients selected",!
    52         .N SUB
    53         .S SUB=""
    54         .F  S SUB=$O(MISSED(SUB)) Q:SUB=""  D
    55         ..W !?PSTART+10,SUB
    56         ;Other reports
    57         N LIT,SUB
    58         D CHECK^PXRMXGPR(5) Q:DONE
    59         S LIT=PXRMFLD
    60         I PXRMSEL="L",$E(PXRMLCSC)="G" S LIT="Clinic Group"
    61         W !!?PSTART,"The following ",LIT,"(s) had no patients selected",!
    62         S SUB=""
    63         F  S SUB=$O(MISSED(SUB)) Q:SUB=""  D
    64         .D CHECK^PXRMXGPR(3) Q:DONE
    65         .W !?PSTART+10,SUB
    66         Q
    67         ;
    68         ;Build array of locations/providers/teams with no patients
    69 NOPATS(MISSED)  ;
    70         N DATA,IC,LTYPE,MARK
    71         S IC=""
    72         I PXRMSEL="P" D  Q
    73         . F  S IC=$O(PXRMPRV(IC)) Q:IC=""  D
    74         .. S DATA=PXRMPRV(IC)
    75         .. D TEST(DATA,$P(DATA,U,1),.MISSED)
    76         I PXRMSEL="T" D
    77         . F  S IC=$O(PXRMPCM(IC)) Q:IC=""  D
    78         .. S DATA=PXRMPCM(IC)
    79         .. D TEST(DATA,$P(DATA,U,1),.MISSED)
    80         I PXRMSEL="O" D
    81         . F  S IC=$O(PXRMOTM(IC)) Q:IC=""  D
    82         .. S DATA=PXRMOTM(IC)
    83         .. D TEST(DATA,$P(DATA,U,1),.MISSED)
    84         S LTYPE=$E($G(PXRMLCSC))
    85         I LTYPE="H" D
    86         . F  S IC=$O(^XTMP(PXRMXTMP,"HLOC",IC)) Q:IC=""  D
    87         .. S DATA=^XTMP(PXRMXTMP,"HLOC",IC)
    88         .. D TEST(DATA,IC,.MISSED)
    89         I LTYPE="C" D
    90         . F  S IC=$O(PXRMCS(IC)) Q:IC=""  D
    91         .. S DATA=PXRMCS(IC)
    92         .. D TEST(DATA,$P(DATA,U,3),.MISSED)
    93         I LTYPE="G" D
    94         . F  S IC=$O(PXRMCGRP(IC)) Q:IC=""  D
    95         .. S DATA=PXRMCGRP(IC)
    96         .. D TEST(DATA,$P(DATA,U,1),.MISSED)
    97         Q
    98         ;
    99         ;Check for match on location
    100 TEST(DATA,IEN,MISSED)   ;
    101         N SUB
    102         I $D(^XTMP(PXRMXTMP,"MARKED AS FOUND",IEN)) Q
    103         I PXRMSEL'="L" S MISSED($P(DATA,U,2))="" Q
    104         N LTYPE
    105         S LTYPE=$E(PXRMLCSC)
    106         I LTYPE="H" S SUB=IEN D
    107         . N FACNAM,FACNUM,HLOC
    108         . S HLOC=$P(DATA,U,2) Q:HLOC=""
    109         . S FACNUM=$$HFAC^PXRMXSL1(IEN)
    110         . S FACNAM=$S(FACNUM="":"?",1:$P($G(PXRMFACN(FACNUM)),U,1))
    111         . I FACNAM'="" S SUB=HLOC_" ("_FACNAM_")"
    112         I LTYPE="C" S SUB=$P(DATA,U,1)_" "_$P(DATA,U,3)
    113         I LTYPE="G" S SUB=$P(DATA,U,2)
    114         S MISSED(SUB)=""
    115         Q
    116         ;
     1PXRMXPR1 ; SLC/AGP - Print Reminder Due report carryover code. ;01/05/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ;Patient list display
     5FOOTER(PLSTCRIT) ;
     6 N CNT,CNT1,COUNT,TEXT
     7 ;Count patients in list
     8 S COUNT=+$O(^PXRMXP(810.5,PXRMLIS1,30,"A"),-1)
     9 ;
     10 I COUNT=0 W !!!,"No patients due. Patient List not created" Q
     11 W !!!,"Patient List "_$P($G(^PXRMXP(810.5,PXRMLIS1,0)),U)_" created by "_$$GET1^DIQ(200,DUZ,.01)_" on "_$$FMTE^XLFDT($P($G(^PXRMXP(810.5,PXRMLIS1,0)),U,4),1)
     12 W !!,"List contains "_COUNT_" patients, report run on "_TTOTAL_" patients."
     13 ;
     14 ;Screen out formatting lines and second piece of criteria array
     15 S (CNT,CNT1)=0 F  S CNT=$O(PLSTCRIT(CNT)) Q:CNT'>0  D
     16 .I $P($G(PLSTCRIT(CNT)),U)="",$P($G(PLSTCRIT(CNT)),U,2)>0 Q
     17 .S CNT1=CNT1+1 S TEXT(CNT1)=$P($G(PLSTCRIT(CNT)),U)
     18 ;Store Report Criteria in the document multiple of the patient list
     19 F CNT1=1:1:CNT1 S ^PXRMXP(810.5,PXRMLIS1,200,CNT1,0)=TEXT(CNT1)
     20 S ^PXRMXP(810.5,PXRMLIS1,200,0)=U_"810.51"_U_CNT1_U_CNT1
     21 Q
     22 ;
     23 ;Set up literals for display
     24LITS ;
     25 I PXRMSEL="I" S PXRMFLD="Individual Patients"
     26 I PXRMSEL="R" S PXRMFLD="Patient List"
     27 I PXRMSEL="P" S PXRMFLD="PCMM Provider"
     28 I PXRMSEL="O" S PXRMFLD="OE/RR Team"
     29 I PXRMSEL="T" S PXRMFLD="PCMM Team"
     30 I PXRMSEL="L" D
     31 .S PXRMFLD="Location"
     32 .I $P(PXRMLCSC,U)="HS" S DES="Selected Hospital Locations"
     33 .I $P(PXRMLCSC,U)="HA" S DES="All Outpatient Locations"
     34 .I $P(PXRMLCSC,U)="HAI" S DES="All Inpatient Locations"
     35 .I $P(PXRMLCSC,U)="CS" S DES="Selected Clinic Stops"
     36 .I $P(PXRMLCSC,U)="CA" S DES="All Clinic Stops"
     37 .I $P(PXRMLCSC,U)="GS" S DES="Selected Clinic Groups"
     38 .I PXRMFD="P" S DES=DES_" (Prior Encounters)"
     39 .I PXRMFD="F" S DES=DES_" (Future Appoints.)"
     40 .I PXRMFD="A" S DES=DES_" (Admissions)"
     41 .I PXRMFD="C" S DES=DES_" (Current Inpatients)"
     42 I PXRMSEL="P" D
     43 .I PXRMPRIM="A" S CDES="All patients on list"
     44 .I PXRMPRIM="P" S CDES="Primary care assigned patients only"
     45 Q
     46 ;
     47 ;Report missed locations if report is partially successful
     48MISSED(PSTART,MISSED) ;
     49 ;Delimited report from template
     50 I PXRMTABS="Y",PXRMTMP'="" D  Q
     51 .W !!?PSTART,"The following had no patients selected",!
     52 .N SUB
     53 .S SUB=""
     54 .F  S SUB=$O(MISSED(SUB)) Q:SUB=""  D
     55 ..W !?PSTART+10,SUB
     56 ;Other reports
     57 N LIT,SUB
     58 D CHECK^PXRMXGPR(5) Q:DONE
     59 S LIT=PXRMFLD
     60 I PXRMSEL="L",$E(PXRMLCSC)="G" S LIT="Clinic Group"
     61 W !!?PSTART,"The following ",LIT,"(s) had no patients selected",!
     62 S SUB=""
     63 F  S SUB=$O(MISSED(SUB)) Q:SUB=""  D
     64 .D CHECK^PXRMXGPR(3) Q:DONE
     65 .W !?PSTART+10,SUB
     66 Q
     67 ;
     68 ;Build array of locations/providers/teams with no patients
     69NOPATS(MISSED) ;
     70 N DATA,IC,LTYPE,MARK
     71 S IC=""
     72 I PXRMSEL="P" D
     73 . F  S IC=$O(PXRMPRV(IC)) Q:IC=""  D
     74 .. S DATA=PXRMPRV(IC)
     75 .. D TEST(DATA,$P(DATA,U,1),.MISSED)
     76 I PXRMSEL="T" D
     77 . F  S IC=$O(PXRMPCM(IC)) Q:IC=""  D
     78 .. S DATA=PXRMPCM(IC)
     79 .. D TEST(DATA,$P(DATA,U,1),.MISSED)
     80 I PXRMSEL="O" D
     81 . F  S IC=$O(PXRMOTM(IC)) Q:IC=""  D
     82 .. S DATA=PXRMOTM(IC)
     83 .. D TEST(DATA,$P(DATA,U,1),.MISSED)
     84 S LTYPE=$E($G(PXRMLCSC))
     85 I LTYPE="H" D
     86 . F  S IC=$O(^XTMP(PXRMXTMP,"HLOC",IC)) Q:IC=""  D
     87 .. S DATA=^XTMP(PXRMXTMP,"HLOC",IC)
     88 .. D TEST(DATA,IC,.MISSED)
     89 I LTYPE="C" D
     90 . F  S IC=$O(PXRMCS(IC)) Q:IC=""  D
     91 .. S DATA=PXRMCS(IC)
     92 .. D TEST(DATA,$P(DATA,U,3),.MISSED)
     93 I LTYPE="G" D
     94 . F  S IC=$O(PXRMCGRP(IC)) Q:IC=""  D
     95 .. S DATA=PXRMCGRP(IC)
     96 .. D TEST(DATA,$P(DATA,U,1),.MISSED)
     97 Q
     98 ;
     99 ;Check for match on location
     100TEST(DATA,IEN,MISSED) ;
     101 N SUB
     102 I $D(^XTMP(PXRMXTMP,"MARKED AS FOUND",IEN)) Q
     103 I PXRMSEL'="L" S MISSED($P(DATA,U,2))="" Q
     104 N LTYPE
     105 S LTYPE=$E(PXRMLCSC)
     106 I LTYPE="H" S SUB=IEN D
     107 . N FACNAM,FACNUM,HLOC
     108 . S HLOC=$P(DATA,U,2) Q:HLOC=""
     109 . S FACNUM=$$HFAC^PXRMXSL1(IEN)
     110 . S FACNAM=$S(FACNUM="":"?",1:$P($G(PXRMFACN(FACNUM)),U,1))
     111 . I FACNAM'="" S SUB=HLOC_" ("_FACNAM_")"
     112 I LTYPE="C" S SUB=$P(DATA,U,1)_" "_$P(DATA,U,3)
     113 I LTYPE="G" S SUB=$P(DATA,U,2)
     114 S MISSED(SUB)=""
     115 Q
     116 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXQUE.m

    r613 r623  
    1 PXRMXQUE        ; SLC/PJH - Reminder reports general queuing routine.;03/23/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ;Determine whether the report should be queued.
    5 JOB     ;
    6         N %ZIS S %ZIS="Q"
    7         W !
    8         D ^%ZIS
    9         I POP G EXIT^PXRMXD
    10         S PXRMIOD=ION_";"_IOST_";"_IOM_";"_IOSL
    11         S PXRMQUE=$G(IO("Q"))
    12         ;
    13         I PXRMQUE D  Q
    14         . ;Queue the report.
    15         . N DESC,PXRMIOV,ROUTINE,TASK,ZTDTH
    16         . S DESC="Reminder Due Report - sort"
    17         . S PXRMIOV=""
    18         . S ROUTINE="^PXRMXSE1"
    19         . M ^TMP("PXRM-MESS",$J)=^TMP("XM-MESS",$J)
    20         . S TASK=$$QUE^PXRMXQUE(DESC,PXRMIOV,ROUTINE,"SAVE^PXRMXQUE") Q:TASK=""
    21         . S ^XTMP(PXRMXTMP,"SORTZTSK")=TASK
    22         . M ^TMP("XM-MESS",$J)=^TMP("PXRM-MESS",$J)
    23         . K ^TMP("PXRM-MESS",$J)
    24         .;
    25         . S DESC="Reminder Due Report - print"
    26         . S PXRMIOV=PXRMIOD
    27         . S ROUTINE="^PXRMXPR"
    28         . S ZTDTH="@"
    29         . S ^XTMP(PXRMXTMP,"PRZTSK")=$$QUE^PXRMXQUE(DESC,PXRMIOV,ROUTINE,"SAVE^PXRMXQUE")
    30         I 'PXRMQUE D ^PXRMXSE1
    31         Q
    32         ;
    33 QUE(DESC,PXRMIOV,ROUTINE,SAVE)  ;Queue a task.
    34         N ZTDESC,ZTIO,ZTRTN,ZTSAVE
    35         D @SAVE
    36         S ZTDESC=DESC
    37         S ZTIO=PXRMIOV
    38         S ZTRTN=ROUTINE
    39         D ^%ZTLOAD
    40         I $D(ZTSK)=0 W !!,DESC," cancelled"
    41         E  W !!,DESC," has been queued, task number ",ZTSK
    42         Q $G(ZTSK)
    43         ;
    44 DEVICE(RTN,DESC,SAVE,%ZIS,RETZTSK)      ;
    45         ;Pass RETZTSK as number such as 1 if you want to get ZTSK.
    46         N ZTSK
    47         W !
    48         D EN^XUTMDEVQ(RTN,DESC,.SAVE,.%ZIS,RETZTSK)
    49         I $D(ZTSK) W !!,DESC," has been queued, task number "_ZTSK H 2
    50         Q $G(ZTSK)
    51         ;
    52         ;=======================================================================
    53 REQUE(DESC,ROUTINE,TASK)        ;Reque a task.
    54         N ZTDTH,ZTRTN,ZTIO,ZTDESC,ZTSK
    55         S ZTDESC=DESC
    56         S ZTRTN=ROUTINE
    57         S ZTSK=TASK
    58         S ZTDTH=$$NOW^XLFDT
    59         D REQ^%ZTLOAD
    60         I ZTSK(0)=1 Q
    61         ;There was a problem, send an error message.
    62         K ZTSK S ZTSK=TASK
    63         D ISQED^%ZTLOAD
    64         N LC,SUB
    65         K ^TMP("PXRMXMZ",$J)
    66         S ^TMP("PXRMXMZ",$J,1,0)="Could not start the print task, task information:"
    67         S ^TMP("PXRMXMZ",$J,2,0)=" Task number "_TASK
    68         S LC=2,SUB=""
    69         F  S SUB=$O(ZTSK(SUB)) Q:SUB=""  D
    70         . S LC=LC+1
    71         . S ^TMP("PXRMXMZ",$J,LC,0)=" ZTSK("_SUB_")="_ZTSK(SUB)
    72         S LC=LC+1,^TMP("PXRMXMZ",$J,LC,0)=" Print start time="_ZTDTH
    73         S LC=LC+1,^TMP("PXRMXMZ",$J,LC,0)=" Submit time="_$P(PXRMXTMP,"PXRMX",2)
    74         S LC=LC+1,^TMP("PXRMXMZ",$J,LC,0)="PXRMXTMP="_$G(PXRMXTMP)
    75         D SEND^PXRMMSG("REMINDER REPORT ERROR",DUZ)
    76         Q
    77         ;
    78         ;=======================================================================
    79 SAVE    ;Save the variables for queing.
    80         S ZTSAVE("PXRMBDT")="",ZTSAVE("PXRMEDT")="",ZTSAVE("PXRMSDT")=""
    81         S ZTSAVE("PXRMCS(")="",ZTSAVE("NCS")=""
    82         S ZTSAVE("PXRMCGRP(")="",ZTSAVE("NCGRP")=""
    83         S ZTSAVE("PXRMFAC(")="",ZTSAVE("NFAC")=""
    84         S ZTSAVE("PXRMFACN(")=""
    85         S ZTSAVE("PXRMFCMB")=""
    86         S ZTSAVE("PXRMFUT")="",ZTSAVE("PXRMDLOC")=""
    87         S ZTSAVE("PXRMFD")=""
    88         S ZTSAVE("PXRMINP")=""
    89         S ZTSAVE("PXRMIOD")=""
    90         S ZTSAVE("PXRMLCHL(")="",ZTSAVE("NHL")=""
    91         S ZTSAVE("PXRMLCMB")=""
    92         S ZTSAVE("PXRMLCSC")=""
    93         S ZTSAVE("PXRMPRIM")=""
    94         S ZTSAVE("PXRMQUE")=""
    95         S ZTSAVE("PXRMREP")=""
    96         S ZTSAVE("PXRMRT")=""
    97         S ZTSAVE("PXRMSCAT")="",ZTSAVE("PXRMSCAT(")=""
    98         S ZTSAVE("PXRMSEL")=""
    99         S ZTSAVE("PXRMSRT")=""
    100         S ZTSAVE("PXRMSSN")=""
    101         S ZTSAVE("PXRMTABC")=""
    102         S ZTSAVE("PXRMTABS")=""
    103         S ZTSAVE("PXRMTCMB")=""
    104         S ZTSAVE("PXRMTMP")=""
    105         S ZTSAVE("PXRMTOT")=""
    106         S ZTSAVE("PXRMXTMP")=""
    107         ; Time initiated
    108         S ZTSAVE("PXRMXST")=""
    109         ; New selection criteria
    110         S ZTSAVE("PXRMOTM(")="",ZTSAVE("NOTM")=""
    111         S ZTSAVE("PXRMPRV(")="",ZTSAVE("NPRV")=""
    112         S ZTSAVE("PXRMPAT(")="",ZTSAVE("NPAT")=""
    113         S ZTSAVE("PXRMPCM(")="",ZTSAVE("NPCM")=""
    114         S ZTSAVE("PXRMREM(")="",ZTSAVE("NREM")=""
    115         S ZTSAVE("PXRMRCAT(")="",ZTSAVE("NCAT")=""
    116         S ZTSAVE("PXRMUSER")=""
    117         ;Reminder list
    118         S ZTSAVE("REMINDER(")=""
    119         ; Arrays by IEN
    120         S ZTSAVE("PXRMLOCN(")=""
    121         S ZTSAVE("PXRMCSN(")=""
    122         S ZTSAVE("PXRMCGRN(")=""
    123         ;Patient List
    124         S ZTSAVE("PATCREAT")=""
    125         S ZTSAVE("PATLST")=""
    126         S ZTSAVE("PXRMLIST(")=""
    127         S ZTSAVE("PXRMLIS1")=""
    128         S ZTSAVE("PLISTPUG")=""
    129         ;User DUZ
    130         S ZTSAVE("DBDUZ")=""
    131         S ZTSAVE("DBERR")=""
    132         S ZTSAVE("PXRMRERR(")=""
    133         ;Dubug information
    134         S ZTSAVE("PXRMDBUG")=""
    135         S ZTSAVE("PXRMDBUS")=""
    136         ;Patient Information
    137         S ZTSAVE("PXRMTPAT")=""
    138         S ZTSAVE("PXRMDPAT")=""
    139         I +$G(PXRMIDOD)>0 S ZTSAVE("PXRMIDOD")=""
    140         S ZTSAVE("PXRMPML")=""
    141         Q
     1PXRMXQUE ; SLC/PJH - Reminder reports general queuing routine.;02/24/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4        ;Determine whether the report should be queued.
     5JOB ;
     6 N %ZIS S %ZIS="Q"
     7 W !
     8 D ^%ZIS
     9 I POP G EXIT^PXRMXD
     10 S PXRMIOD=ION_";"_IOST_";"_IOM_";"_IOSL
     11 S PXRMQUE=$G(IO("Q"))
     12 ;
     13 I PXRMQUE D  Q
     14 . ;Queue the report.
     15 . N DESC,PXRMIOV,ROUTINE,TASK,ZTDTH
     16 . S DESC="Reminder Due Report - sort"
     17 . S PXRMIOV=""
     18 . S ROUTINE="^PXRMXSE1"
     19 . M ^TMP("PXRM-MESS",$J)=^TMP("XM-MESS",$J)
     20 . S TASK=$$QUE^PXRMXQUE(DESC,PXRMIOV,ROUTINE,"SAVE^PXRMXQUE") Q:TASK=""
     21 . S ^XTMP(PXRMXTMP,"SORTZTSK")=TASK
     22 . M ^TMP("XM-MESS",$J)=^TMP("PXRM-MESS",$J)
     23 . K ^TMP("PXRM-MESS",$J)
     24 .;
     25 . S DESC="Reminder Due Report - print"
     26 . S PXRMIOV=PXRMIOD
     27 . S ROUTINE="^PXRMXPR"
     28 . S ZTDTH="@"
     29 . S ^XTMP(PXRMXTMP,"PRZTSK")=$$QUE^PXRMXQUE(DESC,PXRMIOV,ROUTINE,"SAVE^PXRMXQUE")
     30 I 'PXRMQUE D ^PXRMXSE1
     31 Q
     32 ;
     33QUE(DESC,PXRMIOV,ROUTINE,SAVE) ;Queue a task.
     34 N ZTDESC,ZTIO,ZTRTN,ZTSAVE
     35 D @SAVE
     36 S ZTDESC=DESC
     37 S ZTIO=PXRMIOV
     38 S ZTRTN=ROUTINE
     39 D ^%ZTLOAD
     40 I $D(ZTSK)=0 W !!,DESC," cancelled"
     41 E  W !!,DESC," has been queued, task number ",ZTSK
     42 Q $G(ZTSK)
     43 ;
     44DEVICE(ZTRTN,ZTDESC,ZTSAVE,%ZIS,ZTSK) ;
     45 W !
     46 D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,.%ZIS,.ZTSK)
     47 I $D(ZTSK)>1 W !!,ZTDESC," has been queued, task number "_$G(ZTSK) H 2
     48 I $G(ZTSK)="" S ZTSK=0
     49 Q ZTSK
     50 ;
     51 ;=======================================================================
     52REQUE(DESC,ROUTINE,TASK) ;Reque a task.
     53 N ZTDTH,ZTRTN,ZTIO,ZTDESC,ZTSK
     54 S ZTDESC=DESC
     55 S ZTRTN=ROUTINE
     56 S ZTSK=TASK
     57 S ZTDTH=$$NOW^XLFDT
     58 D REQ^%ZTLOAD
     59 I ZTSK(0)=1 Q
     60 ;There was a problem, send an error message.
     61 K ZTSK S ZTSK=TASK
     62 D ISQED^%ZTLOAD
     63 N LC,SUB
     64 K ^TMP("PXRMXMZ",$J)
     65 S ^TMP("PXRMXMZ",$J,1,0)="Could not start the print task, task information:"
     66 S ^TMP("PXRMXMZ",$J,2,0)=" Task number "_TASK
     67 S LC=2,SUB=""
     68 F  S SUB=$O(ZTSK(SUB)) Q:SUB=""  D
     69 . S LC=LC+1
     70 . S ^TMP("PXRMXMZ",$J,LC,0)=" ZTSK("_SUB_")="_ZTSK(SUB)
     71 S LC=LC+1,^TMP("PXRMXMZ",$J,LC,0)=" Print start time="_ZTDTH
     72 S LC=LC+1,^TMP("PXRMXMZ",$J,LC,0)=" Submit time="_$P(PXRMXTMP,"PXRMX",2)
     73 S LC=LC+1,^TMP("PXRMXMZ",$J,LC,0)="PXRMXTMP="_$G(PXRMXTMP)
     74 D SEND^PXRMMSG("REMINDER REPORT ERROR",DUZ)
     75 Q
     76 ;
     77 ;=======================================================================
     78SAVE ;Save the variables for queing.
     79 S ZTSAVE("PXRMBDT")="",ZTSAVE("PXRMEDT")="",ZTSAVE("PXRMSDT")=""
     80 S ZTSAVE("PXRMCS(")="",ZTSAVE("NCS")=""
     81 S ZTSAVE("PXRMCGRP(")="",ZTSAVE("NCGRP")=""
     82 S ZTSAVE("PXRMFAC(")="",ZTSAVE("NFAC")=""
     83 S ZTSAVE("PXRMFACN(")=""
     84 S ZTSAVE("PXRMFCMB")=""
     85 S ZTSAVE("PXRMFUT")="",ZTSAVE("PXRMDLOC")=""
     86 S ZTSAVE("PXRMFD")=""
     87 S ZTSAVE("PXRMINP")=""
     88 S ZTSAVE("PXRMIOD")=""
     89 S ZTSAVE("PXRMLCHL(")="",ZTSAVE("NHL")=""
     90 S ZTSAVE("PXRMLCMB")=""
     91 S ZTSAVE("PXRMLCSC")=""
     92 S ZTSAVE("PXRMPRIM")=""
     93 S ZTSAVE("PXRMQUE")=""
     94 S ZTSAVE("PXRMREP")=""
     95 S ZTSAVE("PXRMRT")=""
     96 S ZTSAVE("PXRMSCAT")="",ZTSAVE("PXRMSCAT(")=""
     97 S ZTSAVE("PXRMSEL")=""
     98 S ZTSAVE("PXRMSRT")=""
     99 S ZTSAVE("PXRMSSN")=""
     100 S ZTSAVE("PXRMTABC")=""
     101 S ZTSAVE("PXRMTABS")=""
     102 S ZTSAVE("PXRMTCMB")=""
     103 S ZTSAVE("PXRMTMP")=""
     104 S ZTSAVE("PXRMTOT")=""
     105 S ZTSAVE("PXRMXTMP")=""
     106 ; Time initiated
     107 S ZTSAVE("PXRMXST")=""
     108 ; New selection criteria
     109 S ZTSAVE("PXRMOTM(")="",ZTSAVE("NOTM")=""
     110 S ZTSAVE("PXRMPRV(")="",ZTSAVE("NPRV")=""
     111 S ZTSAVE("PXRMPAT(")="",ZTSAVE("NPAT")=""
     112 S ZTSAVE("PXRMPCM(")="",ZTSAVE("NPCM")=""
     113 S ZTSAVE("PXRMREM(")="",ZTSAVE("NREM")=""
     114 S ZTSAVE("PXRMRCAT(")="",ZTSAVE("NCAT")=""
     115 S ZTSAVE("PXRMUSER")=""
     116 ;Reminder list
     117 S ZTSAVE("REMINDER(")=""
     118 ; Arrays by IEN
     119 S ZTSAVE("PXRMLOCN(")=""
     120 S ZTSAVE("PXRMCSN(")=""
     121 S ZTSAVE("PXRMCGRN(")=""
     122 ;Patient List
     123 S ZTSAVE("PATCREAT")=""
     124 S ZTSAVE("PATLST")=""
     125 S ZTSAVE("PXRMLIST(")=""
     126 S ZTSAVE("PXRMLIS1")=""
     127 S ZTSAVE("PLISTPUG")=""
     128 ;User DUZ
     129 S ZTSAVE("DBDUZ")=""
     130 S ZTSAVE("DBERR")=""
     131 S ZTSAVE("PXRMRERR(")=""
     132 ;Dubug information
     133 S ZTSAVE("PXRMDBUG")=""
     134 S ZTSAVE("PXRMDBUS")=""
     135 ;Patient Information
     136 S ZTSAVE("PXRMTPAT")=""
     137 S ZTSAVE("PXRMDPAT")=""
     138 I +$G(PXRMIDOD)>0 S ZTSAVE("PXRMIDOD")=""
     139 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXSC.m

    r613 r623  
    1 PXRMXSC ; SLC/PJH - Reminder reports service category selection ;12/18/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 SCAT    ;Get the list of service categories.
    5         N DIR,DIEA,IC,JC,NSC,PCESVC,SCA,VALID,X,Y
    6         K DIRUT,DTOUT,DUOUT
    7         ;Build a list of allowed service categories. PCE uses a subset of the
    8         ;categories in the file.  These are stored in PCESVC.
    9         S PCESVC=""
    10         D HELP^DIE(9000010,"",.07,"S","SCA")
    11         S NSC=SCA("DIHELP")
    12         S DIR("?")=U_"D SCATHELP^PXRMXSC"
    13         S DIR("??")=U_"D SCATHELP^PXRMXSC"
    14 SCATP   ;
    15         S DIR(0)="FU"_U_"1:"_NSC
    16         S DIR("A")="Select SERVICE CATEGORIES"
    17         S DIR("B")="A,I"
    18         W !
    19         D ^DIR K DIR
    20         I $D(DIROUT) S DTOUT=1
    21         I $D(DTOUT)!($D(DUOUT)) Q
    22         ;Make sure we have a valid list.
    23         S VALID=$$VSCLIST(Y,PCESVC)
    24         I 'VALID G SCATP
    25         S PXRMSCAT=$$UP^XLFSTR(Y)
    26         F IC=1:1:$L(PXRMSCAT,",") S X=$P(PXRMSCAT,",",IC),PXRMSCAT(X)=""
    27         Q
    28         ;
    29         ;======================================================
    30 SCATHELP        ;? help for service categories.
    31         N ARRAY,IC,JC,NSC,PCESVC
    32         S PCESVC=""
    33         D HELP^DIE(9000010,"",.07,"S","SCA")
    34         S NSC=SCA("DIHELP")
    35         S JC=0
    36         F IC=2:1:NSC D
    37         . S X=$P(SCA("DIHELP",IC)," ",1)
    38         . I PCESVC="" S PCESVC=X
    39         . E  S PCESVC=PCESVC_","_X
    40         . S JC=JC+1
    41         . S ARRAY(JC)=SCA("DIHELP",IC)
    42         S NSC=JC
    43         W !!,"Enter the letter(s), separated by commas, corresponding to the desired service"
    44         W !,"category or categories. For example A,H,T,E would allow only encounters with"
    45         W !,"service categories of ambulatory, hospitalization, telecommunications, and"
    46         W !,"event (historical) to be included."
    47         W !!,"The possible service categories for the report are:",!
    48         F IC=1:1:NSC W !,ARRAY(IC)
    49         Q
    50         ;
    51         ;======================================================
    52 VSCLIST(LIST,SLIST)     ;LIST is a comma separated list of service categories. SLIST
    53         ;is the standard list of service categories. Make sure all the
    54         ;elements of LIST are in the standard list SLIST. If they are, then
    55         ;LIST is valid. Used for selection in reminder reports and as input
    56         ;transform SERVICE CATEGORY LIST in the REMINDER REPORT TEMPLATE
    57         ;file #810.1.
    58         I LIST="" Q 1
    59         I $G(SLIST)="" D
    60         . N IC,SCA,TEMP
    61         . D HELP^DIE(9000010,"",.07,"S","SCA")
    62         . S SLIST=""
    63         . F IC=2:1:SCA("DIHELP") D
    64         .. S TEMP=$P(SCA("DIHELP",IC)," ",1)
    65         .. I SLIST="" S SLIST=TEMP
    66         .. E  S SLIST=SLIST_","_TEMP
    67         N IC,LE,LEN,VALID
    68         S LIST=$$UP^XLFSTR(LIST)
    69         S VALID=1
    70         S LEN=$L(LIST,",")
    71         F IC=1:1:LEN D
    72         . S LE=$P(LIST,",",IC)
    73         . I LE="" D  Q
    74         .. D EN^DDIOL("Null is not a valid service category!")
    75         .. S VALID=0
    76         . I SLIST'[LE D
    77         .. D EN^DDIOL(LE_" is an invalid service category!")
    78         .. S VALID=0
    79         Q VALID
    80         ;
     1PXRMXSC ; SLC/PJH - Reminder reports service category selection ;11/03/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4SCAT ;Get the list of service categories.
     5 N DIR,DIEA,IC,JC,NSC,PCESVC,SCA,VALID,X,Y
     6 K DIRUT,DTOUT,DUOUT
     7 ;Build a list of allowed service categories. PCE uses a subset of the
     8 ;categories in the file.  These are stored in PCESVC.
     9 S PCESVC=""
     10 D HELP^DIE(9000010,"",.07,"S","SCA")
     11 S NSC=SCA("DIHELP")
     12 S DIR("?")=" "
     13 S DIR("?",1)="The possible service categories for the report are:"
     14 S JC=0
     15 F IC=2:1:NSC D
     16 . S X=$P(SCA("DIHELP",IC)," ",1)
     17 . I PCESVC="" S PCESVC=X
     18 . E  S PCESVC=PCESVC_","_X
     19 . S JC=JC+1
     20 . S DIR("?",JC)=SCA("DIHELP",IC)
     21 S NSC=JC
     22 S DIR("??")=U_"D SCATHELP^PXRMXSC"
     23SCATP ;
     24 S DIR(0)="FU"_U_"1:"_NSC
     25 S DIR("A")="Select SERVICE CATEGORIES"
     26 S DIR("B")="A,I"
     27 W !
     28 D ^DIR K DIR
     29 I $D(DIROUT) S DTOUT=1
     30 I $D(DTOUT)!($D(DUOUT)) Q
     31 ;Make sure we have a valid list.
     32 S VALID=$$VSCLIST(Y,PCESVC)
     33 I 'VALID G SCATP
     34 S PXRMSCAT=$$UP^XLFSTR(Y)
     35 F IC=1:1:$L(PXRMSCAT,",") S X=$P(PXRMSCAT,",",IC),PXRMSCAT(X)=""
     36 Q
     37 ;
     38 ;======================================================
     39SCATHELP ;?? help for service categories.
     40 W !!,"Enter the letter(s), separated by commas, corresponding to the desired service"
     41 W !,"category or categories. For example A,H,T,E would allow only encounters with"
     42 W !,"service categories of ambulatory, hospitalization, telecommunications, and"
     43 W !,"event (historical) to be included."
     44 Q
     45 ;
     46 ;======================================================
     47VSCLIST(LIST,SLIST) ;LIST is a comma separated list of service categories. SLIST
     48 ;is the standard list of service categories. Make sure all the
     49 ;elements of LIST are in the standard list SLIST. If they are, then
     50 ;LIST is valid. Used for selection in reminder reports and as input
     51 ;transform SERVICE CATEGORY LIST in the REMINDER REPORT TEMPLATE
     52 ;file #810.1.
     53 I LIST="" Q 1
     54 I $G(SLIST)="" D
     55 . N IC,SCA,TEMP
     56 . D HELP^DIE(9000010,"",.07,"S","SCA")
     57 . S SLIST=""
     58 . F IC=2:1:SCA("DIHELP") D
     59 .. S TEMP=$P(SCA("DIHELP",IC)," ",1)
     60 .. I SLIST="" S SLIST=TEMP
     61 .. E  S SLIST=SLIST_","_TEMP
     62 N IC,LE,LEN,VALID
     63 S LIST=$$UP^XLFSTR(LIST)
     64 S VALID=1
     65 S LEN=$L(LIST,",")
     66 F IC=1:1:LEN D
     67 . S LE=$P(LIST,",",IC)
     68 . I LE="" D  Q
     69 .. D EN^DDIOL("Null is not a valid service category!")
     70 .. S VALID=0
     71 . I SLIST'[LE D
     72 .. D EN^DDIOL(LE_" is an invalid service category!")
     73 .. S VALID=0
     74 Q VALID
     75 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXSE1.m

    r613 r623  
    1 PXRMXSE1        ; SLC/PJH - Build Patient lists for Reminder Due report; 08/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called/jobbed from PXRMXD
    5         ;
    6         ; Input - PXRMSEL,PXRMXTMP
    7         ;         PXRM*
    8         ; Output- ^XTMP(PXRMXTMP
    9         ;
    10         ;
    11 START   ; 
    12         N LIT,TOTAL,TODAY,ZTSTOP,BUSY
    13         S DBDOWN=0
    14         S TOTAL=0,ZTSTOP="",TODAY=$$DT^XLFDT-.0001
    15         ;
    16         K ^TMP($J,"PXRM PATIENT LIST"),^TMP($J,"PXRM PATIENT EVAL")
    17         K ^TMP($J,"PXRM FUTURE APPT"),^TMP($J,"SDAMA301")
    18         K ^TMP($J),^TMP(PXRMRT,$J),^TMP("PXRMDUP",$J)
    19         K ^TMP("PXRMCMB",$J),^TMP("PXRMCMB1",$J),^TMP("PXRMCMB2",$J)
    20         N PXRMRERR
    21         ;
    22         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    23         ;
    24         ;OE/RR team selected (PXRMOTM)
    25         I PXRMSEL="O" D OERR^PXRMXSL1
    26         ;
    27         ;PCMM team selected (PXRMPCM)
    28         I PXRMSEL="T" D PCMMT^PXRMXSL1
    29         ;
    30         N HLIEN,FACILITY
    31         ;Location selected (PXRMLCHL,PXRMCGRP)
    32         I PXRMSEL="L" D  G:ZTSTOP=1 EXIT
    33         .;Build Clinic List
    34         .D BHLOC^PXRMXSL1
    35         .;Prior Visits - build patient list in ^TMP
    36         .I PXRMFD="P" D VISITS^PXRMXSL2 I DBDOWN=1 Q
    37         .;Inpatient Admissions and current inpatient locations
    38         .I PXRMFD="A"!(PXRMFD="C") D INPADM^PXRMXSL1
    39         .;Future Appointments - build patient list in ^TMP
    40         .I PXRMFD="F" D APPTS^PXRMXSL2 I DBDOWN=1 Q
    41         .;End task requested
    42         .Q:ZTSTOP=1
    43         ;Update ^XTMP from ^TMP
    44         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    45         ;
    46         ;PCMM provider selected (PXRMPRV)
    47         I PXRMSEL="P" D PCMMP^PXRMXSL1
    48         ;
    49         ;Individual Patients selected (PXRMPAT)
    50         I PXRMSEL="I" D IND^PXRMXSL1
    51         ;
    52         ;Patient List selected (PXRMLIST)
    53         I PXRMSEL="R" D LIST^PXRMXSL1
    54         ;
    55         I DBDOWN=1 G EXIT
    56         S START=$H
    57         D EVAL^PXRMXEVL("PXRM PATIENT EVAL",.REMINDER)
    58         D XTMP(START)
    59         ;
    60         ;Update patient list
    61         I PXRMSEL'="I"&(PXRMUSER'="Y")&($G(PXRMLIS1)'="") D
    62         .;If no patients due delete patient list
    63         .I +$O(^TMP($J,"PXRMXPAT",""))=0 D  Q
    64         ..N DA,DIK S DA=PXRMLIS1,DIK="^PXRMXP(810.5," D ^DIK
    65         .;Otherwise create patient list
    66         .D UPDLST^PXRMRULE("PXRMXPAT",PXRMLIS1,"","","",PXRMDPAT,PXRMTPAT)
    67         .S $P(^PXRMXP(810.5,PXRMLIS1,0),U,9)=1
    68         K ^TMP($J,"PXRMXPAT")
    69         K ^TMP($J),^TMP(PXRMRT,$J),^TMP("PXRMDUP",$J)
    70         K ^TMP("PXRMCMB",$J),^TMP("PXRMCMB1",$J),^TMP("PXRMCMB2",$J),^TMP("PXRMCMB3",$J)
    71         K DBDOWN
    72         ;
    73 DONE    ;
    74         ;Sorting is done.
    75         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W ! D DONE^PXRMXBSY("done")
    76         ;
    77         ;I PXRMDBUG="Y" D DEBUG("End of evaluation:",PXRMREP,"^XTMP(PXRMXTMP,PX)")
    78         ;Print the report information.
    79         I PXRMQUE D  Q
    80         .;Start the printing that was queued but not scheduled.
    81         .N DESC,ROUTINE,TASK
    82         .S ROUTINE="^PXRMXPR"
    83         .S DESC="Reminder Due Report - print"
    84         .S TASK=$G(^XTMP(PXRMXTMP,"PRZTSK"))
    85         .I TASK="" D NOPRZTSK(PXRMXTMP) Q
    86         .D REQUE^PXRMXQUE(DESC,ROUTINE,TASK)
    87         .S ZTREQ="@"
    88         I 'PXRMQUE D ^PXRMXPR
    89         Q
    90         ;
    91 AWRITE(REF,LS)      ;This line tag is a copy of AWRITE^PXRMUTIL
    92         N CNT,DONE,IC,IND,LEN,PROOT,ROOT,START,TEMP
    93         I REF="" Q
    94         S PROOT=$P(REF,")",1)
    95         S TEMP=$NA(@REF)
    96         S ROOT=$P(TEMP,")",1)
    97         S REF=$Q(@REF)
    98         I REF'[ROOT Q
    99         S DONE=0,CNT=LS
    100         F IC=0:0 Q:(REF="")!(DONE)  D
    101         . S START=$F(REF,ROOT)
    102         . S LEN=$L(REF)
    103         . S IND=$E(REF,START,LEN)
    104         . S CNT=CNT+1,^TMP("PXRMXMZ",$J,CNT,0)=PROOT_IND_"="_@REF
    105         . S REF=$Q(@REF)
    106         . I REF'[ROOT S DONE=1
    107         Q
    108         ;
    109 DEBUG(LOC,TYPE,REF)     ;
    110         N CNT,DDAT,FACILITY,HEADER,PNAM,PX,SUB
    111         K ^TMP("PXRMXMZ",$J)
    112         S PX="PXRM"
    113         I TYPE'="P"&(TYPE'="DEBUG") D  Q
    114         .D AWRITE(REF,0)
    115         .D SEND^PXRMMSG("Debug output: "_LOC_" Reminder Report type "_TYPE_" ("_$$NOW^XLFDT_")",DUZ)
    116         D AWRITE(REF,0)
    117         S HEADER=LOC_" ("_$$NOW^XLFDT_")"
    118         D SEND^PXRMMSG("Debug output: "_HEADER,DUZ)
    119         Q
    120         ;
    121 ERROR(STATUS,ITEM)      ;
    122         ;Create XTMP entry for Reminders that error out or could not be
    123         ;determing on evaluation
    124         N ERRNAME
    125         S STATUS=$P(STATUS,U)
    126         S ERRNAME=$P(^PXD(811.9,ITEM,0),U)
    127         I $D(^XTMP(PXRMXTMP,STATUS,ERRNAME))>0,^XTMP(PXRMXTMP,STATUS,ERRNAME)>0 D
    128         .S ^XTMP(PXRMXTMP,STATUS,ERRNAME)=^XTMP(PXRMXTMP,STATUS,ERRNAME)+1
    129         E  S ^XTMP(PXRMXTMP,STATUS,ERRNAME)=1
    130         Q
    131         ;
    132         ;End Task requested
    133 EXIT    ;
    134         S ZTSK=$G(^XTMP(PXRMXTMP,"PRZTSK"))
    135         I ZTSK>0 D KILL^%ZTLOAD
    136         D EXIT^PXRMXGUT
    137         K DBDOWN
    138         Q
    139         ;
    140 NOPRZTSK(PXRMXTMP)            ;Could not get PRZTSK send an error message
    141         N TEXT
    142         K ^TMP("PXRMXMZ",$J)
    143         S TEXT(1,0)="The task number for the print job cannot be determined."
    144         S TEXT(2,0)="The reason is:"
    145         I '$D(^XTMP(PXRMXTMP)) S TEXT(3,0)=" The ^XTMP(PXRMXTMP) global is not defined."
    146         I $D(^XTMP(PXRMXTMP)),'$D(^XTMP(PXRMXTMP,"PRZTSK")) S TEXT(3,0)=" ^XTMP(PXRMXTMP,""PRZTSK"") does not exist."
    147         I $D(^XTMP(PXRMXTMP,"PRZTSK")) S TEXT(3,0)=" ^XMTP(PXRMXTMP,""PRZTSK"") is null."
    148         S TEXT(4,0)="PXRMXTMP="_PXRMXTMP
    149         M ^TMP("PXRMXMZ",$J)=TEXT
    150         D SEND^PXRMMSG("REMINDER REPORT ERROR",DUZ)
    151         Q
    152         ;
    153 XTMP(START)     ;
    154         N CNT,CCNT,DDAT,INP,ITEM,LIT,LSSN,MCNBD,MCNBDR,NAME
    155         N SUB,STATUS,TEMP,TEMP1,TEXT
    156         K ^TMP($J,"PXRM CNBD")
    157         S CCNT=0,MCNBD=$G(^PXRM(800,1,"MIERR")),MCNBDR=0
    158         ;I PXRMDBUG="Y" D DEBUG("PATIENT DATA","P","^TMP($J,""PXRM PATIENT EVAL"")")
    159         S BUSY=0,SUB="NAM",TEMP=0,PX="PXRM"
    160         N DDAT,DDUE,DEMARR,DFN,DLAST,DNEXT,FACILITY,NAM,PNAM
    161         S FACILITY="",DDAT="N/A"
    162         F  S FACILITY=$O(^TMP(PXRMRT,$J,FACILITY)) Q:FACILITY=""  D
    163         .S NAM=""
    164         .F  S NAM=$O(^TMP(PXRMRT,$J,FACILITY,NAM)) Q:NAM=""  D
    165         ..S DFN="" F  S DFN=$O(^TMP(PXRMRT,$J,FACILITY,NAM,DFN)) Q:DFN=""  D
    166         ...I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D SPIN^PXRMXBSY("Evaluating Reminders",.BUSY)
    167         ...S INP=$G(^TMP(PXRMRT,$J,FACILITY,NAM,DFN))
    168         ...S CNT=0 F  S CNT=$O(REMINDER(CNT)) Q:CNT'>0  D
    169         ....S ITEM=$P(REMINDER(CNT),U,1),LIT=$P(REMINDER(CNT),U,4)
    170         ....I LIT="" S LIT=$P(REMINDER(CNT),U,2)
    171         ....S STATUS=$G(^TMP($J,"PXRM PATIENT EVAL",DFN,ITEM))
    172         ....I STATUS="" Q
    173         ....I STATUS["ERROR"!(STATUS["CNBD") D
    174         .....D ERROR(STATUS,ITEM) I STATUS["ERROR"!(MCNBDR=1) Q
    175         .....I CCNT=0 D  Q
    176         ......S ^TMP($J,"PXRM CNBD",1,0)=$$RJ^XLFSTR(" ",5)_$$LJ^XLFSTR("PATIENT NAME",30)_$$RJ^XLFSTR("LAST 4",10)
    177         ......S (TEMP,TEMP1)=""
    178         ......F X=1:1:30 S TEMP=TEMP_"_"
    179         ......F X=1:1:6 S TEMP1=TEMP1_"_"
    180         ......S ^TMP($J,"PXRM CNBD",2,0)=$$RJ^XLFSTR(" ",5)_$$LJ^XLFSTR(TEMP,30)_$$RJ^XLFSTR(TEMP1,10)
    181         ......S CCNT=2
    182         .....S CCNT=CCNT+1
    183         .....I CCNT>MCNBD S MCNBDR=1 Q
    184         .....S NAME=$P(^DPT(DFN,0),U)
    185         .....S LSSN=$E($P(^DPT(DFN,0),U,9),6,9)
    186         .....S ^TMP($J,"PXRM CNBD",CCNT,0)=$$RJ^XLFSTR(" ",5)_$$LJ^XLFSTR(NAME,30)_$$RJ^XLFSTR(LSSN,10)
    187         ....;Add reminder status to patient list TMP Global
    188         ....I STATUS["DUE NOW" S ^TMP($J,"PXRMXPAT",DFN,"REM",ITEM)=ITEM_U_STATUS
    189         ....I PXRMREP="D" D SDET^PXRMXDT1(DFN,STATUS,NAM,FACILITY,INP)
    190         ....I PXRMREP="S" D SUM^PXRMXDT1(DFN,STATUS,FACILITY,NAM)
    191         I $D(^TMP($J,"PXRM CNBD"))>0 D ERRMSG^PXRMXDT1("C")
    192         K ^TMP($J,"PXRM CNBD")
    193         S END=$H
    194         S TEXT="Elapsed time for reminder evaluation: "_$$DETIME^PXRMXSL1(START,END)
    195         S ^XTMP(PXRMXTMP,"TIMING","REMINDER EVALUATION")=TEXT
    196         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    197         ;I PXRMDBUG="Y" D DEBUG("DEBUG PATIENT DATA EVALUATION","DEBUG","^TMP($J,""PXRMDEBUG"")")
    198         K ^TMP($J,"PXRM PATIENT EVAL")
    199         Q
    200         ;
     1PXRMXSE1 ; SLC/PJH - Build Patient lists for Reminder Due report; 01/25/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called/jobbed from PXRMXD
     5 ;
     6 ; Input - PXRMSEL,PXRMXTMP
     7 ;         PXRM*
     8 ; Output- ^XTMP(PXRMXTMP
     9 ;
     10 ;
     11START ; 
     12 N LIT,TOTAL,TODAY,ZTSTOP,BUSY
     13 S DBDOWN=0
     14 S TOTAL=0,ZTSTOP="",TODAY=$$DT^XLFDT-.0001
     15 ;
     16 K ^TMP($J,"PXRM PATIENT LIST"),^TMP($J,"PXRM PATIENT EVAL")
     17 K ^TMP($J,"PXRM FUTURE APPT"),^TMP($J,"SDAMA301")
     18 K ^TMP($J),^TMP(PXRMRT,$J),^TMP("PXRMDUP",$J)
     19 K ^TMP("PXRMCMB",$J),^TMP("PXRMCMB1",$J),^TMP("PXRMCMB2",$J)
     20 N PXRMRERR
     21 ;
     22 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     23 ;
     24 ;OE/RR team selected (PXRMOTM)
     25 I PXRMSEL="O" D OERR^PXRMXSL1
     26 ;
     27 ;PCMM team selected (PXRMPCM)
     28 I PXRMSEL="T" D PCMMT^PXRMXSL1
     29 ;
     30 N HLIEN,FACILITY
     31 ;Location selected (PXRMLCHL,PXRMCGRP)
     32 I PXRMSEL="L" D  G:ZTSTOP=1 EXIT
     33 .;Build Clinic List
     34 .D BHLOC^PXRMXSL1
     35 .;Prior Visits - build patient list in ^TMP
     36 .I PXRMFD="P" D VISITS^PXRMXSL2 I DBDOWN=1 Q
     37 .;Inpatient Admissions and current inpatient locations
     38 .I PXRMFD="A"!(PXRMFD="C") D INPADM^PXRMXSL1
     39 .;Future Appointments - build patient list in ^TMP
     40 .I PXRMFD="F" D APPTS^PXRMXSL2 I DBDOWN=1 Q
     41 .;End task requested
     42 .Q:ZTSTOP=1
     43 ;Update ^XTMP from ^TMP
     44 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     45 ;
     46 ;PCMM provider selected (PXRMPRV)
     47 I PXRMSEL="P" D PCMMP^PXRMXSL1
     48 ;
     49 ;Individual Patients selected (PXRMPAT)
     50 I PXRMSEL="I" D IND^PXRMXSL1
     51 ;
     52 ;Patient List selected (PXRMLIST)
     53 I PXRMSEL="R" D LIST^PXRMXSL1
     54 ;
     55 I DBDOWN=1 G EXIT
     56 S START=$H
     57 D EVAL^PXRMXEVL("PXRM PATIENT EVAL",.REMINDER)
     58 D XTMP(START)
     59 ;
     60 ;Update patient list
     61 I PXRMSEL'="I"&(PXRMUSER'="Y")&($G(PXRMLIS1)'="") D
     62 .;If no patients due delete patient list
     63 .I +$O(^TMP($J,"PXRMXPAT",""))=0 D  Q
     64 ..N DA,DIK S DA=PXRMLIS1,DIK="^PXRMXP(810.5," D ^DIK
     65 .;Otherwise create patient list
     66 .D UPDLST^PXRMRULE("PXRMXPAT",PXRMLIS1,"","")
     67 .S $P(^PXRMXP(810.5,PXRMLIS1,0),U,9)=1
     68 K ^TMP($J,"PXRMXPAT")
     69 K ^TMP($J),^TMP(PXRMRT,$J),^TMP("PXRMDUP",$J)
     70 K ^TMP("PXRMCMB",$J),^TMP("PXRMCMB1",$J),^TMP("PXRMCMB2",$J),^TMP("PXRMCMB3",$J)
     71 K DBDOWN
     72 ;
     73DONE ;
     74 ;Sorting is done.
     75 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W ! D DONE^PXRMXBSY("done")
     76 ;
     77 ;I PXRMDBUG="Y" D DEBUG("End of evaluation:",PXRMREP,"^XTMP(PXRMXTMP,PX)")
     78 ;Print the report information.
     79 I PXRMQUE D  Q
     80 .;Start the printing that was queued but not scheduled.
     81 .N DESC,ROUTINE,TASK
     82 .S ROUTINE="^PXRMXPR"
     83 .S DESC="Reminder Due Report - print"
     84 .S TASK=$G(^XTMP(PXRMXTMP,"PRZTSK"))
     85 .I TASK="" D NOPRZTSK(PXRMXTMP) Q
     86 .D REQUE^PXRMXQUE(DESC,ROUTINE,TASK)
     87 .S ZTREQ="@"
     88 I 'PXRMQUE D ^PXRMXPR
     89 Q
     90 ;
     91AWRITE(REF,LS)     ;This line tag is a copy of AWRITE^PXRMUTIL
     92 N CNT,DONE,IC,IND,LEN,PROOT,ROOT,START,TEMP
     93 I REF="" Q
     94 S PROOT=$P(REF,")",1)
     95 S TEMP=$NA(@REF)
     96 S ROOT=$P(TEMP,")",1)
     97 S REF=$Q(@REF)
     98 I REF'[ROOT Q
     99 S DONE=0,CNT=LS
     100 F IC=0:0 Q:(REF="")!(DONE)  D
     101 . S START=$F(REF,ROOT)
     102 . S LEN=$L(REF)
     103 . S IND=$E(REF,START,LEN)
     104 . S CNT=CNT+1,^TMP("PXRMXMZ",$J,CNT,0)=PROOT_IND_"="_@REF
     105 . S REF=$Q(@REF)
     106 . I REF'[ROOT S DONE=1
     107 Q
     108 ;
     109DEBUG(LOC,TYPE,REF) ;
     110 N CNT,DDAT,FACILITY,HEADER,PNAM,PX,SUB
     111 K ^TMP("PXRMXMZ",$J)
     112 S PX="PXRM"
     113 I TYPE'="P"&(TYPE'="DEBUG") D  Q
     114 .D AWRITE(REF,0)
     115 .D SEND^PXRMMSG("Debug output: "_LOC_" Reminder Report type "_TYPE_" ("_$$NOW^XLFDT_")",DUZ)
     116 D AWRITE(REF,0)
     117 S HEADER=LOC_" ("_$$NOW^XLFDT_")"
     118 D SEND^PXRMMSG("Debug output: "_HEADER,DUZ)
     119 Q
     120 ;
     121ERROR(STATUS,ITEM) ;
     122 ;Create XTMP entry for Reminders that error out or could not be
     123 ;determing on evaluation
     124 N ERRNAME
     125 S STATUS=$P(STATUS,U)
     126 S ERRNAME=$P(^PXD(811.9,ITEM,0),U)
     127 I $D(^XTMP(PXRMXTMP,STATUS,ERRNAME))>0,^XTMP(PXRMXTMP,STATUS,ERRNAME)>0 D
     128 .S ^XTMP(PXRMXTMP,STATUS,ERRNAME)=^XTMP(PXRMXTMP,STATUS,ERRNAME)+1
     129 E  S ^XTMP(PXRMXTMP,STATUS,ERRNAME)=1
     130 Q
     131 ;
     132 ;End Task requested
     133EXIT ;
     134 S ZTSK=$G(^XTMP(PXRMXTMP,"PRZTSK"))
     135 I ZTSK>0 D KILL^%ZTLOAD
     136 D EXIT^PXRMXGUT
     137 K DBDOWN
     138 Q
     139 ;
     140NOPRZTSK(PXRMXTMP)       ;Could not get PRZTSK send an error message
     141 N TEXT
     142 K ^TMP("PXRMXMZ",$J)
     143 S TEXT(1,0)="The task number for the print job cannot be determined."
     144 S TEXT(2,0)="The reason is:"
     145 I '$D(^XTMP(PXRMXTMP)) S TEXT(3,0)=" The ^XTMP(PXRMXTMP) global is not defined."
     146 I $D(^XTMP(PXRMXTMP)),'$D(^XTMP(PXRMXTMP,"PRZTSK")) S TEXT(3,0)=" ^XTMP(PXRMXTMP,""PRZTSK"") does not exist."
     147 I $D(^XTMP(PXRMXTMP,"PRZTSK")) S TEXT(3,0)=" ^XMTP(PXRMXTMP,""PRZTSK"") is null."
     148 S TEXT(4,0)="PXRMXTMP="_PXRMXTMP
     149 M ^TMP("PXRMXMZ",$J)=TEXT
     150 D SEND^PXRMMSG("REMINDER REPORT ERROR",DUZ)
     151 Q
     152 ;
     153XTMP(START) ;
     154 N CNT,CCNT,DDAT,INP,ITEM,LIT,LSSN,MCNBD,MCNBDR,NAME,SUB,STATUS,TEMP,TEMP1
     155 K ^TMP($J,"PXRM CNBD")
     156 S CCNT=0,MCNBD=$G(^PXRM(800,1,"MIERR")),MCNBDR=0
     157 ;I PXRMDBUG="Y" D DEBUG("PATIENT DATA","P","^TMP($J,""PXRM PATIENT EVAL"")")
     158 S BUSY=0,SUB="NAM",TEMP=0,PX="PXRM"
     159 N DDAT,DDUE,DEMARR,DFN,DLAST,DNEXT,FACILITY,NAM,PNAM
     160 S FACILITY="",DDAT="N/A"
     161 F  S FACILITY=$O(^TMP(PXRMRT,$J,FACILITY)) Q:FACILITY=""  D
     162 .S NAM=""
     163 .F  S NAM=$O(^TMP(PXRMRT,$J,FACILITY,NAM)) Q:NAM=""  D
     164 ..S DFN="" F  S DFN=$O(^TMP(PXRMRT,$J,FACILITY,NAM,DFN)) Q:DFN=""  D
     165 ...I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D SPIN^PXRMXBSY("Evaluating Reminders",.BUSY)
     166 ...S INP=$G(^TMP(PXRMRT,$J,FACILITY,NAM,DFN))
     167 ...S CNT=0 F  S CNT=$O(REMINDER(CNT)) Q:CNT'>0  D
     168 ....S ITEM=$P(REMINDER(CNT),U,1),LIT=$P(REMINDER(CNT),U,4)
     169 ....I LIT="" S LIT=$P(REMINDER(CNT),U,2)
     170 ....S STATUS=$G(^TMP($J,"PXRM PATIENT EVAL",DFN,ITEM))
     171 ....I STATUS="" Q
     172 ....I STATUS["ERROR"!(STATUS["CNBD") D
     173 .....D ERROR(STATUS,ITEM) I STATUS["ERROR"!(MCNBDR=1) Q
     174 .....I CCNT=0 D  Q
     175 ......S ^TMP($J,"PXRM CNBD",1,0)=$$RJ^XLFSTR(" ",5)_$$LJ^XLFSTR("PATIENT NAME",30)_$$RJ^XLFSTR("LAST 4",10)
     176 ......S (TEMP,TEMP1)=""
     177 ......F X=1:1:30 S TEMP=TEMP_"_"
     178 ......F X=1:1:6 S TEMP1=TEMP1_"_"
     179 ......S ^TMP($J,"PXRM CNBD",2,0)=$$RJ^XLFSTR(" ",5)_$$LJ^XLFSTR(TEMP,30)_$$RJ^XLFSTR(TEMP1,10)
     180 ......S CCNT=2
     181 .....S CCNT=CCNT+1
     182 .....I CCNT>MCNBD S MCNBDR=1 Q
     183 .....S NAME=$P(^DPT(DFN,0),U)
     184 .....S LSSN=$E($P(^DPT(DFN,0),U,9),6,9)
     185 .....S ^TMP($J,"PXRM CNBD",CCNT,0)=$$RJ^XLFSTR(" ",5)_$$LJ^XLFSTR(NAME,30)_$$RJ^XLFSTR(LSSN,10)
     186 ....;Add reminder status to patient list TMP Global
     187 ....I STATUS["DUE NOW" S ^TMP($J,"PXRMXPAT",DFN,"REM",ITEM)=ITEM_U_STATUS
     188 ....I PXRMREP="D" D SDET^PXRMXDT1(DFN,STATUS,NAM,FACILITY,INP)
     189 ....I PXRMREP="S" D SUM^PXRMXDT1(DFN,STATUS,FACILITY,NAM)
     190 I $D(^TMP($J,"PXRM CNBD"))>0 D DBDOWN^PXRMXDT1("C")
     191 K ^TMP($J,"PXRM CNBD")
     192 S END=$H
     193 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DETIME^PXRMXSL1(START,END,"Evaluating Reminders")
     194 ;I PXRMDBUG="Y" D DEBUG("DEBUG PATIENT DATA EVALUATION","DEBUG","^TMP($J,""PXRMDEBUG"")")
     195 K ^TMP($J,"PXRM PATIENT EVAL")
     196 Q
     197 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXSL1.m

    r613 r623  
    1 PXRMXSL1        ; SLC/PJH - Process Visits/Appts Reminder Due report;02/07/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMXSE
    5         ;
    6 TMP(DFN,NAM,FACILITY,INP)       ;Update ^TMP("PXRMX"
    7         I PXRMFCMB="Y" S FACILITY="COMBINED FACILITIES"
    8         I PXRMLCMB="Y" S NAM="COMBINED LOCATIONS"
    9         S ^TMP("PXRMX",$J,FACILITY,NAM,DFN)=INP
    10         Q
    11         ;
    12         ;Mark location as found
    13 MARK(IC)        ;
    14         S ^XTMP(PXRMXTMP,"MARKED AS FOUND",IC)=""
    15         Q
    16         ;
    17         ;Check if facility is on list, PXMRFACN.
    18 HFAC(HLOCIEN)   ;
    19         N DIV,HFAC
    20         ;DBIA #2804
    21         S HFAC=$P(^SC(HLOCIEN,0),U,4)
    22         I HFAC="" S DIV=$P($G(^SC(HLOCIEN,0)),U,15) S:DIV'="" HFAC=$P($G(^DG(40.8,DIV,0)),U,7)
    23         I HFAC="" S HFAC=+$P($$SITE^VASITE,U,3)
    24         I HFAC="" Q ""
    25         I '$D(PXRMFACN(HFAC)) Q ""
    26         Q HFAC
    27         ;
    28 INACTCL(HLIEN,PXRMBDT)  ;
    29         ;Check to see if clinic is inactivated before the start of
    30         ;the reporting period
    31         N INACT,REACT
    32         S INACT=+$P($G(^SC(HLIEN,"I")),U) I INACT=0 Q 0
    33         S REACT=+$P($G(^SC(HLIEN,"I")),U,2)
    34         I REACT'<INACT Q 0
    35         I INACT<PXRMBDT Q 1
    36         Q 0
    37         ;
    38 INPADM  ;
    39         ;Build list of inpatients admissions and current patients on a ward
    40         N BD,DFN,ED,FACILITY,HIEN,NAM
    41         S NAM="All Locations"
    42         S HIEN=0
    43         F  S HIEN=$O(^XTMP(PXRMXTMP,"HLOC",HIEN)) Q:HIEN'>0  D
    44         .S FACILITY=$P(^XTMP(PXRMXTMP,"HLOC",HIEN),U,1)
    45         .;Get WARDIEN,WARDNAM and return DFN's in PATS
    46         .N PATS
    47         .I PXRMFD="C" D WARD^PXRMXAP(HIEN,.PATS)
    48         .I PXRMFD="A" D
    49         ..; Get admissions from patient movements and return DFN's in PATS
    50         ..S BD=PXRMBDT-.0001
    51         ..S ED=PXRMEDT+.2359
    52         ..D ADM^PXRMXAP(HIEN,.PATS,BD,ED)
    53         .;Split report by location
    54         .I PXRMLCMB="N" S NAM=$P(^XTMP(PXRMXTMP,"HLOC",HIEN),U,2)
    55         .;Build ^TMP for selected patients
    56         .S DFN="",FOUND=0
    57         .F  S DFN=$O(PATS(DFN)) Q:DFN=""  D
    58         ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
    59         ..D TMP(DFN,NAM,FACILITY,HIEN) D MARK(HIEN)
    60         Q
    61         ;
    62 BHLOC   ;
    63         N CLINIEN,END,FACILITY,NAM,HLIEN,I,START,TEXT
    64         N INACT,REACT
    65         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    66         ;All inpatient, outpatient all location credit stop and encounter
    67         S START=$H
    68         I $P(PXRMLCSC,U)["HA"!($P(PXRMLCSC,U)="CA") D
    69         .S HLIEN=0 F  S HLIEN=$O(^SC(HLIEN)) Q:HLIEN'>0  D
    70         ..S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
    71         ..I $$INACTCL(HLIEN,PXRMBDT)=1 Q
    72         ..S NAM=$P(^SC(HLIEN,0),U)
    73         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
    74         ..;All inpatient location
    75         ..I $P(PXRMLCSC,U)="HAI",$D(^SC(HLIEN,42)) S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM Q
    76         ..;All outpatient locations
    77         ..I $P(PXRMLCSC,U)="HA",'$D(^SC(HLIEN,42)) S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM Q
    78         ..;All encounters with a credit stop
    79         ..I $P(PXRMLCSC,U)="CA",$P($G(^SC(HLIEN,0)),U,7)>0 S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM Q
    80         ;Select hosiptal locations
    81         I $P(PXRMLCSC,U,1)="HS" D
    82         .S HLIEN=0 F  S HLIEN=$O(PXRMLOCN(HLIEN)) Q:HLIEN'>0  D
    83         ..S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
    84         ..I $$INACTCL(HLIEN,PXRMBDT)=1 Q
    85         ..S NAM=$P(^SC(HLIEN,0),U)
    86         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
    87         ..S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM
    88         ;Select Credit Stops
    89         I PXRMSEL="L",$P(PXRMLCSC,U)="CS" D
    90         .S CLINIEN=0 F  S CLINIEN=$O(PXRMCSN(CLINIEN)) Q:CLINIEN'>0  D
    91         ..S HLIEN=0 F  S HLIEN=$O(^SC("AST",CLINIEN,HLIEN)) Q:HLIEN'>0  D
    92         ...S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
    93         ...I $$INACTCL(HLIEN,PXRMBDT)=1 Q
    94         ...S NAM=$P(^DIC(40.7,CLINIEN,0),U)_" "_$P(PXRMCS($G(PXRMCSN(CLINIEN))),U,3)
    95         ...I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
    96         ...S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM_U_$P(PXRMCS($G(PXRMCSN(CLINIEN))),U,3)
    97         ;Selected Clinic Groups
    98         I PXRMSEL="L",$E(PXRMLCSC)="G" D
    99         .S CGRPIEN=0 F  S CGRPIEN=$O(PXRMCGRN(CGRPIEN)) Q:CGRPIEN'>0  D
    100         ..S HLIEN=0 F  S HLIEN=$O(^SC("ASCRPW",CGRPIEN,HLIEN)) Q:HLIEN'>0  D
    101         ...S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
    102         ...I $$INACTCL(HLIEN,PXRMBDT)=1 Q
    103         ...I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
    104         ...S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_$P(^SC(HLIEN,0),U)_U_CGRPIEN
    105         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    106         S END=$H
    107         S TEXT="Elapsed time for building hospital locations: "_$$DETIME^PXRMXSL1(START,END)
    108         S ^XTMP(PXRMXTMP,"TIMING","BUILDING HOSPITAL LOCATIONS")=TEXT
    109         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    110         Q
    111         ;
    112 DETIME(START,END)       ;
    113         N ETIME,TEXT
    114         S ETIME=$$HDIFF^XLFDT(END,START,2)
    115         I ETIME>90 D
    116         . S ETIME=$$HDIFF^XLFDT(END,START,3)
    117         . S TEXT=ETIME
    118         E  S TEXT=ETIME_" secs"
    119         Q TEXT
    120         ;
    121 OERR    ;
    122         N CNT,II,NAM,OTM
    123         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    124         S II=""
    125         ;Get patient list for each team
    126         F  S II=$O(PXRMOTM(II)) Q:II=""  D
    127         .S OTM=$P(PXRMOTM(II),U),NAM=$P(PXRMOTM(II),U,2)
    128         .;Build list of patients for OE/RR team ; DBIA #2692
    129         .K ^TMP($J,"OTM")
    130         .D TEAMPTS^ORQPTQ1("^TMP($J,""OTM"",",OTM,1)
    131         .I $G(^TMP($J,"OTM",1))["No patients found" Q
    132         .I PXRMTCMB="Y" N OTM,NAM S OTM="COMBINED",NAM="COMBINED TEAMS"
    133         .S CNT=0 F  S CNT=$O(^TMP($J,"OTM",CNT)) Q:CNT'>0  D
    134         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from OE/RR List",.BUSY)
    135         ..S DFN=$P(^TMP($J,"OTM",CNT),U)
    136         ..D UPD1(DFN,NAM,"FACILITY",II)
    137         .D MARK(OTM)
    138         K ^TMP($J,"OTM")
    139         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    140         I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
    141         Q
    142         ;
    143         ;PCMM provider selected
    144 PCMMP   ;
    145         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    146         N CNT,SCDT,LIST,SCERR,SCLIST,II,PCM,NAM,PNAM,PXRM,OK
    147         N FACILITY,NAM
    148         S SCDT("BEGIN")=PXRMSDT,SCDT("END")=PXRMSDT
    149         ;Include patient if in team on any day in range
    150         S SCDT("INCL")=0
    151         S II=""
    152         ;Get patient list for each PROVIDER
    153         F  S II=$O(PXRMPRV(II)) Q:II=""  D
    154         .S PCM=$P(PXRMPRV(II),U),NAM=$P(PXRMPRV(II),U,2)
    155         .;Get patients for practs. roles - excluding assoc clinics
    156         .K ^TMP($J,"PCM")
    157         .N SCTEAM D PTPR^PXRMXAP(PCM,PXRMREP)
    158         .I $O(^TMP($J,"PCM",0))="" Q
    159         .;Save in ^TMP in alpha order within team number (internal)
    160         .S CNT=0 F  S CNT=$O(^TMP($J,"PCM",CNT)) Q:CNT'>0  D
    161         ..S DFN=$P(^TMP($J,"PCM",CNT),U)
    162         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from Primary Provider List",.BUSY)
    163         ..I PXRMPRIM="P",($$PCASSIGN^PXRMXAP(DFN)'=1) Q
    164         ..;For detailed provider report get assoc clinic
    165         ..I PXRMREP="D" S DCLN=$P(^TMP($J,"PCM",CNT),U,7) I +$G(DCLN)>0 D
    166         ...S FACILITY=$$HFAC(DCLN)
    167         ...S NAM=$P(^SC(DCLN,0),U)
    168         ...S ^XTMP(PXRMXTMP,"HLOC",DCLN)=FACILITY_U_NAM
    169         ..I $G(DCLN)'="" S PXRMDCLN(DCLN)=""
    170         ..D UPD1(DFN,NAM,"FACILITY",+$G(DCLN))
    171         .D MARK(PCM)
    172         K ^TMP($J,"PCM")
    173         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    174         I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
    175         Q
    176         ;
    177         ;PCMM team selected
    178 PCMMT   ;
    179         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    180         N CNT,SCDT,LIST,SCERR,SCLIST,II,PCM,NAM,PNAM,OK
    181         S SCDT("BEGIN")=PXRMSDT,SCDT("END")=PXRMSDT
    182         ;Include patient if in team on any day in range
    183         S SCDT("INCL")=0
    184         S II=""
    185         ;Get patient list for each team
    186         F  S II=$O(PXRMPCM(II)) Q:II=""  D
    187         .S PCM=$P(PXRMPCM(II),U),NAM=$P(PXRMPCM(II),U,2)
    188         .K ^TMP($J,"PCM")
    189         .S OK=$$PTTM^PXRMXAP(PCM,.SCERR) Q:'OK
    190         .I $O(^TMP($J,"PCM",0))="" Q
    191         .S FACILITY=$$FAC^PXRMXAP(PCM)
    192         .S CNT=0 F  S CNT=$O(^TMP($J,"PCM",CNT)) Q:CNT'>0  D
    193         ..S DFN=$P(^TMP($J,"PCM",CNT),U)
    194         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from PCMM Team List",.BUSY)
    195         ..D UPD1(DFN,NAM,FACILITY,II)
    196         .D MARK(PCM)
    197         K ^TMP($J,"PCM")
    198         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    199         I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
    200         Q
    201         ;
    202         ;Individual Patients selected
    203 IND     ;
    204         N CNT,DFN,DUMMY,LIST,NAM
    205         S (DUMMY,NAM)="PATIENT"
    206         S CNT=0 F  S CNT=$O(PXRMPAT(CNT)) Q:CNT'>0  D
    207         .S DFN=$P(PXRMPAT(CNT),U)
    208         .D UPD1(DFN,"INDIVIDUAL PATIENTS","FACILITY",DFN)
    209         I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
    210         Q
    211         ;
    212         ;Patient lists selected
    213 LIST    ;
    214         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    215         N DFN,DSUB,DUMMY,LCNT,LIEN,LIST,NAM
    216         S (DUMMY,NAM)="PATIENT",LCNT=0
    217         F  S LCNT=$O(PXRMLIST(LCNT)) Q:'LCNT  D
    218         .S LIEN=$P(PXRMLIST(LCNT),U) Q:'LIEN
    219         .S NAM=$P(^PXRMXP(810.5,LIEN,0),U)
    220         .S DSUB=0
    221         .F  S DSUB=$O(^PXRMXP(810.5,LIEN,30,DSUB)) Q:'DSUB  D
    222         ..S DFN=$P($G(^PXRMXP(810.5,LIEN,30,DSUB,0)),U) Q:'DFN
    223         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from Reminder Patient List",.BUSY)
    224         ..D UPD1(DFN,NAM,"FACILITY",LIEN)
    225         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    226         I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
    227         Q
    228         ;
    229 UPD1(DFN,NAM,FACILITY,INP)      ;
    230         ;Remove test patients.
    231         I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
    232         ;Remove patients that are deceased.
    233         I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
    234         S ^TMP($J,"PXRM PATIENT LIST",DFN)=""
    235         S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
    236         D TMP(DFN,NAM,FACILITY,INP)
    237         Q
    238         ;
     1PXRMXSL1 ; SLC/PJH - Process Visits/Appts Reminder Due report;12/09/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRMXSE
     5 ;
     6TMP(DFN,NAM,FACILITY,INP) ;Update ^TMP("PXRMX"
     7 I PXRMFCMB="Y" S FACILITY="COMBINED FACILITIES"
     8 I PXRMLCMB="Y" S NAM="COMBINED LOCATIONS"
     9 S ^TMP("PXRMX",$J,FACILITY,NAM,DFN)=INP
     10 Q
     11 ;
     12 ;Mark location as found
     13MARK(IC) ;
     14 S ^XTMP(PXRMXTMP,"MARKED AS FOUND",IC)=""
     15 Q
     16 ;
     17 ;Check if facility is on list, PXMRFACN.
     18HFAC(HLOCIEN) ;
     19 N DIV,HFAC
     20 ;DBIA #2804
     21 S HFAC=$P(^SC(HLOCIEN,0),U,4)
     22 I HFAC="" S DIV=$P($G(^SC(HLOCIEN,0)),U,15) S:DIV'="" HFAC=$P($G(^DG(40.8,DIV,0)),U,7)
     23 I HFAC="" S HFAC=+$P($$SITE^VASITE,U,3)
     24 I HFAC="" Q ""
     25 I '$D(PXRMFACN(HFAC)) Q ""
     26 Q HFAC
     27 ;
     28INPADM ;
     29 ;Build list of inpatients admissions and current patients on a ward
     30 N BD,DFN,ED,FACILITY,HIEN,NAM
     31 S NAM="All Locations"
     32 S HIEN=0
     33 F  S HIEN=$O(^XTMP(PXRMXTMP,"HLOC",HIEN)) Q:HIEN'>0  D
     34 .S FACILITY=$P(^XTMP(PXRMXTMP,"HLOC",HIEN),U,1)
     35 .;Get WARDIEN,WARDNAM and return DFN's in PATS
     36 .N PATS
     37 .I PXRMFD="C" D WARD^PXRMXAP(HIEN,.PATS)
     38 .I PXRMFD="A" D
     39 ..; Get admissions from patient movements and return DFN's in PATS
     40 ..S BD=PXRMBDT-.0001
     41 ..S ED=PXRMEDT+.2359
     42 ..D ADM^PXRMXAP(HIEN,.PATS,BD,ED)
     43 .;Split report by location
     44 .I PXRMLCMB="N" S NAM=$P(^XTMP(PXRMXTMP,"HLOC",HIEN),U,2)
     45 .;Build ^TMP for selected patients
     46 .S DFN="",FOUND=0
     47 .F  S DFN=$O(PATS(DFN)) Q:DFN=""  D
     48 ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
     49 ..D TMP(DFN,NAM,FACILITY,HIEN) D MARK(HIEN)
     50 Q
     51 ;
     52BHLOC ;
     53 N CLINIEN,END,FACILITY,NAM,HLIEN,I,START
     54 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     55 ;All inpatient, outpatient all location credit stop and encounter
     56 S START=$H
     57 I $P(PXRMLCSC,U)["HA"!($P(PXRMLCSC,U)="CA") D
     58 .S HLIEN=0 F  S HLIEN=$O(^SC(HLIEN)) Q:HLIEN'>0  D
     59 ..S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
     60 ..S NAM=$P(^SC(HLIEN,0),U)
     61 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
     62 ..;All inpatient location
     63 ..I $P(PXRMLCSC,U)="HAI",$D(^SC(HLIEN,42)) S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM Q
     64 ..;All outpatient locations
     65 ..I $P(PXRMLCSC,U)="HA",'$D(^SC(HLIEN,42)) S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM Q
     66 ..;All encounters with a credit stop
     67 ..I $P(PXRMLCSC,U)="CA",$P($G(^SC(HLIEN,0)),U,7)>0 S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM Q
     68 ;Select hosiptal locations
     69 I $P(PXRMLCSC,U,1)="HS" D
     70 .S HLIEN=0 F  S HLIEN=$O(PXRMLOCN(HLIEN)) Q:HLIEN'>0  D
     71 ..S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
     72 ..S NAM=$P(^SC(HLIEN,0),U)
     73 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
     74 ..S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM
     75 ;Select Credit Stops
     76 I PXRMSEL="L",$P(PXRMLCSC,U)="CS" D
     77 .S CLINIEN=0 F  S CLINIEN=$O(PXRMCSN(CLINIEN)) Q:CLINIEN'>0  D
     78 ..S HLIEN=0 F  S HLIEN=$O(^SC("AST",CLINIEN,HLIEN)) Q:HLIEN'>0  D
     79 ...S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
     80 ...S NAM=$P(^DIC(40.7,CLINIEN,0),U)_" "_$P(PXRMCS($G(PXRMCSN(CLINIEN))),U,3)
     81 ...I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
     82 ...S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_NAM_U_$P(PXRMCS($G(PXRMCSN(CLINIEN))),U,3)
     83 ;Selected Clinic Groups
     84 I PXRMSEL="L",$E(PXRMLCSC)="G" D
     85 .S CGRPIEN=0 F  S CGRPIEN=$O(PXRMCGRN(CGRPIEN)) Q:CGRPIEN'>0  D
     86 ..S HLIEN=0 F  S HLIEN=$O(^SC("ASCRPW",CGRPIEN,HLIEN)) Q:HLIEN'>0  D
     87 ...S FACILITY=$$HFAC(HLIEN) I FACILITY'>0 Q
     88 ...I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Hospital Locations List",.BUSY)
     89 ...S ^XTMP(PXRMXTMP,"HLOC",HLIEN)=FACILITY_U_$P(^SC(HLIEN,0),U)_U_CGRPIEN
     90 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     91 S END=$H
     92 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DETIME(START,END,"Building Hospital Locations")
     93 Q
     94 ;
     95DETIME(START,END,SECTION) ;
     96 N ETIME,TEXT
     97 S ETIME=$$HDIFF^XLFDT(END,START,2)
     98 I ETIME>90 D
     99 . S ETIME=$$HDIFF^XLFDT(END,START,3)
     100 . S TEXT="Elapsed time for "_SECTION_": "_ETIME
     101 E  S TEXT="Elapsed time for "_SECTION_": "_ETIME_" secs"
     102 D MES^XPDUTL(TEXT)
     103 Q
     104 ;
     105OERR ;
     106 N CNT,II,NAM,OTM
     107 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     108 S II=""
     109 ;Get patient list for each team
     110 F  S II=$O(PXRMOTM(II)) Q:II=""  D
     111 .S OTM=$P(PXRMOTM(II),U),NAM=$P(PXRMOTM(II),U,2)
     112 .;Build list of patients for OE/RR team ; DBIA #2692
     113 .K ^TMP($J,"OTM")
     114 .D TEAMPTS^ORQPTQ1("^TMP($J,""OTM"",",OTM,1)
     115 .I $G(^TMP($J,"OTM",1))["No patients found" Q
     116 .I PXRMTCMB="Y" N OTM,NAM S OTM="COMBINED",NAM="COMBINED TEAMS"
     117 .S CNT=0 F  S CNT=$O(^TMP($J,"OTM",CNT)) Q:CNT'>0  D
     118 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from OE/RR List",.BUSY)
     119 ..S DFN=$P(^TMP($J,"OTM",CNT),U)
     120 ..D UPD1(DFN,NAM,"FACILITY",II)
     121 .D MARK(OTM)
     122 K ^TMP($J,"OTM")
     123 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     124 I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
     125 Q
     126 ;
     127 ;PCMM provider selected
     128PCMMP ;
     129 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     130 N CNT,SCDT,LIST,SCERR,SCLIST,II,PCM,NAM,PNAM,PXRM,OK
     131 S SCDT("BEGIN")=PXRMSDT,SCDT("END")=PXRMSDT
     132 ;Include patient if in team on any day in range
     133 S SCDT("INCL")=0
     134 S II=""
     135 ;Get patient list for each PROVIDER
     136 F  S II=$O(PXRMPRV(II)) Q:II=""  D
     137 .S PCM=$P(PXRMPRV(II),U),NAM=$P(PXRMPRV(II),U,2)
     138 .;Get patients for practs. roles - excluding assoc clinics
     139 .K ^TMP($J,"PCM")
     140 .N SCTEAM D PTPR^PXRMXAP(PCM,PXRMREP)
     141 .I $O(^TMP($J,"PCM",0))="" Q
     142 .;Save in ^TMP in alpha order within team number (internal)
     143 .S CNT=0 F  S CNT=$O(^TMP($J,"PCM",CNT)) Q:CNT'>0  D
     144 ..S DFN=$P(^TMP($J,"PCM",CNT),U)
     145 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from Primary Provider List",.BUSY)
     146 ..I PXRMPRIM="P",($$PCASSIGN^PXRMXAP(DFN)'=1) Q
     147 ..;For detailed provider report get assoc clinic
     148 ..I PXRMREP="D" S DCLN=$P(^TMP($J,"PCM",CNT),U,7) I $G(DCLN)'="" S ^XTMP(PXRMXTMP,"HLOC",DCLN)=""
     149 ..I $G(DCLN)'="" S PXRMDCLN(DCLN)=""
     150 ..D UPD1(DFN,NAM,"FACILITY",+$G(DCLN))
     151 .D MARK(PCM)
     152 K ^TMP($J,"PCM")
     153 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     154 I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
     155 Q
     156 ;
     157 ;PCMM team selected
     158PCMMT ;
     159 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     160 N CNT,SCDT,LIST,SCERR,SCLIST,II,PCM,NAM,PNAM,OK
     161 S SCDT("BEGIN")=PXRMSDT,SCDT("END")=PXRMSDT
     162 ;Include patient if in team on any day in range
     163 S SCDT("INCL")=0
     164 S II=""
     165 ;Get patient list for each team
     166 F  S II=$O(PXRMPCM(II)) Q:II=""  D
     167 .S PCM=$P(PXRMPCM(II),U),NAM=$P(PXRMPCM(II),U,2)
     168 .K ^TMP($J,"PCM")
     169 .S OK=$$PTTM^PXRMXAP(PCM,.SCERR) Q:'OK
     170 .I $O(^TMP($J,"PCM",0))="" Q
     171 .S FACILITY=$$FAC^PXRMXAP(PCM)
     172 .S CNT=0 F  S CNT=$O(^TMP($J,"PCM",CNT)) Q:CNT'>0  D
     173 ..S DFN=$P(^TMP($J,"PCM",CNT),U)
     174 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from PCMM Team List",.BUSY)
     175 ..D UPD1(DFN,NAM,FACILITY,II)
     176 .D MARK(PCM)
     177 K ^TMP($J,"PCM")
     178 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     179 I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
     180 Q
     181 ;
     182 ;Individual Patients selected
     183IND ;
     184 N CNT,DFN,DUMMY,LIST,NAM
     185 S (DUMMY,NAM)="PATIENT"
     186 S CNT=0 F  S CNT=$O(PXRMPAT(CNT)) Q:CNT'>0  D
     187 .S DFN=$P(PXRMPAT(CNT),U)
     188 .D UPD1(DFN,"INDIVIDUAL PATIENTS","FACILITY",DFN)
     189 I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
     190 Q
     191 ;
     192 ;Patient lists selected
     193LIST ;
     194 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     195 N DFN,DSUB,DUMMY,LCNT,LIEN,LIST,NAM
     196 S (DUMMY,NAM)="PATIENT",LCNT=0
     197 F  S LCNT=$O(PXRMLIST(LCNT)) Q:'LCNT  D
     198 .S LIEN=$P(PXRMLIST(LCNT),U) Q:'LIEN
     199 .S NAM=$P(^PXRMXP(810.5,LIEN,0),U)
     200 .S DSUB=0
     201 .F  S DSUB=$O(^PXRMXP(810.5,LIEN,30,DSUB)) Q:'DSUB  D
     202 ..S DFN=$P($G(^PXRMXP(810.5,LIEN,30,DSUB,0)),U) Q:'DFN
     203 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Collecting patients from Reminder Patient List",.BUSY)
     204 ..D UPD1(DFN,NAM,"FACILITY",LIEN)
     205 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     206 I PXRMREP="D",$D(^TMP($J,"PXRM PATIENT EVAL"))>0 D SDAM301^PXRMXSL2(DT,"",PXRMSEL,PXRMFD,PXRMREP)
     207 Q
     208 ;
     209UPD1(DFN,NAM,FACILITY,INP) ;
     210 ;Remove test patients.
     211 I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
     212 ;Remove patients that are deceased.
     213 I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
     214 S ^TMP($J,"PXRM PATIENT LIST",DFN)=""
     215 S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
     216 D TMP(DFN,NAM,FACILITY,INP)
     217 Q
     218 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXSL2.m

    r613 r623  
    1 PXRMXSL2        ; SLC/AGP - Process Visits/Appts Reminder Due report; 08/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4 APPTS   ;
    5         ;Call to SDAMA301 for future appointments
    6         N APPTDT,BDT,EDT,NODE,DFN,FACILITY,HLIEN,NAM
    7         S NAM="All Locations"
    8         S BDT=PXRMBDT
    9         ;I PXRMBDT["." S BDT=PXRMBDT
    10         ;E  S BDT=PXRMBDT-.0001
    11         I PXRMEDT["." S EDT=PXRMEDT
    12         E  S EDT=PXRMEDT+.2359
    13         D SDAM301(BDT,EDT,PXRMSEL,PXRMFD,PXRMREP)
    14         I DBDOWN=1 Q
    15         S DFN=0 F  S DFN=$O(^TMP($J,"SDAMA301",DFN)) Q:DFN'>0!(ZTSTOP=1)  D
    16         .;Remove test patients.
    17         .I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
    18         .;Remove patients that are deceased.
    19         .I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
    20         .S APPTDT=0 F  S APPTDT=$O(^TMP($J,"SDAMA301",DFN,APPTDT)) Q:APPTDT'>0!(ZTSTOP=1)  D
    21         ..S NODE=$G(^TMP($J,"SDAMA301",DFN,APPTDT))
    22         ..S HLIEN=$P($P(NODE,U,2),";")
    23         ..S FACILITY=$P(^XTMP(PXRMXTMP,"HLOC",HLIEN),U,1)
    24         ..S NAM=$P(^XTMP(PXRMXTMP,"HLOC",HLIEN),U,2)
    25         ..I PXRMREP="D" D
    26         ...S ^TMP($J,"PXRM FUTURE APPT",DFN,HLIEN,APPTDT)=NODE
    27         ...S ^TMP($J,"PXRM FACILITY FUTURE APPT",DFN,FACILITY,APPTDT)=NODE
    28         ..I $$S^%ZTLOAD S ZTSTOP=1 Q
    29         ..D TMP^PXRMXSL1(DFN,NAM,FACILITY,HLIEN),MARK^PXRMXSL1(HLIEN)
    30         ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
    31         K ^TMP($J,"SDAMA301")
    32         Q
    33         ;
    34 GETHFAC(HLOCIEN)        ;
    35         N DIV,HFAC
    36         ;DBIA #2804
    37         S HFAC=$P(^SC(HLOCIEN,0),U,4)
    38         I HFAC="" S DIV=$P($G(^SC(HLOCIEN,0)),U,15) S:DIV'="" HFAC=$P($G(^DG(40.8,DIV,0)),U,7)
    39         I HFAC="" S HFAC=+$P($$SITE^VASITE,U,3)
    40         Q +HFAC
    41         ;
    42 SDAM301(BD,ED,PXRMSEL,PXRMFD,PXRMREP)   ;
    43         N ARRAY,BUSY,FACILITY,NAM,OPIEN,STATUS,TEXT
    44         K ^TMP($J,"PXRM FUTURE APPT")
    45         K ^TMP($J,"PXRM FACILITY FUTURE APPT")
    46         ;
    47         I ED'>0 S ARRAY(1)=BD
    48         I ED>0 S ARRAY(1)=BD_";"_ED
    49         I PXRMREP="D",PXRMSEL="L",PXRMFD="P" S ARRAY(1)=BD
    50         ;
    51         I $D(^XTMP(PXRMXTMP,"HLOC"))>0 S ARRAY(2)="^XTMP(PXRMXTMP,""HLOC"","
    52         ;S ARRAY(3)=$S(PXRMFD="P":"R;I;NS;NSR;CP;CPR;CC;CCR;NT",1:"R;I")
    53         S ARRAY(3)=$S(PXRMFD="P":"R;I",1:"R;I;NT")
    54         I $D(^TMP($J,"PXRM PATIENT LIST"))>0 S ARRAY(4)="^TMP($J,""PXRM PATIENT LIST"""
    55         S ARRAY("FLDS")="1;2;3;10;12;13;14;22"
    56         I $D(^TMP($J,"PXRM PATIENT LIST"))=0 S ARRAY("SORT")="P"
    57         ;
    58         N END,START,BUSY
    59         S START=$H
    60         S BUSY=0
    61         ;DBIA #4433
    62         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    63         I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y"))) D SPIN^PXRMXBSY("Calling the scheduling package to gather appointment data",.BUSY)
    64         S COUNT=$$SDAPI^SDAMA301(.ARRAY)
    65         S END=$H
    66         S TEXT="Elapsed time for call to the Scheduling Package: "_$$DETIME^PXRMXSL1(START,END)
    67         S ^XTMP(PXRMXTMP,"TIMING","SCHEDULING")=TEXT
    68         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    69         I COUNT<0 D  Q
    70         .N CNT
    71         .S DBDOWN=1,CNT=0
    72         .F  S CNT=$O(^TMP($J,"SDAMA301",CNT)) Q:CNT'>0  D
    73         ..S DBERR(CNT)=$G(^TMP($J,"SDAMA301",CNT))
    74         .D ERRMSG^PXRMXDT1("E")
    75         ;
    76 LOOP    ;
    77         I PXRMFD'="P"!(PXRMSEL'="L") Q
    78         N APPTDT,CIEN,DFN,FUTDT,NODE,TEXT,VIEN
    79         ;LOOP THROUGH PATIENT
    80         S START=$H
    81         S BUSY=0
    82         S FUTDT=$S(DT>$P(ED,"."):DT,1:$P(ED,"."))
    83         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D SPIN^PXRMXBSY("Sorting SDAMA301 Output",.BUSY)
    84         S DFN=0 F  S DFN=$O(^TMP($J,"SDAMA301",DFN)) Q:DFN'>0  D
    85         .;
    86         .;LOOP THROUGH CLINICS
    87         .S CIEN=0
    88         .F  S CIEN=$O(^TMP($J,"SDAMA301",DFN,CIEN)) Q:CIEN'>0  D
    89         ..S APPTDT=0
    90         ..F  S APPTDT=$O(^TMP($J,"SDAMA301",DFN,CIEN,APPTDT)) Q:APPTDT'>0  D
    91         ...I PXRMREP="S",$P(APPTDT,".")>$P(ED,".") Q
    92         ...S NODE=$G(^TMP($J,"SDAMA301",DFN,CIEN,APPTDT))
    93         ...;S STATUS=$P($P(NODE,U,3),";")
    94         ...;I ($P(ED,".")+1)>($P(APPTDT,".")),STATUS'="I",STATUS'="R",STATUS'="NT" D
    95         ...;.K ^TMP($J,"PXRM PATIENT LIST",DFN,CIEN,APPTDT)
    96         ...;
    97         ...;if report is detailed report store future appointment
    98         ...I $P(APPTDT,".")>FUTDT D
    99         ....S ^TMP($J,"PXRM FUTURE APPT",DFN,CIEN,APPTDT)=NODE
    100         ....S ^TMP($J,"PXRM FACILITY FUTURE APPT",DFN,$$GETHFAC(CIEN),APPTDT)=NODE
    101         K ^TMP($J,"SDAMA301")
    102         S END=$H
    103         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    104         S TEXT="Elapsed time for sorting SDAMA301 output: "_$$DETIME^PXRMXSL1(START,END)
    105         S ^XTMP(PXRMXTMP,"TIMING","SCHEDULE SORT")=TEXT
    106         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    107         Q
    108         ;
    109         ;Scan visit file to build list of patients
    110 VISITS  ;
    111         N BUSY,DAS,DATE,DFN,DS,END,ETIME,HLOC,NF
    112         N SC,START,TEMP,TEXT,TGLIST,TIME
    113         S START=$H
    114         K ^TMP($J,"PXRM PATIENT LIST")
    115         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    116         W !,"Building patient list "
    117         K ^TMP($J,"HLOCL"),^TMP($J,"PLIST")
    118         M ^TMP($J,"HLOCL")=^XTMP(PXRMXTMP,"HLOC")
    119         D FPLIST^PXRMLOCL(9000010,"HLOCL",-1,PXRMBDT,PXRMEDT,"PLIST")
    120         K ^TMP($J,"HLOCL")
    121         S DFN=""
    122         F  S DFN=$O(^TMP($J,"PLIST",DFN)) Q:DFN=""  D
    123         . S NF=0
    124         . F  S NF=$O(^TMP($J,"PLIST",DFN,NF)) Q:NF=""  D
    125         .. S TEMP=^TMP($J,"PLIST",DFN,NF)
    126         .. S SC=$P(TEMP,U,4)
    127         .. I '$D(PXRMSCAT(SC)) Q
    128         .. ;Remove test Patients
    129         .. I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
    130         .. ;Remove deceased patients
    131         .. I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
    132         .. S DAS=$P(TEMP,U,1),DATE=$P(TEMP,U,2),HLOC=$P(TEMP,U,3)
    133         .. S ^TMP($J,"PXRM PATIENT LIST",DFN,HLOC,DATE,DAS)=""
    134         K ^TMP($J,"PLIST")
    135         S END=$H
    136         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    137         S TEXT="Elapsed time for building patient list: "_$$DETIME^PXRMXSL1(START,END)
    138         S ^XTMP(PXRMXTMP,"TIMING","PATIENT LIST")=TEXT
    139         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    140         I PXRMREP="D" D SDAM301(PXRMBDT,PXRMEDT,PXRMSEL,PXRMFD,PXRMREP)
    141         I DBDOWN=1 Q
    142         S START=$H
    143         S BUSY=0
    144         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    145         N HLIEN,NAM,FACILITY,LSEL,NODE
    146         S DFN=0 F  S DFN=$O(^TMP($J,"PXRM PATIENT LIST",DFN)) Q:DFN'>0  D
    147         .S HLIEN=0
    148         .F  S HLIEN=$O(^TMP($J,"PXRM PATIENT LIST",DFN,HLIEN)) Q:HLIEN'>0  D
    149         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Removing Invalid Encounter(s)",.BUSY)
    150         ..S NODE=$G(^XTMP(PXRMXTMP,"HLOC",HLIEN))
    151         ..S FACILITY=$P(NODE,U),NAM=$P(NODE,U,2)
    152         ..D TMP^PXRMXSL1(DFN,NAM,FACILITY,HLIEN)
    153         ..S TEMP=$P(PXRMLCSC,U,1)
    154         ..S LSEL=$S(TEMP="CS":$P(NODE,U,3),TEMP="GS":$P(NODE,U,3),1:HLIEN)
    155         ..D MARK^PXRMXSL1(LSEL)
    156         ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
    157         S END=$H
    158         S TEXT="Elapsed time for removing invalid encounter(s): "_$$DETIME^PXRMXSL1(START,END)
    159         S ^XTMP(PXRMXTMP,"TIMING","REMOVING INVALID ENCOUNTER(S)")=TEXT
    160         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    161         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    162         Q
    163         ;
    164 VISITSO ; Old entry point
    165         N BTIME,DAS,DATE,DEND,DFN,DONE,DS,ETIME,HLOC,INVBD,INVDATE,INVDT,INVED
    166         N NFOUND,SC,TEMP,TEXT,TGLIST,TIME
    167         N DOD,START,END
    168         S START=$H
    169         K ^TMP($J,"PXRM PATIENT LIST")
    170         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    171         S DEND=$S(PXRMEDT[".":PXRMEDT,1:PXRMEDT+.240001)
    172         ;"AHL" in Visit file is inverse date_.time instead of a full inverse
    173         ;date and time. For example if the date/time is 3030704.104449 then
    174         ;"AHL" has 6969295.104449 instead of 6969295.89555
    175         S INVBD=9999999-$P(PXRMBDT,".",1),BTIME=+("."_$P(PXRMBDT,".",2))
    176         S INVED=9999999-$P(DEND,".",1),ETIME=+("."_$P(DEND,".",2))
    177         S DS=INVED-.000001
    178         S HLOC=""
    179         F  S HLOC=$O(^XTMP(PXRMXTMP,"HLOC",HLOC)) Q:HLOC=""  D
    180         . S INVDT=DS,DONE=0
    181         . F  S INVDT=$O(^AUPNVSIT("AHL",HLOC,INVDT)) Q:(DONE)!(INVDT="")  D
    182         ..I $$S^%ZTLOAD S ZTSTOP=1 Q
    183         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Patient List",.BUSY)
    184         .. S INVDATE=$P(INVDT,".",1)
    185         .. I INVDATE>INVBD S DONE=1 Q
    186         .. S TIME=+("."_$P(INVDT,".",2))
    187         .. I INVDATE=INVED,TIME>ETIME Q
    188         .. I INVDATE=INVBD,BTIME>TIME S DONE=1 Q
    189         .. S DAS=0
    190         .. F  S DAS=$O(^AUPNVSIT("AHL",HLOC,INVDT,DAS)) Q:DAS=""  D
    191         ... S TEMP=^AUPNVSIT(DAS,0)
    192         ... I $$VAPSTAT^PXRMVSIT(DAS)=0 Q
    193         ... S SC=$P(TEMP,U,7)
    194         ... I SC="" Q
    195         ... I '$D(PXRMSCAT(SC)) Q
    196         ... S DFN=$P(TEMP,U,5)
    197         ... ;Remove Test Patients
    198         ... I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
    199         ... ;Remove Patient that are deceased
    200         ... I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
    201         ... S DATE=$P(TEMP,U,1)
    202         ... S ^TMP($J,"PXRM PATIENT LIST",DFN,HLOC,DATE,DAS)=""
    203         S END=$H
    204         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    205         S TEXT="Elapsed time for building patient list: "_$$DETIME^PXRMXSL1(START,END)
    206         S ^XTMP(PXRMXTMP,"TIMING","PATIENT LIST")=TEXT
    207         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    208         I PXRMREP="D" D SDAM301(PXRMBDT,PXRMEDT,PXRMSEL,PXRMFD,PXRMREP)
    209         ;D SDAM301(PXRMBDT-.0001,PXRMEDT,PXRMSEL,PXRMFD,PXRMREP)
    210         ;
    211         I DBDOWN=1 Q
    212         S START=$H
    213         S BUSY=0
    214         N NODE
    215         I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
    216         N DFN,HLIEN,NAM,FACILITY,LSEL,TEMP
    217         S DFN=0 F  S DFN=$O(^TMP($J,"PXRM PATIENT LIST",DFN)) Q:DFN'>0  D
    218         .S HLIEN=0
    219         .F  S HLIEN=$O(^TMP($J,"PXRM PATIENT LIST",DFN,HLIEN)) Q:HLIEN'>0  D
    220         ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Removing Invalid Encounter(s)",.BUSY)
    221         ..S NODE=$G(^XTMP(PXRMXTMP,"HLOC",HLIEN))
    222         ..S FACILITY=$P(NODE,U),NAM=$P(NODE,U,2)
    223         ..D TMP^PXRMXSL1(DFN,NAM,FACILITY,HLIEN)
    224         ..S TEMP=$P(PXRMLCSC,U,1)
    225         ..S LSEL=$S(TEMP="CS":$P(NODE,U,3),TEMP="GS":$P(NODE,U,3),1:HLIEN)
    226         ..D MARK^PXRMXSL1(LSEL)
    227         ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
    228         S END=$H
    229         S TEXT="Elapsed time for removing invalid encounter(s): "_$$DETIME^PXRMXSL1(START,END)
    230         S ^XTMP(PXRMXTMP,"TIMING","REMOVING INVALID ENCOUNTER(S)")=TEXT
    231         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) W !,TEXT
    232         I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
    233         Q
     1PXRMXSL2 ; SLC/AGP - Process Visits/Appts Reminder Due report; 06/07/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4APPTS ;
     5 ;Call to SDAMA301 for future appointments
     6 N APPTDT,BDT,EDT,NODE,DFN,FACILITY,HLIEN,NAM
     7 S NAM="All Locations"
     8 I PXRMBDT["." S BDT=PXRMBDT
     9 E  S BDT=PXRMBDT-.0001
     10 I PXRMEDT["." S EDT=PXRMEDT
     11 E  S EDT=PXRMEDT+.2359
     12 D SDAM301(BDT,EDT,PXRMSEL,PXRMFD,PXRMREP)
     13 I DBDOWN=1 Q
     14 S DFN=0 F  S DFN=$O(^TMP($J,"SDAMA301",DFN)) Q:DFN'>0!(ZTSTOP=1)  D
     15 .;Remove test patients.
     16 .I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
     17 .;Remove patients that are deceased.
     18 .I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
     19 .S APPTDT=0 F  S APPTDT=$O(^TMP($J,"SDAMA301",DFN,APPTDT)) Q:APPTDT'>0!(ZTSTOP=1)  D
     20 ..S NODE=$G(^TMP($J,"SDAMA301",DFN,APPTDT))
     21 ..S HLIEN=$P($P(NODE,U,2),";")
     22 ..S FACILITY=$P(^XTMP(PXRMXTMP,"HLOC",HLIEN),U,1)
     23 ..S NAM=$P(^XTMP(PXRMXTMP,"HLOC",HLIEN),U,2)
     24 ..I PXRMREP="D" D
     25 ...S ^TMP($J,"PXRM FUTURE APPT",DFN,HLIEN,APPTDT)=NODE
     26 ...S ^TMP($J,"PXRM FACILITY FUTURE APPT",DFN,FACILITY,APPTDT)=NODE
     27 ..I $$S^%ZTLOAD S ZTSTOP=1 Q
     28 ..D TMP^PXRMXSL1(DFN,NAM,FACILITY,HLIEN),MARK^PXRMXSL1(HLIEN)
     29 ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
     30 K ^TMP($J,"SDAMA301")
     31 Q
     32 ;
     33GETHFAC(HLOCIEN) ;
     34 N DIV,HFAC
     35 ;DBIA #2804
     36 S HFAC=$P(^SC(HLOCIEN,0),U,4)
     37 I HFAC="" S DIV=$P($G(^SC(HLOCIEN,0)),U,15) S:DIV'="" HFAC=$P($G(^DG(40.8,DIV,0)),U,7)
     38 I HFAC="" S HFAC=+$P($$SITE^VASITE,U,3)
     39 Q +HFAC
     40 ;
     41SDAM301(BD,ED,PXRMSEL,PXRMFD,PXRMREP) ;
     42 N ARRAY,BUSY,FACILITY,NAM,OPIEN,STATUS
     43 K ^TMP($J,"PXRM FUTURE APPT")
     44 K ^TMP($J,"PXRM FACILITY FUTURE APPT")
     45 ;
     46 I ED'>0 S ARRAY(1)=BD
     47 I ED>0 S ARRAY(1)=BD_";"_ED
     48 I PXRMREP="D",PXRMSEL="L",PXRMFD="P" S ARRAY(1)=BD
     49 ;
     50 I $D(^XTMP(PXRMXTMP,"HLOC"))>0 S ARRAY(2)="^XTMP(PXRMXTMP,""HLOC"","
     51 ;S ARRAY(3)=$S(PXRMFD="P":"R;I;NS;NSR;CP;CPR;CC;CCR;NT",1:"R;I")
     52 S ARRAY(3)=$S(PXRMFD="P":"R;I",1:"R;I;NT")
     53 I $D(^TMP($J,"PXRM PATIENT LIST"))>0 S ARRAY(4)="^TMP($J,""PXRM PATIENT LIST"""
     54 S ARRAY("FLDS")="1;2;3;10;12;13;14;22"
     55 I $D(^TMP($J,"PXRM PATIENT LIST"))=0 S ARRAY("SORT")="P"
     56 ;
     57 N END,START,BUSY
     58 S START=$H
     59 S BUSY=0
     60 ;DBIA #4433
     61 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     62 I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y"))) D SPIN^PXRMXBSY("Calling the scheduling package to gather appointment data",.BUSY)
     63 S COUNT=$$SDAPI^SDAMA301(.ARRAY)
     64 S END=$H
     65 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DETIME^PXRMXSL1(START,END,"Total amount of time to call the Scheduling Package")
     66 I COUNT<0 D  Q
     67 .N CNT
     68 .S DBDOWN=1,CNT=0
     69 .F  S CNT=$O(^TMP($J,"SDAMA301",CNT)) Q:CNT'>0  D
     70 ..S DBERR(CNT)=$G(^TMP($J,"SDAMA301",CNT))
     71 .D DBDOWN^PXRMXDT1("E")
     72 ;
     73LOOP ;
     74 I PXRMFD'="P"!(PXRMSEL'="L") Q
     75 N APPTDT,CIEN,DFN,FUTDT,NODE,VIEN
     76 ;LOOP THROUGH PATIENT
     77 S START=$H
     78 S BUSY=0
     79 S FUTDT=$S(DT>$P(ED,"."):DT,1:$P(ED,"."))
     80 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D SPIN^PXRMXBSY("Sorting SDAMA301 Output",.BUSY)
     81 S DFN=0 F  S DFN=$O(^TMP($J,"SDAMA301",DFN)) Q:DFN'>0  D
     82 .;
     83 .;LOOP THROUGH CLINICS
     84 .S CIEN=0
     85 .F  S CIEN=$O(^TMP($J,"SDAMA301",DFN,CIEN)) Q:CIEN'>0  D
     86 ..S APPTDT=0
     87 ..F  S APPTDT=$O(^TMP($J,"SDAMA301",DFN,CIEN,APPTDT)) Q:APPTDT'>0  D
     88 ...I PXRMREP="S",$P(APPTDT,".")>$P(ED,".") Q
     89 ...S NODE=$G(^TMP($J,"SDAMA301",DFN,CIEN,APPTDT))
     90 ...;S STATUS=$P($P(NODE,U,3),";")
     91 ...;I ($P(ED,".")+1)>($P(APPTDT,".")),STATUS'="I",STATUS'="R",STATUS'="NT" D
     92 ...;.K ^TMP($J,"PXRM PATIENT LIST",DFN,CIEN,APPTDT)
     93 ...;
     94 ...;if report is detailed report store future appointment
     95 ...I $P(APPTDT,".")>FUTDT D
     96 ....S ^TMP($J,"PXRM FUTURE APPT",DFN,CIEN,APPTDT)=NODE
     97 ....S ^TMP($J,"PXRM FACILITY FUTURE APPT",DFN,$$GETHFAC(CIEN),APPTDT)=NODE
     98 K ^TMP($J,"SDAMA301")
     99 S END=$H
     100 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     101 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DETIME^PXRMXSL1(START,END,"Sorting SDAMA301 Output")
     102 Q
     103 ;
     104 ;Scan visit file to build list of patients
     105VISITS ;
     106 N BTIME,DAS,DATE,DEND,DFN,DONE,DS,ETIME,HLOC,INVBD,INVDATE,INVDT,INVED
     107 N NFOUND,SC,TEMP,TGLIST,TIME
     108 N DOD,START,END
     109 S START=$H
     110 K ^TMP($J,"PXRM PATIENT LIST")
     111 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     112 S DEND=$S(PXRMEDT[".":PXRMEDT,1:PXRMEDT+.240001)
     113 ;"AHL" in Visit file is inverse date_.time instead of a full inverse
     114 ;date and time. For example if the date/time is 3030704.104449 then
     115 ;"AHL" has 6969295.104449 instead of 6969295.89555
     116 S INVBD=9999999-$P(PXRMBDT,".",1),BTIME=+("."_$P(PXRMBDT,".",2))
     117 S INVED=9999999-$P(DEND,".",1),ETIME=+("."_$P(DEND,".",2))
     118 S DS=INVED-1
     119 S HLOC=""
     120 F  S HLOC=$O(^XTMP(PXRMXTMP,"HLOC",HLOC)) Q:HLOC=""  D
     121 . S INVDT=DS,DONE=0
     122 . F  S INVDT=$O(^AUPNVSIT("AHL",HLOC,INVDT)) Q:(DONE)!(INVDT="")  D
     123 ..I $$S^%ZTLOAD S ZTSTOP=1 Q
     124 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Building Patient List",.BUSY)
     125 .. S INVDATE=$P(INVDT,".",1)
     126 .. I INVDATE>INVBD S DONE=1 Q
     127 .. S TIME=+("."_$P(INVDT,".",2))
     128 .. I INVDATE=INVED,TIME>ETIME Q
     129 .. I INVDATE=INVBD,BTIME>TIME S DONE=1 Q
     130 .. S DAS=0
     131 .. F  S DAS=$O(^AUPNVSIT("AHL",HLOC,INVDT,DAS)) Q:DAS=""  D
     132 ... S TEMP=^AUPNVSIT(DAS,0)
     133 ... I $$VAPSTAT^PXRMVSIT(DAS)=0 Q
     134 ... S SC=$P(TEMP,U,7)
     135 ... I SC="" Q
     136 ... I '$D(PXRMSCAT(SC)) Q
     137 ... S DFN=$P(TEMP,U,5)
     138 ... ;Remove Test Patients
     139 ... I 'PXRMTPAT,$$TESTPAT^VADPT(DFN)=1 Q
     140 ... ;Remove Patient that are deceased
     141 ... I 'PXRMDPAT,$P($G(^DPT(DFN,.35)),U,1)>0 Q
     142 ... S DATE=$P(TEMP,U,1)
     143 ... S ^TMP($J,"PXRM PATIENT LIST",DFN,HLOC,DATE,DAS)=""
     144 S END=$H
     145 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     146 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DETIME^PXRMXSL1(START,END,"Building Patient List")
     147 D SDAM301(PXRMBDT-.0001,PXRMEDT,PXRMSEL,PXRMFD,PXRMREP)
     148 ;
     149 I DBDOWN=1 Q
     150 S START=$H
     151 S BUSY=0
     152 I DBDOWN=1 Q
     153 N NODE
     154 I '(PXRMQUE!$D(IO("S"))) D INIT^PXRMXBSY(.BUSY)
     155 N DFN,HLIEN,NAM,FACILITY,LSEL,TEMP
     156 S DFN=0 F  S DFN=$O(^TMP($J,"PXRM PATIENT LIST",DFN)) Q:DFN'>0  D
     157 .S HLIEN=0
     158 .F  S HLIEN=$O(^TMP($J,"PXRM PATIENT LIST",DFN,HLIEN)) Q:HLIEN'>0  D
     159 ..I ('(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")))&(DBDOWN=0) D SPIN^PXRMXBSY("Removing Invalid Encounter(s)",.BUSY)
     160 ..S NODE=$G(^XTMP(PXRMXTMP,"HLOC",HLIEN))
     161 ..S FACILITY=$P(NODE,U),NAM=$P(NODE,U,2)
     162 ..D TMP^PXRMXSL1(DFN,NAM,FACILITY,HLIEN)
     163 ..S TEMP=$P(PXRMLCSC,U,1)
     164 ..S LSEL=$S(TEMP="CS":$P(NODE,U,3),TEMP="GS":$P(NODE,U,3),1:HLIEN)
     165 ..D MARK^PXRMXSL1(LSEL)
     166 ..S ^TMP($J,"PXRM PATIENT EVAL",DFN)=""
     167 S END=$H
     168 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DONE^PXRMXBSY("Done")
     169 I '(PXRMQUE!$D(IO("S"))!(PXRMTABS="Y")) D DETIME^PXRMXSL1(START,END,"Removing Invalid Encounter(s)")
     170 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXTB.m

    r613 r623  
    1 PXRMXTB ; SLC/PJH - Reminder Reports Template Load ;11/27/2006
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMXD
    5         ;
    6         ;Select Template
    7         ;---------------
    8 START   N X,Y,CNT,FOUND,PXRMFLD,DIC,MSG
    9         N ERR,SEQ,TMPLST,LIST
    10         K DIROUT,DIRUT,DTOUT,DUOUT
    11         S PXRMTMP="",FOUND=0
    12         ;
    13         ;Check if any templates exist for the user
    14         D GETLST^XPAR(.TMPLST,"USR","PXRM REPORT TEMPLATE (USER)","Q",.ERR)
    15         I ERR>0 W !!,?5,"Error: "_$P(ERR,U,2) S DUOUT=1 H 2 Q
    16         I 'TMPLST W !!,?5,"No report Templates for this user" S DUOUT=1 H 2 Q
    17         ;Build list of templates
    18         S SEQ=0
    19         F  S SEQ=$O(TMPLST(SEQ)) Q:'SEQ  D
    20         .S Y=$P(TMPLST(SEQ),U,2) Q:'Y
    21         .S LIST(Y)=""
    22         ;
    23         ;Select template required
    24         W !
    25         S CNT=0,DIC=810.1,DIC(0)="AEQMZ"
    26         S DIC("A")="Select REPORT TEMPLATE:"
    27         S DIC("S")="I $D(LIST(+Y)),$P(^PXRMPT(810.1,+Y,0),U,3)=PXRMTYP"
    28         D ^DIC
    29         W !!,"1"
    30         I X="" S DUOUT=1
    31         I X=(U_U) S DTOUT=1
    32         I '$D(DTOUT),('$D(DUOUT)) D
    33         .I +Y'=-1 D  Q
    34         ..S CNT=CNT+1,ARRAY(CNT)=Y_U_Y(0,0)_U_$P(Y(0),U,3)
    35         K DIC
    36         ;
    37         ;Load template into local array
    38         I (+Y'=-1)&('$D(DTOUT))&('$D(DUOUT)) D
    39         .L +^PXRMPT(810.1,$P(Y,U)):0
    40         .E  W !!?5,"Another user is editing this entry." S DUOUT=1 Q
    41         .;Load template into an array
    42         .S PXRMTMP=Y_U_$P(Y(0),U,2) D LOAD^PXRMXT
    43         .L -^PXRMPT(810.1,$P(PXRMTMP,U))
    44         .;Exit if problem loading template
    45         .I $D(MSG) S DTOUT=1 Q
    46         .;Display Template information
    47         .D:'$D(MSG) ^PXRMXTD
    48 EXIT    Q
    49         ;
    50 XREF    ;       
    51         K MREF,XREF
    52         S XREF("NAME")=.01
    53         S XREF("TITLE")=1.9
    54         S XREF("PXRMTYP")=1.1
    55         S XREF("PXRMSEL")=1.2
    56         S XREF("PXRMPRIM")=1.3
    57         S XREF("PXRMREP")=1.4
    58         S XREF("PXRMLCSC")=1.5
    59         S XREF("PXRMFD")=1.6
    60         S XREF("PXRMPML")=1.7
    61         S XREF("PXRMREM")=2
    62         S XREF("PXRMFAC")=3
    63         S XREF("PXRMPRV")=4
    64         S XREF("RUN")=5
    65         S XREF("PXRMPAT")=6
    66         S XREF("PXRMOTM")=7
    67         S XREF("PXRMPCM")=8
    68         S XREF("PXRMSCAT")=9
    69         S XREF("PXRMLCHL")=10
    70         S XREF("PXRMCS")=11
    71         S XREF("PXRMCGRP")=12
    72         S XREF("PXRMRCAT")=13
    73         S XREF("PXRMLIST")=14
    74         ;
    75         S MREF("REMINDER")=.01
    76         S MREF("PATIENT")=.01
    77         S MREF("PROVIDER")=.01
    78         S MREF("OERR TEAM")=.01
    79         S MREF("PCMM TEAM")=.01
    80         S MREF("FACILITY")=.01
    81         S MREF("SERVICE")=.01
    82         S MREF("LOCATION")=.01
    83         S MREF("STOP CODE")=.01
    84         S MREF("CLINIC GROUP")=.01
    85         S MREF("DISPLAY ORDER")=.02
    86         S MREF("REMINDER CATEGORY")=.01
    87         S MREF("DISPLAY")=.02
    88         S MREF("PXRMLIST")=.01
    89         Q
     1PXRMXTB ; SLC/PJH - Reminder Reports Template Load ;08/01/2001
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ; Called from PXRMXD
     5 ;
     6 ;Select Template
     7 ;---------------
     8START N X,Y,CNT,FOUND,PXRMFLD,DIC,MSG
     9 N ERR,SEQ,TMPLST,LIST
     10 K DIROUT,DIRUT,DTOUT,DUOUT
     11 S PXRMTMP="",FOUND=0
     12 ;
     13 ;Check if any templates exist for the user
     14 D GETLST^XPAR(.TMPLST,"USR","PXRM REPORT TEMPLATE (USER)","Q",.ERR)
     15 I ERR>0 W !!,?5,"Error: "_$P(ERR,U,2) S DUOUT=1 H 2 Q
     16 I 'TMPLST W !!,?5,"No report Templates for this user" S DUOUT=1 H 2 Q
     17 ;Build list of templates
     18 S SEQ=0
     19 F  S SEQ=$O(TMPLST(SEQ)) Q:'SEQ  D
     20 .S Y=$P(TMPLST(SEQ),U,2) Q:'Y
     21 .S LIST(Y)=""
     22 ;
     23 ;Select template required
     24 W !
     25 S CNT=0,DIC=810.1,DIC(0)="AEQMZ"
     26 S DIC("A")="Select REPORT TEMPLATE:"
     27 S DIC("S")="I $D(LIST(+Y)),$P(^PXRMPT(810.1,+Y,0),U,3)=PXRMTYP"
     28 D ^DIC
     29 W !!,"1"
     30 I X="" S DUOUT=1
     31 I X=(U_U) S DTOUT=1
     32 I '$D(DTOUT),('$D(DUOUT)) D
     33 .I +Y'=-1 D  Q
     34 ..S CNT=CNT+1,ARRAY(CNT)=Y_U_Y(0,0)_U_$P(Y(0),U,3)
     35 K DIC
     36 ;
     37 ;Load template into local array
     38 I (+Y'=-1)&('$D(DTOUT))&('$D(DUOUT)) D
     39 .L +^PXRMPT(810.1,$P(Y,U)):0
     40 .E  W !!?5,"Another user is editing this entry." S DUOUT=1 Q
     41 .;Load template into an array
     42 .S PXRMTMP=Y_U_$P(Y(0),U,2) D LOAD^PXRMXT
     43 .L -^PXRMPT(810.1,$P(PXRMTMP,U))
     44 .;Exit if problem loading template
     45 .I $D(MSG) S DTOUT=1 Q
     46 .;Display Template information
     47 .D:'$D(MSG) ^PXRMXTD
     48EXIT Q
     49 ;
     50XREF ;       
     51 K MREF,XREF
     52 S XREF("NAME")=.01
     53 S XREF("TITLE")=1.9
     54 S XREF("PXRMTYP")=1.1
     55 S XREF("PXRMSEL")=1.2
     56 S XREF("PXRMPRIM")=1.3
     57 S XREF("PXRMREP")=1.4
     58 S XREF("PXRMLCSC")=1.5
     59 S XREF("PXRMFD")=1.6
     60 S XREF("PXRMREM")=2
     61 S XREF("PXRMFAC")=3
     62 S XREF("PXRMPRV")=4
     63 S XREF("RUN")=5
     64 S XREF("PXRMPAT")=6
     65 S XREF("PXRMOTM")=7
     66 S XREF("PXRMPCM")=8
     67 S XREF("PXRMSCAT")=9
     68 S XREF("PXRMLCHL")=10
     69 S XREF("PXRMCS")=11
     70 S XREF("PXRMCGRP")=12
     71 S XREF("PXRMRCAT")=13
     72 S XREF("PXRMLIST")=14
     73 ;
     74 S MREF("REMINDER")=.01
     75 S MREF("PATIENT")=.01
     76 S MREF("PROVIDER")=.01
     77 S MREF("OERR TEAM")=.01
     78 S MREF("PCMM TEAM")=.01
     79 S MREF("FACILITY")=.01
     80 S MREF("SERVICE")=.01
     81 S MREF("LOCATION")=.01
     82 S MREF("STOP CODE")=.01
     83 S MREF("CLINIC GROUP")=.01
     84 S MREF("DISPLAY ORDER")=.02
     85 S MREF("REMINDER CATEGORY")=.01
     86 S MREF("DISPLAY")=.02
     87 S MREF("PXRMLIST")=.01
     88 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXTD.m

    r613 r623  
    1 PXRMXTD ; SLC/PJH - Reminder Reports Template Display ;11/16/2007
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMXT/PXRMXTF
    5         ;
    6         ;
    7         ;Display Template information
    8 START   ;----------------------------
    9         N PAGE,BMARG,DONE,SD,ED,DES,RDES,CDES,PSTART,PXRMOPT,IC,CNT
    10         S PAGE=1,BMARG=0,DONE=0,SD="",ED="",PSTART=10,CNT=0
    11         ;
    12         D LITS^PXRMXPR1
    13         ;
    14         I PXRMREP="D" S PXRMOPT="Detailed Report"
    15         I PXRMREP="S" S PXRMOPT="Summary Report"
    16         W !!?(PSTART),"Report Title:",?32,$P(PXRMTMP,U,3)
    17         W !?PSTART,"Report Type:",?32,$G(PXRMOPT)
    18         W !?PSTART,"Patient Sample:",?32,PXRMFLD
    19         I "LT"[PXRMSEL D
    20         .W !,?PSTART,"Facility:" D FAC
    21         I PXRMSEL'="L" W !,?PSTART,PXRMFLD,":" D ARRS
    22         I PXRMSEL="L" D
    23         .W !?PSTART,PXRMFLD,":",?32,DES
    24         .I $E(PXRMLCSC,2)'="A" W ! D ARRS
    25         I DONE Q
    26         W !?PSTART,"Print Locations without Patients:",?32,$S($G(PXRMPML)=0:"NO",1:"YES")
    27         S IC="" F  S IC=$O(PXRMRCAT(IC)) Q:IC=""  D  Q:DONE
    28         .W !,?PSTART W:IC=1 "Category:"
    29         .W ?32,$P(PXRMRCAT(IC),U,3),?35,$P(PXRMRCAT(IC),U,2) D CHECK(1)
    30         I DONE Q
    31         S IC="" F  S IC=$O(PXRMREM(IC)) Q:IC=""  D  Q:DONE
    32         .W !,?PSTART W:IC=1 "Reminder:"
    33         .W ?32,$P(PXRMREM(IC),U,3),?35,$P(PXRMREM(IC),U,2) D CHECK(1)
    34         I DONE Q
    35         I PXRMSEL="P" W !,?PSTART,"All/Primary:",?32,CDES
    36         W !?(PSTART),"Template Name:",?32,$P(PXRMTMP,U,2)
    37         W !?PSTART,"Date last run:",?32,$S(RUN]"":RUN,1:"n/a")
    38         I $D(PXRMSCAT),PXRMSCAT]"",PXRMFD="P" D OSCAT(PXRMSCAT,PSTART)
    39 EXIT    Q
    40         ;
    41         ;Display selected teams/providers
    42         ;--------------------------------
    43 ARRS    N IC
    44         S IC=""
    45         I PXRMSEL="P" F  S IC=$O(PXRMPRV(IC)) Q:IC=""  D  Q:DONE
    46         .W:IC>1 ! W ?32,$P(PXRMPRV(IC),U,2) D CHECK(1)
    47         I PXRMSEL="T" F  S IC=$O(PXRMPCM(IC)) Q:IC=""  D  Q:DONE
    48         .W:IC>1 ! W ?32,$P(PXRMPCM(IC),U,2) D CHECK(1)
    49         I PXRMSEL="O" F  S IC=$O(PXRMOTM(IC)) Q:IC=""  D  Q:DONE
    50         .W:IC>1 ! W ?32,$P(PXRMOTM(IC),U,2) D CHECK(1)
    51         I PXRMSEL="I" F  S IC=$O(PXRMPAT(IC)) Q:IC=""  D  Q:DONE
    52         .W:IC>1 ! W ?32,$P(PXRMPAT(IC),U,2) D CHECK(1)
    53         I PXRMSEL="R" F  S IC=$O(PXRMLIST(IC)) Q:IC=""  D  Q:DONE
    54         .W:IC>1 ! W ?32,$P(PXRMLIST(IC),U,2) D CHECK(1)
    55         I PXRMSEL="L" D
    56         .I $E(PXRMLCSC)="H" F  S IC=$O(PXRMLCHL(IC)) Q:IC=""  D
    57         ..W:IC>1 ! W ?32,$P(PXRMLCHL(IC),U) D CHECK(1)
    58         .I $E(PXRMLCSC)="C" F  S IC=$O(PXRMCS(IC)) Q:IC=""  D
    59         ..W:IC>1 ! W ?32,$P(PXRMCS(IC),U)," ",$P(PXRMCS(IC),U,3)
    60         ..D CHECK(1)
    61         .I $E(PXRMLCSC)="G" F  S IC=$O(PXRMCGRP(IC)) Q:IC=""  D
    62         ..W:IC>1 ! W ?32,$P(PXRMCGRP(IC),U)," ",$P(PXRMCGRP(IC),U,2)
    63         ..D CHECK(1)
    64         Q
    65         ;
    66         ;Display selected Facilities
    67         ;---------------------------
    68 FAC     N IC
    69         S IC=""
    70         F  S IC=$O(PXRMFAC(IC)) Q:IC=""  D  Q:DONE
    71         .W:IC>1 ! W ?32,$P(PXRMFAC(IC),U,2) D CHECK(1)
    72         Q
    73         ;
    74         ;
    75         ;Output the service categeories
    76         ;------------------------------
    77 OSCAT(SCL,PSTART)       ;
    78         N IC,CSTART,EM,SC,SCTEXT
    79         S CSTART=PSTART+3
    80         W !,?PSTART,"Service categories:",?32,SCL
    81         F IC=1:1:$L(SCL,",") D
    82         .S SC=$P(SCL,",",IC)
    83         .S SCTEXT=$$EXTERNAL^DILFD(9000010,.07,"",SC,.EM)
    84         .W !,?CSTART,SC," - ",SCTEXT
    85         .D CHECK(1)
    86         Q
    87         ;
    88         ;Check for page throw
    89         ;--------------------
    90 CHECK(LEAVE)    ;
    91         S CNT=CNT+1
    92         I CNT>(IOSL-BMARG-LEAVE) D PAGE S CNT=0
    93         Q
    94         ;
    95         ;form feed to new page
    96         ;---------------------
    97 PAGE    I ($E(IOST,1,2)="C-")&(IO=IO(0))&(PAGE>0) D
    98         .S DIR(0)="E"
    99         .W !
    100         .D ^DIR K DIR
    101         I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
    102         W !
    103         Q
     1PXRMXTD ; SLC/PJH - Reminder Reports Template Display ;11/03/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRMXT/PXRMXTF
     5 ;
     6 ;
     7 ;Display Template information
     8START ;----------------------------
     9 N PAGE,BMARG,DONE,SD,ED,DES,RDES,CDES,PSTART,PXRMOPT,IC,CNT
     10 S PAGE=1,BMARG=0,DONE=0,SD="",ED="",PSTART=10,CNT=0
     11 ;
     12 D LITS^PXRMXPR1
     13 ;
     14 I PXRMREP="D" S PXRMOPT="Detailed Report"
     15 I PXRMREP="S" S PXRMOPT="Summary Report"
     16 W !!?(PSTART),"Report Title:",?32,$P(PXRMTMP,U,3)
     17 W !?PSTART,"Report Type:",?32,$G(PXRMOPT)
     18 W !?PSTART,"Patient Sample:",?32,PXRMFLD
     19 I "LT"[PXRMSEL D
     20 .W !,?PSTART,"Facility:" D FAC
     21 I PXRMSEL'="L" W !,?PSTART,PXRMFLD,":" D ARRS
     22 I PXRMSEL="L" D
     23 .W !?PSTART,PXRMFLD,":",?32,DES
     24 .I $E(PXRMLCSC,2)'="A" W ! D ARRS
     25 I DONE Q
     26 S IC="" F  S IC=$O(PXRMRCAT(IC)) Q:IC=""  D  Q:DONE
     27 .W !,?PSTART W:IC=1 "Category:"
     28 .W ?32,$P(PXRMRCAT(IC),U,3),?35,$P(PXRMRCAT(IC),U,2) D CHECK(1)
     29 I DONE Q
     30 S IC="" F  S IC=$O(PXRMREM(IC)) Q:IC=""  D  Q:DONE
     31 .W !,?PSTART W:IC=1 "Reminder:"
     32 .W ?32,$P(PXRMREM(IC),U,3),?35,$P(PXRMREM(IC),U,2) D CHECK(1)
     33 I DONE Q
     34 I PXRMSEL="P" W !,?PSTART,"All/Primary:",?32,CDES
     35 W !?(PSTART),"Template Name:",?32,$P(PXRMTMP,U,2)
     36 W !?PSTART,"Date last run:",?32,$S(RUN]"":RUN,1:"n/a")
     37 I $D(PXRMSCAT),PXRMSCAT]"",PXRMFD="P" D OSCAT(PXRMSCAT,PSTART)
     38EXIT Q
     39 ;
     40 ;Display selected teams/providers
     41 ;--------------------------------
     42ARRS N IC
     43 S IC=""
     44 I PXRMSEL="P" F  S IC=$O(PXRMPRV(IC)) Q:IC=""  D  Q:DONE
     45 .W:IC>1 ! W ?32,$P(PXRMPRV(IC),U,2) D CHECK(1)
     46 I PXRMSEL="T" F  S IC=$O(PXRMPCM(IC)) Q:IC=""  D  Q:DONE
     47 .W:IC>1 ! W ?32,$P(PXRMPCM(IC),U,2) D CHECK(1)
     48 I PXRMSEL="O" F  S IC=$O(PXRMOTM(IC)) Q:IC=""  D  Q:DONE
     49 .W:IC>1 ! W ?32,$P(PXRMOTM(IC),U,2) D CHECK(1)
     50 I PXRMSEL="I" F  S IC=$O(PXRMPAT(IC)) Q:IC=""  D  Q:DONE
     51 .W:IC>1 ! W ?32,$P(PXRMPAT(IC),U,2) D CHECK(1)
     52 I PXRMSEL="R" F  S IC=$O(PXRMLIST(IC)) Q:IC=""  D  Q:DONE
     53 .W:IC>1 ! W ?32,$P(PXRMLIST(IC),U,2) D CHECK(1)
     54 I PXRMSEL="L" D
     55 .I $E(PXRMLCSC)="H" F  S IC=$O(PXRMLCHL(IC)) Q:IC=""  D
     56 ..W:IC>1 ! W ?32,$P(PXRMLCHL(IC),U) D CHECK(1)
     57 .I $E(PXRMLCSC)="C" F  S IC=$O(PXRMCS(IC)) Q:IC=""  D
     58 ..W:IC>1 ! W ?32,$P(PXRMCS(IC),U)," ",$P(PXRMCS(IC),U,3)
     59 ..D CHECK(1)
     60 .I $E(PXRMLCSC)="G" F  S IC=$O(PXRMCGRP(IC)) Q:IC=""  D
     61 ..W:IC>1 ! W ?32,$P(PXRMCGRP(IC),U)," ",$P(PXRMCGRP(IC),U,2)
     62 ..D CHECK(1)
     63 Q
     64 ;
     65 ;Display selected Facilities
     66 ;---------------------------
     67FAC N IC
     68 S IC=""
     69 F  S IC=$O(PXRMFAC(IC)) Q:IC=""  D  Q:DONE
     70 .W:IC>1 ! W ?32,$P(PXRMFAC(IC),U,2) D CHECK(1)
     71 Q
     72 ;
     73 ;
     74 ;Output the service categeories
     75 ;------------------------------
     76OSCAT(SCL,PSTART) ;
     77 N IC,CSTART,EM,SC,SCTEXT
     78 S CSTART=PSTART+3
     79 W !,?PSTART,"Service categories:",?32,SCL
     80 F IC=1:1:$L(SCL,",") D
     81 .S SC=$P(SCL,",",IC)
     82 .S SCTEXT=$$EXTERNAL^DILFD(9000010,.07,"",SC,.EM)
     83 .W !,?CSTART,SC," - ",SCTEXT
     84 .D CHECK(1)
     85 Q
     86 ;
     87 ;Check for page throw
     88 ;--------------------
     89CHECK(LEAVE) ;
     90 S CNT=CNT+1
     91 I CNT>(IOSL-BMARG-LEAVE) D PAGE S CNT=0
     92 Q
     93 ;
     94 ;form feed to new page
     95 ;---------------------
     96PAGE I ($E(IOST)="C")&(IO=IO(0))&(PAGE>0) D
     97 .S DIR(0)="E"
     98 .W !
     99 .D ^DIR K DIR
     100 I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)) S DONE=1 Q
     101 W !
     102 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXTE.m

    r613 r623  
    1 PXRMXTE ; SLC/PJH - Reminder Reports Template Edit ;11/27/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMYD,PXRMXD
    5         ;
    6         ;Option to Edit
    7         ;--------------
    8 EDIT    ;
    9         N DIDEL,DIE,DR K DTOUT,DUOUT
    10         ;Edit report name, title and PXRMSEL (patient sample)
    11         S DIE=810.1,DA=$P(PXRMTMP,U),DR=".01T;1.9;1.2",DIDEL=810.1
    12         D ^DIE I $D(Y) S DUOUT=1 Q
    13         ;Check if template has been deleted
    14         I '$D(DA) Q
    15         ;Get updated value of PXRMXSEL
    16         N PXRMSEL,PXRMFUT S PXRMSEL=X
    17         ;Needed for 1.6 validation - Prior/Future or Current/Admissions
    18         ;N PXRMINP
    19         ;Further fields depend on value in PXRMXSEL
    20         I PXRMSEL="I" S DR="6T~R",PXRMINP=0
    21         I PXRMSEL="R" S DR="14T",PXRMINP=0
    22         I PXRMSEL="L" D  Q:$D(DUOUT)
    23         .;Get location report type
    24         .S DR="3T;1.5R" D ^DIE I $D(Y) S DUOUT=1 Q
    25         .N PXRMLCSC S PXRMLCSC=X,DR="",PXRMINP=0
    26         .;All location reports - prompt for prior/future/current/admissions
    27         .I PXRMLCSC="HAI" S PXRMINP=1,DR="1.6" Q
    28         .I PXRMLCSC="HA" S PXRMINP=0,DR="1.6"
    29         .I PXRMLCSC="CA" S PXRMINP=0,DR="1.6"
    30         .D ^DIE I $D(Y) S DUOUT=1 Q
    31         .S PXRMFUT=X,DR=""
    32         .;Selected Location/Stop Code/Clinic Group fields
    33         .I PXRMLCSC="HS" D  Q:$D(DUOUT)
    34         ..S DR="10T~R"
    35         ..D ^DIE I $D(Y) S DUOUT=1 Q
    36         ..;Determine if locations input are all wards
    37         ..S PXRMINP=$$INP^PXRMXAP(PXRMLCSC,.PXRMLOCN)
    38         ..;Select Prior/Future or Current Inpatient/Admissions
    39         ..S DR="1.6"
    40         ..D ^DIE I $D(Y) S DUOUT=1 Q
    41         ..S PXRMFUT=X,DR=""
    42         .;Clinic Stop input and prior/future
    43         .I PXRMLCSC="CS" S PXRMINP=0,DR="11T~R;1.6" D  I $G(DUOUT)=1 Q
    44         ..D ^DIE I $D(Y) S DUOUT=1 Q
    45         ..S PXRMFUT=X,DR=""
    46         .;Clinic Group input and prior/future
    47         .I PXRMLCSC="GS" S PXRMINP=0,DR="12T~R;1.6" D  I $G(DUOUT)=1 Q
    48         ..D ^DIE I $D(Y) S DUOUT=1 Q
    49         ..S PXRMFUT=X,DR=""
    50         .;Service categories (except for inpatient reports)
    51         .I PXRMINP=0,PXRMFUT'="F",PXRMFUT'="C" S DR=DR_";9T~R"
    52         ;OE/RR teams
    53         I PXRMSEL="O" S DR="7T~R"
    54         ;PCMM Provider and Primary care/All
    55         I PXRMSEL="P" S DR="4T~R;1.3"
    56         ;PCMM teams
    57         I PXRMSEL="T" S DR="3T~R;8T~R"
    58         ;Report type (detail or summary)
    59         S DR=DR_";1.4"
    60         ;Print Locations without patients
    61         S DR=DR_";1.7"
    62         ;Reminder Categories
    63         I $D(^PXRMPT(810.1,DA,12,0))>0 D
    64         .N IEN,CNT,NODE
    65         .S CNT=0,IEN=0 F  S IEN=$O(^PXRMPT(810.1,DA,12,IEN)) Q:IEN'>0  D
    66         ..S CNT=CNT+1,NODE=$G(^PXRMPT(810.1,DA,12,IEN,0))
    67         ..S PXRMTCAT(DA,CNT)=$P(NODE,U)_U_$P($G(^PXRMD(811.7,$P(NODE,U),0)),U)_U_$P(NODE,U,2)
    68         S DR=DR_";13T"
    69         ;Reminders
    70         I $D(^PXRMPT(810.1,DA,1,0))>0 D
    71         .N IEN,CNT,NODE,REMNODE
    72         .S CNT=0,IEN=0 F  S IEN=$O(^PXRMPT(810.1,DA,1,IEN)) Q:IEN'>0  D
    73         ..S CNT=CNT+1,NODE=$G(^PXRMPT(810.1,DA,1,IEN,0))
    74         ..S REMNODE=$G(^PXD(811.9,$P(NODE,U),0))
    75         ..S PXRMTREM(DA,CNT)=$P(NODE,U)_U_$P(REMNODE,U)_U_$P(NODE,U,2)_U_$P($G(REMNODE),U,3)
    76         S DR=DR_";2T"
    77         ;
    78         ;Strip of any leading semi-colons
    79         I $E(DR)=";" S DR=$P(DR,";",2,99)
    80         ;
    81         D ^DIE I $D(Y) S DUOUT=1 Q
    82         ;
    83         ;If all reminders have been deleted from the template disallow save
    84         I +$P($G(^PXRMPT(810.1,DA,1,0)),U,4)=0 D
    85         .;Check categories also
    86         .I +$P($G(^PXRMPT(810.1,DA,12,0)),U,4)>0 D  Q
    87         .. N CAT,CATIEN
    88         .. S CAT=0 F  S CAT=$O(^PXRMPT(810.1,DA,12,CAT)) Q:+CAT'>0  D
    89         ... S CATIEN=$P($G(^PXRMPT(810.1,DA,12,CAT,0)),U)
    90         ... I +$P($G(^PXRMD(811.7,CATIEN,2,0)),U,4)<1 W !!,"** WARNING **",!,"Reminder Category "_$P($G(^PXRMD(811.7,CATIEN,0)),U)_" does not have any reminders assigned to it"
    91         .S DUOUT=1
    92         .W !!,"No reminders defined"
    93         Q
    94         ;
     1PXRMXTE ; SLC/PJH - Reminder Reports Template Edit ;08/03/2006
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRMYD,PXRMXD
     5 ;
     6 ;Option to Edit
     7 ;--------------
     8EDIT ;
     9 N DIDEL,DIE,DR K DTOUT,DUOUT
     10 ;Edit report name, title and PXRMSEL (patient sample)
     11 S DIE=810.1,DA=$P(PXRMTMP,U),DR=".01T;1.9;1.2",DIDEL=810.1
     12 D ^DIE I $D(Y) S DUOUT=1 Q
     13 ;Check if template has been deleted
     14 I '$D(DA) Q
     15 ;Get updated value of PXRMXSEL
     16 N PXRMSEL,PXRMFUT S PXRMSEL=X
     17 ;Needed for 1.6 validation - Prior/Future or Current/Admissions
     18 ;N PXRMINP
     19 ;Further fields depend on value in PXRMXSEL
     20 I PXRMSEL="I" S DR="6T~R",PXRMINP=0
     21 I PXRMSEL="R" S DR="14T",PXRMINP=0
     22 I PXRMSEL="L" D  Q:$D(DUOUT)
     23 .;Get location report type
     24 .S DR="3T;1.5R" D ^DIE I $D(Y) S DUOUT=1 Q
     25 .N PXRMLCSC S PXRMLCSC=X,DR="",PXRMINP=0
     26 .;All location reports - prompt for prior/future/current/admissions
     27 .I PXRMLCSC="HAI" S PXRMINP=1,DR="1.6" Q
     28 .I PXRMLCSC="HA" S PXRMINP=0,DR="1.6"
     29 .I PXRMLCSC="CA" S PXRMINP=0,DR="1.6"
     30 .D ^DIE I $D(Y) S DUOUT=1 Q
     31 .S PXRMFUT=X,DR=""
     32 .;Selected Location/Stop Code/Clinic Group fields
     33 .I PXRMLCSC="HS" D  Q:$D(DUOUT)
     34 ..S DR="10T~R"
     35 ..D ^DIE I $D(Y) S DUOUT=1 Q
     36 ..;Determine if locations input are all wards
     37 ..S PXRMINP=$$INP^PXRMXAP(PXRMLCSC,.PXRMLOCN)
     38 ..;Select Prior/Future or Current Inpatient/Admissions
     39 ..S DR="1.6"
     40 ..D ^DIE I $D(Y) S DUOUT=1 Q
     41 ..S PXRMFUT=X,DR=""
     42 .;Clinic Stop input and prior/future
     43 .I PXRMLCSC="CS" S PXRMINP=0,DR="11T~R;1.6" D  I $G(DUOUT)=1 Q
     44 ..D ^DIE I $D(Y) S DUOUT=1 Q
     45 ..S PXRMFUT=X,DR=""
     46 .;Clinic Group input and prior/future
     47 .I PXRMLCSC="GS" S PXRMINP=0,DR="12T~R;1.6" D  I $G(DUOUT)=1 Q
     48 ..D ^DIE I $D(Y) S DUOUT=1 Q
     49 ..S PXRMFUT=X,DR=""
     50 .;Service categories (except for inpatient reports)
     51 .I PXRMINP=0,PXRMFUT'="F",PXRMFUT'="C" S DR=DR_";9T~R"
     52 ;OE/RR teams
     53 I PXRMSEL="O" S DR="7T~R"
     54 ;PCMM Provider and Primary care/All
     55 I PXRMSEL="P" S DR="4T~R;1.3"
     56 ;PCMM teams
     57 I PXRMSEL="T" S DR="3T~R;8T~R"
     58 ;Report type (detail or summary)
     59 S DR=DR_";1.4"
     60 ;Reminder Categories
     61 I $D(^PXRMPT(810.1,DA,12,0))>0 D
     62 .N IEN,CNT,NODE
     63 .S CNT=0,IEN=0 F  S IEN=$O(^PXRMPT(810.1,DA,12,IEN)) Q:IEN'>0  D
     64 ..S CNT=CNT+1,NODE=$G(^PXRMPT(810.1,DA,12,IEN,0))
     65 ..S PXRMTCAT(DA,CNT)=$P(NODE,U)_U_$P($G(^PXRMD(811.7,$P(NODE,U),0)),U)_U_$P(NODE,U,2)
     66 S DR=DR_";13T"
     67 ;Reminders
     68 I $D(^PXRMPT(810.1,DA,1,0))>0 D
     69 .N IEN,CNT,NODE,REMNODE
     70 .S CNT=0,IEN=0 F  S IEN=$O(^PXRMPT(810.1,DA,1,IEN)) Q:IEN'>0  D
     71 ..S CNT=CNT+1,NODE=$G(^PXRMPT(810.1,DA,1,IEN,0))
     72 ..S REMNODE=$G(^PXD(811.9,$P(NODE,U),0))
     73 ..S PXRMTREM(DA,CNT)=$P(NODE,U)_U_$P(REMNODE,U)_U_$P(NODE,U,2)_U_$P($G(REMNODE),U,3)
     74 S DR=DR_";2T"
     75 ;
     76 ;Strip of any leading semi-colons
     77 I $E(DR)=";" S DR=$P(DR,";",2,99)
     78 ;
     79 D ^DIE I $D(Y) S DUOUT=1 Q
     80 ;
     81 ;If all reminders have been deleted from the template disallow save
     82 I +$P($G(^PXRMPT(810.1,DA,1,0)),U,4)=0 D
     83 .;Check categories also
     84 .I +$P($G(^PXRMPT(810.1,DA,12,0)),U,4)>0 D  Q
     85 .. N CAT,CATIEN
     86 .. S CAT=0 F  S CAT=$O(^PXRMPT(810.1,DA,12,CAT)) Q:+CAT'>0  D
     87 ... S CATIEN=$P($G(^PXRMPT(810.1,DA,12,CAT,0)),U)
     88 ... I +$P($G(^PXRMD(811.7,CATIEN,2,0)),U,4)<1 W !!,"** WARNING **",!,"Reminder Category "_$P($G(^PXRMD(811.7,CATIEN,0)),U)_" does not have any reminders assigned to it"
     89 .S DUOUT=1
     90 .W !!,"No reminders defined"
     91 Q
     92 ;
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXTF.m

    r613 r623  
    1 PXRMXTF ; SLC/PJH - Reminder Reports Template Filing ;05/02/2002
    2         ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMXTA
    5         ;
    6         ;Select template name and file
    7         ;-----------------------------
    8 START   N NEWIEN,NEWTEMP,OLDTEMP
    9         ;Save original name
    10         S OLDTEMP=$P(PXRMTMP,U,2)
    11         ;Reset PXRMTMP in case the template name field has been edited
    12         S $P(PXRMTMP,U,2)=$P($G(^PXRMPT(810.1,$P(PXRMTMP,U,1),0)),U)
    13         ;Redisplay changes made
    14         D REDISP
    15         ;Prompt template name
    16         D NAME
    17         ;Rollback ^DIE changes if edit is abandoned
    18         I $D(DTOUT)!$D(DUOUT) D ROLL Q
    19         ;
    20         I NEWTEMP=$P(PXRMTMP,U,2),NEWTEMP=OLDTEMP D MESS(1,NEWTEMP)
    21         I NEWTEMP=$P(PXRMTMP,U,2),NEWTEMP'=OLDTEMP D MESS(3,OLDTEMP,NEWTEMP)
    22         ;
    23         ;If a new template ID is selected then create a new template
    24         I NEWTEMP'=$P(PXRMTMP,U,2) D  I $D(MSG) S DTOUT=1 Q
    25         .;Create template header
    26         .D HEADER
    27         .;Save edited template detail to new template name
    28         .D REFILE Q:$D(MSG)
    29         .;Save Message
    30         .D MESS(2,NEWTEMP)
    31         .;File original arrays to old template (rollback ^DIE changes)
    32         .D FILE^PXRMXTU(PXRMTMP,1,1)
    33         .;Set selected template ID
    34         .S PXRMTMP=NEWIEN
    35         ;
    36         ;Reload arrays
    37         D LOAD^PXRMXT I $D(MSG) S DTOUT=1 Q
    38 EXIT    Q
    39         ;
    40         ;Rename edited template
    41         ;----------------------
    42 NAME    N X,Y,TEXT,DIR
    43         K DIROUT,DIRUT,DTOUT,DUOUT
    44         S DIR(0)="FAU"_U_"3:30"_U_"K:'$$OK^PXRMXTF(X) X"
    45         S DIR("A")="STORE REPORT LOGIC IN TEMPLATE NAME: "
    46         S DIR("B")=$P(PXRMTMP,U,2)
    47         S DIR("?")="Enter template name. For detailed help type ??"
    48         S DIR("??")=U_"D HELP^PXRMXTF(1)"
    49         W !
    50         D ^DIR K DIR
    51         I $D(DIROUT) S DTOUT=1
    52         I $D(DTOUT)!($D(DUOUT)) Q
    53         S NEWTEMP=Y
    54         Q
    55         ;
    56         ;Check if the template name is in use
    57         ;------------------------------------
    58 OK(NAME)        ;
    59         ;Original template name may be used
    60         I X=DIR("B") Q 1
    61         I $E(DIR("B"),1,$L(X))=X Q 0
    62         ;Else check if template name defined
    63         I '$D(^PXRMPT(810.1,"B",NAME)) Q 1
    64         Q 0
    65         ;
    66         ;Create Template header and get IEN
    67         ;----------------------------------
    68 HEADER  N DATA,IEN,NUM
    69         ;Otherwise create a new entry
    70         S DATA=$G(^PXRMPT(810.1,0)),IEN=$P(DATA,U,3),NUM=$P(DATA,U,4)
    71         F  S IEN=IEN+1 Q:'$D(^PXRMPT(IEN,0))
    72         S ^PXRMPT(810.1,IEN,0)=NEWTEMP
    73         S ^PXRMPT(810.1,"B",NEWTEMP,IEN)=""
    74         S $P(^PXRMPT(810.1,0),U,3)=IEN,$P(^PXRMPT(810.1,0),U,4)=NUM+1
    75         S NEWIEN=IEN_U_NEWTEMP
    76         Q
    77         ;
    78         ;Redisplay edited template details
    79         ;---------------------------------------------
    80 REDISP  N PXRMLCSC,PXRMPRIM,PXRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
    81         N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
    82         N PXRMLIST,TITLE
    83         ;
    84         ;Load temporary arrays from edited template PXRMTMP
    85         D LOAD^PXRMXT I $D(MSG) Q
    86         ;Clear last run date
    87         S RUN=""
    88         ;Display
    89         D ^PXRMXTD
    90         ;
    91         Q
    92         ;
    93         ;Copy edited template details to new template
    94         ;---------------------------------------------
    95 REFILE  N PXRMLCSC,PXRMPRIM,PXRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
    96         N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
    97         N PXRMLIST,TITLE
    98         ;
    99         ;Load temporary arrays from edited template PXRMTMP
    100         D LOAD^PXRMXT I $D(MSG) Q
    101         ;Clear last run date
    102         S RUN=""
    103         ;Save arrays to new ID
    104         D FILE^PXRMXTU(NEWIEN,1,0) Q:$D(MSG)
    105         Q
    106         ;
    107         ;Rollback changes (also called from PXRMXTA)
    108         ;----------------
    109 ROLL    ;
    110         D FILE^PXRMXTU(PXRMTMP,1,1)
    111         I $D(MSG) S DTOUT=1 Q
    112         ;Changes not saved message
    113         D MESS(0,$P(PXRMTMP,U,2))
    114         Q
    115         ;
    116         ;Filing messages
    117         ;---------------
    118 MESS(MODE,INP,INP1)     ;
    119         I MODE=0 W !,"Changes to template '"_INP_"' have not been saved" Q
    120         I MODE=1 W !,"Changes to template '"_INP_"' have been saved"
    121         I MODE=2 W !,"A new template '"_INP_"' has been created"
    122         I MODE=3 W !,"Template '"_INP_"' renamed as '"_INP1_"'"
    123         I MODE=4 W !,"Template '"_INP_"' not saved"
    124         Q
    125         ;
    126         ;General help text routine. Write out the text in the HTEXT array
    127         ;----------------------------------------------------------------
    128 HELP(CALL)      ;
    129         N HTEXT
    130         N DIWF,DIWL,DIWR,IC
    131         S DIWF="C70",DIWL=0,DIWR=70
    132         ;
    133         I CALL=1 D
    134         .S HTEXT(1)="To save or rename the existing template use the default"
    135         .S HTEXT(2)="name. To create a new template and leave the original "
    136         .S HTEXT(3)="unchanged enter a different template name "
    137         .S HTEXT(4)="that is not in use."
    138         ;
    139         K ^UTILITY($J,"W")
    140         S IC=""
    141         F  S IC=$O(HTEXT(IC)) Q:IC=""  D
    142         . S X=HTEXT(IC)
    143         . D ^DIWP
    144         W !
    145         S IC=0
    146         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    147         . W !,^UTILITY($J,"W",0,IC,0)
    148         K ^UTILITY($J,"W")
    149         W !
    150         Q
     1PXRMXTF ; SLC/PJH - Reminder Reports Template Filing ;05/02/2002
     2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
     3 ;
     4 ; Called from PXRMXTA
     5 ;
     6 ;Select template name and file
     7 ;-----------------------------
     8START N NEWIEN,NEWTEMP,OLDTEMP
     9 ;Save original name
     10 S OLDTEMP=$P(PXRMTMP,U,2)
     11 ;Reset PXRMTMP in case the template name field has been edited
     12 S $P(PXRMTMP,U,2)=$P($G(^PXRMPT(810.1,$P(PXRMTMP,U,1),0)),U)
     13 ;Redisplay changes made
     14 D REDISP
     15 ;Prompt template name
     16 D NAME
     17 ;Rollback ^DIE changes if edit is abandoned
     18 I $D(DTOUT)!$D(DUOUT) D ROLL Q
     19 ;
     20 I NEWTEMP=$P(PXRMTMP,U,2),NEWTEMP=OLDTEMP D MESS(1,NEWTEMP)
     21 I NEWTEMP=$P(PXRMTMP,U,2),NEWTEMP'=OLDTEMP D MESS(3,OLDTEMP,NEWTEMP)
     22 ;
     23 ;If a new template ID is selected then create a new template
     24 I NEWTEMP'=$P(PXRMTMP,U,2) D  I $D(MSG) S DTOUT=1 Q
     25 .;Create template header
     26 .D HEADER
     27 .;Save edited template detail to new template name
     28 .D REFILE Q:$D(MSG)
     29 .;Save Message
     30 .D MESS(2,NEWTEMP)
     31 .;File original arrays to old template (rollback ^DIE changes)
     32 .D FILE^PXRMXTU(PXRMTMP,1,1)
     33 .;Set selected template ID
     34 .S PXRMTMP=NEWIEN
     35 ;
     36 ;Reload arrays
     37 D LOAD^PXRMXT I $D(MSG) S DTOUT=1 Q
     38EXIT Q
     39 ;
     40 ;Rename edited template
     41 ;----------------------
     42NAME N X,Y,TEXT,DIR
     43 K DIROUT,DIRUT,DTOUT,DUOUT
     44 S DIR(0)="FAU"_U_"3:30"_U_"K:'$$OK^PXRMXTF(X) X"
     45 S DIR("A")="STORE REPORT LOGIC IN TEMPLATE NAME: "
     46 S DIR("B")=$P(PXRMTMP,U,2)
     47 S DIR("?")="Enter template name. For detailed help type ??"
     48 S DIR("??")=U_"D HELP^PXRMXTF(1)"
     49 W !
     50 D ^DIR K DIR
     51 I $D(DIROUT) S DTOUT=1
     52 I $D(DTOUT)!($D(DUOUT)) Q
     53 S NEWTEMP=Y
     54 Q
     55 ;
     56 ;Check if the template name is in use
     57 ;------------------------------------
     58OK(NAME) ;
     59 ;Original template name may be used
     60 I X=DIR("B") Q 1
     61 I $E(DIR("B"),1,$L(X))=X Q 0
     62 ;Else check if template name defined
     63 I '$D(^PXRMPT(810.1,"B",NAME)) Q 1
     64 Q 0
     65 ;
     66 ;Create Template header and get IEN
     67 ;----------------------------------
     68HEADER N DATA,IEN,NUM
     69 ;Otherwise create a new entry
     70 S DATA=$G(^PXRMPT(810.1,0)),IEN=$P(DATA,U,3),NUM=$P(DATA,U,4)
     71 F  S IEN=IEN+1 Q:'$D(^PXRMPT(IEN,0))
     72 S ^PXRMPT(810.1,IEN,0)=NEWTEMP
     73 S ^PXRMPT(810.1,"B",NEWTEMP,IEN)=""
     74 S $P(^PXRMPT(810.1,0),U,3)=IEN,$P(^PXRMPT(810.1,0),U,4)=NUM+1
     75 S NEWIEN=IEN_U_NEWTEMP
     76 Q
     77 ;
     78 ;Redisplay edited template details
     79 ;---------------------------------------------
     80REDISP N PXRMLCSC,PXRMPRIM,PXRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
     81 N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
     82 N PXRMLIST,TITLE
     83 ;
     84 ;Load temporary arrays from edited template PXRMTMP
     85 D LOAD^PXRMXT I $D(MSG) Q
     86 ;Clear last run date
     87 S RUN=""
     88 ;Display
     89 D ^PXRMXTD
     90 ;
     91 Q
     92 ;
     93 ;Copy edited template details to new template
     94 ;---------------------------------------------
     95REFILE N PXRMLCSC,PXRMPRIM,PXRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
     96 N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
     97 N PXRMLIST,TITLE
     98 ;
     99 ;Load temporary arrays from edited template PXRMTMP
     100 D LOAD^PXRMXT I $D(MSG) Q
     101 ;Clear last run date
     102 S RUN=""
     103 ;Save arrays to new ID
     104 D FILE^PXRMXTU(NEWIEN,1,0) Q:$D(MSG)
     105 Q
     106 ;
     107 ;Rollback changes (also called from PXRMXTA)
     108 ;----------------
     109ROLL ;
     110 D FILE^PXRMXTU(PXRMTMP,1,1)
     111 I $D(MSG) S DTOUT=1 Q
     112 ;Changes not saved message
     113 D MESS(0,$P(PXRMTMP,U,2))
     114 Q
     115 ;
     116 ;Filing messages
     117 ;---------------
     118MESS(MODE,INP,INP1) ;
     119 I MODE=0 W !,"Changes to template '"_INP_"' have not been saved" Q
     120 I MODE=1 W !,"Changes to template '"_INP_"' have been saved"
     121 I MODE=2 W !,"A new template '"_INP_"' has been created"
     122 I MODE=3 W !,"Template '"_INP_"' renamed as '"_INP1_"'"
     123 I MODE=4 W !,"Template '"_INP_"' not saved"
     124 Q
     125 ;
     126 ;General help text routine. Write out the text in the HTEXT array
     127 ;----------------------------------------------------------------
     128HELP(CALL) ;
     129 N HTEXT
     130 N DIWF,DIWL,DIWR,IC
     131 S DIWF="C70",DIWL=0,DIWR=70
     132 ;
     133 I CALL=1 D
     134 .S HTEXT(1)="To save or rename the existing template use the default"
     135 .S HTEXT(2)="name. To create a new template and leave the original "
     136 .S HTEXT(3)="unchanged enter a different template name "
     137 .S HTEXT(4)="that is not in use."
     138 ;
     139 K ^UTILITY($J,"W")
     140 S IC=""
     141 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     142 . S X=HTEXT(IC)
     143 . D ^DIWP
     144 W !
     145 S IC=0
     146 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     147 . W !,^UTILITY($J,"W",0,IC,0)
     148 K ^UTILITY($J,"W")
     149 W !
     150 Q
  • WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMXTU.m

    r613 r623  
    1 PXRMXTU ; SLC/PJH - Reminder Reports Template Update ;11/27/2006
    2         ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
    3         ;
    4         ; Called from PXRMYD,PXRMXD (also at UPD from PXRMXPR/PXRMYPR)
    5         ;
    6         ;Option to create a new template
    7         ;-------------------------------
    8 START   N PXRMASK,MSG D ASK(.PXRMASK)
    9         I $G(PXRMASK)="Y" D SAVE
    10 EXIT    Q
    11         ;
    12         ;Ask name for new template
    13         ;-------------------------
    14 SAVE    N X,Y,DIC,DLAYGO
    15 SAV1    S DIC=810.1,DLAYGO=DIC,DIC(0)="QAELX"
    16         S DIC("A")="STORE REPORT LOGIC IN TEMPLATE NAME: "
    17         W !
    18         D ^DIC
    19         I X="" W !,"A template name must be entered" G SAV1
    20         I X=(U_U) S DTOUT=1
    21         I Y=-1 S DUOUT=1 W !,"Details not saved" Q
    22         I $D(DTOUT)!$D(DUOUT) Q
    23         ;Check
    24         I ($P(Y,U,3)'=1) W !,"This template name already exists" G SAV1
    25         ;Get template name and title
    26         S PXRMTMP=Y,TITLE=$P($G(^PXRMPT(810.1,$P(Y,U),0)),U,2)
    27         S $P(PXRMTMP,U,3)=TITLE
    28         ;File details
    29         D FILE(Y,1,0)
    30         ;File not saved message
    31         I $D(MSG) D  Q
    32         .N DA,DIK
    33         .S DA=$P(Y,U),DIK="^PXRMPT(810.1," D ^DIK
    34         .D MESS^PXRMXTF(4,$P(PXRMTMP,U,2))
    35         ;File saved message
    36         D MESS^PXRMXTF(1,$P(PXRMTMP,U,2))
    37         Q
    38         ;
    39         ;File template detail
    40         ;--------------------
    41 FILE(INP,UPD,CLR)       ;
    42         N CNT,FDA,FDAIEN,FNO,IC,INT,MODE,NAME,X
    43         S FDAIEN(1)=$P(INP,U),NAME=$P(INP,U,2)
    44         ;Save exit flags - needed for rollback
    45         N DUOUT,DTOUT
    46         ;
    47         ;Update or Add
    48         S MODE=$S(UPD:(FDAIEN(1)_","),1:"+1,")
    49         ;Delete entries from existing template
    50         I CLR D
    51         .N DA S DA=0
    52         .F  S DA=$O(^PXRMPT(810.1,FDAIEN(1),DA)) Q:'DA  D
    53         ..K ^PXRMPT(810.1,FDAIEN(1),DA)
    54         ;
    55         I PXRMSEL="L" S X=PXRMLCSC,PXRMLCSC=$P(PXRMLCSC,U)
    56         ;
    57         N MREF,XREF
    58         D XREF^PXRMXTB
    59         ;
    60         ;Save single fields into FDA
    61         F IC="NAME","PXRMLCSC","PXRMPRIM","PXRMREP","PXRMSEL","PXRMTYP","PXRMPML" D
    62         .S FDA(810.1,MODE,XREF(IC))=$G(@IC)
    63         F IC="PXRMFD","PXRMSCAT","RUN","TITLE" D
    64         .S FDA(810.1,MODE,XREF(IC))=$G(@IC)
    65         ;
    66         I PXRMSEL="L" S PXRMLCSC=X
    67         ;
    68         ;Save Arrays into FDA
    69         ;
    70         ;Reminder Items
    71         S CNT=1
    72         D SUB1(.PXRMREM,"810.12",1)
    73         ;Save Facility codes
    74         D SUB1(.PXRMFAC,"810.13",1)
    75         ;Save Provider codes
    76         D SUB1(.PXRMPRV,"810.14",1)
    77         ;Save Patient codes
    78         D SUB1(.PXRMPAT,"810.16",1)
    79         ;Save OE/RR Team codes
    80         D SUB1(.PXRMOTM,"810.17",1)
    81         ;Save PCMM Team codes
    82         D SUB1(.PXRMPCM,"810.18",1)
    83         ;Save Hospital Location codes
    84         D SUB1(.PXRMLCHL,"810.11",2)
    85         ;Save Clinic Stop codes
    86         D SUB1(.PXRMCS,"810.111",2)
    87         ;Save Clinic groups
    88         D SUB1(.PXRMCGRP,"810.112",1)
    89         ;Save Reminder Categories
    90         D SUB1(.PXRMRCAT,"810.113",1)
    91         ;Save Patient lists
    92         D SUB1(.PXRMLIST,"810.114",1)
    93         ;
    94         ;Update template file
    95         D UPDATE^DIE("S","FDA","FDAIEN","MSG")
    96         ;
    97         I $D(MSG) D
    98         .W !!,"Update failed, UPDATE^DIE returned the following error message:"
    99         .S IC="MSG"
    100         .F  S IC=$Q(@IC) Q:IC=""  W !,IC,"=",@IC
    101         .W !,"Examine the above error message for the reason.",!
    102         .H 2
    103         Q
    104         ;
    105         ;Save arrays into FDA
    106         ;--------------------
    107 SUB1(OUTPUT,VAR,PIECE)  ;
    108         S IC=""
    109         ;This is use for saving individual reminders back to the original
    110         ;template
    111         I VAR=810.12,$D(PXRMTREM($P(INP,U)))>0 D  Q
    112         .F  S IC=$O(PXRMTREM($P(INP,U),IC)) Q:IC=""  D
    113         ..S INT=$P(PXRMTREM($P(INP,U),IC),U,PIECE),CNT=CNT+1
    114         ..S FDA(VAR,"+"_CNT_","_MODE,.01)=INT
    115         ..S FDA(VAR,"+"_CNT_","_MODE,.02)=IC
    116         ;
    117         ;This is use for saving individual reminders category back to the
    118         ;original template
    119         I VAR=810.113,$D(PXRMTCAT($P(INP,U)))>0 D  Q
    120         .F  S IC=$O(PXRMTCAT($P(INP,U),IC)) Q:IC=""  D
    121         ..S INT=$P(PXRMTCAT($P(INP,U),IC),U,PIECE),CNT=CNT+1
    122         ..S FDA(VAR,"+"_CNT_","_MODE,.01)=INT
    123         ..S FDA(VAR,"+"_CNT_","_MODE,.02)=IC
    124         ;
    125         ;this is use for saving everything else to the template
    126         F  S IC=$O(OUTPUT(IC)) Q:IC=""  D
    127         .S INT=$P(OUTPUT(IC),U,PIECE),CNT=CNT+1
    128         .S FDA(VAR,"+"_CNT_","_MODE,.01)=INT
    129         .;Save Display order for reminders and categories
    130         .I (VAR=810.12)!(VAR=810.113) S FDA(VAR,"+"_CNT_","_MODE,.02)=IC
    131         Q
    132         ;
    133         ;Save Service Categories into FDA
    134         ;--------------------------------
    135 SUB2(FLD,VAR)   ;
    136         F IC=1:1 S INT=$E(@FLD,IC) Q:INT=""  D
    137         .S CNT=CNT+1,FDA(VAR,"+"_CNT_","_MODE,.01)=INT
    138         Q
    139         ;
    140         ;
    141         ;Option to save a new template
    142         ;-----------------------------
    143 ASK(YESNO)      ;
    144         N X,Y,TEXT
    145         K DIROUT,DIRUT,DTOUT,DUOUT
    146         S DIR(0)="YA0"
    147         S DIR("A")="Create a new report template: "
    148         S DIR("B")="N"
    149         S DIR("?")="Enter Y or N. For detailed help type ??"
    150         S DIR("??")=U_"D HELP^PXRMXTU(1)"
    151         W !
    152         D ^DIR K DIR
    153         I $D(DIROUT) S DTOUT=1
    154         I $D(DTOUT)!($D(DUOUT)) Q
    155         S YESNO=$E(Y(0))
    156         Q
    157         ;
    158         ;General help text routine. Write out the text in the HTEXT array
    159         ;----------------------------------------------------------------
    160 HELP(CALL)      ;
    161         N HTEXT
    162         N DIWF,DIWL,DIWR,IC
    163         S DIWF="C70",DIWL=0,DIWR=70
    164         ;
    165         I CALL=1 D
    166         .S HTEXT(1)="Enter 'Y' to save the reporting parameters as a report"
    167         .S HTEXT(2)="template from which the report may be re-run in future."
    168         ;
    169         K ^UTILITY($J,"W")
    170         S IC=""
    171         F  S IC=$O(HTEXT(IC)) Q:IC=""  D
    172         . S X=HTEXT(IC)
    173         . D ^DIWP
    174         W !
    175         S IC=0
    176         F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
    177         . W !,^UTILITY($J,"W",0,IC,0)
    178         K ^UTILITY($J,"W")
    179         W !
    180         Q
    181         ;
    182         ;Save template info to new name
    183         ;------------------------------
    184 COPY    N PXRMLCSC,PXRMPRIM,PRRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
    185         N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
    186         ;Load arrays from original template PXRMTMP
    187         D LOAD^PXRMXT I $D(MSG) Q
    188         ;Clear last run date
    189         S RUN=""
    190         ;Save arrays to new ID
    191         D FILE(NEWTEMP,0)
    192         Q
    193         ;
    194         ;Update print template last run date (called from PXRMYPR/PXRMXPR)
    195         ;-----------------------------------------------------------------
    196 UPD     S ^PXRMPT(810.1,$P(PXRMTMP,U),7)=PXRMXST
    197         Q
    198         ;
    199         ;Called as an input transform for 810.1/NAME
    200         ;-------------------------------------------
    201 NAME    Q:'$D(X)  Q:X=""  Q:$G(PXRMTYP)=""
    202         ;Disallow duplicate template names
    203         Q:'$D(^PXRMPT(810.1,"B",X))
    204         W !,"This template name already exists" K X
    205         Q
    206         ;
    207         ;Called as an input transform for 810.1/PXRMFD
    208         ;---------------------------------------------
    209 INP     Q:'$D(X)  Q:X=""
    210         ;If inpatient wards prompt only for Admissions/Current Patients
    211         I $G(PXRMINP),"FP"[X D
    212         .W !,"Select either Inpatient Admissions or Current Inpatients" K X
    213         ;If other locations prompt only for Prior visits/Future Appts
    214         I '$G(PXRMINP),"AC"[X D
    215         .W !,"Select either Future Appointments or Prior Visits" K X
    216         Q
     1PXRMXTU ; SLC/PJH - Reminder Reports Template Update ;11/03/2005
     2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
     3 ;
     4 ; Called from PXRMYD,PXRMXD (also at UPD from PXRMXPR/PXRMYPR)
     5 ;
     6 ;Option to create a new template
     7 ;-------------------------------
     8START N PXRMASK,MSG D ASK(.PXRMASK)
     9 I $G(PXRMASK)="Y" D SAVE
     10EXIT Q
     11 ;
     12 ;Ask name for new template
     13 ;-------------------------
     14SAVE N X,Y,DIC,DLAYGO
     15SAV1 S DIC=810.1,DLAYGO=DIC,DIC(0)="QAELX"
     16 S DIC("A")="STORE REPORT LOGIC IN TEMPLATE NAME: "
     17 W !
     18 D ^DIC
     19 I X="" W !,"A template name must be entered" G SAV1
     20 I X=(U_U) S DTOUT=1
     21 I Y=-1 S DUOUT=1 W !,"Details not saved" Q
     22 I $D(DTOUT)!$D(DUOUT) Q
     23 ;Check
     24 I ($P(Y,U,3)'=1) W !,"This template name already exists" G SAV1
     25 ;Get template name and title
     26 S PXRMTMP=Y,TITLE=$P($G(^PXRMPT(810.1,$P(Y,U),0)),U,2)
     27 S $P(PXRMTMP,U,3)=TITLE
     28 ;File details
     29 D FILE(Y,1,0)
     30 ;File not saved message
     31 I $D(MSG) D  Q
     32 .N DA,DIK
     33 .S DA=$P(Y,U),DIK="^PXRMPT(810.1," D ^DIK
     34 .D MESS^PXRMXTF(4,$P(PXRMTMP,U,2))
     35 ;File saved message
     36 D MESS^PXRMXTF(1,$P(PXRMTMP,U,2))
     37 Q
     38 ;
     39 ;File template detail
     40 ;--------------------
     41FILE(INP,UPD,CLR) ;
     42 N CNT,FDA,FDAIEN,FNO,IC,INT,MODE,NAME,X
     43 S FDAIEN(1)=$P(INP,U),NAME=$P(INP,U,2)
     44 ;Save exit flags - needed for rollback
     45 N DUOUT,DTOUT
     46 ;
     47 ;Update or Add
     48 S MODE=$S(UPD:(FDAIEN(1)_","),1:"+1,")
     49 ;Delete entries from existing template
     50 I CLR D
     51 .N DA S DA=0
     52 .F  S DA=$O(^PXRMPT(810.1,FDAIEN(1),DA)) Q:'DA  D
     53 ..K ^PXRMPT(810.1,FDAIEN(1),DA)
     54 ;
     55 I PXRMSEL="L" S X=PXRMLCSC,PXRMLCSC=$P(PXRMLCSC,U)
     56 ;
     57 N MREF,XREF
     58 D XREF^PXRMXTB
     59 ;
     60 ;Save single fields into FDA
     61 F IC="NAME","PXRMLCSC","PXRMPRIM","PXRMREP","PXRMSEL","PXRMTYP" D
     62 .S FDA(810.1,MODE,XREF(IC))=$G(@IC)
     63 F IC="PXRMFD","PXRMSCAT","RUN","TITLE" D
     64 .S FDA(810.1,MODE,XREF(IC))=$G(@IC)
     65 ;
     66 I PXRMSEL="L" S PXRMLCSC=X
     67 ;
     68 ;Save Arrays into FDA
     69 ;
     70 ;Reminder Items
     71 S CNT=1
     72 D SUB1(.PXRMREM,"810.12",1)
     73 ;Save Facility codes
     74 D SUB1(.PXRMFAC,"810.13",1)
     75 ;Save Provider codes
     76 D SUB1(.PXRMPRV,"810.14",1)
     77 ;Save Patient codes
     78 D SUB1(.PXRMPAT,"810.16",1)
     79 ;Save OE/RR Team codes
     80 D SUB1(.PXRMOTM,"810.17",1)
     81 ;Save PCMM Team codes
     82 D SUB1(.PXRMPCM,"810.18",1)
     83 ;Save Hospital Location codes
     84 D SUB1(.PXRMLCHL,"810.11",2)
     85 ;Save Clinic Stop codes
     86 D SUB1(.PXRMCS,"810.111",2)
     87 ;Save Clinic groups
     88 D SUB1(.PXRMCGRP,"810.112",1)
     89 ;Save Reminder Categories
     90 D SUB1(.PXRMRCAT,"810.113",1)
     91 ;Save Patient lists
     92 D SUB1(.PXRMLIST,"810.114",1)
     93 ;
     94 ;Update template file
     95 D UPDATE^DIE("S","FDA","FDAIEN","MSG")
     96 ;
     97 I $D(MSG) D
     98 .W !!,"Update failed, UPDATE^DIE returned the following error message:"
     99 .S IC="MSG"
     100 .F  S IC=$Q(@IC) Q:IC=""  W !,IC,"=",@IC
     101 .W !,"Examine the above error message for the reason.",!
     102 .H 2
     103 Q
     104 ;
     105 ;Save arrays into FDA
     106 ;--------------------
     107SUB1(OUTPUT,VAR,PIECE) ;
     108 S IC=""
     109 ;This is use for saving individual reminders back to the original
     110 ;template
     111 I VAR=810.12,$D(PXRMTREM($P(INP,U)))>0 D  Q
     112 .F  S IC=$O(PXRMTREM($P(INP,U),IC)) Q:IC=""  D
     113 ..S INT=$P(PXRMTREM($P(INP,U),IC),U,PIECE),CNT=CNT+1
     114 ..S FDA(VAR,"+"_CNT_","_MODE,.01)=INT
     115 ..S FDA(VAR,"+"_CNT_","_MODE,.02)=IC
     116 ;
     117 ;This is use for saving individual reminders category back to the
     118 ;original template
     119 I VAR=810.113,$D(PXRMTCAT($P(INP,U)))>0 D  Q
     120 .F  S IC=$O(PXRMTCAT($P(INP,U),IC)) Q:IC=""  D
     121 ..S INT=$P(PXRMTCAT($P(INP,U),IC),U,PIECE),CNT=CNT+1
     122 ..S FDA(VAR,"+"_CNT_","_MODE,.01)=INT
     123 ..S FDA(VAR,"+"_CNT_","_MODE,.02)=IC
     124 ;
     125 ;this is use for saving everything else to the template
     126 F  S IC=$O(OUTPUT(IC)) Q:IC=""  D
     127 .S INT=$P(OUTPUT(IC),U,PIECE),CNT=CNT+1
     128 .S FDA(VAR,"+"_CNT_","_MODE,.01)=INT
     129 .;Save Display order for reminders and categories
     130 .I (VAR=810.12)!(VAR=810.113) S FDA(VAR,"+"_CNT_","_MODE,.02)=IC
     131 Q
     132 ;
     133 ;Save Service Categories into FDA
     134 ;--------------------------------
     135SUB2(FLD,VAR) ;
     136 F IC=1:1 S INT=$E(@FLD,IC) Q:INT=""  D
     137 .S CNT=CNT+1,FDA(VAR,"+"_CNT_","_MODE,.01)=INT
     138 Q
     139 ;
     140 ;
     141 ;Option to save a new template
     142 ;-----------------------------
     143ASK(YESNO) ;
     144 N X,Y,TEXT
     145 K DIROUT,DIRUT,DTOUT,DUOUT
     146 S DIR(0)="YA0"
     147 S DIR("A")="Create a new report template: "
     148 S DIR("B")="N"
     149 S DIR("?")="Enter Y or N. For detailed help type ??"
     150 S DIR("??")=U_"D HELP^PXRMXTU(1)"
     151 W !
     152 D ^DIR K DIR
     153 I $D(DIROUT) S DTOUT=1
     154 I $D(DTOUT)!($D(DUOUT)) Q
     155 S YESNO=$E(Y(0))
     156 Q
     157 ;
     158 ;General help text routine. Write out the text in the HTEXT array
     159 ;----------------------------------------------------------------
     160HELP(CALL) ;
     161 N HTEXT
     162 N DIWF,DIWL,DIWR,IC
     163 S DIWF="C70",DIWL=0,DIWR=70
     164 ;
     165 I CALL=1 D
     166 .S HTEXT(1)="Enter 'Y' to save the reporting parameters as a report"
     167 .S HTEXT(2)="template from which the report may be re-run in future."
     168 ;
     169 K ^UTILITY($J,"W")
     170 S IC=""
     171 F  S IC=$O(HTEXT(IC)) Q:IC=""  D
     172 . S X=HTEXT(IC)
     173 . D ^DIWP
     174 W !
     175 S IC=0
     176 F  S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC=""  D
     177 . W !,^UTILITY($J,"W",0,IC,0)
     178 K ^UTILITY($J,"W")
     179 W !
     180 Q
     181 ;
     182 ;Save template info to new name
     183 ;------------------------------
     184COPY N PXRMLCSC,PXRMPRIM,PRRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
     185 N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
     186 ;Load arrays from original template PXRMTMP
     187 D LOAD^PXRMXT I $D(MSG) Q
     188 ;Clear last run date
     189 S RUN=""
     190 ;Save arrays to new ID
     191 D FILE(NEWTEMP,0)
     192 Q
     193 ;
     194 ;Update print template last run date (called from PXRMYPR/PXRMXPR)
     195 ;-----------------------------------------------------------------
     196UPD S ^PXRMPT(810.1,$P(PXRMTMP,U),7)=PXRMXST
     197 Q
     198 ;
     199 ;Called as an input transform for 810.1/NAME
     200 ;-------------------------------------------
     201NAME Q:'$D(X)  Q:X=""  Q:$G(PXRMTYP)=""
     202 ;Disallow duplicate template names
     203 Q:'$D(^PXRMPT(810.1,"B",X))
     204 W !,"This template name already exists" K X
     205 Q
     206 ;
     207 ;Called as an input transform for 810.1/PXRMFD
     208 ;---------------------------------------------
     209INP Q:'$D(X)  Q:X=""
     210 ;If inpatient wards prompt only for Admissions/Current Patients
     211 I $G(PXRMINP),"FP"[X D
     212 .W !,"Select either Inpatient Admissions or Current Inpatients" K X
     213 ;If other locations prompt only for Prior visits/Future Appts
     214 I '$G(PXRMINP),"AC"[X D
     215 .W !,"Select either Future Appointments or Prior Visits" K X
     216 Q
Note: See TracChangeset for help on using the changeset viewer.