source: WorldVistAEHR/trunk/r/EVENT_CAPTURE-EC--ECT--ECX/ECUMRPC2.m@ 1500

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

initial load of WorldVistAEHR

File size: 6.5 KB
Line 
1ECUMRPC2 ;ALB/JAM;Event Capture Management Broker Utils ; 10/4/00 4:58pm
2 ;;2.0; EVENT CAPTURE ;**25,30,42,46,47,49,75,72**;8 May 96
3GLOC(RESULTS,ECARY) ;
4 ;
5 ;This broker entry point returns all active Event Capture locations
6 ; RPC: EC GETLOC
7 ;INPUTS ECARY - Contains the following subscripted elements
8 ; STAT - Active or inactive locations (optional)
9 ; A-ctive (default), I-nactive, B-oth
10 ;
11 ;OUTPUTS RESULTS - The array of active Event Capture locations.
12 ; PIECE - Description
13 ; 1 Location IEN
14 ; 2 LOC description
15 ; 3 State Abbreviation
16 ; 4 Current Location Flag
17 ; 5 Facility Type
18 ; 6 Station Number
19 N LOC,STAT,CNT,CLOC,ST,NODE,ACT,ECLOC,ELOC,ECFT,ECSN
20 D SETENV^ECUMRPC
21 K ^TMP($J,"ECLOCATION")
22 S STAT=$P($G(ECARY),U),(CNT,LOC)=0,ACT=0 S:STAT="" STAT="A"
23 D GETLOC^ECL(.ECLOC)
24 F S LOC=$O(ECLOC(LOC)) Q:'LOC S ELOC($P(ECLOC(LOC),U,2))=""
25 S LOC=0
26 F S LOC=$O(^DIC(4,LOC)) Q:'LOC S NODE=$G(^DIC(4,LOC,0)) I NODE'="" D
27 . I $P(NODE,U)="" Q
28 . I ($P(NODE,U,11)="I")!($P($G(^DIC(4,LOC,99)),U,4)) S ACT=1
29 . I $S(STAT="A"&(ACT):1,STAT="I"&('ACT):1,1:0) Q
30 . S CLOC=$D(ELOC(LOC)),CLOC=$S(CLOC:"YES",1:"")
31 . S CNT=CNT+1,ST=$P(NODE,U,2) S:ST'="" ST=$$GET1^DIQ(5,ST,1,"I")
32 . S ECFT=$P($G(^DIC(4.1,+$G(^DIC(4,LOC,3)),0)),U)
33 . S ECSN=$P($G(^DIC(4,LOC,99)),U)
34 . S ^TMP($J,"ECLOCATION",CNT)=LOC_U_$P(NODE,U)_U_ST_U_CLOC_U_ECFT_U_ECSN
35 S RESULTS=$NA(^TMP($J,"ECLOCATION"))
36 Q
37CPTFND(RESULTS,ECARY) ;
38 ;
39 ;This broker entry point does a search on a CPT string and returns
40 ;a list of matches from file #81
41 ; RPC: EC GETCPTLST
42 ;INPUTS ECARY - Contains the following subscripted elements
43 ; CPTSTR - CPT search string
44 ;
45 ;OUTPUTS RESULTS - The array of cpt codes. Data pieces as follows:-
46 ; CPT ien^CPT code^Name
47 ;
48 N CPTSTR,ECNT,DIC,ECTG,ECER
49 D SETENV^ECUMRPC
50 S CPTSTR=$P(ECARY,U),ECNT=0 I CPTSTR="" Q
51 K ^TMP($J,"ECPTSRCH"),^TMP("ECCPT",$J)
52 D CPTSRH(81,CPTSTR)
53 F S ECNT=$O(^TMP("ECCPT",$J,"DILIST","ID",ECNT)) Q:'ECNT D
54 .S ^TMP($J,"ECPTSRCH",ECNT)=$G(^TMP("ECCPT",$J,"DILIST",2,ECNT))_U_^TMP("ECCPT",$J,"DILIST","ID",ECNT,.01)_U_^TMP("ECCPT",$J,"DILIST","ID",ECNT,2)
55 K ^TMP("ECCPT",$J)
56 S RESULTS=$NA(^TMP($J,"ECPTSRCH"))
57 Q
58 ;
59PXFND(RESULTS,ECARY) ;
60 ;
61 ;This broker entry point does a search on a procedure string and returns
62 ;a list of matches from file #81 and/or #725
63 ; RPC: EC GETPXLST
64 ;INPUTS ECARY - Contains the following subscripted elements
65 ; PXSTR - Procedure search string
66 ;
67 ;OUTPUTS RESULTS - The array of procedures. Data pieces as follows:-
68 ; Procedure ien^Procedure code Procedure Name
69 ;
70 N CPTSTR,ECNT,DIC,ECX,CNT,ECTG,ECER,PXSTR,ECSTR
71 D SETENV^ECUMRPC
72 S PXSTR=$P(ECARY,U),ECNT=0 I PXSTR="" Q
73 K ^TMP($J,"ECPXSRCH"),^TMP("ECCPT",$J),^TMP("ECCPT1",$J)
74 D
75 . I $P(PXSTR,".")="A" D CPTSRH(81,$P(PXSTR,".",2)) Q
76 . I $P(PXSTR,".")="B" D CPTSRH(725,$P(PXSTR,".",2)) Q
77 . F ECX=81,725 D CPTSRH(ECX,PXSTR)
78 F S ECNT=$O(^TMP("ECCPT",$J,"DILIST","ID",ECNT)) Q:'ECNT D
79 .S ECID=$G(^TMP("ECCPT",$J,"DILIST",2,ECNT))_";ICPT("
80 .S ECSTR=^TMP("ECCPT",$J,"DILIST","ID",ECNT,.01)_" "_^(2)
81 .S ^TMP($J,"ECPXSRCH",ECNT)=ECID_U_ECSTR
82 S ECNT=0,CNT=+$O(^TMP($J,"ECPXSRCH","A"),-1)
83 F S ECNT=$O(^TMP("ECCPT1",$J,"DILIST","ID",ECNT)) Q:'ECNT D
84 .S CNT=CNT+1,ECID=$G(^TMP("ECCPT1",$J,"DILIST",2,ECNT))_";EC(725,"
85 .S ECSTR=^TMP("ECCPT1",$J,"DILIST","ID",ECNT,1)_" "_^(.01)
86 .S ^TMP($J,"ECPXSRCH",CNT)=ECID_U_ECSTR
87 K ^TMP("ECCPT",$J),^TMP("ECCPT1",$J)
88 S RESULTS=$NA(^TMP($J,"ECPXSRCH"))
89 Q
90CPTSRH(FILE,CPTSTR) ;Searches either file 81 or 725 for a CPT string
91 I FILE=81 D
92 .D FINDIC(81,"",".01;2","M",CPTSTR,100,"","I $P($$CPT^ICPTCOD(+Y),""^"",7)","","^TMP(""ECCPT"",$J)")
93 I FILE=725 D
94 .D FINDIC(725,"",".01;1","M",CPTSTR,100,"","I '$P(^(0),""^"",3)","","^TMP(""ECCPT1"",$J)")
95 Q
96FINDIC(ECFL,ECIEN,ECFLD,ECFLG,ECVAL,ECN,ECINDX,ECSCN,ECID,ECTG,ECER) ;
97 ;Find records in a file base on search string
98 S ECER=$G(ECER)
99 D FIND^DIC(ECFL,ECIEN,ECFLD,ECFLG,ECVAL,ECN,ECINDX,ECSCN,ECID,ECTG,ECER)
100 K ECFL,ECIEN,ECFLD,ECFLG,ECVAL,ECN,ECINDX,ECSCN,ECID
101 Q
102PROV ;Return a set of providers from the NEW PERSON file
103 ;Input Variables:-
104 ; FROM - text to $O from
105 ; DATE - checks for an active person class on this date (optional)
106 ; ECDIR - $O direction
107 ; KEY - screen users by security key (optional)
108 ;
109 ;Output Variables:-
110 ; ^TMP($J,"ECFIND",1..n - returned array
111 ; IEN of file 200^Provider Name^occupation^specialty^subspecialty
112 ;
113 N I,IEN,CNT,FROM,DATE,ECUTN S I=0,CNT=44 ;KEY="PROVIDER"
114 ;S FROM=$P(ECSTR,"|"),DATE=$P(ECSTR,"|",2)
115 S FROM=$P(ECSTR,"|"),DATE=$P(ECSTR,"|",2),REPORT=$P(ECSTR,"|",3)
116 F Q:I'<CNT S FROM=$O(^VA(200,"B",FROM),ECDIR) Q:FROM="" D
117 . S IEN="" F S IEN=$O(^VA(200,"B",FROM,IEN),ECDIR) Q:'IEN D
118 . . ;I $L(KEY),'$D(^XUSEC(KEY,+IEN)) Q
119 . . ;I +$G(ALLUSERS)=0,'$$ACTIVE^XUSER(IEN) Q ; terminated user
120 . . I REPORT="R" S I=I+1,^TMP($J,"ECFIND",I)=IEN_"^"_FROM_"^" Q
121 . . S ECUTN=$$GET^XUA4A72(IEN,DATE)
122 . . I DATE>0,ECUTN<1 Q
123 . . S I=I+1,^TMP($J,"ECFIND",I)=IEN_"^"_FROM_"^"_$P(ECUTN,"^",2,4)
124 Q
125LEX ; returns a list of ICD code from lexicon lookup; called from ECUMRPC1
126 ;Input Variables:-
127 ; ECSTR - APP|ECX|ECDT
128 ; application|Search string|procedure date
129 ;
130 ;Output Variables:-
131 ; ^TMP($J,"ECFIND",1..n - returned array
132 ; ICD9 Code^LEX description^IEN of file 80^IEN of file 757.01
133 ;
134 N LEX,ILST,I,IEN,ECX,APP,ECDT,ICD9,ICDIEN,DIC,ECCD
135 S APP=$P(ECSTR,"|"),ECX=$P(ECSTR,"|",2),ECDT=$P(ECSTR,"|",3)
136 S ECDT=$G(ECDT,DT),DIC="^ICD9("
137 ;spacebar default for DUZ
138 I ECX=" ",+($G(DUZ))>0 S IEN=$G(^DISV(DUZ,DIC)) I +IEN D
139 .S ECCD=$$ICDDX^ICDCODE(IEN,ECDT) S:+ECCD>0 ECX=$P(ECCD,U,2)
140 D CONFIG^LEXSET(APP,APP,ECDT) ;LEX DBIA1577
141 D LOOK^LEXA(ECX,APP,1,"",ECDT) ;LEX DBIA2950
142 I '$D(LEX("LIST",1)) S ^TMP($J,"ECFIND",1)="0^No matches found." Q
143 ;LEX DBIA1573
144 S ILST=1,IEN=+LEX("LIST",1)
145 D ICD I ICDIEN<0 S ^TMP($J,"ECFIND",1)="0^No matches found." Q
146 S ^TMP($J,"ECFIND",ILST)=ICD9_U_$P(LEX("LIST",1),U,2)_U_ICDIEN_U_LEX("LIST",1),I=""
147 F S I=$O(^TMP("LEXFND",$J,I)) Q:I'<0 D
148 . S IEN=$O(^TMP("LEXFND",$J,I,0))
149 . D ICD I ICDIEN<0 Q
150 . S ILST=ILST+1
151 . S ^TMP($J,"ECFIND",ILST)=ICD9_U_^TMP("LEXFND",$J,I,IEN)_U_ICDIEN_U_IEN
152 I $O(^TMP($J,"ECFIND",0))="" S ^TMP($J,"ECFIND",1)="0^No matches found."
153 K ^TMP("LEXFND",$J),^TMP("LEXHIT",$J)
154 Q
155ICD ;ICD code
156 S ICD9=$$ICDONE^LEXU(IEN,ECDT)
157 S ICDIEN=+$$ICDDX^ICDCODE(ICD9,ECDT)
158 Q
Note: See TracBrowser for help on using the repository browser.