Search in sources :

Example 1 with StoreSession

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

the class RejectionServiceImpl method reject.

@Override
public int reject(ApplicationEntity ae, String aet, String studyIUID, String seriesIUID, String sopIUID, RejectionNote rjNote, HttpServletRequestInfo httpRequest) throws Exception {
    String changeRequesterAET = ae.getAEExtension(ArchiveAEExtension.class).changeRequesterAET();
    StoreSession storeSession = storeService.newStoreSession(httpRequest, ae, aet, changeRequesterAET != null ? changeRequesterAET : ae.getAETitle());
    String rejectionNoteObjectStorageID = rejectionNoteObjectStorageID(storeSession);
    storeSession.withObjectStorageID(rejectionNoteObjectStorageID);
    storeService.restoreInstances(storeSession, studyIUID, seriesIUID, null);
    Attributes attrs = queryService.createRejectionNote(ae, studyIUID, seriesIUID, sopIUID, rjNote);
    if (attrs == null)
        return 0;
    int count = countInstances(attrs);
    LOG.info("Start rejection of {} instances of Study[UID={}], Series[UID={}], SOPInstance[UID={}].", count, studyIUID, seriesIUID, sopIUID);
    StoreContext storeCtx = storeService.newStoreContext(storeSession);
    storeCtx.setReceiveTransferSyntax(UID.ExplicitVRLittleEndian);
    storeService.store(storeCtx, attrs);
    LOG.info("Rejection of {} instances of Study[UID={}], Series[UID={}], SOPInstance[UID={}] completed.", count, studyIUID, seriesIUID, sopIUID);
    return count;
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) Attributes(org.dcm4che3.data.Attributes) StoreSession(org.dcm4chee.arc.store.StoreSession) StoreContext(org.dcm4chee.arc.store.StoreContext)

Example 2 with StoreSession

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

the class UPSServiceImpl method onStore.

public void onStore(@Observes StoreContext ctx) {
    if (ctx.getStoredInstance() == null || ctx.getException() != null)
        return;
    StoreSession session = ctx.getStoreSession();
    Calendar now = Calendar.getInstance();
    ArchiveAEExtension arcAE = session.getArchiveAEExtension();
    ArchiveDeviceExtension arcDev = arcAE.getArchiveDeviceExtension();
    arcAE.upsOnStoreStream().filter(upsOnStore -> upsOnStore.match(now, session.getRemoteHostName(), session.getCallingAET(), session.getLocalHostName(), session.getCalledAET(), ctx.getAttributes())).forEach(upsOnStore -> createOrUpdateOnStore(arcDev, ctx, now, upsOnStore));
}
Also used : ArchiveServiceEvent(org.dcm4chee.arc.event.ArchiveServiceEvent) LoggerFactory(org.slf4j.LoggerFactory) UPSEvent(org.dcm4chee.arc.ups.UPSEvent) HL7ConnectionEvent(org.dcm4chee.arc.HL7ConnectionEvent) UPS(org.dcm4chee.arc.entity.UPS) SAXTransformer(org.dcm4che3.io.SAXTransformer) Observes(javax.enterprise.event.Observes) UPSContext(org.dcm4chee.arc.ups.UPSContext) StoreSession(org.dcm4chee.arc.store.StoreSession) Session(javax.websocket.Session) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) org.dcm4che3.net(org.dcm4che3.net) TemplatesCache(org.dcm4che3.io.TemplatesCache) Query(org.dcm4chee.arc.query.Query) Collectors(java.util.stream.Collectors) EJBException(javax.ejb.EJBException) List(java.util.List) HttpServletRequestInfo(org.dcm4chee.arc.keycloak.HttpServletRequestInfo) SAXException(org.xml.sax.SAXException) HL7DeviceExtension(org.dcm4che3.net.hl7.HL7DeviceExtension) ScopeOfAccumulation(org.dcm4che3.dcmr.ScopeOfAccumulation) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Socket(java.net.Socket) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) UPSUtils(org.dcm4chee.arc.ups.UPSUtils) QueryParam(org.dcm4chee.arc.query.util.QueryParam) ReverseDNS(org.dcm4che3.util.ReverseDNS) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Calendar(java.util.Calendar) HL7Application(org.dcm4che3.net.hl7.HL7Application) HL7Charset(org.dcm4che3.hl7.HL7Charset) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) ConfigurationNotFoundException(org.dcm4che3.conf.api.ConfigurationNotFoundException) org.dcm4che3.data(org.dcm4che3.data) IApplicationEntityCache(org.dcm4che3.conf.api.IApplicationEntityCache) StoreContext(org.dcm4chee.arc.store.StoreContext) Event(javax.enterprise.event.Event) org.dcm4chee.arc.conf(org.dcm4chee.arc.conf) UPSService(org.dcm4chee.arc.ups.UPSService) Logger(org.slf4j.Logger) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) HL7SAXTransformer(org.dcm4che3.net.hl7.HL7SAXTransformer) IOException(java.io.IOException) StringUtils(org.dcm4che3.util.StringUtils) QueryContext(org.dcm4chee.arc.query.QueryContext) QueryService(org.dcm4chee.arc.query.QueryService) UnparsedHL7Message(org.dcm4che3.net.hl7.UnparsedHL7Message) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) Calendar(java.util.Calendar) StoreSession(org.dcm4chee.arc.store.StoreSession)

Example 3 with StoreSession

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

the class StoreServiceEJB method applyStudyRetentionPolicy.

private void applyStudyRetentionPolicy(StoreContext ctx, Series series) {
    Study study = series.getStudy();
    LocalDate studyExpirationDate = study.getExpirationDate();
    StoreSession session = ctx.getStoreSession();
    ArchiveAEExtension arcAE = session.getArchiveAEExtension();
    StudyRetentionPolicy retentionPolicy = arcAE.findStudyRetentionPolicy(session.getRemoteHostName(), session.getCallingAET(), session.getLocalHostName(), session.getCalledAET(), ctx.getAttributes());
    if (retentionPolicy != null && retentionPolicy.isFreezeExpirationDate() && retentionPolicy.isRevokeExpiration()) {
        LOG.info("Protect Study[UID={}] from being expired, triggered by {}. Set ExpirationDate[=null] and " + "ExpirationState[={FROZEN}].", study.getStudyInstanceUID(), retentionPolicy);
        freezeStudyAndItsSeries(series, study, null, "Protect");
        return;
    }
    if (study.getExpirationState() == ExpirationState.FROZEN) {
        freezeSeries(series, study, studyExpirationDate, "Freeze");
        return;
    }
    if (retentionPolicy == null)
        return;
    study.setExpirationExporterID(retentionPolicy.getExporterID());
    LocalDate expirationDate = retentionPolicy.expirationDate(ctx.getAttributes());
    if (retentionPolicy.isFreezeExpirationDate()) {
        LOG.info("Freeze Study[UID={}] with ExpirationDate[={}] and ExpirationState[=FROZEN], triggered by {}", study.getStudyInstanceUID(), expirationDate, retentionPolicy);
        freezeStudyAndItsSeries(series, study, expirationDate, "Freeze");
    } else {
        if (studyExpirationDate == null || studyExpirationDate.compareTo(expirationDate) < 0)
            study.setExpirationDate(expirationDate);
        if (retentionPolicy.isExpireSeriesIndividually())
            series.setExpirationDate(expirationDate);
    }
}
Also used : LocalDate(java.time.LocalDate) StoreSession(org.dcm4chee.arc.store.StoreSession)

Example 4 with StoreSession

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

the class StoreServiceEJB method updateStudy.

private Study updateStudy(StoreContext ctx, Study study, Date now, String reason) {
    StoreSession session = ctx.getStoreSession();
    Attributes.UpdatePolicy updatePolicy = study.getRejectionState() == RejectionState.EMPTY ? Attributes.UpdatePolicy.OVERWRITE : session.getStudyUpdatePolicy();
    ArchiveDeviceExtension arcDev = getArchiveDeviceExtension();
    AttributeFilter filter = arcDev.getAttributeFilter(Entity.Study);
    Attributes attrs = study.getAttributes();
    UpdateInfo updateInfo = new UpdateInfo(attrs);
    Attributes.unifyCharacterSets(attrs, ctx.getAttributes());
    if (!attrs.updateSelected(updatePolicy, ctx.getAttributes(), updateInfo.modified, filter.getSelection(false)))
        return study;
    updateInfo.log(session, study, attrs);
    study = em.find(Study.class, study.getPk());
    study.setAttributes(recordAttributeModification(ctx) ? attrs.addOriginalAttributes(null, now, reason, device.getDeviceName(), updateInfo.modified) : attrs, filter, true, arcDev.getFuzzyStr());
    study.setIssuerOfAccessionNumber(findOrCreateIssuer(attrs, Tag.IssuerOfAccessionNumberSequence));
    study.setIssuerOfAdmissionID(findOrCreateIssuer(attrs, Tag.IssuerOfAdmissionIDSequence));
    setCodes(study.getProcedureCodes(), attrs, Tag.ProcedureCodeSequence);
    em.createNamedQuery(Series.SCHEDULE_METADATA_UPDATE_FOR_STUDY).setParameter(1, study).executeUpdate();
    return study;
}
Also used : StoreSession(org.dcm4chee.arc.store.StoreSession)

Example 5 with StoreSession

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

the class StoreServiceEJB method copyLocations.

private void copyLocations(StoreContext ctx, Instance instance, UpdateDBResult result) {
    StoreSession session = ctx.getStoreSession();
    Map<Long, UIDMap> uidMapCache = session.getUIDMapCache();
    Map<String, String> uidMap = session.getUIDMap();
    for (Location prevLocation : ctx.getLocations()) {
        result.getLocations().add(copyLocation(session, prevLocation, instance, uidMap, uidMapCache));
        if (prevLocation.getObjectType() == Location.ObjectType.DICOM_FILE)
            instance.getSeries().getStudy().addStorageID(prevLocation.getStorageID());
    }
}
Also used : StoreSession(org.dcm4chee.arc.store.StoreSession)

Aggregations

StoreSession (org.dcm4chee.arc.store.StoreSession)47 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)15 StoreContext (org.dcm4chee.arc.store.StoreContext)13 ApplicationEntity (org.dcm4che3.net.ApplicationEntity)10 IOException (java.io.IOException)7 Attributes (org.dcm4che3.data.Attributes)6 QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)6 ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)5 ArchiveDeviceExtension (org.dcm4chee.arc.conf.ArchiveDeviceExtension)5 Storage (org.dcm4chee.arc.storage.Storage)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Date (java.util.Date)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)4 Location (org.dcm4chee.arc.entity.Location)4 HttpServletRequestInfo (org.dcm4chee.arc.keycloak.HttpServletRequestInfo)4 Outcome (org.dcm4chee.arc.qmgt.Outcome)4 LocalDate (java.time.LocalDate)3