tara
tara

Reputation: 17

Convert FHIR model into FHIR JSON schema

Let's say below is the FHIR model I have in C# for Patient resource.

    var pat = new Patient();        
    var name =  new HumanName().WithGiven("Christopher").WithGiven("C.H.").AndFamily("Parks");
    name.Prefix = new string[] { "Mr." };
    name.Use = HumanName.NameUse.Official;

How do I convert this into FHIR JSON Schema? Basically I want to serialize it. I am expecting the output like below

 {
  "resourceType": "Patient",
  "id": "xcda",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"></div>"
  },
  "active": true,
  "name": [
    {
      "family": "Levin",
      "given": [
        "Henry"
      ]
    }
  ],
  "gender": "male",
  "birthDate": "1932-09-24",
  "managingOrganization": {
    "reference": "Organization/2.16.840.1.113883.19.5",
    "display": "Good Health Clinic"
  }
}

Also, I want to know is it possible to achieve this without using any FHIR external servers?

Upvotes: 1

Views: 780

Answers (2)

Mahesh
Mahesh

Reputation: 46

You are trying to convert an object to FHIR format. There is no generic solution which can do that for you. You can always print out the serialized json of the object and ask copilot to convert to FHIR format. You can also use microsoft's AI offering here : https://learn.microsoft.com/en-us/azure/ai-services/language-service/text-analytics-for-health/overview?tabs=ner

Upvotes: 0

Jaime
Jaime

Reputation: 5965

Using HAPI, it should be something like:

var fhirCtx = FhirContext.forR4(); // Choose the desired FHIR version here
var parser = fhirCtx.newJsonParser();

String jsonString = parser.encodeResourceToString(pat);

Upvotes: 0

Related Questions