コード例 #1
0
ファイル: MDSSegmentData.java プロジェクト: hexbinary/landing
  public void populateMDSSegmentData(String SID) {
    this.segmentID = SID;
    String associatedOBR = "";
    String labID = "";
    int mdsOBXNum = 0;
    try {

      // Get the header info
      MdsMSHDao mshDao = SpringUtils.getBean(MdsMSHDao.class);
      for (Object[] o : mshDao.findMdsSementDataById(ConversionUtils.fromIntString(segmentID))) {
        Date dateTime = (Date) o[0];
        String controlId = (String) o[1];
        String reportFormStatus = (String) o[2];

        GregorianCalendar cal = new GregorianCalendar(Locale.ENGLISH);
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
        cal.setTime(dateTime);

        reportDate = dateFormat.format(cal.getTime());
        reportStatus = (reportFormStatus.equals("1") ? "Final" : "Partial");
        clientNo = controlId.split("-")[0];
        accessionNo = controlId.split("-")[1];
      }

      // Get the lab ID
      MdsZLBDao zlbDao = SpringUtils.getBean(MdsZLBDao.class);
      MdsZLB zlb = zlbDao.find(ConversionUtils.fromIntString(this.segmentID));
      if (zlb != null) {
        labID = zlb.getLabId();
      }

      // Get the providers
      MdsPV1Dao pvDao = SpringUtils.getBean(MdsPV1Dao.class);
      MdsPV1 pv = pvDao.find(ConversionUtils.fromIntString(this.segmentID));
      if (pv != null) {
        providers = new ProviderData(pv.getRefDoctor(), pv.getConDoctor(), pv.getAdmDoctor());
      } else {
        providers = new ProviderData("", "", "");
      }

      // Get the lab status
      ProviderLabRoutingDao plrDao = SpringUtils.getBean(ProviderLabRoutingDao.class);
      for (Object[] o :
          plrDao.findProviderAndLabRoutingByIdAndLabType(
              ConversionUtils.fromIntString(this.segmentID), "MDS")) {
        Provider provider = (Provider) o[0];
        ProviderLabRoutingModel providerLabRouting = (ProviderLabRoutingModel) o[1];

        statusArray.add(
            new ReportStatus(
                provider.getFirstName() + " " + provider.getLastName(),
                provider.getProviderNo(),
                descriptiveStatus(providerLabRouting.getStatus()),
                providerLabRouting.getComment(),
                ConversionUtils.toDateString(providerLabRouting.getTimestamp()),
                this.segmentID));
      }

      // Get item descriptions and ranges and read into a hashtable
      Hashtable<String, Mnemonics> mnemonics = new Hashtable<String, Mnemonics>();
      MdsZMNDao zmnDao = SpringUtils.getBean(MdsZMNDao.class);
      MdsZMN zmn = zmnDao.find(ConversionUtils.fromIntString(this.segmentID));
      if (zmn != null) {
        mnemonics.put(
            zmn.getResultMnemonic(),
            new Mnemonics(zmn.getReportName(), zmn.getUnits(), zmn.getReferenceRange()));
      }

      // Process the notes
      Hashtable<Integer, ArrayList<String>> notes = new Hashtable<Integer, ArrayList<String>>();
      MdsNTEDao nteDao = SpringUtils.getBean(MdsZMNDao.class);
      MdsZMCDao zmcDao = SpringUtils.getBean(MdsZMCDao.class);
      MdsNTE nte = nteDao.find(labID);
      if (nte != null) {
        if (notes.get(nte.getAssociatedOBX()) == null) {
          notes.put(nte.getAssociatedOBX(), new ArrayList<String>());
        }
        if (nte.getSourceOfComment().equals("M")) {
          ((ArrayList<String>) notes.get(nte.getAssociatedOBX()))
              .add(new String(nte.getComment().substring(3)));
        } else {
          if (nte.getSourceOfComment().equals("MC")) {
            MdsZMC zmc =
                zmcDao.findByIdAndSetId(
                    ConversionUtils.fromIntString(this.segmentID), nte.getComment().substring(1));
            if (zmc == null) {
              zmc =
                  zmcDao.findByIdAndSetId(
                      ConversionUtils.fromIntString(this.segmentID),
                      "%" + nte.getComment().substring(1, nte.getComment().length() - 1) + "%");
            }

            if (zmc != null) {
              ((ArrayList<String>) notes.get(nte.getAssociatedOBX())).add(zmc.getMessageCodeDesc());
            }
          } else {
            logger.info(
                "Found message note in unknown format.  Format:" + nte.getSourceOfComment());
            ((ArrayList<String>) notes.get(nte.getAssociatedOBX())).add("Unknown note format!");
          }
        }
      }

      // Get the report section names
      MdsZRGDao zrgDao = SpringUtils.getBean(MdsZRGDao.class);
      for (Object[] o : zrgDao.findById(ConversionUtils.fromIntString(this.segmentID))) {
        String groupDesc = (String) o[0];
        String groupId = (String) o[1];
        Integer groupIdCount = (Integer) o[2];
        String groupHeading = (String) o[3];

        if (groupIdCount == 1 && !groupHeading.equals("")) {
          String[] rGH = {groupHeading};
          headersArray.add(new Headers(groupDesc, groupId, rGH));
        } else if (groupIdCount > 1) {
          ArrayList<String> tempArray = new ArrayList<String>();
          for (Object oo :
              zrgDao.findReportGroupHeadingsById(
                  ConversionUtils.fromIntString(this.segmentID), groupId)) {
            tempArray.add(String.valueOf(oo));
          }

          String[] reportGroupHeading = new String[tempArray.size()];
          reportGroupHeading = tempArray.toArray(reportGroupHeading);
          headersArray.add(new Headers(groupDesc, groupId, reportGroupHeading));
        } else {
          headersArray.add(new Headers(groupDesc, groupId, null));
        }
      }

      // Create the data structures for each section, grouped by OBR
      MdsOBRDao obrDao = SpringUtils.getBean(MdsOBRDao.class);
      for (int i = 0; i < headersArray.size(); i++) {
        List<String> resultCodes =
            zmnDao.findResultCodes(
                ConversionUtils.fromIntString(this.segmentID), headersArray.get(i).reportSequence);
        for (Object[] ooo :
            obrDao.findByIdAndResultCodes(
                ConversionUtils.fromIntString(this.segmentID), resultCodes)) {
          String associatedObr = (String) ooo[0];
          Date observationDateTime = (Date) ooo[1];
          (headersArray.get(i))
              .groupedReportsArray.add(
                  new GroupedReports(
                      associatedObr,
                      ConversionUtils.toTimestampString(observationDateTime),
                      resultCodes));
        }
      }

      MdsOBXDao obxDao = SpringUtils.getBean(MdsOBXDao.class);
      // Get the actual results
      Mnemonics thisOBXMnemonics = new Mnemonics();
      for (int i = 0; i < (headersArray.size()); i++) {
        for (int j = 0; j < (headersArray.get(i)).groupedReportsArray.size(); j++) {
          associatedOBR = ((headersArray.get(i)).groupedReportsArray.get(j)).associatedOBR;
          List<String> codes = ((headersArray.get(i)).groupedReportsArray.get(j)).codes;

          for (MdsOBX obx :
              obxDao.findByIdObrAndCodes(
                  ConversionUtils.fromIntString(this.segmentID), associatedOBR, codes)) {

            mdsOBXNum = obx.getObxId();
            thisOBXMnemonics.update(
                (Mnemonics)
                    mnemonics.get(
                        obx.getObservationIdentifier()
                            .substring(1, obx.getObservationIdentifier().indexOf('^'))));

            ((headersArray.get(i)).groupedReportsArray.get(j))
                .resultsArray.add(
                    new Results(
                        thisOBXMnemonics.reportName,
                        thisOBXMnemonics.referenceRange,
                        thisOBXMnemonics.units,
                        obx.getObservationValue(),
                        obx.getAbnormalFlags(),
                        obx.getObservationIdentifier(),
                        obx.getObservationResultStatus(),
                        (ArrayList<String>) notes.get(Integer.toString(mdsOBXNum)),
                        obx.getProducersId().substring(0, obx.getProducersId().indexOf('^'))));
          }
        }
      }
    } catch (Exception e) {
      logger.error("In MDS Segment Data", e);
    }
  }
コード例 #2
0
  public ArrayList<LabResultData> populatePathnetResultsData(
      String providerNo,
      String demographicNo,
      String patientFirstName,
      String patientLastName,
      String patientHealthNumber,
      String status) {
    if (providerNo == null) {
      providerNo = "";
    }
    if (patientFirstName == null) {
      patientFirstName = "";
    }
    if (patientLastName == null) {
      patientLastName = "";
    }
    if (patientHealthNumber == null) {
      patientHealthNumber = "";
    }
    if (status == null) {
      status = "";
    }

    ArrayList<LabResultData> labResults = new ArrayList<LabResultData>();
    try {
      Hl7MshDao dao = SpringUtils.getBean(Hl7MshDao.class);

      List<Object[]> pathnetResultsData;

      if (demographicNo == null) {
        pathnetResultsData =
            dao.findPathnetResultsDataByPatientNameHinStatusAndProvider(
                patientLastName + "%^" + patientFirstName + "%",
                "%" + patientHealthNumber + "%",
                "%" + status + "%",
                providerNo.equals("") ? "%" : providerNo,
                "BCP");
      } else {
        pathnetResultsData =
            dao.findPathnetResultsDeomgraphicNo(
                ConversionUtils.fromIntString(demographicNo), "BCP");
      }

      for (Object[] o : pathnetResultsData) {
        Hl7Msh msh = (Hl7Msh) o[0];
        Hl7Pid pid = (Hl7Pid) o[1];
        Hl7Orc orc = (Hl7Orc) o[2];
        ProviderLabRoutingModel p = (ProviderLabRoutingModel) o[4];
        Long stat = (Long) o[5];

        LabResultData lbData = new LabResultData(LabResultData.EXCELLERIS);
        lbData.labType = LabResultData.EXCELLERIS;
        lbData.segmentID = "" + pid.getMessageId();

        if (demographicNo == null && !providerNo.equals("0")) {
          lbData.acknowledgedStatus = p.getStatus();
        } else {
          lbData.acknowledgedStatus = "U";
        }

        lbData.accessionNumber = justGetAccessionNumber(orc.getFillerOrderNumber());

        lbData.healthNumber = pid.getExternalId();
        lbData.patientName = pid.getPatientName();
        if (lbData.patientName != null) {
          lbData.patientName = lbData.patientName.replaceAll("\\^", " ");
        }
        lbData.sex = pid.getSex();
        lbData.resultStatus = "0"; // TODO
        // solve lbData.resultStatus.add(oscar.Misc.getString(rs,"abnormalFlag"));
        lbData.dateTime = ConversionUtils.toTimestampString(msh.getDateTime());

        // priority
        lbData.priority = "----";
        lbData.requestingClient = justGetDocName(orc.getOrderingProvider());
        lbData.reportStatus = "" + stat;

        if (lbData.reportStatus != null && lbData.reportStatus.equals("F")) {
          lbData.finalRes = true;
        } else {
          lbData.finalRes = false;
        }

        labResults.add(lbData);
      }
    } catch (Exception e) {
      logger.error("exception in pathnetPopulate", e);
    }
    return labResults;
  }