source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSCLSERV.m@ 1528

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

initial load of FOIAVistA 6/30/08 version

File size: 8.7 KB
Line 
1YSCLSERV ;DALOI/RLM-Clozapine data server ;24 APR 1990
2 ;;5.01;MENTAL HEALTH;**18,22,26,47,61,69,74,90**;Dec 30, 1994;Build 18
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 F X XMREC Q:XMER<0 S XMRG=$TR(XMRG,"- ","") D
46 . ;Verify that + of site number matches local site number
47 . I XMRG'?2U5N1","9N1","1U S YSCLER=" is in error and was not added at " D OUT Q
48 . I $P(XMRG,",")'?2U5N S YSCLER=" is not a valid Clozapine number " D OUT Q
49 . I $P(XMRG,",",2)'?9N S YSCLER=" An SSN must be 9 numbers " D OUT Q
50 . 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
51 . ;Validate the format of the data in the message and report the error.
52 . 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
53 . ;Do not add data for records where the SSN sent is not in the local database
54 . 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
55 . D MIX^DIC1 S YSCLPT=+Y I Y=-1 S YSCLER=" could not be added at " D OUT Q
56 . ;Add the data and report any errors to the Roll-Up group at Forum.
57 . K DD S DIC="^YSCL(603.01,",X=$P(XMRG,","),DIC("DR")="1////"_YSCLPT_";2////"_$P(XMRG,",",3) K DO D FILE^DICN
58 . 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
59EXIT ;If all went well, report that too.
60 S YSDEBUG=$P(^YSCL(603.03,1,0),"^",3)
61 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"","
62 K XMY S XMY("G.CLOZAPINE ROLL-UP@FORUM.VA.GOV")=""
63 I YSDEBUG!(YSCLSUB["DEBUG") S XMY("G.CLOZAPINE DEBUG@FO-DALLAS.MED.VA.GOV")=""
64 D ^XMD
65 ;Mail the errors and successes back to the Roll-Up group at Forum.
66 K ^TMP($J,"YSCLDATA")
67 K %,%DT,%H,D,DA,DD,DIC,DIE,DIK,RET,X,XMDUN,XMDUZ,XMER,XMFROM
68 K XMREC,XMRG,XMSUB,XMTEXT,XMY,XMZ,XQDATE,XQSUB,Y,YSA,YSACTION
69 K YSCL28,YSCLA,YSCLAA,YSCLB,YSCLC,YSCLDA,YSCLDA1,YSCLDATA,YSCLDEA1
70 K YSCLDFN,YSCLDM,YSCLDOC,YSCLDOM,YSCLDR,YSCLDRA,YSCLDRB,YSCLDTA
71 K YSCLDUZ,YSCLED,YSCLER,YSCLFDA,YSCLFRQ,YSCLLNT,YSCLNM,YSCLOVR
72 K YSCLPT,YSCLSD1,YSCLSDT,YSCLSSN,YSCLST,YSCLSTN,YSCLSUB,YSCLTC
73 K YSCLWB,YSCLX,YSCLYN,YSDEBUG,YSI,YSOFF,YSPR,ZTQUEUED,ZTSK
74 Q
75DELETE ;Allow the NCCC users to delete clozapine registration at the individual sites
76 S YSCLLNT=1 F X XMREC Q:XMER<0 S XMRG=$TR(XMRG,"- ","") D
77 . I XMRG="**++**DELETEALL**++**" D DELALL Q
78 . I '$D(^YSCL(603.01,"B",$P(XMRG,","))) S YSCLER=" "_$P(XMRG,",")_" is not registered at " D OUT Q
79 . S YSCLDFN=$O(^DPT("SSN",$P(XMRG,",",2),"")) I YSCLDFN="" S YSCLER=" "_$P(XMRG,",")_" is not a valid SSN at " D OUT Q
80 . I '$D(^YSCL(603.01,"C",YSCLDFN)) S YSCLER=" "_$P(XMRG,",",2)_" is not registered at " D OUT Q
81 . S YSCLA=$O(^YSCL(603.01,"B",$P(XMRG,","),"")) I YSCLA="" S YSCLER=" "_$P(XMRG,",")_" is not a valid entry at " D OUT Q
82 . K ^YSCL(603.01,YSCLA),^YSCL(603.01,"B",$P(XMRG,","),YSCLA),^YSCL(603.01,"C",YSCLDFN,YSCLA)
83 . S YSCLER=" removed at " D OUT
84 . ;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
85 G EXIT
86DELALL ;Delete all patients in file 603.01
87 S YSCLA=0 F S YSCLA=$O(^YSCL(603.01,YSCLA)) Q:YSCLA="" D
88 . 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
89 . K ^YSCL(603.01,YSCLA)
90 Q
91REPORT ;send report of current registrations to the Clozapine group on Forum
92 D REPORT^YSCLSRV2 G EXIT
93OUT S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)=XMRG_YSCLER_YSCLST Q
94 ;Build the text for the return message here.
95REBUILD ;
96 D REBUILD^YSCLSRV2 G EXIT
97UPDATE ;Update record with Monthly, Weekly or Bi-weekly status
98 F X XMREC Q:XMER<0 S XMRG=$TR(XMRG,"- ","") D
99 . I XMRG'?2U5N1","9N1","1U S YSCLER=" is in error and was not added at " D OUT Q
100 . I $P(XMRG,",")'?2U5N S YSCLER=" is not a valid Clozapine number format " D OUT Q
101 . I $P(XMRG,",",2)'?9N S YSCLER=" An SSN must be 9 numbers " D OUT Q
102 . 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
103 . S YSCLNM=$P(XMRG,","),YSCLSSN=$P(XMRG,",",2),YSCLWB=$P(XMRG,",",3)
104 . I '$D(^YSCL(603.01,"B",YSCLNM)) S YSCLER=" does not exist at " D OUT Q
105 . S YSCLDA=$O(^DPT("SSN",YSCLSSN,0))
106 . I YSCLDA="" S YSCLER=" SSN does not exist at " D OUT Q
107 . I $O(^YSCL(603.01,"B",YSCLNM,0))="" S YSCLER=" SSN not in Clozapine file " D OUT Q
108 . I $O(^DPT("SSN",YSCLSSN,YSCLDA)) S YSCLER=" SSN has more than one owner " D OUT Q
109 . 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
110 . I $O(^YSCL(603.01,"B",YSCLNM,0))=$O(^YSCL(603.01,"C",YSCLDA,0)) D
111 . . S YSCLDA1=$O(^YSCL(603.01,"B",YSCLNM,0)) S $P(^YSCL(603.01,YSCLDA1,0),"^",3)=YSCLWB
112 . . 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
113 G EXIT
114RESEND ;Trigger retransmission of Clozapine data
115 X XMREC
116 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
117 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
118 D SERV^YSCLTST2
119 S Y=YSCLSDT X ^DD("DD") S YSCLER=" - Resend triggered (local task #"_$G(ZTSK)_") by "_XMFROM_" for "_Y_" at " D OUT
120 G EXIT
121DSET ;Set the day of the week for the roll-up to run.
122 X XMREC Q:XMER<0 S X=$TR(XMRG,"- ","")
123 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)
124 I YSOFF>6 S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)=X_" isn't a valid day of the week." G EXIT
125 S $P(^YSCL(603.03,1,0),"^",2)=X
126 S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)="Run day set to "_X
127 G EXIT
128 Q
129DEBUG ;Turn debug mode on and off.
130 I YSCLSUB["DEBUG ON" D
131 . S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)="Debug Mode is "_$S(YSDEBUG:"already",1:"now")_" ON at "_YSCLSTN
132 . S $P(^YSCL(603.03,1,0),"^",3)=1
133 I YSCLSUB["DEBUG OFF" D
134 . S YSCLLNT=$G(YSCLLNT)+1,^TMP($J,"YSCLDATA",YSCLLNT)="Debug Mode is "_$S('YSDEBUG:"already",1:"now")_" OFF at "_YSCLSTN
135 . S $P(^YSCL(603.03,1,0),"^",3)=0
136 G EXIT
137ZEOR ;YSCLSERV
Note: See TracBrowser for help on using the repository browser.