https://github.com/chgl/fhirparametersgenerator
A .NET source generator for mapping model classes to HL7 FHIR® Parameters resources.
https://github.com/chgl/fhirparametersgenerator
csharp csharp-sourcegenerator dotnet fhir
Last synced: over 1 year ago
JSON representation
A .NET source generator for mapping model classes to HL7 FHIR® Parameters resources.
- Host: GitHub
- URL: https://github.com/chgl/fhirparametersgenerator
- Owner: chgl
- License: apache-2.0
- Created: 2022-03-04T21:34:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-25T06:54:52.000Z (about 2 years ago)
- Last Synced: 2024-05-28T00:39:38.014Z (about 2 years ago)
- Topics: csharp, csharp-sourcegenerator, dotnet, fhir
- Language: C#
- Homepage:
- Size: 207 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FhirParametersGenerator

[](https://github.com/chgl/FhirParametersGenerator/actions) [](https://www.nuget.org/packages/FhirParametersGenerator/)
A PoC .NET source generator for mapping model classes to HL7 FHIR® Parameters resources.
Useful when interacting with FHIR® server operation endpoints.
## Getting Started
```sh
dotnet add package FhirParametersGenerator
```
This sample code...
```cs
using FhirParametersGenerator;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
var t = new TestModel
{
Age = 123,
Name = "Test",
Code = new("http://snomed.info/sct", "386661006", "Fever"),
};
// the ToFhirParameters() extension method is code-generated
var parameters = t.ToFhirParameters();
Console.WriteLine(parameters.ToJson(new() { Pretty = true }));
// apply this attribute to the desired model class
[GenerateFhirParameters]
public class TestModel
{
public string Name { get; init; } = string.Empty;
public int Age { get; init; } = 0;
public CodeableConcept? Code { get; init; }
}
```
...will output:
```json
{
"resourceType": "Parameters",
"parameter": [
{
"name": "name",
"valueString": "Test"
},
{
"name": "age",
"valueDecimal": 123
},
{
"name": "code",
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "386661006"
}
],
"text": "Fever"
}
}
]
}
```
## Limitations
This library is in a very early stage and many edge and not-so-edge cases that are not covered by the generated source.
The list of open issues is a good starting point to see what isn't yet supported. Contributions are of course always welcome.
## Benchmark
A benchmark project exists which measures the performance of generating the source code for a 1000-property class: .
Benchmarking results over time are available at .
## Credits
### Source Code
Contains source code published under the terms of the MIT license originally from and from .
### Icon
The package icon is composed of
- Fire by artworkbean from NounProject.com
- Edit by Logan from NounProject.com