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

PXRMCALT.m

Go to the documentation of this file.
PXRMCALT ;SLC/AGP - Check for Active SMART Alert ;May 03, 2021@13:48:17
 ;;2.0;CLINICAL REMINDERS;**45,75,71**;Feb 04, 2005;Build 43
 ;
 ;
 ;SACC EXEMPTIONS SECTION
 ;2.3.1.10.1 and 2.3.1.10.2
 ;
 ;DBIA   USED
 ;2265   EN3^RAO7PC1
 ;2630   ^RADPT
 ;871    EN^ORX8
 ;7245   GETDATA^ORWORB
 ;6824   WV(790.1
 ;2479   File 74 FileMan read
 ;7246   RADCASE^WVALERTR,RADREP^WVALERTR
 ;6341   SMALERTS^ORBSMART
 ;
ALT80(ALTID,PXRMARYD,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
 N CNT,DAS,I,ORUPCHUK
 I $P(PXRMARYD,":")'="OR" Q
 S DAS=$P(PXRMARYD,":",2) I +DAS=0 Q
 S NFOUND=NFOUND+1
 S DATA(NFOUND,"DIALOG")=1
 S DATA(NFOUND,"PACKAGE")="ORDER ENTRY/RESULTS REPORTING"
 S DATA(NFOUND,"PACKAGE PREFIX")="OR"
 S DATA(NFOUND,"DAS")=DAS
 S DATA(NFOUND,"ACTIVE ALERT ID")=ALTID
 S DATA(NFOUND,"STATUS")="OPEN"
 S DATE(NFOUND)=DT
 S TEST(NFOUND)=1
 D EN^ORX8(DAS)
 S (CNT,I)=0 F  S I=$O(ORUPCHUK("ORTX",I)) Q:I'>0  D
 .S CNT=CNT+1,TEXT(NFOUND,CNT)="<br>"_ORUPCHUK("ORTX",I)
 ;
 I +$G(ORUPCHUK("ORSTRT"))>0 S CNT=CNT+1,TEXT(NFOUND,CNT)="<br>Start Date: "_$$FMTE^XLFDT(ORUPCHUK("ORSTRT"))
 I $P($G(ORUPCHUK("ORPV")),U,2)'="" S TEXT(NFOUND,CNT)="<br>Provider: "_$P($G(ORUPCHUK("ORPV")),U,2)
 Q
 ;
ALT83(ALTID,PXRMARYD,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
 N ACCESS,DCNT,INC,NODE,PUR,PURIEN,PXRMDIAG,WNIEN,WVIEN
 S NFOUND=NFOUND+1
 S TEST(NFOUND)=1
 S DATE(NFOUND)=DT
 I $G(ALTID)'="" S DATA(NFOUND,"ACTIVE ALERT ID")=ALTID
 Q
 ;
ALT85(ALTID,PXRMARYD,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
 N CASE,DTE,ERR,INC,ISFALT,LIST,NODE,PROCNAME,REPIEN,RESULT,SEX,TEMPCASE,WVIEN,X,Y
 N DIAGNS,WVIENS,WVRPTIEN,WVSECDXS
 S CASE="",WVIEN=0,ISFALT=0
 I ALTID'="",$G(PXRMARYD)'="" D
 .S DTE=$P($P($G(^RADPT(DFN,"DT",$P(PXRMARYD,"~"),0)),U),".") I DTE="" S DATA("RADIOLOGY REPORT FOUND")=0 Q
 .I '$D(^RADPT(DFN,"DT",$P(PXRMARYD,"~"),"P",$P(PXRMARYD,"~",2),0)) S DATA("RADIOLOGY REPORT FOUND")=0 Q
 .S CASE=$E(DTE,4,7)_$E(DTE,2,3)_"-"_$P($G(^RADPT(DFN,"DT",$P(PXRMARYD,"~"),"P",$P(PXRMARYD,"~",2),0)),U)
 .I CASE="" S DATA("RADIOLOGY REPORT FOUND")=0 Q
 .;AGP TODO LOOK at if I have a case # but no report uncomment out the next line
 .I +$P($G(^RADPT(DFN,"DT",$P(PXRMARYD,"~"),"P",$P(PXRMARYD,"~",2),0)),U,17)=0 S DATA("RADIOLOGY REPORT FOUND")=0 Q
 .S WVIEN=+$O(^WV(790.1,"E",CASE,"")) I WVIEN=0  D
 ..S REPIEN=$$FIND1^DIC(74,"","X",CASE,"","","ERR") I REPIEN=0 Q
 ..D LIST^DIC(74.05,","_REPIEN_",","","","","","","","","","LIST","ERR")
 ..S X=0 F  S X=$O(LIST("DILIST",1,X)) Q:X'>0!(WVIEN>0)  D
 ...S TEMPCASE=$G(LIST("DILIST",1,X)) I TEMPCASE="" Q
 ...S WVIEN=+$O(^WV(790.1,"E",TEMPCASE,""))
 .I WVIEN>0 S ISFALT=1
 I $G(DATA("RADIOLOGY REPORT FOUND"))=0 Q
 S SEX=$P(^DPT(DFN,0),U,2)
 I SEX="F" D
 .K DIAGNS,WVIENS,WVRPTIEN,WVSECDXS
 .I WVIEN>0 D
 ..S DATA("RADIOLOGY REPORT FOUND")=1
 ..D RADCASE^WVALERTR(WVIEN,.DIAGNS,.WVIENS,.WVRPTIEN,.WVSECDXS)
 ..I +$G(WVRPTIEN)=0 S DATA("RADIOLOGY REPORT FOUND")=0
 .I $G(DATA("RADIOLOGY REPORT FOUND"))=0 Q
 .I WVIEN>0 S NFOUND=NFOUND+1 D PROCDURE^PXRMCWH(ALTID,PXRMARYD,WVIEN,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)
 .;S DATA("RADIOLOGY REPORT FOUND")=1
 I SEX="M" D
 .D MALE(DFN,PXRMARYD,CASE,ALTID,.NFOUND,.DATE,.DATA,.TEXT)
 .;I '$D(DATA) S DATA("RADIOLOGY REPORT FOUND")=0 Q
 .S DATA(NFOUND,"RADIOLOGY REPORT FOUND")=1
 I $D(DATA),$G(ALTID)'="" S DATA(NFOUND,"ACTIVE ALERT ID")=ALTID
 Q
 ;
MALE(DFN,PXRMARYD,CASE,ALTID,NFOUND,DATE,DATA,TEXT) ;
 N ERR,I,RPTIEN,RPTCASE
 S RPTIEN=+$P($G(^RADPT(DFN,"DT",$P(PXRMARYD,"~"),"P",$P(PXRMARYD,"~",2),0)),U,17)
 I RPTIEN=0 S DATA("RADIOLOGY REPORT FOUND")=0 Q
 S RPTCASE=$P(PXRMARYD,"~",2)_","_$P(PXRMARYD,"~")_","_DFN_","
 ;S DATA(1,"RADIOLOGY REPORT FOUND")=0
 I RPTIEN>0 D
 .K ^TMP("WV RPT",$J)
 .D RADREP^WVALERTR(RPTCASE,RPTIEN)
 .S DATA(1,"RADIOLOGY REPORT FOUND")=1
 S NFOUND=1,DATE(1)=9999999-$P(PXRMARYD,"~")
 I $G(CASE)'="" S DATA(1,"CASE")=CASE,TEST(1)=1
 S DATA(1,"PATIENT SEX")=SEX
 S DATA(1,"ACTIVE ALERT ID")=ALTID
 S DATA(1,"ACTIVE ALERT DATA")=PXRMARYD
 S DATA(1,"DIALOG")=1
 S DATA(1,"PACKAGE")="ORDER ENTRY/RESULTS REPORTING"
 S DATA(1,"PACKAGE PREFIX")="OR"
 S DATA(1,"DAS")=ALTID
 S DATA(1,"NOTIFICATION NUMBER")=+$P(ALTID,",",3)
 I RPTIEN=0 D  Q
 .S TEXT(1,1)="Radiology Report text not found in the radiology package. Please review the Imaging report on the Reports Tab."
 S I=0 F  S I=$O(^TMP("WV RPT",$J,I)) Q:I'>0  D
 .S TEXT(1,I)=^TMP("WV RPT",$J,I,0)
 .I TEXT(1,I)["PRIMARY DIAGNOSIS:" S DATA(1,"DIAGNOSIS")=$P(TEXT(1,I),"PRIMARY DIAGNOSIS: ",2)
 ;K ^TMP($J,"WV RPT"),^TMP($J,"WV CH")
 K ^TMP("WV RPT",$J)
 Q
 ;
GETALT(ALTID,PXRMARYD) ;
 S ALTID=$G(^TMP("ORSMART CURRENT ALERT",$J))
 I ALTID'="" D GETDATA^ORWORB(.PXRMARYD,ALTID)
 Q
 ;
ACTALRTD(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
 N ADDVALUE,ALTID,PXRMARYD,REQALT
 S NFOUND=0,REQALT=TEST
 I REQALT="ALL" S REQALT="84;85"
 D GETALT(.ALTID,.PXRMARYD)
 I $G(PXRMARYD)="" D  Q
 .S TEXT(1,1)="Radiology Report text not found in the radiology package. Please review the Imaging report on the Reports Tab."
 .S DATA("RADIOLOGY REPORT FOUND")=0
 ;I +$P(ALTID,",",3)=80,REQALT[80 D ALT80(ALTID,PXRMARYD,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT) Q
 ;I +$P(ALTID,",",3)=83,REQALT[83 D ALT83(ALTID,PXRMARYD,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT) Q
 I +$P(ALTID,",",3)=84,REQALT[84 D ALT85(ALTID,PXRMARYD,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT) Q
 I +$P(ALTID,",",3)=85,REQALT[85 D ALT85(ALTID,PXRMARYD,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT) Q
 Q
 ;
ACTALERT(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
 N ALTID,PXRMALTD
 S NFOUND=0,REQALT=TEST
 D GETALT(.ALTID,.PXRMALTD)
 I REQALT'="",REQALT'[+$P(ALTID,",",3) Q
 I ALTID="" Q
 S NFOUND=NFOUND+1
 S TEST(NFOUND)=1
 S DATE(NFOUND)=DT
 S DATA(NFOUND,"ACTIVE ALERT ID")=ALTID
 I PXRMALTD'="" S DATA(NFOUND,"ACTIVE ALERT DATA")=PXRMALTD
 S DATA(NFOUND,"DIALOG")=1
 S DATA(NFOUND,"PACKAGE")="ORDER ENTRY/RESULTS REPORTING"
 S DATA(NFOUND,"PACKAGE PREFIX")="OR"
 S DATA(NFOUND,"DAS")=ALTID
 S DATA(NFOUND,"NOTIFICATION NUMBER")=+$P(ALTID,",",3)
 Q
 ;
 ;===============================================
ALERT(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;Computed finding for active
 ;SMART alerts
 N ID,IDS,IND,PIECES,PXRMALRT,OD,TDATE,TDATA,TTEST,X,XQAID
 S IDS=TEST
 I +$G(NFOUND)=0 S NFOUND=0
 S PIECES=$L(TEST,":")
 D SMALERTS^ORBSMART(DFN,DUZ,"PXRMALRT")
 F X=1:1:PIECES D
 .S ID=$P(IDS,":",X)
 .I '$D(PXRMALRT(ID)) Q
 .S XQAID="" F  S XQAID=$O(PXRMALRT(ID,XQAID)) Q:XQAID=""  D
 ..S NFOUND=NFOUND+1,TDATA(NFOUND,"XQAID")=XQAID,TDATE(NFOUND)=$P(PXRMALRT(ID,XQAID,"DATE"),U),TTEST(NFOUND)=1
 ..S TDATA(NFOUND,"SOURCE")=PXRMALRT(ID,XQAID,"DATA")
 ;
 N DATE1,CNT1,JND,TCNT
 F IND=1:1:NFOUND S OD(TDATE(IND),IND)=""
 S CNT1=0,IND=""
 F  S IND=$O(OD(IND),-1) Q:IND=""  D
 . S JND=0
 . F  S JND=$O(OD(IND,JND)) Q:JND=""  D
 .. S CNT1=CNT1+1
 .. S DATE(CNT1)=IND
 .. S TEST(CNT1)=TTEST(JND)
 .. M DATA(CNT1)=TDATA(JND)
 Q
 ;
MAMALERT(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;Computed finding for active
 ;SMART mammogram alerts
 N CODE,I,RADDIAG,RADID,RADTXT,X,Y
 D ALERT(DFN,.NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)
 I +$G(NFOUND)=0 Q
 I $G(TEST(1))=0 Q
 F I=1:1:NFOUND D
 .S RADID=$P(DATA(I,"SOURCE"),"~")
 .D WH(.DATA,.TEXT,I) Q
 .D REPORT(DFN,RADID,.RADTXT,.RADDIAG)
 .M TEXT(I)=RADTXT
 .S X=0,CODE="" F  S CODE=$O(RADDIAG(CODE)) Q:CODE=""  D
 ..S X=X+1,DATA(I,"DIAGNOSIS",X)=CODE
 .S DATA(I,"DAS")=DFN_";"_RADID
 .S DATA(I,"DIALOG")=1
 .S DATA(I,"PACKAGE")="PCE PATIENT CARE ENCOUNTER"
 .S DATA(I,"PACKAGE PREFIX")="PX"
 Q
 ;
REPORT(DFN,RADID,RADTXT,RADDIAG) ;
 K ^TMP($J,"RAE2")
 N CNT,CODE,NAME,X,Y
 D EN3^RAO7PC1(DFN_U_RADID)
 S CNT=0
 S NAME=^TMP($J,"RAE2",DFN,"ORD",1)
 S CNT=CNT+1,RADTXT(CNT)="Image Report\\"
 S CNT=CNT+1,RADTXT(CNT)="Order: "_^TMP($J,"RAE2",DFN,"ORD",1)_"\\"
 S CNT=CNT+1,RADTXT(CNT)="Report Status: "_$P($G(^TMP($J,"RAE2",DFN,1,NAME)),U)_"\\"
 S CNT=CNT+1,RADTXT(CNT)="Verifing Provider: "_$P($G(^TMP($J,"RAE2",DFN,1,NAME,"V")),U,2)_"\\"
 S CNT=CNT+1,RADTXT(CNT)="Report Text:\\"
 S X=0 F  S X=$O(^TMP($J,"RAE2",DFN,1,NAME,"R",X)) Q:X'>0  D
 .S CNT=CNT+1,RADTXT(CNT)=$G(^TMP($J,"RAE2",DFN,1,NAME,"R",X))_"\\"
 S CNT=CNT+1,RADTXT(CNT)="Impression Text:\\"
 S X=0 F  S X=$O(^TMP($J,"RAE2",DFN,1,NAME,"I",X)) Q:X'>0  D
 .S CNT=CNT+1,RADTXT(CNT)=$G(^TMP($J,"RAE2",DFN,1,NAME,"I",X))_"\\"
 S CNT=CNT+1,RADTXT(CNT)="DX Codes:\\"
 S X=0 F  S X=$O(^TMP($J,"RAE2",DFN,1,NAME,"D",X)) Q:X'>0  D
 .S CODE=$G(^TMP($J,"RAE2",DFN,1,NAME,"D",X))
 .S CNT=CNT+1,RADTXT(CNT)=CODE
 .S RADDIAG(CODE)=""
 K ^TMP($J,"RAE2")
 Q
 ;
WH(DATA,TEXT,I) ;
 N DATE,CASE,ID,NAME,NODE,PROCIEN,PXRMDIAG,SOURCE,WVIEN,WVNIEN,X,Y
 S DATA(I,"DIALOG")=1
 S DATA(I,"PACKAGE")="WOMEN'S HEALTH"
 S DATA(I,"PACKAGE PREFIX")="WV"
 S SOURCE=DATA(I,"SOURCE")
 S DATE=$P($P($G(^RADPT(DFN,"DT",$P(SOURCE,"~"),0)),U),".") I DATE="" Q
 I '$D(^RADPT(DFN,"DT",$P(SOURCE,"~"),"P",$P(SOURCE,"~",2),0)) Q
 S CASE=$E(DATE,4,7)_$E(DATE,2,3)_"-"_$P($G(^RADPT(DFN,"DT",$P(SOURCE,"~"),"P",$P(SOURCE,"~",2),0)),U)
 S PROCIEN=$O(^WV(790.1,"E",CASE,"")) I PROCIEN'>0 Q
 S WVIEN=PROCIEN
 D GETTEST^PXRMCWH(WVIEN,I,0,.TEXT,.PXRMDIAG)
 ;K ^TMP("WV RPT",$J)
 ;D EN^WVALERTR(WVIEN,.PXRMDIAG)
 S DATA(I,"DIAGNOSIS",1)=PXRMDIAG
 ;S Y=0 F  S Y=$O(^TMP("WV RPT",$J,Y)) Q:Y'>0  S TEXT(I,Y)=$G(^TMP("WV RPT",$J,Y,0))
 ;K ^TMP("WV RPT",$J)
 S NODE=^WV(790.1,WVIEN,0)
 S DATA(I,"DAS")=WVIEN_","
 S DATA(I,"ACCESSION")=$P(NODE,U)
 S X=$P(NODE,U,5) I X>0 D
 .S NAME=$P($G(^WV(790.31,X,0)),U) S DATA(I,"BI-RAD")=NAME
 S WVNIEN=$O(^WV(790.4,"C",$P(NODE,U),"")) I WVNIEN'>0 Q
 S NODE=$G(^WV(790.4,WVNIEN,0))
 S X=$P(NODE,U,4) I X>0 D
 .S NAME=$P($G(^WV(790.404,X,0)),U) S DATA(I,"PURPOSE OF NOTIFICATION")=NAME
 S X=$P(NODE,U,3) I X>0 D
 .S NAME=$P($G(^WV(790.403,X,0)),U) S DATA(I,"TYPE OF NOTIFICATION")=NAME
 Q
 ;
ALTOBJ(DFN) ;
 ; TIU object that returns procedure information for
 ; inclusion in the text of a SMART alert
 ;
 N PXRMDATA,PXRMDATE,PXRMFOUND,PXRMI,PXRML,PXRMLINE,PXRMRETURN,PXRMTEXT,PXRMX
 ;
 K ^TMP("PXRMCALTOBJ",$J)
 S PXRMRETURN=$NA(^TMP("PXRMCALTOBJ",$J))
 K @PXRMRETURN
 S PXRMLINE=0
 ;
 I $G(^TMP("ORSMART CURRENT ALERT",$J))="" D  Q "~@"_PXRMRETURN
 . S PXRMLINE=PXRMLINE+1
 . S @PXRMRETURN@(PXRMLINE,0)="This object can only be used in the text of a SMART alert." Q
 ;
 D ACTALRTD(DFN,1,"","",.PXRMFOUND,"ALL",.PXRMDATE,.PXRMDATA,.PXRMTEXT)
 ;
 S PXRMI=0
 F  S PXRMI=$O(PXRMTEXT(1,PXRMI)) Q:'PXRMI  D
 . S PXRMLINE=PXRMLINE+1
 . S PXRMX=$G(PXRMTEXT(1,PXRMI))
 . S PXRML=$L(PXRMX)
 . I PXRML>1,$E(PXRMX,PXRML-1,PXRML)="\\" S PXRMX=$E(PXRMX,1,PXRML-2)
 . S @PXRMRETURN@(PXRMLINE,0)=PXRMX
 ;
 I PXRMLINE=0 D
 . S PXRMLINE=PXRMLINE+1
 . S @PXRMRETURN@(PXRMLINE,0)="The procedure text is not available."
 ;
 Q "~@"_PXRMRETURN
 ;
ALTDATA(RESULT,DFN,ALTID) ;
 N BDT,DATA,DATE,EDT,NFOUND,PXRMDARY,TEST,TEXT
 S BDT=0,EDT=DT,NFOUND=0
 D GETDATA^ORWORB(.PXRMARYD,ALTID)
 I +$P(ALTID,",",3)=84 D ALT85(ALTID,PXRMARYD,1,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)
 I +$P(ALTID,",",3)=85 D ALT85(ALTID,PXRMARYD,1,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)
 M RESULT("DATA")=DATA
 M RESULT("TEXT")=TEXT
 Q
 ;