source: FOIAVistA/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGPMSTAT.m@ 1528

Last change on this file since 1528 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.2 KB
Line 
1DGPMSTAT ;ALB/JDS - DETERMINE INPATIENT STATUS - FORMERLY DGINPW ;01 JAN 1986
2 ;;5.3;Registration;**36,246**;Aug 13, 1993
3 ;
4 ; Note: This used to be named 'DGINPW'
5 ; ------
6 ;
7EN ; -- call to return coresp adm and mvt data of pt as of a date
8 ; input: DFN => patient file ifn
9 ; DGT => date to check if pt was inpatient
10 ; output: DGA1 => coresp adm mvt ifn of ^DGPM
11 ; DG1 => ward ^ room-bed ^ mvt type(for xfrs only)
12 ; DGXFR0 => Oth of last xfr mvt for admission
13 ; -- init
14 N MT,IAD,IMD,DGCA,DGDC ; Inverse Adm Date & Inverse Mvt Date
15 S DG1=""
16 ;
17 ; -- scan adms for pt
18 ; -- if still inpt or d/c > DGT date then continue to CA
19 ;F IAD=9999999.9999998-DGT:0 S IAD=$O(^DGPM("ATID1",DFN,IAD)) Q:'IAD S DGA1=+$O(^(IAD,0)) I $D(^DGPM(DGA1,0)),$S('$D(^DGPM(+$P(^(0),"^",17),0)):1,1:^(0)>DGT) D CA Q:DG1
20 F IAD=9999999.9999998-DGT:0 S IAD=$O(^DGPM("ATID1",DFN,IAD)) Q:'IAD S DGA1=+$O(^(IAD,0)),DGCA=$G(^DGPM(DGA1,0)),DGDC=$G(^DGPM(+$P(DGCA,U,17),0)) D Q:DG1!($P(DGCA,U,18)'=40)
21 .I 'DGDC!(DGDC>DGT) D CA I $P(%,U,18)=43!($P(%,U,18)=45) S DG1="" Q
22 K DGNO Q
23 ;
24CA ; -- scan mvts for cor. adm that happened on or before DGT date
25 ; -- if mvt is adm or xfr then set DG1
26 ; -- if mvt is xfr then continue to XFR
27 S %=""
28 F IMD=9999999.9999998-DGT:0 S IMD=$O(^DGPM("APMV",DFN,DGA1,IMD)) Q:'IMD I $D(^DGPM(+$O(^(IMD,0)),0)) S %=^(0),MT=$P(%,"^",2) I MT=1!(MT=2) S DG1=$P(%,"^",6,7) D XFR:MT=2 Q:DG1
29CAQ Q
30 ;
31XFR ; -- set DG1="" if XFR to asih(oth fac) --ELSE-- add MVT type to DG1
32 S DGXFR0=%,DG1=$S($P(%,"^",18)=13:"",1:DG1_"^"_$P(%,"^",18))
33 Q
34 ;
35TREAT S DG2=0 D EN:'$D(DG1) Q:'DG1 S DG2=9999999 D TREAT1
36 I +DG2=9999999 S DG2=0 Q
37 S DG2=$S($D(^DIC(45.7,+DG2,0)):+$P(^(0),U,2),1:0)
38 Q
39TREAT1 F DGID=0:0 S DGID=$O(^DGPM("ATS",DFN,DGA1,DGID)) Q:'DGID F DGS=0:0 S DGS=$O(^DGPM("ATS",DFN,DGA1,DGID,DGS)) Q:'DGS F DGDA=0:0 S DGDA=$O(^DGPM("ATS",DFN,DGA1,DGID,DGS,DGDA)) Q:'DGDA I ^DGPM(+DGDA,0) S DGX=^(0) D TR2
40 Q
41TR2 I +DGX<(DGT+.1)&(+DGX<+DG2) S DG2=DGS
42 Q
43DGT(X) ; FIGURE OUT WHICH TYPE OF DATE TO USE FOR DGWARDWHEN
44 ; Input: X=Date in either FM format or regular date
45 ; Output: Date in FM format
46 N Y,%DT
47 I '$D(X) S X=DT G DGTQ
48 S %DT="T" D ^%DT S X=Y
49DGTQ Q X
Note: See TracBrowser for help on using the repository browser.