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

BPCPCCUP.m

Go to the documentation of this file.
BPCPCCUP ; IHS/OIT/MJL - GUI V FILE VISIT CREATION ;
 ;;1.5;BPC;;MAY 26, 2005
 ;;
EN(BPCARRAY,BPCVFILE,BPCUPDF,BPCPARM,BPCRTN) ;EP CALL
 D
 .D PRECHECK Q:BPCERR'=""
 .D INIT
 .D PARSE I BPCUPDF="C" D VISITCKS Q:BPCERR'=""
 .I BPCRTN'="" D @$TR(BPCRTN,"|","^") Q:BPCERR'=""
 .D UPDATE
 I BPCERR'="" D ERROR(BPCERR)
 D KILL
 Q
 ;
INIT ;
 K APCDALVR
 K X,Y,DINUM,DLAYGO,DR,DIC,DA,D0,DIU,DIW,DIY,DIV  ; KILL FILEMAN VAR
 S APCDALVR("APCDAUTO")="" ;BACKGROUND SILENT VISIT CREATION
 S APCDALVR("AUPNTALK")="" ;BACKGROUND SILENT VISIT CREATION
 S (APCDAUTO,AUPNTALK)=""
 S BPCRTN=$G(BPCRTN)
 Q
 ;
PARSE ;
 F BPCN=1:1:$L(BPCPARM,$C(30)) S BPCVAL=$P(BPCPARM,$C(30),BPCN),APCDALVR("APCD"_$P(BPCVAL,$C(20)))=$P(BPCVAL,$C(20),2)
 Q
 ;
UPDATE ;
 D
 .I BPCUPDF="C" D ^APCDALV I $G(APCDALVR("APCDAFLG"))'="" S BPCERR="PCC Visit not created" Q
 .S APCDALVR("APCDATMP")="[APCDALVR "_BPCVFILE_" ("_$S(BPCUPDF="C":"ADD",1:"MOD")_")]"
 .I '$D(APCDALVR("APCDVSIT")),$G(APCDALVR("APCDADFN")) S APCDALVR("APCDVSIT")=$P(@$P(^DIC(BPCVFILE,0,"GL"),"(")@(APCDALVR("APCDADFN"),0),U,3),APCDALVR("APCDLOOK")=APCDALVR("APCDADFN")
 .I '$G(APCDALVR("APCDVSIT")) S BPCERR=$P(^DIC(BPCVFILE,0),U)_" not updated - Visit IEN not set!" Q
 .D ^APCDALVR
 .;D ^BPCEDM
 .I $G(APCDALVR("APCDAFLG"))'="" S BPCERR=$P(^DIC(BPCVFILE,0),U)_" not updated" Q
 I BPCERR'="" S:$G(APCDALVR("APCDAFLG"))'="" BPCERR=BPCERR_" - "_APCDALVR("APCDAFLG") S:$G(APCDAFLG("ERR"))'="" BPCERR=BPCERR_$C(13,10)_APCDAFLG("ERR") Q
 D MSG("2"_$C(30)_APCDALVR("APCDVSIT")_$C(30)_APCDALVR("APCD"_$S(BPCUPDF="C":"ADFN",1:"LOOK")))
 Q
 ;
ERROR(BPCX) ;
 D MSG("-1"_$C(30)_BPCX)
 Q
 ;
MSG(BPCX) ;
 S BPCARRAY=BPCX
 Q
 ;
PRECHECK ;
 ;check for FILE NAME
 S BPCERR=""
 I $G(BPCVFILE)="" S BPCERR="FILE NAME NOT SENT!" Q
 S:'BPCVFILE BPCVFILE=$O(^DIC("B",BPCVFILE,""))
 ;check for CREATE/MOD flag
 I $G(BPCUPDF)="" S BPCERR="CREATE/MOD FLAG NOT SENT!" Q
 ;check for PCC parameter/value pairs string
 I $G(BPCPARM)="" S BPCERR="NO PARAMETERS SET" Q
 Q
 ;
VISITCKS ;
 ;check patient IEN
 I $G(APCDALVR("APCDPAT"))="" S BPCERR="PATIENT IEN NOT SENT!" Q
 ;check patient
 I '$D(^AUPNPAT($P(APCDALVR("APCDPAT"),"`",2),0)) S BPCERR="PATIENT ENTRY IS NOT DEFINED!" Q
 ;check for DUZ(2)
 I $G(APCDALVR("APCDLOC"))="" S BPCERR="LOCATION (DUZ(2)) NOT SENT!" Q
 ;Set VISIT TYPE
 I $G(APCDALVR("APCDTYPE"))="" S APCDALVR("APCDTYPE")=$P($G(^APCCCTRL(APCDALVR("APCDLOC"),0)),U,4) S:APCDALVR("APCDTYPE")="" APCDALVR("APCDTYPE")="I"
 ;check for good visit type
 I "^I^C^T^O^6^V^P^U^S^"'[U_APCDALVR("APCDTYPE")_U S BPCERR="VISIT TYPE NOT DEFINED!" Q
 ;check for SERVICE CATEGORY
 I $G(APCDALVR("APCDCAT"))="" S BPCERR="SERVICE CATEGORY NOT SENT!" Q
 I "^A^H^I^C^T^N^S^O^E^R^D^X^"'[U_APCDALVR("APCDCAT")_U S BPCERR="SERVICE CATEGORY NOT DEFINED!" Q
 ;check for VISIT DATE
 I $G(APCDALVR("APCDDATE"))="" S BPCERR="VISIT DATE NOT SENT!" Q
 ;check for provider
 ;I $G(APCDALVR("APCDTPRV"))="" S BPCERR="PROVIDER NOT SENT!" Q
 ;check for ORDERING PROVIDER ENTRY IN VA200
 I $G(APCDALVR("APCDTPRO"))'="" S BPCERR=$$PROVCK($P(APCDALVR("APCDTPRO"),"`",2),.05) Q:BPCERR'=""
 ;check for ORDERING PROVIDER ENTRY IN VA200
 I $G(APCDALVR("APCDTPRV"))'="" S BPCERR=$$PROVCK($P(APCDALVR("APCDTPRV"),"`",2),1202) Q:BPCERR'=""
 ;check for ENCOUNTER PROVIDER
 ;I $G(APCDALVR("APCDTEPR"))="" S BPCERR="INVALID ENCOUNTER PROVIDER SENT!" Q
 ;check for ENCOUNTER PROVIDER ENTRY IN VA200
 I $G(APCDALVR("APCDTEPR"))'="" S BPCERR=$$PROVCK($P(APCDALVR("APCDTEPR"),"`",2),1204) Q:BPCERR'=""
 Q
 ;
PROVCK(BPCX,BPCFLD) ;
 ;Provider check
 I $P($P($G(^DD(BPCVFILE,BPCFLD,0)),U,2),"'",1)["P200" Q:$D(^VA(200,BPCX,0)) ""  Q $P(^DD(BPCVFILE,BPCFLD,0),U,1)_" NOT DEFINED IN THE NEW PERSON FILE!"
 S BPCX=$G(^DIC(16,BPCX,"A3")) I BPCX S BPCX=$P($G(^VA(200,BPCX,0)),U,16) I BPCX,$D(^DIC(6,BPCX,0)) Q ""
 Q "No entry in Provider file for the "_$P(^DD(BPCVFILE,BPCFLD,0),U,1)_" field entry"
 ;
KILL ;
 K APCDALVR,BPCPARM,BPCERR,BPCVAL
 Q