Package org.openmrs

Examples of org.openmrs.Drug


        results.assertEncounterCreated();
        encounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(encounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
          hasProperty("dateActivated", is(ymdToDate(dateAsString(date)))))));
      }
     
      @Override
      public Encounter getEncounterToEdit() {
        return encounter;
      }
     
      @Override
      public void testEditFormHtml(String html) {
        System.out.println(html);
      }
     
      @Override
      public void setupEditRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        //drug
        request.setParameter("w7", "2");
        //start date
        request.setParameter("w9", dateAsString(date));
        //dosing type
        request.setParameter("w17", "org.openmrs.SimpleDosingInstructions");
        //dose
        request.setParameter("w11", "2");
        request.setParameter("w18", "51");
        //care setting
        request.setParameter("w26", "2");
        //route
        request.setParameter("w25", "22");
        //frequency
        request.setParameter("w13", "1");
       
        //discontinue date
        request.setParameter("w15", dateAsString(date));
      }
     
      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(editedEncounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(
          allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
            hasProperty("dateActivated", is(ymdToDate(dateAsString(date))))),
          allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(2.0)),
            hasProperty("action", is(Order.Action.REVISE)), hasProperty("dateStopped", is(ymdToDate(dateAsString(date))))),
View Full Code Here


        results.assertEncounterCreated();
        encounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(encounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
          hasProperty("dateActivated", is(ymdToDate(dateAsString(date)))))));
      }
     
      @Override
      public Encounter getEncounterToEdit() {
        return encounter;
      }
     
      @Override
      public void testEditFormHtml(String html) {
        System.out.println(html);
      }
     
      @Override
      public void setupEditRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        //drug
        request.setParameter("w7", "2");
        //start date
        request.setParameter("w9", dateAsString(date));
        //dosing type
        request.setParameter("w17", "org.openmrs.SimpleDosingInstructions");
        //dose
        request.setParameter("w11", "2");
        request.setParameter("w18", "51");
        //care setting
        request.setParameter("w26", "2");
        //route
        request.setParameter("w25", "22");
        //frequency
        request.setParameter("w13", "1");
      }
     
      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(editedEncounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, containsInAnyOrder(
          allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(2.0)),
          hasProperty("dateActivated", is(ymdToDate(dateAsString(date)))), hasProperty("action", is(Order.Action.REVISE))),
          allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
            hasProperty("dateActivated", is(ymdToDate(dateAsString(date)))))
View Full Code Here

        results.assertEncounterCreated();
        encounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(encounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
          hasProperty("dateActivated", is(ymdToDate(dateAsString(date))))),
          allOf(hasProperty("drug", is(drug)), hasProperty("action", is(Order.Action.DISCONTINUE)), hasProperty("dateActivated", is(ymdToDate(dateAsString(discontinueDate)))))));
      }
     
      @Override
      public Encounter getEncounterToEdit() {
        return encounter;
      }
     
      @Override
      public void testEditFormHtml(String html) {
        System.out.println(html);
      }
     
      @Override
      public void setupEditRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        //drug
        request.setParameter("w7", "2");
        //start date
        request.setParameter("w9", dateAsString(date));
        //dosing type
        request.setParameter("w17", "org.openmrs.SimpleDosingInstructions");
        //dose
        request.setParameter("w11", "2"); //changes to dose should not be persisted
        request.setParameter("w18", "51");
        //care setting
        request.setParameter("w26", "2");
        //route
        request.setParameter("w25", "22");
        //frequency
        request.setParameter("w13", "1");
       
        //discontinue date
        request.setParameter("w15", dateAsString(newDiscontinueDate));
      }
     
      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(editedEncounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(
          allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
            hasProperty("dateActivated", is(ymdToDate(dateAsString(date))))),
          allOf(hasProperty("drug", is(drug)), hasProperty("voided", is(true)),
            hasProperty("action", is(Order.Action.DISCONTINUE)), hasProperty("dateActivated", is(ymdToDate(dateAsString(discontinueDate))))),
View Full Code Here

      public void testResults(SubmissionResults results) {
        results.assertNoErrors();
        results.assertEncounterCreated();
        encounter = results.getEncounterCreated();

        Drug drug2 = Context.getConceptService().getDrug(2);
        Drug drug3 = Context.getConceptService().getDrug(3);
        Drug drug11 = Context.getConceptService().getDrug(11);

        assertThat(
            encounter.getOrders(),
            containsInAnyOrder(
                allOf(hasProperty("drug", is(drug2)), hasProperty("dose", is(1.0)),
                    hasProperty("dateActivated", is(ymdToDate(dateAsString(date))))),
                allOf(hasProperty("drug", is(drug3)), hasProperty("dose", is(1.0)),
                    hasProperty("dateActivated", is(ymdToDate(dateAsString(date))))),
                allOf(hasProperty("drug", is(drug11)), hasProperty("dose", is(1.0)),
                    hasProperty("dateActivated", is(ymdToDate(dateAsString(date)))))));
      }

      @Override
      public Encounter getEncounterToEdit() {
        return encounter;
      }

      @Override
      public void testEditFormHtml(String html) {
        System.out.println(html);
      }

      @Override
      public void setupEditRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        //w7 is the standardRegimen tag
        request.setParameter("w7", "drug2and3");
        //start date
        request.setParameter("w9", dateAsString(date));
        //care setting
        request.setParameter("w15", "2");
      }

      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();

        Drug drug2 = Context.getConceptService().getDrug(2);
        Drug drug3 = Context.getConceptService().getDrug(3);

        Set<Order> orders = new HashSet<Order>(editedEncounter.getOrders());
        for (Iterator<Order> it = orders.iterator(); it.hasNext();) {
          Order order = it.next();
          if (order.isVoided()) {
View Full Code Here

    if (rs != null){
      OrderService orderService = Context.getOrderService();
      ConceptService conceptService = Context.getConceptService();
      for (DrugSuggestion ds : rs.getDrugComponents()){
        DrugOrder dor = new DrugOrder();
        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(drug);
View Full Code Here

    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

  public Object createNewDrugInfo(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response)
          throws ResponseException {
    initDrugInfoController();
   
    String drugUuid = post.get("drug").toString();
    Drug drug = Context.getConceptService().getDrugByUuid(drugUuid);
   
    if (drug == null) {
      // drug doesn't exist, so we won't create the drug info
      throw new ObjectNotFoundException();
    }
View Full Code Here

    int drugListIndexPos = 0;
        String displayText = "";
        DrugOrderField dof = new DrugOrderField();
    while (tokenizer.hasMoreElements()) {
      String drugName = (String) tokenizer.nextElement();
      Drug drug = null;

      // see if this is a uuid
      if (HtmlFormEntryUtil.isValidUuidFormat(drugName.trim())) {
        drug = conceptService.getDrugByUuid(drugName.trim());
      }

      // if we didn't find by id, find by uuid or name
      if (drug == null){
        drug = conceptService.getDrugByNameOrId(drugName.trim());
      }

      if (drug != null) {
          displayText = drug.getName();
          if (drugLabels != null) {
              displayText = drugLabels.get(drugListIndexPos);
          }
        options.add(new Option(displayText, drug.getDrugId().toString(), false));
        if (drugsUsedAsKey == null) {
            drugsUsedAsKey = new ArrayList<Drug>();
        }
        drugsUsedAsKey.add(drug);
        DrugOrderAnswer doa = new DrugOrderAnswer(drug, displayText);
View Full Code Here

                throw new Exception("htmlformentry.error.required");
             
              // min max
              if (validateDose) {
                String drugID = (String) drugWidget.getValue(context, submission);
                Drug drug = Context.getConceptService().getDrug(drugID);
                if ((drug.getMinimumDailyDose() != null && dose < drug.getMinimumDailyDose()) || (drug.getMaximumDailyDose() != null && dose > drug.getMaximumDailyDose())) {
                  throw new IllegalArgumentException("htmlformentry.error.doseOutOfRange");
                }             
              }
            }
          } catch (Exception ex) {
View Full Code Here

    }

    @Override
    public void setInitialValue(Object initialValue) {
        if (initialValue instanceof Drug) {
            Drug asDrug = (Drug) initialValue;
            this.initialValue = new Option(asDrug.getName(), "Drug:" + asDrug.getId(), true);
        }
        else if (initialValue instanceof Concept) {
            Concept asConcept = (Concept) initialValue;
            this.initialValue = new Option((asConcept.getName().getName()), asConcept.getConceptId().toString(), true);
        }
View Full Code Here

TOP

Related Classes of org.openmrs.Drug

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.