VistA-WorldVistAEHR/r/ENGINEERING-EN/ENEQPMS2.m

141 lines
5.4 KiB
Mathematica

ENEQPMS2 ;(WASH ISC)/DH-Select Equipment for PMI ;6.5.97
;;7.0;ENGINEERING;**26,35,42**;Aug 17, 1993
NTRY ; Identify entries for specified PM worklist (single shop)
; List is sorted in ^TMP($J,
K ^TMP($J) N I,SE,NODE
F DA=0:0 S DA=$O(^ENG(6914,"AB",ENSHKEY,DA)) Q:DA'>0 S SE=0 F S SE=$O(^ENG(6914,"AB",ENSHKEY,DA,SE)) Q:SE'>0 D LST2
D PR^ENEQPMS5 G OUT
;
MNTRY ; Identify entries for specified PM worklist (all shops)
; List is sorted in ^TMP($J,
K ^TMP($J) N I,SE,NODE
F ENSHKEY=0:0 S ENSHKEY=$O(^ENG(6914,"AB",ENSHKEY)) Q:ENSHKEY'>0 F DA=0:0 S DA=$O(^ENG(6914,"AB",ENSHKEY,DA)) Q:DA'>0 S SE=0 F S SE=$O(^ENG(6914,"AB",ENSHKEY,DA,SE)) Q:SE'>0 D LST2
D PR^ENEQPMS5 G OUT
;
LST2 N EN,A,B,C,X,X1,X2,TAG,SUB,MULT
S X1=$P($G(^ENG(6914,DA,3)),U) I "^4^5^"[(U_X1_U) Q
I 'ENSRT("OOS"),X1=2 Q
Q:'$D(^ENG(6914,DA,4,SE,0)) I '$D(ENCRIT("ALL")) D Q:ENCRIT<0
. S ENCRIT=$P(^ENG(6914,DA,4,SE,0),U,4) I ENCRIT'?1.2N S:'$G(ENCRIT("NULL")) ENCRIT=-1 Q
. I ENCRIT<ENCRIT("FR")!(ENCRIT>ENCRIT("TO")) S ENCRIT=-1
S EN("NEXT")="A" F X="A","B","C" S @X=""
S X1=0,X2=$P(^ENG(6914,DA,4,SE,0),U,2) I 'ENTECH("ALL"),X2'=ENTECH Q
I ENTECH'=0 S:X2="" X2=0 S:$D(^ENG("EMP",X2,0)) X1=""""_$P(^(0),U)_"""" D
. I X2>0,X1=0 S X1=""""_"DELETED"_""""
. S @EN("NEXT")=X1
. S EN("NEXT")=$C($A(EN("NEXT"))+1)
S TAG="LST"_ENSRT D @TAG Q:$G(X)=-1
S SUB="" F X1="A","B","C" Q:$G(@X1)="" S SUB=SUB_@X1_","
D LSTSKP
Q
;
LSTE ; By ENTRY NUMBER
I ENSRT("ALL") Q
I ENSRT("FR")]DA!(DA]ENSRT("TO")) S X=-1
Q
LSTP ; By PM NUMBER
S X1=$P($G(^ENG(6914,DA,3)),U,6) S:X1="" X1=0
S:X1'=0 X1=""""_X1_""""
S @EN("NEXT")=X1
Q
LSTI ; By LOCAL ID
S (X1,X1("T"))=$P($G(^ENG(6914,DA,3)),U,7) S:X1="" (X1,X1("T"))=0
S:X1'?.N X1("T")=""""_X1_""""
I ENSRT("ALL") S @EN("NEXT")=X1("T"),EN("NEXT")=$C($A(EN("NEXT"))+1)
E S X="" D
. I ENSRT("FR")]X1!(X1]ENSRT("TO")) S X=-1 Q
. S @EN("NEXT")=X1("T"),EN("NEXT")=$C($A(EN("NEXT"))+1)
I ENSRT("LOC"),$G(X)'=-1 D
. S X1=$$LOC^ENEQPMS8(DA) I X1=-1 S X=-1 Q
. I $P(X1,U)=-2,ENSRT("LOC","ALL") D
.. S X1=""""_$P(X1,U,2)_""""
.. F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
. I $P(X1,U)=-2 S X=-1 Q
. I X1=-3,ENSRT("LOC","ALL") D
.. S X1=0 F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
. I X1=-3 S X=-1 Q
. S @EN("NEXT")=X1
Q
LSTL ; By LOCATION
S X1=$$LOC^ENEQPMS8(DA) I X1=-1 S X=-1 Q
I $P(X1,U)=-2,ENSRT("LOC","ALL") D
. S X1=""""_$P(X1,U,2)_""""
. F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
I $P(X1,U)=-2 S X=-1 Q
I X1=-3,ENSRT("LOC","ALL") D
. S X1=0 F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
I X1=-3 S X=-1 Q
S @EN("NEXT")=X1
Q
LSTC ; By EQUIPMENT CATEGORY
S X2=$P($G(^ENG(6914,DA,1)),U) S:X2="" X1=0
I X2>0 S X1=$P($G(^ENG(6911,X2,0)),U) S:X1="" X1=0
S:X1'?.N X1=""""_X1_""""
I 'ENSRT("ALL"),X2'=ENSRT("FR") S X=-1 Q
S @EN("NEXT")=X1,EN("NEXT")=$C($A(EN("NEXT"))+1)
I ENSRT("LOC") D
. S X1=$$LOC^ENEQPMS8(DA) I X1=-1 S X=-1 Q
. I $P(X1,U)=-2,ENSRT("LOC","ALL") D
.. S X1=""""_$P(X1,U,2)_""""
.. F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
. I $P(X1,U)=-2 S X=-1 Q
. I X1=-3,ENSRT("LOC","ALL") D
.. S X1=0 F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
. I X1=-3 S X=-1 Q
. S @EN("NEXT")=X1
Q
LSTS ; By OWNING SERVICE
S X2=$P($G(^ENG(6914,DA,3)),U,2) S:X2="" X1=0
I X2>0 S X1=$P($G(^DIC(49,X2,0)),U) S:X1="" X1=0
S:X1'?.N X1=""""_X1_""""
I 'ENSRT("ALL"),X2'=ENSRT("FR") S X=-1 Q
S @EN("NEXT")=X1,EN("NEXT")=$C($A(EN("NEXT"))+1)
I ENSRT("LOC") D
. S X1=$$LOC^ENEQPMS8(DA) I X1=-1 S X=-1 Q
. I $P(X1,U)=-2,ENSRT("LOC","ALL") D
.. S X1=""""_$P(X1,U,2)_""""
.. F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
. I $P(X1,U)=-2 S X=-1 Q
. I X1=-3,ENSRT("LOC","ALL") D
.. S X1=0 F J=1:1:($L(ENSRT("BY"))-1) S X1="0,"_X1
. I X1=-3 S X=-1 Q
. S @EN("NEXT")=X1
Q
;
LSTSKP ; Check for SKIP MONTHS
S ENSKP=$P(^ENG(6914,DA,4,SE,0),U,3) G:ENSKP']"" LST21 S ENMNTH=$P(ENSKP,"-",1) D RVMNTH^ENLIB1 S ENSKP("FR")=ENMN,ENMNTH=$P(ENSKP,"-",2) D RVMNTH^ENLIB1 S ENSKP("TO")=ENMN
I ENSKP("FR")'>ENSKP("TO") G:ENPMMN<ENSKP("FR")!(ENPMMN>ENSKP("TO")) LST21 K ENSKP Q
I ENPMMN'>ENSKP("TO")!(ENPMMN'<ENSKP("FR")) K ENSKP Q
LST21 ; SKIP MONTH not a problem
K ENSKP S ENHZS="^",ENSTMN=1 I $D(^ENG(6914,DA,4,SE,1)),^(1)>1 S ENSTMN=^(1)
S MULT=0 F S MULT=$O(^ENG(6914,DA,4,SE,2,MULT)) Q:MULT'>0 I $P(^ENG(6914,DA,4,SE,2,MULT,0),U)]"" S ENHZS=ENHZS_$P(^(0),U)_"^",ENHZ($P(^(0),U))=SE_U_MULT
I ENPM["W" D LSTW Q
I ENHZS["^TA^" D Q:$G(ENHZ)="TA"
. S MULT=$P(ENHZ("TA"),U,2),ENSTYR=$P(^ENG(6914,DA,4,SE,2,MULT,0),U,6) Q:ENSTYR'?4N
. I ENSTYR>ENPMYR Q
. I '(ENPMYR-ENSTYR#3),(ENPMMN=ENSTMN) S ENHZ="TA",ENHZ(1)="TRI-ANNUAL" D BLD
I ENHZS["^BA^" D Q:$G(ENHZ)="BA"
. S MULT=$P(ENHZ("BA"),U,2),ENSTYR=$P(^ENG(6914,DA,4,SE,2,MULT,0),U,6) Q:ENSTYR'?4N
. I ENSTYR>ENPMYR Q
. I '(ENPMYR-ENSTYR#2),(ENPMMN=ENSTMN) S ENHZ="BA",ENHZ(1)="BI-ANNUAL" D BLD
I ENHZS["^A^",ENSTMN=ENPMMN S ENHZ="A",ENHZ(1)="ANNUAL" D BLD Q
I ENHZS["^S^",'(ENPMMN-ENSTMN#6) S ENHZ="S",ENHZ(1)="SEMI-ANNUAL" D BLD Q
I ENHZS["^Q^",'(ENPMMN-ENSTMN#3) S ENHZ="Q",ENHZ(1)="QUARTERLY" D BLD Q
I ENHZS["^BM^",'(ENPMMN-ENSTMN#2) S ENHZ="BM",ENHZ(1)="BI-MONTHLY" D BLD Q
I ENHZS["^M^" S ENHZ="M",ENHZ(1)="MONTHLY" D BLD
Q
;
LSTW I ENHZS["BW",(ENPM["1"!(ENPM["3")) S ENHZ="BW",ENHZ(1)="BI-WEEKLY" D BLD Q
I ENHZS["^W^" S ENHZ="W",ENHZ(1)="WEEKLY" D BLD
Q
;
BLD ; Build ^TMP GLOBAL
S NODE="^TMP($J,""ENWL"","_ENSHKEY_","_SUB_DA_")"
S @NODE=ENHZ_U_ENHZ(1)_U_ENHZ(ENHZ)
Q
;
OUT K K,S,ENDATE,ENPM,ENPMDT,ENA,ENHZS,ENPMWK,ENSHOP,ENSHKEY,ENPMMN,ENSTMN,ENSTYR,ENCRIT,ENSRT,ENTECH,ENY,ENERR,ENMN,ENMNTH,ENI,ENLID
S:$D(ZTQUEUED) ZTREQ="@"
Q
;ENEQPMS2