SDESCREATEAPPREQ ;ALB/BLB,MGD,BLB,BWF,MGD,LAB,MGD,JAS,BLB,MGD,JDJ,JAS,JAS - SCHEDULING APPOINTMENT REQUEST RPCS; APR 2, 2024
;;5.3;Scheduling;**823,826,833,835,837,843,844,846,847,864,869,871,875**;Aug 13, 1993;Build 25
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
; RPC: SDES CREATE APPT REQ
;
CREATEREQUEST(JSONRETURN,REQUEST) ;
N REQUESTIEN,ERRORS,RETURN,ISDFNVALID,ISDATETIMEVALID,ISMODALINVALID,ISEASVALID,INSTITUTIONIEN
N ISCLINSTOPVALID,ISREQUESTBYVALID,ISPROVIDERVALID,ISMODALITYVALID,ISPIDVALID,ISPRIGROUPVALID
N ISREQTYPEVALID,ISPRIORITYVALID,ISSERVCONNVALID,ISAPPTTYPEVALID,ISAPPTNAMEVALID,ISPATSTATVALID
N ISDATEPREFVALID,ISMTRCDATAVALID,ISCPRSDATAVALID
;
D VALIDATE(.REQUEST,.INSTITUTIONIEN,.ERRORS)
;
I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
;
D CONVERTSTOPCODE(.REQUEST)
;
S REQUESTIEN=$$BUILDER(.REQUEST,INSTITUTIONIEN)
;
S RETURN("Request","IEN")=$G(REQUESTIEN)
;
D BUILDJSON(.JSONRETURN,.RETURN)
Q
;
VALIDATE(REQUEST,INSTITUTIONIEN,ERRORS) ;
;
S ISDFNVALID=$$VALIDATEDFN^SDESCRTAPPREQVAL(.ERRORS,$G(REQUEST("DFN")))
S ISDATETIMEVALID=$$VALIDATEDATETIME^SDESCRTAPPREQVAL(.ERRORS,.REQUEST)
S ISREQTYPEVALID=$$VALIDATEREQTYPE^SDESCRTAPPREQVAL(.ERRORS,$G(REQUEST("REQUEST SUB TYPE")))
S INSTITUTIONIEN=$$STATIONTOINST^SDESCRTAPPREQVAL(.ERRORS,$G(REQUEST("STATION NUMBER")),$G(REQUEST("INSTITUTION NAME")))
S ISCLINSTOPVALID=$$VALIDATECLINSTOP^SDESCRTAPPREQVAL(.ERRORS,$G(REQUEST("CLINIC IEN")),$G(REQUEST("STOP CODE")),$G(REQUEST("SECONDARY STOP CODE")))
S ISREQUESTBYVALID=$$VALIDATEREQBY^SDESCRTAPPREQVAL(.ERRORS,$G(REQUEST("REQUESTED BY")))
I $G(REQUEST("REQUESTED BY"))=1 S ISPROVIDERVALID=$$VALIDATEPROVIDER(.ERRORS,$G(REQUEST("PROVIDER IEN")))
I $G(REQUEST("REQUESTED BY"))'=1 S REQUEST("PROVIDER IEN")=""
S ISPIDVALID=$$VALIDATEPID(.ERRORS,.REQUEST)
S ISEASVALID=$$VALIDATEEAS(.ERRORS,$G(REQUEST("EAS")))
I $L($G(REQUEST("MODALITY"))) S ISMODALINVALID=$$VALIDATEMODALITY^SDESINPUTVALUTL(.ERRORS,$G(REQUEST("MODALITY")))
S ISPRIORITYVALID=$$VALIDATEPRIORITY(.ERRORS,$G(REQUEST("PRIORITY")))
I $L($G(REQUEST("PRIORITY GROUP"))) S ISPRIGROUPVALID=$$VALIDATEPRIGROUP(.ERRORS,$G(REQUEST("PRIORITY GROUP")))
S ISSERVCONNVALID=$$VALIDATESERVCONN(.ERRORS,$G(REQUEST("SERVICE CONNECTED")),$G(REQUEST("SERVICE CONNECTED PERCENTAGE")))
;
N SDIEN,SDNAME
S SDIEN=$G(REQUEST("APPOINTMENT TYPE IEN")),SDNAME=$G(REQUEST("APPOINTMENT TYPE NAME"))
S ISAPPTTYPEVALID=$$VALIDATEAPPTTYPE(.ERRORS,.SDIEN,SDNAME)
S REQUEST("APPOINTMENT TYPE IEN")=SDIEN
I $L($G(REQUEST("PATIENT STATUS"))) S ISPATSTATVALID=$$VALIDATEPATSTAT(.ERRORS,$G(REQUEST("PATIENT STATUS")))
I $D(REQUEST("PATIENT PREFERRED START DATE")),$D(REQUEST("PATIENT PREFERRED END DATE")) D VALIDATEDATEPREF(.ERRORS,.REQUEST)
I $D(REQUEST("MRTC")) D VALIDATEMRTCDATA(.ERRORS,.REQUEST,$G(REQUEST("MRTC","PARENT REQUEST")),$G(REQUEST("MRTC","NEEDED")),$G(REQUEST("MRTC","DAYS BETWEEN APPTS")),$G(REQUEST("MRTC","HOW MANY NEEDED")),$G(REQUEST("DFN")))
I $G(REQUEST("MRTC","PARENT REQUEST")),$G(REQUEST("DFN")) S REQUEST("MRTC","CHILD SEQUENCE NUMBER")=$$MRTCHILDSEQUENCE($G(REQUEST("MRTC","PARENT REQUEST")),$G(REQUEST("DFN")))
;
Q
;
CONVERTSTOPCODE(REQUEST) ;
I $D(REQUEST("STOP CODE")) S REQUEST("STOP CODE")=$$FIND1^DIC(40.7,"","X",REQUEST("STOP CODE"),"C")
I $D(REQUEST("SECONDARY STOP CODE")) S REQUEST("SECONDARY STOP CODE")=$$FIND1^DIC(40.7,"","X",REQUEST("SECONDARY STOP CODE"),"C")
Q
;
BUILDER(REQ,INSTITUTIONIEN) ;
N FDA,RETURNIEN
S FDA(409.85,"+1,",.01)=$G(REQ("DFN"))
S FDA(409.85,"+1,",.02)=$G(REQ("PATIENT STATUS"))
S FDA(409.85,"+1,",1)=$G(REQ("CREATE DATE"))
S FDA(409.85,"+1,",2)=$G(INSTITUTIONIEN)
S FDA(409.85,"+1,",4)=$G(REQ("REQUEST SUB TYPE"))
S FDA(409.85,"+1,",5)=$G(REQ("VAOS GUID"))
S FDA(409.85,"+1,",6)=$G(REQ("MODALITY"))
S FDA(409.85,"+1,",8)=$G(REQ("CLINIC IEN"))
S FDA(409.85,"+1,",8.5)=$G(REQ("STOP CODE"))
S FDA(409.85,"+1,",8.6)=$G(REQ("SECONDARY STOP CODE"))
S FDA(409.85,"+1,",8.7)=$G(REQ("APPOINTMENT TYPE IEN"))
S FDA(409.85,"+1,",9)=$G(DUZ)
S FDA(409.85,"+1,",9.5)=$$NOW^XLFDT
S FDA(409.85,"+1,",10)=$G(REQ("PRIORITY"))
S FDA(409.85,"+1,",10.5)=$G(REQ("PRIORITY GROUP"))
S FDA(409.85,"+1,",11)=$G(REQ("REQUESTED BY"))
S FDA(409.85,"+1,",12)=$G(REQ("PROVIDER IEN"))
S FDA(409.85,"+1,",14)=$G(REQ("SERVICE CONNECTED PERCENTAGE"))
S FDA(409.85,"+1,",15)=$G(REQ("SERVICE CONNECTED"))
S FDA(409.85,"+1,",22)=$G(REQ("PATIENT INDICATED DATE"))
S FDA(409.85,"+1,",23)="O"
S FDA(409.85,"+1,",25)=$G(REQ("REQUEST COMMENT"))
S FDA(409.85,"+1,",41)=$G(REQ("MRTC","NEEDED"))
S FDA(409.85,"+1,",42)=$G(REQ("MRTC","DAYS BETWEEN APPTS"))
S FDA(409.85,"+1,",43)=$G(REQ("MRTC","HOW MANY NEEDED"))
S FDA(409.85,"+1,",43.1)=$G(REQ("MRTC","CHILD SEQUENCE NUMBER"))
S FDA(409.85,"+1,",43.8)=$G(REQ("MRTC","PARENT REQUEST"))
S FDA(409.85,"+1,",46)=$G(REQ("CPRS ORDER NUMBER"))
S FDA(409.85,"+1,",47)=$S($G(REQ("CPRS TIME SENSITIVE"))="YES":"1",$G(REQ("CPRS TIME SENSITIVE"))="NO":"0",1:"")
S FDA(409.85,"+1,",49)=$G(REQ("PID CHANGE ALLOWED"))
S FDA(409.85,"+1,",100)=$G(REQ("EAS"))
;
D UPDATE^DIE("","FDA","RETURNIEN") K FDA
S REQUESTIEN=$G(RETURNIEN(1))
;
D ADDPIDHISTORY(REQUESTIEN,$G(REQ("PATIENT INDICATED DATE")))
;
I $D(REQ("CPRS PREREQUISITES")) D BUILDCPRSPREREQS(.REQ,REQUESTIEN)
;
I $D(REQ("MRTC","PARENT REQUEST"))&($G(REQUESTIEN)'="") D ADDMRTCMULT(REQUESTIEN,REQ("MRTC","PARENT REQUEST"),REQ("PATIENT INDICATED DATE"))
;
I ($D(REQ("PATIENT COMMENT")))!($D(REQ("PATIENT PREFERRED START DATE"))) D BUILDCOMMENTS(.REQ,REQUESTIEN)
;
D AUDIT(REQUESTIEN,$G(REQ("CLINIC IEN")),$G(REQ("STOP CODE")))
;
Q REQUESTIEN
;
ADDPIDHISTORY(REQUESTIEN,PID) ;
N PIDFDA,FDA,OLDPID,PARENTIEN
;
I PID=$$GET1^DIQ(409.854,$O(^SDEC(409.85,REQUESTIEN,10,"A"),-1)_","_REQUESTIEN_",",1,"I") Q
;
S PIDFDA(409.854,"+1,"_REQUESTIEN_",",.01)=$$NOW^XLFDT
S PIDFDA(409.854,"+1,"_REQUESTIEN_",",1)=PID
S PIDFDA(409.854,"+1,"_REQUESTIEN_",",2)=$$GET1^DIQ(200,$G(DUZ),.01,"E")
D UPDATE^DIE(,"PIDFDA") K PIDFDA
;
S OLDPID=$$GET1^DIQ(409.85,REQUESTIEN_",",22,"I")
S PARENTIEN=$$GET1^DIQ(409.85,REQUESTIEN_",",43.8,"I")
;
S FDA(409.85,REQUESTIEN_",",22)=PID
D FILE^DIE(,"FDA") K FDA
;
I PARENTIEN,$D(^SDEC(409.85,PARENTIEN)) D
. N PREFIEN S PREFIEN=$O(^SDEC(409.85,PARENTIEN,5,"B",OLDPID,0))
. S FDA(409.851,PREFIEN_","_PARENTIEN_",",.01)=PID
. D FILE^DIE(,"FDA") K FDA
Q
;
ADDMRTCMULT(CHILD,PARENT,PATIENTINDDATE) ;Update the MRTC subfiles
D ADDMRTCLINKS(CHILD,PARENT)
D ADDMRTCPIDLINKS(PARENT,PATIENTINDDATE)
Q
;
ADDMRTCLINKS(CHILD,PARENT) ;
N FDA
Q:$O(^SDEC(409.85,PARENT,2,"B",CHILD))
S FDA(409.852,"+1,"_PARENT_",",.01)=CHILD
D UPDATE^DIE(,"FDA") K FDA
Q
;
ADDMRTCPIDLINKS(PARENT,PATIENTINDDATE) ;
N SDFDA
Q:$O(^SDEC(409.85,PARENT,5,"B",PATIENTINDDATE,0))
S SDFDA(409.851,"+1,"_PARENT_",",.01)=PATIENTINDDATE
D UPDATE^DIE("","SDFDA") K SDFDA
Q
;
MRTCHILDSEQUENCE(PARENTREQUESTIEN,DFN) ; return next sequence # for child mrtc
N COUNT,REQUESTIEN,IENS,NEXTSEQUENCENUM,CHILD,LASTCHILD
S REQUESTIEN=0,COUNT=0,LASTCHILD=""
F S REQUESTIEN=$O(^SDEC(409.85,"B",DFN,REQUESTIEN)) Q:'REQUESTIEN D
.I $$GET1^DIQ(409.85,REQUESTIEN,43.8,"I")=PARENTREQUESTIEN D
..S COUNT=COUNT+1
..S CHILD(REQUESTIEN)=COUNT
I $D(CHILD) D
.S LASTCHILD=$O(CHILD(LASTCHILD),-1)
.S NEXTSEQUENCENUM=$G(CHILD($G(LASTCHILD)))+1
I '$D(CHILD) S NEXTSEQUENCENUM=1
Q NEXTSEQUENCENUM
;
AUDIT(REQUESTIEN,CLINICIEN,STOPCODE) ;
N FDA
S FDA(409.8545,"+1,"_REQUESTIEN_",",.01)=$$NOW^XLFDT
S FDA(409.8545,"+1,"_REQUESTIEN_",",1)=$G(DUZ)
S FDA(409.8545,"+1,"_REQUESTIEN_",",2)=$G(CLINICIEN)
S FDA(409.8545,"+1,"_REQUESTIEN_",",3)=$G(STOPCODE)
D UPDATE^DIE("","FDA") K FDA
Q
N REQCOMMS,NUM,NUM2,DONE,PREFDATES,PATCOMMS,RANGE,COUNT
S NUM=0
;
I $D(REQUEST("PATIENT COMMENT")) D
.D WP^SDECUTL(.PATCOMMS,$G(REQUEST("PATIENT COMMENT")))
.D WP^DIE(409.85,REQUESTIEN_",",60,"","PATCOMMS")
;
I '$G(REQUEST("PATIENT PREFERRED START DATE",1)) Q
;
S NUM=0,COUNT="",COUNT=$O(REQUEST("PATIENT PREFERRED START DATE",COUNT),-1)
F NUM=1:1:COUNT D
.S STARTDATE=$G(REQUEST("PATIENT PREFERRED START DATE",NUM))
.S ENDDATE=$G(REQUEST("PATIENT PREFERRED END DATE",NUM))
.S STARTDATE=$$ISOTFM^SDAMUTDT(STARTDATE),STARTDATE=$$FMTE^XLFDT(STARTDATE)
.S ENDDATE=$$ISOTFM^SDAMUTDT(ENDDATE),ENDDATE=$$FMTE^XLFDT(ENDDATE)
.S RANGE(NUM)="Patient preferred date range #"_NUM_": "_STARTDATE_" to "_ENDDATE
D WP^DIE(409.85,REQUESTIEN_",",60,"A","RANGE")
Q
;
BUILDCPRSPREREQS(REQUEST,REQUESTIEN) ;
N NUM,FDA
S NUM=0
F S NUM=$O(REQUEST("CPRS PREREQUISITES",NUM)) Q:'NUM D
.S FDA(409.8548,"+1,"_REQUESTIEN_",",.01)=$G(REQUEST("CPRS PREREQUISITES",NUM))
.D UPDATE^DIE(,"FDA") K FDA
Q
;
VALIDATEPROVIDER(ERRORS,PROVIDERIEN) ;
I PROVIDERIEN="" D ERRLOG^SDESJSON(.ERRORS,53) Q 0
I PROVIDERIEN'="",'$D(^VA(200,PROVIDERIEN,0)) D ERRLOG^SDESJSON(.ERRORS,54) Q 0
Q 1
;
VALIDATEPID(ERRORS,REQUEST) ;
I $G(REQUEST("PATIENT INDICATED DATE"))="" D ERRLOG^SDESJSON(.ERRORS,159) Q 0
I $G(REQUEST("PATIENT INDICATED DATE"))'="" S REQUEST("PATIENT INDICATED DATE")=$$ISOTFM^SDAMUTDT($G(REQUEST("PATIENT INDICATED DATE")))
I $G(REQUEST("PATIENT INDICATED DATE"))=-1 D ERRLOG^SDESJSON(.ERRORS,160) 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
;
VALIDATEPRIORITY(ERRORS,PRIORITY) ;
I PRIORITY="" S PRIORITY="ASAP"
I PRIORITY'="ASAP",PRIORITY'="FUTURE" D ERRLOG^SDESJSON(.ERRORS,211) Q 0
S REQUEST("PRIORITY")=$S(PRIORITY="ASAP":"A",PRIORITY="FUTURE":"F",1:"")
Q 1
;
VALIDATEPRIGROUP(ERRORS,GROUP) ;
N NUM,FOUND,GCHECK
S NUM=0,FOUND=0
F NUM=1:1:8 D
.S GCHECK="GROUP "_NUM
.I GROUP=GCHECK S REQUEST("PRIORITY GROUP")=NUM S FOUND=1
I FOUND=0 D ERRLOG^SDESJSON(.ERRORS,199) Q 0
Q 1
;
VALIDATESERVCONN(ERRORS,SERVCONN,SERVCONNPERC) ;
I $L(SERVCONN),SERVCONN'="YES",SERVCONN'="NO" D ERRLOG^SDESJSON(.ERRORS,200) Q 0
I $G(SERVCONNPERC),'+SERVCONNPERC!(SERVCONNPERC'>0)!(SERVCONNPERC'<101) D ERRLOG^SDESJSON(.ERRORS,201) Q 0
;I $G(SERVCONN)="NO",+$G(SERVCONNPERC) D ERRLOG^SDESJSON(.ERRORS,232) Q 0
S REQUEST("SERVICE CONNECTED")=$S(SERVCONN="YES":"1",SERVCONN="NO":"0",1:"")
Q 1
;
VALIDATEAPPTTYPE(ERRORS,APPTTYPEIEN,APPTTYPENAME) ;
I APPTTYPEIEN="",APPTTYPENAME="" D ERRLOG^SDESJSON(.ERRORS,306) Q 0
N APPTTYPIEN
S APPTTYPIEN=0
I $G(APPTTYPENAME)'="" D I 'APPTTYPIEN Q 0
. S APPTTYPIEN=$$FIND1^DIC(409.1,"","X",APPTTYPENAME,"B")
. I 'APPTTYPIEN D ERRLOG^SDESJSON(.ERRORS,180)
I APPTTYPIEN S APPTTYPEIEN=APPTTYPIEN Q 1
I APPTTYPEIEN'="",'$D(^SD(409.1,APPTTYPEIEN,0)) D ERRLOG^SDESJSON(.ERRORS,180)
Q 0
;
VALIDATEPATSTAT(ERRORS,PATIENTSTATUS) ;
I PATIENTSTATUS'="NEW",PATIENTSTATUS'="ESTABLISHED" D ERRLOG^SDESJSON(.ERRORS,203) Q 0
S REQUEST("PATIENT STATUS")=$S(PATIENTSTATUS="NEW":"N",PATIENTSTATUS="ESTABLISHED":"E",1:"")
Q 1
;
VALIDATEDATEPREF(ERRORS,REQUEST) ;
N ARYIEN,ARYIEN2,DATE,ERR,STARTDATE,ENDDATE
S ARYIEN=0,ERR=0
F S ARYIEN=$O(REQUEST("PATIENT PREFERRED START DATE",ARYIEN)) Q:'ARYIEN!($G(ERR)) D
.S STARTDATE=$G(REQUEST("PATIENT PREFERRED START DATE",ARYIEN))
.S STARTDATE=$$ISOTFM^SDAMUTDT(STARTDATE)
.I STARTDATE=-1!($L(STARTDATE,".")=1) S ERR=1 D ERRLOG^SDESJSON(.ERRORS,206) Q
.S ARYIEN2=0
.F S ARYIEN2=$O(REQUEST("PATIENT PREFERRED END DATE",ARYIEN2)) Q:'ARYIEN2 D
..S ENDDATE=$G(REQUEST("PATIENT PREFERRED END DATE",ARYIEN2))
..S ENDDATE=$$ISOTFM^SDAMUTDT(ENDDATE)
..I ENDDATE=-1!($L(ENDDATE,".")=1) S ERR=1 D ERRLOG^SDESJSON(.ERRORS,206) Q
I $G(REQUEST("PATIENT PREFERRED START DATE",1)),'$G(REQUEST("PATIENT PREFERRED END DATE",1)) D ERRLOG^SDESJSON(.ERRORS,195) Q 0
I $G(REQUEST("PATIENT PREFERRED START DATE",2)),'$G(REQUEST("PATIENT PREFERRED END DATE",2)) D ERRLOG^SDESJSON(.ERRORS,195) Q 0
I $G(REQUEST("PATIENT PREFERRED START DATE",3)),'$G(REQUEST("PATIENT PREFERRED END DATE",3)) D ERRLOG^SDESJSON(.ERRORS,195) Q 0
Q
;
VALIDATEMRTCDATA(ERRORS,REQUEST,PARENTREQUEST,NEEDED,DAYSBETWEEN,HOWMANY,REQDFN) ;
N NUM,DONE
I PARENTREQUEST,$$GET1^DIQ(409.85,PARENTREQUEST,.01,"I")'=REQDFN D ERRLOG^SDESJSON(.ERRORS,533)
I NEEDED'="",NEEDED'="YES",NEEDED'="NO" D ERRLOG^SDESJSON(.ERRORS,208) Q
S REQUEST("MRTC","NEEDED")=$S(NEEDED="YES":1,NEEDED="NO":0,1:"")
I REQUEST("MRTC","NEEDED")'=1 D Q ""
.I $G(PARENTREQUEST)!($G(DAYSBETWEEN))!($G(HOWMANY)) D ERRLOG^SDESJSON(.ERRORS,233)
Q 1
;
;
I PARENTREQUEST'="",('$D(^SDEC(409.85,PARENTREQUEST)))!(PARENTREQUEST=0) D ERRLOG^SDESJSON(.ERRORS,207)
;
I DAYSBETWEEN'="" D
.I '+DAYSBETWEEN!(DAYSBETWEEN'<366) D ERRLOG^SDESJSON(.ERRORS,209)
;
I HOWMANY'="" D
.I '+HOWMANY!(HOWMANY'<101) D ERRLOG^SDESJSON(.ERRORS,210)
Q
;
BUILDJSON(JSONRETURN,RETURN) ;.
N JSONERROR
D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERR")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCREATEAPPREQ 13067 printed Dec 13, 2024@02:56:21 Page 2
SDESCREATEAPPREQ ;ALB/BLB,MGD,BLB,BWF,MGD,LAB,MGD,JAS,BLB,MGD,JDJ,JAS,JAS - SCHEDULING APPOINTMENT REQUEST RPCS; APR 2, 2024
+1 ;;5.3;Scheduling;**823,826,833,835,837,843,844,846,847,864,869,871,875**;Aug 13, 1993;Build 25
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
+6 ; RPC: SDES CREATE APPT REQ
+7 ;
CREATEREQUEST(JSONRETURN,REQUEST) ;
+1 NEW REQUESTIEN,ERRORS,RETURN,ISDFNVALID,ISDATETIMEVALID,ISMODALINVALID,ISEASVALID,INSTITUTIONIEN
+2 NEW ISCLINSTOPVALID,ISREQUESTBYVALID,ISPROVIDERVALID,ISMODALITYVALID,ISPIDVALID,ISPRIGROUPVALID
+3 NEW ISREQTYPEVALID,ISPRIORITYVALID,ISSERVCONNVALID,ISAPPTTYPEVALID,ISAPPTNAMEVALID,ISPATSTATVALID
+4 NEW ISDATEPREFVALID,ISMTRCDATAVALID,ISCPRSDATAVALID
+5 ;
+6 DO VALIDATE(.REQUEST,.INSTITUTIONIEN,.ERRORS)
+7 ;
+8 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+9 ;
+10 DO CONVERTSTOPCODE(.REQUEST)
+11 ;
+12 SET REQUESTIEN=$$BUILDER(.REQUEST,INSTITUTIONIEN)
+13 ;
+14 SET RETURN("Request","IEN")=$GET(REQUESTIEN)
+15 ;
+16 DO BUILDJSON(.JSONRETURN,.RETURN)
+17 QUIT
+18 ;
VALIDATE(REQUEST,INSTITUTIONIEN,ERRORS) ;
+1 ;
+2 SET ISDFNVALID=$$VALIDATEDFN^SDESCRTAPPREQVAL(.ERRORS,$GET(REQUEST("DFN")))
+3 SET ISDATETIMEVALID=$$VALIDATEDATETIME^SDESCRTAPPREQVAL(.ERRORS,.REQUEST)
+4 SET ISREQTYPEVALID=$$VALIDATEREQTYPE^SDESCRTAPPREQVAL(.ERRORS,$GET(REQUEST("REQUEST SUB TYPE")))
+5 SET INSTITUTIONIEN=$$STATIONTOINST^SDESCRTAPPREQVAL(.ERRORS,$GET(REQUEST("STATION NUMBER")),$GET(REQUEST("INSTITUTION NAME")))
+6 SET ISCLINSTOPVALID=$$VALIDATECLINSTOP^SDESCRTAPPREQVAL(.ERRORS,$GET(REQUEST("CLINIC IEN")),$GET(REQUEST("STOP CODE")),$GET(REQUEST("SECONDARY STOP CODE")))
+7 SET ISREQUESTBYVALID=$$VALIDATEREQBY^SDESCRTAPPREQVAL(.ERRORS,$GET(REQUEST("REQUESTED BY")))
+8 IF $GET(REQUEST("REQUESTED BY"))=1
SET ISPROVIDERVALID=$$VALIDATEPROVIDER(.ERRORS,$GET(REQUEST("PROVIDER IEN")))
+9 IF $GET(REQUEST("REQUESTED BY"))'=1
SET REQUEST("PROVIDER IEN")=""
+10 SET ISPIDVALID=$$VALIDATEPID(.ERRORS,.REQUEST)
+11 SET ISEASVALID=$$VALIDATEEAS(.ERRORS,$GET(REQUEST("EAS")))
+12 IF $LENGTH($GET(REQUEST("MODALITY")))
SET ISMODALINVALID=$$VALIDATEMODALITY^SDESINPUTVALUTL(.ERRORS,$GET(REQUEST("MODALITY")))
+13 SET ISPRIORITYVALID=$$VALIDATEPRIORITY(.ERRORS,$GET(REQUEST("PRIORITY")))
+14 IF $LENGTH($GET(REQUEST("PRIORITY GROUP")))
SET ISPRIGROUPVALID=$$VALIDATEPRIGROUP(.ERRORS,$GET(REQUEST("PRIORITY GROUP")))
+15 SET ISSERVCONNVALID=$$VALIDATESERVCONN(.ERRORS,$GET(REQUEST("SERVICE CONNECTED")),$GET(REQUEST("SERVICE CONNECTED PERCENTAGE")))
+16 ;
+17 NEW SDIEN,SDNAME
+18 SET SDIEN=$GET(REQUEST("APPOINTMENT TYPE IEN"))
SET SDNAME=$GET(REQUEST("APPOINTMENT TYPE NAME"))
+19 SET ISAPPTTYPEVALID=$$VALIDATEAPPTTYPE(.ERRORS,.SDIEN,SDNAME)
+20 SET REQUEST("APPOINTMENT TYPE IEN")=SDIEN
+21 IF $LENGTH($GET(REQUEST("PATIENT STATUS")))
SET ISPATSTATVALID=$$VALIDATEPATSTAT(.ERRORS,$GET(REQUEST("PATIENT STATUS")))
+22 IF $DATA(REQUEST("PATIENT PREFERRED START DATE"))
IF $DATA(REQUEST("PATIENT PREFERRED END DATE"))
DO VALIDATEDATEPREF(.ERRORS,.REQUEST)
+23 IF $DATA(REQUEST("MRTC"))
DO VALIDATEMRTCDATA(.ERRORS,.REQUEST,$GET(REQUEST("MRTC","PARENT REQUEST")),$GET(REQUEST("MRTC","NEEDED")),$GET(REQUEST("MRTC","DAYS BETWEEN APPTS")),$GET(REQUEST("MRTC","HOW MANY NEEDED")),$GET(REQUEST("DFN")))
+24 IF $GET(REQUEST("MRTC","PARENT REQUEST"))
IF $GET(REQUEST("DFN"))
SET REQUEST("MRTC","CHILD SEQUENCE NUMBER")=$$MRTCHILDSEQUENCE($GET(REQUEST("MRTC","PARENT REQUEST")),$GET(REQUEST("DFN")))
+25 ;
+26 QUIT
+27 ;
CONVERTSTOPCODE(REQUEST) ;
+1 IF $DATA(REQUEST("STOP CODE"))
SET REQUEST("STOP CODE")=$$FIND1^DIC(40.7,"","X",REQUEST("STOP CODE"),"C")
+2 IF $DATA(REQUEST("SECONDARY STOP CODE"))
SET REQUEST("SECONDARY STOP CODE")=$$FIND1^DIC(40.7,"","X",REQUEST("SECONDARY STOP CODE"),"C")
+3 QUIT
+4 ;
BUILDER(REQ,INSTITUTIONIEN) ;
+1 NEW FDA,RETURNIEN
+2 SET FDA(409.85,"+1,",.01)=$GET(REQ("DFN"))
+3 SET FDA(409.85,"+1,",.02)=$GET(REQ("PATIENT STATUS"))
+4 SET FDA(409.85,"+1,",1)=$GET(REQ("CREATE DATE"))
+5 SET FDA(409.85,"+1,",2)=$GET(INSTITUTIONIEN)
+6 SET FDA(409.85,"+1,",4)=$GET(REQ("REQUEST SUB TYPE"))
+7 SET FDA(409.85,"+1,",5)=$GET(REQ("VAOS GUID"))
+8 SET FDA(409.85,"+1,",6)=$GET(REQ("MODALITY"))
+9 SET FDA(409.85,"+1,",8)=$GET(REQ("CLINIC IEN"))
+10 SET FDA(409.85,"+1,",8.5)=$GET(REQ("STOP CODE"))
+11 SET FDA(409.85,"+1,",8.6)=$GET(REQ("SECONDARY STOP CODE"))
+12 SET FDA(409.85,"+1,",8.7)=$GET(REQ("APPOINTMENT TYPE IEN"))
+13 SET FDA(409.85,"+1,",9)=$GET(DUZ)
+14 SET FDA(409.85,"+1,",9.5)=$$NOW^XLFDT
+15 SET FDA(409.85,"+1,",10)=$GET(REQ("PRIORITY"))
+16 SET FDA(409.85,"+1,",10.5)=$GET(REQ("PRIORITY GROUP"))
+17 SET FDA(409.85,"+1,",11)=$GET(REQ("REQUESTED BY"))
+18 SET FDA(409.85,"+1,",12)=$GET(REQ("PROVIDER IEN"))
+19 SET FDA(409.85,"+1,",14)=$GET(REQ("SERVICE CONNECTED PERCENTAGE"))
+20 SET FDA(409.85,"+1,",15)=$GET(REQ("SERVICE CONNECTED"))
+21 SET FDA(409.85,"+1,",22)=$GET(REQ("PATIENT INDICATED DATE"))
+22 SET FDA(409.85,"+1,",23)="O"
+23 SET FDA(409.85,"+1,",25)=$GET(REQ("REQUEST COMMENT"))
+24 SET FDA(409.85,"+1,",41)=$GET(REQ("MRTC","NEEDED"))
+25 SET FDA(409.85,"+1,",42)=$GET(REQ("MRTC","DAYS BETWEEN APPTS"))
+26 SET FDA(409.85,"+1,",43)=$GET(REQ("MRTC","HOW MANY NEEDED"))
+27 SET FDA(409.85,"+1,",43.1)=$GET(REQ("MRTC","CHILD SEQUENCE NUMBER"))
+28 SET FDA(409.85,"+1,",43.8)=$GET(REQ("MRTC","PARENT REQUEST"))
+29 SET FDA(409.85,"+1,",46)=$GET(REQ("CPRS ORDER NUMBER"))
+30 SET FDA(409.85,"+1,",47)=$SELECT($GET(REQ("CPRS TIME SENSITIVE"))="YES":"1",$GET(REQ("CPRS TIME SENSITIVE"))="NO":"0",1:"")
+31 SET FDA(409.85,"+1,",49)=$GET(REQ("PID CHANGE ALLOWED"))
+32 SET FDA(409.85,"+1,",100)=$GET(REQ("EAS"))
+33 ;
+34 DO UPDATE^DIE("","FDA","RETURNIEN")
KILL FDA
+35 SET REQUESTIEN=$GET(RETURNIEN(1))
+36 ;
+37 DO ADDPIDHISTORY(REQUESTIEN,$GET(REQ("PATIENT INDICATED DATE")))
+38 ;
+39 IF $DATA(REQ("CPRS PREREQUISITES"))
DO BUILDCPRSPREREQS(.REQ,REQUESTIEN)
+40 ;
+41 IF $DATA(REQ("MRTC","PARENT REQUEST"))&($GET(REQUESTIEN)'="")
DO ADDMRTCMULT(REQUESTIEN,REQ("MRTC","PARENT REQUEST"),REQ("PATIENT INDICATED DATE"))
+42 ;
+43 IF ($DATA(REQ("PATIENT COMMENT")))!($DATA(REQ("PATIENT PREFERRED START DATE")))
DO BUILDCOMMENTS(.REQ,REQUESTIEN)
+44 ;
+45 DO AUDIT(REQUESTIEN,$GET(REQ("CLINIC IEN")),$GET(REQ("STOP CODE")))
+46 ;
+47 QUIT REQUESTIEN
+48 ;
ADDPIDHISTORY(REQUESTIEN,PID) ;
+1 NEW PIDFDA,FDA,OLDPID,PARENTIEN
+2 ;
+3 IF PID=$$GET1^DIQ(409.854,$ORDER(^SDEC(409.85,REQUESTIEN,10,"A"),-1)_","_REQUESTIEN_",",1,"I")
QUIT
+4 ;
+5 SET PIDFDA(409.854,"+1,"_REQUESTIEN_",",.01)=$$NOW^XLFDT
+6 SET PIDFDA(409.854,"+1,"_REQUESTIEN_",",1)=PID
+7 SET PIDFDA(409.854,"+1,"_REQUESTIEN_",",2)=$$GET1^DIQ(200,$GET(DUZ),.01,"E")
+8 DO UPDATE^DIE(,"PIDFDA")
KILL PIDFDA
+9 ;
+10 SET OLDPID=$$GET1^DIQ(409.85,REQUESTIEN_",",22,"I")
+11 SET PARENTIEN=$$GET1^DIQ(409.85,REQUESTIEN_",",43.8,"I")
+12 ;
+13 SET FDA(409.85,REQUESTIEN_",",22)=PID
+14 DO FILE^DIE(,"FDA")
KILL FDA
+15 ;
+16 IF PARENTIEN
IF $DATA(^SDEC(409.85,PARENTIEN))
Begin DoDot:1
+17 NEW PREFIEN
SET PREFIEN=$ORDER(^SDEC(409.85,PARENTIEN,5,"B",OLDPID,0))
+18 SET FDA(409.851,PREFIEN_","_PARENTIEN_",",.01)=PID
+19 DO FILE^DIE(,"FDA")
KILL FDA
End DoDot:1
+20 QUIT
+21 ;
ADDMRTCMULT(CHILD,PARENT,PATIENTINDDATE) ;Update the MRTC subfiles
+1 DO ADDMRTCLINKS(CHILD,PARENT)
+2 DO ADDMRTCPIDLINKS(PARENT,PATIENTINDDATE)
+3 QUIT
+4 ;
ADDMRTCLINKS(CHILD,PARENT) ;
+1 NEW FDA
+2 if $ORDER(^SDEC(409.85,PARENT,2,"B",CHILD))
QUIT
+3 SET FDA(409.852,"+1,"_PARENT_",",.01)=CHILD
+4 DO UPDATE^DIE(,"FDA")
KILL FDA
+5 QUIT
+6 ;
ADDMRTCPIDLINKS(PARENT,PATIENTINDDATE) ;
+1 NEW SDFDA
+2 if $ORDER(^SDEC(409.85,PARENT,5,"B",PATIENTINDDATE,0))
QUIT
+3 SET SDFDA(409.851,"+1,"_PARENT_",",.01)=PATIENTINDDATE
+4 DO UPDATE^DIE("","SDFDA")
KILL SDFDA
+5 QUIT
+6 ;
MRTCHILDSEQUENCE(PARENTREQUESTIEN,DFN) ; return next sequence # for child mrtc
+1 NEW COUNT,REQUESTIEN,IENS,NEXTSEQUENCENUM,CHILD,LASTCHILD
+2 SET REQUESTIEN=0
SET COUNT=0
SET LASTCHILD=""
+3 FOR
SET REQUESTIEN=$ORDER(^SDEC(409.85,"B",DFN,REQUESTIEN))
if 'REQUESTIEN
QUIT
Begin DoDot:1
+4 IF $$GET1^DIQ(409.85,REQUESTIEN,43.8,"I")=PARENTREQUESTIEN
Begin DoDot:2
+5 SET COUNT=COUNT+1
+6 SET CHILD(REQUESTIEN)=COUNT
End DoDot:2
End DoDot:1
+7 IF $DATA(CHILD)
Begin DoDot:1
+8 SET LASTCHILD=$ORDER(CHILD(LASTCHILD),-1)
+9 SET NEXTSEQUENCENUM=$GET(CHILD($GET(LASTCHILD)))+1
End DoDot:1
+10 IF '$DATA(CHILD)
SET NEXTSEQUENCENUM=1
+11 QUIT NEXTSEQUENCENUM
+12 ;
AUDIT(REQUESTIEN,CLINICIEN,STOPCODE) ;
+1 NEW FDA
+2 SET FDA(409.8545,"+1,"_REQUESTIEN_",",.01)=$$NOW^XLFDT
+3 SET FDA(409.8545,"+1,"_REQUESTIEN_",",1)=$GET(DUZ)
+4 SET FDA(409.8545,"+1,"_REQUESTIEN_",",2)=$GET(CLINICIEN)
+5 SET FDA(409.8545,"+1,"_REQUESTIEN_",",3)=$GET(STOPCODE)
+6 DO UPDATE^DIE("","FDA")
KILL FDA
+7 QUIT
+1 NEW REQCOMMS,NUM,NUM2,DONE,PREFDATES,PATCOMMS,RANGE,COUNT
+2 SET NUM=0
+3 ;
+4 IF $DATA(REQUEST("PATIENT COMMENT"))
Begin DoDot:1
+5 DO WP^SDECUTL(.PATCOMMS,$GET(REQUEST("PATIENT COMMENT")))
+6 DO WP^DIE(409.85,REQUESTIEN_",",60,"","PATCOMMS")
End DoDot:1
+7 ;
+8 IF '$GET(REQUEST("PATIENT PREFERRED START DATE",1))
QUIT
+9 ;
+10 SET NUM=0
SET COUNT=""
SET COUNT=$ORDER(REQUEST("PATIENT PREFERRED START DATE",COUNT),-1)
+11 FOR NUM=1:1:COUNT
Begin DoDot:1
+12 SET STARTDATE=$GET(REQUEST("PATIENT PREFERRED START DATE",NUM))
+13 SET ENDDATE=$GET(REQUEST("PATIENT PREFERRED END DATE",NUM))
+14 SET STARTDATE=$$ISOTFM^SDAMUTDT(STARTDATE)
SET STARTDATE=$$FMTE^XLFDT(STARTDATE)
+15 SET ENDDATE=$$ISOTFM^SDAMUTDT(ENDDATE)
SET ENDDATE=$$FMTE^XLFDT(ENDDATE)
+16 SET RANGE(NUM)="Patient preferred date range #"_NUM_": "_STARTDATE_" to "_ENDDATE
End DoDot:1
+17 DO WP^DIE(409.85,REQUESTIEN_",",60,"A","RANGE")
+18 QUIT
+19 ;
BUILDCPRSPREREQS(REQUEST,REQUESTIEN) ;
+1 NEW NUM,FDA
+2 SET NUM=0
+3 FOR
SET NUM=$ORDER(REQUEST("CPRS PREREQUISITES",NUM))
if 'NUM
QUIT
Begin DoDot:1
+4 SET FDA(409.8548,"+1,"_REQUESTIEN_",",.01)=$GET(REQUEST("CPRS PREREQUISITES",NUM))
+5 DO UPDATE^DIE(,"FDA")
KILL FDA
End DoDot:1
+6 QUIT
+7 ;
VALIDATEPROVIDER(ERRORS,PROVIDERIEN) ;
+1 IF PROVIDERIEN=""
DO ERRLOG^SDESJSON(.ERRORS,53)
QUIT 0
+2 IF PROVIDERIEN'=""
IF '$DATA(^VA(200,PROVIDERIEN,0))
DO ERRLOG^SDESJSON(.ERRORS,54)
QUIT 0
+3 QUIT 1
+4 ;
VALIDATEPID(ERRORS,REQUEST) ;
+1 IF $GET(REQUEST("PATIENT INDICATED DATE"))=""
DO ERRLOG^SDESJSON(.ERRORS,159)
QUIT 0
+2 IF $GET(REQUEST("PATIENT INDICATED DATE"))'=""
SET REQUEST("PATIENT INDICATED DATE")=$$ISOTFM^SDAMUTDT($GET(REQUEST("PATIENT INDICATED DATE")))
+3 IF $GET(REQUEST("PATIENT INDICATED DATE"))=-1
DO ERRLOG^SDESJSON(.ERRORS,160)
QUIT 0
+4 QUIT 1
+5 ;
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 ;
VALIDATEPRIORITY(ERRORS,PRIORITY) ;
+1 IF PRIORITY=""
SET PRIORITY="ASAP"
+2 IF PRIORITY'="ASAP"
IF PRIORITY'="FUTURE"
DO ERRLOG^SDESJSON(.ERRORS,211)
QUIT 0
+3 SET REQUEST("PRIORITY")=$SELECT(PRIORITY="ASAP":"A",PRIORITY="FUTURE":"F",1:"")
+4 QUIT 1
+5 ;
VALIDATEPRIGROUP(ERRORS,GROUP) ;
+1 NEW NUM,FOUND,GCHECK
+2 SET NUM=0
SET FOUND=0
+3 FOR NUM=1:1:8
Begin DoDot:1
+4 SET GCHECK="GROUP "_NUM
+5 IF GROUP=GCHECK
SET REQUEST("PRIORITY GROUP")=NUM
SET FOUND=1
End DoDot:1
+6 IF FOUND=0
DO ERRLOG^SDESJSON(.ERRORS,199)
QUIT 0
+7 QUIT 1
+8 ;
VALIDATESERVCONN(ERRORS,SERVCONN,SERVCONNPERC) ;
+1 IF $LENGTH(SERVCONN)
IF SERVCONN'="YES"
IF SERVCONN'="NO"
DO ERRLOG^SDESJSON(.ERRORS,200)
QUIT 0
+2 IF $GET(SERVCONNPERC)
IF '+SERVCONNPERC!(SERVCONNPERC'>0)!(SERVCONNPERC'<101)
DO ERRLOG^SDESJSON(.ERRORS,201)
QUIT 0
+3 ;I $G(SERVCONN)="NO",+$G(SERVCONNPERC) D ERRLOG^SDESJSON(.ERRORS,232) Q 0
+4 SET REQUEST("SERVICE CONNECTED")=$SELECT(SERVCONN="YES":"1",SERVCONN="NO":"0",1:"")
+5 QUIT 1
+6 ;
VALIDATEAPPTTYPE(ERRORS,APPTTYPEIEN,APPTTYPENAME) ;
+1 IF APPTTYPEIEN=""
IF APPTTYPENAME=""
DO ERRLOG^SDESJSON(.ERRORS,306)
QUIT 0
+2 NEW APPTTYPIEN
+3 SET APPTTYPIEN=0
+4 IF $GET(APPTTYPENAME)'=""
Begin DoDot:1
+5 SET APPTTYPIEN=$$FIND1^DIC(409.1,"","X",APPTTYPENAME,"B")
+6 IF 'APPTTYPIEN
DO ERRLOG^SDESJSON(.ERRORS,180)
End DoDot:1
IF 'APPTTYPIEN
QUIT 0
+7 IF APPTTYPIEN
SET APPTTYPEIEN=APPTTYPIEN
QUIT 1
+8 IF APPTTYPEIEN'=""
IF '$DATA(^SD(409.1,APPTTYPEIEN,0))
DO ERRLOG^SDESJSON(.ERRORS,180)
+9 QUIT 0
+10 ;
VALIDATEPATSTAT(ERRORS,PATIENTSTATUS) ;
+1 IF PATIENTSTATUS'="NEW"
IF PATIENTSTATUS'="ESTABLISHED"
DO ERRLOG^SDESJSON(.ERRORS,203)
QUIT 0
+2 SET REQUEST("PATIENT STATUS")=$SELECT(PATIENTSTATUS="NEW":"N",PATIENTSTATUS="ESTABLISHED":"E",1:"")
+3 QUIT 1
+4 ;
VALIDATEDATEPREF(ERRORS,REQUEST) ;
+1 NEW ARYIEN,ARYIEN2,DATE,ERR,STARTDATE,ENDDATE
+2 SET ARYIEN=0
SET ERR=0
+3 FOR
SET ARYIEN=$ORDER(REQUEST("PATIENT PREFERRED START DATE",ARYIEN))
if 'ARYIEN!($GET(ERR))
QUIT
Begin DoDot:1
+4 SET STARTDATE=$GET(REQUEST("PATIENT PREFERRED START DATE",ARYIEN))
+5 SET STARTDATE=$$ISOTFM^SDAMUTDT(STARTDATE)
+6 IF STARTDATE=-1!($LENGTH(STARTDATE,".")=1)
SET ERR=1
DO ERRLOG^SDESJSON(.ERRORS,206)
QUIT
+7 SET ARYIEN2=0
+8 FOR
SET ARYIEN2=$ORDER(REQUEST("PATIENT PREFERRED END DATE",ARYIEN2))
if 'ARYIEN2
QUIT
Begin DoDot:2
+9 SET ENDDATE=$GET(REQUEST("PATIENT PREFERRED END DATE",ARYIEN2))
+10 SET ENDDATE=$$ISOTFM^SDAMUTDT(ENDDATE)
+11 IF ENDDATE=-1!($LENGTH(ENDDATE,".")=1)
SET ERR=1
DO ERRLOG^SDESJSON(.ERRORS,206)
QUIT
End DoDot:2
End DoDot:1
+12 IF $GET(REQUEST("PATIENT PREFERRED START DATE",1))
IF '$GET(REQUEST("PATIENT PREFERRED END DATE",1))
DO ERRLOG^SDESJSON(.ERRORS,195)
QUIT 0
+13 IF $GET(REQUEST("PATIENT PREFERRED START DATE",2))
IF '$GET(REQUEST("PATIENT PREFERRED END DATE",2))
DO ERRLOG^SDESJSON(.ERRORS,195)
QUIT 0
+14 IF $GET(REQUEST("PATIENT PREFERRED START DATE",3))
IF '$GET(REQUEST("PATIENT PREFERRED END DATE",3))
DO ERRLOG^SDESJSON(.ERRORS,195)
QUIT 0
+15 QUIT
+16 ;
VALIDATEMRTCDATA(ERRORS,REQUEST,PARENTREQUEST,NEEDED,DAYSBETWEEN,HOWMANY,REQDFN) ;
+1 NEW NUM,DONE
+2 IF PARENTREQUEST
IF $$GET1^DIQ(409.85,PARENTREQUEST,.01,"I")'=REQDFN
DO ERRLOG^SDESJSON(.ERRORS,533)
+3 IF NEEDED'=""
IF NEEDED'="YES"
IF NEEDED'="NO"
DO ERRLOG^SDESJSON(.ERRORS,208)
QUIT
+4 SET REQUEST("MRTC","NEEDED")=$SELECT(NEEDED="YES":1,NEEDED="NO":0,1:"")
+5 IF REQUEST("MRTC","NEEDED")'=1
Begin DoDot:1
+6 IF $GET(PARENTREQUEST)!($GET(DAYSBETWEEN))!($GET(HOWMANY))
DO ERRLOG^SDESJSON(.ERRORS,233)
End DoDot:1
QUIT ""
+7 QUIT 1
+8 ;
+9 ;
+10 IF PARENTREQUEST'=""
IF ('$DATA(^SDEC(409.85,PARENTREQUEST)))!(PARENTREQUEST=0)
DO ERRLOG^SDESJSON(.ERRORS,207)
+11 ;
+12 IF DAYSBETWEEN'=""
Begin DoDot:1
+13 IF '+DAYSBETWEEN!(DAYSBETWEEN'<366)
DO ERRLOG^SDESJSON(.ERRORS,209)
End DoDot:1
+14 ;
+15 IF HOWMANY'=""
Begin DoDot:1
+16 IF '+HOWMANY!(HOWMANY'<101)
DO ERRLOG^SDESJSON(.ERRORS,210)
End DoDot:1
+17 QUIT
+18 ;
BUILDJSON(JSONRETURN,RETURN) ;.
+1 NEW JSONERROR
+2 DO ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERR")
+3 QUIT