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

TIUMOVE.m

Go to the documentation of this file.
  1. TIUMOVE ; SLC/JER - Patient movement look-up ;10/26/95 21:17
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**3**;Jun 20, 1997
  1. MAIN(TIUY,DFN,TIUSSN,TIUMDT,TIULDT,TIUMTYP,TIUDFLT,TIUMODE,TIULOC) ;
  1. ; Call with: .TIUY - (by ref) array in which demographic, movement,
  1. ; & visit data are returned
  1. ; [DFN] - patient file entry number
  1. ; [TIUSSN] - patient SSN
  1. ; [TIUMDT] - movement date
  1. ; [TIULDT] - upper bound of date range
  1. ; [TIUMTYP] - MAS Movement event type
  1. ; [TIUDFLT] - Default movement (e.g., "LAST")
  1. ; [TIUMODE] - mode flag 0 ==> Silent
  1. ; 1 ==> Interactive (default)
  1. AGN ; Loop for handling repeated attempts
  1. N TIUI,TIUII,TIUER,TIUOK,TIUOUT,TIUX,TIUMTSTR,TIUMLST,TIUCNT,X
  1. S TIUMTYP=$S(+$G(TIUMTYP):+$G(TIUMTYP),1:1)
  1. S TIUMODE=$S($G(TIUMODE)]"":$G(TIUMODE),1:1)
  1. S TIUMDT=$S(+$G(TIUMDT):+$G(TIUMDT),1:2400101)
  1. S TIULDT=$S(+$G(TIULDT):+$G(TIULDT),1:+$$NOW^TIULC)
  1. S TIUMTSTR="ADMISSION^TRANSFER^DISCHARGE^CHECK-IN^CHECK-OUT^SPECIALTY CHANGE"
  1. I +$G(DFN)'>0,($G(TIUSSN)]"") S DFN=+$$PATIENT^TIULA($G(TIUSSN))
  1. I +$G(DFN)'>0 S TIUOUT=1 Q
  1. I '$D(^DGPM("ATID"_TIUMTYP,DFN)),+TIUMODE W !,"No ",$P(TIUMTSTR,U,TIUMTYP),"S on file.",! Q
  1. I +TIUMTYP=1,(TIUMODE=0),(TIUDFLT="CURRENT"),+$G(^DPT(DFN,.105)) S TIUX=+$G(^DPT(DFN,.105)) G VADPT
  1. D TGET(.TIUMLST,DFN,TIUMDT,TIULDT,TIUMTYP,.TIUCNT,TIUMODE)
  1. ; If call is silent, and multiple movements in result, then quit
  1. I '+TIUMODE,$S(+TIUCNT=1:1,TIUDFLT="LAST":1,1:0) S TIUX=$G(TIUMLST(1))
  1. I '+TIUMODE,(+TIUCNT>1),(+$G(TIUX)'>0) Q
  1. I '+TIUMODE,(+TIUCNT=0) Q
  1. I +TIUMODE D I +TIUER Q:+$G(TIUOUT) G AGN
  1. . I +TIUCNT'>0 W !,"No ",$P(TIUMTSTR,U,TIUMTYP),"S within search parameters.",! Q
  1. . W !,"The following ",$P(TIUMTSTR,U,TIUMTYP)
  1. . W $S(+TIUCNT>1:"(S) are",1:" is")," available:"
  1. . S (TIUER,TIUOK,TIUI)=0
  1. . F S TIUI=$O(TIUMLST(TIUI)) Q:+TIUI'>0!+TIUER!+TIUOK D
  1. . . S TIUII=TIUI,TIUX=$P(TIUMLST(TIUI),"^",2,20)
  1. . . D WRITE I '(TIUI#5) D BREAK
  1. . Q:$D(TIUOUT)
  1. . I +TIUER S TIUOUT=1 Q
  1. . I TIUII#5 D BREAK Q:$D(TIUOUT)
  1. . I +TIUER S TIUOUT=1 Q
  1. . S TIUX=$G(TIUMLST(+TIUOK)),^DISV(DUZ,"DGPMEX",DFN)=+TIUX
  1. . W " ",$$DATE^TIULS(+$P(TIUX,U,2),"AMTH DD CCYY@HR:MIN")
  1. VADPT D PATVADPT^TIULV(.TIUY,DFN,+TIUX)
  1. Q
  1. TGET(Y,DFN,MDT,LDT,MTYPE,C,MODE) ; Get list of movements
  1. N I,N,D S MDT=$G(MDT,9999999.9999999),MTYPE=$G(MTYPE,1),LDT=$G(LDT,0)
  1. I MDT'=9999999.9999999 S MDT=9999999.9999999-$$IDATE^TIULC(MDT)
  1. I LDT'=0 S LDT=9999999.9999999-$$IDATE^TIULC(LDT)
  1. S C=0,I=LDT F S I=$O(^DGPM("ATID"_MTYPE,DFN,I)) Q:+I'>0!(+I>MDT) D
  1. . S N=$O(^DGPM("ATID"_MTYPE,DFN,I,0)) Q:'$D(^DGPM(+N,0))
  1. . S D=^(0),C=C+1,Y(C)=N_"^"_D
  1. . I +$G(MODE) S Y("TIUMVD",+D)=N,Y("TIUMVDA",N)=C
  1. Q
  1. BREAK ; Handle prompting
  1. W !,"CHOOSE 1-",TIUII W:$D(TIUMLST(TIUII+1)) !,"<RETURN> TO CONTINUE",!,"OR '^' TO QUIT" W ": " R X:DTIME
  1. I $S('$T!(X["^"):1,X=""&'$D(TIUMLST(TIUII+1)):1,1:0) S TIUER=1 Q
  1. I X="" Q
  1. I X=" ",$D(^DISV(DUZ,"DGPMEX",DFN)) S TIUX=^(DFN) I $D(TIUMLST("TIUMVDA",+TIUX)) S TIUOK=+$G(TIUMLST("TIUMVDA",+TIUX)) Q
  1. I X'=+X!'$D(TIUMLST(+X)) W !!,$C(7),"INVALID RESPONSE",! G BREAK
  1. S TIUOK=X
  1. Q
  1. WRITE W !,$J(TIUI,4),"> ",$$DATE^TIULS(+TIUX,"AMTH DD, CCYY@HR:MIN"),?30,$S('$D(^DG(405.1,+$P(TIUX,"^",4),0)):"",$P(^(0),"^",7)]"":$P(^(0),"^",7),1:$E($P(^(0),"^",1),1,20))
  1. W ?55,"TO: ",$S($D(^DIC(42,+$P(TIUX,"^",6),0)):$E($P(^(0),"^",1),1,18),1:"") I $P(TIUX,"^",18)=9 W !?23,"FROM: ",$S($D(^DIC(4,+$P(TIUX,"^",5),0)):$P(^(0),"^",1),1:"")
  1. Q