Beispiel #1
0
 private static void checkContentItem(Dataset rqData, int tag, int... sqTags)
     throws DcmServiceException {
   DcmElement sq = rqData.get(tag);
   if (sq == null || sq.isEmpty()) return;
   int[] sqTags1 = cat(sqTags, tag);
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.ValueType, sqTags1);
     type1(item, Tags.ConceptNameCodeSeq, sqTags1);
     checkCodeItem(item, ItemCount.SINGLE, Tags.ConceptNameCodeSeq, sqTags1);
     String valueType = item.getString(Tags.ValueType);
     if (valueType.equals("DATETIME")) type1(item, Tags.DateTime, sqTags1);
     else if (valueType.equals("DATE")) type1(item, Tags.Date, sqTags1);
     else if (valueType.equals("TIME")) type1(item, Tags.Time, sqTags1);
     else if (valueType.equals("PNAME")) type1(item, Tags.PersonName, sqTags1);
     else if (valueType.equals("UIDREF")) type1(item, Tags.UID, sqTags1);
     else if (valueType.equals("TEXT")) type1(item, Tags.TextValue, sqTags1);
     else if (valueType.equals("CODE")) {
       type1(item, Tags.ConceptCodeSeq, sqTags1);
       checkCodeItem(item, ItemCount.SINGLE, Tags.ConceptCodeSeq, sqTags1);
     } else if (valueType.equals("NUMERIC")) {
       type1(item, Tags.NumericValue, sqTags1);
       type1(item, Tags.MeasurementUnitsCodeSeq, sqTags1);
       checkCodeItem(item, ItemCount.SINGLE, Tags.MeasurementUnitsCodeSeq, sqTags1);
     } else
       throw new DcmServiceException(
           Status.InvalidAttributeValue,
           errorMessage("Invalid Value Type: " + valueType + " ", Tags.ValueType, sqTags1));
   }
 }
Beispiel #2
0
 private void checkUPSPerformedProcedure(Dataset rqData) throws DcmServiceException {
   DcmElement sq = rqData.get(Tags.UPSPerformedProcedureSeq);
   if (sq == null || sq.isEmpty()) return;
   int n = sq.countItems();
   if (n > 1)
     throw new DcmServiceException(
         Status.InvalidAttributeValue,
         errorMessage("More than 1 item of Attribute: ", Tags.UPSPerformedProcedureSeq));
   Dataset item = sq.getItem();
   checkActualHumanPerformers(item);
   checkCodeItem(
       item, ItemCount.MULTIPLE, Tags.PerformedStationNameCodeSeq, Tags.UPSPerformedProcedureSeq);
   checkCodeItem(
       item, ItemCount.MULTIPLE, Tags.PerformedStationClassCodeSeq, Tags.UPSPerformedProcedureSeq);
   checkCodeItem(
       item,
       ItemCount.MULTIPLE,
       Tags.PerformedStationGeographicLocationCodeSeq,
       Tags.UPSPerformedProcedureSeq);
   checkCodeItem(
       item,
       ItemCount.MULTIPLE,
       Tags.PerformedProcessingApplicationsCodeSeq,
       Tags.UPSPerformedProcedureSeq);
   checkCodeItem(
       item, ItemCount.SINGLE, Tags.PerformedWorkitemCodeSeq, Tags.UPSPerformedProcedureSeq);
   checkContentItem(item, Tags.PerformedProcessingParametersSeq, Tags.UPSPerformedProcedureSeq);
   checkImageSOPInstanceAndSourceReference(
       item, Tags.OutputInformationSeq, Tags.UPSPerformedProcedureSeq);
 }
  /*
   * Get the contents of an input dataset element by tag,
   * handling CTP elements specially.
   * @param tag the element tag
   * @return the value of the specified element in the current dataset,
   * @throws Exception if the element is missing.
   */
  public String contents(int tag) throws Exception {
    SpecificCharacterSet cs = inDS.getSpecificCharacterSet();

    // Handle FileMetaInfo references
    if ((inFMI != null) && ((tag & 0x7FFFFFFF) < 0x80000)) {
      DcmElement el = inFMI.get(tag);
      if (el == null) throw new Exception(Tags.toString(tag) + " missing");
      return el.getString(cs);
    }

    // Not FMI, handle DataSet references
    boolean ctp = false;
    if (((tag & 0x00010000) != 0) && ((tag & 0x0000ff00) != 0)) {
      int blk = (tag & 0xffff0000) | ((tag & 0x0000ff00) >> 8);
      try {
        ctp = inDS.getString(blk).equals("CTP");
      } catch (Exception notCTP) {
        ctp = false;
      }
    }
    DcmElement el = inDS.get(tag);
    if (el == null) throw new Exception(Tags.toString(tag) + " missing");

    if (ctp) return new String(inDS.getByteBuffer(tag).array());

    String[] s = el.getStrings(cs);
    if (s.length == 1) return s[0];
    if (s.length == 0) return "";
    StringBuffer sb = new StringBuffer(s[0]);
    for (int i = 1; i < s.length; i++) {
      sb.append("\\" + s[i]);
    }
    return sb.toString();
  }
Beispiel #4
0
 private void checkUPSCommunicationsURI(Dataset progressInfo) throws DcmServiceException {
   DcmElement sq = progressInfo.get(Tags.UPSCommunicationsURISeq);
   if (sq == null) return;
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.ContactURI, Tags.UPSProgressInformationSeq, Tags.UPSCommunicationsURISeq);
   }
 }
 /**
  * @param xdsiModel
  * @return
  */
 private Dataset getRootInfo(XDSIModel xdsiModel) {
   Dataset rootInfo = DcmObjectFactory.getInstance().newDataset();
   DcmElement sq = rootInfo.putSQ(Tags.ConceptNameCodeSeq);
   Dataset item = sq.addNewItem();
   CodeItem selectedDocTitle = xdsiModel.selectedDocTitle();
   item.putSH(Tags.CodeValue, selectedDocTitle.getCodeValue());
   item.putSH(Tags.CodingSchemeDesignator, selectedDocTitle.getCodeDesignator());
   item.putLO(Tags.CodeMeaning, selectedDocTitle.getCodeMeaning());
   return rootInfo;
 }
Beispiel #6
0
 private static void checkScheduledHumanPerformers(Dataset rqData) throws DcmServiceException {
   DcmElement sq = rqData.get(Tags.ScheduledHumanPerformersSeq);
   if (sq == null) return;
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.HumanPerformerCodeSeq, Tags.ScheduledHumanPerformersSeq);
     checkCodeItem(
         item, ItemCount.SINGLE, Tags.HumanPerformerCodeSeq, Tags.ScheduledHumanPerformersSeq);
     type1(item, Tags.HumanPerformerName, Tags.ScheduledHumanPerformersSeq);
     type1(item, Tags.HumanPerformerOrganization, Tags.ScheduledHumanPerformersSeq);
   }
 }
Beispiel #7
0
 private static void checkRelatedProcedureSteps(Dataset rqData) throws DcmServiceException {
   DcmElement sq = rqData.get(Tags.RelatedProcedureStepSeq);
   if (sq == null) return;
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.RefSOPClassUID, Tags.RelatedProcedureStepSeq);
     type1(item, Tags.RefSOPInstanceUID, Tags.RelatedProcedureStepSeq);
     type1(item, Tags.PurposeOfReferenceCodeSeq, Tags.RelatedProcedureStepSeq);
     checkCodeItem(
         item, ItemCount.SINGLE, Tags.PurposeOfReferenceCodeSeq, Tags.RelatedProcedureStepSeq);
   }
 }
Beispiel #8
0
 private static void checkActualHumanPerformers(Dataset performedProcedure)
     throws DcmServiceException {
   DcmElement sq = performedProcedure.get(Tags.ActualHumanPerformersSeq);
   if (sq == null) return;
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     checkCodeItem(
         item,
         ItemCount.SINGLE,
         Tags.HumanPerformerCodeSeq,
         Tags.ActualHumanPerformersSeq,
         Tags.UPSPerformedProcedureSeq);
   }
 }
Beispiel #9
0
 private static void checkReferencedRequests(Dataset rqData) throws DcmServiceException {
   DcmElement sq = rqData.get(Tags.RefRequestSeq);
   if (sq == null) return;
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.StudyInstanceUID, Tags.RefRequestSeq);
     type2(item, Tags.AccessionNumber, Tags.RefRequestSeq);
     type2(item, Tags.RequestedProcedureID, Tags.RefRequestSeq);
     type2(item, Tags.RequestedProcedureDescription, Tags.RefRequestSeq);
     type2(item, Tags.RequestedProcedureCodeSeq, Tags.RefRequestSeq);
     checkCodeItem(item, ItemCount.SINGLE, Tags.RequestedProcedureCodeSeq, Tags.RefRequestSeq);
     checkCodeItem(
         item, ItemCount.MULTIPLE, Tags.ReasonforRequestedProcedureCodeSeq, Tags.RefRequestSeq);
   }
 }
Beispiel #10
0
 private void checkUPSProgressInformation(Dataset rqData) throws DcmServiceException {
   DcmElement sq = rqData.get(Tags.UPSProgressInformationSeq);
   if (sq == null || sq.isEmpty()) return;
   int n = sq.countItems();
   if (n > 1)
     throw new DcmServiceException(
         Status.InvalidAttributeValue,
         errorMessage("More than 1 item of Attribute: ", Tags.UPSProgressInformationSeq));
   Dataset item = sq.getItem();
   checkUPSCommunicationsURI(item);
   checkCodeItem(
       item,
       ItemCount.MULTIPLE,
       Tags.UPSDiscontinuationReasonCodeSeq,
       Tags.UPSProgressInformationSeq);
 }
Beispiel #11
0
 private static void checkCodeItem(Dataset rqData, ItemCount itemCount, int tag, int... sqTags)
     throws DcmServiceException {
   DcmElement sq = rqData.get(tag);
   if (sq == null || sq.isEmpty()) return;
   int n = sq.countItems();
   if (itemCount == ItemCount.SINGLE && n > 1)
     throw new DcmServiceException(
         Status.InvalidAttributeValue,
         errorMessage("More than 1 item of Attribute: ", tag, sqTags));
   int[] sqTags1 = cat(sqTags, tag);
   for (int i = 0; i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.CodeValue, sqTags1);
     type1(item, Tags.CodingSchemeDesignator, sqTags1);
     type1(item, Tags.CodeMeaning, sqTags1);
   }
 }
Beispiel #12
0
  private Collection getObserverContextItems(String personName) {
    Dataset ds = dof.newDataset();
    ds.putCS(Tags.RelationshipType, "HAS OBS CONTEXT");
    ds.putCS(Tags.ValueType, "CODE");
    DcmElement cnSq = ds.putSQ(Tags.ConceptNameCodeSeq);
    Dataset cnDS = cnSq.addNewItem();
    cnDS.putSH(Tags.CodeValue, "121005");
    cnDS.putSH(Tags.CodingSchemeDesignator, "DCM");
    cnDS.putLO(Tags.CodeMeaning, "ObserverType");
    DcmElement ccSq = ds.putSQ(Tags.ConceptCodeSeq);
    Dataset ccDS = ccSq.addNewItem();
    ccDS.putSH(Tags.CodeValue, "121006");
    ccDS.putSH(Tags.CodingSchemeDesignator, "DCM");
    ccDS.putLO(Tags.CodeMeaning, "Person");

    Dataset ds1 = dof.newDataset();
    ds1.putCS(Tags.RelationshipType, "HAS OBS CONTEXT");
    ds1.putCS(Tags.ValueType, "PNAME");
    DcmElement cnSq1 = ds1.putSQ(Tags.ConceptNameCodeSeq);
    Dataset cnDS1 = cnSq1.addNewItem();
    cnDS1.putSH(Tags.CodeValue, "121008");
    cnDS1.putSH(Tags.CodingSchemeDesignator, "DCM");
    cnDS1.putLO(Tags.CodeMeaning, "Person Observer Name");
    ds1.putPN(Tags.PersonName, personName);
    ArrayList col = new ArrayList();
    col.add(ds);
    col.add(ds1);
    return col;
  }
 private String[] toIuids(Dataset ds, boolean seriesIuids) throws DcmServiceException {
   List iuids = new ArrayList();
   DcmElement sersq = ds.get(Tags.RefSeriesSeq);
   if (sersq == null) {
     throw new DcmServiceException(Status.MissingAttribute, "Missing Referenced Series Seq.");
   }
   for (int i = 0, n = sersq.countItems(); i < n; ++i) {
     Dataset ser = sersq.getItem(i);
     String siuid = ser.getString(Tags.SeriesInstanceUID);
     if (siuid == null) {
       throw new DcmServiceException(Status.MissingAttribute, "Missing Series Instance UID");
     }
     if (seriesIuids) {
       iuids.add(siuid);
     } else {
       DcmElement sops = ser.get(Tags.RefSOPSeq);
       if (sops == null) {
         throw new DcmServiceException(Status.MissingAttribute, "Missing Referenced SOP Seq.");
       }
       for (int j = 0, m = sops.countItems(); j < m; ++j) {
         Dataset sop = sops.getItem(i);
         String iuid = sop.getString(Tags.RefSOPInstanceUID);
         if (iuid == null) {
           throw new DcmServiceException(
               Status.MissingAttribute, "Missing Referenced SOP Instance UID");
         }
         iuids.add(iuid);
       }
     }
   }
   return (String[]) iuids.toArray(new String[iuids.size()]);
 }
    public PrivateGroupsIndex(Dataset ds) {
      this.ds = ds;
      cs = ds.getSpecificCharacterSet();
      index = new Hashtable<Integer, PrivateGroupIndex>();

      for (Iterator it = ds.iterator(); it.hasNext(); ) {
        DcmElement el = (DcmElement) it.next();
        int tag = el.tag();
        int group = (tag >> 16) & 0xFFFF;
        int element = tag & 0xFFFF;
        if (((group & 1) != 0) && (element < 0x100)) {

          // This is a private group element that claims a block.
          try {
            String blockOwnerID = el.getString(cs);
            if ((blockOwnerID != null) && !(blockOwnerID = blockOwnerID.trim()).equals("")) {

              // Get the index of this group
              Integer gpInteger = new Integer(group);
              PrivateGroupIndex idx = index.get(gpInteger);
              if (idx == null) {
                idx = new PrivateGroupIndex();
                index.put(gpInteger, idx);
              }

              // Store the mapping for this block.
              // Note: this implementation requires that all blocks
              // within a single private group be claimed with unique IDs.
              // The standard doesn't seem to require this constraint, but
              // objects in practice seem to observe it. There is a CP
              // inprocess to require it.
              idx.put(blockOwnerID, new Integer(tag));
            }
          } catch (Exception skip) {
          }
        }
      }
    }
  private Dataset getStudyMgtDataset(StudyLocal study, Map mapSeries) {
    Dataset ds = dof.newDataset();
    ds.putUI(Tags.StudyInstanceUID, study.getStudyIuid());
    ds.putOB(PrivateTags.StudyPk, Convert.toBytes(study.getPk().longValue()));
    ds.putSH(Tags.AccessionNumber, study.getAccessionNumber());
    ds.putLO(Tags.PatientID, study.getPatient().getPatientId());
    ds.putLO(Tags.IssuerOfPatientID, study.getPatient().getIssuerOfPatientId());
    ds.putPN(Tags.PatientName, study.getPatient().getPatientName());

    log.debug("getStudyMgtDataset: studyIUID:" + study.getStudyIuid());
    DcmElement refSeriesSeq = ds.putSQ(Tags.RefSeriesSeq);

    Iterator iter =
        (mapSeries == null) ? study.getSeries().iterator() : mapSeries.keySet().iterator();
    while (iter.hasNext()) {
      SeriesLocal sl = (SeriesLocal) iter.next();
      Dataset dsSer = refSeriesSeq.addNewItem();
      dsSer.putUI(Tags.SeriesInstanceUID, sl.getSeriesIuid());
      Collection instances =
          (mapSeries == null) ? sl.getInstances() : (Collection) mapSeries.get(sl);
      Iterator iter2 = instances.iterator();
      DcmElement refSopSeq = null;
      if (iter2.hasNext()) refSopSeq = dsSer.putSQ(Tags.RefSOPSeq);
      while (iter2.hasNext()) {
        InstanceLocal il = (InstanceLocal) iter2.next();
        Dataset dsInst = refSopSeq.addNewItem();
        dsInst.putUI(Tags.RefSOPClassUID, il.getSopCuid());
        dsInst.putUI(Tags.RefSOPInstanceUID, il.getSopIuid());
        dsInst.putAE(Tags.RetrieveAET, il.getRetrieveAETs());
      }
    }
    if (log.isDebugEnabled()) {
      log.debug("return StgMgtDataset:");
      log.debug(ds);
    }
    return ds;
  }
Beispiel #16
0
  /**
   * @param cuid
   * @param elem
   * @return
   */
  private WaveformGroup[] getWaveformGroups(DcmElement elem, String cuid) {
    float corr = ridSupport.getWaveformCorrection();
    int nrOfWFGroups = elem.countItems();
    if (nrOfWFGroups == 1)
      return new WaveformGroup[] {new WaveformGroup(cuid, elem, 0, corr)}; // dont
    // check
    // the
    // only
    // one

    ArrayList l = new ArrayList(nrOfWFGroups);
    for (int i = 0; i < nrOfWFGroups; i++) {
      try {
        l.add(new WaveformGroup(cuid, elem, i, corr));
      } catch (Exception x) {
        log.warn("Item " + i + " in Waveform Sequence is not valid! Ignored!!");
      }
    }
    return (WaveformGroup[]) l.toArray(new WaveformGroup[l.size()]);
  }
  public void addWorklistItem(
      Long studyPk, String templateFile, String humanPerformerCode, Long scheduleDate)
      throws Exception {
    String uri =
        FileUtils.resolve(new File(templatePath, templateFile + ".xml")).toURI().toString();
    if (log.isDebugEnabled()) log.debug("load template file: " + uri);
    Dataset ds = DatasetUtils.fromXML(new InputSource(uri));

    ContentManager cm = getContentManager();
    // patient
    Dataset patDS = cm.getPatientForStudy(studyPk.longValue());
    if (log.isDebugEnabled()) {
      log.debug("Patient Dataset:");
      log.debug(patDS);
    }

    ds.putAll(patDS.subSet(PAT_ATTR_TAGS));
    //
    Dataset sopInstRef = cm.getSOPInstanceRefMacro(studyPk.longValue(), false);
    String studyIUID = sopInstRef.getString(Tags.StudyInstanceUID);
    ds.putUI(Tags.SOPInstanceUID, UIDGenerator.getInstance().createUID());
    ds.putUI(Tags.StudyInstanceUID, studyIUID);
    DcmElement inSq = ds.putSQ(Tags.InputInformationSeq);
    inSq.addItem(sopInstRef);

    // Scheduled Human Performer Seq
    DcmElement schedHPSq = ds.putSQ(Tags.ScheduledHumanPerformersSeq);
    Dataset item = schedHPSq.addNewItem();
    DcmElement hpCodeSq = item.putSQ(Tags.HumanPerformerCodeSeq);
    Dataset dsCode = (Dataset) this.humanPerformer.get(humanPerformerCode);
    log.info(dsCode);
    if (dsCode != null) {
      hpCodeSq.addItem(dsCode);
      item.putPN(Tags.HumanPerformerName, dsCode.getString(Tags.CodeMeaning));
    }

    // Scheduled Procedure Step Start Date and Time
    ds.putDT(Tags.SPSStartDateAndTime, new Date(scheduleDate.longValue()));

    if (log.isDebugEnabled()) {
      log.debug("GPSPS Dataset:");
      log.debug(ds);
    }

    addWorklistItem(ds);
  }
Beispiel #18
0
 private static void checkImageSOPInstanceAndSourceReference(
     Dataset rqData, int tag, int... sqTags) throws DcmServiceException {
   DcmElement sq = rqData.get(tag);
   if (sq == null) return;
   int[] sqTags1 = cat(sqTags, tag);
   int[] sqTags2 = cat(sqTags1, Tags.RefSOPSeq);
   for (int i = 0, n = sq.countItems(); i < n; i++) {
     Dataset item = sq.getItem(i);
     type1(item, Tags.RefSOPSeq, sqTags1);
     DcmElement refSOPSeq = item.get(Tags.RefSOPSeq);
     for (int j = 0, m = refSOPSeq.countItems(); j < m; j++) {
       Dataset refSOP = refSOPSeq.getItem(j);
       type1(refSOP, Tags.RefSOPClassUID, sqTags2);
       type1(refSOP, Tags.RefSOPInstanceUID, sqTags2);
     }
   }
 }
  private boolean checkDataset(Dataset ds) {
    boolean ok = true;
    for (Iterator it = ds.iterator(); it.hasNext(); ) {
      DcmElement el = (DcmElement) it.next();
      int tag = 0;
      try {
        tag = el.tag();
      } catch (Exception useZero) {
      }
      String command = scriptTable.get(new Integer(tag));
      if (command != null) {
        if (el.vr() == VRs.SQ) {
          Matcher processMatcher = processPattern.matcher(command);
          if (processMatcher.find()) {
            int i = 0;
            Dataset child;
            while ((child = el.getItem(i++)) != null) {
              ok &= checkDataset(child);
            }
          }
        } else {
          Matcher lookupMatcher = lookupPattern.matcher(command);
          // logger.info("Parsing: "+command);
          while (lookupMatcher.find()) {

            int nGroups = lookupMatcher.groupCount();
            String element = lookupMatcher.group(1).trim();
            String keyType = lookupMatcher.group(2).trim() + "/";
            String action = (nGroups > 2) ? lookupMatcher.group(3).trim() : "";
            String regex = (nGroups > 3) ? lookupMatcher.group(4).trim() : "";

            // logger.info("...nGroups  = "+nGroups);
            // logger.info("...element: |"+element+"|");
            // logger.info("...keyType: |"+keyType+"|");
            // logger.info("...action : |"+action+"|");
            // logger.info("...regex:   |"+regex+"|");

            int targetTag = (element.equals("this") ? tag : DicomObject.getElementTag(element));
            String targetValue = handleNull(ds.getString(targetTag));

            if (!targetValue.equals("")) {
              String key = keyType + targetValue;
              if (lutProps.getProperty(key) == null) {
                boolean there = false;
                if (action.equals("keep")
                    || action.equals("skip")
                    || action.equals("remove")
                    || action.equals("empty")
                    || action.equals("default")) there = true;
                else if (action.equals("ignore")) {
                  regex = removeQuotes(regex);
                  there = targetValue.matches(regex);
                }
                try {
                  if (!there) {
                    index.insert(key, keyType, true);
                    ok = false;
                  }
                } catch (Exception ignore) {
                }
              }
            }
          }
        }
      }
    }
    return ok;
  }
 void logInstancesStored(Socket s, SeriesStored seriesStored) {
   try {
     if (auditLogger.isAuditLogIHEYr4()) {
       final AuditLoggerFactory alf = AuditLoggerFactory.getInstance();
       Dataset ian = seriesStored.getIAN();
       Dataset pps = ian.getItem(Tags.RefPPSSeq);
       String ppsiuid = pps != null ? pps.getString(Tags.RefSOPInstanceUID) : null;
       InstancesAction action =
           alf.newInstancesAction(
               "Create",
               ian.getString(Tags.StudyInstanceUID),
               alf.newPatient(seriesStored.getPatientID(), seriesStored.getPatientName()));
       action.setMPPSInstanceUID(ppsiuid);
       action.setAccessionNumber(seriesStored.getAccessionNumber());
       DcmElement sq = ian.getItem(Tags.RefSeriesSeq).get(Tags.RefSOPSeq);
       int n = sq.countItems();
       for (int i = 0; i < n; i++) {
         action.addSOPClassUID(sq.getItem(i).getString(Tags.RefSOPClassUID));
       }
       action.setNumberOfInstances(n);
       RemoteNode remoteNode;
       if (s != null) {
         remoteNode = alf.newRemoteNode(s, seriesStored.getSourceAET());
       } else {
         try {
           InetAddress iAddr = InetAddress.getLocalHost();
           remoteNode = alf.newRemoteNode(iAddr.getHostAddress(), iAddr.getHostName(), "LOCAL");
         } catch (UnknownHostException x) {
           remoteNode = alf.newRemoteNode("127.0.0.1", "localhost", "LOCAL");
         }
       }
       server.invoke(
           auditLogger.getAuditLoggerName(),
           "logInstancesStored",
           new Object[] {remoteNode, action},
           new String[] {RemoteNode.class.getName(), InstancesAction.class.getName()});
     } else {
       InstanceSorter sorter = new InstanceSorter();
       Dataset ian = seriesStored.getIAN();
       String suid = ian.getString(Tags.StudyInstanceUID);
       Dataset series = ian.getItem(Tags.RefSeriesSeq);
       DcmElement refSops = series.get(Tags.RefSOPSeq);
       for (int i = 0, n = refSops.countItems(); i < n; i++) {
         final Dataset refSop = refSops.getItem(i);
         sorter.addInstance(
             suid,
             refSop.getString(Tags.RefSOPClassUID),
             refSop.getString(Tags.RefSOPInstanceUID),
             null);
       }
       InstancesTransferredMessage msg =
           new InstancesTransferredMessage(InstancesTransferredMessage.CREATE);
       String srcAET = seriesStored.getSourceAET();
       String srcHost = s != null ? AuditMessage.hostNameOf(s.getInetAddress()) : null;
       String srcID = srcHost != null ? srcHost : srcAET;
       msg.addSourceProcess(srcID, new String[] {srcAET}, null, srcHost, true);
       msg.addDestinationProcess(
           AuditMessage.getProcessID(),
           calledAETs,
           AuditMessage.getProcessName(),
           AuditMessage.getLocalHostName(),
           false);
       msg.addPatient(seriesStored.getPatientID(), formatPN(seriesStored.getPatientName()));
       String accno = seriesStored.getAccessionNumber();
       Dataset pps = ian.getItem(Tags.RefPPSSeq);
       ParticipantObjectDescription desc = new ParticipantObjectDescription();
       if (accno != null) {
         desc.addAccession(accno);
       }
       if (pps != null) {
         desc.addMPPS(pps.getString(Tags.RefSOPInstanceUID));
       }
       for (String cuid : sorter.getCUIDs(suid)) {
         ParticipantObjectDescription.SOPClass sopClass =
             new ParticipantObjectDescription.SOPClass(cuid);
         sopClass.setNumberOfInstances(sorter.countInstances(suid, cuid));
         desc.addSOPClass(sopClass);
       }
       msg.addStudy(ian.getString(Tags.StudyInstanceUID), desc);
       msg.validate();
       Logger.getLogger("auditlog").info(msg);
     }
   } catch (Exception e) {
     log.warn("Audit Log failed:", e);
   }
 }
Beispiel #21
0
 private void copyCode(boolean copy, Dataset code, DcmElement sq) {
   if (copy && code != null) {
     sq.addItem(code);
   }
 }