source: FOIAVistA/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMTERM.m@ 1561

Last change on this file since 1561 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 7.6 KB
Line 
1PXRMTERM ; SLC/PKR - Handle reminder terms. ;04/23/2007
2 ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
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="" 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 ;=============================================
36DORDER(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 ;=============================================
49EVALFI(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 ;=============================================
81EVALTERM(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 ;=============================================
108IEVALTER(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")
117DEMOK 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 ;=============================================
130MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
131 D OPT(INDENT,.IFIEVAL,.NLINES,.TEXT,"MHV")
132 Q
133 ;
134 ;=============================================
135OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
136 ;maintenance output.
137 D OPT(INDENT,.IFIEVAL,.NLINES,.TEXT,"CM")
138 Q
139 ;
140 ;=============================================
141OPT(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 ;=============================================
171SPFINDPA(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 ;
Note: See TracBrowser for help on using the repository browser.