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

QAMC23.m

Go to the documentation of this file.
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