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

SDESGETUD.m

Go to the documentation of this file.
SDESGETUD ;ALB/ANU,LAB,MGD - VISTA SCHEDULING RPCS GET USER KEYS AND OPTIONS ; July 19, 2022@020:41
 ;;5.3;Scheduling;**801,805,809,814,819,820**;Aug 13, 1993;Build 10
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ;External References
 ;-------------------
 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
 ; Reference to ^%DT in ICR #10003
 ; Reference to $$FIND1^DIC in ICR #2051
 ; Reference to NEW PERSON in ICR #10060
 ;
 ; Global References Supported
 ; ----------------- ----------------- ----------
 ; ^TMP($J SACC 2.3.2.5.1
 Q
 ;
GETUSRDTL(SDUSRJSON,SDSECID,SDEAS) ;Called from RPC: SDES GET USER PROFILE
 ; This RPC gets User name, Keys and Scheduling Options for a given User.
 ; Input:
 ; SDCLNJSON - [required] - Successs or Error message
 ; SDSECID  - [required] - The SECID from the NEW PERSON File #200
 ; SDEAS - [optional] - Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
 ;
 N SDUSRSREC,SDUSRIEN,SDDIV,SDDIVIENC,HASSDERRORS
 D VALIDATESECID(.HASSDERRORS,SDSECID)
 D VALIDATEEAS(.HASSDERRORS,.SDEAS)
 I $D(HASSDERRORS) D
 . M SDUSRSREC=HASSDERRORS
 I '$D(HASSDERRORS) D
 . D GETUSRINFO(.SDUSRSREC,SDUSRIEN)
 D BUILDJSON^SDESBUILDJSON(.SDUSRJSON,.SDUSRSREC)
 Q
 ;
GETUSRDTLDUZ(SDUSRJSON,SDUSRIEN,SDEAS) ;Called from RPC: SDES GET USER  BY DUZ
 N SDUSRSREC,HASSDERRORS
 D VALIDATEUSRIEN(.HASSDERRORS,SDUSRIEN)
 D VALIDATEEAS(.HASSDERRORS,.SDEAS)
 I $D(HASSDERRORS) M SDUSRSREC=HASSDERRORS
 I '$D(HASSDERRORS) D
 . D GETUSRINFO(.SDUSRSREC,SDUSRIEN)
 D BUILDJSON^SDESBUILDJSON(.SDUSRJSON,.SDUSRSREC)
 Q
 ;
VALIDATESECID(HASSDERRORS,SDSECID) ;
 I $G(SDSECID)="" D ERRLOG^SDESJSON(.HASSDERRORS,130)  Q
 I '$D(HASSDERRORS) D
 . D GETUSRIEN(.HASSDERRORS,SDSECID,.SDUSRIEN)
 . I '$D(HASSDERRORS) D
 . . D VALIDATEUSRIEN(.HASSDERRORS,SDUSRIEN)
 Q
 ;
VALIDATEEAS(HASSDERRORS,SDEAS) ;
 S SDEAS=$G(SDEAS,"")
 I $L(SDEAS) S SDEAS=$$EASVALIDATE^SDESUTIL(SDEAS)
 I SDEAS=-1 D ERRLOG^SDESJSON(.HASSDERRORS,142)
 Q
 ;
GETUSRIEN(HASSDERRORS,SDSECID,SDUSRIEN) ;
 N SCERR
 S SDUSRIEN=$$FIND1^DIC(200,,"X",SDSECID,"ASECID",,"SCERR")
 I $D(SCERR) D ERRLOG^SDESJSON(.HASSDERRORS,156)
 Q
 ;
VALIDATEUSRIEN(HASSDERRORS,SDUSRIEN) ;
 I SDUSRIEN="" D ERRLOG^SDESJSON(.HASSDERRORS,127) Q
 I '$D(^VA(200,SDUSRIEN,0)) D ERRLOG^SDESJSON(.HASSDERRORS,44) Q
 Q
 ;
GETUSRINFO(SDUSRSREC,SDUSRIEN) ; Get User Keys and Scheduling Options
 N SDFIELDS,SDDATA,SDMSG,SDX,SDC,SDOPT,SDKEY,SDDIV,SDDIVIEN,SDSTN,SDDEF
 S SDFIELDS=".01;201;203*;51*;16*"
 D GETS^DIQ(200,SDUSRIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
 S SDUSRSREC("User","Name")=$G(SDDATA(200,SDUSRIEN_",",.01,"E")) ;User Name
 S SDUSRSREC("User","IEN")=SDUSRIEN
 S SDUSRSREC("User","Station ID")=$$DEFAULTSTATION^SDECDUZ()
 S SDOPT=$G(SDDATA(200,SDUSRIEN_",",201,"E"))
 S SDUSRSREC("User","Primary Menu Option")=SDOPT ;Primary Menu Option
 ; Secondary Options Multiple
 S SDX="",SDC=0
 F  S SDX=$O(SDDATA(200.03,SDX)) Q:SDX=""  D
 . S SDOPT=$G(SDDATA(200.03,SDX,.01,"E"))
 . S SDC=SDC+1 S SDUSRSREC("User","Secondary Menu",SDC,"Option")=SDOPT
 ; Security Keys Multiple
 S SDX="",SDC=0
 F  S SDX=$O(SDDATA(200.051,SDX)) Q:SDX=""  D
 . S SDKEY=$G(SDDATA(200.051,SDX,.01,"E"))
 . S SDC=SDC+1 S SDUSRSREC("User","Security Key",SDC,"Name")=SDKEY
 ; Divisions Multiple
 S (SDX,SDSTN,SDDEF)="",SDC=0
 F  S SDX=$O(SDDATA(200.02,SDX)) Q:SDX=""  D
 . S SDDIVIEN=$G(SDDATA(200.02,SDX,.01,"I"))
 . S SDSTN=$$GET1^DIQ(4,SDDIVIEN,99,"I")
 . S SDDIV=$G(SDDATA(200.02,SDX,.01,"E"))
 . S SDDEF=$G(SDDATA(200.02,SDX,1,"I"))
 . S SDDEF=$S(SDDEF=1:"YES",1:"")
 . S SDC=SDC+1
 . S SDUSRSREC("User","Division",SDC,"Name")=SDDIV
 . S SDUSRSREC("User","Division",SDC,"IEN")=SDDIVIEN
 . S SDUSRSREC("User","Division",SDC,"Division")=SDSTN
 . S SDUSRSREC("User","Division",SDC,"Default")=SDDEF
 I SDC=0 D
 . I $G(DUZ(2))'="" D
 . . S SDC=SDC+1
 . . S SDUSRSREC("User","Division",SDC,"Division")=$G(DUZ(2))
 . . S SDUSRSREC("User","Division",SDC,"IEN")=$G(DUZ(2))
 . . S SDUSRSREC("User","Division",SDC,"Name")=$$GET1^DIQ(4,$G(DUZ(2)),.01,"E")
 . . S SDUSRSREC("User","Division",SDC,"Default")=""
 I '$D(SDUSRSREC("User")) S SDUSRSREC("User",1)=""
 Q