1 | QACVEMPX ; Return Person Data using Value List Handler Pattern to update Patient Advocate PatsPerson table ;5/8/06 10:36
|
---|
2 | ;;2.0;Patient Representative;**19**;07/25/1995;Build 55
|
---|
3 | EN(PATSBY,LKUPVAL,PATSROWS,PATSFRM0,PATSFRM1) ; Lookup Employee by Name, then
|
---|
4 | ; Output XML formatted data from NEW PERSON file.
|
---|
5 | ; PATSBY contains the name of the output array (pass by reference)
|
---|
6 | ; LKUPVAL is the name of the person to be matched (LAST,FIRST), or
|
---|
7 | ; an array of Security Keys.
|
---|
8 | ; PATSROWS=Number of rows to return in each call
|
---|
9 | ; PATSFRM0=Employee Name value from previous call (empty on first call)
|
---|
10 | ; PATSFRM1=Employee IEN from previous call (empty on first call)
|
---|
11 | K ^TMP("DILIST",$J),^TMP("PatsPersonXml",$J)
|
---|
12 | N STDNAME,NAMECOMP,IENS,PIECE,OUTCNT,TAGLIST,FROM,PART,SRVIEN,MAILCODE,TITLE,SRVRSTA,PATSMORE,PATSERR,DIERR,I,J,X,Y
|
---|
13 | ; If LKUPVAL exists, it contains an employee name. Else, it is
|
---|
14 | ; an array of Security Key values and we want to find all holders
|
---|
15 | ; of those keys.
|
---|
16 | ; Standardize the name, parse out last name and first name.
|
---|
17 | I $G(LKUPVAL)]"" S STDNAME=LKUPVAL D BYNAME
|
---|
18 | I $G(LKUPVAL)="" D
|
---|
19 | . D EN^QACVKHLD(.LKUPVAL,PATSROWS,.PATSFRM0,.PATSFRM1)
|
---|
20 | . S FROM(1)=$G(PATSFRM0),FROM(2)=$G(PATSFRM1)
|
---|
21 | . S PATSMORE=$S(FROM(1)="":0,1:1)
|
---|
22 | . Q
|
---|
23 | I '$D(^TMP("DILIST",$J)),'$D(^TMP("DIERR",$J)) Q
|
---|
24 | S PATSERR="" I $D(^TMP("DIERR",$J)) S PATSERR=$G(^TMP("DIERR",$J,1,"TEXT",1))
|
---|
25 | ; Get Station Number of Institution where server resides (IA #1518)
|
---|
26 | S SRVRSTA=$$STA^XUAF4(+$$GET1^DIQ(8989.3,1,217,"I"))
|
---|
27 | ; Set name of output array into output parameter.
|
---|
28 | S PATSBY=$NA(^TMP("PatsPersonXml",$J))
|
---|
29 | ; Now build the output.
|
---|
30 | D HDR
|
---|
31 | S OUTCNT=2
|
---|
32 | D EN2(.OUTCNT),FOOTER(.OUTCNT)
|
---|
33 | Q
|
---|
34 | ;
|
---|
35 | ;
|
---|
36 | BYNAME ; Standardize the name, parse out last name and first name. (IA #3065)
|
---|
37 | D STDNAME^XLFNAME(.STDNAME,"FG")
|
---|
38 | N FIRST,LAST,LEN,SCR,CURRDT
|
---|
39 | S LAST=$P(STDNAME,","),FIRST=$P(STDNAME,",",2,99)
|
---|
40 | S CURRDT=$$DT^XLFDT()
|
---|
41 | ; Screen out terminated users.
|
---|
42 | S SCR="I ($P(^(0),""^"",11)=""""!(CURRDT<$P(^(0),""^"",11)))"
|
---|
43 | ; If first name was passed, check for it with a screen.
|
---|
44 | S LEN=$L(FIRST) I LEN>0 S SCR=SCR_",$E($P($P(^(0),""^""),"","",2,99),1,"_LEN_")="_""""_FIRST_""""
|
---|
45 | ; Set the starting values, and partial match values.
|
---|
46 | I $G(PATSFRM0)="" S FROM(1)=LAST,FROM(2)=""
|
---|
47 | E S FROM(1)=PATSFRM0,FROM(2)=$G(PATSFRM1)
|
---|
48 | S PART(1)=LAST
|
---|
49 | I '$G(PATSROWS) S PATSROWS=10
|
---|
50 | ; Return list of standard name pointer, title and mail code (IA #10060)
|
---|
51 | D LIST^DIC(200,,"@;8;28","MP",PATSROWS,.FROM,.PART,"B",SCR)
|
---|
52 | ; Set flag telling whether there are more entries to fetch).
|
---|
53 | S PATSMORE=$S(FROM(1)="":0,1:1)
|
---|
54 | Q
|
---|
55 | ;
|
---|
56 | HDR ; Build header node
|
---|
57 | S ^TMP("PatsPersonXml",$J,1)="<?xml version=""1.0"" encoding=""utf-8""?>"
|
---|
58 | S ^TMP("PatsPersonXml",$J,2)="<PersonDataSet hasMore="""_PATSMORE_""" patsFrom0="""_FROM(1)_""" patsFrom1="""_FROM(2)_""" vistAError="""_PATSERR_""">"
|
---|
59 | Q
|
---|
60 | ;
|
---|
61 | EN2(OUTCNT) ; Build output for individual persons.
|
---|
62 | N TAGLIST,IENS,TITLE,MAILCODE,NAMECOMP,I,J,X,Y
|
---|
63 | ; Build list of XML tags to use in output.
|
---|
64 | D BLDLST(.TAGLIST)
|
---|
65 | ; Read through lister results and build output
|
---|
66 | F I=0:0 S I=$O(^TMP("DILIST",$J,I)) Q:'I S X=$G(^(I,0)) D
|
---|
67 | . S OUTCNT=OUTCNT+1
|
---|
68 | . S ^TMP("PatsPersonXml",$J,OUTCNT)="<PatsPerson>"
|
---|
69 | . S IENS=$P(X,"^") Q:IENS="" S IENS=IENS_","
|
---|
70 | . ; NOTE: does not remove reserved XML characters (see $$SYMENC^MXMLUTL, IA#4153)
|
---|
71 | . S TITLE=$E($P(X,"^",2),1,30)
|
---|
72 | . S MAILCODE=$E($P(X,"^",3),1,30)
|
---|
73 | . ; Get the individual name components and add them to the output (IA #3065)
|
---|
74 | . K NAMECOMP S NAMECOMP("FILE")=200,NAMECOMP("FIELD")=.01,NAMECOMP("IENS")=IENS
|
---|
75 | . S NAMECOMP=$$HLNAME^XLFNAME(.NAMECOMP,"S")
|
---|
76 | . F J=1:1:6 D
|
---|
77 | .. S OUTCNT=OUTCNT+1
|
---|
78 | .. S Y=$P(NAMECOMP,"^",J)
|
---|
79 | .. S ^TMP("PatsPersonXml",$J,OUTCNT)="<"_TAGLIST(J)_">"_Y_"</"_TAGLIST(J)_">"
|
---|
80 | .. Q
|
---|
81 | . S OUTCNT=OUTCNT+1
|
---|
82 | . S ^TMP("PatsPersonXml",$J,OUTCNT)="<Title>"_TITLE_"</Title>"
|
---|
83 | . S OUTCNT=OUTCNT+1
|
---|
84 | . S ^TMP("PatsPersonXml",$J,OUTCNT)="<MailCode>"_MAILCODE_"</MailCode>"
|
---|
85 | . S OUTCNT=OUTCNT+1
|
---|
86 | . S ^TMP("PatsPersonXml",$J,OUTCNT)="<VistaIen>"_$P(X,"^")_"</VistaIen>"
|
---|
87 | . S OUTCNT=OUTCNT+1
|
---|
88 | . S ^TMP("PatsPersonXml",$J,OUTCNT)="</PatsPerson>"
|
---|
89 | . Q
|
---|
90 | Q
|
---|
91 | ;
|
---|
92 | FOOTER(OUTCNT) ; Add the footer
|
---|
93 | S ^TMP("PatsPersonXml",$J,OUTCNT+1)="</PersonDataSet>"
|
---|
94 | K ^TMP("DILIST",$J)
|
---|
95 | Q
|
---|
96 | ;
|
---|
97 | CONV(NAMEPART) ; Convert a name part to mixed case
|
---|
98 | N LEN,TEMP,UPPER,I,X
|
---|
99 | S LEN=$L(NAMEPART),UPPER=1,TEMP=""
|
---|
100 | F I=1:1:LEN S X=$E(NAMEPART,I,I) D
|
---|
101 | . I UPPER=1 D
|
---|
102 | .. I X?1L S X=$C($A(X)-32)
|
---|
103 | .. S UPPER=0 Q
|
---|
104 | . E I X?1U S X=$C($A(X)+32)
|
---|
105 | . S TEMP=TEMP_X
|
---|
106 | . I X'?1L,X'?1U S UPPER=1
|
---|
107 | . Q
|
---|
108 | Q TEMP
|
---|
109 | ;
|
---|
110 | BLDLST(TAGLIST) ; Build list of XML data tags
|
---|
111 | S TAGLIST(1)="LastName"
|
---|
112 | S TAGLIST(2)="FirstName"
|
---|
113 | S TAGLIST(3)="MiddleName"
|
---|
114 | S TAGLIST(4)="NameSuffix"
|
---|
115 | S TAGLIST(5)="NamePrefix"
|
---|
116 | S TAGLIST(6)="Degree"
|
---|
117 | Q
|
---|
118 | ;
|
---|