source: FOIAVistA/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNLGSCH.m@ 1607

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

initial load of FOIAVistA 6/30/08 version

File size: 2.3 KB
Line 
1SPNLGSCH ; ISC-SF/GMB - SCD GATHER LAB TEST (SPECIFIC) DATA;15 JUN 94 [ 07/12/94 6:05 AM ] ;6/23/95 11:44
2 ;;2.0;Spinal Cord Dysfunction;;01/02/1997
3SELECT(DFN,FDATE,TDATE,HI,QLIST) ;
4 ; DFN Patient's internal entry number in the Patient file
5 ; FDATE "From" date
6 ; TDATE "Thru" date, default=today
7 ; HI 1=keep track of individual patient usage
8 ; 0=don't keep track
9 ; Data will be rolled up into the following global:
10 ; ^TMP("SPN",$J,"CH",
11 ; with the following nodes:
12 ; "TEST",testnr) # results for this test
13 ; "TEST",testnr,"NAME") the name of the test
14 ; "TEST",testnr,"PAT") # patients who had this test
15 ; "TEST",testnr,"PID",patient) SSN^# results for this patient's test
16 N LFN,LASTDATE,TESTDATE,TESTNR,VALUE,TEST,RESULTS,PNAME,PSSN
17 S LFN=+$P($G(^DPT(DFN,"LR")),U,1) ; Internal entry number in LAB DATA file
18 Q:'LFN
19 I '$D(TDATE) S TDATE=DT
20 ; We are interested in any lab test administered within the 'from' and
21 ; 'thru' date range. The record numbers are date/time (of test),
22 ; subtracted from 9999999. This causes the tests to be listed in order
23 ; from most recent to oldest. So we must modify our from & to dates.
24 S LASTDATE=9999999-FDATE
25 S TESTDATE=9999999-(TDATE+1) ; for each test date in the range
26 F S TESTDATE=$O(^LR(LFN,"CH",TESTDATE)) Q:TESTDATE'>0!(TESTDATE>LASTDATE) D
27 . ;S TESTNR=1 ; for each test on that date
28 . ;; we start after 1 because the first two (0,1) nodes we ignore.
29 . ;; Each node thereafter is for a specific test.
30 . ;F S TESTNR=$O(^LR(LFN,"CH",TESTDATE,TESTNR)) Q:TESTNR'>0 D
31 . ;. Q:'$D(QLIST(TESTNR)) ; make sure we want this test
32 . S TESTNR="" ; for each test we're interested in
33 . F S TESTNR=$O(QLIST(TESTNR)) Q:TESTNR="" D
34 . . Q:'$D(^LR(LFN,"CH",TESTDATE,TESTNR)) ; was this test given?
35 . . S VALUE=$G(^LR(LFN,"CH",TESTDATE,TESTNR))
36 . . ; make sure the test wasn't cancelled
37 . . I VALUE=""!(VALUE["canc")!(VALUE["CANC") Q
38 . . S TEST(TESTNR)=$G(TEST(TESTNR))+1 ; number results for this test
39 Q:'$D(TEST)
40 D:HI GETNAME^SPNLRU(DFN,.PNAME,.PSSN)
41 S TESTNR=""
42 F S TESTNR=$O(TEST(TESTNR)) Q:TESTNR="" D
43 . S RESULTS=TEST(TESTNR)
44 . S ^(TESTNR)=$G(^TMP("SPN",$J,"CH","TEST",TESTNR))+RESULTS
45 . S ^("PAT")=$G(^TMP("SPN",$J,"CH","TEST",TESTNR,"PAT"))+1
46 . S:HI ^TMP("SPN",$J,"CH","TEST",TESTNR,"PID",PNAME_U_PSSN)=RESULTS
47 Q
Note: See TracBrowser for help on using the repository browser.