ENEQPMS8 ;(WIRMFO)/DH-Sort PM Worklist by LOCATION ;4.21.97
;;7.0;ENGINEERING;**26,35**;Aug 17, 1993
;
; Programs calling this routine without having defined loc var
; ENSRT("LOC","ALL") should expect it to exist upon return and
; kill it before terminating job.
;
; In processing ranges, values will be treated as numbers if all
; values are numbers, otherwise all values will be treated as strings
;
LOC(DA) ; DA => IEN for Equipment File (6914)
; Expects ENSRT array as prepared via routine ENEQPMS1
; Called by ENEQPMS2
;
N SPC
S SPC=$P($G(^ENG(6914,DA,3)),U,5) I SPC="" S X=-3 Q X
I $E(SPC)="*" S X=-2_U_$P(SPC,",") Q X ;Not a pointer
I '$D(^ENG("SP",SPC,0)) S X=-2_U_$P(SPC,",") Q X ;Not a pointer either
D MAIN
Q X
;
SPACE(SPC) ; SPC => IEN for Space File (6928)
; Expects ENSRT array as prepared via routine ENWOST
; Called by ENWOP3
;
I SPC="" S X=-3 Q X ;Shouldn't happen
I $E(SPC)="*" S X=-2_U_SPC Q X ;Not a pointer
I '$D(^ENG("SP",SPC,0)) S X=-2_U_$P(SPC,",") Q X ;Still not a pointer
D MAIN
Q X
;
; X returned
; returned as less than 0 if entry is to be excluded, otherwise
; piece 1 => DIVISION
; piece 2 => BUILDING or WING, as specified
; piece 3 => WING or BUILDING, as specified
; piece 4 => ROOM
;
MAIN N A,I,J,D,B,W,R
S (D,B,W,R)=0,X=""
S:$G(ENSRT("LOC","ALL"))="" ENSRT("LOC","ALL")=1 I ENSRT("LOC","ALL")=1 D
. S:'$D(ENSRT("BY")) ENSRT("BY")="DBWR"
. F I="DIV","BLDG","WING","ROOM" S:ENSRT("BY")[$E(I) ENSRT(I,"ALL")=""
F A="D","B","W","R" D @A Q:@A=-1 I @A'="N/A" S:@A="" @A=0 S:@A'?.N @A=""""_@A_"""" S X=X_@A_","
I @A<0 S X=-1 Q
S X=$E(X,1,$L(X)-1) ;Strip trailing coma
Q ;Design EXIT
;
D ; Check DIVISION
I ENSRT("BY")'["D" S D="N/A" Q
S D=$P(^ENG("SP",SPC,0),U,10)
I $D(ENSRT("DIV","ALL")) S:D?.N D=D_" " Q
I D="",$D(ENSRT("DIV","AIND","NULL")) Q
I D]"",$D(ENSRT("DIV","AIND",D)) S:D?.N D=D_" " Q
S J=0 F S J=$O(ENSRT("DIV","FR",J)) Q:'J!($D(D(0))) D
. I ENSRT("DIV","FR",J)?.N,ENSRT("DIV","TO",J)?.N,D?.N D Q
.. I ENSRT("DIV","FR",J)>D!(D>ENSRT("DIV","TO",J)) Q
.. S D(0)="",D=D_" "
. S:ENSRT("DIV","FR",J)?.N ENSRT("DIV","FR",J)=ENSRT("DIV","FR",J)_" "
. S:ENSRT("DIV","TO",J)?.N ENSRT("DIV","TO",J)=ENSRT("DIV","TO",J)_" "
. S:D?.N D=D_" "
. I ENSRT("DIV","FR",J)]D!(D]ENSRT("DIV","TO",J)) Q
. S D(0)=""
I '$D(D(0)) S D=-1
Q
;
B ; Check BUILDING
I ENSRT("BY")'["B" S B="N/A" Q
S B=$P(^ENG("SP",SPC,0),U,2)
I $D(ENSRT("BLDG","ALL")) S:B?.N B=B_" " Q
I B="",$D(ENSRT("BLDG","AIND","NULL")) Q
I B]"",$D(ENSRT("BLDG","AIND",B)) S:B?.N B=B_" " Q
S J=0 F S J=$O(ENSRT("BLDG","FR",J)) Q:'J!($D(B(0))) D
. I ENSRT("BLDG","FR",J)?.N,ENSRT("BLDG","TO",J)?.N,B?.N D Q
.. I ENSRT("BLDG","FR",J)>B!(B>ENSRT("BLDG","TO",J)) Q
.. S B(0)="",B=B_" "
. S:ENSRT("BLDG","FR",J)?.N ENSRT("BLDG","FR",J)=ENSRT("BLDG","FR",J)_" "
. S:ENSRT("BLDG","TO",J)?.N ENSRT("BLDG","TO",J)=ENSRT("BLDG","TO",J)_" "
. S:B?.N B=B_" "
. I ENSRT("BLDG","FR",J)]B!(B]ENSRT("BLDG","TO",J)) Q
. S B(0)=""
I '$D(B(0)) S B=-1
Q
;
W ; Check WING
I ENSRT("BY")'["W" S W="N/A" Q
S W=$P(^ENG("SP",SPC,0),U,3)
I $D(ENSRT("WING","ALL")) S:W?.N W=W_" " Q
I W="",$D(ENSRT("WING","AIND","NULL")) Q
I W]"",$D(ENSRT("WING","AIND",W)) S:W?.N W=W_" " Q
S J=0 F S J=$O(ENSRT("WING","FR",J)) Q:'J!($D(W(0))) D
. I ENSRT("WING","FR",J)?.N,ENSRT("WING","TO",J)?.N,W?.N D Q
.. I ENSRT("WING","FR",J)>W!(W>ENSRT("WING","TO",J)) Q
.. S W(0)="",W=W_" "
. S:ENSRT("WING","FR",J)?.N ENSRT("WING","FR",J)=ENSRT("WING","FR",J)_" "
. S:ENSRT("WING","TO",J)?.N ENSRT("WING","TO",J)=ENSRT("WING","TO",J)_" "
. S:W?.N W=W_" "
. I ENSRT("WING","FR",J)]W!(W]ENSRT("WING","TO",J)) Q
. S W(0)=""
I '$D(W(0)) S W=-1
Q
;
R ; Check ROOM
I ENSRT("BY")'["R" S R="N/A" Q
S R=$P($P(^ENG("SP",SPC,0),U),"-")
I $D(ENSRT("ROOM","ALL")) S:R?.N R=R_" " Q
I $D(ENSRT("ROOM","AIND",R)) S:R?.N R=R_" " Q
S J=0 F S J=$O(ENSRT("ROOM","FR",J)) Q:'J!($D(R(0))) D
. I ENSRT("ROOM","FR",J)?.N,ENSRT("ROOM","TO",J)?.N,R?.N D Q
.. I ENSRT("ROOM","FR",J)>R!(R>ENSRT("ROOM","TO",J)) Q
.. S R(0)="",R=R_" "
. S:ENSRT("ROOM","FR",J)?.N ENSRT("ROOM","FR",J)=ENSRT("ROOM","FR",J)_" "
. S:ENSRT("ROOM","TO",J)?.N ENSRT("ROOM","TO",J)=ENSRT("ROOM","TO",J)_" "
. S:R?.N R=R_" "
. I ENSRT("ROOM","FR",J)]R!(R]ENSRT("ROOM","TO",J)) Q
. S R(0)=""
I '$D(R(0)) S R=-1
Q
;ENEQPMS8
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HENEQPMS8 4489 printed Oct 16, 2024@17:53:49 Page 2
ENEQPMS8 ;(WIRMFO)/DH-Sort PM Worklist by LOCATION ;4.21.97
+1 ;;7.0;ENGINEERING;**26,35**;Aug 17, 1993
+2 ;
+3 ; Programs calling this routine without having defined loc var
+4 ; ENSRT("LOC","ALL") should expect it to exist upon return and
+5 ; kill it before terminating job.
+6 ;
+7 ; In processing ranges, values will be treated as numbers if all
+8 ; values are numbers, otherwise all values will be treated as strings
+9 ;
LOC(DA) ; DA => IEN for Equipment File (6914)
+1 ; Expects ENSRT array as prepared via routine ENEQPMS1
+2 ; Called by ENEQPMS2
+3 ;
+4 NEW SPC
+5 SET SPC=$PIECE($GET(^ENG(6914,DA,3)),U,5)
IF SPC=""
SET X=-3
QUIT X
+6 ;Not a pointer
IF $EXTRACT(SPC)="*"
SET X=-2_U_$PIECE(SPC,",")
QUIT X
+7 ;Not a pointer either
IF '$DATA(^ENG("SP",SPC,0))
SET X=-2_U_$PIECE(SPC,",")
QUIT X
+8 DO MAIN
+9 QUIT X
+10 ;
SPACE(SPC) ; SPC => IEN for Space File (6928)
+1 ; Expects ENSRT array as prepared via routine ENWOST
+2 ; Called by ENWOP3
+3 ;
+4 ;Shouldn't happen
IF SPC=""
SET X=-3
QUIT X
+5 ;Not a pointer
IF $EXTRACT(SPC)="*"
SET X=-2_U_SPC
QUIT X
+6 ;Still not a pointer
IF '$DATA(^ENG("SP",SPC,0))
SET X=-2_U_$PIECE(SPC,",")
QUIT X
+7 DO MAIN
+8 QUIT X
+9 ;
+10 ; X returned
+11 ; returned as less than 0 if entry is to be excluded, otherwise
+12 ; piece 1 => DIVISION
+13 ; piece 2 => BUILDING or WING, as specified
+14 ; piece 3 => WING or BUILDING, as specified
+15 ; piece 4 => ROOM
+16 ;
MAIN NEW A,I,J,D,B,W,R
+1 SET (D,B,W,R)=0
SET X=""
+2 if $GET(ENSRT("LOC","ALL"))=""
SET ENSRT("LOC","ALL")=1
IF ENSRT("LOC","ALL")=1
Begin DoDot:1
+3 if '$DATA(ENSRT("BY"))
SET ENSRT("BY")="DBWR"
+4 FOR I="DIV","BLDG","WING","ROOM"
if ENSRT("BY")[$EXTRACT(I)
SET ENSRT(I,"ALL")=""
End DoDot:1
+5 FOR A="D","B","W","R"
DO @A
if @A=-1
QUIT
IF @A'="N/A"
if @A=""
SET @A=0
if @A'?.N
SET @A=""""_@A_""""
SET X=X_@A_","
+6 IF @A<0
SET X=-1
QUIT
+7 ;Strip trailing coma
SET X=$EXTRACT(X,1,$LENGTH(X)-1)
+8 ;Design EXIT
QUIT
+9 ;
D ; Check DIVISION
+1 IF ENSRT("BY")'["D"
SET D="N/A"
QUIT
+2 SET D=$PIECE(^ENG("SP",SPC,0),U,10)
+3 IF $DATA(ENSRT("DIV","ALL"))
if D?.N
SET D=D_" "
QUIT
+4 IF D=""
IF $DATA(ENSRT("DIV","AIND","NULL"))
QUIT
+5 IF D]""
IF $DATA(ENSRT("DIV","AIND",D))
if D?.N
SET D=D_" "
QUIT
+6 SET J=0
FOR
SET J=$ORDER(ENSRT("DIV","FR",J))
if 'J!($DATA(D(0)))
QUIT
Begin DoDot:1
+7 IF ENSRT("DIV","FR",J)?.N
IF ENSRT("DIV","TO",J)?.N
IF D?.N
Begin DoDot:2
+8 IF ENSRT("DIV","FR",J)>D!(D>ENSRT("DIV","TO",J))
QUIT
+9 SET D(0)=""
SET D=D_" "
End DoDot:2
QUIT
+10 if ENSRT("DIV","FR",J)?.N
SET ENSRT("DIV","FR",J)=ENSRT("DIV","FR",J)_" "
+11 if ENSRT("DIV","TO",J)?.N
SET ENSRT("DIV","TO",J)=ENSRT("DIV","TO",J)_" "
+12 if D?.N
SET D=D_" "
+13 IF ENSRT("DIV","FR",J)]D!(D]ENSRT("DIV","TO",J))
QUIT
+14 SET D(0)=""
End DoDot:1
+15 IF '$DATA(D(0))
SET D=-1
+16 QUIT
+17 ;
B ; Check BUILDING
+1 IF ENSRT("BY")'["B"
SET B="N/A"
QUIT
+2 SET B=$PIECE(^ENG("SP",SPC,0),U,2)
+3 IF $DATA(ENSRT("BLDG","ALL"))
if B?.N
SET B=B_" "
QUIT
+4 IF B=""
IF $DATA(ENSRT("BLDG","AIND","NULL"))
QUIT
+5 IF B]""
IF $DATA(ENSRT("BLDG","AIND",B))
if B?.N
SET B=B_" "
QUIT
+6 SET J=0
FOR
SET J=$ORDER(ENSRT("BLDG","FR",J))
if 'J!($DATA(B(0)))
QUIT
Begin DoDot:1
+7 IF ENSRT("BLDG","FR",J)?.N
IF ENSRT("BLDG","TO",J)?.N
IF B?.N
Begin DoDot:2
+8 IF ENSRT("BLDG","FR",J)>B!(B>ENSRT("BLDG","TO",J))
QUIT
+9 SET B(0)=""
SET B=B_" "
End DoDot:2
QUIT
+10 if ENSRT("BLDG","FR",J)?.N
SET ENSRT("BLDG","FR",J)=ENSRT("BLDG","FR",J)_" "
+11 if ENSRT("BLDG","TO",J)?.N
SET ENSRT("BLDG","TO",J)=ENSRT("BLDG","TO",J)_" "
+12 if B?.N
SET B=B_" "
+13 IF ENSRT("BLDG","FR",J)]B!(B]ENSRT("BLDG","TO",J))
QUIT
+14 SET B(0)=""
End DoDot:1
+15 IF '$DATA(B(0))
SET B=-1
+16 QUIT
+17 ;
W ; Check WING
+1 IF ENSRT("BY")'["W"
SET W="N/A"
QUIT
+2 SET W=$PIECE(^ENG("SP",SPC,0),U,3)
+3 IF $DATA(ENSRT("WING","ALL"))
if W?.N
SET W=W_" "
QUIT
+4 IF W=""
IF $DATA(ENSRT("WING","AIND","NULL"))
QUIT
+5 IF W]""
IF $DATA(ENSRT("WING","AIND",W))
if W?.N
SET W=W_" "
QUIT
+6 SET J=0
FOR
SET J=$ORDER(ENSRT("WING","FR",J))
if 'J!($DATA(W(0)))
QUIT
Begin DoDot:1
+7 IF ENSRT("WING","FR",J)?.N
IF ENSRT("WING","TO",J)?.N
IF W?.N
Begin DoDot:2
+8 IF ENSRT("WING","FR",J)>W!(W>ENSRT("WING","TO",J))
QUIT
+9 SET W(0)=""
SET W=W_" "
End DoDot:2
QUIT
+10 if ENSRT("WING","FR",J)?.N
SET ENSRT("WING","FR",J)=ENSRT("WING","FR",J)_" "
+11 if ENSRT("WING","TO",J)?.N
SET ENSRT("WING","TO",J)=ENSRT("WING","TO",J)_" "
+12 if W?.N
SET W=W_" "
+13 IF ENSRT("WING","FR",J)]W!(W]ENSRT("WING","TO",J))
QUIT
+14 SET W(0)=""
End DoDot:1
+15 IF '$DATA(W(0))
SET W=-1
+16 QUIT
+17 ;
R ; Check ROOM
+1 IF ENSRT("BY")'["R"
SET R="N/A"
QUIT
+2 SET R=$PIECE($PIECE(^ENG("SP",SPC,0),U),"-")
+3 IF $DATA(ENSRT("ROOM","ALL"))
if R?.N
SET R=R_" "
QUIT
+4 IF $DATA(ENSRT("ROOM","AIND",R))
if R?.N
SET R=R_" "
QUIT
+5 SET J=0
FOR
SET J=$ORDER(ENSRT("ROOM","FR",J))
if 'J!($DATA(R(0)))
QUIT
Begin DoDot:1
+6 IF ENSRT("ROOM","FR",J)?.N
IF ENSRT("ROOM","TO",J)?.N
IF R?.N
Begin DoDot:2
+7 IF ENSRT("ROOM","FR",J)>R!(R>ENSRT("ROOM","TO",J))
QUIT
+8 SET R(0)=""
SET R=R_" "
End DoDot:2
QUIT
+9 if ENSRT("ROOM","FR",J)?.N
SET ENSRT("ROOM","FR",J)=ENSRT("ROOM","FR",J)_" "
+10 if ENSRT("ROOM","TO",J)?.N
SET ENSRT("ROOM","TO",J)=ENSRT("ROOM","TO",J)_" "
+11 if R?.N
SET R=R_" "
+12 IF ENSRT("ROOM","FR",J)]R!(R]ENSRT("ROOM","TO",J))
QUIT
+13 SET R(0)=""
End DoDot:1
+14 IF '$DATA(R(0))
SET R=-1
+15 QUIT
+16 ;ENEQPMS8