Examples of DrugInventory


Examples of org.raxa.module.raxacore.DrugInventory

            .getBean("org.raxa.module.raxacore.db.hibernate.HibernateDrugInventoryDAO");
  }
 
  @Test
  public void testSaveDrugInventory() {
    DrugInventory dInventory = new DrugInventory();
    //NOTE: never set Id, will be generated automatically (when saving)
   
    dInventory.setName("TestList6");
    dInventory.setDescription("Third Test List");
    dInventory.setCreator(Context.getUserContext().getAuthenticatedUser());
    dInventory.setDateCreated(new java.util.Date());
    dInventory.setUuid("68547121-1b70-465c-99ee-c9dfd95e7d34");
    dInventory.setDateCreated(new java.util.Date());
    dInventory.setRetired(Boolean.FALSE);
    dInventory.setBatch("batch 1");
    dInventory.setQuantity(10);
    dInventory.setStatus("true");
    //dInventory.setDrugId(2);
    dInventory.setExpiryDate(new Date(2012 - 1 - 1));
    dInventory.setValue(20);
    dInventory.setProviderId(2);
    dInventory.setLocationId(1);
    dInventory.setDrugPurchaseOrderId(14);
    dInventory.setOriginalQuantity(20);
   
    dao.saveDrugInventory(dInventory);
    DrugInventory result = dao.getDrugInventoryByUuid("68547121-1b70-465c-99ee-c9dfd95e7d34");
    //DrugInventory result=dao.get
    String uuid = result.getUuid();
    assertEquals(uuid, "68547121-1b70-465c-99ee-c9dfd95e7d34");
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

    assertEquals(uuid, "68547121-1b70-465c-99ee-c9dfd95e7d34");
  }
 
  @Test
  public void testDeleteDrugInventory() {
    DrugInventory dInventory = new DrugInventory();
    dInventory.setName("TestList6");
    dInventory.setDescription("Third Test List");
    dInventory.setCreator(Context.getUserContext().getAuthenticatedUser());
    dInventory.setDateCreated(new java.util.Date());
    dInventory.setUuid("68547121-1b70-465c-99ee-c9dfd95e7d34");
    dInventory.setDateCreated(new java.util.Date());
    dInventory.setRetired(Boolean.FALSE);
    dInventory.setBatch("batch 1");
    dInventory.setQuantity(10);
    dInventory.setStatus("true");
    //dInventory.setDrugId(2);
    dInventory.setExpiryDate(new Date(2012 - 1 - 1));
    dInventory.setValue(20);
    dInventory.setProviderId(2);
    dInventory.setLocationId(1);
    dInventory.setDrugPurchaseOrderId(14);
    dInventory.setOriginalQuantity(20);
   
    dao.deleteDrugInventory(dInventory);
   
    DrugInventory result = dao.getDrugInventoryByUuid("68547121-1b70-465c-99ee-c9dfd95e7d34");
    assertEquals(result, null);
   
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

   
  }
 
  @Test
  public void testGetDrugInventoryByUuid() {
    DrugInventory result = dao.getDrugInventoryByUuid("68547121-1b70-465c-99ee-c9dfd95e7d36");
    String name = result.getName();
    assertEquals(name, "Test drug inventory");
   
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

    assertEquals(allDrugInventories.size(), 1);
  }
 
  @Test
  public void testUpdateDrugInventory() {
    DrugInventory dInventory = dao.getDrugInventoryByUuid("68547121-1b70-465c-99ee-c9dfd95e7d36");
    dInventory.setName("new test list");
    dao.updateDrugInventory(dInventory);
    String name = dao.getDrugInventoryByUuid("68547121-1b70-465c-99ee-c9dfd95e7d36").getName();
    assertEquals(name, "new test list");
   
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

  @WSDoc("Save DrugInventory")
  @ResponseBody
  public Object saveDrugInventory(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response)
          throws ResponseException {
    initDrugInventoryController();
    DrugInventory drugInventory = setPostFields(post, new DrugInventory());
    DrugInventory created;
    SimpleObject obj = obj = new SimpleObject();
    created = service.saveDrugInventory(drugInventory);
    obj.add("uuid", created.getUuid());
    obj.add("drugId", created.getDrugId());
    obj.add("quantity", created.getQuantity());
    return RestUtil.created(response, obj);
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

  @WSDoc("Gets drug inventory for the uuid path")
  @ResponseBody()
  public String getDrugInventoryByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request)
          throws ResponseException {
    initDrugInventoryController();
    DrugInventory drugInventory = service.getDrugInventoryByUuid(uuid);
    SimpleObject obj = new SimpleObject();
    obj.add("uuid", drugInventory.getUuid());
    obj.add("drugId", drugInventory.getDrugId());
    obj.add("quantity", drugInventory.getQuantity());
    return gson.toJson(obj);
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

  @WSDoc("Updates an existing drug inventory")
  @ResponseBody
  public Object updateDrugInventory(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post,
          HttpServletRequest request, HttpServletResponse response) throws ResponseException {
    initDrugInventoryController();
    DrugInventory di = service.getDrugInventoryByUuid(uuid);
    di = setPostFields(post, di);
    DrugInventory created = service.updateDrugInventory(di);
    SimpleObject obj = new SimpleObject();
    obj.add("uuid", created.getUuid());
    obj.add("name", created.getName());
    obj.add("description", created.getDescription());
    return gson.toJson(obj);
  }
View Full Code Here

Examples of org.raxa.module.raxacore.DrugInventory

      List<DrugInventory> updateInventories = new ArrayList();
      List<DrugInventory> updateBatches = new ArrayList();
      for (int i = 0; i < inventoryObjects.size(); i++) {
        //whether or not current inventory is new or an update
        boolean update = false;
        DrugInventory di = new DrugInventory();
        if (inventoryObjects.get(i).get("uuid") != null) {
          System.out.println("getting existing uuid");
          di = Context.getService(DrugInventoryService.class).getDrugInventoryByUuid(
              inventoryObjects.get(i).get("uuid").toString());
          update = true;
        }
        setDrugInventoryFields(di, inventoryObjects.get(i));
        di.setDrugPurchaseOrder(purchaseOrder);
        di.setDrugPurchaseOrderId(purchaseOrder.getId());
        if (inventoryObjects.get(i).get("batchUuid") != null) {
          DrugInventory batchDrugInv = Context.getService(DrugInventoryService.class).getDrugInventoryByUuid(
              inventoryObjects.get(i).get("batchUuid").toString());
          if (batchDrugInv == null) {
            throw new ResponseException(
                                        "Batch uuid not found") {};
          }
          if (batchDrugInv.getQuantity() < di.getQuantity()) {
            throw new ResponseException(
                                        "Requested quantity cannot exceed batch quantity") {};
          }
          batchDrugInv.setQuantity(batchDrugInv.getQuantity() - di.getQuantity());
          if (batchDrugInv.getQuantity() == 0)
            batchDrugInv.setStatus("out");
          updateBatches.add(batchDrugInv);
        }
        if (update) {
          updateInventories.add(di);
        } else {
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.