onaio / fhir-tooling

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

"Best" way to create resources #181

Closed Wambere closed 5 months ago

Wambere commented 5 months ago

I have a CSV file with a bunch of values that I need to use to create a JSON object (FHIR resource)

The CSV (input):

name active id previousId isAttractive isAvailable condition appropriateUsage imageUrl
thermometer true 26541b18 a190cc7c446c true yes good yes http://someurl.com

The JSON object (output):

{
  "resource": {
    "resourceType": "Group",
    "id": "26541b18",   // from id
    "identifier": [
      {
        "use": "official",
        "value": "26541b18"   // from id
      },
      {
        "use": "secondary",
        "value": "a190cc7c446c"   // from previousId
      }
    ],
    "active": "true",   // from active
    "code": {
      "coding": [
        {
          "system": "http://smartregister.org",
          "code": "386452003",
          "display": "Supply management"
        }
      ]
    },
    "name": "Thermometer",   // from name
    "characteristic": [
      {
        "code": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "23435363",
              "display": "Attractive Item code"
            }
          ]
        },
        "valueBoolean": "true"   // from isAttractive
      },
      {
        "code": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "34536373",
              "display": "Is it there code"
            }
          ]
        },
        "valueCodeableConcept": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "34536373-1",
              "display": "Value entered on the It is there code"
            }
          ],
          "text": "yes"   // from isAvailable
        }
      },
      {
        "code": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "45647484",
              "display": "Is it in good condition? (optional)"
            }
          ]
        },
        "valueCodeableConcept": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "45647484-1",
              "display": "Value entered on the Is it in good condition? (optional)"
            }
          ],
          "text": "good"   // from condition
        }
      },
      {
        "code": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "56758595",
              "display": "Is it being used appropriately? (optional)"
            }
          ]
        },
        "valueCodeableConcept": {
          "coding": [
            {
              "system": "http://smartregister.org",
              "code": "56758595-1",
              "display": "Value entered on the Is it being used appropriately? (optional)"
            }
          ],
          "text": "yes"   // from appropriateUsage
        }
      },
      {
        "code": {
          "coding": [
            {
              "system": "http://smartregister.org/product-image",
              "code": "1231415",
              "display": "Product Image code"
            }
          ]
        },
        "valueReference": {
          "reference": "Binary/a83ff45c-2d94-4bd5-8fd3-bf05901e76c4"   // uuid generated from saving image at source
        }
      }
    ]
  }
}