source: WorldVistAEHR/trunk/r/INCIDENT_REPORTING-QAN/QANDELE.m@ 1369

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

initial load of WorldVistAEHR

File size: 4.4 KB
RevLine 
[613]1QANDELE ;HISC/GJC-Auto E-Mail for locally deleted cases ;8/6/93 10:03
2 ;;2.0;Incident Reporting;**1,18,20**;08/07/1992
3 ;
4 S QANZERO=$S($D(^QA(740,1,0))#2:^(0),1:0) I +QANZERO'>0 S QANERROR=1 D ERROR G EXIT
5 S QANSITE=$S($D(^DIC(4,+QANZERO,0))#2:$P(^(0),"^"),1:"") I QANSITE="" S QANERROR=2 D ERROR G EXIT
6 S QANSTNO=$S($D(^DIC(4,+QANZERO,99))#2:$P(^(99),"^"),1:"") I QANSTNO="" S QANERROR=3 D ERROR G EXIT
7 S QANSERV=$P(QANZERO,"^",4) I QANSERV="" S QANERROR=4 D ERROR G EXIT
8 S QANDOM=$P(QANZERO,"^",5) I QANDOM="" S QANERROR=5 D ERROR G EXIT
9 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
10 S QANQAN=$S($D(^QA(740,1,"QAN")):^("QAN"),1:"") I +QANQAN'>0 S QANERROR=7 D ERROR G EXIT
11 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
12 D INC D:$D(^UTILITY($J,"QAN MAIL")) BULL
13EXIT ;Kill and quit
14 K ^UTILITY($J),DA,DIE,DR,ERROR,QA,QAN0,QAN1,QAN742,QAN7424,QANCASE
15 K QANDATE,QANDESC,QANDOM,QANERROR,QANINCD,QANINCR,QANMLGP,QANNCDNT
16 K QANOK,QANPAT,QANPROV,QANQAN,QANQUIT,QANSERV,QANSITE,QANSLEV,QANSRVCE
17 K QANDOB,QANSTNO,QANTYDTH,QANZERO,X,XMDUZ,XMSUB,XMTEXT,XMY,Y
18 Q
19BULL ;Mail message
20 D KILL^XM
21 S XMY(QANSERV_"@"_QANDOM)="",XMDUZ=.5
22 S XMSUB="QAN Incident Event: "_^DD("SITE")_" ("_^DD("SITE",1)_")"
23 S XMTEXT="^UTILITY($J,""QAN MAIL""," D ^XMD,KILL^XM
24 Q
25ERROR ;Error messages
26 W *7,!!,"*** ",$P($T(ERR+QANERROR),";;",2)," ***",!!,*7
27 Q
28INC ;Choose the incident, check 'ACS' x-ref for deleted.
29 S QANINCR=0
30 F QAN0=0:0 S QAN0=$O(^QA(742.4,"ACS",2,QAN0)) Q:QAN0'>0 S (QANDESC,QANQUIT)=0 D INC1
31 Q
32INC1 ;If 'DELETED' and not xmitted, continue
33 S QAN7424=$G(^QA(742.4,QAN0,0)) Q:QAN7424']""
34 Q:+$P(QAN7424,U,18)'=0 ;Been xmitted
35 S QANDATE=$P(QAN7424,U,3),QANCASE=$P(QAN7424,U),QANNCDNT=$P(QAN7424,U,2)
36 S QANINCD=$S($D(^QA(742.1,QANNCDNT,0)):$P(^(0),U),1:"") Q:QANINCD']""
37 S QANINCD=$TR(QANINCD,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
38 S QANTYDTH=$S(QANINCD="DEATH":$P(QAN7424,U,14),1:""),QANPROV=$P(QAN7424,U,16)
39 ;/*** Grab patient data ***/
40 F QAN1=0:0 S QAN1=$O(^QA(742,"BCS",QAN0,QAN1)) Q:QAN1'>0 S QAN742=$G(^QA(742,QAN1,0)) S:QAN742]"" QANOK=0 D:QAN742]"" PAT
41 I QANQUIT K DA,DIE,DR S DIE="^QA(742.4,",DA=QAN0,DR=".17///^S X=2" D ^DIE K DA,DIE,DR
42 I QANQUIT K DA,DIE,DR S DIE="^QA(742.4,",DA=QAN0,DR=".21///^S X=1" D ^DIE K DA,DIE,DR
43 Q
44INCK ;Check status of incident
45 I QANINCD="HOMICIDE" S QANOK=1
46 I QANINCD="DEATH" D
47 . S QANTYDTH=+$G(QANTYDTH)
48 . I '$D(^QA(742.14,"BUPPER","OTHER",QANTYDTH)),('$D(^QA(742.14,"BUPPER","WITHIN 24 HOURS OF ADMISSION (EX. DOA'S AND TERMINALS)",QANTYDTH))) S QANOK=1
49 I QANINCD="SUICIDE" S QANOK=1
50 I QANINCD="SEXUAL ASSAULT" S QANOK=1
51 I QANINCD="SUICIDE ATTEMPT" S QANOK=1
52 I QANINCD="INFORMED CONSENT-FAIL. TO OBTAIN" S QANOK=1
53 I QANINCD="PATIENT ABUSE" S QANOK=1
54 I QANINCD="INJURY NOT OTHERWISE LISTED",(QANSLEV'<2) S QANOK=1
55 I QANINCD="ASSAULT-PATIENT TO PATIENT",(QANSLEV'<2) S QANOK=1
56 I QANINCD="FIRE-PATIENT INVOLVED IN",(QANSLEV'<2) S QANOK=1
57 I QANINCD="ASSAULT-PATIENT/STAFF",(QANSLEV'<2) S QANOK=1
58 I QANINCD="FALL",(QANSLEV'<2) S QANOK=1
59 I QANINCD="MEDICATION ERROR",(QANSLEV'<2) S QANOK=1
60 I QANINCD="TRANSFUSION ERROR",(QANSLEV'<2) S QANOK=1
61 I QANINCD="MISSING PATIENT",(QANSLEV'<2) S QANOK=1
62 Q
63PAT ;Patient data
64 Q:$P(QAN742,U,12)'<0 ;Checks for deleted patients.
65 S (QANSRVCE,Y)=$P(QAN742,U,8),C=$P(^DD(742,.08,0),U,2) D:Y]"" Y^DIQ S QANSRVCE=Y
66 S QANSLEV=+$P(QAN742,U,10) D INCK Q:'QANOK
67 S QANQUIT=1,QANINCR=QANINCR+1
68 S QANPAT=$P(QAN742,U),^UTILITY($J,"QAN PAT",QAN1)=$P(^DPT(QANPAT,0),U)
69 S ^UTILITY($J,"QAN SSN",QAN1)=$P(^DPT(QANPAT,0),U,9)
70 S QANDOB=$P(^DPT(QANPAT,0),U,3)
71 S ^UTILITY($J,"QAN MAIL",QANINCR)="DELETE^"_QANCASE_"^INCD^"_QANINCD_"^"_QANDATE_"^^^^"_QANMLGP(0)_"^^^"_$G(QANPROV)_"^"
72 S QANINCR=QANINCR+1
73 S ^UTILITY($J,"QAN MAIL",QANINCR)="DELETE^"_QANCASE_"^PAT^"_$G(^UTILITY($J,"QAN PAT",QAN1))_"^"_$G(^UTILITY($J,"QAN SSN",QAN1))_"^"_QANSLEV_"^"_QANTYDTH_"^"_QANSRVCE_"^^"_QANDOB_"^"
74 Q
75ERR ;;ERROR MESSAGES: REASONS EWS BULLETIN COULD NOT BE SENT
76 ;;SITE NOT FOUND IN QA SITE PARAMETERS FILE
77 ;;SITE NOT FOUND IN INSTITUTION FILE
78 ;;SITE NUMBER NOT FOUND IN INSTITUTION FILE
79 ;;NQADB MAIL GROUP/SERVER NOT FOUND IN QA SITE PARAMETERS FILE
80 ;;NQADB DOMAIN NOT FOUND IN QA SITE PARAMETERS FILE
81 ;;NQADB DOMAIN NOT FOUND IN DOMAIN FILE
82 ;;QA INCIDENT MAILGROUP NOT FOUND IN QA SITE PARAMETERS FILE
Note: See TracBrowser for help on using the repository browser.