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.XPN;
19  
20  /**
21   * This class represents a name.
22   * <p>
23   * It is derived from the HL7v2 data type XPN. 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 XpnName extends Name<XPN> {
33      private static final long serialVersionUID = -1443721482370374457L;
34  
35      public XpnName() {
36          super(new XPN(MESSAGE));
37      }
38  
39      public XpnName(XPN xpn) {
40          super(xpn);
41      }
42  
43  
44      /**
45       * Constructs a name.
46       * @param familyName
47       *          the family name (XPN.1.1).
48       * @param givenName
49       *          the given name (XPN.2).
50       * @param secondAndFurtherGivenNames
51       *          the second and further names (XPN.3).
52       * @param suffix
53       *          the suffix (XPN.4).
54       * @param prefix
55       *          the prefix (XPN.5).
56       * @param degree
57       *          academical degree (XPN.6).
58       */
59      public XpnName(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().getXpn1_FamilyName().getFn1_Surname().getValue();
73      }
74  
75      @Override
76      public void setFamilyName(String value) {
77          setValue(getHapiObject().getXpn1_FamilyName().getFn1_Surname(), value);
78      }
79  
80      @Override
81      public String getGivenName() {
82          return getHapiObject().getXpn2_GivenName().getValue();
83      }
84  
85      @Override
86      public void setGivenName(String value) {
87          setValue(getHapiObject().getXpn2_GivenName(), value);
88      }
89  
90      @Override
91      public String getSecondAndFurtherGivenNames() {
92          return getHapiObject().getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().getValue();
93      }
94  
95      @Override
96      public void setSecondAndFurtherGivenNames(String value) {
97          setValue(getHapiObject().getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof(), value);
98      }
99  
100     @Override
101     public String getSuffix() {
102         return getHapiObject().getXpn4_SuffixEgJRorIII().getValue();
103     }
104 
105     @Override
106     public void setSuffix(String value) {
107         setValue(getHapiObject().getXpn4_SuffixEgJRorIII(), value);
108     }
109 
110     @Override
111     public String getPrefix() {
112         return getHapiObject().getXpn5_PrefixEgDR().getValue();
113     }
114 
115     @Override
116     public void setPrefix(String value) {
117         setValue(getHapiObject().getXpn5_PrefixEgDR(), value);
118     }
119 
120     @Override
121     public String getDegree() {
122         return getHapiObject().getXpn6_DegreeEgMD().getValue();
123     }
124 
125     @Override
126     public void setDegree(String value) {
127         setValue(getHapiObject().getXpn6_DegreeEgMD(), value);
128     }
129 
130     @Override
131     public String toString() {
132         return "XpnName(" +
133                 "super=" + super.toString() +
134                 ')';
135     }
136 }