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

BWPCC.m

Go to the documentation of this file.
BWPCC ;IHS/ANMC/MWR - WOMEN'S HEALTH PCC LINK [ 08/16/01  3:50 PM ];05-Feb-2003 08:39;PLS
 ;;2.0;WOMEN'S HEALTH;**7,8,10,13**;APR 19, 1996;Build 9
 ;IHS/CMI/LAB - modified VPROC for CSV  *10*
 ;IHS/CMI/LAB - modified provider lookup for file 6/200
 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
 ;;  CREATE/EDIT A VISIT FILE ENTRY, CREATE A V FILE ENTRY.
 ;;  CALLED BY BWPROC1.
 ;
CREATE(BWDA,BWDUZ2,BW0) ;EP
 ;---> CREATE A VISIT FILE ENTRY, CREATE A V FILE ENTRY.
 ;---> CALLED BY BWPROC1.
 ;---> REQUIRED VARIABLES: BWDA=IEN OF PROCEDURE IN ^BWPCD(.
 ;--->                     BWDUZ2=DUZ(2), THE FACILITY.
 ;--->                     BW0=ZERO NODE OF THE PROC, ^BWPCD(BWDA,0).
 ;
 ;S DUZ(0) ="@" ;*COMEBACK ;FOR ANMC PART III SECURITY.
 ;
 ;---> QUIT IF NECESSARY VARIABLES ARE NOT PRESENT.
 Q:'$G(BWDA)!('$G(BWDUZ2))!($G(BW0)']"")
 ;
 N BWERR,BWPCDN,BWSITE,BWVFIL
 ;---> SET BWPCDN=IEN OF PROCEDURE TYPE, ^BWPN(.
 ;---> SET BWSITE=IEN OF FACILITY WHERE PROCEDURE WAS PERFORMED.
 ;---> SET BWVFIL=IEN OF V FILE.
 S BWPCDN=$P(BW0,U,4),BWSITE=$P(BW0,U,10)
 Q:'BWPCDN  ; Procedure Type is required
 S BWVFIL=$P($G(^BWPN(BWPCDN,0)),U,12)
 ;
 ;---> IF THIS PROCEDURE WON'T GET PASSED TO PCC, BWERR WILL BE
 ;---> GREATER THAN 0: SO, DISPLAY ERROR CODE TEXT AND QUIT.
 S BWERR=$$CHECK^BWPCC1(BW0,DUZ(0),BWDUZ2,BWPCDN,BWSITE,BWVFIL)
 I BWERR D:$P(^BWSITE(DUZ(2),0),U,20) ERRCD^BWUTL2(BWERR) Q
 ;
 W !?5,"* Updating PCC Files..."
 ;
 K APCDALVR N BWTEST,X
 ;
VISIT ;---> CREATE OR MODIFY VISIT IN VISIT FILE.
 ;---> SET BWTEST=1 TO DISPLAY VISIT AND V RAD PTRS AFTER SET.
 S BWTEST=0
 ;
 ;---> PATIENT
 S APCDALVR("APCDPAT")=$P(BW0,U,2)
 ;
 ;---> PCC DATE/TIME; IF NO TIME, ATTACH 12 NOON.
 S APCDALVR("APCDDATE")=$P(BW0,U,3)
 ;
 ;---> LOCATION
 S APCDALVR("APCDLOC")=$P(BW0,U,10)
 ;
 ;---> VISIT TYPE FROM PCC MASTER CONTROL FILE. (I,C,T,6,V)
 S APCDALVR("APCDTYPE")=$P(^APCCCTRL(DUZ(2),0),U,4)
 ;
 ;---> APPEND 12 NOON TO ANY VISIT WITHOUT TIME.
 ;S APCDALVR("APCDAUTO")=""
 ;---> FOR NOW, LEAVE IN INTERACTIVE MODE:
 ;--->    1) IF NO VISIT EXISTS ON THIS DATE, CREATE ONE SILENTLY.
 ;--->    2) IF A VISIT EXISTS WITH EXACT TIME MATCH, APPEND TO IT.
 ;--->    3) IF A VISIT EXISTS FOR THIS DATE BUT A DIFFERENT TIME,
 ;--->    4)    THEN QUERY THE USER IN INTERACTIVE MODE.
 ;
 ;---> CATEGORY
 ;---> IF PROCEDURE WAS DONE OFFSITE, CATEGORY="EVENT".
 ;---> IF ^BWPN( IENS OF 3=HYSTERECTOMY, 33=MASTECTOMY, CAT="INPATIENT".
 ;---> OTHERWISE, CATEGORY="AMBULATORY".
 S APCDALVR("APCDCAT")=$S(BWSITE'=BWDUZ2:"E",33[BWPCDN:"I",1:"A")
 ;
 ;---> NO INTERACTION, NO FILEMAN ECHOING
 S APCDALVR("AUPNTALK")="",APCDALVR("APCDANE")=""
 ;
 D ^APCDALV
 D:BWTEST DISPLAY1^BWPCC1
 ;
 ;---> QUIT IF VISIT WAS NOT CREATED.
 I '$D(APCDALVR("APCDVSIT"))!($D(APCDALVR("APCDAFLG"))) D  G EXIT
 .W !!?5,"* There is a PCC Link problem creating a VISIT."
 .W !,?7,"Please contact your site manager.",!  D DIRZ^BWUTL3
 ;
 ;RETURNS  APCDVSIT - PTR TO VISIT JUST SELECTED OR CREATED
 ;         APCDVSIT("NEW") - IF ^APCDALVR CREATED A NEW VISIT
 ;         APCDAFLG - =2 IF FAILED TO CREATE VISIT
 ;
VFILE ;---> CREATE (ADD) VISIT TO APPROPRIATE V FILE.
 ;---> V FILE#=PIECE 15 OF BW PROCEDURE TYPE.
 S DLAYGO=BWVFIL
 ;
 ;---> CLINIC STOP.
 S X=$P(BW0,U,11)
 S:X X=$P($G(^SC(X,0)),U,7)
 S:X APCDALVR("APCDTCLN")="`"_X K X
 ;
 ;---> WOMEN'S HEALTH PROCEDURE EVENT DATE/TIME.
 ;---> *NOTE: EVENT DATE/TIME MAY DIFFER FROM PCC DATE/TIME (PC 3).
 S APCDALVR("APCDTCDT")=$P(BW0,U,12)
 ;
 ;---> SET APPROPRIATE V FILE VARIABLES.
 D
 .I BWVFIL=9000010.08 D VPROC Q
 .I BWVFIL=9000010.09 D VLAB  Q
 .I BWVFIL=9000010.13 D VEXAM Q
 .I BWVFIL=9000010.22 D VRAD  Q
 .I BWVFIL=9000010.18 D VCPT Q
 ;
 ;---> TEMPLATE TO ADD VISIT TO V WOMEN'S HEALTH FILE.
 S APCDALVR("APCDATMP")="[APCDALVR "_BWVFIL_" (ADD)]"
 D ^APCDALVR
 D:BWTEST DISPLAY2^BWPCC1
 ;
 ;---> QUIT IF V FILE ENTRY WAS NOT CREATED.
 I '$D(APCDALVR("APCDADFN"))!($D(APCDALVR("APCDAFLG"))) D  G EXIT
 .W !!?5,"* There is a PCC Link problem creating V FILE entries."
 .W !,?7,"Please contact your site manager.",!  D DIRZ^BWUTL3
 ;
STORE ;---> STORE VISIT AND V FILE IEN'S IN WH PROCEDURE FILE #9002086.1.
 I $G(BWDA) D
 .N DR
 .S DR="5.01////"_APCDALVR("APCDVSIT")_";5.02////"_APCDALVR("APCDADFN")
 .D DIE^BWFMAN(9002086.1,DR,BWDA,.BWPOP)
 D:BWTEST DISPLAY3^BWPCC1
 ;
EXIT ;EP
 K APCDALVR,AUPNTALK,APCDALVR
 Q
 ;
 ;
EDIT(BWDA,BWDUZ2,BW0,BWPCCN) ;EP
 ;---> EDIT A VISIT FILE ENTRY, CREATE A V FILE ENTRY.
 ;---> CALLED BY BWPROC1.
 ;---> REQUIRED VARIABLES: BWDA=IEN OF PROCEDURE IN ^BWPCD(.
 ;--->                     BWDUZ2=DUZ(2), THE FACILITY.
 ;--->                     BW0=ZERO NODE OF THE PROC, ^BWPCD(BWDA,0).
 ;--->                     BWPCCN=PCC NODE OF THE PROCEDURE.
 ;
 ;S DUZ(0) ="@" ;*COMEBACK ;FOR ANMC PART III SECURITY.
 ;
 ;---> QUIT IF NECESSARY VARIABLES ARE NOT PRESENT.
 Q:'$G(BWDA)!('$G(BWDUZ2))!($G(BW0)']"")!($G(BWPCCN)']"")
 ;
 N BWPCDN,BWSITE,BWVFIL
 ;---> SET BWPCDN=IEN OF PROCEDURE TYPE, ^BWPN(.
 ;---> SET BWVFIL=IEN OF V FILE.
 S BWPCDN=$P(BW0,U,4),BWSITE=$P(BW0,U,10)
 S BWVFIL=$P($G(^BWPN(BWPCDN,0)),U,12)
 ;
 ;---> IF THIS PROCEDURE WON'T GET PASSED TO PCC, BWERR WILL BE
 ;---> GREATER THAN 0: SO, DISPLAY ERROR CODE TEXT AND QUIT.
 S BWERR=$$CHECK^BWPCC1(BW0,DUZ(0),BWDUZ2,BWPCDN,BWSITE,BWVFIL)
 ;---> IF RESULT WAS EDITED TO "ERROR/DISREGARD", THEN DELETE
 ;---> VISIT AND QUIT (DON'T CREATE A NEW ONE).
 I BWERR=2 D  Q
 .D DELETE(BWDA,BWPCCN,BWVFIL)
 .D:$P(^BWSITE(DUZ(2),0),U,20) ERRCD^BWUTL2(BWERR)
 I BWERR D:$P(^BWSITE(DUZ(2),0),U,20) ERRCD^BWUTL2(BWERR) Q
 ;
 D DELETE(BWDA,BWPCCN,BWVFIL)
 D CREATE(BWDA,BWDUZ2,BW0)
 Q
 ;
DELETE(BWDA,BWPCCN,BWVFIL) ;EP ;---> DELETE PCC V FILE ENTRY.
 N BWVGBL,DA,DIK
 Q:'$G(BWPCCN)  Q:'$G(BWVFIL)
 S DA=$P(BWPCCN,U,2)
 ;---> QUIT IF POINTER TO V FILE IS NULL.
 Q:'+DA
 S BWVGBL=^DIC(BWVFIL,0,"GL")
 ;---> IF V FILE ENTRY DOES NOT EXIST, KILL WH PCC NODE AND QUIT.
 I '$D(@(BWVGBL_DA_",0)")) K:$G(BWDA) ^BWPCD(BWDA,"PCC") Q
 ;
 S APCDVDLT=$P(@(BWVGBL_DA_",0)"),U,3)
 ;---> FIRST DELETE THE V FILE ENTRY (AND DECREMENT THE DEPENDENT
 ;---> ENTRY COUNT OF THE VISIT).
 S DIK=BWVGBL D ^DIK
 Q:APCDVDLT'=$P(BWPCCN,U)
 ;---> ASK LORI WHAT THIS NEXT LINE DOES?  DECREMENT/INACTIVATE VISIT?
 D:'$P(^AUPNVSIT(APCDVDLT,0),U,9) ^APCDVDLT
 ;---> SET PCC VISIT POINTERS FOR THIS PROCEDURE= NULL.
 K:$G(BWDA) ^BWPCD(BWDA,"PCC")
 Q
 ;
VPROC ;EP
 ;---> SET UP V PROCEDURE FILE VARIABLES.
 ;---> PROCEDURE (.01).
 N BWICD S BWICD=$P(^BWPN(BWPCDN,0),U,14)
 S APCDALVR("APCDTPRC")="`"_BWICD
 ;---> PROVIDER NARRATIVE.
 ;IHS/CMI/LAB - commented out line below for CSV 5/5/09
 ;and replaced it with call to ICDCODE
 ;S APCDALVR("APCDTNQ")=$P(^ICD0(BWICD,0),U,4)
 S APCDALVR("APCDTNQ")=$P($$ICDOP^ICDCODE(BWICD,$P(BW0,U,12)),U,5)
 ;---> DATE OF PROCEDURE.
 S APCDALVR("APCDTPD")=$P(BW0,U,12)
 ;---> ENCOUNTER PROVIDER.
 N X S X=$$PROVIDER(BW0,9000010.08,1204) S:X APCDALVR("APCDTEPR")="`"_X
 Q
 ;
VLAB ;EP
 ;---> SET UP V LAB FILE VARIABLES.
 ;---> LAB TEST (.01).
 S APCDALVR("APCDTLAB")="`"_$P(^BWPN(BWPCDN,0),U,15)
 ;---> RESULT.
 N X S X=$$DIAG^BWUTL4($P(BW0,U,5))
 S APCDALVR("APCDTRES")=$S(X]"":X,1:"RESULT NOT ENTERED")
 ;---> ACCESSION# PREFIXED WITH "WH".
 S APCDALVR("APCDTACC")="WH"_$P(BW0,U)
 ;---> ENCOUNTER PROVIDER.
 N X S X=$$PROVIDER(BW0,9000010.09,1204) S:X APCDALVR("APCDTEPR")="`"_X
 Q
 ;
VEXAM ;EP
 ;---> SET UP V EXAM FILE VARIABLES.
 ;---> EXAM (.01).
 S APCDALVR("APCDTEX")="`"_$P(^BWPN(BWPCDN,0),U,16)
 ;---> RESULT ABNORMAL/NORMAL.
 N X S X=$$NORMAL^BWUTL4($P(BW0,U,5))
 S:X<2 APCDALVR("APCDTRES")=$S(X:"A",1:"N")
 ;---> ENCOUNTER PROVIDER.
 N X S X=$$PROVIDER(BW0,9000010.13,1204) S:X APCDALVR("APCDTEPR")="`"_X
 Q
 ;
VRAD ;EP
 ;---> SET UP V RADIOLOGY FILE VARIABLES.
 ;---> RADIOLOGY PROCEDURE (.01).
 S APCDALVR("APCDTRAD")="`"_$P(^BWPN(BWPCDN,0),U,17)
 ;
 ;---> RESULT *COMEBACK AFTER FILE #78.3 DIAG CODES HAS STANDARDIZED.
 ;---> FOR NOW, PASS RESULT TEXT (FROM ^BWDIAG) AS IMPRESSION.
 N X S X=$P(BW0,U,5)
 ;I X S:$D(^BWRADX(X,0)) APCDALVR("APCDTRES")="`"_$P(^(0),U,2)
 ;---> IMPRESSION
 S:X APCDALVR("APCDTIMP")=$$DIAG^BWUTL4(X)
 ;
 ;---> ORDERING PROVIDER.
 S X=$$PROVIDER(BW0,9000010.22,1202) S:X APCDALVR("APCDTPRV")="`"_X
 Q
 ;
VCPT ;EP
 S APCDALVR("APCDTCPT")="`"_$P(^BWPN(BWPCDN,0),U,8)
 N X S X=$$PROVIDER(BW0,9000010.13,1204) S:X APCDALVR("APCDTEPR")="`"_X
 S APCDALVR("APCDTPN")=$$ICPT^BQIUL3($P(^BWPN(BWPCDN,0),U,8),$P(BW0,U,3),3)
 Q
 ;
PROVIDER(BW0,FILE,FIELD) ;EP
 Q:$G(BW0)="" ""
 Q:$G(FILE)="" ""
 Q:$G(FIELD)="" ""
 S X=$P(BW0,U,7)
 Q:'X ""
 ;---> IF PCC WANTS A FILE 6 POINTER FOR PROVIDER, RESET X.
 I $P(^DD(FILE,FIELD,0),U,2)[6 D
 .I $P($G(^VA(200,X,0)),U,16) S X=$P(^(0),U,16) Q
 .S X=$P($G(^DIC(3,X,0)),U,16)
 Q X