Package org.openmrs

Examples of org.openmrs.DrugOrder


   *
   */
  private static DrugOrder drugIdFoundInDrugSet(DrugSuggestion ds, List<Order> dors){
    for (Order or : dors){
      if (or instanceof DrugOrder){
        DrugOrder dor = (DrugOrder) or;
        if (dor.getDrug() != null && !dor.isVoided() && (dor.getDrug().getDrugId().toString().equals(ds.getDrugId()) || dor.getDrug().getUuid().toString().equals(ds.getDrugId())))
          return dor;
      }
    }
    return null;
  }
View Full Code Here


  }
 
  @Override
  protected void editOrder(FormEntrySession session, OrderTag oldOrderTag) {
    OrderTag1_10 orderTag = (OrderTag1_10) oldOrderTag;
    DrugOrder discontinuationOrder = null;
   
    if (!existingOrder.getAction().equals(Action.DISCONTINUE)) {
      //Discontinued orders must not be changed except for discontinue date and reason
      DrugOrder revisedOrder = existingOrder.cloneForRevision();
      setOrderer(session, revisedOrder);
      revisedOrder.setDrug(orderTag.drug);
      revisedOrder.setConcept(orderTag.drug.getConcept());
      revisedOrder.setDosingType(orderTag.dosingType);
      revisedOrder.setDose(orderTag.dose);
      revisedOrder.setDoseUnits(orderTag.doseUnits);
      revisedOrder.setQuantity(orderTag.quantity);
      revisedOrder.setQuantityUnits(orderTag.quantityUnits);
      revisedOrder.setDuration(orderTag.duration);
      revisedOrder.setDurationUnits(orderTag.durationUnits);
      revisedOrder.setRoute(orderTag.route);
      revisedOrder.setCareSetting(Context.getOrderService().getCareSetting(orderTag.careSettingId));
      OrderFrequency orderFrequency = Context.getOrderService().getOrderFrequency(Integer.valueOf(orderTag.frequency));
      revisedOrder.setFrequency(orderFrequency);
      revisedOrder.setDateActivated(orderTag.startDate);
            revisedOrder.setNumRefills(orderTag.numRefills);
      if (orderTag.orderDuration != null)
        revisedOrder.setAutoExpireDate(calculateAutoExpireDate(orderTag.startDate, orderTag.orderDuration));
      if (!StringUtils.isEmpty(orderTag.instructions))
        revisedOrder.setInstructions((String) orderTag.instructions);
     
      log.debug("modifying drug order, drugId is " + orderTag.drugId + " and startDate is " + orderTag.startDate);
      session.getSubmissionActions().getCurrentEncounter().setDateChanged(new Date());
      session.getSubmissionActions().getCurrentEncounter().addOrder(revisedOrder);
     
View Full Code Here

   */
  public static Set<Order> standardRegimenToDrugOrders(RegimenSuggestion rs, Date startDate, Patient patient){
    Set<Order> ret = new HashSet<Order>();
    if (rs != null){
      for (DrugSuggestion ds : rs.getDrugComponents()){
        DrugOrder dor = new DrugOrder();
        dor.setVoided(false);
        Drug drug = Context.getConceptService().getDrugByNameOrId(ds.getDrugId());
        if (drug == null)
          drug = Context.getConceptService().getDrugByUuid(ds.getDrugId());
        if (drug == null)
          throw new RuntimeException("Your standard regimen xml file constains a drugId that can't be found, for regimen " + rs.getCodeName() + ", DrugComponent.id = " + ds.getDrugId());
        dor.setDrug(Context.getConceptService().getDrugByNameOrId(ds.getDrugId()));
        dor.setFrequency(ds.getFrequency());
        dor.setUnits(ds.getUnits());
        dor.setInstructions(ds.getInstructions());
        dor.setDose(Double.valueOf(ds.getDose()));
        dor.setStartDate(startDate);
        dor.setDiscontinued(false);
        dor.setPatient(patient);
        dor.setDateChanged(new Date());
        dor.setCreator(Context.getAuthenticatedUser());
        dor.setOrderType(Context.getOrderService().getOrderType(OpenmrsConstants.ORDERTYPE_DRUG));
        dor.setConcept(drug.getConcept());
        ret.add(dor);
      }
    } 
    return ret;
  }
View Full Code Here

    }
  }
 
  private DrugOrder createDiscontinuationOrderIfNeeded(DrugOrder drugOrder, Date discontinuedDate,
          String discontinuedReasonStr) {
    DrugOrder discontinuationOrder = null;
   
    if (discontinuedDate != null) {
      discontinuationOrder = drugOrder.cloneForDiscontinuing();
      discontinuationOrder.setDateActivated(discontinuedDate);
      if (!StringUtils.isEmpty(discontinuedReasonStr))
        discontinuationOrder.setOrderReason(HtmlFormEntryUtil.getConcept(discontinuedReasonStr));
    } else if (drugOrder.getAutoExpireDate() != null) {
      Date date = new Date();
      if (drugOrder.getAutoExpireDate().getTime() < date.getTime()) {
        drugOrder.setDateActivated(drugOrder.getAutoExpireDate());
        discontinuationOrder = drugOrder.cloneForDiscontinuing();
View Full Code Here

            List<Order> list = existingOrders.get(concept);
            if (list != null) {
                for (Iterator<Order> iter = list.iterator(); iter.hasNext();) {
                    Order test = iter.next();
                    if (test instanceof DrugOrder){
                        DrugOrder testDrugOrder = (DrugOrder) test;
                        if (equalDrug(testDrugOrder.getDrug(), drug)) {
                            iter.remove();
                            if (list.size() == 0)
                                existingOrders.remove(concept);
                            return testDrugOrder;
                        }
View Full Code Here

    e.setEncounterDatetime(date);
    e.setLocation(Context.getLocationService().getLocation(2));
    e.setProvider(Context.getPersonService().getPerson(502));
    TestUtil.addObs(e, 1, 5000, date); //a matching obs
   
    DrugOrder dor = new DrugOrder();
    dor.setVoided(false);
    dor.setConcept(Context.getConceptService().getConcept(792));
    dor.setCreator(Context.getUserService().getUser(1));
    dor.setDateCreated(new Date());
    dor.setDiscontinued(false);
    dor.setDrug(Context.getConceptService().getDrug(2));
    dor.setOrderType(Context.getOrderService().getOrderType(1));
    dor.setPatient(Context.getPatientService().getPatient(2));
    dor.setStartDate(new Date());
    e.addOrder(dor);
   
    Context.getEncounterService().saveEncounter(e);
   
    Form form = new Form();
View Full Code Here

    e.setEncounterDatetime(date);
    e.setLocation(Context.getLocationService().getLocation(2));
    e.setProvider(Context.getPersonService().getPerson(502));
    TestUtil.addObs(e, 3, 5000, date);//adding an un-matched Obs
   
    DrugOrder dor = new DrugOrder();
    dor.setVoided(false);
    dor.setConcept(Context.getConceptService().getConcept(792));
    dor.setCreator(Context.getUserService().getUser(1));
    dor.setDateCreated(new Date());
    dor.setDiscontinued(false);
    dor.setDrug(Context.getConceptService().getDrug(2));
    dor.setOrderType(Context.getOrderService().getOrderType(1));
    dor.setPatient(Context.getPatientService().getPatient(2));
    dor.setStartDate(new Date());
    e.addOrder(dor);
   
    Context.getEncounterService().saveEncounter(e);
   
    Form form = new Form();
View Full Code Here

      o.setVoidReason("blah");
      o.setDateVoided(new Date());
    }
   
    //and adding a voided drug order
    DrugOrder dor = new DrugOrder();
    dor.setVoided(false);
    dor.setConcept(Context.getConceptService().getConcept(792));
    dor.setCreator(Context.getUserService().getUser(1));
    dor.setDateCreated(new Date());
    dor.setDiscontinued(false);
    dor.setDrug(Context.getConceptService().getDrug(2));
    dor.setOrderType(Context.getOrderService().getOrderType(1));
    dor.setPatient(Context.getPatientService().getPatient(2));
    dor.setVoided(true);
    dor.setVoidedBy(Context.getUserService().getUser(1));
    dor.setVoidReason("blah");
    dor.setDateVoided(new Date());
    dor.setStartDate(new Date());
    e.addOrder(dor);
   
    Context.getEncounterService().saveEncounter(e);
   
    Form form = new Form();
View Full Code Here

TOP

Related Classes of org.openmrs.DrugOrder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.