How structure all resources to export JSON

Hello,

I’m using the FHIR standard to load some information about patients.

My doubt is,I have 10 patients, each patient has some episodes of care, and each episode of care has some observations. What is better:

  1. Put in the same JSON all information about one patient? How I did do?

  2. I should have one JSON for resource and patient ?

  3. I should have one JSON for episode and patient.?

Thanks.

You’ll have one Bundle resource containing separate entries for each Patient, each EpisodeOfCare and each Observation. The Observations will point to the Patients and the EpisodeOfCare instances. The EpisodeOfCare instances will point to the Patients

For example, if I have this data:

patient:1 episode:1

patient:1 episode:2

patient: 2, episode:1

For this example, the structure will be :

{
“resourceType”: “Bundle”,
“entry”:[
{
“patient”:{“identifier”:1},
“episodeofcare”:{“identifier”:1},
“episodeofcare”:{“identifier”:2},

},
{
“patient”:{“identifier”:2},
“episodeofcare”:{“identifier”:1},
}
]
}

This structure meets the standard FHIR? I can put same respources in the same json for the same patient?

Thanks.

Not the correct syntax, but first lets deal with the relationships. In FHIR, the expectation in the base spec is that every EpisodeOfCare instance corresponds to exactly 1 Patient. It’s not possible to have multiple patients tied to an EpisodeOfCare without using extensions. It’s certainly possible to add extensions, but it would be good to have clarity about what your intentions are with the relationship first.

In terms of syntax, you’d have 4 entries - one for Patient 1, one for Patient 2, one for EpisodeOfCare 1 and one for EpisodeOfCare 2. EpisodeOfCare 1 would have an element that pointed to the id of Patient 1. etc. (And of course the identifier element is much more complex than a simple number). Look at the JSON examples for Bundle to get a sense of what it looks like and how resources reference each other.

Yes, you’re rigth, the episode is unique for a each patient.

The correct syntax would one entry for resource?

The best practice will be a only JSON that contain all patients, or it’s better one JSON for patient?

Thanks.

One entry per resource - that should hopefully be clear from the spec. As for whether you want a Bundle with all patients or a Bundle per patient, that’s totally up to the needs of your use-case. Either is fine.

This is an example of one patient, this structure is valid?
The id of patient is: 12345

{
“resourceType”:“Bundle”,
“identifier”:{
“value”:12345
},
“type”:“collection”,
“total”:6,
“entry”:[
{
“resource”:{
“resourceType”:“Patient”,
“identifier”:{
“value”:12345
},
“name”:{
“text”:“Jonhy Walker”
}
}
},
{
“resource”:{
“resourceType”:“EpisodeOfCare”,
“identifier”:{
“value”:456789
},
“statusHistory”:{
“period”:{
“start”:“2011-10-13 15:07”
}
}
}
},

{
"resource":{
	"resourceType": "Observation",
	"id": "temperature",
	"subject": {
		"identifier":{
			"value":12345
						}
				},
		"value": {
			"valueQuantity":38.5
				}
		}
},
{
"resource":{
	"resourceType": "Observation",
	"id": "weight",
	"subject": {
		"identifier":{
			"value":12345
						}
				},
		"value": {
			"valueQuantity":89
				}
		}
},
{
"resource":{
	"resourceType":"EpisodeOfCare",
	"identifier":{
		"value":456790
				},
	"statusHistory":{
		"period":{
			"start":"2011-12-25 15:07"
					}
				}
		}
},
{
"resource":{
	"resourceType": "Observation",
	"id": "HIV",
	"subject": {
		"identifier":{
			"value":12345
						}
				},
		"value": {
			"valueString":"S"
				}
		}
}
	]

}

PD:Sorry, In each episodeOfCare I will put the patient reference.

You’ll also need an “id” element on the Patient so you can point to it and a fullUrl on the entries. You can’t nest elements inside subject other than those allowed by reference. So you’d have:
“subject”: {“reference”: “Patient/1”}

Also, if you’re going to use identifier, give serious thought to specifying an identifier system URL that makes the identifier globally unique.

To validate, try posting your example to one of the reference servers. HealthIntersections is particularly good about validating your input.

Hello,

I’ve installed the FHIR validator.

I’m getting the next error: Relative Reference appears inside Bundle whose entry is missing a fullUrl.

I see the bundle definition and I don’t understand that i have to put in the fullUrl field…?

It is obligatory to put this field.

Thanks.

According to the spec:
“The fullUrl element SHALL have a value except that: * fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) * Results from operations might involve resources that are not identified.”

I think that I understand this field. But I have another question…in the code fields, for example in observation resource, the system, code and display fields can be any codes definied in the url specific in the system field , correct?

Fro example in mi case, the code : 3 is a display: Weight, and code FHIR is 871…

The system must be the URL for the code system in which the codes are defined. So, for LOINC, the code system would be “http://loinc.org”. If you’re using a local code system,you’ll need to define a URL for that code system. The ‘code’ is the code value as defined in the code system and ‘display’ is one of the display values defined by the code system.