MDWORSR2 ; SLC OIFO/GDU - CONFIRM AUTO CHECK IN;8/22/18 6:10 pm ; 8/29/18 10:52am
 ;;1.0;CLINICAL PROCEDURES;**54**;Apr 01,2004;Build 14
 ;
 ;Added by patch MD*1.0*54 for SDM R6900025FY16
 ;This is to prevent the auto check-in of a new CP order on the same
 ;day as a CP order already scheduled.
 ;
 ;Variables passed in:
 ; MDY1 = The patient's IEN
 ; MDDX = The CP Transaction record IEN
 ; MDSCHD = The date/time of the appointment
 ;Value returned:
 ; Returns 1 if auto check-in is to continue
 ; Returns 0 if auto check-in is not to continue
 ;
 ;Integration Areemements used:
 ; IA# 2051 [Supported] FIND^DIC
 ; IA# 2056 [Supported] $$GET1^DIQ
 ;
 ;Not intended for interactive use.
 Q
CACI(MDY1,MDDX,MDSCHD) ;CONFIRM AUTO CHECK IN
 N MDCHKDT,MDERR,MDFLDS,MDFND,MDNAME,MDRECS,MDRTN,MDSTEP,MDTS,MDX
 ;Pull patient's CP Transaction records
 S MDNAME=$$GET1^DIQ(2,MDY1_",",.01,"E")
 S MDFLDS="@;.01I;.02I;.09I;.14I"
 D FIND^DIC(702,"",MDFLDS,"P",MDNAME,"*","B","","","MDRECS","MDERR")
 S MDSTEP=+MDRECS("DILIST",0)
 I MDSTEP=1 Q 1 ;Only one record found, quit, continue check-in
 ;Check records found for a CP Transaction for same day as appointment
 S MDFND=0
 F MDX=1:1:MDSTEP D
 . S MDTS=$P(MDRECS("DILIST",MDX,0),U,4)
 . S MDCHKDT=$P(MDRECS("DILIST",MDX,0),U,5)
 . I MDTS=6 Q  ;IF CANCELLED QUIT
 . I MDTS=0 Q  ;IF NEW QUIT
 . I MDCHKDT="" Q  ;IF NOT SCHEDULED SAME DAY QUIT
 . I $P(MDCHKDT,".")=$P(MDSCHD,".") S MDFND=1 Q
 S:MDFND=1 MDRTN=0 ;A record found for today, stop check-in
 S:MDFND=0 MDRTN=1 ;No record found for today, continue check-in
 Q MDRTN
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDWORSR2   1605     printed  Sep 23, 2025@19:20:33                                                                                                                                                                                                    Page 2
MDWORSR2  ; SLC OIFO/GDU - CONFIRM AUTO CHECK IN;8/22/18 6:10 pm ; 8/29/18 10:52am
 +1       ;;1.0;CLINICAL PROCEDURES;**54**;Apr 01,2004;Build 14
 +2       ;
 +3       ;Added by patch MD*1.0*54 for SDM R6900025FY16
 +4       ;This is to prevent the auto check-in of a new CP order on the same
 +5       ;day as a CP order already scheduled.
 +6       ;
 +7       ;Variables passed in:
 +8       ; MDY1 = The patient's IEN
 +9       ; MDDX = The CP Transaction record IEN
 +10      ; MDSCHD = The date/time of the appointment
 +11      ;Value returned:
 +12      ; Returns 1 if auto check-in is to continue
 +13      ; Returns 0 if auto check-in is not to continue
 +14      ;
 +15      ;Integration Areemements used:
 +16      ; IA# 2051 [Supported] FIND^DIC
 +17      ; IA# 2056 [Supported] $$GET1^DIQ
 +18      ;
 +19      ;Not intended for interactive use.
 +20       QUIT 
CACI(MDY1,MDDX,MDSCHD) ;CONFIRM AUTO CHECK IN
 +1        NEW MDCHKDT,MDERR,MDFLDS,MDFND,MDNAME,MDRECS,MDRTN,MDSTEP,MDTS,MDX
 +2       ;Pull patient's CP Transaction records
 +3        SET MDNAME=$$GET1^DIQ(2,MDY1_",",.01,"E")
 +4        SET MDFLDS="@;.01I;.02I;.09I;.14I"
 +5        DO FIND^DIC(702,"",MDFLDS,"P",MDNAME,"*","B","","","MDRECS","MDERR")
 +6        SET MDSTEP=+MDRECS("DILIST",0)
 +7       ;Only one record found, quit, continue check-in
           IF MDSTEP=1
               QUIT 1
 +8       ;Check records found for a CP Transaction for same day as appointment
 +9        SET MDFND=0
 +10       FOR MDX=1:1:MDSTEP
               Begin DoDot:1
 +11               SET MDTS=$PIECE(MDRECS("DILIST",MDX,0),U,4)
 +12               SET MDCHKDT=$PIECE(MDRECS("DILIST",MDX,0),U,5)
 +13      ;IF CANCELLED QUIT
                   IF MDTS=6
                       QUIT 
 +14      ;IF NEW QUIT
                   IF MDTS=0
                       QUIT 
 +15      ;IF NOT SCHEDULED SAME DAY QUIT
                   IF MDCHKDT=""
                       QUIT 
 +16               IF $PIECE(MDCHKDT,".")=$PIECE(MDSCHD,".")
                       SET MDFND=1
                       QUIT 
               End DoDot:1
 +17      ;A record found for today, stop check-in
           if MDFND=1
               SET MDRTN=0
 +18      ;No record found for today, continue check-in
           if MDFND=0
               SET MDRTN=1
 +19       QUIT MDRTN