QAMC8 ;HISC/DAD-CONDITION: LENGTH OF STAY ON A WARD ;2/10/92 07:33
;;1.0;Clinical Monitoring System;;09/13/1993
EN1 ; *** CONDITION CODE
S LOS=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:+^("P1"),1:0)
S WARDGRP=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:+^("P2"),1:0)
S X1=QAMTODAY,X2=-LOS D C^%DTC S (X1,START)=X,X2=1 D C^%DTC S END=X,START=START-.0000001 K ^UTILITY($J,"QAM TEMP")
F WARDDT=START:0 S WARDDT=$O(^DGPM("AMV1",WARDDT)) Q:(WARDDT'>0)!(WARDDT'<END)!(WARDDT\1'?7N) F QAMDFN=0:0 S QAMDFN=$O(^DGPM("AMV1",WARDDT,QAMDFN)) Q:QAMDFN'>0 F IEN=0:0 S IEN=$O(^DGPM("AMV1",WARDDT,QAMDFN,IEN)) Q:IEN'>0 D LOOP1
F WARDDT=START:0 S WARDDT=$O(^DGPM("AMV2",WARDDT)) Q:(WARDDT'>0)!(WARDDT'<END)!(WARDDT\1'?7N) F QAMDFN=0:0 S QAMDFN=$O(^DGPM("AMV2",WARDDT,QAMDFN)) Q:QAMDFN'>0 F IEN=0:0 S IEN=$O(^DGPM("AMV2",WARDDT,QAMDFN,IEN)) Q:IEN'>0 D LOOP1
F QAMDFN=0:0 S QAMDFN=$O(^UTILITY($J,"QAM TEMP",QAMDFN)) Q:QAMDFN'>0 F WARDDT=0:0 S WARDDT=$O(^UTILITY($J,"QAM TEMP",QAMDFN,WARDDT)) Q:WARDDT'>0 D LOOP2
K ^UTILITY($J,"QAM TEMP"),LOS,WARDGRP,X1,X2,X,END,START,WARDDT,IEN
Q
LOOP1 I WARDGRP S WARD=+$S($D(^DGPM(IEN,0))#2:$P(^(0),"^",6),1:0) Q:$O(^QA(743.5,WARDGRP,"GRP","AB",WARD,0))'>0
K ^UTILITY($J,"QAM TEMP",QAMDFN) S ^UTILITY($J,"QAM TEMP",QAMDFN,WARDDT)=IEN
Q
LOOP2 S X=$O(^DGPM("APTT3",QAMDFN,WARDDT)) Q:(X'>QAMTODAY)&X S X=$O(^DGPM("APTT2",QAMDFN,WARDDT)) Q:(X'>QAMTODAY)&X
S ^UTILITY($J,"QAM CONDITION",QAMD1,QAMDFN)="",^UTILITY($J,"QAM CONDITION",QAMD1,QAMDFN,QAMTODAY)=^UTILITY($J,"QAM TEMP",QAMDFN,WARDDT)
Q
EN2 ; *** PARAMETER CODE
K DIR,DIRUT S DIR(0)="NO^1:365:0",DIR("A")="LENGTH OF STAY",DIR("B")=$S($D(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:^("P1"),1:"") K:DIR("B")="" DIR("B")
S DIR("?",1)="Enter the LOS from the date of the patient's transfer onto a ward.",DIR("?")="Enter the ward length of stay from 1-365 days."
S QAMPARAM="P1" D EN3^QAMUTL1 I $D(DIRUT) S Y=-1 G Y
S:Y]"" ^QA(743,QAMD0,"COND",QAMD1,"P1")=Y
2 K DIC,DIR,DIRUT S DIC=743.5,DIC(0)="EMNQZ",DIC("S")="I $P(^(0),""^"",2)=42",DIC("A")="WARD 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 MAS ward locations.",DIR("?")="press 'RETURN' for all ward locations."
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)
EXIT K Y
K QAMPARAM
Y Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HQAMC8 2422 printed Dec 13, 2024@01:42:15 Page 2
QAMC8 ;HISC/DAD-CONDITION: LENGTH OF STAY ON A WARD ;2/10/92 07:33
+1 ;;1.0;Clinical Monitoring System;;09/13/1993
EN1 ; *** CONDITION CODE
+1 SET LOS=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:+^("P1"),1:0)
+2 SET WARDGRP=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P2"))#2:+^("P2"),1:0)
+3 SET X1=QAMTODAY
SET X2=-LOS
DO C^%DTC
SET (X1,START)=X
SET X2=1
DO C^%DTC
SET END=X
SET START=START-.0000001
KILL ^UTILITY($JOB,"QAM TEMP")
+4 FOR WARDDT=START:0
SET WARDDT=$ORDER(^DGPM("AMV1",WARDDT))
if (WARDDT'>0)!(WARDDT'<END)!(WARDDT\1'?7N)
QUIT
FOR QAMDFN=0:0
SET QAMDFN=$ORDER(^DGPM("AMV1",WARDDT,QAMDFN))
if QAMDFN'>0
QUIT
FOR IEN=0:0
SET IEN=$ORDER(^DGPM("AMV1",WARDDT,QAMDFN,IEN))
if IEN'>0
QUIT
DO LOOP1
+5 FOR WARDDT=START:0
SET WARDDT=$ORDER(^DGPM("AMV2",WARDDT))
if (WARDDT'>0)!(WARDDT'<END)!(WARDDT\1'?7N)
QUIT
FOR QAMDFN=0:0
SET QAMDFN=$ORDER(^DGPM("AMV2",WARDDT,QAMDFN))
if QAMDFN'>0
QUIT
FOR IEN=0:0
SET IEN=$ORDER(^DGPM("AMV2",WARDDT,QAMDFN,IEN))
if IEN'>0
QUIT
DO LOOP1
+6 FOR QAMDFN=0:0
SET QAMDFN=$ORDER(^UTILITY($JOB,"QAM TEMP",QAMDFN))
if QAMDFN'>0
QUIT
FOR WARDDT=0:0
SET WARDDT=$ORDER(^UTILITY($JOB,"QAM TEMP",QAMDFN,WARDDT))
if WARDDT'>0
QUIT
DO LOOP2
+7 KILL ^UTILITY($JOB,"QAM TEMP"),LOS,WARDGRP,X1,X2,X,END,START,WARDDT,IEN
+8 QUIT
LOOP1 IF WARDGRP
SET WARD=+$SELECT($DATA(^DGPM(IEN,0))#2:$PIECE(^(0),"^",6),1:0)
if $ORDER(^QA(743.5,WARDGRP,"GRP","AB",WARD,0))'>0
QUIT
+1 KILL ^UTILITY($JOB,"QAM TEMP",QAMDFN)
SET ^UTILITY($JOB,"QAM TEMP",QAMDFN,WARDDT)=IEN
+2 QUIT
LOOP2 SET X=$ORDER(^DGPM("APTT3",QAMDFN,WARDDT))
if (X'>QAMTODAY)&X
QUIT
SET X=$ORDER(^DGPM("APTT2",QAMDFN,WARDDT))
if (X'>QAMTODAY)&X
QUIT
+1 SET ^UTILITY($JOB,"QAM CONDITION",QAMD1,QAMDFN)=""
SET ^UTILITY($JOB,"QAM CONDITION",QAMD1,QAMDFN,QAMTODAY)=^UTILITY($JOB,"QAM TEMP",QAMDFN,WARDDT)
+2 QUIT
EN2 ; *** PARAMETER CODE
+1 KILL DIR,DIRUT
SET DIR(0)="NO^1:365:0"
SET DIR("A")="LENGTH OF STAY"
SET DIR("B")=$SELECT($DATA(^QA(743,QAMD0,"COND",QAMD1,"P1"))#2:^("P1"),1:"")
if DIR("B")=""
KILL DIR("B")
+2 SET DIR("?",1)="Enter the LOS from the date of the patient's transfer onto a ward."
SET DIR("?")="Enter the ward length of stay from 1-365 days."
+3 SET QAMPARAM="P1"
DO EN3^QAMUTL1
IF $DATA(DIRUT)
SET Y=-1
GOTO Y
+4 if Y]""
SET ^QA(743,QAMD0,"COND",QAMD1,"P1")=Y
2 KILL DIC,DIR,DIRUT
SET DIC=743.5
SET DIC(0)="EMNQZ"
SET DIC("S")="I $P(^(0),""^"",2)=42"
SET DIC("A")="WARD 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 MAS ward locations."
SET DIR("?")="press 'RETURN' for all ward locations."
+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)
EXIT KILL Y
+1 KILL QAMPARAM
Y QUIT