@Override public PatientPushedToInfo getPatientPushInfo(String localPatientID, String remoteServerName) { if (localPatientID == null || remoteServerName == null) { return null; } Session session = this.sessionFactory.getSessionFactory().openSession(); PatientPushedToInfo data = (PatientPushedToInfo) session.createCriteria(PatientPushedToInfo.class) .add(Restrictions.eq("localPatientID", localPatientID)) .add(Restrictions.eq("remoteServerName", remoteServerName)) .uniqueResult(); if (data == null) { this.logger.debug("Never pushed [{}] to [{}]", localPatientID, remoteServerName); return null; } this.logger.debug("[{}] was previously pushed to [{}@{}]", localPatientID, data.getRemotePatientID(), remoteServerName); return data; } }
/** * Constructor that copies the information from a persisted entity. * * @param pushInfo the stored data to copy, must be non-null */ public DefaultPatientPushHistory(PatientPushedToInfo pushInfo) { this.lastTimePushed = pushInfo.getLastPushTime(); this.remotePatientGUID = pushInfo.getRemotePatientGUID(); this.remotePatientID = pushInfo.getRemotePatientID(); this.remotePatientURL = pushInfo.getRemotePatientURL(); }
/** * Constructor that copies the information from a persisted entity. * * @param pushInfo the stored data to copy, must be non-null */ public DefaultPatientPushHistory(PatientPushedToInfo pushInfo) { this.lastTimePushed = pushInfo.getLastPushTime(); this.remotePatientGUID = pushInfo.getRemotePatientGUID(); this.remotePatientID = pushInfo.getRemotePatientID(); this.remotePatientURL = pushInfo.getRemotePatientURL(); }
@Override public void storePatientPushInfo(String localPatientID, String remoteServerName, String remotePatientGUID, String remotePatientID, String remotePatientURL) { if (localPatientID == null || remoteServerName == null) { return; } PatientPushedToInfo existing = getPatientPushInfo(localPatientID, remoteServerName); Session session = this.sessionFactory.getSessionFactory().openSession(); Transaction t = session.beginTransaction(); t.begin(); if (existing != null) { this.logger.debug("Updating patient push info for [{}]: [{}@{}] -> [{}@{}]", localPatientID, existing.getRemotePatientID(), existing.getRemoteServerName(), remotePatientID, remoteServerName); existing.setLastPushTimeToNow(); existing.setRemotePatientID(remotePatientID); existing.setRemotePatientGUID(remotePatientGUID); existing.setRemotePatientURL(remotePatientURL); session.update(existing); } else { this.logger.debug("Saving new patient push info [{}]: [{}@{}]", localPatientID, remotePatientID, remoteServerName); session.save(new PatientPushedToInfo(localPatientID, remoteServerName, remotePatientGUID, remotePatientID, remotePatientURL)); } t.commit(); }