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.ToStringBuilder;
24  import org.apache.commons.lang3.builder.ToStringStyle;
25  import org.hibernate.validator.constraints.NotBlank;
26  
27  import javax.persistence.*;
28  import java.io.Serializable;
29  
30  @Entity
31  @Table(name = "TRM_CONCEPT_PROPERTY", uniqueConstraints = {
32  }, indexes = {
33  })
34  public class TermConceptProperty implements Serializable {
35  
36  	static final int MAX_PROPTYPE_ENUM_LENGTH = 6;
37  	private static final long serialVersionUID = 1L;
38  	@ManyToOne
39  	@JoinColumn(name = "CONCEPT_PID", referencedColumnName = "PID", foreignKey = @ForeignKey(name = "FK_CONCEPTPROP_CONCEPT"))
40  	private TermConcept myConcept;
41  	/**
42  	 * TODO: Make this non-null
43  	 *
44  	 * @since 3.5.0
45  	 */
46  	@ManyToOne
47  	@JoinColumn(name = "CS_VER_PID", nullable = true, referencedColumnName = "PID", foreignKey = @ForeignKey(name = "FK_CONCEPTPROP_CSV"))
48  	private TermCodeSystemVersion myCodeSystemVersion;
49  	@Id()
50  	@SequenceGenerator(name = "SEQ_CONCEPT_PROP_PID", sequenceName = "SEQ_CONCEPT_PROP_PID")
51  	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_CONCEPT_PROP_PID")
52  	@Column(name = "PID")
53  	private Long myId;
54  	@Column(name = "PROP_KEY", length = 500, nullable = false)
55  	@NotBlank
56  	private String myKey;
57  	@Column(name = "PROP_VAL", length = 500, nullable = true)
58  	private String myValue;
59  	@Column(name = "PROP_TYPE", length = MAX_PROPTYPE_ENUM_LENGTH, nullable = false)
60  	private TermConceptPropertyTypeEnum myType;
61  	/**
62  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
63  	 */
64  	@Column(name = "PROP_CODESYSTEM", length = 500, nullable = true)
65  	private String myCodeSystem;
66  	/**
67  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
68  	 */
69  	@Column(name = "PROP_DISPLAY", length = 500, nullable = true)
70  	private String myDisplay;
71  
72  	/**
73  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
74  	 */
75  	public String getCodeSystem() {
76  		return myCodeSystem;
77  	}
78  
79  	/**
80  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
81  	 */
82  	public TermConceptProperty setCodeSystem(String theCodeSystem) {
83  		myCodeSystem = theCodeSystem;
84  		return this;
85  	}
86  
87  	/**
88  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
89  	 */
90  	public String getDisplay() {
91  		return myDisplay;
92  	}
93  
94  	/**
95  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
96  	 */
97  	public TermConceptProperty setDisplay(String theDisplay) {
98  		myDisplay = theDisplay;
99  		return this;
100 	}
101 
102 	public String getKey() {
103 		return myKey;
104 	}
105 
106 	public void setKey(String theKey) {
107 		myKey = theKey;
108 	}
109 
110 	public TermConceptPropertyTypeEnum getType() {
111 		return myType;
112 	}
113 
114 	public TermConceptProperty setType(TermConceptPropertyTypeEnum theType) {
115 		myType = theType;
116 		return this;
117 	}
118 
119 	/**
120 	 * This will contain the value for a {@link TermConceptPropertyTypeEnum#STRING string}
121 	 * property, and the code for a {@link TermConceptPropertyTypeEnum#CODING coding} property.
122 	 */
123 	public String getValue() {
124 		return myValue;
125 	}
126 
127 	/**
128 	 * This will contain the value for a {@link TermConceptPropertyTypeEnum#STRING string}
129 	 * property, and the code for a {@link TermConceptPropertyTypeEnum#CODING coding} property.
130 	 */
131 	public void setValue(String theValue) {
132 		myValue = theValue;
133 	}
134 
135 	public TermConceptProperty setCodeSystemVersion(TermCodeSystemVersion theCodeSystemVersion) {
136 		myCodeSystemVersion = theCodeSystemVersion;
137 		return this;
138 	}
139 
140 	public void setConcept(TermConcept theConcept) {
141 		myConcept = theConcept;
142 	}
143 
144 	@Override
145 	public String toString() {
146 		return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
147 			.append("key", myKey)
148 			.append("value", myValue)
149 			.toString();
150 	}
151 
152 }