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

BQITDLST.m

Go to the documentation of this file.
BQITDLST ;PRXM/HC/DB-Get History of a Tagged Patient ; 14 Nov 2007  4:38 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 Q
 ;
GET(DATA,DFN,TAG) ; EP -- BQI GET DX CAT HISTORY
 ; 
 ; Input
 ;  DFN - Patient internal entry number
 ;
 NEW UID,II,TIEN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J),II=0
 S DATA=$NA(^TMP("BQITDLST",UID))
 K @DATA
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITDLST D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S TAG=$G(TAG,"")
 D HDR
 I TAG="" D  G DONE
 . S TIEN=""
 . F  S TIEN=$O(^BQIREG("AC",DFN,TIEN)) Q:TIEN=""  D TG(DFN,TIEN)
 ;
 I TAG'="" D
 . S TIEN=""
 . F  S TIEN=$O(^BQIREG("C",DFN,TAG,TIEN)) Q:TIEN=""  D TG(DFN,TIEN)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
GETDATA(DFN) ;EP - Retrieve patient data
 NEW NAME,HRN,SEX,DOB,AGE,DOD
 S NAME=$$GET1^DIQ(9000001,DFN_",",.01,"E")
 S HRN=$$HRNL^BQIULPT(DFN),HRN=$TR(HRN,";",$C(10))
 ;S SSN=$$GET1^DIQ(2,DFN_",",.09,"E")
 S SEX=$$GET1^DIQ(2,DFN_",",.02,"I")
 S DOB=$$FMTE^BQIUL1($$GET1^DIQ(2,DFN,.03,"I"))
 S AGE=$$AGE^BQIAGE(DFN,,1)
 S DOD=$$FMTE^BQIUL1($$GET1^DIQ(2,DFN_",",.351,"I"))
 Q DFN_U_NAME_U_HRN_U_DOB_U_AGE_U_SEX_U_DOD_U
 ;
HDR ;
 S @DATA@(II)="I00010DFN^T00030PATIENT_NAME^T00030HRN^D00030DOB^T00010AGE^"
 S @DATA@(II)=@DATA@(II)_"T00035TAG_NAME^I00010TAG_IEN^T00015STATUS^D00030DATE_LASTUPDATE^"
 S @DATA@(II)=@DATA@(II)_"T00035UPDATED_BY^T00050COMMENT^T01024OTHER_COMMENT"_$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(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
TG(DFN,TIEN) ;EP - Get tag history data
 NEW DEMOG,CDATA,HIEN,TAGNM,TAGIEN,STAT,TAGDTU,WHO,SCOM,OCOM,OCN
 S DEMOG=$$GETDATA(DFN)
 ; Get current tag data plus factors
 D TAG^BQITDPNL(TIEN)
 S CDATA=$P(@DATA@(II),U,1,12),CDATA=$$TKO^BQIUL1(CDATA,$C(30))
 ; Get history data
 S HIEN=0
 F  S HIEN=$O(^BQIREG(TIEN,10,HIEN)) Q:'HIEN  D
 . NEW DA,IENS
 . S DA(1)=TIEN,DA=HIEN,IENS=$$IENS^DILF(.DA)
 . S TAGNM=$$GET1^DIQ(90509,TIEN_",",.01,"E")
 . S TAGIEN=$$GET1^DIQ(90509,TIEN_",",.01,"I")
 . S STAT=$$GET1^DIQ(90509.01,IENS,.02,"I")
 . S TAGDTU=$$GET1^DIQ(90509.01,IENS,.05,"I")
 . S TAGDTU=$$FMTE^BQIUL1(TAGDTU)
 . S WHO=$$GET1^DIQ(90509.01,IENS,.03,"E")
 . S SCOM=$$GET1^DIQ(90509.01,IENS,.04,"I")
 . S OCOM=""
 . S OCN=0
 . F  S OCN=$O(^BQIREG(TIEN,10,HIEN,1,OCN)) Q:'OCN  D
 .. S OCOM=OCOM_^BQIREG(TIEN,10,HIEN,1,OCN,0)_$C(10)
 . S II=II+1,@DATA@(II)=$P(DEMOG,U,1,5)_U_TAGNM_U_TAGIEN_U_STAT_U_TAGDTU_U_WHO_U_SCOM_U_OCOM_$C(30)
 Q
 ;
DET(DATA,DFN,TAG) ; EP -- BQI GET DX CAT HIS DETAIL
 ; 
 ; Input
 ;  DFN - Patient internal entry number
 ;
 NEW UID,II,TIEN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J),II=0
 S DATA=$NA(^TMP("BQITDLST",UID))
 K @DATA
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITDLST D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S TAG=$G(TAG,"")
 D DHDR
 I TAG="" D  G DDNE
 . S TIEN=""
 . F  S TIEN=$O(^BQIREG("AC",DFN,TIEN)) Q:TIEN=""  D DTG(DFN,TIEN)
 ;
 I TAG'="" D
 . S TIEN=""
 . F  S TIEN=$O(^BQIREG("C",DFN,TAG,TIEN)) Q:TIEN=""  D DTG(DFN,TIEN)
 ;
DDNE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
DDATA(DFN) ;EP - Retrieve patient data
 NEW NAME,HRN,SEX,DOB,AGE,DOD
 S NAME=$$GET1^DIQ(9000001,DFN_",",.01,"E")
 S HRN=$$HRNL^BQIULPT(DFN),HRN=$TR(HRN,";",$C(10))
 ;S SSN=$$GET1^DIQ(2,DFN_",",.09,"E")
 S SEX=$$GET1^DIQ(2,DFN_",",.02,"I")
 S DOB=$$FMTE^BQIUL1($$GET1^DIQ(2,DFN,.03,"I"))
 S AGE=$$AGE^BQIAGE(DFN,,1)
 S DOD=$$FMTE^BQIUL1($$GET1^DIQ(2,DFN_",",.351,"I"))
 Q DFN_U_NAME_U_HRN_U_DOB_U_AGE_U_SEX_U_DOD_U
 ;
DHDR ;
 S @DATA@(II)="I00010DFN^T00030PATIENT_NAME^T00030HRN^D00030DOB^T00010AGE^"
 S @DATA@(II)=@DATA@(II)_"T00035TAG_NAME^I00010TAG_IEN^T00015STATUS^D00030DATE_LASTUPDATE^"
 S @DATA@(II)=@DATA@(II)_"T00035UPDATED_BY^T00050COMMENT^T01024OTHER_COMMENT^T00060FACTOR^T00030PROBVISIT^"
 S @DATA@(II)=@DATA@(II)_"T00030COMPLIANCE_VALUE^T00020PROB_VISIT_IEN^D00030VISIT_DATETIME"_$C(30)
 Q
 ;
DTG(DFN,TIEN) ;EP - Get tag history data
 NEW DEMOG,CDATA,FC,FACN,FPARMS,NN,HIEN,TAGNM,TAGIEN,STAT,TAGDTU,WHO,SCOM,OCOM,OCN
 S DEMOG=$$DDATA(DFN)
 ; Get current tag data plus factors
 D TAG^BQITDPNL(TIEN)
 S CDATA=$P(@DATA@(II),U,1,12),CDATA=$$TKO^BQIUL1(CDATA,$C(30))
 I $O(^BQIREG(TIEN,5,0))'="" D
 . S FC=0
 . F  S FC=$O(^BQIREG(TIEN,5,FC)) Q:'FC  D
 .. S FACN=$P(^BQIREG(TIEN,5,FC,0),U,1)
 .. D FACD^BQIPTDX(FACN,.FPARMS)
 .. S @DATA@(II)=CDATA_U_$G(FPARMS(1))_U_$G(FPARMS(2))_U_$G(FPARMS(3))_U_$G(FPARMS(4))_U_$G(FPARMS(5))_$C(30)
 .. I $O(^BQIREG(TIEN,5,FC))'="B" S II=II+1
 D FPD^BQIPTDX(DFN,$P(^BQIREG(TIEN,0),U,1),.FPARMS)
 S NN=""
 F  S NN=$O(FPARMS(NN)) Q:NN=""  D
 . S @DATA@(II)=CDATA_U_$G(FPARMS(NN,1))_U_$G(FPARMS(NN,2))_U_$G(FPARMS(NN,3))_U_$G(FPARMS(NN,4))_U_$G(FPARMS(NN,5))_$C(30)
 . I $O(FPARMS(NN))'="" S II=II+1
 K FPARMS
 ; Get history data
 S HIEN=0
 F  S HIEN=$O(^BQIREG(TIEN,10,HIEN)) Q:'HIEN  D
 . NEW DA,IENS
 . S DA(1)=TIEN,DA=HIEN,IENS=$$IENS^DILF(.DA)
 . S TAGNM=$$GET1^DIQ(90509,TIEN_",",.01,"E")
 . S TAGIEN=$$GET1^DIQ(90509,TIEN_",",.01,"I")
 . S STAT=$$GET1^DIQ(90509.01,IENS,.02,"I")
 . S TAGDTU=$$GET1^DIQ(90509.01,IENS,.05,"I")
 . S TAGDTU=$$FMTE^BQIUL1(TAGDTU)
 . S WHO=$$GET1^DIQ(90509.01,IENS,.03,"E")
 . S SCOM=$$GET1^DIQ(90509.01,IENS,.04,"I")
 . S OCOM=""
 . S OCN=0
 . F  S OCN=$O(^BQIREG(TIEN,10,HIEN,1,OCN)) Q:'OCN  D
 .. S OCOM=OCOM_^BQIREG(TIEN,10,HIEN,1,OCN,0)_$C(10)
 . S FC=0
 . I $O(^BQIREG(TIEN,10,HIEN,5,FC))'="" D  Q
 .. F  S FC=$O(^BQIREG(TIEN,10,HIEN,5,FC)) Q:'FC  D
 ... S FACN=$P(^BQIREG(TIEN,10,HIEN,5,FC,0),U,1)
 ... D FACD^BQIPTDX(FACN,.FPARMS)
 ... S II=II+1,@DATA@(II)=$P(DEMOG,U,1,5)_U_TAGNM_U_TAGIEN_U_STAT_U_TAGDTU_U_WHO_U_SCOM_U_OCOM_U
 ... S @DATA@(II)=@DATA@(II)_$G(FPARMS(1))_U_$G(FPARMS(2))_U_$G(FPARMS(3))_U_$G(FPARMS(4))_U_$G(FPARMS(5))_$C(30)
 . S II=II+1,@DATA@(II)=$P(DEMOG,U,1,5)_U_TAGNM_U_TAGIEN_U_STAT_U_TAGDTU_U_WHO_U_SCOM_U_OCOM_U
 . S @DATA@(II)=@DATA@(II)_$G(FPARMS(1))_U_$G(FPARMS(2))_U_$G(FPARMS(3))_U_$G(FPARMS(4))_U_$G(FPARMS(5))_$C(30)
 K FPARMS
 Q