Skip to content

Commit

Permalink
TRUNK-5793: Migrate AllergyReaction from Hibernate mapping XML to ann…
Browse files Browse the repository at this point in the history
…otations
  • Loading branch information
ManojLL committed Nov 8, 2024
1 parent 5f89ffc commit 7c19c6c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 36 deletions.
33 changes: 29 additions & 4 deletions api/src/main/java/org/openmrs/AllergyReaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
3 changes: 1 addition & 2 deletions api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<property name="hibernate.search.model_mapping">org.openmrs.api.db.hibernate.search.LuceneAnalyzerFactory</property>

<!-- API -->

<mapping resource="org/openmrs/api/db/hibernate/AllergyReaction.hbm.xml" />

<mapping resource="org/openmrs/api/db/hibernate/Concept.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAnswer.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAttribute.hbm.xml" />
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2740,6 +2741,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(AllergyReaction.class)
.getMetadataBuilder().build();


Expand Down

0 comments on commit 7c19c6c

Please sign in to comment.