source: FOIAVistA/trunk/r/LEXICON_UTILITY-LEX-GMPT/LEXSRC.m@ 945

Last change on this file since 945 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.0 KB
Line 
1LEXSRC ; ISL/KER - Classification Code Source ; 02/02/2006
2 ;;2.0;LEXICON UTILITY;**7,25,26,38**;Sep 23, 1996
3 ;
4 ; External References
5 ; None
6 ;
7ONE(LEXI,LEXS,LEXVDT) ; Return a single primary code of a source
8 S LEXI=+($G(LEXI)),LEXS=$G(LEXS) S LEXI=$$CODE(LEXI,LEXS,$G(LEXVDT)) Q LEXI
9ALL(LEXI,LEXS,LEXVDT) ; Return all codes of a source
10 S LEXI=+($G(LEXI)),LEXS=$G(LEXS)
11 D CODES(LEXI,LEXS,$G(LEXVDT))
12 Q
13CODE(LEXI,LEXS,LEXVDT) ; Return a single primary code
14 N LEXSRC D CODES(LEXI,LEXS,$G(LEXVDT)) S LEXI=$G(LEXSRC(1)) Q LEXI
15CODES(LEXI,LEXS,LEXVDT) ; Build an array LEXSRC of codes
16 S LEXI=+($G(LEXI)) Q:LEXI=0 Q:'$D(^LEX(757.01,LEXI))
17 S LEXS=$G(LEXS) Q:'$D(^LEX(757.03,"ASAB",LEXS))
18 N LEXMC S LEXMC=+($G(^LEX(757.01,LEXI,1))) Q:'$D(^LEX(757,LEXMC,0))
19 N LEXMCE S LEXMCE=+($G(^LEX(757,LEXMC,0))) Q:'$D(^LEX(757.01,LEXMCE,0))
20 N LEXUNI,LEXSA,LEXN,LEXSAB,LEXSTA,LEXPRI,LEXNOM,LEXCC,LEXX S LEXSA=0
21 F S LEXSA=$O(^LEX(757.02,"AMC",LEXMC,LEXSA)) Q:+LEXSA=0 D
22 . S LEXN=$G(^LEX(757.02,LEXSA,0)) N LEXLD,LEXLS
23 . S LEXCC=$P(LEXN,"^",2) Q:LEXCC=""
24 . S LEXSTA=+($$STATCHK^LEXSRC2(LEXCC,$G(LEXVDT))) Q:+LEXSTA'>0
25 . S LEXSAB=+($P(LEXN,"^",3)),LEXSAB=$E($G(^LEX(757.03,LEXSAB,0)),1,3) Q:LEXSAB'=LEXS
26 . S LEXPRI=+($P(LEXN,"^",7)),LEXCC=$P(LEXN,"^",2) Q:LEXCC=""
27 . D:LEXPRI>0 PRI(LEXCC) D:LEXPRI=0 NOM(LEXCC)
28 D COMP
29 Q
30PRI(LEXX) ; Primary Code
31 N LEXCC S LEXCC=$G(LEXX) Q:LEXCC="" S LEXX=+($G(LEXPRI(0))),LEXX=LEXX+1
32 S LEXPRI(LEXX)=LEXCC,LEXPRI(0)=LEXX Q
33NOM(LEXX) ; Normal Code
34 N LEXCC S LEXCC=$G(LEXX) Q:LEXCC="" S LEXX=+($G(LEXNOM(0))),LEXX=LEXX+1
35 S LEXNOM(LEXX)=LEXCC,LEXNOM(0)=LEXX Q
36COMP ; Compile array from Primary and Normal Codes
37 N LEXUNI,LEXCT,LEXNT S (LEXCT,LEXNT)=0
38 I $L($G(LEXPRI(1))) D
39 . S LEXCT=LEXCT+1,LEXSRC(LEXCT)=LEXPRI(1)
40 . S LEXSRC(0)=LEXCT,LEXUNI(LEXPRI(1))=""
41 F S LEXNT=$O(LEXNOM(LEXNT)) Q:+LEXNT=0 D
42 . Q:$D(LEXUNI(LEXNOM(LEXNT)))
43 . I $L($G(LEXNOM(LEXNT))) D
44 . . S LEXCT=LEXCT+1,LEXSRC(LEXCT)=LEXNOM(LEXNT),LEXSRC(0)=LEXCT,LEXUNI(LEXNOM(LEXNT))=""
45 K LEXPRI,LEXNOM,LEXUNI Q
Note: See TracBrowser for help on using the repository browser.