/** @ejb.interface-method */ public void setAttributes(Dataset ds) { setPpsStartDateTime(ds.getDateTime(Tags.PPSStartDate, Tags.PPSStartTime)); setPpsStatus(ds.getString(Tags.GPPPSStatus)); AttributeFilter filter = AttributeFilter.getExcludePatientAttributeFilter(); byte[] b = DatasetUtils.toByteArray(filter.filter(ds), filter.getTransferSyntaxUID()); if (log.isDebugEnabled()) { log.debug("setEncodedAttributes(byte[" + b.length + "])"); } setEncodedAttributes(b); }
public void addWorklistItem( Long studyPk, String templateFile, String humanPerformerCode, Long scheduleDate) throws Exception { String uri = FileUtils.resolve(new File(templatePath, templateFile + ".xml")).toURI().toString(); if (log.isDebugEnabled()) log.debug("load template file: " + uri); Dataset ds = DatasetUtils.fromXML(new InputSource(uri)); ContentManager cm = getContentManager(); // patient Dataset patDS = cm.getPatientForStudy(studyPk.longValue()); if (log.isDebugEnabled()) { log.debug("Patient Dataset:"); log.debug(patDS); } ds.putAll(patDS.subSet(PAT_ATTR_TAGS)); // Dataset sopInstRef = cm.getSOPInstanceRefMacro(studyPk.longValue(), false); String studyIUID = sopInstRef.getString(Tags.StudyInstanceUID); ds.putUI(Tags.SOPInstanceUID, UIDGenerator.getInstance().createUID()); ds.putUI(Tags.StudyInstanceUID, studyIUID); DcmElement inSq = ds.putSQ(Tags.InputInformationSeq); inSq.addItem(sopInstRef); // Scheduled Human Performer Seq DcmElement schedHPSq = ds.putSQ(Tags.ScheduledHumanPerformersSeq); Dataset item = schedHPSq.addNewItem(); DcmElement hpCodeSq = item.putSQ(Tags.HumanPerformerCodeSeq); Dataset dsCode = (Dataset) this.humanPerformer.get(humanPerformerCode); log.info(dsCode); if (dsCode != null) { hpCodeSq.addItem(dsCode); item.putPN(Tags.HumanPerformerName, dsCode.getString(Tags.CodeMeaning)); } // Scheduled Procedure Step Start Date and Time ds.putDT(Tags.SPSStartDateAndTime, new Date(scheduleDate.longValue())); if (log.isDebugEnabled()) { log.debug("GPSPS Dataset:"); log.debug(ds); } addWorklistItem(ds); }
/** @ejb.interface-method */ public Dataset getAttributes() { return DatasetUtils.fromByteArray(getEncodedAttributes()); }
private void sendMwlItem() throws CreateException, FinderException, Exception { String id = "123"; String PatientId = "PATID-" + id; String PatientName = "Ivanov-" + id + "^I^I"; String PatientBirthDate = "19740301"; String PatientSex = "M"; String AdmissionID = "ADMID-" + id; String ScheduledProcedureStepID = "SPSID-" + id; String RequestedProcedureID = "RPID-" + id; // TODO Auto-generated method stub File fXmlFile = new File("./test/dicom/mwlitem.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); // optional, but recommended // read this - // http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work doc.getDocumentElement().normalize(); System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("attr"); for (int i = 0; i < nList.getLength(); i++) { Node attrNode = nList.item(i); // PatientId if (((Element) (attrNode)).getAttribute("tag").equals("00100020")) { attrNode.getFirstChild().setNodeValue(PatientId); System.out.println("PatientId " + attrNode.getFirstChild().getNodeValue()); } // PatientName if (((Element) (attrNode)).getAttribute("tag").equals("00100010")) { attrNode.getFirstChild().setNodeValue(PatientName); System.out.println("PatientName " + attrNode.getFirstChild().getNodeValue()); } // PatientBirthDate if (((Element) (attrNode)).getAttribute("tag").equals("00100030")) { attrNode.getFirstChild().setNodeValue(PatientBirthDate); System.out.println("PatientBirthDate " + attrNode.getFirstChild().getNodeValue()); } // PatientSex if (((Element) (attrNode)).getAttribute("tag").equals("00100040")) { attrNode.getFirstChild().setNodeValue(PatientSex); System.out.println("PatientSex " + attrNode.getFirstChild().getNodeValue()); } // AdmissionID if (((Element) (attrNode)).getAttribute("tag").equals("00380010")) { attrNode.getFirstChild().setNodeValue(AdmissionID); System.out.println("AdmissionID " + attrNode.getFirstChild().getNodeValue()); } // Scheduled Procedure Step Sequence if (((Element) (attrNode)).getAttribute("tag").equals("00400100")) { NodeList itemList = attrNode.getChildNodes(); for (int j = 0; j < itemList.getLength(); j++) { Node itemNode = itemList.item(j); if (itemNode.getNodeType() == Node.ELEMENT_NODE) { NodeList tagList = ((Element) itemNode).getElementsByTagName("attr"); for (int k = 0; k < tagList.getLength(); k++) { Node itemNode2 = tagList.item(k); // ScheduledProcedureStepID if (((Element) (itemNode2)).getAttribute("tag").equals("00400009")) { itemNode2.getFirstChild().setNodeValue(ScheduledProcedureStepID); System.out.println( "ScheduledProcedureStepID " + itemNode2.getFirstChild().getNodeValue()); } } } } } // RequestedProcedureID if (((Element) (attrNode)).getAttribute("tag").equals("00401001")) { attrNode.getFirstChild().setNodeValue(RequestedProcedureID); System.out.println("RequestedProcedureID " + attrNode.getFirstChild().getNodeValue()); } } TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); String output = writer.getBuffer().toString().replaceAll("\n|\r", ""); // System.out.println("!! "+output); Dataset ds = DatasetUtils.fromXML(output); ds = add(ds); Dataset spsitem = ds.getItem(Tags.SPSSeq); System.out.println( ds.getString(Tags.RequestedProcedureID) + '/' + spsitem.getString(Tags.SPSID)); }