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-5799: EncounterProvider Domain - Switching from Hibernate Mappings to Annotations #4828

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
37 changes: 33 additions & 4 deletions api/src/main/java/org/openmrs/EncounterProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,53 @@
*/
package org.openmrs;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;

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;

/**
* Mapping Class between Encounters and Providers which allows many to many relationship.
*
* @since 1.9
*/
@Entity
@Table(name = "encounter_provider")
@BatchSize(size = 25)
@Audited
public class EncounterProvider extends BaseChangeableOpenmrsData {

public static final long serialVersionUID = 1L;


@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "encounter_provider_id_seq")
@GenericGenerator(
name = "encounter_provider_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "encounter_provider_encounter_provider_id_seq")
)
@Column(name = "encounter_provider_id")
private Integer encounterProviderId;


@ManyToOne
@JoinColumn(name = "encounter_id", nullable = false)
private Encounter encounter;


@ManyToOne
@JoinColumn(name = "provider_id", nullable = false)
private Provider provider;


@ManyToOne
@JoinColumn(name = "encounter_role_id", nullable = false)
private EncounterRole encounterRole;

public void setEncounterProviderId(Integer encounterProviderId) {
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 @@ -77,7 +77,6 @@
<mapping resource="org/openmrs/api/db/hibernate/LocationTag.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/LocationAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/EncounterType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/EncounterProvider.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/EncounterRole.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Program.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ProgramWorkflow.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 @@ -35,6 +35,7 @@
import org.openmrs.DrugIngredient;
import org.openmrs.DrugOrder;
import org.openmrs.Encounter;
import org.openmrs.EncounterProvider;
import org.openmrs.FreeTextDosingInstructions;
import org.openmrs.GlobalProperty;
import org.openmrs.Location;
Expand Down Expand Up @@ -2740,6 +2741,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(EncounterProvider.class)
.getMetadataBuilder().build();


Expand Down
Loading