Skip to content

Commit

Permalink
feat: Rewrote the Separator struct
Browse files Browse the repository at this point in the history
  • Loading branch information
wokket committed Dec 7, 2019
1 parent 3a305eb commit 5913da8
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 901 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"rusthl"
"rusthl",
"subcomponent"
]
}
13 changes: 3 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ license = "MIT OR Apache-2.0"
name="rusthl7"
path="src/lib.rs"

[[bin]]
name="test_app"
path="src/bin.rs"

[profile.release]
debug = true #temp include debug symbols for perf profiling


[dependencies]
itertools = "0.8.0"
libc = "0.2.48"
#itertools = "0.8"
#libc = "0.2"
failure = "0.1"
82 changes: 41 additions & 41 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
#![feature(test)]
extern crate test;
// #![feature(test)]
// extern crate test;

#[cfg(test)]
mod benches {
use rusthl7::message_parser::MessageParser;
use rusthl7::segment_parser::SegmentParser;
use rusthl7::*;
use test::Bencher;
// #[cfg(test)]
// mod benches {
// use rusthl7::message_parser::MessageParser;
// use rusthl7::segment_parser::SegmentParser;
// use rusthl7::*;
// use test::Bencher;

fn get_sample_message() -> String {
"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".to_string()
}
#[bench]
fn bench_full_message(b: &mut test::Bencher) {
b.iter(
|| MessageParser::parse_message(get_sample_message()), //note the trailing \r\r
);
}
// fn get_sample_message() -> String {
// "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".to_string()
// }
// #[bench]
// fn bench_full_message(b: &mut test::Bencher) {
// b.iter(
// || MessageParser::parse_message(get_sample_message()), //note the trailing \r\r
// );
// }

#[bench]
fn message_parse_and_retrieve_field(b: &mut test::Bencher) {
b.iter(|| {
let msg = MessageParser::parse_message(get_sample_message());
let _ = msg.get_segments("OBR")[0].fields[16].get_all_as_string();
});
}
// #[bench]
// fn message_parse_and_retrieve_field(b: &mut test::Bencher) {
// b.iter(|| {
// let msg = MessageParser::parse_message(get_sample_message());
// let _ = msg.get_segments("OBR")[0].fields[16].get_all_as_string();
// });
// }

#[bench]
fn bench_full_segment(b: &mut Bencher) {
b.iter(
|| SegmentParser::parse_segment(get_sample_segment(), &Seperators::default()), //note the trailing \r\r
);
}
// #[bench]
// fn bench_full_segment(b: &mut Bencher) {
// b.iter(
// || SegmentParser::parse_segment(get_sample_segment(), &Seperators::default()), //note the trailing \r\r
// );
// }

#[bench]
fn bench_full_segment_alternate(b: &mut Bencher) {
//comparitor for a/b testing
b.iter(
|| SegmentParser::parse_segment(get_sample_segment(), &Seperators::default()), //note the trailing \r\r
);
}
// #[bench]
// fn bench_full_segment_alternate(b: &mut Bencher) {
// //comparitor for a/b testing
// b.iter(
// || SegmentParser::parse_segment(get_sample_segment(), &Seperators::default()), //note the trailing \r\r
// );
// }

fn get_sample_segment() -> &'static str {
"PID|||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\r"
}
}
// fn get_sample_segment() -> &'static str {
// "PID|||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\r"
// }
// }
21 changes: 0 additions & 21 deletions examples/simple.rs

This file was deleted.

23 changes: 13 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

Totally nothing like production ready!

Basic usage:
This first cut is intended to parse from a multiline text blob into a tree of strings, representing all the different facets of info.

```
let input = "PID|Field1|Component1^Component2|Component1^Sub-Component1&Sub-Component2^Component3|Repeat1~Repeat2\r";
let message = pipe_parser::message_parser::MessageParser::parse_message(input);
Interpreting these facets (type conversion, determining which fields they represent etc) is a future problem.

println!("message: {:?}", message);
```

This first cut is intended to parse from a multiline text blob into a tree of strings, representing all the different components.

Interpreting these components (type conversion, determining which fields they represent etc) is a future problem.
### Intended Features and Design Notes:
- [x] Initially use hl7 default separator chars
- [x] Use separator chars from the message
- [ ] Parse using a from_str() impl rather than a dedicated parser (idiomatic)
- [ ] Add support for sub-field (repeat/component/subcomponent) items
- [ ] Avoid any lifetime complexities, even if it costs perf initially
- [ ] Initially, avoid any per-segment knowledge, requirement to read the spec too much etc.
- Implementing all the segments, across all the hl7 versions, version-specific parsing etc is tooooo much while we're getting started.
- [ ] Add tighter MSH as an exception to the above
- [ ] The above allows us to parse everything as strings, and provide helper methods for type conversions as required.
- [ ] Add Decoding/Encoding of special chars
31 changes: 0 additions & 31 deletions src/bin.rs

This file was deleted.

164 changes: 0 additions & 164 deletions src/field_parser.rs

This file was deleted.

Loading

0 comments on commit 5913da8

Please sign in to comment.