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

LR7OF1.m

Go to the documentation of this file.
LR7OF1 ;DALOI/STAFF - Setup new order from OE/RR ;Jan 27, 2008
 ;;5.2;LAB SERVICE;**121,187,223,256,299,291,350**;Sep 27, 1994;Build 230
 ;
EN ; Setup NEW orders from OE/RR messages
 ; [^TMP("OR",$J,"LRES") DOCUMENTATION]
 ; 'Combining of Orders' functionality depends on this TMP global
 ; Set and Killed when BHS and BTS batch message headers are received
 ; Global contains a list of lab orders for a session
 ; Lab adds elements to the global array as orders are processed:
 ;  ^TMP("OR",$J,"LRES",LRDFN,LRSDT,LRXZ,^TMP("OR",$J,"LRES","CTR"))=LRORD_"^"_LRODT_"^"_LRSN
 ;  ^TMP("OR",$J,"LRES","CTR")=Count
 ;
 N ZTSK,LRORDR,X,UNEEK,LRNT ;UNEEK forces a unique entry (Micro tests), set when ^..."LROT" built
 D DT
 S LRORDR=LRXZ
 S:'$D(^TMP("OR",$J,"LRES","CTR")) ^("CTR")=0
 F LRSAMP=-1:0 S LRSAMP=$O(^TMP("OR",$J,"LROT",LRSDT,LRXZ,LRSAMP)) Q:LRSAMP=""  D
 . F LRSPEC=-1:0 S LRSPEC=$O(^TMP("OR",$J,"LROT",LRSDT,LRXZ,LRSAMP,LRSPEC)) Q:LRSPEC=""  S X=^(LRSPEC,0) D
 . . S ORIFN=+X,UNEEK=$P(X,"^",2)
 . . D ZX
 Q
 ;
 ;
ZX ;
 N COMBINE,X,NEWORD
 I '$D(^LRO(69,LRODT,0)) S ^(0)=$P(^LRO(69,0),U,1,2)_"^"_LRODT_"^"_(1+$P(^(0),U,4)),^LRO(69,LRODT,0)=LRODT,^LRO(69,"B",LRODT,LRODT)=""
 S COMBINE=""
 ;
 I 'UNEEK D
 . S COMBINE=$$ORES^LR7OF5(LRDFN,LRSDT,LRXZ,+LRSAMP,LRPRAC,LROLLOC,LRSPEC,LRDUZ)
 . I COMBINE="" S COMBINE=$$FIND^LR7OF5(LRDFN,LRODT,LRSDT,LRXZ,+LRSAMP,LRPRAC,LROLLOC,LRSPEC,LRDUZ)
 ;
 I COMBINE="" S (NEWORD,LRQUIET)=1 D ORDER^LROW2 K ZTSK,ZTQUEUED,ZTREQ G LOCK
 ;
 I $E(COMBINE,1,2)="S." S LRSN=$P(COMBINE,".",2),LRORD=$P(COMBINE,".",3) G ADD ;Combine on specimen
 I $E(COMBINE,1,2)="O."!($E(COMBINE,1,2)="C.") S LRORD=$S($E(COMBINE,1,2)="O.":$P(COMBINE,".",2),1:$P(COMBINE,".",3)) ;Combine on order #
 ;
LOCK ;
 L +^LRO(69,LRODT,1):360
 I '$T G LOCK
 S LRSN=1+$O(^LRO(69,LRODT,1,999999999),-1),LRSUM=1+$S($D(^LRO(69,LRODT,1,0)):$P(^(0),U,4),1:0)
 ;
ZSN ;
 I $D(^LRO(69,LRODT,1,LRSN,0)) S LRSN=LRSN+1 G ZSN
 S ^LRO(69,LRODT,1,LRSN,0)=LRDFN_"^"_LRDUZ_"^"_+LRSAMP_"^"_LRORDR_"^"_LRNT_"^"_LRPRAC_"^"_LRLLOC_"^"_LRSDT_"^"_LROLLOC_"^^"_ORIFN
 S ^LRO(69,LRODT,1,0)="^69.01PA^"_LRSN_"^"_LRSUM
 L -^LRO(69,LRODT,1)
 ;
 S ^LRO(69,LRODT,1,"AA",LRDFN,LRSN)=""
 S ^TMP("OR",$J,"LROT",LRSDT,LRXZ,LRSAMP,LRSPEC,"SN")=LRSN
 S ^LRO(69,"D",LRDFN,LRODT,LRSN)=""
 ;
 I LRLLOC'="" S ^LRO(69,LRODT,1,"AC",LRLLOC,LRSN)=""
 I LRSPEC'="" S ^LRO(69,LRODT,1,LRSN,4,0)="^69.02PA^1^1",^(1,0)=LRSPEC
 ;
 S ^LRO(69,LRODT,1,LRSN,.1)=LRORD,^LRO(69,"C",+LRORD,LRODT,LRSN)=""
 ;I $G(NEWORD) L -^LRO(69,$E(DT,1,3)_"0000",2)
 ;
ADD ;
 N I,J,LRJ,LRSXN,LRORIFN,NODE,STATUS
 S ^TMP("OR",$J,"LRES","CTR")=^TMP("OR",$J,"LRES","CTR")+1,^TMP("OR",$J,"LRES",LRDFN,LRSDT,LRXZ,^TMP("OR",$J,"LRES","CTR"))=LRORD_"^"_LRODT_"^"_LRSN
 S LRORIFN=+$G(^TMP("OR",$J,"LROT",LRSDT,LRXZ,LRSAMP,LRSPEC,0))
 ;
 S J=0
 F LRJ=1:1 S J=$O(^TMP("OR",$J,"LROT",LRSDT,LRXZ,LRSAMP,LRSPEC,J)) Q:J<1  S NODE=^(J),STATUS=$G(^(J,1)) D ZSN1(NODE,STATUS)
 ;
 S (LRSXN,I)=0
 F  S I=$O(^LRO(69,LRODT,1,LRSN,2,I)) Q:I<1  S LRSXN=LRSXN+1
 S:LRSXN ^LRO(69,LRODT,1,LRSN,2,0)="^69.03PA^"_LRSXN_"^"_LRSXN
 ;
 I $E(COMBINE,1,2)="C." D
 . S (LRSXN,I)=0 F  S I=$O(^LRO(69,LRODT,1,+$P(COMBINE,".",2),2,I)) Q:I<1  S LRSXN=LRSXN+1
 . S:LRSXN ^LRO(69,LRODT,1,+$P(COMBINE,".",2),2,0)="^69.03PA^"_LRSXN_"^"_LRSXN
 Q
 ;
 ;
ZSN1(NODE,STATUS)    ;Add tests
 N CNT,XI,X,I,C,TCNT
 S CNT=+$O(^LRO(69,LRODT,1,LRSN,2,99999),-1)
 S LRTSTS=+NODE,LRQUANT=$P(NODE,"^",2)
 ;
 I $D(^LRO(69,LRODT,1,LRSN,2,"B",LRTSTS)) S REJECT(LRTSTS)="" Q
 S ^LRO(69,LRODT,1,LRSN,2,CNT+LRJ,0)=LRTSTS_"^"_$S($L(STATUS):STATUS,1:LROUTINE)_"^^^^^"_LRORIFN
 ;
 D SDGX69^LRBEBA2(J,(CNT+LRJ)_","_LRSN_","_LRODT_",")
 ;
 ; Add "~" to comment lines, when needed, to insure that "~" is stored with comments
 ;  to distinguish order and result comments when moved to file #63.
 I $O(^TMP("OR",$J,"COM",LRSDT,LRXZ,LRSAMP,LRSPEC,J,0)) D
 . S X=^TMP("OR",$J,"COM",LRSDT,LRXZ,LRSAMP,LRSPEC,J)+$S($P($G(^LRO(69,LRODT,1,LRSN,2,CNT+LRJ,1,0)),"^",4):$P(^(0),"^",4),1:0)
 . S ^LRO(69,LRODT,1,LRSN,2,CNT+LRJ,1,0)="^^"_X_"^"_X_"^"_DT
 . S TCNT=+$O(^LRO(69,LRODT,1,LRSN,2,CNT+LRJ,1,99999),-1),(C,I)=0
 . F  S I=$O(^TMP("OR",$J,"COM",LRSDT,LRXZ,LRSAMP,LRSPEC,J,I)) Q:I<1  D
 . . S X=^TMP("OR",$J,"COM",LRSDT,LRXZ,LRSAMP,LRSPEC,J,I)
 . . I $E(X,1)'="~" S X="~"_X
 . . S C=C+1
 . . S ^LRO(69,LRODT,1,LRSN,2,CNT+LRJ,1,C+TCNT,0)=X
 ;
 S ^LRO(69,LRODT,1,LRSN,2,"B",LRTSTS,CNT+LRJ)=""
 S ^LRO(69,"AT",LRDFN,LRTSTS,LRSPEC,LRODT)="",^(-LRODT)=""
 ;
 I $E(COMBINE,1,2)="C." D
 . S X=^LRO(69,LRODT,1,LRSN,2,CNT+LRJ,0),$P(^(0),"^",6)=LRORD
 . S XI=$P($G(^LRO(69,LRODT,1,LRSN,1)),"^",7)
 . S XI=XI_LRORD_"/",$P(^(1),"^",7)=XI
 . N CNT1
 . S CNT1=$O(^LRO(69,LRODT,1,+$P(COMBINE,".",2),2,99999),-1)+1,^(CNT1,0)=X,$P(^(0),"^",14)=LRODT_";"_LRSN_";"_(CNT+LRJ)
 . S ^LRO(69,LRODT,1,$P(COMBINE,".",2),2,"B",LRTSTS,CNT1)=""
 Q
 ;
 ;
DT ;
 S DT=$$DT^XLFDT
 S LRNT=$P($H,",",2),LRNT=LRNT\3600*100+(LRNT\60#60)/10000+DT
 Q