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