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

RAHLO.m

Go to the documentation of this file.
  1. RAHLO ;HIRMFO/GJC - Process data set from the bridge program ; Aug 15, 2024@11:49:39
  1. ;;5.0;Radiology/Nuclear Medicine;**4,8,27,55,66,84,94,106,144,162,165,218**;Mar 16, 1998;Build 1
  1. ; 09/07/2005 Remedy call 108405 - KAM Allow Radiology to accept dx codes from Talk Technology
  1. ;
  1. ;Integration Agreements
  1. ;----------------------
  1. ;DT^DILF(2054); LOCK^DILF(2054); DEM^VADPT(10061); $$DT^XLFDT(10103)
  1. ;
  1. EN1 ; Check the validity of the following data globals:
  1. ; Example: '^TMP("RARPT-REC",$J,RASUB,' where RASUB is a
  1. ; record in file 772.
  1. ;**************** Validates (if data present): ************************
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RACNI")=Case IEN
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RADATE")=Date reported/entered/verified
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RADFN")=Patient IEN
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RADTI")=Inverted Exam Date/Time
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RADX",#)=Dx codes (could be more than 1)
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RAESIG")=Verifier's E-Sig (if present)
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RAHIST")=Additional Clinical History
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RAIMP",#)=Impression Text
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RALONGCN")=Long Case Number
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RASSN")=Patient SSN
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RASTAT")=A, C, F or R
  1. ; Note: we use 'F' for final and 'P' for preliminary as RESULT
  1. ; STATUS values for both the v2.3 & v2.4 HL7 interfaces.
  1. ; BUT: we use 'C' ('corrected') for the v2.4 interface &
  1. ; 'A' ('amended') for the v2.3 interface.
  1. ;
  1. ; Note: VAQ - added w/P106 study released back to VAMC
  1. ; for interpretation
  1. ;
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RATXT",#)=Report Text
  1. ; ^TMP("RARPT-REC",$J,RASUB,"VENDOR")=vendor
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RAVERF")=Verifier ien
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RATRANSCRIPT")=transcriptionist (optional)
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RASTAFF")=Primary staff
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RARESIDENT")=Primary resident
  1. ; ^TMP("RARPT-REC",$J,RASUB,"RAWHOCHANGE")=Who changed status to Verify
  1. ;**********************************************************************
  1. K RAERR S RAQUIET=1
  1. ; Check if the minimum data set exists.
  1. I '$D(^TMP("RARPT-REC",$J,RASUB,"RACNI")) S RAERR="Missing Case Number" Q
  1. I '$D(^TMP("RARPT-REC",$J,RASUB,"RADFN")) S RAERR="Internal Patient ID Missing" Q
  1. I '$D(^TMP("RARPT-REC",$J,RASUB,"RADTI")) S RAERR="Missing Exam Date" Q
  1. I '$D(^TMP("RARPT-REC",$J,RASUB,"RALONGCN")) S RAERR="Missing Exam Date and/or Case Number" Q
  1. I '$D(^TMP("RARPT-REC",$J,RASUB,"RASSN")) S RAERR="Missing Patient ID" Q
  1. D CHECK ; check the validity of our data.
  1. XIT ; Kill and quit
  1. K A,B,DFN,K,RACNI,RADX,RADENDUM,RADFN,RADTI,RADUZ,RAIMGTY,RALONGCN,RAMDIV,RAMDV,RAMLC
  1. K RAQUIET,RARPT,RARPTSTS,RASSN,RAVLDT,X,Y,Z,RATRANSC,RAERRCHK,RAOR,RAPURGE,RARPTI,RASIUID
  1. K RASN,RASSNVAL,RAST32,RASTAT,RASTI,RAZDAYCS,RAZDTE,RAZORD,RAZORD1,RAZPROC,RAZRXAM,RAZXAM
  1. Q
  1. CHECK ; Check if our data is valid.
  1. S RACNI=$G(^TMP("RARPT-REC",$J,RASUB,"RACNI"))
  1. S RADATE=$G(^TMP("RARPT-REC",$J,RASUB,"RADATE"))
  1. S RADFN=$G(^TMP("RARPT-REC",$J,RASUB,"RADFN"))
  1. S RADTI=$G(^TMP("RARPT-REC",$J,RASUB,"RADTI"))
  1. S RALONGCN=$G(^TMP("RARPT-REC",$J,RASUB,"RALONGCN"))
  1. S RASSN=$G(^TMP("RARPT-REC",$J,RASUB,"RASSN"))
  1. S (RAVERF,RADUZ)=$G(^TMP("RARPT-REC",$J,RASUB,"RAVERF"))
  1. S RATRANSC=$G(^TMP("RARPT-REC",$J,RASUB,"RATRANSCRIPT"))
  1. S RASTAT=$G(^TMP("RARPT-REC",$J,RASUB,"RASTAT")) I RASTAT="A"!(RASTAT="C") S RADENDUM=""
  1. I $D(^TMP("RARPT-REC",$J,RASUB,"RAESIG")) S RAESIG=$G(^("RAESIG"))
  1. I $D(^TMP("RARPT-REC",$J,RASUB,"RAIMP")) D IMPTXT^RAHLO2
  1. I RADATE']"" S RAERR="Missing report date" Q
  1. I RADFN']"" S RAERR="Missing Internal Patient ID" Q
  1. I RACNI']"" S RAERR="Missing Case Number" Q
  1. I RADTI']"" S RAERR="Missing Exam Date" Q
  1. D DT^DILF("ET",RADATE,.RAVLDT)
  1. S:RAVLDT=-1 RAERR="Invalid report date" Q:$D(RAERR)
  1. K VA,VADM,VAERR S DFN=RADFN D DEM^VADPT
  1. I VADM(1)']"" S RAERR="Unknown Internal patient identifier" K VA,VADM,VAERR Q
  1. I RASSN'=$P(VADM(2),"^") S RAERR="Internal patient identifier and SSN don't match" K VA,VADM,VAERR Q
  1. I '$D(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0))!(RALONGCN']"") D Q
  1. . S RAERR="Invalid Exam Date and/or Case Number"
  1. . Q
  1. D EDTCHK^RAHLQ ; is user allowed to edit report for a cancelled case?
  1. I RARPT=1 S RAERR="Report for CANCELLED case not permitted." Q
  1. I RARPT=2 S RAERR="Please use VISTA to edit CANCELLED printset cases." Q
  1. S RARPT=+$P(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0),"^",17)
  1. I '$D(^RARPT(RARPT,0)),($D(RADENDUM)#2) S RAERR="Can't add addendum, no report" Q
  1. ;
  1. I $D(^RARPT(RARPT,0)),($P(^(0),"^",5)'="V"),($D(RADENDUM)#2) D Q
  1. .S RAERR=$P($G(^RARPT(RARPT,0)),"^")_": Cannot add addendum to a non-verified report." Q ;P94 & P218
  1. ;DO block below updated by patches 94 & 218
  1. I $D(^RARPT(RARPT,0)),(($P(^(0),"^",5)="V")!($P(^(0),"^",5)="EF")),('$D(RADENDUM)#2) D Q
  1. .S RAERR=$P($G(^RARPT(RARPT,0)),"^")_": Report already on file."
  1. .Q
  1. ;
  1. I ($D(RADENDUM)#2),'$O(^TMP("RARPT-REC",$J,RASUB,"RAIMP",0)),'$O(^TMP("RARPT-REC",$J,RASUB,"RATXT",0)) S RAERR="Missing addendum report/impression text" Q
  1. I $D(^RADPT(RADFN,"DT",RADTI,0)) S RAMDIV=^(0),RAMLC=+$P(RAMDIV,"^",4),RAMDIV=+$P(RAMDIV,"^",3),RAMDV=$S($D(^RA(79,RAMDIV,.1)):^(.1),1:""),RAMDV=$S(RAMDV="":RAMDV,1:$TR(RAMDV,"YyNn",1100))
  1. I '($D(RADENDUM)#2) I $P(RAMDV,"^",16),('$D(^TMP("RARPT-REC",$J,RASUB,"RAIMP"))) S RAERR="Missing Impression Text" Q ; impression req'd for this division
  1. I ($D(RADENDUM)#2),($D(^RARPT(RARPT,0))#2),($P(RAMDV,"^",16)),('$O(^RARPT(RARPT,"I",0))),('$D(^TMP("RARPT-REC",$J,RASUB,"RAIMP"))) S RAERR="Impression Text missing for current record." Q ; impression req'd for this division
  1. I $D(RADENDUM)#2 D CKDUPA^RAHLO4 I RADUPA S RAERR=$P($G(^RARPT(RARPT,0)),"^")_": Duplicate Addendum" Q ;P218
  1. ; check resident and staff
  1. N X1,X2,X3 S X2=0,X3=""
  1. I '$G(RATELE),+$G(^TMP("RARPT-REC",$J,RASUB,"RARESIDENT"))!(+$G(^("RASTAFF"))) D Q:$G(RAERR)]""
  1. . S X1=+$G(^TMP("RARPT-REC",$J,RASUB,"RARESIDENT"))
  1. . I X1 D
  1. .. I '$D(^VA(200,"ARC","R",X1)),'$D(^VA(200,"ARC","S",X1)) S X2=1
  1. .. I $P($G(^VA(200,X1,"RA")),"^",3),$P(^("RA"),"^",3)'>$$DT^XLFDT S X2=X2+2
  1. .. I X2=1 S X3=$E($P($G(^VA(200,X1,0)),"^"),1,20)_" is not class'd as Resident or Staff"
  1. .. I X2=2 S X3=$P($G(^VA(200,X1,0)),"^")_"'s INACTIVE DATE is past"
  1. .. I X2=3 S X3=$P($G(^VA(200,X1,0)),"^")_" is not class'd as resident and past INACTIVE DATE"
  1. .. I X3]"" S RAERR=X3
  1. . S X2=0,X3="" S X1=+$G(^TMP("RARPT-REC",$J,RASUB,"RASTAFF"))
  1. . I X1 D
  1. .. I '$D(^VA(200,"ARC","S",X1)) S X2=1
  1. .. I $P($G(^VA(200,X1,"RA")),"^",3),$P(^("RA"),"^",3)'>$$DT^XLFDT S X2=X2+2
  1. .. I X2=1 S X3=$E($P($G(^VA(200,X1,0)),"^"),1,20)_" is not class'd as staff"
  1. .. I X2=2 S X3=$P($G(^VA(200,X1,0)),"^")_"'s INACTIVE DATE is past"
  1. .. I X2=3 S X3=$P($G(^VA(200,X1,0)),"^")_" is not class'd as staff and past INACTIVE DATE"
  1. .. I X3]"" S RAERR=$S($G(RAERR)]"":RAERR_", ",1:"")_X3
  1. . Q
  1. ; raesig is in alphanumeric format, so shouldn't use $g of it here
  1. I ($G(RAESIG)]"")!($G(RAVERF)) D:'$G(RATELE) VERCHK^RAHLO3 ; check if provider can verify report
  1. ; if verifier fails checks,
  1. ; quit only if vendor is non-kurzweil,
  1. ; if vendor is kurzweil, continue on by deleting raerr, raverf
  1. I $D(RAERR) Q:$G(^TMP("RARPT-REC",$J,RASUB,"VENDOR"))'="KURZWEIL" K RAERR,RAVERF
  1. S RAIMGTY=$$IMGTY^RAUTL12("l",RAMLC) I '$L(RAIMGTY) S RAERR="No Imaging Type for Location where exam was performed" Q
  1. K RASECDX ;clear secondary dx array because RAHLO2 may not be called
  1. ; 09/07/2005 108405 KAM- Removed ('$D(RADENDUM)#2) from next line
  1. I $G(RATELE),'$D(RADENDUM),'$D(^TMP("RARPT-REC",$J,RASUB,"RADX")) D ;Patch 84
  1. .I RASTAT="R" S:$D(RATELEDR) ^TMP("RARPT-REC",$J,RASUB,"RADX",1)=RATELEDR Q
  1. .S:$D(RATELEDF) ^TMP("RARPT-REC",$J,RASUB,"RADX",1)=RATELEDF
  1. D:$D(^TMP("RARPT-REC",$J,RASUB,"RADX")) DIAG^RAHLO2 Q:$D(RAERR) ; DX code check took out - &('$D(RADENDUM)#2)
  1. ; edit sec Dx codes if they exist for non-addendums
  1. ; 09/07/2005 108405 KAM - Removed ('$D(RADENDUM)#2)from next line
  1. I $D(RASECDX) D SECDX^RAHLO2 Q:$D(RAERR)
  1. S B=0 F A="I","R" D Q:$D(RAERR)
  1. . Q:A="R"&('$D(^TMP("RARPT-REC",$J,RASUB,"RATXT"))) ; no rpt text
  1. . Q:A="I"&('$D(^TMP("RARPT-REC",$J,RASUB,"RAIMP"))) ; no imp text
  1. . S B=$$TEXT^RAHLO3(A)
  1. . S:'B RAERR=$$ERR^RAHLO2(A)
  1. . Q
  1. ;
  1. I $G(RATELE),$L($G(RATELEPI)),RATELEPI'?10N S RAERR="Incorrect Teleradiologist's NPI: "_RATELEPI Q
  1. D RPTSTAT^RAHLO3 ; determine the status of the report
  1. Q:$D(RAERR)#2 ;P162 added error chk
  1. ;
  1. ;new w/P106
  1. I RARPT,($T(EN^RARPTUT)'=""),(RASTAT="VAQ") D EN^RARPTUT QUIT ;p162 removed $D(RAERR)#2
  1. ;
  1. ;new w/P162
  1. I $G(RARPT)>0 D Q:$D(RAERR)#2
  1. .L +^RARPT(RARPT):5
  1. .I '$T S RAERR="Lock of report record: "_RARPT_" failed."
  1. .Q
  1. ;p165 - Need to unlock the report if accession is locked.
  1. L +^RADPT(RADFN,"DT",RADTI):60
  1. I '$T S RAERR="Lock of study accession: "_$S(RALONGCN'="":RALONGCN,1:"N/A")_" failed." D Q
  1. .I $G(RARPT)>0 L -^RARPT(RARPT)
  1. .Q
  1. D FILE^RAHLO1
  1. ;unlock the report & study unconditionally
  1. L -^RARPT(RARPT) L -^RADPT(RADFN,"DT",RADTI)
  1. Q
  1. ;