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

DVBCREPT.m

Go to the documentation of this file.
DVBCREPT ;ALB/BG - CAPRI REPORT BUILDER RPC; SEP 7, 2022@16:20 ; 2/2/23 7:18am
 ;;2.7;AMIE;**226,227,243**;Apr 10, 1995;Build 13
 ;Per VHA Directive 6402 this routine should not be modified
 ;Reference to TGET^TIUSRVR1 supported with IA #1635
 ;Reference to LIST^ORQQCN supported with IA #1671
 ;Reference to CUM^OWRLR supported with IA #1687
 ;Reference to ORWRP REPORT TEXT supported with IA #1841
 ;Reference to ORQQPL PROBLEM LIST supported with IA #3365
 ;Reference to ORWORR AGET supported with IA #3366
 ;Reference to ORWORR GET4LST supported with IA #3367
 ;Reference to ORWLRR MICRO supported with IA #3368
 ;Reference to GETDLG^ORCD and GETORDER^ORCD supported with IA #5493
 ;Reference to DATA^PSS50 supported with IA #4533
 Q
 ;
REPORT(DVNEWRPT,DVBARRAY) ;
 N DVBI,DVBRPC,DVBARPC,DVBDATA,DVBRPT,DVBTAG,DVBRPCAL
 N DVRPT,DVBROU,DVNCT
 N DVBINST,DVBPL,DVBTITLE,DVBVSIT,DVBRPT2,DVA,DVB,DVBB,DVBCT,DVBLOG,DVBMSG,DVCLASS,DVBTXT,DVGRG,DVI
 K ^TMP("CAPRI REPORT",$J)
 S DVNCT=""
 S DVBI="" F  S DVBI=$O(DVBARRAY(DVBI)) Q:DVBI=""  D
 .N DVBRPC,DVBDATA,DVBARPC,DVBTAG,DVBAIEN,DVBN1,DVBN2,DVBN3,DVBN4
 .N DVBN5,DVBN6,DVBHOSP,DVBDIV,DVBRPT,DVBEDDT,DVBBGDT,DVBREP
 .S DVBRPC=$P(DVBARRAY(DVBI),U) S DVBARPC=$O(^XWB(8994,"B",DVBRPC,""))
 .S DVBDATA=$G(^XWB(8994,DVBARPC,0))
 .S DVBTAG=$P(DVBDATA,U,2),DVBROU=$P(DVBDATA,U,3)
 .S DVBAIEN=$P(DVBARRAY(DVBI),U,2),DVBN1=$P(DVBARRAY(DVBI),U,3)
 .S DVBN2=$P(DVBARRAY(DVBI),U,4),DVBN3=$P(DVBARRAY(DVBI),U,5)
 .S DVBN4=$P(DVBARRAY(DVBI),U,6),DVBN5=$P(DVBARRAY(DVBI),U,7),DVBN6=$P(DVBARRAY(DVBI),U,8)
 .I (DVBRPC["ORWRP")&($P(DVBARRAY(DVBI),U,3)'=11)&($P(DVBARRAY(DVBI),U,3)'=20)&($P(DVBARRAY(DVBI),U,3)'=5) D DVBMOST Q
 .I (DVBRPC["ORWRP")&($P(DVBARRAY(DVBI),U,3)=11) D DVBORSUM Q
 .I (DVBRPC["CUMU")!($P(DVBARRAY(DVBI),U,3)=20) D DVBLABCM Q
 .I (DVBRPC["ORWRP")&($P(DVBARRAY(DVBI),U,3)=5) D DVBVITAL Q
 .I DVBRPC["MICRO" D DVBMICRO
 .I DVBRPC["ORWORR" D DVBMED Q
 .I (DVBRPC["ORQQCN")!(DVBRPC["TIU") D DVBTGET Q
 .I DVBRPC["ORQQPL" D DVBPROBL Q
 S DVNEWRPT=$NA(^TMP("CAPRI REPORT",$J))
 K ORDIALOG
 Q
 S DVNCT=DVNCT+1 S ^TMP("CAPRI REPORT",$J,DVNCT)=$$REPEAT^XLFSTR("*",2)_DVBTITLE_$$REPEAT^XLFSTR("*",70)
 Q
MIDDLE ;
 S DVNCT=DVNCT+1 S ^TMP("CAPRI REPORT",$J,DVNCT)=$$REPEAT^XLFSTR("-",85)
 Q
END ;
 S DVNCT=DVNCT+1 S ^TMP("CAPRI REPORT",$J,DVNCT)=$$REPEAT^XLFSTR(" ",2)
 Q
DVBPROBL ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_")"
 D @DVBRPCAL
 S DVBTITLE="PROBLEM LIST" D HEADER D END D MIDDLE
 I $G(DVBRPT(0))=0 S DVBRPT2="No Problems Found" D
 .M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBRPT2
 I $G(DVBRPT(0))'=0 S DVBPL=0 F  S DVBPL=$O(DVBRPT(DVBPL)) Q:DVBPL=""  D
 .S DVBRPT2=$P(DVBRPT(DVBPL),U,2)_" "_$P(DVBRPT(DVBPL),U,3)_" "_$P($P(DVBRPT(DVBPL),U,12),";",2)_" "_"Onset:"_$$FMTE^XLFDT($P(DVBRPT(DVBPL),U,5))
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBRPT2
 D END
 Q
DVBORSUM ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_","_"DVBN2"_","_"DVBN3"_","_")"
 D @DVBRPCAL
 S DVBTITLE="ORDER SUMMARY" D HEADER D END D MIDDLE
 I '$D(@DVBRPT) S DVBRPT="No Orders Found" D  Q
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBRPT
 .D END
 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=@DVBRPT
 D END
 Q
DVBMICRO ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_","_"DVBN2"_")"
 D @DVBRPCAL
 M DVBREP=@DVBRPT
 S DVBTITLE="LAB" D HEADER D END D MIDDLE
 I $G(DVBREP(2))["No Data" S DVBREP(2)="No data found in the date range specified..." D  Q
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP D END Q
 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 D END
 Q
DVBLABCM ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_","_"DVBN2"_","_"DVBN3"_")"
 D @DVBRPCAL
 M DVBREP=@DVBRPT
 S DVBTITLE="LAB"
 D HEADER D END D MIDDLE
 I $G(DVBREP(2))["No Data" S DVBREP="No data found in the date range specified..."  D  Q
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 I $G(DVBREP(.001))["[HIDDEN" S DVBCT=$P(DVBREP(.001),U,2)  D
 .S DVB=.001 F DVI=1:1:DVBCT K DVBREP(DVB) S DVB=DVB+.001
 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 D END
 Q
DVBTGET ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,DVBAIEN)"
 D @DVBRPCAL
 M DVBREP=@DVBRPT
 I DVBRPC["ORQQCN" S DVBTITLE="CONSULTS"  D  Q
 .D HEADER D END D MIDDLE S DVNCT=DVNCT+1
 .M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP D END
 I $D(DVBREP) S DVBHOSP=$$GET1^DIQ(8925,DVBAIEN,1205,"I")
 I $G(DVBHOSP)="" S DVBVSIT=$$GET1^DIQ(8925,DVBAIEN,.03,"I") S DVBHOSP=$$GET1^DIQ(9000010,$G(DVBVSIT),.22,"I")
 S DVBBGDT=$$GET1^DIQ(8925,DVBAIEN,.07,"E"),DVBEDDT=$$GET1^DIQ(8925,DVBAIEN,.08,"E")
 S DVBINST=$$GET1^DIQ(44,$G(DVBHOSP),3),DVBDIV=$$GET1^DIQ(44,$G(DVBHOSP),3.5)
 I $P(DVBARRAY(DVBI),U,3)="PN"  D
 .S DVBTITLE="PROGRESS NOTES"
 .S DVBREP(4,1)=" INSTITUTION: "_DVBINST
 .S DVBREP(4,2)="    DIVISION: "_DVBDIV
 I $P(DVBARRAY(DVBI),U,3)="DS"  D
 .S DVBTITLE="DISCHARGE SUMMARIES"
 .S DVBREP(4,1)="EPISODE BEGIN DATE/TIME: "_DVBBGDT
 .S DVBREP(4,2)="EPISODE END DATE/TIME:  "_DVBEDDT
 .S DVBREP(4,3)=" INSTITUTION:     "_DVBINST
 .S DVBREP(4,4)="    DIVISION:   "_DVBDIV
 D HEADER D MIDDLE D END
 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 D END
 Q
DVBNUTR ;
 S DVBTITLE="NUTRITIONAL ASSESSMENTS"
 D HEADER D END D MIDDLE
 I '$D(DVBREP) D
 .S DVBREP="No Nutritional Assessments Found"
 .M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 I $D(DVBREP) D
 .S DVBXX="" F  S DVBXX=$O(DVBREP(DVBXX)) Q:DVBXX=""  D
 ..S DVBX="" F  S DVBX=$O(DVBREP(DVBXX,"WP",3,1,DVBX)) Q:DVBX=""  D
 ...S DVCT="",DVCT=DVCT+1 S DVARR(DVCT)=$P(DVBREP(DVBXX,"WP",3,1,DVBX),U,2)
 ...S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVARR
 D END
 Q
DVBVITAL ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_","_"DVBN2"_","_"DVBN3"_","_"DVBN4"_","_"DVBN5"_","_"DVBN6"_")"
 D @DVBRPCAL
 M DVBREP=@DVBRPT
 S DVBTITLE="VITAL SIGNS"
 S DVBMSG="No cumulative vitals data for this patient within the selected date range"
 D HEADER D END D MIDDLE
 I '$D(DVBREP)  D  Q
 .S DVBREP=DVBMSG
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 .D END
 I $D(DVBREP)  D  Q
 .S DVBXX="" F  S DVBXX=$O(DVBREP(DVBXX)) Q:DVBXX=""  D
 ..I DVBREP(DVBXX)["***" S DVBREP(DVBXX)=""
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 D END
 Q
DVBMOST ;
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_","_"DVBN2"_","_"DVBN3"_","_"DVBN4"_","_"DVBN5"_","_"DVBN6"_")"
 D @DVBRPCAL
 M DVBREP=@DVBRPT
 I $P(DVBARRAY(DVBI),U,3)[13 S DVBTITLE="MEDICATIONS"
 ;I $P(DVBARRAY(DVBI),U,3)=5 S DVBTITLE="VITAL SIGNS",DVBMSG="No cumulative vitals data for this patient within the selected date range"
 I $P(DVBARRAY(DVBI),U,3)[17 D DVBNUTR Q
 I ($P(DVBARRAY(DVBI),U,3)[13)!($P(DVBARRAY(DVBI),U,3)[22) S DVBMSG="There is no data for the requested search criteria."
 I $P(DVBARRAY(DVBI),U,3)=18 S DVBTITLE="IMAGING",DVBMSG="No Images available"
 I $P(DVBARRAY(DVBI),U,3)=4 S DVBTITLE="DIETS",DVBMSG="No data available"
 I $P(DVBARRAY(DVBI),U,3)=19 S DVBTITLE="PROCEDURES",DVBMSG="No data available"
 I $P(DVBARRAY(DVBI),U,3)[22 S DVBTITLE="MED ADMIN HISTORY"
 I $P(DVBARRAY(DVBI),U,3)=20 S DVBTITLE="LAB"
 I $P(DVBARRAY(DVBI),U,3)=1093 S DVBTITLE="LAB"
 I $P(DVBARRAY(DVBI),U,3)=2 S DVBTITLE="LAB"
 D HEADER D END D MIDDLE
 I '$D(DVBREP)  D  Q
 .S DVBREP=DVBMSG
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 .D END
 I $D(DVBREP)  D  Q
 .S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 .D END
 Q
DVBMED ;
 N DVBX,DVCT,DVARR,DVBRT,DVBPROV,DVCLASS,DVBSTOP
 N DVBSTRT,DVBREP1,DVBREP2,DVDRG,DVBXX
 S DVBN1=$P(DVBARRAY(DVBI),U,3)_"^"_$P(DVBARRAY(DVBI),U,4)
 S DVBRPCAL=DVBTAG_"^"_DVBROU_"(.DVBRPT,"_"DVBAIEN"_","_"DVBN1"_","_"DVBN3"_","_"DVBN4"_","_"DVBN5"_")"
 D @DVBRPCAL
 S DVNCT=DVNCT+1,DVCT=0
 M DVBREP=@DVBRPT
 S DVBTITLE="MEDICATIONS"
 D HEADER D END D MIDDLE
 I $P(DVBREP(.1),U)=0 D  Q
 .S DVBREP="There is no data for the requested search criteria."
 .K DVBREP(.1) S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP
 .D END
 I $P(DVBREP(.1),U)'=0 D  Q
 .S DVBX="" F  S DVBX=$O(DVBREP(DVBX)) Q:DVBX=""  D
 ..S DVCT=DVCT+1 S DVARR(DVCT)=$P(DVBREP(DVBX),U)
 .D GET4V11^ORWORR(.DVBRT,DVBAIEN,-1,.DVARR)
 .S DVBXX="" F  S DVBXX=$O(DVBRT(DVBXX)) Q:DVBXX=""  D
 ..I DVBRT(DVBXX)["~",$P(DVBRT(DVBXX),U,2)="" Q
 ..I DVBRT(DVBXX)["~"  D PROV
 ..I (DVBN3=4),(DVBRT(DVBXX)["~")  D DRUG(.DVBREP2)
 ..I DVBRT(DVBXX)["t"  D TPRINT
 .D END
 Q
PROV ;
 S DVBPROV=$P(DVBRT(DVBXX),U,11)
 S DVBSTRT=$$FMTE^XLFDT($P(DVBRT(DVBXX),U,4))
 S DVBSTOP=$$FMTE^XLFDT($P(DVBRT(DVBXX),U,5))
 I DVBN3=4 S DVGRG=$P($P(DVBRT(DVBXX),";",1),"~",2)
 S DVBREP1="Provider: "_DVBPROV_"  START DATE: "_DVBSTRT_"  STOP DATE:  "_DVBSTOP
 D END
 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP1
 Q
TPRINT ;
 S DVNCT=DVNCT+1
 I DVBRT(DVBXX)["tQ" D
 .I ($G(DVBRT(DVBXX+1))["~")!($G(DVBRT(DVBXX+1))="") D
 ..I DVBN3=4 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP2
 I DVBRT(DVBXX)["t<" D
 .I DVBN3=4 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP2
 I DVBRT(DVBXX)["t" D
 .S DVBTXT=$E(DVBRT(DVBXX),2,99) S DVBREP1=DVBTXT
 .M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP1
 .I ($G(DVBRT(DVBXX+1))["~")!($G(DVBRT(DVBXX+1))="") D
 ..I DVBN3=4 S DVNCT=DVNCT+1 M ^TMP("CAPRI REPORT",$J,DVNCT)=DVBREP2
 Q
DRUG(DVBREP2) ;
 I DVGRG="" Q
 S DVBB=$G(^OR(100,+DVGRG,0)) S DVBLOG=+$P(DVBB,U,5)
 D GETDLG^ORCD(DVBLOG)
 D GETORDER^ORCD(+DVGRG)
 S DVA=$P($G(ORDIALOG("B","DISPENSE DRUG")),"^",2)
 I DVA="" S DVBREP2="VA DRUG CLASS-NOT AVAILABLE" Q
 S DVDRG=$G(ORDIALOG(DVA,1))
 I DVDRG="" S DVBREP2="VA DRUG CLASS-NOT AVAILABLE" Q 
 D DATA^PSS50(DVDRG,,,,,"DVRPT")
 I $P($G(^TMP($J,"DVRPT",0)),U,1)="-1" S DVBREP2="VA DRUG CLASS-NOT AVAILABLE" Q
 S DVCLASS=$G(^TMP($J,"DVRPT",DVDRG,2))
 S DVBREP2="VA DRUG CLASS-"_DVCLASS_"  "_$P($G(^TMP($J,"DVRPT",DVDRG,25)),U,3)
 Q