Search in sources :

Example 1 with QueryRetrieveView

use of org.dcm4chee.arc.conf.QueryRetrieveView in project dcm4chee-arc-light by dcm4che.

the class QueryAETs method writeTo.

private void writeTo(ApplicationEntity ae, JsonGenerator gen) {
    ArchiveAEExtension arcAE = ae.getAEExtension(ArchiveAEExtension.class);
    JsonWriter writer = new JsonWriter(gen);
    gen.writeStartObject();
    gen.write("dicomAETitle", ae.getAETitle());
    writer.writeNotNullOrDef("dicomDescription", ae.getDescription(), null);
    writer.writeNotEmpty("dcmOtherAETitle", ae.getOtherAETitles());
    if (arcAE != null) {
        QueryRetrieveView queryRetrieveView = arcAE.getQueryRetrieveView();
        writer.writeNotDef("dcmHideNotRejectedInstances", queryRetrieveView != null && queryRetrieveView.isHideNotRejectedInstances(), false);
        writer.writeNotNullOrDef("dcmAllowDeletePatient", arcAE.allowDeletePatient(), null);
        writer.writeNotNullOrDef("dcmAllowDeleteStudyPermanently", arcAE.allowDeleteStudy(), null);
    }
    gen.writeEnd();
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) QueryRetrieveView(org.dcm4chee.arc.conf.QueryRetrieveView) JsonWriter(org.dcm4che3.conf.json.JsonWriter)

Example 2 with QueryRetrieveView

use of org.dcm4chee.arc.conf.QueryRetrieveView in project dcm4chee-arc-light by dcm4che.

the class QueryServiceEJB method getSeriesAttributes.

public Attributes getSeriesAttributes(Long seriesPk, QueryContext context) {
    QueryRetrieveView qrView = context.getQueryParam().getQueryRetrieveView();
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Tuple> q = cb.createTupleQuery();
    Root<Series> series = q.from(Series.class);
    Join<Series, Study> study = series.join(Series_.study);
    Join<Study, Patient> patient = study.join(Study_.patient);
    Join<Series, Metadata> metadata = series.join(Series_.metadata, JoinType.LEFT);
    String viewID = context.getQueryParam().getViewID();
    CollectionJoin<Study, StudyQueryAttributes> studyQueryAttributesPath = QueryBuilder.joinStudyQueryAttributes(cb, study, viewID);
    CollectionJoin<Series, SeriesQueryAttributes> seriesQueryAttributesPath = QueryBuilder.joinSeriesQueryAttributes(cb, series, viewID);
    Path<byte[]> seriesAttrBlob = series.join(Series_.attributesBlob).get(AttributesBlob_.encodedAttributes);
    Path<byte[]> studyAttrBlob = study.join(Study_.attributesBlob).get(AttributesBlob_.encodedAttributes);
    Path<byte[]> patAttrBlob = patient.join(Patient_.attributesBlob).get(AttributesBlob_.encodedAttributes);
    Tuple result;
    try {
        result = em.createQuery(q.multiselect(study.get(Study_.pk), patient.get(Patient_.numberOfStudies), patient.get(Patient_.createdTime), patient.get(Patient_.updatedTime), patient.get(Patient_.verificationTime), patient.get(Patient_.verificationStatus), patient.get(Patient_.failedVerifications), study.get(Study_.createdTime), study.get(Study_.updatedTime), study.get(Study_.accessTime), study.get(Study_.expirationState), study.get(Study_.expirationDate), study.get(Study_.expirationExporterID), study.get(Study_.rejectionState), study.get(Study_.completeness), study.get(Study_.failedRetrieves), study.get(Study_.accessControlID), study.get(Study_.storageIDs), study.get(Study_.size), series.get(Series_.createdTime), series.get(Series_.updatedTime), series.get(Series_.expirationState), series.get(Series_.expirationDate), series.get(Series_.expirationExporterID), series.get(Series_.rejectionState), series.get(Series_.completeness), series.get(Series_.failedRetrieves), series.get(Series_.sendingAET), series.get(Series_.receivingAET), series.get(Series_.sendingPresentationAddress), series.get(Series_.receivingPresentationAddress), series.get(Series_.metadataScheduledUpdateTime), series.get(Series_.metadataUpdateFailures), series.get(Series_.instancePurgeTime), series.get(Series_.instancePurgeState), series.get(Series_.storageVerificationTime), series.get(Series_.failuresOfLastStorageVerification), series.get(Series_.compressionTime), series.get(Series_.compressionFailures), series.get(Series_.transferSyntaxUID), metadata.get(Metadata_.createdTime), metadata.get(Metadata_.storageID), metadata.get(Metadata_.storagePath), metadata.get(Metadata_.digest), metadata.get(Metadata_.size), metadata.get(Metadata_.status), seriesQueryAttributesPath.get(SeriesQueryAttributes_.numberOfInstances), studyQueryAttributesPath.get(StudyQueryAttributes_.numberOfInstances), studyQueryAttributesPath.get(StudyQueryAttributes_.numberOfSeries), studyQueryAttributesPath.get(StudyQueryAttributes_.modalitiesInStudy), studyQueryAttributesPath.get(StudyQueryAttributes_.sopClassesInStudy), seriesAttrBlob, studyAttrBlob, patAttrBlob).where(cb.equal(series.get(Series_.pk), seriesPk))).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
    Long studySize = result.get(study.get(Study_.size));
    if (studySize < 0)
        studySize = querySizeEJB.calculateStudySize(result.get(study.get(Study_.pk)));
    Integer numberOfSeriesRelatedInstances = result.get(seriesQueryAttributesPath.get(SeriesQueryAttributes_.numberOfInstances));
    if (numberOfSeriesRelatedInstances == null) {
        SeriesQueryAttributes seriesQueryAttributes = queryService.calculateSeriesQueryAttributes(seriesPk, qrView);
        numberOfSeriesRelatedInstances = seriesQueryAttributes.getNumberOfInstances();
    }
    int numberOfStudyRelatedSeries;
    String modalitiesInStudy;
    String sopClassesInStudy;
    Integer numberOfStudyRelatedInstances = result.get(studyQueryAttributesPath.get(StudyQueryAttributes_.numberOfInstances));
    if (numberOfStudyRelatedInstances == null) {
        StudyQueryAttributes studyQueryAttributes = queryService.calculateStudyQueryAttributes(result.get(study.get(Study_.pk)), qrView);
        numberOfStudyRelatedInstances = studyQueryAttributes.getNumberOfInstances();
        numberOfStudyRelatedSeries = studyQueryAttributes.getNumberOfSeries();
        modalitiesInStudy = studyQueryAttributes.getModalitiesInStudy();
        sopClassesInStudy = studyQueryAttributes.getSOPClassesInStudy();
    } else {
        numberOfStudyRelatedSeries = result.get(studyQueryAttributesPath.get(StudyQueryAttributes_.numberOfSeries));
        modalitiesInStudy = result.get(studyQueryAttributesPath.get(StudyQueryAttributes_.modalitiesInStudy));
        sopClassesInStudy = result.get(studyQueryAttributesPath.get(StudyQueryAttributes_.sopClassesInStudy));
    }
    Attributes patAttrs = AttributesBlob.decodeAttributes(result.get(patAttrBlob), null);
    Attributes studyAttrs = AttributesBlob.decodeAttributes(result.get(studyAttrBlob), null);
    Attributes seriesAttrs = AttributesBlob.decodeAttributes(result.get(seriesAttrBlob), null);
    Attributes.unifyCharacterSets(patAttrs, studyAttrs, seriesAttrs);
    Attributes attrs = new Attributes(patAttrs.size() + studyAttrs.size() + seriesAttrs.size() + 20);
    attrs.addAll(patAttrs);
    attrs.addAll(studyAttrs, true);
    attrs.addAll(seriesAttrs, true);
    PatientQuery.addPatientQRAttrs(patient, context, result, attrs);
    StudyQuery.addStudyQRAddrs(study, context, result, studySize, numberOfStudyRelatedInstances, numberOfStudyRelatedSeries, modalitiesInStudy, sopClassesInStudy, attrs);
    SeriesQuery.addSeriesQRAttrs(series, metadata, context, result, numberOfSeriesRelatedInstances, attrs);
    return attrs;
}
Also used : Attributes(org.dcm4che3.data.Attributes) QueryRetrieveView(org.dcm4chee.arc.conf.QueryRetrieveView)

Example 3 with QueryRetrieveView

use of org.dcm4chee.arc.conf.QueryRetrieveView in project dcm4chee-arc-light by dcm4che.

the class InstanceQuery method nextMatchFromMetadata.

private Attributes nextMatchFromMetadata() throws IOException {
    QueryRetrieveView qrView = context.getQueryParam().getQueryRetrieveView();
    ZipEntry entry;
    do {
        while ((entry = seriesMetadataStream.getNextEntry()) != null) {
            if (matchSOPInstanceUID(entry.getName())) {
                JSONReader jsonReader = new JSONReader(Json.createParser(new InputStreamReader(seriesMetadataStream, StandardCharsets.UTF_8)));
                jsonReader.setSkipBulkDataURI(true);
                Attributes metadata = jsonReader.readDataset(null);
                if (!qrView.hideRejectedInstance(metadata.getNestedDataset(PrivateTag.PrivateCreator, PrivateTag.RejectionCodeSequence)) && !qrView.hideRejectionNote(metadata) && metadata.matches(instQueryKeys, false, false)) {
                    seriesMetadataStream.closeEntry();
                    Attributes instAtts = new Attributes(metadata, instTags);
                    Attributes.unifyCharacterSets(seriesAttrs, instAtts);
                    Attributes attrs = new Attributes(seriesAttrs.size() + instAtts.size());
                    attrs.addAll(seriesAttrs);
                    attrs.addAll(instAtts, true);
                    return attrs;
                }
            }
            seriesMetadataStream.closeEntry();
        }
    } while (nextSeriesMetadataStream());
    return null;
}
Also used : InputStreamReader(java.io.InputStreamReader) ZipEntry(java.util.zip.ZipEntry) Attributes(org.dcm4che3.data.Attributes) QueryRetrieveView(org.dcm4chee.arc.conf.QueryRetrieveView) JSONReader(org.dcm4che3.json.JSONReader)

Aggregations

QueryRetrieveView (org.dcm4chee.arc.conf.QueryRetrieveView)3 Attributes (org.dcm4che3.data.Attributes)2 InputStreamReader (java.io.InputStreamReader)1 ZipEntry (java.util.zip.ZipEntry)1 JsonWriter (org.dcm4che3.conf.json.JsonWriter)1 JSONReader (org.dcm4che3.json.JSONReader)1 ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)1