SD53430P ;WOIFO/CLC - PFSS Scheduled Outpatient Conversion Backload ;22-APR-2005
;;5.3;Scheduling;**430**;Aug 13, 1993
D HDR
Q
;
PRECHK ;
N VCNT
D HDR W !!,"Pre-Backload Analysis - Outpatient future appointments."
S VCNT=$$FUTRAPP(0)
I VCNT<0 W !,"Analysis exited without processing..." Q
W !!,VCNT," Outpatient future appointments identified in VistA..."
W !!,"Analysis complete...."
Q
FUTRAPP(CMP) ;
N I,DFN,APP,STDT,DT,APPINFO
S (DFN,APP)=0
S STDT=$$GETRESP($$NOW^XLFDT(),"Future Appointment search start date") I STDT="" S APP=-1 G OFAQ
W !,"Checking VistA future appointments ",STDT," forward..."
F I=1:1 S DFN=$O(^DPT(DFN)) Q:+DFN<1 D
.I I#10000=0 W "."
.S DT=STDT
.F S DT=$O(^DPT(DFN,"S",DT)) Q:+DT<1 D
..S APPINFO=$G(^DPT(DFN,"S",DT,0))
..I APPINFO="" W !,"Invalid Patient Appointment Node:",DFN,"-",DT Q
..I $P(APPINFO,"^",2)="" D
...S APP=APP+1
...I CMP I $G(^TMP($J,"OFA",DFN))="" S EXC(DFN_"^"_DT)=^DPT(DFN,0)
OFAQ Q APP
POSTCHK ;
N PATH,FILENM,LN,TMP,I,DFN,BLCNT,EXC,VCNT
D HDR W !!,"Post-Backload Analysis - Outpatient future appointments."
S FILENM="SDCONV_ACCT.TXT",BLCNT=0,PATH=$$PWD^%ZISH()
S PATH=$$GETRESP(PATH,"Select Backload Path") Q:PATH=""
I '$$LISTF(PATH) S FILENM=""
S FILENM=$$GETRESP(FILENM,"Select Backload File") Q:FILENM=""
;
K ^TMP($J,"OFA")
D OPEN^%ZISH("SD",PATH,FILENM,"R")
F U IO R LN:1 Q:LN']"" S ^TMP($J,"OFA",$P(LN,"^"))=LN,BLCNT=BLCNT+1
D CLOSE^%ZISH(IO)
;
W !!,"File: ",FILENM," contains: ",BLCNT," records."
S VCNT=$$FUTRAPP(1)
W !!,VCNT," Outpatient future appointments identified in VistA..."
;
W !," VistA Total:",$J(VCNT,10)
W !,"Backload Total:",$J(BLCNT,10)
W !,"=================================="
W !," ",$J(VCNT-BLCNT,10)
;
I '$D(EXC) W !,"No Discrepencies between VistA and the Backload file" Q
W !!,"Missing patients from backload file:",!
S DFN=0
F I=1:1 S DFN=$O(EXC(DFN)) Q:DFN="" W !,I,") ",DFN,"^",EXC(DFN)
W !!,"Post analysis complete...."
K ^TMP($J,"OFA")
Q
EP1 ;
N CNT,GOOD,ERR,SDKEY,ANS,PATH,Y,FN,GFILE,RFILE,FILENM
S SDKEY="SDCONV_ACCT.TXT",FILENM=SDKEY
S PATH=$$PWD^%ZISH(),(CNT,GOOD)=0
D HDR
S PATH=$$GETRESP(PATH,"Select Backload Path") Q:PATH=""
;
I '$$LISTF(PATH) S FILENM=""
S FILENM=$$GETRESP(FILENM,"Select Backload File") Q:FILENM=""
S CNT=$$LOADFILE(PATH,FILENM)
;
I CNT>0 S GOOD=$$PROCESS(CNT)
D RPTERR(CNT,GOOD,PATH_FILENM)
W !!,"Finished.... Mailman message sent to:",$$GET1^DIQ(200,DUZ,.01)," and G.PATCHES"
Q
LISTF(PATH) ;
N GFILE,Y,RFILE,FN
S GFILE("SD*.TXT")=""
S Y=$$LIST^%ZISH(PATH,"GFILE","RFILE")
W !!,"SD*.TXT Files in ",PATH,!,"=================================="
I Y=1 S FN="" F S FN=$O(RFILE(FN)) Q:FN="" W !,?10,FN
I Y=0 W !!,?10,"** No files matching the SD*.TXT filter exists **"
Q Y
HDR ;
D HOME^%ZIS W @IOF
W !!,"==========================================================="
W !,"Scheduled Outpatient Conversion Backload",!
W !," **********************************************************"
W !," * This Routine should ONLY be run by PFSS Implementation *"
W !," * Staff. DO NOT run this routine as part of the normal *"
W !," * Patch installation process. *"
W !," **********************************************************"
W !!,"==========================================================="
Q
GETRESP(DEF,TXT) ;
N DIR,DIRUT,DTOUT,X,Y
S DIR(0)="Fr",DIR("A")=TXT,DIR("B")=DEF D ^DIR
I $D(DIRUT)!$D(DTOUT) S Y=""
Q Y
RPTERR(CNT,GOOD,FULLPATH) ;
N REC,CAT,ROW,ERR,ET,DETAIL
N XMDF,XMDUZ,XMSUB,XMDUN,XMTEXT,XMSTRIP,XMROU,XMY,XMZ,XMMG
S XMDF="",XMDUZ="SD53430P-"_$TR($P($$SITE^VASITE(),"^",2,3),"^","-")
S XMY(DUZ)="",XMY("G.PATCHES")=""
S XMSUB="PFSS Scheduled Outpatient Conversion"
D XMZ^XMA2 ; Call Create Message Module
I XMZ<1 D Q
.W !!,"** UNABLE TO CREATE MAILMAN MESSAGE PLEASE CHECK XTMP FOR DETAILS!"
;
S ^XMB(3.9,XMZ,2,1,0)="Scheduled OutPatient Conversion Backload"
S ^XMB(3.9,XMZ,2,2,0)=" File: "_FULLPATH
S ^XMB(3.9,XMZ,2,3,0)=" Run By: "_$$GET1^DIQ(200,DUZ,.01)
S ^XMB(3.9,XMZ,2,4,0)=""
S ^XMB(3.9,XMZ,2,5,0)="Sucessful Records: "_GOOD
S ^XMB(3.9,XMZ,2,7,0)=" ----------------------"
S ^XMB(3.9,XMZ,2,8,0)=" Total Processed: "_CNT
S ^XMB(3.9,XMZ,2,9,0)="==============================================="
;
S REC="",ROW=9,ERR=0
F S REC=$O(^XTMP(SDKEY,"ERR",REC)) Q:REC="" D
.S ERR=ERR+1,ROW=ROW+1
.S ^XMB(3.9,XMZ,2,ROW,0)="Record: "_REC_" ----------------------"
.S CAT=""
.F S CAT=$O(^XTMP(SDKEY,"ERR",REC,CAT)) Q:CAT="" D
..S ROW=ROW+1,^XMB(3.9,XMZ,2,ROW,0)=" "_CAT
..S ET=""
..F S ET=$O(^XTMP(SDKEY,"ERR",REC,CAT,ET)) Q:ET="" D
...S ROW=ROW+1
...S ^XMB(3.9,XMZ,2,ROW,0)=" "_^XTMP(SDKEY,"ERR",REC,CAT,ET)
;
S ^XMB(3.9,XMZ,2,6,0)=" Error Records: "_ERR
I ROW=9 S ROW=10,^XMB(3.9,XMZ,2,ROW,0)="Sucessful Backload..... No ERRORS found..."
;
S ^XMB(3.9,XMZ,2,0)="^3.92^"_ROW_"^"_ROW_"^"_$$NOW^XLFDT()
D ENT1^XMD ;Deliver MSG
K ^XTMP(SDKEY)
Q
LOADFILE(PATH,FILENM) ;
N POP,NOW,PURGDT,STOP,TOT,LN
W !,"Loading backload file..."
K ^XTMP(SDKEY)
S NOW=$$NOW^XLFDT(),PURGDT=NOW+2,TOT=0 ;Purge 2 days later
S ^XTMP(SDKEY,0)=PURGDT_"^"_NOW_"^PFSS Scheduled Outpatient Back Load"
;
D OPEN^%ZISH("SD",PATH,FILENM,"R")
I $G(POP) S ^XTMP(SDKEY,"ERR",0,"FATAL",1)="Could NOT PROCESS File!"
;
S (STOP,TOT)=0
F U IO R LN:1 Q:LN']"" Q:$$STATUS^%ZISH Q:STOP D
.I $G(LN)="" S STOP=1 Q
.S TOT=TOT+1,^XTMP(SDKEY,"DAT",TOT)=LN I TOT#1000=0 U 0 W "."
;
D CLOSE^%ZISH(IO)
LFQ Q TOT
;
PROCESS(TOT) ;
N CNT,INFO,DFN,SDT,SDCLN,SDEXVN,SDANR,SDCHK,GOOD
W !,"Processing data..."
S GOOD=0
F CNT=1:1:TOT D
.I CNT#1000=0 W "."
.S INFO=^XTMP(SDKEY,"DAT",CNT)
.S DFN=$P(INFO,"^",1),SDT=$P(INFO,"^",18)
.S SDCLN=$P(INFO,"^",8),SDEXVN=$TR($P(INFO,"^",21)," ","")
.;
.Q:$$CHKINFO(CNT,DFN,SDT,SDCLN,SDEXVN)
.S SDANR=$$GETARN^SDPFSS2(SDT,DFN,SDCLN)
.I +SDANR>0 D Q
..I $$EXTNUM^IBBAPI(DFN,SDANR)'=SDEXVN D Q
...S ^XTMP(SDKEY,"ERR",CNT,"ACCT",1)="Visit Number Discrepancy: "_INFO_" NOT EQUAL: "_SDANR
..S GOOD=GOOD+1
.;
.S SDANR=$$IBBACONV^IBBAADTI(DFN,"O",SDT,SDCLN,SDEXVN)
.I SDANR="" S ^XTMP(SDKEY,"ERR",CNT,"ACCT",2)="PFSS Account Reference NOT Created" Q
.;
.S SDCHK=$$FILE^SDPFSS(DFN,SDT,SDCLN,SDANR)
.I +SDCHK<0 D
..S ^XTMP(SDKEY,"ERR",CNT,"APPT LINK",1)="Unable to update file 409.55"
..S ^XTMP(SDKEY,"ERR",CNT,"APPT LINK",2)=SDCHK
.I SDCHK="" S ^XTMP(SDKEY,"ERR",CNT,"APPT LINK",3)="Link Already Exists:"_INFO
.I +SDCHK=1 S GOOD=GOOD+1
Q GOOD
CHKINFO(CNT,DFN,SDT,SDCLN,SDEXVN) ;
I SDEXVN="" S ^XTMP(SDKEY,"ERR",CNT,"IDX",1)="NO IDX Vist Number:"_INFO
;
I +DFN=0 S ^XTMP(SDKEY,"ERR",CNT,"PATIENT",1)="DFN Invalid or Missing"
I +DFN>0 D
.I $G(^DPT(DFN,0))="" S ^XTMP(SDKEY,"ERR",CNT,"PATIENT",2)="Invalid Patient: "_DFN
;
I +SDT=0 S ^XTMP(SDKEY,"ERR",CNT,"APPT DT/TIME",1)="Appointment Date/Time Invalid or Missing"
;
I +SDCLN=0 S ^XTMP(SDKEY,"ERR",CNT,"LOCATION",1)="Location Invalid or Missing"
I +SDCLN>0 D
.I $G(^SC(SDCLN,0))="" S ^XTMP(SDKEY,"ERR",CNT,"LOCATION",2)="Invalid Location:"_SDCLN
Q $D(^XTMP(SDKEY,"ERR",CNT))
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSD53430P 7570 printed Nov 22, 2024@17:55:08 Page 2
SD53430P ;WOIFO/CLC - PFSS Scheduled Outpatient Conversion Backload ;22-APR-2005
+1 ;;5.3;Scheduling;**430**;Aug 13, 1993
+2 DO HDR
+3 QUIT
+4 ;
PRECHK ;
+1 NEW VCNT
+2 DO HDR
WRITE !!,"Pre-Backload Analysis - Outpatient future appointments."
+3 SET VCNT=$$FUTRAPP(0)
+4 IF VCNT<0
WRITE !,"Analysis exited without processing..."
QUIT
+5 WRITE !!,VCNT," Outpatient future appointments identified in VistA..."
+6 WRITE !!,"Analysis complete...."
+7 QUIT
FUTRAPP(CMP) ;
+1 NEW I,DFN,APP,STDT,DT,APPINFO
+2 SET (DFN,APP)=0
+3 SET STDT=$$GETRESP($$NOW^XLFDT(),"Future Appointment search start date")
IF STDT=""
SET APP=-1
GOTO OFAQ
+4 WRITE !,"Checking VistA future appointments ",STDT," forward..."
+5 FOR I=1:1
SET DFN=$ORDER(^DPT(DFN))
if +DFN<1
QUIT
Begin DoDot:1
+6 IF I#10000=0
WRITE "."
+7 SET DT=STDT
+8 FOR
SET DT=$ORDER(^DPT(DFN,"S",DT))
if +DT<1
QUIT
Begin DoDot:2
+9 SET APPINFO=$GET(^DPT(DFN,"S",DT,0))
+10 IF APPINFO=""
WRITE !,"Invalid Patient Appointment Node:",DFN,"-",DT
QUIT
+11 IF $PIECE(APPINFO,"^",2)=""
Begin DoDot:3
+12 SET APP=APP+1
+13 IF CMP
IF $GET(^TMP($JOB,"OFA",DFN))=""
SET EXC(DFN_"^"_DT)=^DPT(DFN,0)
End DoDot:3
End DoDot:2
End DoDot:1
OFAQ QUIT APP
POSTCHK ;
+1 NEW PATH,FILENM,LN,TMP,I,DFN,BLCNT,EXC,VCNT
+2 DO HDR
WRITE !!,"Post-Backload Analysis - Outpatient future appointments."
+3 SET FILENM="SDCONV_ACCT.TXT"
SET BLCNT=0
SET PATH=$$PWD^%ZISH()
+4 SET PATH=$$GETRESP(PATH,"Select Backload Path")
if PATH=""
QUIT
+5 IF '$$LISTF(PATH)
SET FILENM=""
+6 SET FILENM=$$GETRESP(FILENM,"Select Backload File")
if FILENM=""
QUIT
+7 ;
+8 KILL ^TMP($JOB,"OFA")
+9 DO OPEN^%ZISH("SD",PATH,FILENM,"R")
+10 FOR
USE IO
READ LN:1
if LN']""
QUIT
SET ^TMP($JOB,"OFA",$PIECE(LN,"^"))=LN
SET BLCNT=BLCNT+1
+11 DO CLOSE^%ZISH(IO)
+12 ;
+13 WRITE !!,"File: ",FILENM," contains: ",BLCNT," records."
+14 SET VCNT=$$FUTRAPP(1)
+15 WRITE !!,VCNT," Outpatient future appointments identified in VistA..."
+16 ;
+17 WRITE !," VistA Total:",$JUSTIFY(VCNT,10)
+18 WRITE !,"Backload Total:",$JUSTIFY(BLCNT,10)
+19 WRITE !,"=================================="
+20 WRITE !," ",$JUSTIFY(VCNT-BLCNT,10)
+21 ;
+22 IF '$DATA(EXC)
WRITE !,"No Discrepencies between VistA and the Backload file"
QUIT
+23 WRITE !!,"Missing patients from backload file:",!
+24 SET DFN=0
+25 FOR I=1:1
SET DFN=$ORDER(EXC(DFN))
if DFN=""
QUIT
WRITE !,I,") ",DFN,"^",EXC(DFN)
+26 WRITE !!,"Post analysis complete...."
+27 KILL ^TMP($JOB,"OFA")
+28 QUIT
EP1 ;
+1 NEW CNT,GOOD,ERR,SDKEY,ANS,PATH,Y,FN,GFILE,RFILE,FILENM
+2 SET SDKEY="SDCONV_ACCT.TXT"
SET FILENM=SDKEY
+3 SET PATH=$$PWD^%ZISH()
SET (CNT,GOOD)=0
+4 DO HDR
+5 SET PATH=$$GETRESP(PATH,"Select Backload Path")
if PATH=""
QUIT
+6 ;
+7 IF '$$LISTF(PATH)
SET FILENM=""
+8 SET FILENM=$$GETRESP(FILENM,"Select Backload File")
if FILENM=""
QUIT
+9 SET CNT=$$LOADFILE(PATH,FILENM)
+10 ;
+11 IF CNT>0
SET GOOD=$$PROCESS(CNT)
+12 DO RPTERR(CNT,GOOD,PATH_FILENM)
+13 WRITE !!,"Finished.... Mailman message sent to:",$$GET1^DIQ(200,DUZ,.01)," and G.PATCHES"
+14 QUIT
LISTF(PATH) ;
+1 NEW GFILE,Y,RFILE,FN
+2 SET GFILE("SD*.TXT")=""
+3 SET Y=$$LIST^%ZISH(PATH,"GFILE","RFILE")
+4 WRITE !!,"SD*.TXT Files in ",PATH,!,"=================================="
+5 IF Y=1
SET FN=""
FOR
SET FN=$ORDER(RFILE(FN))
if FN=""
QUIT
WRITE !,?10,FN
+6 IF Y=0
WRITE !!,?10,"** No files matching the SD*.TXT filter exists **"
+7 QUIT Y
HDR ;
+1 DO HOME^%ZIS
WRITE @IOF
+2 WRITE !!,"==========================================================="
+3 WRITE !,"Scheduled Outpatient Conversion Backload",!
+4 WRITE !," **********************************************************"
+5 WRITE !," * This Routine should ONLY be run by PFSS Implementation *"
+6 WRITE !," * Staff. DO NOT run this routine as part of the normal *"
+7 WRITE !," * Patch installation process. *"
+8 WRITE !," **********************************************************"
+9 WRITE !!,"==========================================================="
+10 QUIT
GETRESP(DEF,TXT) ;
+1 NEW DIR,DIRUT,DTOUT,X,Y
+2 SET DIR(0)="Fr"
SET DIR("A")=TXT
SET DIR("B")=DEF
DO ^DIR
+3 IF $DATA(DIRUT)!$DATA(DTOUT)
SET Y=""
+4 QUIT Y
RPTERR(CNT,GOOD,FULLPATH) ;
+1 NEW REC,CAT,ROW,ERR,ET,DETAIL
+2 NEW XMDF,XMDUZ,XMSUB,XMDUN,XMTEXT,XMSTRIP,XMROU,XMY,XMZ,XMMG
+3 SET XMDF=""
SET XMDUZ="SD53430P-"_$TRANSLATE($PIECE($$SITE^VASITE(),"^",2,3),"^","-")
+4 SET XMY(DUZ)=""
SET XMY("G.PATCHES")=""
+5 SET XMSUB="PFSS Scheduled Outpatient Conversion"
+6 ; Call Create Message Module
DO XMZ^XMA2
+7 IF XMZ<1
Begin DoDot:1
+8 WRITE !!,"** UNABLE TO CREATE MAILMAN MESSAGE PLEASE CHECK XTMP FOR DETAILS!"
End DoDot:1
QUIT
+9 ;
+10 SET ^XMB(3.9,XMZ,2,1,0)="Scheduled OutPatient Conversion Backload"
+11 SET ^XMB(3.9,XMZ,2,2,0)=" File: "_FULLPATH
+12 SET ^XMB(3.9,XMZ,2,3,0)=" Run By: "_$$GET1^DIQ(200,DUZ,.01)
+13 SET ^XMB(3.9,XMZ,2,4,0)=""
+14 SET ^XMB(3.9,XMZ,2,5,0)="Sucessful Records: "_GOOD
+15 SET ^XMB(3.9,XMZ,2,7,0)=" ----------------------"
+16 SET ^XMB(3.9,XMZ,2,8,0)=" Total Processed: "_CNT
+17 SET ^XMB(3.9,XMZ,2,9,0)="==============================================="
+18 ;
+19 SET REC=""
SET ROW=9
SET ERR=0
+20 FOR
SET REC=$ORDER(^XTMP(SDKEY,"ERR",REC))
if REC=""
QUIT
Begin DoDot:1
+21 SET ERR=ERR+1
SET ROW=ROW+1
+22 SET ^XMB(3.9,XMZ,2,ROW,0)="Record: "_REC_" ----------------------"
+23 SET CAT=""
+24 FOR
SET CAT=$ORDER(^XTMP(SDKEY,"ERR",REC,CAT))
if CAT=""
QUIT
Begin DoDot:2
+25 SET ROW=ROW+1
SET ^XMB(3.9,XMZ,2,ROW,0)=" "_CAT
+26 SET ET=""
+27 FOR
SET ET=$ORDER(^XTMP(SDKEY,"ERR",REC,CAT,ET))
if ET=""
QUIT
Begin DoDot:3
+28 SET ROW=ROW+1
+29 SET ^XMB(3.9,XMZ,2,ROW,0)=" "_^XTMP(SDKEY,"ERR",REC,CAT,ET)
End DoDot:3
End DoDot:2
End DoDot:1
+30 ;
+31 SET ^XMB(3.9,XMZ,2,6,0)=" Error Records: "_ERR
+32 IF ROW=9
SET ROW=10
SET ^XMB(3.9,XMZ,2,ROW,0)="Sucessful Backload..... No ERRORS found..."
+33 ;
+34 SET ^XMB(3.9,XMZ,2,0)="^3.92^"_ROW_"^"_ROW_"^"_$$NOW^XLFDT()
+35 ;Deliver MSG
DO ENT1^XMD
+36 KILL ^XTMP(SDKEY)
+37 QUIT
LOADFILE(PATH,FILENM) ;
+1 NEW POP,NOW,PURGDT,STOP,TOT,LN
+2 WRITE !,"Loading backload file..."
+3 KILL ^XTMP(SDKEY)
+4 ;Purge 2 days later
SET NOW=$$NOW^XLFDT()
SET PURGDT=NOW+2
SET TOT=0
+5 SET ^XTMP(SDKEY,0)=PURGDT_"^"_NOW_"^PFSS Scheduled Outpatient Back Load"
+6 ;
+7 DO OPEN^%ZISH("SD",PATH,FILENM,"R")
+8 IF $GET(POP)
SET ^XTMP(SDKEY,"ERR",0,"FATAL",1)="Could NOT PROCESS File!"
+9 ;
+10 SET (STOP,TOT)=0
+11 FOR
USE IO
READ LN:1
if LN']""
QUIT
if $$STATUS^%ZISH
QUIT
if STOP
QUIT
Begin DoDot:1
+12 IF $GET(LN)=""
SET STOP=1
QUIT
+13 SET TOT=TOT+1
SET ^XTMP(SDKEY,"DAT",TOT)=LN
IF TOT#1000=0
USE 0
WRITE "."
End DoDot:1
+14 ;
+15 DO CLOSE^%ZISH(IO)
LFQ QUIT TOT
+1 ;
PROCESS(TOT) ;
+1 NEW CNT,INFO,DFN,SDT,SDCLN,SDEXVN,SDANR,SDCHK,GOOD
+2 WRITE !,"Processing data..."
+3 SET GOOD=0
+4 FOR CNT=1:1:TOT
Begin DoDot:1
+5 IF CNT#1000=0
WRITE "."
+6 SET INFO=^XTMP(SDKEY,"DAT",CNT)
+7 SET DFN=$PIECE(INFO,"^",1)
SET SDT=$PIECE(INFO,"^",18)
+8 SET SDCLN=$PIECE(INFO,"^",8)
SET SDEXVN=$TRANSLATE($PIECE(INFO,"^",21)," ","")
+9 ;
+10 if $$CHKINFO(CNT,DFN,SDT,SDCLN,SDEXVN)
QUIT
+11 SET SDANR=$$GETARN^SDPFSS2(SDT,DFN,SDCLN)
+12 IF +SDANR>0
Begin DoDot:2
+13 IF $$EXTNUM^IBBAPI(DFN,SDANR)'=SDEXVN
Begin DoDot:3
+14 SET ^XTMP(SDKEY,"ERR",CNT,"ACCT",1)="Visit Number Discrepancy: "_INFO_" NOT EQUAL: "_SDANR
End DoDot:3
QUIT
+15 SET GOOD=GOOD+1
End DoDot:2
QUIT
+16 ;
+17 SET SDANR=$$IBBACONV^IBBAADTI(DFN,"O",SDT,SDCLN,SDEXVN)
+18 IF SDANR=""
SET ^XTMP(SDKEY,"ERR",CNT,"ACCT",2)="PFSS Account Reference NOT Created"
QUIT
+19 ;
+20 SET SDCHK=$$FILE^SDPFSS(DFN,SDT,SDCLN,SDANR)
+21 IF +SDCHK<0
Begin DoDot:2
+22 SET ^XTMP(SDKEY,"ERR",CNT,"APPT LINK",1)="Unable to update file 409.55"
+23 SET ^XTMP(SDKEY,"ERR",CNT,"APPT LINK",2)=SDCHK
End DoDot:2
+24 IF SDCHK=""
SET ^XTMP(SDKEY,"ERR",CNT,"APPT LINK",3)="Link Already Exists:"_INFO
+25 IF +SDCHK=1
SET GOOD=GOOD+1
End DoDot:1
+26 QUIT GOOD
CHKINFO(CNT,DFN,SDT,SDCLN,SDEXVN) ;
+1 IF SDEXVN=""
SET ^XTMP(SDKEY,"ERR",CNT,"IDX",1)="NO IDX Vist Number:"_INFO
+2 ;
+3 IF +DFN=0
SET ^XTMP(SDKEY,"ERR",CNT,"PATIENT",1)="DFN Invalid or Missing"
+4 IF +DFN>0
Begin DoDot:1
+5 IF $GET(^DPT(DFN,0))=""
SET ^XTMP(SDKEY,"ERR",CNT,"PATIENT",2)="Invalid Patient: "_DFN
End DoDot:1
+6 ;
+7 IF +SDT=0
SET ^XTMP(SDKEY,"ERR",CNT,"APPT DT/TIME",1)="Appointment Date/Time Invalid or Missing"
+8 ;
+9 IF +SDCLN=0
SET ^XTMP(SDKEY,"ERR",CNT,"LOCATION",1)="Location Invalid or Missing"
+10 IF +SDCLN>0
Begin DoDot:1
+11 IF $GET(^SC(SDCLN,0))=""
SET ^XTMP(SDKEY,"ERR",CNT,"LOCATION",2)="Invalid Location:"_SDCLN
End DoDot:1
+12 QUIT $DATA(^XTMP(SDKEY,"ERR",CNT))
+13 ;