SDESGETCONSULTS ;ALB/BLB,MGD,RRM,BWF,CGP,BLB,ANU,LAB,BLB - VISTA SCHEDULING RPCS GET CONSULTS ;DEC 01,2023
;;5.3;Scheduling;**815,820,824,837,842,847,857,867,875,877,886**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified
;
;External References
;-------------------
; Reference to ^VA(200 in ICR #10060 ;
; Reference to $$GETS^DIQ,$$GET1^DIQ in ICR #2056
;
;
; ----------------- ----------------- ----------
;
;
; for an example of the return object, see SDESGETREQWRAPPR due to its length.
;
Q
;
GETCONSULTSBYDFN(JSONRETURN,DFN,EAS) ; SDES GET CONSULTS BY DFN
N ISDFNVALID,RETURN,REQUEST,CPRSSTATUS,IFCROLE,CONSULTIEN,ERRORS
;
S ISDFNVALID=$$VALIDATEDFN(.ERRORS,$G(DFN))
S ISEASVALID=$$VALIDATEEAS(.ERRORS,$G(EAS))
I $D(ERRORS) S ERRORS("Request",1)="" M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
;
S CONSULTIEN=0
F S CONSULTIEN=$O(^GMR(123,"F",DFN,CONSULTIEN)) Q:'CONSULTIEN D
.S CPRSSTATUS=$$GET1^DIQ(123,CONSULTIEN,8,"E"),IFCROLE=$$GET1^DIQ(123,CONSULTIEN,.125,"E")
.I CPRSSTATUS'="PENDING",CPRSSTATUS'="ACTIVE" Q
.I IFCROLE="PLACER" Q
.D GETCONSULT(.REQUEST,CONSULTIEN)
I '$D(REQUEST) S REQUEST("Request",1)=""
M RETURN=REQUEST
;
D BUILDJSON(.JSONRETURN,.RETURN)
Q
;
GETCONSULTBYIEN(JSONRETURN,CONSULTIEN,EAS) ; SDES GET CONSULTS BY IEN
N ISCONSIENVALID,ISEASVALID,RETURN,ERRORS,REQUEST
;
S ISCONSIENVALID=$$VALIDATECONIEN(.ERRORS,$G(CONSULTIEN))
S ISEASVALID=$$VALIDATEEAS(.ERRORS,$G(EAS))
I $D(ERRORS) S ERRORS("Request",1)="" M RETURN=ERRORS
;
I '$D(ERRORS) D
.D GETCONSULT(.REQUEST,CONSULTIEN)
I '$D(REQUEST) S REQUEST("Request",1)=""
M RETURN=REQUEST
;
D BUILDJSON(.JSONRETURN,.RETURN)
Q
;
VALIDATEDFN(ERRORS,DFN) ;
I DFN="" D ERRLOG^SDESJSON(.ERRORS,1) Q 0
I DFN'="",'$D(^DPT(DFN,0)) D ERRLOG^SDESJSON(.ERRORS,2) Q 0
Q 1
;
VALIDATECONIEN(ERRORS,CONSULTIEN) ;
I CONSULTIEN="" D ERRLOG^SDESJSON(.ERRORS,5) Q 0
I CONSULTIEN'="",('$D(^GMR(123,CONSULTIEN)))!(CONSULTIEN=0) D ERRLOG^SDESJSON(.ERRORS,6) Q 0
Q 1
;
VALIDATEEAS(ERRORS,EAS) ;
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL($G(EAS))
I $P($G(EAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142) Q 0
Q 1
;
COVIDPRIORITYCHK(CONSULTIEN) ; pass back the latest entry in the comment multiple containging "covid-19 priority"
N SUBIEN,SUBIEN2,FOUND,COVIDCOMMENT
S SUBIEN=999999999,FOUND=0,COVIDCOMMENT=""
F S SUBIEN=$O(^GMR(123,CONSULTIEN,40,SUBIEN),-1) Q:'SUBIEN!(FOUND=1) D
.S SUBIEN2=0
.F S SUBIEN2=$O(^GMR(123,CONSULTIEN,40,SUBIEN,1,SUBIEN2)) Q:'SUBIEN2 D
..S COVIDCOMMENT=$$GET1^DIQ(123.25,SUBIEN2_","_SUBIEN_","_CONSULTIEN_",",.01)
..I COVIDCOMMENT["COVID-19 Priority" D
...S COVIDCOMMENT=$P(COVIDCOMMENT,"-COVID-19 Priority",1)
...S FOUND=1 Q
Q COVIDCOMMENT
;857
GETSTOPCODES(REQUEST,SERVICEIEN,NUM) ;
N SUBIEN,COUNT,STOPCODE
S COUNT=0,SUBIEN=0
F S SUBIEN=$O(^GMR(123.5,SERVICEIEN,688,SUBIEN)) Q:'SUBIEN D
.S COUNT=COUNT+1
.S STOPCODE=$$GET1^DIQ(123.5688,SUBIEN_","_SERVICEIEN_",",.01,"I")
.S REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"StopCode")=STOPCODE
.S REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"StopCodeName")=$$GET1^DIQ(40.7,STOPCODE,.01,"E")
.S REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"AmisStopCode")=$$GET1^DIQ(40.7,STOPCODE,1,"I")
.S REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"RestrictionType")=$$GET1^DIQ(40.7,STOPCODE,5,"I")
Q
;
GETPID(CONSULTIEN) ;
N CHIEN,CHSIEN,OLDESTPID
S CHIEN=$O(^SDEC(409.87,"B",CONSULTIEN,0))
S CHSIEN=$O(^SDEC(409.87,CHIEN,1,9999999),-1)
S OLDESTPID=$$GET1^DIQ(409.871,CHSIEN_","_CHIEN_",",1,"I")
Q OLDESTPID
;
CONSCANCELCHECK(CONSULTIEN,DFN) ;looking for most recent appt linked to this consult and checking if cancelled by patient or clinic
N FOUND,APPTIEN,CANCHANGE
S APPTIEN="",FOUND=0,CANCHANGE=0
F S APPTIEN=$O(^SDEC(409.84,"CPAT",DFN,APPTIEN),-1) Q:'APPTIEN!(FOUND=1) D
.I $P($$GET1^DIQ(409.84,APPTIEN,.22,"I"),";")=CONSULTIEN S FOUND=1 D
..I $$GET1^DIQ(409.84,APPTIEN,.17,"I")="PC" S CANCHANGE=1
..I $$GET1^DIQ(409.84,APPTIEN,.1,"I")=1 S CANCHANGE=1
Q CANCHANGE
;857
GETCONSULT(REQUEST,CONSULTIEN) ;Build a consult record for every consult
N CLINICIEN,CLINICNAME,SERVICEIEN,CONDATA,CONSERR,CANCHANGEPID,PID,NUM,ERRORS,PROVIDERIEN
D GETS^DIQ(123,CONSULTIEN,"**","IE","CONDATA","CONSERR")
S NUM="",NUM=$O(REQUEST("Request",NUM),-1)+1
S REQUEST("Request",NUM,"Type")="Consult"
;
;I $D(^SDEC(409.86,"SRP",CONSULTIEN)) D
;I $$GETCONTIEN^SDESCONTACTS(.ERRORS,CONSULTIEN,"C") D
D BUILDSDECONTACT^SDESGETAPPTREQ(.REQUEST,CONSULTIEN,NUM,"C")
;
S SERVICEIEN=$G(CONDATA(123,CONSULTIEN_",",1,"I"))
I $G(SERVICEIEN) D
.D GETSTOPCODES(.REQUEST,SERVICEIEN,NUM)
I '$G(SERVICEIEN) D
.S REQUEST("Request",NUM,"ConsultAssociatedStopCodes",1)=""
;
S CLINICIEN=$G(CONDATA(123,CONSULTIEN_",",2,"I"))
S CLINICNAME=$G(CONDATA(123,CONSULTIEN_",",2,"E"))
I '$G(CLINICIEN) D
.S CLINICIEN=$G(CONDATA(123,CONSULTIEN_",",.05,"I"))
.S CLINICNAME=$G(CONDATA(123,CONSULTIEN_",",.05,"E"))
;
I $D(^SDEC(409.87,"B",CONSULTIEN)) D
.S PID=$$GETPID(CONSULTIEN)
.S REQUEST("Request",NUM,"ConsultClinicIndicatedDate")=$$FMTISO^SDAMUTDT(PID)
I '$D(^SDEC(409.87,"B",CONSULTIEN)) D
.S REQUEST("Request",NUM,"ConsultClinicIndicatedDate")=$$FMTISO^SDAMUTDT($G(CONDATA(123,CONSULTIEN_",",17,"I")))
;
S PROVIDERIEN=$G(CONDATA(123,CONSULTIEN_",",10,"I"))
;
S DFN=$G(CONDATA(123,CONSULTIEN_",",.02,"I"))
S REQUEST("Request",NUM,"Type")="Consult"
S REQUEST("Request",NUM,"PatientIEN")=DFN
S REQUEST("Request",NUM,"PatientICN")=$$GETPATICN^SDESINPUTVALUTL(DFN)
S REQUEST("Request",NUM,"PatientName")=$G(CONDATA(123,CONSULTIEN_",",.02,"E"))
S REQUEST("Request",NUM,"RequestIEN")=CONSULTIEN
S REQUEST("Request",NUM,"ConsultRequestType")=$G(CONDATA(123,CONSULTIEN_",",13,"E"))
S REQUEST("Request",NUM,"CreateDate")=$$FMTISO^SDAMUTDT($G(CONDATA(123,CONSULTIEN_",",.01,"I")))
S REQUEST("Request",NUM,"ConsultToService")=$G(CONDATA(123,CONSULTIEN_",",1,"E"))
S REQUEST("Request",NUM,"ClinicIEN")=CLINICIEN
S REQUEST("Request",NUM,"ClinicName")=CLINICNAME
S REQUEST("Request",NUM,"EnteredByIEN")=$G(CONDATA(123,CONSULTIEN_",",10,"I"))
S REQUEST("Request",NUM,"EnteredByName")=$G(CONDATA(123,CONSULTIEN_",",10,"E"))
S REQUEST("Request",NUM,"ConsultCovidPriority")=$$COVIDPRIORITYCHK(CONSULTIEN)
S REQUEST("Request",NUM,"ConsultDateReleasedFromCPRS")=$$FMTISO^SDAMUTDT($G(CONDATA(123,CONSULTIEN_",",3,"I")))
S REQUEST("Request",NUM,"ConsultUrgencyOrEarliestDate")=$$FMTISO^SDAMUTDT($$PRIO^SDEC51A(CONSULTIEN))
S REQUEST("Request",NUM,"ProviderIEN")=$G(CONDATA(123,CONSULTIEN_",",10,"I"))
S REQUEST("Request",NUM,"ProviderName")=$G(CONDATA(123,CONSULTIEN_",",10,"E"))
S REQUEST("Request",NUM,"ProviderSecID")=$$GET1^DIQ(200,PROVIDERIEN_",",205.1,"E")
S REQUEST("Request",NUM,"ConsultServiceRenderedAs")=$G(CONDATA(123,CONSULTIEN_",",14,"E"))
S REQUEST("Request",NUM,"ConsultProhibitedClinicFlag")=$S($$GET1^DIQ(44,+CLINICIEN_",",2500,"I")="Y":1,1:0)
S REQUEST("Request",NUM,"CPRSStatus")=$$GET1^DIQ(123,CONSULTIEN,8,"E")
S REQUEST("Request",NUM,"ConsultCanEditPid")=$$CONSCANCELCHECK^SDES2GETCONSULTS(CONSULTIEN,DFN)
S REQUEST("Request",NUM,"PatientLast4")=$$LAST4SSN^SDESINPUTVALUTL(DFN)
; build appointment request and recall
I '$$GETCONTIEN^SDESCONTACTS(.ERRORS,CONSULTIEN,"C") D
.D SDECONTACT^SDESGETREQWRAPPR(.REQUEST,NUM)
D APPTREQUEST^SDESGETREQWRAPPR(.REQUEST,NUM)
D RECALL^SDESGETREQWRAPPR(.REQUEST,NUM)
;
Q
;
BUILDJSON(JSONRETURN,RETURN) ;
D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETCONSULTS 7683 printed Nov 22, 2024@18:06:46 Page 2
SDESGETCONSULTS ;ALB/BLB,MGD,RRM,BWF,CGP,BLB,ANU,LAB,BLB - VISTA SCHEDULING RPCS GET CONSULTS ;DEC 01,2023
+1 ;;5.3;Scheduling;**815,820,824,837,842,847,857,867,875,877,886**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;External References
+5 ;-------------------
+6 ; Reference to ^VA(200 in ICR #10060 ;
+7 ; Reference to $$GETS^DIQ,$$GET1^DIQ in ICR #2056
+8 ;
+9 ;
+10 ; ----------------- ----------------- ----------
+11 ;
+12 ;
+13 ; for an example of the return object, see SDESGETREQWRAPPR due to its length.
+14 ;
+15 QUIT
+16 ;
GETCONSULTSBYDFN(JSONRETURN,DFN,EAS) ; SDES GET CONSULTS BY DFN
+1 NEW ISDFNVALID,RETURN,REQUEST,CPRSSTATUS,IFCROLE,CONSULTIEN,ERRORS
+2 ;
+3 SET ISDFNVALID=$$VALIDATEDFN(.ERRORS,$GET(DFN))
+4 SET ISEASVALID=$$VALIDATEEAS(.ERRORS,$GET(EAS))
+5 IF $DATA(ERRORS)
SET ERRORS("Request",1)=""
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+6 ;
+7 SET CONSULTIEN=0
+8 FOR
SET CONSULTIEN=$ORDER(^GMR(123,"F",DFN,CONSULTIEN))
if 'CONSULTIEN
QUIT
Begin DoDot:1
+9 SET CPRSSTATUS=$$GET1^DIQ(123,CONSULTIEN,8,"E")
SET IFCROLE=$$GET1^DIQ(123,CONSULTIEN,.125,"E")
+10 IF CPRSSTATUS'="PENDING"
IF CPRSSTATUS'="ACTIVE"
QUIT
+11 IF IFCROLE="PLACER"
QUIT
+12 DO GETCONSULT(.REQUEST,CONSULTIEN)
End DoDot:1
+13 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+14 MERGE RETURN=REQUEST
+15 ;
+16 DO BUILDJSON(.JSONRETURN,.RETURN)
+17 QUIT
+18 ;
GETCONSULTBYIEN(JSONRETURN,CONSULTIEN,EAS) ; SDES GET CONSULTS BY IEN
+1 NEW ISCONSIENVALID,ISEASVALID,RETURN,ERRORS,REQUEST
+2 ;
+3 SET ISCONSIENVALID=$$VALIDATECONIEN(.ERRORS,$GET(CONSULTIEN))
+4 SET ISEASVALID=$$VALIDATEEAS(.ERRORS,$GET(EAS))
+5 IF $DATA(ERRORS)
SET ERRORS("Request",1)=""
MERGE RETURN=ERRORS
+6 ;
+7 IF '$DATA(ERRORS)
Begin DoDot:1
+8 DO GETCONSULT(.REQUEST,CONSULTIEN)
End DoDot:1
+9 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+10 MERGE RETURN=REQUEST
+11 ;
+12 DO BUILDJSON(.JSONRETURN,.RETURN)
+13 QUIT
+14 ;
VALIDATEDFN(ERRORS,DFN) ;
+1 IF DFN=""
DO ERRLOG^SDESJSON(.ERRORS,1)
QUIT 0
+2 IF DFN'=""
IF '$DATA(^DPT(DFN,0))
DO ERRLOG^SDESJSON(.ERRORS,2)
QUIT 0
+3 QUIT 1
+4 ;
VALIDATECONIEN(ERRORS,CONSULTIEN) ;
+1 IF CONSULTIEN=""
DO ERRLOG^SDESJSON(.ERRORS,5)
QUIT 0
+2 IF CONSULTIEN'=""
IF ('$DATA(^GMR(123,CONSULTIEN)))!(CONSULTIEN=0)
DO ERRLOG^SDESJSON(.ERRORS,6)
QUIT 0
+3 QUIT 1
+4 ;
VALIDATEEAS(ERRORS,EAS) ;
+1 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL($GET(EAS))
+2 IF $PIECE($GET(EAS),U)=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
QUIT 0
+3 QUIT 1
+4 ;
COVIDPRIORITYCHK(CONSULTIEN) ; pass back the latest entry in the comment multiple containging "covid-19 priority"
+1 NEW SUBIEN,SUBIEN2,FOUND,COVIDCOMMENT
+2 SET SUBIEN=999999999
SET FOUND=0
SET COVIDCOMMENT=""
+3 FOR
SET SUBIEN=$ORDER(^GMR(123,CONSULTIEN,40,SUBIEN),-1)
if 'SUBIEN!(FOUND=1)
QUIT
Begin DoDot:1
+4 SET SUBIEN2=0
+5 FOR
SET SUBIEN2=$ORDER(^GMR(123,CONSULTIEN,40,SUBIEN,1,SUBIEN2))
if 'SUBIEN2
QUIT
Begin DoDot:2
+6 SET COVIDCOMMENT=$$GET1^DIQ(123.25,SUBIEN2_","_SUBIEN_","_CONSULTIEN_",",.01)
+7 IF COVIDCOMMENT["COVID-19 Priority"
Begin DoDot:3
+8 SET COVIDCOMMENT=$PIECE(COVIDCOMMENT,"-COVID-19 Priority",1)
+9 SET FOUND=1
QUIT
End DoDot:3
End DoDot:2
End DoDot:1
+10 QUIT COVIDCOMMENT
+11 ;857
GETSTOPCODES(REQUEST,SERVICEIEN,NUM) ;
+1 NEW SUBIEN,COUNT,STOPCODE
+2 SET COUNT=0
SET SUBIEN=0
+3 FOR
SET SUBIEN=$ORDER(^GMR(123.5,SERVICEIEN,688,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET STOPCODE=$$GET1^DIQ(123.5688,SUBIEN_","_SERVICEIEN_",",.01,"I")
+6 SET REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"StopCode")=STOPCODE
+7 SET REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"StopCodeName")=$$GET1^DIQ(40.7,STOPCODE,.01,"E")
+8 SET REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"AmisStopCode")=$$GET1^DIQ(40.7,STOPCODE,1,"I")
+9 SET REQUEST("Request",NUM,"ConsultAssociatedStopCodes",COUNT,"RestrictionType")=$$GET1^DIQ(40.7,STOPCODE,5,"I")
End DoDot:1
+10 QUIT
+11 ;
GETPID(CONSULTIEN) ;
+1 NEW CHIEN,CHSIEN,OLDESTPID
+2 SET CHIEN=$ORDER(^SDEC(409.87,"B",CONSULTIEN,0))
+3 SET CHSIEN=$ORDER(^SDEC(409.87,CHIEN,1,9999999),-1)
+4 SET OLDESTPID=$$GET1^DIQ(409.871,CHSIEN_","_CHIEN_",",1,"I")
+5 QUIT OLDESTPID
+6 ;
CONSCANCELCHECK(CONSULTIEN,DFN) ;looking for most recent appt linked to this consult and checking if cancelled by patient or clinic
+1 NEW FOUND,APPTIEN,CANCHANGE
+2 SET APPTIEN=""
SET FOUND=0
SET CANCHANGE=0
+3 FOR
SET APPTIEN=$ORDER(^SDEC(409.84,"CPAT",DFN,APPTIEN),-1)
if 'APPTIEN!(FOUND=1)
QUIT
Begin DoDot:1
+4 IF $PIECE($$GET1^DIQ(409.84,APPTIEN,.22,"I"),";")=CONSULTIEN
SET FOUND=1
Begin DoDot:2
+5 IF $$GET1^DIQ(409.84,APPTIEN,.17,"I")="PC"
SET CANCHANGE=1
+6 IF $$GET1^DIQ(409.84,APPTIEN,.1,"I")=1
SET CANCHANGE=1
End DoDot:2
End DoDot:1
+7 QUIT CANCHANGE
+8 ;857
GETCONSULT(REQUEST,CONSULTIEN) ;Build a consult record for every consult
+1 NEW CLINICIEN,CLINICNAME,SERVICEIEN,CONDATA,CONSERR,CANCHANGEPID,PID,NUM,ERRORS,PROVIDERIEN
+2 DO GETS^DIQ(123,CONSULTIEN,"**","IE","CONDATA","CONSERR")
+3 SET NUM=""
SET NUM=$ORDER(REQUEST("Request",NUM),-1)+1
+4 SET REQUEST("Request",NUM,"Type")="Consult"
+5 ;
+6 ;I $D(^SDEC(409.86,"SRP",CONSULTIEN)) D
+7 ;I $$GETCONTIEN^SDESCONTACTS(.ERRORS,CONSULTIEN,"C") D
+8 DO BUILDSDECONTACT^SDESGETAPPTREQ(.REQUEST,CONSULTIEN,NUM,"C")
+9 ;
+10 SET SERVICEIEN=$GET(CONDATA(123,CONSULTIEN_",",1,"I"))
+11 IF $GET(SERVICEIEN)
Begin DoDot:1
+12 DO GETSTOPCODES(.REQUEST,SERVICEIEN,NUM)
End DoDot:1
+13 IF '$GET(SERVICEIEN)
Begin DoDot:1
+14 SET REQUEST("Request",NUM,"ConsultAssociatedStopCodes",1)=""
End DoDot:1
+15 ;
+16 SET CLINICIEN=$GET(CONDATA(123,CONSULTIEN_",",2,"I"))
+17 SET CLINICNAME=$GET(CONDATA(123,CONSULTIEN_",",2,"E"))
+18 IF '$GET(CLINICIEN)
Begin DoDot:1
+19 SET CLINICIEN=$GET(CONDATA(123,CONSULTIEN_",",.05,"I"))
+20 SET CLINICNAME=$GET(CONDATA(123,CONSULTIEN_",",.05,"E"))
End DoDot:1
+21 ;
+22 IF $DATA(^SDEC(409.87,"B",CONSULTIEN))
Begin DoDot:1
+23 SET PID=$$GETPID(CONSULTIEN)
+24 SET REQUEST("Request",NUM,"ConsultClinicIndicatedDate")=$$FMTISO^SDAMUTDT(PID)
End DoDot:1
+25 IF '$DATA(^SDEC(409.87,"B",CONSULTIEN))
Begin DoDot:1
+26 SET REQUEST("Request",NUM,"ConsultClinicIndicatedDate")=$$FMTISO^SDAMUTDT($GET(CONDATA(123,CONSULTIEN_",",17,"I")))
End DoDot:1
+27 ;
+28 SET PROVIDERIEN=$GET(CONDATA(123,CONSULTIEN_",",10,"I"))
+29 ;
+30 SET DFN=$GET(CONDATA(123,CONSULTIEN_",",.02,"I"))
+31 SET REQUEST("Request",NUM,"Type")="Consult"
+32 SET REQUEST("Request",NUM,"PatientIEN")=DFN
+33 SET REQUEST("Request",NUM,"PatientICN")=$$GETPATICN^SDESINPUTVALUTL(DFN)
+34 SET REQUEST("Request",NUM,"PatientName")=$GET(CONDATA(123,CONSULTIEN_",",.02,"E"))
+35 SET REQUEST("Request",NUM,"RequestIEN")=CONSULTIEN
+36 SET REQUEST("Request",NUM,"ConsultRequestType")=$GET(CONDATA(123,CONSULTIEN_",",13,"E"))
+37 SET REQUEST("Request",NUM,"CreateDate")=$$FMTISO^SDAMUTDT($GET(CONDATA(123,CONSULTIEN_",",.01,"I")))
+38 SET REQUEST("Request",NUM,"ConsultToService")=$GET(CONDATA(123,CONSULTIEN_",",1,"E"))
+39 SET REQUEST("Request",NUM,"ClinicIEN")=CLINICIEN
+40 SET REQUEST("Request",NUM,"ClinicName")=CLINICNAME
+41 SET REQUEST("Request",NUM,"EnteredByIEN")=$GET(CONDATA(123,CONSULTIEN_",",10,"I"))
+42 SET REQUEST("Request",NUM,"EnteredByName")=$GET(CONDATA(123,CONSULTIEN_",",10,"E"))
+43 SET REQUEST("Request",NUM,"ConsultCovidPriority")=$$COVIDPRIORITYCHK(CONSULTIEN)
+44 SET REQUEST("Request",NUM,"ConsultDateReleasedFromCPRS")=$$FMTISO^SDAMUTDT($GET(CONDATA(123,CONSULTIEN_",",3,"I")))
+45 SET REQUEST("Request",NUM,"ConsultUrgencyOrEarliestDate")=$$FMTISO^SDAMUTDT($$PRIO^SDEC51A(CONSULTIEN))
+46 SET REQUEST("Request",NUM,"ProviderIEN")=$GET(CONDATA(123,CONSULTIEN_",",10,"I"))
+47 SET REQUEST("Request",NUM,"ProviderName")=$GET(CONDATA(123,CONSULTIEN_",",10,"E"))
+48 SET REQUEST("Request",NUM,"ProviderSecID")=$$GET1^DIQ(200,PROVIDERIEN_",",205.1,"E")
+49 SET REQUEST("Request",NUM,"ConsultServiceRenderedAs")=$GET(CONDATA(123,CONSULTIEN_",",14,"E"))
+50 SET REQUEST("Request",NUM,"ConsultProhibitedClinicFlag")=$SELECT($$GET1^DIQ(44,+CLINICIEN_",",2500,"I")="Y":1,1:0)
+51 SET REQUEST("Request",NUM,"CPRSStatus")=$$GET1^DIQ(123,CONSULTIEN,8,"E")
+52 SET REQUEST("Request",NUM,"ConsultCanEditPid")=$$CONSCANCELCHECK^SDES2GETCONSULTS(CONSULTIEN,DFN)
+53 SET REQUEST("Request",NUM,"PatientLast4")=$$LAST4SSN^SDESINPUTVALUTL(DFN)
+54 ; build appointment request and recall
+55 IF '$$GETCONTIEN^SDESCONTACTS(.ERRORS,CONSULTIEN,"C")
Begin DoDot:1
+56 DO SDECONTACT^SDESGETREQWRAPPR(.REQUEST,NUM)
End DoDot:1
+57 DO APPTREQUEST^SDESGETREQWRAPPR(.REQUEST,NUM)
+58 DO RECALL^SDESGETREQWRAPPR(.REQUEST,NUM)
+59 ;
+60 QUIT
+61 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 DO ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
+2 QUIT
+3 ;