SDES2RSTCAVAIL ;ALB/LAB - VISTA SCHEDULING SDES2 RESTORE CLIN AVAIL ;OCT 30, 2023
;;5.3;Scheduling;**861,864,875**;Aug 13, 1993;Build 25
;;Per VHA Directive 6402, this routine should not be modified
Q
;
RESTORE(RESULT,SDCONTEXT,SDRESTORE) ;
N ERRORS,RETURN
;validate context array for accuracy
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("Restore",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
;
;set up needed variables and validate
;
D ASSIGNVARS(.CLINIC,.DATETIME,.RESTORETYPE)
D VALIDATE(.ERRORS,CLINIC,.DATETIME,RESTORETYPE)
I $D(ERRORS) S ERRORS("Restore",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
D GETCLINICINFO(CLINIC,.INCREMENT,.STARTHOUR,DATETIME,.CANCELDATE)
I $D(ERRORS) S ERRORS("Restore",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
;
; verify that date/time has cancellation
;
D VERIFYCANCEL(.ERRORS,CLINIC,DATETIME)
I $D(ERRORS) S ERRORS("Restore",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
;
D:RESTORETYPE="F" FULLRESTORE(.RETURN,CLINIC,DATETIME)
D:RESTORETYPE="P" PARTIALRESTORE(.ERRORS,.RETURN,CLINIC,DATETIME,STARTHOUR,INCREMENT)
I $D(ERRORS) S ERRORS("Restore",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
D BUILDJSON^SDES2JSON(.RESULT,.RETURN)
Q
;
GETCLINICINFO(CLINIC,INCREMENT,STARTHOUR,DATETIME,CANCELDATE) ;assign variables needed from clinic
S INCREMENT=+$$GET1^DIQ(44,CLINIC_",",1917,"I")
S INCREMENT=$S(INCREMENT<3:4,INCREMENT:INCREMENT,1:4)
S STARTHOUR=$$GET1^DIQ(44,CLINIC_",",1914,"I")
S:STARTHOUR="" STARTHOUR=8
S CANCELDATE=$P(DATETIME,".")
Q
;
ASSIGNVARS(CLINIC,DATETIME,RESTORETYPE) ;assign variables from input array
S CLINIC=$G(SDRESTORE("CLINIC IEN"))
S DATETIME=$G(SDRESTORE("DATE OR DATETIME")) ;date for full datetime for partial
S RESTORETYPE=$G(SDRESTORE("RESTORE TYPE")) ;partial or full restore
Q
;
VALIDATE(ERRORS,CLINIC,DATETIME,RESTORETYPE) ; validate input array variables
D VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,CLINIC,1,"",18,19)
Q:$D(ERRORS)
I $$INACTIVE^SDES2UTIL(CLINIC) S ERRORS("Restore",1)="" D ERRLOG^SDES2JSON(.ERRORS,52,"Inactive clinic cannot restore availability.")
Q:$D(ERRORS)
I '$$CLNCK^SDUTL2(CLINIC,1) S ERRORS("Restore",1)="" D ERRLOG^SDES2JSON(.ERRORS,52,"Clinic stop code restriction invalid. MUST be corrected before continuing.")
Q:$D(ERRORS)
S DATETIME=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,DATETIME,CLINIC,1,45,46) ;
I (RESTORETYPE'="P")&(RESTORETYPE'="F") S ERRORS("Restore",1)="" D ERRLOG^SDES2JSON(.ERRORS,52,"Invalid Restore type value.") Q
I (RESTORETYPE="F")&($P(DATETIME,".",2)'="") S ERRORS("Restore",1)="" D ERRLOG^SDES2JSON(.ERRORS,52,"No time needed for Full restore.")
I (RESTORETYPE="P")&($P(DATETIME,".",2)="") S ERRORS("Restore",1)="" D ERRLOG^SDES2JSON(.ERRORS,52,"Start time of period to restore is required.")
Q
;
VERIFYCANCEL(ERRORS,CLINIC,DATETIME) ;Verify that the clinic has cancellation for that a date or datetime
N CURRENTSCHEDULE
S CURRENTSCHEDULE=$$GET1^DIQ(44.005,$P(DATETIME,".")_","_CLINIC_",",1)
I (CURRENTSCHEDULE'["CANCELLED")&(CURRENTSCHEDULE'["X") D ERRLOG^SDES2JSON(.ERRORS,52,"Clinic has not been cancelled for that date. Cannot restore.")
Q
;
FULLRESTORE(RETURN,CLINIC,DATETIME) ;perform a full day restore for date provided
N CURRENTSCHEDULE,RESTOREPATTERN,FDA,SDDATE
S SDDATE=$P(DATETIME,".")
S CURRENTSCHEDULE=$$GET1^DIQ(44.005,SDDATE_","_CLINIC_",",1)
I (CURRENTSCHEDULE'["CANCELLED") D RETCANPERIODS(.ERRORS,CLINIC,DATETIME) Q
D GETRETSTOREVALUE(.RESTOREPATTERN,CLINIC,SDDATE)
S FDA(44.005,SDDATE_","_CLINIC_",",1)=RESTOREPATTERN
D FILE^DIE(,"FDA") K FDA
K ^SC(CLINIC,"ST",SDDATE,"CAN")
D UPDATETMP(CLINIC,SDDATE,,"UC","RESTORED - DAY")
S RETURN("Restore",1)="Restore completed successfully"
Q
;
PARTIALRESTORE(ERRORS,RETURN,CLINIC,DATETIME,STARTHOUR,INCREMENT) ;perform partial day restore
N RESTORESTART,RESTOREEND,SDATE,FDA,RESTOREDSCHEDULE,CURRENTSCHEDULE,RESTOREPATTERN,ENDPOSITION,STARTPOSITION
S RESTORESTART=$P($$GET1^DIQ(44.05,DATETIME_","_CLINIC_",",.01,"I"),".",2)
I RESTORESTART="" D RETCANPERIODS(.ERRORS,CLINIC,DATETIME) Q
;restore the sent in time period
S RESTOREEND=$$GET1^DIQ(44.05,DATETIME_","_CLINIC_",",1,"I")
D FORMATTIME(.RESTORESTART)
D FORMATTIME(.RESTOREEND)
D GETPOSITION(.STARTPOSITION,RESTORESTART,STARTHOUR,INCREMENT)
D GETPOSITION(.ENDPOSITION,RESTOREEND,STARTHOUR,INCREMENT)
S SDDATE=$P(DATETIME,".")
S CURRENTSCHEDULE=$$GET1^DIQ(44.005,SDDATE_","_CLINIC_",",1)
D GETRETSTOREVALUE(.RESTOREPATTERN,CLINIC,SDDATE)
S RESTOREDSCHEDULE=$E(CURRENTSCHEDULE,1,STARTPOSITION-1)_$E(RESTOREPATTERN,STARTPOSITION,ENDPOSITION)_$E(CURRENTSCHEDULE,ENDPOSITION+1,80)
S FDA(44.005,SDDATE_","_CLINIC_",",1)=RESTOREDSCHEDULE
D FILE^DIE(,"FDA") K FDA
S FDA(44.05,DATETIME_","_CLINIC_",",.01)="@"
D FILE^DIE(,"FDA") K FDA
D FILE^DIE(,"FDA") K FDA
K ^SC(CLINIC,"S",DATETIME,"MES") ;to prevent issues with roll and scroll need to kill off the entire node.
I RESTOREDSCHEDULE'["X" K ^SC(CLINIC,"ST",SDDATE,"CAN")
D UPDATETMP(CLINIC,RESTORESTART,RESTOREEND,"UP","RESTORED - PARTIAL DAY")
S RETURN("Restore",1)="Restore completed successfully"
Q
;
RETCANPERIODS(ERRORS,CLINIC,DATETIME) ; if sent in time is not cancelled return time periods that are cancelled
N NEWDATE,STARTDATE,CNT,ECNT
S STARTDATE=$P(DATETIME,"."),NEWDATE=STARTDATE
S CNT=1
S ECNT=2
D ERRLOG^SDES2JSON(.ERRORS,52,"Not a cancelled period. Must send defined cancelled period.")
F S NEWDATE=$O(^SC(CLINIC,"SDCAN",NEWDATE)) Q:$P(NEWDATE,".")'=STARTDATE D
. N STARTTIME,ENDTIME
. S STARTTIME=$$GET1^DIQ(44.05,NEWDATE_","_CLINIC_",",.01,"I")
. S ENDTIME=$$GET1^DIQ(44.05,NEWDATE_","_CLINIC_",",1,"I")
. S ENDTIME=$E(ENDTIME,1,2)_":"_$E(ENDTIME,3,4)
. S ERRORS("Error",2,"Restore Periods",CNT)=$$FMTISO^SDAMUTDT($$GET1^DIQ(44.05,NEWDATE_","_CLINIC_",",.01,"I"),CLINIC)
. S ERRORS("Error",2,"Restore Periods",CNT)=ERRORS("Error",2,"Restore Periods",CNT)_" (to restore: "_$$FMTISO^SDAMUTDT(STARTTIME,CLINIC)
. S ERRORS("Error",2,"Restore Periods",CNT)=ERRORS("Error",2,"Restore Periods",CNT)_" to "_$$FMTISO^SDAMUTDT($P(STARTTIME,".")_"."_$TR(ENDTIME,":"),CLINIC)_")"
. S ECNT=ECNT+1
. S CNT=CNT+1
Q
;
FORMATTIME(TIME) ;add zeros to fileman time where needed
S TIME=$E((TIME_"0000"),1,4)
Q
;
GETRETSTOREVALUE(RESTOREPATTERN,CLINIC,PATTERNDATE) ;need to define pattern
;if ,9 node exists, there should be an OST record. Would want to get that record for restore.
;if no ',9) node exists, then get T_# record and build the front end
N DAYOFWEEK,SUBFILE,SDPATTERNDATE
I $$GET1^DIQ(44.005,PATTERNDATE_","_CLINIC_",",3,"I")'="" S RESTOREPATTERN=$$GET1^DIQ(44.0002,PATTERNDATE_","_CLINIC_",",1) Q
S DAYOFWEEK=$$DOW^XLFDT(PATTERNDATE,1)
S SUBFILE=$S(DAYOFWEEK=0:44.06,DAYOFWEEK=1:44.07,DAYOFWEEK=2:44.08,DAYOFWEEK=3:44.09,DAYOFWEEK=4:44.008,DAYOFWEEK=5:44.009,DAYOFWEEK=6:44.0001,1:1)
I SUBFILE=1 D ERRLOG^SDES2JSON(.ERRORS,52,"Cannot find Mastern pattern for T"_DAYOFWEEK)
S SDPATTERNDATE=$O(^SC(CLINIC,"T"_DAYOFWEEK,PATTERNDATE))
S RESTOREPATTERN=$P("SU^MO^TU^WE^TH^FR^SA","^",DAYOFWEEK+1)_" "_$E(PATTERNDATE,6,7)_$J("",(2*INCREMENT)-6)_$$GET1^DIQ(SUBFILE,SDPATTERNDATE_","_CLINIC_",",1,"I")
Q
;
GETPOSITION(POSITION,TIME,DISPSTART,INCREMENT) ;given time returns back character string position
NEW MINUTES
S MINUTES=$E(TIME,3,4)
S POSITION=TIME\100-DISPSTART*INCREMENT+(MINUTES*INCREMENT\60)*2+(2*INCREMENT)
Q
;
UPDATETMP(CLINIC,STARTDATE,ENDDATE,FUNCTION,COMMENT) ;
D EN^SDTMPHLC(CLINIC,STARTDATE,$G(ENDDATE),FUNCTION,COMMENT)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2RSTCAVAIL 7638 printed Nov 22, 2024@18:04:31 Page 2
SDES2RSTCAVAIL ;ALB/LAB - VISTA SCHEDULING SDES2 RESTORE CLIN AVAIL ;OCT 30, 2023
+1 ;;5.3;Scheduling;**861,864,875**;Aug 13, 1993;Build 25
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 QUIT
+4 ;
RESTORE(RESULT,SDCONTEXT,SDRESTORE) ;
+1 NEW ERRORS,RETURN
+2 ;validate context array for accuracy
+3 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+4 IF $DATA(ERRORS)
SET ERRORS("Restore",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+5 ;
+6 ;set up needed variables and validate
+7 ;
+8 DO ASSIGNVARS(.CLINIC,.DATETIME,.RESTORETYPE)
+9 DO VALIDATE(.ERRORS,CLINIC,.DATETIME,RESTORETYPE)
+10 IF $DATA(ERRORS)
SET ERRORS("Restore",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+11 DO GETCLINICINFO(CLINIC,.INCREMENT,.STARTHOUR,DATETIME,.CANCELDATE)
+12 IF $DATA(ERRORS)
SET ERRORS("Restore",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+13 ;
+14 ; verify that date/time has cancellation
+15 ;
+16 DO VERIFYCANCEL(.ERRORS,CLINIC,DATETIME)
+17 IF $DATA(ERRORS)
SET ERRORS("Restore",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+18 ;
+19 if RESTORETYPE="F"
DO FULLRESTORE(.RETURN,CLINIC,DATETIME)
+20 if RESTORETYPE="P"
DO PARTIALRESTORE(.ERRORS,.RETURN,CLINIC,DATETIME,STARTHOUR,INCREMENT)
+21 IF $DATA(ERRORS)
SET ERRORS("Restore",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+22 DO BUILDJSON^SDES2JSON(.RESULT,.RETURN)
+23 QUIT
+24 ;
GETCLINICINFO(CLINIC,INCREMENT,STARTHOUR,DATETIME,CANCELDATE) ;assign variables needed from clinic
+1 SET INCREMENT=+$$GET1^DIQ(44,CLINIC_",",1917,"I")
+2 SET INCREMENT=$SELECT(INCREMENT<3:4,INCREMENT:INCREMENT,1:4)
+3 SET STARTHOUR=$$GET1^DIQ(44,CLINIC_",",1914,"I")
+4 if STARTHOUR=""
SET STARTHOUR=8
+5 SET CANCELDATE=$PIECE(DATETIME,".")
+6 QUIT
+7 ;
ASSIGNVARS(CLINIC,DATETIME,RESTORETYPE) ;assign variables from input array
+1 SET CLINIC=$GET(SDRESTORE("CLINIC IEN"))
+2 ;date for full datetime for partial
SET DATETIME=$GET(SDRESTORE("DATE OR DATETIME"))
+3 ;partial or full restore
SET RESTORETYPE=$GET(SDRESTORE("RESTORE TYPE"))
+4 QUIT
+5 ;
VALIDATE(ERRORS,CLINIC,DATETIME,RESTORETYPE) ; validate input array variables
+1 DO VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,CLINIC,1,"",18,19)
+2 if $DATA(ERRORS)
QUIT
+3 IF $$INACTIVE^SDES2UTIL(CLINIC)
SET ERRORS("Restore",1)=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Inactive clinic cannot restore availability.")
+4 if $DATA(ERRORS)
QUIT
+5 IF '$$CLNCK^SDUTL2(CLINIC,1)
SET ERRORS("Restore",1)=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Clinic stop code restriction invalid. MUST be corrected before continuing.")
+6 if $DATA(ERRORS)
QUIT
+7 ;
SET DATETIME=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,DATETIME,CLINIC,1,45,46)
+8 IF (RESTORETYPE'="P")&(RESTORETYPE'="F")
SET ERRORS("Restore",1)=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Invalid Restore type value.")
QUIT
+9 IF (RESTORETYPE="F")&($PIECE(DATETIME,".",2)'="")
SET ERRORS("Restore",1)=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"No time needed for Full restore.")
+10 IF (RESTORETYPE="P")&($PIECE(DATETIME,".",2)="")
SET ERRORS("Restore",1)=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Start time of period to restore is required.")
+11 QUIT
+12 ;
VERIFYCANCEL(ERRORS,CLINIC,DATETIME) ;Verify that the clinic has cancellation for that a date or datetime
+1 NEW CURRENTSCHEDULE
+2 SET CURRENTSCHEDULE=$$GET1^DIQ(44.005,$PIECE(DATETIME,".")_","_CLINIC_",",1)
+3 IF (CURRENTSCHEDULE'["CANCELLED")&(CURRENTSCHEDULE'["X")
DO ERRLOG^SDES2JSON(.ERRORS,52,"Clinic has not been cancelled for that date. Cannot restore.")
+4 QUIT
+5 ;
FULLRESTORE(RETURN,CLINIC,DATETIME) ;perform a full day restore for date provided
+1 NEW CURRENTSCHEDULE,RESTOREPATTERN,FDA,SDDATE
+2 SET SDDATE=$PIECE(DATETIME,".")
+3 SET CURRENTSCHEDULE=$$GET1^DIQ(44.005,SDDATE_","_CLINIC_",",1)
+4 IF (CURRENTSCHEDULE'["CANCELLED")
DO RETCANPERIODS(.ERRORS,CLINIC,DATETIME)
QUIT
+5 DO GETRETSTOREVALUE(.RESTOREPATTERN,CLINIC,SDDATE)
+6 SET FDA(44.005,SDDATE_","_CLINIC_",",1)=RESTOREPATTERN
+7 DO FILE^DIE(,"FDA")
KILL FDA
+8 KILL ^SC(CLINIC,"ST",SDDATE,"CAN")
+9 DO UPDATETMP(CLINIC,SDDATE,,"UC","RESTORED - DAY")
+10 SET RETURN("Restore",1)="Restore completed successfully"
+11 QUIT
+12 ;
PARTIALRESTORE(ERRORS,RETURN,CLINIC,DATETIME,STARTHOUR,INCREMENT) ;perform partial day restore
+1 NEW RESTORESTART,RESTOREEND,SDATE,FDA,RESTOREDSCHEDULE,CURRENTSCHEDULE,RESTOREPATTERN,ENDPOSITION,STARTPOSITION
+2 SET RESTORESTART=$PIECE($$GET1^DIQ(44.05,DATETIME_","_CLINIC_",",.01,"I"),".",2)
+3 IF RESTORESTART=""
DO RETCANPERIODS(.ERRORS,CLINIC,DATETIME)
QUIT
+4 ;restore the sent in time period
+5 SET RESTOREEND=$$GET1^DIQ(44.05,DATETIME_","_CLINIC_",",1,"I")
+6 DO FORMATTIME(.RESTORESTART)
+7 DO FORMATTIME(.RESTOREEND)
+8 DO GETPOSITION(.STARTPOSITION,RESTORESTART,STARTHOUR,INCREMENT)
+9 DO GETPOSITION(.ENDPOSITION,RESTOREEND,STARTHOUR,INCREMENT)
+10 SET SDDATE=$PIECE(DATETIME,".")
+11 SET CURRENTSCHEDULE=$$GET1^DIQ(44.005,SDDATE_","_CLINIC_",",1)
+12 DO GETRETSTOREVALUE(.RESTOREPATTERN,CLINIC,SDDATE)
+13 SET RESTOREDSCHEDULE=$EXTRACT(CURRENTSCHEDULE,1,STARTPOSITION-1)_$EXTRACT(RESTOREPATTERN,STARTPOSITION,ENDPOSITION)_$EXTRACT(CURRENTSCHEDULE,ENDPOSITION+1,80)
+14 SET FDA(44.005,SDDATE_","_CLINIC_",",1)=RESTOREDSCHEDULE
+15 DO FILE^DIE(,"FDA")
KILL FDA
+16 SET FDA(44.05,DATETIME_","_CLINIC_",",.01)="@"
+17 DO FILE^DIE(,"FDA")
KILL FDA
+18 DO FILE^DIE(,"FDA")
KILL FDA
+19 ;to prevent issues with roll and scroll need to kill off the entire node.
KILL ^SC(CLINIC,"S",DATETIME,"MES")
+20 IF RESTOREDSCHEDULE'["X"
KILL ^SC(CLINIC,"ST",SDDATE,"CAN")
+21 DO UPDATETMP(CLINIC,RESTORESTART,RESTOREEND,"UP","RESTORED - PARTIAL DAY")
+22 SET RETURN("Restore",1)="Restore completed successfully"
+23 QUIT
+24 ;
RETCANPERIODS(ERRORS,CLINIC,DATETIME) ; if sent in time is not cancelled return time periods that are cancelled
+1 NEW NEWDATE,STARTDATE,CNT,ECNT
+2 SET STARTDATE=$PIECE(DATETIME,".")
SET NEWDATE=STARTDATE
+3 SET CNT=1
+4 SET ECNT=2
+5 DO ERRLOG^SDES2JSON(.ERRORS,52,"Not a cancelled period. Must send defined cancelled period.")
+6 FOR
SET NEWDATE=$ORDER(^SC(CLINIC,"SDCAN",NEWDATE))
if $PIECE(NEWDATE,".")'=STARTDATE
QUIT
Begin DoDot:1
+7 NEW STARTTIME,ENDTIME
+8 SET STARTTIME=$$GET1^DIQ(44.05,NEWDATE_","_CLINIC_",",.01,"I")
+9 SET ENDTIME=$$GET1^DIQ(44.05,NEWDATE_","_CLINIC_",",1,"I")
+10 SET ENDTIME=$EXTRACT(ENDTIME,1,2)_":"_$EXTRACT(ENDTIME,3,4)
+11 SET ERRORS("Error",2,"Restore Periods",CNT)=$$FMTISO^SDAMUTDT($$GET1^DIQ(44.05,NEWDATE_","_CLINIC_",",.01,"I"),CLINIC)
+12 SET ERRORS("Error",2,"Restore Periods",CNT)=ERRORS("Error",2,"Restore Periods",CNT)_" (to restore: "_$$FMTISO^SDAMUTDT(STARTTIME,CLINIC)
+13 SET ERRORS("Error",2,"Restore Periods",CNT)=ERRORS("Error",2,"Restore Periods",CNT)_" to "_$$FMTISO^SDAMUTDT($PIECE(STARTTIME,".")_"."_$TRANSLATE(ENDTIME,":"),CLINIC)_")"
+14 SET ECNT=ECNT+1
+15 SET CNT=CNT+1
End DoDot:1
+16 QUIT
+17 ;
FORMATTIME(TIME) ;add zeros to fileman time where needed
+1 SET TIME=$EXTRACT((TIME_"0000"),1,4)
+2 QUIT
+3 ;
GETRETSTOREVALUE(RESTOREPATTERN,CLINIC,PATTERNDATE) ;need to define pattern
+1 ;if ,9 node exists, there should be an OST record. Would want to get that record for restore.
+2 ;if no ',9) node exists, then get T_# record and build the front end
+3 NEW DAYOFWEEK,SUBFILE,SDPATTERNDATE
+4 IF $$GET1^DIQ(44.005,PATTERNDATE_","_CLINIC_",",3,"I")'=""
SET RESTOREPATTERN=$$GET1^DIQ(44.0002,PATTERNDATE_","_CLINIC_",",1)
QUIT
+5 SET DAYOFWEEK=$$DOW^XLFDT(PATTERNDATE,1)
+6 SET SUBFILE=$SELECT(DAYOFWEEK=0:44.06,DAYOFWEEK=1:44.07,DAYOFWEEK=2:44.08,DAYOFWEEK=3:44.09,DAYOFWEEK=4:44.008,DAYOFWEEK=5:44.009,DAYOFWEEK=6:44.0001,1:1)
+7 IF SUBFILE=1
DO ERRLOG^SDES2JSON(.ERRORS,52,"Cannot find Mastern pattern for T"_DAYOFWEEK)
+8 SET SDPATTERNDATE=$ORDER(^SC(CLINIC,"T"_DAYOFWEEK,PATTERNDATE))
+9 SET RESTOREPATTERN=$PIECE("SU^MO^TU^WE^TH^FR^SA","^",DAYOFWEEK+1)_" "_$EXTRACT(PATTERNDATE,6,7)_$JUSTIFY("",(2*INCREMENT)-6)_$$GET1^DIQ(SUBFILE,SDPATTERNDATE_","_CLINIC_",",1,"I")
+10 QUIT
+11 ;
GETPOSITION(POSITION,TIME,DISPSTART,INCREMENT) ;given time returns back character string position
+1 NEW MINUTES
+2 SET MINUTES=$EXTRACT(TIME,3,4)
+3 SET POSITION=TIME\100-DISPSTART*INCREMENT+(MINUTES*INCREMENT\60)*2+(2*INCREMENT)
+4 QUIT
+5 ;
UPDATETMP(CLINIC,STARTDATE,ENDDATE,FUNCTION,COMMENT) ;
+1 DO EN^SDTMPHLC(CLINIC,STARTDATE,$GET(ENDDATE),FUNCTION,COMMENT)
+2 QUIT
+3 ;