Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5132

Show
Ignore:
Timestamp:
08/02/08 03:24:03 (5 months ago)
Author:
mhdiallo
Message:

Person Portrait Module - Added a jsp file (upload.jsp) for uploading an image on the browser. Also added jquery-1.2.6.js library to use jquery instead of javascript.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/personportrait/.classpath

    r5075 r5132  
    99        <classpathentry kind="lib" path="lib-common/servlet-api.jar"/> 
    1010        <classpathentry kind="lib" path="lib-common/spring-2.0.jar"/> 
    11         <classpathentry kind="lib" path="lib-common/commons-fileupload-1.1.1.jar"/> 
    12         <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.3.0.12.4984.jar"/> 
    13         <classpathentry kind="lib" path="lib-common/openmrs-api-1.3.0.12.4984.jar"/> 
    14         <classpathentry kind="lib" path="lib-common/portlet-api-1.0.jar"/> 
    15         <classpathentry kind="lib" path="lib-common/dwr-1.1.3mod.jar"/> 
    16         <classpathentry kind="lib" path="lib-common/taglibs-response-1.1.jar"/> 
    17         <classpathentry kind="lib" path="lib-common/taglibs-request-1.1.jar"/> 
    18         <classpathentry kind="lib" path="lib-common/taglibs-standard-1.1.jar"/> 
    1911        <classpathentry kind="lib" path="lib-common/jsp-api.jar"/> 
    20         <classpathentry kind="lib" path="lib-common/taglibs-page-1.1.jar"/> 
     12        <classpathentry kind="lib" path="lib-common/openmrs-api-1.3.0.12.5080.jar"/> 
     13        <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.3.0.12.5080.jar"/> 
     14        <classpathentry kind="lib" path="lib-common/simple-xml-1.7.2.jar"/> 
    2115        <classpathentry kind="output" path="build"/> 
    2216</classpath> 
  • openmrs-modules/personportrait/web/module/portlets/personPortraitDashboardPortlet.jsp

    r5081 r5132  
    1 <%@ include file="/WEB-INF/template/include.jsp"%> 
     1<%@ include file="/WEB-INF/template/include.jsp" %> 
    22 
    33<script src='<%= request.getContextPath() %>/dwr/interface/PersonPortraitDWRService.js'></script> 
     
    55<html> 
    66  <body> 
    7    
    8   <script type="text/javascript"> 
    9         function uploadPersonImage() { 
    10                 alert("Start Upload"); 
    11                 PersonPortraitDWRService.uploadImage(request); 
    12                 alert("End Upload"); 
    13         } 
    14   </script> 
    157 
     8        <script type="text/javascript"> 
     9                <%@ include file="jquery-1.2.6.js" %> 
     10                var $j = jQuery.noConflict(); 
     11                 
     12                var personPortrait; 
     13                var imageTypes=["bmp","gif","png","jpg","jpeg"]; 
     14                 
     15                $j.fn.copyImage = function(src, f){ 
     16                    return this.each(function(){ 
     17                        var img = new Image(); 
     18                        img.src = src; 
     19                        img.onload = f; 
     20                        this.appendChild(img); 
     21                    }); 
     22                } 
     23                 
     24                function uploadPersonImage() { 
     25                        var filePath = $j('#imageFile').val(); 
     26                         
     27                        // Check the file extension 
     28                        var extension=filePath.substring(filePath.lastIndexOf(".")+1,filePath.length).toLowerCase(); 
     29                        for (var i=0; i<imageTypes.length; i++)  
     30                                if (imageTypes[i]==extension) break; 
     31                         
     32                        alert("File Path: "+filePath); 
     33                        personPortrait= new Image(); 
     34                        if (i<imageTypes.length) { 
     35                                $j('#personPortrait.src').val(filePath); 
     36                         
     37                                PersonPortraitDWRService.uploadImage($j('#personPortrait').val()); 
     38                                alert('Complete'); 
     39                        } 
     40                        else { 
     41                                alert("The image is not valid.\n"+ 
     42                                "Please load an image with an extention of one of the following:\n\n"+ 
     43                                imageTypes.join(", ")); 
     44                                 
     45                                $j("#photo").copyImage("http://localhost:8080/openmrs/images/patient_M.gif",function(){ 
     46                              alert("The default image is loaded"); 
     47                                }); 
     48                        } 
     49                } 
     50        </script> 
     51 
     52  
    1653        <div id="personPortraitUploadBoxHeader" class="boxHeader${model.patientVariation}"> 
    1754                <spring:message code="personportrait.portrait.upload" /> 
     
    1956         
    2057        <div id="personPortraitUploadBox" class="box${model.patientVariation}"> 
     58                <br> 
    2159                <form name="uploadForm" action="" enctype="multipart/form-data" method="post"> 
    22                         <input type="file" name="imageFile"/> 
    23                         <input type="submit" value='<spring:message code="general.submit" />' onClick="uploadPersonImage()"> 
     60                        <input type="file" id="imageFile" name="imageFile"/> 
     61                        <input TYPE="button" name='Upload' value="Upload Portrait" onClick="uploadPersonImage();document.uploadForm.submit()"> 
    2462                </form> 
     63                <br> 
    2564        </div> 
    2665         
     
    3069         
    3170        <div id="personPortraitViewBox" class="box${model.patientVariation}"> 
    32                 <span style="color:#0000FF;">Patient Most Recent Portrait</span> 
    33                  
     71                <img alt="" id="photoField" src=""> 
     72        </div> 
     73        <div id="photo"> 
     74         
    3475        </div> 
    3576         
  • openmrs-modules/personportrait/web/src/org/openmrs/module/personportrait/web/controller/PersonPortraitFormController.java

    r5081 r5132  
    126126                                                         
    127127                                                        // Save the obs object 
    128                                                       Context.getObsService().createObs(obsImage); 
     128                                                //    Context.getObsService().createObs(obsImage); 
    129129                                                         
    130130                                                //      String msg = getMessageSourceAccessor().getMessage("Info", "ID="+dataImage.getTitle()); 
  • openmrs-modules/personportrait/web/src/org/openmrs/module/personportrait/web/dwr/PersonPortraitDWRService.java

    r5081 r5132  
    1414import org.openmrs.Location; 
    1515import org.openmrs.Obs; 
     16import org.openmrs.Patient; 
    1617import org.openmrs.api.PatientService; 
    1718import org.openmrs.api.context.Context; 
     
    2021import org.springframework.web.multipart.MultipartFile; 
    2122import org.springframework.web.multipart.MultipartHttpServletRequest; 
     23 
     24import com.sun.medialib.mlib.Image; 
    2225 
    2326public class PersonPortraitDWRService { 
     
    2932        } 
    3033         
    31         public void uploadImage(HttpServletRequest request) { 
     34        public void uploadImage(Image image) { 
    3235                log.info("Getting Person Image"); 
    3336                 
    34                 HttpSession httpSession = request.getSession(); 
     37                /* 
     38                 HttpSession httpSession = request.getSession(); 
    3539                 
    3640                if (Context.isAuthenticated()) { 
     
    6064                                                         
    6165                                                        PatientService ps = Context.getPatientService(); 
    62                                                 //      Patient patient = ps.getPatient(patientId); 
     66                                                //      Patient patient = ps.getPatient("patientId"); 
    6367                                                         
    6468                                                        String conceptName = Context.getAdministrationService().getGlobalProperty("personportrait.person_portrait_concept"); 
     
    8690                                                        Context.getObsService().createObs(obsImage); 
    8791                                                        Integer id = obsImage.getObsId(); 
    88                                                 //    httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ID="+id); 
     92                                                      httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ID="+id); 
    8993                                                         
    9094                                                        Obs obs = Context.getObsService().getObs(id); 
    91                                    //   httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, ""+obs.getDateCreated()); 
     95                                                       httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, ""+obs.getDateCreated()); 
    9296                                                 } 
    9397                                        } 
     
    99103                        } 
    100104                } 
     105                */ 
    101106        } 
    102107}