Текущий вывод JSON:
Код: Выделить всё
{
"id": {
"value": "bundle-example"
},
"type": {
"value": "searchset"
},
"total": {
"value": 5
},
"entry": [
{
"fullUrl": {
"value": "http://example.org/fhir/Observation/8393939"
},
"resource": {
"id": {
"value": "8393939"
},
"status": {
"value": "final"
},
"code": {
"coding": [
{
"system": {
"value": "http://loinc.org"
},
"code": {
"value": "1988-5"
},
"display": {
"value": "CRP"
}
}
]
}
// ... other fields
}
}
// ... other entries
]
}
Код: Выделить всё
{
"resourceType": "Bundle",
"id": "bundle-example",
"type": "searchset",
"total": 5,
"entry": [
{
"fullUrl": "http://example.org/fhir/Observation/8393939",
"resource": {
"resourceType": "Observation",
"id": "8393939",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "1988-5",
"display": "CRP"
}
]
}
// ... other fields
}
}
// ... other entries
]
}
Код: Выделить всё
using Hl7.Fhir.Model;
using System;
using System.Data;
using System.Collections.Generic;
using FHIR.PoC.Data;
namespace FHIR.PoC.Service
{
public class ObservationService
{
private readonly SpecimenRepository m_specimenRepository;
public ObservationService(SpecimenRepository specimenRepository)
{
m_specimenRepository = specimenRepository;
}
public Bundle MapToObservations(DataTable dtDbResults, bool bIncludeSpecimen)
{
var bundle = new Bundle
{
Id = "bundle-example",
Type = Bundle.BundleType.Searchset,
Total = dtDbResults.Rows.Count,
Entry = new List()
};
foreach (DataRow drRow in dtDbResults.Rows)
{
var observation = new Observation
{
Id = drRow["zissample_id"].ToString() ?? "null",
Status = drRow["ZISRESULTSTATUS_ID"].ToString() == "8000013" ? ObservationStatus.Final : ObservationStatus.Preliminary,
Code = new CodeableConcept
{
Coding = new List
{
new Coding
{
System = "http://loinc.org",
Code = drRow["LOINC_CODE"] != DBNull.Value ? drRow["LOINC_CODE"].ToString() : null,
Display = drRow["MEASURE_CODE"] != DBNull.Value ? drRow["MEASURE_CODE"].ToString() : null
}
}
},
Subject = new ResourceReference($"Patient/{drRow["SOURCE_ID"].ToString()}"),
Effective = GetEffectiveDate(drRow),
Issued = drRow["FIRSTREPORTDATETIME"] != DBNull.Value ? (DateTimeOffset?)Convert.ToDateTime(drRow["FIRSTREPORTDATETIME"]) : null,
Performer = new List
{
new ResourceReference("Practitioner/VasteWaardeLabTrain")
},
Value = GetObservationValue(drRow)
};
ProcessReferenceRangeIfPresent(drRow, observation);
if (bIncludeSpecimen)
{
ProcessSpecimen(drRow, observation);
}
bundle.Entry.Add(new Bundle.EntryComponent
{
FullUrl = $"http://example.org/fhir/Observation/{observation.Id}",
Resource = observation
});
}
return bundle;
}
Как я могу полностью удалить уровни значений из ответа JSON, сгенерированного моим FHIR Ресурсы наблюдения? Что мне следует изменить в коде, чтобы ответ имел правильную структуру, как показано в желаемой структуре JSON выше?
Подробнее здесь: https://stackoverflow.com/questions/791 ... son-output
Мобильная версия