Пример #1
0
 private DicomObject toSCN(DicomObject ian) {
   DicomObject scn = new BasicDicomObject();
   scn.putString(Tag.PatientID, VR.LO, ian.getString(Tag.PatientID));
   scn.putString(Tag.PatientName, VR.PN, ian.getString(Tag.PatientName));
   scn.putString(Tag.StudyID, VR.SH, ian.getString(Tag.StudyID));
   scn.putString(Tag.StudyInstanceUID, VR.UI, ian.getString(Tag.StudyInstanceUID));
   DicomElement ianSeriesSeq = ian.get(Tag.ReferencedSeriesSequence);
   DicomElement scnSeriesSeq = scn.putSequence(Tag.ReferencedSeriesSequence);
   DicomObject ianSeriesItem, scnSeriesItem, scnSOPItem;
   DicomElement ianSOPSeq, scnSOPSeq;
   for (int i = 0, n = ianSeriesSeq.countItems(); i < n; ++i) {
     ianSeriesItem = ianSeriesSeq.getDicomObject(i);
     scnSeriesItem = new BasicDicomObject();
     scnSeriesItem.putString(
         Tag.SeriesInstanceUID, VR.UI, ianSeriesItem.getString(Tag.SeriesInstanceUID));
     scnSeriesSeq.addDicomObject(scnSeriesItem);
     ianSOPSeq = ianSeriesItem.get(Tag.ReferencedSOPSequence);
     scnSOPSeq = scnSeriesItem.putSequence(Tag.ReferencedImageSequence);
     for (int j = 0, m = ianSOPSeq.countItems(); j < m; ++j) {
       scnSOPItem = new BasicDicomObject();
       ianSOPSeq.getDicomObject(j).exclude(INSTANCE_AVAILABILITY).copyTo(scnSOPItem);
       scnSOPSeq.addDicomObject(scnSOPItem);
     }
   }
   return scn;
 }
Пример #2
0
  private void insertDicomTags(
      int dcmobject_id, DicomObject obj, Integer parentId, PreparedStatement stmt)
      throws Exception {

    for (Iterator<DicomElement> it = obj.iterator(); it.hasNext(); ) {
      DicomElement e = it.next();

      StringBuffer sb = new StringBuffer();
      try {
        String[] values = e.getStrings(obj.getSpecificCharacterSet(), false);
        sb.append(values[0].replaceAll("\0", ""));
        int i;
        for (i = 1; i < values.length; i++) {
          sb.append("/").append(values[i].replaceAll("\0", ""));
        }

      } catch (Exception ee) {
        try {
          sb.append(e.getString(obj.getSpecificCharacterSet(), false));
        } catch (Exception e2) {

        }
      }
      stmt.setInt(1, dcmobject_id);
      stmt.setString(2, DicomHeader.toTagString(e.tag()));
      stmt.setString(3, e.vr().toString());

      // only the first 150 chars are saved if the tag-value is longer
      if (sb.length() > 150) {
        stmt.setString(
            4, sb.toString().substring(0, 150).concat("*** end of tag-value not applicable ***"));
      } else {
        stmt.setString(4, sb.toString());
      }

      stmt.setInt(5, itemOrder);
      if (parentId == null) {
        stmt.setNull(6, Types.INTEGER);
      } else {
        stmt.setInt(6, parentId);
      }
      stmt.addBatch();
      // System.out.println( stmt );

      itemOrder++;
      if (e.countItems() > 0) {
        if (e.hasDicomObjects()) {
          for (int i = 0; i < e.countItems(); i++) {
            insertDicomTags(dcmobject_id, e.getDicomObject(i), itemOrder - 1, stmt);
          }
        }
      }
    }
  }
Пример #3
0
 private DicomObject mkStgCmtResult(Association as, DicomObject rqdata) {
   DicomObject result = new BasicDicomObject();
   result.putString(Tag.TransactionUID, VR.UI, rqdata.getString(Tag.TransactionUID));
   DicomElement rqsq = rqdata.get(Tag.ReferencedSOPSequence);
   DicomElement resultsq = result.putSequence(Tag.ReferencedSOPSequence);
   if (stgcmtRetrieveAET != null) {
     result.putString(Tag.RetrieveAETitle, VR.AE, stgcmtRetrieveAET);
   }
   DicomElement failedsq = null;
   File dir = getDir(as);
   for (int i = 0, n = rqsq.countItems(); i < n; i++) {
     DicomObject rqItem = rqsq.getDicomObject(i);
     String uid = rqItem.getString(Tag.ReferencedSOPInstanceUID);
     DicomObject resultItem = new BasicDicomObject();
     rqItem.copyTo(resultItem);
     if (stgcmtRetrieveAETs != null) {
       resultItem.putString(Tag.RetrieveAETitle, VR.AE, stgcmtRetrieveAETs);
     }
     File f = new File(dir, uid);
     if (f.isFile()) {
       resultsq.addDicomObject(resultItem);
     } else {
       resultItem.putInt(Tag.FailureReason, VR.US, NO_SUCH_OBJECT_INSTANCE);
       if (failedsq == null) {
         failedsq = result.putSequence(Tag.FailedSOPSequence);
       }
       failedsq.addDicomObject(resultItem);
     }
   }
   return result;
 }