ORWGAPIB ; SLC/STAFF - Graph Blood Bank ;12/21/05 08:21
;;3.0;ORDER ENTRY/RESULTS REPORTING;**215,243**;Dec 17, 1997;Build 242
;
BBITEM(ITEMS,DFN,FMT,OLDEST,NEWEST,CNT,TMP) ; from ORWGAPIR
N DATE,IDATE,INEWEST,IOLDEST,ITEM,LRDFN,OK,RESULT
K ^TMP("ORWGRPC TEMP",$J)
S INEWEST=$$LRIDT^ORWGAPIC(NEWEST),IOLDEST=$$LRIDT^ORWGAPIC(OLDEST)
S LRDFN=$$LRDFN^ORWGAPIC(DFN)
S IDATE=0
F S IDATE=$O(^LR(LRDFN,1.6,IDATE)) Q:IDATE<1 D
. S ITEM=+$P($G(^LR(LRDFN,1.6,IDATE,0)),U,2)
. I 'ITEM Q
. S OK=0
. I FMT=6 D
.. Q:IDATE<INEWEST Q:IDATE>IOLDEST
.. S OK=1
.. S CNT=CNT+1
.. S RESULT="63BB"_U_ITEM
. I FMT=3 D
.. I '$D(^TMP("ORWGRPC TEMP",$J,ITEM)) D
... S OK=1
... S ^TMP("ORWGRPC TEMP",$J,ITEM)=""
... S DATE=$$LRIDT^ORWGAPIC(IDATE)
... S CNT=CNT+1
... S RESULT="63BB^"_ITEM_"^^"_$P($G(^LAB(66,ITEM,0)),U)_"^^"_DATE
. I FMT=0 D
.. S OK=1
.. S CNT=CNT+1
.. S RESULT="63BB^"_ITEM_U_$P($G(^LAB(66,ITEM,0)),U)
. I OK D SETUP^ORWGAPIW(.ITEMS,RESULT,TMP,.CNT)
K ^TMP("ORWGRPC TEMP",$J)
Q
;
BBDATA(DATA,ITEM,START,DFN,CNT,TMP,BACKTO) ; from ORWGAPIR
N DATE,IDATE,LRDFN,NITEM,RESULT
S LRDFN=$$LRDFN^ORWGAPIC(DFN)
S IDATE="",CNT=$G(CNT),BACKTO=+$G(BACKTO)
F S IDATE=$O(^LR(LRDFN,1.6,IDATE)) Q:IDATE="" D
. S NITEM=+$P($G(^LR(LRDFN,1.6,IDATE,0)),U,2)
. I NITEM'=ITEM Q
. S DATE=$$LRIDT^ORWGAPIC(IDATE)
. I DATE>START Q
. I DATE<BACKTO Q
. S RESULT="63BB^"_ITEM_U_DATE_U
. D SETUP^ORWGAPIW(.DATA,RESULT,TMP,.CNT)
Q
;
BBX(DFN) ; $$(dfn) -> 1 if patient has blood bank data ,else 0
Q $L($O(^LR(+$$LRDFN^ORWGAPIC($G(DFN)),1.6,"")))>0
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORWGAPIB 1612 printed Oct 16, 2024@18:36:53 Page 2
ORWGAPIB ; SLC/STAFF - Graph Blood Bank ;12/21/05 08:21
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**215,243**;Dec 17, 1997;Build 242
+2 ;
BBITEM(ITEMS,DFN,FMT,OLDEST,NEWEST,CNT,TMP) ; from ORWGAPIR
+1 NEW DATE,IDATE,INEWEST,IOLDEST,ITEM,LRDFN,OK,RESULT
+2 KILL ^TMP("ORWGRPC TEMP",$JOB)
+3 SET INEWEST=$$LRIDT^ORWGAPIC(NEWEST)
SET IOLDEST=$$LRIDT^ORWGAPIC(OLDEST)
+4 SET LRDFN=$$LRDFN^ORWGAPIC(DFN)
+5 SET IDATE=0
+6 FOR
SET IDATE=$ORDER(^LR(LRDFN,1.6,IDATE))
if IDATE<1
QUIT
Begin DoDot:1
+7 SET ITEM=+$PIECE($GET(^LR(LRDFN,1.6,IDATE,0)),U,2)
+8 IF 'ITEM
QUIT
+9 SET OK=0
+10 IF FMT=6
Begin DoDot:2
+11 if IDATE<INEWEST
QUIT
if IDATE>IOLDEST
QUIT
+12 SET OK=1
+13 SET CNT=CNT+1
+14 SET RESULT="63BB"_U_ITEM
End DoDot:2
+15 IF FMT=3
Begin DoDot:2
+16 IF '$DATA(^TMP("ORWGRPC TEMP",$JOB,ITEM))
Begin DoDot:3
+17 SET OK=1
+18 SET ^TMP("ORWGRPC TEMP",$JOB,ITEM)=""
+19 SET DATE=$$LRIDT^ORWGAPIC(IDATE)
+20 SET CNT=CNT+1
+21 SET RESULT="63BB^"_ITEM_"^^"_$PIECE($GET(^LAB(66,ITEM,0)),U)_"^^"_DATE
End DoDot:3
End DoDot:2
+22 IF FMT=0
Begin DoDot:2
+23 SET OK=1
+24 SET CNT=CNT+1
+25 SET RESULT="63BB^"_ITEM_U_$PIECE($GET(^LAB(66,ITEM,0)),U)
End DoDot:2
+26 IF OK
DO SETUP^ORWGAPIW(.ITEMS,RESULT,TMP,.CNT)
End DoDot:1
+27 KILL ^TMP("ORWGRPC TEMP",$JOB)
+28 QUIT
+29 ;
BBDATA(DATA,ITEM,START,DFN,CNT,TMP,BACKTO) ; from ORWGAPIR
+1 NEW DATE,IDATE,LRDFN,NITEM,RESULT
+2 SET LRDFN=$$LRDFN^ORWGAPIC(DFN)
+3 SET IDATE=""
SET CNT=$GET(CNT)
SET BACKTO=+$GET(BACKTO)
+4 FOR
SET IDATE=$ORDER(^LR(LRDFN,1.6,IDATE))
if IDATE=""
QUIT
Begin DoDot:1
+5 SET NITEM=+$PIECE($GET(^LR(LRDFN,1.6,IDATE,0)),U,2)
+6 IF NITEM'=ITEM
QUIT
+7 SET DATE=$$LRIDT^ORWGAPIC(IDATE)
+8 IF DATE>START
QUIT
+9 IF DATE<BACKTO
QUIT
+10 SET RESULT="63BB^"_ITEM_U_DATE_U
+11 DO SETUP^ORWGAPIW(.DATA,RESULT,TMP,.CNT)
End DoDot:1
+12 QUIT
+13 ;
BBX(DFN) ; $$(dfn) -> 1 if patient has blood bank data ,else 0
+1 QUIT $LENGTH($ORDER(^LR(+$$LRDFN^ORWGAPIC($GET(DFN)),1.6,"")))>0
+2 ;