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

BQIRRD.m

Go to the documentation of this file.
BQIRRD ;PRXM/HC/DLS - Patient Radiology ; 18 Jan 2006  12:02 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 Q
 ;
EN(DATA,DFN,DRANGE) ; EP -- BQI PATIENT RADIOLOGY
 ;Description
 ; Generates a Radiology Report for a given DFN and Relative Date.
 ;
 ;Input
 ;  DFN  -  Patient IEN
 ;  DRANGE - Date to pull Patient Radiology events from (to the present).
 ;
 ;Output
 ;  DATA - Name of global in which data is stored(^TMP("BQIRRD"))
 ;
 N BQII,UID,X,RAD,DA,IENS,RADDT,RRADDT,RADIEN,VISIT
 N DATE,PROC,ABNR,RADCODE,CPTCODE,RDRANGE,ORPHY,IMPRS
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIRRD",UID))
 K @DATA
 ;
 S BQII=0
 ;
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRRD D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D HDR
 S DRANGE=$$DATE^BQIUL1($G(DRANGE))
 S RDRANGE=9999999-DRANGE
 S RAD=""
 F  S RAD=$O(^AUPNVRAD("AA",DFN,RAD)) Q:RAD=""  D
 . S RADDT=0
 . F  S RADDT=$O(^AUPNVRAD("AA",DFN,RAD,RADDT)) Q:RADDT=""!(RADDT>RDRANGE)  D
 . . S RADIEN=0
 . . F  S RADIEN=$O(^AUPNVRAD("AA",DFN,RAD,RADDT,RADIEN)) Q:RADIEN=""  D
 . . . S RRADDT=9999999-RADDT
 . . . S DA=RADIEN
 . . . S IENS=$$IENS^DILF(.DA)
 . . . S DATE=$$FMTE^BQIUL1(RRADDT)
 . . . S PROC=$$GET1^DIQ(9000010.22,IENS,".01","E")
 . . . S VISIT=$$GET1^DIQ(9000010.22,IENS,".03","I") I VISIT="" Q
 . . . S ABNR=$$GET1^DIQ(9000010.22,IENS,".05","E")
 . . . S RADCODE=$$GET1^DIQ(9000010.22,IENS,.01,"I")
 . . . S ORPHY=$$GET1^DIQ(9000010.22,IENS,1202,"E")
 . . . S IMPRS=$$GET1^DIQ(9000010.22,IENS,1101,"E")
 . . . S CPTCODE=$$GET1^DIQ(71,RADCODE,"9","E")
 . . . S BQII=BQII+1,@DATA@(BQII)=VISIT_"^"_DATE_"^"_PROC_"^"_IMPRS_"^"_ABNR_"^"_ORPHY_$C(30)
 ;
 ; Check for refusals
 D REF
 ;
DONE ;
 S BQII=BQII+1,@DATA@(BQII)=$C(31)
 Q
 ;
HDR ;
 S @DATA@(BQII)="I00010VISIT_IEN^D00030VISIT_DATETIME^T00100RAD_PROC^T00245RAD_IMPRESSION^T00010RAD_ABNR^T00035RAD_ORD_PHY"_$C(30)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(BQII),$D(DATA) S BQII=BQII+1,@DATA@(BQII)=$C(31)
 Q
 ;
REF ; Check for refusals
 NEW XRN,RVDT,REVDT,RFIEN,PROC,IMPRS,ORPHY,ABNR,VISIT
 S XRN=""
 F  S XRN=$O(^AUPNPREF("AA",DFN,71,XRN)) Q:XRN=""  D
 . S RVDT=""
 . F  S RVDT=$O(^AUPNPREF("AA",DFN,71,XRN,RVDT)) Q:RVDT=""  D
 .. ; Reverse the reverse date
 .. S REVDT=9999999-RVDT
 .. I DRANGE'="",(REVDT\1)<DRANGE Q
 .. S RFIEN=""
 .. F  S RFIEN=$O(^AUPNPREF("AA",DFN,71,XRN,RVDT,RFIEN)) Q:RFIEN=""  D
 ... S PROC=$$GET1^DIQ(71,XRN_",",.01,"E")
 ... S IMPRS=$$GET1^DIQ(9000022,RFIEN_",",.07,"E")
 ... S ORPHY=$$GET1^DIQ(9000022,RFIEN_",",1204,"E")
 ... S ABNR="",VISIT=""
 ... S BQII=BQII+1,@DATA@(BQII)=VISIT_"^"_$$FMTE^BQIUL1(REVDT)_"^"_PROC_"^"_IMPRS_"^"_ABNR_"^"_ORPHY_$C(30)
 Q