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

SDEC33.m

Go to the documentation of this file.
SDEC33 ;ALB/SAT,WTC - VISTA SCHEDULING RPCS ;Feb 12, 2020@15:22
 ;;5.3;Scheduling;**627,694**;Aug 13, 1993;Build 61
 ;
 Q
 ;
REBKNEXT(SDECY,SDECDATE,SDECRES,SDECTPID) ; find the next ACCESS BLOCK in resource SDECRES after SDECSTART
 ;REBKNEXT(SDECY,SDECDATE,SDECRES,SDECTPID)  external parameter tag is in SDEC
 ;SDECDATE - Date in external form
 ;SDECRES  - Resource Name from the NAME field of the SDEC RESOURCE file
 ;SDECTPID - Access Type Id - Pointer to the SDEC ACCESS TYPE file
 ;Returns 1 in ERRORID and date in NEXTBLOCK if a block was found or NULL in NEXTBLOCK of no date found
 ;Otherwise, returns 0 and error message in ERRORTEXT
 ;If SDECTPID = 0 then any access type match
 ;
 N SDAB,SDECI,SDECIENS,SDI,%DT,SDECMSG,X,Y,SDECRESD,SDECFND,SDECIEN,SDECNOD,SDECATID
 S SDAB="^TMP("_$J_",""SDEC"",""BLKS"")"
 K @SDAB
 S SDECY="^TMP(""SDEC"","_$J_")"
 K @SDECY
 S SDECI=0
 S ^TMP("SDEC",$J,SDECI)="I00020ERRORID^D00010NEXTBLOCK^T00030ERRORTEXT"_$C(30)
 ;
 I SDECRES="" D ERR2("","SDEC REBOOK NEXT BLOCK: Invalid resource name") Q
 I '$D(^SDEC(409.831,"B",SDECRES)) D ERR2(SDECRES,"SDEC REBOOK NEXT BLOCK: Invalid resource name") Q
 S SDECRESD=$O(^SDEC(409.831,"B",SDECRES,0))
 I '+SDECRESD D ERR2(SDECRES,"SDEC REBOOK NEXT BLOCK: Invalid resource name") Q
 S X=SDECDATE,%DT="XT" D ^%DT
 I Y=-1 D ERR2(1,"SDEC REBOOK NEXT BLOCK: Invalid datetime") Q
 S SDECDATE=$P(Y,".")
 ;
 S SDECFND=0
 D GETSLOTS^SDEC04(SDAB,SDECRESD,SDECDATE,$$FMADD^XLFDT(SDECDATE,10))
 S SDI=0 F  S SDI=$O(@SDAB@(SDI)) Q:SDI'>0  D
 .S SDECNOD=@SDAB@(SDI)
 .Q:+$P(SDECNOD,U,4)=0  ;Slots
 .S SDECATID=$P(SDECNOD,U,5)
 .I SDECTPID=0!(SDECATID=SDECTPID) S SDECFND=$P(SDECNOD,U,2) Q
 ;
 I SDECFND=0 S SDECFND=""
 ;
 ;  Change date/time conversion so midnight is handled properly.  wtc 694 5/17/18
 ;
 E  S SDECFND=$$FMTONET^SDECDATE(SDECFND,"Y") ;
 ;E  S Y=SDECFND X ^DD("DD") S SDECFND=Y
 ;S SDECFND=$TR(SDECFND,"@"," ")
 S SDECI=SDECI+1
 S ^TMP("SDEC",$J,SDECI)="1^"_SDECFND_"^"_$C(30)_$C(31)
 Q
 ;
SETRBOOK(SDECY,SDECAPPT,SDECDATE) ;Sets rebook date into appointment
 ;SETRBOOK(SDECY,SDECAPPT,SDECDATE)  external parameter tag is in SDEC
 ;SDECAPPT - Appointment ID
 ;SDECDATE - Rebook Datetime in external format
 ;Called by SDEC REBOOK SET
 ;
 ;ErrorID:
 ; 0 if a problem.  Message in ERRORTEXT
 ; 1 if OK
 ;
 N SDECFDA,SDECI,SDECIENS,%DT,SDECMSG,X,Y
 S SDECY="^TMP(""SDEC"","_$J_")"
 K @SDECY
 S SDECI=0
 S ^TMP("SDEC",$J,SDECI)="I00020ERRORID^T00030ERRORTEXT"_$C(30)
 ;
 I '+SDECAPPT
 I '$D(^SDEC(409.84,SDECAPPT,0)) D ERR(1,"SDEC REBOOK SET: Invalid appointment ID") Q
 ;
 ;  Change date/time conversion so midnight is handled properly.  wtc 694 5/17/18
 ;
 S SDECDATE=$$NETTOFM^SDECDATE(SDECDATE,"Y","N") I SDECDATE=-1 D ERR(1,"SDEC REBOOK SET: Invalid rebook datetime") Q
 ;S X=SDECDATE,%DT="XT" D ^%DT
 ;I Y=-1 D ERR(1,"SDEC REBOOK SET: Invalid rebook datetime") Q
 ;S SDECDATE=Y
 S SDECIENS=SDECAPPT_","
 S SDECFDA(409.84,SDECIENS,.11)=SDECDATE
 ;
 K SDECMSG
 D FILE^DIE("","SDECFDA","SDECMSG")
 S SDECI=SDECI+1
 S ^TMP("SDEC",$J,SDECI)="1^"_$C(31)
 ;
 Q
 ;
ERR(SDECERID,ERRTXT) ;Error processing
 S:'+$G(SDECI) SDECI=999999
 S SDECI=SDECI+1
 S ^TMP("SDEC",$J,SDECI)=SDECERID_"^"_ERRTXT_$C(30)
 S SDECI=SDECI+1
 S ^TMP("SDEC",$J,SDECI)=$C(31)
 Q
 ;
ERROR ;
 D ^%ZTER
 I '+$G(SDECI) N SDECI S SDECI=999999
 S SDECI=SDECI+1
 D ERR(0,"SDEC33 Error")
 Q
 ;
ERR2(SDECERID,ERRTXT) ;Error processing
 S:'+$G(SDECI) SDECI=999999
 S SDECI=SDECI+1
 S ^TMP("SDEC",$J,SDECI)=SDECERID_"^^"_ERRTXT_$C(30)
 S SDECI=SDECI+1
 S ^TMP("SDEC",$J,SDECI)=$C(31)
 Q
 ;
ERROR2 ;
 D ^%ZTER
 I '+$G(SDECI) N SDECI S SDECI=999999
 S SDECI=SDECI+1
 D ERR2(0,"SDEC33 Error")
 Q