SDESGETRECALL ;ALB/BLB,MGD,RRM,BWF,JAS,ANU,LAB - VISTA SCHEDULING - GET RECALL REQUESTS ;Mar 13,2023
;;5.3;Scheduling;**803,805,809,813,815,820,824,837,842,845,875**;Aug 13, 1993;Build 25
;;Per VHA Directive 6402, this routine should not be modified
;
;
;
; for an example of the return object, see SDESGETREQWRAPPR due to its length.
;
Q
;
GETRECALLBYIEN(JSONRETURN,RECALLIEN,EAS) ;
N DFN,ISEASVALID,ISRECALLIENVALID,RETURN,REQUEST,ERRORS
;
S ISRECALLIENVALID=$$VALIDATERECIEN(.ERRORS,$G(RECALLIEN))
S ISEASVALID=$$VALIDATEEAS(.ERRORS,$G(EAS))
I $D(ERRORS) S ERRORS("Request",1)="" M RETURN=ERRORS
;
I '$D(ERRORS) D
.S DFN=$$GET1^DIQ(403.5,RECALLIEN,.01,"I")
.D GETRECALL(.REQUEST,RECALLIEN,DFN)
I '$D(REQUEST) S REQUEST("Request",1)=""
M RETURN=REQUEST
;
D BUILDJSON(.JSONRETURN,.RETURN) Q
Q
;
GETRECALLSBYDFN(JSONRETURN,DFN,EAS) ;
N ISDFNVALID,ISEASVALID,REQUEST,RECALLIEN,ERRORS,RETURN
;
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 RECALLIEN=0
F S RECALLIEN=$O(^SD(403.5,"B",DFN,RECALLIEN)) Q:RECALLIEN="" D
.D GETRECALL(.REQUEST,RECALLIEN,DFN)
I '$D(REQUEST) S REQUEST("Request",1)=""
M RETURN=REQUEST
D BUILDJSON(.JSONRETURN,.RETURN) Q
Q
;
VALIDATERECIEN(ERRORS,RECALLIEN) ;
I RECALLIEN="" D ERRLOG^SDESJSON(.ERRORS,16) Q 0
I RECALLIEN'="",'$D(^SD(403.5,RECALLIEN))!(RECALLIEN=0) D ERRLOG^SDESJSON(.ERRORS,17) Q 0
Q 1
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
;
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
;
GETRECALL(REQUEST,RECALLIEN,DFN) ;
N F,RECARY,NUM,IENS,RECPROVIEN,RECPROVIEN200,RECPROVIEN40954,RECCLINICIEN,STOPCDIEN,SECSTOPCDIEN,VA,YSZ
D GETS^DIQ(403.5,RECALLIEN,"**","IE","RECARY","SDMSG")
S F=403.5,NUM=""
S NUM=$O(REQUEST("Request",NUM),-1)+1
S IENS=RECALLIEN_","
;
S RECPROVIEN40954=$G(RECARY(F,IENS,4,"I"))
S RECPROVIEN200=$$GET1^DIQ(403.54,RECPROVIEN40954,.01,"I")
S RECCLINICIEN=$G(RECARY(F,IENS,4.5,"I"))
S STOPCDIEN=$$GET1^DIQ(44,RECCLINICIEN,8,"I")
S SECSTOPCDIEN=$$GET1^DIQ(44,RECCLINICIEN,2503,"I")
D BUILDSDECONTACT^SDESGETAPPTREQ(.REQUEST,RECALLIEN,NUM,"R")
;
S REQUEST("Request",NUM,"Type")="Recall"
S REQUEST("Request",NUM,"RecallAppointmentType")=$G(RECARY(F,IENS,3,"E"))
S REQUEST("Request",NUM,"PatientIEN")=DFN
S REQUEST("Request",NUM,"PatientICN")=$$GETPATICN^SDESINPUTVALUTL(DFN)
S REQUEST("Request",NUM,"PatientLast4")=$$LAST4SSN^SDESINPUTVALUTL(DFN)
S REQUEST("Request",NUM,"PatientName")=RECARY(F,IENS,.01,"E")
S REQUEST("Request",NUM,"RequestIEN")=RECALLIEN
S REQUEST("Request",NUM,"EASTrackingNumber")=RECARY(F,IENS,100,"E")
S REQUEST("Request",NUM,"RecallAccessionNumber")=RECARY(F,IENS,2,"E")
S REQUEST("Request",NUM,"RecallComment")=RECARY(F,IENS,2.5,"E")
S REQUEST("Request",NUM,"RecallFastingNonFasting")=RECARY(F,IENS,2.6,"E")
S REQUEST("Request",NUM,"RecallProviderNewPersonIEN")=RECPROVIEN200
S REQUEST("Request",NUM,"RecallProviderIEN")=RECARY(F,IENS,4,"I")
S REQUEST("Request",NUM,"RecallProviderName")=$$GET1^DIQ(403.54,RECARY(F,IENS,4,"I"),.01,"E")
S REQUEST("Request",NUM,"RecallProviderSecID")=$$GET1^DIQ(200,RECPROVIEN200,205.1,"E")
S REQUEST("Request",NUM,"ClinicIEN")=RECARY(F,IENS,4.5,"I")
S REQUEST("Request",NUM,"ClinicName")=RECARY(F,IENS,4.5,"E")
S REQUEST("Request",NUM,"RecallClinicStopCodeIEN")=STOPCDIEN
S REQUEST("Request",NUM,"RecallClinicStopCodeAMIS")=$$STOPCODETOAMIS^SDESUTIL(STOPCDIEN)
S REQUEST("Request",NUM,"RecallClinicStopCodeName")=$$GET1^DIQ(40.7,STOPCDIEN,.01,"E")
;ANU
S REQUEST("Request",NUM,"DisplayClinicAppt")=$$GET1^DIQ(44,RECCLINICIEN,62,"E")
;
S REQUEST("Request",NUM,"RecallClinicSecondaryStopCodeIEN")=SECSTOPCDIEN
S REQUEST("Request",NUM,"RecallClinicSecondaryStopCodeAMIS")=$$STOPCODETOAMIS^SDESUTIL(SECSTOPCDIEN)
S REQUEST("Request",NUM,"RecallClinicSecondaryStopCodeName")=$$GET1^DIQ(40.7,SECSTOPCDIEN,.01,"E")
S REQUEST("Request",NUM,"RecallAppointmentLength")=RECARY(F,IENS,4.7,"E") ;
S REQUEST("Request",NUM,"RecallProviderIndicatedDate")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,5,"I"))
S REQUEST("Request",NUM,"PatientIndicatedDate")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,5.5,"I"))
S REQUEST("Request",NUM,"RecallDateReminderSent")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,6,"I"))
S REQUEST("Request",NUM,"EnteredByIEN")=RECARY(F,IENS,7,"I")
S REQUEST("Request",NUM,"EnteredByName")=RECARY(F,IENS,7,"E")
S REQUEST("Request",NUM,"RecallEnteredBySecID")=$$GET1^DIQ(200,RECARY(F,IENS,7,"I"),205.1,"E")
S REQUEST("Request",NUM,"RecallSecondPrint")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,8,"I"))
S REQUEST("Request",NUM,"CreateDate")=$$FMTISO^SDAMUTDT(RECARY(403.5,IENS,7.5,"I"))
S REQUEST("Request",NUM,"RecallGAFScore")=$$GAF^SDECU2(DFN)
S REQUEST("Request",NUM,"RecallPatientSensitiveRecordAccessChecks")=$$PTSEC^SDECUTL(DFN)
S REQUEST("Request",NUM,"RecallSimilarPatientData")=$$SIM^SDECU3(DFN)
S REQUEST("Request",NUM,"ProviderIEN")=""
S REQUEST("Request",NUM,"ProviderName")=""
;
I '$D(REQUEST("Request",NUM,"PatientIndicatedDate")) D
.S REQUEST("Request",NUM,"PatientIndicatedDate")=""
; build appointment request and consult
I '$D(^SDEC(409.86,"SRP",RECALLIEN)) D
.D SDECONTACT^SDESGETREQWRAPPR(.REQUEST,NUM)
D APPTREQUEST^SDESGETREQWRAPPR(.REQUEST,NUM)
D CONSULT^SDESGETREQWRAPPR(.REQUEST,NUM)
;
Q
;
BUILDJSON(JSONRETURN,RETURN) ;
D ENCODE^XLFJSON("RETURN","JSONRETURN","ERR")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETRECALL 5711 printed Dec 13, 2024@02:57:02 Page 2
SDESGETRECALL ;ALB/BLB,MGD,RRM,BWF,JAS,ANU,LAB - VISTA SCHEDULING - GET RECALL REQUESTS ;Mar 13,2023
+1 ;;5.3;Scheduling;**803,805,809,813,815,820,824,837,842,845,875**;Aug 13, 1993;Build 25
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;
+5 ;
+6 ; for an example of the return object, see SDESGETREQWRAPPR due to its length.
+7 ;
+8 QUIT
+9 ;
GETRECALLBYIEN(JSONRETURN,RECALLIEN,EAS) ;
+1 NEW DFN,ISEASVALID,ISRECALLIENVALID,RETURN,REQUEST,ERRORS
+2 ;
+3 SET ISRECALLIENVALID=$$VALIDATERECIEN(.ERRORS,$GET(RECALLIEN))
+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 SET DFN=$$GET1^DIQ(403.5,RECALLIEN,.01,"I")
+9 DO GETRECALL(.REQUEST,RECALLIEN,DFN)
End DoDot:1
+10 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+11 MERGE RETURN=REQUEST
+12 ;
+13 DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+14 QUIT
+15 ;
GETRECALLSBYDFN(JSONRETURN,DFN,EAS) ;
+1 NEW ISDFNVALID,ISEASVALID,REQUEST,RECALLIEN,ERRORS,RETURN
+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 RECALLIEN=0
+8 FOR
SET RECALLIEN=$ORDER(^SD(403.5,"B",DFN,RECALLIEN))
if RECALLIEN=""
QUIT
Begin DoDot:1
+9 DO GETRECALL(.REQUEST,RECALLIEN,DFN)
End DoDot:1
+10 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+11 MERGE RETURN=REQUEST
+12 DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+13 QUIT
+14 ;
VALIDATERECIEN(ERRORS,RECALLIEN) ;
+1 IF RECALLIEN=""
DO ERRLOG^SDESJSON(.ERRORS,16)
QUIT 0
+2 IF RECALLIEN'=""
IF '$DATA(^SD(403.5,RECALLIEN))!(RECALLIEN=0)
DO ERRLOG^SDESJSON(.ERRORS,17)
QUIT 0
+3 QUIT 1
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 ;
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 ;
GETRECALL(REQUEST,RECALLIEN,DFN) ;
+1 NEW F,RECARY,NUM,IENS,RECPROVIEN,RECPROVIEN200,RECPROVIEN40954,RECCLINICIEN,STOPCDIEN,SECSTOPCDIEN,VA,YSZ
+2 DO GETS^DIQ(403.5,RECALLIEN,"**","IE","RECARY","SDMSG")
+3 SET F=403.5
SET NUM=""
+4 SET NUM=$ORDER(REQUEST("Request",NUM),-1)+1
+5 SET IENS=RECALLIEN_","
+6 ;
+7 SET RECPROVIEN40954=$GET(RECARY(F,IENS,4,"I"))
+8 SET RECPROVIEN200=$$GET1^DIQ(403.54,RECPROVIEN40954,.01,"I")
+9 SET RECCLINICIEN=$GET(RECARY(F,IENS,4.5,"I"))
+10 SET STOPCDIEN=$$GET1^DIQ(44,RECCLINICIEN,8,"I")
+11 SET SECSTOPCDIEN=$$GET1^DIQ(44,RECCLINICIEN,2503,"I")
+12 DO BUILDSDECONTACT^SDESGETAPPTREQ(.REQUEST,RECALLIEN,NUM,"R")
+13 ;
+14 SET REQUEST("Request",NUM,"Type")="Recall"
+15 SET REQUEST("Request",NUM,"RecallAppointmentType")=$GET(RECARY(F,IENS,3,"E"))
+16 SET REQUEST("Request",NUM,"PatientIEN")=DFN
+17 SET REQUEST("Request",NUM,"PatientICN")=$$GETPATICN^SDESINPUTVALUTL(DFN)
+18 SET REQUEST("Request",NUM,"PatientLast4")=$$LAST4SSN^SDESINPUTVALUTL(DFN)
+19 SET REQUEST("Request",NUM,"PatientName")=RECARY(F,IENS,.01,"E")
+20 SET REQUEST("Request",NUM,"RequestIEN")=RECALLIEN
+21 SET REQUEST("Request",NUM,"EASTrackingNumber")=RECARY(F,IENS,100,"E")
+22 SET REQUEST("Request",NUM,"RecallAccessionNumber")=RECARY(F,IENS,2,"E")
+23 SET REQUEST("Request",NUM,"RecallComment")=RECARY(F,IENS,2.5,"E")
+24 SET REQUEST("Request",NUM,"RecallFastingNonFasting")=RECARY(F,IENS,2.6,"E")
+25 SET REQUEST("Request",NUM,"RecallProviderNewPersonIEN")=RECPROVIEN200
+26 SET REQUEST("Request",NUM,"RecallProviderIEN")=RECARY(F,IENS,4,"I")
+27 SET REQUEST("Request",NUM,"RecallProviderName")=$$GET1^DIQ(403.54,RECARY(F,IENS,4,"I"),.01,"E")
+28 SET REQUEST("Request",NUM,"RecallProviderSecID")=$$GET1^DIQ(200,RECPROVIEN200,205.1,"E")
+29 SET REQUEST("Request",NUM,"ClinicIEN")=RECARY(F,IENS,4.5,"I")
+30 SET REQUEST("Request",NUM,"ClinicName")=RECARY(F,IENS,4.5,"E")
+31 SET REQUEST("Request",NUM,"RecallClinicStopCodeIEN")=STOPCDIEN
+32 SET REQUEST("Request",NUM,"RecallClinicStopCodeAMIS")=$$STOPCODETOAMIS^SDESUTIL(STOPCDIEN)
+33 SET REQUEST("Request",NUM,"RecallClinicStopCodeName")=$$GET1^DIQ(40.7,STOPCDIEN,.01,"E")
+34 ;ANU
+35 SET REQUEST("Request",NUM,"DisplayClinicAppt")=$$GET1^DIQ(44,RECCLINICIEN,62,"E")
+36 ;
+37 SET REQUEST("Request",NUM,"RecallClinicSecondaryStopCodeIEN")=SECSTOPCDIEN
+38 SET REQUEST("Request",NUM,"RecallClinicSecondaryStopCodeAMIS")=$$STOPCODETOAMIS^SDESUTIL(SECSTOPCDIEN)
+39 SET REQUEST("Request",NUM,"RecallClinicSecondaryStopCodeName")=$$GET1^DIQ(40.7,SECSTOPCDIEN,.01,"E")
+40 ;
SET REQUEST("Request",NUM,"RecallAppointmentLength")=RECARY(F,IENS,4.7,"E")
+41 SET REQUEST("Request",NUM,"RecallProviderIndicatedDate")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,5,"I"))
+42 SET REQUEST("Request",NUM,"PatientIndicatedDate")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,5.5,"I"))
+43 SET REQUEST("Request",NUM,"RecallDateReminderSent")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,6,"I"))
+44 SET REQUEST("Request",NUM,"EnteredByIEN")=RECARY(F,IENS,7,"I")
+45 SET REQUEST("Request",NUM,"EnteredByName")=RECARY(F,IENS,7,"E")
+46 SET REQUEST("Request",NUM,"RecallEnteredBySecID")=$$GET1^DIQ(200,RECARY(F,IENS,7,"I"),205.1,"E")
+47 SET REQUEST("Request",NUM,"RecallSecondPrint")=$$FMTISO^SDAMUTDT(RECARY(F,IENS,8,"I"))
+48 SET REQUEST("Request",NUM,"CreateDate")=$$FMTISO^SDAMUTDT(RECARY(403.5,IENS,7.5,"I"))
+49 SET REQUEST("Request",NUM,"RecallGAFScore")=$$GAF^SDECU2(DFN)
+50 SET REQUEST("Request",NUM,"RecallPatientSensitiveRecordAccessChecks")=$$PTSEC^SDECUTL(DFN)
+51 SET REQUEST("Request",NUM,"RecallSimilarPatientData")=$$SIM^SDECU3(DFN)
+52 SET REQUEST("Request",NUM,"ProviderIEN")=""
+53 SET REQUEST("Request",NUM,"ProviderName")=""
+54 ;
+55 IF '$DATA(REQUEST("Request",NUM,"PatientIndicatedDate"))
Begin DoDot:1
+56 SET REQUEST("Request",NUM,"PatientIndicatedDate")=""
End DoDot:1
+57 ; build appointment request and consult
+58 IF '$DATA(^SDEC(409.86,"SRP",RECALLIEN))
Begin DoDot:1
+59 DO SDECONTACT^SDESGETREQWRAPPR(.REQUEST,NUM)
End DoDot:1
+60 DO APPTREQUEST^SDESGETREQWRAPPR(.REQUEST,NUM)
+61 DO CONSULT^SDESGETREQWRAPPR(.REQUEST,NUM)
+62 ;
+63 QUIT
+64 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 DO ENCODE^XLFJSON("RETURN","JSONRETURN","ERR")
+2 QUIT