source: WorldVistAEHR/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSCLSERV.m@ 619

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

initial load of WorldVistAEHR

File size: 8.8 KB
Line 
1YSCLSERV ;DALOI/RLM-Clozapine data server ;24 APR 1990
2 ;;5.01;MENTAL HEALTH;**18,22,26,47,61,69,74,90,92**;Dec 30, 1994;Build 7
3 ; Reference to ^%ZOSF supported by IA #10096
4 ; Reference to ^DPT supported by IA #10035
5 ; Reference to ^DD("DD" supported by IA #10017
6 ; Reference to ^PS(55 supported by IA #787
7 ; Reference to ^PSDRUG supported by IA #25
8 ; Reference to ^PSRX supported by IA #780
9 ; Reference to ^VA(200 supported by IA #10060
10 ; Reference to $$SITE^VASITE supported by IA #10112
11 ; Reference to $$FMTE^XLFDT() supported by IA #10103
12 ; Reference to ^PSDRUG supported by IA #221
13 ; Reference to ^XMD supported by IA #10070
14START ;
15 K ^TMP($J,"YSCLDATA")
16 S YSDEBUG=$P(^YSCL(603.03,1,0),"^",3)
17 S YSCLST=$P($$SITE^VASITE,"^",3)
18 S YSCLSTN=$P($$SITE^VASITE,"^",2)
19 ;Determine station number
20 S X=XQSUB X ^%ZOSF("UPPERCASE") S YSCLSUB=Y
21 S ^TMP($J,"YSCLDATA",1)=$S(YSDEBUG:"DEBUG ",1:"")_YSCLSUB_" triggered at "_YSCLST_" by "_XMFROM_" on "_XQDATE
22 ;The first line of the message tells who requested the action and when
23 D
24 . S YSACTION=$S(YSCLSUB["REMOVE"!(YSCLSUB["DELETE"):"data deleted",YSCLSUB["REPORT":"report generated",YSCLSUB["REBUILD":"data verified",YSCLSUB["UPDATE":"data updated",YSCLSUB["DATESET":"date set",1:"CONT")
25 . I YSACTION="CONT" S YSACTION=$S(YSCLSUB["DEMOG RESET":"Demographics Flag Reset",YSCLSUB["DEBUG":"Debug Mode set",YSCLSUB["AUTH":"Authorization",YSCLSUB["LOCK":"Lock",1:"Site Lock")
26 . S ^TMP($J,"YSCLDATA",2)="No "_$S(YSDEBUG:"DEBUG ",1:"")_YSACTION_" at "_YSCLST
27 ;The second line tells when the server is activated and no data can be
28 ;gathered from the MailMan message. This line gets replaced if the
29 ;server finds something to do.
30 S YSCLLNT=1 I YSCLSUB["REMOVE"!(YSCLSUB["DELETE") G DELETE
31 ;If the subject contains the word REMOVE or DELETE delete those entries from the list.
32 I YSCLSUB["REPORT" G REPORT
33 ;If the subject contains "REPORT" send a report of the currently registered patients to the Clozapine group on Forum
34 ;I YSCLSUB["REBUILD" G REBUILD
35 I YSCLSUB["RESEND" G RESEND
36 I YSCLSUB["UPDATE" G UPDATE
37 ;I YSCLSUB["CHECKSUM" G CSUM^YSCLSRV1
38 I YSCLSUB["DATESET" G DSET
39 I YSCLSUB["DEBUG" G DEBUG
40 I YSCLSUB["PATIENT" G ^YSCLSRV3
41 I YSCLSUB["LOCKOUT" G LOCK^YSCLSRV3
42 I YSCLSUB="DEMOG RESET" G DEMOG^YSCLSRV3
43 I YSCLSUB["AUTHORIZE" G AUTH^YSCLSRV3
44 I YSCLSUB="OVERRIDE" G OVRRID^YSCLSRV2
45 I YSCLSUB="CLAPI" G CLAPI^YSCLSRV2
46 I YSCLSUB="CL1API" G CL1API^YSCLSRV2
47 I YSCLSUB["DISCON" G DCON^YSCLSRV2
48 F X XMREC Q:XMER<0 S XMRG=$TR(XMRG,"- ","") D
49 . ;Verify that + of site number matches local site number
50 . I XMRG'?2U5N1","9N1","1U S YSCLER=" is in error and was not added at " D OUT Q
51 . I $P(XMRG,",")'?2U5N S YSCLER=" is not a valid Clozapine number " D OUT Q
52 . I $P(XMRG,",",2)'?9N S YSCLER=" An SSN must be 9 numbers " D OUT Q
53 . I $P(XMRG,",",3)'="B",$P(XMRG,",",3)'="W",$P(XMRG,",",3)'="M" S YSCLER=" You must specify Weekly, Biweekly, or Monthly " D OUT Q
54 . ;Validate the format of the data in the message and report the error.
55 . S DIC="^DPT(",DIC(0)="X",D="SSN",X=$P(XMRG,",",2) I '$D(^DPT("SSN",X)) S YSCLER=" SSN does not exist at " D OUT Q
56 . ;Do not add data for records where the SSN sent is not in the local database
57 . I $D(^YSCL(603.01,"B",$P(XMRG,","))) S YSCLX=$O(^YSCL(603.01,"B",$P(XMRG,","),"")) S:YSCLX]"" YSCLX=$P(^YSCL(603.01,YSCLX,0),"^",2),YSCLER=" Clozapine # is in use by "_$P($G(^DPT(YSCLX,0)),"^")_" at " D OUT Q
58 . D MIX^DIC1 S YSCLPT=+Y I Y=-1 S YSCLER=" could not be added at " D OUT Q
59 . ;Add the data and report any errors to the Roll-Up group at Forum.
60 . K DD S DIC="^YSCL(603.01,",X=$P(XMRG,","),DIC("DR")="1////"_YSCLPT_";2////"_$P(XMRG,",",3) K DO D FILE^DICN
61 . S YSCLX=$O(^YSCL(603.01,"B",$P(XMRG,","),"")) S:YSCLX]"" YSCLX=$P(^YSCL(603.01,YSCLX,0),"^",2),YSCLER=" assigned to "_$P($G(^DPT(YSCLX,0)),"^")_" at " D OUT
62EXIT ;If all went well, report that too.
63 S YSDEBUG=$P(^YSCL(603.03,1,0),"^",3)
64 S %H=$H D YMD^%DTC S XMDUN="NCCC LOGGER",XMDUZ=".5",XMSUB=$S(YSDEBUG:"DEBUG ",YSCLSUB["DEBUG":"DEBUG ",1:"")_YSCLST_" NCCC ENROLLER ("_X_%_")",XMTEXT="^TMP($J,""YSCLDATA"","
65 K XMY S XMY("G.CLOZAPINE ROLL-UP@FORUM.VA.GOV")=""
66 I YSDEBUG!(YSCLSUB["DEBUG") S XMY("G.CLOZAPINE DEBUG@FO-DALLAS.MED.VA.GOV")=""
67 D ^XMD
68 ;Mail the errors and successes back to the Roll-Up group at Forum.
69 K ^TMP($J,"YSCLDATA")
70 K %,%DT,%H,D,DA,DD,DIC,DIE,DIK,RET,X,XMDUN,XMDUZ,XMER,XMFROM
71 K XMREC,XMRG,XMSUB,XMTEXT,XMY,XMZ,XQDATE,XQSUB,Y,YSA,YSACTION,YSCLTYPE
72 K YSCL28,YSCLA,YSCLAA,YSCLB,YSCLC,YSCLDA,YSCLDA1,YSCLDATA,YSCLDEA1
73 K YSCLDFN,YSCLDM,YSCLDOC,YSCLDOM,YSCLDR,YSCLDRA,YSCLDRB,YSCLDTA,YSCLERR
74 K YSCLDUZ,YSCLED,YSCLER,YSCLFDA,YSCLFRQ,YSCLLNT,YSCLNM,YSCLOVR,YSCLSITE
75 K YSCLPT,YSCLRPT,YSCLSD1,YSCLSDT,YSCLSSN,YSCLST,YSCLSTN,YSCLSUB,YSCLTC
76 K YSCLRX,YSCLSAND,YSCLWB,YSCLX,YSCLYN,YSDEBUG,YSI,YSOFF,YSPR,ZTQUEUED,ZTSK
77 Q
78DELETE ;Allow the NCCC users to delete clozapine registration at the individual sites
79 S YSCLLNT=1 F X XMREC Q:XMER<0 S XMRG=$TR(XMRG,"- ","") D
80 . I XMRG="**++**DELETEALL**++**" D DELALL Q
81 . I '$D(^YSCL(603.01,"B",$P(XMRG,","))) S YSCLER=" "_$P(XMRG,",")_" is not registered at " D OUT Q
82 . S YSCLDFN=$O(^DPT("SSN",$P(XMRG,",",2),"")) I YSCLDFN="" S YSCLER=" "_$P(XMRG,",")_" is not a valid SSN at " D OUT Q
83 . I '$D(^YSCL(603.01,"C",YSCLDFN)) S YSCLER=" "_$P(XMRG,",",2)_" is not registered at " D OUT Q
84 . S YSCLA=$O(^YSCL(603.01,"B",$P(XMRG,","),"")) I YSCLA="" S YSCLER=" "_$P(XMRG,",")_" is not a valid entry at " D OUT Q
85 . K ^YSCL(603.01,YSCLA),^YSCL(603.01,"B",$P(XMRG,","),YSCLA),^YSCL(603.01,"C",YSCLDFN,YSCLA)
86 . S YSCLER=" removed at " D OUT
87 . ;I $D(^YSCL(603.01,"C",+Y)) K ^YSCL(603.01,YSCLA),^YSCL(603.01,"B",$P(XMRG,","),YSCLA),^YSCL(603.01,"C",YSCLDFN,YSCLA) S YSCLER=" removed at " D OUT Q ;RLM 9-29-99 ADDED QUIT
88 G EXIT
89DELALL ;Delete all patients in file 603.01
90 S YSCLA=0 F S YSCLA=$O(^YSCL(603.01,YSCLA)) Q:YSCLA="" D
91 . I YSCLA S YSCLER=$P(^YSCL(603.01,YSCLA,0),"^",1)_", "_$P(^DPT($P(^YSCL(603.01,YSCLA,0),"^",2),0),"^",9)_", ("_$P(^YSCL(603.01,YSCLA,0),"^",3)_") gdeleted at " D OUT
92 . K ^YSCL(603.01,YSCLA)
93 Q
94REPORT ;send report of current registrations to the Clozapine group on Forum
95 D REPORT^YSCLSRV2 G EXIT
96OUT S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)=XMRG_YSCLER_YSCLST Q
97 ;Build the text for the return message here.
98REBUILD ;
99 D REBUILD^YSCLSRV2 G EXIT
100UPDATE ;Update record with Monthly, Weekly or Bi-weekly status
101 F X XMREC Q:XMER<0 S XMRG=$TR(XMRG,"- ","") D
102 . I XMRG'?2U5N1","9N1","1U S YSCLER=" is in error and was not added at " D OUT Q
103 . I $P(XMRG,",")'?2U5N S YSCLER=" is not a valid Clozapine number format " D OUT Q
104 . I $P(XMRG,",",2)'?9N S YSCLER=" An SSN must be 9 numbers " D OUT Q
105 . I $P(XMRG,",",3)'="B",$P(XMRG,",",3)'="W",$P(XMRG,",",3)'="M" S YSCLER=" You must specify Monthly, Weekly or Biweekly " D OUT Q ;RLM 06/15/05
106 . S YSCLNM=$P(XMRG,","),YSCLSSN=$P(XMRG,",",2),YSCLWB=$P(XMRG,",",3)
107 . I '$D(^YSCL(603.01,"B",YSCLNM)) S YSCLER=" does not exist at " D OUT Q
108 . S YSCLDA=$O(^DPT("SSN",YSCLSSN,0))
109 . I YSCLDA="" S YSCLER=" SSN does not exist at " D OUT Q
110 . I $O(^YSCL(603.01,"B",YSCLNM,0))="" S YSCLER=" SSN not in Clozapine file " D OUT Q
111 . I $O(^DPT("SSN",YSCLSSN,YSCLDA)) S YSCLER=" SSN has more than one owner " D OUT Q
112 . I $O(^YSCL(603.01,"B",YSCLNM,0))'=$O(^YSCL(603.01,"C",YSCLDA,0)) S YSCLER=" SSN ("_YSCLSSN_","_$P(^DPT(YSCLDA,0),"^")_") has multiple Clozapine Numbers at " D OUT
113 . I $O(^YSCL(603.01,"B",YSCLNM,0))=$O(^YSCL(603.01,"C",YSCLDA,0)) D
114 . . S YSCLDA1=$O(^YSCL(603.01,"B",YSCLNM,0)) S $P(^YSCL(603.01,YSCLDA1,0),"^",3)=YSCLWB
115 . . S YSCLER=" "_YSCLNM_" ("_$P(^DPT(YSCLDA,0),"^")_") updated to "_$S(YSCLWB="M":"Monthly",YSCLWB="W":"Weekly",YSCLWB="B":"Bi-weekly",1:"Unknown")_" at " D OUT ;06/15/05
116 G EXIT
117RESEND ;Trigger retransmission of Clozapine data
118 X XMREC
119 K %DT S X=XMRG,%DT="P" D ^%DT I Y=-1 S YSCLER=" is an invalid date, RESEND not triggered at " D OUT G EXIT
120 S YSCLED=Y,(YSCLSDT,X)=Y D H^%DTC I %H#7'=5 S YSCLER=" is not a Tuesday, RESEND not triggered at " D OUT G EXIT
121 D SERV^YSCLTST2
122 S Y=YSCLSDT X ^DD("DD") S YSCLER=" - Resend triggered (local task #"_$G(ZTSK)_") by "_XMFROM_" for "_Y_" at " D OUT
123 G EXIT
124DSET ;Set the day of the week for the roll-up to run.
125 X XMREC Q:XMER<0 S X=$TR(XMRG,"- ","")
126 S YSOFF=$S(X="SUNDAY":0,X="MONDAY":1,X="TUESDAY":2,X="WEDNESDAY":3,X="THURSDAY":4,X="FRIDAY":5,X="SATURDAY":6,1:7)
127 I YSOFF>6 S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)=X_" isn't a valid day of the week." G EXIT
128 S $P(^YSCL(603.03,1,0),"^",2)=X
129 S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)="Run day set to "_X
130 G EXIT
131 Q
132DEBUG ;Turn debug mode on and off.
133 I YSCLSUB["DEBUG ON" D
134 . S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)="Debug Mode is "_$S(YSDEBUG:"already",1:"now")_" ON at "_YSCLSTN
135 . S $P(^YSCL(603.03,1,0),"^",3)=1
136 I YSCLSUB["DEBUG OFF" D
137 . S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)="Debug Mode is "_$S('YSDEBUG:"already",1:"now")_" OFF at "_YSCLSTN
138 . S $P(^YSCL(603.03,1,0),"^",3)=0
139 G EXIT
140ZEOR ;YSCLSERV
Note: See TracBrowser for help on using the repository browser.