Advertisement
Guest User

drug.java

a guest
Jul 26th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. /**
  2. * The contents of this file are subject to the OpenMRS Public License
  3. * Version 1.0 (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://license.openmrs.org
  6. *
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. *
  12. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  13. */
  14. package org.openmrs;
  15.  
  16. import java.util.Locale;
  17. import java.util.Collection;
  18. import java.util.Collections;
  19. import java.util.HashSet;
  20.  
  21. /**
  22. * Drug
  23. */
  24. public class Drug extends BaseOpenmrsMetadata implements java.io.Serializable {
  25.  
  26. public static final long serialVersionUID = 285L;
  27.  
  28. // Fields
  29.  
  30. private Integer drugId;
  31.  
  32. private Boolean combination = false;
  33.  
  34. private Concept dosageForm;
  35.  
  36. private Double doseStrength;
  37.  
  38. private Double maximumDailyDose;
  39.  
  40. private Double minimumDailyDose;
  41.  
  42. private Concept route;
  43.  
  44. private String units;
  45.  
  46. private Concept concept;
  47.  
  48. private Collection<DrugIngredient> ingredients;
  49.  
  50. // Constructors
  51.  
  52. /** default constructor */
  53. public Drug() {
  54. ingredients = new HashSet<DrugIngredient>();
  55. }
  56.  
  57. /** constructor with id */
  58. public Drug(Integer drugId) {
  59. this.drugId = drugId;
  60. }
  61.  
  62. /**
  63. * Compares two Drug objects for similarity
  64. *
  65. * @param obj
  66. * @return boolean true/false whether or not they are the same objects
  67. */
  68. public boolean equals(Object obj) {
  69. if (obj == null || !(obj instanceof Drug))
  70. return false;
  71.  
  72. Drug drug = (Drug) obj;
  73. if (this.drugId != null && drug.drugId != null)
  74. return this.drugId.equals(drug.getDrugId());
  75.  
  76. return this == obj;
  77. }
  78.  
  79. public int hashCode() {
  80. if (this.getDrugId() == null)
  81. return super.hashCode();
  82. return this.getDrugId().hashCode();
  83. }
  84.  
  85. // Property accessors
  86.  
  87. /**
  88. * Gets the internal identification number for this drug
  89. *
  90. * @return Integer
  91. */
  92. public Integer getDrugId() {
  93. return this.drugId;
  94. }
  95.  
  96. /**
  97. * Sets the internal identification number for this drug
  98. *
  99. * @param drugId
  100. */
  101. public void setDrugId(Integer drugId) {
  102. this.drugId = drugId;
  103. }
  104.  
  105. /**
  106. * Gets the entires concept drug name in the form of CONCEPTNAME (Drug: DRUGNAME)
  107. *
  108. * @param locale
  109. * @return full drug name (with concept name appended)
  110. */
  111. public String getFullName(Locale locale) {
  112. if (concept == null)
  113. return getName();
  114. else
  115. return getName() + " (" + concept.getName(locale).getName() + ")";
  116. }
  117.  
  118. /**
  119. * Gets whether or not this is a combination drug
  120. *
  121. * @return Boolean
  122. */
  123. public Boolean isCombination() {
  124. return this.combination;
  125. }
  126.  
  127. public Boolean getCombination() {
  128. return isCombination();
  129. }
  130.  
  131. /**
  132. * Sets whether or not this is a combination drug
  133. *
  134. * @param combination
  135. */
  136. public void setCombination(Boolean combination) {
  137. this.combination = combination;
  138. }
  139.  
  140. /**
  141. * Gets the dose strength of this drug
  142. *
  143. * @return Double
  144. */
  145. public Double getDoseStrength() {
  146. return this.doseStrength;
  147. }
  148.  
  149. /**
  150. * Sets the dose strength
  151. *
  152. * @param doseStrength
  153. */
  154. public void setDoseStrength(Double doseStrength) {
  155. this.doseStrength = doseStrength;
  156. }
  157.  
  158. /**
  159. * Gets the units
  160. *
  161. * @return String
  162. */
  163. public String getUnits() {
  164. return this.units;
  165. }
  166.  
  167. /**
  168. * Sets the units
  169. *
  170. * @param units
  171. */
  172. public void setUnits(String units) {
  173. this.units = units;
  174. }
  175.  
  176. /**
  177. * Gets the concept this drug is tied to
  178. *
  179. * @return Concept
  180. */
  181. public Concept getConcept() {
  182. return this.concept;
  183. }
  184.  
  185. /**
  186. * Sets the concept this drug is tied to
  187. *
  188. * @param concept
  189. */
  190. public void setConcept(Concept concept) {
  191. this.concept = concept;
  192. }
  193.  
  194. public Concept getDosageForm() {
  195. return dosageForm;
  196. }
  197.  
  198. public void setDosageForm(Concept dosageForm) {
  199. this.dosageForm = dosageForm;
  200. }
  201.  
  202. public Double getMaximumDailyDose() {
  203. return maximumDailyDose;
  204. }
  205.  
  206. public void setMaximumDailyDose(Double maximumDailyDose) {
  207. this.maximumDailyDose = maximumDailyDose;
  208. }
  209.  
  210. public Double getMinimumDailyDose() {
  211. return minimumDailyDose;
  212. }
  213.  
  214. public void setMinimumDailyDose(Double minimumDailyDose) {
  215. this.minimumDailyDose = minimumDailyDose;
  216. }
  217.  
  218. public Concept getRoute() {
  219. return route;
  220. }
  221.  
  222. public void setRoute(Concept route) {
  223. this.route = route;
  224. }
  225.  
  226. /**
  227. * @return Returns the ingredients
  228. */
  229. public Collection<DrugIngredient> getIngredients() {
  230. return ingredients;
  231. }
  232.  
  233. /**
  234. * @param ingredients The ingredients to set
  235. */
  236. public void setIngredients(Collection<DrugIngredient> ingredients) {
  237. this.ingredients = ingredients;
  238. }
  239.  
  240. /**
  241. * @since 1.5
  242. * @see org.openmrs.OpenmrsObject#getId()
  243. */
  244. public Integer getId() {
  245.  
  246. return getDrugId();
  247. }
  248.  
  249. /**
  250. * @since 1.5
  251. * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
  252. */
  253. public void setId(Integer id) {
  254. setDrugId(id);
  255.  
  256. }
  257.  
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement