source: WorldVistAEHR/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNLGICI.m@ 1306

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

initial load of WorldVistAEHR

File size: 1.7 KB
Line 
1SPNLGICI ; ISC-SF/GMB - SCD GATHER CURRENT INPATIENT DATA; 4 JUL 94 [ 09/21/94 9:48 AM ] ;6/23/95 11:29
2 ;;2.0;Spinal Cord Dysfunction;;01/02/1997
3GATHER(DFN,FDATE) ;
4 ; DFN Patient's internal entry number in the Patient file
5 ; FDATE "From" date (IGNORED)
6 ; Data will be rolled up into the following global:
7 ; ^TMP("SPN",$J,"CI", (The node at this level has the total inpatient count)
8 ; with the following nodes:
9 ; ward,name^ssn) admit date^curr los^fytd los^room bed^diagnosos
10 N VADM,VA,NAME,SSNLAST4,WARD,VAIP,CURRLOS,FYTDLOS,CURRADM,ROOMBED,DIAG
11 D IN5^VADPT ; Is patient an inpatient right now?
12 S WARD=$P($G(VAIP(5)),U,2)
13 Q:WARD=""
14 S ROOMBED=$P($G(VAIP(6)),U,2) ; Room Bed
15 S DIAG=$G(VAIP(9)) ; Diagnosis
16 S FDATE=$E(DT,1,3)_"1001" ; Set FDATE to the start of the FY
17 I FDATE>DT S FDATE=FDATE-10000
18 D DEM^VADPT ; Get patient demographics
19 S NAME=VADM(1)
20 S SSNLAST4=VA("BID")
21 D ADMIT
22 S ^TMP("SPN",$J,"CI",WARD,NAME_"^"_SSNLAST4)=CURRADM_"^"_CURRLOS_"^"_FYTDLOS_"^"_ROOMBED_"^"_DIAG
23 S ^("CI")=$G(^TMP("SPN",$J,"CI"))+1 ; count of current inpatients
24 Q
25ADMIT ;
26 N RECNR,NODE0,NODE70,ZDD,ZAD,X,X1,X2
27 S (CURRADM,CURRLOS,FYTDLOS,RECNR)=0
28 F S RECNR=$O(^DGPT("B",DFN,RECNR)) Q:RECNR="" D
29 . S NODE0=$G(^DGPT(RECNR,0))
30 . Q:$P(NODE0,U,11)'=1 ; 1=PTF record, 2=census record
31 . S NODE70=$G(^DGPT(RECNR,70))
32 . S ZDD=$P(NODE70,U,1) ; Discharge date
33 . Q:ZDD'=""&(ZDD<FDATE)
34 . S ZAD=$P(NODE0,U,2) ; Admit date
35 . S X2=$S(ZAD<FDATE:FDATE,1:ZAD)
36 . S X1=$S(ZDD="":DT,1:ZDD)
37 . D ^%DTC
38 . S FYTDLOS=FYTDLOS+X+1
39 . Q:ZDD'=""
40 . S CURRADM=ZAD
41 . I ZAD<FDATE D ;If current admission date is prior to this FY,
42 . . S X1=DT,X2=ZAD ;then redo the calculation to get the full number
43 . . D ^%DTC ;of admit days.
44 . S CURRLOS=X+1
45 Q
Note: See TracBrowser for help on using the repository browser.