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

BRAWH.m

Go to the documentation of this file.
BRAWH ; IHS/ITSC/PDW,CLS - RADIOLOGY WOMEN'S HEALTH LINK ; 20 Apr 2011  7:23 PM
 ;;5.0;Radiology/Nuclear Medicine;**1002,1003**;Nov 01, 2010;Build 3
 ;;  RA*5.0*1002 IHS/OIT/CLS modified to accomodate 2007 mammogram CPT's
 ;;  
 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
 ;;  CREATE MAMMOGRAM PROCEDURE IN WOMEN'S HEALTH FOR THIS PATIENT.
 ;;  CALLED BY ^RART WHEN A RADIOLOGY REPORT IS VERIFIED.
 ;;  CALLED BY ^RARTE1 WHEN A RADIOLOGY REPORT IS UNVERIFIED.
 ;;  CALLED BY ^BRAEXPT WHEN EXPORTING HISTORICAL MAMS TO WOMEN'S HEALTH
 ;
 ;G LOOP
 ;---> REQUIRED VARIABLES: DFN  = DFN OF RADIOLOGY PATIENT.
 ;--->                     DATE = INVERSE DATE/TIME OF VISIT.
 ;--->                     CASE = IEN OF RADIOLOGY EXAM (CASE).
 ;
 ;---> OPTIONAL VARIABLE:  RANEWP = TOTAL NEW WH PATIENTS ADDED.
 ;--->                     RAMCNT = TOTAL NEW MAMS PROCEDURES ADDED.
 ;--->                     THESE IF CALLED FROM ^BRAEXPT ROUTINE.
 ;
 ;---> GENERATED VARIBLES:
 ;---> RAPROC = IEN OF RADIOLOGY PROCEDURE (FILE #71), THEN IT
 ;--->          GETS CHANGED TO WOMEN'S HEALTH PROCEDURE TYPE
 ;--->                                   (FILE #9002086.2).
 ;---> RALOC  = WARD/CLINIC/LOCATION (FILE #44).
 ;---> RADATE = DATE OF THE PROCEDURE.
 ;---> RAPCCDT= PCC DATE/TIME IF IT EXISTS.
 ;---> RAPROV = ORDERING PROVIDER.
 ;---> RAMOD  = LEFT OR RIGHT, IF IT'S A UNILATERAL MAMMOGRAM.
 ;---> RADX   = RADIOLOGY DIAGNOSTIC CODE.
 ;---> RABWDX = WOMEN'S HEALTH RESULT/DIAGNOSIS.
 ;
CREATE(DFN,DATE,CASE) ;EP
 N RAPROC,RALOC,RADATE,RAPCCDT,RAPROV,RAMOD,RADX,RABWDX,RALEFT,RARIGHT
 ;N RACASE,RACPT,RAERR,;,RAEXAM0 ;cmn'td out IHS/HQW/SCR 10/29/01 **11**
 N RACASE,RACPT,RAERR,BRAIRAD  ;,RAEXAM0  ;IHS/HQW/SCR 10/29/01 **11** 
 N D,DR,DIE,DIC  ;IHS/ANMC/CLS 10/28/97
 ;
 ;---> QUIT IF RADIOLOGY DATA IS NOT DEFINED OR ="".
 Q:($G(DFN)']"")!($G(DATE)']"")!($G(CASE)']"")
 I $P($G(^DPT(DFN,0)),U,2)'="F" Q
 I $$AGE^AUPNPAT(DFN)<13 Q
 Q:'$D(^RADPT(DFN,"DT",DATE,"P",CASE,0))
 ;
 ;---> RAEXAM0=ZERO NODE OF RADIOLOGY EXAM.
 S RAEXAM0=^RADPT(DFN,"DT",DATE,"P",CASE,0)
 ;
 ;The next line identifies the Interpreting Physician for WH records
 S BRAIRAD=$P(RAEXAM0,U,15)   ;IHS/HQW/SCR 10/29/01 **11**
 ;
 S RACPTI=$P(^RAMIS(71,$P(RAEXAM0,U,2),0),U,9)
 S RACPT=$$GET1^DIQ(81,RACPTI,.01)
 ;
 ;IHS/BJI/DAY - Patch 1003 - Add new G codes for Digital Mammos
 Q:(RACPT'=77055)&(RACPT'=77056)&(RACPT'=77057)&(RACPT'=77031)&(RACPT'=76645)&(RACPT'="G0202")&(RACPT'="G0204")&(RACPT'="G0206")
 ;End patch
 ;
 ;
 ;---> QUIT IF NO WOMEN'S HEALTH SITE PARAMETER FILE ON THIS MACHINE.
 Q:'$D(^BWSITE(DUZ(2)))
 ;
 ;---> QUIT IF "IMPORT MAMMOGRAMS FROM RADIOLOGY" IS NOT SET TO "YES"
 ;---> IN THE WOMEN'S HEALTH SITE PARAMETERS.
 N Y S Y=^BWSITE(DUZ(2),0)
 Q:'$P(Y,U,10)
 ;
 ;---> SET BRASTAT =THE STATUS (OPEN OR CLOSED) IN WOMEN'S HEALTH.
 ;---> THAT MAMMOGRAMS SHOULD RECEIVE WHEN COPIED OVER FROM RADIOLOGY.
 S BRASTAT=$P(Y,U,23) S:BRASTAT="" BRASTAT="o"
 ;
 ;---> BELOW ARE IENS FOR BW PROCEDURE TYPE FILE #9002086.2.
 ;---> IEN 26 IN ^BWPN( IS UNILATERAL MAMMOGRAM.
 ;---> IEN 25 IN ^BWPN( IS BILATERAL MAMMOGRAM.
 ;---> IEN 28 IN ^BWPN( IS SCREENING MAMMOGRAM.
 ;---> IEN 35 IN ^BWPN( IS STERIOTACTIC BIOPSY
 ;---> IEN 38 IN ^BWPN( IS BREAST ULTRASOUND
 ;
 I RACPT=76090 S RAPROC=26 D COPY(RAEXAM0) G EXIT
 I RACPT=76091 S RAPROC=25 D COPY(RAEXAM0) G EXIT
 I RACPT=76092 S RAPROC=28 D COPY(RAEXAM0) G EXIT
 I RACPT=76095 S RAPROC=35 D COPY(RAEXAM0) G EXIT  ;IHS/ANMC/MWR
 I RACPT=76645 S RAPROC=38 D COPY(RAEXAM0) G EXIT  ;IHS/ANMC/MWR
 ;
 ;----> ADDED 2007 CPT CODES
 I RACPT=77055 S RAPROC=26 D COPY(RAEXAM0) G EXIT  ;IHS/OIT/CLS patch 1002
 I RACPT=77056 S RAPROC=25 D COPY(RAEXAM0) G EXIT  ;IHS/OIT/CLS patch 1002
 I RACPT=77057 S RAPROC=28 D COPY(RAEXAM0) G EXIT  ;IHS/OIT/CLS patch 1002
 I RACPT=77031 S RAPROC=35 D COPY(RAEXAM0) G EXIT  ;IHS/ANMC/MWR  ;IHS/OIT/CLS patch 1002
 I RACPT=76645 S RAPROC=38 D COPY(RAEXAM0) G EXIT  ;IHS/ANMC/MWR
 ;
 ;IHS/BJI/DAY - Patch 1003 - Add new G codes for Digital Mammos
 I RACPT="G0202" S RAPROC=28 D COPY(RAEXAM0) G EXIT
 I RACPT="G0204" S RAPROC=25 D COPY(RAEXAM0) G EXIT
 I RACPT="G0206" S RAPROC=26 D COPY(RAEXAM0) G EXIT
 ;End patch
 ;
EXIT ;EP
 K I,N,X
 Q
 ;
 ;
COPY(Y) ;EP
 ;---> COPY MAM PROCEDURE DATA FROM RADIOLOGY TO WOMEN'S HEALTH.
 ;---> VARIABLE DFN=PATIENT
 ;---> LOCATION=DUZ(2)
 ;---> WARD/CLINIC/LOCATION
 N X
 S RALOC=$P(Y,U,8)
 ;
 ;---> RADATE=DATE OF THE PROCEDURE.
 S RADATE=$P($P(^RADPT(DFN,"DT",DATE,0),U),".")
 ;
 ;---> RECONSTRUCT THE FULL CASE# FOR THIS RAD PROCEDURE.
 ;---> THIS IS USED AS A LINK (XREF) BETWEEN THE RADIOLOGY PROCEDURE
 ;---> AND THE WOMEN'S HEALTH PROCEDURE.
 S RACASE=$E(RADATE,4,7)_$E(RADATE,2,3)_"-"_$P(Y,U)
 ;---> CHECK TO BE SURE THE CASE# XREF IS REALLY DOWN THERE.
 S:'$D(^RADPT("ADC",RACASE,DFN,DATE,CASE)) RACASE="UNKNOWN"
 ;
 ;---> QUIT IF THIS PROCEDURE HAS ALREADY BEEN SENT TO WOMEN'S HEALTH.
 I $D(^BWPCD("E",RACASE)) Q
 ;
 ;---> PCC DATE/TIME; IF NO TIME, ATTACH 12 NOON.
 I $D(^RADPT(DFN,"DT",DATE,"P",CASE,"PCC")) D
 .S RAPCCDT=$P(^RADPT(DFN,"DT",DATE,"P",CASE,"PCC"),U)
 .S:'$P(RAPCCDT,".",2) RAPCCDT=RAPCCDT_".12"
 ;
 ;
 ;---> REQUESTING PROVIDER/ORDERING PROVIDER
 ;---> USE FILE 16 "A3" POINTER TO PASS PROVIDER FILE #200 IEN.
 ;---> CHANGE THIS WHEN RADIOLOGY CONVERSION TO FILE #200 IS DONE.
 ;S RAPROV=^DIC(16,$P(Y,U,14),"A3") ;IHS/ISD/EDE 02/16/97
 ; chg file 16 to 200  IHS/ISD/EDE 02/16/97
 S RAPROV=$P(Y,U,14) ;IHS/ISD/EDE 02/16/97
 ;
 ;---> IF UNILATERAL, ATTEMPT TO PICK UP LEFT OR RIGHT MODIFIER.
 I RAPROC=26 D
 .I $D(^RADPT(DFN,"DT",DATE,"P",CASE,"M",0)) D
 ..N N S N=0
 ..F  S N=$O(^RADPT(DFN,"DT",DATE,"P",CASE,"M",N)) Q:'N  D
 ...S RAMOD=$P(^RADPT(DFN,"DT",DATE,"P",CASE,"M",N,0),U)
 ...S RAMOD=$P(^RAMIS(71.2,RAMOD,0),U)
 ...I "LEFTleft"[RAMOD S RALEFT=1
 ...I "RIGHTright"[RAMOD S RARIGHT=1
 ..Q:$D(RALEFT)&($D(RARIGHT))
 ..I $D(RALEFT) S RAMOD="l" Q
 ..I $D(RARIGHT) S RAMOD="r" Q
 ;
 ;---> IF THERE'S A DIAGNOSTIC CODE, ATTEMPT TO PICK UP DIAGNOSIS.
 ;---> USE "BW DIAGNOSTIC CODE TRANSLATION" FILE #9002086.32.
 S RADX=$P(Y,U,13)
 I +RADX I $D(^BWRADX("C",RADX)) S RABWDX=$O(^BWRADX("C",RADX,0))
 ;
 W !!?20,"* Updating Women's Health Database. *",!
 ;
PATIENT ;---> IF PATIENT ISN'T IN WOMEN'S HEALTH DATABASE, ADD HER.
 S RAERR=1
 I '$D(^BWP(DFN,0)) D
 .D AUTOADD^BWPATE(DFN,DUZ(2),.RAERR)
 .I $D(RANEWP) S:RAERR RANEWP=RANEWP+1
 Q:RAERR<0
 ;
PROC ;---> CREATE MAMMOGRAM PROCEDURE IN BW PROCEDURE FILE #9002086.1.
 ;
 S RADR=".02////"_DFN_";.03////"_$G(RAPCCDT)_";.04////"_RAPROC
 S RADR=RADR_";.05////"_$G(RABWDX)_";.07////"_RAPROV
 S RADR=RADR_";.09////"_$G(RAMOD)_";.1////"_DUZ(2)_";.11////"_RALOC
 S RADR=RADR_";.12////"_RADATE_";.14////"_BRASTAT_";.15////"_RACASE
 ;
 ;S RADR=RADR_";.18////.5;.19////"_DT  ;Cmnt'd out to add Interpreting Radiologist field IHS/HQW/SCR 10/29/01 **11**
 S RADR=RADR_";.18////.5;.19////"_DT_";.35////"_BRAIRAD  ;IHS/HQW/SCR 10/29/01 **11**
 ;
 D NEW2^BWPROC(DFN,RAPROC,RADATE,RADR,"","",.RAERR)
 I $D(RAMCNT) S:RAERR>-1 RAMCNT=RAMCNT+1
 Q
 ;
 ;
UPDATE(DFN,DATE,CASE) ;EP
 ;---> MODIFY WOMEN'S HEALTH PROCEDURE TO REFLECT CHANGE.
 ;---> CALLED FROM RARTE1 (DELETE A REPORT AND UNVERIFY A REPORT).
 ; maybe called by RAEDFN if the system is setup to send PCC date at EXAMINED
 ;
 ;
 ;Q:'$D(DFN)!('$D(DATE))!('$D(CASE))
 Q:'$G(DFN)!('$G(DATE))!('$G(CASE))  ;IHS/ITSC/CLS 12/31/2003
 Q:'$D(^RADPT(DFN,"DT",DATE,"P",CASE,0))
 I $P($G(^DPT(DFN,0)),U,2)'="F" Q
 I $$AGE^AUPNPAT(DFN)<13 Q
 ;
 W !!,?20,"* Updating Women's Health Database *",!
 ;
 N RAIEN,RADATE,RACASE,RAMSG
 ;
 ;---> RADATE=DATE OF PROCEDURE.
 S RADATE=$P($P(^RADPT(DFN,"DT",DATE,0),U),".")
 S RACASE=$P(^RADPT(DFN,"DT",DATE,"P",CASE,0),U)
 ;
 ;---> RACASE=RECONSTRUCTED CASE# OF PROCEDURE.
 S RACASE=$E(RADATE,4,7)_$E(RADATE,2,3)_"-"_RACASE
 ;---> QUIT IF NO CASE# XREF IN WOMEN'S HEALTH PROCEDURE FILE.
 Q:'$D(^BWPCD("E",RACASE))
 ;
 S RAIEN=$O(^BWPCD("E",RACASE,0))
 Q:'$D(^BWPCD(RAIEN,0))
 S RAMSG="* NOTE: THIS PROCEDURE HAS BEEN ALTERED IN RADIOLOGY.  "
 S RAMSG=RAMSG_"FOLLOW-UP REQUIRED!!  RADIOLOGY CASE# IS "_RACASE_"."
 ;---> IF THERE'S AN EXISTING CLINICAL HX, PRESERVE AND CONCATENATE IT
 ;---> TO THE END OF THE MESSAGE PASSED HERE.
 I $G(^BWPCD(RAIEN,3))]"" D
 .S RAMSG=RAMSG_"  PREVIOUS CLINICAL HX: "
 .S RAMSG=RAMSG_^BWPCD(RAIEN,3),RAMSG=$E(RAMSG,1,240)
 D RADMOD^BWPROC(RAIEN,RAMSG)
 Q
 ;
 ;
UPDTDX(DFN,DATE,CASE) ;EP - Called from BRAPRAD when report is filed
 ;
 N RAZERO,RACASE,RADATE,RAACC,RADA
 N RADX,RAIRAD,RABWDX,DA,DR
 I '$G(DFN) Q
 I '$G(DATE) Q
 I '$G(CASE) Q
 I '$D(^RADPT(DFN,"DT",DATE,"P",CASE,0)) Q
 I $P($G(^DPT(DFN,0)),U,2)'="F" Q
 I $$AGE^AUPNPAT(DFN)<13 Q
 ;
 ;Check WH Site Parameter to see if we pass data
 I $$GET1^DIQ(9002086.02,DUZ(2),.1,"I")'=1 Q
 ;
 ;Build Accession Number
 S RAZERO=$G(^RADPT(DFN,"DT",DATE,"P",CASE,0))
 I RAZERO="" Q
 S RACASE=$P(RAZERO,U)
 S RADATE=$P($P(^RADPT(DFN,"DT",DATE,0),U),".")
 S RAACC=$E(RADATE,4,7)_$E(RADATE,2,3)_"-"_RACASE
 ;
 ;If BW Procedure does not exist then Create it and quit
 S RADA=$O(^BWPCD("E",RAACC,0))
 I RADA="" D CREATE^BRAWH(DFN,DATE,CASE) Q
 ;
 ;Get DX
 S RADX=$P(RAZERO,U,13)
 I +RADX D
 .S RABWDX=$O(^BWRADX("C",RADX,0))
 .I RABWDX="" Q
 .;
 .;File in Women's Health BW PROCEDURE file
 .S DA=RADA
 .S DR=".05////"_RABWDX
 .D DIE^BWFMAN(9002086.1,DR,DA)
 ;
 ;Get Interpreting Radiologist
 S RAIRAD=$P(RAZERO,U,15)
 I +RAIRAD D
 .;
 .;File in Women's Health BW PROCEDURE file
 .S DA=RADA
 .S DR=".35////"_RAIRAD
 .D DIE^BWFMAN(9002086.1,DR,DA)
 ;
 Q
 ;
LOOP ;EP
 ;---> LOOP THROUGH PREVIOUS RA EXAMS AND PASS TO WOMEN'S HEALTH.
 ;
 ;---> QUIT IF NO WOMEN'S HEALTH SITE PARAMETER FILE ON THIS MACHINE.
 Q:'$D(^BWSITE(DUZ(2)))
 ;
 ;---> QUIT IF "IMPORT MAMMOGRAMS FROM RADIOLOGY" IS NOT SET TO "YES"
 ;---> IN THE WOMEN'S HEALTH SITE PARAMETERS.
 Q:'$P(^BWSITE(DUZ(2),0),U,10)
 ;
 N BRADT1,BRACOUNT,BRADFN,BRADT2,BRACS,BRA0,DIR,X,Y
 D GETDATE  ;IHS/OIT/CLS patch 1002 ask date S BRADT1 
 S BRACOUNT=0
 F  S BRADT1=$O(^RADPT("AR",BRADT1)) Q:'BRADT1  D
 .S BRADFN=0
 .F  S BRADFN=$O(^RADPT("AR",BRADT1,BRADFN)) Q:'BRADFN  D
 ..S BRADT2=0
 ..F  S BRADT2=$O(^RADPT("AR",BRADT1,BRADFN,BRADT2)) Q:'BRADT2  D
 ...Q:'$D(^RADPT(BRADFN,"DT",BRADT2))
 ...S BRACS=0
 ...F  S BRACS=$O(^RADPT(BRADFN,"DT",BRADT2,"P",BRACS)) Q:'BRACS  D
 ....Q:'$D(^RADPT(BRADFN,"DT",BRADT2,"P",BRACS,0))
 ....S BRA0=^RADPT(BRADFN,"DT",BRADT2,"P",BRACS,0)
 ....;---> QUIT IF THIS EXAM DOES NOT HAVE A STATUS OF COMPLETE.
 ....;Q:$P(BRA0,U,3)'=2
 ....;W !,^RADPT(BRADFN,"DT",BRADT2,"P",BRACS,0)
 ....D CREATE(BRADFN,BRADT2,BRACS)
 ....S BRACOUNT=BRACOUNT+1
 W !?5,BRACOUNT," procedures checked."
 Q
 ;
GETDATE ;---> GET STARTDATE FOR LOOP
 S DIR(0)="D^:"_DT_":AE"
 S DIR("A")="Enter starting date"
 S DIR("?")="Enter date to begin searching from"
 D ^DIR
 Q:$D(DIRUT)
 S BRADT1=Y
 Q