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

QANMAIL.m

Go to the documentation of this file.
QANMAIL ;HISC/GJC-Manually xmit data to the region (part 1) ;8/23/93  13:39
 ;;2.0;Incident Reporting;**1,18,20**;08/07/1992
EN1 ;Manually xmit data
 S (QANQUIT,QANXIT)=0 K ^UTILITY($J,"QAN MAIL")
 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 INCD ;Set incident data
 I QANXIT D EXIT Q
 D:$D(^UTILITY($J,"QAN MAIL")) BULL^QANMAL0
 W !!?5,$S($D(^UTILITY($J,"QAN MAIL")):"Data transmitted to the region.",1:"No data found!")
EXIT ;Kill and quit
 D KILL^XUSCLEAN K ^UTILITY($J,"QAN MAIL")
 Q
ERROR ;Find error type
 W *7,!!,"*** ",$P($T(ERR+QANERROR),";;",2)," ***",!!,*7
 Q
INCD ;
 ;Choose the incident, put into report option
 ;*** QANIEN IS FILE 742.4'S IEN ***
 K DD,DLAYGO,DO,DINUM,D,DIC S QANTYPE=1,DIC="^QA(742.4,",DIC(0)="QEANZ",DIC("A")="Select Incident Case Number: ",DIC("W")="D EN1^QANUTL"
 S DIC("S")="I +$P(^(0),U,18)=0"
 D ^DIC K DD,DLAYGO,DINUM,DO,D,DIC
 I +Y=-1 W !!,*7,"Incident not selected, exiting!!" Q
 E  S QANIEN=+Y
 S QAN7424=$G(^QA(742.4,QANIEN,0)) S:QAN7424']"" QANXIT=1
 Q:QANXIT  S (QANDESC,QANINCR)=0
 S QANDATE=$P(QAN7424,U,3),QANCASE=$P(QAN7424,U)
 S QANNCDNT=$P(QAN7424,U,2),QANINLOC=$P(QAN7424,U,4)
 S:QANINLOC]"" QANINLOC=$P($G(^QA(742.5,QANINLOC,0)),U)
 S QANINCD=$P($G(^QA(742.1,QANNCDNT,0)),U)
 S:QANINCD']"" QANXIT=1 Q:QANXIT
 S QANINCD=$TR(QANINCD,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 S QANTYDTH=$S(QANINCD="DEATH":$P(QAN7424,U,14),1:"")
 S QANLCST=$P(QAN7424,U,8)
 S QABANNER=$S(QANLCST=0:"CMAN",QANLCST=2:"DMAN",1:"OMAN")
 S VA1026=+$P(QAN7424,U,9),QANLVL=$P(QAN7424,U,11)
 S QANLRIN=$P(QAN7424,U,12),QANLRCP=$P(QAN7424,U,13)
 I $D(^QA(742.4,QANIEN,1,0)) D DESC
 D EN1^QANMAL0 ;Grab all associated patient data
 I QANQUIT D
 . K DA,DIE,DR S DA=QANIEN,DIE="^QA(742.4,"
 . S DR=".17////"_QANLCST_";.21////1" D ^DIE
 . K DIE,DA,DR
 Q
DESC ;Grab description data
 S DIWF="",DIWL=20,DIWR=60,QANDESC=1 K ^UTILITY($J,"W")
 F QANLOOP=0:0 S QANLOOP=$O(^QA(742.4,QANIEN,1,QANLOOP)) Q:QANLOOP'>0  S X=$P(^QA(742.4,QANIEN,1,QANLOOP,0),U) D ^DIWP
 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