Closed sempervictus closed 3 years ago
Hey mate,
Repeats/Components/Subcomponents are on the TODO list, but I haven't given much concrete through to it.
My general thinking was to have variants of Field
where Generic was just a string, and Repeat etc had more logic/behaviour associated with them. The hard bit I had to work through in my head was how best to actually expose that data, as a consumer of the HL7 do I really just want a bag of bags of bags of strings?? Or something more like:
enum Field {
Generic(str),
Repeating(Vec<Repeat>)
Componentised(Vec<Component>)
}
enum Repeat {
Generic(str),
Componentised(Vec<Component>)
}
enum Component {
Generic(str),
Subcomponentised(Vec<SubComponent/str>)
Given I really don't want to get into interpresting field types etc I'm envisaging a set of helper methods in the library (to say convert a str to a DateTime etc) is just exposing the strings enough? What value does a value() method even provide on a repeating field?
Thoughts?
For the time being, i implemented this functionally at the Field
level to emulate how value()
works and to return Vec<&str>
and Vec<Vec<&str>>
as appropriate. Looking at this from a consumer's perspective, i need to be able to rapidly access complex fields by index (see #11) which necessitates having an iterable set of dimensions which i can traverse to reach the desired position in each dimension requested by the FIELDNAME.FX.RX.CX
index notation
Closed via #11
I've implemented the basic structure for parsing out
component
andsubcomponent
&str
s into vectors:However, getting data out of this construct is... non-trivial?
because making an &str out of vectors of them or vectors of vectors of them requires some sort of borrowing function that i'm not quite getting.
@wokket - happen to have any insight to how i can implement that without
or
biting me in the arse? The alternative approach would be to keep the field data as a string and perform
components()
andsubcomponents()
calls as functions against that, i think. Thoughts?