source: FOIAVistA/tag/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XLFNAME8.m@ 1590

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

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1XLFNAME8 ;BPOIFO/KEITH/DW - NAME STANDARDIZATION ; 12 Aug 2002@20:20
2 ;;8.0;KERNEL;**343**; Jul 10, 1995;
3 ;
4FAMILY ;Family name help text
5 S XUM("LENGTH")="1-35"
6 Q
7 ;
8GIVEN ;Given name help text
9 S XUM("LENGTH")="1-25"
10 Q
11 ;
12MIDDLE ;Middle name help text
13 S XUM("LENGTH")="1-25"
14 Q
15 ;
16PREFIX ;Name prefix help text
17 S XUM("LENGTH")="1-10"
18 Q
19 ;
20SUFFIX ;Name suffix help text
21 S XUM("LENGTH")="1-10"
22 Q
23 ;
24DEGREE ;Name degree help text
25 S XUM("LENGTH")="1-10"
26 Q
27 ;
28CVALID(XUC,XUX,XUM) ;Name component validation
29 ; Input: XUC=name component (e.g. FAMILY, GIVEN, etc.)
30 ; XUX=input value to validate
31 ; XUM=array to return results and errors (pass by reference)
32 ;
33 ;Output: XUM array in the format:
34 ; XUM("ERROR",n)=error text (if any)
35 ; XUM("HELP",n)=help text
36 ; XUM("LENGTH")=field length in length (e.g. 3-30)
37 ; XUM("RESULT")=transformed name value (null if invalid entry)
38 ;
39 N XUL,XUF,XUI,XUR,XUMSG,DIERR
40 S XUF="FAMILY^GIVEN^MIDDLE^PREFIX^SUFFIX^DEGREE"
41 S XUF=$P(XUF,XUC),XUF=$L(XUF,U)
42 D @XUC ;Set up length and help text
43 S XUL=+$P(XUM("LENGTH"),"-")_U_+$P(XUM("LENGTH"),"-",2)
44 ;Transform suffixes
45 I XUC="SUFFIX" S XUX=$$CLEANC^XLFNAME(XUX)
46 ;Clean/format input value
47 S XUX=$$FORMAT^XLFNAME7(XUX,$P(XUL,U),$P(XUL,U,2),,3,,1,1)
48 ;Validate against file 20
49 D CHK^DIE(20,XUF,"E",XUX,.XUR,"XUMSG")
50 I $D(XUMSG("DIERR","E",701)) D
51 .S XUI=$O(XUMSG("DIERR","E",701,""))
52 .M XUM("ERROR")=XUMSG("DIERR",XUI,"TEXT")
53 .Q
54 S XUM("RESULT")=$S(XUR=U:"",1:XUR)
55 Q
56 ;
57NOTES() ;Produce value for the file #20 NOTES ABOUT NAME field
58 ;Output: string representing when, who and how editing occurred
59 ;
60 N XUWHEN,XUWHO,XUHOW
61 S XUWHEN=$$FMTE^XLFDT($$NOW^XLFDT())
62 S XUWHO=$S($G(DUZ)>0:$$GET1^DIQ(200,DUZ_",",.01),1:"Unknown")
63 S XUWHO=XUWHO_" ("_$G(DUZ)_")"
64 S XUHOW=$P($G(XQY0),U)
65 Q "Edited: "_XUWHEN_" By: "_XUWHO_" With: "_XUHOW
66 ;
67COMP(XUX,XUDNC) ;Use existing name array
68 ;Input: XUX=name array (pass by reference)
69 ; XUDNC='do not componentize' flag (pass by reference)
70 ;
71 N XUY,XUI,XUZ
72 Q:$D(XUX)<10 Q:(XUDNC=0)!(XUDNC=2)
73 S XUDNC=1,XUY="FAMILY^GIVEN^MIDDLE^PREFIX^SUFFIX^DEGREE"
74 F XUI=1:1:6 S XUZ=$P(XUY,U,XUI) S:'$D(XUX(XUZ)) XUX(XUZ)=""
75 Q
76 ;
77F1(XUX,XUCOMA) ;Transform text value
78 ;Input: XUX=text value to transform (pass by reference)
79 ; XUCOMA=comma indicator
80 ;Output: 1 if changed, 0 otherwise
81 ;
82 N XUI,XUII,XUC,XUY,XUZ,XUOLDX S XUOLDX=XUX
83 ;Transform accent grave to apostrophe
84 S XUX=$TR(XUX,"`","'")
85 ;Transform single characters
86 F XUI=1:1:$L(XUX) S XUC=$E(XUX,XUI) D:$$FC1(.XUC,XUCOMA)
87 .S XUX=$E(XUX,0,XUI-1)_XUC_$E(XUX,XUI+1,999)
88 .Q
89 ;Transform double character combinations
90 S XUY=" ^--^,,^''^,-^,'^ ,^-,^',^ -^ '^- ^' ^-'^'-"
91 S XUZ=" ^-^,^'^,^,^,^,^,^ ^ ^ ^ ^-^-"
92 F XUI=1:1 S XUC=$P(XUY,U,XUI) Q:XUC="" D
93 .Q:XUX'[XUC
94 .F XUII=1:1:$L(XUX,XUC)-1 D
95 ..S XUX=$P(XUX,XUC,0,XUII)_$P(XUZ,U,XUI)_$P(XUX,XUC,XUII+1,999)
96 ..Q
97 .Q
98 ;Remove NMI and NMN
99 F XUY="NMI","NMN" I XUX[XUY,XUCOMA=3 D
100 .S XUC=$F(XUX,XUY)
101 .I " ,"[$E(XUX,(XUC-4))," ,"[$E(XUX,XUC) D
102 ..S XUX=$E(XUX,0,(XUC-4))_$E(XUX,(XUC),999)
103 ..F XUY=" ",",," I XUX[XUY D
104 ...S XUC=$F(XUX,XUY) S XUX=$E(XUX,0,(XUC-3))_$E(XUX,(XUC-1),999) Q
105 ..F XUZ=" ","," F XUC=1,$L(XUX) D
106 ...I $E(XUX,XUC)=XUZ S XUX=$E(XUX,0,(XUC-1))_$E(XUX,(XUC+1),999) Q
107 ..Q
108 .Q
109 ;Clean up numerics
110 I XUX?.E1N.E D
111 .S XUY="1ST^2ND^3RD^4TH^5TH^6TH^7TH^8TH^9TH"
112 .F XUI=1:1:$L(XUX) S XUC=$E(XUX,XUI) D:XUC?1N
113 ..I XUC," ,"[$E(XUX,XUI-1),$E(XUX,XUI,XUI+2)=$P(XUY,U,XUC)," ,"[$E(XUX,XUI+3) Q
114 ..I XUC=1," ,"[$E(XUX,XUI-1),$E(XUX,XUI,XUI+3)="10TH"," ,"[$E(XUX,XUI+4) S XUI=XUI+1 Q
115 ..S XUX=$E(XUX,0,XUI-1)_$E(XUX,XUI+1,999)
116 ..Q
117 .Q
118 ;Check for dangling apostrophes
119 I XUX["'" F XUI=1:1:$L(XUX) S XUC=$E(XUX,XUI) D:XUC?1"'"
120 .I $E(XUX,(XUI-1))?1U,$E(XUX,(XUI+1))?1U Q
121 .S XUX=$E(XUX,0,(XUI-1))_$E(XUX,(XUI+1),99),XUI=1
122 .Q
123 ;Remove parenthetical text from name value
124 N XUCH S XUOLDX(2)=XUX,XUCH=1 F Q:'XUCH D
125 .S XUCH=0,XUOLDX(1)=XUX,XUY="()[]{}" D
126 ..F XUI=1,3,5 S XUC(1)=$E(XUY,XUI),XUC(2)=$E(XUY,XUI+1) D
127 ...S XUZ(1)=$$CLAST(XUX,XUC(1)) Q:'XUZ(1) S XUZ(2)=$F(XUX,XUC(2),XUZ(1))
128 ...I XUZ(2)>XUZ(1) S XUX=$E(XUX,0,(XUZ(1)-2))_$E(XUX,XUZ(2),999)
129 ...S XUCH=(XUX'=XUOLDX(1)) Q
130 ..Q
131 .Q
132 S:XUX'=XUOLDX(2) XUAUDIT(2)=""
133 F XUI=1:1:6 S XUC=$E(XUY,XUI) D
134 .F Q:XUX'[XUC S XUX=$P(XUX,XUC)_$P(XUX,XUC,2,999)
135 .Q
136 ;Insure value begins and ends with an alpha character
137 F Q:'$L(XUX)!($E(XUX,1)?1A) S XUX=$E(XUX,2,999)
138 F Q:'$L(XUX)!($E(XUX,$L(XUX))?1A) Q:($L(XUX,",")=2)&($E(XUX,$L(XUX))=",") S XUX=$E(XUX,1,($L(XUX)-1))
139 Q XUX'=XUOLDX
140 ;
141CLAST(XUX,XUC) ;Find last instance of character
142 N XUY,XUZ
143 S XUZ=$F(XUX,XUC) Q:'XUZ XUZ
144 F S XUY=$F(XUX,XUC,XUZ) Q:'XUY S XUZ=XUY
145 Q XUZ
146 ;
147FC1(XUC,XUCOMA) ;Transform single character
148 ;Input: XUC=character to transform (pass by reference)
149 ; XUCOMA=comma indicator
150 ;Output: 1 if value is changed, 0 otherwise
151 ;
152 S XUC=$E(XUC) Q:'$L(XUC) 0
153 ;See if comma stays
154 I XUCOMA'=3,XUC?1"," Q 0
155 ;Retain uppercase, numeric, hyphen, apostrophe and space
156 Q:XUC?1U!(XUC?1N)!(XUC?1"-")!(XUC?1"'")!(XUC?1" ") 0
157 ;Retain parenthesis, bracket and brace characters
158 Q:XUC?1"("!(XUC?1")")!(XUC?1"[")!(XUC?1"]")!(XUC?1"{")!(XUC?1"}") 0
159 ;Transform lowercase to uppercase
160 I XUC?1L S XUC=$C($A(XUC)-32) Q 1
161 ;Set all other characters to space
162 S XUC=" " Q 1
163 ;
164CMP(XUNC) ;Cleanup name components
165 ;
166 N XUCOM,XUI,XUCOMP,XUM
167 ;
168 S XUCOM="FAMILY^GIVEN^MIDDLE^SUFFIX"
169 F XUI=1:1:4 D
170 . S XUCOMP=$P(XUCOM,U,XUI)
171 . D CVALID^XLFNAME8(XUCOMP,$G(XUNC(XUCOMP)),.XUM)
172 . S XUNC(XUCOMP)=$G(XUM("RESULT"))
173 Q
174 ;
175BLDNAME(XUNC,XUMAX) ;Build standard name from components
176 ;Called by XU forms
177 ;Modified version of BLDNAME^XLFNAME
178 ;
179 D CMP(.XUNC)
180 Q $$NAMEFMT^XLFNAME(.XUNC,"F","CL"_+$G(XUMAX))
181 ;
Note: See TracBrowser for help on using the repository browser.