EDPBST ;SLC/KCM - Staff Configuration ;5/2/12 3:36pm
;;2.0;EMERGENCY DEPARTMENT;**6**;Feb 24, 2012;Build 200
;
MATCH(X) ; Return matching providers
Q
LOAD(AREA) ; Return nurse and provider sources, staff config
N TOKEN,RIEN,RXMLNM,X0,RABBR
D READL^EDPBLK(AREA,"staff",.TOKEN) ; read staff config -- LOCK
D XML^EDPX("<staffToken>"_TOKEN_"</staffToken>")
S RIEN=0 F S RIEN=$O(^EDPB(232.5,RIEN)) Q:'RIEN D
.S X0=$G(^EDPB(232.5,RIEN,0)),RABBR=$P(X0,U,2),RXMLNM=$P(X0,U,7)
.D XML^EDPX("<"_RXMLNM_">"),ACTIVE(AREA,RIEN,RABBR),XML^EDPX("</"_RXMLNM_">")
;D XML^EDPX("<providers>"),ACTIVE(AREA,"P"),XML^EDPX("</providers>")
;D XML^EDPX("<residents>"),ACTIVE(AREA,"R"),XML^EDPX("</residents>")
;D XML^EDPX("<nurses>"),ACTIVE(AREA,"N"),XML^EDPX("</nurses>")
D READU^EDPBLK(AREA,"staff",.TOKEN) ; read staff config -- UNLOCK
Q
ACTIVE(AREA,ROLE,ABBR) ; build list of active for a role
N IEN,X0,X,EDPNURS
I ABBR="N" S EDPNURS=$$GET^XPAR("ALL","EDPF NURSE STAFF SCREEN")
S IEN=0 F S IEN=$O(^EDPB(231.7,"AC",EDPSITE,AREA,ROLE,IEN)) Q:'IEN D
. S X0=^EDPB(231.7,IEN,0)
. I '$$ALLOW^EDPFPER(+X0,ABBR) Q
. ;I '$$ALLOW^EDPFPER(+X0,ROLE) Q
. S X("duz")=$P(X0,U)
. S X("nm")=$P(^VA(200,X("duz"),0),U)
. S X("role")=$P(X0,U,6) I $G(X("role")) S X("role")=$$GET1^DIQ(232.5,X("role"),.02,"E")
. S X("itl")=$P(^VA(200,X("duz"),0),U,2)
. S X("clr")=$P(X0,U,8)
. D XML^EDPX($$XMLA^EDPX("staff",.X))
Q
SAVE(REQ) ; save updated staff members
N X,STAFF,ERR,EDPAREA,TOKEN,LOCKERR
S EDPAREA=$G(REQ("area",1))
I EDPAREA="" D SAVERR^EDPX("fail","Missing Area") Q
;
S TOKEN=$G(REQ("staffToken",1))
D SAVEL^EDPBLK(EDPAREA,"staff",.TOKEN,.LOCKERR) ; save staff config -- LOCK
I $L(LOCKERR) D SAVERR^EDPX("collide",LOCKERR),LOAD(EDPAREA) Q
;
S X="staff-",ERR=""
F S X=$O(REQ(X)) Q:$E(X,1,6)'="staff-" D
. K STAFF S STAFF=""
. D NVPARSE^EDPX(.STAFF,REQ(X,1))
. I STAFF("chg") D UPD(.STAFF,.ERR)
D SAVEU^EDPBLK(EDPAREA,"staff",.TOKEN) ; save staff config -- UNLOCK
;
I $L(ERR) D SAVERR^EDPX("fail",ERR) Q
D XML^EDPX("<save status='ok' />")
D LOAD(EDPAREA)
S ^EDPB(231.9,EDPAREA,231)=$H ; update choices timestamp
Q
UPD(FLD,ERRMSG) ; Add/Update Record (expects EDPAREA, EDPSITE to be defined)
N EDPIEN
S EDPIEN=$O(^EDPB(231.7,"AD",EDPSITE,EDPAREA,+FLD("duz"),0))_","
I 'EDPIEN,FLD("inact") Q ; don't add inactive selection
I 'EDPIEN S EDPIEN="+1,"
;
N FDA,FDAIEN,DIERR,ERR
S FDA(231.7,EDPIEN,.01)=FLD("duz")
S FDA(231.7,EDPIEN,.02)=EDPSITE
S FDA(231.7,EDPIEN,.03)=EDPAREA
S FDA(231.7,EDPIEN,.04)=FLD("inact")
S FDA(231.7,EDPIEN,.06)=$S(FLD("role")="":"",1:$O(^EDPB(232.5,"C",FLD("role"),"")))
;S FDA(231.7,EDPIEN,.07)=FLD("itl") --NtoL
S FDA(231.7,EDPIEN,.08)=FLD("clr")
I EDPIEN="+1," D
. D UPDATE^DIE("","FDA","FDAIEN","ERR")
. I $D(DIERR) S ERRMSG=ERRMSG_"Adding "_FLD("name")_" failed. "
E D
. D FILE^DIE("","FDA","ERR")
. I $D(DIERR) S ERRMSG=ERRMSG_"Updating "_FLD("name")_" failed. "
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPBST 3014 printed Nov 22, 2024@17:01:48 Page 2
EDPBST ;SLC/KCM - Staff Configuration ;5/2/12 3:36pm
+1 ;;2.0;EMERGENCY DEPARTMENT;**6**;Feb 24, 2012;Build 200
+2 ;
MATCH(X) ; Return matching providers
+1 QUIT
LOAD(AREA) ; Return nurse and provider sources, staff config
+1 NEW TOKEN,RIEN,RXMLNM,X0,RABBR
+2 ; read staff config -- LOCK
DO READL^EDPBLK(AREA,"staff",.TOKEN)
+3 DO XML^EDPX("<staffToken>"_TOKEN_"</staffToken>")
+4 SET RIEN=0
FOR
SET RIEN=$ORDER(^EDPB(232.5,RIEN))
if 'RIEN
QUIT
Begin DoDot:1
+5 SET X0=$GET(^EDPB(232.5,RIEN,0))
SET RABBR=$PIECE(X0,U,2)
SET RXMLNM=$PIECE(X0,U,7)
+6 DO XML^EDPX("<"_RXMLNM_">")
DO ACTIVE(AREA,RIEN,RABBR)
DO XML^EDPX("</"_RXMLNM_">")
End DoDot:1
+7 ;D XML^EDPX("<providers>"),ACTIVE(AREA,"P"),XML^EDPX("</providers>")
+8 ;D XML^EDPX("<residents>"),ACTIVE(AREA,"R"),XML^EDPX("</residents>")
+9 ;D XML^EDPX("<nurses>"),ACTIVE(AREA,"N"),XML^EDPX("</nurses>")
+10 ; read staff config -- UNLOCK
DO READU^EDPBLK(AREA,"staff",.TOKEN)
+11 QUIT
ACTIVE(AREA,ROLE,ABBR) ; build list of active for a role
+1 NEW IEN,X0,X,EDPNURS
+2 IF ABBR="N"
SET EDPNURS=$$GET^XPAR("ALL","EDPF NURSE STAFF SCREEN")
+3 SET IEN=0
FOR
SET IEN=$ORDER(^EDPB(231.7,"AC",EDPSITE,AREA,ROLE,IEN))
if 'IEN
QUIT
Begin DoDot:1
+4 SET X0=^EDPB(231.7,IEN,0)
+5 IF '$$ALLOW^EDPFPER(+X0,ABBR)
QUIT
+6 ;I '$$ALLOW^EDPFPER(+X0,ROLE) Q
+7 SET X("duz")=$PIECE(X0,U)
+8 SET X("nm")=$PIECE(^VA(200,X("duz"),0),U)
+9 SET X("role")=$PIECE(X0,U,6)
IF $GET(X("role"))
SET X("role")=$$GET1^DIQ(232.5,X("role"),.02,"E")
+10 SET X("itl")=$PIECE(^VA(200,X("duz"),0),U,2)
+11 SET X("clr")=$PIECE(X0,U,8)
+12 DO XML^EDPX($$XMLA^EDPX("staff",.X))
End DoDot:1
+13 QUIT
SAVE(REQ) ; save updated staff members
+1 NEW X,STAFF,ERR,EDPAREA,TOKEN,LOCKERR
+2 SET EDPAREA=$GET(REQ("area",1))
+3 IF EDPAREA=""
DO SAVERR^EDPX("fail","Missing Area")
QUIT
+4 ;
+5 SET TOKEN=$GET(REQ("staffToken",1))
+6 ; save staff config -- LOCK
DO SAVEL^EDPBLK(EDPAREA,"staff",.TOKEN,.LOCKERR)
+7 IF $LENGTH(LOCKERR)
DO SAVERR^EDPX("collide",LOCKERR)
DO LOAD(EDPAREA)
QUIT
+8 ;
+9 SET X="staff-"
SET ERR=""
+10 FOR
SET X=$ORDER(REQ(X))
if $EXTRACT(X,1,6)'="staff-"
QUIT
Begin DoDot:1
+11 KILL STAFF
SET STAFF=""
+12 DO NVPARSE^EDPX(.STAFF,REQ(X,1))
+13 IF STAFF("chg")
DO UPD(.STAFF,.ERR)
End DoDot:1
+14 ; save staff config -- UNLOCK
DO SAVEU^EDPBLK(EDPAREA,"staff",.TOKEN)
+15 ;
+16 IF $LENGTH(ERR)
DO SAVERR^EDPX("fail",ERR)
QUIT
+17 DO XML^EDPX("<save status='ok' />")
+18 DO LOAD(EDPAREA)
+19 ; update choices timestamp
SET ^EDPB(231.9,EDPAREA,231)=$HOROLOG
+20 QUIT
UPD(FLD,ERRMSG) ; Add/Update Record (expects EDPAREA, EDPSITE to be defined)
+1 NEW EDPIEN
+2 SET EDPIEN=$ORDER(^EDPB(231.7,"AD",EDPSITE,EDPAREA,+FLD("duz"),0))_","
+3 ; don't add inactive selection
IF 'EDPIEN
IF FLD("inact")
QUIT
+4 IF 'EDPIEN
SET EDPIEN="+1,"
+5 ;
+6 NEW FDA,FDAIEN,DIERR,ERR
+7 SET FDA(231.7,EDPIEN,.01)=FLD("duz")
+8 SET FDA(231.7,EDPIEN,.02)=EDPSITE
+9 SET FDA(231.7,EDPIEN,.03)=EDPAREA
+10 SET FDA(231.7,EDPIEN,.04)=FLD("inact")
+11 SET FDA(231.7,EDPIEN,.06)=$SELECT(FLD("role")="":"",1:$ORDER(^EDPB(232.5,"C",FLD("role"),"")))
+12 ;S FDA(231.7,EDPIEN,.07)=FLD("itl") --NtoL
+13 SET FDA(231.7,EDPIEN,.08)=FLD("clr")
+14 IF EDPIEN="+1,"
Begin DoDot:1
+15 DO UPDATE^DIE("","FDA","FDAIEN","ERR")
+16 IF $DATA(DIERR)
SET ERRMSG=ERRMSG_"Adding "_FLD("name")_" failed. "
End DoDot:1
+17 IF '$TEST
Begin DoDot:1
+18 DO FILE^DIE("","FDA","ERR")
+19 IF $DATA(DIERR)
SET ERRMSG=ERRMSG_"Updating "_FLD("name")_" failed. "
End DoDot:1
+20 QUIT