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

SDES880P.m

Go to the documentation of this file.
SDES880P ;ALB/MGD,BWF - SD*5.3*880 Post Init Routine ; Apr 03, 2024
 ;;5.3;SCHEDULING;**880**;AUG 13, 1993;Build 5
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
EN ; Update the VS GUI version in #409.98
 D TASK
 D FIND
 Q
TASK ;
 D MES^XPDUTL("")
 D MES^XPDUTL("   SD*5.3*880 Post-Install to add missing MES subscript")
 D MES^XPDUTL("   to the cancelled times in the HOSPITAL LOCATION (#44))")
 D MES^XPDUTL("   file is being queued to run in the background.")
 D MES^XPDUTL("")
 N ZTDESC,ZTRTN,ZTIO,ZTSK,X,ZTDTH,ZTSAVE
 S ZTDESC="SD*5.3*880 Post Install Routine"
 D NOW^%DTC S ZTDTH=X,ZTIO="",ZTRTN="FIXCAN^SDES880P",ZTSAVE("*")="" D ^%ZTLOAD
 I $D(ZTSK) D
 . D MES^XPDUTL("  >>>Task "_ZTSK_" has been queued.")
 . D MES^XPDUTL("")
 I '$D(ZTSK) D
 . D MES^XPDUTL("  UNABLE TO QUEUE THIS JOB.")
 . D MES^XPDUTL("  Please contact the National Help Desk to report this issue.")
 Q
FIXCAN ;
 N CLIN,CANDT,CANSTART,CANENDTIME,FDA,FDAIEN,FIXCNT
 K ^XTMP("SDES880P")
 S ^XTMP("SDES880P",0)=$$FMADD^XLFDT(DT,30)_"^"_DT_"^880 Post Install Data Repair"
 S (CLIN,FIXCNT)=0 F  S CLIN=$O(^SC(CLIN)) Q:'CLIN  D
 .S CANDT=3211201 F  S CANDT=$O(^SC(CLIN,"SDCAN",CANDT)) Q:'CANDT  D
 ..I $D(^SC(CLIN,"S",CANDT,"MES")) Q
 ..S CANSTART=$$GET1^DIQ(44.05,CANDT_","_CLIN_",",.01)
 ..S CANENDTIME=$$GET1^DIQ(44.05,CANDT_","_CLIN_",",1)
 ..I $$ACTIVEAPPTS(CLIN,CANDT,CANENDTIME) Q
 ..S FIXCNT=FIXCNT+1
 ..S ^XTMP("SDES880P",FIXCNT,"BEFORE","MES")=CLIN_U_CANDT_U_$$GET1^DIQ(44.001,CANDT_","_CLIN_",",1400,"E")
 ..I $D(^SC(CLIN,"S",CANDT)) D  Q
 ...S FDA(44.001,CANDT_","_CLIN_",",1400)="CANCELLED UNTIL "_CANENDTIME_" (SCHEDULING PATCH 880 CLEANUP)"
 ...D FILE^DIE(,"FDA") K FDA
 ...S ^XTMP("SDES880P",FIXCNT,"AFTER","MES")=CLIN_U_CANDT_U_$$GET1^DIQ(44.001,CANDT_","_CLIN_",",1400,"E")
 ..S FDA(44.001,"+1,"_CLIN_",",.01)=CANDT
 ..S FDA(44.001,"+1,"_CLIN_",",1400)="CANCELLED UNTIL "_CANENDTIME_" (SCHEDULING PATCH 880 CLEANUP)"
 ..S FDAIEN(1)=CANDT
 ..D UPDATE^DIE(,"FDA","FDAIEN") K FDAIEN,FDA
 ..S ^XTMP("SDES880P",FIXCNT,"AFTER","MES")=CLIN_U_CANDT_U_$$GET1^DIQ(44.001,CANDT_","_CLIN_",",1400,"E")
 Q
 ; try to find active appointments on the cancelled date
ACTIVEAPPTS(CLIN,CANSTART,CANENDTIME) ;
 N APPTDATE,RECCNT,APPTENDDATE,APPTIEN
 S RECCNT=0
 S APPTDATE=CANSTART-.0001
 S APPTENDDATE=$P(CANSTART,".")_"."_CANENDTIME
 F  S APPTDATE=$O(^SC(CLIN,"S",APPTDATE)) Q:'APPTDATE!(APPTDATE=APPTENDDATE)!(APPTDATE>APPTENDDATE)  D
 .S APPTIEN=0 F  S APPTIEN=$O(^SC(CLIN,"S",APPTDATE,1,APPTIEN)) Q:'APPTIEN  D
 ..I $$GET1^DIQ(44.003,APPTIEN_","_APPTDATE_","_CLIN_",",310,"I")="C" Q
 ..S RECCNT=RECCNT+1
 Q RECCNT
 ;
FIND ;FIND THE IEN FOR "VS GUI NATIONAL"
 N SDECDA,SDECDA1
 D MES^XPDUTL("")
 D MES^XPDUTL("   Updating SDEC SETTINGS file (#409.98)")
 S SDECDA=0,SDECDA=$O(^SDEC(409.98,"B","VS GUI NATIONAL",SDECDA)) G:$G(SDECDA)="" NOFIND
 D VERSION   ;update GUI version number and date
 Q
VERSION ;SET THE NEW VERSION UPDATE IN SDEC SETTING FILE #409.98 TO 1.7.57
 S DA=SDECDA,DIE=409.98,DR="2///1.7.57;3///"_DT D ^DIE  ;update VS GUI NATIONAL
 K DIE,DR,DA
 S SDECDA1=0,SDECDA1=$O(^SDEC(409.98,"B","VS GUI LOCAL",SDECDA1)) Q:$G(SDECDA1)=""    ;get DA for the VS GUI LOCAL
 S DA=SDECDA1,DIE=409.98,DR="2///1.7.57;3///"_DT D ^DIE  ;update VS GUI LOCAL
 K DIE,DR,DA
 Q
 ;
NOFIND ;"VS GUI NATIONAL" NOT FOUND
 D MES^XPDUTL("   VS GUI NATIONAL not found in the SDEC SETTINGS file (#409.98)")
 Q