RGTKPOC ;BIRMIO/CML-Establish Visitor Record for TK POC ;25-NOV-14
 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**62**;30 Apr 99;Build 3
 ;
 ;Reference to ^XWB2HL7 supported by IA #3144
 ;Reference to ^XWBDRPC supported by IA #3149
 ;Reference to GET^XUESSO1 supported by IA #4342
 ;
 ; This routine was created new for I13 (MVI_CR4999) DG*5.3*62 (cml and cmc).
 ; It is called by a new option "ToolKit POC User Setup" [RG TK POC USER SETUP]
 ; that calls a new RPC (MPI TK POC USER SETUP) that accesses the MPI to establish a Visitor Record in the New Person file (#200).
 ; Just calling the RPC will establish the Visitor record if one didn't exist.  It will then update the ToolKit user with the
 ; DUZ from the MPI, SSN and NT username.
 ;
 ; The RPC will identify any missing required fields in the New Person file and instruct the user to check their setup in the New Person
 ; file to be sure they have Name, SSN ,Network Username and phone contact number.
 ; - If a problem is detected they will need to use the Edit an Existing User option on the User Management menu or contact IRM if needed.
 ; - If they have all the required fields the user will get a message back that all is good  
 ;
 W @IOF
 W !!,"This option allows you to create a Visitor Record in the New Person file on"
 W !,"the MPI production account.  The purpose of this action is to accomplish the"
 W !,"first step toward establishing your ToolKit POC remote view access. Once this"
 W !,"action is completed successfully you will have the ability to use the new tools."
 W !!,"Note: It is important that prior to using this option you be set up correctly"
 W !,"as a user in your local New Person file (#200).  You should verify your user"
 W !,"record has the correct Name, SSN, Network Username and Phone Contact Number."
 ;
 W !!,"Attempting to establish Visitor Record on MPI..."
 N SITE,IEN,USER,NAME,NTNAME,PHONE,SSN,USR
 S SITE="200M"
 K RETURN
 S USR=$$GET^XUESSO1(DUZ) ;USER=ssn^name^station name^station number^DUZ^phone^vpid^NETWORK USERNAME
 I +USR=-1 W !!,"<Missing data> - ",$P(USR,"^",2),!,"Please populate this data via the User Management menu." G QUIT
 I $P(USR,"^",8)="" W !!,"<Missing Network Username> - please populate this field via the User Management",!,"menu as it is required for mapping your VistA account to your ToolKit account." G QUIT
 S NAME=$P(USR,"^",2),SSN=$P(USR,"^"),NTNAME=$P(USR,"^",8),PHONE=$P(USR,"^",6)
 D EN1^XWB2HL7(.RETURN,SITE,"MPI TK POC USER SETUP",1,NAME_"~"_SSN_"~"_NTNAME_"~"_PHONE)
 I RETURN(0)="" W !!,"Attempt was unsuccessful: "_$P(RETURN(1),"^",2) G QUIT
 ;Else RPC successful, RETURN(0) has IEN for other calls.
 S IEN=RETURN(0)
 ; Retrieve data
 N CNT
 F CNT=1:1:10 D RPCCHK^XWB2HL7(.RET,IEN) Q:+RET(0)=1  Q:+RET(0)=-1  H 2
 I +RET(0)=-1 W !!,"Attempt was unsuccessful: "_$S($P(RET(0),"^",2)["Handle":"Error in Process",1:$P(RET(0),"^",2)) G QUIT
 I +RET(0)'=1 W !!,"Attempt was unsuccessful, unable to get data after 10 attempts." G QUIT
 ;
 ; Get results
 K RET D RTNDATA^XWBDRPC(.RET,IEN)
 I +RET(0)=1 W !!,"Your Visitor Record was successfully established, ",!,"and your ToolKit user profile updated."
 I +RET(0)'=1 W !!,"There was an issue with your record ",RET(0),!,"Please report this to HC IdM for assistance."
 ;
QUIT ;
 W !! S DIR(0)="E" D ^DIR K DIR
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGTKPOC   3349     printed  Sep 23, 2025@19:19:04                                                                                                                                                                                                     Page 2
RGTKPOC   ;BIRMIO/CML-Establish Visitor Record for TK POC ;25-NOV-14
 +1       ;;1.0;CLINICAL INFO RESOURCE NETWORK;**62**;30 Apr 99;Build 3
 +2       ;
 +3       ;Reference to ^XWB2HL7 supported by IA #3144
 +4       ;Reference to ^XWBDRPC supported by IA #3149
 +5       ;Reference to GET^XUESSO1 supported by IA #4342
 +6       ;
 +7       ; This routine was created new for I13 (MVI_CR4999) DG*5.3*62 (cml and cmc).
 +8       ; It is called by a new option "ToolKit POC User Setup" [RG TK POC USER SETUP]
 +9       ; that calls a new RPC (MPI TK POC USER SETUP) that accesses the MPI to establish a Visitor Record in the New Person file (#200).
 +10      ; Just calling the RPC will establish the Visitor record if one didn't exist.  It will then update the ToolKit user with the
 +11      ; DUZ from the MPI, SSN and NT username.
 +12      ;
 +13      ; The RPC will identify any missing required fields in the New Person file and instruct the user to check their setup in the New Person
 +14      ; file to be sure they have Name, SSN ,Network Username and phone contact number.
 +15      ; - If a problem is detected they will need to use the Edit an Existing User option on the User Management menu or contact IRM if needed.
 +16      ; - If they have all the required fields the user will get a message back that all is good  
 +17      ;
 +18       WRITE @IOF
 +19       WRITE !!,"This option allows you to create a Visitor Record in the New Person file on"
 +20       WRITE !,"the MPI production account.  The purpose of this action is to accomplish the"
 +21       WRITE !,"first step toward establishing your ToolKit POC remote view access. Once this"
 +22       WRITE !,"action is completed successfully you will have the ability to use the new tools."
 +23       WRITE !!,"Note: It is important that prior to using this option you be set up correctly"
 +24       WRITE !,"as a user in your local New Person file (#200).  You should verify your user"
 +25       WRITE !,"record has the correct Name, SSN, Network Username and Phone Contact Number."
 +26      ;
 +27       WRITE !!,"Attempting to establish Visitor Record on MPI..."
 +28       NEW SITE,IEN,USER,NAME,NTNAME,PHONE,SSN,USR
 +29       SET SITE="200M"
 +30       KILL RETURN
 +31      ;USER=ssn^name^station name^station number^DUZ^phone^vpid^NETWORK USERNAME
           SET USR=$$GET^XUESSO1(DUZ)
 +32       IF +USR=-1
               WRITE !!,"<Missing data> - ",$PIECE(USR,"^",2),!,"Please populate this data via the User Management menu."
               GOTO QUIT
 +33       IF $PIECE(USR,"^",8)=""
               WRITE !!,"<Missing Network Username> - please populate this field via the User Management",!,"menu as it is required for mapping your VistA account to your ToolKit account."
               GOTO QUIT
 +34       SET NAME=$PIECE(USR,"^",2)
           SET SSN=$PIECE(USR,"^")
           SET NTNAME=$PIECE(USR,"^",8)
           SET PHONE=$PIECE(USR,"^",6)
 +35       DO EN1^XWB2HL7(.RETURN,SITE,"MPI TK POC USER SETUP",1,NAME_"~"_SSN_"~"_NTNAME_"~"_PHONE)
 +36       IF RETURN(0)=""
               WRITE !!,"Attempt was unsuccessful: "_$PIECE(RETURN(1),"^",2)
               GOTO QUIT
 +37      ;Else RPC successful, RETURN(0) has IEN for other calls.
 +38       SET IEN=RETURN(0)
 +39      ; Retrieve data
 +40       NEW CNT
 +41       FOR CNT=1:1:10
               DO RPCCHK^XWB2HL7(.RET,IEN)
               if +RET(0)=1
                   QUIT 
               if +RET(0)=-1
                   QUIT 
               HANG 2
 +42       IF +RET(0)=-1
               WRITE !!,"Attempt was unsuccessful: "_$SELECT($PIECE(RET(0),"^",2)["Handle":"Error in Process",1:$PIECE(RET(0),"^",2))
               GOTO QUIT
 +43       IF +RET(0)'=1
               WRITE !!,"Attempt was unsuccessful, unable to get data after 10 attempts."
               GOTO QUIT
 +44      ;
 +45      ; Get results
 +46       KILL RET
           DO RTNDATA^XWBDRPC(.RET,IEN)
 +47       IF +RET(0)=1
               WRITE !!,"Your Visitor Record was successfully established, ",!,"and your ToolKit user profile updated."
 +48       IF +RET(0)'=1
               WRITE !!,"There was an issue with your record ",RET(0),!,"Please report this to HC IdM for assistance."
 +49      ;
QUIT      ;
 +1        WRITE !!
           SET DIR(0)="E"
           DO ^DIR
           KILL DIR
 +2        QUIT