in src/FhirImporter/FhirImportReferenceConverter.cs [19:56]
private static void ConvertUUIDs(JToken tok, Dictionary<string, IdTypePair> idLookupTable)
{
switch (tok.Type)
{
case JTokenType.Object:
case JTokenType.Array:
foreach (var c in tok.Children())
{
ConvertUUIDs(c, idLookupTable);
}
return;
case JTokenType.Property:
JProperty prop = (JProperty)tok;
if (prop.Value.Type == JTokenType.String &&
prop.Name == "reference" &&
idLookupTable.TryGetValue(prop.Value.ToString(), out var idTypePair))
{
prop.Value = idTypePair.ResourceType + "/" + idTypePair.Id;
}
else
{
ConvertUUIDs(prop.Value, idLookupTable);
}
return;
case JTokenType.String:
case JTokenType.Boolean:
case JTokenType.Float:
case JTokenType.Integer:
case JTokenType.Date:
return;
default:
throw new NotSupportedException($"Invalid token type {tok.Type} encountered");
}
}