source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORX012.m@ 1783

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

initial load of FOIAVistA 6/30/08 version

File size: 3.7 KB
Line 
1RORX012 ;HOIFO/SG - COMBINED MEDS AND LABS REPORT ; 11/8/05 8:48am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 Q
5 ;
6 ;***** OUTPUTS THE REPORT HEADER
7 ;
8 ; PARTAG Reference (IEN) to the parent tag
9 ;
10 ; Return Values:
11 ; <0 Error code
12 ; >0 IEN of the HEADER element
13 ;
14HEADER(PARTAG) ;
15 ;;DRUGS(#,NAME,LAST4,DOD,RXNAME)
16 ;;LABTESTS(#,NAME,LAST4,DOD,DATE,LTNAME,RESULT)
17 ;;PATIENTS(#,NAME,LAST4,DOD)
18 ;
19 N HEADER,RC
20 S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
21 Q:HEADER<0 HEADER
22 S RC=$$TBLDEF^RORXU002("HEADER^RORX012",HEADER)
23 Q $S(RC<0:RC,1:HEADER)
24 ;
25 ;***** OUTPUTS THE PARAMETERS TO THE REPORT
26 ;
27 ; PARTAG Reference (IEN) to the parent tag
28 ;
29 ; [.STDT] Start and end dates of the report
30 ; [.ENDT] are returned via these parameters
31 ;
32 ; [.FLAGS] Flags for the $$SKIP^RORXU005 are
33 ; returned via this parameter
34 ;
35 ; Return Values:
36 ; <0 Error code
37 ; >0 IEN of the PARAMETERS element
38 ;
39PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
40 N PARAMS,TMP
41 S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
42 Q:PARAMS<0 PARAMS
43 ;--- Process the list of drugs and groups
44 I RORPHARM D Q:TMP<0 TMP
45 . S TMP=$$DRUGLST^RORXU007(.RORTSK,PARAMS,.RORXL,.RORXGRP)
46 ;--- Process the list of Lab tests
47 I RORLAB D Q:TMP<0 TMP
48 . S TMP=$$LTLST^RORXU006(.RORTSK,PARAMS,.RORLTST,"RORLTRV")
49 ;---
50 Q PARAMS
51 ;
52 ;***** DETERMINES THE REPORT MODE FOR LAB OR PHARMACY
53 ;
54 ; NAME Base name of the attribute ("LAB" or "PHARM")
55 ;
56 ; Return Values:
57 ; <0 "Did Not"
58 ; 0 Not selected
59 ; >0 "Did"
60RPTMODE(NAME) ;
61 Q:$$PARAM^RORTSK01("PATIENTS",NAME) 1 ; "Did"
62 Q:$$PARAM^RORTSK01("PATIENTS","NO"_NAME) -1 ; "Did Not"
63 Q 0
64 ;
65 ;***** COMPILES THE "COMBINED PHARMACY AND LAB" REPORT
66 ; REPORT CODE: 012
67 ;
68 ; .RORTSK Task number and task parameters
69 ;
70 ; The ^TMP("RORX012",$J) global node is used by this function.
71 ;
72 ; ^TMP("RORX012",$J,
73 ; "PAT",
74 ; DFN, Patient descriptor
75 ; ^01: Last 4 digits of SSN
76 ; ^02: Patient name
77 ; ^03: Date of Death
78 ; "LR",
79 ; Date,
80 ; TestName,
81 ; TestIEN) Result
82 ; "RX",
83 ; DrugName,
84 ; DrugIEN) ""
85 ;
86 ; Return Values:
87 ; <0 Error code
88 ; 0 Ok
89 ;
90RXANDLAB(RORTSK) ;
91 N RORLAB ; Labs mode (-1|0|1)
92 N RORLTST ; Closed root of the list of lab tests for the
93 ; ; Lab search API
94 N RORLTRV ; Closed root of the list of lab tests with ranges
95 N RORPHARM ; Meds mode (-1|0|1)
96 N RORREG ; Registry IEN
97 N RORXEDT ; Pharmacy end date
98 N RORXGRP ; List of drug groups
99 N RORXL ; Closed root of the drug list for the pharmacy
100 ; ; search API or "*" if all drugs were selected
101 N RORXSDT ; Pharmacy start date
102 ;
103 N ECNT,NSPT,RC,REPORT,SFLAGS,TMP
104 S (RORXL,RORLTST)="",(ECNT,RC)=0
105 K ^TMP("RORX012",$J)
106 ;--- Root node of the report
107 S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
108 Q:REPORT<0 REPORT
109 ;
110 D
111 . ;--- Get and prepare the report parameters
112 . S RORREG=$$PARAM^RORTSK01("REGIEN") ; Registry IEN
113 . S RORLAB=$$RPTMODE("LAB") ; Labs logic
114 . S RORPHARM=$$RPTMODE("PHARM") ; Meds logic
115 . S RC=$$PARAMS(REPORT,.RORXSDT,.RORXEDT,.SFLAGS) Q:RC<0
116 . ;--- Report header
117 . S RC=$$HEADER(REPORT) Q:RC<0
118 . ;--- Query the registry
119 . D TPPSETUP^RORTSK01(80)
120 . S RC=$$QUERY^RORX012A(SFLAGS,.NSPT)
121 . I RC Q:RC<0 S ECNT=ECNT+RC
122 . ;--- Store the results
123 . D TPPSETUP^RORTSK01(20)
124 . S RC=$$STORE^RORX012A(REPORT,NSPT)
125 . I RC Q:RC<0 S ECNT=ECNT+RC
126 ;
127 ;--- Cleanup
128 K ^TMP("RORX012",$J)
129 D FREE^RORTMP(RORXL),FREE^RORTMP(RORLTST)
130 Q $S(RC<0:RC,ECNT>0:-43,1:0)
Note: See TracBrowser for help on using the repository browser.