1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.metadata;
17
18 import ca.uhn.hl7v2.model.v25.datatype.XON;
19
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlElement;
23 import javax.xml.bind.annotation.XmlType;
24 import java.util.Objects;
25
26
27
28
29
30
31
32
33
34
35
36
37 @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
38 @XmlType(name = "Organization", propOrder = {"idNumber", "assigningAuthority", "organizationName"})
39 public class Organization extends Hl7v2Based<XON> {
40 private static final long serialVersionUID = 8283797476558181158L;
41
42
43
44
45 public Organization() {
46 super(new XON(MESSAGE));
47 }
48
49
50
51
52
53
54 public Organization(XON xon) {
55 super(xon);
56 }
57
58
59
60
61
62
63 public Organization(String organizationName) {
64 this();
65 setOrganizationName(organizationName);
66 }
67
68
69
70
71
72
73
74
75
76
77 public Organization(String organizationName, String idNumber, AssigningAuthority assigningAuthority) {
78 this();
79 setOrganizationName(organizationName);
80 setIdNumber(idNumber);
81 setAssigningAuthority(assigningAuthority);
82 }
83
84
85
86
87 public AssigningAuthority getAssigningAuthority() {
88 AssigningAuthority authority = new AssigningAuthority(getHapiObject().getXon6_AssigningAuthority());
89 return authority.isEmpty() ? null : authority;
90 }
91
92
93
94
95
96 public void setAssigningAuthority(AssigningAuthority assigningAuthority) {
97 setAssigningAuthority(assigningAuthority, getHapiObject().getXon6_AssigningAuthority());
98 }
99
100
101
102
103 @XmlElement(name = "name")
104 public String getOrganizationName() {
105 return getHapiObject().getXon1_OrganizationName().getValue();
106 }
107
108
109
110
111
112 public void setOrganizationName(String organizationName) {
113 setValue(getHapiObject().getXon1_OrganizationName(), organizationName);
114 }
115
116
117
118
119 public String getIdNumber() {
120 return getHapiObject().getXon10_OrganizationIdentifier().getValue();
121 }
122
123
124
125
126
127 public void setIdNumber(String idNumber) {
128 setValue(getHapiObject().getXon10_OrganizationIdentifier(), idNumber);
129 }
130
131 @Override
132 public boolean equals(Object o) {
133 if (this == o) return true;
134 if (o == null || getClass() != o.getClass()) return false;
135 Organization that = (Organization) o;
136 return Objects.equals(getAssigningAuthority(), that.getAssigningAuthority()) &&
137 Objects.equals(getOrganizationName(), that.getOrganizationName()) &&
138 Objects.equals(getIdNumber(), that.getIdNumber());
139 }
140
141 @Override
142 public int hashCode() {
143 return Objects.hash(getAssigningAuthority(), getOrganizationName(), getIdNumber());
144 }
145
146 @Override
147 public String toString() {
148 return "Organization(" +
149 "assigningAuthority=" + getAssigningAuthority() +
150 ", organizationName=" + getOrganizationName() +
151 ", idNumber=" + getIdNumber() +
152 ')';
153 }
154 }