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

BQIUTB3.m

Go to the documentation of this file.
BQIUTB3 ;VNGT/HS/ALA-Taxonomy table ; 20 Feb 2013  7:50 AM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;
 Q
 ;
EN(DATA,TAXTY) ;EP -- BQI GET TAXONOMIES
 NEW UID,II,Z,FILE,TN,NM
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIUTB3",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIUTB1 D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="T00030TAXONOMY_NAME^T00015TAXONOMY_IEN"_$C(30)
 S TAXTY=$G(TAXTY,""),FILE=""
 I TAXTY'="" S FILE=$S(TAXTY="DX":80,TAXTY="M":50,TAXTY="CP":81,TAXTY="PR":80.1,TAXTY="LB":60,TAXTY="ED":9999999.09,1:"")
 I TAXTY'="LB" D
 . S TN=0
 . F  S TN=$O(^ATXAX(TN)) Q:'TN  D
 .. I FILE'="",$P(^ATXAX(TN,0),U,15)'=FILE Q
 .. I $P(^ATXAX(TN,0),U,12)="" Q
 .. I $O(^ATXAX(TN,21,0))="" Q
 .. S NM=$P(^ATXAX(TN,0),U,1)
 .. S Z(NM,TN)=""
 . ;
 . S NM=""
 . F  S NM=$O(Z(NM)) Q:NM=""  D
 .. S TN=""
 .. F  S TN=$O(Z(NM,TN)) Q:TN=""  S II=II+1,@DATA@(II)=NM_U_TN_";ATXAX("_$C(30)
 ;
 I TAXTY="LB" D
 . S TN=0
 . F  S TN=$O(^ATXLAB(TN)) Q:'TN  D
 .. I FILE'="",$P(^ATXLAB(TN,0),U,9)'=FILE Q
 .. ;I $P(^ATXLAB(TN,0),U,7)="" Q
 .. I $O(^ATXLAB(TN,21,0))="" Q
 .. S NM=$P(^ATXLAB(TN,0),U,1)
 .. S Z(NM,TN)=""
 . ;
 . S NM=""
 . F  S NM=$O(Z(NM)) Q:NM=""  D
 .. S TN=""
 .. F  S TN=$O(Z(NM,TN)) Q:TN=""  S II=II+1,@DATA@(II)=NM_U_TN_";ATXLAB("_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ALG(DATA) ;EP - Get a list of allergies
 NEW TEXT,IEN,VALUE
 K @DATA
 S II=0
 S @DATA@(II)="T00080IEN^T00080"_$C(30)
 S VALUE=$NA(^TMP("BQIALGY",UID)) K @VALUE
 S IEN=0
 F  S IEN=$O(^GMR(120.8,IEN)) Q:'IEN  D
 . S TEXT=$P($G(^GMR(120.8,IEN,0)),U,2) I TEXT="" Q
 . I $P($G(^GMR(120.8,IEN,"ER")),U,1)=1 Q
 . S TEXT=$$STRIP^BQIUL1(TEXT," ")
 . S @VALUE@(TEXT)=""
 ;
 S TEXT=""
 F  S TEXT=$O(@VALUE@(TEXT)) Q:TEXT=""  S II=II+1,@DATA@(II)=TEXT_U_TEXT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 K @VALUE
 Q
 ;
LAB(DATA) ;EP - Lab Tests
 NEW LN
 K @DATA
 S II=0,LN=0
 S @DATA@(II)="T00010IEN^T00060"_$C(30)
 F  S LN=$O(^AUPNVLAB("B",LN)) Q:LN=""  D
 . I $G(^LAB(60,LN,0))="" Q
 . S II=II+1,@DATA@(II)=LN_U_$P(^LAB(60,LN,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
LABR(DATA) ;EP - Lab Tests and results
 NEW LN,TYP,TYPE,VALUE,LTYP
 K @DATA
 S II=0,LN=0
 S @DATA@(II)="T00010IEN^T00060^T00010TYPE^T00030VALUE"_$C(30)
 F  S LN=$O(^AUPNVLAB("B",LN)) Q:LN=""  D
 . I $G(^LAB(60,LN,0))="" Q
 . S TYP=$P(^LAB(60,LN,0),"^",12),VALUE="",TYPE="",LTYP=""
 . I TYP'="" D LTY(TYP)
 . I $O(^LAB(60,LN,2,0))'="" S LTYP="P",TYPE="PANEL"
 . S II=II+1,@DATA@(II)=LN_U_$P(^LAB(60,LN,0),U,1)_$S(TYPE="":"",1:" ("_LTYP_")")_U_TYPE_U_VALUE_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
LTY(TYP) ;EP - Lab results
 NEW FLD,TEST
 S FLD=$P(TYP,",",2)
 D FIELD^DID(63.04,FLD,"","*","TEST")
 S TYPE=$G(TEST("TYPE")) I TYPE'="" S LTYP=$E(TYPE,1,1)
 S VALUE=$G(TEST("POINTER"))
 Q
 ;
MED(DATA) ;EP - Medications
 NEW MN
 K @DATA
 S II=0,MN=0
 S @DATA@(II)="T00010IEN^T00060"_$C(30)
 F  S MN=$O(^AUPNVMED("B",MN)) Q:MN=""  D
 . I $G(^PSDRUG(MN,0))="" Q
 . S II=II+1,@DATA@(II)=MN_U_$P(^PSDRUG(MN,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
CPT(DATA) ; EP - CPT
 NEW MN
 K @DATA
 S II=0,MN=""
 S @DATA@(II)="T00010IEN^T00060"_$C(30)
 F  S MN=$O(^AUPNVCPT("B",MN)) Q:MN=""  D
 . I $G(^ICPT(MN,0))="" Q
 . S II=II+1,@DATA@(II)=MN_U_$P(^ICPT(MN,0),U,1)_"-"_$P(^ICPT(MN,0),U,2)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
EXM(DATA) ;EP - Exams
 NEW MN
 K @DATA
 S II=0,MN=""
 S @DATA@(II)="T00010IEN^T00060"_$C(30)
 F  S MN=$O(^AUPNVXAM("B",MN)) Q:MN=""  D
 . I $G(^AUTTEXAM(MN,0))="" Q
 . S II=II+1,@DATA@(II)=MN_U_$P(^AUTTEXAM(MN,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
DXN(DATA) ;EP - Diagnoses
 NEW DN,VALUE
 S II=0,DN=0
 S @DATA@(II)="T00010IEN^T00030"_$C(30)
 F  S DN=$O(^XTMP("BQIPOV",DN)) Q:'DN  D
 . S VALUE=^XTMP("BQIPOV",DN)
 . S II=II+1,@DATA@(II)=$P(VALUE,U,1)_U_$P(VALUE,U,2)_" ["_$P(VALUE,U,3)_"] ("_$P(VALUE,U,4)_")"_$C(30) Q
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
TPOV(DATA,NUM) ;EP - Top # of POVs
 NEW NM,DN,VALUE,CT
 S II=0,NM="",CT=0
 F  S NM=$O(^XTMP("BQIPOV","Z",NM),-1) Q:NM=""  D  Q:CT>NUM
 . S DN="" F  S DN=$O(^XTMP("BQIPOV","Z",NM,DN)) Q:DN=""  D
 .. S VALUE=^XTMP("BQIPOV","Z",NM,DN)
 .. S II=II+1,@DATA@(II)=DN_U_$P(VALUE,U,1)_" ["_$P(VALUE,U,2)_"]"_$C(30),CT=CT+1
 Q
 ;
POVS(DATA) ;EP - Snomed IDs for POV
 NEW DN,SN
 K @DATA
 S II=0,DN=0
 S @DATA@(II)="T00100IEN^T00245"_$C(30)
 F  S DN=$O(^AUPNVPOV("ASCI",DN)) Q:DN=""  D
 . S SN=$O(^BSTS(9002318.4,"C",36,DN,""))
 . S II=II+1,@DATA@(II)=DN_U_$G(^BSTS(9002318.4,SN,1))_" ["_DN_"]"_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
PROB(DATA) ; EP - Problems
 NEW DN
 K @DATA
 S II=0,DN=0
 S @DATA@(II)="T00010IEN^T00030"_$C(30)
 F  S DN=$O(^AUPNPROB("B",DN)) Q:DN=""  D
 . I $G(^ICD9(DN,0))="" Q
 . S II=II+1,@DATA@(II)=DN_U_$$VST^ICDCODE(DN,"",80)_" ["_$$CODEC^ICDCODE(DN,80)_"]"_$C(30) Q
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
PROBS(DATA) ;EP - Snomed IDs for Problems
 NEW DN,SN
 K @DATA
 S II=0,DN=0
 S @DATA@(II)="T00100IEN^T00245"_$C(30)
 F  S DN=$O(^AUPNPROB("ASCT",DN)) Q:DN=""  D
 . S SN=$O(^BSTS(9002318.4,"C",36,DN,""))
 . S II=II+1,@DATA@(II)=DN_U_$G(^BSTS(9002318.4,SN,1))_" ["_DN_"]"_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
EMP(DATA) ;EP - Employers
 NEW EN
 K @DATA
 S II=0,EN=""
 S @DATA@(II)="T00010IEN^T00060"_$C(30)
 F  S EN=$O(^AUPNPAT("AF",EN)) Q:EN=""  D
 . I $G(^AUTNEMPL(EN,0))="" Q
 . S II=II+1,@DATA@(II)=EN_U_$P(^AUTNEMPL(EN,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
DIV(DATA) ;EP - Divisions
 NEW NM
 K @DATA
 S II=0,NM=0
 S @DATA@(II)="T00010IEN^T00060"_$C(30)
 F  S NM=$O(^XTMP("BQISYDIV",NM)) Q:NM=""  D
 . S IEN=^XTMP("BQISYDIV",NM)
 . I $G(^DIC(4,IEN,0))="" Q
 . S II=II+1,@DATA@(II)=IEN_U_NM_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
COD(DATA) ; EP - Cause of Death
 NEW DN
 K @DATA
 S II=0
 S @DATA@(II)="T00010IEN^T00010^T00030DESCRIPTION"_$C(30)
 S DN=""
 F  S DN=$O(^XTMP("BQICOD",DN)) Q:DN=""  D
 . I $G(^ICD9(DN,0))="" Q
 . I $$VERSION^XPDUTL("AICD")>3.51 S II=II+1,@DATA@(II)=DN_U_$$VST^ICDCODE(DN,"",80)_" ["_$$CODEC^ICDCODE(DN,80)_"]"_$C(30) Q
 . S II=II+1,@DATA@(II)=DN_U_$P(^ICD9(DN,0),U,3)_" ["_$P(^ICD9(DN,0),U,1)_"]"_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
LANG(DATA) ;EP - Preferred Language
 NEW DN
 K @DATA
 S II=0
 S @DATA@(II)="T00010IEN^T00030"_$C(30)
 S DN=""
 F  S DN=$O(^XTMP("BQILANG",DN)) Q:DN=""  D
 . I $G(^AUTTLANG(DN,0))="" Q
 . S II=II+1,@DATA@(II)=DN_U_$P(^AUTTLANG(DN,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
DET(DATA) ;EP - Definition Detail list
 NEW DN
 K @DATA
 S II=0
 S @DATA@(II)="T00010CODE^T00030"_$C(30)
 S DN=0
 F  S DN=$O(^BQI(90506.5,DN)) Q:'DN  D
 . I $P(^BQI(90506.5,DN,0),U,15)'=1 Q
 . S II=II+1,@DATA@(II)=$P(^BQI(90506.5,DN,0),U,2)_U_$P(^BQI(90506.5,DN,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q