Loading a form on Kenya EMR patient view

2 views
Skip to first unread message

Timothy Tuti

unread,
Mar 13, 2013, 6:41:25 AM3/13/13
to d...@openmrs.org
I keep getting this error:

org.openmrs.ui.framework.ViewException: In view 'patientSummary', could not find property 'NEWBORN_DETAILS_FORM_UUID'

The code segment on the patientSummary.gsp is as follows:

${ ui.includeFragment("uilibrary", "widget/button", [
            iconProvider: "paediatrics",
            icon: "forms/baby.png",
            label: "Newborn Details",
            href: ui.pageLink("paediatrics", "editChildDetailsHtmlForm", [
                patientId: patient.id,
                formUuid: MetadataConstants.NEWBORN_DETAILS_FORM_UUID,
                returnUrl: ui.thisUrl()
            ])
    ]) }


I have defined the NEWBORN_DETAILS_FORM_UUID in a MetadataConstants class and it references a form in the OpenMRS installation.

the code segment from editChildDetailsHtmlForm Fragment Class:

public String controller(@RequestParam("patientId") Patient patient,
                             @RequestParam("formUuid") String formUuid,
                             @RequestParam("returnUrl") String returnUrl,
                             PageModel model) {

            Form form = Context.getFormService().getFormByUuid(formUuid);
            if (form == null) {
                throw new IllegalArgumentException("Cannot find form with uuid = " + formUuid);
            }

            StringBuilder sb = new StringBuilder("redirect:" + PaediatricCareConstants.MODULE_ID + "/");

            List<Encounter> encounters = Context.getEncounterService().getEncounters(patient, null, null, null, Collections.singleton(form), null, null, null, null, false);
            if (encounters.size() == 0) {
                sb.append("enterHtmlForm.page?formUuid=" + formUuid);
            } else {
                // in case there are more than one, we pick the last one
                Encounter encounter = encounters.get(encounters.size() - 1);
                sb.append("editHtmlForm.page?encounterId=" + encounter.getEncounterId());
            }

            sb.append("&patientId=" + patient.getId());
            sb.append("&returnUrl=" + java.net.URLEncoder.encode(returnUrl));
            return sb.toString();
        }

I have already registered the form using FormManager.registerForm class and its frequency is ONCE

What might be the cause of this error?

Rowan Seymour

unread,
Mar 13, 2013, 7:59:49 AM3/13/13
to d...@openmrs.org
( It's probably better to use the Kenya EMR developers mailing list for questions relating specifically to the Kenya EMR )

I'd guess this is due to MetadataConstants not being accessible in your GSPs. The MetadataConstants class in Kenya EMR is accessible in our GSPs because we use a configurator class to "inject" it into all uiframework managed pages and fragments...


You could have your own configurator to make your own class of constants accessible in your GSPs.

Btw I made a lot of changes yesterday to extract all the re-usable UI components into a separate library module (Kenya EMR UI) and updated the example add-on module accordingly. This should make things easier for you as you can rely on things in the UI module not changing so often. We hadn't planned on the Kenya EMR module being something that would be built on by other groups, so it's been a bit of scramble over the last week to get it into a state where someone can easily do so without making their own fork. But I think we're there now. 

The Kenya EMR UI module completely replaces uilibrary for this project so in your development environment you should replace the uilibrary omod with the latest Kenya UI omod, and then you'll need to update your widgets accordingly, e.g.

${ ui.includeFragment("uilibrary", "widget/button", [ .. ]) ... becomes ... ${ ui.includeFragment("kenyaui", "widget/button", [ .. ])

-Rowan


--
OpenMRS Developers: http://go.openmrs.org/dev
Post: d...@openmrs.org
Unsubscribe: dev+uns...@openmrs.org
Manage your OpenMRS subscriptions at https://id.openmrs.org/
 
 



--
Rowan Seymour
tel: +250 783835665

Timothy Tuti

unread,
Mar 13, 2013, 8:02:47 AM3/13/13
to d...@openmrs.org
I noted that thread. tracking the progress. I will probably shift to the new separate UI library end of week.



Timothy Tuti,
Senior Principal Partner,
Hazelband Consulting Group
Tel : (+254)(0)736262966

www.hazelband.com

Timothy Tuti

unread,
Mar 13, 2013, 9:04:47 AM3/13/13
to d...@openmrs.org
FYI your suggestion worked. Also worth noting that if injection is used, it is required that your class with the metadata constants does not hold the same name as that of KenyaEMR module i.e MetadataConstants. Thank you for the help.

Tuti.
Reply all
Reply to author
Forward
0 new messages