Downloads Documentation Community Contribute Demo

How add a tab in patient dashboard

General discussion about OpenMRS that may not apply to any of the specific forums

Moderators: burke, paul, ben, ChrisS

How add a tab in patient dashboard

Postby mattew80 on Nov Tue 20, 2007 11:56 am

Ciao,

I want add a new tab in the patient dashboard (over Overview, Regiments, Encounters, Demographics, Graphs).
How can I do?

Best Regards and thank in advance,
Matteo
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am

Re: How add a tab in patient dashboard

Postby ben on Nov Tue 20, 2007 4:59 pm

This is done with an extension point in a module.

You can see an example in the formentry module:
Define the extension class and which point its extending:
http://dev.openmrs.org/browser/openmrs- ... ig.xml#L39
and define the java that does the work on the extension point:
http://dev.openmrs.org/browser/openmrs- ... abExt.java
ben
OpenMRS Team Member
 
Posts: 574
Joined: Aug Mon 28, 2006 8:54 am
Location: Indianapolis

Re: How add a tab in patient dashboard

Postby mattew80 on Nov Fri 23, 2007 7:16 am

Ciao,

In the first place thanks for reply.
I have installed successfully the OpenMRS for developer, I have read the "Module" article and now I'm reading the "Creating Your First OpenMRS Module" article.
I have check-out the basic module and edit it a little bit (name, author, etc.) but when I execute ant build command the DOS-Shell gimme an error:
Code: Select all
BUILD FAILED
Target "build" does not exist in the project "BasicModule".

Also ant compile and ant dist gimme the same error :(

What can I do?

Best Regards and thanks in advance
Matteo
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am

Re: How add a tab in patient dashboard

Postby mattew80 on Nov Fri 23, 2007 11:30 am

Auto reply :D

NOT ant build but ant package-module (or ant -buildfile build.xml)
However the ant version of Eclipse 3.3.0 is not working with OpenMRS modules, gimme the following error
Code: Select all
error starting modern compiler


I must use my shell version.
I will try Eclipse 3.3.2 ;)
Last edited by mattew80 on Nov Fri 23, 2007 12:24 pm, edited 1 time in total.
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am

Re: How add a tab in patient dashboard

Postby ben on Nov Fri 23, 2007 12:02 pm

Ant building should work within eclipse...so you must have some settings that are effecting it. Look in your eclipse preferences for the compiler settings. Try setting it to java 1.5 instead of 1.6.
ben
OpenMRS Team Member
 
Posts: 574
Joined: Aug Mon 28, 2006 8:54 am
Location: Indianapolis

Re: How add a tab in patient dashboard

Postby mattew80 on Nov Wed 28, 2007 8:13 am

I have deployed the basicModule and customized it exampleModule.
I have add the follow code in Referenced Libreries --> metadata --> config.xml
Code: Select all
<extension>
      <point>org.openmrs.patientDashboardTab</point>
      <class>@MODULE_PACKAGE@.extension.html.ExamplePatientDashboardTab</class>
</extension>


I have add the follow code in src --> org.openmrs.module.examplemodule.exention.html --> ExamplePatientDashboardTab.java
Code: Select all
package org.openmrs.module.examplemodule.extension.html;

import org.openmrs.module.Extension;
import org.openmrs.module.web.extension.PatientDashboardTabExt;

public class ExamplePatientDashboardTab extends PatientDashboardTabExt {

   public Extension.MEDIA_TYPE getMediaType() {
      return Extension.MEDIA_TYPE.html;
   }
   
   @Override
   public String getPortletUrl() {
      return "patientExample";
   }

   @Override
   public String getRequiredPrivilege() {
      return "Patient Dashboard - View Example Section";
   }

   @Override
   public String getTabId() {
      return "PatientExample";
   }

   @Override
   public String getTabName() {
      return "Example";
   }
   
}


Now I see the tab "Example" in the patientDashboad :)
For see a simple page with a javascript, for example
Code: Select all
<html>
<body>
<script language=javascript>
//says the language is javascript

document.write("Hello World!"); //prints Hello World!

//stop JavaScript Code
</script>
</body>
</html>

How can I do? I suppose that I must edit the file web --> module --> portlet --> PatientExample.jsp but I don't understand :cry:

Someone can help me, please.
Thanks in advance,
Matteo
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am

Re: How add a tab in patient dashboard

Postby ben on Nov Wed 28, 2007 9:17 am

Close. You said to use the portlet named "patientExample".

public String getPortletUrl() {
return "patientExample";
}


This corresponds to a patientExample.jsp portlet in that web/module/portlet folder -- case is important.

Using the formentry module as an example again:
The extension code:
http://dev.openmrs.org/browser/openmrs- ... abExt.java
The portlet:
http://dev.openmrs.org/browser/openmrs- ... tForms.jsp
ben
OpenMRS Team Member
 
Posts: 574
Joined: Aug Mon 28, 2006 8:54 am
Location: Indianapolis

Re: How add a tab in patient dashboard

Postby mattew80 on Nov Wed 28, 2007 9:49 am

Thanks for reply
It's mandatory use a portlet? I want only a simple html web page like this:
Code: Select all
<html>
<body>
<script language=javascript>
//says the language is javascript

document.write("Hello World!"); //prints Hello World!

//stop JavaScript Code
</script>
</body>
</html>
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am

Re: How add a tab in patient dashboard

Postby ben on Nov Wed 28, 2007 9:54 am

Yes, you must use portlet. However, in the openmrs world a portlet is just an snippet of html code that is included on some page. You can create the patientExample.jsp page with exactly that text to get the effect you want.

For verification, you can see how the extension point is used via the code on the patientDashboard.jsp page:
http://dev.openmrs.org/browser/openmrs/ ... m.jsp#L147
ben
OpenMRS Team Member
 
Posts: 574
Joined: Aug Mon 28, 2006 8:54 am
Location: Indianapolis

Re: How add a tab in patient dashboard

Postby mattew80 on Nov Thu 29, 2007 11:30 am

Work...cool! :mrgreen:
Now there's a problem :cry:
I want insert into patientExample.jsp a simple applet.
I create a .class from this java file
Code: Select all
import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {
    public void paint(Graphics g) {
        g.drawString("Hello world!", 50, 25);
    }
}


and insert the applet into patientExample.jsp in this way
Code: Select all
[...]
<jsp:plugin type="applet" codebase="." code="HelloWorld.class">
</jsp:plugin>
[...]

The file class is in the same directory of patientExample.jsp
So:
Code: Select all
web
|_module
   |_portlets
       |_HelloWorld.class
       |_patientExample.jsp


But the applet don't work. I think that the problem is that the browser don't see this folder, I suppose that I must copy the HelloWorld.class file in another folder....where?
I thinks that insert an applet is more important cause the Web is full of interesting applet :)

Thanks in advance and sorry for disturb,
Matteo
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am

Re: How add a tab in patient dashboard

Postby ben on Nov Thu 29, 2007 11:35 am

Hmm, unfortunately I don't have any experience with applets. Do you need to reference the full path to the .class file? If you put it in the portlets folder, you could see it via /openmrs/module/yourmoduleid/portlets/helloWorld.class

OR, if the .class file just needs to be in the classpath, you can drop that .class file into the "lib" folder in your module. It will then be copied over during module load in openmrs.

OR, you might need to just drop the .class file into the jar file. Do you have the java file for it? What is the package of the .class file?
ben
OpenMRS Team Member
 
Posts: 574
Joined: Aug Mon 28, 2006 8:54 am
Location: Indianapolis

Re: How add a tab in patient dashboard

Postby mattew80 on Dec Mon 03, 2007 8:22 am

Auto-reply :)

I have insert my .class file in /openmrs folder and go ...but I must Improve it :?

Thanks ben ...you are a saint :mrgreen:
mattew80
OpenMRS Forum Member
 
Posts: 26
Joined: Nov Wed 14, 2007 8:44 am


Return to General Discussion

Who is online

Users browsing this forum: Ask Jeeves [Bot] and 1 guest

cron