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

BLRTNORD.m

Go to the documentation of this file.
BLRTNORD ;DATA RETRIVAL FROM LAB ORDER FOR TRANSACTION LOG ENTRY  [ 09/06/2002  7:09 AM ]
 ;;5.2;LR;**1013**;JUL 30, 2002
 ;
 ;
 Q  ;EP PARAM CALL
 ;ORDER is the order number from ORDER/TEST STATUS in lab
 ;or 'C' cross reference from file 69
ORDER(ORDER) ;EP ORDER NUMBER PASSED
 ;returns ORDER IEN IN DT;SEQ^DT;SEQ^ if successful, -1 if not
 ;
 N X,Y
 S BLR="",X=0,U="^" F  S X=$O(^LRO(69,"C",ORDER,X)) Q:+X=0  D
 . S Y=0 F  S Y=$O(^LRO(69,"C",ORDER,X,Y)) Q:+Y=0  S BLR=BLR_X_";"_Y_"^"
 Q:'$L(BLR) -1
 Q BLR
 ;
OLOCIEN(ORDDT,ORDIEN) ;EP ORDERING LOCATION IEN
 ;returns HOSP LOCATION IEN^NAME^ABBR^INST44^INST69  or -1
 N IEN,NAME,ABBR,INST44,INST69,CLSTOP,CLSTOPN
 S IEN=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,9) Q:'IEN -1
 S ABBR=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,7)
 S INST69=$P($G(^LRO(69,ORDDT,1,ORDIEN,1)),U,8)
 S NAME=$P($G(^SC(IEN,0)),U,1)
 S INST44=$P($G(^SC(IEN,0)),U,4)
 S CLSTOP=$P($G(^SC(IEN,0)),U,7)
 S:+CLSTOP CLSTOPN=$P($G(^DIC(40.7,CLSTOP,0)),U,1)
 Q IEN_U_NAME_U_ABBR_U_INST44_U_INST69_U_CLSTOP_U_CLSTOPN
 ;
OENPRIEN(ORDDT,ORDIEN) ;EP ENCOUNTER PROVIDER IEN
 ;returns PROVIDER(VA200)IEN^NAME^  or -1
 N IEN,NAME
 S IEN=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,2) Q:'IEN -1
 S NAME=$P($G(^VA(200,IEN,0)),U,1)
 Q IEN_U_NAME
 ;
OPROVIEN(ORDDT,ORDIEN) ;EP ORDERING PROVIDER IEN
 ;returns PROVIDER(VA200)IEN^NAME^  or -1
 N IEN,NAME
 S IEN=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,6) Q:'IEN -1
 S NAME=$P($G(^VA(200,IEN,0)),U,1)
 Q IEN_U_NAME
 ;
OCOLLIEN(ORDDT,ORDIEN) ;EP ORDERING COLLECTION SAMPLE IEN
 ;returns COLLECTION IEN^NAME^  or -1
 N IEN,NAME
 S IEN=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,3) Q:'IEN -1
 S NAME=$P($G(^LAB(62,IEN,0)),U,1)
 Q IEN_U_NAME
 ;
OSITEIEN(ORDDT,ORDIEN) ;EP ORDERING SITE/SPECIMEN IEN
 ;returns SITE/SPECIMEN IEN^NAME^  MULTIPLE or -1
 N IEN,NAME,X,Y
 S IEN="",X=0 F  S X=$O(^LRO(69,ORDDT,1,ORDIEN,4,X)) Q:+X=0  D
 . S Y=$P($G(^LRO(69,ORDDT,1,ORDIEN,4,X,0)),U,1)
 . S IEN=IEN_Y_";"_$P($G(^LAB(61,Y,0)),U,1)_"^"
 Q:'$L(IEN) -1
 Q IEN
 ;
OTEST(ORDDT,ORDIEN) ;EP ORDERING TEST IEN
 ;returns TEST(60)IEN;NAME;URG^  MULTIPLE or -1
 N IEN,NAME,X,Y,URG
 S IEN="",X=0 F  S X=$O(^LRO(69,ORDDT,1,ORDIEN,2,X)) Q:+X=0  D
 . S Y=$P($G(^LRO(69,ORDDT,1,ORDIEN,2,X,0)),U,1)
 . S URG=$P($G(^LRO(69,ORDDT,1,ORDIEN,2,X,0)),U,2)
 . S IEN=IEN_Y_";"_$P($G(^LAB(60,Y,0)),U,1)_";"_URG_"^"
 Q:'$L(IEN) -1
 Q IEN
 ;
OTESTIEN(ORDDT,ORD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y0,0)),U,1)_";"_X1_";"_URG_"^"
 S BLRT(Y0)=""
 Q 1
 ;
ODATE(ORDDT,ORDIEN) ;EP ORDERING DATE/TIME
 ;returns ORDER DATE/TIME^COLL DATE^ACC DATE^RESULTED DATE^EST COLL DATE  or -1
 N ODATE,CDATE,ADATE,RDATE,ECDATE
 S ODATE=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,5) Q:'ODATE -1
 S CDATE=$P($G(^LRO(69,ORDDT,1,ORDIEN,1)),U,1)
 S ADATE=$P($G(^LRO(69,ORDDT,1,ORDIEN,3)),U,1)
 S RDATE=$P($G(^LRO(69,ORDDT,1,ORDIEN,3)),U,2)
 S ECDATE=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,8)
 Q ODATE_U_CDATE_U_ADATE_U_RDATE_U_ECDATE
 ;
LRDFN(ORDDT,ORDIEN) ;EP LRDFN
 ;returns LRDFN^LRFILE^POINTER IEN^NAME
 N LRDFN,LRFILE,DFN,NAME
 S LRDFN=$P($G(^LRO(69,ORDDT,1,ORDIEN,0)),U,1) Q:'LRDFN -1
 S LRFILE=$P($G(^LR(LRDFN,0)),U,2)
 S DFN=$P($G(^LR(LRDFN,0)),U,3)
 S:LRFILE=2 NAME=$P($G(^DPT(DFN,0)),U,1)
 S:LRFILE=62.3 NAME=$P($G(^LAB(62.3,DFN,0)),U,1)
 S:LRFILE=67 NAME=$P($G(^LRT(67,DFN,0)),U,1)
 S:LRFILE=67.1 NAME=$P($G(^LRT(67.1,DFN,0)),U,1)
 S:LRFILE=67.2 NAME=$P($G(^LRT(67.2,DFN,0)),U,1)
 S:LRFILE=67.3 NAME=$P($G(^LRT(67.3,DFN,0)),U,1)
 Q LRDFN_U_LRFILE_U_DFN_U_NAME
 ;
TEST ;TEST FUNCTIONS
 S ORDER=5840
 S BLR=$$ORDER(ORDER) W !,BLR
 S BLR=$P(BLR,U,1)
 S ORDDT=$P(BLR,";",1),ORDIEN=$P(BLR,";",2)
 W !,"LRDFN = ",$$LRDFN(ORDDT,ORDIEN),!
 W "LOC   = ",$$OLOCIEN(ORDDT,ORDIEN),!
 W "PROV  = ",$$OPROVIEN(ORDDT,ORDIEN),!
 W "ENPROV= ",$$OENPRIEN(ORDDT,ORDIEN),!
 W "ODATE = ",$$ODATE(ORDDT,ORDIEN),!
 W "COLL = ",$$OCOLLIEN(ORDDT,ORDIEN),!
 W "SITE = ",$$OSITEIEN(ORDDT,ORDIEN),!
 W "TEST = ",$$OTESTIEN(ORDDT,ORDIEN),!
 Q