Search in sources :

Example 11 with UPSContext

use of org.dcm4chee.arc.ups.UPSContext in project dcm4chee-arc-light by dcm4che.

the class UpsCSV method createUPSRecords.

private int createUPSRecords(Map<String, IDWithIssuer> studyPatientMap, String movescp) {
    int count = 0;
    for (Map.Entry<String, IDWithIssuer> studyPatient : studyPatientMap.entrySet()) {
        try {
            UPSContext ctx = upsService.newUPSContext(httpServletRequestInfo, arcAE);
            ctx.setUPSInstanceUID(UIDUtils.createUID());
            UPSUtils.updateUPSTemplateAttrs(arcAE, upsTemplateAttrs, studyPatient, movescp);
            ctx.setAttributes(upsTemplateAttrs);
            UPS ups = upsService.createUPS(ctx);
            LOG.info("UPSTemplateWorkitem[uid={}]: created {}", upsTemplateAttrs.getString(Tag.SOPInstanceUID), ups);
            count++;
        } catch (Exception e) {
            LOG.info("UPSTemplateWorkitem[uid={}]: create UPS failed for Study[uid={}] of Patient[id={}]\n", upsTemplateAttrs.getString(Tag.SOPInstanceUID), studyPatient.getKey(), studyPatient.getValue(), e);
        }
    }
    return count;
}
Also used : UPSContext(org.dcm4chee.arc.ups.UPSContext) UPS(org.dcm4chee.arc.entity.UPS) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with UPSContext

use of org.dcm4chee.arc.ups.UPSContext in project dcm4chee-arc-light by dcm4che.

the class UpsMatchingRS method upsTemplateAttrs.

private Attributes upsTemplateAttrs(String upsTemplateUID, ArchiveAEExtension arcAE) throws DicomServiceException {
    UPSContext ctx = upsService.newUPSContext(HttpServletRequestInfo.valueOf(request), arcAE);
    ctx.setUPSInstanceUID(upsTemplateUID);
    Attributes upsAttrs = upsService.findUPS(ctx).getAttributes();
    upsAttrs.setDate(Tag.ScheduledProcedureStepStartDateTime, VR.DT, scheduledTime());
    if (upsLabel != null)
        upsAttrs.setString(Tag.ProcedureStepLabel, VR.LO, upsLabel);
    return upsAttrs;
}
Also used : UPSContext(org.dcm4chee.arc.ups.UPSContext) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes)

Example 13 with UPSContext

use of org.dcm4chee.arc.ups.UPSContext in project dcm4chee-arc-light by dcm4che.

the class UpsMatchingRS method createUPS.

private void createUPS(ArchiveAEExtension arcAE, Attributes ups, AtomicInteger count) {
    UPSContext ctx = upsService.newUPSContext(HttpServletRequestInfo.valueOf(request), arcAE);
    ctx.setUPSInstanceUID(UIDUtils.createUID());
    ctx.setAttributes(ups);
    try {
        upsService.createUPS(ctx);
        count.getAndIncrement();
    } catch (DicomServiceException e) {
        LOG.info("Failed to create UPS record for Study[uid={}]\n", ups.getSequence(Tag.InputInformationSequence).get(0).getString(Tag.StudyInstanceUID), e);
    }
}
Also used : UPSContext(org.dcm4chee.arc.ups.UPSContext) DicomServiceException(org.dcm4che3.net.service.DicomServiceException)

Example 14 with UPSContext

use of org.dcm4chee.arc.ups.UPSContext in project dcm4chee-arc-light by dcm4che.

the class UPSServiceImpl method createUPSOnUPSCompleted.

private void createUPSOnUPSCompleted(UPSContext ctx, UPS prevUPS, UPSOnUPSCompleted rule, Calendar now) {
    UPSContext upsCtx = newUPSContext(ctx);
    upsCtx.setUPSInstanceUID(rule.getInstanceUID(prevUPS.getAttributes()));
    upsCtx.setAttributes(upsOnCompleted(upsCtx, prevUPS, now, rule));
    try {
        createUPS(upsCtx);
    } catch (DicomServiceException e) {
        LOG.info("Failed to apply {} create on completion of {}", rule, prevUPS, e);
    }
}
Also used : UPSContext(org.dcm4chee.arc.ups.UPSContext) DicomServiceException(org.dcm4che3.net.service.DicomServiceException)

Example 15 with UPSContext

use of org.dcm4chee.arc.ups.UPSContext in project dcm4chee-arc-light by dcm4che.

the class UPSServiceImpl method onUPSCompleted.

private void onUPSCompleted(UPSContext ctx, UPS ups) {
    Calendar now = Calendar.getInstance();
    ctx.getArchiveAEExtension().upsOnUPSCompletedStream().filter(rule -> rule.getConditions().match(ctx.getRemoteHostName(), ctx.getRequesterAET(), ctx.getLocalHostName(), ctx.getApplicationEntity().getAETitle(), ups.getAttributes())).peek(rule -> LOG.info("Apply {} on completion of {}", rule, ups)).filter(rule -> isRequiredOtherUPSCompleted(ctx, ups, rule)).forEach(rule -> createUPSOnUPSCompleted(ctx, ups, rule, now));
}
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)

Aggregations

UPSContext (org.dcm4chee.arc.ups.UPSContext)25 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)16 UPS (org.dcm4chee.arc.entity.UPS)3 QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)3 Date (java.util.Date)2 IOException (java.io.IOException)1 Socket (java.net.Socket)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 EJBException (javax.ejb.EJBException)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Event (javax.enterprise.event.Event)1 Observes (javax.enterprise.event.Observes)1 Inject (javax.inject.Inject)1 Session (javax.websocket.Session)1