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

BTPWEHIS.m

Go to the documentation of this file.
BTPWEHIS ;VNGT/HS/ALA-Patient Event History ; 18 Aug 2010  9:56 AM
 ;;1.2;CARE MANAGEMENT EVENT TRACKING;;Jul 07, 2017;Build 71
 ;
 ;
EHIS(DATA,DFN,OCAT) ;EP - BTPW GET PATIENT EVENT HISTORY
 ;
 NEW UID,II,LINK,VSDTM,CAT,PROCNM,WHREC,BREC,WHIEN,HDR,ORD,QFL,REF,RIEN,STAT,TGLOB,VISIT,WIEN,RARPT
 NEW ACCN,BQII,D0,DA,DIC,DK,FULLE,FULLR,ECHR,FRIL,I,J,K,LEN,LG,LIEN,LN,PRCN,TAB,VAL,VALUE,VHD
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWEHIS",UID))
 K @DATA
 I $G(DT)=""!($G(U)="") D DT^DICRW
 ;
 S BQII=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWPPAT D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S HDR="T00040CATEGORY^T00060EVENT^D00015EVNT_DATE^T01024EXP_EVENT^D00030RESULT^T01024EXP_RESULT^"
 S HDR=HDR_"T01024HIDE_RESULT^T01024INTERPRETATION^T01024HIDE_INTERPRETATION"
 S @DATA@(BQII)=HDR_$C(30)
 ;
 S OCAT=$G(OCAT,""),TGLOB=$NA(^XTMP("BTPWPRC"))
 ;
 ; If history of all events for this patient
 S PRCN="" F  S PRCN=$O(@TGLOB@(DFN,PRCN)) Q:PRCN=""  D
 . Q:PRCN="~"
 . ;
 . ;Get internal category and filter on inputed category
 . S CAT=$$GET1^DIQ(90621,PRCN_",",.1,"I") I OCAT'="",CAT'=OCAT Q
 . S CAT=$$CAT^BTPWPDSP(PRCN)  ;Get external Category
 . D LEVT(PRCN,CAT)
 ;
DONE ;
 S BQII=BQII+1,@DATA@(BQII)=$C(31)
 Q
 ;
LEVT(PRCN,CAT) ;EP - Get event
 N EXVDT,INTR,HINTR,HLINK
 S VSDTM="",PROCNM=$P(^BTPW(90621,PRCN,0),U,1)
 S WHREC="",RARPT="",LINK="",ACCN=""
 F  S VSDTM=$O(@TGLOB@(DFN,PRCN,VSDTM)) Q:VSDTM=""  D
 . S ORD=""
 . S ORD=$O(@TGLOB@(DFN,PRCN,VSDTM,ORD)) Q:ORD=""  D  Q:'QFL
 .. S VISIT="",QFL=1
 .. S VISIT=$O(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT)) Q:VISIT=""  D  Q:'QFL
 ... S RIEN="",STAT="",RARPT="",ACCN=""
 ... S RIEN=$O(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN)) Q:RIEN=""  D  Q:'QFL
 .... S WHIEN="",BREC(VSDTM)=RIEN,WHREC=""
 .... I $G(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN))="" D
 ..... S WIEN=$O(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN,""))
 ..... S WHIEN=$P(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN,WIEN),U,1)
 ..... S REF=$P(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN,WIEN),U,2,3)
 ..... S RARPT=$P(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN,WIEN),U,4)
 .... I $G(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN))'="" D
 ..... S WHIEN=$P(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN),U,1)
 ..... S REF=$P(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN),U,2,3)
 ..... S RARPT=$P(@TGLOB@(DFN,PRCN,VSDTM,ORD,VISIT,RIEN),U,4)
 ... ;
 ... ; Look for entry in Tracked file - pull interpretation
 ... S (HINTR,INTR)=""
 ... S FRIL=$P(REF,U,2) S:FRIL]"" FRIL=$O(^BTPW(90621.1,"B",FRIL,""))
 ... I DFN'="",PRCN'="",VISIT'="",RIEN'="",FRIL'="" D
 .... N TIEN
 .... S TIEN=$O(^BTPWP("C",DFN,PRCN,VISIT,RIEN,FRIL,""))
 .... I TIEN]"" S INTR=$$INTER^BTPWPEVT(TIEN),HINTR=$P(INTR,$C(26),2),INTR=$P(INTR,$C(26))
 ... ;
 ... S:VISIT="~" VISIT=""
 ... ; pull interpretation if WH record
 ... I $G(INTR)="",WHIEN'="" S INTR=$$INTER^BTPWPEVT("",WHIEN),HINTR=$P(INTR,$C(26),2),INTR=$P(INTR,$C(26))
 ... S RIEN=$G(BREC(VSDTM))
 ... S EXVDT=$$FMTE^BQIUL1(VSDTM)
 ... I $P(REF,U,1)=9000010.09 D
 .... I RIEN'="~",RIEN'="",WHIEN="" S ACCN=$P($G(^AUPNVLAB(RIEN,0)),U,6)
 .... I $E(ACCN,1,2)="WH" S WHIEN=$O(^BPWCD("B",$E(ACCN,3,$L(ACCN)),"")) I WHIEN'="" S ACCN=""
 ... S FULLR=""
 ... ; If V LAB but now RIEN and WH IEN
 ... I ACCN="",WHIEN'="" S $P(REF,U,2)="WH RECORD"
 ... ; If WH record but no result has been entered
 ... ;I WHIEN'="",$P($G(^BWPCD(WHIEN,0)),U,5)="" S WHIEN=""
 ... S LINK=""
 ... I WHIEN'="" S LINK=EXVDT_$C(28)_$P(REF,U,2)_$C(28)_"W:"_WHIEN
 ... I RARPT'="" S LINK=EXVDT_$C(28)_$P(REF,U,2)_$C(28)_"R:"_RARPT
 ... I WHIEN'="" D
 .... NEW TDATA
 .... D EN^BTPWRWHP(.TDATA,WHIEN)
 .... F I=1:1 Q:@TDATA@(I)=$C(30)  S FULLR=FULLR_@TDATA@(I)
 ... I RARPT'="" D
 .... NEW TDATA
 .... D EN^BTPWRRAD(.TDATA,DFN,RARPT)
 .... F I=1:1 Q:@TDATA@(I)=$C(30)  S FULLR=FULLR_@TDATA@(I)
 ... I ACCN'="" D
 .... NEW RES
 .... S RES=$P($G(^AUPNVLAB(RIEN,0)),U,4)
 .... NEW TDATA
 .... D EN^BTPWRLAB(.TDATA,DFN,RIEN)
 .... F I=1:1 Q:@TDATA@(I)=$C(30)  S FULLR=FULLR_@TDATA@(I)
 .... I RES="",$P($G(^AUPNVLAB(RIEN,11)),U,9)'="R" Q
 .... S LINK=EXVDT_$C(28)_$P(REF,U,2)_$C(28)_"L:"_RIEN
 ... S HLINK=$P(LINK,$C(28),2,3),LINK=$P(LINK,$C(28))
 ... S FULLE="Event obtained from: "_$C(13)_$C(10) D
 .... I WHIEN'="" S FULLE=FULLE_"Women's Health Package" Q
 .... S FULLE=FULLE_$P(^BTPW(90621.1,FRIL,0),"^",1)_" - "
 .... NEW FIL,FLD
 .... S FIL=$P(^BTPW(90621.1,FRIL,0),"^",2),FLD=$P(^(0),"^",3),TAB=$P(^(0),"^",8)
 .... S FULLE=FULLE_$$GET1^DIQ(FIL,RIEN_",",FLD,"E")
 .... S LIEN=$$GET1^DIQ(FIL,RIEN_",",FLD,"I")
 .... I TAB=80!(TAB=80.1)!(TAB=81) D
 .... I TAB=80 S FULLE=FULLE_" "_$$ICD9^BQIUL3(LIEN,,4)_$C(13)_$C(10) Q
 .... I TAB=80.1 S FULLE=FULLE_" "_$$ICD0^BQIUL3(LIEN,,5)_$C(13)_$C(10) Q
 .... I TAB=81 S FULLE=FULLE_" "_$$ICPT^BQIUL3(LIEN,"",3)
 ... S BQII=BQII+1,@DATA@(BQII)=CAT_U_PROCNM_U_EXVDT_U_FULLE_U_LINK_U_FULLR_U_HLINK_U_INTR_U_HINTR_$C(30)
 Q