Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5425

Show
Ignore:
Timestamp:
09/02/08 14:01:15 (3 months ago)
Author:
shahid
Message:

patientnotes: Save notes as observations and did some clean up in code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/patientnotes/branches/example/metadata/config.xml

    r5362 r5425  
    77        <id>patientnotes</id> 
    88        <name>Patient Notes</name> 
    9         <version>1.0</version> 
     9        <version>0.1</version> 
    1010        <package>org.openmrs.module.patientnotes</package> 
    1111        <author>Mohammad Shahiduzzaman</author> 
     
    1919        <!-- /Base Module Properties --> 
    2020         
    21         <require_version>1.2.0.3400</require_version> 
     21        <require_version>1.3.0.0000</require_version> 
    2222         
    2323        <!-- Extensions --> 
  • openmrs-modules/patientnotes/branches/example/metadata/moduleApplicationContext.xml

    r5421 r5425  
    4242    <!-- /Controllers --> 
    4343 
     44<!-- 
    4445    <bean parent="serviceContext"> 
    4546        <property name="moduleService"> 
     
    6970        </property> 
    7071    </bean> 
     72--> 
    7173 
    7274</beans> 
  • openmrs-modules/patientnotes/branches/example/metadata/sqldiff.xml

    r5106 r5425  
    1919                <date>Jun 22nd 2008</date> 
    2020                <description> 
    21             Creating a table to hold a message for each patient                         
     21            <!--Creating a table to hold a message for each patient (experimental table)--> 
    2222                </description> 
    2323                <sql> 
    24 <!--            DROP TABLE patientnotes_note;--> 
    25  
     24<!-- 
    2625            CREATE TABLE IF NOT EXISTS `patientnotes_note` ( 
    2726              `patientnotes_note_id` int(10) NOT NULL auto_increment, 
     
    3433 
    3534            INSERT INTO patientnotes_note VALUES (1, 'a first note', 385); 
     35--> 
    3636        </sql> 
    3737        </diff> 
  • openmrs-modules/patientnotes/branches/example/web/module/portlets/notePortlet.jsp

    r5175 r5425  
    1313<div id="patientNotesBox" class="box${model.patientVariation}"> 
    1414    <c:forEach var="note" items="${model.notes}" varStatus="status"> 
    15         <p></p><u>Note ${status.count}:</u> ${note.text} 
    16         <a href=${pageContext.request.contextPath}/module/patientnotes/patientNote.form?patientId=${model.patient.patientId}&&noteId=${note.noteId}> 
     15        <p></p><u>Note ${status.count} (Create Date - ${note.dateCreated}):</u> <%--${note.text}--%>${note.valueText} 
     16<%--        <a href=${pageContext.request.contextPath}/module/patientnotes/patientNote.form?patientId=${model.patient.patientId}&&noteId=${note.noteId}>--%> 
     17        <a href=${pageContext.request.contextPath}/module/patientnotes/patientNote.form?patientId=${model.patient.patientId}&&obsId=${note.obsId}> 
    1718            <spring:message code="patientnotes.edit.note"/></a> 
    1819    </c:forEach> 
  • openmrs-modules/patientnotes/branches/example/web/src/net/fckeditor/connector/ConnectorServlet.java

    r5421 r5425  
    5050import org.slf4j.LoggerFactory; 
    5151import org.openmrs.util.OpenmrsUtil; 
     52import org.openmrs.api.context.Context; 
    5253 
    5354/** 
     
    130131 
    131132//                      String typePath = UtilsFile.constructServerSidePath(request, resourceType); 
    132 //            String typePath = "/usr/local/tomcat/webapps/openmrs/userfiles/image"; 
    133             String typePath = "patientnotes/userfiles/image"; 
    134 //            String typeDirPath = getServletContext().getRealPath(typePath); 
     133//          String typeDirPath = getServletContext().getRealPath(typePath); 
     134//          File typeDir = new File(typeDirPath); 
     135            String typePath = Context.getAdministrationService().getGlobalProperty("obs.complex_obs_dir"); 
     136            if(typePath == null) { 
     137                typePath = "patientnotes/userfiles/image"; 
     138            } 
     139 
    135140            File typeDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(typePath);             
    136 //            File typeDir = new File(typeDirPath); 
     141 
    137142                        UtilsFile.checkDirAndCreate(typeDir); 
    138143 
     
    231236//                      String typePath = UtilsFile.constructServerSidePath(request, resourceType); 
    232237//                      String typeDirPath = getServletContext().getRealPath(typePath); 
    233 // 
    234238//                      File typeDir = new File(typeDirPath); 
    235  
    236             String typePath = "patientnotes/userfiles/image";             
     239            String typePath = Context.getAdministrationService().getGlobalProperty("obs.complex_obs_dir"); 
     240            if(typePath == null) { 
     241                typePath = "patientnotes/userfiles/image"; 
     242            } 
    237243            File typeDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(typePath); 
    238244 
  • openmrs-modules/patientnotes/branches/example/web/src/org/openmrs/module/patientnotes/web/controller/NoteFormController.java

    r5175 r5425  
    1616import javax.servlet.http.HttpServletRequest; 
    1717import javax.servlet.http.HttpServletResponse; 
     18import javax.imageio.ImageIO; 
    1819 
    1920import org.apache.commons.logging.Log; 
     
    2627import org.openmrs.module.patientnotes.Notes; 
    2728import org.openmrs.module.patientnotes.NoteService; 
    28 import org.openmrs.Patient; 
     29import org.openmrs.module.patientnotes.util.NoteUtils; 
     30import org.openmrs.*; 
     31import org.openmrs.util.OpenmrsUtil; 
     32import org.openmrs.obs.ComplexData; 
    2933import org.openmrs.api.context.Context; 
     34 
     35import java.util.Date; 
     36import java.util.List; 
     37import java.awt.image.BufferedImage; 
     38import java.io.File; 
     39import java.io.IOException; 
    3040 
    3141/** 
     
    6474        //HttpSession httpSession = request.getSession(); 
    6575        Notes note = (Notes) object; 
     76 
     77//        Concept concept = Context.getConceptService().getConcept(Integer.valueOf(1353)); 
     78        Concept concept = Context.getConceptService().getConceptByName("PATIENT NOTES");         
     79        Location location = Context.getEncounterService() 
     80                                   .getLocation(Integer.valueOf(1)); 
     81 
     82        Obs obs; 
     83        if (note.getNoteId() == null || note.getNoteId() == 0) { 
     84            obs = new Obs(); 
     85            obs.setConcept(concept); 
     86            obs.setPerson(note.getPatient()); 
     87            obs.setCreator(Context.getAuthenticatedUser()); 
     88            obs.setDateCreated(new Date()); 
     89            obs.setObsDatetime(new Date()); 
     90            obs.setLocation(location); 
     91            obs.setVoided(false); 
     92            obs.setValueText(note.getText()); 
     93            Context.getObsService().saveObs(obs, null); 
     94        } else { 
     95            obs = Context.getObsService().getObs(note.getNoteId()); 
     96            obs.setValueText(note.getText()); 
     97                    Context.getObsService().saveObs(obs, "Updating existing note observation"); 
     98        } 
     99 
     100 
    66101        log.info("in NoteFormController: noteId: " + note.getNoteId() + ", patientId: " + note.getPatient().getPatientId() 
    67102                 + ", text: " + note.getText()); 
    68103 
    69         NoteService ns = ((NoteService) Context.getService(NoteService.class)); 
    70         ns.createNote(note); 
    71104        return new ModelAndView(new RedirectView(getSuccessView() + "?patientId=" + note.getPatient().getPatientId())); 
    72105    } 
     
    94127        // under the "commandName" tag 
    95128        int patientId = ServletRequestUtils.getIntParameter(request, "patientId", 0); 
    96         int noteId = ServletRequestUtils.getIntParameter(request, "noteId", 0); 
    97         log.info("in NoteFormController: noteId: " + noteId + ", patientId: " + patientId); 
     129//        int noteId = ServletRequestUtils.getIntParameter(request, "noteId", 0); 
     130        int obsId = ServletRequestUtils.getIntParameter(request, "obsId", 0); 
     131//        log.info("in NoteFormController: noteId: " + noteId + ", patientId: " + patientId); 
    98132        Notes note = new Notes(); 
     133/* 
    99134        if (noteId != 0) { 
    100135            NoteService ns = ((NoteService) Context.getService(NoteService.class)); 
     
    107142            } 
    108143        } 
     144*/ 
     145        if(obsId != 0){ 
     146            Obs obs = Context.getObsService().getObs(obsId); 
     147            note.setPatient(Context.getPatientService().getPatient(obs.getPersonId())); 
     148            note.setText(obs.getValueText()); 
     149            note.setNoteId(obsId); 
     150        } else { 
     151            if(patientId != 0) { 
     152                Patient patient = new Patient(); 
     153                patient.setPatientId(patientId); 
     154                note.setPatient(patient); 
     155            } 
     156        } 
     157 
    109158        log.info("in NoteFormController: noteId: " + note.getNoteId() + ", patientId: " + note.getPatient().getPatientId() 
    110159                 + ", text: " + note.getText()); 
    111160        return note; 
    112161    } 
    113  
    114  
    115  
    116162} 
  • openmrs-modules/patientnotes/branches/example/web/src/org/openmrs/module/patientnotes/web/controller/NotePortletController.java

    r5175 r5425  
    66import org.openmrs.module.patientnotes.Notes; 
    77import org.openmrs.Patient; 
     8import org.openmrs.Concept; 
     9import org.openmrs.Obs; 
     10import org.apache.commons.logging.Log; 
     11import org.apache.commons.logging.LogFactory; 
    812 
    913import javax.servlet.http.HttpServletRequest; 
     
    1822public class NotePortletController extends PortletController { 
    1923 
    20 //    private Log log = LogFactory.getLog(this.getClass()); 
     24    private Log log = LogFactory.getLog(NotePortletController.class); 
    2125    protected void populateModel(HttpServletRequest httpServletRequest, Map<String, Object> stringObjectMap) { 
    2226 
     27        log.debug("putting notes in model"); 
    2328        Patient p = (Patient) stringObjectMap.get("patient"); 
    24         NoteService ns = ((NoteService) Context.getService(NoteService.class)); 
     29//        Concept concept = Context.getConceptService().getConcept(Integer.valueOf(1353)); 
     30        Concept concept = Context.getConceptService().getConceptByName("PATIENT NOTES");         
     31        List<Obs> noteObs = Context.getObsService().getObservationsByPersonAndConcept(p, concept); 
     32 
     33//        NoteService ns = ((NoteService) Context.getService(NoteService.class)); 
    2534        try { 
    26             List<Notes> noteList = ns.getNoteByPatientId(p.getPatientId()); 
    27 //            stringObjectMap.put("note", note.getText()); 
    28             stringObjectMap.put("notes", noteList); 
     35//            List<Notes> noteList = ns.getNoteByPatientId(p.getPatientId()); 
     36//            stringObjectMap.put("notes", noteList); 
     37            stringObjectMap.put("notes", noteObs); 
    2938        } catch (Throwable e) { 
    3039            log.debug("exception in populateModel", e);