onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
2 stars 1 forks source link

Initial AI generated questionnaire response #71

Closed Wambere closed 9 months ago

Wambere commented 9 months ago

IMPORTANT: Where possible all PRs must be linked to a Github issue

Fixes https://github.com/onaio/fhir-tooling/issues/15

Engineer Checklist

Wambere commented 9 months ago

This is just the first version with the AI endpoint, still testing out the $populate version

Wambere commented 9 months ago

Sample questionnaire used to test: source

{
  "resourceType": "Questionnaire",
  "language": "nb-NO",
  "id": "CRVS-Client-Reg-32862",
  "name": "CRVS Client Registration",
  "title": "CRVS Client Registration",
  "description": "CRVS Client Registration",
  "status": "draft",
  "publisher": "1212",
  "meta": {
    "versionId": "3",
    "lastUpdated": "2022-01-15T12:26:01.749+00:00",
    "source": "#fdbbe189f66c3beb",
    "profile": [
      "http://ehelse.no/fhir/StructureDefinition/sdf-Questionnaire"
    ],
    "tag": [
      {
        "system": "urn:ietf:bcp:47",
        "code": "nb-NO",
        "display": "Norsk Bokmål"
      }
    ]
  },
  "useContext": [
    {
      "code": {
        "system": "http://hl7.org/fhir/codesystem-usage-context-type.html",
        "code": "focus"
      },
      "valueCodeableConcept": {
        "coding": [
          {
            "system": "http://fhir.ona.io",
            "code": "000002",
            "display": "CRVS Client Registration"
          }
        ]
      }
    }
  ],
  "contact": [
    {
      "name": "http://www.nhn.no"
    }
  ],
  "subjectType": [
    "Patient"
  ],
  "item": [
    {
      "linkId": "791e1b1c-a7f2-4f84-8af1-48fe6154cb26",
      "text": "First Name ",
      "type": "string",
      "required": true
    },
    {
      "linkId": "51e7a214-6e01-43ca-8adf-d07314eec2da",
      "text": "Middle Name ",
      "type": "string",
      "required": false
    },
    {
      "linkId": "3139c685-4cb1-45ca-81cf-b5f2b5107e59",
      "text": "Surname ",
      "type": "string",
      "required": true
    },
    {
      "linkId": "3ad8ae39-e2a7-4fcc-815e-6a126673df7a",
      "type": "date",
      "text": "Date of Birth",
      "required": false
    },
    {
      "linkId": "590b9eb1-3cb3-47cf-c1a5-505763edcff0",
      "text": "Sex ",
      "type": "choice",
      "required": true,
      "answerOption": [
        {
          "valueCoding": {
            "id": "ee07abb9-f33e-419c-810a-8b10b4500d43",
            "system": "https://www.hl7.org/fhir/codesystem-administrative-gender.html",
            "code": "male",
            "display": "Male"
          }
        },
        {
          "valueCoding": {
            "id": "84aabe6e-d482-476d-c5e4-d694e63aa96d",
            "system": "https://www.hl7.org/fhir/codesystem-administrative-gender.html",
            "code": "female",
            "display": "Female"
          }
        }
      ]
    }
  ]
}

The questionnaire response generated:

{
  "resourceType": "QuestionnaireResponse",
  "questionnaire": "CRVS-Client-Reg-32862",
  "status": "completed",
  "subject": {
    "reference": "Patient/123456"
  },
  "authored": "2022-02-03T13:45:00.000Z",
  "item": [ {
    "linkId": "791e1b1c-a7f2-4f84-8af1-48fe6154cb26",
    "answer": [ {
      "valueString": "John"
    } ]
  }, {
    "linkId": "51e7a214-6e01-43ca-8adf-d07314eec2da",
    "answer": [ {
      "valueString": "Doe"
    } ]
  }, {
    "linkId": "3139c685-4cb1-45ca-81cf-b5f2b5107e59",
    "answer": [ {
      "valueString": "Smith"
    } ]
  }, {
    "linkId": "3ad8ae39-e2a7-4fcc-815e-6a126673df7a",
    "answer": [ {
      "valueDate": "1990-05-15"
    } ]
  }, {
    "linkId": "590b9eb1-3cb3-47cf-c1a5-505763edcff0",
    "answer": [ {
      "valueCoding": {
        "id": "ee07abb9-f33e-419c-810a-8b10b4500d43",
        "system": "https://www.hl7.org/fhir/codesystem-administrative-gender.html",
        "code": "male",
        "display": "Male"
      }
    } ]
  } ]
}
Wambere commented 9 months ago

pretty cool, does this usually return content that validates?

Not always. I've tested a few and I think it relies mostly on the questionnaire, so some are "more valid" than others