Package org.openmrs.module.webservices.rest

Examples of org.openmrs.module.webservices.rest.SimpleObject


   * Test of getAllDrugInfoByUuid method, of class DrugInfoController.
   */
  @Test
  public void testGetAllDrugInfoByUuid() throws Exception {
    String result = controller.getAllDrugInfoByUuid(getUuid(), request);
    SimpleObject drugGroup = SimpleObject.parseJson(result);
    Assert.assertNotNull(result);
    Assert.assertEquals(getUuid(), drugGroup.get("uuid"));
    Assert.assertEquals("TestDrugInfo1", drugGroup.get("name"));
    Assert.assertNull(drugGroup.get("auditInfo"));
  }
View Full Code Here


   * Test of getAllDrugInfoByUuidFull method, of class DrugInfoController.
   */
  @Test
  public void testGetAllDrugInfoByUuidFull() throws Exception {
    String result = controller.getAllDrugInfoByUuidFull(getUuid(), "full", request);
    SimpleObject drugGroup = SimpleObject.parseJson(result);
    Assert.assertNotNull(result);
    Assert.assertEquals(getUuid(), drugGroup.get("uuid"));
    Assert.assertEquals("TestDrugInfo1", drugGroup.get("name"));
    Assert.assertNotNull(drugGroup.get("auditInfo"));
  }
View Full Code Here

    throw new ResponseException(
                                "User type is unsupported") {};
  }
 
  private Object getUserAsSimpleObject(User u) {
    SimpleObject obj = new SimpleObject();
    obj.add("uuid", u.getUuid());
    obj.add("display", u.getDisplayString());
    return obj;
  }
View Full Code Here

   */
  @Test
  public void testCreateNewRelationship() throws Exception {
    int before = service.getAllRelationships(true).size();
    String json = "{\"fromPerson\":\"a7e04421-525f-442f-8138-05b619d16def\",\"toPerson\":\"5946f880-b197-400b-9caa-a3c661d23041\",\"relationshipType\":\"Doctor/Patient\"}";
    SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class);
    Object drug = controller.createNewRelationship(post, request, response);
    Assert.assertEquals(before + 1, service.getAllRelationships(true).size());
  }
View Full Code Here

   */
  @Test
  public void updateDrugGroup_shouldSaveANewDrugGroup() throws Exception {
    int before = service.getAllDrugGroup(false).size();
    String json = "{ \"name\":\"Test DrugGroup\",\"description\":\"Test Drug Group\"}";
    SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class);
    controller.updateDrugGroup(getUuid(), post, request, response);
    Assert.assertEquals(before, service.getAllDrugGroup(false).size());
    String result = controller.getAllDrugGroupByUuid(getUuid(), request);
    SimpleObject updatedDrugGroup = SimpleObject.parseJson(result);
    Util.log("Updated Drug Group", updatedDrugGroup);
    Assert.assertEquals(getUuid(), updatedDrugGroup.get("uuid"));
    Assert.assertEquals("Test DrugGroup", updatedDrugGroup.get("name"));
  }
View Full Code Here

   */
  @Test
  public void createNewDrugGroup_shouldSaveANewDrugGroup() throws Exception {
    int before = service.getAllDrugGroup(false).size();
    String json = "{ \"name\":\"Test DrugGroup\",\"description\":\"Test Drug Group\"}";
    SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class);
    Object drugGroup = controller.createNewDrugGroup(post, request, response);
    Util.log("Created Patient List", drugGroup);
    Assert.assertEquals(before + 1, service.getAllDrugGroup(false).size());
  }
View Full Code Here

   * @verifies get the full representation of a patient list by its uuid
   */
  @Test
  public void getDrugGroupByUuidFull_shouldGetAFullRepresentationOfADrugGroup() throws Exception {
    String result = controller.getAllDrugGroupByUuidFull(getUuid(), "full", request);
    SimpleObject drugGroup = SimpleObject.parseJson(result);
    Assert.assertNotNull(result);
    Util.log("DrugGroup fetched (full)", result);
    Assert.assertEquals("68547121-1b70-465d-99ee-c9dfd95e7d30", drugGroup.get("uuid"));
    Assert.assertEquals("TestDrugGroup1", drugGroup.get("name"));
    Assert.assertNotNull(drugGroup.get("auditInfo"));
  }
View Full Code Here

   * @verifies get a default representation of a patient list by its uuid
   */
  @Test
  public void getDrugGroupByUuid_shouldGetADefaultRepresentationOfADrugGroup() throws Exception {
    String result = controller.getAllDrugGroupByUuid(getUuid(), request);
    SimpleObject drugGroup = SimpleObject.parseJson(result);
    Assert.assertNotNull(result);
    Util.log("DrugGroup fetched (default)", result);
    Assert.assertEquals("68547121-1b70-465d-99ee-c9dfd95e7d30", drugGroup.get("uuid"));
    Assert.assertEquals("TestDrugGroup1", drugGroup.get("name"));
    Assert.assertNull(drugGroup.get("auditInfo"));
  }
View Full Code Here

          throws ResponseException {
    initRaxaAlertController();
    RaxaAlert raxaAlert = setPostFields(new RaxaAlert(), post);
    raxaAlert.setSeen(Boolean.FALSE);
    RaxaAlert created = service.saveRaxaAlert(raxaAlert);
    SimpleObject obj = new SimpleObject();
    obj.add("uuid", created.getUuid());
    obj.add("name", created.getName());
    obj.add("description", created.getDescription());
    return RestUtil.created(response, obj);
  }
View Full Code Here

   *
   * @param rAlert
   * @return SimpleObject the representation of Raxa Alert
   */
  private SimpleObject getFieldsFromRaxaAlert(RaxaAlert rAlert) {
    SimpleObject obj = new SimpleObject();
    obj.add("uuid", rAlert.getUuid());
    obj.add("name", rAlert.getName());
    obj.add("description", rAlert.getDescription());
    SimpleObject pRecipientObj = new SimpleObject();
    Provider pRecipient = rAlert.getProviderRecipient();
    if (pRecipient != null) {
      pRecipientObj.add("uuid", pRecipient.getUuid());
      pRecipientObj.add("display", pRecipient.getName());
    }
    obj.add("providerRecipient", pRecipientObj);
    SimpleObject pSentObj = new SimpleObject();
    Provider pSent = rAlert.getProviderSent();
    if (pSent != null) {
      pSentObj.add("uuid", pSent.getUuid());
      pSentObj.add("display", pSent.getName());
    }
    obj.add("providerSent", pSentObj);
    SimpleObject toLocationObj = new SimpleObject();
    Location toLocation = rAlert.getToLocation();
    if (toLocation != null) {
      toLocationObj.add("uuid", toLocation.getUuid());
      toLocationObj.add("display", toLocation.getName());
    }
    obj.add("toLocation", toLocationObj);
    SimpleObject fromLocationObj = new SimpleObject();
    Location fromLocation = rAlert.getFromLocation();
    if (fromLocation != null) {
      fromLocationObj.add("uuid", fromLocation.getUuid());
      fromLocationObj.add("display", fromLocation.getName());
    }
    obj.add("fromLocation", fromLocationObj);
    obj.add("alertType", rAlert.getAlertType());
    obj.add("defaultTask", rAlert.getDefaultTask());
    obj.add("seen", rAlert.getSeen());
View Full Code Here

TOP

Related Classes of org.openmrs.module.webservices.rest.SimpleObject

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.