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

SDESGETAPPTREQ.m

Go to the documentation of this file.
SDESGETAPPTREQ ;ALB/BLB,RRM,MGD,DJS,BLB,BWF,BLB,CGP,ANU,LAB,TJB/BLB ,LAB- GET APPT REQ RPCS ;MAR 13, 2024
 ;;5.3;Scheduling;**815,818,819,823,824,825,828,831,833,837,838,839,845,847,851,861,873,875**;Aug 13, 1993;Build 25
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ; Reference to ^VA(200 in ICR #10060 ;
 Q
 ;
 ; For an ex of the return object, see SDESGETREQWRAPPR due to its length.
 ; If you add new components to the JSON return object here, document
 ; in header of SDESGETREQWRAPPR, initialize in APPTREQUEST.
 ;
GETREQSBYDFN(JSONRETURN,DFN,EAS) ;GET APPT REQ BY PATIENT
 N ISDFNVALID,ISEASVALID,RETURN,ERRORS,REQUESTIEN,REQUEST
 ;
 S ISDFNVALID=$$VALIDATEDFN^SDESGETAPPTREQ2(.ERRORS,$G(DFN))
 S ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$G(EAS))
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
 ;
 S REQUESTIEN=0
 F  S REQUESTIEN=$O(^SDEC(409.85,"B",DFN,REQUESTIEN)) Q:'REQUESTIEN  D
 .I $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C" Q
 .D GETREQUEST(.REQUEST,REQUESTIEN)
 I '$D(REQUEST) S REQUEST("Request",1)=""
 M RETURN=REQUEST
 D BUILDJSON(.JSONRETURN,.RETURN)
 Q
 ;
GETREQSBYDFNALL(JSONRETURN,DFN,EAS,STARTDATE,ENDDATE) ;GET APPT REQ BY PAT ALL
 N ISDFNVALID,ISEASVALID,ISDATEVALID,RETURN,ERRORS,REQUESTIEN,REQUEST
 S ISDATEVALID=1
 ;
 S ISDFNVALID=$$VALIDATEDFN^SDESGETAPPTREQ2(.ERRORS,$G(DFN))
 S ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$G(EAS))
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
 ;
 I STARTDATE'="" D VALIDATESTART^SDESGETAPPTREQ2(.ERRORS,STARTDATE)
 I ENDDATE'="" D VALIDATEEND^SDESGETAPPTREQ2(.ERRORS,ENDDATE)
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
 I (STARTDATE'="")&(ENDDATE'="") D VALIDATERANGE^SDESGETAPPTREQ2(.ERRORS,STARTDATE,ENDDATE)
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
 ;
 S REQUESTIEN=0
 F  S REQUESTIEN=$O(^SDEC(409.85,"B",DFN,REQUESTIEN)) Q:'REQUESTIEN  D
 .I ($G(STARTDATE,"")'="")!($G(ENDDATE,"")'="") S ISDATEVALID=$$VALIDATEDATES^SDESGETAPPTREQ2(REQUESTIEN,STARTDATE,ENDDATE)
 .I ISDATEVALID'=1 Q
 .D GETREQUEST(.REQUEST,REQUESTIEN)
 I '$D(REQUEST) S REQUEST("Request",1)=""
 M RETURN=REQUEST
 D BUILDJSON(.JSONRETURN,.RETURN)
 Q
 ;
GETREQSBYDFNOPEN(JSONRETURN,DFN,EAS) ;GET APPT REQ BY PAT OPEN
 N ISDFNVALID,ISEASVALID,RETURN,ERRORS,REQUESTIEN,REQUEST
 S ISDFNVALID=$$VALIDATEDFN^SDESGETAPPTREQ2(.ERRORS,$G(DFN))
 S ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$G(EAS))
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
 ;
 S REQUESTIEN=0
 F  S REQUESTIEN=$O(^SDEC(409.85,"B",DFN,REQUESTIEN)) Q:'REQUESTIEN  D
 .I $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C" Q
 .D GETREQUEST(.REQUEST,REQUESTIEN)
 I '$D(REQUEST) S REQUEST("Request",1)=""
 M RETURN=REQUEST
 D BUILDJSON(.JSONRETURN,.RETURN)
 Q
 ;
GETREQBYREQIEN(JSONRETURN,REQUESTIEN,EAS) ;GET APPT REQ BY IEN
 N ISREQIENVALID,ISEASVALID,RETURN,ERRORS,REQUEST
 ;
 S ISREQIENVALID=$$VALIDATEREQIEN^SDESGETAPPTREQ2(.ERRORS,$G(REQUESTIEN))
 S ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$G(EAS))
 I $D(ERRORS) M RETURN=ERRORS
 ;
 I '$D(ERRORS) D
 .D GETREQUEST(.REQUEST,REQUESTIEN)
 I '$D(REQUEST) S REQUEST("Request",1)=""
 M RETURN=REQUEST
 D BUILDJSON(.JSONRETURN,.RETURN)
 Q
 ;
GETREQBYTYPEVET(JSONRETURN,EAS) ;GET APPT REQ BY TYPE VET
 N ISEASVALID,RETURN,ERRORS,REQUEST,COUNT
 ;
 S ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$G(EAS))
 I $D(ERRORS) M RETURN=ERRORS
 ;
 I '$D(ERRORS) D
 .S REQUESTIEN=0,COUNT=0
 .F  S REQUESTIEN=$O(^SDEC(409.85,"TYPE","VETERAN",REQUESTIEN)) Q:'REQUESTIEN!(COUNT=200)  D
 ..I $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C" Q
 ..S COUNT=COUNT+1
 ..D GETREQUEST(.REQUEST,REQUESTIEN)
 I '$D(REQUEST) S REQUEST("Request",1)=""
 M RETURN=REQUEST
 ;
 D BUILDJSON(.JSONRETURN,.RETURN)
 Q
 ;
BUILDPATCOMMENTS(REQUEST,REQUESTIEN,NUM) ;
 N SUBIEN,COUNT
 S SUBIEN=0,COUNT=0
 F  S SUBIEN=$O(^SDEC(409.85,REQUESTIEN,"PATCOM",SUBIEN)) Q:'SUBIEN  D
 .S COUNT=COUNT+1
 .S REQUEST("Request",NUM,"PatientComment",COUNT,"Comment")=$$GET1^DIQ(409.855,SUBIEN_","_REQUESTIEN_",",.01,"E")
 Q
 ;
BUILDCOMMENTMULT(REQUEST,REQUESTIEN,NUM) ;Comments Multiple (#26)
 N SUBIEN,COUNT
 S SUBIEN=0,COUNT=0
 F  S SUBIEN=$O(^SDEC(409.85,REQUESTIEN,1,SUBIEN)) Q:'SUBIEN  D
 .S COUNT=COUNT+1
 .S REQUEST("Request",NUM,"CommentMultiple",COUNT,"Comment")=$$GET1^DIQ(409.8526,SUBIEN_","_REQUESTIEN_",",.01,"E")
 Q
 ;
BUILDPATCONTACTS(REQUEST,REQUESTIEN,NUM) ;
 N SUBIEN,SUBIEN2,PIENS,PIENS2,COMMENTS,COUNT
 S SUBIEN=0,COUNT=0
 F  S SUBIEN=$O(^SDEC(409.85,REQUESTIEN,4,SUBIEN)) Q:'SUBIEN  D
 .S COUNT=COUNT+1
 .S PIENS=SUBIEN_","_REQUESTIEN_","
 .S REQUEST("Request",NUM,"PatientContact",COUNT,"DateEntered")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8544,PIENS,.01,"E"))
 .S REQUEST("Request",NUM,"PatientContact",COUNT,"EnteredByIEN")=$$GET1^DIQ(409.8544,PIENS,2,"I")
 .S REQUEST("Request",NUM,"PatientContact",COUNT,"EnteredByName")=$$GET1^DIQ(409.8544,PIENS,2,"E")
 .S REQUEST("Request",NUM,"PatientContact",COUNT,"Action")=$$GET1^DIQ(409.8544,PIENS,3,"E")
 .S REQUEST("Request",NUM,"PatientContact",COUNT,"PatientPhone")=$$GET1^DIQ(409.8544,PIENS,4,"E")
 Q
 ;
BUILDMRTCPIDS(REQUEST,REQUESTIEN,NUM) ;MRTC PID entries
 N SUBIEN,DATE,COUNT
 S SUBIEN=0,COUNT=0
 F  S SUBIEN=$O(^SDEC(409.85,REQUESTIEN,5,SUBIEN)) Q:'SUBIEN  D
 .S COUNT=COUNT+1
 .S DATE=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.851,SUBIEN_","_REQUESTIEN_",",.01,"I"))
 .S REQUEST("Request",NUM,"MRTC",COUNT,"PatientIndicatedDate")=DATE
 Q
 ;
BUILDMRTCS(REQUEST,REQUESTIEN,NUM) ;
 N SUBIEN,COUNT,MIENS,CHILDIEN
 S SUBIEN=0,COUNT=0
 F  S SUBIEN=$O(^SDEC(409.85,REQUESTIEN,2,SUBIEN)) Q:'SUBIEN  D
 .S COUNT=COUNT+1
 .S MIENS=SUBIEN_","_REQUESTIEN_","
 .S CHILDIEN=$$GET1^DIQ(409.852,MIENS,.01,"I")
 .S REQUEST("Request",NUM,"MRTC",COUNT,"ChildRequestIEN")=CHILDIEN
 .S REQUEST("Request",NUM,"MRTC",COUNT,"LinkedAppointmentIEN")=$$GET1^DIQ(409.852,MIENS,.02,"I")
 .S REQUEST("Request",NUM,"MRTC",COUNT,"ChildRequestSequenceNumber")=$$GET1^DIQ(409.85,CHILDIEN,43.1,"I")
 S REQUEST("Request",NUM,"MRTCTotal")=COUNT
 Q
 ;
BUILDSDECONTACT(REQUEST,REQUESTIEN,NUM,REQUESTTYPE) ;get consult/recall
 N CONTACTIEN,SUBIEN,CIENS,COUNT,CONTARY,CONTACTYPE,CONTACTS,ERRORS
 S COUNT=0,CONTACTIEN=0
 S CONTACTIEN=$$GETCONTIEN^SDESCONTACTS(.ERRORS,REQUESTIEN,REQUESTTYPE)
 I 'CONTACTIEN S REQUEST("Request",NUM,"Contact",1)="" Q
 S SUBIEN=$$GET1^DIQ(409.86,CONTACTIEN,2.2,"I")-1
 F  S SUBIEN=$O(^SDEC(409.86,CONTACTIEN,1,SUBIEN)) Q:'SUBIEN  D
 .S CIENS=SUBIEN_","_CONTACTIEN_","
 .S CONTACTYPE=$$GET1^DIQ(409.863,CIENS,1,"I")
 .I $L($G(CONTACTYPE)) D
 ..S CONTARY(CONTACTYPE)=$G(CONTARY(CONTACTYPE))+1
 ..S COUNT=COUNT+1
 ..S REQUEST("Request",NUM,"SdecContactNumberOfCalls")=$G(CONTARY("C"))
 ..S REQUEST("Request",NUM,"SdecContactNumberOfEmailContact")=$G(CONTARY("E"))
 ..S REQUEST("Request",NUM,"SdecContactNumberOfTextContact")=$G(CONTARY("T"))
 ..S REQUEST("Request",NUM,"SdecContactNumberOfSecureMessage")=$G(CONTARY("S"))
 ..S REQUEST("Request",NUM,"SdecContactNumberOfLetters")=$G(CONTARY("L"))
 ..S:($G(CONTACTYPE)="L") REQUEST("Request",NUM,"SdecContactDateOfLastLetterSent")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.863,CIENS,.01,"I"))
 .S:('$D(REQUEST("Request",NUM,"SdecContactDateOfLastLetterSent"))) REQUEST("Request",NUM,"SdecContactDateOfLastLetterSent")=""
 S REQUEST("Request",NUM,"SdecContactNumberOfContacts")=COUNT
 D BLDCONTACT^SDESCONTACTS(.CONTACTS,CONTACTIEN)
 D DISPMULT^SDESCONTACTS(.CONTACTS,CONTACTIEN)
 I $D(CONTACTS) M REQUEST("Request",NUM)=CONTACTS Q
 I '$D(CONTACTS) S REQUEST("Request",NUM,"Contact",1)=""
 Q
BUILDCPRSPREREQS(REQUEST,REQUESTIEN,NUM) ;
 N SUBIEN,COUNT,PIENS
 S SUBIEN=0,COUNT=0
 F  S SUBIEN=$O(^SDEC(409.85,REQUESTIEN,8,SUBIEN)) Q:'SUBIEN  D
 .S COUNT=COUNT+1
 .S PIENS=SUBIEN_","_REQUESTIEN_","
 .S REQUEST("Request",NUM,"CPRSPreRequisites",COUNT,"PreRequisite")=$$GET1^DIQ(409.8548,PIENS,.01,"E")
 Q
 ;
GETREQUEST(REQUEST,REQUESTIEN) ;
 N APPT,REQUESTARY,ERR,IENS,FN,REQDATA,NUM,CLINSTOPIEN,CLINCREDIEN
 S FN=409.85,NUM=""
 S NUM=$O(REQUEST("Request",NUM),-1)+1
 S IENS=REQUESTIEN_","
 D GETS^DIQ(FN,IENS,"**","IE","REQDATA","ERR")
 Q:$D(ERR)
 ; Check the AMIS Stop codes on clinic
 S CLINSTOPIEN=$S(REQDATA(FN,REQUESTIEN_",",8.5,"I")'="":REQDATA(FN,REQUESTIEN_",",8.5,"I"),1:$$GET1^DIQ(44,REQDATA(FN,REQUESTIEN_",",8,"I")_",",8,"I"))
 S CLINCREDIEN=$S(REQDATA(FN,REQUESTIEN_",",13.5,"I")'="":REQDATA(FN,REQUESTIEN_",",13.5,"I"),1:$$GET1^DIQ(44,REQDATA(FN,REQUESTIEN_",",8,"I")_",",2503,"I"))
 ;
 I $D(^SDEC(409.85,REQUESTIEN,"PATCOM")) D BUILDPATCOMMENTS(.REQUEST,REQUESTIEN,NUM)
 I '$D(^SDEC(409.85,REQUESTIEN,"PATCOM")) S REQUEST("Request",NUM,"PatientComment",1)=""
 ;
 I $D(^SDEC(409.85,REQUESTIEN,1)) D BUILDCOMMENTMULT(.REQUEST,REQUESTIEN,NUM)
 I '$D(^SDEC(409.85,REQUESTIEN,1)) S REQUEST("Request",NUM,"CommentMultiple",1)=""
 ;
 S REQUEST("Request",NUM,"PatientContact",1)=""
 ;
 I $D(^SDEC(409.85,REQUESTIEN,8)) D BUILDCPRSPREREQS(.REQUEST,REQUESTIEN,NUM)
 I '$D(^SDEC(409.85,REQUESTIEN,8)) S REQUEST("Request",NUM,"CPRSPreRequisites",1)=""
 ;
 I $D(^SDEC(409.85,REQUESTIEN,2)) D BUILDMRTCS(.REQUEST,REQUESTIEN,NUM) ;MRTCs
 I '$D(^SDEC(409.85,REQUESTIEN,2)) S REQUEST("Request",NUM,"MRTC",1)=""
 ;
 I $D(^SDEC(409.85,REQUESTIEN,5)) D BUILDMRTCPIDS(.REQUEST,REQUESTIEN,NUM) ;MRTC PIDs
 ;
 I $D(^SDEC(409.86,"SRP",REQUESTIEN)) D BUILDSDECONTACT(.REQUEST,REQUESTIEN,NUM,"A")
 ;
 S REQUEST("Request",NUM,"Type")="Appt Request"
 S REQUEST("Request",NUM,"PatientIEN")=REQDATA(FN,REQUESTIEN_",",.01,"I")
 S REQUEST("Request",NUM,"PatientICN")=$$GETPATICN^SDESINPUTVALUTL(REQDATA(FN,REQUESTIEN_",",.01,"I"))
 S REQUEST("Request",NUM,"PatientName")=REQDATA(FN,REQUESTIEN_",",.01,"E") ;
 S REQUEST("Request",NUM,"RequestIEN")=REQUESTIEN
 S REQUEST("Request",NUM,"RequestComments")=REQDATA(FN,REQUESTIEN_",",25,"E")
 S REQUEST("Request",NUM,"CreateDate")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",1,"I"))
 S REQUEST("Request",NUM,"InstitutionIEN")=REQDATA(FN,REQUESTIEN_",",2,"I")
 S REQUEST("Request",NUM,"InstitutionName")=REQDATA(FN,REQUESTIEN_",",2,"E")
 S REQUEST("Request",NUM,"InstitutionNumber")=$$GET1^DIQ(4,REQDATA(FN,REQUESTIEN_",",2,"I"),99)
 S REQUEST("Request",NUM,"RequestSubType")=REQDATA(FN,REQUESTIEN_",",4,"E")
 S REQUEST("Request",NUM,"ClinicIEN")=REQDATA(FN,REQUESTIEN_",",8,"I")
 S REQUEST("Request",NUM,"ClinicName")=REQDATA(FN,REQUESTIEN_",",8,"E")
 S REQUEST("Request",NUM,"ClinicStopCodeIEN")=CLINSTOPIEN
 S REQUEST("Request",NUM,"ClinicStopCodeName")=$$GET1^DIQ(40.7,CLINSTOPIEN_",",.01,"E")
 S REQUEST("Request",NUM,"ClinicStopCodeAMIS")=$$GET1^DIQ(40.7,CLINSTOPIEN_",",1,"E")
 S REQUEST("Request",NUM,"ClinicSecondaryStopCodeIEN")=REQDATA(FN,REQUESTIEN_",",8.6,"I")
 S REQUEST("Request",NUM,"ClinicSecondaryStopCodeName")=REQDATA(FN,REQUESTIEN_",",8.6,"E")
 S REQUEST("Request",NUM,"ClinicSecondaryStopCodeAMIS")=$$GET1^DIQ(40.7,REQDATA(FN,REQUESTIEN_",",8.6,"I"),1)
 S REQUEST("Request",NUM,"CreditStopCodeIEN")=CLINCREDIEN
 S REQUEST("Request",NUM,"CreditStopCodeName")=$$GET1^DIQ(40.7,CLINCREDIEN_",",.01,"E")
 S REQUEST("Request",NUM,"CreditStopCodeAMIS")=$$GET1^DIQ(40.7,CLINCREDIEN_",",1,"E")
 S REQUEST("Request",NUM,"DisplayClinicAppt")=$$GET1^DIQ(44,REQDATA(FN,REQUESTIEN_",",8,"I")_",",62,"E")
 S REQUEST("Request",NUM,"ApptType")=REQDATA(FN,REQUESTIEN_",",8.7,"E")
 S REQUEST("Request",NUM,"EnteredByName")=REQDATA(FN,REQUESTIEN_",",9,"E")
 S REQUEST("Request",NUM,"EnteredByIEN")=REQDATA(FN,REQUESTIEN_",",9,"I")
 S REQUEST("Request",NUM,"DateTimeEntered")=$$FMTISO^SDAMUTDT($G(REQDATA(FN,REQUESTIEN_",",9.5,"I")))
 S REQUEST("Request",NUM,"Priority")=REQDATA(FN,REQUESTIEN_",",10,"E")
 S REQUEST("Request",NUM,"EnrollmentPriorityGroup")=REQDATA(FN,REQUESTIEN_",",10.5,"E")
 S REQUEST("Request",NUM,"ByPatientOrProvider")=REQDATA(FN,REQUESTIEN_",",11,"E")
 S REQUEST("Request",NUM,"ProviderIEN")=REQDATA(FN,REQUESTIEN_",",12,"I")
 S REQUEST("Request",NUM,"ProviderName")=REQDATA(FN,REQUESTIEN_",",12,"E")
 S REQUEST("Request",NUM,"ProviderSecID")=$$GET1^DIQ(200,REQDATA(FN,REQUESTIEN_",",12,"I"),205.1)
 S REQUEST("Request",NUM,"ScheduledDateOfAppt")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",13,"I"))
 S REQUEST("Request",NUM,"DateLinkedApptMade")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",13.1,"I"))
 S REQUEST("Request",NUM,"LinkedApptClinic")=REQDATA(FN,REQUESTIEN_",",13.2,"E")
 S REQUEST("Request",NUM,"LinkedApptInstitutionName")=REQDATA(FN,REQUESTIEN_",",13.3,"E")
 S REQUEST("Request",NUM,"LinkedApptStopCode")=REQDATA(FN,REQUESTIEN_",",13.4,"E")
 S REQUEST("Request",NUM,"LinkedApptCreditStopCode")=REQDATA(FN,REQUESTIEN_",",13.5,"E")
 S REQUEST("Request",NUM,"LinkedApptInstitutionNumber")=REQDATA(FN,REQUESTIEN_",",13.6,"I")
 S REQUEST("Request",NUM,"LinkedApptEnteredBy")=REQDATA(FN,REQUESTIEN_",",13.7,"E")
 S REQUEST("Request",NUM,"LinkedApptStatus")=REQDATA(FN,REQUESTIEN_",",13.8,"E")
 S REQUEST("Request",NUM,"ServiceConnectedPercentage")=REQDATA(FN,REQUESTIEN_",",14,"E")
 S REQUEST("Request",NUM,"PatientIndicatedDate")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",22,"I"))
 S REQUEST("Request",NUM,"Status")=(REQDATA(FN,REQUESTIEN_",",23,"E"))
 S REQUEST("Request",NUM,"MRTCNeeded")=REQDATA(409.85,REQUESTIEN_",",41,"E")
 S REQUEST("Request",NUM,"MRTCDaysBetweenAppts")=REQDATA(409.85,REQUESTIEN_",",42,"E")
 S REQUEST("Request",NUM,"MRTCHowManyNeeded")=REQDATA(409.85,REQUESTIEN_",",43,"E")
 S REQUEST("Request",NUM,"EASTrackingNumber")=REQDATA(FN,REQUESTIEN_",",100,"E")
 S REQUEST("Request",NUM,"DispositionedDate")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",19,"I"))
 S REQUEST("Request",NUM,"DispositionedBy")=REQDATA(FN,REQUESTIEN_",",20,"I")
 S REQUEST("Request",NUM,"DispositionedBy")=REQDATA(FN,REQUESTIEN_",",20,"E")
 S REQUEST("Request",NUM,"DispositionReason")=REQDATA(FN,REQUESTIEN_",",21,"E")
 S REQUEST("Request",NUM,"DispositionIEN")=REQDATA(FN,REQUESTIEN_",",21,"I")
 S REQUEST("Request",NUM,"ServiceConnectedPriority")=REQDATA(FN,REQUESTIEN_",",15,"E")
 S REQUEST("Request",NUM,"PatientStatus")=REQDATA(FN,REQUESTIEN_",",.02,"E")
 S REQUEST("Request",NUM,"ChildRequestSequenceNumber")=$$GET1^DIQ(409.85,REQUESTIEN,43.1,"I")
 S REQUEST("Request",NUM,"ParentRequest")=REQDATA(FN,REQUESTIEN_",",43.8,"I")
 S REQUEST("Request",NUM,"ModalityName")=REQDATA(FN,REQUESTIEN_",",6,"E")
 S REQUEST("Request",NUM,"ModalityCode")=REQDATA(FN,REQUESTIEN_",",6,"I")
 S REQUEST("Request",NUM,"CPRSOrderID")=REQDATA(FN,REQUESTIEN_",",46,"I")
 S REQUEST("Request",NUM,"CPRSTimeSensitive")=REQDATA(FN,REQUESTIEN_",",47,"I")
 S REQUEST("Request",NUM,"PIDChangeAllowed")=$S(+$G(REQDATA(FN,REQUESTIEN_",",49,"I"))=1:1,1:0)
 S REQUEST("Request",NUM,"PatientLast4")=$$LAST4SSN^SDESINPUTVALUTL(REQDATA(FN,REQUESTIEN_",",.01,"I"))
 ;
 D FINISHAPPTREQ^SDESGETAPPTREQ2(.REQUEST,NUM,REQUESTIEN)
 ; build recall and consult
 D RECALL^SDESGETREQWRAPPR(.REQUEST,NUM)
 D CONSULT^SDESGETREQWRAPPR(.REQUEST,NUM)
 Q
 ;
BUILDJSON(JSONRETURN,RETURN) ;
 N JSONERROR
 D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
 Q
 ;