Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5017

Encounter.removeProvider fails if same provider has already been removed once before

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: Platform 1.9.11, Platform 1.10.3, Platform 1.11.7, Platform 2.0.2
    • Fix Version/s: Core 2.1.0
    • Component/s: None
    • Labels:
    • Complexity:
      Low

      Description

      The Encounter removeProvider(EncounterRole role, Provider provider) method sets voided=true on the first matching provider it finds, regardless of whether that provider is voided or not.

      Therefore, if you add and then remove the same provider twice, the second remove fails.

      Test to reproduce:

      	@Test
      	public void multipleAddingAndRemovingOfSameProviderShouldNotFail() throws Exception {
      
      		Encounter encounter = new Encounter();
      		EncounterRole role = new EncounterRole();
      		Provider provider = new Provider();
      
      		encounter.addProvider(role, provider);
      
      		Assert.assertEquals(1, encounter.getProvidersByRole(role).size());
      		Assert.assertTrue(encounter.getProvidersByRole(role).contains(provider));
      
      		encounter.removeProvider(role, provider);
      
      		//the size should be 0 for non voided providers
      		Assert.assertEquals(0, encounter.getProvidersByRole(role).size());
      
      		encounter.addProvider(role, provider);
      		Assert.assertEquals(1, encounter.getProvidersByRole(role).size());
      
      		encounter.removeProvider(role, provider);
      		Assert.assertEquals(0, encounter.getProvidersByRole(role).size());  // current fails, returns 1
      
      	}
      }
      

      (this might make a good intro ticket)

        Attachments

          Activity

            People

            • Assignee:
              jtatia Jai Tatia [X] (Inactive)
              Reporter:
              mogoodrich Mark Goodrich
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: