[613] | 1 | LEXAS2 ; ISL Look-up Check Input (ONE) ; 09-23-96
|
---|
| 2 | ;;2.0;LEXICON UTILITY;;Sep 23, 1996;Build 1
|
---|
| 3 | ;
|
---|
| 4 | ONE(LEXX) ; One letter missing/incorrect
|
---|
| 5 | ;
|
---|
| 6 | ; LEXRIM Trimmed string
|
---|
| 7 | ; LEXI Character position
|
---|
| 8 | ; LEXF First portion
|
---|
| 9 | ; LEXT Trailing portion
|
---|
| 10 | ; LEXTL Trailing letter
|
---|
| 11 | ; LEXNF Strings found
|
---|
| 12 | ; LEXO $O variable
|
---|
| 13 | ; LEXNT Temporary string
|
---|
| 14 | ; LEXX String returned
|
---|
| 15 | ;
|
---|
| 16 | N LEXI,LEXF,LEXT,LEXTL,LEXNF,LEXO,LEXNT,LEXRIM
|
---|
| 17 | S LEXTL=$E(LEXX,$L(LEXX)),LEXRIM=$$TRIM^LEXAS6(LEXX)
|
---|
| 18 | S LEXF=$E(LEXRIM,1,($L(LEXRIM)-1)),LEXNF="",LEXKEY=$G(LEXKEY)
|
---|
| 19 | F LEXI=1:1:$L(LEXX) D
|
---|
| 20 | . S LEXF=$E(LEXX,1,LEXI)
|
---|
| 21 | . S LEXT=$E(LEXX,(LEXI+1),$L(LEXX))
|
---|
| 22 | . S LEXO=$$SCH^LEXAS6(LEXF)
|
---|
| 23 | . F S LEXO=$O(^LEX(757.01,"AWRD",LEXO)) Q:LEXO'[LEXF D
|
---|
| 24 | . . S LEXO=$E(LEXO,1,($L(LEXF)+1))
|
---|
| 25 | . . Q:$L(LEXO)<($L(LEXF)+1)
|
---|
| 26 | . . S LEXNT=LEXO_LEXT
|
---|
| 27 | . . I $D(^LEX(757.01,"ASL",LEXNT)) D
|
---|
| 28 | . . . S LEXNF=LEXNF_"/"_LEXNT
|
---|
| 29 | . . S LEXNT=LEXO_$E(LEXT,2,$L(LEXT))
|
---|
| 30 | . . I $D(^LEX(757.01,"ASL",LEXNT)) D
|
---|
| 31 | . . . S LEXNF=LEXNF_"/"_LEXNT
|
---|
| 32 | . . S LEXO=LEXO_"~"
|
---|
| 33 | S:$E(LEXNF,1)="/" LEXNF=$E(LEXNF,2,$L(LEXNF))
|
---|
| 34 | I LEXNF'="",LEXNF["/" D PICK
|
---|
| 35 | I LEXNF'=""&(LEXNF'["/") S LEXRIM=LEXNF Q LEXRIM
|
---|
| 36 | S LEXRIM=$$TRIM^LEXAS6(LEXRIM) Q LEXRIM
|
---|
| 37 | Q LEXRIM
|
---|
| 38 | ;
|
---|
| 39 | PICK ; Pick one string
|
---|
| 40 | ;
|
---|
| 41 | ; LEXNF Strings found
|
---|
| 42 | ; LEXAN Array of strings by frequency
|
---|
| 43 | ; LEXI Position/Piece in string
|
---|
| 44 | ; LEXIN Position/Piece in altered string
|
---|
| 45 | ; LEXEXP Expression
|
---|
| 46 | ; LEXES Expresseion segment/string
|
---|
| 47 | ; LEXKEY Key for selecting string
|
---|
| 48 | ; LEXKEYO $Orderable KEY
|
---|
| 49 | ; LEXOK Flag - Selection is OK
|
---|
| 50 | ; LEXC Control string
|
---|
| 51 | ; LEXP Character position in segment
|
---|
| 52 | ; LEXR Record number for expression
|
---|
| 53 | ; LEXN Altered string
|
---|
| 54 | ; LEXM Maximum string length
|
---|
| 55 | ; LEXS Shortest string length
|
---|
| 56 | ;
|
---|
| 57 | N LEXOK,LEXI,LEXC,LEXN,LEXS,LEXM S LEXI=0,LEXC=""
|
---|
| 58 | S LEXS=$P(LEXNF,"/",1)
|
---|
| 59 | F LEXI=1:1:$L(LEXNF,"/") D
|
---|
| 60 | . S LEXN=$P(LEXNF,"/",LEXI) I LEXC="" S LEXC=LEXN Q
|
---|
| 61 | . S LEXM=$S($L(LEXC)>$L(LEXN):$L(LEXC),1:$L(LEXN))
|
---|
| 62 | . N LEXP F LEXP=LEXM:-1:1 Q:$E(LEXC,1,LEXP)=$E(LEXN,1,LEXP)
|
---|
| 63 | . S:LEXP<$L(LEXS) LEXS=$E(LEXS,1,LEXP)
|
---|
| 64 | S LEXC=$E(LEXX,($L(LEXS)+2),$L(LEXX)),LEXN=""
|
---|
| 65 | ; Key supplied
|
---|
| 66 | I $L($G(LEXKEY)) S LEXOK=0 D Q:LEXOK
|
---|
| 67 | . ; order through pieces
|
---|
| 68 | . N LEXAN,LEXI
|
---|
| 69 | . F LEXI=1:1:$L(LEXNF,"/") D Q:LEXOK
|
---|
| 70 | . . S LEXN=$P(LEXNF,"/",LEXI)
|
---|
| 71 | . . ; order through expressions
|
---|
| 72 | . . N LEXR,LEXKEYO S LEXR=0,LEXKEYO=$$SCH^LEXAS6(LEXKEY)
|
---|
| 73 | . . F S LEXKEYO=$O(^LEX(757.01,"AWRD",LEXKEYO)) Q:LEXKEYO=""!(LEXKEYO'[LEXKEY)!(LEXOK) D
|
---|
| 74 | . . . F S LEXR=$O(^LEX(757.01,"AWRD",LEXKEYO,LEXR)) Q:+LEXR=0!(LEXOK) D
|
---|
| 75 | . . . . N LEXEXP S LEXEXP=$$UP^XLFSTR(^LEX(757.01,LEXR,0))
|
---|
| 76 | . . . . N LEXIN,LEXES F LEXIN=1:1:$L(LEXEXP," ") D Q:LEXOK
|
---|
| 77 | . . . . . S LEXES=$P(LEXEXP," ",LEXIN)
|
---|
| 78 | . . . . . Q:$E(LEXES,1)'=$E(LEXN,1)
|
---|
| 79 | . . . . . Q:$E(LEXN,$L(LEXN))'=$E(LEXES,$L(LEXN))
|
---|
| 80 | . . . . . N LEXP,LEXC S LEXC=0 F LEXP=1:1:$L(LEXN) D Q:LEXOK
|
---|
| 81 | . . . . . . I $E(LEXES,1,$L(LEXN))[$E(LEXN,LEXP) S LEXC=LEXC+1
|
---|
| 82 | . . . . . S:LEXC>0 LEXAN(-(LEXC))=LEXN
|
---|
| 83 | . S LEXN="" S:$O(LEXAN(-999999))<0 LEXN=$O(LEXAN(-999999)),LEXN=LEXAN(LEXN)
|
---|
| 84 | . I LEXN'="" S LEXNF=LEXN,LEXOK=1
|
---|
| 85 | ; No key supplied
|
---|
| 86 | F LEXI=1:1:$L(LEXNF,"/") D Q:LEXN[LEXC
|
---|
| 87 | . S LEXN=$P(LEXNF,"/",LEXI)
|
---|
| 88 | . I LEXN[LEXC,$E(LEXN,$L(LEXN))=LEXTL S LEXNF=LEXN
|
---|
| 89 | Q
|
---|