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

BWMDEU.m

Go to the documentation of this file.
  1. BWMDEU ;IHS/ANMC/MWR - MDE FUNCTIONS.;29-Oct-2003 21:34;PLS
  1. ;;2.0;WOMEN'S HEALTH;**8,9**;MAY 16, 1996
  1. ; CDC Export functions to retrieve data for individual fields.
  1. ;
  1. ;
  1. RACE(BWDFN,MDEVER,MDERACE) ; EP - CDC's MDE Race classification.
  1. ; Call with BWDFN = ien of patient in file PATIENT (#9000001)
  1. ; MDEVER = version number of CDC Minimum Data Extraction (MDE)
  1. ;
  1. ; Returns MDERACE = MDE Race classification based on MDE version number (passed by reference).
  1. ; Contains array of all races reported by patient
  1. ;
  1. N BWIEN,CODE,I,TRIBE
  1. ;
  1. ; Build array of race code for patient's designated races
  1. S I=0
  1. F S I=$O(^BWP(BWDFN,2,I)) Q:'I D
  1. . S BWIEN=+^BWP(BWDFN,2,I,0)
  1. . S CODE=$O(^BWRACE(BWIEN,1,"AC",MDEVER,0))
  1. . I CODE S MDERACE(I)=CODE
  1. ;
  1. ; If no race designated then return a CDC MDE Race code based on tribal relationship
  1. ; ***These relationships should moved to a table. ***
  1. I '$O(MDERACE(0)) D
  1. . S TRIBE=$P($G(^AUPNPAT(BWDFN,11)),U,8),BWIEN=0
  1. . I TRIBE D
  1. . . I "^1^215^219^220^"[(U_TRIBE_U) S BWIEN=6 Q ; Other
  1. . . I "^206^207^208^209^210^212^213^217^"[(U_TRIBE_U) S BWIEN=3 Q ; Asian
  1. . . I TRIBE=211 S BWIEN=4 Q ; Native Hawaiian/Pacific Islander
  1. . . I TRIBE=214 S BWIEN=1 Q ; White
  1. . . I TRIBE=216 S BWIEN=2 Q ; Black
  1. . . S BWIEN=5 ; American Indian/Alaska Native
  1. . I BWIEN D
  1. . . S CODE=$O(^BWRACE(BWIEN,1,"AC",MDEVER,0))
  1. . . I CODE S MDERACE(1)=CODE
  1. ;
  1. ; If no race designated then return 'unknown' for corresponding MDE version
  1. I '$O(MDERACE(0)) D
  1. . S CODE=$O(^BWRACE(7,1,"AC",MDEVER,0))
  1. . I CODE S MDERACE(1)=CODE
  1. Q
  1. ;
  1. ;
  1. HISP(BWDFN) ; EP - Determine Hispanic/Latino origin
  1. ; Call with BWDFN = ien of patient in file PATIENT (#9000001)
  1. ; Returns BWY = 1 (yes), 2 (no), 3 (unknown)
  1. ;
  1. N BWY,TRIBE
  1. S TRIBE=$P($G(^AUPNPAT(BWDFN,11)),U,8)
  1. I TRIBE=215 S BWY=1
  1. E S BWY=3
  1. Q BWY
  1. ;
  1. ;
  1. BSU(BWDT,SITE) ; EP - Determine Bethesda System Used
  1. ; Call with BWDT = "as of" date to check
  1. ; SITE = site to check (pointer to BW SITE PARAMETER file #9002086.02)
  1. ;
  1. ; Returns BWBSU = 1 (Bethesda 1991)
  1. ; 2 (Bethesda 2001)
  1. ;
  1. N BWBSU,X
  1. ;
  1. S X=$G(^BWSITE(SITE,.51))
  1. I $P(X,"^",2),BWDT'<$P(X,"^",2) S BWBSU=2
  1. E S BWBSU=1
  1. ;
  1. Q BWBSU
  1. ;
  1. ;
  1. SAPT(BWIEN,BWBSU,BWMDEV) ; EP - Specimen Adequacy of Pap Test
  1. ; Call with BWIEN = ien of entry in file BW PROCEDURE (#9002086.1)
  1. ; BWBSU = Bethesda System Used
  1. ; BWMDEV = MDE version
  1. ;
  1. ; Returns BWSAPT = Specimen adequacy based on Bethesda system used
  1. ;
  1. N BWPDT,BWSAPT
  1. ;
  1. ; Specimen adequacy not collected under versions of MDE prior to 5.0
  1. I BWMDEV<50 S BWSAPT=" "
  1. ;
  1. ; Need to code for Bethesda 2001 and collected after 10/01/02.
  1. I BWMDEV=50 D
  1. . S BWSAPT=$P($G(^BWPCD(BWIEN,.3)),"^")
  1. . S BWPDT=$P($G(^BWPCD(BWIEN,0)),"^",12)
  1. . I BWBSU=2,BWSAPT=2 S BWSAPT=1 Q ; code 2 only for Bethesda 1991
  1. . I BWPDT>3020930,BWSAPT="" S BWSAPT=4 Q ; default to 4-unknown when none entered.
  1. ;
  1. Q BWSAPT
  1. ;
  1. ;
  1. POTHR(BWIEN,BWBSU,BWRPT) ; EP - Text results of Pap Test
  1. ; Call with BWIEN = ien of entry in file BW PROCEDURE (#9002086.1)
  1. ; BWBSU = Bethesda system used
  1. ; BWRPT = Results of Pap Test
  1. ;
  1. ; Return BWRES = Pap test text results when result = other
  1. ;
  1. N BWRES,X,Y
  1. S BWRES="",X=+$P($G(^BWPCD(BWIEN,0)),"^",5),Y=""
  1. I X S Y=$P($G(^BWDIAG(X,0)),"^")
  1. ;
  1. I BWBSU=1,BWRPT=7 S BWRES=$E(Y,1,20)
  1. I BWBSU=2,BWRPT=8 S BWRES=$E(Y,1,20)
  1. ;
  1. Q BWRES
  1. ;
  1. ;
  1. PSCRDT(BWDT,BWBSU,BWRPT) ; EP - Return date of Pap Test
  1. ; Call with BWDT = date of Pap test
  1. ; BWBSU = Bethesda system used
  1. ; BWRPT = results of Pap test
  1. ;
  1. ; Returns BWPDT = date of Pap test in MDE date format
  1. ;
  1. N BWPDT,FLAG
  1. S FLAG=1
  1. ;
  1. I BWBSU=1,BWRPT>8,BWRPT<11 S FLAG=0
  1. I BWBSU=2,BWRPT>8,BWRPT<11 S FLAG=0
  1. ;
  1. I FLAG,BWDT S BWPDT=$TR($$FMTE^XLFDT(BWDT,"5DZ"),"/")
  1. E S BWPDT=$$REPEAT^XLFSTR(" ",8)
  1. Q BWPDT
  1. ;
  1. ;
  1. PRESLT(BWIEN,BWBSU) ; EP - Results of Pap Test
  1. ; Call with BWIEN = ien of entry in file BW PROCEDURE (#9002086.1)
  1. ; BWBSU = Bethesda system used (1-Bethesda 1991) (2-Bethesda 2001)
  1. ;
  1. ; Return BWRESLT = result of Pap test based on Bethesda system used
  1. ;
  1. ;
  1. N BWRESN,BWRESLT
  1. ;
  1. S BWRESN=$P($G(^BWPCD(BWIEN,0)),"^",5),BWRESLT=""
  1. ; If no result, return 11 (Result pending).
  1. I 'BWRESN S BWRESLT=11
  1. ;
  1. ; Return CDC code for the result.
  1. I BWRESN D
  1. . I BWBSU=1 S BWRESLT=$P($G(^BWDIAG(BWRESN,0)),"^",24) Q
  1. . I BWBSU=2 S BWRESLT=$P($G(^BWDIAG(BWRESN,1)),"^",1)
  1. ;
  1. I BWRESLT,BWRESLT<10 S BWRESLT=$$RJ^XLFSTR(BWRESLT,2,"0")
  1. ;
  1. Q BWRESLT
  1. ;
  1. ;
  1. PABN(BWBSU,BWPRESLT) ; EP - Abnormal Pap Flag
  1. ; Call with BWBSU = Bethesda system used (1-Bethesda 1991) (2-Bethesda 2001)
  1. ; BWPRESLT = results of Pap test
  1. ;
  1. ; Return BWPABN = 1-yes, 2-no
  1. ;
  1. N BWPABN
  1. S BWPABN=""
  1. I BWBSU=1 D
  1. . I BWPRESLT=11 S BWPABN=0 Q
  1. . I BWPRESLT=14 S BWPABN=1 Q
  1. . I "3456"[BWPRESLT S BWPABN=1 Q
  1. . S BWPABN=0
  1. I BWBSU=2 D
  1. . I BWPRESLT=11 S BWPABN=0 Q
  1. . I "4567"[BWPRESLT S BWPABN=1 Q
  1. . S BWPABN=0
  1. ;
  1. Q BWPABN
  1. ;
  1. ;
  1. PPAY(BWBSU,BWPRESLT) ; EP - Pap paid for by NBCCEDP funds
  1. ; Call with BWBSU = Bethesda system used (1-Bethesda 1991) (2-Bethesda 2001)
  1. ; BWPRESLT = results of Pap test
  1. ;
  1. ; Return BWPPAY = 1-yes, 2-no, 3=unknown
  1. ;
  1. N BWPPAY
  1. S BWPPAY=1
  1. I BWBSU=1 D
  1. . I BWPRESLT>8,BWPRESLT<12 S BWPPAY="" Q
  1. . I BWPRESLT>11,BWPRESLT<14 S BWPPAY=2
  1. I BWBSU=2 D
  1. . I BWPRESLT>8,BWPRESLT<12 S BWPPAY="" Q
  1. . I BWPRESLT>11,BWPRESLT<14 S BWPPAY=2
  1. Q BWPPAY
  1. ;
  1. ;
  1. PWKUP(BWIEN,BWBSU,BWPRESLT) ; EP - Diagnostic workup 1=PLANNED, 2=NOT PLANNED, 3=UNDETERMINED.
  1. ; Call with BWIEN = ien of entry in file BW PROCEDURE (#9002086.1)
  1. ; BWBSU = Bethesda system used (1-Bethesda 1991) (2-Bethesda 2001)
  1. ; BWPRESLT = result of Pap test
  1. ;
  1. ; Return BWPWKUP = CDC code for diagnostic workup
  1. ;
  1. N BWPWKUP,X
  1. ;
  1. I BWBSU=1,BWPRESLT=11 S BWPWKUP=3
  1. I BWBSU=2,BWPRESLT=11 S BWPWKUP=3
  1. S X=$P($G(^BWPCD(BWIEN,2)),"^",20)
  1. I X S BWPWKUP=X
  1. E S BWPWKUP=2
  1. Q BWPWKUP
  1. ;
  1. ;
  1. MPREVDT(BWIEN) ; EP - Retrieve date of previous mammogram if any in CDC MDE date format
  1. ; Call with BWIEN = ien of entry in file BW PROCEDURE (#9002086.1)
  1. ;
  1. ; Return BWMDT = date of mammogram in CDC MDE date format (MMYYYY)
  1. ;
  1. N BWMAM,BWMDT,BWI,CUTOFF,DFN,N,X,Y
  1. ;
  1. ; Look for previous mammograms (ien 25, 26, or 28)
  1. S X=$G(^BWPCD(BWIEN,0))
  1. S DFN=+$P(X,"^",2),CUTOFF=+$P(^BWPCD(BWIEN,0),"^",12)
  1. S N=0
  1. F S N=$O(^BWPCD("C",DFN,N)) Q:'N D
  1. . S Y=^BWPCD(N,0)
  1. . I "^25^26^28^"'[(U_$P(Y,U,4)_U) Q ;CIA/DKM - added delimeters
  1. . I $P(Y,"^",12)<CUTOFF S BWMAM($P(Y,"^",12))=""
  1. ;
  1. ; Get last date in list and return in CDC MDE date format
  1. S BWI=$O(BWMAM(""),-1)
  1. I BWI S BWMDT=$E(BWI,4,5)_($E(BWI,1,3)+1700) ;$$CDCDT^BWMDEU2(BWI)
  1. E S BWMDT=""
  1. Q BWMDT
  1. ;
  1. ;
  1. MSCRDT(BWDT,BWRPT) ; EP - Return date of Mammogram Test
  1. ; Call with BWDT = date of Mammogram test
  1. ; BWRPT = results of Mammogram test
  1. ;
  1. ; Returns BWPDT = date of Pap test in MDE date format
  1. ;
  1. N BWPDT,FLAG
  1. S FLAG=1
  1. ;
  1. I BWRPT>7,BWRPT<10 S FLAG=0
  1. ;
  1. I FLAG,BWDT S BWPDT=$$CDCDT^BWMDEU2(BWDT)
  1. E S BWPDT=$$REPEAT^XLFSTR(" ",8)
  1. Q BWPDT
  1. ;
  1. ;
  1. ; Call with DFN = patient ien in Patient file
  1. ; PCCDATE = PCC event date in FileMan format
  1. ; MDATE = date of mammogram in MDE date format
  1. ; RESULT = mammography test result from item k of MDE
  1. ; SITE = pointer to site in BW SITE file
  1. ;
  1. ; Reuturns PAID = 1-yes, 2-no, 3-unknown
  1. ;
  1. N AGE,PAID
  1. S PAID=""
  1. ; PCC event date before CDC Funding Began date, funded if procedure is before CDC Funding date
  1. I MDATE,PCCDATE<$P($G(^BWSITE(SITE,0)),"^",17) S PAID=1
  1. ; Result type 12 do not have funding
  1. I 'PAID,RESULT=12 S PAID=2
  1. ; Age logic ensures that 75% of the reported population meets the CDC 75% rule.
  1. ; IHS WH does not turn away patients not meeting the age limitations.
  1. ; Ensure that at least 75% of those between ages 50 and 65 are funded
  1. I PAID>1 D
  1. . S AGE=+$$AGE^AUPNPAT(DFN)
  1. . I AGE<50!(AGE>65) S AGE=$R(100)
  1. . E S AGE=1
  1. . S PAID=$S(AGE<26:1,1:2)
  1. ; Date of Mammogram required to mark funding as YES
  1. I PAID="",MDATE S PAID=1
  1. Q PAID