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

SDESGETRECALL.m

Go to the documentation of this file.
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