source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCDXUTL4.m@ 1306

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

initial load of WorldVistAEHR

File size: 7.0 KB
Line 
1SCDXUTL4 ;ALB/JRP - ACRP ERROR CODE UTILITIES;08-OCT-1996
2 ;;5.3;Scheduling;**68**;AUG 13, 1993
3PAT4XMIT(XMITPTR) ;Return patient associated to entry in TRANSMITTED
4 ; OUTPATIENT ENCOUNTER file (#409.73)
5 ;
6 ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
7 ; ENCOUNTER file (#409.73)
8 ;Output : DFN^Name - Patient that is associated to the encounter
9 ; DFN = Pointer to PATIENT file (#2)
10 ; Name = Patient's name
11 ; 0 - Error/bad input
12 ;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
13 ; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
14 ; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
15 ; to the PATIENT file (#2)
16 ;
17 ;Check input
18 S XMITPTR=+$G(XMITPTR)
19 Q:('$D(^SD(409.73,XMITPTR,0))) 0
20 ;Declare variables
21 N DFN,DELPTR,ENCPTR,NODE,NAME
22 S DFN=0
23 ;Determine if entry in transmit file is for a deleted encounter or
24 ; an existing encounter
25 S NODE=$G(^SD(409.73,XMITPTR,0))
26 S ENCPTR=+$P(NODE,"^",2)
27 S DELPTR=+$P(NODE,"^",3)
28 Q:(('ENCPTR)&('DELPTR)) 0
29 ;Existing encounter
30 I (ENCPTR) D
31 .;Follow pointer to OUTPATIENT ENCOUNTER file
32 .S NODE=$G(^SCE(ENCPTR,0))
33 .;Get pointer to PATIENT file
34 .S DFN=+$P(NODE,"^",2)
35 ;Deleted encounter
36 I (DELPTR) D
37 .;Follow pointer to DELETED OUTPATIENT ENCOUNTER file
38 .S NODE=$G(^SD(409.74,DELPTR,0))
39 .;Get pointer to PATIENT file
40 .S DFN=+$P(NODE,"^",2)
41 ;Bad pointer to PATIENT file
42 Q:('$D(^DPT(DFN,0))) 0
43 ;Get patient's name
44 S NODE=$G(^DPT(DFN,0))
45 S NAME=$P(NODE,"^",1)
46 ;No name on file
47 S:(NAME="") NAME="NAME NOT ON FILE (#"_DFN_")"
48 ;Done
49 Q DFN_"^"_NAME
50 ;
51PAT4ERR(PTRERR) ;Return patient associated to entry in TRANSMITTED OUTPATIENT
52 ; ENCOUNTER ERROR file (#409.75)
53 ;
54 ;Input : PTRERR - Pointer to entry in TRANSMITTED OUTPATIENT
55 ; ENCOUNTER ERROR file (#409.75)
56 ;Output : DFN^Name - Patient that is associated to the error
57 ; DFN = Pointer to PATIENT file (#2)
58 ; Name = Patient's name
59 ; 0 - Error/bad input
60 ;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
61 ; ENCOUNTER ERROR file (#409.75) to the TRANSMITTED OUTPATIENT
62 ; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
63 ; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
64 ; to the PATIENT file (#2)
65 ;
66 ;Check input
67 S PTRERR=+$G(PTRERR)
68 Q:('$D(^SD(409.75,PTRERR,0))) 0
69 ;Declare variables
70 N NODE,XMITPTR
71 ;Get pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
72 S NODE=$G(^SD(409.75,PTRERR,0))
73 S XMITPTR=+$P(NODE,"^",1)
74 Q:('XMITPTR) 0
75 ;Return patient info
76 Q $$PAT4XMIT(XMITPTR)
77 ;
78GETREJ(OUTARR,SCREEN,DOTS) ;Return list of all patients/encounters in the
79 ; TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73) that were rejected
80 ;
81 ;Input : OUTARR - Array to store output in (full global reference)
82 ; Defaults to ^TMP("SCDX",$J)
83 ; SCREEN - Flag denoting if entries should be screen
84 ; 0 = Don't apply any screens (default)
85 ; 1 = Screen out entries that are marked for [re]xmit
86 ; 2 = Only return entries that are demographic rejects
87 ; 3 = Apply screen #1 & #2
88 ; DOTS - Flag denoting if dots (.) should be printed
89 ; 0 = Don't print dots whild building list (default)
90 ; N = Print 1 dot for every N encounters found
91 ;Output : PATCNT ^ ENCCNT
92 ; PATS = Number of patients that were found
93 ; COUNT = Number of entries in TRANSMITTED OUTPATIENT
94 ; ENCOUNTER file (#409.73) that were found
95 ; If entries are found, OUTARR() will be in the format
96 ; OUTARR("NAME",NAME) = DFN ^ REJ
97 ; OUTARR("DFN",DFN,XMITPTR) = NAME
98 ; Where NAME = Patient's name
99 ; DFN = Pointer to entry in PATIENT file (#2)
100 ; REJ = Total number of encounters rejected for patient
101 ; XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
102 ; ENCOUNTER file (#409.73)
103 ;Notes : It is the responsibility of the calling program to
104 ; initialize (ie KILL) the output array
105 ;
106 ;Check input
107 S OUTARR=$G(OUTARR)
108 S:(OUTARR="") OUTARR="^TMP(""SCDX"","_$J_")"
109 S SCREEN=+$G(SCREEN)
110 S DOTS=+$G(DOTS)
111 S:(DOTS<0) DOTS=0
112 ;Declare variables
113 N DFN,XMITPTR,PATCNT,ENCCNT,NAME,TMP,MARKED
114 S PATCNT=0
115 S ENCCNT=0
116 ;Loop through all encounters that have been rejected
117 S XMITPTR=""
118 F S XMITPTR=+$O(^SD(409.75,"B",XMITPTR)) Q:('XMITPTR) D
119 .;If applicable, screen out encounters marked for [re]transmission
120 .I ((SCREEN=1)!(SCREEN=3)) D Q:(MARKED)
121 ..S TMP=$G(^SD(409.73,XMITPTR,0))
122 ..S MARKED=+$P(TMP,"^",4)
123 .;If applicable, screen out encounters that are not demographic rejects
124 .I ((SCREEN=2)!(SCREEN=3)) Q:'$$REJ4DEMO^SCDXUTL3(XMITPTR)
125 .;Get pointer to encounter's patient
126 .S TMP=$$PAT4XMIT(XMITPTR)
127 .S DFN=+$P(TMP,"^",1)
128 .S NAME=$P(TMP,"^",2)
129 .;Couldn't find patient - ignore
130 .Q:('DFN)
131 .;Increment patient count
132 .S:('$D(@OUTARR@("DFN",DFN))) PATCNT=PATCNT+1
133 .;Store patient & encounter in output array
134 .S @OUTARR@("DFN",DFN,XMITPTR)=NAME
135 .;Increment encounter counts
136 .S TMP=$G(@OUTARR@("NAME",NAME))
137 .S @OUTARR@("NAME",NAME)=DFN_"^"_(1+$P(TMP,"^",2))
138 .S ENCCNT=ENCCNT+1
139 .;Print dots ?
140 .I (DOTS) W:('(ENCCNT#DOTS)) "."
141 Q PATCNT_"^"_ENCCNT
142 ;
143XMIT4DFN(DFN,OUTARR) ;Return list of entries in TRANSMITTED OUTPATIENT
144 ; ENCOUNTER file (#409.73) for a given patient
145 ;
146 ;Input : DFN - Pointer to entry in PATIENT file (#2)
147 ; OUTARR - Array to store output in (full global reference)
148 ; Defaults to ^TMP("SCDX",$J)
149 ;Output : X - Number of entries in TRANSMITTED OUTPATIENT ENCOUNTER
150 ; file (#409.73) that were found
151 ; If entries are found, OUTARR() will be in the format
152 ; OUTARR(DFN,XMITPTR) = ""
153 ; Where XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
154 ; ENCOUNTER file (#409.73)
155 ;Notes : It is the responsibility of the calling program to
156 ; initialize (ie KILL) the output array
157 ;
158 ;Check input
159 S DFN=+$G(DFN)
160 Q:('$D(^DPT(DFN,0))) 0
161 S OUTARR=$G(OUTARR)
162 S:(OUTARR="") OUTARR="^TMP(""SCDX"","_$J_")"
163 ;Declare variables
164 N ENCPTR,DELPTR,XMITPTR,COUNT
165 S COUNT=0
166 ;Find all entries in the OUTPATIENT ENCOUNTER file (#409.68) that
167 ;pertain to the given patient
168 S ENCPTR=""
169 F S ENCPTR=+$O(^SCE("C",DFN,ENCPTR)) Q:('ENCPTR) D
170 .;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
171 .S XMITPTR=+$O(^SD(409.73,"AENC",ENCPTR,0))
172 .Q:('XMITPTR)
173 .;Store pointer in output array an increment counter
174 .S @OUTARR@(DFN,XMITPTR)=""
175 .S COUNT=COUNT+1
176 ;Find all entries in DELETED OUTPATIENT ENCOUNTER file (#409.74) that
177 ;pertain to the given patient
178 S DELPTR=""
179 F S DELPTR=+$O(^SD(409.74,"PAT",DFN,DELPTR)) Q:('DELPTR) D
180 .;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
181 .S XMITPTR=+$O(^SD(409.73,"ADEL",DELPTR,0))
182 .Q:('XMITPTR)
183 .;Store pointer in output array an increment counter
184 .S @OUTARR@(DFN,XMITPTR)=""
185 .S COUNT=COUNT+1
186 Q COUNT
Note: See TracBrowser for help on using the repository browser.