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