278002a26443bb254328af087a74572f2cdc45ea .../web/resource/localisation/messages.properties | 2 + .../web/workspace/customer/CustomerSummary.java | 18 +- .../customer/estimate/CustomerEstimateQuery.java | 11 +- .../workspace/patient/summary/PatientSummary.java | 24 +- .../web/workspace/summary/PartySummary.java | 346 +++++++++++---------- 5 files changed, 223 insertions(+), 178 deletions(-) diff --git a/openvpms-web-component/src/main/java/org/openvpms/web/resource/localisation/messages.properties b/openvpms-web-component/src/main/java/org/openvpms/web/resource/localisation/messages.properties index e72a6f2..9f67803 100644 --- a/openvpms-web-component/src/main/java/org/openvpms/web/resource/localisation/messages.properties +++ b/openvpms-web-component/src/main/java/org/openvpms/web/resource/localisation/messages.properties @@ -515,6 +515,7 @@ customer.account.effective Projected Amount: customer.alert.title Alerts customer.alert.accounttype Account Type: {0} customer.alert.notes Notes +customer.estimates Estimates Active # Customer information workspace @@ -634,6 +635,7 @@ patient.desexed Desexed patient.entire Entire patient.referralvet Referral Vet: patient.referralpractice Practice: +patient.estimates Estimates Active # Patient information workspace diff --git a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/CustomerSummary.java b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/CustomerSummary.java index ac6ce52..baf9393 100644 --- a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/CustomerSummary.java +++ b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/CustomerSummary.java @@ -16,6 +16,9 @@ package org.openvpms.web.workspace.customer; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; import nextapp.echo2.app.Button; import nextapp.echo2.app.Column; import nextapp.echo2.app.Component; @@ -51,15 +54,11 @@ import org.openvpms.web.echo.help.HelpContext; import org.openvpms.web.system.ServiceHelper; import org.openvpms.web.workspace.alert.Alert; import org.openvpms.web.workspace.alert.AlertSummary; +import org.openvpms.web.workspace.customer.estimate.CustomerEstimateQuery; import org.openvpms.web.workspace.customer.note.CustomerAlertQuery; import org.openvpms.web.workspace.summary.PartySummary; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; - - /** * Renders customer summary information. * @@ -156,6 +155,9 @@ public class CustomerSummary extends PartySummary { if (alerts != null) { column.add(ColumnFactory.create("Inset.Small", alerts.getComponent())); } + if(hasEstimates(party)) { + column.add(LabelFactory.create("customer.estimates")); + } Column result = ColumnFactory.create("PartySummary", column); if (SMSHelper.isSMSEnabled(practice)) { final List contacts = ContactHelper.getSMSContacts(party); @@ -193,7 +195,7 @@ public class CustomerSummary extends PartySummary { } return result; } - + /** * Returns outstanding alerts for a party. * @@ -207,6 +209,10 @@ public class CustomerSummary extends PartySummary { return query.query(); } + protected ResultSet createEstimateResultSet(Party party, int pageSize) { + CustomerEstimateQuery query = new CustomerEstimateQuery(party); + return query.query(); + } /** * Returns a button to launch an {@link MailDialog} for a customer. * diff --git a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/estimate/CustomerEstimateQuery.java b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/estimate/CustomerEstimateQuery.java index a70f2a4..23ef8ef 100644 --- a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/estimate/CustomerEstimateQuery.java +++ b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/customer/estimate/CustomerEstimateQuery.java @@ -9,23 +9,26 @@ package org.openvpms.web.workspace.customer.estimate; import static org.openvpms.archetype.rules.finance.estimate.EstimateArchetypes.ESTIMATE; import org.openvpms.component.business.domain.im.act.Act; import org.openvpms.component.business.domain.im.party.Party; +import org.openvpms.component.system.common.query.SortConstraint; import org.openvpms.web.component.im.query.ActStatuses; import org.openvpms.web.component.im.query.DateRangeActQuery; +import org.openvpms.web.component.im.util.VirtualNodeSortConstraint; /** - * + * Queries a customers estimates. + * * @author benjamincharlton */ - - - public class CustomerEstimateQuery extends DateRangeActQuery { private static final ActStatuses STATUSES = new ActStatuses(ESTIMATE); + private static final SortConstraint[] DEFAULT_SORT = { + new VirtualNodeSortConstraint("startTime",false)}; public CustomerEstimateQuery(Party customer) { super(customer, "customer", "participation.customer", new String[]{ESTIMATE}, STATUSES, Act.class); + setDefaultSortConstraint(DEFAULT_SORT); } diff --git a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/patient/summary/PatientSummary.java b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/patient/summary/PatientSummary.java index 50c347e..e7ef98f 100644 --- a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/patient/summary/PatientSummary.java +++ b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/patient/summary/PatientSummary.java @@ -15,12 +15,16 @@ */ package org.openvpms.web.workspace.patient.summary; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import nextapp.echo2.app.Component; import nextapp.echo2.app.Grid; import nextapp.echo2.app.Label; import nextapp.echo2.app.event.ActionEvent; import org.openvpms.archetype.rules.act.ActStatus; import org.openvpms.archetype.rules.patient.PatientArchetypes; +import static org.openvpms.archetype.rules.patient.PatientArchetypes.PATIENT_PARTICIPATION; import org.openvpms.archetype.rules.patient.PatientRules; import org.openvpms.archetype.rules.patient.reminder.ReminderArchetypes; import org.openvpms.archetype.rules.patient.reminder.ReminderRules; @@ -32,7 +36,6 @@ import org.openvpms.component.system.common.query.NodeSortConstraint; import org.openvpms.component.system.common.query.ShortNameConstraint; import org.openvpms.component.system.common.query.SortConstraint; import org.openvpms.web.component.app.Context; -import org.openvpms.web.component.im.layout.LayoutContext; import org.openvpms.web.component.im.layout.DefaultLayoutContext; import org.openvpms.web.component.im.layout.LayoutContext; import org.openvpms.web.component.im.query.ActResultSet; @@ -46,6 +49,7 @@ import org.openvpms.web.component.im.view.IMObjectReferenceViewer; import org.openvpms.web.component.im.view.IMObjectViewer; import org.openvpms.web.component.im.view.TableComponentFactory; import org.openvpms.web.echo.dialog.PopupDialog; +import static org.openvpms.web.echo.dialog.PopupDialog.OK; import org.openvpms.web.echo.event.ActionListener; import org.openvpms.web.echo.factory.ButtonFactory; import org.openvpms.web.echo.factory.ColumnFactory; @@ -57,15 +61,9 @@ import org.openvpms.web.resource.i18n.Messages; import org.openvpms.web.system.ServiceHelper; import org.openvpms.web.workspace.alert.Alert; import org.openvpms.web.workspace.alert.AlertSummary; +import org.openvpms.web.workspace.customer.estimate.CustomerEstimateQuery; import org.openvpms.web.workspace.summary.PartySummary; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import static org.openvpms.archetype.rules.patient.PatientArchetypes.PATIENT_PARTICIPATION; -import static org.openvpms.web.echo.dialog.PopupDialog.OK; - /** * Renders Patient Summary Information. * @@ -122,7 +120,9 @@ public class PatientSummary extends PartySummary { if (alerts != null) { column.add(ColumnFactory.create("Inset.Small", alerts.getComponent())); } - + if(hasEstimates(patient)){ + column.add(ButtonFactory.create("patient.estimates")); + } return ColumnFactory.create("PartySummary", column); } @@ -364,6 +364,12 @@ public class PatientSummary extends PartySummary { return new ActResultSet(archetypes, participants, dateRange, statuses, false, null, pageSize, null); } + + protected ResultSet createEstimateResultSet(Party patient, int pageSize) { + Party customer = rules.getOwner(patient); + CustomerEstimateQuery query = new CustomerEstimateQuery(customer); + return query.query(); + } /** * Returns outstanding acts for a patient. diff --git a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/summary/PartySummary.java b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/summary/PartySummary.java index 63cbd66..a8ef59d 100644 --- a/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/summary/PartySummary.java +++ b/openvpms-web-workspaces/src/main/java/org/openvpms/web/workspace/summary/PartySummary.java @@ -1,159 +1,187 @@ -/* - * Version: 1.0 - * - * The contents of this file are subject to the OpenVPMS License Version - * 1.0 (the 'License'); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.openvpms.org/license/ - * - * Software distributed under the License is distributed on an 'AS IS' basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Copyright 2010 (C) OpenVPMS Ltd. All Rights Reserved. - */ -package org.openvpms.web.workspace.summary; - -import nextapp.echo2.app.Component; -import org.openvpms.component.business.domain.im.act.Act; -import org.openvpms.component.business.domain.im.lookup.Lookup; -import org.openvpms.component.business.domain.im.party.Party; -import org.openvpms.web.component.app.Context; -import org.openvpms.web.component.im.query.ResultSet; -import org.openvpms.web.component.im.query.ResultSetIterator; -import org.openvpms.web.echo.help.HelpContext; -import org.openvpms.web.system.ServiceHelper; -import org.openvpms.web.workspace.alert.Alert; -import org.openvpms.web.workspace.alert.AlertSummary; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -/** - * Creates summary components for a given party. - * - * @author Tim Anderson - */ -public abstract class PartySummary { - - /** - * The context. - */ - private final Context context; - - /** - * The help context. - */ - private final HelpContext help; - - /** - * Constructs a {@code PartySummary}. - * - * @param context the context - * @param help the help context - */ - public PartySummary(Context context, HelpContext help) { - this.context = context; - this.help = help; - } - - /** - * Returns summary information for a party. - *

- * The summary includes any alerts. - * - * @param party the party. May be {@code null} - * @return a summary component, or {@code null} if there is no summary - */ - public Component getSummary(Party party) { - Component result = null; - if (party != null) { - result = createSummary(party); - } - return result; - } - - /** - * Returns the context. - * - * @return the context - */ - protected Context getContext() { - return context; - } - - /** - * Returns the help context. - * - * @return the context - */ - protected HelpContext getHelpContext() { - return help; - } - - /** - * Returns summary information for a party. - *

- * The summary includes any alerts. - * - * @param party the party - * @return a summary component - */ - protected abstract Component createSummary(Party party); - - /** - * Creates an alert summary for the specified party. - * - * @param party the party - * @return the party's alerts, or {@code null} if the party has no alerts - */ - public AlertSummary getAlertSummary(Party party) { - AlertSummary result = null; - List alerts = getAlerts(party); - if (!alerts.isEmpty()) { - Collections.sort(alerts); - result = new AlertSummary(alerts, context, help); - } - return result; - } - - /** - * Returns the alerts for a party. - * - * @param party the party - * @return the party's alerts - */ - protected abstract List getAlerts(Party party); - - /** - * Returns the alerts for a party. - * - * @param party the party - * @return the party's alerts - */ - protected List queryAlerts(Party party) { - List result = new ArrayList(); - ResultSet set = createAlertsResultSet(party, 20); - ResultSetIterator iterator = new ResultSetIterator(set); - while (iterator.hasNext()) { - Act act = iterator.next(); - Lookup lookup = ServiceHelper.getLookupService().getLookup(act, "alertType"); - if (lookup != null) { - result.add(new Alert(lookup, act)); - } - } - return result; - } - - /** - * Returns outstanding alerts for a party. - * - * @param party the party - * @param pageSize the no. of alerts to return per page - * @return the set of outstanding alerts for the party - */ - protected abstract ResultSet createAlertsResultSet(Party party, int pageSize); -} +/* + * Version: 1.0 + * + * The contents of this file are subject to the OpenVPMS License Version + * 1.0 (the 'License'); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.openvpms.org/license/ + * + * Software distributed under the License is distributed on an 'AS IS' basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Copyright 2010 (C) OpenVPMS Ltd. All Rights Reserved. + */ +package org.openvpms.web.workspace.summary; + +import nextapp.echo2.app.Component; +import org.openvpms.component.business.domain.im.act.Act; +import org.openvpms.component.business.domain.im.lookup.Lookup; +import org.openvpms.component.business.domain.im.party.Party; +import org.openvpms.web.component.app.Context; +import org.openvpms.web.component.im.query.ResultSet; +import org.openvpms.web.component.im.query.ResultSetIterator; +import org.openvpms.web.echo.help.HelpContext; +import org.openvpms.web.system.ServiceHelper; +import org.openvpms.web.workspace.alert.Alert; +import org.openvpms.web.workspace.alert.AlertSummary; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + + +/** + * Creates summary components for a given party. + * + * @author Tim Anderson + */ +public abstract class PartySummary { + + /** + * The context. + */ + private final Context context; + + /** + * The help context. + */ + private final HelpContext help; + + /** + * Constructs a {@code PartySummary}. + * + * @param context the context + * @param help the help context + */ + public PartySummary(Context context, HelpContext help) { + this.context = context; + this.help = help; + } + + /** + * Returns summary information for a party. + *

+ * The summary includes any alerts. + * + * @param party the party. May be {@code null} + * @return a summary component, or {@code null} if there is no summary + */ + public Component getSummary(Party party) { + Component result = null; + if (party != null) { + result = createSummary(party); + } + return result; + } + + /** + * Returns the context. + * + * @return the context + */ + protected Context getContext() { + return context; + } + + /** + * Returns the help context. + * + * @return the context + */ + protected HelpContext getHelpContext() { + return help; + } + + /** + * Returns summary information for a party. + *

+ * The summary includes any alerts. + * + * @param party the party + * @return a summary component + */ + protected abstract Component createSummary(Party party); + + /** + * Creates an alert summary for the specified party. + * + * @param party the party + * @return the party's alerts, or {@code null} if the party has no alerts + */ + public AlertSummary getAlertSummary(Party party) { + AlertSummary result = null; + List alerts = getAlerts(party); + if (!alerts.isEmpty()) { + Collections.sort(alerts); + result = new AlertSummary(alerts, context, help); + } + return result; + } + + /** + * Returns the alerts for a party. + * + * @param party the party + * @return the party's alerts + */ + protected abstract List getAlerts(Party party); + + /** + * Returns the alerts for a party. + * + * @param party the party + * @return the party's alerts + */ + protected List queryAlerts(Party party) { + List result = new ArrayList(); + ResultSet set = createAlertsResultSet(party, 20); + ResultSetIterator iterator = new ResultSetIterator(set); + while (iterator.hasNext()) { + Act act = iterator.next(); + Lookup lookup = ServiceHelper.getLookupService().getLookup(act, "alertType"); + if (lookup != null) { + result.add(new Alert(lookup, act)); + } + } + return result; + } + + /** + * Returns outstanding alerts for a party. + * + * @param party the party + * @param pageSize the no. of alerts to return per page + * @return the set of outstanding alerts for the party + * @author benjamincharlton + */ + protected abstract ResultSet createAlertsResultSet(Party party, int pageSize); + /** + * Returns {@code true} if the party has a valid Estimate + * @param party + * @return boolean + * @author benjamincharlton + */ + protected boolean hasEstimates(Party party){ + ResultSet set = createEstimateResultSet(party,20); + ResultSetIterator iterator = new ResultSetIterator(set); + while (iterator.hasNext()) { + Act act = iterator.next(); + Date endTime = act.getActivityEndTime(); + if(endTime == null || endTime.after(new Date())) { + return true; + } + } + return false; + } + /** + * Returns a Set of Estimates for a party + * + * @param party the party + * @param pageSize the no. of estimates to return per page. + * @return the set of estimates for the party. + */ + protected abstract ResultSet createEstimateResultSet(Party party, int pageSize); +}