use of org.weasis.dicom.param.DicomParam in project karnak by OsiriX-Foundation.
the class DicomWorkListLogic method query.
public void query(WorkListQueryData queryData) {
String modalityStr = null;
Modality modality = queryData.getScheduledModality();
if (modality != Modality.ALL) {
modalityStr = modality.name();
}
int[] sps = { Tag.ScheduledProcedureStepSequence };
DicomParam[] RETURN_KEYS = { new DicomParam(Tag.AccessionNumber, queryData.getAccessionNumber()), CFind.IssuerOfAccessionNumberSequence, CFind.ReferringPhysicianName, new DicomParam(Tag.PatientName, queryData.getPatientName()), new DicomParam(Tag.PatientID, queryData.getPatientId()), CFind.IssuerOfPatientID, CFind.PatientBirthDate, CFind.PatientSex, ModalityWorklist.PatientWeight, ModalityWorklist.MedicalAlerts, ModalityWorklist.Allergies, ModalityWorklist.PregnancyStatus, CFind.StudyInstanceUID, ModalityWorklist.RequestingPhysician, ModalityWorklist.RequestingService, ModalityWorklist.RequestedProcedureDescription, ModalityWorklist.RequestedProcedureCodeSequence, new DicomParam(Tag.AdmissionID, queryData.getAdmissionId()), ModalityWorklist.IssuerOfAdmissionIDSequence, ModalityWorklist.SpecialNeeds, ModalityWorklist.CurrentPatientLocation, ModalityWorklist.PatientState, ModalityWorklist.RequestedProcedureID, ModalityWorklist.RequestedProcedurePriority, ModalityWorklist.PatientTransportArrangements, ModalityWorklist.PlacerOrderNumberImagingServiceRequest, ModalityWorklist.FillerOrderNumberImagingServiceRequest, ModalityWorklist.ConfidentialityConstraintOnPatientDataDescription, // Scheduled Procedure Step Sequence
new DicomParam(sps, Tag.Modality, modalityStr), ModalityWorklist.RequestedContrastAgent, new DicomParam(sps, Tag.ScheduledStationAETitle, queryData.getScheduledStationAet()), new DicomParam(sps, Tag.ScheduledProcedureStepStartDate, getDate(queryData.getScheduledFrom())), new DicomParam(sps, Tag.ScheduledProcedureStepEndDate, getDate(queryData.getScheduledTo())), ModalityWorklist.ScheduledPerformingPhysicianName, ModalityWorklist.ScheduledProcedureStepDescription, ModalityWorklist.ScheduledProcedureStepID, ModalityWorklist.ScheduledStationName, ModalityWorklist.ScheduledProcedureStepLocation, ModalityWorklist.PreMedication, ModalityWorklist.ScheduledProcedureStepStatus, ModalityWorklist.ScheduledProtocolCodeSequence };
DicomNode workListNode = new DicomNode(queryData.getWorkListAet(), queryData.getWorkListHostname(), queryData.getWorkListPort());
DicomState state = ModalityWorklist.process(null, new DicomNode(queryData.getCallingAet()), workListNode, 0, RETURN_KEYS);
view.loadAttributes(state.getDicomRSP());
if (state != null && state.getStatus() != Status.Success) {
String errorMsg = "Cannot get a worklist! DICOM error status: " + Integer.toHexString(state.getStatus());
Message message = new Message(MessageLevel.ERROR, MessageFormat.TEXT, errorMsg);
view.displayMessage(message);
}
}
use of org.weasis.dicom.param.DicomParam in project Weasis by nroduit.
the class SearchParameters method buildDicomParams.
private static void buildDicomParams(XMLStreamReader xmler, SearchParameters node) throws XMLStreamException {
String key = xmler.getName().getLocalPart();
if (T_PARAM.equals(key)) {
int tag = StringUtil.getInt(xmler.getAttributeValue(null, T_TAG));
int[] parentSeq = StringUtil.getIntegerArray(xmler.getAttributeValue(null, T_PARENT_SEQ), ",");
List<String> values = new ArrayList<>();
boolean state = true;
while (xmler.hasNext() && state) {
int eventType = xmler.next();
if (eventType == XMLStreamConstants.START_ELEMENT) {
if (T_VALUES.equals(xmler.getName().getLocalPart())) {
boolean stateValues = true;
while (xmler.hasNext() && stateValues) {
eventType = xmler.next();
if (eventType == XMLStreamConstants.START_ELEMENT) {
buildDicomParam(xmler, values);
} else if (eventType == XMLStreamConstants.END_ELEMENT && T_VALUES.equals(xmler.getName().getLocalPart())) {
// NON-NLS
stateValues = false;
}
}
}
DicomParam param = new DicomParam(parentSeq, tag, values.toArray(new String[0]));
node.getParameters().add(param);
} else if (eventType == XMLStreamConstants.END_ELEMENT && T_PARAM.equals(xmler.getName().getLocalPart())) {
// NON-NLS
state = false;
}
}
}
}
use of org.weasis.dicom.param.DicomParam in project Weasis by nroduit.
the class RsQuery method call.
@Override
public Boolean call() throws Exception {
StringBuilder buf = new StringBuilder(getBaseUrl());
// NON-NLS
buf.append("/studies?");
for (int i = 0; i < queries.size(); i++) {
DicomParam query = queries.get(i);
StringJoiner joiner = new StringJoiner(",");
if (query.getValues() != null) {
for (String v : query.getValues()) {
if (StringUtil.hasText(v)) {
String encode = URLEncoder.encode(v, StandardCharsets.UTF_8.toString());
joiner.add(encode);
}
}
}
String value = joiner.toString();
if (StringUtil.hasText(value)) {
buf.append(TagUtils.toHexString(query.getTag()));
buf.append("=");
if (Tag.PatientID == query.getTag()) {
// IssuerOfPatientID filter ( syntax like in HL7 with extension^^^root)
int beginIndex = value.indexOf("^^^");
String patientVal = beginIndex <= 0 ? value : value.substring(0, beginIndex);
buf.append(patientVal);
if (beginIndex > 0) {
buf.append("&00100021=");
buf.append(value.substring(beginIndex + 3));
}
} else {
buf.append(value);
}
if (i + 1 < queries.size()) {
buf.append("&");
}
}
}
buildQueries(buf);
return true;
}
use of org.weasis.dicom.param.DicomParam in project Weasis by nroduit.
the class WorklistDialog method queryWorklist.
private static DicomState queryWorklist(DicomNode calling, DicomNode called) {
DicomParam stationAet = new DicomParam(Tag.ScheduledStationAETitle, calling.getAet());
DicomParam[] keys = { CFind.AccessionNumber, CFind.IssuerOfAccessionNumberSequence, CFind.ReferringPhysicianName, CFind.PatientName, CFind.PatientID, CFind.IssuerOfPatientID, CFind.PatientBirthDate, CFind.PatientSex, ModalityWorklist.PatientWeight, ModalityWorklist.MedicalAlerts, ModalityWorklist.Allergies, ModalityWorklist.PregnancyStatus, CFind.StudyInstanceUID, ModalityWorklist.RequestingPhysician, ModalityWorklist.RequestingService, ModalityWorklist.RequestedProcedureDescription, ModalityWorklist.RequestedProcedureCodeSequence, ModalityWorklist.AdmissionID, ModalityWorklist.IssuerOfAdmissionIDSequence, ModalityWorklist.SpecialNeeds, ModalityWorklist.CurrentPatientLocation, ModalityWorklist.PatientState, ModalityWorklist.RequestedProcedureID, ModalityWorklist.RequestedProcedurePriority, ModalityWorklist.PatientTransportArrangements, ModalityWorklist.PlacerOrderNumberImagingServiceRequest, ModalityWorklist.FillerOrderNumberImagingServiceRequest, ModalityWorklist.ConfidentialityConstraintOnPatientDataDescription, // Scheduled Procedure Step Sequence
ModalityWorklist.Modality, ModalityWorklist.RequestedContrastAgent, stationAet, ModalityWorklist.ScheduledProcedureStepStartDate, ModalityWorklist.ScheduledProcedureStepStartTime, ModalityWorklist.ScheduledPerformingPhysicianName, ModalityWorklist.ScheduledProcedureStepDescription, ModalityWorklist.ScheduledProcedureStepID, ModalityWorklist.ScheduledStationName, ModalityWorklist.ScheduledProcedureStepLocation, ModalityWorklist.PreMedication, ModalityWorklist.ScheduledProcedureStepStatus, ModalityWorklist.ScheduledProtocolCodeSequence };
AdvancedParams params = new AdvancedParams();
ConnectOptions connectOptions = new ConnectOptions();
connectOptions.setConnectTimeout(3000);
connectOptions.setAcceptTimeout(5000);
params.setConnectOptions(connectOptions);
return ModalityWorklist.process(params, calling, called, 0, keys);
}
use of org.weasis.dicom.param.DicomParam in project Weasis by nroduit.
the class WorklistDialog method fillTable.
public void fillTable() {
DicomState state = queryWorklist(calling, called);
jtable.getSelectionModel().removeListSelectionListener(selectionListener);
List<Attributes> items = state.getDicomRSP();
if (items != null && !items.isEmpty()) {
DicomParam[] cols = { CFind.PatientName, CFind.PatientID, CFind.PatientBirthDate, CFind.PatientSex, CFind.AccessionNumber, ModalityWorklist.ScheduledProcedureStepDescription, ModalityWorklist.Modality, ModalityWorklist.ScheduledStationName };
TagW[] tags = TagD.getTagFromIDs(Arrays.stream(cols).mapToInt(DicomParam::getTag).toArray());
Object[][] labels = new Object[items.size()][];
for (int i = 0; i < labels.length; i++) {
Attributes m = items.get(i);
Object[] row = new Object[tags.length];
for (int j = 0; j < tags.length; j++) {
int[] pSeq = cols[j].getParentSeqTags();
if (pSeq == null || pSeq.length == 0) {
row[j] = tags[j].getFormattedTagValue(tags[j].getValue(m), null);
} else {
Attributes parent = m;
for (int value : pSeq) {
Attributes p = parent.getNestedDataset(value);
if (p == null) {
break;
}
parent = p;
}
row[j] = tags[j].getFormattedTagValue(tags[j].getValue(parent), null);
}
}
labels[i] = row;
}
jtable.setModel(new SimpleTableModel(Arrays.stream(tags).map(TagW::getDisplayedName).toArray(String[]::new), labels));
TableColumnAdjuster.pack(jtable);
selectionListener = event -> {
int row = jtable.getSelectedRow();
if (row < 0) {
selectedItem = null;
selection.setText("");
} else {
selectedItem = items.get(row);
TagW name = TagD.get(Tag.PatientName);
StringBuilder buf = new StringBuilder(name.getFormattedTagValue(name.getValue(selectedItem), null));
buf.append(" ");
TagW date = TagD.get(Tag.PatientBirthDate);
buf.append(date.getFormattedTagValue(date.getValue(selectedItem), null));
selection.setText(buf.toString());
}
};
jtable.getSelectionModel().addListSelectionListener(selectionListener);
} else {
if (state.getStatus() != Status.Success) {
GuiExecutor.instance().execute(() -> JOptionPane.showMessageDialog(this, state.getMessage(), null, JOptionPane.ERROR_MESSAGE));
dispose();
throw new IllegalStateException(state.getMessage());
}
jtable.setModel(new SimpleTableModel(new String[] {}, new Object[][] {}));
tableContainer.setPreferredSize(GuiUtils.getDimension(450, 50));
}
tableContainer.setViewportView(jtable);
}
Aggregations