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

BLRTNDEL.m

Go to the documentation of this file.
BLRTNDEL ; IHS/HQT/MJL - CREATE/EDIT TRANSACTIONS (CONTINUED) DELETION ;MAY 06, 2009 9:58 AM
 ;;5.2T1;IHS LABORATORY;**1026**;NOV 01, 1997
 ;
 ; Code removed from BLRTN routine due to BLRTN becoming too large
DELETE ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER DELETE^BLRTN")
 I BLROPT="DELORD" D  Q
 . S BLRODTM=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRODTM"))
 . I BLRPARAM["TESTS" D  Q
 .. S BLRCRSBS="""AOT"",BLRODTM,BLRSEQ,BLRTEST1"
 .. S BLRDIR=1
 .. S BLROKCK="CKORD"
 .. S BLRBADCK=""
 .. S BLRTEST=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRTEST"))
 .. S BLRSEQ=$G(^("LRSN")) D SET1^BLRTN
 . M BLRT=^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"T")
 . ;
 . S BLRII=""
 . F  S BLRII=$O(BLRT(BLRII)) Q:'BLRII  D
 .. S BLRLRSN=BLRT(BLRII)
 .. S BLRTEST=$P(BLRLRSN,U,3)
 .. S BLRLRSN=+BLRLRSN
 .. S BLRTN=0
 .. F  S BLRTN=$O(^BLRTXLOG("AOT",BLRODTM,BLRLRSN,BLRTEST,BLRTN)) Q:'BLRTN  S BLRTN(BLRTN)=""
 . ;
 . S BLRLRSN=0
 . F  S BLRLRSN=$O(^BLRTXLOG("AOT",BLRODTM,BLRLRSN)) Q:'BLRLRSN  D
 .. S BLRTEST=0
 .. F  S BLRTEST=$O(^BLRTXLOG("AOT",BLRODTM,BLRLRSN,BLRTEST)) Q:'BLRTEST  D
 ... S BLRTN=0
 ... F  S BLRTN=$O(^BLRTXLOG("AOT",BLRODTM,BLRLRSN,BLRTEST,BLRTN)) Q:'BLRTN  S BLRTNS(BLRTN)=""
 . ;
 . S BLRTN=0
 . F  S BLRTN=$O(BLRTNS(BLRTN)) Q:'BLRTN  D
 .. S BLRPAR=+$P($G(^BLRTXLOG(BLRTN,1)),U)
 .. I $D(BLRTN(BLRTN))!$D(BLRTN(BLRPAR)) D
 ... S BLRTN(BLRTN)=""
 ... S BLR("SEQUENCE NUMBER")=BLRTN
 ... S BLRENT=BLRTN
 ... S BLRIEN=BLRTN_","
 ... D ^BLRNFLTL
 . K BLRT,BLRTN,BLRTNS
 ;
 S BLRACCN=""
 I BLRIDS,BLRIDS["," S BLRAA=$P(BLRIDS,","),BLRAD=$P(BLRIDS,",",2),BLRAN=$P(BLRIDS,",",3),BLRACCN=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRACCN"))
 S:BLRACCN="" BLRACCN=BLRIDS
 ;
 I BLROPT="DELACC" D DELACC  Q
 ;
 I BLROPT="REMACC" D  Q
 . S BLRTEST=0
 . F  S BLRTEST=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) Q:'BLRTEST  D
 .. S BLRENT=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST," "),-1)
 .. I BLRENT S BLR("SEQUENCE NUMBER")=BLRENT,BLRIEN=BLRENT_"," D ^BLRNFLTL
 Q
 ;
DELACC ; EP
 K BLRTN,BLRTNS
 S BLRTEST=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRTEST"))
 M ^BLRTEST=^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRTEST")
 ;
 ;GET TEST IEN BEING DELETED
 S BLRTN=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST," "),-1) I 'BLRTN K BLRTN Q
 S BLRTN(BLRTN)=""  ; TEST BEING DELETED
 S DELSEQ=BLRTN     ; SAVE SEQ BEING DELETED
 S COMP=1           ; FIX PARENT NOT UPDATING WHEN DELETING A TEST ;ASSUME ITS COMPLETE
 S ALLDEL=1         ; IF ALL TESTS ARE DELETED THE DELETE PARENT TO ASSUME ALL ARE DELETED. IF ANY ARE NOT DELETED S ALLDEL=0
 K PARENT
 ;
 ;GET LIST OF ALL TESTS BELONGING TO THIS ACCESSION
 S (COUNT,BLRTEST)=0
 F  S BLRTEST=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) Q:'BLRTEST  D
 . S BLRTN=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST," "),-1)
 . I BLRTN S BLRTNS(BLRTN)="",COUNT=COUNT+1  ;IF COUNT = 1 THEN WE HAVE A LONE PARENT SINGLE TEST
 ;
 S (COUNT,BLRTEST)=0
 F  S BLRTEST=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) Q:'BLRTEST  D
 . S BLRTN=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST," "),-1) Q:BLRTN=""
 . S BLRTEMP(BLRTN)=$P($G(^BLRTXLOG(BLRTN,1)),U)
 ;
 S P=""
 F  S P=$O(BLRTEMP(P)) Q:P=""  D
 . I $G(BLRTEMP(P)) S BLRTEMP(BLRTEMP(P),P)="" K BLRTEMP(P)
 ;
 ; IF SEQ BEING DELETED IS THE PARENT AND THERE ARE NO CHILDREN DELETE IT
 I $D(BLRTEMP(DELSEQ))=1 D DELPAR(DELSEQ) Q
 ;
 S PARENT=$O(BLRTNS(""))  ;PARENT ALWAYS FIRST IN THIS ARRAY
 ;
 ;SKIP THE PARENT WE'LL DEAL WITH IT LATER
 S BLRTN=0 S BLRTN=$O(BLRTNS(BLRTN)) F  S BLRTN=$O(BLRTNS(BLRTN)) Q:'BLRTN  S BLRPAR=+$P($G(^BLRTXLOG(BLRTN,1)),U) I $D(BLRTN(BLRTN))!$D(BLRTN(BLRPAR)) S BLRTN(BLRTN)="",BLR("SEQUENCE NUMBER")=BLRTN,BLRENT=BLRTN,BLRIEN=BLRTN_"," D ^BLRNFLTL
 S BLRTEST=0 F  S BLRTEST=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) Q:'BLRTEST  S BLRTN=$O(^BLRTXLOG("AAT",BLRACCN,BLRTEST," "),-1) D UPDTPAR(BLRTEST,BLRTN) S:BLRTN BLRTNS(BLRTN)=""   ;IHS/ITSC/TPF 03/15/02
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("BEFORE CHECK COMP")
 ;
 I COMP D
 . D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER COMP")
 . I COUNT=1 S $P(^BLRTXLOG(PARENT,1),U,2)="D",BLR("STATUS FLAG")="D"
 . E  S $P(^BLRTXLOG(PARENT,1),U,2)="R",BLR("STATUS FLAG")="R"
 . S BLR("SEQUENCE NUMBER")=PARENT
 . S BLRENT=PARENT
 . S BLRIEN=PARENT_","
 . D ^BLRNFLTL  ;IHS/ITSC/TPF 03/15/02 UPDATE PCC WITH PARENT STATUS
 ;
 K BLRTN,BLRTNS
 ;
 ;NEW TO DELETE PARENT IF ALL TESTS ARE DELETED
 I ALLDEL D
 . D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER ALLDEL")
 . Q:COUNT=1
 . S $P(^BLRTXLOG(PARENT,1),U,2)="D",BLR("STATUS FLAG")="D"
 . S BLR("SEQUENCE NUMBER")=PARENT
 . S BLRENT=PARENT
 . S BLRIEN=PARENT_","
 . D ^BLRNFLTL
 Q
 ;
 ; AFTER DELETING A TEST UPDATE PARENT FOR RESULT STATUS IF ALL REQUIRED
 ; TESTS ARE RESULTED
UPDTPAR(TST,SEQ) ; EP
 ;IS STATUS FLAG "A" AND ITS REQUIRED THEN PARENT STAYS ACCESSIONED
 Q:SEQ=PARENT
 ;
 I $P($G(^BLRTXLOG(SEQ,1)),U,2)'="D" S ALLDEL=0  ;IF ANY ARE NOT DELETED
 ;
 ; DON'T DELETE PARENT
 ; TEST ACCESSIONED AND REQUIRED TEST COMPLETE IS FALSE
 I ($P($G(^BLRTXLOG(SEQ,1)),U,2)="A"),$P($G(^LAB(60,TST,0)),U,17) S COMP=0
 Q
 ; 
 ; DELETE THE LONE PARENT
DELPAR(P) ; EP
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER DELPAR^BLRTN")
 ;
 S $P(^BLRTXLOG(P,1),U,2)="D",BLR("STATUS FLAG")="D"
 S BLR("SEQUENCE NUMBER")=P
 S BLRENT=P
 S BLRIEN=P_","
 D ^BLRNFLTL
 Q