/** * @see DosingInstructions#setDosingInstructions(DrugOrder) */ @Override public void setDosingInstructions(DrugOrder order) { order.setDosingType(this.getClass()); order.setDose(this.dose); order.setDoseUnits(this.doseUnits); order.setRoute(this.route); order.setFrequency(this.frequency); order.setDuration(this.duration); order.setDurationUnits(this.durationUnits); order.setAsNeeded(this.asNeeded); order.setAsNeededCondition(this.asNeededCondition); order.setDosingInstructions(this.administrationInstructions); }
/** * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldFailValidationIfDoseIsNullForSimpleDosingInstructionsDosingType() { DrugOrder order = new DrugOrder(); order.setDosingType(SimpleDosingInstructions.class); order.setDose(null); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("dose")); }
private DrugOrder createValidDrugOrder() { DrugOrder drugOrder = new DrugOrder(); drugOrder.setDose(10.0); drugOrder.setDoseUnits(createConceptWithName("ml")); drugOrder.setRoute(createConceptWithName("IV")); OrderFrequency frequency = new OrderFrequency(); frequency.setConcept(createConceptWithName("Twice a day")); drugOrder.setFrequency(frequency); return drugOrder; }
protected void editOrder(FormEntrySession session, OrderTag orderTag) { existingOrder.setDrug(orderTag.drug); existingOrder.setDose(orderTag.dose); existingOrder.setFrequency(orderTag.frequency); existingOrder.setStartDate(orderTag.startDate); if (orderTag.orderDuration != null) existingOrder.setAutoExpireDate(calculateAutoExpireDate(orderTag.startDate, orderTag.orderDuration)); if (orderTag.discontinuedDate != null){ existingOrder.setDiscontinuedDate(orderTag.discontinuedDate); existingOrder.setDiscontinued(true); } if (!StringUtils.isEmpty(orderTag.discontinuedReasonStr)) existingOrder.setDiscontinuedReason(HtmlFormEntryUtil.getConcept(orderTag.discontinuedReasonStr)); existingOrder.setConcept(orderTag.drug.getConcept()); if (!StringUtils.isEmpty(orderTag.instructions)) existingOrder.setInstructions((String) orderTag.instructions); log.debug("modifying drug order, drugId is " + orderTag.drugId + " and startDate is " + orderTag.startDate); existingOrder = setDiscontinueDateFromAutoExpire(existingOrder); session.getSubmissionActions().getCurrentEncounter().setDateChanged(new Date()); }
/** * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldFailValidationIfDoseUnitsIsNullWhenDoseIsPresent() { DrugOrder order = new DrugOrder(); order.setDosingType(FreeTextDosingInstructions.class); order.setDose(20.0); order.setDoseUnits(null); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("doseUnits")); }
/** * @see DrugOrderValidator#validate(Object,Errors) */ @Test public void validate_shouldFailValidationIfQuantityUnitsItNotAQuantityUnitConcept() { Concept concept = Context.getConceptService().getConcept(3); assertThat(concept, not(isIn(Context.getOrderService().getDrugDispensingUnits()))); DrugOrder order = new DrugOrder(); order.setDosingType(FreeTextDosingInstructions.class); order.setDuration(5); order.setDurationUnits(concept); order.setDose(1.0); order.setDoseUnits(concept); order.setQuantity(30.0); order.setQuantityUnits(concept); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("quantityUnits")); }
/** * @see DrugOrderValidator#validate(Object,Errors) */ @Test public void validate_shouldFailValidationIfDoseUnitsIsNotADoseUnitConcept() { Concept concept = Context.getConceptService().getConcept(3); assertThat(concept, not(isIn(Context.getOrderService().getDrugDosingUnits()))); DrugOrder order = new DrugOrder(); order.setDosingType(FreeTextDosingInstructions.class); order.setDuration(5); order.setDurationUnits(concept); order.setDose(1.0); order.setDoseUnits(concept); order.setQuantity(30.0); order.setQuantityUnits(concept); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("doseUnits")); }
/** * @see DrugOrderValidator#validate(Object,Errors) */ @Test public void validate_shouldFailValidationIfDurationUnitsIsNotADurationUnitConcept() { Concept concept = Context.getConceptService().getConcept(3); assertThat(concept, not(isIn(Context.getOrderService().getDurationUnits()))); DrugOrder order = new DrugOrder(); order.setDosingType(FreeTextDosingInstructions.class); order.setDuration(5); order.setDurationUnits(concept); order.setDose(1.0); order.setDoseUnits(concept); order.setQuantity(30.0); order.setQuantityUnits(concept); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("durationUnits")); }
/** * @see org.openmrs.Order#copyHelper(Order) */ protected DrugOrder copyHelper(DrugOrder target) { super.copyHelper(target); target.setDose(getDose()); target.setDoseUnits(getDoseUnits()); target.setFrequency(getFrequency()); target.setAsNeeded(getAsNeeded()); target.setAsNeededCondition(getAsNeededCondition()); target.setQuantity(getQuantity()); target.setQuantityUnits(getQuantityUnits()); target.setDrug(getDrug()); target.setDosingType(getDosingType()); target.setDosingInstructions(getDosingInstructions()); target.setDuration(getDuration()); target.setDurationUnits(getDurationUnits()); target.setNumRefills(getNumRefills()); target.setRoute(getRoute()); target.setBrandName(getBrandName()); target.setDispenseAsWritten(getDispenseAsWritten()); target.setDrugNonCoded(getDrugNonCoded()); return target; }
/** * @see Order#cloneForRevisionHelper(Order) */ protected DrugOrder cloneForRevisionHelper(DrugOrder target) { super.cloneForRevisionHelper(target); target.setDose(getDose()); target.setDoseUnits(getDoseUnits()); target.setFrequency(getFrequency()); target.setAsNeeded(getAsNeeded()); target.setAsNeededCondition(getAsNeededCondition()); target.setQuantity(getQuantity()); target.setQuantityUnits(getQuantityUnits()); target.setDrug(getDrug()); target.setDosingType(getDosingType()); target.setDosingInstructions(getDosingInstructions()); target.setDuration(getDuration()); target.setDurationUnits(getDurationUnits()); target.setRoute(getRoute()); target.setNumRefills(getNumRefills()); target.setBrandName(getBrandName()); target.setDispenseAsWritten(getDispenseAsWritten()); target.setDrugNonCoded(getDrugNonCoded()); return target; }
/** * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldFailIfRouteIsNotAValidConcept() { Concept concept = Context.getConceptService().getConcept(3); assertThat(concept, not(isIn(Context.getOrderService().getDrugRoutes()))); DrugOrder order = new DrugOrder(); order.setDosingType(FreeTextDosingInstructions.class); order.setDuration(5); order.setDurationUnits(concept); order.setDose(1.0); order.setDoseUnits(concept); order.setQuantity(30.0); order.setQuantityUnits(concept); order.setRoute(concept); Errors errors = new BindException(order, "order"); new DrugOrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("route")); Assert.assertEquals("DrugOrder.error.routeNotAmongAllowedConcepts", errors.getFieldError("route").getCode()); }
order.setDrug(conceptService.getDrug(2)); order.setDosingType(SimpleDosingInstructions.class); order.setDose(300.0); order.setDoseUnits(conceptService.getConcept(50)); order.setQuantity(20.0);
order.setDateActivated(newOrderDateActivated); order.setDrug(duplicateOrder.getDrug()); order.setDose(duplicateOrder.getDose()); order.setDoseUnits(duplicateOrder.getDoseUnits()); order.setRoute(duplicateOrder.getRoute());
order.setDrug(conceptService.getDrug(2)); order.setDosingType(SimpleDosingInstructions.class); order.setDose(300.0); order.setDoseUnits(conceptService.getConcept(50)); order.setQuantity(20.0); order2.setDrug(conceptService.getDrug(2)); order2.setDosingType(SimpleDosingInstructions.class); order2.setDose(300.0); order2.setDoseUnits(conceptService.getConcept(50)); order2.setQuantity(20.0);
order.setDateActivated(new Date()); order.setDosingType(SimpleDosingInstructions.class); order.setDose(orderToDiscontinue.getDose()); order.setDoseUnits(orderToDiscontinue.getDoseUnits()); order.setRoute(orderToDiscontinue.getRoute());
order.setDateActivated(new Date()); order.setDosingType(SimpleDosingInstructions.class); order.setDose(500.0); order.setDoseUnits(conceptService.getConcept(50)); order.setFrequency(orderService.getOrderFrequency(1));
drugOrder.setCareSetting(duplicateOrder.getCareSetting()); drugOrder.setDrug(duplicateOrder.getDrug()); drugOrder.setDose(duplicateOrder.getDose()); drugOrder.setDoseUnits(duplicateOrder.getDoseUnits()); drugOrder.setRoute(duplicateOrder.getRoute());
@Test public void saveOrder_shouldSetAutoExpireDateOfDrugOrderIfAutoExpireDateIsNotSet() throws ParseException { executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrderAutoExpireDate.xml"); Drug drug = conceptService.getDrug(3000); DrugOrder drugOrder = new DrugOrder(); Encounter encounter = encounterService.getEncounter(3); drugOrder.setEncounter(encounter); drugOrder.setPatient(patientService.getPatient(7)); drugOrder.setCareSetting(orderService.getCareSetting(1)); drugOrder.setOrderer(Context.getProviderService().getProvider(1)); drugOrder.setDrug(drug); drugOrder.setDosingType(SimpleDosingInstructions.class); drugOrder.setDose(300.0); drugOrder.setDoseUnits(conceptService.getConcept(50)); drugOrder.setQuantity(20.0); drugOrder.setQuantityUnits(conceptService.getConcept(51)); drugOrder.setFrequency(orderService.getOrderFrequency(3)); drugOrder.setRoute(conceptService.getConcept(22)); drugOrder.setNumRefills(0); drugOrder.setOrderType(null); drugOrder.setDateActivated(TestUtil.createDateTime("2014-08-03")); drugOrder.setDuration(20);// 20 days drugOrder.setDurationUnits(conceptService.getConcept(1001)); Order savedOrder = orderService.saveOrder(drugOrder, null); Order loadedOrder = orderService.getOrder(savedOrder.getId()); Assert.assertEquals(TestUtil.createDateTime("2014-08-22 23:59:59"), loadedOrder.getAutoExpireDate()); }
order.setDateActivated(new Date()); order.setDosingType(SimpleDosingInstructions.class); order.setDose(500.0); order.setDoseUnits(conceptService.getConcept(50)); order.setFrequency(orderService.getOrderFrequency(1));
drugOrder.setDrug(drug); drugOrder.setDosingType(SimpleDosingInstructions.class); drugOrder.setDose(300.0); drugOrder.setDoseUnits(conceptService.getConcept(50)); drugOrder.setQuantity(20.0);