Skip to content

Instantly share code, notes, and snippets.

@derekmerck
Last active August 29, 2015 14:22
Show Gist options
  • Save derekmerck/5d4f40a7b952525a09c4 to your computer and use it in GitHub Desktop.
Save derekmerck/5d4f40a7b952525a09c4 to your computer and use it in GitHub Desktop.
RIH 3D Lab DICOM Deidentification Rules v1.0
describe rule_name hidden
describe rule_version hidden
describe rule_author hidden
// ==================================================
rule_name := "General DICOM Deidentification Rules"
rule_version := "v1.0"
rule_author := "RIH 3D Lab"
// by Derek Merck <derek_merck@brown.edu> and Scott Collins
// Spring 2015
// <https://gist.github.com/derekmerck/5d4f40a7b952525a09c4#file-3dlab_anon-das>
// ==================================================
// Requirements
// --------------------------------------------------
// Requires `DicomRemap` from the DicomBrowser command line tools
//
// - Script is based on NRG sample anonymization script v. 001, 2010-06-21
// by Kevin Archie <karchie@wustl.edu>
// - DicomEdit language specification:
// <http://nrg.wustl.edu/software/dicomedit/dicomedit-reference/>
// Requires [GID_Mint](https://github.com/derekmerck/GID_Mint)
// for global subject and study IDs and placeholder names
//
// - Public instance is available on heroku at <http://get-a-gid.herokuapp.com>
// - Can also be run locally on port 5000
describe ggid_base_url hidden
//ggid_base_url := "http://get-a-gid.herokuapp.com"
ggid_base_url := "http://localhost:5000"
// Todo
// --------------------------------------------------
// 1. Use study description (0008,1030) for project enrollment
// - For example, on older/pre-epic ablation studies, it was
// "LIVER ABLATION"
// - For newer ones it is be something like "CT Ablation Pulmonary
// Tumor Pleura Right" or "CT RF Ablation Renal", or "CT RF Ablation
// Bone Percutaneous". Probably just look for "Ablation"
// Compute Placeholder Values
// --------------------------------------------------
// Temporary query strings apparently can not be reused
describe ggid_query_url0 hidden
describe ggid_query_url1 hidden
describe ggid_query_url2 hidden
describe ggid_query_url3 hidden
describe ggid_query_url4 hidden
describe ggid_query_url5 hidden
// Hash the accession number to prevent redundant uploads
ggid_query_url0 := format["{0}/giri?institution={1}&record_id={2}", \
ggid_base_url, urlEncode[(0008,0080)], urlEncode[(0008,0050)]]
describe accession_giri hidden
accession_giri := getURL[ggid_query_url0]
// Get the global subject ID for this pname
ggid_query_url1 := format["{0}/gsid?pname={1}&dob={2}", \
ggid_base_url, urlEncode[(0010,0010)], urlEncode[(0010,0030)]]
describe gsid hidden
gsid := getURL[ggid_query_url1]
// Get a placeholder name based on the gsid
ggid_query_url2 := format["{0}/ppname?gid={1}", \
ggid_base_url, gsid]
describe ppname hidden
ppname := getURL[ggid_query_url2]
// Convert dob to placeholder dob, using the gid to seed a randomized
// date in the correct year
ggid_query_url3 := format["{0}/pdob?dob={1}&gid={2}", \
ggid_base_url, (0010,0030), gsid]
describe pdob hidden
pdob := getURL[ggid_query_url3]
// Hash the referring physician name and get a placeholder physician name
ggid_query_url4 := format["{0}/ggid?pname={1}", \
ggid_base_url, urlEncode[(0008,0090)]]
describe mdgid hidden
mdgid := getURL[ggid_query_url4]
ggid_query_url5 := format["{0}/pmdname?gid={1}", \
ggid_base_url, mdgid]
describe pmdname hidden
pmdname := getURL[ggid_query_url5]
// Assign Placeholder Values
// --------------------------------------------------
// Assign the new gsid first, so that it isn't (re)computed after (0010,0010)
// or (0010,0030) is changed
(0010,0020) := gsid // Patient ID
(0008,0050) := accession_giri // Accession
(0008,0090) := pmdname // Referring Physician's Name
(0010,0010) := ppname // Patient's Name
(0010,0030) := pdob // Patient's Birth Date
// Deidentification signatures
(0012,0062) := "YES" // Patient name removed
(0010,0021) := rule_author // Issuer of Patient ID
(0012,0063) := format["{0} {1} {2}", rule_author, rule_name, rule_version] // Deidentification method
// Remove PHI
// --------------------------------------------------
- (0008,0014) // Instance Creator UID
- (0008,1111) // Referenced Performed Procedure Step SQ
- (0008,1120) // Referenced Patient SQ
- (0008,1140) // Referenced Image SQ
- (0008,0096) // Referring Physician Identification SQ
- (0008,1032) // Procedure Code SQ
- (0008,1048) // Physician(s) of Record
- (0008,1049) // Physician(s) of Record Identification SQ
- (0008,1050) // Performing Physicians' Name
- (0008,1052) // Performing Physician Identification SQ
- (0008,1060) // Name of Physician(s) Reading Study
- (0008,1062) // Physician(s) Reading Study Identification SQ
- (0008,1110) // Referenced Study SQ
- (0008,1111) // Referenced Performed Procedure Step SQ
- (0008,1250) // Related Series SQ
- (0008,9092) // Referenced Image Evidence SQ
- (0010,0032) // Patient's Birth Time
- (0010,0050) // Patient's Insurance Plan Code SQ
- (0010,0101) // Patient's Primary Language Code SQ
- (0010,1000) // Other Patient IDs
- (0010,1001) // Other Patient Names
- (0010,1002) // Other Patient IDs SQ
- (0010,1005) // Patient's Birth Name
// Keep age since we are keeping year of birth
//- (0010,1010) // Patient's Age
- (0010,1040) // Patient's Address
- (0010,1060) // Patient's Mother's Birth Name
- (0010,1080) // Military Rank
- (0010,1081) // Branch of Service
- (0010,1090) // Medical Record Locator
- (0010,2000) // Medical Alerts
- (0010,2110) // Allergies
- (0010,2150) // Country of Residence
- (0010,2152) // Region of Residence
- (0010,2154) // Patient's Telephone Numbers
- (0010,2160) // Ethnic Group
- (0010,2180) // Occupation
- (0010,21A0) // Smoking Status
- (0010,21B0) // Additional Patient History
- (0010,21C0) // Pregnancy Status
- (0010,21D0) // Last Menstrual Date
- (0010,21F0) // Patient's Religious Preference
- (0010,2203) // Patient's Sex Neutered
- (0010,2297) // Responsible Person
- (0010,2298) // Responsible Person Role
- (0010,2299) // Responsible Organization
- (0020,9221) // Dimension Organization SQ
- (0020,9222) // Dimension Index SQ
- (0038,0010) // Admission ID
- (0038,0011) // Issuer of Admission ID
- (0038,0060) // Service Episode ID
- (0038,0061) // Issuer of Service Episode ID
- (0038,0062) // Service Episode Description
- (0038,0500) // Patient State
- (0038,0100) // Pertinent Documents SQ
- (0040,0260) // Performed Protocol Code SQ
- (0088,0130) // Storage Media File-Set ID
- (0088,0140) // Storage Media File-Set UID
- (5200,9229) // Shared Functional Groups SQ
// Replace Series UIDs
// --------------------------------------------------
(0002,0003) := new UID // Media Storage SOP Instance UID
(0008,0018) := new UID // SOP Instance UID
(0020,000D) := new UID // Study Instance UID
(0020,000E) := new UID // Series Instance UID
(0020,0052) := new UID // Frame of Reference UID
(0020,0200) := new UID // Synchronization FofR UID
(0020,9161) := new UID // Concatenation UID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment