View Javadoc
1   package ca.uhn.fhir.jpa.entity;
2   
3   /*-
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import org.apache.commons.lang3.builder.EqualsBuilder;
24  import org.apache.commons.lang3.builder.HashCodeBuilder;
25  import org.apache.commons.lang3.builder.ToStringBuilder;
26  import org.apache.commons.lang3.builder.ToStringStyle;
27  import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
28  
29  import javax.persistence.*;
30  import java.io.Serializable;
31  
32  @Entity
33  @Table(name = "TRM_CONCEPT_MAP_GRP_ELM_TGT", indexes = {
34  	@Index(name = "IDX_CNCPT_MP_GRP_ELM_TGT_CD", columnList = "TARGET_CODE")
35  })
36  public class TermConceptMapGroupElementTarget implements Serializable {
37  	@Id()
38  	@SequenceGenerator(name = "SEQ_CNCPT_MAP_GRP_ELM_TGT_PID", sequenceName = "SEQ_CNCPT_MAP_GRP_ELM_TGT_PID")
39  	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_CNCPT_MAP_GRP_ELM_TGT_PID")
40  	@Column(name = "PID")
41  	private Long myId;
42  
43  	@ManyToOne()
44  	@JoinColumn(name = "CONCEPT_MAP_GRP_ELM_PID", nullable = false, referencedColumnName = "PID", foreignKey=@ForeignKey(name="FK_TCMGETARGET_ELEMENT"))
45  	private TermConceptMapGroupElement myConceptMapGroupElement;
46  
47  	@Column(name = "TARGET_CODE", nullable = false, length = 50)
48  	private String myCode;
49  
50  	@Column(name = "TARGET_DISPLAY", length = TermConcept.MAX_DESC_LENGTH)
51  	private String myDisplay;
52  
53  	@Enumerated(EnumType.STRING)
54  	@Column(name = "TARGET_EQUIVALENCE", length = 50)
55  	private ConceptMapEquivalence myEquivalence;
56  
57  	private String myConceptMapUrl;
58  	private String mySystem;
59  	private String mySystemVersion;
60  	private String myValueSet;
61  
62  	public String getCode() {
63  		return myCode;
64  	}
65  
66  	public void setCode(String theCode) {
67  		myCode = theCode;
68  	}
69  
70  	public TermConceptMapGroupElement getConceptMapGroupElement() {
71  		return myConceptMapGroupElement;
72  	}
73  
74  	public void setConceptMapGroupElement(TermConceptMapGroupElement theTermConceptMapGroupElement) {
75  		myConceptMapGroupElement = theTermConceptMapGroupElement;
76  	}
77  
78  	public String getConceptMapUrl() {
79  		if (myConceptMapUrl == null) {
80  			myConceptMapUrl = getConceptMapGroupElement().getConceptMapGroup().getConceptMap().getUrl();
81  		}
82  		return myConceptMapUrl;
83  	}
84  
85  	public String getDisplay() {
86  		return myDisplay;
87  	}
88  
89  	public void setDisplay(String theDisplay) {
90  		myDisplay = theDisplay;
91  	}
92  
93  	public ConceptMapEquivalence getEquivalence() {
94  		return myEquivalence;
95  	}
96  
97  	public void setEquivalence(ConceptMapEquivalence theEquivalence) {
98  		myEquivalence = theEquivalence;
99  	}
100 
101 	public Long getId() {
102 		return myId;
103 	}
104 
105 	public String getSystem() {
106 		if (mySystem == null) {
107 			mySystem = getConceptMapGroupElement().getConceptMapGroup().getTarget();
108 		}
109 		return mySystem;
110 	}
111 
112 	public String getSystemVersion() {
113 		if (mySystemVersion == null) {
114 			mySystemVersion = getConceptMapGroupElement().getConceptMapGroup().getTargetVersion();
115 		}
116 		return mySystemVersion;
117 	}
118 
119 	public String getValueSet() {
120 		if (myValueSet == null) {
121 			myValueSet = getConceptMapGroupElement().getConceptMapGroup().getTargetValueSet();
122 		}
123 		return myValueSet;
124 	}
125 
126 	@Override
127 	public boolean equals(Object o) {
128 		if (this == o) return true;
129 
130 		if (!(o instanceof TermConceptMapGroupElementTarget)) return false;
131 
132 		TermConceptMapGroupElementTarget that = (TermConceptMapGroupElementTarget) o;
133 
134 		return new EqualsBuilder()
135 			.append(getCode(), that.getCode())
136 			.append(getEquivalence(), that.getEquivalence())
137 			.append(getSystem(), that.getSystem())
138 			.append(getSystemVersion(), that.getSystemVersion())
139 			.isEquals();
140 	}
141 
142 	@Override
143 	public int hashCode() {
144 		return new HashCodeBuilder(17, 37)
145 			.append(getCode())
146 			.append(getEquivalence())
147 			.append(getSystem())
148 			.append(getSystemVersion())
149 			.toHashCode();
150 	}
151 
152 	@Override
153 	public String toString() {
154 		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
155 			.append("myId", myId)
156 			.append("myConceptMapGroupElement - id", myConceptMapGroupElement.getId())
157 			.append("myCode", myCode)
158 			.append("myDisplay", myDisplay)
159 			.append("myEquivalence", myEquivalence.toCode())
160 			.append("myConceptMapUrl", this.getConceptMapUrl())
161 			.append("mySystem", this.getSystem())
162 			.append("mySystemVersion", this.getSystemVersion())
163 			.append("myValueSet", this.getValueSet())
164 			.toString();
165 	}
166 }