source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMCEV3.m@ 1432

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

initial load of WorldVistAEHR

File size: 4.0 KB
RevLine 
[613]1SCMCEV3 ;ALB/CMM - TEAM EVENT DRIVER UTILITIES ; 03/20/96
2 ;;5.3;Scheduling;**41**;AUG 13, 1993
3 ;
4INVOKE(DFN) ;envokes Team Event Driver
5 I '$D(^TMP($J,"SC CED",DFN,"BEFORE"))!('$D(^TMP($J,"SC CED",DFN,"AFTER"))) G EXIT
6 S X=+$O(^ORD(101,"B","SC CLINIC ENROLL/DISCHARGE EVENT DRIVER",0))_";ORD(101,"
7 D EN^XQOR
8EXIT ;
9 K ^TMP($J,"SC CED",DFN,"BEFORE"),^TMP($J,"SC CED",DFN,"AFTER"),X
10 Q
11 ;
12BEFORE(DFN) ;
13 ;get before picture of ^DPT(DFN,"DE") node
14 ;
15 K ^TMP($J,"SC CED",DFN,"BEFORE")
16 MERGE ^TMP($J,"SC CED",DFN,"BEFORE")=^DPT(DFN,"DE")
17 I '$D(^TMP($J,"SC CED",DFN,"BEFORE")) S ^TMP($J,"SC CED",DFN,"BEFORE")=""
18 ; ^ not enrolled in any clinics ever
19 Q
20 ;
21AFTER(DFN) ;
22 ;get after picture of ^DPT(DFN,"DE") node
23 ;
24 K ^TMP($J,"SC CED",DFN,"AFTER")
25 MERGE ^TMP($J,"SC CED",DFN,"AFTER")=^DPT(DFN,"DE")
26 Q
27 ;
28COMPARE(DFN) ;team event driver
29 ;compare before and after of DFN's "DE" node
30 N NXT,SUB1,SUB2,NEW,CLN,ENT
31 S (NXT,SUB1,SUB2)=0
32 I '$D(^TMP($J,"SC CED",DFN,"AFTER")) G DELS
33 F S NXT=$O(^TMP($J,"SC CED",DFN,"AFTER",NXT)) Q:NXT=""!(NXT'?.N) D
34 .S NEW=0
35 .;check clinic added
36 .I '$D(^TMP($J,"SC CED",DFN,"BEFORE",NXT,0)) D NEWC(DFN,NXT) S NEW=1
37 .Q:NEW
38 .S SUB1=0
39 .;change to existing entry
40 .F S SUB1=$O(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1)) Q:SUB1=""!(SUB1'?.N) D
41 ..S SUB2=0
42 ..F S SUB2=$O(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2)) Q:SUB2=""!(SUB2'?.N) D
43 ...I $G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0))'=$G(^TMP($J,"SC CED",DFN,"BEFORE",NXT,SUB1,SUB2,0)) D CHNG(DFN,NXT,SUB1,SUB2)
44 ;
45DELS ;look for deletes
46 S CLN=""
47 F S CLN=$O(^TMP($J,"SC CED",DFN,"BEFORE","B",CLN)) Q:CLN="" D
48 .S ENT=$O(^TMP($J,"SC CED",DFN,"BEFORE","B",CLN,""))
49 .Q:ENT=""
50 .I '$D(^TMP($J,"SC CED",DFN,"AFTER","B",CLN,ENT)) D DELT^SCMCEV1(DFN,CLN)
51 Q
52 ;
53CHNG(DFN,NXT,SUB1,SUB2) ;
54 ;changes made in entry SUB2 of SUB1 entry of entry NXT of "DE" node
55 N FLAG,EDATE,GDATE,CIEN,CHECK,ENROL,CNAME
56 S (ENROL,FLAG,GDATE)=0
57 I $P($G(^TMP($J,"SC CED",DFN,"BEFORE",NXT,SUB1,SUB2,0)),"^")'=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^") S EDATE=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^"),FLAG=1,ENROL=1,EDATE=$P(EDATE,".")
58 ; ^ date only
59 ;enroll date changed
60 I $P($G(^TMP($J,"SC CED",DFN,"BEFORE",NXT,SUB1,SUB2,0)),"^",3)'=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^",3) S GDATE=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^",3),FLAG=1,ENROL=$S(ENROL=1:3,1:2),GDATE=$P(GDATE,".")
61 ; ^ date only
62 ;discharge date changed/added
63 S CHECK=""
64 S CIEN=+$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,0)),"^") ;clinic ien
65 S CNAME=$P($G(^SC(CIEN,0)),"^") ;clinic name
66 I $D(EDATE),EDATE=""!(EDATE=0) D DELT^SCMCEV1(DFN,CIEN) Q
67 ; ^ deleted enrollment date
68 I $D(GDATE),'$D(EDATE) S EDATE=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^"),EDATE=$P(EDATE,".") ;date only
69 I $D(GDATE),EDATE=GDATE D DELT^SCMCEV1(DFN,CIEN) Q
70 ; ^ enrolled and discharged on same date
71 I GDATE'="",ENROL=1 S ENROL=3
72 I GDATE'="",ENROL=1 S ENROL=2
73 ;enrol = 1:enrollment ; 2=discharge ; 3=both
74 I FLAG S CHECK=$$CHK^SCMCEV2(DFN,CIEN,ENROL)
75 ;update 404.42?
76 I +CHECK D UPDATE^SCMCEV1(DFN,$P(CHECK,"^",2),EDATE,GDATE,CNAME)
77 Q
78 ;
79NEWC(DFN,NXT) ;
80 ;new clinic added (enrolled)
81 ;DFN - patient ien
82 ;NXT - ien of "DE" node
83 ;
84 N CIEN,NODE,CHKIT,SUB1,EDATE,GDATE,FLG,CNAME,SCRESTA,SCREST
85 S NODE=$G(^TMP($J,"SC CED",DFN,"AFTER",NXT,0))
86 Q:NODE=""
87 S CIEN=$P(NODE,"^") ;clinic ien
88 S CNAME=$P($G(^SC(+CIEN,0)),"^") ;clinic name
89 S SUB1=$O(^TMP($J,"SC CED",DFN,"AFTER",NXT,0))
90 S SUB2=$O(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,"A"),-1)
91 S EDATE=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^"),FLG=1
92 S EDATE=$P(EDATE,".") ;date only
93 S GDATE=$P($G(^TMP($J,"SC CED",DFN,"AFTER",NXT,SUB1,SUB2,0)),"^",3)
94 S GDATE=$P(GDATE,".") ;date only
95 I GDATE'="" S FLG=3
96 ; -- This fires off MailMessage for new assignment to Clinic
97 S SCREST=$$RESTPT^SCAPMCU4(DFN,DT,"SCRESTA")
98 D:SCREST MAIL^SCMCCON(DFN,.CNAME,1,EDATE,"SCRESTA")
99 ; --- ----
100 S CHKIT=$$CHK^SCMCEV2(DFN,CIEN,FLG)
101 I +CHKIT D ENROLL^SCMCEV1(DFN,$P(CHKIT,"^",2),EDATE,GDATE,CNAME)
102 Q
103 ;
Note: See TracBrowser for help on using the repository browser.