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

SDEC01B.m

Go to the documentation of this file.
SDEC01B ;ALB/SAT - VISTA SCHEDULING RPCS ;APR 08, 2016
 ;;5.3;Scheduling;**627,642,722**;Aug 13, 1993;Build 26
 ;
 Q
 ;
RESDG(SDRES)  ;remove SDEC RESOURCE from all SDEC RESOURCE GROUPs
 N SDECY,SDI,SDJ
 S SDECY=""
 S SDRES=$G(SDRES) Q:'+SDRES  Q:'$D(^SDEC(409.831,+SDRES,0))
 S SDI=9999999 F  S SDI=$O(^SDEC(409.832,"AB",+SDRES,SDI),-1) Q:SDI=""  D
 .D DELRGI^SDEC(.SDECY,SDI,SDRES)
 Q
 ;
RESDGA     ;remove all inactive SDEC RESOURCEs from all SDEC RESOURCE GROUPs
 N SDI,X
 S SDI=0 F  S SDI=$O(^SDEC(409.831,SDI)) Q:SDI'>0  S X=$$GET1^DIQ(409.831,SDI_",",.02)="YES"   ;computed routine calls RESDG
 Q
 ;
RESCK(SDRES)      ;check if SDEC RESOURCE is inactive ;remove from all SDEC RESOURCE GROUPs if inactive
 N X
 S SDRES=$G(SDRES) Q:'+SDRES  Q:'$D(^SDEC(409.831,+SDRES,0))
 S X=$$GET1^DIQ(409.831,SDRES_",",.02)="YES"   ;computed routines calls RESDG
 Q
 ;
USRDG(SDDUZ) ;remove SDEC RESOURCEs associated with SDDUZ from all SDEC RESOURCE GROUPs
 ; SDDUZ = pointer to NEW PERSON file 200
 N SDRES
 S SDRES=0 F  S SDRES=$O(^SDEC(409.831,"AC","P",SDDUZ,SDRES)) Q:SDRES=""  D
 .D RESDG(SDRES)
 Q
 ;
 ;
RESPRV1(SDPRV,SDCL,SDPRVN)  ;process 1 provider
 N EFFDT,EXPDT,PACT,SDFDA,SDIEN,SDMSG,SDRES
 ;look for existing resource
 S (EFFDT,EXPDT)=""
 S SDCL=$G(SDCL) Q:'$D(^SC(+SDCL,0))
 S SDPRV=$G(SDPRV) Q:'$D(^VA(200,+SDPRV,0))
 S SDPRVN=$G(SDPRVN) S:SDPRVN="" SDPRVN=$$GET1^DIQ(200,SDPRV_",",.01)
 S SDRES=$O(^SDEC(409.831,"AC","P",SDPRV,0))
 I SDRES'="",$$CHKP(SDPRV,SDRES) Q  ;if entry found, update and quit
 ;S SDRES=$O(^SDEC(409.831,"B",SDPRVN,0))  ;look for existing SDEC RESOURCE id with provider name
 ;I SDRES'="",$$CHKP(SDPRV,SDRES) Q  ;if entry found, update and quit
 S SDRES="+1"
 S PACT=$$PC^SDEC45(SDPRV,DT,.EFFDT,.EXPDT)
 S:EXPDT="" EXPDT=DT
 ;
 K SDFDA,SDIEN,SDMSG
 S SDFDA=$NA(SDFDA(409.831,SDRES_","))
 S @SDFDA@(.01)=SDPRVN
 S @SDFDA@(.012)=SDPRV_";VA(200,"
 S @SDFDA@(.015)=$E($$NOW^XLFDT,1,12)
 S @SDFDA@(.016)=DUZ
 S:+PACT @SDFDA@(.021)=EXPDT
 S @SDFDA@(.04)=SDCL
 D UPDATE^DIE("","SDFDA","SDIEN","SDMSG")
 S SDRES=SDIEN(1)
 Q
CHKP(USER,SDRES) ;update existing provider resource entry
 ;returns 0=SDRES does not match USER ;1=matches and updated
 N EFFDT,EXPDT,RACT,PACT,RSN,RSTS,RSTYP,SDFDA,SCN,SDNOD,SCTS
 S RSTYP=$$GET1^DIQ(409.831,SDRES_",",.012,"I")
 Q:$P(RSTYP,";",1)'=USER 0
 ;
 S SCN=$$GET1^DIQ(200,USER_",",.01)
 S RSN=$$GET1^DIQ(409.831,SDRES_",",.01)
 S:SCN'=RSN SDFDA(409.831,SDRES_",",.01)=SCN
 ;
 S (EFFDT,EXPDT)=""
 S RACT=$$GET1^DIQ(409.831,SDRES_",",.02) S RACT=$S(RACT="YES":1,1:0)
 S PACT=$$PC^SDEC45(USER,DT,.EFFDT,.EXPDT)
 I RACT'=PACT D
 .S SDNOD=$G(^SDEC(409.831,SDRES,0))
 .I PACT=0 S SDFDA(409.831,SDRES_",",.021)="@",SDFDA(409.831,SDRES_",",.025)="@"
 .E  S SDFDA(409.831,SDRES_",",.021)=$S(EXPDT="":$$FMADD^XLFDT(DT,-1),EXPDT'>DT:EXPDT,1:$$FMADD^XLFDT(DT,-1)),SDFDA(409.831,SDRES_",",.025)="@"
 ;
 I $D(SDFDA) D UPDATE^DIE("","SDFDA")
 D:+PACT RESCK(SDRES)
 Q 1
 ;
CHKC(SDCL,SDRES) ;update existing clinic resource entry
 Q  ;  722 disabled to stop changing the resource file wtc 2/22/19
 N CINACT,CREACT,RINACT,RREACT,RSN,RSTS,RSTYP,SDFDA,SCN,SCTS
 S RSTYP=$$GET1^DIQ(409.831,SDRES_",",.012,"I")
 Q:$P(RSTYP,";",1)'=SDCL
 ;
 S SCN=$$GET1^DIQ(44,SDCL_",",.01)
 S RSN=$$GET1^DIQ(409.831,SDRES_",",.01)
 S:SCN'=RSN SDFDA(409.831,SDRES_",",.01)=SCN
 ;
 S CINACT=$$GET1^DIQ(44,SDCL_",",2505,"I")
 S RINACT=$$GET1^DIQ(409.831,SDRES_",",.021,"I")
 S:CINACT'=RINACT SDFDA(409.831,SDRES_",",.021)=CINACT,SDFDA(409.831,SDRES_",",.022)="@"
 S CREACT=$$GET1^DIQ(44,SDCL_",",2506,"I")
 S RREACT=$$GET1^DIQ(409.831,SDRES_",",.025)
 S:CREACT'=RREACT SDFDA(409.831,SDRES_",",.025)=CREACT,SDFDA(409.831,SDRES_",",.026)="@"
 ;
 S SCTS=$$GET1^DIQ(44,SDCL_",",1917,"I") S SCTS=$S(SCTS=6:10,SCTS=4:15,SCTS=3:20,SCTS=2:30,1:60)
 S RSTS=$$GET1^DIQ(409.831,SDRES_",",.03,"I")
 S:SCTS'=RSTS SDFDA(409.831,SDRES_",",.03)=SCTS  ;time scale
 ;
 I $D(SDFDA) D UPDATE^DIE("","SDFDA")
 Q
 ;
RESCLIN1(SDCL)   ;
 N SDCLN,SDDATA,SDFDA,SDFIELDS,SDFOUND,SDIEN,SDIN,SDLET,SDMSG,SDRES11,SDRESH,SDRN,SDMSG,SDTS,SDWP
 S SDFOUND=0
 ; .01 name; 2 type; 1912 len of appt; 2508 no show let; 2509 pre-appt let; 2510 clinic can let;
 S SDFIELDS=".01;2;50.01;1912;1917;2505;2506;2508;2509;2510"
 D GETS^DIQ(44,SDCL_",",SDFIELDS,"IE","SDDATA","SDMSG")
 I SDDATA(44,SDCL_",",2,"I")="C" D
 .;Q:SDDATA(44,SDCL_",",50.01,"I")=1  ;OOS?
 .S SDIN=SDDATA(44,SDCL_",",2505,"I"),SDRN=SDDATA(44,SDCL_",",2506,"I")
 .Q:$$INACT(SDIN,SDRN)
 .S SDCLN=SDDATA(44,SDCL_",",.01,"E")   ;clinic name
 .;look for existing to allow this post-init to be re-entrant
 .S SDRESH=0 F  S SDRESH=$O(^SDEC(409.831,"ALOC",SDCL,SDRESH)) Q:SDRESH'>0  D  Q:+SDFOUND
 ..S SDRES11=$$GET1^DIQ(409.831,SDRESH_",",.012,"I")
 ..I $P(SDRES11,";",2)="SC(",$P(SDRES11,";",1)=SDCL S SDFOUND=1
 .I +SDFOUND D CHKC(SDCL,SDRESH) Q
 .S SDRESH=$O(^SDEC(409.831,"B",$$UP^XLFSTR(SDCLN),0))  ;look for existing SDEC RESOURCE id with clinic name
 .I SDRESH'="" Q
 .S SDRESH="+1"
 .K SDFDA,SDIEN,SDMSG
 .S SDFDA=$NA(SDFDA(409.831,SDRESH_","))
 .S @SDFDA@(.01)=SDCLN
 .S @SDFDA@(.012)=SDCL_";SC("
 .S @SDFDA@(.015)=$E($$NOW^XLFDT,1,12)
 .S @SDFDA@(.016)=DUZ
 .I SDDATA(44,SDCL_",",2505,"I")'="" S @SDFDA@(.021)=SDDATA(44,SDCL_",",2505,"I")
 .I SDDATA(44,SDCL_",",2506,"I")'="" S @SDFDA@(.025)=SDDATA(44,SDCL_",",2506,"I")
 .S SDTS=SDDATA(44,SDCL_",",1917,"I") S @SDFDA@(.03)=$S(SDTS=5:5,SDTS=6:10,SDTS=4:15,SDTS=3:20,SDTS=2:30,SDTS=45:15,1:60)  ;time scale
 .S @SDFDA@(.04)=SDCL
 .D UPDATE^DIE("","SDFDA","SDIEN","SDMSG")
 .I $D(SDMSG) W !,"RESCLIN: Unable to store clinic "_SDCL_" in resource." Q
 .S SDRESH=SDIEN(1)
 .;get letter text
 .S SDLET=SDDATA(44,SDCL_",",2509,"I")
 .D RESLET(SDLET,.SDWP)
 .I $D(SDWP) D WP^DIE(409.831,SDRESH_",",1,"","SDWP")
 .;get no show letter
 .S SDLET=SDDATA(44,SDCL_",",2508,"I")
 .D RESLET(SDLET,.SDWP)
 .I $D(SDWP) D WP^DIE(409.831,SDRESH_",",1201,"","SDWP")
 .;get clinic cancellation letter
 .S SDLET=SDDATA(44,SDCL_",",2510,"I")
 .D RESLET(SDLET,.SDWP)
 .I $D(SDWP) D WP^DIE(409.831,SDRESH_",",1301,"","SDWP")
 Q
RESLET(SDLET,SDWP) ;get letter text
 ;INPUT:
 ;  SDLET - Letter ID pointer to LETTER file 407.5
 ;RETURN
 ; .SDWP  - Word Processor array used to store text using WP^DIE
 N SDMSG,SDWPI,SDWPJ,SDWP2,SDWP3,X
 S X=$$GET1^DIQ(407.5,SDLET_",",2,"","SDWP2","SDMSG")
 Q:$D(SDMSG)
 S X=$$GET1^DIQ(407.5,SDLET_",",3,"","SDWP3","SDMSG")
 S SDWPI=0
 S SDWPJ="" F  S SDWPJ=$O(SDWP2(SDWPJ)) Q:SDWPJ=""  S SDWPI=SDWPI+1 S SDWP(SDWPI)=SDWP2(SDWPJ)
 S SDWPJ="" F  S SDWPJ=$O(SDWP3(SDWPJ)) Q:SDWPJ=""  S SDWPI=SDWPI+1 S SDWP(SDWPI)=SDWP3(SDWPJ)
 Q
INACT(SDIN,SDRN) ;
 ;0=ACTIVATE
 ;1=INACTIVE
 N NOW,RET
 S RET=0
 S NOW=$P($$NOW^XLFDT,".",1)
 S SDIN=$P($G(SDIN),".",1)
 S SDRN=$P($G(SDRN),".",1)
 Q:SDIN="" 0   ;no inactive date
 Q:NOW<SDIN 0  ;inactive date still in future
 I SDIN'>NOW D
 .;MGH added one more check on dates
 .S RET=$S(SDRN="":1,SDRN'>NOW:0,SDRN>SDIN:0,1:1)
 Q RET