QAMC23 ;HISC/DAD-CONDITION: MH SECLUSION/RESTRAINT ;9/3/93 13:24
;;1.0;Clinical Monitoring System;;09/13/1993
EN1 ; *** CONDITION CODE
S WARDGRP=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:+^("P1"),1:0)
S TYPEGRP=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:+^("P2"),1:0)
S REASGRP=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P3"))#2:+^("P3"),1:0)
S SRHOURS=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P4"))#2:+^("P4"),1:0)
D NOW^%DTC S QAMNOW=%
F QAMHDT=QAMTODAY-.0000001:0 S QAMHDT=$O(^YS(615.2,"B",QAMHDT)) Q:(QAMHDT'>0)!(QAMHDT>(QAMTODAY+.9999999))!(QAMHDT\1'?7N) F QAMHD0=0:0 S QAMHD0=$O(^YS(615.2,"B",QAMHDT,QAMHD0)) Q:QAMHD0'>0 D LOOP1
K DIC,DIR,DIRUT,FOUND,QAMHD0,QAMHDT,QAMHZERO,QAMPARAM,REAS,REASGRP,TYPE,TYPEGRP,WARD,WARDGRP,QAMAPPLY,QAMNOW,QAMRELAS,QAMDAY,QAMHRS,QAMSEC,SRHOURS
Q
LOOP1 S QAMHZERO=$G(^YS(615.2,QAMHD0,0)) Q:QAMHZERO=""
I WARDGRP S WARD=$P(QAMHZERO,"^",4) Q:$O(^QA(743.5,WARDGRP,"GRP","AB",WARD,0))'>0
I TYPEGRP S FOUND=0 D Q:'FOUND
. F TYPE=0:0 S TYPE=$O(^YS(615.2,QAMHD0,5,"B",TYPE)) Q:TYPE'>0 I $O(^QA(743.5,WARDGRP,"GRP","AB",WARD,0)) S FOUND=1 Q
. Q
I REASGRP S FOUND=0 D Q:'FOUND
. F REAS=0:0 S REAS=$O(^YS(615.2,QAMHD0,10,"B",REAS)) Q:REAS'>0 I $O(^QA(743.5,REASGRP,"GRP","AB",REAS,0)) S FOUND=1 Q
. Q
S QAMDFN=+$P(QAMHZERO,"^",2),QAMAPPLY=+$P(QAMHZERO,"^",3),QAMRELAS=$P($G(^YS(615.2,QAMHD0,40)),"^",3),QAMRELAS=$S(QAMRELAS:QAMRELAS,1:QAMNOW)
S X=QAMAPPLY D H^%DTC S QAMAPPLY(1)=+%H,QAMAPPLY(2)=%T
S X=QAMRELAS D H^%DTC S QAMRELAS(1)=+%H,QAMRELAS(2)=%T
S QAMDAY=QAMRELAS(1)-QAMAPPLY(1),QAMSEC=QAMRELAS(2)-QAMAPPLY(2)
S QAMDAY=QAMDAY-(QAMSEC<0),QAMSEC=QAMSEC+$S(QAMSEC<0:86400,1:0)
S QAMHRS=24*QAMDAY+(QAMSEC/3600) Q:QAMHRS<SRHOURS
S ^UTILITY($J,"QAM CONDITION",QAMD1,QAMDFN)="",^(QAMDFN,QAMAPPLY)=QAMHD0
Q
EN2 ; *** PARAMETER CODE
21 K DIC,DIR,DIRUT S DIC=743.5,DIC(0)="EMNQZ",DIC("S")="I $P(^(0),""^"",2)=44",DIC("A")="HOSPITAL LOCATION GROUP: ",DIC("B")=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:$P(^("P1"),"^",2),1:"") K:DIC("B")="" DIC("B")
S DIR("?",1)="Enter a GROUP name that contains MAS hospital locations.",DIR("?")="Press 'RETURN' for all hospital locations."
S QAMPARAM="P1" D EN2^QAMUTL1 I $D(DIRUT) S Y=-1 G Y
S:Y]"" ^QA(743,QAMD0,"COND",QAMD1,"P1")=+Y_"^"_Y(0,0)
;
22 K DIC,DIR,DIRUT S DIC=743.5,DIC(0)="EMNQZ",DIC("S")="I $P(^(0),""^"",2)=615.6",DIC("A")="SECLUSION/RESTRAINT TYPE GROUP: ",DIC("B")=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:$P(^("P2"),"^",2),1:"") K:DIC("B")="" DIC("B")
S DIR("?",1)="Enter a GROUP name that contains types of seclusion or restraints.",DIR("?")="Press 'RETURN' for all types of seclusion and restraints."
S QAMPARAM="P2" D EN2^QAMUTL1 I $D(DIRUT) S Y=-1 G Y
S:Y]"" ^QA(743,QAMD0,"COND",QAMD1,"P2")=+Y_"^"_Y(0,0)
;
23 K DIC,DIR,DIRUT S DIC=743.5,DIC(0)="EMNQZ",DIC("S")="I $P(^(0),""^"",2)=615.5",DIC("A")="REASON FOR S/R GROUP: ",DIC("B")=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P3"))#2:$P(^("P3"),"^",2),1:"") K:DIC("B")="" DIC("B")
S DIR("?",1)="Enter a GROUP name that contains reasons for seclusion/restraint.",DIR("?")="Press 'RETURN' for all reasons."
S QAMPARAM="P3" D EN2^QAMUTL1 I $D(DIRUT) S Y=-1 G Y
S:Y]"" ^QA(743,QAMD0,"COND",QAMD1,"P3")=+Y_"^"_Y(0,0)
24 ;
2 K DIR,DIRUT S DIR(0)="NO^1:96:0",DIR("A")="MAXIMUM TIME IN S/R (HOURS)",DIR("B")=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:+^("P2"),1:24) K:DIR("B")'>0 DIR("B")
S DIR("?",1)="Enter the maximum number of hours the patient may be held"
S DIR("?",2)="in seclusion/restraint. Patients in S/R for more than"
S DIR("?",3)="this amount of time will be captured."
S DIR("?")="Enter a number from 1 to 96."
S QAMPARAM="P4" D EN3^QAMUTL1 I $D(DIRUT) S Y=-1 G Y
S:Y]"" ^QA(743,QAMD0,"COND",QAMD1,"P4")=Y
EXIT K Y
K QAMPARAM
Y Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HQAMC23 3746 printed Dec 13, 2024@01:42:07 Page 2
QAMC23 ;HISC/DAD-CONDITION: MH SECLUSION/RESTRAINT ;9/3/93 13:24
+1 ;;1.0;Clinical Monitoring System;;09/13/1993
EN1 ; *** CONDITION CODE
+1 SET WARDGRP=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:+^("P1"),1:0)
+2 SET TYPEGRP=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:+^("P2"),1:0)
+3 SET REASGRP=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P3"))#2:+^("P3"),1:0)
+4 SET SRHOURS=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P4"))#2:+^("P4"),1:0)
+5 DO NOW^%DTC
SET QAMNOW=%
+6 FOR QAMHDT=QAMTODAY-.0000001:0
SET QAMHDT=$ORDER(^YS(615.2,"B",QAMHDT))
if (QAMHDT'>0)!(QAMHDT>(QAMTODAY+.9999999))!(QAMHDT\1'?7N)
QUIT
FOR QAMHD0=0:0
SET QAMHD0=$ORDER(^YS(615.2,"B",QAMHDT,QAMHD0))
if QAMHD0'>0
QUIT
DO LOOP1
+7 KILL DIC,DIR,DIRUT,FOUND,QAMHD0,QAMHDT,QAMHZERO,QAMPARAM,REAS,REASGRP,TYPE,TYPEGRP,WARD,WARDGRP,QAMAPPLY,QAMNOW,QAMRELAS,QAMDAY,QAMHRS,QAMSEC,SRHOURS
+8 QUIT
LOOP1 SET QAMHZERO=$GET(^YS(615.2,QAMHD0,0))
if QAMHZERO=""
QUIT
+1 IF WARDGRP
SET WARD=$PIECE(QAMHZERO,"^",4)
if $ORDER(^QA(743.5,WARDGRP,"GRP","AB",WARD,0))'>0
QUIT
+2 IF TYPEGRP
SET FOUND=0
Begin DoDot:1
+3 FOR TYPE=0:0
SET TYPE=$ORDER(^YS(615.2,QAMHD0,5,"B",TYPE))
if TYPE'>0
QUIT
IF $ORDER(^QA(743.5,WARDGRP,"GRP","AB",WARD,0))
SET FOUND=1
QUIT
+4 QUIT
End DoDot:1
if 'FOUND
QUIT
+5 IF REASGRP
SET FOUND=0
Begin DoDot:1
+6 FOR REAS=0:0
SET REAS=$ORDER(^YS(615.2,QAMHD0,10,"B",REAS))
if REAS'>0
QUIT
IF $ORDER(^QA(743.5,REASGRP,"GRP","AB",REAS,0))
SET FOUND=1
QUIT
+7 QUIT
End DoDot:1
if 'FOUND
QUIT
+8 SET QAMDFN=+$PIECE(QAMHZERO,"^",2)
SET QAMAPPLY=+$PIECE(QAMHZERO,"^",3)
SET QAMRELAS=$PIECE($GET(^YS(615.2,QAMHD0,40)),"^",3)
SET QAMRELAS=$SELECT(QAMRELAS:QAMRELAS,1:QAMNOW)
+9 SET X=QAMAPPLY
DO H^%DTC
SET QAMAPPLY(1)=+%H
SET QAMAPPLY(2)=%T
+10 SET X=QAMRELAS
DO H^%DTC
SET QAMRELAS(1)=+%H
SET QAMRELAS(2)=%T
+11 SET QAMDAY=QAMRELAS(1)-QAMAPPLY(1)
SET QAMSEC=QAMRELAS(2)-QAMAPPLY(2)
+12 SET QAMDAY=QAMDAY-(QAMSEC<0)
SET QAMSEC=QAMSEC+$SELECT(QAMSEC<0:86400,1:0)
+13 SET QAMHRS=24*QAMDAY+(QAMSEC/3600)
if QAMHRS<SRHOURS
QUIT
+14 SET ^UTILITY($JOB,"QAM CONDITION",QAMD1,QAMDFN)=""
SET ^(QAMDFN,QAMAPPLY)=QAMHD0
+15 QUIT
EN2 ; *** PARAMETER CODE
21 KILL DIC,DIR,DIRUT
SET DIC=743.5
SET DIC(0)="EMNQZ"
SET DIC("S")="I $P(^(0),""^"",2)=44"
SET DIC("A")="HOSPITAL LOCATION GROUP: "
SET DIC("B")=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:$PIECE(^("P1"),"^",2),1:"")
if DIC("B")=""
KILL DIC("B")
+1 SET DIR("?",1)="Enter a GROUP name that contains MAS hospital locations."
SET DIR("?")="Press 'RETURN' for all hospital locations."
+2 SET QAMPARAM="P1"
DO EN2^QAMUTL1
IF $DATA(DIRUT)
SET Y=-1
GOTO Y
+3 if Y]""
SET ^QA(743,QAMD0,"COND",QAMD1,"P1")=+Y_"^"_Y(0,0)
+4 ;
22 KILL DIC,DIR,DIRUT
SET DIC=743.5
SET DIC(0)="EMNQZ"
SET DIC("S")="I $P(^(0),""^"",2)=615.6"
SET DIC("A")="SECLUSION/RESTRAINT TYPE GROUP: "
SET DIC("B")=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:$PIECE(^("P2"),"^",2),1:"")
if DIC("B")=""
KILL DIC("B")
+1 SET DIR("?",1)="Enter a GROUP name that contains types of seclusion or restraints."
SET DIR("?")="Press 'RETURN' for all types of seclusion and restraints."
+2 SET QAMPARAM="P2"
DO EN2^QAMUTL1
IF $DATA(DIRUT)
SET Y=-1
GOTO Y
+3 if Y]""
SET ^QA(743,QAMD0,"COND",QAMD1,"P2")=+Y_"^"_Y(0,0)
+4 ;
23 KILL DIC,DIR,DIRUT
SET DIC=743.5
SET DIC(0)="EMNQZ"
SET DIC("S")="I $P(^(0),""^"",2)=615.5"
SET DIC("A")="REASON FOR S/R GROUP: "
SET DIC("B")=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P3"))#2:$PIECE(^("P3"),"^",2),1:"")
if DIC("B")=""
KILL DIC("B")
+1 SET DIR("?",1)="Enter a GROUP name that contains reasons for seclusion/restraint."
SET DIR("?")="Press 'RETURN' for all reasons."
+2 SET QAMPARAM="P3"
DO EN2^QAMUTL1
IF $DATA(DIRUT)
SET Y=-1
GOTO Y
+3 if Y]""
SET ^QA(743,QAMD0,"COND",QAMD1,"P3")=+Y_"^"_Y(0,0)
24 ;
2 KILL DIR,DIRUT
SET DIR(0)="NO^1:96:0"
SET DIR("A")="MAXIMUM TIME IN S/R (HOURS)"
SET DIR("B")=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:+^("P2"),1:24)
if DIR("B")'>0
KILL DIR("B")
+1 SET DIR("?",1)="Enter the maximum number of hours the patient may be held"
+2 SET DIR("?",2)="in seclusion/restraint. Patients in S/R for more than"
+3 SET DIR("?",3)="this amount of time will be captured."
+4 SET DIR("?")="Enter a number from 1 to 96."
+5 SET QAMPARAM="P4"
DO EN3^QAMUTL1
IF $DATA(DIRUT)
SET Y=-1
GOTO Y
+6 if Y]""
SET ^QA(743,QAMD0,"COND",QAMD1,"P4")=Y
EXIT KILL Y
+1 KILL QAMPARAM
Y QUIT