Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDOQMP2

SDOQMP2.m

Go to the documentation of this file.
SDOQMP2 ;LRVAMC/JRC ;ALB/SCK - Appointment monitoring ; 7/15/96
 ;;5.3;SCHEDULING;**47,179**;AUG 13, 1993
 ; MODIFIED FOR NATIONAL RELEASE
 Q
 ;
START D LOOP
 S $P(^TMP("SDPM",$J,0),U,2)=DT
 D KILL
 Q
LOOP S IEN=0 F  S IEN=$O(^TMP("APPT",$J,IEN)) Q:IEN'>0  D
 .S GET=$G(^TMP("APPT",$J,IEN)),DATE1=$P(GET,U,1),DATE2=$P(GET,U,2)
 .;S RUNDATE=$E(DATE1,4,5)_$E(DATE1,6,7)_$E(DATE1,2,3)
 .S RUNDATE=DATE1
 .I DATE2=0 S (NEXTDATE,SLOT,TDCNT,FTCNT,XSLOT,FSLOT,OPENDAYS,DIFF,TIME)=0 D WRITE Q
 .S X2=DATE1,X1=DATE2 D ^%DTC S DIFF=X
 .S NEXTDATE=DATE2
 .;S NEXTDATE=$E(DATE2,4,5)_$E(DATE2,6,7)_$E(DATE2,2,3)
 .S SLOT=0
 .D SLOT
 .S TDCNT=0
 .D:SLOT>0 TODAY
 .S FSLOT=0,XSLOT=0
 .D FTSLOT
 .S TIME=".1200"
 .D TIME
 .S FTCNT=0
 .D:FSLOT>0 APPT
 .D WRITE
 Q
SLOT S SLDATE=DT
 I '$D(^SC(IEN,"ST",SLDATE,1)) N DATE S DATE=DT D FIX
 S SLOTWK=$G(^SC(IEN,"ST",SLDATE,1))
 S:SLOTWK="" SLOT=0
 S SLOTWK=$E(SLOTWK,6,$L(SLOTWK))
 Q:SLOTWK'["["
 S SLOTWK=$TR(SLOTWK,"[]*| ","")
 S SLOT=$L(SLOTWK)
 Q
TODAY S DATE=DT_".000001",END=DT_".595959"
 F  S DATE=$O(^SC(IEN,"S",DATE)) Q:DATE'>0!(DATE>END)  D
 .S NODE=0 F  S NODE=$O(^SC(IEN,"S",DATE,NODE)) Q:NODE'>0  D
 ..S NODE2=0 F  S NODE2=$O(^SC(IEN,"S",DATE,NODE,NODE2)) Q:NODE2'>0  D
 ...S DFN=$P($G(^SC(IEN,"S",DATE,NODE,NODE2,0)),U)
 ...S TDCNT=TDCNT+1
 Q
FTSLOT S X="T" D ^%DT S DATE=Y,OPENDAYS=0,SW=0
 F DATE=DATE:0 S X1=DATE,X2=1 D C^%DTC S DATE=X Q:DATE>DATE2  D CHECK
 Q
CHECK I '$D(^SC(IEN,"ST",DATE,1)) D FIX
 S SLOTWK=$G(^SC(IEN,"ST",DATE,1)) Q:'$L(SLOTWK)
 Q:SLOTWK["CANCEL"
 Q:SLOTWK'["["
 S SLOTWK=$E(SLOTWK,6,$L(SLOTWK)),SLOTWK=$TR(SLOTWK,"[]*| ","")
 I DATE=DATE2 D SLTCNT S FSLOT=FSLOT+XSLOT,OPENDAYS=OPENDAYS+1 Q
 S FSLOT=FSLOT+$L(SLOTWK),OPENDAYS=OPENDAYS+1
 Q
SLTCNT F %=1:1:$L(SLOTWK) Q:SW=1  D
 .S NUMBER=$E(SLOTWK,%)
 .I NUMBER'=0 S SW=1 Q
 .S XSLOT=XSLOT+1
 Q
TIME S (SW2,XCNT,XCNT1)=0
 S SLOTWK1=$G(^SC(IEN,"ST",DATE2,1))
 S SLOTWK1=$E(SLOTWK1,6,$L(SLOTWK1))
 S SLOTWK1=$TR(SLOTWK1,")(]* ","")
 F %=1:1:$L(SLOTWK1) Q:SW2=1  D
 .S NMBR=$E(SLOTWK1,%)
 .S:NMBR="|" XCNT=XCNT+1
 .S:NMBR="[" SAVE=1,XCNT1=XCNT1+1
 . ;====================== CHANGE SCK ===============================
 . I +$G(SAVE)=1&(XCNT1=XSLOT) S SW2=1
 ;
 I XCNT=0 S TIME=$S(XCNT1=1:"0800",XCNT1=2:"0900",XCNT1=3:"1000",XCNT1=4:"1100",1:"1200")
 I XCNT=1 S TIME=$S(XCNT1=1:"0900",XCNT1=2:"1000",XCNT1=3:"1100",XCNT1=4:"1200",1:"1300")
 I XCNT=2 S TIME=$S(XCNT1=1:"1000",XCNT1=2:"1100",XCNT1=3:"1200",XCNT1=4:"1300",1:"1300")
 I XCNT=3 S TIME=$S(XCNT1=0:"1100",XCNT1=1:"1200",XCNT1=2:"1300",XCNT1=3:"1400",XCNT1=4:"1500",1:"1500")
 I XCNT=4 S TIME=$S(XCNT1=0:"1200",XCNT1=1:"1300",XCNT1=2:"1400",XCNT1=3:"1500",XCNT1=4:"1600",1:"1600")
 I XCNT>4 S TIME=$S(XCNT1=0:"1200",XCNT1=1:"1300",XCNT1=2:"1400",XCNT1=3:"1500",XCNT1=4:"1600",1:"1600")
 Q
APPT S X="T+1" D ^%DT S DATE=Y_".000001",END=DATE2_"."_TIME
 F  S DATE=$O(^SC(IEN,"S",DATE)) Q:DATE'>0!(DATE>END)  D
 .S NODE=0 F  S NODE=$O(^SC(IEN,"S",DATE,NODE)) Q:NODE'>0  D
 ..S NODE2=0 F  S NODE2=$O(^SC(IEN,"S",DATE,NODE,NODE2)) Q:NODE2'>0  D
 ...S DFN=$P($G(^SC(IEN,"S",DATE,NODE,NODE2,0)),U)
 ...S FTCNT=FTCNT+1
 Q
 ;
WRITE ;
 N PMDIV
 S PMDIV=$P($G(^SC(IEN,0)),U,15)
 S ^TMP("SDPM",$J,IEN,RUNDATE)=NEXTDATE_U_SLOT_U_TDCNT_U_FSLOT_U_FTCNT_U_OPENDAYS_U_$S(PMDIV]"":PMDIV,1:"ND")
 Q
 ;
KILL K IEN,DATE1,DATE2,DATE,CNT,CNT1,CNT2,NEXTDATE,RUNDATE,SLOTS,APPTS,OPENDAYS,TIME
 K ^TMP("APPT",$J)
 Q
FIX ;DH=PATTERN  X=DATE
 N SC,DAY,DH,DIFF,DOW,DR,DR1,S,SB,SDAPPT,SDAPPT1,SDSI,SDSL,SI,SL,SM,SS,STARTDAY,STR,SDSOH,HSI,P,ST S SC=IEN
SETX Q:'$D(^SC(SC,"SL"))  S SDSL=^("SL"),SL=+^("SL"),X=$P(SDSL,U,3),STARTDAY=$S($L(X):X,1:8),X=$P(SDSL,U,6),HSI=$S('X:4,X<3:8/X,1:2),SI=$S(X:X,1:4),SDSI=SI S:SI=1 SI=4 S:SI=2 SI=4 S SDSOH=$S($P(SDSL,U,8)']"":0,1:1)
 S X=DATE D DW^%DTC S DAY=$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR",U,Y+1),DOW=Y,X=DATE
 S SS=+$O(^SC(SC,"T"_DOW,DATE)),SB=STARTDAY-1/100,STR="{}&%?#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz"
 Q:'$D(^SC(SC,"T"_DOW,SS,1))  S DH=^(1) Q:DH=""
 D SM ;G:'SDAPPT OVR
SDAPPT S DR=+$O(^SC(SC,"S",DATE)),SDAPPT=0 I DR>(DATE_.9) S DR=DATE G OVR
I S I=DR#1-SB*100,I=I#1*SI\.6+(I\1*SI)*2,S=$E(SM,I,999),SM=$E(SM,1,I-1)
 I $D(^SC(SC,"S",DR,"MES")) D CAN S X=SDSAVX K SDSAVX S DR=+$O(^SC(SC,"S",DR)) G:DR\1=X I G OVR
 F Y=0:0 S Y=$O(^SC(SC,"S",DR,1,Y)) Q:Y'>0  I $P(^(Y,0),"^",9)'["C" S SDSL=$P(^(0),U,2)/SL*(SL\(60/SDSI))*HSI-HSI F I=0:HSI:SDSL S ST=$E(S,I+2) S:ST="" ST=" " S S=$E(S,1,I+2-1)_$E(STR,$F(STR,ST)-2)_$E(S,I+3,999)
 S SM=SM_S,DR=$O(^SC(SC,"S",DR)) I DR\1=X G I
OVR I $L(SM)>SM S ^SC(SC,"ST",X,0)=X,^(1)=SM S:SS'>0 ^(9)=SC
 Q  ;G Z
SM S SM=$P("SU^MO^TU^WE^TH^FR^SA",U,DOW+1)_" "_$E(X,6,7)_$J("",SI+SI-6)_DH_$J("",64-$L(DH)) Q
APPT1 S DR=+$O(^SC(SC,"S",DATE)),SDAPPT=0 I DR>(DATE_.9) S DR=DATE Q
 F DR1=DATE:0 S DR1=$O(^SC(SC,"S",DR1)) Q:DR1'>0!(DR1>(DATE+1))!(SDAPPT)  S:$D(^(DR1,"MES")) SDAPPT=1 F SDAPPT1=0:0 S SDAPPT1=$O(^SC(SC,"S",DR1,1,SDAPPT1)) Q:SDAPPT1'>0  I $D(^(SDAPPT1,0)) S SDAPPT=$S($P(^(0),"^",9)="C":0,1:1)
 Q
CAN S SDSAVX=X Q:'$D(^SC(SC,"SDCAN",DR,0))  S X=$E($P(DR,".",2)_"0000",1,4),I=SM_S D TT S ST=%,X=$P(^SC(SC,"SDCAN",DR,0),"^",2) D TT S I=I_$J("",%-$L(I)),Y=""
 F X=0:2:% S S=$E(I,X+SI+SI),P=$S(X<ST:S_$E(I,X+1+SI+SI),X=%:$S(Y="[":Y,1:S)_$E(I,X+1+SI+SI),1:$S(Y="["&(X=ST):"]",1:"X")_"X"),Y=$S(S="]":"",S="[":S,1:Y),I=$E(I,1,X-1+SI+SI)_P_$E(I,X+2+SI+SI,999)
 S SM=I Q
TT S %=$E(X,3,4),%=X\100-STARTDAY*SI+(%*SI\60)*2 Q