Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-5749 : Drug Domain - Switching from Hibernate Mappings to Annotations #4863

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions api/src/main/java/org/openmrs/Drug.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,73 @@
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.openmrs.api.context.Context;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
* Drug
*/
@Indexed
@Audited
@Entity
@Table(name = "drug")
public class Drug extends BaseChangeableOpenmrsMetadata {

public static final long serialVersionUID = 285L;

// Fields
@DocumentId
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "drug_id_seq")
@GenericGenerator(
name = "drug_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "drug_drug_id_seq")
)
@Column(name = "drug_id", nullable = false)
private Integer drugId;

@Column(name = "combination", length = 1, nullable = false)
private Boolean combination = false;

@ManyToOne
@JoinColumn(name = "dosage_form", nullable = true)
private Concept dosageForm;

@Column(name = "maximum_daily_dose", length = 22)
private Double maximumDailyDose;

@Column(name = "minimum_daily_dose", length = 22)
private Double minimumDailyDose;

@Column(name = "strength", length = 255)
private String strength;

@ManyToOne
@JoinColumn(name = "dose_limit_units", nullable = true)
private Concept doseLimitUnits;

@IndexedEmbedded(includeEmbeddedObjectId = true)
@ManyToOne
@JoinColumn(name = "concept_id", nullable = false)
private Concept concept;

@IndexedEmbedded(includeEmbeddedObjectId = true)
@OneToMany(mappedBy = "drug", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DrugReferenceMap> drugReferenceMaps;

@OneToMany(mappedBy = "drug", fetch = FetchType.LAZY)
private Collection<DrugIngredient> ingredients;

// Constructors
Expand Down
1 change: 0 additions & 1 deletion api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<mapping resource="org/openmrs/api/db/hibernate/ConceptReferenceTermMap.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/DiagnosisAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/DiagnosisAttributeType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Drug.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/DrugReferenceMap.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Field.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/FieldType.hbm.xml" />
Expand Down
92 changes: 0 additions & 92 deletions api/src/main/resources/org/openmrs/api/db/hibernate/Drug.hbm.xml

This file was deleted.

1 change: 1 addition & 0 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(Drug.class)
.getMetadataBuilder().build();


Expand Down