source: FOIAVistA/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNLGRRA.m@ 1352

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

initial load of FOIAVistA 6/30/08 version

File size: 3.7 KB
Line 
1SPNLGRRA ; ISC-SF/GMB - SCD GATHER RADIOLOGY DATA;25 MAY 94 [ 08/09/94 9:35 AM ] ;6/23/95 11:41
2 ;;2.0;Spinal Cord Dysfunction;**13**;01/02/1997
3ROLLUP(DFN,FDATE,TDATE,HI) ;
4 ; This entry point is to be used solely for gathering data for reports
5 ; DFN Patient's internal entry number in the Patient file
6 ; FDATE "From" date
7 ; TDATE "Thru" date, default=today
8 ; HI 1=keep track of individual patient usage
9 ; 0=don't keep track
10 ; Data will be rolled up into the following global:
11 ; ^TMP("SPN",$J,"RA",
12 ; with the following nodes:
13 ; "PAT") # patients with at least 1 procedure
14 ; "EXAMS") # procedures
15 ; "EXAMS",-procs) # patients who had this many procedures
16 ; "PROC",cptcode) # times this procedure was done
17 ; "PROC",cptcode,"PAT") # patients who had this procedure
18 ; "PROC",cptcode,"NAME") name of the procedure
19 ; "PROC",cptcode,"VAL") current value of all instances of this procedure
20 ; ... and track usage by individual patient ranked by:
21 ; "HI","H1",-procs,-diff procs,-value,DFN)
22 ; "HI","H2",-value,-procs,-diff procs,DFN)
23 N LASTDATE,EXAMDATE,RECNR,PROCNAME,PROCCOST,CPTCODE,EXAMSTAT
24 N TPROCS,NPROCS,NDPROCS,VALUE,TVALUE,PROC,PROCREC,PROCPTR,COMPLETE,REC0
25 I '$D(TDATE) S TDATE=DT
26 ; Need to be able to recognize if an exam has been completed
27 ;S COMPLETE=$O(^RA(72,"B","COMPLETE",0)) ; obsolete. See DBIA #996
28 ; We are interested in any radiology procedure administered within the
29 ; 'from' and 'thru' date range. The record numbers are date/time (of
30 ; procedure), subtracted from 9999999.9999. This causes the procedures
31 ; to be listed in order from most recent to oldest. So we must modify
32 ; our from & to dates.
33 S LASTDATE=9999999.9999-FDATE
34 S EXAMDATE=9999999.9999-(TDATE+1) ; for each exam date in range
35 F S EXAMDATE=$O(^RADPT(DFN,"DT",EXAMDATE)) Q:EXAMDATE'>0!(EXAMDATE>LASTDATE) D
36 . S COMPLETE=$O(^RA(72,"AA",$P(^RA(79.2,$P(^RADPT(DFN,"DT",EXAMDATE,0),U,2),0),U,1),9,"")) ; updated call to radiology
37 . S RECNR=0 ; for each procedure on that date
38 . F S RECNR=$O(^RADPT(DFN,"DT",EXAMDATE,"P",RECNR)) Q:RECNR'>0 D
39 . . S REC0=$G(^RADPT(DFN,"DT",EXAMDATE,"P",RECNR,0))
40 . . S PROCPTR=+$P(REC0,U,2) ; points to the procedure
41 . . Q:PROCPTR=0
42 . . S EXAMSTAT=+$P(REC0,U,3) ; exam status
43 . . Q:EXAMSTAT'=COMPLETE
44 . . S PROC(PROCPTR)=$G(PROC(PROCPTR))+1 ; # times this proc was done
45 Q:'$D(PROC)
46 S (TPROCS,NDPROCS,TVALUE)=0
47 S PROCPTR=""
48 F S PROCPTR=$O(PROC(PROCPTR)) Q:PROCPTR="" D
49 . S PROCREC=$G(^RAMIS(71,PROCPTR,0))
50 . Q:PROCREC=""
51 . S NDPROCS=NDPROCS+1 ; number of different procedures
52 . S NPROCS=PROC(PROCPTR)
53 . S TPROCS=TPROCS+NPROCS
54 . S CPTCODE=+$P(PROCREC,U,9)
55 . S PROCCOST=$P(PROCREC,U,10)
56 . S ^(CPTCODE)=$G(^TMP("SPN",$J,"RA","PROC",CPTCODE))+NPROCS
57 . S ^("PAT")=$G(^TMP("SPN",$J,"RA","PROC",CPTCODE,"PAT"))+1
58 . S VALUE=NPROCS*PROCCOST
59 . S TVALUE=TVALUE+VALUE
60 S ^("PAT")=$G(^TMP("SPN",$J,"RA","PAT"))+1
61 S ^("EXAMS")=$G(^TMP("SPN",$J,"RA","EXAMS"))+TPROCS
62 S ^(-TPROCS)=$G(^TMP("SPN",$J,"RA","EXAMS",-TPROCS))+1
63 Q:'HI
64 S ^TMP("SPN",$J,"RA","HI","H1",-TPROCS,-NDPROCS,-TVALUE,DFN)=""
65 S ^TMP("SPN",$J,"RA","HI","H2",-TVALUE,-TPROCS,-NDPROCS,DFN)=""
66 Q
67NAMEIT ; Name the radiology procedures and get their current values
68 N CPTCODE,PROCREC,PROCPTR,PROCNAME,PROCCOST,VALUE,NPROCS
69 S CPTCODE=""
70 F S CPTCODE=$O(^TMP("SPN",$J,"RA","PROC",CPTCODE)) Q:CPTCODE="" D
71 . S PROCPTR=+$O(^RAMIS(71,"D",CPTCODE,""))
72 . S PROCREC=$G(^RAMIS(71,PROCPTR,0))
73 . S PROCNAME=$P(PROCREC,U,1)
74 . I PROCNAME="" S PROCNAME="Not identified"
75 . S ^TMP("SPN",$J,"RA","PROC",CPTCODE,"NAME")=PROCNAME
76 . S PROCCOST=+$P(PROCREC,U,10)
77 . S NPROCS=$G(^TMP("SPN",$J,"RA","PROC",CPTCODE))
78 . S VALUE=NPROCS*PROCCOST
79 . S ^TMP("SPN",$J,"RA","PROC",CPTCODE,"VAL")=VALUE
80 Q
Note: See TracBrowser for help on using the repository browser.