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

LR7OGMU.m

Go to the documentation of this file.
LR7OGMU ;VA/SLC/STAFF- Interim report rpc memo utility ; 17-Oct-2014 09:22 ; MKK
 ;;5.2;LR;**187,312,1022,395,1031,1034**;NOV 01, 1997;Build 146
 ;
 ; IHS/MSC/MKK - LR*5.2*1034 - Naked References removed
 ;
NEWOLD(Y,DFN) ; from ORWLRR
 N LRDFN
 D DEMO^LR7OGU(DFN,.LRDFN)
 S Y=$$NEWEST(LRDFN)_U_$$OLDEST(LRDFN)
 Q
 ;
NEWEST(LRDFN) ;
 N IDT,FIRSTCH,FIRSTMI,LRCAN,ZERO,UID,AREA,ACDT,NUM,TESTNUM,CHKTYP,ANODE,ACOMP,GOTNP
 S (FIRSTCH,FIRSTMI)=""
 S IDT=0
 ; F  S IDT=$O(^LR(LRDFN,"CH",IDT)) Q:IDT<1  S ZERO=^(IDT,0),UID=$P($G(^("ORU")),"^") D  Q:FIRSTCH
 F  S IDT=$O(^LR(LRDFN,"CH",IDT)) Q:IDT<1  S ZERO=$G(^(IDT,0)),UID=$P($G(^("ORU")),"^") D  Q:FIRSTCH    ; IHS/MSC/MKK - LR*5.2*1034
 . I $P(ZERO,U,3) S FIRSTCH=9999999-IDT Q
 . I UID'="" S UID=$$CHECKUID^LRWU4(UID) Q:'UID
 . I 'UID,'$P(ZERO,"^",3) Q
 . S GOTNP=0 D GETNP^LR7OGMC Q:GOTNP
 . S AREA=$P(UID,"^",2),ACDT=$P(UID,"^",3),NUM=$P(UID,"^",4)
 . I '$D(^LRO(68,+AREA,1,+ACDT,1,+NUM)) Q
 . S TESTNUM=0,CHKTYP=0,ACOMP=0
 . ; F  S TESTNUM=$O(^LRO(68,+AREA,1,+ACDT,1,+NUM,4,TESTNUM)) Q:'TESTNUM  S ANODE=^(TESTNUM,0) D
 . F  S TESTNUM=$O(^LRO(68,+AREA,1,+ACDT,1,+NUM,4,TESTNUM)) Q:'TESTNUM  S ANODE=$G(^(TESTNUM,0)) D      ; IHS/MSC/MKK - LR*5.2*1034
 .. Q:'$D(^LAB(60,TESTNUM,0))  I ("BO"[$P($G(^(0)),U,3)) S CHKTYP=1
 .. I '$P(ANODE,"^",5) S ACOMP=1
 . Q:'CHKTYP
 . Q:'ACOMP
 . S FIRSTCH=9999999-IDT
 . Q
 S IDT=$O(^LR(LRDFN,"MI",0)) I IDT>0  S FIRSTMI=9999999-IDT
 I FIRSTCH>FIRSTMI Q FIRSTCH
 I FIRSTCH'>FIRSTMI Q FIRSTMI
 Q ""
 ;
OLDEST(LRDFN) ;
 N IDT,FIRSTCH,FIRSTMI,LRCAN,ZERO,UID,AREA,ACDT,NUM,TESTNUM,CHKTYP,ANODE,ACOMP,GOTNP
 S (FIRSTCH,FIRSTMI)=""
 S IDT=""
 ; F  S IDT=$O(^LR(LRDFN,"CH",IDT),-1) Q:IDT<1  S ZERO=^(IDT,0),UID=$P($G(^("ORU")),"^") D  Q:FIRSTCH
 F  S IDT=$O(^LR(LRDFN,"CH",IDT),-1) Q:IDT<1  S ZERO=$G(^(IDT,0)),UID=$P($G(^("ORU")),"^") D  Q:FIRSTCH  ; IHS/MSC/MKK - LR*5.2*1034
 . I $P(ZERO,U,3) S FIRSTCH=9999999-IDT Q
 . I UID'="" S UID=$$CHECKUID^LRWU4(UID)
 . I 'UID,'$P(ZERO,"^",3) Q
 . S GOTNP=0 D GETNP^LR7OGMC Q:GOTNP
 . S AREA=$P(UID,"^",2),ACDT=$P(UID,"^",3),NUM=$P(UID,"^",4)
 . I '$D(^LRO(68,+AREA,1,+ACDT,1,+NUM)) Q
 . S TESTNUM=0,CHKTYP=0,ACOMP=0
 . ; F  S TESTNUM=$O(^LRO(68,+AREA,1,+ACDT,1,+NUM,4,TESTNUM)) Q:'TESTNUM  S ANODE=^(TESTNUM,0) D
 . F  S TESTNUM=$O(^LRO(68,+AREA,1,+ACDT,1,+NUM,4,TESTNUM)) Q:'TESTNUM  S ANODE=$G(^(TESTNUM,0)) D      ; IHS/MSC/MKK - LR*5.2*1034
 .. Q:'$D(^LAB(60,TESTNUM,0))  I ("BO"[$P($G(^(0)),U,3)) S CHKTYP=1
 .. I '$P(ANODE,"^",5) S ACOMP=1
 . Q:'CHKTYP
 . Q:'ACOMP
 . S FIRSTCH=9999999-IDT
 . Q
 S IDT=$O(^LR(LRDFN,"MI",""),-1) I IDT>0  S FIRSTMI=9999999-IDT
 I FIRSTMI="" Q FIRSTCH
 I FIRSTCH="" Q FIRSTMI
 I FIRSTCH<FIRSTMI Q FIRSTCH
 I FIRSTCH'<FIRSTMI Q FIRSTMI
 Q ""