FirelyTeam / firely-net-sdk

The official Firely .NET SDK for HL7 FHIR
Other
830 stars 345 forks source link

Custom Resource #337

Closed sandeepac closed 7 years ago

sandeepac commented 7 years ago

How to access the Custom Resource using the .net client?

sandeepac commented 7 years ago

More Info: Department resource is a custom resource. Inherited from domain resource.

ewoutkramer commented 7 years ago

Hi @sandeepac, the only way to handle custom resources currently is to create a StructureDefinition for it, add it to the profiles-resources.xml file in the Model/Generated/Source directory, and rerun the T4 templates - you'll get your own version of the .NET library, with a POCO for your own resources....

sandeepac commented 7 years ago

Thanks @ewoutkramer , We will try the solution.

sandeepac commented 7 years ago

Hi @ewoutkramer, I have tried to rerun the Template-Model.tt by right click-> Run custom tool. I am getting the error(as attached). This is with the original profiles-resources.xml file. Is there any sequence in which the T4 templates need to be re-run or Is there any tool that we can use the run the T4 templates. I have opened the solution in VS 2017 and .Net framework is 4.5. image

ewoutkramer commented 7 years ago

Hi @sandeepac, you're doing the same thing I am doing & using the same tools ;-) What branch are you using?

ewoutkramer commented 7 years ago

This may help too: Make sure you never accidentally run the TemplateFileManagerV2.1.ttinclude file separately. If so, just remove the associated .cs file and try again.

sandeepac commented 7 years ago

There was a newline character at the end of TemplateFileManagerV2.1.ttinclude file, removed that. It is working now. Thanks.

ewoutkramer commented 7 years ago

Yes, I think adding this to .csproj will avoid some of this trouble:

<None Update="Model\Generated\TemplateFileManagerV2.1.ttinclude"> 
  <Generator>TextTemplatingFileGenerator</Generator> 
  <LastGenOutput>TemplateFileManagerV2.1.cs</LastGenOutput> 
</None> 

since this stuff is literally included in the other .tt files, it should never be compiled all by itself.

mzocco commented 6 years ago

Hi to everyone; I have a problem in deserializing a custom class containing some fhir object in it.

For example a CustomClass extending the DomainResource and containing as class variable a Patient instance and other variables (booleans, string...).

Does exist a way to register a custom resource type in C# using the FHIR C# library (without modifying the profiles-resources.xml file) and to deserialize it in a Controller? In other words I'd like to deserialize in the C# controller a class instance containing the following information:

{  
   "resourceType":"customClass",
   "id":"0c5b363e-ec06-4908-9727-3ddfccb209d1",
   "meta":{  
      "profile":[  
         "http://hl7.org/fhir/profiles/custom-class"
      ]
   },

   "boolExample":true,
   "patient":{  
      "resourceType":"Patient",
      "id":"af8b5324-0d88-11e8-a996-000c296d924a",
      "gender":"female",
      "birthDate":"2018-04-03"
   }
}

The controller signature should be something like this:

[HttpPost("asignature")]
public void ReceiveCustomClass([FromBody]CustomClass customClass)
{
        //Handle customClass object
}

Thanks in advance. Matteo