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

SDES2VVSJSON.m

Go to the documentation of this file.
SDES2VVSJSON ;ALB/ANU - VISTA SCHEDULING RPC SDES2 GET INFO FOR VIDEO VISIT ; FEB 15,2024@11:25
 ;;5.3;Scheduling;**871**;Aug 13, 1993;Build 13
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ; Documented API's and Integration Agreements
 ; -------------------------------------------
 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
 Q
 ; INPUT
 ;
 ; SDCONTEXT("ACHERON AUDIT ID") = Up to 40 Character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action in the calling application.
 ; SDCONTEXT("USER SECID") = The SECID of the user taking action in the calling application.
 ; SDINPUT("PATIENT IEN") = The DFN/IEN of the target patient from the calling application.
 ; SDINPUT("CLINIC IEN") = The IEN of the target clinic from the calling application.
 ; SDINPUT("APPT DATE TIME") = Appointment Date and Time.
 ;
GETVVSMAKEINFO(JSON,SDCONTEXT,SDINPUT) ;Get info to make a Video Visit Web Service (VVS) call
 N ERRORS,SDRETURN,PARAMETERS,FDA,SDCHECKIN,IEN,ENTRY,SDUSER
 ;
 ; Validate SDCONTEXT
 ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 I $D(ERRORS) S ERRORS("VVSMakeInfo",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ; Validate PARAMS
 S PARAMETERS=$$VALPARAMS(.SDINPUT,.ERRORS)
 I $D(ERRORS) S ERRORS("VVSMakeInfo",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ;
 S SDUSER=$S(+$G(SDCONTEXT("USER DUZ")):+SDCONTEXT("USER DUZ"),1:$G(DUZ))
 S PATIENTIEN=$P(PARAMETERS,"^")
 S CLINICIEN=$P(PARAMETERS,"^",2)
 S APPTDTTM=$P(PARAMETERS,"^",3)
 D GETVVSMAKE(.SDRETURN,PATIENTIEN,CLINICIEN,APPTDTTM)
 I '$D(SDRETURN) S SDRETURN("VVSMakeInfo",1)=""
 D BUILDJSON^SDES2JSON(.JSON,.SDRETURN)
 Q
 ;
VALPARAMS(PARAMS,SDERRORS) ; Validate
 N STATUS,PATIENTIEN,CLINICIEN,APPTDTTM,SDVALID
 ;
 ; Validate Patient IEN
 S PATIENTIEN=$G(PARAMS("PATIENT IEN"))
 D VALFILEIEN^SDES2VALUTIL(.SDVALID,.SDERRORS,2,$G(PATIENTIEN),1,,66,2)
 I $G(SDVALID)'=1 Q 0
 ; Validate Clinic IEN
 S CLINICIEN=$G(PARAMS("CLINIC IEN"))
 D VALFILEIEN^SDES2VALUTIL(.SDVALID,.SDERRORS,44,$G(CLINICIEN),1,,67,19)
 I $G(SDVALID)'=1 Q 0
 ; Validate Appointment date and time 
 S APPTDTTM=$G(PARAMS("APPT DATE TIME"))
 S APPTDTTM=$$VALISODTTM^SDES2VALISODTTM(.SDERRORS,$G(APPTDTTM),$G(CLINICIEN),1,76,77)
 ;
 Q:$D(SDERRORS) 0
 Q PATIENTIEN_"^"_CLINICIEN_"^"_APPTDTTM
 ;
GETVVSMAKE(SDRETURN,PATIENTIEN,CLINICIEN,APPTDTTM) ;GET INFO TO MAKE A VIDEO VISIT WEB SERVICE (VVS) CALL
 ;INPUT:
 ; PATIENTIEN (Patient IEN)
 ; CLINICIEN (Clinic IEN)
 ; APPTDTTM - Appointment date and time external format
 ;
 ;RETURN PARMETER:
 ; Field List:
 ; (1) Patient Info
 ; (2) Default Provider Info
 ; (3) System Info
 ;
 N ERRPOP,ERR,ERRMSG,SDESI,VVSPATIENT,VVSPROVIDER,PROVIDERINFO,VVSSYSTEMINFO,PATINFO
 S SDESI=0
 S SDESI=$G(SDESI,0),ERR=""
 S (VVSPATIENT,VVSPROVIDER,PROVIDERINFO,VVSSYSTEMINFO)=""
 S ERRPOP=0,SDESI=0,ERRMSG=""
 ; Build VVS info
 S SDRETURN("VVSMakeInfo","Appointment","ApptDtTm")=$$FMTISO^SDAMUTDT(APPTDTTM,CLINICIEN)
 S VVSPATIENT=""
 D GETVVSPATIENT(.VVSPATIENT,PATIENTIEN)
 I VVSPATIENT'="" D
 .S SDESI=1
 .S SDRETURN("VVSMakeInfo","Patient","IEN")=$P(VVSPATIENT,"^",1)
 .S SDRETURN("VVSMakeInfo","Patient","DateOfBirth")=$P(VVSPATIENT,"^",2)
 .S SDRETURN("VVSMakeInfo","Patient","FirstName")=$P(VVSPATIENT,"^",3)
 .S SDRETURN("VVSMakeInfo","Patient","LastName")=$P(VVSPATIENT,"^",4)
 .S SDRETURN("VVSMakeInfo","Patient","SSN")=$P(VVSPATIENT,"^",5)
 .S SDRETURN("VVSMakeInfo","Patient","Email")=$P(VVSPATIENT,"^",6)
 .S SDRETURN("VVSMakeInfo","Patient","HomePhone")=$P(VVSPATIENT,"^",7)
 .S SDRETURN("VVSMakeInfo","Patient","CellPhone")=$P(VVSPATIENT,"^",8)
 .S SDRETURN("VVSMakeInfo","Patient","ICN")=$P(VVSPATIENT,"^",9)
 .S SDRETURN("VVSMakeInfo","Patient","ZipCode")=$P(VVSPATIENT,"^",10)
 D GETDPROIEN(.PROVIDERIEN,CLINICIEN)
 D GETPROINFO(.PROVIDERINFO,PROVIDERIEN)
 I PROVIDERINFO'="" D
 .S SDESI=1
 .S SDRETURN("VVSMakeInfo","Provider","IEN")=$P(PROVIDERINFO,"^",1)
 .S SDRETURN("VVSMakeInfo","Provider","Name")=$P(PROVIDERINFO,"^",2)
 .S SDRETURN("VVSMakeInfo","Provider","Email")=$P(PROVIDERINFO,"^",3)
 .S SDRETURN("VVSMakeInfo","Provider","Cell")=$P(PROVIDERINFO,"^",4)
 D GETSYSTEMINFO(.VVSSYSTEMINFO,CLINICIEN)
 I VVSSYSTEMINFO'="" D
 .S SDESI=1
 .S SDRETURN("VVSMakeInfo","SystemInfo","StationID")=$P(VVSSYSTEMINFO,"^",1)
 .S SDRETURN("VVSMakeInfo","SystemInfo","FacilityName")=$P(VVSSYSTEMINFO,"^",2)
 .S SDRETURN("VVSMakeInfo","SystemInfo","TimeZone")=$P(VVSSYSTEMINFO,"^",3)
 .S SDRETURN("VVSMakeInfo","SystemInfo","TimeZoneException")=$P(VVSSYSTEMINFO,"^",4)
 .S SDRETURN("VVSMakeInfo","SystemInfo","Offset")=$P(VVSSYSTEMINFO,"^",5)
 .S SDRETURN("VVSMakeInfo","SystemInfo","OffsetDST")=$P(VVSSYSTEMINFO,"^",6)
 Q
 ;
GETVVSPATIENT(RETURN,PATIENTIEN) ;GET VIDEO VISIT SERVICE (VVS) PATIENT
 Q:PATIENTIEN=""
 N NAME,LASTNAME,FIRSTNAME,DOB,SSN,EMAIL,HOMEPHONE,CELLPHONE,ICN,ZIPCODE
 S NAME=$$GET1^DIQ(2,PATIENTIEN,.01)
 S LASTNAME=$P(NAME,",",1)
 S FIRSTNAME=$P($P(NAME,",",2)," ",1)
 S DOB=$$GET1^DIQ(2,PATIENTIEN,.03)
 S SSN=$$LAST4SSN^SDESINPUTVALUTL(PATIENTIEN) ;SSN
 S EMAIL=$$GET1^DIQ(2,PATIENTIEN,.133)
 S HOMEPHONE=$$GET1^DIQ(2,PATIENTIEN,.131)
 S CELLPHONE=$$GET1^DIQ(2,PATIENTIEN,.134)
 S ICN=$$GETICN^MPIF001(PATIENTIEN)
 S ZIPCODE=$$GET1^DIQ(2,PATIENTIEN,.116)
 S RETURN=PATIENTIEN_"^"_DOB_"^"_FIRSTNAME_"^"_LASTNAME_"^"_SSN_"^"_EMAIL_"^"_HOMEPHONE_"^"_CELLPHONE_"^"_ICN_"^"_ZIPCODE
 Q
 ;
GETDPROIEN(RETURN,CLINICIEN) ;GET THE IEN FOR THE DEFAULT PROVIDER ASSIGNED TO A CLINIC
 Q:CLINICIEN=""
 N SDFIELDS,PROVREC
 S (PROVIDERIEN,PROVREC)="",SDFIELDS="2600*"
 K SDDATA,SDMSG
 D GETS^DIQ(44,CLINICIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
 F  S PROVREC=$O(SDDATA(44.1,PROVREC)) Q:PROVREC=""  D  Q:$G(PROVIDERIEN)
 . I $G(SDDATA(44.1,PROVREC,.02,"E"))="YES" S PROVIDERIEN=$G(SDDATA(44.1,PROVREC,.01,"I"))
 S RETURN=PROVIDERIEN
 Q
 ;
GETPROINFO(RETURN,PROVIDERIEN) ;GET PROVIDER INFO REQUIRED TO MAKE VIDEO VISIT SERVICE (VVS) CALL
 Q:PROVIDERIEN=""
 N NAME,EMAIL,CELL,TITLE,PROVCLASS
 S NAME=$$GET1^DIQ(200,PROVIDERIEN,.01)
 S EMAIL=$$GET1^DIQ(200,PROVIDERIEN,.151)
 S CELL=$$GET1^DIQ(200,PROVIDERIEN,.133)
 S TITLE=$$GET1^DIQ(200,PROVIDERIEN,8,"E")
 S PROVCLASS=$$GET1^DIQ(200,PROVIDERIEN,53.5,"E")
 S RETURN=PROVIDERIEN_"^"_NAME_"^"_EMAIL_"^"_CELL_"^"_TITLE_"^"_PROVCLASS
 S ^TMP(DUZ,"SDECPROIEN")=PROVIDERIEN
 Q
 ;
GETSYSTEMINFO(RETURN,CLINICIEN) ;GET SYSTEM INFO NEED TO CALL MAKE VIDEO VISIT SERVICE (VVS) CALL
 N FACILITYSITECODE,FACILITYNAME,SYSTEMTIMEZONEI,SDDIV,CLINICSITECODE,DFTINSTITUTION,OFFSET,TIMEZONEEXECPT
 N OFFSETDST,SYSTEMTIMEZONEE,TIMEFRAMEIEN,TIMEFRAMEARY,POP,X,EXECPTFLG
 S POP=0,(OFFSET,OFFSETDST,EXECPTFLG)=""
 ;Removed, want site from clinic not user S FACILITYSITECODE=DUZ(2)
 S SDDIV=$$GET1^DIQ(44,CLINICIEN_",",3.5,"I")
 S CLINICSITECODE=$$GET1^DIQ(40.8,SDDIV_",",.07,"I")
 S SYSTEMTIMEZONEE=$$GET1^DIQ(4,CLINICSITECODE,800,"E")
 S SYSTEMTIMEZONEI=$$GET1^DIQ(4,CLINICSITECODE,800,"I")
 S EXECPTFLG=$$GET1^DIQ(4,CLINICSITECODE,802,"I")
 S TIMEZONEEXECPT=$S(EXECPTFLG=0:1,1:0) ;there is a timezone exception if the value = 0
 F X=1:1:3 D  Q:POP
 .S TIMEFRAMEIEN=X_","_SYSTEMTIMEZONEI_","
 .D GETS^DIQ(1.711,TIMEFRAMEIEN,".01;.02","IE","TIMEFRAMEARY","SDMSG") ;Data from WORLD TIMEZONE file
 .I '$D(TIMEFRAMEARY(1.711,TIMEFRAMEIEN,.01)) S POP=1 Q
 .I $G(TIMEFRAMEARY(1.711,TIMEFRAMEIEN,.01,"I"))="SST" S OFFSET=$G(TIMEFRAMEARY(1.711,TIMEFRAMEIEN,.02,"E"))
 .I $G(TIMEFRAMEARY(1.711,TIMEFRAMEIEN,.01,"I"))="DST" S OFFSETDST=$G(TIMEFRAMEARY(1.711,TIMEFRAMEIEN,.02,"E"))
 S DFTINSTITUTION=$$GET1^DIQ(8989.3,1,217,"I")
 S FACILITYNAME=$$GET1^DIQ(4,DFTINSTITUTION,.01)
 S FACILITYSITECODE=$$DEFAULTSTATION^SDECDUZ()
 S RETURN=FACILITYSITECODE_"^"_FACILITYNAME_"^"_SYSTEMTIMEZONEE_"^"_TIMEZONEEXECPT_"^"_OFFSET_"^"_OFFSETDST
 Q
 ;