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

ORWTPT.m

Go to the documentation of this file.
ORWTPT ; SLC/STAFF Personal Preference - Teams ;05/27/14  18:31
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**85,243,377**;Oct 24, 2000;Build 582
 ;
 ; External Reference
 ;   DBIA 1917  $$TPTM^SCAPMC
 ;   DBIA 1917  $$PRTP^SCAPMC
 ;
GETTEAM(USERS,TEAM) ; RPC
 ; returns members of a team
 N CNT,NAME,NUM,USER K USERS
 S TEAM=+$G(TEAM),CNT=0
 S NUM=0 F  S NUM=$O(^OR(100.21,TEAM,1,NUM)) Q:NUM<1  S USER=+$G(^(NUM,0)) D
 .S NAME=$P($G(^VA(200,USER,0)),U)
 .I '$L(NAME) Q
 .S CNT=CNT+1
 .S USERS(CNT)=USER_U_NAME
 Q
 ;
GETPTEAM(MEMBERS,TEAM) ; RPC
 ; TDP - Added 5/21/2014
 ; returns members of a team\
 ; (Should be using $$PRTM^SCAPMC to return team members for a
 ;  specific team. However, it does not work correctly. So, we
 ;  improvised a work around solution.)
 N CNT,DATA,NAME,NUM,ORRSLT,POSIEN,SUB,USER
 K MEMBERS,^TMP("ORPCMMPOS",$J),^TMP("SCERR",$J)
 S TEAM=+$G(TEAM)
 ; Get list of team positions for specified team
 S ORRSLT=$$TPTM^SCAPMC(TEAM,,,,"^TMP(""ORPCMMPOS"",$J)",)
 I '$D(^TMP("ORPCMMPOS",$J)) Q
 S CNT=0
 S NUM=0
 F  S NUM=$O(^TMP("ORPCMMPOS",$J,NUM)) Q:NUM<1  D
 . K ^TMP("ORPCMMBRS",$J),^TMP("SCERR",$J)
 . S POSIEN=+$G(^TMP("ORPCMMPOS",$J,NUM))
 . ; Get list of team members occupying team positions
 . S ORRSLT=$$PRTP^SCAPMC(POSIEN,,"^TMP(""ORPCMMBRS"",$J)",,0,0)
 . I ORRSLT=0 Q
 . S SUB=0
 . F  S SUB=$O(^TMP("ORPCMMBRS",$J,SUB)) Q:SUB<1  D
 .. S DATA=$P(^TMP("ORPCMMBRS",$J,SUB),U,1,2)
 .. I $P(DATA,U,2)="" Q  ;No name, so quit
 .. S CNT=CNT+1
 .. S MEMBERS(CNT)=DATA
 K ^TMP("ORPCMMBRS",$J),^TMP("ORPCMMPOS",$J),^TMP("SCERR",$J)
 Q
 ;
TEAMS(TEAMS,USER) ; from ORWTPP
 ; returns all teams a user is a member of (exculdes personal lists)
 N CNT,NUM,ZERO K TEAMS
 S USER=+$G(USER),CNT=0
 S NUM=0 F  S NUM=$O(^OR(100.21,"C",USER,NUM)) Q:NUM<1  D
 .S ZERO=$G(^OR(100.21,NUM,0))
 .I $P(ZERO,U,2)="P" Q
 .S CNT=CNT+1
 .S TEAMS(CNT)=NUM_U_ZERO
 Q
 ;
PLISTS(TEAMS,USER) ; from ORWTPP
 ; returns a user's personal lists
 N CNT,NUM,ZERO K TEAMS
 S USER=+$G(USER),CNT=0
 S NUM=0 F  S NUM=$O(^OR(100.21,"C",USER,NUM)) Q:NUM<1  D
 .S ZERO=$G(^OR(100.21,NUM,0))
 .I $P(ZERO,U,2)'="P" Q
 .S CNT=CNT+1
 .N VIS S VIS=$P($G(^OR(100.21,NUM,11)),U)
 .I '$L(VIS) S VIS=1
 .S TEAMS(CNT)=NUM_U_ZERO_U_VIS
 Q
 ;
PLTEAMS(TEAMS,USER) ; from ORWTPP
 ; returns all teams and personal lists for a user
 N CNT,NUM,ZERO K TEAMS
 S USER=+$G(USER),CNT=0
 S NUM=0 F  S NUM=$O(^OR(100.21,"C",USER,NUM)) Q:NUM<1  D
 .S ZERO=$G(^OR(100.21,NUM,0))
 .S CNT=CNT+1
 .S TEAMS(CNT)=NUM_U_ZERO
 Q
 ;
PCMTEAMS(TEAMS,USER) ; from ORWTPP
 ; TDP - Added 5/21/2014
 ; returns all PCMM teams for a user
 N CNT,DATA,NUM,UNAME K TEAMS
 S USER=+$G(USER),CNT=0
 D PTEAMPR^ORQPTQ1(.TEAMS,USER)
 I TEAMS(1)="^No PCMM teams found." Q
 S NUM=0 F  S NUM=$O(TEAMS(NUM)) Q:NUM=""  D
 . S DATA=$P(TEAMS(NUM),U,1,2)
 . S UNAME=$$UP^XLFSTR($P(DATA,U,2))
 . S TEAMS(NUM)=DATA_"^E^"_UNAME_"^^^^"
 Q
 ;
ATEAMS(TEAMS) ; RPC
 ; all teams available to subscribe to
 N CNT,NAME,NODE,NUM K TEAMS
 S CNT=0
 S NUM=0 F  S NUM=$O(^OR(100.21,NUM)) Q:NUM<1  S NODE=$G(^(NUM,0)) D
 .I $P(NODE,U,6)'="Y" Q
 .I $P(NODE,U,2)="P" Q
 .S CNT=CNT+1
 .S TEAMS(CNT)=NUM_U_NODE ;$P(NODE,U)
 Q
 ;
ADDLIST(OK,VALUE,USER) ; from ORWTPP
 ; adds a user to a team
 N DA,DIC,DLAYGO,X,Y K DA,DIC,DLAYGO
 S USER=+$G(USER)
 S DA=USER,DA(1)=+$G(VALUE),OK=1
 I '$D(^OR(100.21,DA(1),0)) Q
 S DIC(0)="LM"
 S DLAYGO=100.212
 S X=$P($G(^VA(200,USER,0)),U)
 S DIC="^OR(100.21,"_DA(1)_",1,"
 D
 .L +^OR(100.21,DA(1)):5 I '$T Q
 .D ^DIC
 .L -^OR(100.21,DA(1))
 I Y=-1 S OK=0
 K DA,DIC,DLAYGO
 Q
 ;
REMLIST(OK,VALUE,USER) ; from ORWTPP
 ; removes a user from a team
 N DA,DIK K DA
 S DA=+$G(USER),DA(1)=+$G(VALUE),OK=1
 I '$D(^OR(100.21,DA(1),0)) Q
 S DIK="^OR(100.21,"_DA(1)_",1,"
 D
 .L +^OR(100.21,DA(1)):5 I '$T S OK=0 Q
 .D ^DIK
 .L -^OR(100.21,DA(1))
 K DA,DIK
 Q
 ;
GETCOMBO(VALUES,USER) ; from ORWTPP
 ; get user's combo list definition
 N CNT,IEN,NAME,NODE,NUM,SOURCE K VALUES
 S USER=+$G(USER)
 I '$D(^OR(100.24,USER,0)) Q
 S CNT=0
 S NUM=0 F  S NUM=$O(^OR(100.24,USER,.01,NUM)) Q:NUM<1  S NODE=$G(^(NUM,0)) D
 .I '$L(NODE) Q
 .S IEN=+NODE,SOURCE=$P(NODE,";",2),NAME=""
 .D
 ..I SOURCE="DIC(42," S SOURCE="WARD",NAME=$P($G(^DIC(42,IEN,0)),U) Q
 ..I SOURCE="VA(200," S SOURCE="PROVIDER",NAME=$P($G(^VA(200,IEN,0)),U) Q
 ..I SOURCE="DIC(45.7," S SOURCE="SPECIALTY",NAME=$P($G(^DIC(45.7,IEN,0)),U) Q
 ..I SOURCE="OR(100.21," S SOURCE="LIST",NAME=$P($G(^OR(100.21,IEN,0)),U) Q
 ..I SOURCE="SC(" S SOURCE="CLINIC",NAME=$P($G(^SC(IEN,0)),U) Q
 ..I SOURCE="SCTM(404.51," D
 ...S SOURCE="PCMM"
 ...N DIC,DLAYGO,X,Y
 ...S DIC="^SCTM(404.51,"
 ...S DIC(0)=""
 ...S X="`"_IEN
 ...D ^DIC
 ...S NAME=$P(Y,U,2)
 .I '$L(NAME) Q
 .S CNT=CNT+1
 .S VALUES(CNT)=SOURCE_U_NAME_U_IEN
 Q
 ;
SETCOMBO(OK,VALUES,USER) ; from ORWTPP
 ; set user's combo list definition
 N CNT,DA,DIK,IEN,NUM,NVALUES,SOURCE,SOURCENM K NVALUES
 S USER=+$G(USER),OK=1
 I 'USER Q
 S NUM=0 F  S NUM=$O(VALUES(NUM)) Q:NUM<1  D
 .S IEN=+VALUES(NUM),SOURCENM=$$UP^XLFSTR($P(VALUES(NUM),U,2)),SOURCE=""
 .I 'IEN Q
 .I SOURCENM="WARD" S SOURCE=";DIC(42,"
 .I SOURCENM="PROVIDER" S SOURCE=";VA(200,"
 .I SOURCENM="SPECIALTY" S SOURCE=";DIC(45.7,"
 .I SOURCENM="LIST" S SOURCE=";OR(100.21,"
 .I SOURCENM="PCMM" S SOURCE=";SCTM(404.51,"
 .I SOURCENM="CLINIC" S SOURCE=";SC("
 .I '$L(SOURCE) Q
 .S NVALUES(NUM)=IEN_SOURCE
 I '$D(^OR(100.24,USER,0)) D  I '$D(^OR(100.24,USER,0)) Q
 .L +^OR(100.24,0):5 I '$T S OK=0 Q
 .S ^OR(100.24,USER,0)=USER
 .S $P(^OR(100.24,0),U,4)=$P(^OR(100.24,0),U,4)+1,$P(^(0),U,3)=USER
 .L -^OR(100.24,0)
 S CNT=0,DA=USER,DIK="^OR(100.24,"
 L +^OR(100.24,USER,0):5 I '$T Q
 K ^OR(100.24,USER,.01)
 S NUM=0 F  S NUM=$O(NVALUES(NUM)) Q:NUM<1  D
 .S CNT=CNT+1
 .S ^OR(100.24,USER,.01,CNT,0)=NVALUES(NUM)
 S ^OR(100.24,USER,.01,0)="^100.241V^"_CNT_U_CNT
 D IX1^DIK
 L -^OR(100.24,USER,0)
 K NVALUES
 Q