diff --git a/api/src/main/java/org/openmrs/DrugReferenceMap.java b/api/src/main/java/org/openmrs/DrugReferenceMap.java
index bd28135ea9a..ced2b03431d 100644
--- a/api/src/main/java/org/openmrs/DrugReferenceMap.java
+++ b/api/src/main/java/org/openmrs/DrugReferenceMap.java
@@ -9,48 +9,85 @@
*/
package org.openmrs;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.Parameter;
+import org.hibernate.annotations.GenericGenerator;
import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.annotations.CascadeType;
+
+
/**
* The DrugReferenceMap map object represents a mapping between a drug and alternative drug
* terminologies.
- *
+ *
* @since 1.10
*/
+@Entity
+@Table(name="drug_reference_map")
@Audited
public class DrugReferenceMap extends BaseOpenmrsObject implements Auditable, Serializable {
-
+
public static final long serialVersionUID = 1L;
-
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "drug_reference_map_id_seq")
+ @GenericGenerator(
+ name = "drug_reference_map_id_seq",
+ strategy = "native",
+ parameters = @Parameter(name = "sequence", value = "drug_reference_map_drug_reference_map_id_seq")
+ )
@DocumentId
+ @Column(name = "drug_reference_map_id")
private Integer drugReferenceMapId;
-
+
+ @ManyToOne
+ @JoinColumn(name = "drug_id", nullable = false)
@ContainedIn
private Drug drug;
-
+
+ @ManyToOne
+ @JoinColumn(name = "term_id", nullable = false)
+ @Cascade(CascadeType.SAVE_UPDATE)
@IndexedEmbedded(includeEmbeddedObjectId = true)
private ConceptReferenceTerm conceptReferenceTerm;
-
+
+ @ManyToOne
+ @JoinColumn(name = "concept_map_type", nullable = false)
private ConceptMapType conceptMapType;
-
+
+ @ManyToOne
+ @JoinColumn(name = "creator", nullable = false)
private User creator;
-
+
+ @Column(name = "date_created", nullable = false, length = 19)
private Date dateCreated;
+ @ManyToOne
+ @JoinColumn(name = "changed_by")
private User changedBy;
-
+
+ @Column(name = "date_changed", length = 19)
private Date dateChanged;
-
+
/** default constructor */
public DrugReferenceMap() {
}
-
+
/**
* @param term
* @param conceptMapType
@@ -59,63 +96,63 @@ public DrugReferenceMap(ConceptReferenceTerm term, ConceptMapType conceptMapType
this.conceptReferenceTerm = term;
this.conceptMapType = conceptMapType;
}
-
+
/**
* @return Returns the drugReferenceMapId.
*/
public Integer getDrugReferenceMapId() {
return drugReferenceMapId;
}
-
+
/**
* @param drugReferenceMapId The drugReferenceMapId to set.
*/
public void setDrugReferenceMapId(Integer drugReferenceMapId) {
this.drugReferenceMapId = drugReferenceMapId;
}
-
+
/**
* @return Returns the drug.
*/
public Drug getDrug() {
return drug;
}
-
+
/**
* @param drug The drug to set.
*/
public void setDrug(Drug drug) {
this.drug = drug;
}
-
+
/**
* @return Returns the conceptReferenceTerm.
*/
public ConceptReferenceTerm getConceptReferenceTerm() {
return conceptReferenceTerm;
}
-
+
/**
* @param conceptReferenceTerm The conceptReferenceTerm to set.
*/
public void setConceptReferenceTerm(ConceptReferenceTerm conceptReferenceTerm) {
this.conceptReferenceTerm = conceptReferenceTerm;
}
-
+
/**
* @return Returns the conceptMapType.
*/
public ConceptMapType getConceptMapType() {
return conceptMapType;
}
-
+
/**
* @param conceptMapType The conceptMapType to set.
*/
public void setConceptMapType(ConceptMapType conceptMapType) {
this.conceptMapType = conceptMapType;
}
-
+
/**
* @return id - The unique Identifier for the object
*/
@@ -123,7 +160,7 @@ public void setConceptMapType(ConceptMapType conceptMapType) {
public Integer getId() {
return getDrugReferenceMapId();
}
-
+
/**
* @param id - The unique Identifier for the object
*/
@@ -131,7 +168,7 @@ public Integer getId() {
public void setId(Integer id) {
setDrugReferenceMapId(id);
}
-
+
/**
* @return User - the user who created the object
*/
@@ -139,7 +176,7 @@ public void setId(Integer id) {
public User getCreator() {
return this.creator;
}
-
+
/**
* @param creator - the user who created the object
*/
@@ -147,7 +184,7 @@ public User getCreator() {
public void setCreator(User creator) {
this.creator = creator;
}
-
+
/**
* @return Date - the date the object was created
*/
@@ -155,7 +192,7 @@ public void setCreator(User creator) {
public Date getDateCreated() {
return dateCreated;
}
-
+
/**
* @param dateCreated - the date the object was created
*/
@@ -163,7 +200,7 @@ public Date getDateCreated() {
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
-
+
/**
* @return User - the user who last changed the object
*/
@@ -171,7 +208,7 @@ public void setDateCreated(Date dateCreated) {
public User getChangedBy() {
return this.changedBy;
}
-
+
/**
* @param changedBy - the user who last changed the object
*/
@@ -179,7 +216,7 @@ public User getChangedBy() {
public void setChangedBy(User changedBy) {
this.changedBy = changedBy;
}
-
+
/**
* @return Date - the date the object was last changed
*/
@@ -187,7 +224,7 @@ public void setChangedBy(User changedBy) {
public Date getDateChanged() {
return this.dateChanged;
}
-
+
/**
* @param dateChanged - the date the object was last changed
*/
diff --git a/api/src/main/resources/hibernate.cfg.xml b/api/src/main/resources/hibernate.cfg.xml
index 2bd3c6ad8dc..1cad8cc6aa4 100644
--- a/api/src/main/resources/hibernate.cfg.xml
+++ b/api/src/main/resources/hibernate.cfg.xml
@@ -43,7 +43,6 @@
-
diff --git a/api/src/main/resources/org/openmrs/api/db/hibernate/DrugReferenceMap.hbm.xml b/api/src/main/resources/org/openmrs/api/db/hibernate/DrugReferenceMap.hbm.xml
deleted file mode 100644
index 5248f9dde87..00000000000
--- a/api/src/main/resources/org/openmrs/api/db/hibernate/DrugReferenceMap.hbm.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
- drug_reference_map_drug_reference_map_id_seq
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/api/src/test/java/org/openmrs/api/OrderServiceTest.java b/api/src/test/java/org/openmrs/api/OrderServiceTest.java
index 6d553c03825..12f636a6708 100644
--- a/api/src/test/java/org/openmrs/api/OrderServiceTest.java
+++ b/api/src/test/java/org/openmrs/api/OrderServiceTest.java
@@ -32,6 +32,7 @@
import org.openmrs.Condition;
import org.openmrs.Diagnosis;
import org.openmrs.Drug;
+import org.openmrs.DrugReferenceMap;
import org.openmrs.DrugIngredient;
import org.openmrs.DrugOrder;
import org.openmrs.Encounter;
@@ -2735,6 +2736,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(SerializedObject.class)
.addAnnotatedClass(PatientState.class)
.addAnnotatedClass(DrugIngredient.class)
+ .addAnnotatedClass(DrugReferenceMap.class)
.addAnnotatedClass(AlertRecipient.class)
.addAnnotatedClass(PatientIdentifierType.class)
.addAnnotatedClass(ProgramAttributeType.class)