1 | ORLP3AUC ; SLC/CLA - Automatically load clinic patients into team lists ;9/11/96 [12/28/99 2:45pm]
|
---|
2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,47**;Dec 17, 1997
|
---|
3 | ; Re-created by PKS, 7/99.
|
---|
4 | ;
|
---|
5 | ; This code checks the ^TMP file that is written by the
|
---|
6 | ; SC CLINIC ENROLL/DISCHARGE EVENT DRIVER protocol. That
|
---|
7 | ; protocol in turn calls the protocol ORU AUTOLIST CLINIC,
|
---|
8 | ; which calls this routine. When control is returned to
|
---|
9 | ; SC CLINIC ENROLL/DISCHARGE EVENT DRIVER, the ^TMP entries
|
---|
10 | ; are deleted. They can be viewed by breaking out before
|
---|
11 | ; that point for testing [^TMP($J,"SC CED")].
|
---|
12 | ;
|
---|
13 | ; (NOTE: At the time of re-creation of this routine, existing code
|
---|
14 | ; would not allow a user to enter a clinic enrollment or clinic
|
---|
15 | ; discharge date later than the current day. Thus, no post-date
|
---|
16 | ; checking is included in this routine.)
|
---|
17 | ;
|
---|
18 | EN ; Called by protocol: ORU AUTOLIST CLINIC. Updates Team Lists
|
---|
19 | ; where the Autolink is a clinic.
|
---|
20 | ;
|
---|
21 | ; Variables used -
|
---|
22 | ;
|
---|
23 | ; By tags called (in ORLP3AC1):
|
---|
24 | ;
|
---|
25 | ; ORTL = OE/RR TEAM LIST file.
|
---|
26 | ; ORTEAM = Team List.
|
---|
27 | ; ORAL = Team List Autolink.
|
---|
28 | ; ORVAL = Team List Autolink node data value.
|
---|
29 | ; ORTYPE = Type of Autolink.
|
---|
30 | ; ORLINK = Autolink holder variable.
|
---|
31 | ; LNAME = Team List textual name.
|
---|
32 | ; VP = Array for call to PTS^ORLP2.
|
---|
33 | ;
|
---|
34 | ; By this tag (and by tags called as needed):
|
---|
35 | ;
|
---|
36 | ; ORPT = Patient number.
|
---|
37 | ; ORBARY = Array of "B" index clinics.
|
---|
38 | ; ORCL = Clinic.
|
---|
39 | ; ORBRCD = "BEFORE" clinic record number.
|
---|
40 | ; ORARCD = "AFTER" clinic record number.
|
---|
41 | ; ORBLAST = Last record in ^TMP file for "BEFORE" clinic.
|
---|
42 | ; ORALAST = Last record in ^TMP file for "AFTER" clinic.
|
---|
43 | ; ORBEFORE = Data in "BEFORE" record.
|
---|
44 | ; ORAFTER = Data in "AFTER" record.
|
---|
45 | ; ORBEDATE = "BEFORE" clinic enrollment date.
|
---|
46 | ; ORBDDATE = "BEFORE" clinic discharge date.
|
---|
47 | ; ORAEDATE = "AFTER" clinic enrollment date.
|
---|
48 | ; ORADDATE = "AFTER" clinic discharge date.
|
---|
49 | ;
|
---|
50 | N ORTL,ORPT,ORBARY,ORCL,ORBRCD,ORARCD,ORBLAST,ORALAST,ORBEFORE,ORAFTER,ORBEDATE,ORBDDATE,ORAEDATE,ORADDATE
|
---|
51 | S ORTL="100.21" ; Assign for use by ADD and DELETE tags.
|
---|
52 | ;
|
---|
53 | ; Check for existence of ^TMP entries:
|
---|
54 | I '$D(^TMP($J,"SC CED")) Q
|
---|
55 | ;
|
---|
56 | ; Process each patient in the ^TMP file:
|
---|
57 | S ORPT=0 ; Initialize.
|
---|
58 | F S ORPT=$O(^TMP($J,"SC CED",ORPT)) Q:'ORPT D
|
---|
59 | .;
|
---|
60 | .; Build an array of clinics for each patient in the ^TMP file:
|
---|
61 | .K ORBARY ; Clean up each time through.
|
---|
62 | .;
|
---|
63 | .; Order through the "B" index records for this patient:
|
---|
64 | .S ORCL=0 ; Initialize.
|
---|
65 | .F S ORCL=$O(^TMP($J,"SC CED",ORPT,"BEFORE","B",ORCL)) Q:'+ORCL DO ; Each "BEFORE" "B" record for clinics.
|
---|
66 | ..S ORBARY(ORCL)="" ; Set array element for each "BEFORE" clinic.
|
---|
67 | .S ORCL=0 ; Re-initialize.
|
---|
68 | .F S ORCL=$O(^TMP($J,"SC CED",ORPT,"AFTER","B",ORCL)) Q:'+ORCL D ; Each "AFTER" "B" record for clinics.
|
---|
69 | ..S ORBARY(ORCL)="" ; Set array element for each "AFTER" clinic.
|
---|
70 | .; The previous array should contain only one entry for each clinic,
|
---|
71 | .; whether from "BEFORE" or "AFTER" entries - (dupes overwritten).
|
---|
72 | .;
|
---|
73 | .; Check for valid data again:
|
---|
74 | .I '$D(ORBARY) Q ; If nothing to process, done.
|
---|
75 | .;
|
---|
76 | .; Write data entries for "BEFORE" and "AFTER" based on ^TMP data:
|
---|
77 | .S ORCL=0 ; Initialize.
|
---|
78 | .F S ORCL=$O(ORBARY(ORCL)) Q:'+ORCL D ; Array entries.
|
---|
79 | ..I $D(^TMP($J,"SC CED",ORPT,"BEFORE","B",ORCL)) S ORBARY(ORCL)=$O(^TMP($J,"SC CED",ORPT,"BEFORE","B",ORCL,"")) ; Set array element to ^TMP "BEFORE" "B" x-ref record number.
|
---|
80 | ..S ORBARY(ORCL)=ORBARY(ORCL)_"^" ; Add delimiter.
|
---|
81 | ..I $D(^TMP($J,"SC CED",ORPT,"AFTER","B",ORCL)) S ORBARY(ORCL)=ORBARY(ORCL)_$O(^TMP($J,"SC CED",ORPT,"AFTER","B",ORCL,"")) ; Set array element to ^TMP "AFTER" "B" x-ref record number.
|
---|
82 | .;
|
---|
83 | .; Array entries like the following should now exist:
|
---|
84 | .;
|
---|
85 | .; ORBARY(5)=1^1 | Clinic 5 has "BEFORE" and "AFTER" entries.
|
---|
86 | .; ORBARY(16)=^3 | Clinic 16 has only an "AFTER" entry.
|
---|
87 | .; (Etc.)
|
---|
88 | .; ORBARY(11)=2^ | No "AFTER" entry - should never happen!
|
---|
89 | .;
|
---|
90 | .; Process each clinic listed for this patient:
|
---|
91 | .S ORCL=0 ; Initialize.
|
---|
92 | .F S ORCL=$O(ORBARY(ORCL)) Q:'+ORCL D ; Each clinic.
|
---|
93 | ..;
|
---|
94 | ..; Check for no "AFTER" records:
|
---|
95 | ..;I $P($G(ORBARY(ORCL)),"^",2)="" Q ; Shouldn't happen!
|
---|
96 | ..;
|
---|
97 | ..; Get "BEFORE" and "AFTER" record entries for this clinic:
|
---|
98 | ..S ORBRCD="",ORARCD="" ; Initialize.
|
---|
99 | ..S ORBRCD=$P(ORBARY(ORCL),"^") ; Assign "BEFORE" record number, if any.
|
---|
100 | ..S ORARCD=$P(ORBARY(ORCL),"^",2) ; Assign "AFTER" record number, if any.
|
---|
101 | ..;
|
---|
102 | ..; Find the last records for each case, as applicable:
|
---|
103 | ..S ORBLAST="",ORALAST="" ; Initialize.
|
---|
104 | ..I $G(ORBRCD) S ORBLAST=$O(^TMP($J,"SC CED",ORPT,"BEFORE",ORBRCD,1,ORBLAST),-1) ; Last "BEFORE" record.
|
---|
105 | ..I $G(ORARCD) S ORALAST=$O(^TMP($J,"SC CED",ORPT,"AFTER",ORARCD,1,ORALAST),-1) ; Last "AFTER" record.
|
---|
106 | ..;
|
---|
107 | ..; Get BEFORE and AFTER data from last records for each clinic:
|
---|
108 | ..S ORBEFORE="",ORAFTER="" ; Initialize.
|
---|
109 | ..I $G(ORBLAST) S ORBEFORE=$G(^TMP($J,"SC CED",ORPT,"BEFORE",ORBRCD,1,ORBLAST,0)) ; Get "BEFORE" data.
|
---|
110 | ..I $G(ORALAST) S ORAFTER=$G(^TMP($J,"SC CED",ORPT,"AFTER",ORARCD,1,ORALAST,0)) ; Get "AFTER" data.
|
---|
111 | ..;
|
---|
112 | ..; With "BEFORE" and "AFTER" data, process Team Lists -
|
---|
113 | ..;
|
---|
114 | ..; If no changes, there's nothing to do for this clinic:
|
---|
115 | ..I ORBEFORE=ORAFTER Q
|
---|
116 | ..;
|
---|
117 | ..; Get date information in each case as applicable:
|
---|
118 | ..S ORBEDATE=$P($G(ORBEFORE),"^") ; "BEFORE" enroll date.
|
---|
119 | ..S ORBEDATE=$P($G(ORBEDATE),".") ; Remove time, if any.
|
---|
120 | ..S ORBDDATE=$P($G(ORBEFORE),"^",3) ; "BEFORE" d/c date.
|
---|
121 | ..S ORAEDATE=$P($G(ORAFTER),"^") ; "AFTER" date.
|
---|
122 | ..S ORAEDATE=$P($G(ORAEDATE),".") ; Remove time, if any.
|
---|
123 | ..S ORADDATE=$P($G(ORAFTER),"^",3) ; "AFTER" d/c date.
|
---|
124 | ..; (All four dates should now be set, even if to null.)
|
---|
125 | ..;
|
---|
126 | ..; Now call the ADD or DELETE tags in ORLP3AC1 as appropriate -
|
---|
127 | ..;
|
---|
128 | ..; If no "AFTER" d/c and enroll <> "BEFORE" enroll, call add:
|
---|
129 | ..I (ORADDATE="")&(ORAEDATE'=ORBEDATE) D ADD^ORLP3AC1
|
---|
130 | ..;
|
---|
131 | ..; If "AFTER" d/c exists and <> "BEFORE" d/c, call delete:
|
---|
132 | ..I (ORADDATE'="")&(ORADDATE'=ORBDDATE) D DELETE^ORLP3AC1
|
---|
133 | ;
|
---|
134 | K ORBARY ; Clean up.
|
---|
135 | Q
|
---|
136 | ;
|
---|