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

VBECRPT.m

Go to the documentation of this file.
VBECRPT ;HOIFO/RLM - APIS TO RETURN BLOOD BANK DATA FOR LAB ;Jan 31, 2020@13:10:43
 ;;2.0;VBEC;**8**;Jun 05, 2015;Build 27
 ;
 ; Note: This routine supports data exchange with an FDA registered
 ; medical device. As such, it may not be changed in any way without
 ; prior written approval from the medical device manufacturer.
 ; 
 ; Integration Agreements:
 ; Reference to GETS^DIQ is supported by ICR #2056
 ; Reference to $$GET1^DIQ supported by ICR #2052
 ; Reference to DD^%DT supported by ICR #10003
 ; Reference to FIND^DIC supported by ICR #2051
 ; Reference to GETWP^XPAR supported by ICR #2263
 ;
EN ;Add sections as they are finished.
 S VBLINE=1,PATID="`"_DFN,PATNAM=$P(^DPT(DFN,0),"^"),PATDOB=$P(^DPT(DFN,0),"^",3) D HEADER,ABORH
 I $E(ABORH,1,2)="1^" D INCRL(3) D  G EXIT
  . D GETWP^XPAR(.VBERR,"ALL","OR VBECS ERROR MESSAGE") F I=1:1 Q:'$D(VBERR(I,0))  S VBLINE(VBLINE)="     "_VBERR(I,0),VBLINE=VBLINE+1
 D ABID,TRRX,AVUNIT,DFN,COMPREQ,TRAN ;COMPREQ must follow DFN
EXIT ;Set up to print and clean up.
 K ^TMP("ORLRC",$J) D INCRL(4)
 S VBA=0 F  S VBA=$O(VBLINE(VBA)) Q:VBA=""  S ^TMP("ORLRC",$J,VBA,0)=VBLINE(VBA)
 K VBA,VBABID,VBABIDC,VBB,VBC,VBCM,VBCM1,VBCMO,VBD,VBDATA,VBDATE,VBDATI,VBDTNT,VBECERR,VBINST,VBLINE,VBLN,VBM,VBPLC,VBQ,VBREQBY,VBREQD,VBREQR,VBRSLT,VBRXTYP,VBSPCCLM,VBSPCCM,VBSPCCML,VBSPCL,VBT,VBTN,VBTR,VBTRRX,VBTXT,VBWNTD,VBX,VBY
 Q
 S VBLINE(VBLINE)="                             ---- BLOOD BANK ----",VBLINE=VBLINE+1
 Q
TEST ;Calls
 N ORVP,PATID,PATNAM,PATDOB,LRDFN,ERR,ABORH,ID,ID1,ID2,ARR,GMI,DI2,BPN,VBECERR,ERROR
 D ABORH,ABID,TRRX,DFN,CPRS,TRAN
 W !!!,"CROSSMATCHED UNITS: "
 I $O(^TMP("VBDATA",$J,"CROSSMATCH",0)) D
 . S ID=0 F  S ID=$O(^TMP("VBDATA",$J,"CROSSMATCH",ID)) Q:'ID  W !?2,^(ID)
 K ^TMP("VBDATA",$J),^TMP("TRRX",$J),^TMP("TRAN",$J)
 Q
OEAPI ;Call to OEAPI^VBECA3
 N DIV,ORSTN,ERROR,ORVB
 S DIV=+$P($G(^SC(+$G(ORL),0)),U,15),ORSTN=$P($$SITE^VASITE(DT,DIV),U,3)
 D OEAPI^VBECA3(.ORVB,+ORVP,ORSTN)
 I $O(ORVB(0)) D
 . W !!!,"Array returned from OEAPI^VBECA3 API in ORVB():",!
 K ^TMP("OR",$J),^TMP("VBECRPC",$J),^TMP("VBECS_XML_RES",$J),^TMP("VBEC_OE_DATA",$J)
 Q
ABORH ;Call to ABORH^VBECA1 for ABO/Rh - DBIA 3181
 S ABORH=$$ABORH^VBECA1(PATID,PATNAM,PATDOB) Q:ABORH["1^"
 D INCRL(3) ;F I=1:1:3 S VBLINE(VBLINE)="",VBLINE=VBLINE+1
 S VBLINE(VBLINE)="ABO/RH: " I ABORH=""!(ABORH=" ")  S VBLINE(VBLINE)="  No ABO/Rh results.",VBLINE=VBLINE+1 Q
 S:ABO="I " ABO="Inconclusive "
 S VBLINE(VBLINE)=VBLINE(VBLINE)_$G(ABO)_" "_$S(RH="P":"Positive",RH="N":"Negative",RH="I":"Inconclusive",1:""),VBLINE=VBLINE+1
 Q
ABID ;Call to ABID^VBECA1 for Antibodies Identified - DBIA 3181, 3184
 D ABID^VBECA1(PATID,PATNAM,PATDOB,.ORPARNT,.ORARR)
 D INCRL(3)
 S VBLINE(VBLINE)="ANTIBODIES IDENTIFIED: ",VBLINE=VBLINE+1
 I '$O(ORARR("ABID","")) D INCRL(1) S VBLINE(VBLINE)="  No Antibody results.",VBLINE=VBLINE+1 G TREQ
 S ID=0,VBABID=" " F  S ID=$O(ORARR("ABID",ID)) Q:'ID  S VBABID=VBABID_$S(VBABID=" ":"",1:", ")_ORARR("ABID",ID) D
 . S ID1=0 F  S ID1=$O(ORARR("ABID",ID,ID1)) Q:'ID1  S VBABIDC(ID1)=ORARR("ABID",ID,ID1)
 S VBLINE(VBLINE)=" "_VBABID,VBLINE=VBLINE+1
 S VBLINE(VBLINE)="  COMMENT:",VBLINE=VBLINE+1
 ;S ID1=0 F  S ID1=$O(VBABIDC(ID1)) Q:ID1=""  S VBLINE(VBLINE)="  "_VBABIDC(ID1),VBLINE=VBLINE+1
 S ID1=0 S VBLINE(VBLINE)="  " F  S ID1=$O(VBABIDC(ID1)) Q:ID1=""  S VBLINE(VBLINE)=VBLINE(VBLINE)_" "_VBABIDC(ID1)
 S VBLINE=VBLINE+1
 K VBABID,VBABIDC
TREQ ;W !!,"Transfusion Requirements"
 D INCRL(2) S VBLINE(VBLINE)="TRANSFUSION REQUIREMENTS",VBLINE=VBLINE+1
 I '$O(ORARR("ABID","TR","")) D INCRL(1) S VBLINE(VBLINE)="  No Transfusion Requirements.",VBLINE=VBLINE+1 Q
 S ID=0,VBABID=" " F  S ID=$O(ORARR("ABID","TR",ID)) Q:'ID  S VBABID=VBABID_$S(VBABID=" ":"",1:", ")_ORARR("ABID","TR",ID) D
 . S ID1=0 F  S ID1=$O(ORARR("ABID","TR",ID,ID1)) Q:'ID1  S VBABIDC(ID1)=ORARR("ABID","TR",ID,ID1)
 S VBLINE(VBLINE)=" "_VBABID,VBLINE=VBLINE+1
 S VBLINE(VBLINE)="  COMMENT:",VBLINE=VBLINE+1
 S ID1=0 S VBLINE(VBLINE)="  " F  S ID1=$O(VBABIDC(ID1)) Q:ID1=""  S VBLINE(VBLINE)=VBLINE(VBLINE)_" "_VBABIDC(ID1)
 S VBLINE=VBLINE+1
 Q
DFN ;Call to DFN^VBECA3A - DBIA 3879
 K ^TMP("VBDATA",$J)
 D DFN^VBECA1B(DFN)
 D INCRL(2) K ^TMP("VBRPTDTA",$J) S VBSPCCML=1,$P(VBX," ",256)=""
 S VBLINE(VBLINE)="DIAGNOSTIC TESTS",VBLINE=VBLINE+1
 I '$O(^TMP("VBDATA",$J,"SPECIMEN","")) D INCRL(1) S VBLINE(VBLINE)="  No results.",VBLINE=VBLINE+1 Q
 S (ID,ID1,ID2)="" F  S ID=$O(^TMP("VBDATA",$J,"SPECIMEN",ID)) Q:'ID  D
 . S VBSPCID=$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",9)
 . S VBDATE=$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",8) D VBDAT S VBSPDT=VBDATE,VBDPDTI=VBDATI
 . S VBDPDTI=VBDATI_" "_VBSPCID
 . S VBSPCID=VBSPCID_$E(VBX,$L(VBX),12)
 . S VBDATE=$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",10) D VBDAT1 S VBCLDT=VBDATE,VBCLDTI=VBDATI
 . S VBINST=$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",2) D INSTLK
 . S VBTN=$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",5)
 . S VBPLC=$S(VBTN="ABO Interp":2,VBTN="Rh Interp":3,VBTN="Antibody Screen Interp":4,VBTN="DAT Poly AHG":5,VBTN="DAT Poly Interp":6,VBTN="DAT IgG  AHG":7,VBTN="DAT IgG Interp":8,VBTN="DAT Comp AHG":9,VBTN="DAT Comp Interp":10,1:0)
 . S:'$D(^TMP("VBRPTDTA",$J,VBDPDTI)) ^TMP("VBRPTDTA",$J,VBDPDTI)=VBSPDT_"^^^^^^^^^^"_VBINST_"^"_VBCLDT_"^"_VBSPCID
 . S VBRSLT=$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",7) I VBRSLT="No Agglutination" S VBRSLT=0
 . I VBPLC S $P(^TMP("VBRPTDTA",$J,VBDPDTI),"^",VBPLC)=VBRSLT D
 . . F VBLN=1:1:3 I $G(^TMP("VBDATA",$J,"SPECIMEN",ID,VBLN))]"" S ^TMP("VBRPTDTA",$J,VBDPDTI,$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",5),VBLN)="Comment ("_$P(^TMP("VBDATA",$J,"SPECIMEN",ID),"^",5)_"): "_^TMP("VBDATA",$J,"SPECIMEN",ID,VBLN)
 . . F VBLN=4:1:6 S VBSPCCM=$G(^TMP("VBDATA",$J,"SPECIMEN",ID,VBLN)) I VBSPCCM]"" D
 . . . I '$D(^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM)) S ^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM,VBSPCCML)="" S ^TMP("VBRPTDTA",$J,VBDPDTI,"VBSPCL",VBSPCCML)="",VBSPCCML=VBSPCCML+1 Q
 . . . I $D(^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM)) S VBSPCCLM=$O(^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM,"")) S ^TMP("VBRPTDTA",$J,VBDPDTI,"VBSPCL",VBSPCCLM)=""
 . . I $G(^TMP("VBDATA",$J,"SPECIMEN",ID,7))]"" D
 . . . S VBSPCCM=^TMP("VBDATA",$J,"SPECIMEN",ID,7)
 . . . I '$D(^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM)) S ^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM,VBSPCCML)="" S ^TMP("VBRPTDTA",$J,VBDPDTI,"VBSPCL",VBSPCCML)="",VBSPCCML=VBSPCCML+1 Q
 . . . I $D(^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM)) S VBSPCCLM=$O(^TMP("VBRPTDTA",$J,"VBSPCCM",VBSPCCM,"")) S ^TMP("VBRPTDTA",$J,VBDPDTI,"VBSPCL",VBSPCCLM)=""
 S VBLINE(VBLINE)="",VBLINE=VBLINE+1
 S VBLINE(VBLINE)="                                                                     |------- DAT -------|",VBLINE=VBLINE+1
 S VBLINE(VBLINE)="                                                                     |Poly|  |IgG|  |Comp|",VBLINE=VBLINE+1
 S VBLINE(VBLINE)="       Collection Date  UID        Test Date/Time    ABO Rh   ABS    Intrp   Intrp  Intrp  Division",VBLINE=VBLINE+1
 S VBLINE(VBLINE)="       ---------------  ---        --------------    ------   ---    -----   -----  -----  --------",VBLINE=VBLINE+1
 S VBDATI="" F  S VBDATI=$O(^TMP("VBRPTDTA",$J,VBDATI)) Q:'VBDATI  S VBDATA=^TMP("VBRPTDTA",$J,VBDATI) D  ;
 . D INCRL(1) S VBLINE(VBLINE)=""
 . I $O(^TMP("VBRPTDTA",$J,VBDATI,"VBSPCL",0)) S VBSPCL=0 S VBLINE(VBLINE)="(" D
 . . F  S VBSPCL=$O(^TMP("VBRPTDTA",$J,VBDATI,"VBSPCL",VBSPCL)) Q:'VBSPCL  S VBLINE(VBLINE)=VBLINE(VBLINE)_VBSPCL S VBLINE(VBLINE)=VBLINE(VBLINE)_$S($O(^TMP("VBRPTDTA",$J,VBDATI,"VBSPCL",VBSPCL)):",",1:")")
 . S VBLINE(VBLINE)=VBLINE(VBLINE)_$E("         ",1,(7-$L(VBLINE(VBLINE))))
 . S VBLINE(VBLINE)=VBLINE(VBLINE)_$P(VBDATA,"^",12)_" "_$P(VBDATA,"^",13)_" "_$P(VBDATA,"^")_"  "_$P(VBDATA,"^",2)_" "_$E(VBX,1,(3-$L($P(VBDATA,"^",2))))_$P(VBDATA,"^",3)_$E(VBX,1,(5-$L($P(VBDATA,"^",3)))) D
 . . S VBLINE(VBLINE)=VBLINE(VBLINE)_$P(VBDATA,"^",4)_$E(VBX,1,(7-$L($P(VBDATA,"^",4))))_$P(VBDATA,"^",6)_$E(VBX,1,(8-$L($P(VBDATA,"^",6))))_$P(VBDATA,"^",8)_$E(VBX,1,(7-$L($P(VBDATA,"^",8))))
 . . S VBLINE(VBLINE)=VBLINE(VBLINE)_$P(VBDATA,"^",10)_$E(VBX,1,(7-$L($P(VBDATA,"^",10))))_$P(VBDATA,"^",11),VBLINE=VBLINE+1
 . S VBCM="" F  S VBCM=$O(^TMP("VBRPTDTA",$J,VBDATI,VBCM)) Q:VBCM="VBSPCL"!(VBCM="")  F I=1:1 Q:'$D(^TMP("VBRPTDTA",$J,VBDATI,VBCM,I))  S VBLINE(VBLINE)="      "_^TMP("VBRPTDTA",$J,VBDATI,VBCM,I),VBLINE=VBLINE+1
 S (VBCM,VBCM1)="" F  S VBCM=$O(^TMP("VBRPTDTA",$J,"VBSPCCM",VBCM)) Q:VBCM=""  F  S VBCM1=$O(^TMP("VBRPTDTA",$J,"VBSPCCM",VBCM,VBCM1)) Q:'VBCM1  S VBCMO(VBCM1)=VBCM
 I $O(VBCMO(0))="" Q
 D INCRL(2) S VBLINE(VBLINE)="   ----- STANDARD COMMENTS FOR DIAGNOSTIC TESTS ABOVE -----",VBLINE=VBLINE+1
 S VBI="" F  S VBI=$O(VBCMO(VBI)) Q:VBI=""  S VBLINE(VBLINE)="("_VBI_") "_VBCMO(VBI),VBLINE=VBLINE+1
 Q
VBDAT ;CONVERT DATE 3200114.16132
 S VBDATI=9999999-VBDATE
VBDAT1 S Y=VBDATE D DD^%DT S VBT=$P($P(Y,"@",2),":",1,2)
 S VBY=(($E(VBDATE,1)*100)+1700)+$E(VBDATE,2,3),VBM=$E(VBDATE,4,5),VBD=$E(VBDATE,6,7)
 S VBDATE=VBM_"/"_VBD_"/"_VBY_"@"_VBT
 S VBDTNT=VBM_"/"_VBD_"/"_VBY
 Q
AVUNIT ;Available Units
 D AVUNIT^VBECA4(DFN,"VBA"),INCRL(3)
 S VBLINE(VBLINE)="AVAILABLE/ISSUED UNITS:",VBLINE=VBLINE+1
 I $O(^TMP("VBA",$J,""))="" D INCRL(1) S VBLINE(VBLINE)="  No Available/Issued Units.",VBLINE=VBLINE+1 Q
 S VBA=$G(^TMP("VBA",$J,0)),$P(VBX," ",256)=""
 Q:VBA=""
 S VBLINE(VBLINE)=" Date Assigned    Issue Date       Unit ID        Product Code Product Name                                                ABO/Rh         Exp. Date   Location   Division",VBLINE=VBLINE+1
 S VBLINE(VBLINE)=" -------------    ----------       -------        ------------ ---------                                                   ------         ---------   --------   --------",VBLINE=VBLINE+1
 S (VBA,VBB)=0 F  S VBA=$O(^TMP("VBA",$J,VBA)) Q:VBA=""  S VBB=^TMP("VBA",$J,VBA) D
 . S VBDATE=9999999-VBA D VBDAT1 S VBDTA=VBDATE
 . S VBC=^TMP("VBA",$J,VBA)
 . S VBDATE=$P(VBC,"^",14) I VBDATE]"" D VBDAT1 S VBDST=VBDATE
 . I $P(VBC,"^",14)="" S VBDST="                "
 . S VBABORH=$J($P(VBC,"^",6),2)_" "_$J($P(VBC,"^",7),3)_"        ",VBABORH=$E(VBABORH,1,14)
 . S VBUNIT=$P(VBC,"^",3),VBUNIT=VBUNIT_$E(VBX,$L(VBUNIT),13)
 . S VBPRID=$P(VBC,"^",11),VBPRID=VBPRID_$E(VBX,$L(VBPRID),9)
 . S VBLOC=$E($P(VBC,"^",10),1,10),VBLOC=VBLOC_$E(VBX,1,(11-$L(VBLOC)))
 . S VBLINE(VBLINE)=" "_VBDTA_" "_VBDST_" "_VBUNIT_" "_VBPRID_"   "_$E($P(VBC,"^",13),1,57)_$E(VBX,1,(58-$L($P(VBC,"^",13))))_" "
 . S VBLINE(VBLINE)=VBLINE(VBLINE)_VBABORH_"  "_$P(VBC,"^",2)_" "_VBLOC_$P(VBC,"^",9),VBLINE=VBLINE+1
 Q
INSTLK ;Lookup Institution
 D FIND^DIC(4,,.01,"MX",VBINST,,"D",,,"VBINST1","VBERR")
 S VBINST=$G(VBINST1("DILIST","ID",1,.01))
 Q
CPRS ;Call to CPRS^VBECA3B - DBIA 3880
 N ID,ID1,ID2,ERROR
 K ^TMP("BBD",$J)
 D CPRS^VBECA3B
 W !!!,"Specimen: "
 I $O(^TMP("BBD",$J,"SPECIMEN",0)) D
 .  S ID=0 F  S ID=$O(^TMP("BBD",$J,"SPECIMEN",ID)) Q:'ID  W !?2,^(ID) D
 .. S ID1=0 F  S ID1=$O(^TMP("BBD",$J,"SPECIMEN",ID,ID1)) Q:'ID1  W:$D(^(ID1))#2 !,"."_^(ID1) D
 ... S ID2=0 F  S ID2=$O(^TMP("BBD",$J,"SPECIMEN",ID,ID1,ID2)) Q:'ID2  W:$D(^(ID2))#2 !,".."_^(ID2)
 Q
COMPREQ ;Component Requests
 D INCRL(3)
 S VBLINE(VBLINE)="COMPONENT REQUESTS:",VBLINE=VBLINE+1
 I '$O(^TMP("VBDATA",$J,"COMPONENT REQUEST",0)) D INCRL(1) S VBLINE(VBLINE)="  No Component Requests.",VBLINE=VBLINE+1 Q
 S VBLINE(VBLINE)=" Component Type       Qty  Request date        Date wanted        Requestor  By",VBLINE=VBLINE+1
 S VBLINE(VBLINE)=" --------------       ---  ------------        -----------        ---------  --",VBLINE=VBLINE+1
 I $O(^TMP("VBDATA",$J,"COMPONENT REQUEST",0)) D
 . S ID=0 F  S ID=$O(^TMP("VBDATA",$J,"COMPONENT REQUEST",ID)) Q:'ID  S VBA=^(ID) D
 . . S VBDATE=$P(VBA,"^",3) D VBDAT1 S VBREQD=VBDATE S VBDATE=$P(VBA,"^",4) D VBDAT1 S VBWNTD=VBDTNT
 . . S VBREQR=$$GET1^DIQ(200,$P(VBA,"^",5),1),VBREQBY=$$GET1^DIQ(200,$P(VBA,"^",6),1),VBREQR=$E(VBREQR_"     ",1,5)
 . . S VBLINE(VBLINE)="  "_$E($P(VBA,"^"),1,20)_$E(VBX,$L($P(VBA,"^")),20)_$P(VBA,"^",2)_$E(VBX,$L($P(VBA,"^",2)),3)_VBREQD_"    "_VBWNTD_"         "_VBREQR_"      "_VBREQBY,VBLINE=VBLINE+1
 Q
TRAN ;Call to TRAN^VBECA4 for Tranfused Units - DBIA 3176
 K ^TMP("TRAN",$J),^TMP("ZTRAN",$J)
 D TRAN^VBECA4(+DFN,"TRAN")
 S CNT=0 F ID="RBC","FFP","PLT","CRY","PLA","SER","GRA","WB" S CNT=CNT+1,ORAY(ID)=CNT
 S ID=0 F  S ID=$O(^TMP("TRAN",$J,ID)) Q:'ID  S GMR=^(ID),COMP=$P(GMR,"^",2),COMP=$P(COMP,"\",2),COMP=$E($P(COMP,";"),1,3),COMPSEQ=$S($D(ORAY(COMP)):ORAY(COMP),1:99) D
 . I '$D(^TMP("ZTRAN",$J,$P(ID,"."),COMPSEQ)) S ^TMP("ZTRAN",$J,$P(ID,"."),COMPSEQ)=GMR_"^"_1 Q
 . S CNT=$P(^TMP("ZTRAN",$J,$P(ID,"."),COMPSEQ),"^",3),$P(^(COMPSEQ),"^",3)=CNT+1
 D INCRL(3) S VBLINE(VBLINE)="TRANSFUSED UNITS",VBLINE=VBLINE+1,$P(VBX," ",256)=""
 I '$O(^TMP("TRAN",$J,0)) D INCRL(1) S VBLINE(VBLINE)="  No Transfused Units.",VBLINE=VBLINE+1 Q
 S VBLINE(VBLINE)=" Date Transfused   Unit ID        Product Code    Product Name                                              ABO/Rh",VBLINE=VBLINE+1
 S VBLINE(VBLINE)=" ---------------   -------        ------------    ------------                                              ------",VBLINE=VBLINE+1
 S ID=0 F  S ID=$O(^TMP("TRAN",$J,ID)) Q:'ID  S VBA=^(ID),VBDATE=$P(VBA,"^") D VBDAT1 D
 . S VBTR=$P(VBA,"^",2)
 . S VBQ=$P(VBTR,"\"),VBQ=$J("("_VBQ_")",5)
 . S VBT=$P(VBA,"^",7),VBT=VBT_$E(VBX,$L(VBT),57)
 . S VBABORH=$P(VBA,"^",3)_" "_$P(VBA,"^",4)_"        ",VBABORH=$E(VBABORH,1,14)
 . S VBUNIT=$P(VBA,"^",6),VBUNIT=VBUNIT_$E(VBX,$L(VBUNIT),14)
 . S VBPROD=$P(VBA,"^",5),VBPROD=VBPROD_$E(VBX,$L(VBPROD),15)
 . S VBLINE(VBLINE)=" "_VBDTNT_"        "_VBUNIT_VBPROD_VBT_VBABORH,VBLINE=VBLINE+1
 . ;S VBLINE(VBLINE)=" "_VBDTNT_"    ("_VBQ_")"_$E("     ",$L(VBQ),4)_$P(VBT,";"),VBLINE=VBLINE+1
 ;S VBTXT=1,VBA="A" F  S VBA=$O(^TMP("TRAN",$J,VBA)) Q:VBA=""  S VBLINE(VBLINE)=$S(VBTXT:" Blood Product Key: ",1:"                    ")_VBA_" = "_^(VBA),VBLINE=VBLINE+1,VBTXT=0
 Q
TRRX ;Call to TRRX^VBECA1 for Transfusion Reactions - DBIA 3181, 3187
 D TRRX^VBECA1(PATID,PATNAM,PATDOB,.ORPARNT,.ORARR)
 D INCRL(3) S VBLINE(VBLINE)="TRANSFUSION REACTIONS: ",VBLINE=VBLINE+1 S $P(VBX," ",256)=""
 I '$O(ORARR("TRRX",0)) D INCRL(1) S VBLINE(VBLINE)="  No Transfusion Reactions.",VBLINE=VBLINE+1 Q
 I $O(ORARR("TRRX",0)) D
 . S ID=0 F  S ID=$O(ORARR("TRRX",ID)) Q:'ID  D  ;W !?2,ORARR("TRRX",ID)
 . . S VBRXTYP=$P(ORARR("TRRX",ID),"^",2)
 . . S Y=$P(ORARR("TRRX",ID),"^") D DD^%DT Q:Y=""  I VBRXTYP="" S VBRXTYP="Unknown"
 . . S VBTRRX(VBRXTYP,ID)=Y_"^"_$S($P(ORARR("TRRX",ID),"^",3)]"":$P(ORARR("TRRX",ID),"^",3),1:"None")_"^"_$S($P(ORARR("TRRX",ID),"^",4)]"":$P(ORARR("TRRX",ID),"^",4),1:"         None")
 . . S ID1="" F  S ID1=$O(ORARR("TRRX",ID,ID1)) Q:'ID1  S VBTRRX(VBRXTYP,ID,ID1)=ORARR("TRRX",ID,ID1)
 S (ID,ID1)="" F  S ID=$O(VBTRRX(ID)) Q:ID=""  S VBLINE(VBLINE)=" Type: "_ID,VBLINE=VBLINE+1 D TRRXHDR D
 . F  S ID1=$O(VBTRRX(ID,ID1)) Q:'ID1  S VBLINE(VBLINE)="  "_$P(VBTRRX(ID,ID1),"^")_$E(VBX,$L($P(VBTRRX(ID,ID1),"^")),26)_$P(VBTRRX(ID,ID1),"^",2)_$E(VBX,$L($P(VBTRRX(ID,ID1),"^")),27)_$P(VBTRRX(ID,ID1),"^",3),VBLINE=VBLINE+1 D
 . . S:$O(VBTRRX(ID,ID1,"")) VBLINE(VBLINE)="     Comment: ",VBLINE=VBLINE+1
 . . S ID2="" F  S ID2=$O(VBTRRX(ID,ID1,ID2)) Q:'ID2  S VBLINE(VBLINE)="     "_VBTRRX(ID,ID1,ID2),VBLINE=VBLINE+1 ;W !?5,VBTRRX(ID,ID1,ID2)
 Q
TRRXHDR ;Transfusion Reaction Header
 S VBLINE(VBLINE)="  Date/Time                  Unit Id             Component",VBLINE=VBLINE+1,VBLINE(VBLINE)="  ---------                  -------             ---------",VBLINE=VBLINE+1
 Q
PARSE ;Parse Record
 N GMI,X
 S TD=$$FMTE^XLFDT(+GMR)
 S GMA(1)=$P(GMR,U,2),BPN=$L(GMA(1),";")
 I $P(GMA(1),";",BPN)="" S BPN=BPN-1
 F GMI=2:1:BPN S GMA(GMI)="("_$P($P(GMA(1),";",GMI),"\")_") "_$P($P(GMA(1),";",GMI),"\",2)
 S GMA(1)="("_$P($P(GMA(1),";",1),"\")_") "_$P($P(GMA(1),";",1),"\",2)
 Q
WRT ; Writes the Transfusion Record for each day
 N GML,GMI1,GMI2,GMM,GMJ
 S GMM=$S(BPN#4:1,1:0),GML=BPN\4+GMM
 W TD
 F GMI1=1:1:GML D
 . F GMI2=1:1:($S((GMI1=GML)&(BPN#4):BPN#4,1:4)) D
 .. S GMJ=((GMI1-1)*4)+GMI2
 .. W ?(((GMI2-1)*15)+13),GMA(GMJ)
 .. I $S(GMI2#4=0:1,GMI2=BPN:1,GMI2+(4*(GMI1-1))=BPN:1,1:0) W !
 Q
INCRL(I) ;Increment line
 F I=1:1:I S VBLINE(VBLINE)="",VBLINE=VBLINE+1
 Q