Stream: dotnet
Topic: rdf/turtle
Michael van der Zel (Mar 14 2016 at 09:41):
I am extending the fhr-net-api to support rdf/turtle and have some questions.
Michael van der Zel (Mar 14 2016 at 09:46):
Am also looking for someone who implements this on the server side.
Michael van der Zel (Mar 14 2016 at 11:13):
@Brian Postlethwaite I am trying to implement what is on https://hl7-fhir.github.io/rdf and what is discussed on w3c/hcls-fhir-rdf.
Brian Postlethwaite (Mar 14 2016 at 11:21):
you're looking for a dotnet implementaiton fo the rdf format?
Michael van der Zel (Mar 14 2016 at 11:32):
I have forked the fhir-net-api and added rdf support to it. I am running in some issues and are looking for people to solve it.
Michael van der Zel (Mar 14 2016 at 11:32):
... with
Brian Postlethwaite (Mar 14 2016 at 11:32):
Send me details and I can give it a whirl.
Michael van der Zel (Mar 14 2016 at 11:34):
https://github.com/mvdzel/fhir-net-api here is my fork
Michael van der Zel (Mar 14 2016 at 11:35):
I try to keep the code clean with minimal changes. And than this is the result.
Brian Postlethwaite (Mar 14 2016 at 11:35):
and the issue you're having?
(are therefailing unit tests for them, or are they build issues?
Michael van der Zel (Mar 14 2016 at 11:36):
At the moment I have not created unit-tests yet :-( The issue is in the resulting turtle compared to the specs at https://hl7-fhir.github.io/rdf
Michael van der Zel (Mar 14 2016 at 11:38):
For example Observation.value, in the both json and xml that becomes Observation.valueQualifier when the value is a Qualifier. And that is implemented in the fhir-net-api. But in the rdf they actually want "Observation.value" and then "is a Qualifier".
Grahame Grieve (Mar 14 2016 at 19:56):
I think you mean Quantity not Qualfier
Grahame Grieve (Mar 14 2016 at 19:57):
my server implements this
Grahame Grieve (Mar 14 2016 at 19:57):
fhir3.healthintersections.com.au/open
Michael van der Zel (Mar 15 2016 at 18:35):
Yes. Quantity. Sorry. And in the actual instance it becomes SimpleQuantity.
Michael van der Zel (Mar 15 2016 at 18:39):
My plan now is to write the page https://hl7-fhir.github.io/rdf and fill in the chapters with how I now can generate it in the fhir-net-api. That way the gaps will be identified.
Grahame Grieve (Mar 15 2016 at 20:45):
It doesn't become SimpleQuantity, it's just Quantity. Sounds like an underlying issue in the Dotnet framework
Grahame Grieve (Mar 15 2016 at 20:45):
and what page are you going to write?
Michael van der Zel (Mar 16 2016 at 07:46):
https://hl7-fhir.github.io/rdf the part on "RDF Resource Instances". Just to show the diffs with my current impl.
Michael van der Zel (Mar 16 2016 at 11:02):
@Grahame Grieve Why Quantity and not SimpleQuantity? On https://hl7-fhir.github.io/formats.html#choice it says " "[x]" is replaced with the title-cased name of the type that is actually used. ". In this case it is a SimpleQuantity.
Grahame Grieve (Mar 16 2016 at 11:03):
no, SimpleQuantity is not a type. It's a profile on the type Quantity
Michael van der Zel (Mar 16 2016 at 11:05):
Ok. Than I have to discuss how I can "see" this in the api.
Grahame Grieve (Mar 16 2016 at 11:05):
yes.
Grahame Grieve (Mar 16 2016 at 11:06):
actually, the property name is Observation.value
Grahame Grieve (Mar 16 2016 at 11:06):
in RDF
Grahame Grieve (Mar 16 2016 at 11:06):
not Observation.valueQuantity
Grahame Grieve (Mar 16 2016 at 11:06):
and you use type
a fhir:Quantity
Michael van der Zel (Mar 16 2016 at 11:07):
I know. But I missed the discussion on that. Why use different "attribute"-names than in json / xml?
Grahame Grieve (Mar 16 2016 at 11:08):
well, we are using the same attribute names, we're just serialising the type information differently
Grahame Grieve (Mar 16 2016 at 11:08):
we want the RDF model to correspond to the definitions most closely so you can reason against the definitions
Grahame Grieve (Mar 16 2016 at 11:09):
in json, there's no accepted way to type an element. In xml, there's xsi:type but it has many problems associated with it
Grahame Grieve (Mar 16 2016 at 11:09):
but in RDF, there's a proper way to do typing, and reasoning across value[x] is harder
Michael van der Zel (Mar 16 2016 at 11:09):
Ah. Got it. That makes a lot of sense. Thanks.
Michael van der Zel (Mar 16 2016 at 11:10):
Then I will have to change the framework in the fhir-net-api to accomodate this.
Grahame Grieve (Mar 16 2016 at 11:10):
np. note that there's a new stream for discussions about RDF ('ontology') - that's where to raise general issues about rdf
Michael van der Zel (Mar 16 2016 at 11:11):
Can we merge this stream there?
Grahame Grieve (Mar 16 2016 at 11:11):
well, this is the right place to ask about dotnet api internal details about supporting the RDF requirements. But there's no way to move content from one stream to another
Grahame Grieve (Mar 16 2016 at 11:12):
so here's where you explore getting the dotnet api to get SimpleQuantity typing correct
Michael van der Zel (Mar 16 2016 at 11:12):
ok
Michel Rutten (Mar 16 2016 at 12:17):
@Grahame Grieve thank you for clarifying the proper rules for choice type element renaming. Reading your comments I realized that Forge is currently implementing this the wrong way (i.e. the current release 12.2 will emit valueSimpleQuantity instead of valueQuantity). I'll try and fix this ASAP.
Ewout Kramer (Mar 16 2016 at 13:24):
I still don't see what I'd need to change, all the information you need is available in the .NET framework.... every property in the POCO needs it's real name (so "value", not "value[x]"), it's know which types are allowed, it's known what the actual type IS in an instance. What more do you need?
Michael van der Zel (Mar 16 2016 at 13:25):
The IFhirWriter interface does not pass the instance.
Michael van der Zel (Mar 16 2016 at 13:25):
The only instance it passes is the primitive value of the attributes.
Ewout Kramer (Mar 16 2016 at 13:27):
I just saw your email. So IFhirWriter is not receiving enough information....clear! I will await your pull request ;-)
Michael van der Zel (Mar 16 2016 at 13:28):
@Ewout Kramer Sorry for the multiple threads and mails. I have to get used to using Zulip ...
Michael van der Zel (Mar 16 2016 at 13:29):
By changing the IFhirWriter I also touch the current XML and JSON writers. How can I be sure I don't break those?
Ewout Kramer (Mar 16 2016 at 13:32):
By running the "RoundtripAllExamples" unit-test!
Michael van der Zel (Mar 16 2016 at 13:33):
Thanks! Will do.
Michael van der Zel (Mar 31 2016 at 22:05):
Is the dotnetrdf package creator on zulip? I run into a couple of issues.
1) it always adds the "xsd:" namespace and we want that namespace prefix to be "xs:".
2) the datatype shows as "<xs:dateTime>" instead of "xs:dateTime".
Grahame Grieve (Mar 31 2016 at 22:49):
I thought that was you?
Michael van der Zel (Mar 31 2016 at 22:50):
@Grahame Grieve helas. I only use that library to generate the turtle. Just like the json dotnet library that is used for json.
Grahame Grieve (Mar 31 2016 at 22:50):
well, we decided we prefer xs: over xsd: but it's only a preference
Michael van der Zel (Mar 31 2016 at 22:51):
Ah. Good. That is one down.
Michael van der Zel (Mar 31 2016 at 22:51):
I have some more questions based on your generated ttls.
Michael van der Zel (Mar 31 2016 at 22:52):
Why are you using xs:date instead of xs:dateTime for Observation.effectiveDateTime?
Grahame Grieve (Mar 31 2016 at 22:52):
see here:
Grahame Grieve (Mar 31 2016 at 22:53):
http://hl7.org/fhir/2016May/rdf.html#primitive
Grahame Grieve (Mar 31 2016 at 22:53):
"Note that the correct schema type for a date/dateTime must be determined by inspecting the value of the date for precision"
Michael van der Zel (Mar 31 2016 at 22:54):
Ah. I missed that line :-( Will add. Hate all the "special" code. Hoped that would not be necessary... What rule do you use to inspect the precision?
Grahame Grieve (Mar 31 2016 at 22:54):
here's my code:
Grahame Grieve (Mar 31 2016 at 22:55):
if (type.equals("date") || type.equals("dateTime") ) {
String v = value;
if (v.length() > 10) {
int i = value.substring(10).indexOf("-");
if (i == -1)
i = value.substring(10).indexOf("+");
v = i == -1 ? value : value.substring(0, 10+i);
}
if (v.length() > 10)
xst = "^^xs:dateTime";
else if (v.length() == 10)
xst = "^^xs:date";
else if (v.length() == 7)
xst = "^^xs:gYearMonth";
else if (v.length() == 4)
xst = "^^xs:gYear";
}
Michael van der Zel (Mar 31 2016 at 22:56):
Thanks
Michael van der Zel (Mar 31 2016 at 22:58):
Did you see the typo on 1.17.3.1.3? You mean to say fhir:value there right?
Grahame Grieve (Mar 31 2016 at 22:59):
crap I do. sigh
Michael van der Zel (Apr 01 2016 at 11:56):
Okey. The roundtriptest is now running for almost all examples. 727 pass and 2 fail.
Michael van der Zel (Apr 01 2016 at 11:56):
Roundtrip xml1->turtle->xml2 and compare the xml1 with xml2.
Michael van der Zel (Apr 01 2016 at 11:56):
There are a couple of things that don't feel right.
Michael van der Zel (Apr 01 2016 at 12:00):
1) E.g. with the "Reference" added to the members that are references. In XML and JSON the type is added when it is a polymorph member. In Turtle this is done the same way. Except for Reference. Because in Turtle all the References have "Reference" appended. When parsing the turtle I have to figure out if this is a polymorph member or not, so extra code is needed.
Michael van der Zel (Apr 01 2016 at 12:06):
2) Internal references e.g. "#" style. I'm not sure how these should end up in fhir:reference, so for now I ignored them
Michael van der Zel (Apr 01 2016 at 12:09):
3) In Bundles the subject is anonymous for entries, whilst they are not. They do have id's and you can reference them. E.g. http://hl7.org/fhir/2016May/bundle-example.ttl.html "fhir:Bundle.entry.resource" has an anonymous resource. In my implementation I use the id version as object for "fhir:Bundle.entry.resource".
Michael van der Zel (Apr 01 2016 at 12:14):
.. and I hope that some of the Furora guys can help me merge my feature branch back into develop.. Or where ever it belongs...
Grahame Grieve (Apr 02 2016 at 04:46):
can you clarify the reference issue? I don't understand what you wrote
Grahame Grieve (Apr 02 2016 at 04:47):
internal references to contained resources - the url for the resource is [container]#[contained-id]
Grahame Grieve (Apr 02 2016 at 04:47):
I'm not sure I understand the bundle issue either
Michael van der Zel (Apr 03 2016 at 08:10):
eg 1) Observation.subject is a reference, so becomes Observation.subjectReference in rdf, but not in xml/json because that is not [x].
ConceptMap.source (or target) are [x] types so they become ConceptMap.sourceReference in both xml/json and rdf.
Michael van der Zel (Apr 03 2016 at 08:13):
2) Ok. I ran into trouble with contained / bundles. The bundle has a base and the entries also. Think is was in the examples diagnosticreport-examples-general(72ac8493-52ac-41bd-8d5d-7258c289b5ea) and diagnosticreport-examples-lab-text(2763c3ea-6bce-4f15-bdc9-4b41aaceee03)
Michael van der Zel (Apr 03 2016 at 08:16):
<http://localhost/fhir/Bundle/bundle-example> fhir:Bundle.entry [fhir:index "0" ; fhir:Bundle.entry.fullUrl [fhir:value <https://example.com/base/MedicationOrder/3123>] ; fhir:Bundle.entry.resource <http://localhost/fhir/MedicationOrder/3123> ; fhir:Bundle.entry.search [fhir:Bundle.entry.search.mode [fhir:value "match"] ; fhir:Bundle.entry.search.score [fhir:value "1"^^<xsd:decimal>]]]
Michael van der Zel (Apr 03 2016 at 08:18):
eg 3) The above line and here http://hl7.org/fhir/2016May/bundle-example.ttl.html the resource is anonymous at Bundle.entry.resource
Michael van der Zel (Apr 03 2016 at 08:36):
eg 3) On http://hl7.org/fhir/2016May/diagnosticorder-example.ttl.html I expected a fhir:reference. But for that the contained resource "fasting" must not be anonymous.
fhir:DiagnosticOrder.supportingInformationReference [ fhir:index 0; fhir:Reference.reference [ fhir:value "#fasting" ] ];
Michael van der Zel (Apr 03 2016 at 08:39):
I was expecting either <http://localhost/fhir/Observation/fasting> or <http://hl7.org/fhir//DiagnosticOrder/example#fasting>, right?
Michael van der Zel (Apr 03 2016 at 08:48):
On second thought I think I expect the second:
fhir:DiagnosticOrder.supportingInformationReference [fhir:index "0" ; fhir:reference <http://localhost/fhir/DiagnosticOrder/example#fasting> ; fhir:Reference.reference [fhir:value "#fasting"]];
Michael van der Zel (Apr 03 2016 at 08:48):
And that means the id is used differently for contained resources.
<http://localhost/fhir/DiagnosticOrder/example#fasting> fhir:Resource.id [fhir:value "fasting"]; a fhir:Observation.
Michael van der Zel (Apr 03 2016 at 08:58):
@Ewout Kramer What's up with test-data/diagnosticreport-examples-general(72ac8493-52ac-41bd-8d5d-7258c289b5ea).xml? It repeats the same contained resource 10+ times. Should I ignore that test?
Ewout Kramer (Apr 04 2016 at 07:52):
Hi Michael, we take 99% of the test data straight from the examples.zip in the build. Where is this file exactly? I have no directory test-data, so we can take a look at it (might be wrong in the build too)
Michael van der Zel (Apr 04 2016 at 07:53):
@Ewout Kramer It is a filename in the Hl7.Fhir.Core.Tests/TestData/example.zip file
Ewout Kramer (Apr 04 2016 at 07:54):
There you go. So, this is straight from the example.zip as it comes out of the standard package on fhir.org....
Ewout Kramer (Apr 04 2016 at 07:54):
Ewout Kramer (Apr 04 2016 at 07:57):
Which ones are duplicates? On first scan, the first 4-5 contained resources seem to contain different data?!
Michael van der Zel (Apr 04 2016 at 07:59):
They do, but the id is the same.
Michael van der Zel (Apr 04 2016 at 07:59):
So my question should be about the scope of id's.
Michael van der Zel (Apr 04 2016 at 08:00):
I expected the id scope to be a file.
Michael van der Zel (Apr 04 2016 at 08:03):
There are 17 contained Observations with id "o1".
Ewout Kramer (Apr 04 2016 at 08:10):
I see, I think they should be scoped to the file indeed.
Michael van der Zel (Apr 04 2016 at 09:25):
Ok. So the example will be adjusted?
Grahame Grieve (Apr 07 2016 at 20:03):
so is this all sorted now?
Michael van der Zel (Apr 07 2016 at 20:04):
I have no idea who took the task...
Grahame Grieve (Apr 07 2016 at 20:04):
well, do I need to do anything? can I do anything?
Michael van der Zel (Apr 07 2016 at 20:06):
Two of the diagnosticreport-examples-general (see above) have id's that are scoped for the contained resource and not for the file (bundle).
Grahame Grieve (Apr 07 2016 at 20:10):
is that a problem in the specification itself?
Michael van der Zel (Apr 07 2016 at 20:19):
I don't know. Is there a place were is says what the scope for the '#' references is?
Michael van der Zel (Apr 07 2016 at 20:19):
I could not find it.
Grahame Grieve (Apr 07 2016 at 20:21):
within the resource, There's a special rule for bundles and parameters, that the resolution stops at the boundary of a resource in an entry or a parameter
Grahame Grieve (Apr 07 2016 at 20:22):
it does not stop at DomainResource.contains
Michael van der Zel (Apr 07 2016 at 20:23):
Ok. But then I can only create a full reference if the entry is not anonymous.
Michael van der Zel (Apr 07 2016 at 20:24):
See about 10 messages back for the example. I don't know how to link in zulip :-(
... a found it : https://chat.fhir.org/#narrow/stream/dotnet/subject/rdf.2Fturtle/near/9117
Michael van der Zel (Apr 07 2016 at 21:22):
Think I got it working. Will run tests tomorrow. Still would like to know were I can read the "special rule for bundles" ... On what page is it. Thanks.
Grahame Grieve (Apr 07 2016 at 22:02):
can't see it where i thought it was - perhaps you want to create a task to explain...
Michael van der Zel (Apr 08 2016 at 07:28):
@Grahame Grieve I sure want to create a task, but where??
Grahame Grieve (Apr 09 2016 at 20:43):
gForge
Grahame Grieve (Apr 09 2016 at 20:43):
can someone comment on this: http://stackoverflow.com/questions/36499889/hl7-fhir-routing-with-advanced-search-and-modifiers-in-net
Michael van der Zel (Apr 11 2016 at 17:07):
@Grahame Grieve done: issue #9801
Michael van der Zel (May 20 2016 at 13:51):
I have updated the ft-turtle branch in my fork https://github.com/mvdzel/fhir-net-api/tree/ft-turtle
Michael van der Zel (May 20 2016 at 13:51):
- renamed predicate fhir:reference -> fhir:link
- renamed predicate a sct:xxxxxx -> fhir:concept
- prefix for snomed codes is "http://snomed.info/id/"
- fhir:index is xs:integer, can only do this in dotnetrdf by adding the datatype
- predicate is now without "Reference" for non polymorph reference props e.g. used to be "subjectReference" is now "subject"
- added DateTime handling based on Grahames code
- workaround datatype uri issue by using full uri -> also shows fhir:index without quotes now
Michael van der Zel (May 20 2016 at 13:53):
Also tested a couple with the FancyShExDemo against the ShEx and they worked. Next step is to test all the generated ttl against the corresponding ShEx.
Ewout Kramer (May 23 2016 at 15:57):
Nice work!
Michael van der Zel (May 23 2016 at 21:30):
I'll do another pull-request...
Michael van der Zel (May 26 2016 at 06:40):
On http://hl7-fhir.github.io/downloads.html it says the ref impl implement xml and json. There is no mention of the current RDF/Turtle impl in the C# ref impl. Is it worth mentioning that?
Ewout Kramer (May 26 2016 at 14:35):
Well, it doesn't yet ;-) It's in a feature branche on DSTU2, but really we should include it as a separatee NuGet package in STU3. I'm redoing the parser API so we can add it more easily as an optional package.
Last updated: Apr 12 2022 at 19:14 UTC