Search in sources :

Example 21 with InstanceLocations

use of org.dcm4chee.arc.store.InstanceLocations in project dcm4chee-arc-light by dcm4che.

the class CopyToRetrieveCacheTask method copiedToRetrieveCache.

public InstanceLocations copiedToRetrieveCache() {
    try {
        LOG.debug("Wait for next finished copy to retrieve cache");
        InstanceLocations inst = completed.take().instanceLocations;
        if (inst == null)
            LOG.debug("No more copy to retrieve cache");
        else
            LOG.debug("Got next finished copy to retrieve cache");
        return inst;
    } catch (InterruptedException e) {
        LOG.error("Failed to wait for next finished copy to retrieve cache:", e);
        return null;
    }
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations)

Example 22 with InstanceLocations

use of org.dcm4chee.arc.store.InstanceLocations in project dcm4chee-arc-light by dcm4che.

the class IocmUtils method linkInstancesWithMWL.

static Attributes linkInstancesWithMWL(StoreSession session, RetrieveService retrieveService, ProcedureService procedureService, ProcedureContext ctx, QueryService queryService, RejectionNote rjNote, Attributes coerceAttrs, InputStream in) throws Exception {
    final Attributes result;
    String studyInstanceUID = ctx.getStudyInstanceUID();
    ArchiveAEExtension arcAE = session.getArchiveAEExtension();
    StoreService storeService = session.getStoreService();
    Attributes instanceRefs = parseSOPInstanceReferences(in);
    ctx.setSourceInstanceRefs(instanceRefs);
    restoreInstances(session, instanceRefs);
    Collection<InstanceLocations> instanceLocations = retrieveService.queryInstances(session, instanceRefs, studyInstanceUID);
    if (instanceLocations.isEmpty())
        return null;
    if (studyInstanceUID.equals(instanceRefs.getString(Tag.StudyInstanceUID))) {
        procedureService.updateStudySeriesAttributes(ctx);
        result = getResult(instanceLocations);
    } else {
        Attributes sopInstanceRefs = getSOPInstanceRefs(instanceRefs, instanceLocations, arcAE.getApplicationEntity());
        moveSequence(sopInstanceRefs, Tag.ReferencedSeriesSequence, instanceRefs);
        session.setAcceptConflictingPatientID(AcceptConflictingPatientID.YES);
        session.setPatientUpdatePolicy(Attributes.UpdatePolicy.PRESERVE);
        session.setStudyUpdatePolicy(arcAE.linkMWLEntryUpdatePolicy());
        result = storeService.copyInstances(session, instanceLocations, coerceAttrs, Attributes.UpdatePolicy.OVERWRITE);
        rejectInstances(instanceRefs, queryService, rjNote, session, result);
    }
    return result;
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) StoreService(org.dcm4chee.arc.store.StoreService)

Example 23 with InstanceLocations

use of org.dcm4chee.arc.store.InstanceLocations in project dcm4chee-arc-light by dcm4che.

the class IocmUtils method copyMove.

static Attributes copyMove(StoreSession session, RetrieveService retrieveService, QueryService queryService, String studyInstanceUID, Attributes coerceAttrs, RejectionNote rjNote, InputStream in) throws Exception {
    ArchiveAEExtension arcAE = session.getArchiveAEExtension();
    StoreService storeService = session.getStoreService();
    Attributes instanceRefs = parseSOPInstanceReferences(in);
    restoreInstances(session, instanceRefs);
    Collection<InstanceLocations> instanceLocations = retrieveService.queryInstances(session, instanceRefs, studyInstanceUID);
    if (instanceLocations.isEmpty())
        return null;
    Attributes sopInstanceRefs = getSOPInstanceRefs(instanceRefs, instanceLocations, arcAE.getApplicationEntity());
    moveSequence(sopInstanceRefs, Tag.ReferencedSeriesSequence, instanceRefs);
    session.setAcceptConflictingPatientID(AcceptConflictingPatientID.YES);
    session.setPatientUpdatePolicy(Attributes.UpdatePolicy.PRESERVE);
    session.setStudyUpdatePolicy(arcAE.copyMoveUpdatePolicy());
    Attributes result = storeService.copyInstances(session, instanceLocations, coerceAttrs, Attributes.UpdatePolicy.MERGE);
    if (rjNote != null)
        rejectInstances(instanceRefs, queryService, rjNote, session, result);
    return result;
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) StoreService(org.dcm4chee.arc.store.StoreService)

Example 24 with InstanceLocations

use of org.dcm4chee.arc.store.InstanceLocations in project dcm4chee-arc-light by dcm4che.

the class WadoRS method retrievePresentionState.

private void retrievePresentionState(RetrieveContext ctx) throws IOException {
    InstanceLocations inst = ctx.getMatches().iterator().next();
    if (ctx.copyToRetrieveCache(inst)) {
        ctx.copyToRetrieveCache(null);
        inst = ctx.copiedToRetrieveCache();
    }
    Attributes attrs;
    try (DicomInputStream dis = service.openDicomInputStream(ctx, inst)) {
        attrs = dis.readDataset();
        service.getAttributesCoercion(ctx, inst).coerce(attrs, null);
    } catch (IOException e) {
        throw e;
    } catch (Exception e) {
        throw new IOException(e);
    }
    Collection<InstanceLocations> matches = new ArrayList<>();
    for (Attributes series : attrs.getSequence(Tag.ReferencedSeriesSequence)) {
        ctx.setSeriesInstanceUIDs(series.getString(Tag.SeriesInstanceUID));
        ctx.setSopInstanceUIDs(series.getSequence(Tag.ReferencedImageSequence).stream().map(item -> item.getString(Tag.ReferencedSOPInstanceUID)).toArray(String[]::new));
        service.calculateMatches(ctx);
        matches.addAll(ctx.getMatches());
    }
    ctx.getMatches().clear();
    ctx.getMatches().addAll(matches);
    ctx.setNumberOfMatches(matches.size());
    presentationState = attrs;
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) DicomInputStream(org.dcm4che3.io.DicomInputStream)

Example 25 with InstanceLocations

use of org.dcm4chee.arc.store.InstanceLocations in project dcm4chee-arc-light by dcm4che.

the class WadoRS method matchPresentionState.

private static boolean matchPresentionState(RetrieveContext ctx) {
    InstanceLocations inst = ctx.getMatches().iterator().next();
    ArchiveDeviceExtension arcDev = ctx.getArchiveAEExtension().getArchiveDeviceExtension();
    return arcDev.isWadoSupportedPRClass(inst.getSopClassUID());
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension)

Aggregations

InstanceLocations (org.dcm4chee.arc.store.InstanceLocations)34 IOException (java.io.IOException)8 RetrieveContext (org.dcm4chee.arc.retrieve.RetrieveContext)7 StoreService (org.dcm4chee.arc.store.StoreService)6 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)5 ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 ZipEntry (java.util.zip.ZipEntry)4 Event (javax.enterprise.event.Event)4 Inject (javax.inject.Inject)4 Attributes (org.dcm4che3.data.Attributes)4 HttpServletRequestInfo (org.dcm4chee.arc.keycloak.HttpServletRequestInfo)4 StoreSession (org.dcm4chee.arc.store.StoreSession)4 Map (java.util.Map)3 ZipOutputStream (java.util.zip.ZipOutputStream)3 Tag (org.dcm4che3.data.Tag)3 DicomInputStream (org.dcm4che3.io.DicomInputStream)3