コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
  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;
  }