-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from wokket/feat/15-query-selector
Work pending for 0.5 release
- Loading branch information
Showing
8 changed files
with
262 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
# Changelog | ||
|
||
## 0.5.0 | ||
- Add `query` functions to replace the string based `Index` impls in the version version. These are functionally identical to the string `Index` implementations, but avoid some lifetime issues (returning `&&str`) and have visible documentation. | ||
|
||
## 0.4.0 | ||
- Large change (thanks @sempervictus) to allow querying of message content by both numerical indexer and dot-notation string indexers | ||
- Note that the string indexers will be replaced with a normal function call in a future release. | ||
|
||
## 0.3.0 | ||
- Changes from @sempervictus to expose internal values again | ||
- Extensive work by @sempervictus to expose the segments/fields as collections (which I hadn't got back to after the re-write to slices.) | ||
|
||
## 0.2.0 | ||
- Re-write to avoid excessive string cloning by operating on slices of the source HL7 | ||
- Re-Write to not expose cloned/copied vecs of vecs everywhere. We have all the data in a single string slice to begin with so lets return slices from that. | ||
|
||
## 0.1.0 | ||
- Initial string.clone() heavy library, nothing to see here... | ||
- Initial string.clone() heavy library, nothing to see here... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,77 @@ | ||
use std::convert::TryFrom; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rusthl7::{message::*, segments::Segment}; | ||
use std::convert::TryFrom; | ||
|
||
fn get_sample_message() -> &'static str { | ||
"MSH|^~\\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4\rPID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|19620320|F|||153 FERNWOOD DR.^^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520\rOBR|1|845439^GHH OE|1045813^GHH LAB|15545^GLUCOSE|||200202150730|||||||||555-55-5555^PRIMARY^PATRICIA P^^^^MD^^|||||||||F||||||444-44-4444^HIPPOCRATES^HOWARD H^^^^MD\rOBX|1|SN|1554-5^GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN||^182|mg/dl|70_105|H|||F" | ||
} | ||
|
||
fn message_parse(c: &mut Criterion) { | ||
|
||
c.bench_function("oru parse", |b| { | ||
|
||
c.bench_function("ORU parse", |b| { | ||
b.iter(|| { | ||
let _ = Message::try_from(get_sample_message()).unwrap(); | ||
}) | ||
}); | ||
} | ||
|
||
fn get_segments_by_name(c: &mut Criterion) { | ||
c.bench_function("Get Segment By Name", |b| { | ||
let m = Message::try_from(get_sample_message()).unwrap(); | ||
|
||
b.iter(|| { | ||
let _segs = m.generic_segments_by_name("OBR").unwrap(); | ||
//assert!(segs.len() == 1); | ||
}) | ||
}); | ||
} | ||
|
||
fn get_msh_and_read_field(c: &mut Criterion) { | ||
c.bench_function("Read Field from MSH (variable)", |b| { | ||
let m = Message::try_from(get_sample_message()).unwrap(); | ||
|
||
b.iter(|| { | ||
let m = Message::try_from(get_sample_message()).unwrap(); | ||
let seg = m.segments.first(); | ||
|
||
if let Some(Segment::MSH(msh)) = seg { | ||
let _app = msh.msh_3_sending_application.as_ref().unwrap(); | ||
//println!("{}", _app.value()); | ||
let _app = msh.msh_3_sending_application.as_ref().unwrap(); // direct variable access | ||
//println!("{}", _app.value()); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, message_parse); | ||
fn get_pid_and_read_field_via_vec(c: &mut Criterion) { | ||
c.bench_function("Read Field from PID (lookup)", |b| { | ||
let m = Message::try_from(get_sample_message()).unwrap(); | ||
|
||
b.iter(|| { | ||
let seg = &m.segments[1]; | ||
|
||
if let Segment::Generic(pid) = seg { | ||
let _field = pid[3]; | ||
assert_eq!(_field, "555-44-4444"); // lookup from vec | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn get_pid_and_read_field_via_query(c: &mut Criterion) { | ||
c.bench_function("Read Field from PID (query)", |b| { | ||
let m = Message::try_from(get_sample_message()).unwrap(); | ||
|
||
b.iter(|| { | ||
let _val = m.query("PID.F3"); // query via Message | ||
assert_eq!(_val, "555-44-4444"); // lookup from vec | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
message_parse, | ||
get_segments_by_name, | ||
get_msh_and_read_field, | ||
get_pid_and_read_field_via_vec, | ||
get_pid_and_read_field_via_query | ||
); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.