Skip to content

Commit

Permalink
remove undefined types
Browse files Browse the repository at this point in the history
  • Loading branch information
lmdulz committed Aug 31, 2023
1 parent 08b80b1 commit 48b8bbe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
22 changes: 8 additions & 14 deletions src/anonymizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,27 @@ export class Anonymizer {
reuse an Anonymizer.
*/

private patientID: string;

private id_prefix: string | undefined;
private id_suffix: string | undefined;
private seed: string | undefined;


private date_offset_hours: number
randomizer: Randomizer;
address_anonymizer: AddressAnonymizer;
element_handlers: any[];
private date_offset_hours: number

constructor( patientID: string, id_prefix?: string | undefined, id_suffix?: string | undefined, seed?: string | undefined) {

constructor( patientID: string, protected_tags?: string[], id_prefix?: string, id_suffix?: string, seed?: string) {
const minimum_offset_hours: number = 62 * 24;
const maximum_offset_hours: number = 730 * 24;
this.patientID = patientID;
this.id_prefix = id_prefix;
this.id_suffix = id_suffix;
this.seed = seed;
this.randomizer = new Randomizer(this.seed)
this.randomizer = new Randomizer(seed)
this.date_offset_hours = Number(-(
this.randomizer.toInt("date_offset") % (BigInt(maximum_offset_hours) - BigInt(minimum_offset_hours)) + BigInt(minimum_offset_hours)
))
//this.data = data;
this.address_anonymizer = new AddressAnonymizer(this.randomizer);
this.element_handlers =
[new UnwantedElementStripper(["00101081",//"BranchOfService",
[new Protector(protected_tags).protect,
new UnwantedElementStripper(["00101081",//"BranchOfService",
"00102180",//"Occupation",
"00101090",//"MedicalRecordLocator",
"00101080",//"MilitaryRank",
Expand Down Expand Up @@ -73,7 +67,7 @@ export class Anonymizer {
"00081010",//"StationName",
"00200010",//"StudyID"
],
undefined, undefined).anonymize,
id_prefix, id_suffix).anonymize,
this.address_anonymizer.anonymize,
new InstitutionAnonymizer(this.address_anonymizer).anonymize,
new FixedValueAnonymizer("00100020", this.patientID).anonymize,
Expand Down
2 changes: 1 addition & 1 deletion src/datetimeanonymizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class DateTimeAnonymizer{



zipLongest = (fillValue: any | undefined, ...arr: any[]): string[][] =>{
zipLongest = (fillValue: string = "", ...arr: any[]): string[][] =>{

Check failure on line 119 in src/datetimeanonymizer.ts

View workflow job for this annotation

GitHub Actions / CI (16.x)

Type string trivially inferred from a string literal, remove type annotation
const maxLength = Math.max(...arr.map((arr: any) => arr.length));

return Array.from({ length: maxLength }, (_, index) => {
Expand Down
22 changes: 4 additions & 18 deletions src/idanonymizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,23 @@ export class IDAnonymizer {

private keywords: string[];
private randomizer: Randomizer;
private id_suffix: string | undefined;
private id_prefix: string | undefined;
private id_suffix: string;
private id_prefix: string;
private issuer_tag: string;
//private tag_ids: string[];
private alphabet: string;
private totalAffixesLength: number;
private indicesForRandomizer: number[];

constructor(Randomizer: Randomizer, keywords: string[], id_prefix?: string | undefined, id_suffix?: string | undefined) {
constructor(Randomizer: Randomizer, keywords: string[], id_prefix: string = "", id_suffix: string = "") {

Check failure on line 17 in src/idanonymizer.ts

View workflow job for this annotation

GitHub Actions / CI (16.x)

Type string trivially inferred from a string literal, remove type annotation

Check failure on line 17 in src/idanonymizer.ts

View workflow job for this annotation

GitHub Actions / CI (16.x)

Type string trivially inferred from a string literal, remove type annotation
this.keywords = keywords;
this.randomizer = Randomizer;
this.id_prefix = id_prefix;
this.id_suffix = id_suffix;
this.issuer_tag = dcmjs.data.DicomMetaDictionary.nameMap["IssuerOfPatientID"].tag
//this.tag_ids = this.keywords.map(tag_name => dcmjs.data.DicomMetaDictionary.unpunctuateTag(dcmjs.data.DicomMetaDictionary.nameMap[tag_name].tag));
this.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

if (this.id_prefix && this.id_suffix){
this.totalAffixesLength = this.id_prefix.length + this.id_suffix.length
} else if (this.id_prefix && !this.id_suffix){
this.id_suffix = ""
this.totalAffixesLength = this.id_prefix.length

} else if (!this.id_prefix && this.id_suffix){
this.id_prefix = ""
this.totalAffixesLength = this.id_suffix.length
}
else {
this.totalAffixesLength = 0
}

this.totalAffixesLength = this.id_prefix.length + this.id_suffix.length
this.indicesForRandomizer = new Array<number>(12 - this.totalAffixesLength).fill(this.alphabet.length)
}

Expand Down
2 changes: 1 addition & 1 deletion src/pnanonymizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class PNAnonymizer {
return true
}

new_pn(original_value: string, sex?: string | undefined,){
new_pn(original_value: string, sex: string = "",){

Check failure on line 35 in src/pnanonymizer.ts

View workflow job for this annotation

GitHub Actions / CI (16.x)

Type string trivially inferred from a string literal, remove type annotation
let first_names: string[];
if (sex == "F"){
first_names = this.lists.female_first_names;}
Expand Down
6 changes: 2 additions & 4 deletions src/randomizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import getRandomValues from 'get-random-values'; // use only in node env
export class Randomizer {
private seed: string;

constructor(seed?: string | undefined ) {
if (seed != null || seed === undefined) {
constructor(seed: string = "" ) {

Check failure on line 7 in src/randomizer.ts

View workflow job for this annotation

GitHub Actions / CI (16.x)

Type string trivially inferred from a string literal, remove type annotation
if (seed == "") {
this.seed = this.generateRandomSeed();
} else {
this.seed = seed;
Expand Down Expand Up @@ -67,8 +67,6 @@ export class Randomizer {
for (const x of suprema) {
const s = BigInt(x)
result.push(Number(big_Int % s));
// console.log(s, big_Int, big_Int%s);
// console.log(BigInt(Math.floor(Number(big_Int / s))));
big_Int = big_Int / s;
}

Expand Down

0 comments on commit 48b8bbe

Please sign in to comment.