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

LEXSRC.m

Go to the documentation of this file.
LEXSRC ;ISL/KER - Classification Code Source ;08/17/2011
 ;;2.0;LEXICON UTILITY;**7,25,26,38,73,81**;Sep 23, 1996;Build 1
 ;
 ; External References
 ;   None
 ;                     
ONE(LEXI,LEXS,LEXVDT) ; Return a single primary code of a source
 S LEXI=+($G(LEXI)),LEXS=$G(LEXS) S LEXI=$$CODE(LEXI,LEXS,$G(LEXVDT)) Q LEXI
ALL(LEXI,LEXS,LEXVDT) ; Return all codes of a source
 S LEXI=+($G(LEXI)),LEXS=$G(LEXS)
 D CODES(LEXI,LEXS,$G(LEXVDT))
 Q
CODE(LEXI,LEXS,LEXVDT) ; Return a single primary code
 N LEXSRC D CODES(LEXI,LEXS,$G(LEXVDT))
 S LEXI=$G(LEXSRC(1)) Q LEXI
CODES(LEXI,LEXS,LEXVDT) ; Build an array LEXSRC of codes
 S LEXI=+($G(LEXI)) Q:LEXI=0  Q:'$D(^LEX(757.01,LEXI))
 S LEXS=$G(LEXS) Q:'$D(^LEX(757.03,"ASAB",LEXS))
 N LEXMC S LEXMC=+($G(^LEX(757.01,LEXI,1))) Q:'$D(^LEX(757,LEXMC,0))
 N LEXMCE S LEXMCE=+($G(^LEX(757,LEXMC,0))) Q:'$D(^LEX(757.01,LEXMCE,0))
 N LEXUNI,LEXSA,LEXN,LEXSAB,LEXSTA,LEXPRI,LEXNOM,LEXCC,LEXX S LEXSA=0
 F  S LEXSA=$O(^LEX(757.02,"AMC",LEXMC,LEXSA)) Q:+LEXSA=0  D
 . N LEXLD,LEXLS,LEXSR,LEXHC,LEXHE,LEXHI,LEXHN,LEXHS,LEXN
 . S LEXN=$G(^LEX(757.02,LEXSA,0))
 . S LEXHC=$S(+LEXVDT>0:(LEXVDT_".99999"),1:" ")
 . S LEXHE=$O(^LEX(757.02,+LEXSA,4,"B",LEXHC),-1) Q:+LEXHE'>0
 . S LEXHI=$O(^LEX(757.02,+LEXSA,4,"B",+LEXHE," "),-1)
 . S LEXHN=$G(^LEX(757.02,+LEXSA,4,+LEXHI,0)),LEXHS=$P(LEXHN,"^",2) Q:+($G(LEXHS))'>0
 . S LEXCC=$P(LEXN,"^",2) Q:LEXCC=""  S LEXSR=$P(LEXN,"^",3) Q:+LEXSR'>0
 . S LEXSAB=+($P(LEXN,"^",3)),LEXSAB=$E($G(^LEX(757.03,LEXSAB,0)),1,3) Q:LEXSAB'=LEXS
 . S LEXPRI=+($P(LEXN,"^",7)),LEXCC=$P(LEXN,"^",2) Q:LEXCC=""
 . D:LEXPRI>0 PRI(LEXCC) D:LEXPRI=0 NOM(LEXCC)
 D COMP
 Q
PRI(LEXX) ; Primary Code
 N LEXCC S LEXCC=$G(LEXX) Q:LEXCC=""  S LEXX=+($G(LEXPRI(0))),LEXX=LEXX+1
 S LEXPRI(LEXX)=LEXCC,LEXPRI(0)=LEXX Q
NOM(LEXX) ; Normal Code
 N LEXCC S LEXCC=$G(LEXX) Q:LEXCC=""  S LEXX=+($G(LEXNOM(0))),LEXX=LEXX+1
 S LEXNOM(LEXX)=LEXCC,LEXNOM(0)=LEXX Q
COMP ; Compile array from Primary and Normal Codes
 N LEXUNI,LEXCT,LEXNT S (LEXCT,LEXNT)=0
 I $L($G(LEXPRI(1))) D
 . S LEXCT=LEXCT+1,LEXSRC(LEXCT)=LEXPRI(1)
 . S LEXSRC(0)=LEXCT,LEXUNI(LEXPRI(1))=""
 F  S LEXNT=$O(LEXNOM(LEXNT)) Q:+LEXNT=0  D
 . Q:$D(LEXUNI(LEXNOM(LEXNT)))
 . I $L($G(LEXNOM(LEXNT))) D
 . . S LEXCT=LEXCT+1,LEXSRC(LEXCT)=LEXNOM(LEXNT),LEXSRC(0)=LEXCT,LEXUNI(LEXNOM(LEXNT))=""
 K LEXPRI,LEXNOM,LEXUNI Q