View Javadoc
1   /*
2    * Copyright 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.metadata;
17  
18  import ca.uhn.hl7v2.model.v25.datatype.XCN;
19  
20  /**
21   * This class represents a name.
22   * <p>
23   * It is derived from the HL7v2 data type XCN. It only contains
24   * naming related fields of these data types.
25   * <p>
26   * All members of this class are allowed to be <code>null</code>. When transforming
27   * to HL7 this indicates that the values are empty. Trailing empty values are
28   * removed from the HL7 string.
29   * @author Jens Riemschneider
30   * @author Dmytro Rud
31   */
32  public class XcnName extends Name<XCN> {
33      private static final long serialVersionUID = 1003106925101895418L;
34  
35      public XcnName() {
36          super(new XCN(MESSAGE));
37      }
38  
39      public XcnName(XCN xcn) {
40          super(xcn);
41      }
42  
43  
44      /**
45       * Constructs a name.
46       * @param familyName
47       *          the family name (XCN.2.1).
48       * @param givenName
49       *          the given name (XCN.3).
50       * @param secondAndFurtherGivenNames
51       *          the second and further names (XCN.4).
52       * @param suffix
53       *          the suffix (XCN.5).
54       * @param prefix
55       *          the prefix (XCN.6).
56       * @param degree
57       *          academical degree (XCN.7).
58       */
59      public XcnName(String familyName, String givenName, String secondAndFurtherGivenNames, String suffix, String prefix, String degree) {
60          this();
61          setFamilyName(familyName);
62          setGivenName(givenName);
63          setSecondAndFurtherGivenNames(secondAndFurtherGivenNames);
64          setSuffix(suffix);
65          setPrefix(prefix);
66          setDegree(degree);
67      }
68  
69  
70      @Override
71      public String getFamilyName() {
72          return getHapiObject().getXcn2_FamilyName().getFn1_Surname().getValue();
73      }
74  
75      @Override
76      public void setFamilyName(String value) {
77          setValue(getHapiObject().getXcn2_FamilyName().getFn1_Surname(), value);
78      }
79  
80      @Override
81      public String getGivenName() {
82          return getHapiObject().getXcn3_GivenName().getValue();
83      }
84  
85      @Override
86      public void setGivenName(String value) {
87          setValue(getHapiObject().getXcn3_GivenName(), value);
88      }
89  
90      @Override
91      public String getSecondAndFurtherGivenNames() {
92          return getHapiObject().getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof().getValue();
93      }
94  
95      @Override
96      public void setSecondAndFurtherGivenNames(String value) {
97          setValue(getHapiObject().getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof(), value);
98      }
99  
100     @Override
101     public String getSuffix() {
102         return getHapiObject().getXcn5_SuffixEgJRorIII().getValue();
103     }
104 
105     @Override
106     public void setSuffix(String value) {
107         setValue(getHapiObject().getXcn5_SuffixEgJRorIII(), value);
108     }
109 
110     @Override
111     public String getPrefix() {
112         return getHapiObject().getXcn6_PrefixEgDR().getValue();
113     }
114 
115     @Override
116     public void setPrefix(String value) {
117         setValue(getHapiObject().getXcn6_PrefixEgDR(), value);
118     }
119 
120     @Override
121     public String getDegree() {
122         return getHapiObject().getXcn7_DegreeEgMD().getValue();
123     }
124 
125     @Override
126     public void setDegree(String value) {
127         setValue(getHapiObject().getXcn7_DegreeEgMD(), value);
128     }
129 
130     @Override
131     public String toString() {
132         return "XcnName(" +
133                 "super=" + super.toString() +
134                 ')';
135     }
136 }