source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCDXFU03.m@ 1361

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

initial load of WorldVistAEHR

File size: 6.6 KB
RevLine 
[613]1SCDXFU03 ;ALB/JRP - AMBULATORY CARE FILE UTILITIES;01-JUL-1996
2 ;;5.3;Scheduling;**44,110,121,126,128**;AUG 13, 1993
3 ;
4DELXMIT(PTR,PTR2) ;Delete entry in TRANSMITTED OUTPATIENT ENCOUNTER
5 ; file (#409.73)
6 ;
7 ;Input : PTR - Pointer to entry in one of the following files
8 ; * TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
9 ; * OUTPATIENT ENCOUNTER file (#409.68)
10 ; * DELETED OUTPATIENT ENCOUNTER file (#409.74)
11 ; PTR2 - Denotes which file PTR points to
12 ; 0 = TRANSMITTED OUTPATIENT ENCOUNTER file (Default)
13 ; 1 = OUTPATIENT ENCOUNTER file
14 ; 2 = DELETED OUTPATIENT ENCOUNTER file
15 ;Output : 0 - Success
16 ; -1 - Unable to delete entry
17 ;Note : Success (0) is returned when a valid pointer to the
18 ; specified file is not passed or an entry in the
19 ; TRANSMITTED OUTPATIENT ENCOUNTER file can not be found
20 ; (Deleting an entry that doesn't exist is successful)
21 ; : If the TRANSMITTED OUTPATIENT ENCOUNTER points to an entry
22 ; in the DELETED OUTPATIENT ENCOUNTER file, the DELETED
23 ; OUTPATIENT ENCOUNTER will also be deleted
24 ;
25 ;Check input
26 S PTR=+$G(PTR)
27 S PTR2=+$G(PTR2)
28 S:((PTR2<0)!(PTR2>2)) PTR2=0
29 ;Declare variables
30 N DIK,DA,X,Y,DIC,XMITPTR,DELPTR
31 ;Get pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
32 S XMITPTR=PTR
33 S:(PTR2=1) XMITPTR=+$O(^SD(409.73,"AENC",PTR,0))
34 S:(PTR2=2) XMITPTR=+$O(^SD(409.73,"ADEL",PTR,0))
35 ;Entry in TRANSMITTED OUTPATIENT ENCOUNTER file doesn't exist - success
36 Q:('$D(^SD(409.73,XMITPTR,0))) 0
37 ;Delete all entries in TRANSMITTED OUTPATIENT ENCOUNTER ERROR file
38 ; (#409.75) that refer to entry being deleted
39 D DELAERR^SCDXFU02(XMITPTR)
40 ;Delete all entries in ACRP Transmission History file (#409.77)
41 D DELAHIST^SCDXFU10(XMITPTR)
42 ;Delete entry in DELETED OUTPATIENT ENCOUNTER file (#409.74)
43 S DELPTR=+$$XMIT4DEL^SCDXFU11(XMITPTR)
44 S:(DELPTR>0) X=$$DELDEL^SCDXFU02(DELPTR)
45 ;Delete entry
46 S DIK="^SD(409.73,"
47 S DA=XMITPTR
48 D ^DIK
49 ;Done
50 Q 0
51 ;
52XMITDATA(XMITPTR,XMITDATE,MID,BID) ;Store transmission data for entry in
53 ; TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
54 ;
55 ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
56 ; ENCOUNTER file (#409.73)
57 ; XMITDATE - FileMan ate/time entry was transmitted to National
58 ; Patient Care Database (Defaults to NOW)
59 ; MID - Message Control ID used when entry was transmitted
60 ; to National Patient Care Database
61 ; BID - Batch Control ID used when entry was transmitted
62 ; to National Patient Care Database
63 ;Output : None
64 ;
65 ;Check input
66 S XMITPTR=+$G(XMITPTR)
67 Q:('$D(^SD(409.73,XMITPTR)))
68 S XMITDATE=+$G(XMITDATE)
69 S:('XMITDATE) XMITDATE="NOW"
70 S MID=$G(MID)
71 S BID=$G(BID)
72 ;Declare variables
73 N DIE,DA,DR,DIDEL,X,Y,DIC
74 ;Store transmission data
75 S DIE="^SD(409.73,"
76 S DA=XMITPTR
77 S DR="11///^S X=XMITDATE;12///^S X=MID;13///^S X=BID"
78 D ^DIE
79 ;Done
80 Q
81 ;
82ACKDATA(XMITPTR,ACKDATE,ACKCODE) ;Store acknowledgement data for entry
83 ; in TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
84 ;
85 ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
86 ; ENCOUNTER file (#409.73)
87 ; ACKDATE - FileMan date/time acknowledgement from National
88 ; Patient Care Database was received (Defaults to NOW)
89 ; ACKCODE - Denotes type of acknowledgement received
90 ; A = Transmission was accepted (DEFAULT)
91 ; R = Transmission was rejected
92 ; E = Error
93 ;Output : None
94 ;
95 ;Check input
96 S XMITPTR=+$G(XMITPTR)
97 Q:('$D(^SD(409.73,XMITPTR)))
98 S ACKDATE=+$G(ACKDATE)
99 S:('ACKDATE) ACKDATE="NOW"
100 S ACKCODE=$G(ACKCODE)
101 S:("ARE"'[ACKCODE) ACKCODE="A"
102 ;Declare variables
103 N DIE,DA,DR,DIDEL,X,Y,DIC
104 ;Store acknowledgement data
105 S DIE="^SD(409.73,"
106 S DA=XMITPTR
107 S DR="14///^S X=ACKDATE;15////^S X=ACKCODE"
108 D ^DIE
109 ;Done
110 Q
111 ;
112XMITED(ENCPTR) ;Determine if Outpatient Encounter was ever transmitted to the
113 ; National Patient Care Database
114 ;
115 ;Input : ENCPTR - Pointer to Outpatient Encounter
116 ;Output : DateTime - Date of last transmission (FileMan format)
117 ; 0 - Encounter never transmitted
118 ;Notes : Zero (0) will be returned on bad input
119 ;
120 ;Check input
121 S ENCPTR=+$G(ENCPTR)
122 Q:('ENCPTR) 0
123 ;Declare variables
124 N XMITPTR,XMITDATE,XMITHIST
125 S XMITHIST=$NA(^TMP("SCDXFU03",$J,"XMITED"))
126 K @XMITHIST
127 ;Find entry in transmission file (#409.73)
128 S XMITPTR=+$O(^SD(409.73,"AENC",ENCPTR,0))
129 Q:('XMITPTR) 0
130 Q:('$D(^SD(409.73,XMITPTR,0))) 0
131 ;Get transmission history
132 S XMITDATE=$$HST4XMIT^SCDXFU13(XMITPTR,XMITHIST,1)
133 ;Get last transmission date/time
134 S XMITDATE=+$O(@XMITHIST@(""),-1)
135 ;Clean up and return date/time of last transmission
136 K @XMITHIST
137 Q XMITDATE
138 ;
139ACCEPTED(ENCPTR) ;Determine if Outpatient Encounter was ever accepted
140 ; by the National Patient Care Database (i.e. ACK = Accept)
141 ;
142 ;Input : ENCPTR - Pointer to Outpatient Encounter
143 ;Output : DateTime - Date/time of last successfull ack (FileMan)
144 ; 0 - Encounter never accepted
145 ;Notes : Zero (0) will be returned on bad input
146 ;
147 ;Check input
148 S ENCPTR=+$G(ENCPTR)
149 Q:('ENCPTR) 0
150 ;Declare variables
151 N XMITPTR,ACKDATE,ACKHIST
152 S ACKHIST=$NA(^TMP("SCDXFU03",$J,"ACCEPTED"))
153 K @ACKHIST
154 ;Find entry in transmission file (#409.73)
155 S XMITPTR=+$O(^SD(409.73,"AENC",ENCPTR,0))
156 Q:('XMITPTR) 0
157 Q:('$D(^SD(409.73,XMITPTR,0))) 0
158 ;Get acknowledgement history
159 S ACKDATE=$$HST4XMIT^SCDXFU13(XMITPTR,ACKHIST,2)
160 ;Search history for last ack with code of ACCEPT
161 S ACKDATE=""
162 F S ACKDATE=+$O(@ACKHIST@(ACKDATE),-1) Q:('ACKDATE) Q:($P($G(@ACKHIST@(ACKDATE)),"^",3)="A")
163 ;Clean up and return date/time of last successfull ack
164 K @ACKHIST
165 Q ACKDATE
166 ;
167VIDCNT(VSITID,EXCLUDE) ;Determine the number of parent Outpatient
168 ; Encounters that have the given Visit ID
169 ;
170 ;Input : VSITID - Visit ID to check for (NOT THE POINTER TO 9000010)
171 ; EXCLUDE - Encounter to optionally exclude from count
172 ;Output : N - Number of parent encounters found
173 ;Notes : Stand alone add/edits are considered a parent encounter
174 ; : Zero (0) is returned if the Visit ID is not valid
175 ;
176 ;Check input
177 S VSITID=$G(VSITID)
178 Q:(VSITID="") 0
179 S EXCLUDE=+$G(EXCLUDE)
180 S:('$D(^SCE(EXCLUDE,0))) EXCLUDE=0
181 ;Declare variables
182 N ENCPTR,VSITPTR,COUNT
183 ;Get pointer to Visit
184 S VSITPTR=$$VID2IEN^VSIT(VSITID)
185 Q:(VSITPTR<1) 0
186 ;Count parent encounters for visit
187 S COUNT=0
188 S ENCPTR=0
189 F S ENCPTR=+$O(^SCE("AVSIT",VSITPTR,ENCPTR)) Q:('ENCPTR) D
190 .;Bad entry in x-ref
191 .Q:('$D(^SCE(ENCPTR,0)))
192 .;Exclude input encounter
193 .Q:(ENCPTR=EXCLUDE)
194 .;Screen out children
195 .Q:(+$P($G(^SCE(ENCPTR,0)),"^",6))
196 .;Increment count
197 .S COUNT=COUNT+1
198 Q COUNT
Note: See TracBrowser for help on using the repository browser.