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

Drug order is not allowed without a drug

    XMLWordPrintable

    Details

      Description

      This issue was identified while working https://issues.openmrs.org/browse/TRUNK-4436

      • The drug_inventory_id in liquibase migration sets up default value as 0 in database. This would not allow drug_order with non coded drug name in future.
      • The DrugOrder Class overrides setConcept() to do nothing and getConcept() return null when no drug is set.

      We had written tests for for DrugOrder#hasSameOrderableAs(Order) to consider drug orders without drug. These below tests can not be run till above issues are fixed.

      DrugOrderTest.java
      	@Test
      	public void hasSameOrderableAs_shouldBeFalseWhenThisOrderHasDrugAndOtherOrderDoesNotHaveDrug() {
      		DrugOrder order = new DrugOrder();
      		order.setDrug(new Drug());
      		
      		DrugOrder otherOrder = new DrugOrder();
      		otherOrder.setDrug(null);
              otherOrder.setConcept(new Concept());
      		
      		assertFalse(order.hasSameOrderableAs(otherOrder));
      	}
      	
      	@Test
      	public void hasSameOrderableAs_shouldBeFalseWhenThisOrderDoesNotHaveDrugAndOtherOrderHasDrug() {
      		DrugOrder order = new DrugOrder();
      		order.setDrug(null);
              order.setConcept(new Concept());
      		
      		DrugOrder otherOrder = new DrugOrder();
      		otherOrder.setDrug(new Drug());
      		
      		assertFalse(order.hasSameOrderableAs(otherOrder));
      	}
      	
      	@Test
      	public void hasSameOrderableAs_shouldBeTrueWhenBothOrdersDoNotHaveDrugAndConceptsMatch() {
      		DrugOrder order = new DrugOrder();
      		Concept concept = new Concept();
      		order.setDrug(null);
      		order.setConcept(concept);
      		
      		DrugOrder otherOrder = new DrugOrder();
      		otherOrder.setDrug(null);
      		otherOrder.setConcept(concept);
      		
      		assertTrue(order.hasSameOrderableAs(otherOrder));
      	}
      	
      	@Test
      	public void hasSameOrderableAs_shouldBeFalseWhenBothOrdersDoNotHaveDrugAndConceptsDoNotMatch() {
      		DrugOrder order = new DrugOrder();
      		order.setDrug(null);
      		order.setConcept(new Concept(123));
      		
      		DrugOrder otherOrder = new DrugOrder();
      		otherOrder.setDrug(null);
      		otherOrder.setConcept(new Concept(456));
      		
      		assertFalse(order.hasSameOrderableAs(otherOrder));
      	}
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                wyclif Wyclif Luyima
                Reporter:
                bharti Bharti Nagpal
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 4 hours
                    4h
                    Remaining:
                    Time Spent - 3 hours Remaining Estimate - 1 hour
                    1h
                    Logged:
                    Time Spent - 3 hours Remaining Estimate - 1 hour
                    3h