Examples of Obs


Examples of org.openmrs.Obs

  @Override
  public String generateHtml(FormEntryContext context) {
    StringBuilder sb = new StringBuilder();
   
    if (context.getMode().equals(Mode.VIEW) && existingObs != null) {
      Obs complexObs = Context.getObsService().getComplexObs(existingObs.getId(), "");
      AnnotatedImage ai = (AnnotatedImage) existingObs.getComplexData().getData();
      String encodedImage = null;
      try {
        encodedImage = DrawingUtil.imageToBase64(ai.getImage());
      }
      catch (IOException e) {
        log.error("unable to encode image to Base64 format", e);
      }
      sb.append("<link rel='stylesheet' media='screen' type='text/css' href='/" + WebConstants.WEBAPP_NAME
              + "/moduleResources/drawing/drawingHtmlForm.css' />");
      sb.append("<script type='text/javascript'>var ancount"
              + id
              + "=0;    var redDot ='/openmrstru/moduleResources/drawing/red-dot.png';var close = '/openmrstru/moduleResources/drawing/close.gif';function createMarker"
              + id
              + "(identification, x, y, text, stat) {var annotationId = \"marker"
              + id
              + "\" + ancount"
              + id
              + ";ancount"
              + id
              + "++;var annDivData = \"<img src='\" + close + \"' style='float:right' onClick='$j(this).parent().parent().fadeOut(500)'/><span style='background-color:white'>\" + text + \"</span></br>\";var v = '<div class=\"container\"><div style=\"position:absolute;z-index:5;display:none\"><div id=\"' + annotationId + '_data\" class=\"divContainerDown\">' + annDivData + '</div><div class=\"calloutDown\"><div class=\"calloutDown2\"></div></div></div>';$j('#canvasDiv"
              + id
              + "').append(v + '<img id=\"' + annotationId + '\" src=\"' + redDot + '\" style=\"top:' + y + 'px;left:' + x + 'px;position:absolute;z-index:4\"/></div>');$j('#' + annotationId).click(function(event) {$j('#' + annotationId + '_data').parent().css('top', event.pageY-$j('#canvasDiv"
              + id
              + "').offset().top - $j('#' + annotationId + '_data').parent().height());$j('#' + annotationId + '_data').parent().css('left', event.pageX-$j('#canvasDiv"
              + id
              + "').offset().left - $j('#' + annotationId + '_data').parent().width() / 8 - 5);$j('#' + annotationId + '_data').parent().show();});}");
     
      sb.append("$j(document).ready(function(){");
      for (ImageAnnotation annotation : ai.getAnnotations())
        sb.append("createMarker" + id + "(" + annotation.getId() + "," + annotation.getLocation().getX() + ","
                + annotation.getLocation().getY() + ",'" + annotation.getText() + "','" + annotation.getStatus()
                + "');");
      sb.append("})</script>");
      sb.append("<h4>" + complexObs.getConcept().getName(Context.getLocale()).getName() + "</h4>");
      sb.append("<div id='canvasDiv" + id + "' style='position:relative'><img  src='" + encodedImage + "'></div>");
     
      //sb.append(complexData.getData());
    } else if (context.getMode() == Mode.EDIT || context.getMode() == Mode.ENTER) {
      sb.append("<link rel='stylesheet' type='text/css' href='/" + WebConstants.WEBAPP_NAME
View Full Code Here

Examples of org.openmrs.Obs

  @RequestMapping(value = "/module/drawing/manage", method = RequestMethod.GET)
  public void manage(ModelMap model, HttpServletRequest request) {
   
    if (StringUtils.isNotBlank(request.getParameter("obsId"))) {
      int obsId = Integer.parseInt(request.getParameter("obsId"));
      Obs obs = Context.getObsService().getComplexObs(obsId, "");
      if (obs == null || !obs.getConcept().isComplex()) {
        log.error("obs is not complex ");
      } else {
        AnnotatedImage ai = (AnnotatedImage) obs.getComplexData().getData();
        String encodedImage;
        try {
          encodedImage = DrawingUtil.imageToBase64(ai.getImage());
          model.addAttribute("encodedImage", encodedImage);
        }
        catch (IOException e) {
          log.error("Error generated", e);
        }
        model.addAttribute("annotations", ai.getAnnotations());
        model.addAttribute("obsId", obs.getId());
       
      }
    }
  }
View Full Code Here

Examples of org.openmrs.Obs

    if (StringUtils.isBlank(redirectUrl))
      redirectUrl = "/patientDashboard.form?patientId=" + patient.getPatientId();
   
    try {
      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

Examples of org.openmrs.Obs

  @RequestMapping(value = "/module/drawing/updateDrawing", method = RequestMethod.POST)
  public String updateDrawing(@RequestParam(value = "encodedImage", required = true) String encodedImage,
                              @RequestParam(value = "obsId", required = true) String obsId, HttpServletRequest request)
      throws IOException {
   
    Obs obs = Context.getObsService().getComplexObs(Integer.parseInt(obsId.trim()), "");
    if (obs == null) {
      log.error("obs cannot be null");
      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
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.