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

QANFULL.m

Go to the documentation of this file.
QANFULL ;HISC/GJC-Auto E-Mail for locally closed cases. ; 5/30/12 2:06pm
 ;;2.0;Incident Reporting;**1,13,18,20,33**;08/07/1992;Build 12
 ;
 ;DON'T FORGET QAQDATE FOR AD HOC REPORTS!
 S QANZERO=$S($D(^QA(740,1,0))#2:^(0),1:0) I +QANZERO'>0 S QANERROR=1 D ERROR G EXIT
 S QANSITE=$S($D(^DIC(4,+QANZERO,0))#2:$P(^(0),"^"),1:"") I QANSITE="" S QANERROR=2 D ERROR G EXIT
 S QANSTNO=$S($D(^DIC(4,+QANZERO,99))#2:$P(^(99),"^"),1:"") I QANSTNO="" S QANERROR=3 D ERROR G EXIT
 S QANSERV=$P(QANZERO,"^",4) I QANSERV="" S QANERROR=4 D ERROR G EXIT
 S QANDOM=$P(QANZERO,"^",5) I QANDOM="" S QANERROR=5 D ERROR G EXIT
 S QA=+$O(^DIC(4.2,"B",QANDOM,0)) I $S('$D(^DIC(4.2,QA,0))#2:1,$P(^(0),"^")'=QANDOM:1,1:0) S QANERROR=6 D ERROR G EXIT
 S QANQAN=$S($D(^QA(740,1,"QAN")):^("QAN"),1:"") I +QANQAN'>0 S QANERROR=7 D ERROR G EXIT
 S QANMLGP=+$P(QANQAN,U),QANMLGP(0)=$S($D(^XMB(3.8,QANMLGP,0))#2:$P(^(0),U),1:"") I QANMLGP(0)']"" S QANERROR=7 D ERROR G EXIT
 D INC D:$D(^UTILITY($J,"QAN MAIL")) BULL^QANFULL0
EXIT ;Kill and quit
 K ^UTILITY($J),C,DA,DFN,DIE,DIWF,DIWL,DIWR,DR,ERROR,QA,QAN0,QAN1,QAN742
 K QAN7424,QANCASE,QANDATE,QANDESC,QANDOM,QANERROR,QANINCD,QANINCR
 K QANLOOP,QANLRCP,QANLRIN,QANLVL,QANMLGP,QANNCDNT,QANOK,QANPAT
 K QANPROV,QANQAN,QANQUIT,QANRSRV,QANSERV,QANSITE,QANSLEV,QANSRVCE
 K QANSTNO,QANADMIT,QANDOB,QANINLOC,QANTYDTH,QANY,QANZERO,VA1026,VAIN
 K VAINDT,X,XMDUZ,XMSUB,XMTEXT,XMY,Y
 Q
DESC ;Description
 S DIWF="",DIWL=20,DIWR=60,QANDESC=1 K ^UTILITY($J,"W")
 F QANLOOP=0:0 S QANLOOP=$O(^QA(742.4,QAN0,1,QANLOOP)) Q:QANLOOP'>0  S X=$P(^QA(742.4,QAN0,1,QANLOOP,0),U) D ^DIWP
 Q
ERROR ;Errors
 W *7,!!,"*** ",$P($T(ERR+QANERROR),";;",2)," ***",!!,*7
 Q
INC ;Incident data, for closed incidents.
 S QANINCR=0
 F QAN0=0:0 S QAN0=$O(^QA(742.4,"ACS",0,QAN0)) Q:QAN0'>0  S (QANDESC,QANQUIT)=0 D INC1
 Q
INC1 ;Incident data
 S QAN7424=$G(^QA(742.4,QAN0,0)) Q:QAN7424']""
 Q:+$P(QAN7424,U,18)'=0  ;has been xmitted
 K ^UTILITY($J,"W") ;Clean up for description
 S QANDATE=$P(QAN7424,U,3),QANCASE=$P(QAN7424,U)
 S QANNCDNT=+$P(QAN7424,U,2),QANINLOC=$P(QAN7424,U,4)
 Q:QANNCDNT'>0  ;check for null incident
 S:QANINLOC]"" QANINLOC=$P($G(^QA(742.5,QANINLOC,0)),U)
 S QANINCD=$S($D(^QA(742.1,QANNCDNT,0)):$P(^(0),U),1:"") Q:QANINCD']""
 S QANINCD=$TR(QANINCD,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 S QANTYDTH=$S(QANINCD="DEATH":$P(QAN7424,U,14),1:""),QANPROV=$P(QAN7424,U,16)
 S VA1026=$P(QAN7424,U,9),QANLVL=$P(QAN7424,U,11),QANLRIN=$P(QAN7424,U,12)
 S QANLRCP=$P(QAN7424,U,13)
 D:$D(^QA(742.4,QAN0,1,0)) DESC
 D EN1^QANFULL0 ;Grab patient data, build mail message
 I QANQUIT K DA,DIE,DR S DIE="^QA(742.4,",DA=QAN0,DR=".17///^S X=4" D ^DIE K DA,DIE,DR
 I QANQUIT K DA,DIE,DR S DIE="^QA(742.4,",DA=QAN0,DR=".21///^S X=1" D ^DIE K DA,DIE,DR
 Q
ERR ;;ERROR MESSAGES: REASONS EWS BULLETIN COULD NOT BE SENT
 ;;SITE NOT FOUND IN QA SITE PARAMETERS FILE
 ;;SITE NOT FOUND IN INSTITUTION FILE
 ;;SITE NUMBER NOT FOUND IN INSTITUTION FILE
 ;;NQADB MAIL GROUP/SERVER NOT FOUND IN QA SITE PARAMETERS FILE
 ;;NQADB DOMAIN NOT FOUND IN QA SITE PARAMETERS FILE
 ;;NQADB DOMAIN NOT FOUND IN DOMAIN FILE
 ;;QA INCIDENT MAILGROUP NOT FOUND IN QA SITE PARAMETERS FILE