diff --git a/api/src/main/java/org/openmrs/AllergyReaction.java b/api/src/main/java/org/openmrs/AllergyReaction.java
index 28d5e416e95..e087d87ccd1 100644
--- a/api/src/main/java/org/openmrs/AllergyReaction.java
+++ b/api/src/main/java/org/openmrs/AllergyReaction.java
@@ -10,24 +10,49 @@
package org.openmrs;
import org.apache.commons.lang3.StringUtils;
+import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;
import org.openmrs.util.OpenmrsUtil;
+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;
+
/**
* Represent allergy reactions
*/
+@Entity
+@Table(name = "allergy_reaction")
@Audited
public class AllergyReaction extends BaseOpenmrsObject implements java.io.Serializable{
public static final long serialVersionUID = 1;
-
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "allergy_reaction_id_seq")
+ @GenericGenerator(
+ name = "allergy_reaction_id_seq",
+ strategy = "native",
+ parameters = @Parameter(name = "sequence", value = "allergy_reaction_allergy_reaction_id_seq")
+ )
+ @Column(name = "allergy_reaction_id")
private Integer allergyReactionId;
-
+
+ @ManyToOne
+ @JoinColumn(name = "allergy_id", nullable = false)
private Allergy allergy;
-
+
+ @ManyToOne
+ @JoinColumn(name = "reaction_concept_id", nullable = false)
private Concept reaction;
-
+
+ @Column(name = "reaction_non_coded")
private String reactionNonCoded;
/**
diff --git a/api/src/main/resources/hibernate.cfg.xml b/api/src/main/resources/hibernate.cfg.xml
index 2bd3c6ad8dc..fc645d164ea 100644
--- a/api/src/main/resources/hibernate.cfg.xml
+++ b/api/src/main/resources/hibernate.cfg.xml
@@ -21,8 +21,7 @@
org.openmrs.api.db.hibernate.search.LuceneAnalyzerFactory
-
-
+
diff --git a/api/src/main/resources/org/openmrs/api/db/hibernate/AllergyReaction.hbm.xml b/api/src/main/resources/org/openmrs/api/db/hibernate/AllergyReaction.hbm.xml
deleted file mode 100644
index 087d9d96607..00000000000
--- a/api/src/main/resources/org/openmrs/api/db/hibernate/AllergyReaction.hbm.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
- allergy_reaction_allergy_reaction_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..325ee8e3720 100644
--- a/api/src/test/java/org/openmrs/api/OrderServiceTest.java
+++ b/api/src/test/java/org/openmrs/api/OrderServiceTest.java
@@ -20,6 +20,7 @@
import org.junit.jupiter.api.Test;
import org.openmrs.Allergy;
+import org.openmrs.AllergyReaction;
import org.openmrs.CareSetting;
import org.openmrs.Concept;
import org.openmrs.ConceptClass;
@@ -2740,6 +2741,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
+ .addAnnotatedClass(AllergyReaction.class)
.getMetadataBuilder().build();