I am trying to create a quality improvement program using a MySQL database of my patients and their surgical procedures and subsequent outcomes. I can create a nice datatable using Primefaces with the lazyDataModel. My first problem is that I cannot use a computed number for the total number of rows.
Code: Select all
public class PatientsController {
private Patients selected;
@EJB
private PatientsFacade ejbFacade;
private int selectedItemIndex;
private LazyDataModel<Patients> lazyModel;
private Patients item;
private List<Patients> itemList;
public PatientsController() {
lazyModel = new LazyDataModel<Patients>(10000) {
@Override
public List<Patients> fetchLazyData(int first, int pageSize) {
System.out.println("**** Loading the lazy data **** "
+ first + " " + pageSize);
return ejbFacade.findRange(first, pageSize);
}
};
}
getters and setters . . . . .
Code: Select all
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ListPatientsTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form styleClass="jsfcrud_list_form">
<br />
<h:commandLink value="#{bundle.ListPatientsIndexLink}" action="/index" immediate="true" />
<br />
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:outputText value="rendered text" rendered="#{patientsController.lazyModel.rowCount > 0}" />
<h:panelGroup rendered="true">
<p:dataTable id="ptTable" var="pt" value="#{patientsController.lazyModel}" paginator="true"
dynamic="true" lazy="true" rows="20" rowsPerPageTemplate="20, 50, 100"
selectionMode="single" selection="#{patientsController.selected}"
update="display" onselectComplete="ptDialog.show()" >
<p:column sortBy="#{pt.patientFileID}" filterBy="#{pt.patientFileID}">
<f:facet name="header">
<h:outputText value="Patient File ID" />
</f:facet>
<h:outputText value="#{pt.patientFileID}" />
</p:column>
As you will notice, I have filterable and sortable columns, but these don't work currently.
I also have set up a p:dialog so that when I select a patient, it will show me their brief demographics (Name, DOB, DOD) and a datatable listing their surgeries. Problem: I can select patient A and see patient A's surgeries. When I select Patient B (on same or different page of data), I still see Patient's A surgeries, even though I'm seeing patient B's demographics.
Code: Select all
<p:dialog header="Patient Detail" widgetVar="ptDialog"
modal="true" fixedCenter="true" draggable="false" width="550px">
<h:panelGrid id="display" columns="2">
<h:outputText value="Patient File ID:" />
<h:outputText value="#{patientsController.selected.patientFileID}" style="font-weight:bold"/>
<h:outputText value="Full Name:" />
<h:outputText value="#{patientsController.selected.fullname}" style="font-weight:bold"/>
<h:outputText value="DOB:" />
<h:outputText value="#{patientsController.selected.dob}" style="font-weight:bold" >
<f:convertDateTime dateStyle="default" />
</h:outputText>
<h:outputText value="DOD:" />
<h:outputText value="#{patientsController.selected.dod}" style="font-weight:bold"
rendered="#{patientsController.selected.dod > patientsController.selected.dob}">
<f:convertDateTime dateStyle="default"/>
</h:outputText>
</h:panelGrid>
<h:panelGrid id="surgDisplay" columns="2" rendered="true">
<p:dataTable id="surgTable" var="surg" value="#{patientsController.selected.surgeryList}"
dynamic="true" lazy="true" rows="5">
<p:column sortBy="#{surg.invoiceCPTStartSerDate}">
<f:facet name="header">
<h:outputText value="Surgery Date"/>
</f:facet>
<h:outputText value="#{surg.invoiceCPTStartSerDate}" >
<f:convertDateTime dateStyle="default"/>
</h:outputText>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="POS"/>
</f:facet>
<h:outputText value="#{surg.pos}"/>
</p:column>
</p:dataTable>
</h:panelGrid>
</p:dialog>
Thanks in advance.