Examples of Drug


Examples of org.openmrs.Drug

 
  @Test
  public void testDeleteDrugGroupShouldDeleteDrugGroup() {
    DrugGroup drugGroup = new DrugGroup();
    Set<Drug> drugs = new HashSet<Drug>();
    Drug drug1 = new Drug();
    Drug drug2 = new Drug();
    drug1.setId(1);
    drug1.setConcept(new Concept(792));
    drug1.setDateCreated(new Date());
    drug1.setCreator(Context.getUserContext().getAuthenticatedUser());
    drug2.setId(2);
    drug2.setConcept(new Concept(792));
    drug2.setDateCreated(new Date());
    drug2.setCreator(Context.getUserContext().getAuthenticatedUser());
    drugs.add(drug1);
    drugs.add(drug2);
    drugGroup.setId(2);
    drugGroup.setName("TestDrugGroup2");
    drugGroup.setDescription("Second Test Drug Group");
View Full Code Here

Examples of org.openmrs.Drug

   
    if (concept == null) {
      throw new ObjectNotFoundException();
    }
   
    Drug drug = new Drug();
    drug.setConcept(concept);
    updateDrugFieldsFromPostData(drug, post);
    Drug drugJustCreated = service.saveDrug(drug);
    if (post.get("drugInfo") != null) {
      this.createNewDrugInfo(drugJustCreated, (LinkedHashMap) post.get("drugInfo"));
    }
    return RestUtil.created(response, getDrugAsSimpleObject(drugJustCreated));
  }
View Full Code Here

Examples of org.openmrs.Drug

  @WSDoc("Updates an existing drug")
  @ResponseBody
  public Object updateDrug(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post, HttpServletRequest request,
          HttpServletResponse response) throws ResponseException {
    initDrugController();
    Drug drug = service.getDrugByUuid(uuid);
    updateDrugFieldsFromPostData(drug, post);
    service.saveDrug(drug);
    return RestUtil.created(response, getDrugAsSimpleObject(drug));
  }
View Full Code Here

Examples of org.openmrs.Drug

  @RequestMapping(value = "/{uuid}", method = RequestMethod.GET)
  @WSDoc("Gets Drug for the uuid path")
  @ResponseBody()
  public String getDrugByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request) throws ResponseException {
    initDrugController();
    Drug drug = service.getDrugByUuid(uuid);
    return gson.toJson(getDrugAsSimpleObject(drug));
  }
View Full Code Here

Examples of org.openmrs.Drug

  @WSDoc("Gets Full representation of Drug for the uuid path")
  @ResponseBody()
  public String getDrugByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
          HttpServletRequest request) throws ResponseException {
    initDrugController();
    Drug drug = service.getDrugByUuid(uuid);
    SimpleObject obj = getDrugAsSimpleObject(drug);
    if (rep.equals("full")) {
      obj.add("retired", drug.getRetired());
      if (drug.getRetired()) {
        obj.add("retiredBy", drug.getRetiredBy().getUuid());
        obj.add("retireReason", drug.getRetireReason());
      }
      SimpleObject auditInfo = new SimpleObject();
      auditInfo.add("creator", drug.getCreator().getUuid());
      auditInfo.add("dateCreated", df.format(drug.getDateCreated()));
      if (drug.getChangedBy() != null) {
        auditInfo.add("changedBy", drug.getChangedBy().getUuid());
        auditInfo.add("dateChanged", df.format(drug.getDateChanged()));
      }
      obj.add("auditInfo", auditInfo);
    }
    obj.add("resourceVersion", getResourceVersion());
    return gson.toJson(obj);
View Full Code Here

Examples of org.openmrs.Drug

  @ResponseBody
  public Object retireDrug(@PathVariable("uuid") String uuid,
          @RequestParam(value = "reason", defaultValue = "web service call") String reason, HttpServletRequest request,
          HttpServletResponse response) throws ResponseException {
    initDrugController();
    Drug drug = service.getDrugByUuid(uuid);
    if (drug != null) {
      drug.setRetired(true);
      drug.setRetireReason(reason);
      drug.setRetiredBy(Context.getAuthenticatedUser());
      service.updateDrug(drug);
    }
    return RestUtil.noContent(response);
  }
View Full Code Here

Examples of org.openmrs.Drug

   * Test of saveDrugInfo method, of class DrugInfoServiceImpl.
   */
  @Test
  public void testSaveDrugInfoShouldUsePrivileges() throws Exception {
    Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer"));
    Drug drug = new Drug();
    drug.setId(3);
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    drugInfo.setName("TestDrugInfo3");
    drugInfo.setDescription("Third Test DrugInfo");
    drugInfo.setCreator(Context.getUserContext().getAuthenticatedUser());
View Full Code Here

Examples of org.openmrs.Drug

  /**
   * Test of saveDrugInfo method, of class DrugInfoServiceImpl.
   */
  @Test
  public void testSaveDrugInfoShouldSaveDrugInfo() throws Exception {
    Drug drug = new Drug();
    drug.setId(3);
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    drugInfo.setName("TestDrugInfo3");
    drugInfo.setDescription("Third Test DrugInfo");
    drugInfo.setCreator(Context.getUserContext().getAuthenticatedUser());
View Full Code Here

Examples of org.openmrs.Drug

   * Test of deleteDrugInfo method, of class DrugInfoServiceImpl.
   */
  @Test
  public void testDeleteDrugInfoShouldUsePrivileges() {
    Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer"));
    Drug drug = new Drug();
    drug.setId(3);
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    drugInfo.setId(2);
    drugInfo.setName("TestDrugInfo2");
    drugInfo.setDescription("Second Test DrugInfo");
View Full Code Here

Examples of org.openmrs.Drug

  /**
   * Test of deleteDrugInfo method, of class DrugInfoServiceImpl.
   */
  @Test
  public void testDeleteDrugInfoShouldDeleteDrugInfo() {
    Drug drug = new Drug();
    drug.setId(3);
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    drugInfo.setId(2);
    drugInfo.setName("TestDrugInfo2");
    drugInfo.setDescription("Second Test DrugInfo");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.