AHHOBJ1 ;NCH/RLP   TIU Object LAB Extract - Modified AHHOBJ1  20-Sep-01
        ;;1.0;NCH Object
        ;
        ;++ER-NCHGO MODIFIED 12/4/01
        ; --- for testing purposes ---
TWBC    W $$LRTST(55842,"WBC","^TMP(""OBJECT"",$J)") Q
THCT    W $$LRTST(417,"HCT","^TMP(""OBJECT"",$J)") Q
THGB    W $$LRTST(55842,"HGB","^TMP(""OBJECT"",$J)") Q
TPLT    W $$LRTST(55842,"PLT","^TMP(""OBJECT"",$J)") Q
TPSA    W $$LRTST(55842,"PSA","^TMP(""OBJECT"",$J)") Q
TA1C    W $$LRTST(55842,"A1C","^TMP(""OBJECT"",$J)") Q
TCOL    W $$LRTST(55842,"COL","^TMP(""OBJECT"",$J)") Q
        Q
        ;
        ;
LRTST(DFN,ObjTest,TARGET)       ;--- Object calls line tag with DFN and TEST ---
        ;
        ; --- Add object test name with internal lab test number ---
TESTS   I ObjTest="WBC" S ObjTest=384,TestName="WBC............: "
        I ObjTest="HGB" S ObjTest=386,TestName="HGB............: "
        I ObjTest="HCT" S ObjTest=387,TestName="HCT............: "
        I ObjTest="PLT" S ObjTest=392,TestName="PLT............: "
        I ObjTest="PSA" S ObjTest=556177,TestName="PSA............: "
        I ObjTest="A1C" S ObjTest=556207,TestName="HGB A1C....: "
        I ObjTest="COL" S ObjTest=556203,TestName="COLO-REC...........: "
        I ObjTest="ALT" S ObjTest=20,TestName="ALT............: "
        I ObjTest="AST" S ObjTest=19,TestName="AST............: "
        I ObjTest="ALKP" S ObjTest=17,TestName="ALKP...........: "
        I ObjTest="INR" S ObjTest=556294,TestName="INR............: "
        I ObjTest="CHOLEST" S ObjTest=12,TestName="Cholesterol....: "
        I ObjTest="LDL CHOLESTEROL" S ObjTest=291,TestName="LDL Cholesterol: "
        I ObjTest="POTASSIUM" S ObjTest=6,TestName="Potassium......: "
        I ObjTest="CREATININE" S ObjTest=4,TestName="Creatinine.....: "
        I ObjTest="GLUCOSE" S ObjTest=2,TestName="Glucose........: "
        I ObjTest="ALBUMIN" S ObjTest=14,TestName="Albumin.......: "
        I ObjTest="PRE-ALBUMIN" S ObjTest=556376,TestName="Pre-Albumin....: "
        I ObjTest="ALBUMIN SERUM" S ObjTest=556677,TestName="Albumin Serum....:
"
        I ObjTest="TSH" S ObjTest=741,TestName="TSH............: "
        I ObjTest="TRIGLYCERIDES" S ObjTest=47,TestName="Triglycerides..: "
        I ObjTest="T. BIL" S ObjTest=15,TestName="T. Bil.........: "
        I ObjTest="HDL CHOLESTEROL" S ObjTest=80,TestName="HDL Cholesterol: "
        I ObjTest="SODIUM" S ObjTest=5,TestName="Sodium.........: "
        I ObjTest="BUN" S ObjTest=3,TestName="BUN............: "
        I ObjTest="LYMPH %" S ObjTest=396TestName="Lymph %........: "
        ;
VARS    N ChkTest,HaveNode,LRDFN,RefHigh,RefLow,RefRngFl,RevDate
        N SEX,TestDate,TestFlag,TestNode,TestRslt,UNITS  ;++ER
        ;
        K @TARGET
        S (ChkTest,HaveNode,RefRngFl,RevDate)=0
        S LRDFN=+$G(^DPT(DFN,"LR"))
        S SEX=$P(^DPT(DFN,0),"^",2)
        ;
        I LRDFN D  ;
L1      . F  S RevDate=$O(^LR(LRDFN,"CH",RevDate)) Q:'RevDate  D  Q:HaveNode
        . . I $D(^LR(LRDFN,"CH",RevDate,ObjTest)) D  ;
        . . . S TestNode=^LR(LRDFN,"CH",RevDate,ObjTest)
        . . . S HaveNode=1
        ;
HIT     I HaveNode D  ;
        . S TestDate=9999999-RevDate ;++ER
        . S Y=TestDate X ^DD("DD") S Y=$P(Y,":",1,2) S TestDate=Y ;++ER
        . S TestRslt=$P(TestNode,"^",1)
        . S TestFlag=$P(TestNode,"^",2)
        . S RefLow=$P($P(TestNode,"^",5),"!",2)
        . I RefLow["SEX" S @("RefLow="_RefLow)
        . I RefLow]"" S RefRngFl=1
        . S RefHigh=$P($P(TestNode,"^",5),"!",3)
        . I RefHigh["SEX" S @("RefHigh="_RefHigh)
        . I RefHigh]"" S RefRngFl=1
        . S UNITS=$P($P(TestNode,"^",5),"!",7) ;++ER
        . I UNITS["SEX" S @("UNITS="_UNITS) ;++ER
        . S @TARGET@(1,0)=TestName_"Date of Test: "_TestDate_"    Result: "_Test
Rslt_" "_TestFlag_" "_UNITS ;++ER
        . I RefRngFl S @TARGET@(2,0)="                 Reference Range on Date o
f Test: "_RefLow_" - "_RefHigh
        E  S @TARGET@(1,0)=TestName_"No Lab Data for Test"
        Q "~@"_$NA(@TARGET)