VistA-WorldVistAEHR/r/LEXICON_UTILITY-LEX-GMPT/LEXXGI.m

169 lines
8.4 KiB
Mathematica

LEXXGI ; ISL/KER - Global Import (Needs ^LEXM) ; 02/22/2007
;;2.0;LEXICON UTILITY;**4,25,26,27,28,29,46,49**;Sep 23, 1996;Build 3
;
; NEWed or KILLed Elsewhere
;
; LEXBUILD, LEXFY, LEXIGHF, LEXLREV, LEXPTYPE
; LEXQTR, LEXREQP, LEXSHORT, XPDNM
;
; Global Variables
; ^LEXM
;
; External References
; HOME^%ZIS
; ^DIM
; $$GET1^DIQ
; $$DT^XLFDT
; $$FMTE^XLFDT
; BMES^XPDUTL
; MES^XPDUTL
;
EN ; Main Entry Point for Installing LEXM in Post-Installs
;
; Requires
;
; LEXBUILD - the name of the patch/build being installed
;
; Uses
;
; LEXMSG - If this variable exist, then an install message
; message will be set to G.LEXICON
;
; LEXSHORT - If this variable exist, the install message
; will be an abbreviated message, without the
; file totals and checksums
;
; Abbreviated Install Message
;
; Date and Time Installed
; Account where the Data was Installed
; Who Installed the Data
; The Name of the Build Installed
; The Name of the Global Host File
; Protocol Invoked
; Date and time Protocol was Invoked
; Install Start Date/Time
; Install Complete Date/Time
; Install Elapsed Time
;
; Long Install Message
;
; All of the elements above plus:
;
; File Versions/Revisions
; File Checksums
; File Record Counts
;
; LEXPTYPE - Patch Type
; LEXLREV - Revision
; LEXREQP - Required Patches/Builds
; LEXIGHF - The patch Export Global Host Filename
; LEXFY - Fiscal Year
; LEXQTR - Quarter
; LEXCRE - Import Global Creation Date
;
D IMPORT,KALL^LEXXGI2
Q
IMPORT ; Import Data during a Patch Installation
S:$D(ZTQUEUED) ZTREQ="@"
S:$L($G(LEXPTYPE)) LEXPTYPE=$G(LEXPTYPE) S:$L($G(LEXLREV)) LEXLREV=$G(LEXLREV) S:$L($G(LEXREQP)) LEXREQP=$G(LEXREQP)
S:$L($G(LEXBUILD)) LEXBUILD=$G(LEXBUILD) S:$L($G(LEXIGHF)) LEXIGHF=$G(LEXIGHF) S:$L($G(LEXFY)) LEXFY=$G(LEXFY)
S:$L($G(LEXQTR)) LEXQTR=$G(LEXQTR) K LEXSCHG,LEXCHG
N LEXB,LEXCD,LEXSTR,LEXLAST,%,%DT,C,D,D0,D1,D2,DG,DIC,DICR,DILOCKTM,DIW,IREC,J,XMDUN,XMZ,ZTSK
S U="^",LEXSTR=$G(LEXPTYPE),LEXB=$G(^LEXM(0,"BUILD"))
S:$L($G(LEXFY))&($L($G(LEXQTR)))&($L(LEXSTR)) LEXSTR=LEXSTR_" for "_$G(LEXFY)_" "_$G(LEXQTR)_" Quarter"
S:$L(LEXB) LEXBLD=LEXB S:'$L(LEXBLD)&($L(LEXBUILD)) LEXBLD=LEXBUILD
I '$L(LEXB)!(LEXB'=LEXBUILD) D
. N X,LEXBLD I '$L(LEXB) D Q
. . S X=" Invalid export global, aborting data install" W:'$D(XPDNM) !!,X D:$D(XPDNM) BMES^XPDUTL(X) W:'$D(XPDNM) ! D:$D(XPDNM) MES^XPDUTL(" ")
. I '$L(LEXBUILD) D Q
. . S X=" Undefined KIDS Build, aborting data install" W:'$D(XPDNM) !!,X D:$D(XPDNM) BMES^XPDUTL(X) W:'$D(XPDNM) ! D:$D(XPDNM) MES^XPDUTL(" ")
I $L(LEXB)&(LEXB=LEXBUILD) D
. N LEXFI,LEXID S X="Installing Data for patch "_LEXB W:'$D(XPDNM) !!,X D:$D(XPDNM) BMES^XPDUTL(X) W:'$D(XPDNM) ! D:$D(XPDNM) MES^XPDUTL(" ")
. K LEXSCHG S LEXCHG=0,LEXFI=0 F S LEXFI=$O(^LEXM(LEXFI)) Q:+LEXFI'>0 D
. . S LEXID=$S(LEXFI=80!(LEXFI=80.1):"ICD",LEXFI=81!(LEXFI=81.1)!(LEXFI=81.2)!(LEXFI=81.3):"CPT",$P(LEXFI,".",1)=757:"LEX",1:"UNK")
. . S LEXSCHG(LEXFI,0)=+($G(^LEXM(LEXFI,0))),LEXSCHG("B",LEXFI)="" S LEXSCHG("C",LEXID,LEXFI)=""
. S:$D(LEXSCHG("C","CPT"))!($D(LEXSCHG("C","ICD"))) LEXSCHG("D","PRO")="",LEXCHG=1,LEXSCHG(0)=1
. D LOAD,NOTIFY^LEXXGI2 I +($G(DUZ))>0,$L($$GET1^DIQ(200,(+($G(DUZ))_","),.01)) D
. . D HOME^%ZIS N DIFROM,LEXPRO,LEXPRON,LEXLAST D:$D(LEXMSG) POST^LEXXFI
Q
LOAD ; Load Data from ^LEXM into IC*/LEX Files
Q:'$L($G(LEXB)) S:$D(ZTQUEUED) ZTREQ="@"
N LEXBEG,LEXELP,LEXEND,LEXMSG,LEXOK,LEXFL
D:'$D(^LEXM) NF^LEXXGI2 Q:'$D(^LEXM)
S LEXOK=0 S:$O(^LEXM(0))>0 LEXOK=1 D:'LEXOK IG^LEXXGI2 Q:'LEXOK
S LEXBEG=$$HACK^LEXXGI2 D FILES S LEXEND=$$HACK^LEXXGI2,LEXELP=$$ELAP^LEXXGI2(LEXBEG,LEXEND)
S:LEXELP="" LEXELP="00:00:00"
D PB^LEXXGI2(" Data Updated ")
D PB^LEXXGI2((" Started: "_$TR($$FMTE^XLFDT(LEXBEG),"@"," ")))
D TL^LEXXGI2((" Finished: "_$TR($$FMTE^XLFDT(LEXEND),"@"," ")))
D TL^LEXXGI2((" Elapsed: "_LEXELP))
Q
FILES ; Load Data for all files
Q:'$L($G(LEXB)) N LEXHDR,LEXBLD,LEXDAT,LEXFI,LEXFIC,LEXHDRS,LEXLOG,LEXINS
S (LEXFI,LEXFIC)=0,LEXHDR=0,LEXBLD=LEXB
S LEXDAT=$P($G(^LEXM(0,"VRRVDT")),"^",1),LEXINS=1
S:+LEXDAT'>0 LEXDAT=$$DT^XLFDT I LEXOK D
. N LEXCRE,LEXL1 S LEXL1="" S LEXCRE=$G(^LEXM(0,"CREATED")) S LEXCRE=$S(+LEXCRE>0:($$MIX^LEXXGI2($$FMTE^XLFDT(LEXCRE))),1:"")
. S:$L($P(LEXCRE,"@",2)) LEXCRE=$P(LEXCRE,"@",1)_" at "_$P(LEXCRE,"@",2) S LEXL1=" Updating files "
. S:$L($G(LEXCRE))&($L($G(LEXL1))) LEXL1=$G(LEXL1)_"using export global created "_$G(LEXCRE)
. D PB^LEXXGI2(LEXL1)
F S LEXFI=$O(^LEXM(LEXFI)) Q:+LEXFI=0 D FILE
Q
FILE ; Load Data for one file
N LEXCF,LEXCHG,LEXCHGS,LEXCNT,LEXFIL,LEXI,LEXID,LEXIEN,LEXL,LEXLC
N LEXMUMPS,LEXNM,LEXRT,LEXS,LEXTOT,LEXTXT,LEXIGL,LEXIGI,LEXIGF,LEXIGT
N LEXIGD,LEXIGO,LEXBEG,LEXEND,LEXELP,LEXFB
S LEXFB=$G(^LEXM(+LEXFI,0,"BUILD")),LEXIGO=0,LEXBEG=$$HACK^LEXXGI2
S (LEXCNT,LEXLC,LEXI)=0,LEXL=68,LEXFIC=LEXFIC+1 I LEXOK D
. N LEXB,LEXFID,LEXNM,LEXVR,LEXRV,LEXDT,LEXL1,LEXL2 S (LEXL1,LEXL2)="",LEXFID=$P(LEXFI,".",1)
. Q:+LEXFID'>0 Q:$D(LEXHDRS(+LEXFID)) S LEXHDRS(LEXFID)="" S:+LEXFI=81!(+LEXFI=81.3) LEXHDRS(81)="",LEXHDRS(81.3)=""
. S:LEXFID=80 LEXNM="ICD-9-CM" S:LEXFID=81 LEXNM="CPT-4/HCPSC" S:LEXFID=757 LEXNM="Lexicon" S LEXB=$G(^LEXM(LEXFI,0,"BUILD"))
. S LEXVR=$G(^LEXM(LEXFI,0,"VR")),LEXRV=$G(^LEXM(LEXFI,0,"VRRV")),LEXDT=$$MIX^LEXXGI2($$FMTE^XLFDT($P(LEXRV,"^",2))),LEXRV=$P(LEXRV,"^",1)
. S LEXL1="Updating "_LEXNM S:$L(LEXB) LEXL1=LEXL1_" with patch/build "_LEXB S:$L(LEXVR) LEXL2=" To version "_LEXVR
. S:$L(LEXVR)&($L(LEXRV)) LEXL2=LEXL2_" revision "_LEXRV S:$L(LEXVR)&($L(LEXRV))&($L(LEXDT)) LEXL2=LEXL2_" dated "_LEXDT
. S:$L(LEXL1) LEXL1=" "_LEXL1 S:$L(LEXL2) LEXL2=" "_LEXL2 D BL^LEXXGI2 D:$L(LEXL1) TL^LEXXGI2(LEXL1) D:$L(LEXL2) TL^LEXXGI2(LEXL2),BL^LEXXGI2
S LEXTOT=+($G(^LEXM(LEXFI,0))) G:LEXTOT=0 FILEQ
S LEXNM=$G(^LEXM(LEXFI,0,"NM"))
I $L(LEXNM),$$UP^LEXXGI2(LEXNM)'["FILE" S LEXNM=LEXNM_" FILE"
S:$L(LEXNM) LEXNM=$$MIX^LEXXGI2(LEXNM) S LEXCHG=$G(^LEXM(LEXFI,0))
S LEXTXT=" "_LEXNM,LEXTXT=LEXTXT_$J("",(40-$L(LEXTXT)))_LEXFI
D:LEXFIC=1 PB^LEXXGI2(LEXTXT) D:LEXFIC'=1 TL^LEXXGI2(LEXTXT)
S LEXS=+(LEXTOT\LEXL) S:LEXS=0 LEXS=1 W:+($O(^LEXM(LEXFI,0)))>0 !," "
D UPCHG^LEXXGI2 F S LEXI=$O(^LEXM(LEXFI,LEXI)) Q:+LEXI=0 D
. S LEXCNT=LEXCNT+1,LEXMUMPS=$G(^LEXM(LEXFI,LEXI))
. I LEXCNT'<LEXS S LEXLC=LEXLC+1 W:LEXLC'>LEXL "." S LEXCNT=0
. S LEXRT=$P(LEXMUMPS,"^",2),LEXFIL=""
. S:LEXMUMPS["^LEX("!(LEXMUMPS["^LEXT(")!(LEXMUMPS["^LEXC(") LEXFIL=+($P(LEXRT,"(",2)),LEXFL(+($P(LEXRT,"(",2)))=""
. S:LEXMUMPS["^ICD9(" LEXFIL=80,LEXFL(80)=""
. S:LEXMUMPS["^ICD0(" LEXFIL=80.1,LEXFL(80.1)=""
. S:LEXMUMPS["^ICPT(" LEXFIL=81,LEXFL(81)=""
. S:LEXMUMPS["^DIC(81.3" LEXFIL=81.3,LEXFL(81.3)=""
. S:LEXMUMPS["^DIC(81.2" LEXFIL=81.2,LEXFL(81.2)=""
. S:LEXMUMPS["^LEX("!(LEXMUMPS["^LEXT(")!(LEXMUMPS["^LEXC(") LEXFIL=+($P(LEXRT,"(",2))
. S:LEXMUMPS["^ICD9(" LEXFIL=80 S:LEXMUMPS["^ICD0(" LEXFIL=80.1
. S:LEXMUMPS["^ICPT(" LEXFIL=81 S:LEXMUMPS["^DIC(81.3" LEXFIL=81.3
. S:+LEXFIL>0 LEXSCHG(+LEXFIL,0)=""
. I $L(LEXMUMPS) D
. . N X S X=LEXMUMPS D ^DIM Q:'$D(X) X LEXMUMPS S LEXIGO=1
I +($G(LEXIGO))>0 D
. S LEXEND=$$HACK^LEXXGI2 S LEXELP=$$ELAP^LEXXGI2(LEXBEG,LEXEND) S:LEXELP="" LEXELP="00:00:00"
FILEQ ; Load Data for one file - QUIT
K ^LEXM(+LEXFI)
Q
;
NOTIFY ; Notify by Protocol - LEXICAL SERVICES UPDATE
D NOTIFY^LEXXGI2,KALL^LEXXGI2
Q
SCHG ; Save Change File Changes (for NOTIFY)
N FI,ID K LEXSCHG S LEXCHG=0
N FI S FI=0 F S FI=$O(^LEXM(FI)) Q:+FI'>0 D
. S ID=$S(FI=80!(FI=80.1):"ICD",FI=81!(FI=81.1)!(FI=81.2)!(FI=81.3):"CPT",$P(FI,".",1)=757:"LEX",1:"UNK")
. S LEXSCHG(FI,0)=+($G(^LEXM(FI,0))),LEXSCHG("B",FI)="" S LEXSCHG("C",ID,FI)=""
S:$D(LEXSCHG("C","CPT"))!($D(LEXSCHG("C","ICD"))) LEXSCHG("D","PRO")=""
S:$D(^LEXM(80))!($D(^LEXM(80.1)))!($D(^LEXM(81)))!($D(^LEXM(81.2)))!($D(^LEXM(81.3)))!($D(LEXSCHG("D","PRO"))) LEXCHG=1,LEXSCHG(0)=1
Q
ZTQ ; Taskman Quit
K ZTDESC,ZTDTH,ZTIO,ZTQUEUED,ZTREQ,ZTRTN,ZTSAVE,ZTSK
Q