source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XUPSQRY.m@ 1697

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

initial load of WorldVistAEHR

File size: 5.1 KB
RevLine 
[613]1XUPSQRY ;EDS/GRR - Query New Person file ;4/9/04 10:40
2 ;;8.0;KERNEL;**325**; Jul 10, 1995
3 ;;Input Parameter:
4 ;; XUPSVPID - VPID of the user (Required for lookup by VPID)
5 ;; XUPSLNAM - Part or all of the last name to use for basis
6 ;; of query (Required for lookup by name)
7 ;; XUPSFNAM - Part or all of the first name to use for basis
8 ;; of query filter (optional, can be null)
9 ;; XUPSSSN - Social Security Number (null or full 9 digits) to
10 ;; use as additional filter for query
11 ;; XUPSPROV - If value set to "P", screen for only providers
12 ;; (only persons with active person class)
13 ;; XUPSSTN - Filter persons based on station number entered
14 ;; (optional, can be null)
15 ;; XUPSMNM - Maximum Number of entries to return
16 ;; (Number between 1 and 50. Null defaults to 50)
17 ;; XUPSDATE - Date to be used to determine whether person has
18 ;; active person class. If null, current date is used.
19 ;;
20 ;;Output:
21 ;; RESULT - Name of global array were output data is stored
22 ;; ^TMP($J,"XUPSQRY",1) - 1 if found, 0 if not found
23 ;; ^TMP($J,"XUPSQRY",n,0) - VPID^IEN^Last Name~First Name~
24 ;; Middle Name^SSN^DOB^SEX^
25 ;; ^TMP($J,"XUPSQRY",n,1) - Provider Type^
26 ;; ^TMP($J,"XUPSQRY",n,2) - Provider Classification^
27 ;; ^TMP($J,"XUPSQRY",n,3) - Provider Area of Specialization^
28 ;; ^TMP($J,"XUPSQRY",n,4) - VA CODE^X12 CODE^Specialty Code^
29 ;; end-of-record character "|"
30 ;;
31EN1(RESULT,XUPSVPID,XUPSLNAM,XUPSFNAM,XUPSSSN,XUPSPROV,XUPSSTN,XUPSMNM,XUPSDATE) ;
32 N %,XUPSNDAT
33 K ^TMP($J,"XUPSQRY")
34 K RESULT
35 S RESULT=$NA(^TMP($J,"XUPSQRY")) ;set variable to name of global array where output data will be stored
36 S ^TMP($J,"XUPSQRY",1)=0 ;initialize to not found
37 I $G(XUPSLNAM)="",($G(XUPSVPID)="") Q ;last name parameter empty, and is required
38 S XUPSFNAM=$G(XUPSFNAM) ;Set to null if missing
39 S XUPSSSN=$G(XUPSSSN) ;Set to null if missing
40 S XUPSPROV=$G(XUPSPROV) ;Set to null if missing
41 S XUPSSTN=$G(XUPSSTN) ;Set to null if missing
42 I $G(XUPSDATE)="" S XUPSDATE="" ;set to null if missing
43 D NOW^%DTC S XUPSNDAT=%\1 ;set date to today and truncate time
44 S XUPSDATE=$S(XUPSDATE="":XUPSNDAT,1:$$FMDATE^HLFNC(XUPSDATE)) ;change date from hl7 format to fileman format
45 N XUPSCNT,XUPSNAME,XUPSIEN,XUPSDOB,XUPSSEX,XUPSPC,XUPSX12,XUPSPASS ;initialize new set of variables
46 S:$G(XUPSMNM)="" XUPSMNM=50 ;set to default
47 S XUPSCNT=0 ;Initialize variable
48 ;
49 ;Lookup by VPID
50 I $G(XUPSVPID)'="" D Q
51 .S XUPSIEN=$$IEN^XUPS(XUPSVPID)
52 .I +XUPSIEN>0 D
53 ..D FILTER
54 ..Q:XUPSPASS=0
55 ..S XUPSCNT=XUPSCNT+1
56 ..D FOUND(XUPSCNT,XUPSIEN,XUPSDATE) ;set array with person data
57 ;
58 S XUPSIEN=0,XUPSNAME=XUPSLNAM ;initialize variables
59 ;;
60 ;;Loop through the Name index, quit if name is null or beginning portion of name not equal parameter passed or maximum number of entries reached
61 ;;
62 F S XUPSNAME=$O(^VA(200,"B",XUPSNAME)) Q:XUPSNAME=""!($E(XUPSNAME,1,$L(XUPSLNAM))'[XUPSLNAM)!(XUPSCNT+1>XUPSMNM) S XUPSIEN=0 F S XUPSIEN=$O(^VA(200,"B",XUPSNAME,XUPSIEN)) Q:XUPSIEN="" D
63 .D FILTER
64 .Q:XUPSPASS=0
65 .S XUPSCNT=XUPSCNT+1
66 .D FOUND(XUPSCNT,XUPSIEN,XUPSDATE) ;set array with person data
67 Q
68FILTER ;
69 S XUPSPASS=1 ;initialize found flag to found
70 I '$$ACTIVE^XUSER(XUPSIEN),($O(^VA(200,XUPSIEN,8910,0))>0) S XUPSPASS=0 Q ;skip visitors
71 I XUPSFNAM]"" S XUPSPASS=$$NMATCH^XUPSUTL1(XUPSIEN,XUPSFNAM) ;check if matches name filter
72 Q:'XUPSPASS ;failed to match
73 I XUPSSSN]"",($P($G(^VA(200,XUPSIEN,1)),"^",9)'=XUPSSSN) S XUPSPASS=0 Q ;check ssn filter
74 I XUPSSTN]"" S XUPSPASS=$$STNMAT^XUPSUTL1(XUPSIEN,XUPSSTN) ;check station number
75 Q:'XUPSPASS ;failed match
76 I XUPSPROV]"",($$GET^XUA4A72(XUPSIEN,XUPSDATE)<0) S XUPSPASS=0 Q ;check if active person class
77 Q
78FOUND(XUPSCNT,XUPSIEN,XUPSDATE) ;format output array
79 N XUPSNAME,XUPSSSN,XUPSVPID,XUPSSEX,XUPSDOB,I,Y
80 S Y=$P(^VA(200,XUPSIEN,0),"^",1) ;get full name
81 S XUPSNAME=$$HLNAME^HLFNC(Y,"~|\/") ;format name into last name~first name~middle name
82 I $L(XUPSNAME,"~")<3 S $P(XUPSNAME,"~",3)="" ;make sure formatted name has all 3 pieces
83 S Y=$G(^VA(200,XUPSIEN,1)) ;get ssn,dob,sex
84 S XUPSSSN=$P(Y,"^",9) ;ssn
85 S XUPSVPID=$P($G(^VA(200,XUPSIEN,"VPID")),"^",1)
86 S XUPSSEX=$P(Y,"^",2) ;sex
87 S XUPSDOB=$P(Y,"^",3) ;dob fileman format
88 I XUPSDOB]"" S XUPSDOB=$$HLDATE^HLFNC(XUPSDOB,"DT") ;format dob to correct hl7 format yyyymmdd
89 S ^TMP($J,"XUPSQRY",1)=1 ;set to indicate match found
90 S ^TMP($J,"XUPSQRY",XUPSCNT,0)=XUPSVPID_"^"_XUPSIEN_"^"_XUPSNAME_"^"_XUPSSSN_"^"_XUPSDOB_"^"_XUPSSEX_"^"
91 S XUPSPC=$$GET^XUA4A72(XUPSIEN,XUPSDATE) ;get active person class data
92 S:XUPSPC<0 XUPSPC="" ;no active person class
93 F I=1:1:3 S ^TMP($J,"XUPSQRY",XUPSCNT,I)=$P(XUPSPC,"^",(1+I))_"^" ;put provider type, provider class, and are of specialization in output array
94 S XUPSX12=$S(XUPSPC="":"",1:$P(^USC(8932.1,+XUPSPC,0),"^",7)) ;get x12 code which is not returned by api
95 S ^TMP($J,"XUPSQRY",XUPSCNT,4)=$P(XUPSPC,"^",7)_"^"_XUPSX12_"^"_$P(XUPSPC,"^",8)_"^|" ;put va code, x12 code, specialty code, and end-of-record character in output array
96 Q
Note: See TracBrowser for help on using the repository browser.