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

LEXXGP2.m

Go to the documentation of this file.
LEXXGP2 ;ISL/KER - Global Post-Install (Repair Subsets) ;04/21/2014
 ;;2.0;LEXICON UTILITY;**80**;Sep 23, 1996;Build 10
 ;               
 ; Global Variables
 ;    ^TMP("LEXSUB")      SACC 2.3.2.5.1
 ;    ^TMP("LEXTKN")      SACC 2.3.2.5.1
 ;    ^TMP("LEXXGPDAT")   SACC 2.3.2.5.1
 ;    ^TMP("LEXXGPMSG")   SACC 2.3.2.5.1
 ;    ^TMP("LEXXGPRPT")   SACC 2.3.2.5.1
 ;               
 ; External References
 ;    $$S^%ZTLOAD         ICR  10063
 ;    ^DIC                ICR  10006
 ;    IXALL^DIK           ICR  10013
 ;    $$GET1^DIQ          ICR   2056
 ;    $$UP^XLFSTR         ICR  10104
 ;    ^XMD                ICR  10070
 ;               
 ; Local Variables NEWed or KILLed Elsewhere
 ; 
 ;    LEXMAIL   Set and Killed by the developer, used to 
 ;              report the timing of the task and
 ;              send to the user by MailMan message
 ;     
 ;    LEXHOME   Set and Killed by the developer in the
 ;              post-install, used to send the timing
 ;              message to G.LEXINS@FO-SLC.MED.VA.GOV
 ;              (see entry point POST2)
 ;              
 Q
SUB ; Subset file Indexes Aaaa
 N LEXBEG,LEXBEGD,LEXBEGT,LEXDF,LEXELP,LEXEND,LEXENDD,LEXENDT
 N LEXTMP,LEXTXT S LEXTXT="Subset Indexes"
 S:'$D(LEXQUIT) LEXQUIT="SUB" K ^TMP("LEXSUB",$J)
 S LEXBEG=$$BEG^LEXXGP1 D ASUBB H 1 S LEXEND=$$END^LEXXGP1
 D SAV(LEXBEG,LEXEND,LEXTXT) S LEXELP=$$ELP^LEXXGP1(LEXBEG,LEXEND)
 S LEXBEGD=$$ED^LEXXGP1(LEXBEG),LEXBEGT=$$ET^LEXXGP1(LEXBEG),LEXENDT=$$ET^LEXXGP1(LEXEND)
 S LEXDF=$$DF^LEXXGP1(LEXBEG),LEXTXT=$G(LEXTXT)_$J(" ",(35-$L($G(LEXTXT))))
 S LEXTXT=LEXTXT_LEXDF_"   "_LEXBEGT_"   "_LEXENDT_"   "_LEXELP
 S LEXTXT=" "_LEXTXT W:'$D(ZTQUEUED) !,LEXTXT
 N ZTQUEUED,LEXTEST
 I $G(LEXQUIT)="SUB" D
 . D:$D(LEXMAIL) XM
 . K ^TMP("LEXAWRD"),^TMP("LEXSUB"),^TMP("LEXTKN")
 . K ^TMP("LEXXGPDAT"),^TMP("LEXXGPTIM"),^TMP("LEXXGPRPT")
 . K:'$D(LEXMAIL) ^TMP("LEXXGPMSG")
 . K LEXQUIT,ZTQUEUED,LEXMAIL,LEXHOME
 Q
ASUBB ;   ASUB Word Index Build                        11.5 minutes
 ;     Create the AWRD Index in the ^TMP global
 N LEXBEG,LEXBEGD,LEXBEGT,LEXCHK,LEXDF,LEXELP,LEXEND,LEXENDD,LEXENDT,LEXEX
 N LEXEXP,LEXTEXP,LEXIDX,LEXMC,LEXMCEI,LEXMCI,LEXRI,LEXSI,LEXSUB
 N LEXTKC,LEXTKN,LEXTXT,X
 K ^TMP("LEXSUB",$J) S:'$D(LEXQUIT) LEXQUIT="ASUBB"
 S LEXBEG=$$BEG^LEXXGP1,LEXSUB=0,LEXTXT="Build 'ASUB' Word Index"
 I +($G(ZTSK))>0 S LEXCHK=$$S^%ZTLOAD((LEXTXT_" in file 757.21"))
 F  S LEXSUB=$O(^LEX(757.21,LEXSUB)) Q:+LEXSUB'>0  D
 . N X,LEXEX,LEXEXP,LEXIDX,LEXMCI,LEXMCEI,LEXSI,LEXTKN
 . N LEXTKC,LEXNAM,LEXINAM,LEXNOD,LEXRP,LEXTEXP S LEXTEXP=0
 . S LEXNOD=$G(^LEX(757.21,LEXSUB,0)),LEXEX=+LEXNOD
 . S LEXNAM=+($P(LEXNOD,"^",2))
 . S LEXNAM=$P($G(^LEXT(757.2,+LEXNAM,0)),"^",2)
 . Q:$L(LEXNAM)'=3  S LEXINAM="A"_LEXNAM
 . S LEXEXP=$$UP^XLFSTR($G(^LEX(757.01,LEXEX,0))) Q:'$L(LEXEXP)
 . S LEXMCI=$P($G(^LEX(757.01,LEXEX,1)),"^",1) Q:+LEXMCI'>0
 . S LEXMCEI=$P($G(^LEX(757,LEXMCI,0)),"^",1) Q:+LEXMCEI'>0
 . F  S LEXTEXP=$O(^LEX(757.01,"AMC",LEXMCI,LEXTEXP)) Q:+LEXTEXP=0  D
 . . N LEXEXP,X,LEXIDX,LEXLOOK,LEXEXPT,LEXRP
 . . Q:$P($G(^LEX(757.01,+LEXTEXP,1)),"^",5)>0
 . . S (LEXEXP,X)=^LEX(757.01,LEXTEXP,0)
 . . K ^TMP("LEXTKN",$J) S LEXIDX="" D PTX^LEXTOKN
 . . ;     Supplemental Words
 . . I $D(^LEX(757.01,LEXTEXP,5)) D
 . . . N LEXV,LEXEXPT S LEXV=""
 . . . F  S LEXV=$O(^LEX(757.01,LEXTEXP,5,"B",LEXV)) Q:LEXV=""  D
 . . . . N LEXC S LEXC=$O(^TMP("LEXTKN",$J," "),-1)+1
 . . . . S ^TMP("LEXTKN",$J,LEXC,LEXV)=""
 . . . . S ^TMP("LEXTKN",$J,0)=LEXC
 . . ;     Replacement Words
 . . I $D(^LEX(757.05,"AEXP",LEXTEXP)) N LEXRP S LEXRP=0 D
 . . . F  S LEXRP=$O(^LEX(757.05,"AEXP",LEXTEXP,LEXRP)) Q:+LEXRP'>0  D
 . . . . N LEXV,LEXC
 . . . . S LEXV=$P(^LEX(757.05,LEXRP,0),U) Q:'$L(LEXV)
 . . . . S LEXC=$O(^TMP("LEXTKN",$J," "),-1)+1
 . . . . S ^TMP("LEXTKN",$J,LEXC,LEXV)=""
 . . . . S ^TMP("LEXTKN",$J,0)=LEXC
 . . I $D(^TMP("LEXTKN",$J,0)),^TMP("LEXTKN",$J,0)>0 D
 . . . S LEXTKN="",LEXTKC=0
 . . . F  S LEXTKC=$O(^TMP("LEXTKN",$J,LEXTKC)) Q:+LEXTKC'>0  D
 . . . . S LEXTKN=$O(^TMP("LEXTKN",$J,LEXTKC,"")) Q:'$L(LEXTKN)
 . . . . S ^TMP("LEXSUB",$J,LEXINAM,LEXTKN,LEXSUB)=""
 . . K ^TMP("LEXTKN",$J)
 K ^TMP("LEXTKN",$J) H 1 S LEXEND=$$END^LEXXGP1 D SAV(LEXBEG,LEXEND,LEXTXT)
 S LEXELP=$$ELP^LEXXGP1(LEXBEG,LEXEND),LEXBEGD=$$ED^LEXXGP1(LEXBEG)
 S LEXBEGT=$$ET^LEXXGP1(LEXBEG),LEXENDT=$$ET^LEXXGP1(LEXEND),LEXDF=$$DF^LEXXGP1(LEXBEG)
 S LEXTXT=$G(LEXTXT)_$J(" ",(35-$L($G(LEXTXT))))
 S LEXTXT=LEXTXT_LEXDF_"   "_LEXBEGT_"   "_LEXENDT_"   "_LEXELP
 S LEXTXT=" "_LEXTXT W:'$D(ZTQUEUED) !,LEXTXT
 D ASUBR N ZTQUEUED,LEXTEST
 I $G(LEXQUIT)="ASUBB" D
 . D:$D(LEXMAIL) XM
 . K ^TMP("LEXAWRD"),^TMP("LEXSUB"),^TMP("LEXTKN")
 . K ^TMP("LEXXGPDAT"),^TMP("LEXXGPTIM"),^TMP("LEXXGPRPT")
 . K LEXQUIT,ZTQUEUED,LEXMAIL,LEXHOME
 Q
ASUBR ;   ASUB Word Index Replace                       1.5 minutes
 N LEX1,LEX2,LEX3,LEX4,LEXBEG,LEXBEGD,LEXBEGT,LEXCHK,LEXCHR,LEXCHRS,LEXIDS
 N LEXCMD,LEXCOM,LEXCTL,LEXDF,LEXELP,LEXEND,LEXENDD,LEXENDT
 N LEXLWRD,LEXNOD,LEXRT,LEXRT1,LEXRT2,LEXTK,LEXTMP,LEXTWRD
 N LEXTXT,LEXID S (LEX1,LEX2,LEX3,LEX4)=0 Q:'$D(LEXQUIT)
 S LEXBEG=$$BEG^LEXXGP1,LEXTXT="Replace 'ASUB' Word Index" K LEXIDS
 I +($G(ZTSK))>0 S LEXCHK=$$S^%ZTLOAD((LEXTXT_" in file 757.21"))
 S LEXTMP=" " F  S LEXTMP=$O(^LEX(757.21,LEXTMP)) Q:'$L(LEXTMP)  D
 . S:$E(LEXTMP,1)="A" LEXIDS(LEXTMP)=""
 S LEXTMP=" "
 F  S LEXTMP=$O(^TMP("LEXSUB",$J,LEXTMP)) Q:'$L(LEXTMP)  D
 . S:$E(LEXTMP,1)="A" LEXIDS(LEXTMP)=""
 S LEXID="" F  S LEXID=$O(LEXIDS(LEXID)) Q:'$L(LEXID)  D
 . ;     For Subset Index
 . W:'$D(ZTQUEUED)&($D(LEXTEST)) !,LEXID," " S LEX1=LEX1+1
 . K LEXCHRS S LEXRT1="^LEX(757.21,"""_LEXID_""","
 . S LEXRT2="^TMP(""LEXSUB"","_$J_","""_LEXID_""","
 . F LEXRT=LEXRT1,LEXRT2 D
 . . N LEXTK S LEXTK=""
 . . F  S LEXTK=$O(@(LEXRT_""""_LEXTK_""")")) Q:'$L(LEXTK)  D
 . . . N LEXCHR S LEXCHR=$E($TR(LEXTK," ",""),1)
 . . . S LEXTK=$E(LEXTK,1)_"~" S:$L(LEXCHR) LEXCHRS(LEXCHR)=""
 . S LEXCHR="" F  S LEXCHR=$O(LEXCHRS(LEXCHR)) Q:'$L(LEXCHR)  D
 . . ;       For words beginning with character
 . . W:'$D(ZTQUEUED)&($D(LEXTEST)) LEXCHR
 . . N LEXLWRD,LEXTWRD,LEXIT
 . . S (LEXLWRD,LEXTWRD)=$C($A(LEXCHR)-1)_"~",LEXIT=0
 . . F  S LEXLWRD=$O(^LEX(757.21,LEXID,LEXLWRD)) D  Q:LEXIT>0
 . . . S:'$L(LEXLWRD) LEXIT=1 S:$E(LEXLWRD,1)'=LEXCHR LEXIT=1
 . . . Q:LEXIT>0  S LEX2=LEX2+1
 . . . ;         Delete words from the Subset
 . . . N LEXNOD,LEXCTL,LEXCMD
 . . . S LEXNOD="^LEX(757.21,"""_LEXID_""","""_LEXTWRD_""")"
 . . . S LEXCTL="^LEX(757.21,"""_LEXID_""","""_LEXTWRD_""","
 . . . F  S LEXNOD=$Q(@LEXNOD) Q:'$L(LEXNOD)!(LEXNOD'[LEXCTL)  D
 . . . . S LEX3=LEX3+1
 . . . S LEXCMD="K ^LEX(757.21,"""_LEXID_""","""_LEXLWRD_""")"
 . . . X LEXCMD
 . . S LEXTWRD=$C($A(LEXCHR)-1)_"~",LEXIT=0
 . . F  S LEXTWRD=$O(^TMP("LEXSUB",$J,LEXID,LEXTWRD)) D  Q:LEXIT>0
 . . . S:'$L(LEXTWRD) LEXIT=1 S:$E(LEXTWRD,1)'=LEXCHR LEXIT=1
 . . . Q:LEXIT>0  N LEXNOD,LEXCTL
 . . . S LEXNOD="^TMP(""LEXSUB"","_$J_","""_LEXID_""","""_LEXTWRD_""")"
 . . . S LEXCTL="^TMP(""LEXSUB"","_$J_","""_LEXID_""","""_LEXTWRD_""","
 . . . F  S LEXNOD=$Q(@LEXNOD) Q:'$L(LEXNOD)!(LEXNOD'[LEXCTL)  D
 . . . . ;         Copy Index from ^TMP to ^LEX
 . . . . N LEXCMD S LEXCMD="S ^LEX(757.21,"""_LEXID_""","
 . . . . S LEXCMD=LEXCMD_$P(LEXNOD,",",4,229)_"="""""
 . . . . X LEXCMD S LEX4=LEX4+1
 . . ;       Repeat for all characters
 . ;     Repeat for all Subset Indexes
 H 1 S LEXEND=$$END^LEXXGP1 D SAV(LEXBEG,LEXEND,LEXTXT)
 S LEXELP=$$ELP^LEXXGP1(LEXBEG,LEXEND),LEXBEGD=$$ED^LEXXGP1(LEXBEG)
 S LEXBEGT=$$ET^LEXXGP1(LEXBEG),LEXENDT=$$ET^LEXXGP1(LEXEND),LEXDF=$$DF^LEXXGP1(LEXBEG)
 S LEXTXT=$G(LEXTXT)_$J(" ",(35-$L($G(LEXTXT))))
 S LEXTXT=LEXTXT_LEXDF_"   "_LEXBEGT_"   "_LEXENDT_"   "_LEXELP
 S LEXTXT=" "_LEXTXT W:'$D(ZTQUEUED) !,LEXTXT
 I LEX1>0,$D(LEXFUL) D
 . S LEXCOM=LEX1_" Subset"_$S(LEX1>1:"s",1:"")
 . D SAV(LEXBEG,"","",LEXCOM)
 . W:'$D(ZTQUEUED) !,"   ",LEXCOM
 I LEX2>0,$D(LEXFUL) D
 . S LEXCOM=LEX2_" Word"_$S(LEX2>1:"s",1:"")
 . D SAV(LEXBEG,"","",LEXCOM)
 . W:'$D(ZTQUEUED) !,"   ",LEXCOM
 I LEX4>0,$D(LEXFUL) D
 . S LEXCOM=LEX4_" Subset Index Node"_$S(LEX4>1:"s",1:"")
 . D SAV(LEXBEG,"","",LEXCOM)
 . W:'$D(ZTQUEUED) !,"   ",LEXCOM
 N ZTQUEUED,LEXTEST,LEXFUL
 Q
 ;
 ; MailMan
XM ;   Mail Message
 N LEX1,LEX2,LEXB,LEXC,LEXD,LEXE,LEXJ,LEXMAIL,LEXN
 N LEXPRE,LEXNEW,LEXS,LEXT,LEXX,LEXI,LEXNM,XCNP
 N XMDUZ,XMSCR,XMSUB,XMTEXT,XMY,XMZ
 D XMG K ^TMP("LEXXGPMSG") N LEXI S LEXI=0
 F  S LEXI=$O(^TMP("LEXXGPRPT",$J,LEXI)) Q:+LEXI'>0  D
 . N LEXN,LEXT S LEXN=$O(^TMP("LEXXGPMSG",$J," "),-1)+1
 . S LEXT=$G(^TMP("LEXXGPRPT",$J,LEXI))
 . S ^TMP("LEXXGPMSG",$J,+LEXN)=$G(LEXT),^TMP("LEXXGPMSG",$J,0)=LEXN
 D:$O(^TMP("LEXXGPMSG",$J,0))>0 XMS
 Q
XMG ;   Get Data for Message
 K ^TMP("LEXXGPRPT",$J)
 N LEXO1,LEXTXT,LEXLN,LEXPDT S LEXPDT="",(LEXLN,LEXO1)=0
 F  S LEXO1=$O(^TMP("LEXXGPDAT",$J,LEXO1)) Q:+LEXO1'>0  D
 . N LEXO2 S LEXO2="" F  S LEXO2=$O(^TMP("LEXXGPDAT",$J,LEXO1,LEXO2)) Q:+LEXO2'>0  D
 . . N LEXN,LEXBEG,LEXBEGD,LEXDF,LEXBEGT,LEXEND,LEXENDD,LEXENDT,LEXTXT
 . . N LEXCOM,LEXHDR,LEXELPT
 . . S LEXNOD=$G(^TMP("LEXXGPDAT",$J,LEXO1,LEXO2)),LEXLN=LEXLN+1
 . . S LEXBEG=$P(LEXNOD,"^",1),LEXD=$P(LEXBEG,".",1),LEXCOM=$P(LEXNOD,"^",8)
 . . I $L(LEXBEG),LEXD?7N,$L(LEXCOM) D  Q
 . . . N LEXN S LEXN=$O(^TMP("LEXXGPRPT",$J," "),-1)+1
 . . . S ^TMP("LEXXGPRPT",$J,+LEXN)="   "_LEXCOM
 . . S LEXDF=$$DF^LEXXGP1(LEXBEG)
 . . S LEXEND=$P(LEXNOD,"^",2)
 . . S LEXBEGD=$P(LEXNOD,"^",3)
 . . S LEXBEGT=$P(LEXNOD,"^",4)
 . . S LEXENDT=$P(LEXNOD,"^",5)
 . . S LEXELPT=$P(LEXNOD,"^",6)
 . . S LEXTXT=$P(LEXNOD,"^",7)
 . . S:LEXBEGD=LEXPDT&($L(LEXDF))&(LEXD'["-") LEXBEGD=LEXDF
 . . S LEXPDT=$G(LEXBEGD)
 . . S LEXTXT=$$FMT^LEXXGP1($G(LEXTXT),LEXBEGD,LEXBEGT,LEXENDT,LEXELPT)
 . . I '$D(^TMP("LEXXGPRPT",$J)) D
 . . . S ^TMP("LEXXGPRPT",$J,0)=1,^TMP("LEXXGPRPT",$J,1)="  "
 . . . N LEXHDR S LEXHDR="Re-Index Repair"
 . . . S LEXHDR=$G(LEXHDR)_$J(" ",(35-$L($G(LEXHDR))))_"Date      "_"   "_"Start   "_"   "_"Finish  "_"   "_"Elapsed "
 . . . S LEXHDR=" "_LEXHDR S ^TMP("LEXXGPRPT",$J,0)=2,^TMP("LEXXGPRPT",$J,2)=LEXHDR
 . . . S LEXHDR="---------------------------------"
 . . . S LEXHDR=$G(LEXHDR)_$J(" ",(35-$L($G(LEXHDR))))_"----------"_"   "_"--------"_"   "_"--------"_"   "_"--------"
 . . . S LEXHDR=" "_LEXHDR S ^TMP("LEXXGPRPT",$J,0)=3,^TMP("LEXXGPRPT",$J,3)=LEXHDR
 . . S LEXN=$O(^TMP("LEXXGPRPT",$J," "),-1)+1
 . . S ^TMP("LEXXGPRPT",$J,0)=LEXN,^TMP("LEXXGPRPT",$J,LEXN)=" "_LEXTXT
 S LEXTXT=$$FMTT^LEXXGP1 I $L(LEXTXT) D
 . N LEXN,LEXHDR
 . S LEXHDR="---------------------------------"
 . S LEXHDR=$G(LEXHDR)_$J(" ",(35-$L($G(LEXHDR))))_"----------"_"   "_"--------"_"   "_"--------"_"   "_"--------"
 . S LEXN=$O(^TMP("LEXXGPRPT",$J," "),-1)+1
 . S ^TMP("LEXXGPRPT",$J,0)=LEXN,^TMP("LEXXGPRPT",$J,LEXN)=" "_LEXHDR
 . S LEXN=$O(^TMP("LEXXGPRPT",$J," "),-1)+1
 . S ^TMP("LEXXGPRPT",$J,0)=LEXN,^TMP("LEXXGPRPT",$J,LEXN)=" "_LEXTXT
 Q
XMGS ;   Show Message
 W:$O(^TMP("LEXXGPRPT",$J,0))>0 !
 N LEXC S LEXC=0 F  S LEXC=$O(^TMP("LEXXGPRPT",$J,LEXC)) Q:+LEXC'>0  D
 . N LEXT S LEXT=$G(^TMP("LEXXGPRPT",$J,LEXC)) W:$L(LEXT) !,LEXT
 W:$O(^TMP("LEXXGPRPT",$J,0))>0 !!
 Q
XMB ;   Build Message
 K ^TMP("LEXXGPMSG") N LEXI S LEXI=0
 F  S LEXI=$O(^TMP("LEXXGPRPT",$J,LEXI)) Q:+LEXI'>0  D
 . N LEXN,LEXT S LEXN=$O(^TMP("LEXXGPMSG",$J," "),-1)+1
 . S LEXT=$G(^TMP("LEXXGPRPT",$J,LEXI))
 . S ^TMP("LEXXGPMSG",$J,+LEXN)=$G(LEXT),^TMP("LEXXGPMSG",$J,0)=LEXN
 Q
XMS ;   Send Message
 N XCNP,XMSCR,XMDUZ,XMY,XMZ,XMSUB,XMY,XMTEXT,XMDUZ,LEXJ,LEXNM
 Q:'$D(^TMP("LEXXGPMSG",$J))
 S XMTEXT="^TMP(""LEXXGPMSG"","_$J_",",XMSUB="Repair Major Word Indexes"
 S LEXNM=$$GET1^DIQ(200,+($G(DUZ)),.01) S:$D(LEXHOME) XMY(("G.LEXINS@"_$$XMA))=""
 S XMY(LEXNM)="",XMDUZ=.5 D ^XMD
 I '$D(ZTQUEUED),+($G(XMZ))>0 D
 . W !!," Lexicon Index Repair Message #",($G(XMZ))," sent"
XMSQ ;   Send Message (Quit)
 K ^TMP("LEXXGPMSG",$J) K XCNP,XMSCR,XMDUZ,XMY,XMZ,XMSUB,XMY,XMTEXT,XMDUZ,LEXNM
 Q
XMA(LEX) ;   Message Address
 N DIC,DTOUT,DUOUT,X,Y S DIC="^DIC(4.2,",DIC(0)="M",(LEX,X)="FO-SLC.MED.VA.GOV" D ^DIC Q:+Y>0 LEX
 S DIC="^DIC(4.2,",DIC(0)="M",(LEX,X)="ISC-SLC.MED.VA.GOV" D ^DIC Q:+Y>0 LEX
 Q "ISC-SLC.VA.GOV"
SSF ; Subsets (Fileman)
 N LEX F LEX="AADM","AASS","AATT","ABDS","ACLF","ACLL","ACLS","ACON","ADEN","ADIS","AENL","AENV","AETH","AEVE","AFND","AFOR" K ^LEX(757.21,LEX)
 F LEX="AGEO","AIMM","AINA","ALIF","AMAB","ANAM","ANAV","ANUR","AOBJ","AOBS","AOCC","AORG","APER","APLS","APRC","APRD" K ^LEX(757.21,LEX)
 F LEX="AQUV","AREC","AREG","AREL","ASCH","ASCT","ASIT","ASOC","ASPC","ASPL","ASTG","ASUB","ATMR","B","C" K ^LEX(757.21,LEX)
 N DIK,ZTQUEUED S ZTQUEUED="" S DIK="^LEX(757.21," D IXALL^DIK
 Q
 ; Miscellaneous
SAV(LEXBEG,LEXEND,LEXTXT,LEXCOM) ; Save Dates, Times and Text
 N LEXTMP,LEXBEGD,LEXBEGT,LEXENDD,LEXENDT,LEXP,LEXD,LEXC,LEXN,LEXELP
 S LEXBEG=$G(LEXBEG),LEXCOM=$G(LEXCOM)
 S LEXD=$P(LEXBEG,".",1) Q:LEXD'?7N
 I $L(LEXD),$L(LEXBEG),$L(LEXCOM) D  Q
 . N LEXN S LEXN=$O(^TMP("LEXXGPDAT",$J,LEXD," "),-1)+1
 . S ^TMP("LEXXGPDAT",$J,LEXD,+LEXN)=LEXBEG_"^^^^^^^"_LEXCOM
 S LEXEND=$G(LEXEND),LEXTXT=$G(LEXTXT)
 Q:$P(LEXEND,".",1)'?7N  Q:'$L(LEXTXT)
 S LEXELP=$$ELP^LEXXGP1(LEXBEG,LEXEND),LEXBEGD=$$ED^LEXXGP1(LEXBEG)
 S LEXBEGT=$$ET^LEXXGP1(LEXBEG),LEXENDT=$$ET^LEXXGP1(LEXEND)
 S LEXBEGD=$$DF^LEXXGP1(LEXBEG),LEXN=$O(^TMP("LEXXGPDAT",$J,LEXD," "),-1)+1
 S LEXTMP=LEXBEG_"^"_LEXEND_"^"_LEXBEGD_"^"_LEXBEGT_"^"_LEXENDT
 S LEXTMP=LEXTMP_"^"_LEXELP_"^"_LEXTXT
 S ^TMP("LEXXGPDAT",$J,LEXD,+LEXN)=LEXTMP
 Q