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

BQIPTEXM.m

Go to the documentation of this file.
BQIPTEXM ;PRXM/HC/ALA-Patient Exams ; 26 Mar 2007  2:57 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 Q
 ;
EXM(DATA,DFN,DRANGE) ; EP -- BQI PATIENT EXAMS
 ;
 ;Description - all the exams that a patient has
 ;
 ;Input
 ;  DFN - Patient internal entry number
 ;
 NEW UID,II,IEN,EXAM,VISIT,VSDTM,RESULT,ORPHY,ENPHY,COMMENT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTEXM",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTEXM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S DRANGE=$$DATE^BQIUL1($G(DRANGE))
 S @DATA@(II)="I00010EXAM_IEN^I00010VISIT_IEN^D00030VISIT_DATETIME^T00030EXAM^T00020RESULT^T00035ENC_PROV^T00245COMMENTS"_$C(30)
 S IEN=""
 F  S IEN=$O(^AUPNVXAM("AC",DFN,IEN),-1) Q:IEN=""  D
 . S EXAM=$$GET1^DIQ(9000010.13,IEN_",",.01,"E") I EXAM="" Q
 . S VISIT=$$GET1^DIQ(9000010.13,IEN_",",.03,"I") I VISIT="" Q
 . S VSDTM=$$GET1^DIQ(9000010,VISIT_",",.01,"I") I VSDTM=0 Q
 . I DRANGE'="",(VSDTM\1<DRANGE) Q
 . S RESULT=$$GET1^DIQ(9000010.13,IEN_",",.04,"E")
 . ;S ORPHY=$$GET1^DIQ(9000010.13,IEN_",",1202,"E")
 . S ENPHY=$$GET1^DIQ(9000010.13,IEN_",",1204,"E")
 . S COMMENT=$$GET1^DIQ(9000010.13,IEN_",",81101,"E")
 . S II=II+1,@DATA@(II)=IEN_U_VISIT_U_$$FMTE^BQIUL1(VSDTM)_U_EXAM_U_RESULT_U_ENPHY_U_COMMENT_$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 EXN,RVDT,REVDT,RFIEN,VISIT,EXAM,RESULT
 S EXN=""
 F  S EXN=$O(^AUPNPREF("AA",DFN,9999999.15,EXN)) Q:EXN=""  D
 . S RVDT=""
 . F  S RVDT=$O(^AUPNPREF("AA",DFN,9999999.15,EXN,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,9999999.15,EXN,RVDT,RFIEN)) Q:RFIEN=""  D
 ... S EXAM=$$GET1^DIQ(9999999.15,EXN_",",.01,"E")
 ... S RESULT=$$GET1^DIQ(9000022,RFIEN_",",.07,"E")
 ... S ENPHY=$$GET1^DIQ(9000022,RFIEN_",",1204,"E")
 ... S COMMENT=$$GET1^DIQ(9000022,RFIEN_",",1101,"E")
 ... S VISIT=""
 ... S II=II+1,@DATA@(II)=U_VISIT_U_$$FMTE^BQIUL1(REVDT)_U_EXAM_U_RESULT_U_ENPHY_U_COMMENT_$C(30)
 Q