def pull_and_send(self, items: Iterable, source: Orthanc, domain: str, dest: Orthanc, anonymize=False): def mkq(d: Dixel): return {"StudyInstanceUID": d.tags["StudyInstanceUID"]} for d in items: sham_oid = ShamDixel.sham_oid(d) logging.debug(sham_oid) if dest.exists(sham_oid): logging.debug("SKIPPING {}".format(d.tags["PatientName"])) continue if not source.exists(d): source.rfind(mkq(d), domain, level=DicomLevel.STUDIES, retrieve=True) else: logging.debug("SKIPPING PULL for {}".format( d.tags["PatientName"])) replacement_map = ShamDixel.orthanc_sham_map(d) anon_id = source.anonymize(d, replacement_map=replacement_map) source.psend(anon_id, dest) source.delete(anon_id) source.delete(d)
def test_psend(setup_orthanc0, setup_orthanc1): O = Orthanc(peername="peer0") print(O) O.check() O2 = Orthanc(port=8043, peername="peer0") print(O2) O2.check() dicom_dir = find_resource("resources/dcm") D = DcmDir(path=dicom_dir) d = D.get("IM2263", view=DixelView.TAGS_FILE) O2.put(d) logging.debug(O2.gateway._get("peers")) O2.psend(d.oid(), O) e = O.get(d.oid(), level=DicomLevel.INSTANCES) logging.debug(e) assert d.oid() == e.oid()