コード例 #1
0
  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());
  }
コード例 #2
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);
    }
  }