Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DVBAVRX2

DVBAVRX2.m

Go to the documentation of this file.
DVBAVRX2 ;ALB/GAK - CAPRI BACKGROUND JOB1 FOR VOCREHAB ;06/21/2012 12:00pm
 ;;2.7;AMIE;**181**;Apr 10, 1995;Build 38
 ;
 Q  ;NO DIRECT ENTRY
 ;
JOB1 ;PROCESS NEW REQUESTS AND SEND MAILMAN MESSAGES FOR AGED REQUESTS
 ;
 N %H,X,Y,%Y,DAT
 N DVBADAT,DVBAIEN
 N DVBAFARY   ;FORM ARRAY FOR GETS
 N DVBAFERR   ;FORM ARRAY ERROR ARRAY
 N DVBAPOC,DVBARDAT,DVBAPNAM,DVBAPDFN,DVBAPSSN,DVBAPSDT,DVBASNTL
 N DVBAOK   ;OKAY TO PASS PII TO MAILMAN MESSAGE
 N DVBAGERR   ;GET1 ERROR ARRAY
 N DVBAXIEN   ;WORKING VARIABLE TO ADD "," TO END OF IEN FOR GETS/GET1
 N DVBAVRRA   ;DVBA VOCREHAB REQUESTOR EMAIL ADDRESS FROM #200,.151 - EXCHANGE EMAIL ADDRESS
 N DVBATD   ;TODAY
 N DVBATAG   ;TEST AGE
 N DVBASWSD   ;SWITCH FOR DATE (0 OR 1)
 N DVBAFARY,ERROR    ;FORM ARRAY
 N DATENG   ;DATE IN ENGLISH
 N DVBADOW    ;DAY OF WEEK
 N DVBAAGE,DVBAXAGE
 N DVBAEMA    ;WORKING VARIABLE FOR EMAIL ADDRESS
 N DVBARPTD   ;REPORT FORMAT DATE AND TIME
 N MAILSUBLN
 ;
 S (%H,DAT)=+$H D YMD^%DTC    ; CONVERT $H TO FILEMAN DATE
 S DVBATD=X
 F DVBAXAGE=5,6,7 D
 . K DVBAAGE
 . ;BUILD AGE ARRAY
 . D WWDA(DVBATD,DVBAXAGE)
 . S J="" F  S J=$O(DVBAAGE(J)) Q:J=""  D
 .. S DVBASWSD=0
 .. S DVBADAT=$P(DVBAAGE(J),"^",2)_".0000001"
 .. F  S DVBADAT=$O(^DVB(396.9,"ARSDT","N",DVBADAT)) Q:DVBADAT=""!(DVBASWSD=1)  D
 ... S DVBATAG=$P(DVBADAT,".",1) I DVBATAG'=$P(DVBAAGE(J),"^",2) S DVBASWSD=1 Q
 ... S DVBAIEN="" F  S DVBAIEN=$O(^DVB(396.9,"ARSDT","N",DVBADAT,DVBAIEN)) Q:DVBAIEN=""  D
 .... K DVBAFARY,DVBAFERR
 .... K DVBAPOC,DVBARDAT,DVBAPNAM,DVBAPDFN,DVBAPSSN,DVBAPSDT,DVBAOK
 .... S DVBAOK=0
 .... D GETS^DIQ(396.9,DVBAIEN_",","*","IE","DVBAFARY","DVBAFERR")
 .... ;
 .... S DVBASNTL=$G(DVBAFARY(396.9,DVBAIEN_",",1,"E"))   ;SEND TO LOCATION
 .... S DVBAPOC=$G(DVBAFARY(396.9,DVBAIEN_",",11,"I"))   ;POINT OF CONTACT IEN
 .... S DVBARDAT=$G(DVBAFARY(396.9,DVBAIEN_",",.01,"E"))   ;REQUEST DATE
 .... S DVBAPNAM=$G(DVBAFARY(396.9,DVBAIEN_",",4,"E"))   ;PATIENT NAME
 .... S DVBAPDFN=$G(DVBAFARY(396.9,DVBAIEN_",",4,"I"))   ;PATIENT DFN
 .... ;ICR# FOR #2;.09 - no IA needed for this file
 .... S DVBAPSDT=DVBAFARY(396.9,DVBAIEN_",",9,"E")   ;PREFERRED SCHEDULE DATE   [2;3] [D]
 .... S MAILSUBLN="VOC REHAB REQUEST IS NOW "_DVBAXAGE_" DAYS OLD"
 .... I DVBAXAGE=5!(DVBAXAGE=6) D
 ..... S DVBAOK=1
 ..... S DVBAEMA="G.DVBA VR VOCREHAB PERSONNEL"
 ..... D NFYAGE
 ..... ;
 .... I DVBAXAGE=7 D
 ..... ;ICR# (10060) FOR #200;.151 - no IA needed for this file
 ..... S DVBAXIEN=DVBAIEN_","
 ..... S DVBAVRRA=$$GET1^DIQ(200,DVBAFARY(396.9,DVBAXIEN,11,"I"),.151,"","","DVBAGERR")
 ..... I $D(DVBAGERR) Q
 ..... Q:DVBAVRRA=""
 ..... S DVBAEMA=DVBAVRRA
 ..... D NFYAGE
 ;
 Q
 ;
NFYAGE ;SETUP MAILMAN MESSAGE BASED ON JOB1 VARIABLES
 ;
 Q:DVBAEMA=""
 N XMSUB,XMTEXT,XMY,XMDUZ,XMDUN,XMZ,XMMG
 N DVBAMMT   ;MAILMAN MESSAGE TEXT ARRAY
 N DVBASTT   ;START TIME STAMP
 N C,D,D0,DA,DI,DIC,DIE,DILOCKTM,DISYS,DQ,DR,X,Y,%
 ;
 S %H=$H D YX^%DTC S X=X_% S DVBASTT=$$FMTE^XLFDT(X,"5FPZ")
 S XMDUZ="VOCREHAB POSTMASTER"
 S XMSUB="Chapter 31 Referral for Medical Services has aged "_DVBAXAGE_" days"
 S XMY(DVBAEMA)=""
 S XMTEXT="DVBAMMT("
 S DVBAMMT(1)="Sent: "_DVBASTT
 S DVBAMMT(2)="To: "_DVBAEMA
 S DVBAMMT(3)="Subject: "_XMSUB
 S DVBAMMT(4)=""
 S DVBAMMT(5)="            REQUEST DATE: "_DVBARDAT
 S DVBAMMT(6)="            PATIENT  DFN: `"_DVBAPDFN
 S DVBAMMT(7)=" PREFERRED SCHEDULE DATE: "_DVBAPSDT
 S DVBAMMT(7.5)=""
 S DVBAMMT(8)="THE 'NEW' STATUS ON THIS FORM 28-8861 HAS NOW AGED "_DVBAXAGE_" DAYS"
 S DVBAMMT(9)="PLEASE MAKE SURE PATIENT HAS CONSULT LINKED TO FORM."
 S DVBAMMT(10)=""
 S DVBAMMT(11)="**NOTE: To view the patient using the DFN, paste the DFN number into the"
 S DVBAMMT(12)="CAPRI Patient Selector 'Patient ID' field to find the patient. Be sure to"
 S DVBAMMT(13)="include the ' (backward-apostrophe) character."
 ;
 D XMZ^XMA2
 D ^XMD
 ;
 Q
 ;
WWDA(DVBATD,DVBAXAGE)   
 ;
 ;WORK WEEK DAY AGING
 ; RETURNS   THE DATES TO WRITE EMAILS FOR
 ; DVBATD    TODAY IS THE DATE THE FUNCTION IS RUNNING FOR
 ; DVBAAGE   AGE IS THE NUMBER OF DAYS TO AGE FOR (5, 6, OR 7) ONLY
 ; SPECIAL DAYS OF THE WEEK ARE MON, FRIDAY, AND TUESDAY
 ;
 ;IS DAT A WEEKEND DAY?
 ;
 ;S DVBAAGE(5)=""   ; MON=MON, TUE=TUE, ...
 ;                  ; FRIDAY LOOKS FOR ALL SAT AND SUN FORM 8861 ENTRIES 5 DAYS OLD
 ;S DVBAAGE(6)=""   ; MON=FRI, TUE=MON, WED=TUE, THR=WED, FRI=THR
 ;                  ; MONDAY LOOKS FOR ALL SAT AND SUN FORM 8861 ENTRIES 6 DAYS OLD
 ;S DVBAAGE(7)=""   ; MON=THR, TUE=FRI, WED=MON, THR=TUE, FRI=WED
 ;                  ; TUESDAY LOOKS FOR ALL SAT AND SUN FORM 8861 ENTRIES 7 DAYS OLD
 ;
 N %Y,X,X1,X2
 N J,DVBADOW
 K DVBAAGE
 ;
 S X=DVBATD
 ;RETURN TODAY'S DAY OF THE WEEK (0-6)/(SUN - SAT)
 D DW^%DTC
 S DVBADOW=%Y
 ; 
 ;DO NOT RUN ON DOW 0 OR 6
 I DVBADOW=0!(DVBADOW=6) Q ""
 ;
 I DVBADOW=1&(DVBAXAGE=5) S DVBAAGE("MON")=-7
 I DVBADOW=1&(DVBAXAGE=6) S DVBAAGE("FRI")=-10
 I DVBADOW=1&(DVBAXAGE=6) S DVBAAGE("SAT")=-9
 I DVBADOW=1&(DVBAXAGE=6) S DVBAAGE("SUN")=-8
 I DVBADOW=1&(DVBAXAGE=7) S DVBAAGE("THR")=-11
 ;
 I DVBADOW=2&(DVBAXAGE=5) S DVBAAGE("TUE")=-7
 I DVBADOW=2&(DVBAXAGE=6) S DVBAAGE("MON")=-8
 I DVBADOW=2&(DVBAXAGE=7) S DVBAAGE("FRI")=-11
 I DVBADOW=2&(DVBAXAGE=7) S DVBAAGE("SAT")=-10
 I DVBADOW=2&(DVBAXAGE=7) S DVBAAGE("SUN")=-9
 ;
 I DVBADOW=3&(DVBAXAGE=5) S DVBAAGE("WED")=-7
 I DVBADOW=3&(DVBAXAGE=6) S DVBAAGE("TUE")=-8
 I DVBADOW=3&(DVBAXAGE=7) S DVBAAGE("MON")=-9
 ;
 I DVBADOW=4&(DVBAXAGE=5) S DVBAAGE("THR")=-7
 I DVBADOW=4&(DVBAXAGE=6) S DVBAAGE("WED")=-8
 I DVBADOW=4&(DVBAXAGE=7) S DVBAAGE("TUE")=-9
 ;
 I DVBADOW=5&(DVBAXAGE=5) S DVBAAGE("FRI")=-7
 I DVBADOW=5&(DVBAXAGE=5) S DVBAAGE("SAT")=-6
 I DVBADOW=5&(DVBAXAGE=5) S DVBAAGE("SUN")=-5
 I DVBADOW=5&(DVBAXAGE=6) S DVBAAGE("THR")=-8
 I DVBADOW=5&(DVBAXAGE=7) S DVBAAGE("WED")=-9
 ;
 S J="" F  S J=$O(DVBAAGE(J)) Q:J=""  D
 . S X1=DVBATD
 . S X2=DVBAAGE(J)
 . D C^%DTC
 . S $P(DVBAAGE(J),"^",2)=X
 ;
 Q
 ;