ADO.NET Provider for FHIR

Build 23.0.8839

DataAdapter を使用したクエリ

CData ADO.NET Provider for FHIR では、次の2つのネイティブ.NET インターフェースを使用して、FHIR からデータを取得できます。FHIRDataAdapter オブジェクトおよびFHIRDataReader オブジェクト。各オブジェクトは同じタスク(データの取得)を実行しますが、実行方法が異なります。FHIRDataAdapter オブジェクトはクエリに一致するすべてのデータを取得しますが、FHIRDataReader オブジェクトは必要に応じてインクリメントしながら一部のデータだけをフェッチします。

FHIRDataAdapter の使用

アダプターのFill メソッドを使用して、データソースからデータを取得します。空のDataTable インスタンスがFill メソッドへの引数として渡されます。このメソッドが戻ってきたとき、DataTable インスタンスにはクエリされたデータが設定されています。Fill メソッドは、戻る前にデータソースからすべてのデータを取得する必要があるため、FHIRDataAdapter はFHIRDataReader よりも時間がかかります。

次の例は、Patient テーブルのId カラムと[address-city] カラムを選択します。

C#

string connectionString = "URL=http://test.fhir.org/r4b/;ConnectionType=Generic;ContentType=JSON;AuthScheme=None;";

using (FHIRConnection connection = new FHIRConnection(connectionString)) {
  FHIRDataAdapter dataAdapter = new FHIRDataAdapter(
  "SELECT Id, [address-city] FROM Patient", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);

  Console.WriteLine("Contents of Patient.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["Id"], row["[address-city]"]);
  }
}

VB.NET

Dim connectionString As String = "URL=http://test.fhir.org/r4b/;ConnectionType=Generic;ContentType=JSON;AuthScheme=None;"

Using connection As New FHIRConnection(connectionString)
  Dim dataAdapter As New FHIRDataAdapter("SELECT Id, [address-city] FROM Patient", connection)

  Dim table As New DataTable()
  dataAdapter.Fill(table)

  Console.WriteLine("Contents of Patient.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("Id"), row("[address-city]"))
  Next
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839