Package org.openmrs.api

Examples of org.openmrs.api.ConceptService


   */
  public static Set<Order> standardRegimenToDrugOrders(RegimenSuggestion rs, Date startDate, Patient patient){
    Set<Order> ret = new HashSet<Order>();
    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);
       
        OrderFrequency frequency = findFrequency(orderService, ds.getFrequency());
        dor.setFrequency(frequency);
        dor.setInstructions(ds.getInstructions());
        dor.setDose(Double.valueOf(ds.getDose()));
        dor.setDoseUnits(conceptService.getConceptByName(ds.getUnits()));
        dor.setRoute(Context.getConceptService().getConceptByName("UNKNOWN"));
        dor.setDateActivated(startDate);
        dor.setPatient(patient);
        dor.setDateChanged(new Date());
        dor.setCreator(Context.getAuthenticatedUser());
View Full Code Here


  protected DrugOrder existingOrder;
  protected List<Drug> drugsUsedAsKey;


  public DrugOrderSubmissionElement(FormEntryContext context, Map<String, String> parameters) {
    ConceptService conceptService = Context.getConceptService();
    MessageSourceService mss = Context.getMessageSourceService();

    Boolean usingDurationField = false;
    String orderDurationStr = parameters.get(FIELD_SHOW_ORDER_DURATION);
    if (!StringUtils.isEmpty(orderDurationStr) && orderDurationStr.equals("true"))
        usingDurationField = true;
    String hideDoseAndFreqStr = parameters.get(CONFIG_SHOW_DOSE_AND_FREQ);
    if (!StringUtils.isEmpty(hideDoseAndFreqStr) && hideDoseAndFreqStr.equals("true"))
        hideDoseAndFrequency = true;

    String checkboxStr = parameters.get(FIELD_CHECKBOX);
        if (checkboxStr != null && checkboxStr.equals("true"))
            checkbox = true;

    // check URL
    String drugNames = parameters.get(FIELD_DRUG_NAMES);
    if (drugNames == null || drugNames.length() < 1)
      throw new IllegalArgumentException("You must provide a valid drug name, or a valid ID or a valid UUID in " + parameters);

    String fieldValidateDose = parameters.get(FIELD_VALIDATE_DOSE);
    if (fieldValidateDose != null && fieldValidateDose.length() > 1)
      validateDose = Boolean.parseBoolean(fieldValidateDose);

        if (parameters.get(FIELD_DRUG_LABELS) != null) {
            drugLabels = Arrays.asList(parameters.get(FIELD_DRUG_LABELS).split(","));
        }

    // fill drop down with drug names from database
    List<Option> options = new ArrayList<Option>();
    options.add(new Option("", "", false));

    // drugNames is comma separated list which can contain ID, UUID or drugname
    StringTokenizer tokenizer = new StringTokenizer(drugNames, ",");
    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) {
View Full Code Here

                }
                //RegimenSuggestion -- see global property 'dashboard.regimen.standardRegimens'
                if (RegimenSuggestion.class.equals(attributeDescriptor.getClazz())){
                  List<RegimenSuggestion> stRegimens = DrugOrderSupport.getInstance().getStandardRegimens();
                  if (stRegimens != null){
                    ConceptService cs = Context.getConceptService();
                    for (RegimenSuggestion rs : stRegimens){
                      if (rs.getCodeName().equals(id) && rs.getDrugComponents() != null){
                        for (DrugSuggestion ds : rs.getDrugComponents()){
                          Drug drug = cs.getDrugByNameOrId(ds.getDrugId());
                          if (drug == null)
                             drug = cs.getDrugByUuid(ds.getDrugId());
                          if (drug != null)
                            dependencies.add(drug);
                        }
                      }
                    }
View Full Code Here

TOP

Related Classes of org.openmrs.api.ConceptService

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.