Index: metadata/api/hibernate/org/openmrs/api/db/hibernate/Encounter.hbm.xml =================================================================== --- metadata/api/hibernate/org/openmrs/api/db/hibernate/Encounter.hbm.xml (revision 13550) +++ metadata/api/hibernate/org/openmrs/api/db/hibernate/Encounter.hbm.xml Fri Jun 18 11:40:19 IST 2010 @@ -77,5 +77,9 @@ + + + + Index: metadata/model/liquibase-update-to-latest.xml =================================================================== --- metadata/model/liquibase-update-to-latest.xml (revision 13754) +++ metadata/model/liquibase-update-to-latest.xml Thu Jun 17 14:26:39 IST 2010 @@ -3301,4 +3301,35 @@ message_state IN (0,1) + + + + + + + + + Ticket 2369, to store multiple providers for an encounter instead of just one + + + + + + + + + + + + + + \ No newline at end of file Index: src/api/org/openmrs/Encounter.java =================================================================== --- src/api/org/openmrs/Encounter.java (revision 11652) +++ src/api/org/openmrs/Encounter.java Thu Jun 17 17:53:27 IST 2010 @@ -24,42 +24,44 @@ * encounter can have 0 to n Observations associated with it Every encounter can have 0 to n Orders * associated with it The patientId attribute should be equal to patient.patientId and is only * included this second time for performance increases on bulk calls. - * + * * @see Obs * @see Order */ public class Encounter extends BaseOpenmrsData implements java.io.Serializable { - + public static final long serialVersionUID = 2L; - + // Fields - + private Integer encounterId; - + private Date encounterDatetime; - + private Patient patient; - + private Integer patientId; - + private Location location; - + private Form form; - + private EncounterType encounterType; - + private Person provider; - + private Set orders; - + private Set obs; - + + private List providers; + // Constructors - + /** default constructor */ public Encounter() { } - + /** * @param encounterId * @should set encounter id @@ -67,10 +69,10 @@ public Encounter(Integer encounterId) { this.encounterId = encounterId; } - + /** * Compares two Encounter objects for similarity - * + * * @param obj Encounter object to compare to * @return boolean true/false whether or not they are the same objects * @see java.lang.Object#equals(java.lang.Object) @@ -92,9 +94,9 @@ this.getEncounterDatetime().equals(enc.getEncounterDatetime())); */ } return this == obj; - + } - + /** * @see java.lang.Object#hashCode() * @should have same hashcode when equal @@ -106,65 +108,65 @@ return super.hashCode(); return this.getEncounterId().hashCode(); } - + // Property accessors - + /** * @return Returns the encounterDatetime. */ public Date getEncounterDatetime() { return encounterDatetime; } - + /** * @param encounterDatetime The encounterDatetime to set. */ public void setEncounterDatetime(Date encounterDatetime) { this.encounterDatetime = encounterDatetime; } - + /** * @return Returns the encounterId. */ public Integer getEncounterId() { return encounterId; } - + /** * @param encounterId The encounterId to set. */ public void setEncounterId(Integer encounterId) { this.encounterId = encounterId; } - + /** * @return Returns the encounterType. */ public EncounterType getEncounterType() { return encounterType; } - + /** * @param encounterType The encounterType to set. */ public void setEncounterType(EncounterType encounterType) { this.encounterType = encounterType; } - + /** * @return Returns the location. */ public Location getLocation() { return location; } - + /** * @param location The location to set. */ public void setLocation(Location location) { this.location = location; } - + /** * @return Returns a Set of all non-voided, non-obsGroup children Obs of this Encounter * @should not return null with null obs set @@ -179,7 +181,7 @@ */ public Set getObs() { Set ret = new HashSet(); - + if (this.obs != null) { for (Obs o : this.obs) ret.addAll(getObsLeaves(o)); @@ -187,20 +189,20 @@ //if (o.isVoided() == false && o.isObsGrouping() == false) // ret.add(o); } - + return ret; } - + /** * Convenience method to recursively get all leaf obs of this encounter. This method goes down * into each obs and adds all non-grouping obs to the return list - * + * * @param obsParent current obs to loop over * @return list of leaf obs */ private List getObsLeaves(Obs obsParent) { List leaves = new ArrayList(); - + if (obsParent.hasGroupMembers()) { for (Obs child : obsParent.getGroupMembers()) { if (child.isVoided() == false) { @@ -214,14 +216,14 @@ } else if (obsParent.isVoided() == false) { leaves.add(obsParent); } - + return leaves; } - + /** * Returns all Obs where Obs.encounterId = Encounter.encounterId In practice, this method should * not be used very often... - * + * * @param includeVoided specifies whether or not to include voided Obs * @return Returns the all Obs. * @should not return null with null obs set @@ -233,9 +235,9 @@ public Set getAllObs(boolean includeVoided) { if (includeVoided && obs != null) return obs; - + Set ret = new HashSet(); - + if (this.obs != null) { for (Obs o : this.obs) { if (includeVoided) @@ -246,20 +248,20 @@ } return ret; } - + /** * Convenience method to call {@link #getAllObs(boolean)} with a false parameter - * + * * @return all non-voided obs * @should not get voided obs */ public Set getAllObs() { return getAllObs(false); } - + /** * Returns a Set of all root-level Obs of an Encounter, including obsGroups - * + * * @param includeVoided specifies whether or not to include voided Obs * @return Returns all obs at top level -- will not be null * @should not return null with null obs set @@ -277,17 +279,17 @@ } return ret; } - + /** * @param obs The obs to set. */ public void setObs(Set obs) { this.obs = obs; } - + /** * Add the given Obs to the list of obs for this Encounter. - * + * * @param observation the Obs to add to this encounter * @should add obs with null values * @should not fail with null obs @@ -300,7 +302,7 @@ obs = new HashSet(); if (observation != null) { observation.setEncounter(this); - + if (observation.getObsDatetime() == null) observation.setObsDatetime(getEncounterDatetime()); if (observation.getPerson() == null) @@ -310,10 +312,10 @@ obs.add(observation); } } - + /** * Remove the given observation from the list of obs for this Encounter - * + * * @param observation * @should remove obs successfully * @should not throw error when removing null obs from empty set @@ -323,7 +325,7 @@ if (obs != null) obs.remove(observation); } - + /** * @return Returns the orders */ @@ -333,17 +335,17 @@ } return orders; } - + /** * @param orders The orders to set. */ public void setOrders(Set orders) { this.orders = orders; } - + /** * Add the given Order to the list of orders for this Encounter - * + * * @param order * @should add order with null values * @should not fail with null obs passed to add order @@ -358,10 +360,10 @@ orders.add(order); } } - + /** * Remove the given observation from the list of orders for this Encounter - * + * * @param order * @should remove order from encounter * @should not fail when removing null order @@ -371,35 +373,35 @@ if (orders != null) orders.remove(order); } - + /** * @return Returns the patient. */ public Patient getPatient() { return patient; } - + /** * @param patient The patient to set. */ public void setPatient(Patient patient) { this.patient = patient; } - + /** * @return the patientId */ public Integer getPatientId() { return patientId; } - + /** * @param patientId the patientId to set */ public void setPatientId(Integer patientId) { this.patientId = patientId; } - + /** * @return Returns the provider. * @since 1.6 (used to return User) @@ -407,15 +409,15 @@ public Person getProvider() { return provider; } - + /** * @param provider The provider to set. - * @deprecated use {@link #setProvider(Person)} + * @deprecated use {@link #setProvider(Person)} */ public void setProvider(User provider) { setProvider(provider.getPerson()); } - + /** * @param provider The provider to set. */ @@ -424,19 +426,50 @@ } /** + * @return Returns the providers + */ + public List getProviders() { + return providers; + } + + /** + * @param provider a new provider + */ + public void addProvider(Person provider) { + if(providers==null) providers = new ArrayList(); + providers.add(provider); + } + + /** + * @param provider a provider is removed + */ + public void removeProvider(Person provider) { + if(provider!=null){ + providers.remove(provider); + } + } + + /** + * @param providers The providers to set. + */ + public void setProviders(List providers) { + this.providers = providers; + } + + /** * @return Returns the form. */ public Form getForm() { return form; } - + /** * @param form The form to set. */ public void setForm(Form form) { this.form = form; } - + /** * @see java.lang.Object#toString() * @should not fail with empty object @@ -454,23 +487,23 @@ ret += this.getOrders() == null ? "(no Orders) " : "num Orders: " + this.getOrders().size() + " "; return "Encounter: [" + ret + "]"; } - + /** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ public Integer getId() { - + return getEncounterId(); } - + /** * @since 1.5 * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer) */ public void setId(Integer id) { setEncounterId(id); - + } - + }