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.CX;
19
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlAttribute;
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
38 @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
39 @XmlType(name = "ReferenceId", propOrder = {"id", "assigningAuthority", "idTypeCode"})
40 public class ReferenceId extends Hl7v2Based<CX> {
41 private static final long serialVersionUID = 6615092850652668283L;
42
43 public static final String ID_TYPE_CODE_UNIQUE_ID = "urn:ihe:iti:xds:2013:uniqueId";
44 public static final String ID_TYPE_CODE_ACCESSION = "urn:ihe:iti:xds:2013:accession";
45 public static final String ID_TYPE_CODE_REFERRAL = "urn:ihe:iti:xds:2013:referral";
46 public static final String ID_TYPE_CODE_ORDER = "urn:ihe:iti:xds:2013:order";
47 public static final String ID_TYPE_WORKFLOW_INSTANCE_ID = "urn:ihe:iti:xdw:2013:workflowInstanceId";
48 public static final String ID_TYPE_ENCOUNTER_ID = "urn:ihe:iti:xds:2015:encounterId";
49 public static final String ID_TYPE_STUDY_INSTANCE_ID = "urn:ihe:iti:xds:2016:studyInstanceUID";
50
51
52
53
54 public ReferenceId() {
55 super(new CX(MESSAGE));
56 }
57
58
59
60
61
62 public ReferenceId(CX cx) {
63 super(cx);
64 }
65
66
67
68
69
70
71
72
73
74
75
76 public ReferenceId(String id, CXiAssigningAuthority assigningAuthority, String idTypeCode) {
77 this();
78 setId(id);
79 setAssigningAuthority(assigningAuthority);
80 setIdTypeCode(idTypeCode);
81 }
82
83
84
85
86 @XmlAttribute
87 public String getId() {
88 return getHapiObject().getCx1_IDNumber().getValue();
89 }
90
91
92
93
94
95 public void setId(String id) {
96 setValue(getHapiObject().getCx1_IDNumber(), id);
97 }
98
99
100
101
102 public CXiAssigningAuthority getAssigningAuthority() {
103 CXiAssigningAuthority assigningAuthority = new CXiAssigningAuthority(getHapiObject().getCx4_AssigningAuthority());
104 return assigningAuthority.isEmpty() ? null : assigningAuthority;
105 }
106
107
108
109
110
111 public void setAssigningAuthority(CXiAssigningAuthority assigningAuthority) {
112 setAssigningAuthority(assigningAuthority, getHapiObject().getCx4_AssigningAuthority());
113 }
114
115
116
117
118 @XmlAttribute
119 public String getIdTypeCode() {
120 return getHapiObject().getCx5_IdentifierTypeCode().getValue();
121 }
122
123
124
125
126
127 public void setIdTypeCode(String idTypeCode) {
128 setValue(getHapiObject().getCx5_IdentifierTypeCode(), idTypeCode);
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 ReferenceId that = (ReferenceId) o;
136 return Objects.equals(getAssigningAuthority(), that.getAssigningAuthority()) &&
137 Objects.equals(getId(), that.getId()) &&
138 Objects.equals(getIdTypeCode(), that.getIdTypeCode());
139 }
140
141 @Override
142 public int hashCode() {
143 return Objects.hash(getId(), getIdTypeCode(), getAssigningAuthority());
144 }
145
146 @Override
147 public String toString() {
148 return "ReferenceId(" +
149 "id=" + getId() +
150 ", assigningAuthority=" + getAssigningAuthority() +
151 ", idTypeCode=" + getIdTypeCode() +
152 ')';
153 }
154 }