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

LEXWUS.m

Go to the documentation of this file.
LEXWUS ;ISL/KER - Lexicon Keywords - Update (Set) ;05/23/2017
 ;;2.0;LEXICON UTILITY;**103**;Sep 23, 1996;Build 2
 ;               
 ; Global Variables
 ;    ^LEX(757.01,        SACC 1.3
 ;    ^LEX(757.071,       SACC 1.3
 ;    ^TMP("LEXWU",$J)    SACC 2.3.2.5.1
 ;               
 ; External References
 ;    HOME^%ZIS           ICR  10086
 ;    ^%ZTLOAD            ICR  10063
 ;    $$GET1^DIQ          ICR   2056
 ;    $$DT^XLFDT          ICR  10103
 ;    $$FMDIFF^XLFDT      ICR  10103
 ;    $$FMTE^XLFDT        ICR  10103
 ;    $$NOW^XLFDT         ICR  10103
 ;    $$UP^XLFSTR         ICR  10011
 ;               
 ; Local Variables NEWed or KILLed Elsewhere
 ;    Control Variables
 ;      LEXTEST           For testing only
 ;      LEXAFT            Set keywords active after date
 ;      LEXCOM            Commit Flag
 ;      LEXQUIET          Suppress Display
 ;               
 ; Call STOP^LEXWUS to stop the task.  It sets the following
 ; global node:
 ; 
 ;     ^TMP("LEXWU",$J,"STOP")
 ;               
 Q
EN ; Main Entry Point (tasked - includes ICD-9)
 N ZT,ZTKEY,ZTUCI,ZTSK,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTQUEUED,ZTREQ,LEXRUN,LEXCOM,LEXCHK,LEXNAM,X,Y
 I '$D(LEXTEST) S LEXRUN=$$RUN2^LEXWUM I LEXRUN>0 W:$L($P(LEXRUN,"^",2)) !,?4,$P(LEXRUN,"^",2),! Q
 S ZTRTN="UPD^LEXWUS" S (LEXNAM,ZTDESC)="Keyword Update Utility (Set)",LEXCHK=""
 S LEXCOM=1,ZTSAVE("LEXCOM")="" K:$D(LEXTEST) LEXCOM,ZTSAVE("LEXCOM") S:$G(LEXAFT)?7N ZTSAVE("LEXAFT")=""
 K ^TMP("LEXWU",$J,"STOP") S ZTIO="",ZTDTH=$H D:'$D(LEXTEST) ^%ZTLOAD D:$D(LEXTEST) @ZTRTN
 I +($G(ZTSK))>0 W !!,?4,$G(LEXNAM)," tasked (#",+($G(ZTSK)),")",!
 D HOME^%ZIS K LEXTEST,LEXAFT
 Q
EN2 ; Entry Point (tasked - Update Selected keyword - LEXKEY)
 ; 
 ;   Needs   LEXKEY             One Keyword 
 ;            <or>
 ;           LEXKEY(LEXKEY1)    Selected Keywords
 ;           LEXKEY(LEXKEY2)
 ;           LEXKEY(LEXKEYn)
 ;           
 N ZT,ZTKEY,ZTUCI,ZTSK,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTQUEUED,ZTREQ,LEXNAM,LEXRUN,LEXCOM,LEXCHK,X,Y
 I '$L($G(LEXKEY))&('$L($O(LEXKEY("")))) W !," LEXKEY keyword variable not defined",! Q
 I '$D(LEXTEST) S LEXRUN=$$RUN2^LEXWUM I LEXRUN>0 W:$L($P(LEXRUN,"^",2)) !,?4,$P(LEXRUN,"^",2),! Q
 S (LEXNAM,ZTDESC)="Keyword Update Utility (Set Selected Keyword)",ZTRTN="SEL^LEXWUS",LEXCHK=""
 S LEXCOM=1,ZTSAVE("LEXCOM")="" K:$D(LEXTEST) LEXCOM,ZTSAVE("LEXCOM")
 S:$L($G(LEXKEY)) ZTSAVE("LEXKEY")="" S:$L($O(LEXKEY(""))) ZTSAVE("LEXKEY(")=""
 S:$G(LEXAFT)?7N ZTSAVE("LEXAFT")="" K ^TMP("LEXWU",$J,"STOP")
 S ZTIO="",ZTDTH=$H D:'$D(LEXTEST) ^%ZTLOAD D:$D(LEXTEST) @ZTRTN
 I +($G(ZTSK))>0 W !!,?4,$G(LEXNAM)," tasked (#",+($G(ZTSK)),")",!
 D HOME^%ZIS K LEXTEST,LEXAFT
 Q
 ; Update
UPD ;   Update Keywords
 N LEXENV S LEXENV=$$ENV G:'LEXENV UPDQ K ^TMP("LEXWU",$J,"STOP") S:$D(ZTQUEUED) ZTREQ="@"
 N LEXBEG,LEXCHK,LEXCHKI,LEXCTR,LEXEFF,LEXELP,LEXEND,LEXENV,LEXEXC,LEXICDC,LEXICPC,LEXINA,LEXINC,LEXINP
 N LEXKEY,LEXKEYC,LEXKIEN,LEXTBEG,LEXTD,LEXTELP,LEXTEND,LEXTMP
 N LEXL01C,LEXL02C,LEXL03C,LEXL04C,LEXL17C,LEXL30C,LEXL31C,LEXL56C,LEXI01C,LEXI02C,LEXI30C,LEXI31C
 S (LEXL01C,LEXL02C,LEXL03C,LEXL04C,LEXL17C,LEXL30C,LEXL31C,LEXL56C,LEXI01C,LEXI02C,LEXI30C,LEXI31C)=0
 S (LEXCTR,LEXICDC,LEXICPC)=0,LEXCOM=1 K:$D(LEXTEST) LEXCOM
 S LEXTD=$$DT^XLFDT,LEXKEY="",LEXBEG=$$NOW^XLFDT S LEXAFT=$G(LEXAFT)
 F  S LEXKEY=$O(^LEX(757.071,"B",LEXKEY)) Q:'$L(LEXKEY)  Q:$$ABT  D  Q:$$ABT
 . N LEXKIEN,LEXTBEG,LEXTEND,LEXTELP,LEXTCHK S (LEXTCHK,LEXKIEN)=0
 . F  S LEXKIEN=$O(^LEX(757.071,"B",LEXKEY,LEXKIEN)) Q:+LEXKIEN'>0  Q:$$ABT  D KEY  Q:$$ABT
 D UEND
UPDQ ;     Update Keywords Quit
 D NOSTOP
 Q
SEL ;   Update Selected Keyword
 S:$D(ZTQUEUED) ZTREQ="@" N LEXENV S LEXENV=$$ENV G:'LEXENV SELQ K ^TMP("LEXWU",$J,"STOP")
 I '$L($G(LEXKEY))&('$L($O(LEXKEY("")))) W !," LEXKEY keyword variable not defined",! G SELQ
 N LEXBEG,LEXCHK,LEXCHKI,LEXCTR,LEXEFF,LEXELP,LEXEND,LEXENV,LEXEXC,LEXICDC,LEXICPC,LEXINA,LEXINC,LEXINP
 N LEXKEYC,LEXKIEN,LEXTBEG,LEXTD,LEXTELP,LEXTEND,LEXTMP
 N LEXL01C,LEXL02C,LEXL03C,LEXL04C,LEXL17C,LEXL30C,LEXL31C,LEXL56C,LEXI01C,LEXI02C,LEXI30C,LEXI31C
 S (LEXL01C,LEXL02C,LEXL03C,LEXL04C,LEXL17C,LEXL30C,LEXL31C,LEXL56C,LEXI01C,LEXI02C,LEXI30C,LEXI31C)=0
 S (LEXCTR,LEXICDC,LEXICPC)=0,LEXCOM=1 K:$D(LEXTEST) LEXCOM
 S LEXTD=$$DT^XLFDT,LEXBEG=$$NOW^XLFDT S LEXAFT=$G(LEXAFT)
 I $L($G(LEXKEY)) D
 . N LEXKIEN S LEXKIEN=0 F  S LEXKIEN=$O(^LEX(757.071,"B",LEXKEY,LEXKIEN)) Q:+LEXKIEN'>0  Q:$$ABT  D KEY  Q:$$ABT
 I $L($O(LEXKEY(""))) D
 . N LEXTKEY S LEXTKEY="" F  S LEXTKEY=$O(LEXKEY(LEXTKEY)) Q:'$L(LEXTKEY)  D
 . . N LEXKIEN,LEXKEY S LEXKEY=LEXTKEY,LEXKIEN=0
 . . F  S LEXKIEN=$O(^LEX(757.071,"B",LEXKEY,LEXKIEN)) Q:+LEXKIEN'>0  Q:$$ABT  D KEY  Q:$$ABT
 D UEND
SELQ ;     Update Selected Keyword Quit
 D NOSTOP
 Q
KEY ;   Process Keyword ICD and Lexicon
 N LEXCHK,LEXCHK2,LEXCHKI,LEXEFF,LEXINA,LEXINC,LEXINCS,LEXEXC,LEXKEYC,LEXTBEG,LEXTEND,LEXTELP S (LEXKEYC(0),LEXKEYC(9))=0
 S LEXEFF=$P($G(^LEX(757.071,+LEXKIEN,0)),"^",2) Q:$G(LEXAFT)?7N&(LEXAFT>LEXEFF)
 S LEXINA=$P($G(^LEX(757.071,+LEXKIEN,0)),"^",3) Q:LEXINA>LEXEFF&(LEXINA'>LEXTD)
 S LEXINC=$P($G(^LEX(757.071,+LEXKIEN,0)),"^",4) Q:'$L(LEXINC)  S LEXEXC=$P($G(^LEX(757.071,+LEXKIEN,0)),"^",5)
 S LEXCHK="" K LEXINP D INC(LEXINC) Q:'$L(LEXCHK)
 Q:$$ABT  D IDP^LEXWUI,LEX^LEXWUL
 Q
UEND ;   Update End
 Q:$D(LEXQUIET)  Q:$D(ZTQUEUED)  H 2 S LEXEND=$$NOW^XLFDT,LEXELP=$$FMDIFF^XLFDT($G(LEXEND),$G(LEXBEG),3)
 S:$L($G(LEXEND))&($L($G(LEXBEG)))&('$L(LEXELP)) LEXELP="00:00:00" N LEXII,LEXTT S LEXII="",LEXTT=0
 N LEXLEXC,LEXSDOC,LEXICDC,LEXTTT S LEXLEXC=+($G(LEXL56C))+($G(LEXL17C))+($G(LEXL03C))+($G(LEXL04C))
 ;     Lexicon
 S LEXLEXC=+($G(LEXL56C))+($G(LEXL17C))+($G(LEXL03C))+($G(LEXL04C))+($G(LEXL01C))+($G(LEXL02C))+($G(LEXL30C))+($G(LEXL31C))
 I +($G(LEXLEXC))>0 D
 . W !,?3,"Lexicon Changes ",?35,$J(LEXLEXC,8)
 . I +($G(LEXL01C))>0 W !,?5,"ICD-9 Diagnosis Changes ",?35,$J(LEXL01C,8)
 . I +($G(LEXL02C))>0 W !,?5,"ICD-9 Procedure Changes ",?35,$J(LEXL02C,8)
 . I +($G(LEXL30C))>0 W !,?5,"ICD-10 Diagnosis Changes ",?35,$J(LEXL30C,8)
 . I +($G(LEXL31C))>0 W !,?5,"ICD-10 Procedure Changes ",?35,$J(LEXL31C,8)
 . I +($G(LEXL56C))>0 W !,?5,"SNOMED CT Changes ",?35,$J(LEXL56C,8)
 . I +($G(LEXL17C))>0 W !,?5,"TITLE 38 Changes ",?35,$J(LEXL17C,8)
 . I +($G(LEXL03C))>0 W !,?5,"CPT-4 Procedure Changes ",?35,$J(LEXL03C,8)
 . I +($G(LEXL04C))>0 W !,?5,"HCPCS Procedure Changes ",?35,$J(LEXL04C,8)
 ;     ICD files
 S LEXSDOC=+($G(LEXI01C))+($G(LEXI30C))+($G(LEXI02C))+($G(LEXI31C))
 S LEXICDC=+($G(LEXI01C))+($G(LEXI30C)),LEXICPC=+($G(LEXI02C))+($G(LEXI31C))
 I +($G(LEXSDOC))>0 D
 . N LEXTAB W:+($G(LEXLEXC))>0 ! W !,?3,"ICD* File Changes",?35,$J(LEXSDOC,8)
 . S LEXTAB="",LEXICDC=+($G(LEXI01C))+($G(LEXI30C))
 . I +($G(LEXI01C))>0&(+($G(LEXI30C))>0) W:LEXICDC>0 !,?5,"ICD Diagnosis File #80",?35,$J(LEXICDC,8) S LEXTAB="  "
 . I +($G(LEXI01C))>0 W !,?5,LEXTAB,"ICD-9 Diagnosis Changes ",?35,$J(LEXI01C,8)
 . I +($G(LEXI30C))>0 W !,?5,LEXTAB,"ICD-10 Diagnosis Changes ",?35,$J(LEXI30C,8)
 . S LEXTAB="",LEXICPC=+($G(LEXI02C))+($G(LEXI31C))
 . I +($G(LEXI02C))>0&(+($G(LEXI31C))>0) W:LEXICPC>0 !,?5,"ICD Procedures File #80.1",?35,$J(LEXICPC,8) S LEXTAB="  "
 . I +($G(LEXI02C))>0 W !,?5,LEXTAB,"ICD-9 Procedure Changes ",?35,$J(LEXI02C,8)
 . I +($G(LEXI31C))>0 W !,?5,LEXTAB,"ICD-10 Procedure Changes ",?35,$J(LEXI31C,8)
 S LEXTTT=+($G(LEXLEXC))+($G(LEXSDOC)) I LEXTTT>0 D
 . W:+($G(LEXLEXC))>0!(+($G(LEXSDOC))>0) !
 . I +($G(LEXLEXC))>0 W !,?3,"Total Changes ",?35,$J(LEXTTT,8)
 W ! I $L($G(LEXBEG)) W !,?3,"Start:   ",?14,$TR($$FMTE^XLFDT(LEXBEG,"5Z"),"@"," ")
 I $L($G(LEXEND)) W !,?3,"Finish:  ",?14,$TR($$FMTE^XLFDT(LEXEND,"5Z"),"@"," ")
 I $L($G(LEXELP)) W !,?3,"Elapsed: ",?14,$TR(LEXELP," ","0"),!
 Q
 ;
 ; Miscellaneous
INC(X) ;   Include Check
 K LEXINP S LEXCHKI=0,LEXCHK="" D PAR($G(X),.LEXINP)
 S LEXCHKI=$O(LEXINP(0)) S:+LEXCHKI>0 LEXCHK=$O(LEXINP(+LEXCHKI,""))
 K:LEXCHKI>0&($L(LEXCHK)) LEXINP(+LEXCHKI,LEXCHK),LEXINP("B",LEXCHK)
 S:'$L(LEXCHK) LEXCHK=$P(LEXINC," ",1)
 Q
ABT(X) ;   Abort
 Q:$D(^TMP("LEXWU",$J,"STOP")) 1
 Q 0
DT ;   Display ^TMP
 D DT^LEXWUM
 Q
STOP ;   Stop Task
 D STOP^LEXWUM
 Q
NOSTOP ;   Remove Stop
 N LEXI S LEXI=0 F  S LEXI=$O(^TMP("LEXWU",LEXI)) Q:+LEXI'>0  K ^TMP("LEXWU",LEXI,"STOP")
 Q
BK(X) ;   Stop Task
 Q
PAR(X,LEXARY) ;   Key Word In Context, KWIC
 N LEXASRC,LEXBEG,LEXEND,LEXNUM,LEXTKN,LEXTXT S LEXTXT=$$UP^XLFSTR(X)
 K LEXARY S LEXBEG=1 F LEXEND=1:1:$L(LEXTXT)+1 D
 . S LEXASRC=$E(LEXTXT,LEXEND) I "~!@#$%&*()_+`-=[]{};'\:|,./?<> """[LEXASRC D
 . . S LEXTKN=$E(LEXTXT,LEXBEG,LEXEND-1),LEXBEG=LEXEND+1 I $L(LEXTKN)>0 D
 . . . N LEXNUM S LEXNUM=$O(^LEX(757.01,"ASL",LEXTKN,0))
 . . . S LEXARY(+($G(LEXNUM)),LEXTKN)=""
 . . . S LEXARY("B",LEXTKN)=""
 Q
MON(X) ;   Month
 Q $S($G(X)=1:"JAN",$G(X)=2:"FEB",$G(X)=3:"MAR",$G(X)=4:"APR",$G(X)=5:"MAY",$G(X)=6:"JUN",$G(X)=7:"JUL",$G(X)=8:"AUG",$G(X)=9:"SEP",$G(X)=10:"OCT",$G(X)=11:"NOV",$G(X)=12:"DEC",1:$G(X))
 Q
ENV(X) ;   Environment
 D HOME^%ZIS S U="^",DT=$$DT^XLFDT,DTIME=300 K POP
 N LEXNM S LEXNM=$$GET1^DIQ(200,(DUZ_","),.01)
 I '$L(LEXNM) W !!,?5,"Invalid/Missing DUZ" Q 0
 Q 1