QAMSANE ;HISC/DAD-MONITOR SANITY CHECK ;9/10/93 14:35
;;1.0;Clinical Monitoring System;;09/13/1993
;
;Checks monitor with internal entry number QAMD0 for correctness.
;If the monitor is ok Y is returned as 1. If The monitor is not
;ok Y will be returned as -1. Error messages will also be printed
;if QAMMSGS contains an 'E'. Warning messages will also be printed
;if QAMMSGS contains a 'W' (in addition to an 'E'). No messsages
;will be printed if QAMMSGS is undefined or null.
;
; Required variables
; QAMD0 = IEN of a monitor (file #743)
; QAMMSGS = <UNDEF> or Null - Do not display any messages
; E - Display error messages only
; EW - Display error and warning messages
;
S Y=1 G EXIT:$D(QAMD0)[0,EXIT:QAMD0'?1N.N
N QAMZERO,QAMONE,QAMTHRES,QAMERR,X
S QAMZERO=$G(^QA(743,QAMD0,0)),QAMONE=$G(^QA(743,QAMD0,1))
S QAMTHRES=$P(QAMONE,"^",3),QAMMSGS=$G(QAMMSGS)
I QAMMSGS["E" W !!,"Checking monitor..."
I QAMZERO="" S QAMERR=1 D ERROR G DONE ; Monitor exists
I $P(QAMZERO,"^",4)="" S QAMERR=2 D ERROR ; Auto enroll monitor
I $O(^QA(743,QAMD0,"COND",0))'>0 S QAMERR=3 D ERROR ; No conditions
I $G(^QA(743,QAMD0,"REL"))="" S QAMERR=4 D ERROR ; Fall out relate
I $G(^QA(743,QAMD0,"SMP"))="",$O(^QA(743,QAMD0,"COND","AS",0)) S QAMERR=5 D ERROR ; Sample size relate
I $P(QAMONE,"^",15)'>0 S QAMERR=6 D ERROR ; Cond for date of event
I $P(QAMONE,"^")'>0 S QAMERR=7 D ERROR ; Time frame
I QAMTHRES="" S QAMERR=8 D ERROR ; Threshold
I QAMTHRES["%",$P(QAMONE,"^",2)'>0 S QAMERR=9 D ERROR ; Minimum sample
I QAMTHRES,QAMTHRES'["%",$P(QAMONE,"^",2)>QAMTHRES S QAMERR=10 D ERROR ; Pre-threshold alert level > threshold
I QAMTHRES["%",$P(QAMONE,"^",4)="" S QAMERR=11 D ERROR ; Hi/Lo percent
I $P(QAMONE,"^",9),$G(^QA(743,QAMD0,"WSR"))="" S QAMERR=12 D ERROR ; Print daily worksheets and no worksheet routine
I $P(QAMONE,"^",10,12)["1",$P(QAMONE,"^",13)'>0 S QAMERR=13 D ERROR ; Bulletin mail group
I $P(QAMONE,"^",6)'>0 S QAMERR=14 D ERROR ; Start date
I $P(QAMONE,"^",6),$P(QAMONE,"^",7),$P(QAMONE,"^",7)<$P(QAMONE,"^",6) S QAMERR=15 D ERROR ; End date < Start date
I $P(QAMONE,"^",5)'>0 S QAMERR=16 D ERROR ; On/Off switch
DONE I QAMMSGS["E" W !,$S(Y=1:"No errors found.",Y=-1:"All errors must be corrected in order for this monitor to run !!",1:""),!
EXIT K QAMMSGS
Q
ERROR ; *** Set error flag (Y=-1) optionally write error message
S X=$P($T(ERRMSG+QAMERR),";;",2)
S:X Y=-1 Q:QAMMSGS="" Q:(X'>0)&(QAMMSGS'["W")
W !?2,$S(X:"*ERROR*",1:"Warning"),": ",$P(X,"^",2)
Q
ERRMSG ;;$S(1:"*ERROR*",0:"Warning") ^ Monitor error and warning messages
;;1^Monitor not found
;;1^AUTO ENROLL MONITOR not specified
;;1^No CONDITIONS specified
;;1^FALL OUT RELATIONSHIP not specified
;;0^SAMPLE RELATIONSHIP not specified
;;1^CONDITION FOR DATE OF EVENT not specified
;;0^TIME FRAME not specified
;;0^THRESHOLD not specified
;;0^MINIMUM SAMPLE not specified
;;0^PRE-THRESHOLD ALERT LEVEL greater than THRESHOLD
;;0^HI/LO PERCENT not specified
;;0^PRINT DAILY WORKSHEETS selected, WORKSHEET ROUTINE not specified
;;0^BULLETIN MAIL GROUP not specified
;;1^START DATE not specified
;;1^END DATE is less than the START DATE
;;0^ON/OFF SWITCH is turned off
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HQAMSANE 3303 printed Dec 13, 2024@01:42:42 Page 2
QAMSANE ;HISC/DAD-MONITOR SANITY CHECK ;9/10/93 14:35
+1 ;;1.0;Clinical Monitoring System;;09/13/1993
+2 ;
+3 ;Checks monitor with internal entry number QAMD0 for correctness.
+4 ;If the monitor is ok Y is returned as 1. If The monitor is not
+5 ;ok Y will be returned as -1. Error messages will also be printed
+6 ;if QAMMSGS contains an 'E'. Warning messages will also be printed
+7 ;if QAMMSGS contains a 'W' (in addition to an 'E'). No messsages
+8 ;will be printed if QAMMSGS is undefined or null.
+9 ;
+10 ; Required variables
+11 ; QAMD0 = IEN of a monitor (file #743)
+12 ; QAMMSGS = <UNDEF> or Null - Do not display any messages
+13 ; E - Display error messages only
+14 ; EW - Display error and warning messages
+15 ;
+16 SET Y=1
if $DATA(QAMD0)[0
GOTO EXIT
if QAMD0'?1N.N
GOTO EXIT
+17 NEW QAMZERO,QAMONE,QAMTHRES,QAMERR,X
+18 SET QAMZERO=$GET(^QA(743,QAMD0,0))
SET QAMONE=$GET(^QA(743,QAMD0,1))
+19 SET QAMTHRES=$PIECE(QAMONE,"^",3)
SET QAMMSGS=$GET(QAMMSGS)
+20 IF QAMMSGS["E"
WRITE !!,"Checking monitor..."
+21 ; Monitor exists
IF QAMZERO=""
SET QAMERR=1
DO ERROR
GOTO DONE
+22 ; Auto enroll monitor
IF $PIECE(QAMZERO,"^",4)=""
SET QAMERR=2
DO ERROR
+23 ; No conditions
IF $ORDER(^QA(743,QAMD0,"COND",0))'>0
SET QAMERR=3
DO ERROR
+24 ; Fall out relate
IF $GET(^QA(743,QAMD0,"REL"))=""
SET QAMERR=4
DO ERROR
+25 ; Sample size relate
IF $GET(^QA(743,QAMD0,"SMP"))=""
IF $ORDER(^QA(743,QAMD0,"COND","AS",0))
SET QAMERR=5
DO ERROR
+26 ; Cond for date of event
IF $PIECE(QAMONE,"^",15)'>0
SET QAMERR=6
DO ERROR
+27 ; Time frame
IF $PIECE(QAMONE,"^")'>0
SET QAMERR=7
DO ERROR
+28 ; Threshold
IF QAMTHRES=""
SET QAMERR=8
DO ERROR
+29 ; Minimum sample
IF QAMTHRES["%"
IF $PIECE(QAMONE,"^",2)'>0
SET QAMERR=9
DO ERROR
+30 ; Pre-threshold alert level > threshold
IF QAMTHRES
IF QAMTHRES'["%"
IF $PIECE(QAMONE,"^",2)>QAMTHRES
SET QAMERR=10
DO ERROR
+31 ; Hi/Lo percent
IF QAMTHRES["%"
IF $PIECE(QAMONE,"^",4)=""
SET QAMERR=11
DO ERROR
+32 ; Print daily worksheets and no worksheet routine
IF $PIECE(QAMONE,"^",9)
IF $GET(^QA(743,QAMD0,"WSR"))=""
SET QAMERR=12
DO ERROR
+33 ; Bulletin mail group
IF $PIECE(QAMONE,"^",10,12)["1"
IF $PIECE(QAMONE,"^",13)'>0
SET QAMERR=13
DO ERROR
+34 ; Start date
IF $PIECE(QAMONE,"^",6)'>0
SET QAMERR=14
DO ERROR
+35 ; End date < Start date
IF $PIECE(QAMONE,"^",6)
IF $PIECE(QAMONE,"^",7)
IF $PIECE(QAMONE,"^",7)<$PIECE(QAMONE,"^",6)
SET QAMERR=15
DO ERROR
+36 ; On/Off switch
IF $PIECE(QAMONE,"^",5)'>0
SET QAMERR=16
DO ERROR
DONE IF QAMMSGS["E"
WRITE !,$SELECT(Y=1:"No errors found.",Y=-1:"All errors must be corrected in order for this monitor to run !!",1:""),!
EXIT KILL QAMMSGS
+1 QUIT
ERROR ; *** Set error flag (Y=-1) optionally write error message
+1 SET X=$PIECE($TEXT(ERRMSG+QAMERR),";;",2)
+2 if X
SET Y=-1
if QAMMSGS=""
QUIT
if (X'>0)&(QAMMSGS'["W")
QUIT
+3 WRITE !?2,$SELECT(X:"*ERROR*",1:"Warning"),": ",$PIECE(X,"^",2)
+4 QUIT
ERRMSG ;;$S(1:"*ERROR*",0:"Warning") ^ Monitor error and warning messages
+1 ;;1^Monitor not found
+2 ;;1^AUTO ENROLL MONITOR not specified
+3 ;;1^No CONDITIONS specified
+4 ;;1^FALL OUT RELATIONSHIP not specified
+5 ;;0^SAMPLE RELATIONSHIP not specified
+6 ;;1^CONDITION FOR DATE OF EVENT not specified
+7 ;;0^TIME FRAME not specified
+8 ;;0^THRESHOLD not specified
+9 ;;0^MINIMUM SAMPLE not specified
+10 ;;0^PRE-THRESHOLD ALERT LEVEL greater than THRESHOLD
+11 ;;0^HI/LO PERCENT not specified
+12 ;;0^PRINT DAILY WORKSHEETS selected, WORKSHEET ROUTINE not specified
+13 ;;0^BULLETIN MAIL GROUP not specified
+14 ;;1^START DATE not specified
+15 ;;1^END DATE is less than the START DATE
+16 ;;0^ON/OFF SWITCH is turned off