Skip to content

Commit efe713a

Browse files
author
Doug Schmidt
authored
Merge pull request #273 from DougSchmidt-AI/feature/PF-1235-MoreNwfwmdLabFileImporterFixes
Feature/pf 1235 more nwfwmd lab file importer fixes
2 parents db4794f + 3439b67 commit efe713a

File tree

8 files changed

+232
-119
lines changed

8 files changed

+232
-119
lines changed

Samples/DotNetSdk/NWFWMD-LabFileImporter/Context.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ public class Context
1616
public Dictionary<string, string> AnalysisMethodAliases { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
1717
public Dictionary<string, string> UnitAliases { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
1818
public List<string> Files { get; } = new List<string>();
19+
public string EquipmentBlankLocation { get; set; } = "000000";
20+
public HashSet<string> EquipmentBlankPatterns { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
1921
public bool DryRun { get; set; }
2022
public string ResultGrade { get; set; } = "OK";
2123
public string LabResultStatus { get; set; } = "Preliminary";
2224
public string DefaultLaboratory { get; set; } = "";
2325
public string DefaultMedium { get; set; } = "Water";
26+
public string DefaultCollectionAgency { get; set; } = "NWFWMD";
2427
public string NonDetectCondition { get; set; } = "Non-Detect";
2528
public bool StopOnFirstError { get; set; }
2629
public int ErrorLimit { get; set; } = 10;

Samples/DotNetSdk/NWFWMD-LabFileImporter/CsvWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void WriteObservations(StreamWriter writer, IEnumerable<ObservationV2> ob
4747
{nameof(ObservationV2.QCSourceSampleID), "QC: Source Sample ID"},
4848
{nameof(ObservationV2.EARequestID), "EA: RequestId"},
4949
{nameof(ObservationV2.EASampler), "EA: Sampler"},
50+
{nameof(ObservationV2.EACollectionAgency), "EA: CollectionAgency"},
5051
};
5152

5253
writer.Write(CsvSerializer.SerializeToCsv(observations).Trim());

Samples/DotNetSdk/NWFWMD-LabFileImporter/LabFileLoader.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ private ObservationV2 ParseRow()
169169
LabQualityFlag = valueQualifier,
170170
EARequestID = GetColumn("REQUEST_ID"),
171171
EASampler = GetColumn("SAMPLER"),
172+
EACollectionAgency = Context.DefaultCollectionAgency,
172173
};
173174
}
174175

175176
private string LookupLocation(string fieldId)
176177
{
177-
if (EquipmentBlanks.Any(text => fieldId.IndexOf(text, StringComparison.InvariantCultureIgnoreCase) >= 0))
178-
return "000000";
178+
if (Context.EquipmentBlankPatterns.Any(text => fieldId.IndexOf(text, StringComparison.InvariantCultureIgnoreCase) >= 0))
179+
return Context.EquipmentBlankLocation;
179180

180181
var leadingNumberText = fieldId.Split('-')[0];
181182
var locationId = leadingNumberText;
@@ -197,12 +198,6 @@ private string LookupLocation(string fieldId)
197198
return fieldId;
198199
}
199200

200-
private static readonly string[] EquipmentBlanks =
201-
{
202-
"Equipment Blank",
203-
"Equipment Blk",
204-
};
205-
206201
private (string PropertyId, string UnitId) LookupObservedProperty(string paramCode, string paramName, string unitOfMeasure)
207202
{
208203
var propertyId = paramCode;

Samples/DotNetSdk/NWFWMD-LabFileImporter/MainForm.Designer.cs

Lines changed: 201 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples/DotNetSdk/NWFWMD-LabFileImporter/MainForm.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,15 @@ private void LoadContext()
122122
labResultStatusTextBox.Text = Context.LabResultStatus;
123123
defaultLaboratoryTextBox.Text = Context.DefaultLaboratory;
124124
defaultMediumTextBox.Text = Context.DefaultMedium;
125+
defaultCollectionAgencyTextBox.Text = Context.DefaultCollectionAgency;
125126
nonDetectConditionTextBox.Text = Context.NonDetectCondition;
126127

128+
equipmentBlankLocationTextBox.Text = Context.EquipmentBlankLocation;
129+
foreach (var pattern in Context.EquipmentBlankPatterns)
130+
{
131+
equipmentBlankPatternsListView.Items.Add(pattern);
132+
}
133+
127134
overwriteCheckBox.Checked = Context.Overwrite;
128135
CsvOutputPathTextBox.Text = Context.CsvOutputPath;
129136

@@ -365,11 +372,21 @@ private void defaultLaboratoryTextBox_TextChanged(object sender, EventArgs e)
365372
Context.DefaultLaboratory = defaultLaboratoryTextBox.Text.Trim();
366373
}
367374

375+
private void defaultCollectionAgencyTextBox_TextChanged(object sender, EventArgs e)
376+
{
377+
Context.DefaultCollectionAgency = defaultCollectionAgencyTextBox.Text.Trim();
378+
}
379+
368380
private void defaultMediumTextBox_TextChanged(object sender, EventArgs e)
369381
{
370382
Context.DefaultMedium = defaultMediumTextBox.Text.Trim();
371383
}
372384

385+
private void equipmentBlankLocationTextBox_TextChanged(object sender, EventArgs e)
386+
{
387+
Context.EquipmentBlankLocation = equipmentBlankLocationTextBox.Text.Trim();
388+
}
389+
373390
private void nonDetectConditionTextBox_TextChanged(object sender, EventArgs e)
374391
{
375392
Context.NonDetectCondition = nonDetectConditionTextBox.Text.Trim();

Samples/DotNetSdk/NWFWMD-LabFileImporter/ObservationV2.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ public class ObservationV2
3939
public string QCSourceSampleID { get; set; }
4040
public string EARequestID { get; set; }
4141
public string EASampler { get; set; }
42+
public string EACollectionAgency { get; set; }
4243
}
4344
}

Samples/DotNetSdk/NWFWMD-LabFileImporter/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ private static Context ParseArgs(string[] args)
121121
new Option {Key = nameof(context.LabResultStatus), Setter = value => context.LabResultStatus = value, Getter = () => context.LabResultStatus, Description = $"Lab result status."},
122122
new Option {Key = nameof(context.DefaultLaboratory), Setter = value => context.DefaultLaboratory = value, Getter = () => context.DefaultLaboratory, Description = $"Default laboratory ID for lab results"},
123123
new Option {Key = nameof(context.DefaultMedium), Setter = value => context.DefaultMedium = value, Getter = () => context.DefaultMedium, Description = $"Default medium for results"},
124+
new Option {Key = nameof(context.DefaultCollectionAgency), Setter = value => context.DefaultCollectionAgency = value, Getter = () => context.DefaultCollectionAgency, Description = $"Default collection agency"},
124125
new Option {Key = nameof(context.NonDetectCondition), Setter = value => context.NonDetectCondition = value, Getter = () => context.NonDetectCondition, Description = $"Lab detect condition for non-detect events."},
126+
new Option {Key = nameof(context.EquipmentBlankLocation), Setter = value => context.EquipmentBlankLocation = value, Getter = () => context.EquipmentBlankLocation, Description = $"The sampling location ID used for equipment blanks."},
127+
new Option {Key = nameof(context.EquipmentBlankPatterns), Setter = value => context.EquipmentBlankPatterns.Add(value), Getter = () => string.Join(", ", context.EquipmentBlankPatterns), Description = $"When the FIELD_ID column contains one of these patterns, use the configured -{nameof(Context.EquipmentBlankLocation)}=value."},
125128
new Option {Key = nameof(context.VerboseErrors), Setter = value => context.VerboseErrors = ParseBoolean(value), Getter = () => $"{context.VerboseErrors}", Description = "Show row-by-row errors?"},
126129

127130
new Option(), new Option{Description = "Alias options: (these help you map from your external system to AQUARIUS Samples)"},

Samples/DotNetSdk/NWFWMD-LabFileImporter/Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ Supported -option=value settings (/option=value works too):
100100
-LabResultStatus Lab result status. [default: Preliminary]
101101
-DefaultLaboratory Default laboratory ID for lab results
102102
-DefaultMedium Default medium for results [default: Water]
103+
-DefaultCollectionAgency Default collection agency [default: NWFWMD]
103104
-NonDetectCondition Lab detect condition for non-detect events. [default: Non-Detect]
105+
-EquipmentBlankLocation The sampling location ID used for equipment blanks. [default: 000000]
106+
-EquipmentBlankPatterns When the FIELD_ID column contains one of these patterns, use the configured -EquipmentBlankLocation=value.
104107
-VerboseErrors Show row-by-row errors? [default: False]
105108
106109
========================= Alias options: (these help you map from your external system to AQUARIUS Samples)

0 commit comments

Comments
 (0)