HL7 FHIR uses RESTful APIs for creating, modifying and accessing resources. The resources listed below are based on the minimum data set that contact tracing applications are expected to provide.

Sample FHIR Resources:

Patient

patient.json

{
   "resourceType":"Patient",
   "id": "1", // FHIR PatientId, automatically generated when a new resource is created.
							// To be used as CaseID. Not required for POST, required for PUT.
   "telecom":[ 
      {
         "system":"phone", 
         "value":"09999999999"
      },
      {
         "system":"email",
         "value":"[email protected]"
      }
   ],
   "gender":"female",
   "address":[ 
      {
        "use": "home",
        "text": "141102040" //PSGC code
      }
   ],
   "extension":[
    {
      "url": "<http://hl7.org/fhir/SearchParameter/patient-extensions-Patient-age>",
      "valueInteger": 33 
    }
   ]
}

QuestionnaireResponse

questionnaireresponse.json

{
  "resourceType": "QuestionnaireResponse",
  "questionnaire": "Questionnaire/CT", // reference to Questionnaire defined below
  "status": "completed",
  "subject": {
    "reference": "Patient/1" // 1 here is the generated FHIR PatientId / CaseID, to link the data below to a specific person
  },
  "item": [
    {
      "linkId": "1",
      "text": "Health status",
      "answer": [
        {
          "valueString": "Mild" // Possible values: Suspect Severe/Mild Severe/Low Risk
        }
      ]
    },
    {
      "linkId": "2",
      "text": "Workplace name",
      "answer": [
        {
          "valueString": "Company"
        }
      ]
    },
    {
      "linkId": "2.1",
      "text": "Workplace address (PSGC)",
      "answer": [
        {
          "valueInteger": 141102040
        }
      ]
    },
    {
      "linkId": "2.2",
      "text": "Work from home?",
      "answer": [
        {
          "valueBoolean": true
        }
      ]
    },
    {
      "linkId": "3",
      "text": "Admitted?",
      "answer": [
        {
          "valueBoolean": false
        }
      ]
    },
    {
      "linkId": "3.1",
      "text": "Hospital name where patient is admitted",
      "answer": [
        {
          "valueString": ""
        }
      ]
    },
    {
      "linkId": "4",
      "text": "Quarantined?",
      "answer": [
        {
          "valueBoolean": true
        }
      ]
    },
    {
      "linkId": "4.1",
      "text": "Quarantine location",
      "answer": [
        {
          "valueString": "Facility" // home or name of quarantine facility
        }
      ]
    },
    {
      "linkId": "5",
      "text": "Verifier ID",
      "answer": [
        {
          "valueInteger": 123
        }
      ]
    },
    {
      "linkId": "6",
      "text": "Source CaseID",
      "answer": [
        {
          "valueInteger": 2345
        }
      ]
    }
  ]
}

Questionnaire

Note: Apps do not need to send this resource, as this is just the list of questions that are answered by the QuestionnaireResponse, and is only included here as reference.

{
  "resourceType": "Questionnaire",
  "id": "CT",
  "url": "<http://sil-asia.org/fhir/Questionnaire/CT>",
  "status": "active",
  "subjectType": [
    "Patient"
  ],
  "date": "2020",
  "item": [
    {
      "linkId": "1",
      "text": "Health status",
      "type": "string"
    },
    {
      "linkId": "2",
      "text": "Workplace name",
      "type": "string"
    },
    {
      "linkId": "2.1",
      "text": "Workplace address (PSGC)",
      "type": "integer"
    },
    {
      "linkId": "2.2",
      "text": "Work from home?",
      "type": "boolean"
    },
    {
      "linkId": "3",
      "text": "Admitted?",
      "type": "boolean"
    },
    {
      "linkId": "3.1",
      "text": "Hospital name where patient is admitted",
      "type": "string"
    },
    {
      "linkId": "4",
      "text": "Quarantined?",
      "type": "boolean"
    },
    {
      "linkId": "4.1",
      "text": "Quarantine location",
      "type": "string"
    },
    {
      "linkId": "5",
      "text": "Verifier ID",
      "type": "integer"
    },
    {
      "linkId": "6",
      "text": "Source CaseID",
      "type": "integer"
    }
  ]
}

Sample usage:

curl <endpoint>/<resource> -d @<jsonfile> -H "content-type: application/json" 

# Example (using test endpoint "<http://172.104.170.172:8080/sila-fhirserver/fhir>"): 
curl <http://172.104.170.172:8080/sila-fhirserver/fhir/Patient> -d @patient.json -H "content-type: application/json" 
curl <endpoint>/<resource>/<resourceId>

# Example: 
curl <http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/29779>
curl <endpoint>/<resource>/<resourceId> -X PUT -d @<jsonfile> -H "content-type: application/json" 

# Example (make sure that resource's id is specified in file and matches resourceId in URL): 
curl <http://172.104.170.172:8080/sila-fhirserver/fhir/Patient/29779> -X PUT -d @patient.json -H "content-type: application/json"