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

BPCLAB.m

Go to the documentation of this file.
  1. BPCLAB ; IHS/OIT/MJL - GUI LAB INTERIM ;
  1. ;;1.5;BPC;;MAY 26, 2005
  1. ;;
  1. Q
  1. INT(Y,DFN,DATE1,DATE2) ; from Remote Procedure file
  1. S XWBWRAP=1,DATE1=DATE1+1 ;FJE FIX FOR GUI 6/6/01
  1. D INTERIM(.Y,DFN,DATE1,DATE2)
  1. Q
  1. ;
  1. INTERIM(ROOT,DFN,SDATE,EDATE) ;
  1. N FORMAT,MICROCHK,TESTS K TESTS
  1. S (FORMAT,MICROCHK)=""
  1. S ROOT=$NA(^TMP("BPC7OGX",$J,"OUTPUT"))
  1. D SELECT(DFN,SDATE,EDATE,.TESTS,FORMAT,MICROCHK) ;
  1. N BPCLAST S BPCLAST=$O(^TMP("BPC7OGX",$J,"OUTPUT",""),-1) S:+BPCLAST ^TMP("BPC7OGX",$J,"OUTPUT",.5)=BPCLAST+1 ;FJE
  1. Q
  1. ;
  1. SELECT(DFN,SDATE,EDATE,TESTS,FORMAT,MICROCHK) ;
  1. ; get patient info, and expand tests
  1. ; route setup chem and/or micro data
  1. ; 9th piece of output indicates format (2: CH of CH/MI exact date/time, 3: MI of CH/MI, else 1 or "")
  1. N AGE,ALL,ASK,AVAIL,CNIDT,DIRECT,DONE,EDT,FOK,IDT,LRDFN,MICROSUB,MNIDT,OUTCNT,PNM,ROUTE,SEX,SDT K MICROSUB
  1. K ^TMP("BPC7OG",$J),^TMP("BPC7OGX",$J,"OUTPUT")
  1. S OUTCNT=1,DONE=0
  1. D DEMO^BPC7OGU(DFN,.LRDFN,.PNM,.AGE,.SEX)
  1. I '$G(LRDFN) Q
  1. S ^TMP("BPC7OG",$J,"G")=DFN_U_PNM_U_LRDFN_U_AGE_U_SEX_"^8"
  1. S ALL=$S($O(TESTS(0)):0,1:1)
  1. I 'ALL D TESTSGET^BPC7OGU(.TESTS,.MICROSUB)
  1. S DIRECT=1
  1. I FORMAT S DIRECT=EDATE,EDATE=2700101
  1. S EDATE=EDATE\1
  1. S (IDT,SDT)=9999999-SDATE,EDT=9999999-EDATE
  1. I FORMAT>1 S FOK=0 D I FOK Q
  1. .I DIRECT=1 D Q
  1. ..I FORMAT=2 D Q
  1. ...D MI^BPC7OGMM(LRDFN,IDT,.MICROSUB,ALL,.OUTCNT,FORMAT,.DONE)
  1. ...S $P(^TMP("BPC7OGX",$J,"OUTPUT",1),U,9)=3
  1. ...S FOK=1
  1. ..I FORMAT=3 D Q
  1. ...S $P(^TMP("BPC7OGX",$J,"OUTPUT",1),U,9)=1
  1. .I DIRECT=-1 D Q
  1. ..I FORMAT=2 D Q
  1. ...S $P(^TMP("BPC7OGX",$J,"OUTPUT",1),U,9)=1
  1. ..I FORMAT=3 D Q
  1. ...D CH^BPC7OGMC(LRDFN,IDT,ALL,.OUTCNT,FORMAT,.DONE)
  1. ...S $P(^TMP("BPC7OGX",$J,"OUTPUT",1),U,9)=2
  1. ...S FOK=1
  1. I ALL S ASK="BOTH"
  1. E I $O(MICROSUB(0)) D
  1. .S ASK="MI" I $O(^TMP("BPC7OG",$J,"TMP",0)) S ASK="BOTH"
  1. E S ASK="CH"
  1. S CNIDT=+$O(^LR(LRDFN,"CH",IDT),DIRECT),MNIDT=+$O(^LR(LRDFN,"MI",IDT),DIRECT)
  1. S AVAIL="NONE"
  1. I CNIDT,CNIDT'>EDT D
  1. .S AVAIL="CH" I MNIDT,MNIDT'>EDT S AVAIL="BOTH"
  1. E I MNIDT,MNIDT'>EDT S AVAIL="MI"
  1. I DIRECT=-1 S AVAIL="BOTH"
  1. S ROUTE="NONE"
  1. I ASK="BOTH" S ROUTE=AVAIL
  1. I ASK="CH",AVAIL="CH"!(AVAIL="BOTH") S ROUTE="CH"
  1. I ASK="MI",AVAIL="MI"!(AVAIL="BOTH") S ROUTE="MI"
  1. I MICROCHK=-1 S ROUTE="MI"
  1. I ROUTE="NONE" D Q
  1. .K ^TMP("BPC7OG",$J)
  1. I ROUTE="CH" D Q
  1. .F S IDT=$O(^LR(LRDFN,"CH",IDT),DIRECT) Q:IDT<1 Q:IDT>EDT D CH^BPC7OGMC(LRDFN,IDT,ALL,.OUTCNT,FORMAT,.DONE) Q:DONE
  1. .K ^TMP("BPC7OG",$J)
  1. I ROUTE="MI" D Q
  1. .F S IDT=$O(^LR(LRDFN,"MI",IDT),DIRECT) Q:IDT<1 Q:IDT>EDT D MI^BPC7OGMM(LRDFN,IDT,.MICROSUB,ALL,.OUTCNT,FORMAT,.DONE) Q:DONE
  1. .K ^TMP("BPC7OG",$J)
  1. F S CNIDT=+$O(^LR(LRDFN,"CH",IDT),DIRECT),MNIDT=+$O(^LR(LRDFN,"MI",IDT),DIRECT) Q:'CNIDT&'MNIDT D Q:IDT>EDT Q:DONE
  1. .I CNIDT=MNIDT D Q ; both chem and micro at this date/time
  1. ..S IDT=CNIDT
  1. ..I IDT'>EDT D
  1. ...I FORMAT D Q
  1. ....I SDT=(9999999-2700101)!(DIRECT=-1) D Q
  1. .....D MI^BPC7OGMM(LRDFN,IDT,.MICROSUB,ALL,.OUTCNT,FORMAT,.DONE)
  1. .....S $P(^TMP("BPC7OGX",$J,"OUTPUT",1),U,9)=3
  1. ....D CH^BPC7OGMC(LRDFN,IDT,ALL,.OUTCNT,FORMAT,.DONE)
  1. ....S $P(^TMP("BPC7OGX",$J,"OUTPUT",1),U,9)=2
  1. ...I MICROCHK'=1 D Q:DONE
  1. ....D CH^BPC7OGMC(LRDFN,IDT,ALL,.OUTCNT,FORMAT,.DONE)
  1. ....I FORMAT S MICROCHK=1
  1. ...D MI^BPC7OGMM(LRDFN,IDT,.MICROSUB,ALL,.OUTCNT,FORMAT,.DONE)
  1. .I 'MNIDT D Q ; no micro since this date/time, only chem at this date/time
  1. ..S IDT=CNIDT
  1. ..I IDT'>EDT D CH^BPC7OGMC(LRDFN,IDT,ALL,.OUTCNT,FORMAT,.DONE)
  1. .I 'CNIDT D Q ; no chem since this date/time, only micro at this date/time
  1. ..S IDT=MNIDT
  1. ..I IDT'>EDT D MI^BPC7OGMM(LRDFN,IDT,.MICROSUB,ALL,.OUTCNT,FORMAT,.DONE)
  1. .I (DIRECT=1&(CNIDT<MNIDT))!(DIRECT=-1&(CNIDT>MNIDT)) D Q ;chem and micro data, chem is more recent
  1. ..S IDT=CNIDT
  1. ..I IDT'>EDT D CH^BPC7OGMC(LRDFN,IDT,ALL,.OUTCNT,FORMAT,.DONE)
  1. .S IDT=MNIDT
  1. .I IDT'>EDT D MI^BPC7OGMM(LRDFN,IDT,.MICROSUB,ALL,.OUTCNT,FORMAT,.DONE)
  1. K ^TMP("BPC7OG",$J)
  1. Q