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

APCDALV.m

Go to the documentation of this file.
APCDALV ; IHS/CMI/LAB - VISIT CREATION ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;IHS/CMI/LAB - patch 3 added kill of APCDA11
 ;
 ;
 ;visits - 08/01/94
EN ;PEP - Called to create PCC Visits
 NEW D0,DA,DIC,DIE,DR
 D INIT
 I $D(APCDAFLG) D EOJ Q
 LOCK +^TMP("APCDALV",APCDPAT):60
 I $D(APCDADD) D GENVISIT,EOJ Q  ; forced add
 I $D(APCDAUTO) D AUTO,EOJ Q  ;    non-interactive mode
 D INTERACT,EOJ ;                  interactive mode
 Q
 ;
 ;--------------------------------------------------------------
 ;
INTERACT ; INTERACTIVE MODE
 K APCDALV
 S (APCDAVD,APCDAVDC)=9999999-$P(APCDDATE,"."),APCDAVD=(APCDAVD-1)_".999999"
 S APCDAC=3
 F APCDAL=0:0 S APCDAVD=$O(^AUPNVSIT("AA",APCDPAT,APCDAVD)) Q:APCDAVD=""  Q:$P(APCDAVD,".")'=APCDAVDC  F APCDAI=0:0 S APCDAI=$O(^AUPNVSIT("AA",APCDPAT,APCDAVD,APCDAI)) Q:APCDAI=""  D GATHER
 I '$D(APCDALV) D GENVISIT Q  ;      no visits gathered
 I $D(^XUSEC("APCDZVMRG",DUZ)),$D(APCDALV(5)) D
 .K APCDALVX S %=0 F  S %=$O(APCDALV(%)) Q:%'=+%  S APCDALVX(%)=APCDALV(%)
 .K APCDALV
 .S %=0 F  S %=$O(APCDALVX(%)) Q:%'=+%  S APCDALV(%+1)=APCDALVX(%)
 .S APCDAC=APCDAC+1
 .K APCDALVX,%
 .Q
 D SELECT ;                          select or generate visit
 I APCDAO=4,'$D(APCDALV(4)) G INTERACT
 Q
 ;
GATHER ; GATHER VISITS FOR USER TO SELECT
 S APCDAX=^AUPNVSIT(APCDAI,0)
 Q:$P(APCDAX,U,11)
 ;Q:$P(APCDAX,U,3)'=APCDTYPE
 Q:$P(APCDAX,U,6)'=APCDLOC
 Q:$P(APCDAX,U,7)'=APCDCAT
 I $D(APCDCLN),$P(APCDAX,U,8),APCDCLN'=$P(APCDAX,U,8) Q
 S APCDAC=APCDAC+1,APCDALV(APCDAC)=APCDAI
 Q
 ;
SELECT ; ALLOW USER TO SELECT, EXIT, OR ADD
 I '$D(APCDADF),APCDAC=4 S APCDADF=APCDAC
 S APCDAO=""
 D OPTION ;                         get option from user
 I APCDAO=2 S APCDAFLG=1 Q  ;       exit with no selection
 I APCDAO=1 D GENVISIT Q  ;         user said generate new visit
 I APCDAO=4,'$D(APCDALV(4)) D MRG^APCDALV1 G INTERACT
 S Y=$P(^AUPNVSIT(APCDVSIT,0),U,5) D ^AUPNPAT K Y
 Q
 ;
OPTION ; LET USER SELECT OPTION
 D OPTION^APCDALV1
 Q
 ;
 ;--------------------------------------------------------------
 ;
AUTO ; NON-INTERACTIVE MODE
 S APCDAVDC=9999999-$P(APCDDATE,".")_"."_$P(APCDDATE,".",2)
 F APCDAI=0:0 S APCDAI=$O(^AUPNVSIT("AA",APCDPAT,APCDAVDC,APCDAI)) Q:APCDAI=""  D CHECK Q:APCDVSIT
 Q:APCDVSIT
 D GENVISIT
 Q
 ;
CHECK ; CHECK VISIT AUTO MODE
 S APCDAX=^AUPNVSIT(APCDAI,0)
 Q:$P(APCDAX,U,11)
 I $D(APCDCLN),$P(APCDAX,U,8)'=APCDCLN Q  ;CHANGED THIS LINE ON 4/4/96 - DOES THIS FIX IT?
 I '$D(APCDCLN),$P(APCDAX,U,8)]"" Q  ;if not passing clinic and visit has clinic do not select this visit
 Q:$P(APCDAX,U,3)'=APCDTYPE
 Q:$P(APCDAX,U,6)'=APCDLOC
 Q:$P(APCDAX,U,7)'=APCDCAT
 S APCDVSIT=APCDAI
 Q
 ;
 ;--------------------------------------------------------------
 ;
GENVISIT ; GENERATE NEW VISIT
 S Y=APCDPAT D ^AUPNPAT K Y
 S APCDSEX=AUPNSEX,APCDDOB=AUPNDOB,APCDDOD=AUPNDOD
 S X=APCDDATE,%DT="TRXN" D ^%DT S X=Y I X=-1 S APCDAFLG=2,APCDAFLG("ERR")=".01^"_APCDDATE_"^DATE INVALID FOR PATIENT,CANNOT CREATE VISIT .01 VALUE" Q
 D VSIT01^AUPNVSIT
 I '$D(X) S APCDAFLG=2,APCDAFLG("ERR")=".01^"_APCDDATE_"^DATE INVALID FOR PATIENT,CANNOT CREATE VISIT .01 VALUE" Q
 K APCDLOOK S DIC="^AUPNVSIT(",DIC(0)="L"_$S($D(ZTQUEUED)!($D(ZTSK)):"",1:"E"),DLAYGO=9000010,DIC("DR")="[APCD VISIT (ADD)]" K DD,DO D FILE^DICN K DIC,DLAYGO
 I Y<0 S APCDAFLG=2,APCDAFLG("ERR")=".01^"_APCDDATE_"^FILE^DICN FAILED TO CREATE VISIT" Q
 S APCDVSIT=+Y
 ;IHS/ITSC/LJF 8/1/2003 
 I $T(GETVID^VSITVID)]"",$P($G(^DIC(150.9,1,4)),U,2)]"" S VID=$$GETVID^VSITVID S DIE=9000010,DA=APCDVSIT,DR="15001///"_VID D ^DIE K VID,DIE,DR,DA
 S APCDVSIT("NEW")=1
 Q
 ;
 ;--------------------------------------------------------------
 ;
INIT ; INITIALIZATION/EDIT INPUT VARIABLES
 D INIT^APCDALV1
 Q
 ;
EOJ ; CLEAN UP
 LOCK -^TMP("APCDALV",APCDPAT)
 ; The line below must 'hard set' the clinic code because
 ; ^DIE would have to be called recursively.  An exception to the
 ; standard has been granted by DSM/OIRM.
 I APCDVSIT,$D(APCDCLN),$P(^AUPNVSIT(APCDVSIT,0),U,8)="" S $P(^AUPNVSIT(APCDVSIT,0),U,8)=APCDCLN ; ***** BAD, VERY BAD, FORGIVE US PLEASE *****
 I APCDVSIT,$P($G(^AUPNVSIT(APCDVSIT,11)),U,4)="" S $P(^AUPNVSIT(APCDVSIT,11),U,4)=$$UID^AUPNVSIT(APCDVSIT) ;stuff UID if blank
 K X,Y
 K DIRUT,DTOUT,DUOUT
 K APCDADD,APCDADF,APCDAUTO
 K APCDAC,APCDAI,APCDAL,APCDALV,APCDAO,APCDAVD,APCDAVDC,APCDAX,APCDA11
 I $D(APCDALVR)\10 S APCDALVR("APCDPAT")=APCDPAT,APCDALVR("APCDVSIT")=APCDVSIT S:$D(APCDVSIT("NEW")) APCDALVR("APCDVSIT","NEW")=APCDVSIT("NEW") S:$D(APCDAFLG) APCDALVR("APCDAFLG")=APCDAFLG D:'$D(APCDNOK) EN1^APCDEKL
 Q