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

BQIPTPRC.m

Go to the documentation of this file.
BQIPTPRC ;PRXM/HC/ALA - PATIENT ICD9 PROCEDURES ; 26 Mar 2007  5:15 PM
 ;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
 ;
 Q
 ;
PR(DATA,DFN,DRANGE) ; EP -- BQI PATIENT PROCEDURES
 ;
 ;Description - all the procedures that a patient has
 ;
 ;Input
 ;  DFN - Patient internal entry number
 ;
 NEW UID,II,IEN,VISIT,VSDTM,PRCN,OPPRC,PRCC,DXC,PRDTM,PRPRC,INFC,OPPHY,CPT
 NEW ORPHY,ENPHY,PRNAR,PNARR
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTPRC",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTPRC D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S DRANGE=$$DATE^BQIUL1($G(DRANGE))
 S @DATA@(II)="D00030VISIT_DATETIME^I00010VISIT_IEN^I00010PRC_IEN^T00060OPPROC_CODE^T00080PROV_NARR"_$C(30)
 S IEN=""
 F  S IEN=$O(^AUPNVPRC("AC",DFN,IEN),-1) Q:IEN=""  D
 . S PRCN=$$GET1^DIQ(9000010.08,IEN_",",.01,"I") I PRCN="" Q
 . S VISIT=$$GET1^DIQ(9000010.08,IEN_",",.03,"I") I VISIT="" Q
 . S VSDTM=$$GET1^DIQ(9000010,VISIT_",",.01,"I") I VSDTM=0 Q
 . I DRANGE'="",(VSDTM\1<DRANGE) Q
 . I $$VERSION^XPDUTL("BCSV") D  ;csv
 .. S OPPRC=$$ICD0^BQIUL3(PRCN,VSDTM\1,5) ; Code set versioning
 .. S PRCC=$$ICD0^BQIUL3(PRCN,VSDTM\1,2) ; Code set versioning
 . I '$$VERSION^XPDUTL("BCSV") D
 .. S OPPRC=$$GET1^DIQ(80.1,PRCN_",",4,"E")
 .. S PRCC=$$GET1^DIQ(80.1,PRCN_",",.01,"E")
 . S DXC=$$GET1^DIQ(9000010.08,IEN_",",.05,"E")
 . S PRDTM=$$GET1^DIQ(9000010.08,IEN_",",.06,"I")
 . S PRPRC=$$GET1^DIQ(9000010.08,IEN_",",.07,"I")
 . S INFC=$$GET1^DIQ(9000010.08,IEN_",",.08,"I")
 . S OPPHY=$$GET1^DIQ(9000010.08,IEN_",",.11,"E")
 . S CPT=$$GET1^DIQ(9000010.08,IEN_",",.16,"E")
 . S ORPHY=$$GET1^DIQ(9000010.08,IEN_",",1202,"E")
 . S ENPHY=$$GET1^DIQ(9000010.08,IEN_",",1204,"E")
 . S PRNAR=$$GET1^DIQ(9000010.08,IEN_",",.019,"E")
 . S NIEN=$$GET1^DIQ(9000010.08,IEN_",",.04,"I")
 . S PNARR=PRNAR
 . I $$PATCH^XPDUTL("BJPC*2.0*10") S PNARR=$$PNPROB^AUPNVUTL(NIEN)
 . S II=II+1,@DATA@(II)=$$FMTE^BQIUL1(VSDTM)_U_VISIT_U_IEN_U_PRCC_"-"_OPPRC_U_PNARR_$C(30)
 ;
 ; Check for refusals
 D REF
 S II=II+1,@DATA@(II)=$C(31)
 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(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
REF ; Check for refusals
 NEW PRCN,RVDT,REVDT,RFIEN,VISIT,PRCC,IEN,PRNAR
 S PRCN=""
 F  S PRCN=$O(^AUPNPREF("AA",DFN,80.1,PRCN)) Q:PRCN=""  D
 . S RVDT=""
 . F  S RVDT=$O(^AUPNPREF("AA",DFN,80.1,PRCN,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,80.1,PRCN,RVDT,RFIEN)) Q:RFIEN=""  D
 ... I $$VERSION^XPDUTL("BCSV") D  ;csv
 .... S PRCC=$$ICD0^BQIUL3(PRCN,REVDT\1,2) ; Code set versioning)
 .... S PRNAR=$$ICD0^BQIUL3(PRCN,REVDT\1,5) ; Code set versioning
 ... I '$$VERSION^XPDUTL("BCSV") D  ;csv
 .... S PRCC=$$GET1^DIQ(80.1,PRCN_",",.01,"E")
 .... S PRNAR=$$GET1^DIQ(80.1,PRCN_",",4,"E")
 ... S RESULT=$$GET1^DIQ(9000022,RFIEN_",",.07,"E")
 ... S ORPHY=$$GET1^DIQ(9000022,RFIEN_",",1204,"E")
 ... S VISIT="",IEN=""
 ... S II=II+1,@DATA@(II)=$$FMTE^BQIUL1(REVDT)_U_VISIT_U_IEN_U_PRCC_"-"_OPPRC_U_RESULT_$C(30)
 Q