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

BWUTL1.m

Go to the documentation of this file.
BWUTL1 ;IHS/ANMC/MWR - UTIL: MOSTLY PATIENT DATA;11-Feb-2003 18:51;PLS
 ;;2.0;WOMEN'S HEALTH;**1,8**;MAY 16, 1996
 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
 ;;  UTILITY: PATIENT DEMOG, NEEDS, AND REGIMENS, DISPLAY PRIORITY,
 ;;  PROCEDURE TYPE.
 ;;  PATCHED AT LINELABELS BNEED AND REFS.  IHS/ANMC/MWR 11/20/96
 ;
NAME(DFN) ;EP
 ; PATIENT NAME.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,0)) "UNKNOWN"
 Q $P(^DPT(DFN,0),U)
 ;
DOB(DFN) ;EP
 ; RETURN PATIENT'S DATE OF BIRTH IN FILEMAN FORMAT.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$P(^DPT(DFN,0),U,3) "UNKNOWN"
 Q $P(^DPT(DFN,0),U,3)
 ;
 ;
AGE(DFN) ;EP
 ; YIELD PATIENT'S AGE IN YEARS.
 ; REQ: DFN=IEN PATIENT FILE
 N X,X1,X2
 Q:'$G(DFN) "NO PATIENT"
 S X2=$$DOB(DFN)
 Q:'+X2 "UNKNOWN"
 I $$DECEASED(DFN),'$G(BWCUTF) Q "DECEASED: "_$$SLDT2^BWUTL5(+^DPT(DFN,.35))  ;IHS/CIM/THL PATCH 8
 I '$D(DT) D NOW^%DTC S DT=X
 S X1=DT
 D ^%DTC
 Q $P(X/365.25,".")_"y/o"
 ;
DECEASED(DFN) ;EP
 ; RETURN 1 IF PATIENT IS DECEASED, 0 IF NOT DECEASED.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) 0
 Q:'$D(^DPT(DFN,.35)) 0
 Q:'+^DPT(DFN,.35) 0
 Q 1
 ;
SEX(DFN) ;EP
 ; RETURN 1 IF PATIENT IS FEMALE.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) ""
 Q:'$D(^DPT(DFN,0)) ""
 Q:$P(^DPT(DFN,0),U,2)'="F" ""
 Q 1
 ;
INACT(DFN) ;EP
 ; DATE THIS PATIENT BECAME INACTIVE
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,0)) "UNKNOWN"
 Q $P(^BWP(DFN,0),U,24)
 ;
AGEAT(DFN,DATE) ;EP
 ; YIELD PATIENT'S AGE IN YEARS AT GIVEN DATE.
 ; REQ: DFN =IEN PATIENT FILE
 ; DATE=DATE AT WHICH AGE IS DESIRED.
 N X,X1,X2
 Q:'$G(DFN) "NO PATIENT"
 Q:'$G(DATE) "NO DATE"
 S X2=$$DOB(DFN)
 Q:'+X2 "UNKNOWN"
 S X1=DATE
 D ^%DTC
 Q $P(X/365.25,".")_"y/o"
 ;
NAMAGE(DFN) ;EP
 ; PATIENT NAME CONCAT WITH AGE.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q $$NAME(DFN)_" ("_$$AGE(DFN)_")"
 ;
SSN(DFN) ;EP
 ; SOCIAL SECURITY NUMBER.
 ; REQ: DFN=IEN PATIENT FILE
 N X
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,0)) "UNKNOWN"
 S X=$P(^DPT(DFN,0),U,9)
 Q:X']"" "UNKNOWN"
 Q X
 ;
CDCID(DFN) ;EP
 ; CDC UNIQUE PATIENT ID.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 Q $P(^BWP(DFN,0),U,20)
 ;
HRCN1(DFN,DUZ2) ;EP
 ; IHS HEALTH RECORD NUMBER, WITH NO DASHES INSERTED.
 ; REQUIRED VARIABLES: DFN, DUZ(2)
 Q:'$G(DFN)!('$G(DUZ2)) "UNKNOWN1"
 I '$D(^AUPNPAT(DFN,41,DUZ2,0)) Q "UNKNOWN2"
 I '+$P(^AUPNPAT(DFN,41,DUZ2,0),"^",2) Q "UNKNOWN3"
 Q $P(^AUPNPAT(DFN,41,DUZ2,0),"^",2)
 ;
HRCN(DFN,DUZ2) ;EP
 ; IHS HEALTH RECORD NUMBER.  IF NOT IHS, RETURN SSN.
 ; REQ: DFN
 ; OPT: DUZ2 (SITE), IF NOT PASSED, ASSUMED =DUZ(2).
 S:'$G(DUZ2) DUZ2=$G(DUZ(2))
 I $$AGENCY^BWUTL5(DUZ2)'="i" Q $$SSN(DFN)
 N Y S Y=$$HRCN1(DFN,DUZ2)
 Q:'+Y Y
 I $L(Y)=7 D  Q Y
 .S Y=$TR("123-45-67",1234567,Y)
 S Y=$E("00000",0,6-$L(Y))_Y
 S Y=$TR("12-34-56",123456,Y)
 Q Y
 ;
HPHONE(DFN) ;EP
 ; GET HOME PHONE#.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,.13)) "UNKNOWN"
 Q:$P(^DPT(DFN,.13),U)="" "UNKNOWN"
 Q $P(^DPT(DFN,.13),U)
 ;
STREET(DFN) ;EP
 ; GET STREET ADDRESS.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,.11)) "UNKNOWN"
 Q:$P(^DPT(DFN,.11),U)="" "UNKNOWN"
 Q $P(^DPT(DFN,.11),U)
 ;
CITY(DFN) ;EP
 ; GET CITY ADDRESS.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,.11)) "UNKNOWN"
 Q:$P(^DPT(DFN,.11),U,4)="" "UNKNOWN"
 Q $P(^DPT(DFN,.11),U,4)
 ;
STATE(DFN) ;EP
 ; GET STATE ADDRESS.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,.11)) "UNKNOWN"
 Q:$P(^DPT(DFN,.11),U,5)="" "UNKNOWN"
 Q $P(^DIC(5,$P(^DPT(DFN,.11),U,5),0),U,2)
 ;
ZIP(DFN) ;EP
 ; GET ZIPCODE ADDRESS.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^DPT(DFN,.11)) "UNKNOWN"
 Q:$P(^DPT(DFN,.11),U,6)="" "UNKNOWN"
 Q $P(^DPT(DFN,.11),U,6)
 ;
CTYSTZ(DFN) ;EP
 ; GET ZIPCODE ADDRESS.
 ; REQ: DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q $$CITY(DFN)_", "_$$STATE(DFN)_"  "_$$ZIP(DFN)
 ;
CURCOM(DFN) ;EP
 ; GET CURRENT COMMUNITY IEN (ITEM 6 ON PAGE 1 OF REGISTRATION).
 ; REQ: DFN=IEN PATIENT FILE
 N Y
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^AUPNPAT(DFN,11)) "UNKNOWN1"
 S Y=$P(^AUPNPAT(DFN,11),U,17)
 Q:Y="" "UNKNOWN2"
 Q:'$D(^AUTTCOM(Y,0)) "BAD POINTER"
 Q Y
 ;
CMGR(DFN) ;EP
 ; YIELD PATIENT'S CASE MANAGER.
 ; REQ: DFN=IEN PATIENT FILE
 N X
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 S X=$P(^BWP(DFN,0),U,10)
 Q $$PERSON(X)
 ;
PERSON(X) ;EP
 ; RETURN PERSON'S NAME FROM FILE #200.
 Q:'X "UNKNOWN"
 Q:'$D(^VA(200,X,0)) "UNKNOWN"
 Q $P(^VA(200,X,0),U)
 ;
EDC(DFN) ;EP
 ; YIELD IF PATIENT IS PREGNANT, AND EDC.
 ; REQ: DFN=IEN PATIENT FILE
 N X,Y
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 S Y=$P(^BWP(DFN,0),U,13)
 S X=$P(^BWP(DFN,0),U,14)
 Q:'Y ""
 S Y=" PREGNANT"
 Q Y_", EDC: "_$S(X:$$SLDT2^BWUTL5(X),1:"NO DATE ")_" "
 ;
PAPRG(DFN,TXDT) ;EP
 ; YIELD PATIENT'S PAP REGIMEN AND DATE IT BEGAN.
 ; REQ: DFN=IEN PATIENT FILE
 ; OPT: TXDT=1 IF DATE SHOULD BE TEXT FORMAT.
 N Y,X
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 S Y=$P(^BWP(DFN,0),U,16)
 S X=$P(^BWP(DFN,0),U,17) D Z(.X,$G(TXDT))
 Q $$PAPRG1(Y)_" (began "_X_")"
 ;
PAPRG1(PREG) ;EP
 ; YIELD PATIENT'S PAP REGIMEN.
 ; REQ: PREG=IEN IN BW PAP REGIMEN FILE #9002086.03.
 Q:'$G(PREG) "UNKNOWN"
 Q:'$D(^BWPR(PREG,0)) "PAP REGIMEN MISSING"
 Q $P(^BWPR(PREG,0),U)
 ;
CNEED(DFN,TXDT) ;PEP
 ; YIELD PATIENT'S CX TX NEED AND CX TX NEED DUE DATE.
 ; REQ: DFN=IEN PATIENT FILE
 ; OPT: TXDT=1 IF DATE SHOULD BE TEXT FORMAT.
 N X,Y
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 S Y=$P(^BWP(DFN,0),U,11)
 Q:'Y "UNKNOWN"
 Q:'$D(^BWCUR(Y,0)) "UNKNOWN"
 S X=$P(^BWP(DFN,0),U,12) D Z(.X,$G(TXDT))
 Q $E($P(^BWCUR(Y,0),U),1,22)_" (by "_X_")"
 ;
BNEED(DFN,TXDT) ;PEP
 ; YIELD PATIENT'S BR TX NEED AND BR TX NEED DUE DATE.
 ; REQ: DFN=IEN PATIENT FILE
 ; OPT: TXDT=1 IF DATE SHOULD BE TEXT FORMAT.
 N X,Y,Z
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 ;S Y=$P(^BWP(BWDFN,0),U,18)
 S Y=$P(^BWP(DFN,0),U,18)  ;IHS/ANMC/MWR 11/20/96
 Q:'Y "UNKNOWN"
 Q:'$D(^BWMAMT(Y,0)) "UNKNOWN"
 ;S X=$P(^BWP(DFN,0),U,19) D Z(.X,$G(TXDT))
 S X=$P(^BWP(DFN,0),U,19) D Z(.X,$G(TXDT))  ;IHS/ANMC/MWR 11/20/96
 Q $E($P(^BWMAMT(Y,0),U),1,22)_" (by "_X_")"
 ;
DES(DFN) ;EP
 ; YIELD PATIENT'S STATUS AS A DES DAUGHTER: 1=YES, 0=NO.
 ; DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 Q:'$D(^DD(9002086,.15,0)) "^DD MISSING"
 S X=$P(^BWP(DFN,0),U,15)
 Q:X="" ""
 Q $P($P(^DD(9002086,.15,0),X_":",2),";")
 ;
FAMHX(DFN) ;EP
 ; RETURN FAMILY HISTORY OF BREAST CANCER.
 ; DFN=IEN PATIENT FILE
 N X
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 Q:'$D(^DD(9002086,.23,0)) "^DD MISSING"
 S X=$P(^BWP(DFN,0),U,23)
 Q:X="" ""
 Q $P($P(^DD(9002086,.23,0),X_":",2),";")
 ;
REFS(DFN) ;EP
 ; RETURN REFERRAL SOURCE FOR THIS PATIENT (INTO CDC PROGRAM).
 ; DFN=IEN PATIENT FILE
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 Q:'$D(^DD(9002086,.22,0)) "^DD MISSING"  ;IHS/ANMC/MWR 11/20/96
 S X=$P(^BWP(DFN,0),U,22)
 Q:X="" ""
 Q $P($P(^DD(9002086,.22,0),X_":",2),";")
 ;
ENRLDT(DFN,TXDT) ;PEP
 ; YIELD PATIENT'S ENROLLMENT DATE.
 ; REQ: DFN=IEN PATIENT FILE
 ; OPT: TXDT=1 IF DATE SHOULD BE IN TEXT FORMAT.
 N X
 Q:'$G(DFN) "NO PATIENT"
 Q:'$D(^BWP(DFN,0)) "UNKNOWN"
 S X=$P(^BWP(DFN,0),U,21)
 Q:'X ""  D Z(.X,$G(TXDT))
 Q X
 ;
Z(X,Z) ;EP
 ; SET Z = NUMERIC (1/1/95) OR TEXT (JAN 1,1995) FORMAT OF DATE.
 ; REQ:  X=FILEMAN INTERNAL DATE FORMAT.
 ; OPT: Z=1 IF TEXT, 0/"" IF NUMERIC.
 S X=$S($G(Z):$$TXDT^BWUTL5(X),1:$$SLDT2^BWUTL5(X))
 Q
 ;
 ;
ACC(IEN) ;EP
 ; ACCESSION#; CONCATENATE SCREENING PAP IF IT EXISTS.
 ; IEN=IEN IN BW PROCEDURE FILE #9002086.1).
 Q:'$G(IEN) "NO PROC"
 Q:'$D(^BWPCD(IEN,0)) "NO PROC"
 N X S X=$P(^BWPCD(IEN,0),U,30)
 I X]"" I $D(^BWPCD(X,0)) S X=$P(^BWPCD(X,0),U),X=","_X
 Q $E($P(^BWPCD(IEN,0),U)_X,1,19)
 ;
PRIOR() ;EP
 ; CALLED FROM BW NOTIF-EDITBLK-1 TO GET VALUE AND TEXT OF
 ; NOTIFICATION PRIORITY AND RESULT/REMINDER, FROM PURPOSE OF
 ; NOTIFICATION WHEN FIRST DISPLAYING SCREEN.
 ; REQ: DA=IEN OF NOTIFICATION.
 N X
 Q:'$D(DA) "UNKNOWN"
 Q:'$D(^BWNOT(DA,0)) "UNKNOWN"
 S X=$P(^BWNOT(DA,0),U,4)
 Q:'X "UNKNOWN"
 Q $$PRIOR1
 ;
PRIOR1() ;EP
 ; CALLED FROM BW NOTIF-EDITBLK-1 TO GET VALUE AND TEXT OF
 ; NOTIFICATION PRIORITY FROM PURPOSE OF NOTIFICATION AS AN
 ; ACTION WHEN EDITING PURPOSE OF NOTIFICATION.  ALSO DISPLAY
 ; WHETHER PURPOSE IS A RESULT OR A REMINDER.
 ; REQ: X=IEN IN NOTIFICATION PURPOSE FILE.
 N R,Y,Z
 Q:'$D(X) "UNDEFINED"
 Q:'X "UNKNOWN"
 Q:'$D(^BWNOTP(X,0)) "UNKNOWN"
 S Y=$P(^BWNOTP(X,0),U,2) D
 .I 'Y S R="UNKNOWN" Q
 .I '$D(^DD(9002086.404,.02,0)) S R="^DD MISSING"
 .S R=$P($P(^DD(9002086.404,.02,0),Y_":",2),";")
 S Z=$P(^BWNOTP(X,0),U,6)
 Q:Z="" R
 Q:Z R_", RESULT"
 Q R_", REMINDER"
 ;
 ;
NTPROC() ;EP
 ; CALLED FROM BW NOTIF-EDITBLK-1(?) BLOCK TO DISPLAY PROCEDURE
 ; NAME, BASED ON ACCESSION# PTR, WHEN FIRST DISPLAYING SCREEN.
 ; REQ: X=ACCESSION# OF PROCEDURE
 N X
 S X=$P(^BWNOT(DA,0),U,6)
 Q $$PROC
 ;
PROC() ;EP
 ; DISPLAY PROCEDURE TYPE OF THIS PROCEDURE.
 ; REQ: X=IEN OF PROCEDURE IN PROC FILE #9002086.1.
 N BWY,BWYY,Y,Z S BWYY="INVALID ACC# OR PTR"
 Q:X']"" ""
 Q:'$D(^BWPCD(X,0)) BWYY
 S BWY=$P(^BWPCD(X,0),U,4)
 Q:'BWY BWYY
 Q:'$D(^BWPN(BWY,0)) BWYY
 S Z=$P(^BWPN(BWY,0),U)
 ; IF UNILATERAL AND LEFT/RIGHT HAS A VALUE, REPLACE "UNILATERAL"
 ; WITH LEFT OR RIGHT.
 S Y=$P(^BWPCD(X,0),U,9)
 S Y=$S(Y="l":"LEFT",Y="r":"RIGHT",1:"")
 Q:Y="" Z
 Q $P(Z," ")_" "_Y
 ;
PROC1() ;EP
 ; DISPLAY PROCEDURE TYPE OF THIS PROCEDURE, USING DA.
 ; CALLED BY BW PROC-HEADER-1, WHICH CANNOT USE X.
 ; REQ: DA=IEN OF PROCEDURE IN PROC FILE #9002086.1.
 N X S X=DA
 Q $$PROC