firelyteam / firely-net-sdk Goto Github PK
View Code? Open in Web Editor NEWThe official Firely .NET SDK for HL7 FHIR
License: Other
The official Firely .NET SDK for HL7 FHIR
License: Other
I've played around with this some, what seems to be happening is:
If a FHIR server returns a location with history information (i.e. http://fhirtest.uhn.ca/base/Observation/4041/_history/4) after an update, everything works great.
If a FHIR server returns a location that doesn't have history information (i.e. http://fhirstorm.dyndns.org:8080/FhirStorm/fhir/Observation/1), this snippet (FhirClient.cs, 338)
if (reqId.VersionId != null)
updated.SelfLink = reqId;
prevents SelfLink from being set.
Later, when the refresh occurs, FhirClient.cs 351 says:
if (refresh) updated = Refresh(updated, versionSpecific: true);
which causes the read to happen on SelfLink, which is null, so an exception is thrown.
It seems like either SelfLink should be set regardless of the version information being present, or the update code should set versionSpecific based on whether the version information is present.
Subclass naming seems inconsistent
MedicationPrescription.MedicationPrescriptionDosageInstructionComponent
Versus:
Patient.AnimalComponent
Parsing this gives a null-reference exception ("resourceType":"OperationOutcome","issue":[{"severity":"error","details":"NullReferenceException: Object reference not set to an instance of an object."},{"severity":"information","details":" at Hl7.Fhir.Serialization.ComplexTypeWriter.serializedIntoTwoProperties(PropertyMapping prop, Object instance) in c:\Git\fhir-net-api\src\Serialization\ComplexTypeWriter.cs:line 105\r\n at Hl7.Fhir.Serialization.ComplexTypeWriter.write(ClassMapping mapping, Object instance, PropertyMapping prop, SerializationMode mode):
{
"resourceType": "Profile",
"identifier": "oh1394156991825",
"name": "a new profile",
"publisher": "Orion Health",
"description": "xcv",
"status": "draft",
"experimental": true,
"date": "2014-03-07T14:49:51+13:00",
"requirements": "cxv",
"extensionDefn": [{
"code": "test1",
"contextType": "resource",
"context": [null],
"definition": {
"short": "should change - and again",
"formal": "",
"min": "0",
"max": "1",
"type": [{"code": "date"}],
"isModifier": false,
"binding": {
"name": "ValueSet1",
"referenceResource": {"reference": "http://spark.furore.com/fhir/ValueSet/3216371"}
}
},
"meta": {"profileName": "a new profile"}
}]
}
Messing around with my .net client pointed at the HAPI test server, which returned the following for a "next" url in a bundle:
http://fhirtest.uhn.ca/base?_getpages=8bba8a5a-233f-4f00-8db4-a00418c806fd&_getpagesoffset=10&_count=10&_format=xml
If I call Continue on the bundle, FhirClient ends up with an error in makeAbsolute because the IsBaseOf check on whether "http://fhirtest.uhn.ca.base/" is a base of "http://fhirtest.uhn.ca/base?_getpages=8bba8a5a-233f-4f00-8db4-a00418c806fd&_getpagesoffset=10&_count=10&_format=xml" fails.
When searching Patient by id:
var sparkFhirClient = new FhirClient("http://spark.furore.com/fhir");
sparkFhirClient.SearchById<Patient>(id);
FormatException was throw with message At line 1, pos 2: Encountered an unknown resource 'feed'
I have looked into this issue and found out, that Atom support was dropped. How could I search for entries without Atom support?
I'm using the FhirSerializer.SerializeResource(entry.Resource, jsonwriter) to serialise a single DiagnosticReport with a single Observation, "contained" within it. I keep getting the error "An item with the same key has already been added.", but I can't figure out what is wrong.
It would be helpful to give a more meaningful exception to show which key is being duplicated? I guess it is just a standard .NET exception at the moment though.
The Hl7.Fhir.Api nuget does not include the PDB files so it is difficult to debug the code.
Any ideas? Thanks :)
Hi,
Do you guys have a .NET UCUM validator? I saw that you had plans to make something like this....
FloatHandling makes sure parsing works well, but when serializing precision is lost.
ParseQueryFromUriParameters
does not really parse the parameters - it just creates a Query
object containing the parameters 'as is'. This means that malformed parameters are not caught by ParseQueryFromUriParameters
, that is somewhat undesirable.
When validating against XSD, I get the following error on a Atom feed created by the serialiser.
The element 'deleted-entry' in namespace 'http://purl.org/atompub/tombstones/1.0' has invalid child element 'link' in namespace 'http://www.w3.org/2005/Atom'. List of possible elements expected: 'link' in namespace 'http://purl.org/atompub/tombstones/1.0'.
<deleted-entry ref="https://localhost/fhir/Patient/6b7fe168-c36a-4a49-a54f-b38b9ff647eb"
when="2014-05-19T09:50:51.6593675+12:00"
xmlns="http://purl.org/atompub/tombstones/1.0">
<link rel="self"
href="https://localhost/fhir/Patient/6b7fe168-c36a-4a49-a54f-b38b9ff647eb/_history/2"
xmlns="http://www.w3.org/2005/Atom" />
</deleted-entry>
When searching for entry by id (or by query):
var sparkFhirClient = new FhirClient("http://spark.furore.com/fhir");
sparkFhirClient.SearchById<Patient>(id);
request sent to server is with Headers:
User-Agent: .NET FhirClient for FHIR 0.4.0
Accept: application/xml+fhir;charset=utf-8
Host: spark.furore.com/fhir
Proxy-Connection: Keep-Alive
while returned response from server is with header application/atom+xml
.
It looks like the C# ModelInfo.SearchParameters has the wrong SearchParamType for many entries. It appears that "Conformance.SearchParamType.Number" is specified when "Conformance.SearchParamType.Token" should be used. Check out the definition for Location.Type.
Query.Sort
can have only a single value, but according to the specs it should be possible to specify multiple sort parameters
/// <summary>
/// new Uri() is creating a canonical uri. This means that the identifier's
/// system contains a trailing forward slash.
/// </summary>
[TestMethod]
public void Uri_Canonical()
{
var identifier = new Identifier("http://nhi.health.nz", "123");
Assert.AreEqual("123", identifier.Value);
Assert.AreEqual("http://nhi.health.nz", identifier.System);
}
The above fails with Expected:<http://nhi.health.nz (System.String)>. Actual:<http://nhi.health.nz/ (System.Uri)>.
The validation of standard FHIR model classes returns results which do not include a reference to the field they apply to. The exact (c#) field name would be very beneficial here. There are two possible alternatives:
[8:12:45 PM] Angus Millar: I find the paging has a bug
[8:13:00 PM] Angus Millar: when you use this method
[8:13:15 PM] Angus Millar: Hl7.Fhir.Model.Bundle oReturnedBundle = Client.Continue(oBundle, PageDirection);
[8:14:13 PM] Angus Millar: as you walk forward through the pages all is fine and goig back is fine, but when you get to page zero "the first page" it returns null
[8:14:56 PM] Angus Millar: So that is go forward one page and then go back one page and you get null
[8:15:09 PM] Angus Millar: Sure we can look at next week
[8:19:34 PM] Angus Millar: 'Hl7.Fhir.Client.PageDirection.Last' works fine so I have to implement my own tracking to work around the bug
The validation of an element by using 'Validator.TryValidateObject' (or another method on Validator) returns the ValidationResults directly linked to the validated element as well as the ValidationResults of the element's property values. In itself, this is useful functionality. However, especially for UI-oriented applications it would also be useful to have an option to return merely the ValidationResults directly related to the element and its immediate properties.
We have discussed this could be done by passing a switch in the ValidationContext.Items dictionary. Preferably, an extension is added in the API to the ValidationContext class, setting the switch in a more controllable way.
Encounter the following error when attempting to build a fresh clone from GitHub:
Error 1 This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is C:\fhir-net-api\src.nuget\NuGet.targets. C:\fhir-net-api\src\Hl7.Fhir.Specification.Tests\Hl7.Fhir.Specification.Tests.csproj 218 5 Hl7.Fhir.Specification.Tests
Removal of the following block in the Hl7.Fhir.Specification.Tests.csproj file should resolve this issue:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> </Target>
It looks like there was an attempt on January 14th to remove MSBuild integrated package restore from the other projects in this repo - maybe this one was left out?
According to the spec, the server does not return a body, nor the tags as the result of an update, consequently, the returned ResourceEntry by Update() does not contain the tags anymore (the body is retained however)
As discussed at the connectathon, This test should pass:
[TestMethod]
public void TestNullExtensionRemoval()
{
var p = new Patient
{
Extension = new List
{
new Extension("http://hl7.org/fhir/Profile/iso-21090#qualifier", new Code("VV")),
null
}
};
var xml = FhirSerializer.SerializeResourceToXml(p);
}
This will currently throw from DispatchingWriter:49
From the Code Analysis this should not throw exceptions in ToString overrides. (CA1065)
It is intended as a diagnostic or descriptive method.
So if the state is invalid this can be portrayed in the resulting string.
The XML from FhirSerializer.SerializeBundle(...) starts with an XML-header.
FhirSerializer.SerializeResource(...) does not
When calling the server with the following code:
DateTimeOffset? since = null;
if (_lastInboundCheck.HasValue)
since = new DateTimeOffset(_lastInboundCheck.Value);
Bundle questionnaires = fhirServer.TypeHistory(since, 100);
This generates this URL:
GET /fhir/Questionnaire/_history?_since=2014-06-23T09:44:39+00:00&_count=100
should be generating
GET /fhir/Questionnaire/_history?_since=2014-06-23T09:44:39Z&_count=100
Looks like its gets the timezone output incorrect.
I'm using the FHIR Schemas (XSD and Schematron) to validate resources. Would it be possible to embed these files as resources in the API or FHIR assembly. This way I can guarantee that the schemas match the C# object representation.
Please consider creating a separate nuget package for the xml schema/schematron files in the validation.zip
Probably means splitting up in:
I.e. for the output of the reflection caching.
To reduce traffic on reading a list of profiles in a repository before retrieving the profile in Forge, please add the summary call like specified in the fhir spec.
Hi Ewout,
I'm working on a new integration engine for healthcare (yet another one). Its here on GitHub. Obviously I will be having a lot of ER7 coded stuff coming in, and currently I translate that into XML. However, looking at various mapping solutions in JavaScript I kind of decided to go for working with JSON for this. Which made this project very interesting (thanks for the code).
But I just want to understand if there is a transformation path from ER7 encoded data to the current JSON model you have, and if so, what does that pipeline look like?
If not, any suggestions on how to go from ER7 to JSON in a standard fashion would be very much appreciated.
In any regard, I will add support for this initiative into the server soon.
Cheers,
Niclas
The URI parser throws an exception when it encounters this query:
http://spark.furore.com/fhir/DiagnosticReport?image:missing=true
The server should at least make sure it's own OperationOutcome's carry Narrative
I'm trying to get Resource from server and then update it.
Method 2 works as intended. Method 1 does not work on update, because Patient id is not an absolute path.
Error due to code in
BundleXmlParser.cs 157: var id = SerializationUtil.UriValueOrNull(entry.Element(XmlNs.XATOM + XATOM_ID));
Method 1:
[TestMethod]
public void TestSearchByPersonaCode()
{
var client = new FhirClient("http://spark.furore.com/fhir");
var pats =
client.Search<Patient>(
new[] { string.Format("identifier={0}|{1}", "http://esveikata.lt/Identifier/PersonalCode", "[value]") });
var pat = pats.Entries.FirstOrDefault() as ResourceEntry<Patient>;
client.Update<Patient>(pat);
}
Method 2:
[TestMethod]
public void TestRead()
{
var client = new FhirClient("http://spark.furore.com/fhir");
var pat = client.Read<Patient>("Patient/[value2]");
client.Update<Patient>(pat);
}
Btw, I'm using DSTU1 version.
When adding resource to a bundle there are no option to generate temporary id for it.
It would be nice if fhir-net-api library could create temporary ids for resources so it would be easier to send a transaction to FHIR server.
Btw, I'm using DSTU1 version.
Port code from current Java implementation
I'm getting a System.NullReferenceException when XML serialising an OperationOutcome. The basic code is:
var settings = new XmlWriterSettings
{
CloseOutput = true,
Encoding = new UTF8Encoding(false),
Indent = true,
OmitXmlDeclaration = true
};
using (var writer = XmlWriter.Create(writeStream, settings))
{
FhirSerializer.SerializeResource((Resource)value, writer);
}
And the stack trace (see the bottom for Fhir exception details). It looks like get_Inspector is not working.
Test Name: GetWardByName
Test Outcome: Failed
Result Message:
Test method Orchestral.Blaze.Blog_2013_10_24.GetWardByName threw exception:
System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Result StandardOutput:
Debug Trace:
vstest.executionengine.x86.exe Information: 0 : Request, Method=GET, Url=http://localhost/fhir/Location?name="Medical ICU"&type=urn:his/WRD, Message='http://localhost/fhir/Location?name="Medical ICU"&type=urn:his/WRD'
vstest.executionengine.x86.exe Information: 0 : Message='Location', Operation=DefaultHttpControllerSelector.SelectController
vstest.executionengine.x86.exe Information: 0 : Message='Orchestral.Blaze.Hint.LocationController', Operation=DefaultHttpControllerActivator.Create
vstest.executionengine.x86.exe Information: 0 : Message='Orchestral.Blaze.Hint.LocationController', Operation=HttpControllerDescriptor.CreateController
vstest.executionengine.x86.exe Information: 0 : Message='Selected action 'Search(Search filter)'', Operation=ApiControllerActionSelector.SelectAction
vstest.executionengine.x86.exe Error: 0 : Operation=LocationController.ExecuteAsync, Exception=System.ArgumentException: Integer query parameter value is not a valid integer
at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.Tracers.HttpControllerTracer.<ExecuteAsyncCore>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__21`1.MoveNext()
vstest.executionengine.x86.exe Information: 0 : Message='Will use same 'FhirResourceXmlFormatter' formatter', Operation=FhirResourceXmlFormatter.GetPerRequestFormatterInstance
vstest.executionengine.x86.exe Information: 0 : Message='Selected formatter='FhirResourceXmlFormatter', content-type='application/fhir+xml; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate
vstest.executionengine.x86.exe Information: 0 : Response, Status=500 (InternalServerError), Method=GET, Url=http://localhost/fhir/Location?name="Medical ICU"&type=urn:his/WRD, Message='Content-type='application/fhir+xml; charset=utf-8', content-length=unknown'
vstest.executionengine.x86.exe Error: 0 : Operation=FhirResourceXmlFormatter.WriteToStream, Exception=System.NullReferenceException: Object reference not set to an instance of an object.
at Hl7.Fhir.Introspection.PropertyMapping.Create(PropertyInfo prop, IEnumerable`1& referredTypes) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Introspection\PropertyMapping.cs:line 53
at Hl7.Fhir.Introspection.PropertyMapping.Create(PropertyInfo prop) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Introspection\PropertyMapping.cs:line 36
at Hl7.Fhir.Introspection.ClassMapping.inspectProperties(ClassMapping me) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Introspection\ClassMapping.cs:line 127
at Hl7.Fhir.Introspection.ClassMapping.Create(Type type) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Introspection\ClassMapping.cs:line 107
at Hl7.Fhir.Introspection.ModelInspector.ImportType(Type type) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Introspection\ModelInspector.cs:line 95
at Hl7.Fhir.Introspection.ModelInspector.Import(Assembly assembly) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Introspection\ModelInspector.cs:line 51
at Hl7.Fhir.Serialization.SerializationConfig.<createDefaultModelInspector>b__0() in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Serialization\SerializationConfig.cs:line 26
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Hl7.Fhir.Serialization.SerializationConfig.get_Inspector() in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Serialization\SerializationConfig.cs:line 36
at Hl7.Fhir.Serialization.ResourceWriter..ctor(IFhirWriter writer) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Serialization\ResourceWriter.cs:line 23
at Hl7.Fhir.Serialization.FhirSerializer.Serialize(Object instance, IFhirWriter writer) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Serialization\FhirSerializer.cs:line 48
at Hl7.Fhir.Serialization.FhirSerializer.SerializeResource(Resource resource, XmlWriter writer) in c:\Projects\fhir-net-api-master\src\Hl7.Fhir.Serialization\Serialization\FhirSerializer.cs:line 129
at Orchestral.Blaze.Http.FhirResourceXmlFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content) in c:\Projects\Hint\Blaze\Core\Http\FhirResourceXmlFormatter.cs:line 148
at System.Web.Http.Tracing.Tracers.BufferedMediaTypeFormatterTracer.<>c__DisplayClass7.<WriteToStream>b__6()
at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action`1 beginTrace, Action execute, Action`1 endTrace, Action`1 errorTrace)
Some resource properties (AllergyIntolerance sensitivityType) have been defined in c# with a trailing "_". I assume this is done to avoid name clash with contained class/enum.
The SearchParamDefinition Path for these special properties does not have the trailing "_".
System.Runtime.Serialization.InvalidDataContractException occurred
_HResult=-2146233088
_message=Type 'Hl7.Fhir.Model.Resource' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'Hl7.Fhir.Model.Base' with DataContractAttribute or SerializableAttribute, or removing them from the derived type.
HResult=-2146233088
IsTransient=false
Message=Type 'Hl7.Fhir.Model.Resource' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'Hl7.Fhir.Model.Base' with DataContractAttribute or SerializableAttribute, or removing them from the derived type.
Source=System.Runtime.Serialization
StackTrace:
at System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper..ctor(Type type)
InnerException:
I was reviewing the code in DSTU2 develop branch. RoundtripTest unit test failed with this error.
Converting json-edge-cases [.json->.xml]
Test method Hl7.Fhir.Tests.Serialization.RoundtripTest.FullRoundtripOfAllExamples threw exception:
System.FormatException: Cannot parse json: After parsing a value an unexpected character was encountered: :. Path '_active.['http://hl7.org/fhir/example-do-not-use#recordStatus'][0]', line 14, position 20.
I looked at the extracted JSON and confirmed the JSON improperly formed.
UPDATE: this may be a non-issue - I see a working copy of a replacement in the testdata folder that hasn't been added to the zip file yet. I replaced locally, but see the test failing in other places.
I'm implementing the search functionality on DiagnosticReport.date.
The Query specification suggests I can query with dates which are greater than or less than the date. Such as _DiagnosticReport/search?date>=2014/02/23 or _DiagnosticReport/search?date<=2014/05/27.
The new FhirParser.ParseQueryFromUriParameters only accepts a list of Tuples, which doesn't include any operator types (<=, >=, etc).
I might have misunderstood the Query object, but if not, it would be useful to have a new ParseQueryFromUriParameters method which accepted the full QueryString object.
Thanks.
Before, Narrative.Div used the XHtml type to represent FHIR XHTML narrative. Now, this has become string. Either remove the XHtml type in its entirety or make Narrative.Div an XHtml type again (might lead to complications in the parser/serializer because Div as an inlined XmlNode value)
Say I have a 'Contained' Resource with an id (like <Valueset id="set1">
) and it is referenced using '#' (<reference value="#set1"/>
). I'd like to retrieve that referenced Resource with a simple function, instead of using syntax like questionnaire.Contained.First(o => o.Id == Reference.Substring(1))
(pseudocode)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.