source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORXU001.m@ 1578

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

initial load of WorldVistAEHR

File size: 4.5 KB
Line 
1RORXU001 ;HCIOFO/BH,SG - REPORT UTILITIES ; 1/24/06 8:14am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 ; This routine uses the following IAs:
5 ;
6 ; #92 Read access to the file #45 (controlled)
7 ; fields 3 and 4.
8 ; #1480 Read access to the file #405 (controlled)
9 ; #1894 ENCEVENT^PXKENC (controlled)
10 ;
11 Q
12 ;
13 ;***** DOUBLE CHECKS THE ADMISSION
14 ;
15 ; DFN Patient IEN
16 ; VAINDT Admission date
17 ; .DISDT Discharge date
18 ;
19 ; Return Values:
20 ; 0 Ok
21 ; 1 Invalid admission date
22 ;
23CHKADM(DFN,VAINDT,DISDT) ;
24 N IEN,RORMSG,VADMVT,VAHOW,VAROOT
25 D ADM^VADPT2 Q:'VADMVT 1
26 S IEN=+$$GET1^DIQ(405,VADMVT,.17,"I",,"RORMSG")
27 S:IEN>0 DISDT=$$GET1^DIQ(405,IEN_",",.01,"I",,"RORMSG")
28 Q 0
29 ;
30 ;***** DATE OF THE MOST RECENT VISIT TO ANY OF THE SELECTED CLINICS
31 ;
32 ; PATIEN Patient IEN (file #2)
33 ;
34 ; .RORCLIN Reference to a local array of Clinics, the subscripts
35 ; are IEN's from file #44 or will be a single element
36 ; array with a subscript of "ALL", which will denote
37 ; all clinics (i.e. CLIN("ALL")="").
38 ;
39 ; Return Values:
40 ; 0 The patient has never been seen at any of the given
41 ; clinics
42 ; >0 Date of the most recent visit to one of the selected
43 ; clinics
44 ;
45LASTVSIT(PATIEN,RORCLIN) ;
46 N QUERY,RORDT,RORLAST
47 S RORDT=$$FMADD^XLFDT($$DT^XLFDT,1),RORLAST=0
48 ;---
49 D OPEN^SDQ(.QUERY)
50 D INDEX^SDQ(.QUERY,"PATIENT","SET")
51 D PAT^SDQ(.QUERY,PATIEN,"SET")
52 D SCANCB^SDQ(.QUERY,"D SDQSCAN2^RORXU001(Y,Y0)","SET")
53 D ACTIVE^SDQ(.QUERY,"TRUE","SET")
54 D SCAN^SDQ(.QUERY,"FORWARD")
55 D CLOSE^SDQ(.QUERY)
56 ;---
57 Q RORLAST
58 ;
59 ;***** LOADS PTF DATA AND CHECKS IF THE RECORD SHOULD BE SKIPPED
60 ;
61 ; PTFIEN IEN of the PTF record
62 ;
63 ; [FLAGS] Flags to control processing
64 ; F Skip fee-basis records
65 ; P Skip non-PTF records
66 ;
67 ; [.ADMDT] Admission date is returned via this parameter
68 ; [.DISDT] Discharge date is returned via this parameter
69 ; [.SUFFIX] Suffix is returned via this parameter
70 ; [.STATUS] Status is returned via this parameter
71 ; [.FACILITY] Facility number is returned via this parameter
72 ;
73 ; Return Values:
74 ; <0 Error code
75 ; 0 Ok
76 ; 1 Skip this record
77 ;
78PTF(PTFIEN,FLAGS,ADMDT,DISDT,SUFFIX,STATUS,FACILITY) ;
79 N FLDLST,IENS,RORBUF,RORMSG
80 S FLAGS=$G(FLAGS),IENS=(+PTFIEN)_","
81 S FLDLST="2;3;5;6;70"
82 S:FLAGS["F" FLDLST=FLDLST_";4" ; FEE BASIS
83 S:FLAGS["P" FLDLST=FLDLST_";11" ; TYPE OF RECORD
84 ;--- Load the data
85 D GETS^DIQ(45,IENS,FLDLST,"I","RORBUF","RORMSG")
86 Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,45,IENS)
87 ;---
88 S ADMDT=$G(RORBUF(45,IENS,2,"I")) ; ADMISSION DATE
89 S FACILITY=$G(RORBUF(45,IENS,3,"I")) ; FACILITY
90 S SUFFIX=$G(RORBUF(45,IENS,5,"I")) ; SUFFIX
91 S STATUS=$G(RORBUF(45,IENS,6,"I")) ; STATUS
92 S DISDT=$G(RORBUF(45,IENS,70,"I")) ; DISCHARGE DATE
93 Q:ADMDT'>0 1
94 ;--- Skip a non-PTF record
95 I FLAGS["P" Q:$G(RORBUF(45,IENS,11,"I"))'=1 1
96 ;--- Skip a fee basis record
97 I FLAGS["F" Q:$G(RORBUF(45,IENS,4,"I")) 1
98 ;--- Success
99 Q 0
100 ;
101 ;**** CALL-BACK ENTRY POINTS FOR THE SDQ API
102SDQSCAN1(Y,Y0) ;
103 N TMP
104 ;--- Check the clinic
105 I '$$PARAM^RORTSK01("CLINICS","ALL") D Q:'TMP
106 . S TMP=$D(RORTSK("PARAMS","CLINICS","C",+$P(Y0,U,4)))
107 ;--- Count the encounters
108 S RORENCNT=RORENCNT+1
109 Q
110 ;
111SDQSCAN2(Y,Y0) ;
112 N DTX,TMP
113 ;--- Check the clinic
114 I '$$PARAM^RORTSK01("CLINICS","ALL") D Q:'TMP
115 . S TMP=$D(RORTSK("PARAMS","CLINICS","C",+$P(Y0,U,4)))
116 ;--- Date of the visit
117 S DTX=+$P(Y0,U) S:(DTX>RORLAST)&(DTX<RORDT) RORLAST=DTX
118 Q
119 ;
120 ;***** CHECKS IF THE PATIENT WAS SEEN AT SELECTED CLINICS
121 ;
122 ; RORSDT Start Date for search (FileMan).
123 ; Time is ignored and the beginning of the day is
124 ; considered as the boundary (ST\1).
125 ;
126 ; ROREDT End Date for search (FileMan).
127 ; Time is ignored and the end of the day is
128 ; considered as the boundary (ED\1+1).
129 ;
130 ; PATIEN Patient IEN (file #2)
131 ;
132 ; Return Values:
133 ; 0 The patient was not seen at any of the given clinics
134 ; during the provided time frame
135 ; 1 The patient was seen
136 ;
137SEEN(RORSDT,ROREDT,PATIEN) ;
138 N QUERY,RORENCNT
139 S RORENCNT=0
140 ;---
141 D OPEN^SDQ(.QUERY)
142 D INDEX^SDQ(.QUERY,"PATIENT/DATE","SET")
143 D PAT^SDQ(.QUERY,PATIEN,"SET")
144 D DATE^SDQ(.QUERY,RORSDT\1,$$FMADD^XLFDT(ROREDT\1,1),"SET")
145 D SCANCB^SDQ(.QUERY,"D SDQSCAN1^RORXU001(Y,Y0)","SET")
146 D ACTIVE^SDQ(.QUERY,"TRUE","SET")
147 D SCAN^SDQ(.QUERY,"FORWARD")
148 D CLOSE^SDQ(.QUERY)
149 ;---
150 Q (RORENCNT>0)
Note: See TracBrowser for help on using the repository browser.