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

APCDVLK.m

Go to the documentation of this file.
  1. APCDVLK ; IHS/CMI/LAB - VISIT LOOKUP ;
  1. ;;2.0;IHS PCC SUITE;**2**;MAY 14, 2009
  1. ;IHS/CMI/LAB - added VCN display
  1. ;
  1. ;EP;CALLED BY THIS PACKAGE AND OTHER PACKAGES
  1. ;This routine is a 'published', callable entry point used to
  1. ;look-up a visit for a patient.
  1. ;Called by QA.
  1. ;Caller can pass the visit date in APCDVLDT or this routine
  1. ;will prompt for the visit date/time.
  1. ;Variable APCDPAT must contain the patient DFN.
  1. ;User will be returned the following variables:
  1. ;APCDVSIT-ien of visit
  1. ;APCDCAT-service category of visit
  1. ;APCDTYPE-type of visit
  1. ;APCDDATE-date of visit
  1. ;APCDCLN-clinic of visit
  1. ;APCDLOC-location of visit
  1. ;APCDPAT-patient dfn
  1. ;Caller is responsible for killing these variables
  1. ;This routine is called by INPUT TEMPLATES, therefore, I would
  1. ;prefer NOT to use DIR for reads until I'm sure that DIE and DIR
  1. ;do not collide with each other. Especially using the variables
  1. ;X and Y.
  1. ; ADD DUZ(2) LOGIC WHEN STABLE ********
  1. S U="^",APCDLOOK=""
  1. I $D(APCDVLK),APCDVLK S APCDLOOK=APCDVLK Q ;*** FOR MODIFY IN ADD MODE ***
  1. I $D(APCDVLDT) S Y=$P(APCDVLDT,".") G VDPASSED
  1. RDV W !,"Enter VISIT date: " R X:$S($D(DTIME):DTIME,1:300) S:'$T X="" I X=" " W $C(7)," ??" G RDV
  1. Q:X=""!(X="^")
  1. S %DT="EX" D ^%DT
  1. G:X="?" RDV
  1. I Y<0 K Y Q
  1. VDPASSED ; FOR CALLER PASSING VISIT DATE
  1. K APCDVLKT
  1. S APCDVLDC=Y,(APCDVLI,APCDVLV)=0 K Y
  1. ;IHS/CMI/LAB - modified to use AA xref rather than AC to speed it up
  1. ;F APCDVLL=0:0 S APCDVLV=$O(^AUPNVSIT("AC",APCDPAT,APCDVLV)) Q:APCDVLV="" I APCDVLDC=$P(+^AUPNVSIT(APCDVLV,0),"."),'$P(^(0),U,11) D
  1. S APCDVLID=9999999-APCDVLDC,APCDVLL=$$FMADD^XLFDT(APCDVLDC,1),APCDVLL=9999999-APCDVLL,APCDVLL=APCDVLL_".9999"
  1. F S APCDVLL=$O(^AUPNVSIT("AA",APCDPAT,APCDVLL)) Q:APCDVLL'=+APCDVLL!($P(APCDVLL,".")'=APCDVLID) D
  1. .S APCDVLV=0 F S APCDVLV=$O(^AUPNVSIT("AA",APCDPAT,APCDVLL,APCDVLV)) Q:APCDVLV'=+APCDVLV I $D(^AUPNVSIT(APCDVLV,0)),'$P(^(0),U,11) D
  1. ..S APCDVLI=APCDVLI+1,APCDVLKT(APCDVLI)=APCDVLV
  1. .Q
  1. G:'$D(APCDVLKT) XIT
  1. I APCDVLI=1,'$D(APCDVLDT) S APCDLOOK=APCDVLKT(1) G XIT
  1. SELECT ; SELECT EXISTING VISIT
  1. W !!,"PATIENT: ",$P(^DPT(APCDPAT,0),U)," has one or more VISITs on this date.",!
  1. S APCDVLI="" F APCDVLL=0:0 S APCDVLI=$O(APCDVLKT(APCDVLI)) Q:APCDVLI="" S APCDVLX=^AUPNVSIT(APCDVLKT(APCDVLI),0),APCDA11=$G(^AUPNVSIT(APCDVLKT(APCDVLI),11)) D WRITE
  1. S APCDVLV=""
  1. SRDR W !!,"Select one: " R APCDVLI:$S($D(DTIME):DTIME,1:300) I '$T S APCDVLI=""
  1. G:APCDVLI=""!(APCDVLI="^") XIT
  1. I APCDVLI'?1N.N W $C(7),$C(7) G SELECT
  1. I '$D(APCDVLKT(APCDVLI)) W $C(7),$C(7) G SELECT
  1. S APCDLOOK=APCDVLKT(APCDVLI)
  1. G XIT
  1. ;
  1. WRITE ; WRITE VISITS FOR SELECT
  1. S APCDVLT=$P(+APCDVLX,".",2),APCDVLT=$S(APCDVLT="":"<NONE>",$L(APCDVLT)=1:APCDVLT_"0:00 ",1:$E(APCDVLT,1,2)_":"_$E(APCDVLT,3,4)_$E("00",1,2-$L($E(APCDVLT,3,4)))_" ")
  1. S APCDVLOC=""
  1. I $P(APCDVLX,U,6),$D(^AUTTLOC($P(APCDVLX,U,6),0)) S APCDVLOC=$P(^(0),U,7),APCDVLOC=APCDVLOC_$E(" ",1,4-$L(APCDVLOC))
  1. S:APCDVLOC="" APCDVLOC="...."
  1. W !,APCDVLI," TIME: ",APCDVLT,"LOC: ",APCDVLOC," TYPE: ",$P(APCDVLX,U,3)," CAT: ",$P(APCDVLX,U,7)," CLINIC: ",$S($P(APCDVLX,U,8)]"":$E($P(^DIC(40.7,$P(APCDVLX,U,8),0),U),1,8),1:"<NONE>") D
  1. .W ?57,"DEC: ",$S($P(APCDVLX,U,9):$P(APCDVLX,U,9),1:0),$S($P(APCDA11,U,3)]"":" VCN:"_$P(APCDA11,U,3),1:"")
  1. .I $P(APCDVLX,U,22) W !?3,"Hospital Location: ",$P($G(^SC($P(APCDVLX,U,22),0)),U)
  1. .I $$PRIMPROV^APCLV(APCDVLKT(APCDVLI))]"" W !?3,"Primary Provider: ",$$PRIMPROV^APCLV(APCDVLKT(APCDVLI),"N")
  1. K APCDVLT,APCDVLOC
  1. Q
  1. ;
  1. XIT ; KILL VARIABLES AND QUIT
  1. I APCDLOOK S APCDVSIT=APCDLOOK,APCDDATE=+^AUPNVSIT(APCDLOOK,0),APCDTYPE=$P(^AUPNVSIT(APCDLOOK,0),U,3),APCDCAT=$P(^(0),U,7),APCDLOC=$P(^(0),U,6),APCDCLN=$P(^(0),U,8)
  1. I APCDVLI="^",$D(APCDGHVD) S APCDGHVD="^"
  1. K APCDVLDC,APCDVLDT,APCDVLI,APCDVLKT,APCDVLL,APCDVLOC,APCDVLT,APCDVLV,APCDVLX,Y,APCDA11,APCDVLID
  1. Q