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
;
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
;
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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETAPPTREQ 15170 printed Sep 02, 2024@19:41:27 Page 2
SDESGETAPPTREQ ;ALB/BLB,RRM,MGD,DJS,BLB,BWF,BLB,CGP,ANU,LAB,TJB/BLB ,LAB- GET APPT REQ RPCS ;MAR 13, 2024
+1 ;;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
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Reference to ^VA(200 in ICR #10060 ;
+5 QUIT
+6 ;
+7 ; For an ex of the return object, see SDESGETREQWRAPPR due to its length.
+8 ; If you add new components to the JSON return object here, document
+9 ; in header of SDESGETREQWRAPPR, initialize in APPTREQUEST.
+10 ;
GETREQSBYDFN(JSONRETURN,DFN,EAS) ;GET APPT REQ BY PATIENT
+1 NEW ISDFNVALID,ISEASVALID,RETURN,ERRORS,REQUESTIEN,REQUEST
+2 ;
+3 SET ISDFNVALID=$$VALIDATEDFN^SDESGETAPPTREQ2(.ERRORS,$GET(DFN))
+4 SET ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$GET(EAS))
+5 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+6 ;
+7 SET REQUESTIEN=0
+8 FOR
SET REQUESTIEN=$ORDER(^SDEC(409.85,"B",DFN,REQUESTIEN))
if 'REQUESTIEN
QUIT
Begin DoDot:1
+9 IF $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C"
QUIT
+10 DO GETREQUEST(.REQUEST,REQUESTIEN)
End DoDot:1
+11 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+12 MERGE RETURN=REQUEST
+13 DO BUILDJSON(.JSONRETURN,.RETURN)
+14 QUIT
+15 ;
GETREQSBYDFNALL(JSONRETURN,DFN,EAS,STARTDATE,ENDDATE) ;GET APPT REQ BY PAT ALL
+1 NEW ISDFNVALID,ISEASVALID,ISDATEVALID,RETURN,ERRORS,REQUESTIEN,REQUEST
+2 SET ISDATEVALID=1
+3 ;
+4 SET ISDFNVALID=$$VALIDATEDFN^SDESGETAPPTREQ2(.ERRORS,$GET(DFN))
+5 SET ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$GET(EAS))
+6 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+7 ;
+8 IF STARTDATE'=""
DO VALIDATESTART^SDESGETAPPTREQ2(.ERRORS,STARTDATE)
+9 IF ENDDATE'=""
DO VALIDATEEND^SDESGETAPPTREQ2(.ERRORS,ENDDATE)
+10 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+11 IF (STARTDATE'="")&(ENDDATE'="")
DO VALIDATERANGE^SDESGETAPPTREQ2(.ERRORS,STARTDATE,ENDDATE)
+12 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+13 ;
+14 SET REQUESTIEN=0
+15 FOR
SET REQUESTIEN=$ORDER(^SDEC(409.85,"B",DFN,REQUESTIEN))
if 'REQUESTIEN
QUIT
Begin DoDot:1
+16 IF ($GET(STARTDATE,"")'="")!($GET(ENDDATE,"")'="")
SET ISDATEVALID=$$VALIDATEDATES^SDESGETAPPTREQ2(REQUESTIEN,STARTDATE,ENDDATE)
+17 IF ISDATEVALID'=1
QUIT
+18 DO GETREQUEST(.REQUEST,REQUESTIEN)
End DoDot:1
+19 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+20 MERGE RETURN=REQUEST
+21 DO BUILDJSON(.JSONRETURN,.RETURN)
+22 QUIT
+23 ;
GETREQSBYDFNOPEN(JSONRETURN,DFN,EAS) ;GET APPT REQ BY PAT OPEN
+1 NEW ISDFNVALID,ISEASVALID,RETURN,ERRORS,REQUESTIEN,REQUEST
+2 SET ISDFNVALID=$$VALIDATEDFN^SDESGETAPPTREQ2(.ERRORS,$GET(DFN))
+3 SET ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$GET(EAS))
+4 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+5 ;
+6 SET REQUESTIEN=0
+7 FOR
SET REQUESTIEN=$ORDER(^SDEC(409.85,"B",DFN,REQUESTIEN))
if 'REQUESTIEN
QUIT
Begin DoDot:1
+8 IF $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C"
QUIT
+9 DO GETREQUEST(.REQUEST,REQUESTIEN)
End DoDot:1
+10 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+11 MERGE RETURN=REQUEST
+12 DO BUILDJSON(.JSONRETURN,.RETURN)
+13 QUIT
+14 ;
GETREQBYREQIEN(JSONRETURN,REQUESTIEN,EAS) ;GET APPT REQ BY IEN
+1 NEW ISREQIENVALID,ISEASVALID,RETURN,ERRORS,REQUEST
+2 ;
+3 SET ISREQIENVALID=$$VALIDATEREQIEN^SDESGETAPPTREQ2(.ERRORS,$GET(REQUESTIEN))
+4 SET ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$GET(EAS))
+5 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
+6 ;
+7 IF '$DATA(ERRORS)
Begin DoDot:1
+8 DO GETREQUEST(.REQUEST,REQUESTIEN)
End DoDot:1
+9 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+10 MERGE RETURN=REQUEST
+11 DO BUILDJSON(.JSONRETURN,.RETURN)
+12 QUIT
+13 ;
GETREQBYTYPEVET(JSONRETURN,EAS) ;GET APPT REQ BY TYPE VET
+1 NEW ISEASVALID,RETURN,ERRORS,REQUEST,COUNT
+2 ;
+3 SET ISEASVALID=$$VALIDATEEAS^SDESGETAPPTREQ2(.ERRORS,$GET(EAS))
+4 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
+5 ;
+6 IF '$DATA(ERRORS)
Begin DoDot:1
+7 SET REQUESTIEN=0
SET COUNT=0
+8 FOR
SET REQUESTIEN=$ORDER(^SDEC(409.85,"TYPE","VETERAN",REQUESTIEN))
if 'REQUESTIEN!(COUNT=200)
QUIT
Begin DoDot:2
+9 IF $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C"
QUIT
+10 SET COUNT=COUNT+1
+11 DO GETREQUEST(.REQUEST,REQUESTIEN)
End DoDot:2
End DoDot:1
+12 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+13 MERGE RETURN=REQUEST
+14 ;
+15 DO BUILDJSON(.JSONRETURN,.RETURN)
+16 QUIT
+17 ;
+1 NEW SUBIEN,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.85,REQUESTIEN,"PATCOM",SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET REQUEST("Request",NUM,"PatientComment",COUNT,"Comment")=$$GET1^DIQ(409.855,SUBIEN_","_REQUESTIEN_",",.01,"E")
End DoDot:1
+6 QUIT
+7 ;
+1 NEW SUBIEN,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.85,REQUESTIEN,1,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET REQUEST("Request",NUM,"CommentMultiple",COUNT,"Comment")=$$GET1^DIQ(409.8526,SUBIEN_","_REQUESTIEN_",",.01,"E")
End DoDot:1
+6 QUIT
+7 ;
BUILDPATCONTACTS(REQUEST,REQUESTIEN,NUM) ;
+1 NEW SUBIEN,SUBIEN2,PIENS,PIENS2,COMMENTS,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.85,REQUESTIEN,4,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET PIENS=SUBIEN_","_REQUESTIEN_","
+6 SET REQUEST("Request",NUM,"PatientContact",COUNT,"DateEntered")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8544,PIENS,.01,"E"))
+7 SET REQUEST("Request",NUM,"PatientContact",COUNT,"EnteredByIEN")=$$GET1^DIQ(409.8544,PIENS,2,"I")
+8 SET REQUEST("Request",NUM,"PatientContact",COUNT,"EnteredByName")=$$GET1^DIQ(409.8544,PIENS,2,"E")
+9 SET REQUEST("Request",NUM,"PatientContact",COUNT,"Action")=$$GET1^DIQ(409.8544,PIENS,3,"E")
+10 SET REQUEST("Request",NUM,"PatientContact",COUNT,"PatientPhone")=$$GET1^DIQ(409.8544,PIENS,4,"E")
End DoDot:1
+11 QUIT
+12 ;
BUILDMRTCPIDS(REQUEST,REQUESTIEN,NUM) ;MRTC PID entries
+1 NEW SUBIEN,DATE,COUNT
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.85,REQUESTIEN,5,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET DATE=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.851,SUBIEN_","_REQUESTIEN_",",.01,"I"))
+6 SET REQUEST("Request",NUM,"MRTC",COUNT,"PatientIndicatedDate")=DATE
End DoDot:1
+7 QUIT
+8 ;
BUILDMRTCS(REQUEST,REQUESTIEN,NUM) ;
+1 NEW SUBIEN,COUNT,MIENS,CHILDIEN
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.85,REQUESTIEN,2,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET MIENS=SUBIEN_","_REQUESTIEN_","
+6 SET CHILDIEN=$$GET1^DIQ(409.852,MIENS,.01,"I")
+7 SET REQUEST("Request",NUM,"MRTC",COUNT,"ChildRequestIEN")=CHILDIEN
+8 SET REQUEST("Request",NUM,"MRTC",COUNT,"LinkedAppointmentIEN")=$$GET1^DIQ(409.852,MIENS,.02,"I")
+9 SET REQUEST("Request",NUM,"MRTC",COUNT,"ChildRequestSequenceNumber")=$$GET1^DIQ(409.85,CHILDIEN,43.1,"I")
End DoDot:1
+10 SET REQUEST("Request",NUM,"MRTCTotal")=COUNT
+11 QUIT
+12 ;
BUILDSDECONTACT(REQUEST,REQUESTIEN,NUM,REQUESTTYPE) ;get consult/recall
+1 NEW CONTACTIEN,SUBIEN,CIENS,COUNT,CONTARY,CONTACTYPE,CONTACTS,ERRORS
+2 SET COUNT=0
SET CONTACTIEN=0
+3 SET CONTACTIEN=$$GETCONTIEN^SDESCONTACTS(.ERRORS,REQUESTIEN,REQUESTTYPE)
+4 IF 'CONTACTIEN
SET REQUEST("Request",NUM,"Contact",1)=""
QUIT
+5 SET SUBIEN=$$GET1^DIQ(409.86,CONTACTIEN,2.2,"I")-1
+6 FOR
SET SUBIEN=$ORDER(^SDEC(409.86,CONTACTIEN,1,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+7 SET CIENS=SUBIEN_","_CONTACTIEN_","
+8 SET CONTACTYPE=$$GET1^DIQ(409.863,CIENS,1,"I")
+9 IF $LENGTH($GET(CONTACTYPE))
Begin DoDot:2
+10 SET CONTARY(CONTACTYPE)=$GET(CONTARY(CONTACTYPE))+1
+11 SET COUNT=COUNT+1
+12 SET REQUEST("Request",NUM,"SdecContactNumberOfCalls")=$GET(CONTARY("C"))
+13 SET REQUEST("Request",NUM,"SdecContactNumberOfEmailContact")=$GET(CONTARY("E"))
+14 SET REQUEST("Request",NUM,"SdecContactNumberOfTextContact")=$GET(CONTARY("T"))
+15 SET REQUEST("Request",NUM,"SdecContactNumberOfSecureMessage")=$GET(CONTARY("S"))
+16 SET REQUEST("Request",NUM,"SdecContactNumberOfLetters")=$GET(CONTARY("L"))
+17 if ($GET(CONTACTYPE)="L")
SET REQUEST("Request",NUM,"SdecContactDateOfLastLetterSent")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.863,CIENS,.01,"I"))
End DoDot:2
+18 if ('$DATA(REQUEST("Request",NUM,"SdecContactDateOfLastLetterSent")))
SET REQUEST("Request",NUM,"SdecContactDateOfLastLetterSent")=""
End DoDot:1
+19 SET REQUEST("Request",NUM,"SdecContactNumberOfContacts")=COUNT
+20 DO BLDCONTACT^SDESCONTACTS(.CONTACTS,CONTACTIEN)
+21 DO DISPMULT^SDESCONTACTS(.CONTACTS,CONTACTIEN)
+22 IF $DATA(CONTACTS)
MERGE REQUEST("Request",NUM)=CONTACTS
QUIT
+23 IF '$DATA(CONTACTS)
SET REQUEST("Request",NUM,"Contact",1)=""
+24 QUIT
BUILDCPRSPREREQS(REQUEST,REQUESTIEN,NUM) ;
+1 NEW SUBIEN,COUNT,PIENS
+2 SET SUBIEN=0
SET COUNT=0
+3 FOR
SET SUBIEN=$ORDER(^SDEC(409.85,REQUESTIEN,8,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+4 SET COUNT=COUNT+1
+5 SET PIENS=SUBIEN_","_REQUESTIEN_","
+6 SET REQUEST("Request",NUM,"CPRSPreRequisites",COUNT,"PreRequisite")=$$GET1^DIQ(409.8548,PIENS,.01,"E")
End DoDot:1
+7 QUIT
+8 ;
GETREQUEST(REQUEST,REQUESTIEN) ;
+1 NEW APPT,REQUESTARY,ERR,IENS,FN,REQDATA,NUM,CLINSTOPIEN,CLINCREDIEN
+2 SET FN=409.85
SET NUM=""
+3 SET NUM=$ORDER(REQUEST("Request",NUM),-1)+1
+4 SET IENS=REQUESTIEN_","
+5 DO GETS^DIQ(FN,IENS,"**","IE","REQDATA","ERR")
+6 if $DATA(ERR)
QUIT
+7 ; Check the AMIS Stop codes on clinic
+8 SET CLINSTOPIEN=$SELECT(REQDATA(FN,REQUESTIEN_",",8.5,"I")'="":REQDATA(FN,REQUESTIEN_",",8.5,"I"),1:$$GET1^DIQ(44,REQDATA(FN,REQUESTIEN_",",8,"I")_",",8,"I"))
+9 SET CLINCREDIEN=$SELECT(REQDATA(FN,REQUESTIEN_",",13.5,"I")'="":REQDATA(FN,REQUESTIEN_",",13.5,"I"),1:$$GET1^DIQ(44,REQDATA(FN,REQUESTIEN_",",8,"I")_",",2503,"I"))
+10 ;
+11 IF $DATA(^SDEC(409.85,REQUESTIEN,"PATCOM"))
DO BUILDPATCOMMENTS(.REQUEST,REQUESTIEN,NUM)
+12 IF '$DATA(^SDEC(409.85,REQUESTIEN,"PATCOM"))
SET REQUEST("Request",NUM,"PatientComment",1)=""
+13 ;
+14 IF $DATA(^SDEC(409.85,REQUESTIEN,1))
DO BUILDCOMMENTMULT(.REQUEST,REQUESTIEN,NUM)
+15 IF '$DATA(^SDEC(409.85,REQUESTIEN,1))
SET REQUEST("Request",NUM,"CommentMultiple",1)=""
+16 ;
+17 SET REQUEST("Request",NUM,"PatientContact",1)=""
+18 ;
+19 IF $DATA(^SDEC(409.85,REQUESTIEN,8))
DO BUILDCPRSPREREQS(.REQUEST,REQUESTIEN,NUM)
+20 IF '$DATA(^SDEC(409.85,REQUESTIEN,8))
SET REQUEST("Request",NUM,"CPRSPreRequisites",1)=""
+21 ;
+22 ;MRTCs
IF $DATA(^SDEC(409.85,REQUESTIEN,2))
DO BUILDMRTCS(.REQUEST,REQUESTIEN,NUM)
+23 IF '$DATA(^SDEC(409.85,REQUESTIEN,2))
SET REQUEST("Request",NUM,"MRTC",1)=""
+24 ;
+25 ;MRTC PIDs
IF $DATA(^SDEC(409.85,REQUESTIEN,5))
DO BUILDMRTCPIDS(.REQUEST,REQUESTIEN,NUM)
+26 ;
+27 IF $DATA(^SDEC(409.86,"SRP",REQUESTIEN))
DO BUILDSDECONTACT(.REQUEST,REQUESTIEN,NUM,"A")
+28 ;
+29 SET REQUEST("Request",NUM,"Type")="Appt Request"
+30 SET REQUEST("Request",NUM,"PatientIEN")=REQDATA(FN,REQUESTIEN_",",.01,"I")
+31 SET REQUEST("Request",NUM,"PatientICN")=$$GETPATICN^SDESINPUTVALUTL(REQDATA(FN,REQUESTIEN_",",.01,"I"))
+32 ;
SET REQUEST("Request",NUM,"PatientName")=REQDATA(FN,REQUESTIEN_",",.01,"E")
+33 SET REQUEST("Request",NUM,"RequestIEN")=REQUESTIEN
+34 SET REQUEST("Request",NUM,"RequestComments")=REQDATA(FN,REQUESTIEN_",",25,"E")
+35 SET REQUEST("Request",NUM,"CreateDate")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",1,"I"))
+36 SET REQUEST("Request",NUM,"InstitutionIEN")=REQDATA(FN,REQUESTIEN_",",2,"I")
+37 SET REQUEST("Request",NUM,"InstitutionName")=REQDATA(FN,REQUESTIEN_",",2,"E")
+38 SET REQUEST("Request",NUM,"InstitutionNumber")=$$GET1^DIQ(4,REQDATA(FN,REQUESTIEN_",",2,"I"),99)
+39 SET REQUEST("Request",NUM,"RequestSubType")=REQDATA(FN,REQUESTIEN_",",4,"E")
+40 SET REQUEST("Request",NUM,"ClinicIEN")=REQDATA(FN,REQUESTIEN_",",8,"I")
+41 SET REQUEST("Request",NUM,"ClinicName")=REQDATA(FN,REQUESTIEN_",",8,"E")
+42 SET REQUEST("Request",NUM,"ClinicStopCodeIEN")=CLINSTOPIEN
+43 SET REQUEST("Request",NUM,"ClinicStopCodeName")=$$GET1^DIQ(40.7,CLINSTOPIEN_",",.01,"E")
+44 SET REQUEST("Request",NUM,"ClinicStopCodeAMIS")=$$GET1^DIQ(40.7,CLINSTOPIEN_",",1,"E")
+45 SET REQUEST("Request",NUM,"ClinicSecondaryStopCodeIEN")=REQDATA(FN,REQUESTIEN_",",8.6,"I")
+46 SET REQUEST("Request",NUM,"ClinicSecondaryStopCodeName")=REQDATA(FN,REQUESTIEN_",",8.6,"E")
+47 SET REQUEST("Request",NUM,"ClinicSecondaryStopCodeAMIS")=$$GET1^DIQ(40.7,REQDATA(FN,REQUESTIEN_",",8.6,"I"),1)
+48 SET REQUEST("Request",NUM,"CreditStopCodeIEN")=CLINCREDIEN
+49 SET REQUEST("Request",NUM,"CreditStopCodeName")=$$GET1^DIQ(40.7,CLINCREDIEN_",",.01,"E")
+50 SET REQUEST("Request",NUM,"CreditStopCodeAMIS")=$$GET1^DIQ(40.7,CLINCREDIEN_",",1,"E")
+51 SET REQUEST("Request",NUM,"DisplayClinicAppt")=$$GET1^DIQ(44,REQDATA(FN,REQUESTIEN_",",8,"I")_",",62,"E")
+52 SET REQUEST("Request",NUM,"ApptType")=REQDATA(FN,REQUESTIEN_",",8.7,"E")
+53 SET REQUEST("Request",NUM,"EnteredByName")=REQDATA(FN,REQUESTIEN_",",9,"E")
+54 SET REQUEST("Request",NUM,"EnteredByIEN")=REQDATA(FN,REQUESTIEN_",",9,"I")
+55 SET REQUEST("Request",NUM,"DateTimeEntered")=$$FMTISO^SDAMUTDT($GET(REQDATA(FN,REQUESTIEN_",",9.5,"I")))
+56 SET REQUEST("Request",NUM,"Priority")=REQDATA(FN,REQUESTIEN_",",10,"E")
+57 SET REQUEST("Request",NUM,"EnrollmentPriorityGroup")=REQDATA(FN,REQUESTIEN_",",10.5,"E")
+58 SET REQUEST("Request",NUM,"ByPatientOrProvider")=REQDATA(FN,REQUESTIEN_",",11,"E")
+59 SET REQUEST("Request",NUM,"ProviderIEN")=REQDATA(FN,REQUESTIEN_",",12,"I")
+60 SET REQUEST("Request",NUM,"ProviderName")=REQDATA(FN,REQUESTIEN_",",12,"E")
+61 SET REQUEST("Request",NUM,"ProviderSecID")=$$GET1^DIQ(200,REQDATA(FN,REQUESTIEN_",",12,"I"),205.1)
+62 SET REQUEST("Request",NUM,"ScheduledDateOfAppt")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",13,"I"))
+63 SET REQUEST("Request",NUM,"DateLinkedApptMade")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",13.1,"I"))
+64 SET REQUEST("Request",NUM,"LinkedApptClinic")=REQDATA(FN,REQUESTIEN_",",13.2,"E")
+65 SET REQUEST("Request",NUM,"LinkedApptInstitutionName")=REQDATA(FN,REQUESTIEN_",",13.3,"E")
+66 SET REQUEST("Request",NUM,"LinkedApptStopCode")=REQDATA(FN,REQUESTIEN_",",13.4,"E")
+67 SET REQUEST("Request",NUM,"LinkedApptCreditStopCode")=REQDATA(FN,REQUESTIEN_",",13.5,"E")
+68 SET REQUEST("Request",NUM,"LinkedApptInstitutionNumber")=REQDATA(FN,REQUESTIEN_",",13.6,"I")
+69 SET REQUEST("Request",NUM,"LinkedApptEnteredBy")=REQDATA(FN,REQUESTIEN_",",13.7,"E")
+70 SET REQUEST("Request",NUM,"LinkedApptStatus")=REQDATA(FN,REQUESTIEN_",",13.8,"E")
+71 SET REQUEST("Request",NUM,"ServiceConnectedPercentage")=REQDATA(FN,REQUESTIEN_",",14,"E")
+72 SET REQUEST("Request",NUM,"PatientIndicatedDate")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",22,"I"))
+73 SET REQUEST("Request",NUM,"Status")=(REQDATA(FN,REQUESTIEN_",",23,"E"))
+74 SET REQUEST("Request",NUM,"MRTCNeeded")=REQDATA(409.85,REQUESTIEN_",",41,"E")
+75 SET REQUEST("Request",NUM,"MRTCDaysBetweenAppts")=REQDATA(409.85,REQUESTIEN_",",42,"E")
+76 SET REQUEST("Request",NUM,"MRTCHowManyNeeded")=REQDATA(409.85,REQUESTIEN_",",43,"E")
+77 SET REQUEST("Request",NUM,"EASTrackingNumber")=REQDATA(FN,REQUESTIEN_",",100,"E")
+78 SET REQUEST("Request",NUM,"DispositionedDate")=$$FMTISO^SDAMUTDT(REQDATA(FN,REQUESTIEN_",",19,"I"))
+79 SET REQUEST("Request",NUM,"DispositionedBy")=REQDATA(FN,REQUESTIEN_",",20,"I")
+80 SET REQUEST("Request",NUM,"DispositionedBy")=REQDATA(FN,REQUESTIEN_",",20,"E")
+81 SET REQUEST("Request",NUM,"DispositionReason")=REQDATA(FN,REQUESTIEN_",",21,"E")
+82 SET REQUEST("Request",NUM,"DispositionIEN")=REQDATA(FN,REQUESTIEN_",",21,"I")
+83 SET REQUEST("Request",NUM,"ServiceConnectedPriority")=REQDATA(FN,REQUESTIEN_",",15,"E")
+84 SET REQUEST("Request",NUM,"PatientStatus")=REQDATA(FN,REQUESTIEN_",",.02,"E")
+85 SET REQUEST("Request",NUM,"ChildRequestSequenceNumber")=$$GET1^DIQ(409.85,REQUESTIEN,43.1,"I")
+86 SET REQUEST("Request",NUM,"ParentRequest")=REQDATA(FN,REQUESTIEN_",",43.8,"I")
+87 SET REQUEST("Request",NUM,"ModalityName")=REQDATA(FN,REQUESTIEN_",",6,"E")
+88 SET REQUEST("Request",NUM,"ModalityCode")=REQDATA(FN,REQUESTIEN_",",6,"I")
+89 SET REQUEST("Request",NUM,"CPRSOrderID")=REQDATA(FN,REQUESTIEN_",",46,"I")
+90 SET REQUEST("Request",NUM,"CPRSTimeSensitive")=REQDATA(FN,REQUESTIEN_",",47,"I")
+91 SET REQUEST("Request",NUM,"PIDChangeAllowed")=$SELECT(+$GET(REQDATA(FN,REQUESTIEN_",",49,"I"))=1:1,1:0)
+92 SET REQUEST("Request",NUM,"PatientLast4")=$$LAST4SSN^SDESINPUTVALUTL(REQDATA(FN,REQUESTIEN_",",.01,"I"))
+93 ;
+94 DO FINISHAPPTREQ^SDESGETAPPTREQ2(.REQUEST,NUM,REQUESTIEN)
+95 ; build recall and consult
+96 DO RECALL^SDESGETREQWRAPPR(.REQUEST,NUM)
+97 DO CONSULT^SDESGETREQWRAPPR(.REQUEST,NUM)
+98 QUIT
+99 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 NEW JSONERROR
+2 DO ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
+3 QUIT
+4 ;