/** * @param routing * @param lab_no * @return True if valid Lab Measurement, else false */ private boolean isValidLabMeasurement(List<PatientLabRouting> routing, String lab_no) { int labNo = Integer.parseInt(lab_no); for (PatientLabRouting entry : routing) { if (entry.getLabNo() == labNo) { return true; } } return false; }
private void populateDemoNo(String labId) { PatientLabRoutingDao dao = SpringUtils.getBean(PatientLabRoutingDao.class); for (PatientLabRouting r : dao.findByLabNoAndLabType(ConversionUtils.fromIntString(labId), "CML")) { String d = r.getDemographicNo().toString(); if (!"0".equals(d)) { this.demographicNo = d; } } }
public boolean isLabLinkedWithPatient(String labId) { PatientLabRoutingDao dao = SpringUtils.getBean(PatientLabRoutingDao.class); for (PatientLabRouting p : dao.findByLabNoAndLabType(ConversionUtils.fromIntString(labId), "BCP")) { String demo = "" + p.getDemographicNo(); if (demo != null && !demo.trim().equals("0")) { return true; } } return false; }
/** Populates ArrayList with labs attached to a consultation request */ public ArrayList<LabResultData> populatePathnetResultsData( String demographicNo, String consultationId, boolean attached) { ArrayList<LabResultData> labResults = new ArrayList<LabResultData>(); ArrayList<LabResultData> attachedLabs = new ArrayList<LabResultData>(); try { ConsultDocsDao dao = SpringUtils.getBean(ConsultDocsDao.class); for (Object[] o : dao.findDocs(ConversionUtils.fromIntString(consultationId))) { ConsultDocs c = (ConsultDocs) o[0]; LabResultData lbData = new LabResultData(LabResultData.EXCELLERIS); lbData.labPatientId = "" + c.getDocumentNo(); attachedLabs.add(lbData); } LabResultData lbData = new LabResultData(LabResultData.EXCELLERIS); LabResultData.CompareId c = lbData.getComparatorId(); Hl7MessageDao hmDao = SpringUtils.getBean(Hl7MessageDao.class); for (Object[] o : hmDao.findByDemographicAndLabType(ConversionUtils.fromIntString(demographicNo), "BCP")) { Hl7Message m = (Hl7Message) o[0]; PatientLabRouting r = (PatientLabRouting) o[1]; lbData.labType = LabResultData.EXCELLERIS; lbData.segmentID = "" + m.getId(); lbData.labPatientId = "" + r.getId(); lbData.dateTime = findPathnetObservationDate(lbData.segmentID); lbData.discipline = findPathnetDisipline(lbData.segmentID); if (attached && Collections.binarySearch(attachedLabs, lbData, c) >= 0) labResults.add(lbData); else if (!attached && Collections.binarySearch(attachedLabs, lbData, c) < 0) labResults.add(lbData); lbData = new LabResultData(LabResultData.EXCELLERIS); } } catch (Exception e) { logger.error("exception in CMLPopulate:", e); } return labResults; }
private List<Lab> assembleLabs() { // Gather hl7TextInfo labs List<PatientLabRouting> tempRouting = patientLabRoutingDao.findByDemographicAndLabType(demographicNo, "HL7"); List<Hl7TextInfo> tempLabs = new ArrayList<Hl7TextInfo>(); for (PatientLabRouting routing : tempRouting) { Hl7TextInfo temp = hl7TextInfoDao.findLabId(routing.getLabNo()); if (temp != null) { tempLabs.add(temp); } } // Short circuit if no labs if (tempLabs.size() < 1) return null; // Gather and filter measurements based on existence of lab_no field List<Measurement> rawMeasurements = measurementDao.findByDemographicNo(demographicNo); List<Measurement> tempMeasurements = new ArrayList<Measurement>(); for (Measurement entry : rawMeasurements) { MeasurementsExt isFromLab = measurementsExtDao.getMeasurementsExtByMeasurementIdAndKeyVal(entry.getId(), "lab_no"); if (isFromLab != null && isValidLabMeasurement(tempRouting, isFromLab.getVal())) { tempMeasurements.add(entry); } } // Gather measurementsExt List<List<MeasurementsExt>> tempMeasurementsExt = new ArrayList<List<MeasurementsExt>>(); for (Measurement entry : tempMeasurements) { List<MeasurementsExt> tempMeasurementsExtElement = measurementsExtDao.getMeasurementsExtByMeasurementId(entry.getId()); tempMeasurementsExt.add(tempMeasurementsExtElement); } // Create Lab Objects List<Lab> allLabs = new ArrayList<Lab>(); // Group Measurements into Lab Objects for (Hl7TextInfo labReport : tempLabs) { Lab labObj = new Lab(); labObj.hl7TextInfo = labReport; // Group Measurements by Lab Number int labNumber = labReport.getLabNumber(); List<Measurement> labMeasurementAll = new ArrayList<Measurement>(); List<List<MeasurementsExt>> labMeasurementsExtAll = new ArrayList<List<MeasurementsExt>>(); for (int i = 0; i < tempMeasurementsExt.size(); i++) { List<MeasurementsExt> entry = tempMeasurementsExt.get(i); String entryLabNo = getLabExtValue(entry, "lab_no"); // Add related entries to correct Lab if (labNumber == Integer.valueOf(entryLabNo)) { labMeasurementsExtAll.add(entry); entry.get(0).getMeasurementId(); Measurement entryMeasurement = tempMeasurements.get(i); labMeasurementAll.add(entryMeasurement); } } // Group Measurements into Organizer Groups int prevGroup = 0; LabGroup tempGroup = new LabGroup(prevGroup); for (int i = 0; i < labMeasurementsExtAll.size(); i++) { String temp = getLabExtValue(labMeasurementsExtAll.get(i), "other_id"); if (temp != null && !temp.isEmpty()) { int currGroup = parseOtherID(temp)[0]; // Create New Group if (prevGroup != currGroup) { labObj.group.add(tempGroup); prevGroup = currGroup; tempGroup = new LabGroup(prevGroup); } } // Add current measurement to Organizer Group tempGroup.measurement.add(labMeasurementAll.get(i)); tempGroup.measurementsExt.add(labMeasurementsExtAll.get(i)); } // Save final Group labObj.group.add(tempGroup); // Save Lab Object allLabs.add(labObj); } return allLabs; }