Package org.openmrs.obs

Examples of org.openmrs.obs.ComplexData


      } else if (existingObs != null && session.getContext().getMode() == Mode.EDIT) {
        // For complex obs: if value is to be retained, get the value from existingObs
      if (valueWidget instanceof UploadWidget && value == null) {
        if (!((UploadWidget) valueWidget).shouldDelete(session.getContext(), submission)) {
          value = new ComplexData(existingObs.getValueComplex(), null);
        }
      }
             
      // call this regardless of whether the new value is null -- the
      // modifyObs method is smart
View Full Code Here


        e.setLocation(Context.getLocationService().getLocation(2));
        e.setProvider(Context.getPersonService().getPerson(502));
       
        Obs obs = new Obs();
        obs.setConcept(Context.getConceptService().getConcept(6100));
        obs.setComplexData(new ComplexData("complex_obs_image_test.gif", image));
        obs.setValueComplex("gif image |complex_obs_image_test.gif");
       
        e.addObs(obs);
        Context.getEncounterService().saveEncounter(e);
        return e;
View Full Code Here

  public static ComplexData convertToComplexData(HttpServletRequest request, String name) {
    MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) request;
    MultipartFile file = mRequest.getFile(name);
    if (file != null && file.getSize() > 0) {
      try {
        return new ComplexData(file.getOriginalFilename(), file.getInputStream());
      }
      catch (IOException e) {
        throw new IllegalArgumentException(e);
      }
    } else {
View Full Code Here

 
  @Test
  @Verifies(value="shouldSetTheValueComplexOfObsIfConceptIsComplex",method="createObs(Concept concept, Object value, Date datetime, String accessionNumber)")
  public void createObs_shouldSetTheValueComplexOfObsIfConceptIsComplex(){
   
    ComplexData complexData=new ComplexData("test", null);
    Concept c=new Concept();
    ConceptDatatype cd=new ConceptDatatype();
    cd.setUuid(HtmlFormEntryConstants.COMPLEX_UUID);
    c.setDatatype(cd);
    Obs o=HtmlFormEntryUtil.createObs(c, complexData, null, null);
      Assert.assertEquals(o.getValueComplex(),complexData.getTitle());
   
  }
View Full Code Here

  /**
   * @see org.openmrs.obs.handler.ImageHandler#saveObs(org.openmrs.Obs)
   */
  @Override
  public Obs saveObs(Obs obs) {
    ComplexData c = obs.getComplexData();
    AnnotatedImage ai = (AnnotatedImage) c.getData();
    obs.setComplexData(new ComplexData(c.getTitle(), ai.getImage()));
    Obs o = super.saveObs(obs);
    for (ImageAnnotation annotation : ai.getAnnotations())
      saveAnnotation(o, annotation, annotation.getStatus() == Status.DELETE);
    log.info("drawing:saving complexObs:" + o);
   
View Full Code Here

    }
    AnnotatedImage aimage = loadMetadata(obs, new AnnotatedImage(img));
   
    String url = "/" + WebConstants.WEBAPP_NAME + "/module/drawing/manage.form?obsId=" + obs.getId();
    if (view == WebConstants.HYPERLINK_VIEW) {
      obs.setComplexData(new ComplexData(imageFile.getName(), url));
    } else if (view == WebConstants.HTML_VIEW) {
      String html = "<a href=\"" + url + "\">" + imageFile.getName() + "</a>";
      obs.setComplexData(new ComplexData(imageFile.getName(), html));
    } else {
      obs.setComplexData(new ComplexData(imageFile.getName(), aimage));
    }
    return obs;
  }
View Full Code Here

    try {
      AnnotatedImage ai = new AnnotatedImage(DrawingUtil.base64ToImage(encodedImage));
      ai.setAnnotations(DrawingUtil.getAnnotations(submission, id));
      if (session.getContext().getMode() == Mode.EDIT && existingObs != null)
        session.getSubmissionActions().modifyObs(existingObs, questionConcept,
            new ComplexData(existingObs.getComplexData().getTitle(), ai), null, null);
      else
        session.getSubmissionActions().createObs(questionConcept, new ComplexData("drawingObs.png", ai), null, null);
     
    }
    catch (Exception e) {
      log.error("cannot create obs :" + e.getMessage(), e);
      throw new RuntimeException("Unable to save complex Observation!");
View Full Code Here

      Date date = StringUtils.isBlank(dateString) ? new Date() : Context.getDateFormat().parse(dateString);
      Obs o = new Obs(patient, concept, date, null);
      o.setEncounter(encounter);
      AnnotatedImage ai = new AnnotatedImage(DrawingUtil.base64ToImage(encodedImage));
      ai.setAnnotations(DrawingUtil.getAnnotations(request, ""));
      o.setComplexData(new ComplexData("drawingObs.png", ai));
      Errors obsErrors = new BindException(o, "obs");
      ValidationUtils.invokeValidator(new ObsValidator(), o, obsErrors);
      if (!obsErrors.hasErrors()) {
        Context.getObsService().saveObs(o, "saving obs");
        request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "drawing.saved");
View Full Code Here

      request.getSession().setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "drawing.save.error");
    }
    AnnotatedImage ai = (AnnotatedImage) obs.getComplexData().getData();
    ai.setImage(DrawingUtil.base64ToImage(encodedImage));
    ai.setAnnotations(DrawingUtil.getAnnotations(request, ""));
    obs.setComplexData(new ComplexData(obs.getComplexData().getTitle(), ai));
    Context.getObsService().saveObs(obs, "saving obs");
   
    return "redirect:/module/drawing/manage.form?obsId=" + obs.getId();
  }
View Full Code Here

TOP

Related Classes of org.openmrs.obs.ComplexData

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.