public String convertDate8Char(String s) { String sdate = "00000000", syear = "", smonth = "", sday = ""; MiscUtils.getLogger().debug("s=" + s); if (s != null) { if (s.indexOf("-") != -1) { syear = s.substring(0, s.indexOf("-")); s = s.substring(s.indexOf("-") + 1); smonth = s.substring(0, s.indexOf("-")); if (smonth.length() == 1) { smonth = "0" + smonth; } s = s.substring(s.indexOf("-") + 1); sday = s; if (sday.length() == 1) { sday = "0" + sday; } MiscUtils.getLogger().debug("Year" + syear + " Month" + smonth + " Day" + sday); sdate = syear + smonth + sday; } else { sdate = s; } MiscUtils.getLogger().debug("sdate:" + sdate); } else { sdate = "00000000"; } return sdate; }
public static void toDataBase(InputStream inputStream, String fileName) { boolean validation = true; DOMParser parser = new DOMParser(); Document doc; try { // InputStream inputStream = file.getInputStream(); InputSource source = new InputSource(inputStream); // String fileName = file.getFileName(); int indexForm = fileName.indexOf("_"); int indexDemo = fileName.indexOf("_", indexForm + 1); int indexTimeStamp = fileName.indexOf(".", indexDemo); String formName = fileName.substring(0, indexForm); String demographicNo = fileName.substring(indexForm + 1, indexDemo); String timeStamp = fileName.substring(indexDemo + 1, indexTimeStamp); // check if the data existed in the database already... String sql = "SELECT * FROM " + formName + " WHERE demographic_no='" + demographicNo + "' AND formEdited='" + timeStamp + "'"; MiscUtils.getLogger().debug(sql); ResultSet rs = DBHandler.GetSQL(sql); if (!rs.first()) { rs.close(); sql = "SELECT * FROM " + formName + " WHERE demographic_no='" + demographicNo + "' AND ID='0'"; MiscUtils.getLogger().debug("sql: " + sql); rs = DBHandler.GetSQL(sql, true); rs.moveToInsertRow(); // To validate or not parser.setFeature("http://xml.org/sax/features/validation", validation); parser.parse(source); doc = parser.getDocument(); rs = toResultSet(doc, rs); rs.insertRow(); } rs.close(); } catch (Exception e) { MiscUtils.getLogger().debug("Errors " + e); } }
public boolean matchRegExp(String regExp, String inputValue) { boolean validation = true; MiscUtils.getLogger().debug("matchRegExp function is called."); if (!GenericValidator.isBlankOrNull(regExp) && !GenericValidator.isBlankOrNull(inputValue)) { MiscUtils.getLogger().debug("both the regExp and inputValue is not blank nor null."); if (!inputValue.matches(regExp)) { MiscUtils.getLogger().debug("Regexp not matched"); validation = false; } } return validation; }
public class ProviderRxInteractionWarningLevelAction extends DispatchAction { private static final Logger logger = MiscUtils.getLogger(); private UserPropertyDAO propertyDao = (UserPropertyDAO) SpringUtils.getBean("UserPropertyDAO"); public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String value = request.getParameter("value"); Provider provider = LoggedInInfo.loggedInInfo.get().loggedInProvider; UserProperty prop = propertyDao.getProp(provider.getProviderNo(), "rxInteractionWarningLevel"); if (prop == null) { prop = new UserProperty(); prop.setName("rxInteractionWarningLevel"); prop.setProviderNo(provider.getProviderNo()); } prop.setValue(value); propertyDao.saveProp(prop); try { response.getWriter().println("ok"); } catch (IOException e) { logger.error("error", e); } return null; } }
public WCB getWCBForm(String formID) { if (formID == null) { return null; } MiscUtils.getLogger().debug("\nFORM ID " + formID); return entityManager.find(WCB.class, Integer.parseInt(formID)); }
@Test public void testFind3rdPartyPayRecordsByBill() throws Exception { BillingONCHeader1Dao daoBONCH = (BillingONCHeader1Dao) SpringUtils.getBean(BillingONCHeader1Dao.class); BillingONCHeader1 bONCHeader1 = new BillingONCHeader1(); EntityDataGenerator.generateTestDataForModelClass(bONCHeader1); int billingNo = 1; BillingONPayment bONPayment1 = new BillingONPayment(); EntityDataGenerator.generateTestDataForModelClass(bONPayment1); Date date1 = new Date(dfm.parse("20110101").getTime()); bONPayment1.setBillingNo(billingNo); bONPayment1.setPaymentDate(date1); BillingONPayment bONPayment2 = new BillingONPayment(); EntityDataGenerator.generateTestDataForModelClass(bONPayment2); Date date2 = new Date(dfm.parse("20110701").getTime()); bONPayment2.setBillingNo(billingNo); bONPayment2.setPaymentDate(date2); BillingONPayment bONPayment3 = new BillingONPayment(); EntityDataGenerator.generateTestDataForModelClass(bONPayment3); Date date3 = new Date(dfm.parse("20110301").getTime()); bONPayment3.setBillingNo(billingNo); bONPayment3.setPaymentDate(date3); daoBONCH.persist(bONCHeader1); dao.persist(bONPayment1); dao.persist(bONPayment2); dao.persist(bONPayment3); List<BillingONPayment> result = dao.find3rdPartyPayRecordsByBill(bONCHeader1); List<BillingONPayment> expectedResult = new ArrayList<BillingONPayment>( Arrays.asList( bONPayment1, bONPayment3, bONPayment2)); /// add the three payment obj in the expected order and assert = // expected result Logger logger = MiscUtils.getLogger(); if (result.size() != expectedResult.size()) { logger.warn("Array sizes do not match."); fail("Array sizes do not match."); } for (int i = 0; i < expectedResult.size(); i++) { if (!expectedResult.get(i).equals(result.get(i))) { logger.warn("Items not sorted by Billing Payment Date."); fail("Items not sorted by Billing Payment Date."); } } assertTrue(true); }
public static void saveAsXML(Document doc, String fileName) { try { TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); DOMSource source = new DOMSource(doc); File newXML = new File(fileName); FileOutputStream os = new FileOutputStream(newXML); StreamResult result = new StreamResult(os); transformer.transform(source, result); MiscUtils.getLogger().debug("Next is to call zip function!"); zip z = new zip(); z.write2Zip("xml"); } catch (Exception e) { MiscUtils.getLogger().debug(e.getMessage() + "cannot saveAsXML"); File newXML = new File(fileName); newXML.delete(); } }
public List getMRIList(String sDate, String eDate, String status) { List retval = new Vector(); BillingDiskNameData obj = null; try { List<BillingONDiskName> results = diskNameDao.findByCreateDateRangeAndStatus( dateformatter.parse(sDate), dateformatter.parse(eDate), status); for (BillingONDiskName b : results) { obj = new BillingDiskNameData(); obj.setId("" + b.getId()); obj.setMonthCode(b.getMonthCode()); obj.setBatchcount("" + b.getBatchCount()); obj.setOhipfilename(b.getOhipFilename()); obj.setGroupno(b.getGroupNo()); obj.setClaimrecord(b.getClaimRecord()); obj.setCreatedatetime(tsFormatter.format(b.getCreateDateTime())); obj.setUpdatedatetime(tsFormatter.format(b.getTimestamp())); obj.setStatus(b.getStatus()); obj.setTotal(b.getTotal()); List<BillingONFilename> ff = filenameDao.findByDiskIdAndStatus(b.getId(), status); Vector vecHtmlfilename = new Vector(); Vector vecProviderohipno = new Vector(); Vector vecProviderno = new Vector(); Vector vecClaimrecord = new Vector(); Vector vecStatus = new Vector(); Vector vecTotal = new Vector(); Vector vecFilenameId = new Vector(); for (BillingONFilename f : ff) { vecFilenameId.add("" + f.getId()); vecHtmlfilename.add(f.getHtmlFilename()); vecProviderohipno.add(f.getProviderOhipNo()); vecProviderno.add(f.getProviderNo()); vecClaimrecord.add(f.getClaimRecord()); vecStatus.add(f.getStatus()); vecTotal.add(f.getTotal()); } obj.setVecFilenameId(vecFilenameId); obj.setHtmlfilename(vecHtmlfilename); obj.setProviderohipno(vecProviderohipno); obj.setProviderno(vecProviderno); obj.setVecClaimrecord(vecClaimrecord); obj.setVecStatus(vecStatus); obj.setVecTotal(vecTotal); retval.add(obj); } } catch (Exception e) { MiscUtils.getLogger().error("Error", e); retval = null; } return retval; }
public float getPercentage() { float percentage = 0; try { percentage = ((float) getNumeratorCount() / (float) getDenominatorCount()) * 100; } catch (java.lang.ArithmeticException arithEx) { MiscUtils.getLogger().error("Error", arithEx); // request.setAttribute("divisionByZero",denominatorId); percentage = 0; } return percentage; }
@Test public void testFindByTypeAndMeasuringInstruction() throws Exception { String measuringInstruction1 = "instruction1"; String measuringInstruction2 = "instruction2"; String type1 = "typ1"; String type2 = "typ2"; MeasurementType measurementType1 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType1); measurementType1.setMeasuringInstruction(measuringInstruction2); measurementType1.setType(type1); dao.persist(measurementType1); MeasurementType measurementType2 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType2); measurementType2.setMeasuringInstruction(measuringInstruction1); measurementType2.setType(type1); dao.persist(measurementType2); MeasurementType measurementType3 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType3); measurementType3.setMeasuringInstruction(measuringInstruction2); measurementType3.setType(type2); dao.persist(measurementType3); MeasurementType measurementType4 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType4); measurementType4.setMeasuringInstruction(measuringInstruction1); measurementType4.setType(type1); dao.persist(measurementType4); List<MeasurementType> expectedResult = new ArrayList<MeasurementType>(Arrays.asList(measurementType2, measurementType4)); List<MeasurementType> result = dao.findByTypeAndMeasuringInstruction(type1, measuringInstruction1); Logger logger = MiscUtils.getLogger(); if (result.size() != expectedResult.size()) { logger.warn("Array sizes do not match."); fail("Array sizes do not match."); } for (int i = 0; i < expectedResult.size(); i++) { if (!expectedResult.get(i).equals(result.get(i))) { logger.warn("Items do not match."); fail("Items do not match."); } } assertTrue(true); }
// 1-hin 2-ver private String[] getHinVer(String val) { String[] ret = {"", ""}; MiscUtils.getLogger().debug("Hinver: " + val); if (val != null) { for (int i = 0; i < val.length(); i++) { if (("" + val.charAt(i)).matches("\\d")) { ret[0] += val.charAt(i); } else { ret[1] += val.charAt(i); } } } return ret; }
public boolean isValidBloodPressure(String regExp, String inputValue) { boolean validation = true; if (matchRegExp(regExp, inputValue)) { MiscUtils.getLogger().debug("/"); int slashIndex = inputValue.indexOf("/"); MiscUtils.getLogger().debug(slashIndex); if (slashIndex >= 0) { String systolic = inputValue.substring(0, slashIndex); String diastolic = inputValue.substring(slashIndex + 1); MiscUtils.getLogger().debug("The systolic value is " + systolic); MiscUtils.getLogger().debug("The diastolic value is " + diastolic); int iSystolic = Integer.parseInt(systolic); int iDiastolic = Integer.parseInt(diastolic); if (iDiastolic > iSystolic) { validation = false; } else if (iDiastolic > 300 || iSystolic > 300) { validation = false; } } } return validation; }
@Test public void testGetCriteriaTypeOptionByTypeId() throws Exception { int criteriaTypeId1 = 101, criteriaTypeId2 = 202; CriteriaTypeOption cTO1 = new CriteriaTypeOption(); EntityDataGenerator.generateTestDataForModelClass(cTO1); cTO1.setCriteriaTypeId(criteriaTypeId1); dao.persist(cTO1); CriteriaTypeOption cTO2 = new CriteriaTypeOption(); EntityDataGenerator.generateTestDataForModelClass(cTO2); cTO2.setCriteriaTypeId(criteriaTypeId2); dao.persist(cTO2); CriteriaTypeOption cTO3 = new CriteriaTypeOption(); EntityDataGenerator.generateTestDataForModelClass(cTO3); cTO3.setCriteriaTypeId(criteriaTypeId2); dao.persist(cTO3); CriteriaTypeOption cTO4 = new CriteriaTypeOption(); EntityDataGenerator.generateTestDataForModelClass(cTO4); cTO4.setCriteriaTypeId(criteriaTypeId1); dao.persist(cTO4); CriteriaTypeOption cTO5 = new CriteriaTypeOption(); EntityDataGenerator.generateTestDataForModelClass(cTO5); cTO5.setCriteriaTypeId(criteriaTypeId1); dao.persist(cTO5); List<CriteriaTypeOption> expectedResult = new ArrayList<CriteriaTypeOption>(Arrays.asList(cTO1, cTO4, cTO5)); List<CriteriaTypeOption> result = dao.getCriteriaTypeOptionByTypeId(criteriaTypeId1); Logger logger = MiscUtils.getLogger(); if (result.size() != expectedResult.size()) { logger.warn("Array sizes do not match."); fail("Array sizes do not match."); } for (int i = 0; i < expectedResult.size(); i++) { if (!expectedResult.get(i).equals(result.get(i))) { logger.warn("Items do not match."); fail("Items do not match."); } } assertTrue(true); }
public synchronized String getWarnings(String demo) { String ret = (String) mShell.get(PREVS).get(demo); if (ret == null) { try { Prevention prev = PreventionData.getLocalandRemotePreventions(Integer.parseInt(demo)); pf.getMessages(prev); @SuppressWarnings("unchecked") Map<String, Object> m = prev.getWarningMsgs(); @SuppressWarnings("rawtypes") Set set = m.entrySet(); @SuppressWarnings("rawtypes") Iterator i = set.iterator(); // Display elements String k = ""; if (ret == null || ret.equals("null")) { ret = ""; } while (i.hasNext()) { @SuppressWarnings("rawtypes") Map.Entry me = (Map.Entry) i.next(); k = "[" + me.getKey() + "=" + me.getValue() + "]"; boolean prevCheck = PreventionManager.isPrevDisabled(me.getKey().toString()); if (prevCheck == false) { ret = ret + k; } } mShell.get(PREVS).put(demo, ret); } catch (Exception e) { ret = ""; MiscUtils.getLogger().error("Error", e); } } return ret; }
@Test public void testFindAll() throws Exception { MeasurementType measurementType1 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType1); dao.persist(measurementType1); MeasurementType measurementType2 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType2); dao.persist(measurementType2); MeasurementType measurementType3 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType3); dao.persist(measurementType3); MeasurementType measurementType4 = new MeasurementType(); EntityDataGenerator.generateTestDataForModelClass(measurementType4); dao.persist(measurementType4); List<MeasurementType> expectedResult = new ArrayList<MeasurementType>( Arrays.asList(measurementType1, measurementType2, measurementType3, measurementType4)); List<MeasurementType> result = dao.findAll(); Logger logger = MiscUtils.getLogger(); if (result.size() != expectedResult.size()) { logger.warn("Array sizes do not match."); fail("Array sizes do not match."); } for (int i = 0; i < expectedResult.size(); i++) { if (!expectedResult.get(i).equals(result.get(i))) { logger.warn("Items do not match."); fail("Items do not match."); } } assertTrue(true); }
public String getName() { StringBuilder name = new StringBuilder(); name.append(numerator.getNumeratorName()); name.append("/"); name.append(denominator.getDenominatorName()); if (denominator.hasReplaceableValues()) { name.append(" ("); String[] repKeys = denominator.getReplaceableKeys(); Hashtable repVals = denominator.getReplaceableValues(); for (int i = 0; i < repKeys.length; i++) { // provider_no:999998 if key is provider_no look up provider name MiscUtils.getLogger().debug("repKeys " + repKeys[i]); if (repKeys[i] != null && repKeys[i].equals("provider_no")) { name.append("Provider: " + getProviderStringName("" + repVals.get(repKeys[i]))); } else { name.append(repKeys[i] + ":" + repVals.get(repKeys[i])); } } name.append(")"); } return name.toString(); }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { if (!securityInfoManager.hasPrivilege( LoggedInInfo.getLoggedInInfoFromSession(request), "_con", "r", null)) { throw new SecurityException("missing required security object (_con)"); } String reqId = request.getParameter("reqId"); String demoNo = request.getParameter("demographicNo"); // ArrayList docs = EDocUtil.listDocs( demoNo, reqId, EDocUtil.ATTACHED); String[] docs = request.getParameterValues("docNo"); ArrayList alist = new ArrayList(); String path = OscarProperties.getInstance().getProperty("DOCUMENT_DIR"); for (int i = 0; i < docs.length; i++) alist.add(path + docs[i]); if (alist.size() > 0) { response.setContentType("application/pdf"); // octet-stream response.setHeader( "Content-Disposition", "attachment; filename=\"combinedPDF-" + UtilDateUtilities.getToday("yyyy-mm-dd.hh.mm.ss") + ".pdf\""); try { ConcatPDF.concat(alist, response.getOutputStream()); } catch (IOException ex) { MiscUtils.getLogger().error("Error", ex); } return null; } return mapping.findForward("noprint"); }
@Repository public class Hsfo2VisitDao extends AbstractDao<Hsfo2Visit> { private static Logger logger = MiscUtils.getLogger(); public Hsfo2VisitDao() { super(Hsfo2Visit.class); } public Hsfo2Visit getHsfoVisitById(int id) { String sqlCommand = "select x from Hsfo2Visit x where x.id=?"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, id); return getSingleResultOrNull(query); } public List<Hsfo2Visit> getHsfoVisitByDemographicNo(Integer demographic_no) { String sqlCommand = "select x from Hsfo2Visit x where x.demographic_no=? order by x.VisitDate_Id"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, demographic_no); @SuppressWarnings("unchecked") List<Hsfo2Visit> results = query.getResultList(); return results; } public List<Hsfo2Visit> getLockedVisitByDemographicNo(String demographic_no) { String sqlCommand = "select x from Hsfo2Visit x where x.locked=true and x.demographic_no=? order by x.VisitDate_Id"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, demographic_no); @SuppressWarnings("unchecked") List<Hsfo2Visit> results = query.getResultList(); return results; } public List<Hsfo2Visit> getVisitRecordByPatientId(String patientId) { String sqlCommand = "select x FROM Hsfo2Visit x where x.id in (SELECT max(y.id) FROM Hsfo2Visit y WHERE y.Patient_Id = ? group by y.VisitDate_Id)"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, patientId); @SuppressWarnings("unchecked") List<Hsfo2Visit> results = query.getResultList(); return results; } public Hsfo2Visit getPatientLatestVisitRecordByVisitDate(Date visitdate, String demographic_no) { String sqlCommand = "select x FROM Hsfo2Visit x WHERE x.VisitDate_Id=?1 and x.demographic_no = ?2 order by x.id desc"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, visitdate); query.setParameter(2, demographic_no); return getSingleResultOrNull(query); } public List<Hsfo2Visit> getVisitRecordInDateRangeByDemographicNo( String patientId, String startDate, String endDate) { String sqlCommand = "select x FROM Hsfo2Visit x where x.Patient_Id=?1 and x.VisitDate_Id>?2 and x.VisitDate_Id<?3 group by x.VisitDate_Id"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, patientId); try { Date start = new SimpleDateFormat("yyyy-MM-dd").parse(startDate); Date end = new SimpleDateFormat("yyyy-MM-dd").parse(endDate); query.setParameter(2, start); query.setParameter(3, end); @SuppressWarnings("unchecked") List<Hsfo2Visit> results = query.getResultList(); return results; } catch (ParseException e) { logger.error("[Hsfo2VisitDao] - formatDate: ", e); return null; } } /** * @param patientId * @return Hsfo2Visit */ public Hsfo2Visit getFirstVisitRecordForThePatient(String patientId) { String sqlCommand = "select * FROM form_hsfo2_visit x WHERE x.Patient_Id=? order by x.id ASC"; Query query = entityManager.createNativeQuery(sqlCommand, modelClass); query.setParameter(1, patientId); return getSingleResultOrNull(query); } public Hsfo2Visit getPatientBaseLineVisitData(String patientId) { String sqlCommand = "select x FROM Hsfo2Visit x WHERE x.Patient_Id = ? and x.lastBaseLineRecord = 1"; Query query = entityManager.createQuery(sqlCommand); query.setParameter(1, patientId); return getSingleResultOrNull(query); } public int getMaxVisitId() { String sqlCommand = "select x from Hsfo2Visit x where x.id=(select max(x.id) from Hsfo2Visit x) "; Query query = entityManager.createQuery(sqlCommand); int maxId = 1; Hsfo2Visit v = getSingleResultOrNull(query); if (v != null) { maxId = v.getId().intValue(); } return maxId; } }
public class EctViewRequestAction extends Action { private static final Logger logger = MiscUtils.getLogger(); @Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EctViewRequestForm frm = (EctViewRequestForm) form; request.setAttribute("id", frm.getRequestId()); logger.debug("Id:" + frm.getRequestId()); logger.debug("SegmentId:" + request.getParameter("segmentId")); return mapping.findForward("success"); } private static Calendar setAppointmentDateTime( EctConsultationFormRequestForm thisForm, ConsultationRequest consult) { Calendar cal = Calendar.getInstance(); Date date1 = consult.getAppointmentDate(); Date date2 = consult.getAppointmentTime(); if (date1 == null || date2 == null) { cal.set(1970, 0, 1, 1, 0, 0); thisForm.setAppointmentDay(String.valueOf(cal.get(Calendar.DAY_OF_MONTH))); thisForm.setAppointmentMonth(String.valueOf(cal.get(Calendar.MONTH) + 1)); thisForm.setAppointmentYear(String.valueOf(cal.get(Calendar.YEAR))); Integer hr = cal.get(Calendar.HOUR_OF_DAY); hr = hr == 0 ? 12 : hr; hr = hr > 12 ? hr - 12 : hr; thisForm.setAppointmentHour(String.valueOf(hr)); thisForm.setAppointmentMinute(String.valueOf(cal.get(Calendar.MINUTE))); String appointmentPm; if (cal.get(Calendar.HOUR_OF_DAY) > 11) { appointmentPm = "PM"; } else { appointmentPm = "AM"; } thisForm.setAppointmentPm(appointmentPm); } else { cal.setTime(date1); thisForm.setAppointmentDay(String.valueOf(cal.get(Calendar.DAY_OF_MONTH))); thisForm.setAppointmentMonth(String.valueOf(cal.get(Calendar.MONTH) + 1)); thisForm.setAppointmentYear(String.valueOf(cal.get(Calendar.YEAR))); cal.setTime(date2); Integer hr = cal.get(Calendar.HOUR_OF_DAY); hr = hr == 0 ? 12 : hr; hr = hr > 12 ? hr - 12 : hr; thisForm.setAppointmentHour(String.valueOf(hr)); thisForm.setAppointmentMinute(String.valueOf(cal.get(Calendar.MINUTE))); String appointmentPm; if (cal.get(Calendar.HOUR_OF_DAY) > 11) { appointmentPm = "PM"; } else { appointmentPm = "AM"; } thisForm.setAppointmentPm(appointmentPm); } return cal; } public static void fillFormValues(EctConsultationFormRequestForm thisForm, Integer requestId) { ConsultationRequestDao consultDao = (ConsultationRequestDao) SpringUtils.getBean("consultationRequestDao"); ConsultationRequest consult = consultDao.find(requestId); thisForm.setAllergies(consult.getAllergies()); thisForm.setReasonForConsultation(consult.getReasonForReferral()); thisForm.setClinicalInformation(consult.getClinicalInfo()); thisForm.setCurrentMedications(consult.getCurrentMeds()); Date date = consult.getReferralDate(); thisForm.setReferalDate(DateFormatUtils.ISO_DATE_FORMAT.format(date)); thisForm.setSendTo(consult.getSendTo()); thisForm.setService(consult.getServiceId().toString()); thisForm.setStatus(consult.getStatus()); setAppointmentDateTime(thisForm, consult); thisForm.setConcurrentProblems(consult.getConcurrentProblems()); thisForm.setAppointmentNotes(consult.getStatusText()); thisForm.setUrgency(consult.getUrgency()); thisForm.setPatientWillBook(String.valueOf(consult.isPatientWillBook())); date = consult.getFollowUpDate(); if (date != null) { thisForm.setFollowUpDate(DateFormatUtils.ISO_DATE_FORMAT.format(date)); } else { thisForm.setFollowUpDate(""); } DemographicDao demoDao = (DemographicDao) SpringUtils.getBean("demographicDao"); Demographic demo = demoDao.getDemographicById(consult.getDemographicId()); thisForm.setPatientAddress(demo.getAddress()); thisForm.setPatientDOB(demo.getFormattedDob()); thisForm.setPatientHealthNum(demo.getHin()); thisForm.setPatientHealthCardVersionCode(demo.getVer()); thisForm.setPatientHealthCardType(demo.getHcType()); thisForm.setPatientFirstName(demo.getFirstName()); thisForm.setPatientLastName(demo.getLastName()); thisForm.setPatientPhone(demo.getPhone()); thisForm.setPatientSex(demo.getSex()); thisForm.setPatientWPhone(demo.getPhone2()); thisForm.setPatientEmail(demo.getEmail()); thisForm.setPatientAge(demo.getAge()); ProviderDao provDao = (ProviderDao) SpringUtils.getBean("providerDao"); Provider prov = provDao.getProvider(consult.getProviderNo()); thisForm.setProviderName(prov.getFormattedName()); thisForm.seteReferral(false); } public static void fillFormValues( EctConsultationFormRequestForm thisForm, EctConsultationFormRequestUtil consultUtil) { thisForm.setAllergies(consultUtil.allergies); thisForm.setReasonForConsultation(consultUtil.reasonForConsultation); thisForm.setClinicalInformation(consultUtil.clinicalInformation); thisForm.setCurrentMedications(consultUtil.currentMedications); thisForm.setReferalDate(consultUtil.referalDate); thisForm.setSendTo(consultUtil.sendTo); thisForm.setService(consultUtil.service); thisForm.setStatus(consultUtil.status); thisForm.setAppointmentDay(consultUtil.appointmentDay); thisForm.setAppointmentMonth(consultUtil.appointmentMonth); thisForm.setAppointmentYear(consultUtil.appointmentYear); thisForm.setAppointmentHour(consultUtil.appointmentHour); thisForm.setAppointmentMinute(consultUtil.appointmentMinute); thisForm.setAppointmentPm(consultUtil.appointmentPm); thisForm.setConcurrentProblems(consultUtil.concurrentProblems); thisForm.setAppointmentNotes(consultUtil.appointmentNotes); thisForm.setUrgency(consultUtil.urgency); thisForm.setPatientWillBook(consultUtil.pwb); if (consultUtil.sendTo != null && !consultUtil.teamVec.contains(consultUtil.sendTo)) { consultUtil.teamVec.add(consultUtil.sendTo); } // --- thisForm.setPatientAddress(consultUtil.patientAddress); thisForm.setPatientDOB(consultUtil.patientDOB); thisForm.setPatientHealthNum(consultUtil.patientHealthNum); thisForm.setPatientHealthCardVersionCode(consultUtil.patientHealthCardVersionCode); thisForm.setPatientHealthCardType(consultUtil.patientHealthCardType); thisForm.setPatientFirstName(consultUtil.patientFirstName); thisForm.setPatientLastName(consultUtil.patientLastName); thisForm.setPatientPhone(consultUtil.patientPhone); thisForm.setPatientSex(consultUtil.patientSex); thisForm.setPatientWPhone(consultUtil.patientWPhone); thisForm.setPatientEmail(consultUtil.patientEmail); thisForm.setPatientAge(consultUtil.patientAge); thisForm.setProviderName(consultUtil.getProviderName(consultUtil.providerNo)); thisForm.seteReferral(false); } public static void fillFormValues(EctConsultationFormRequestForm thisForm, String segmentId) throws HL7Exception, UnsupportedEncodingException, Base64DecodingException { Hl7TextMessageDao hl7TextMessageDao = (Hl7TextMessageDao) SpringUtils.getBean("hl7TextMessageDao"); Hl7TextMessage hl7TextMessage = hl7TextMessageDao.find(Integer.parseInt(segmentId)); String encodedMessage = hl7TextMessage.getBase64EncodedeMessage(); byte[] decodedMessage = Base64.decode(encodedMessage); String decodedMessageString = new String(decodedMessage, MiscUtils.DEFAULT_UTF8_ENCODING); REF_I12 refI12 = (REF_I12) OscarToOscarUtils.pipeParserParse(decodedMessageString); thisForm.setHl7TextMessageId(hl7TextMessage.getId()); thisForm.setAllergies(RefI12.getNteValue(refI12, RefI12.REF_NTE_TYPE.ALLERGIES)); thisForm.setReasonForConsultation( RefI12.getNteValue(refI12, RefI12.REF_NTE_TYPE.REASON_FOR_CONSULTATION)); thisForm.setClinicalInformation( RefI12.getNteValue(refI12, RefI12.REF_NTE_TYPE.CLINICAL_INFORMATION)); thisForm.setCurrentMedications( RefI12.getNteValue(refI12, RefI12.REF_NTE_TYPE.CURRENT_MEDICATIONS)); GregorianCalendar referralDate = DataTypeUtils.getCalendarFromDTM(refI12.getRF1().getEffectiveDate()); thisForm.setReferalDate(DateFormatUtils.ISO_DATE_FORMAT.format(referralDate)); thisForm.setConcurrentProblems( RefI12.getNteValue(refI12, RefI12.REF_NTE_TYPE.CONCURRENT_PROBLEMS)); // spoecifically told that this field should not be sent electronically (so it shouldn't be // received either). // thisForm.setAppointmentNotes(RefI12.getNteValue(refI12, // RefI12.REF_NTE_TYPE.APPOINTMENT_NOTES)); // --- PID pid = refI12.getPID(); Demographic demographic = DataTypeUtils.parsePid(pid); StringBuilder address = new StringBuilder(); if (demographic.getAddress() != null) address.append(demographic.getAddress()).append("<br />"); if (demographic.getCity() != null) address.append(demographic.getCity()).append(", "); if (demographic.getProvince() != null) address.append(demographic.getProvince()); thisForm.setPatientAddress(address.toString()); if (demographic.getBirthDay() != null) { thisForm.setPatientDOB(DateFormatUtils.ISO_DATE_FORMAT.format(demographic.getBirthDay())); String ageString = UtilDateUtilities.calcAgeAtDate(demographic.getBirthDay().getTime(), new Date()); thisForm.setPatientAge(ageString); } thisForm.setPatientHealthNum(demographic.getHin()); thisForm.setPatientHealthCardType(demographic.getHcType()); thisForm.setPatientHealthCardVersionCode(demographic.getVer()); thisForm.setPatientFirstName(demographic.getFirstName()); thisForm.setPatientLastName(demographic.getLastName()); thisForm.setPatientPhone(demographic.getPhone()); thisForm.setPatientSex(demographic.getSex()); // thisForm.setPatientWPhone(patientAddress); thisForm.setPatientEmail(demographic.getEmail()); // referring provider PRD referringPrd = RefI12.getPrdByRoleId(refI12, "RP"); Provider provider = DataTypeUtils.parsePrdAsProvider(referringPrd); thisForm.setProviderName(provider.getLastName() + ", " + provider.getFirstName()); thisForm.seteReferral(true); // referredTo specialist PRD referredToPrd = RefI12.getPrdByRoleId(refI12, "RT"); ProfessionalSpecialist professionalSpecialist = DataTypeUtils.parsePrdAsProfessionalSpecialist(referredToPrd); thisForm.setProfessionalSpecialistName( professionalSpecialist.getLastName() + ", " + professionalSpecialist.getFirstName()); thisForm.setProfessionalSpecialistAddress(professionalSpecialist.getStreetAddress()); thisForm.setProfessionalSpecialistPhone(professionalSpecialist.getPhoneNumber()); } }
/** @author jay */ @Repository @SuppressWarnings("unchecked") @Transactional(propagation = Propagation.REQUIRES_NEW) public class BillingmasterDAO { private static Logger log = MiscUtils.getLogger(); @PersistenceContext protected EntityManager entityManager = null; /** Creates a new instance of BillingmasterDAO */ public BillingmasterDAO() {} public List<Billingmaster> getBillingMasterWithStatus(String billingmasterNo, String status) { log.debug("WHAT IS NULL ? " + billingmasterNo + " status " + status + " " + entityManager); Query query = entityManager.createQuery( "select b from Billingmaster b where b.billingNo = (:billingNo) and billingstatus = (:status)"); query.setParameter("billingNo", Integer.parseInt(billingmasterNo)); query.setParameter("status", status); List<Billingmaster> list = query.getResultList(); return list; } public List<Billingmaster> getBillingMasterByBillingNo(String billingNo) { return getBillingmasterByBillingNo(Integer.parseInt(billingNo)); } public List<Billingmaster> getBillingmasterByBillingNo(int billingNo) { Query query = entityManager.createQuery("select b from Billingmaster b where b.billingNo = (:billingNo)"); query.setParameter("billingNo", billingNo); List<Billingmaster> list = query.getResultList(); return list; } public List<Billing> getPrivateBillings(String demographicNo) { Query query = entityManager.createQuery( "select b from Billing b where b.billingtype = 'Pri' and b.demographicNo = (:demographicNo)"); query.setParameter("demographicNo", Integer.parseInt(demographicNo)); return query.getResultList(); } /** Same as {@link #getBillingmaster(int)} */ public Billingmaster getBillingmaster(String billingNo) { return getBillingmaster(Integer.parseInt(billingNo)); } public Billingmaster getBillingmaster(int billingmasterNo) { Query query = entityManager.createQuery( "select b from Billingmaster b where b.billingmasterNo = (:billingmasterNo)"); query.setParameter("billingmasterNo", billingmasterNo); List<Billingmaster> list = query.getResultList(); return list.get(0); } public void save(Billingmaster bm) { entityManager.persist(bm); } public void save(WCB wcb) { if (wcb.getW_doi() == null) { wcb.setW_doi(new Date()); // Fixes SF ID : 2962864 } entityManager.persist(wcb); } public void save(Billing billing) { entityManager.persist(billing); } public void update(Billingmaster bm) { entityManager.merge(bm); } public void update(Billing billing) { entityManager.merge(billing); } public Billing getBilling(int billingNo) { return entityManager.find(Billing.class, billingNo); } public List<WCB> getWCBForms(int demographic) { Query query = entityManager.createQuery( "select wcb from WCB wcb where wcb.demographic_no = (:demographicNo) order by wcb.id desc"); query.setParameter("demographicNo", demographic); List<WCB> list = query.getResultList(); return list; } public List<WCB> getWCBForms(String demographic) { return getWCBForms(Integer.parseInt(demographic)); } public WCB getWCBForm(String formID) { if (formID == null) { return null; } MiscUtils.getLogger().debug("\nFORM ID " + formID); return entityManager.find(WCB.class, Integer.parseInt(formID)); } public Billingmaster getBillingMasterByBillingMasterNo(String billingNo) { return getBillingmaster(billingNo); } public int markListAsBilled(List<String> list) { // TODO: Should be set form CONST var Query query = entityManager.createQuery( "UPDATE Billingmaster b set b.billingstatus = 'B' where b.billingmasterNo in (:billingNumbers)"); query.setParameter("billingNumbers", ConversionUtils.toIntList(list)); return query.executeUpdate(); } /** * Sets the specified billing unit for the billing master with the specified number. * * @param billingUnit Billing unit to be set on the billing master * @param billingNo Number of the billing master to be updated * @return Returns the total number of rows affected by the operation */ public int updateBillingUnitForBillingNumber(String billingUnit, Integer billingNo) { Query query = entityManager.createQuery( "UPDATE " + Billingmaster.class.getSimpleName() + " b SET b.billingUnit = :billingUnit WHERE b.billingNo = :billingNo"); query.setParameter("billingUnit", billingUnit); query.setParameter("billingNo", billingNo); return query.executeUpdate(); } public WCB getWcbByBillingNo(Integer billing_no) { Query query = entityManager.createQuery("FROM WCB w WHERE w.billing_no = :billingNo"); query.setParameter("billingNo", billing_no); query.setMaxResults(1); List<WCB> ws = query.getResultList(); if (ws.isEmpty()) return null; return ws.get(0); } public List<Object[]> findByStatus(String status) { Query query = entityManager.createQuery( "FROM Billing b, Billingmaster bm " + "WHERE b.id = bm.billingNo " + "AND bm.billingstatus = :st"); query.setParameter("st", status); return query.getResultList(); } @NativeSql({"billingmaster", "billing"}) public List<Object[]> getBillingMasterByVariousFields( String statusType, String providerNo, String startDate, String endDate) { String providerQuery = ""; String startDateQuery = ""; String endDateQuery = ""; if (providerNo != null && !providerNo.trim().equalsIgnoreCase("all")) { providerQuery = " and provider_no = '" + providerNo + "'"; } if (startDate != null && !startDate.trim().equalsIgnoreCase("")) { startDateQuery = " and ( to_days(service_date) > to_days('" + startDate + "')) "; } if (endDate != null && !endDate.trim().equalsIgnoreCase("")) { endDateQuery = " and ( to_days(service_date) < to_days('" + endDate + "')) "; } String p = " select " + "b.billing_no, " + "b.demographic_no, " + "b.demographic_name, " + "b.update_date, " + "b.status, " + "b.apptProvider_no, " + "b.appointment_no, " + "b.billing_date, " + "b.billing_time, " + "bm.billingstatus, " + "bm.bill_amount, " + "bm.billing_code, " + "bm.dx_code1, " + "bm.dx_code2, " + "bm.dx_code3," + "b.provider_no, " + "b.visitdate, " + "b.visittype," + "bm.billingmaster_no " + "from billing b, " + " billingmaster bm where b.billing_no= bm.billing_no and bm.billingstatus = '" + statusType + "' " + providerQuery + startDateQuery + endDateQuery; Query query = entityManager.createNativeQuery(p); return query.getResultList(); } /* * Yes, this sucks, but it's only used in one place, and I can't figure out a good way to deal with it right now. */ public List<Object[]> select_user_bill_report_wcb(Integer billingMasterNo) { Query q = entityManager.createNativeQuery( " SELECT b.demographic_no, b.billingmaster_no, d.first_name, d.last_name, d.address, d.city, d.province, d.postal," + " d.hin, d.month_of_birth, d.date_of_birth, d.year_of_birth, b.practitioner_no, b.billing_code, w.bill_amount, b.billing_unit, b.service_date," + " b.billing_no, t.t_dataseq, w.w_servicelocation, w.w_icd9, w.w_reporttype, w.w_mname, w.w_gender, w.w_doi, w.w_area, w.w_phone, w.w_empname, " + "w.w_emparea, w.w_empphone,w.w_wcbno, w.w_opaddress,w.w_opcity,w.w_rphysician,w.w_duration,w.w_ftreatment,w.w_problem,w.w_servicedate," + "w.w_diagnosis, w.w_icd9,w.w_bp,w.w_side,w.w_noi,w.w_work,w.w_workdate,w.w_clinicinfo,w.w_capability,w.w_capreason,w.w_estimate,w.w_rehab," + "w.w_rehabtype,w.w_estimatedate,w.w_tofollow,w.w_wcbadvisor,w.w_feeitem,w.w_extrafeeitem,b.billingstatus,w.formNeeded,w.provider_no,w.w_payeeno, w.w_pracno " + " FROM billingmaster b LEFT JOIN teleplanC12 t ON t.t_officefolioclaimno=b.billingmaster_no, demographic d , wcb w " + "WHERE b.demographic_no=d.demographic_no AND b.billing_no=w.billing_no AND b.billingmaster_no=?"); q.setParameter(1, billingMasterNo); @SuppressWarnings("unchecked") List<Object[]> results = q.getResultList(); return results; } public List<Billing> search_teleplanbill(Integer billingmasterNo) { Query q = entityManager.createQuery( "select b from Billing b, Billingmaster bm where b.id= bm.billingNo and bm.billingmasterNo=?"); q.setParameter(1, billingmasterNo); @SuppressWarnings("unchecked") List<Billing> results = q.getResultList(); return results; } public List<Billingmaster> findByDemoNoCodeAndStatuses( Integer demoNo, String billingCode, List<String> statuses) { Query query = entityManager.createQuery( "FROM Billingmaster bm " + "WHERE bm.demographicNo = :demoNo " + "AND bm.billingCode = :billingCode " + "AND bm.billingstatus NOT IN (:statuses)"); query.setParameter("demoNo", demoNo); query.setParameter("billingCode", billingCode); query.setParameter("statuses", statuses); return query.getResultList(); } public List<Billingmaster> findByDemoNoCodeStatusesAndYear( Integer demoNo, Date date, String billingCode) { String sql = "FROM Billingmaster bm " + "WHERE bm.demographicNo = :demoNo " + "AND bm.billingCode = :billingCode " + "AND YEAR(bm.serviceDate) = YEAR(:date) " + "AND bm.billingstatus != 'D'"; Query query = entityManager.createQuery(sql); query.setParameter("demoNo", demoNo); query.setParameter("date", date); query.setParameter("billingCode", billingCode); return query.getResultList(); } }
public class ExtractBean implements Serializable { private static final long serialVersionUID = 1L; private static Logger logger = MiscUtils.getLogger(); private BillingDao billingDao = SpringUtils.getBean(BillingDao.class); private String apptDate; private String batchCount = ""; private String batchHeader; private int batchOrder = 0; private BigDecimal bdFee = new BigDecimal("0").setScale(2, BigDecimal.ROUND_HALF_UP); private BigDecimal BigTotal = new BigDecimal("0").setScale(2, BigDecimal.ROUND_HALF_UP); private String billingUnit; private String content; private int count = 0; private DateRange dateRange = null; public String[] dbParam; private String demoName; private String demoSex = ""; private double dFee; private String diagcode; private String dob; private String eFlag = ""; public String errorMsg = ""; public String errorPartMsg = ""; private String fee; private int flagOrder = 0; private SimpleDateFormat formatter; private String groupNo; private String hcCount = ""; private String hcFirst = ""; private String hcFlag = ""; private String hcHin = ""; private String hcLast = ""; private String hcType = ""; private String HE = "HE"; private int healthcardCount = 0; private String hin; private String htmlCode = ""; private String htmlContent = ""; private String htmlFilename; private String htmlFooter = ""; private String htmlHeader = ""; private String htmlValue = ""; private String inPatient; private int invCount = 0; private String invNo; private String m_Flag = ""; private String m_review = ""; private String ohipCenter; private String ohipClaim; private String ohipFilename; private String ohipReciprocal; private String ohipRecord; private String ohipVer; private String outPatient; private String outPatientDateValue; private String output; private int patientCount = 0; private String patientHeader; private String patientHeader2; private String pCount = ""; private BigDecimal percent = new BigDecimal("0").setScale(2, BigDecimal.ROUND_HALF_UP); private String providerNo; private String rCount = ""; private int recordCount = 0; private String referral; private String referralDoc; private int secondFlag = 0; private String serviceCode; private String spec; private String specCode; private String specialty; private int thirdFlag = 0; private java.util.Date today; private String totalAmount; private String value; private java.sql.Date visitDate; private String visitType; public ExtractBean() { formatter = new SimpleDateFormat("yyyyMMdd"); // yyyyMMddHmm"); today = new java.util.Date(); output = formatter.format(today); } private String buildBatchHeader() { return (HE + "B" + ohipVer + ohipCenter + output + zero(batchOrder) + batchCount + space(6) + groupNo + providerNo + specialty + space(42) + "\r"); } private String buildHeader1() { referralDoc = "000000"; hcFlag = ""; // for html content m_Flag = ""; // for html content referral = oscar.SxmlMisc.getXmlContent(content, "<xml_referral>", "</xml_referral>"); referralDoc = oscar.SxmlMisc.getXmlContent(content, "<rdohip>", "</rdohip>"); hcType = oscar.SxmlMisc.getXmlContent(content, "<hctype>", "</hctype>"); m_review = oscar.SxmlMisc.getXmlContent(content, "<mreview>", "</mreview>"); m_review = (m_review != null && m_review.equals("checked")) ? "Y" : space(1); m_Flag = m_review.equals("Y") ? "M" : ""; hcFlag = (hcType == null || hcType.compareTo("ON") == 0 || hcType.compareTo("") == 0) ? "" : "H"; if (referral != null && referral.compareTo("checked") == 0) { if (referralDoc == null || referralDoc.compareTo("000000") == 0) { referral = ""; referralDoc = space(6); } else { referral = "R"; // referralDoc = referralDoc; } } else { referral = ""; referralDoc = space(6); } outPatientDateValue = (visitDate == null) ? space(8) : UtilDateUtilities.DateToString(visitDate, "yyyyMMdd"); spec = (specCode != null && specCode.equals("O")) ? "HCP" : "WCB"; hin = (hin.length() < 12) ? (hin + space(12 - hin.length())) : hin.substring(0, 12); hin = hin.toUpperCase(); count = invNo.length(); count = 8 - count; hcHin = hin; // need for html content if (hcFlag.compareTo("H") == 0) { patientHeader2 = buildHeader2(); hin = space(12); } else { patientHeader2 = ""; } checkHeader1(); if (visitType == null || visitType.compareTo("00") == 0) { patientHeader = HE + "H" + hin + dob + zero(count) + invNo + spec + "P" + referralDoc + space(4) + space(8) + space(4) + m_review + inPatient + space(11) + space(6); } else { patientHeader = HE + "H" + hin + dob + zero(count) + invNo + spec + "P" + referralDoc + outPatient + outPatientDateValue + space(4) + m_review + inPatient + space(11) + space(6); } return ("\n" + patientHeader + "\r" + patientHeader2); } private String buildHeader2() { spec = "RMB"; hcFlag = "H"; healthcardCount++; demoSex = oscar.SxmlMisc.getXmlContent(content, "<demosex>", "</demosex>"); hcLast = demoName.substring(0, demoName.indexOf(",")).toUpperCase(); hcFirst = demoName.substring(demoName.indexOf(",") + 1).toUpperCase(); hcLast = hcLast.length() < 9 ? (hcLast + space(9 - hcLast.length())) : (hcLast.substring(0, 9)); hcFirst = hcFirst.length() < 5 ? (hcFirst + space(5 - hcFirst.length())) : (hcFirst.substring(0, 5)); hcLast.replaceAll("\\W", ""); hcFirst.replaceAll("\\W", ""); checkHeader2(); // patientHeader2 = "\n" + HE + "R" + hcHin + hcLast + hcFirst + demoSex + hcType + // space(47) + "\r"; return ("\n" + HE + "R" + hcHin + hcLast + hcFirst + demoSex + hcType + space(47) + "\r"); } private String buildHTMLContentHeader() { String ret = null; ret = "\n<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n" + "<tr><td colspan='4' class='bodytext'>OHIP Invoice for OHIP No." + providerNo + "</td><td colspan='4' class='bodytext'>Payment date of " + output + "\n</td></tr>"; ret += "\n<tr><td class='bodytext'>ACCT NO</td>" + "<td class='bodytext'>NAME</td><td class='bodytext'>HEALTH #</td>" + "<td class='bodytext'>BILLDATE</td><td class='bodytext'>CODE</td>" + "<td align='right' class='bodytext'>BILLED</td>" + "<td align='right' class='bodytext'>DX</td><td align='right' class='bodytext'>Comment</td></tr>"; return ret; } private String buildHTMLContentRecord(int invCount) { String ret = null; if (invCount == 0) { ret = "\n<tr><td class='bodytext'>" + invNo + "</td><td class='bodytext'>" + demoName + "</td><td class='bodytext'>" + hcHin + "</td><td class='bodytext'>" + apptDate + "</td><td class='bodytext'>" + serviceCode + "</td><td align='right' class='bodytext'>" + fee + "</td><td align='right' class='bodytext'>" + diagcode + "</td><td class='bodytext'> " + referral + hcFlag + m_Flag + " </td></tr>"; } else { ret = "\n<tr><td class='bodytext'> </td> <td class='bodytext'> </td>" + "<td class='bodytext'> </td> <td class='bodytext'> </td>" + "<td class='bodytext'>" + serviceCode + "</td><td align='right' class='bodytext'>" + fee + "</td><td align='right' class='bodytext'>" + diagcode + "</td><td class='bodytext'> </td></tr>"; } return ret; } private String buildHTMLContentTrailer() { htmlContent += "\n<tr><td colspan='8' class='bodytext'> </td></tr><tr><td colspan='4' class='bodytext'>OHIP No: " + providerNo + ": " + pCount + " RECORDS PROCESSED</td><td colspan='4' class='bodytext'>TOTAL: " + BigTotal.toString().substring(0, BigTotal.toString().length() - 2) + "\n</td></tr>" + "\n</table>"; // writeFile(value); String checkSummary = errorMsg.equals("") ? "\n<table border='0' width='100%' bgcolor='green'><tr><td>Pass</td></tr></table>" : "\n<table border='0' width='100%' bgcolor='orange'><tr><td>Please correct the errors and run this simulation again!</td></tr></table>"; htmlValue += htmlContent + checkSummary; htmlHeader = "<html><body><style type='text/css'><!-- .bodytext{ font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; color: #003366; text-decoration: none; --></style>"; htmlFooter = "</body></html>"; htmlCode = htmlHeader + htmlValue + htmlFooter; return htmlCode; } private String buildItem() { // return ("\n" + HE + "T" + serviceCode + space(2) + zero(count) + fee + "0" + billingUnit // + apptDate + diagcode + space(12)+ space(5) + space(2) + space(6) + space(25) + "\r"); return ("\n" + HE + "T" + serviceCode + space(2) + zero(count) + fee + forwardZero(billingUnit, 2) + apptDate + diagcode + space(12) + space(5) + space(2) + space(6) + space(25) + "\r"); } private String buildTrailer() { return ("\n" + HE + "E" + zero(flagOrder) + pCount + zero(thirdFlag) + hcCount + zero(secondFlag) + rCount + space(63) + "\r"); } private void checkBatchHeader() { if (ohipVer.length() != 3) { errorPartMsg = "Batch Header: Ver. wrong!<br>"; } if (ohipCenter.length() != 1) { errorPartMsg += "Batch Header: Health Office Code wrong!<br>"; } if (groupNo.length() != 4) { errorPartMsg += "Batch Header: GroupNo. wrong!<br>"; } if (providerNo.length() != 6) { errorPartMsg += "Batch Header: Provider OHIP No. wrong!<br>"; } if (specialty.length() != 2) { errorPartMsg += "Batch Header: Specialty Code wrong!<br>"; } errorMsg += errorPartMsg; } private void checkHeader1() { if (referralDoc != null && referralDoc.length() != 6) errorPartMsg = "Header1: Referral Doc. No. wrong!<br>"; if (visitType != null && visitType.compareTo("00") != 0) { if ((outPatient != null && outPatient.length() != 4) || outPatient == null) { errorPartMsg = "Header1: outPatient Visit. wrong!<br>"; } } errorMsg += errorPartMsg; } private void checkHeader2() { if (hcHin.length() == 0 || hcHin.length() > 12) errorPartMsg += "Header2: Reg. No. wrong!<br>"; if (hcLast.length() == 0) errorPartMsg += "Header2: Patient's Lastname wrong!<br>"; if (hcFirst.length() == 0) errorPartMsg += "Header2: Patient's Firstname wrong!<br>"; if (!(demoSex.equals("1") || demoSex.equals("2"))) errorPartMsg += "Header2: Patient's Sex Code wrong! (1 or 2)<br>"; if (hcType.length() != 2 || !(hcType.equals("AB") || hcType.equals("BC") || hcType.equals("MB") || hcType.equals("NL") || hcType.equals("NB") || hcType.equals("NT") || hcType.equals("NS") || hcType.equals("PE") || hcType.equals("SK") || hcType.equals("YT"))) errorPartMsg += "Header2: Patient's Province Code wrong!<br>"; errorMsg += errorPartMsg; } private void checkItem() { if (serviceCode.trim().length() != 5) errorPartMsg = "Item: Service Code wrong!<br>"; errorMsg += errorPartMsg; } private void checkNoDetailRecord(int invCount) { if (invCount == 0) errorPartMsg = "The billing no:" + invNo + " should be marked as 'Delete'.<br>"; errorMsg += errorPartMsg; } private String printErrorPartMsg() { String ret = ""; ret = errorPartMsg.length() > 0 ? ("\n<tr bgcolor='yellow'><td colspan='8'><font color='red'>" + errorPartMsg + "</font></td></tr>") : ""; errorPartMsg = ""; return ret; } public void dbQuery() { try { batchOrder = 4 - batchCount.length(); // check length checkBatchHeader(); batchHeader = buildBatchHeader(); htmlValue = buildHTMLContentHeader(); // start here value = batchHeader; BillingDao dao = SpringUtils.getBean(BillingDao.class); BillingDetailDao bdDao = SpringUtils.getBean(BillingDetailDao.class); for (Billing b : dao.findByProviderStatusAndDates( providerNo, Arrays.asList(new String[] {"O", "W"}), dateRange)) { patientCount++; invNo = "" + b.getId(); // ohipVer = b.getorganization_spec_code"); inPatient = "" + b.getClinicNo(); // if there is no clinic no for a clinic, it should be an empty str inPatient = "0".equals(inPatient) ? " " : inPatient; demoName = b.getDemographicName(); hin = b.getHin(); dob = b.getDob(); visitDate = new Date(b.getVisitDate().getTime()); visitType = b.getVisitType(); outPatient = b.getClinicRefCode(); specCode = b.getStatus(); content = b.getContent(); value += buildHeader1(); htmlContent += printErrorPartMsg(); // build billing detail invCount = 0; for (BillingDetail bd : bdDao.findByBillingNoAndStatus(ConversionUtils.fromIntString(invNo), specCode)) { recordCount++; count = 0; serviceCode = bd.getServiceCode(); fee = bd.getBillingAmount(); diagcode = bd.getDiagnosticCode(); // changed the following line for the no need of diagcode diagcode = ":::".equals(diagcode) ? " " : diagcode; // appt = rs2.getDate("appointment_date").toString(); billingUnit = bd.getBillingUnit(); count = 6 - fee.length(); apptDate = UtilDateUtilities.DateToString(bd.getAppointmentDate(), "yyyyMMdd"); dFee = Double.parseDouble(fee); bdFee = BigDecimal.valueOf(dFee).setScale(2, BigDecimal.ROUND_HALF_UP); BigTotal = BigTotal.add(bdFee); checkItem(); value += buildItem(); htmlContent += buildHTMLContentRecord(invCount); htmlContent += printErrorPartMsg(); invCount++; } checkNoDetailRecord(invCount); htmlContent += printErrorPartMsg(); if (eFlag.compareTo("1") == 0) { setAsBilled(invNo); } } hcCount = hcCount + healthcardCount; pCount = pCount + patientCount; rCount = rCount + recordCount; flagOrder = 4 - pCount.length(); secondFlag = 5 - rCount.length(); thirdFlag = 4 - hcCount.length(); percent = BigDecimal.valueOf(0.01).setScale(2, BigDecimal.ROUND_HALF_UP); BigTotal = BigTotal.multiply(percent); value += buildTrailer(); htmlCode = buildHTMLContentTrailer(); // writeHtml(htmlCode); ohipReciprocal = String.valueOf(hcCount); ohipRecord = String.valueOf(rCount); ohipClaim = String.valueOf(pCount); totalAmount = BigTotal.toString(); // } // dbExt.closeConnection(); } catch (Exception e) { MiscUtils.getLogger().error("error", e); } } public String getHtmlCode() { return htmlCode; } public String getHtmlValue() { return htmlValue; } public String getInvNo() { return invNo; } public String getOhipCenter() { return ohipCenter; } public String getOhipClaim() { return ohipClaim; } public String getOhipReciprocal() { return ohipReciprocal; } public String getOhipRecord() { return ohipRecord; } public String getOhipVer() { return ohipVer; } public String getTotalAmount() { return totalAmount; } public String getValue() { return value; } public void setAsBilled(String newInvNo) { Billing b = billingDao.find(Integer.parseInt(newInvNo)); if (b != null) { b.setStatus("B"); billingDao.merge(b); } } // batchCount 1 ??? public synchronized void setBatchCount(String newBatchCount) { batchCount = newBatchCount; } public synchronized void setDateRange(DateRange newDateRange) { dateRange = newDateRange; } // flag 0 - nothing ??? 1 - set as billed. public synchronized void seteFlag(String neweFlag) { eFlag = neweFlag; } public synchronized void setGroupNo(String newGroupNo) { groupNo = newGroupNo; } public synchronized void setHtmlFilename(String newHtmlFilename) { htmlFilename = newHtmlFilename; } public synchronized void setOhipCenter(String newOhipCenter) { ohipCenter = newOhipCenter; } public synchronized void setOhipFilename(String newOhipFilename) { ohipFilename = newOhipFilename; } public synchronized void setOhipVer(String newOhipVer) { ohipVer = newOhipVer; } public synchronized void setOscarHome(String oscarHOME) { // empty.potential problem here. } public synchronized void setProviderNo(String newProviderNo) { providerNo = newProviderNo; } public synchronized void setSpecialty(String newSpecialty) { specialty = newSpecialty; } // return i space str, e.g. " " public String space(int i) { String returnValue = new String(); for (int j = 0; j < i; j++) { returnValue += " "; } return returnValue; } // write OHIP file to it public void writeFile(String value1) { try { String home_dir; home_dir = OscarProperties.getInstance().getProperty("HOME_DIR"); FileOutputStream out = new FileOutputStream(home_dir + ohipFilename); PrintStream p = new PrintStream(out); p.println(value1); p.close(); out.close(); } catch (Exception e) { logger.error("Write OHIP File Error", e); } } // get path from the property file, e.g. // OscarDocument/.../billing/download/, and then write to it public void writeHtml(String htmlvalue1) { try { String home_dir1; home_dir1 = OscarProperties.getInstance().getProperty("HOME_DIR"); FileOutputStream out1 = new FileOutputStream(home_dir1 + htmlFilename); PrintStream p1 = new PrintStream(out1); p1.println(htmlvalue1); p1.close(); out1.close(); } catch (Exception e) { logger.error("Write HTML File Error!!!", e); } } // return x zero str, e.g. 000000 public String zero(int x) { String returnZeroValue = new String(); for (int y = 0; y < x; y++) { returnZeroValue += "0"; } return returnZeroValue; } // return x length string with zero str, e.g. 0018 public String forwardZero(String y, int x) { // x must >= y.length() String returnZeroValue = ""; for (int i = y.length(); i < x; i++) { returnZeroValue += "0"; } return (returnZeroValue + y); } }
public void dbQuery() { try { batchOrder = 4 - batchCount.length(); // check length checkBatchHeader(); batchHeader = buildBatchHeader(); htmlValue = buildHTMLContentHeader(); // start here value = batchHeader; BillingDao dao = SpringUtils.getBean(BillingDao.class); BillingDetailDao bdDao = SpringUtils.getBean(BillingDetailDao.class); for (Billing b : dao.findByProviderStatusAndDates( providerNo, Arrays.asList(new String[] {"O", "W"}), dateRange)) { patientCount++; invNo = "" + b.getId(); // ohipVer = b.getorganization_spec_code"); inPatient = "" + b.getClinicNo(); // if there is no clinic no for a clinic, it should be an empty str inPatient = "0".equals(inPatient) ? " " : inPatient; demoName = b.getDemographicName(); hin = b.getHin(); dob = b.getDob(); visitDate = new Date(b.getVisitDate().getTime()); visitType = b.getVisitType(); outPatient = b.getClinicRefCode(); specCode = b.getStatus(); content = b.getContent(); value += buildHeader1(); htmlContent += printErrorPartMsg(); // build billing detail invCount = 0; for (BillingDetail bd : bdDao.findByBillingNoAndStatus(ConversionUtils.fromIntString(invNo), specCode)) { recordCount++; count = 0; serviceCode = bd.getServiceCode(); fee = bd.getBillingAmount(); diagcode = bd.getDiagnosticCode(); // changed the following line for the no need of diagcode diagcode = ":::".equals(diagcode) ? " " : diagcode; // appt = rs2.getDate("appointment_date").toString(); billingUnit = bd.getBillingUnit(); count = 6 - fee.length(); apptDate = UtilDateUtilities.DateToString(bd.getAppointmentDate(), "yyyyMMdd"); dFee = Double.parseDouble(fee); bdFee = BigDecimal.valueOf(dFee).setScale(2, BigDecimal.ROUND_HALF_UP); BigTotal = BigTotal.add(bdFee); checkItem(); value += buildItem(); htmlContent += buildHTMLContentRecord(invCount); htmlContent += printErrorPartMsg(); invCount++; } checkNoDetailRecord(invCount); htmlContent += printErrorPartMsg(); if (eFlag.compareTo("1") == 0) { setAsBilled(invNo); } } hcCount = hcCount + healthcardCount; pCount = pCount + patientCount; rCount = rCount + recordCount; flagOrder = 4 - pCount.length(); secondFlag = 5 - rCount.length(); thirdFlag = 4 - hcCount.length(); percent = BigDecimal.valueOf(0.01).setScale(2, BigDecimal.ROUND_HALF_UP); BigTotal = BigTotal.multiply(percent); value += buildTrailer(); htmlCode = buildHTMLContentTrailer(); // writeHtml(htmlCode); ohipReciprocal = String.valueOf(hcCount); ohipRecord = String.valueOf(rCount); ohipClaim = String.valueOf(pCount); totalAmount = BigTotal.toString(); // } // dbExt.closeConnection(); } catch (Exception e) { MiscUtils.getLogger().error("error", e); } }
public boolean getInfo( EctSessionBean bean, HttpServletRequest request, NavBarDisplayDAO Dao, MessageResources messages) { boolean a = true; Vector v = OscarRoleObjectPrivilege.getPrivilegeProp("_newCasemgmt.episode"); String roleName = (String) request.getSession().getAttribute("userrole") + "," + (String) request.getSession().getAttribute("user"); a = OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) v.get(0), (Vector) v.get(1)); a = true; if (!a) { return true; } else { try { String appointmentNo = request.getParameter("appointment_no"); // Set lefthand module heading and link String winName = "episode" + bean.demographicNo; String pathview, pathedit; pathview = request.getContextPath() + "/Episode.do?method=list&demographicNo=" + bean.demographicNo; pathedit = request.getContextPath() + "/Episode.do?method=edit&demographicNo=" + bean.demographicNo; String url = "popupPage(500,900,'" + winName + "','" + pathview + "')"; Dao.setLeftHeading(messages.getMessage(request.getLocale(), "global.episode")); Dao.setLeftURL(url); // set right hand heading link winName = "AddEpisode" + bean.demographicNo; url = "popupPage(500,600,'" + winName + "','" + pathedit + "'); return false;"; Dao.setRightURL(url); Dao.setRightHeadingID(cmd); EpisodeDao episodeDao = SpringUtils.getBean(EpisodeDao.class); List<Episode> episodes = episodeDao.findAllCurrent(Integer.parseInt(bean.demographicNo)); for (Episode episode : episodes) { NavBarDisplayDAO.Item item = NavBarDisplayDAO.Item(); String itemHeader = StringUtils.maxLenString( episode.getDescription(), MAX_LEN_TITLE, CROP_LEN_TITLE, ELLIPSES); item.setLinkTitle(itemHeader); item.setTitle(itemHeader); item.setDate(episode.getStartDate()); int hash = Math.abs(winName.hashCode()); url = "popupPage(500,900,'" + hash + "','" + request.getContextPath() + "/Episode.do?method=edit&episode.id=" + episode.getId() + "'); return false;"; item.setURL(url); Dao.addItem(item); } } catch (Exception e) { MiscUtils.getLogger().error("Error", e); return false; } return true; } }
public class OcanSubmissionTask extends TimerTask { private static final Logger logger = MiscUtils.getLogger(); private GenericIntakeManager genericIntakeManager; private OcanDataProcessor ocanDataProcessor; private boolean useTestData; private String testDataPath; public void setGenericIntakeManager(GenericIntakeManager genericIntakeManager) { this.genericIntakeManager = genericIntakeManager; } public void setOcanDataProcessor(OcanDataProcessor ocanDataProcessor) { this.ocanDataProcessor = ocanDataProcessor; } @Override public void run() { LoggedInInfo.setLoggedInInfoToCurrentClassAndMethod(); try { logger.info("start ocan submission task"); OcanProcess process = ocanDataProcessor.createOcanProcess(); if (useTestData) { ocanDataProcessor.createOcanRecord( process, new FileInputStream(testDataPath + "/client.xml"), new FileInputStream(testDataPath + "/staff.xml"), "1001"); } else { Calendar after = new GregorianCalendar(); after.roll(Calendar.MONTH, -1); List<Map<String, String>> intakes = genericIntakeManager.getIntakeListforOcan(after); if (intakes == null || intakes.size() == 0) { logger.warn( "getIntakeListforOcan() returned null or empty list - no data for submission."); return; } for (Map<String, String> intakeMap : intakes) { MiscUtilsOld.checkShutdownSignaled(); try { ocanDataProcessor.createOcanRecord( process, new ByteArrayInputStream(intakeMap.get("client").getBytes()), new ByteArrayInputStream(intakeMap.get("staff").getBytes()), intakeMap.get("clientId")); } catch (Exception e) { logger.error("createOcanRecord() thrown an exception, skipping the record.", e); continue; } } } ocanDataProcessor.finishOcanProcess(process); logger.info("finish ocan submission task"); } catch (ShutdownException e) { logger.debug("OcanSubmissionTask noticed shutdown signaled."); } catch (FileNotFoundException e) { logger.error("finishOcanProcess() thrown an exception, terminating the submission.", e); } catch (JAXBException e) { logger.error("finishOcanProcess() thrown an exception, terminating the submission.", e); } catch (NumberFormatException e) { logger.error("finishOcanProcess() thrown an exception, terminating the submission.", e); } catch (ParseException e) { logger.error("finishOcanProcess() thrown an exception, terminating the submission.", e); } finally { LoggedInInfo.loggedInInfo.remove(); DbConnectionFilter.releaseAllThreadDbResources(); } } public void setUseTestData(boolean useTestData) { this.useTestData = useTestData; } public void setTestDataPath(String testDataPath) { this.testDataPath = testDataPath; } }
public class BedProgramDischargeTask extends TimerTask { private static final Logger log = MiscUtils.getLogger(); // TODO IC Bedlog bedProgram.getDischargeTime(); private static final String DISCHARGE_TIME = "8:00 AM"; private static final long PERIOD = 3600000; private ProgramManager programManager; private BedManager bedManager; private BedDemographicManager bedDemographicManager; private AdmissionManager admissionManager; public void setProgramManager(ProgramManager programManager) { this.programManager = programManager; } public void setBedManager(BedManager bedManager) { this.bedManager = bedManager; } public void setBedDemographicManager(BedDemographicManager bedDemographicManager) { this.bedDemographicManager = bedDemographicManager; } @Override public void run() { LoggedInInfo.setLoggedInInfoToCurrentClassAndMethod(); try { log.debug("start bed program discharge task"); Program[] bedPrograms = programManager.getBedPrograms(); if (bedPrograms == null) { log.error("getBedPrograms returned null"); return; } for (Program bedProgram : bedPrograms) { MiscUtilsOld.checkShutdownSignaled(); Date dischargeTime = DateTimeFormatUtils.getTimeFromString(DISCHARGE_TIME); Date previousExecutionTime = DateTimeFormatUtils.getTimeFromLong(scheduledExecutionTime() - PERIOD); Date currentExecutionTime = DateTimeFormatUtils.getTimeFromLong(scheduledExecutionTime()); // previousExecutionTime < dischargeTime <= currentExecutionTime if (previousExecutionTime.before(dischargeTime) && (dischargeTime.equals(currentExecutionTime) || dischargeTime.before(currentExecutionTime))) { Bed[] reservedBeds = bedManager.getBedsByProgram(bedProgram.getId(), true); if (reservedBeds == null) { log.error( "getBedsByProgram returned null for bed program with id: " + bedProgram.getId()); continue; } for (Bed reservedBed : reservedBeds) { MiscUtilsOld.checkShutdownSignaled(); BedDemographic bedDemographic = bedDemographicManager.getBedDemographicByBed(reservedBed.getId()); if (bedDemographic != null && bedDemographic.getId() != null && bedDemographic.isExpired()) { try { admissionManager.processDischargeToCommunity( Program.DEFAULT_COMMUNITY_PROGRAM_ID, bedDemographic.getId().getDemographicNo(), Provider.SYSTEM_PROVIDER_NO, "bed reservation ended - automatically discharged", "0", null); } catch (AdmissionException e) { log.error("Error discharging to community", e); } } } } } log.debug("finish bed program discharge task"); } catch (ShutdownException e) { log.debug("BedProgramDischargeTask noticed shutdown signaled."); } finally { LoggedInInfo.loggedInInfo.remove(); DbConnectionFilter.releaseAllThreadDbResources(); } } }
public void skippedEntity(String name) throws SAXException { MiscUtils.getLogger().debug("Skipping entity " + name); }
@Override String getHl7Type() { MiscUtils.getLogger().debug("HSSEmrDownloadHandler getting called"); return "HHSEMR"; }
/** * Properties are loaded in the following order Hard-coded defaults OSCAR system properties file * (pref.<key>) Provider properties (db) * * @author Marc Dumontier */ public class UserPreferenceAction extends DispatchAction { private Logger logger = MiscUtils.getLogger(); protected SecurityDao securityDao = (SecurityDao) SpringUtils.getBean("securityDao"); protected UserPropertyDAO userPropertyDao = (UserPropertyDAO) SpringUtils.getBean("UserPropertyDAO"); static Map<String, String> defaults = new HashMap<String, String>(); protected Map<String, String> siteDefaults = new HashMap<String, String>(); private boolean inited = false; static { defaults.put("pref." + UserProperty.SCHEDULE_START_HOUR, "8"); defaults.put("pref." + UserProperty.SCHEDULE_END_HOUR, "18"); defaults.put("pref." + UserProperty.SCHEDULE_PERIOD, "15"); defaults.put("pref." + UserProperty.NEW_CME, "Enabled"); defaults.put("pref." + UserProperty.ENCOUNTER_FORM_LENGTH, "3"); defaults.put("pref." + UserProperty.RX_USE_RX3, "yes"); } public String getParameter(HttpServletRequest request, String name) { String val = request.getParameter(name); if (val == null) { return new String(); } return val; } protected void init() { try { InputStream in = this.getServlet() .getServletContext() .getResourceAsStream("/WEB-INF/classes/pref.defaults"); Properties p = new Properties(); p.load(in); Iterator<Object> i = p.keySet().iterator(); while (i.hasNext()) { String key = (String) i.next(); String value = p.getProperty(key); this.siteDefaults.put(key, value); logger.info("site default:" + key + "=" + value); } } catch (IOException e) { logger.info("Error", e); } } @Override public ActionForward unspecified( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { return form(mapping, actionForm, request, response); } public ActionForward form( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { if (!inited) init(); Map<String, String> prefs = new HashMap<String, String>(); List<UserProperty> userProperties = userPropertyDao.getDemographicProperties( LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo()); prefs.putAll(defaults); prefs.putAll(siteDefaults); for (UserProperty up : userProperties) { prefs.put(up.getName(), up.getValue()); } request.setAttribute("prefs", prefs); return mapping.findForward("form"); } public ActionForward saveGeneral( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { // Is there a password change? if (!getParameter(request, "new_password").isEmpty()) { try { changePassword(request); } catch (Exception e) { logger.error("Error", e); } } Iterator<Object> iter = request.getParameterMap().keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); if (!key.startsWith("pref.")) continue; String value = request.getParameter(key); // a couple special cases if (key.equals("pref." + UserProperty.ENCOUNTER_FORM_NAME) || key.equals("pref." + UserProperty.EFORM_NAME)) { String[] values = request.getParameterValues(key); StringBuilder sb = new StringBuilder(); for (int x = 0; x < values.length; x++) { if (x > 0) sb.append(","); sb.append(values[x]); } value = sb.toString(); } UserProperty up = userPropertyDao.getProp( LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo(), key); if (up != null) { up.setValue(value); userPropertyDao.saveProp(up); } else { up = new UserProperty(); up.setProviderNo(LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo()); up.setName(key); up.setValue(value); userPropertyDao.saveProp(up); } } return form(mapping, actionForm, request, response); } private void changePassword(HttpServletRequest request) throws Exception { String currentPassword = getParameter(request, "current_password"); String newPassword = getParameter(request, "new_password"); MessageDigest md = MessageDigest.getInstance("SHA"); // the current password byte[] btOldPasswd = md.digest(currentPassword.getBytes()); StringBuilder sbTemp = new StringBuilder(); for (int i = 0; i < btOldPasswd.length; i++) sbTemp = sbTemp.append(btOldPasswd[i]); String stroldpasswd = sbTemp.toString(); // get password from db Security secRecord = securityDao.getByProviderNo( LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo()); String strDBpasswd = secRecord.getPassword(); if (strDBpasswd.length() < 20) { sbTemp = new StringBuilder(); byte[] btDBPasswd = md.digest(secRecord.getPassword().getBytes()); for (int i = 0; i < btDBPasswd.length; i++) sbTemp = sbTemp.append(btDBPasswd[i]); strDBpasswd = sbTemp.toString(); } if (stroldpasswd.equals(strDBpasswd)) { sbTemp = new StringBuilder(); byte[] btNewPasswd = md.digest(newPassword.getBytes()); for (int i = 0; i < btNewPasswd.length; i++) sbTemp = sbTemp.append(btNewPasswd[i]); secRecord.setPassword(sbTemp.toString()); securityDao.merge(secRecord); logger.info("password changed for provider"); } else { throw new Exception("Current password did not match."); } } public static String getTextData(Map<String, String> prefs, String key) { String val = prefs.get(key); if (val == null) { val = new String(); } return "name=\"" + key + "\" value=\"" + val + "\""; } public static String getSelect(Map<String, String> prefs, String key) { StringBuilder sb = new StringBuilder(); List<LabelValueBean> options = getOptions(key); String selectedValue = prefs.get(key); if (selectedValue == null) { selectedValue = new String(); } sb.append("<select name=\"" + key + "\">"); for (LabelValueBean option : options) { String selected = (option.getValue().equals(selectedValue)) ? "selected=\"selected\"" : ""; sb.append( "<option value=\"" + option.getValue() + "\" " + selected + ">" + option.getLabel() + "</option>\n"); } sb.append("</select>"); return sb.toString(); } private static List<LabelValueBean> getOptions(String key) { List<LabelValueBean> options = new ArrayList<LabelValueBean>(); if (key.equals("pref." + UserProperty.SEX)) { options.add(new LabelValueBean("", "")); options.add(new LabelValueBean("Male", "M")); options.add(new LabelValueBean("Female", "F")); } if (key.equals("pref." + UserProperty.HC_TYPE)) { options.add(new LabelValueBean("", "")); options.addAll(constructProvinceList()); } if (key.equals("pref." + UserProperty.WORKLOAD_MANAGEMENT)) { options.add(new LabelValueBean("none", "")); options.addAll(constructWorkloadManagementList()); } if (key.equals("pref." + UserProperty.SCHEDULE_START_HOUR)) { options.addAll(constructScheduleHourList()); } if (key.equals("pref." + UserProperty.SCHEDULE_END_HOUR)) { options.addAll(constructScheduleHourList()); } if (key.equals("pref." + UserProperty.SCHEDULE_PERIOD)) { options.addAll(constructSchedulePeriodList()); } if (key.equals("pref." + UserProperty.MYGROUP_NO)) { options.addAll(constructMyGroupList()); } if (key.equals("pref." + UserProperty.NEW_CME)) { options.add(new LabelValueBean("Enabled", "Enabled")); options.add(new LabelValueBean("Disabled", "Disabled")); } if (key.equals("pref." + UserProperty.STALE_NOTEDATE)) { options.add(new LabelValueBean("All", "All")); for (int x = 1; x <= 36; x++) { options.add(new LabelValueBean(String.valueOf(x), String.valueOf(x))); } } if (key.equals("pref." + UserProperty.RX_USE_RX3)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.RX_SHOW_QR_CODE)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.RX_PAGE_SIZE)) { options.add(new LabelValueBean("A4", "A4")); options.add(new LabelValueBean("A6", "A6")); } if (key.equals("pref." + UserProperty.RX_SHOW_PATIENT_DOB)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.EFORM_FAVOURITE_GROUP)) { EFormGroupDao eFormGroupDao = (EFormGroupDao) SpringUtils.getBean("EFormGroupDao"); options.add(new LabelValueBean("None", "")); List<String> groups = eFormGroupDao.getGroupNames(); for (String group : groups) { options.add(new LabelValueBean(group, group)); } } if (key.equals("pref." + UserProperty.CONSULTATION_TEAM_WARNING)) { options.add(new LabelValueBean("All", "-1")); options.addAll(constructProviderTeamList()); options.add(new LabelValueBean("None", "")); } if (key.equals("pref." + UserProperty.CONSULTATION_REQ_PASTE_FMT)) { options.add(new LabelValueBean("Single Line", "single")); options.add(new LabelValueBean("Multi Line", "multi")); } if (key.equals("pref." + UserProperty.MYMEDS)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.NEW_TICKLER_WARNING_WINDOW)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.CAISI_DEFAULT_PMM)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.CAISI_PREV_BILLING)) { options.add(new LabelValueBean("Yes", "yes")); options.add(new LabelValueBean("No", "no")); } if (key.equals("pref." + UserProperty.DEFAULT_BILLING_FORM)) { options.add(new LabelValueBean("-- no --", "no")); options.addAll(constructWorkloadManagementList()); } if (key.equals("pref." + UserProperty.DEFAULT_REFERRAL_TYPE)) { options.add(new LabelValueBean("Refer To", "1")); options.add(new LabelValueBean("Refer By", "2")); options.add(new LabelValueBean("Neither", "3")); } if (key.equals("pref." + UserProperty.DEFAULT_PAYEE)) { options.add(new LabelValueBean("", "0")); options.addAll(constructPayeeList()); } return options; } public static ArrayList<LabelValueBean> constructProvinceList() { ArrayList<LabelValueBean> provinces = new ArrayList<LabelValueBean>(); provinces.add(new LabelValueBean("AB-Alberta", "AB")); provinces.add(new LabelValueBean("BC-British Columbia", "BC")); provinces.add(new LabelValueBean("MB-Manitoba", "MB")); provinces.add(new LabelValueBean("NB-New Brunswick", "NB")); provinces.add(new LabelValueBean("NL-Newfoundland", "NL")); provinces.add(new LabelValueBean("NT-Northwest Territory", "NT")); provinces.add(new LabelValueBean("NS-Nova Scotia", "NS")); provinces.add(new LabelValueBean("NU-Nunavut", "NU")); provinces.add(new LabelValueBean("ON-Ontario", "ON")); provinces.add(new LabelValueBean("PE-Prince Edward Island", "PE")); provinces.add(new LabelValueBean("QC-Quebec", "QC")); provinces.add(new LabelValueBean("SK-Saskatchewan", "SK")); provinces.add(new LabelValueBean("YT-Yukon", "YK")); provinces.add(new LabelValueBean("US resident", "US")); provinces.add(new LabelValueBean("US-AK-Alaska", "US-AK")); provinces.add(new LabelValueBean("US-AL-Alabama", "US-AL")); provinces.add(new LabelValueBean("US-AR-Arkansas", "US-AR")); provinces.add(new LabelValueBean("US-AZ-Arizona", "US-AZ")); provinces.add(new LabelValueBean("US-CA-California", "US-CA")); provinces.add(new LabelValueBean("US-CO-Colorado", "US-CO")); provinces.add(new LabelValueBean("US-CT-Connecticut", "US-CT")); provinces.add(new LabelValueBean("US-CZ-Canal Zone", "US-CZ")); provinces.add(new LabelValueBean("US-DC-District of Columbia", "US-DC")); provinces.add(new LabelValueBean("US-DE-Delaware", "US-DE")); provinces.add(new LabelValueBean("US-FL-Florida", "US-FL")); provinces.add(new LabelValueBean("US-GA-Georgia", "US-GA")); provinces.add(new LabelValueBean("US-GU-Guam", "US-GU")); provinces.add(new LabelValueBean("US-HI-Hawaii", "US-HI")); provinces.add(new LabelValueBean("US-IA-Iowa", "US-IA")); provinces.add(new LabelValueBean("US-ID-Idaho", "US-ID")); provinces.add(new LabelValueBean("US-IL-Illinois", "US-IL")); provinces.add(new LabelValueBean("US-IN-Indiana", "US-IN")); provinces.add(new LabelValueBean("US-KS-Kansas", "US-KS")); provinces.add(new LabelValueBean("US-KY-Kentucky", "US-KY")); provinces.add(new LabelValueBean("US-LA-Louisiana", "US-LA")); provinces.add(new LabelValueBean("US-MA-Massachusetts", "US-MA")); provinces.add(new LabelValueBean("US-MD-Maryland", "US-MD")); provinces.add(new LabelValueBean("US-ME-Maine", "US-ME")); provinces.add(new LabelValueBean("US-MI-Michigan", "US-MI")); provinces.add(new LabelValueBean("US-MN-Minnesota", "US-MN")); provinces.add(new LabelValueBean("US-MO-Missouri", "US-MO")); provinces.add(new LabelValueBean("US-MS-Mississippi", "US-MS")); provinces.add(new LabelValueBean("US-MT-Montana", "US-MT")); provinces.add(new LabelValueBean("US-NC-North Carolina", "US-NC")); provinces.add(new LabelValueBean("US-ND-North Dakota", "US-ND")); provinces.add(new LabelValueBean("US-NE-Nebraska", "US-NE")); provinces.add(new LabelValueBean("US-NH-New Hampshire", "US-NH")); provinces.add(new LabelValueBean("US-NJ-New Jersey", "US-NJ")); provinces.add(new LabelValueBean("US-NM-New Mexico", "US-NM")); provinces.add(new LabelValueBean("US-NU-Nunavut", "US-NU")); provinces.add(new LabelValueBean("US-NV-Nevada", "US-NV")); provinces.add(new LabelValueBean("US-NY-New York", "US-NY")); provinces.add(new LabelValueBean("US-OH-Ohio", "US-OH")); provinces.add(new LabelValueBean("US-OK-Oklahoma", "US-OK")); provinces.add(new LabelValueBean("US-OR-Oregon", "US-OR")); provinces.add(new LabelValueBean("US-PA-Pennsylvania", "US-PA")); provinces.add(new LabelValueBean("US-PR-Puerto Rico", "US-PR")); provinces.add(new LabelValueBean("US-RI-Rhode Island", "US-RI")); provinces.add(new LabelValueBean("US-SC-South Carolina", "US-SC")); provinces.add(new LabelValueBean("US-SD-South Dakota", "US-SD")); provinces.add(new LabelValueBean("US-TN-Tennessee", "US-TN")); provinces.add(new LabelValueBean("US-TX-Texas", "US-TX")); provinces.add(new LabelValueBean("US-UT-Utah", "US-UT")); provinces.add(new LabelValueBean("US-VA-Virginia", "US-VA")); provinces.add(new LabelValueBean("US-VI-Virgin Islands", "US-VI")); provinces.add(new LabelValueBean("US-VT-Vermont", "US-VT")); provinces.add(new LabelValueBean("US-WA-Washington", "US-WA")); provinces.add(new LabelValueBean("US-WI-Wisconsin", "US-WI")); provinces.add(new LabelValueBean("US-WV-West Virginia", "US-WV")); provinces.add(new LabelValueBean("US-WY-Wyoming", "US-WY")); return provinces; } public static ArrayList<LabelValueBean> constructWorkloadManagementList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); CtlBillingServiceDao ctlBillingServiceDao = (CtlBillingServiceDao) SpringUtils.getBean("ctlBillingServiceDao"); List<Object[]> cbsList = ctlBillingServiceDao.getUniqueServiceTypes(); for (Object[] cbs : cbsList) { results.add(new LabelValueBean((String) cbs[1], (String) cbs[0])); } return results; } public static ArrayList<LabelValueBean> constructScheduleHourList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); for (int x = 0; x < 23; x++) { results.add(new LabelValueBean(String.valueOf(x), (String.valueOf(x)))); } return results; } public static ArrayList<LabelValueBean> constructSchedulePeriodList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); results.add(new LabelValueBean("5", "5")); results.add(new LabelValueBean("10", "10")); results.add(new LabelValueBean("15", "15")); results.add(new LabelValueBean("20", "20")); results.add(new LabelValueBean("30", "30")); results.add(new LabelValueBean("60", "60")); return results; } public static ArrayList<LabelValueBean> constructMyGroupList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); MyGroupDao myGroupDao = (MyGroupDao) SpringUtils.getBean("myGroupDao"); List<String> cbsList = myGroupDao.getGroups(); for (String cbs : cbsList) { results.add(new LabelValueBean(cbs, cbs)); } return results; } public static ArrayList<LabelValueBean> constructEncounterFormList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); EncounterFormDao encounterFormDao = (EncounterFormDao) SpringUtils.getBean("encounterFormDao"); List<EncounterForm> forms = encounterFormDao.findAll(); Collections.sort(forms, EncounterForm.FORM_NAME_COMPARATOR); for (EncounterForm form : forms) { results.add(new LabelValueBean(form.getFormName(), form.getFormName())); } return results; } public static String getEncounterFormHTML(Map<String, String> prefs, String key) { StringBuilder sb = new StringBuilder(); List<LabelValueBean> forms = constructEncounterFormList(); for (LabelValueBean lvb : forms) { String checked = new String(); if (prefs.get(key) != null) { String[] savedValues = prefs.get(key).split(","); for (int x = 0; x < savedValues.length; x++) { if (savedValues[x].equals(lvb.getValue())) { checked = "checked=\"checked\""; } } } sb.append( "<input name=\"pref." + UserProperty.ENCOUNTER_FORM_NAME + "\" value=\"" + lvb.getValue() + "\" type=\"checkbox\" " + checked + "/>" + lvb.getLabel() + "\n"); sb.append("<br/>\n"); } return sb.toString(); } public static ArrayList<LabelValueBean> constructEformList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); EFormDao eFormDao = (EFormDao) SpringUtils.getBean("EFormDao"); List<EForm> forms = eFormDao.findAll(true); Collections.sort(forms, EForm.FORM_NAME_COMPARATOR); for (EForm form : forms) { results.add(new LabelValueBean(form.getFormName(), String.valueOf(form.getId()))); } return results; } public static String getEformHTML(Map<String, String> prefs, String key) { StringBuilder sb = new StringBuilder(); List<LabelValueBean> forms = constructEformList(); for (LabelValueBean lvb : forms) { String checked = new String(); if (prefs.get(key) != null) { String[] savedValues = prefs.get(key).split(","); for (int x = 0; x < savedValues.length; x++) { if (savedValues[x].equals(lvb.getValue())) { checked = "checked=\"checked\""; } } } sb.append( "<input name=\"pref." + UserProperty.EFORM_NAME + "\" value=\"" + lvb.getValue() + "\" type=\"checkbox\" " + checked + "/>" + lvb.getLabel() + "\n"); sb.append("<br/>\n"); } return sb.toString(); } public static ArrayList<LabelValueBean> constructProviderTeamList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao"); List<String> teams = providerDao.getUniqueTeams(); for (String team : teams) { if (team.length() > 0) { results.add(new LabelValueBean(team, team)); } } return results; } public static ArrayList<LabelValueBean> constructPayeeList() { ArrayList<LabelValueBean> results = new ArrayList<LabelValueBean>(); MSPReconcile rec = new MSPReconcile(); @SuppressWarnings("unchecked") List<oscar.entities.Provider> providers = rec.getAllProviders(); for (oscar.entities.Provider provider : providers) { results.add( new LabelValueBean( provider.getLastName() + "," + provider.getFirstName(), provider.getProviderNo())); } return results; } }
/** @author jay */ public class FOBTReport implements PreventionReport { private static Logger log = MiscUtils.getLogger(); /** Creates a new instance of MammogramReport */ public FOBTReport() {} public Hashtable<String, Object> runReport(ArrayList<ArrayList<String>> list, Date asofDate) { int inList = 0; double done = 0, doneWithGrace = 0; ArrayList<PreventionReportDisplay> returnReport = new ArrayList<PreventionReportDisplay>(); for (int i = 0; i < list.size(); i++) { // for each element in arraylist ArrayList<String> fieldList = list.get(i); Integer demo = Integer.valueOf(fieldList.get(0)); // search prevention_date prevention_type deleted refused ArrayList<Map<String, Object>> prevs = PreventionData.getPreventionData("FOBT", demo); PreventionData.addRemotePreventions(prevs, demo, "FOBT", null); ArrayList<Map<String, Object>> colonoscopys = PreventionData.getPreventionData("COLONOSCOPY", demo); PreventionData.addRemotePreventions(colonoscopys, demo, "COLONOSCOPY", null); PreventionReportDisplay prd = new PreventionReportDisplay(); prd.demographicNo = demo; prd.bonusStatus = "N"; prd.billStatus = "N"; Date prevDate = null; if (ineligible(prevs) || colonoscopywith5(colonoscopys, asofDate)) { prd.rank = 5; prd.lastDate = "------"; prd.state = "Ineligible"; prd.numMonths = "------"; prd.color = "grey"; inList++; } else if (prevs.size() == 0) { // no info prd.rank = 1; prd.lastDate = "------"; prd.state = "No Info"; prd.numMonths = "------"; prd.color = "Magenta"; } else { Map<String, Object> h = prevs.get(prevs.size() - 1); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String prevDateStr = (String) h.get("prevention_date"); try { prevDate = formatter.parse(prevDateStr); } catch (Exception e) { // empty } boolean refused = false; if (h.get("refused") != null && ((String) h.get("refused")).equals("1")) { refused = true; } Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -2); Date dueDate = cal.getTime(); cal.add(Calendar.MONTH, -6); Date cutoffDate = cal.getTime(); Calendar cal2 = GregorianCalendar.getInstance(); cal2.add(Calendar.YEAR, -2); // Date dueDate2 = cal.getTime(); // cal2.roll(Calendar.YEAR, -1); cal2.add(Calendar.MONTH, -6); Date cutoffDate2 = cal2.getTime(); log.info("cut 1 " + cutoffDate.toString() + " cut 2 " + cutoffDate2.toString()); // if prevDate is less than as of date and greater than 2 years prior Calendar bonusEl = Calendar.getInstance(); bonusEl.setTime(asofDate); bonusEl.add(Calendar.MONTH, -30); Date bonusStartDate = bonusEl.getTime(); log.debug("\n\n\n prevDate " + prevDate); log.debug("bonusEl date " + bonusStartDate + " " + bonusStartDate.before(prevDate)); log.debug("asofDate date" + asofDate + " " + asofDate.after(prevDate)); String result = PreventionData.getExtValue((String) h.get("id"), "result"); if (!refused && bonusStartDate.before(prevDate) && asofDate.after(prevDate) && !result.equalsIgnoreCase("pending")) { prd.bonusStatus = "Y"; prd.billStatus = "Y"; done++; } // Calendar today = Calendar.getInstance(); // change as of date to run the report for a different year String numMonths = "------"; if (prevDate != null) { int num = UtilDateUtilities.getNumMonths(prevDate, asofDate); numMonths = "" + num + " months"; } // outcomes log.debug( "due Date " + dueDate.toString() + " cutoffDate " + cutoffDate.toString() + " prevDate " + prevDate.toString()); log.debug( "due Date (" + dueDate.toString() + " ) After Prev (" + prevDate.toString() + " ) " + dueDate.after(prevDate)); log.debug( "cutoff Date (" + cutoffDate.toString() + " ) before Prev (" + prevDate.toString() + " ) " + cutoffDate.before(prevDate)); if (!refused && dueDate.after(prevDate) && cutoffDate.before(prevDate)) { // overdue prd.rank = 2; prd.lastDate = prevDateStr; prd.state = "due"; prd.numMonths = numMonths; prd.color = "yellow"; // FF00FF doneWithGrace++; } else if (!refused && cutoffDate.after(prevDate)) { // overdue prd.rank = 2; prd.lastDate = prevDateStr; prd.state = "Overdue"; prd.numMonths = numMonths; prd.color = "red"; // FF00FF } else if (refused) { // recorded and refused prd.rank = 3; prd.lastDate = "-----"; prd.state = "Refused"; prd.numMonths = numMonths; prd.color = "orange"; // FF9933 } else if (dueDate.before(prevDate) && result.equalsIgnoreCase("pending")) { prd.rank = 4; prd.lastDate = prevDateStr; prd.state = "Pending"; prd.numMonths = numMonths; prd.color = "pink"; } else if (dueDate.before(prevDate)) { // recorded done prd.rank = 4; prd.lastDate = prevDateStr; prd.state = "Up to date"; prd.numMonths = numMonths; prd.color = "green"; // done++; } } letterProcessing(prd, "FOBF", asofDate, prevDate); returnReport.add(prd); } String percentStr = "0"; String percentWithGraceStr = "0"; double eligible = list.size() - inList; log.debug("eligible " + eligible + " done " + done); if (eligible != 0) { double percentage = (done / eligible) * 100; double percentageWithGrace = (done + doneWithGrace) / eligible * 100; log.debug("in percentage " + percentage + " " + (done / eligible)); percentStr = "" + Math.round(percentage); percentWithGraceStr = "" + Math.round(percentageWithGrace); } Collections.sort(returnReport); Hashtable<String, Object> h = new Hashtable<String, Object>(); h.put("up2date", "" + Math.round(done)); h.put("percent", percentStr); h.put("percentWithGrace", percentWithGraceStr); h.put("returnReport", returnReport); h.put("inEligible", "" + inList); h.put("eformSearch", "FOBT"); h.put("followUpType", "FOBF"); h.put("BillCode", "Q005A"); log.debug("set returnReport " + returnReport); return h; } boolean ineligible(Map<String, Object> h) { boolean ret = false; if (h.get("refused") != null && ((String) h.get("refused")).equals("2")) { ret = true; } return ret; } boolean ineligible(ArrayList<Map<String, Object>> list) { for (int i = 0; i < list.size(); i++) { Map<String, Object> h = list.get(i); if (ineligible(h)) { return true; } } return false; } boolean colonoscopywith5(ArrayList<Map<String, Object>> list, Date asofDate) { DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.setTime(asofDate); cal.add(Calendar.YEAR, -5); Date fiveyearcutoff = cal.getTime(); for (int i = 0; i < list.size(); i++) { Map<String, Object> h = list.get(i); if (h.get("refused") != null && ((String) h.get("refused")).equals("0")) { String prevDateStr = (String) h.get("prevention_date"); Date prevDate = null; try { prevDate = formatter.parse(prevDateStr); } catch (Exception e) { // empty } if (fiveyearcutoff.before(prevDate)) { log.debug( "Colonoscopy within 5 years: Last colonoscopy " + formatter.format(prevDate) + " 5 year mark " + formatter.format(fiveyearcutoff)); return true; } } } return false; } // TODO: THIS MAY NEED TO BE REFACTORED AT SOME POINT IF MAM and PAP are exactly the same // If they don't have a FOBT Test with guidelines // Get contact methods // NO contact // Send letter // Was last contact within a year ago // NO // Send Letter 1 // Was contact within the last year and at least one month ago // Yes count it // No contacts qualify // send letter 1 // One contact qualifies // send letter 2 // Two contacts qualify // Phone call // Reached limit no contact suggested // Measurement Type will be 1 per Prevention report, with the dataField holding method ie L1, L2, // P1 (letter 1 , letter 2, phone call 1) String LETTER1 = "L1"; String LETTER2 = "L2"; String PHONE1 = "P1"; String CALLFU = "Follow Up"; private String letterProcessing( PreventionReportDisplay prd, String measurementType, Date asofDate, Date prevDate) { if (prd != null) { boolean inclUpToDate = false; if (prd.state.equals("Up to date")) { Calendar cal = Calendar.getInstance(); cal.setTime(asofDate); cal.add(Calendar.YEAR, -2); Date dueDate = cal.getTime(); cal.add(Calendar.MONTH, -6); Date cutoffDate = cal.getTime(); if ((dueDate.after(prevDate) && cutoffDate.before(prevDate)) || cutoffDate.after(prevDate)) { inclUpToDate = true; } } if (prd.state.equals("No Info") || prd.state.equals("due") || prd.state.equals("Overdue") || inclUpToDate) { // Get LAST contact method EctMeasurementsDataBeanHandler measurementDataHandler = new EctMeasurementsDataBeanHandler(prd.demographicNo, measurementType); log.debug("getting followup data for " + prd.demographicNo); Collection<EctMeasurementsDataBean> followupData = measurementDataHandler.getMeasurementsDataVector(); // NO Contact if (followupData.size() == 0) { prd.nextSuggestedProcedure = this.LETTER1; return this.LETTER1; } else { // There has been contact Calendar oneyear = Calendar.getInstance(); oneyear.setTime(asofDate); oneyear.add(Calendar.YEAR, -1); Calendar onemonth = Calendar.getInstance(); onemonth.setTime(asofDate); onemonth.add(Calendar.MONTH, -1); Date observationDate = null; int count = 0; int index = 0; EctMeasurementsDataBean measurementData = null; @SuppressWarnings("unchecked") Iterator<EctMeasurementsDataBean> iterator = followupData.iterator(); while (iterator.hasNext()) { measurementData = iterator.next(); observationDate = measurementData.getDateObservedAsDate(); if (index == 0) { log.debug("fluData " + measurementData.getDataField()); log.debug( "lastFollowup " + measurementData.getDateObservedAsDate() + " last procedure " + measurementData.getDateObservedAsDate()); log.debug("toString: " + measurementData.toString()); prd.lastFollowup = observationDate; prd.lastFollupProcedure = measurementData.getDataField(); if (measurementData.getDateObservedAsDate().before(oneyear.getTime())) { prd.nextSuggestedProcedure = this.LETTER1; return this.LETTER1; } if (prd.lastFollupProcedure.equals(this.PHONE1)) { prd.nextSuggestedProcedure = "----"; return "----"; } } log.debug( prd.demographicNo + " obs" + observationDate + String.valueOf(observationDate.before(onemonth.getTime())) + " OneYear " + oneyear.getTime() + " " + String.valueOf(observationDate.after(oneyear.getTime()))); if (observationDate.before(onemonth.getTime()) && observationDate.after(oneyear.getTime())) { ++count; } else if (count > 1 && observationDate.after(oneyear.getTime())) { ++count; } ++index; } switch (count) { case 0: prd.nextSuggestedProcedure = this.LETTER1; break; case 1: prd.nextSuggestedProcedure = this.LETTER2; break; case 2: prd.nextSuggestedProcedure = this.PHONE1; break; default: prd.nextSuggestedProcedure = "----"; } return prd.nextSuggestedProcedure; /* if ( measurementData.getDateObservedAsDate().before(onemonth.getTime())){ if (prd.lastFollupProcedure.equals(this.LETTER1)){ prd.nextSuggestedProcedure = this.LETTER2; return this.LETTER2; }else if(prd.lastFollupProcedure.equals(this.LETTER2)){ prd.nextSuggestedProcedure = this.PHONE1; return this.PHONE1; }else{ prd.nextSuggestedProcedure = "----"; return "----"; } }else if(prd.lastFollupProcedure.equals(this.LETTER2)){ prd.nextSuggestedProcedure = this.PHONE1; return this.PHONE1; }else{ prd.nextSuggestedProcedure = "----"; return "----"; } */ } } else if (prd.state.equals("Refused")) { // Not sure what to do about refused // prd.lastDate = "-----"; prd.nextSuggestedProcedure = "----"; // prd.numMonths ; } else if (prd.state.equals("Ineligible")) { // Do nothing prd.nextSuggestedProcedure = "----"; } else if (prd.state.equals("Pending")) { prd.nextSuggestedProcedure = this.CALLFU; } else if (prd.state.equals("Up to date")) { // Do nothing prd.nextSuggestedProcedure = "----"; } else { log.debug("NOT SURE WHAT HAPPEND IN THE LETTER PROCESSING"); } } return null; } }
public int addOneClaimHeaderRecord(BillingClaimHeader1Data val) { BillingONCHeader1 b = new BillingONCHeader1(); b.setHeaderId(0); b.setTranscId(val.transc_id); b.setRecId(val.rec_id); b.setHin(val.hin); b.setVer(val.ver); b.setDob(val.dob); b.setPayProgram(val.pay_program); b.setPayee(val.payee); b.setRefNum(val.ref_num); b.setFaciltyNum(val.facilty_num); if (val.admission_date.length() > 0) try { b.setAdmissionDate(dateformatter.parse(val.admission_date)); } catch (ParseException e) { /*empty*/ } b.setRefLabNum(val.ref_lab_num); b.setManReview(val.man_review); b.setLocation(val.location); b.setDemographicNo(Integer.parseInt(val.demographic_no)); b.setProviderNo(val.provider_no); String apptNo = StringUtils.trimToNull(val.appointment_no); if (apptNo != null) { b.setAppointmentNo(Integer.parseInt(val.appointment_no)); } else { b.setAppointmentNo(null); } b.setDemographicName(val.demographic_name); b.setSex(val.sex); b.setProvince(val.province); if (val.billing_date.length() > 0) try { b.setBillingDate(dateformatter.parse(val.billing_date)); } catch (ParseException e) { /*empty*/ } if (val.billing_time.length() > 0) try { b.setBillingTime(timeFormatter.parse(val.billing_time)); } catch (ParseException e) { MiscUtils.getLogger().error("Invalid time", e); } b.setTotal(new BigDecimal(val.total == null ? "0.00" : val.total)); if (val.paid == null || val.paid.isEmpty()) { b.setPaid(new BigDecimal("0.00")); } else { b.setPaid(new BigDecimal(val.paid)); } b.setStatus(val.status); b.setComment(val.comment); b.setVisitType(val.visittype); b.setProviderOhipNo(val.provider_ohip_no); b.setProviderRmaNo(val.provider_rma_no); b.setApptProviderNo(val.apptProvider_no); b.setAsstProviderNo(val.asstProvider_no); b.setCreator(val.creator); b.setClinic(val.clinic); cheaderDao.persist(b); return b.getId(); }