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

ORWLR1.m

Go to the documentation of this file.
ORWLR1 ; slc/dcm -  VBEC Blood Bank Report ;01/16/03  15:02
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**172**;Dec 17, 1997
 ;Re-write of ^LR7OSBR
EN(DFN) ;Get Blood Bank Report
 Q:'$G(DFN)
 N GCNT,CCNT,GIOSL,GIOM,ORABORH,PATID,PATNAM,PATDOB,ORN
 S PATID="`"_DFN,PATNAM=$P(^DPT(DFN,0),"^"),PATDOB=$P(^(0),"^",3) ;Why PATNAM and PATDOB???
 K ^TMP("ORLRC",$J)
 S GCNT=0,CCNT=1,GIOSL=999999,GIOM=80
 S ORABORH=$$ABORH^VBECA1(PATID,PATNAM,PATDOB) ;Get ABO/RH
 S ORN(2.91)="DIRECT AHG TEST COMMENT",ORN(8)="ANTIBODY SCREEN COMMENT"
 S ORN(10.3)="ABO TESTING COMMENT",ORN(11.3)="RH TESTING COMMENT"
 D EN^ORWLR2
 Q
 ;
REPORT ;Blood Bank Report for M reports menu
 Q:'$G(DFN)
 N DIC,ID,ORDFN,ORY,PAGE,XQORNOD
 S ORDFN=DFN,ID=2
 D BLR^ORWRP1(.ORY,.ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDAYSBK,.REMOTE)
 Q:'$L(ORY)
 S PAGE=1
 D HEAD^ORWRPP1(ORDFN,PAGE,"PATIENT BLOOD BANK REPORT",$G(STATION))
 D HURL^ORWRPP1(.ORY,ORDFN,"PATIENT BLOOD BANK REPORT",,,1)
 Q
TEST ;Test calls
 N ORVP,PATID,PATNAM,PATDOB,LRDFN,ERR,ABORH,ID,ID1,ID2,ARR,GMI,DI2,BPN,VBECERR
 D EN2^ORUDPA
 Q:'ORVP
 K ^TMP("BBD",$J),^TMP("TRRX",$J),^TMP("TRAN",$J)
 S PATID="`"_+ORVP,PATNAM=ORPNM,PATDOB=$P(^DPT(+ORVP,0),"^",3)
 D PAT^VBECA1A W !,LRDFN I $O(VBECERR(0)) S ERR=0 F  S ERR=$O(VBECERR(ERR)) Q:'ERR  W !?5," ERR:"_VBECERR(1)
 S ABORH=$$ABORH^VBECA1(PATID,PATNAM,PATDOB) W !,"ABO/RH: "_ABORH
 D ABID^VBECA1(PATID,PATNAM,PATDOB,.PARENT,.ARR) I $O(ARR("ABID",0)) D
 . W !,"Antibodies Identified: " S ID=0 F  S ID=$O(ARR("ABID",ID)) Q:'ID  W !?2,ARR("ABID",ID)
 D TRRX^VBECA1(PATID,PATNAM,PATDOB,.PARENT,.ARR) I $O(ARR("TRRX",0)) D
 . W !,"Transfusion reactions: " S ID=0 F  S ID=$O(ARR("TRRX",ID)) Q:'ID  W !?2,ARR("TRRX",ID)
 D DFN^VBECA3A(DFN),CPRS^VBECA3B
 I $O(^TMP("BBD",$J,"CROSSMATCH",0)) D
 . W !,"Crossmatched Units: " S ID=0 F  S ID=$O(^TMP("BBD",$J,"CROSSMATCH",ID)) Q:'ID  W !?2,^(ID)
 I $O(^TMP("BBD",$J,"COMPONENT REQUEST",0)) D
 . W !,"Component request: " S ID=0 F  S ID=$O(^TMP("BBD",$J,"COMPONENT REQUEST",ID)) Q:'ID  W !?2,^(ID) D
 .. S ID1=0 F  S ID1=$O(^TMP("BBD",$J,"COMPONENT REQUEST",ID,ID1)) Q:'ID1  W !,"."_^(ID1)
 D TRAN^VBECA4(+ORVP,"TRAN")
 I $O(^TMP("TRAN",$J,0)) D
 . N ID,GMR,GMA
 . W !,"Transfused Units: ",! S ID=0
 . F  S ID=$O(^TMP("TRAN",$J,ID)) Q:'ID  S GMR=^(ID) D
 .. D PARSE,WRT
 . I $O(^TMP("TRAN",$J,"A"))'="" D
 .. W !
 .. W " Blood Product Key: "
 . S GMI="A" F  S GMI=$O(^TMP("TRAN",$J,GMI)) Q:GMI=""  D
 .. W ?21,GMI," = ",$G(^TMP("TRAN",$J,GMI)),!
 I $O(^TMP("BBD",$J,"SPECIMEN",0)) D
 . W !,"Specimen: " 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)
 K ^TMP("BBD",$J),^TMP("TRRX",$J),^TMP("TRAN",$J)
 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