Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4c46b15
Add PrintPreview.js and PrintPreview.jsp for new Rx preview
chitrankd May 20, 2025
0071576
refactor: move Java code from PrintPreview.jsp to RxPrintPreviewAction
chitrankd May 20, 2025
8e1b3de
Update PrintPreview.jsp
chitrankd May 20, 2025
d83e8e8
refactor: Improve Print Preview JSP and Action
chitrankd May 21, 2025
ba72675
Refactor Rx Print Preview to streamline and enhance logic
chitrankd May 21, 2025
9e9799a
refactor: modularize printPreview method with documentation
chitrankd May 21, 2025
18d25de
Refactor PrintPreview.jsp and clean up unused code.
chitrankd May 22, 2025
8c2cf64
Revert "Refactor PrintPreview.jsp and clean up unused code."
chitrankd May 22, 2025
5ae84fb
Refactor and streamline RxPrintPreviewAction and PrintPreview.jsp
chitrankd May 22, 2025
ec4bc54
Fix missing parenthesis in PrintPreview.jsp
chitrankd May 22, 2025
e8ff275
Refactor(RxPrintPreviewAction, PrintPreview.jsp): Improve Rx print pr…
chitrankd May 23, 2025
0cc29ca
Refactor UI and enhance implementation of Rx-PrintPreview
chitrankd May 27, 2025
4329d62
Introduced new signature pad into the new Rx print preview
chitrankd May 30, 2025
1f141a6
Upgrade signature pad library to v5.0.7 and refactor related implemen…
chitrankd May 30, 2025
1219f80
Refactor signaturePad logic and improve signature handling
chitrankd Jun 2, 2025
a235171
Improve Rx PrintPreview layout and enhance modal responsiveness
chitrankd Jun 2, 2025
36f98db
Refactor Rx print preview to improve maintainability and modularity
chitrankd Jun 4, 2025
cf4e1fe
Refactor Rx print preview logic and UI for improved maintainability
chitrankd Jun 6, 2025
31b036d
Optimized RxPrintPreview data retrieval
chitrankd Jun 6, 2025
f39bf82
Refactor signature pad and Rx print preview logic
chitrankd Jun 9, 2025
12dfd22
Fix issue with print & enhance print handling
chitrankd Jun 10, 2025
ffc2391
Add pharmacy address toggle to Rx print preview
chitrankd Jun 10, 2025
5451796
Update Rx popup dimensions for display consistency
chitrankd Jun 10, 2025
19699b3
fix: Prescription preview rendering and null handling
chitrankd Jul 7, 2025
8be1c02
fix: Resolve prescription preview functionality issues
chitrankd Jul 16, 2025
5269f68
Enable fax buttons after signature is saved
chitrankd Jul 17, 2025
88c9fce
Merge branch 'main' into enhancement/rx-print-preview-modal
chitrankd Jul 17, 2025
203c24b
Refactor Ajax.Request calls to fetch API
chitrankd Aug 11, 2025
0a56318
fix: eChart loading behavior after print Rx & add to encounter
chitrankd Aug 11, 2025
1a08c1e
Remove large button styling from print button
chitrankd Sep 15, 2025
16784b8
Relocate action buttons in PrintPreview.jsp
chitrankd Sep 15, 2025
81673dc
Update fax button styles to btn-secondary (filled)
chitrankd Sep 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/main/java/org/oscarehr/common/dao/DrugDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,10 @@
*/
package org.oscarehr.common.dao;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Query;

import org.apache.commons.lang.StringUtils;
import org.oscarehr.common.NativeSql;
import org.oscarehr.common.model.Drug;
import org.oscarehr.util.MiscUtils;

public interface DrugDao extends AbstractDao<Drug> {

Expand Down Expand Up @@ -120,4 +113,12 @@ public Drug findByDemographicIdRegionalIdentifierAndAtcCode(String atcCode, Stri

public List<Drug> findLongTermDrugsByDemographic(Integer demographicId);

/**
* Retrieves a list of Drug objects based on the provided script number and demographic number.
*
* @param scriptNo the script number associated with the drugs to be retrieved
* @param demographicNo the demographic number associated with the drugs to be retrieved
* @return a list of Drug objects matching the provided script number and demographic number
*/
List<Drug> findBy(int scriptNo, int demographicNo);
}
13 changes: 13 additions & 0 deletions src/main/java/org/oscarehr/common/dao/DrugDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.List;

import javax.persistence.Query;
import javax.persistence.TypedQuery;

import org.apache.commons.lang.StringUtils;
import org.oscarehr.common.NativeSql;
Expand Down Expand Up @@ -620,4 +621,16 @@ public List<Drug> findLongTermDrugsByDemographic(Integer demographicId) {

}

@Override
public List<Drug> findBy(int scriptNo, int demographicNo) {
TypedQuery<Drug> drugQuery = entityManager.createQuery(
"SELECT d FROM Drug d WHERE d.scriptNo = :scriptNo AND d.demographicId = :demoId " +
"ORDER BY d.position DESC, d.rxDate DESC, d.id ASC", Drug.class
);
drugQuery.setParameter("scriptNo", scriptNo);
drugQuery.setParameter("demoId", demographicNo);

return drugQuery.getResultList();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/**
* Copyright (c) 2005-2012. Centre for Research on Inner City Health, St. Michael's Hospital, Toronto. All Rights Reserved.
* This software is published under the GPL GNU General Public License.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* <p>
* This software was written for
* Centre for Research on Inner City Health, St. Michael's Hospital,
* Toronto, Ontario, Canada
*/

package org.oscarehr.digitalSignature;

import com.google.gson.JsonObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.oscarehr.common.model.DigitalSignature;
import org.oscarehr.common.model.enumerator.ModuleType;
import org.oscarehr.managers.DigitalSignatureManager;
import org.oscarehr.util.DigitalSignatureUtils;
import org.oscarehr.util.LoggedInInfo;
import org.oscarehr.util.MiscUtils;
import org.oscarehr.util.SpringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class DigitalSignatureAction extends DispatchAction {

/**
* Handles the upload of a digital signature from various sources
*
* @param mapping The ActionMapping used to select this instance
* @param form The optional ActionForm bean for this request
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
* @return An ActionForward to the JSP page that will display the result
*/
public ActionForward uploadSignature(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);

String signatureId = "";
String uploadSource = request.getParameter("source");
String imageString = request.getParameter("signatureImage");
String demographic = request.getParameter("demographicNo");
boolean saveToDB = "true".equals(request.getParameter("saveToDB"));
String signatureKey = request.getParameter(DigitalSignatureUtils.SIGNATURE_REQUEST_ID_KEY);
ModuleType moduleType = ModuleType.getByName(request.getParameter(ModuleType.class.getSimpleName()));

JsonObject jsonResponse = new JsonObject();

if(signatureKey != null) {
String filename = DigitalSignatureUtils.getTempFilePath(signatureKey);

if ("IPAD".equalsIgnoreCase(uploadSource) && imageString != null && !imageString.isEmpty()) {
try (FileOutputStream fos = new FileOutputStream(filename)) {
imageString = imageString.substring(imageString.indexOf(",") + 1);

Base64 b64 = new Base64();
byte[] imageByteData = imageString.getBytes();
byte[] imageData = b64.decode(imageByteData);

if (imageData != null) {
fos.write(imageData);
MiscUtils.getLogger().debug("Signature uploaded: {}, size={}", filename, imageData.length);
}
} catch (Exception e) {
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
} catch (Exception ex) {
MiscUtils.getLogger().error("Error sending error response", ex);
}
MiscUtils.getLogger().error("Error uploading signature from IPAD: {}", filename, e);
}
} else if (uploadSource == null) {
try (FileOutputStream fos = new FileOutputStream(filename);
InputStream is = request.getInputStream()) {

int i = 0;
int counter = 0;

while ((i = is.read()) != -1) {
fos.write(i);
counter++;
}
MiscUtils.getLogger().debug("Signature uploaded : " + filename + ", size=" + counter);
} catch (Exception e) {
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
} catch (Exception ex) {
MiscUtils.getLogger().error("Error sending error response", ex);
}
MiscUtils.getLogger().error("Error uploading signature: {}", filename, e);
}
}

if (saveToDB) {
int demographicNo = -1;

if (demographic != null && !demographic.isEmpty()) {
demographicNo = Integer.parseInt(demographic);
}

DigitalSignatureManager digitalSignatureManager = SpringUtils.getBean(DigitalSignatureManager.class);
DigitalSignature signature = digitalSignatureManager.processAndSaveDigitalSignature(loggedInInfo,
request.getParameter(DigitalSignatureUtils.SIGNATURE_REQUEST_ID_KEY),
demographicNo, moduleType);
if (signature != null) {
signatureId = "" + signature.getId();
}
}

try {
response.setStatus(HttpServletResponse.SC_OK);
jsonResponse.addProperty("signatureId", signatureId);
} catch (Exception e) {
MiscUtils.getLogger().error("Error setting response status or request attribute", e);
}
}


response.setContentType("application/json");

try(PrintWriter out = response.getWriter()) {
out.print(jsonResponse);
} catch (IOException e) {
MiscUtils.getLogger().error("Error writing JSON response", e);
}

return null;
}
}
Loading