source: FOIAVistA/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGRRLU1.m@ 1751

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

initial load of FOIAVistA 6/30/08 version

File size: 8.5 KB
Line 
1DGRRLU1 ;alb/aas - DG Replacement and Rehosting RPC for VADPT ;1/4/06 11:31
2 ;;5.3;Registration;**538**;Aug 13, 1993
3 ;
4 SET X="You Can't Enter DGRRLU1 at top of routine!"
5 QUIT
6 ;
7BUS(RESULT,PARAMS) ; -- return business logic data for 1 patient in xml format
8 ; -- RPC: DGRR GET PTLK BUSINESS DATA
9 ;
10 ; -- input [required] PARAMS("PATIENT_ID_TYPE") = 'DFN' or 'ICN'
11 ; [required] PARAMS("PATIENT_ID") = a DFN value or an ICN value
12 ; [required] PARAMS("USER_ID_TYPE") = 'VPID' or 'DUZ'
13 ; [required] PARAMS("USER_ID") = value of a VPID, or DUZ
14 ; [optional] PARAMS("USER_INSTITUTION") = Station # (Defaults to DUZ(2) if not received)
15 ; [temporary/optional] PARAMS("PATIENT_RECORD_FLAG") = Optional. If 1 the query returns old version of the patient_record_flag business rule
16 ;
17 ; -- returns result array that contains XML document containing data for 12 checks of patient
18 ; related to lookup that is executed in the business layer. See Patient Lookup documentation
19 ; for logic
20 ;
21 NEW X,Y,CNT,DGRRLINE,DGRRESLT,PTID,DGENR,ICN,USERID,INSTTTN,ERRMESS
22 KILL RESULT,DGRRESLT
23 SET CNT=0
24 SET DGRRLINE=0
25 K ^TMP($J,"PLU-BRULES")
26 SET DGRRESLT="^TMP($J,""PLU-BRULES"")"
27 SET RESULT=$NA(@DGRRESLT)
28 DO DT^DICRW
29 ;
30USER ; establish the DUZ from User ID
31 IF ($G(PARAMS("USER_ID_TYPE"))="VPID") SET USERID=$$IEN^XUPS($G(PARAMS("USER_ID")))
32 IF ($G(PARAMS("USER_ID_TYPE"))="DUZ") SET USERID=$G(PARAMS("USER_ID"))
33 IF +$G(USERID)>0 DO DUZ^XUP(USERID)
34 IF +$G(USERID)<1 SET ERRMESS="USER_ID_TYPE: "_$G(PARAMS("USER_ID_TYPE"))_" USER_ID: "_$G(PARAMS("USER_ID"))_" does not exist."
35 ;
36INSTTTN ; set institution to USER_INSTITUTION if available else set to default institution
37 ;USER_INSTITUTION parameter if defined will contain the station number for
38 ;an institution. Call $$IEN^XUAF4 (IA#2171) to convert station number to IEN.
39 SET INSTTTN=$G(PARAMS("USER_INSTITUTION")),INSTTTN=$$IEN^XUAF4(INSTTTN)
40 IF INSTTTN="" S INSTTTN=$G(DUZ(2))
41 ;
42PATIENT ; establish Patient VPID from Patient ID
43 IF $G(PARAMS("PATIENT_ID_TYPE"))="ICN" DO
44 .SET ICN=$G(PARAMS("PATIENT_ID"))
45 .SET PTID=$$CHARCHK^DGRRUTL($$GETDFN^MPIF001($P(ICN,"V",1)))
46 IF $G(PARAMS("PATIENT_ID_TYPE"))="DFN" DO
47 .SET PTID=$$CHARCHK^DGRRUTL($GET(PARAMS("PATIENT_ID")))
48 IF ($G(PTID)<1) SET ERRMESS="PATIENT_ID_TYPE: "_$G(PARAMS("PATIENT_ID_TYPE"))_" PATIENT_ID: "_$G(PARAMS("PATIENT_ID"))_" does not exist."
49 IF ($G(PTID)>0),($G(^DPT(PTID,0))="") SET ERRMESS="For Patient Id ("_PTID_"), no data exists."
50 ;
51 DO ADD^DGRRLU($$XMLHDR^DGRRUTL())
52 IF ($G(ERRMESS)'="") D ADD^DGRRLU("<error message="_ERRMESS_"'></error>") GOTO BUSEND
53 DO ADD^DGRRLU("<businessRules patientId='"_PTID_"' patientName='"_$$CHARCHK^DGRRUTL($P($G(^DPT(PTID,0)),"^",1))_"' patientSSN='"_$P($G(^DPT(PTID,0)),"^",9)_"'>")
54 DO ADD^DGRRLU("<error message=''></error>")
55 D RULES(PTID,INSTTTN)
56BUSEND DO ADD^DGRRLU("</businessRules>")
57 QUIT
58 ;
59RULES(DFN,DIV) ;
60 ; -- display order from old SRS
61 ; Messages will display in the following order:
62 ; emp SSN mission, Similar, Deceased, Security (sometimes), CWAD, Missing, Test, Enrollment and Means Test.
63 ;
64 N DOD,MASPARAM,TPFIELD,SENSITIV,USERKEY,SIM,PTSSN,PRIM1,EMPSSN,PTSSN
65 SET EMPSSN=$$GET1^DIQ(200,DUZ_",",9,"I","","DGNPERR")
66 SET PTSSN=$P($G(^DPT(DFN,0)),"^",9)
67 SET USERKEY=$S($D(^XUSEC("DG RECORD ACCESS",DUZ)):"true",1:"false")
68 SET MASPARAM=$S(+$P($G(^DG(43,1,"REC")),"^")=1:"true",1:"false") ;Restrict Patient Record Access (#1201)
69 ;
700 ; -- employee SSN missing from new person file
71 N X
72 S X=" <businessRule alertId='employeeSSNExists' empSsn='"_$$CHARCHK^DGRRUTL(EMPSSN)
73 S X=X_"' masParameter='"_$$CHARCHK^DGRRUTL(MASPARAM)
74 S X=X_"' userRecordAccessPrivilege='"_$$CHARCHK^DGRRUTL(USERKEY)_"'></businessRule>"
75 D ADD^DGRRLU(X)
76 ;
771 ; -- similar patients, Checks the BS5 cross reference for similar patients and matches last name
78 ; bs5 index is first character of last name concatenated with last 4 of ssn.
79 ; give warning, ask if okay,
80 ;
81 SET SIM=$S($$BS5^DPTLK5(DFN)=1:"true",1:"false")
82 DO ADD^DGRRLU(" <businessRule alertId='similarPatients' similarPatientsFound='"_$$CHARCHK^DGRRUTL(SIM)_"'></businessRule>")
83 ;
842 ; -- deceased patient
85 ; give warning if patient is deceased
86 SET DOD=$P($G(^DPT(DFN,.35)),"^",1)
87 DO ADD^DGRRLU(" <businessRule alertId='deceasedPatient' theDateOfDeath='"_$$CHARCHK^DGRRUTL(DOD)_"'></businessRule>")
88 ;
893 ; -- accessing own record and user doesn't have dg record access key and MAS parameter to restrict patient records=yes
90 ; check parameter first, check key second. if (param && !userKey), if (emp ssn == to pt ssn) don't allow (check format of ssn)
91 ; if (empssn=="") tell them to get added and don't allow access
92 SET X=" <businessRule alertId='accessOwnRecord' masParameter='"_$$CHARCHK^DGRRUTL(MASPARAM)
93 SET X=X_"' userRecordAccessPrivilege='"_$$CHARCHK^DGRRUTL(USERKEY)_"' employeeSSN='"_$$CHARCHK^DGRRUTL(EMPSSN)_"' patientSSN='"_$$CHARCHK^DGRRUTL(PTSSN)_"'></businessRule>"
94 DO ADD^DGRRLU(X)
95 ;
964 ; -- primary elig = employee and user doesn't hold dg security office key,from EMPL^DGSEC4(DFN)
97 ; give message and log if chosen
98 NEW ELIST,DGELIG
99 S DGELIG=0,ELIST=""
100 F S DGELIG=+$O(^DPT("AEL",DFN,DGELIG)) Q:'DGELIG D
101 . S ELIST=ELIST_$P($G(^DIC(8.1,+$P($G(^DIC(8,DGELIG,0)),"^",9),0)),"^",1)_","
102 SET USERKEY=$S($D(^XUSEC("DG SECURITY OFFICER",DUZ)):"true",1:"false")
103 DO ADD^DGRRLU(" <businessRule alertId='patientIsEmployee' eligibilityList='"_$$CHARCHK^DGRRUTL(ELIST)_"' primElig='"_$$CHARCHK^DGRRUTL($$PRIM^DGRRLUA(DFN))_"' userSecurityOfficerPrivilege='"_$$CHARCHK^DGRRUTL(USERKEY)_"'></businessRule>")
104 ;
1055 ; -- sensitive record and user doesn't have the dg sensitivity key
106 ; ask to continue, if yes, log if chosen
107 SET SENSITIV=$S($P($G(^DGSL(38.1,DFN,0)),"^",2)=1:"true",1:"false")
108 SET USERKEY=$S($D(^XUSEC("DG SENSITIVITY",DUZ)):"true",1:"false")
109 DO ADD^DGRRLU(" <businessRule alertId='sensitiveRecord' isSensitive='"_$$CHARCHK^DGRRUTL(SENSITIV)_"' userSensitivityPrivilege='"_$$CHARCHK^DGRRUTL(USERKEY)_"'></businessRule>")
110 ;
1116 ; -- cwad for patient (C)risis notes, Clinical (W)arnings, (A)lergies, and Advance (D)irectives
112 NEW CWAD
113 SET CWAD=$$CWAD^ORQPT2(DFN)
114 DO ADD^DGRRLU(" <businessRule alertId='cwadChecks' cwads='"_$$CHARCHK^DGRRUTL(CWAD)_"'></businessRule>")
115 ;
1167 ; -- patient on MPR, see if patient is listed in Missing Patient Register
117 NEW MPREC
118 ;S X="MPRCHK" X ^%ZOSF("TEST") I $T I $L($T(GUI^MPRCHK)) D GUI^MPRCHK(DFN,.MPREC) ; MPR
119 DO ADD^DGRRLU(" <businessRule alertId='patientOnMPR' value='"_$$CHARCHK^DGRRUTL($S($G(MPREC(0))=1:"true",1:"false"))_"'></businessRule>")
120 ;
1218 ; -- test patient
122 ; if (dataColumn=1) display message.
123 S TPFIELD="false"
124 I $$TESTPAT^VADPT(DFN) S TPFIELD="true"
125 DO ADD^DGRRLU(" <businessRule alertId='testPatient' testPatientColumn='"_$$CHARCHK^DGRRUTL(TPFIELD)_"'></businessRule>")
126 ;
1279 ; -- enrollment information FROM DPTLK, Provide Enrollment data for user notification
128 ;
129 ; If patient is NOT ELIGIBLE, display Enrollment Status (Ineligible Project Phase I)
130 ; Get Enrollment Group Threshold Priority and Subgroup
131 ; Compare Patient's Enrollment Priority to Enrollment Group Threshold
132 ;
133 NEW ENCAT,ENPRIO,ENSUBGRP,ENEND,LINE,DGENST
134 S ENCAT=""
135 I $$GET^DGENA($$FINDCUR^DGENA(+DFN),.DGENR) D
136 . S ENCAT=$$CATEGORY^DGENA4(+DFN)
137 . S ENCAT=$$EXTERNAL^DILFD(27.15,.02,"",ENCAT)
138 S ENPRIO=$S($G(DGENR("PRIORITY")):$$EXT^DGENU("PRIORITY",DGENR("PRIORITY")),1:"")
139 S ENSUBGRP=$S($G(DGENR("SUBGRP"))="":"",1:$$EXT^DGENU("SUBGRP",$G(DGENR("SUBGRP"))))
140 SET ENEND=$G(DGENR("END"))
141 SET DGENST=$S($G(DGENR("STATUS"))=10:DGENR("STATUS"),$G(DGENR("STATUS"))=19:DGENR("STATUS"),$G(DGENR("STATUS"))=20:DGENR("STATUS"),1:"")
142 I DGENST'="" S DGENST=$$EXTERNAL^DILFD(27.11,.04,"",DGENST)
143 ; check for Combat Veteran Eligibility, if elig do not display EGT info
144 N DGENTHR
145 S DGENTHR=1
146 I '$$CVEDT^DGCV(+DFN) D
147 .;Get Enrollment Group Threshold Priority and Subgroup
148 .N DGEGTIEN,DGEGT
149 .S DGEGTIEN=$$FINDCUR^DGENEGT
150 .S DGEGT=$$GET^DGENEGT(DGEGTIEN,.DGEGT)
151 .Q:$G(DGENR("PRIORITY"))=""!($G(DGEGT("PRIORITY"))="")
152 .;Compare Patient's Enrollment Priority to Enrollment Group Threshold
153 .S DGENTHR=$$ABOVE^DGENEGT1(+DFN,DGENR("PRIORITY"),$G(DGENR("SUBGRP")),DGEGT("PRIORITY"),DGEGT("SUBGRP"))
154 SET LINE=" <businessRule alertId='enrollmentData' category='"_$$CHARCHK^DGRRUTL(ENCAT)_"' endDate='"_$$CHARCHK^DGRRUTL(ENEND)_"' priority='"
155 SET LINE=LINE_$$CHARCHK^DGRRUTL(ENPRIO)_"' subgroup='"_$$CHARCHK^DGRRUTL(ENSUBGRP)_"' status='"_$$CHARCHK^DGRRUTL(DGENST)
156 SET LINE=LINE_"' aboveThreshold='"_DGENTHR_"'></businessRule>"
157 D ADD^DGRRLU(LINE)
158 ;
159 D 10^DGRRLU1A
160END ;
161 QUIT
Note: See TracBrowser for help on using the repository browser.