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

BWMDE2.m

Go to the documentation of this file.
BWMDE2 ;IHS/ANMC/MWR - MDE FUNCTIONS.;11-Feb-2003 12:34;PLS
 ;;2.0;WOMEN'S HEALTH;**5,7,8**;MAY 16, 1996
 ;;Modified for Y2K compliance       THL/HJT 5/14/99
 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
 ;;  CDC EXPORT, FUNCTIONS TO RETRIEVE DATA FOR INDIVIDUAL FIELDS
 ;;  FOR EXPORT.
 ;
 ;IHS/CMI/THL BROKE ROUTINE INTO BWMDE2 AND BWMDE21
 ;DUE TO ROUTINE SIZE - PATCH 7
 ;
CDCDT(FMDATE) ;EP
 ;Begin Y2K fix
 ;---> CHANGE FILEMAN DATE FORMAT TO CDC DATE FORMAT (MMDDYY).
 ;Q $E(FMDATE,4,5)_$E(FMDATE,6,7)_($E(FMDATE,2,3))
 ;
 ;MOD PER THL 03/25/99 FOR CDC V4.0 AND Y2K COMPLIANCE
 ;
 Q:'FMDATE ""
 Q $E(FMDATE,4,5)_$E(FMDATE,6,7)_($E(FMDATE,1,3)+1700)  ;Y2000
 ;
 ;END MOD PER THL 03/25/99 FOR CDC V4.0 AND Y2K COMPLIANCE
 ;End Y2k fix
 ;
STSCR(SITE) ;EP
 ;---> TRIBAL FIPS CODE.
 ; Call with SITE = site ien
 ; Return     BWX = 2 digit numeric FIPS or tribal code for state, right justified.
 N BWX
 S BWX=$P($G(^BWSITE(SITE,0)),U,11)
 I BWX]"" S BWX=$$RJ^XLFSTR(BWX,2,"0")
 Q BWX
 ;
 ;
CNTYSCR(SITE) ;EP
 ;---> COUNTY OF SCREENING.
 ; Call with SITE = site ien
 ; Return     BWX = 3 digit numeric FIPS code for county, right justified, if none then return 999.
 ;
 N BWX
 S BWX=$P($G(^BWSITE(SITE,0)),U,16)
 I BWX>0 S BWX=$$RJ^XLFSTR(BWX,3,"0")
 E  S BWX=999
 Q BWX
 ;
 ;
CITY() ;EP
 ;---> CITY OF SCREENING.
 Q $P($G(^AUTTLOC(DUZ(2),0)),U,13)
 ;
ENROLL() ;EP
 ;---> ENROLLMENT SITE - DUZ(2) (INSTITUTION FILE).
 Q $J($P(BW0,U,10),5)
 ;
PSCRSI() ;EP
 ;---> PAP SCREENING SITE--OPTIONAL.
 Q:BWPAP $J($P(BW0,U,10),5)
 Q ""
 ;
MSCRSI() ;EP
 ;---> MAM SCREENING SITE--OPTIONAL.
 Q:BWMAM $J($P(BW0,U,10),5)
 Q ""
 ;
PATID() ;EP
 ;---> UNIQUE PATIENT IDENTIFIER.
 D:$$CDCID^BWUTL1(BWDFN)']"" CDCID^BWPATE(BWDFN)
 Q $$CDCID^BWUTL1(BWDFN)
 ;
RECID() ;EP
 ;---> RECORD IDENTIFIER FOR THIS PATIENT.
 ;---> FIRST DIGIT IS 1 IF IT'S A PAP, 2 IF IT'S A MAM.
 ;---> SECOND DIGIT IS THE ONES DIGIT OF THE YEAR, LAST FOUR DIGITS
 ;---> ARE THE 1-10000 DIGITS OF THE ACCESSION#.
 N X
 S X=$P(BWACCN,"-",2)
 Q $S($E(BWACCN)="P":1,1:2)_$E(BWACCN,4)_$E(X,($L(X)-3),$L(X))
 ;
RECTYP() ;EP
 ;---> RECORD TYPE: 1=ADD(NEW), 2=UPDATE.
 ;Q $P(BW0,U,17)
 ;---> FOR NOW, PER TELEPHONE CONVERSATION WITH BILL HELSEL 3/12/96,
 ;---> SINCE WE ARE RE-EXPORTING ALL RECORDS WITH EACH SUBMISSION,
 ;---> IT'S OKAY TO JUST FLAG THEM ALL AS NEW.
 ;IHS/CIM/THL PATCH 8 DEFAULT RECORD TYPE CHANGED TO 2
 Q 2
 ;
CNTYRES() ;EP
 ;---> COUNTY OF RESIDENCE--OPTIONAL.
 Q ""
 ;
STRES() ;EP
 ;---> STATE OF RESIDENCE, FIPS CODE.
 Q:'$D(^DPT(BWDFN,.11)) ""
 Q:$P(^DPT(BWDFN,.11),U,5)="" ""
 Q $P(^DIC(5,$P(^DPT(BWDFN,.11),U,5),0),U,3)
 ;
ZIP() ;EP
 ;---> ZIP OF RESIDENCE.
 N X
 S X=$E($$ZIP^BWUTL1(BWDFN),1,5)
 Q:+X X
 Q ""
 ;
DOB() ;EP
 ;---> DATE OF BIRTH, FORMAT: 09011956.
 N X
 S X=$$DOB^BWUTL1(BWDFN)
 Q:'+X ""
 Q $E(X,4,5)_$E(X,6,7)_($E(X,1,3)+1700)
 ;
 ;
ENRLDT() ;EP
 ;---> ENROLLMENT DATE.  IF PATIENT DOESN'T HAVE ENROLLMENT DATE,
 ;---> COMPUTE IT AND STUFF IT FOR THE PATIENT, THEN USE IT HERE.
 N X S X=$P(^BWP(BWDFN,0),U,21)
 D:'X ENROL^BWMDE5(BWDFN,$P(^BWSITE(DUZ(2),0),U,17),.X)
 ;---> IF COMPUTED DATE IS MM/YY ONLY, MAKE IT THE FIRST OF THE MONTH.
 S:$E(X,6,7)="00" $E(X,6,7)="01"
 Q $$CDCDT(X)
 ;
REFER() ;EP
 ;---> REFERRAL SOURCE: IF NOT TRACKED, 4="UNKNOWN".
 N X S X=$P(^BWP(BWDFN,0),U,22)
 Q:X X
 Q 4
 ;
BRSYMP() ;EP
 ;---> BREAST SYMTOMS: IF NOT TRACKED, 3="UNKNOWN".
 Q:'BWMAM 3
 ;---> IF THIS PCD IS MAM, RETURN FIELD 2.35 OF BW PROCEDURE FILE,
 ;---> WHICH SHOULD HAVE BEEN ENTERED MANUALLY.
 Q:$P(BW2,U,35) $P(BW2,U,35)
 Q 3
 ;
CBE() ;EP
 Q:'BWMAM 3
 ;---> RETURN FIELD 2.32 OF BW PROCEDURE FILE.
 ;---> FIELD 2.32 IS ENTERED AUTOMATICALLY IF A CBE IS ADDED FROM
 ;---> THE "PROCEDURE FOLLOWUP MENU" FOR A PAP; OR, IT IS ENTERED
 ;---> MANUALLY ON PAGE 2 OF A MAMMOGRAM.
 ;
 ;===> ANMC MODS BEGIN, IHS/ANMC/MWRZ  12/12/96
 ;N Z S Z=$P(BW2,U,32)
 ;Q:('Z&(BWMAM)) ""
 ;Q:'Z 3
 ;;---> NOW COLLAPSE CDC CLINCAL CATEGORIES TO 4 MDE CATEGORIES.
 ;Q:'$D(^BWCBE(Z,0)) 0 ;---> IF ZERO, PROBLEM WITH ^BWCBE POINTER.
 ;Q $P(^BWCBE(Z,0),U,2)
 ;
 ;
 ;---> GET MANUALLY ENTERED CBE RESULT FOR THIS PROCEDURE.
 N Z S Z=$P(BW2,U,32)
 ;
 ;---> IF NO CBE RESULT AND THIS IS A PAP, RETURN 3.
 Q:('Z&(BWPAP)) 3
 ;
 ;---> IF THERE IS A CBE RESULT, RETURN 1-4 MDE CATEGORIES.
 ;---> (IF ZERO, PROBLEM WITH ^BWCBE POINTER.)
 I Z Q:'$D(^BWCBE(Z,0)) 0  Q $P(^BWCBE(Z,0),U,2)
 ;
 ;---> IF IT WASN'T A PAP AND ISN'T A MAM, RETURN "" (ERROR).
 ;
 ;---> IF NO CBE RESULT AND THIS IS A MAM, LOOK FOR LAST CBE.
 N N,Y K BW("CBE") S N=0
 F  S N=$O(^BWPCD("C",BWDFN,N)) Q:'N  D
 .S Y=^BWPCD(N,0)
 .;---> IF THIS IS A CBE, GET DATE AND RESULT.
 .I $P(Y,U,4)=27 S BWCBEDT=$P(Y,U,12),BWCBERS=$P(Y,U,5) D
 ..Q:BWCBEDT'<$P(BW0,U,12)
 ..;---> IF CBE IS >1 YEAR BEFORE MAM, IGNORE IT.
 ..N X,X1,X2,Y S X1=$P(BW0,U,12),X2=BWCBEDT  D ^%DTC Q:X>365
 ..S BW("CBE",9999999-BWCBEDT)=BWCBERS
 ;
 ;---> IF NO CBE'S, RETURN "".
 Q:'$D(BW("CBE")) ""
 ;
 ;---> GET RESULT AND COLLAPSE TO 4 MDE CATEGORIES.
 N N S N=$O(BW("CBE",0))
 S BWCBERS=$P(BW("CBE",N),U)
 Q:BWCBERS=11 1
 Q:BWCBERS=64 1
 Q:BWCBERS=78 ""
 Q:BWCBERS="" ""
 Q 2
 ;
 ;===> ANMC MODS END, IHS/ANMC/MWRZ  12/12/96
 ;
 ;
CBEDT() ;EP
 Q:BWPAP ""
 ;---> RETURN THE DATE OF THE CBE.
 ;---> NOTE: IF THERE'S A DATE, BUT NO RESULT ABOVE, THEN SEND THE DATE
 ;---> SO THAT ERROR WILL SHOW UP NEED TO ENTER RESULT FOR THAT CBE.
 ;Q:789[$P(BW2,U,32) ""
 ;
 ;===> ANMC MODS BEGIN, IHS/ANMC/MWRZ  12/12/96
 ;---> IF THE DATE HAS BEEN ENTERED MANUALLY, USE IT.
 Q:$P(BW2,U,33) $$CDCDT($P(BW2,U,33))
 ;---> IF THIS IS A PAP AND NO CBE DATE ENTERED MANUALLY, QUIT ""
 ;---> (DON'T LOOK AT CBE ARRAY).
 ;---> THIS MUST BE A MAM, SO LOOK FOR CBE ARRAY.
 Q:'$D(BW("CBE")) ""
 ;---> USE ABOVE BW("CBE") ARRAY TO RETURN DATE OF LAST CBE.
 N N S N=$O(BW("CBE",0))
 Q:'N ""
 Q $$CDCDT(9999999-N)
 ;===> ANMC MODS END, IHS/ANMC/MWRZ  12/12/96
 ;
PPREV() ;EP
 ;---> BUILD BW("PAP") ARRAY OF PREVIOUS PAPS.  RETURN 3 IF NONE.
 Q:'BWPAP 3
 N N,Y K BW("PAP") S N=0
 F  S N=$O(^BWPCD("C",BWDFN,N)) Q:'N  D
 .S Y=^BWPCD(N,0)
 .I $P(Y,U,4)=1 S BWPAPDT=$P(Y,U,12) D
 ..Q:BWPAPDT'<$P(BW0,U,12)
 ..S BW("PAP",9999999-BWPAPDT)=BWPAPDT
 Q:$D(BW("PAP")) 1
 Q 3
 ;
PPREVDT() ;EP
 Q:'BWPAP ""
 ;---> USE ABOVE BW("PAP") ARRAY TO RETURN DATE OF PREVIOUS PAP.
 Q:'$D(BW("PAP")) ""
 N N
 S N=$O(BW("PAP",0))
 ;Begin Y2k fix
 ;I N S N=BW("PAP",N) K BW("PAP") Q $E(N,4,5)_$E(N,2,3)
 ;
 ;MOD PER THL 03/25/99 FOR CDC V4.0 AND Y2K COMPLIANCE
 ;
 I N S N=BW("PAP",N) K BW("PAP") Q $E(N,4,5)_($E(N,1,3)+1700)  ;Y2000
 ;
 ;END MOD PER THL 03/25/99 FOR CDC V4.0 AND Y2K COMPLIANCE
 ;End Y2k fix
 ;
 Q ""
 ;
ADQPAP() ;EP
 ;---> ADEQUACY OF SCREENING PAP--OPTIONAL.
 Q ""
 ;
 ;
PRESLT() ;EP
 ;---> IF THIS PCD IS NOT PAP, RETURN 9 & SET BWPABN=0 (ABNORMAL PAP=0).
 ;---> (BWPABN=0 WILL BLANK FILL ALL DATA IN ABNORMAL PAP SECTION.)
 ;
 I 'BWPAP S BWPABN=0 Q " 9"
 ;---> THIS PROCEDURE MUST BE A PAP.
 ;---> IF NO RESULT, RETURN 11 (RESULT PENDING) AND SET BWPABN=0.
 I 'BWRESN S BWPABN=0 Q 11
 ;
 ;---> RETURN THE CDC CODE FOR THE RESULT (PC 24).  IF RESULT IS 3,4,5
 ;---> OR 6, SET BWPABN=1 TO EXTRACT DATA FOR ABNORMAL PAP SECTION.
 N X S X=$P(^BWDIAG(BWRESN,0),U,24)
 S BWPABN=$S(6543[X!(X=14):1,1:0)
 Q $J(X,2)
 ;
POTHR() ;EP
 ;---> IF RESULT IS "OTHER" (7), RETURN TEXT OF THE RESULT
 Q:'BWPAP ""
 Q:'BWRESN ""
 Q:$P(^BWDIAG(BWRESN,0),U,24)=7 $E(BWRES,1,20)
 Q ""
 ;
PSCRDT() ;EP
 ;---> IF THIS PCD IS A PAP, RETURN THE DATE OF THIS PCD.
 Q:'BWPAP ""
 Q:BWPAP $$CDCDT($P(BW0,U,12))
 ;
PPAY() ;EP
 ;---> PAP PAID FOR BY COOP AGREEMENT FUNDS, 3=DON'T KNOW.
 Q:'BWPAP ""
 N X
 S X=$$PRESLT
 Q:X=9!(X=10)!(X=11) ""
 Q:BWPAP 1
 Q 3