Class: OrcaApi::Client
- Inherits:
 - 
      Object
      
        
- Object
 - OrcaApi::Client
 
 
- Defined in:
 - lib/orca_api/client.rb
 
Overview
日医レセAPIを呼び出すため低レベルインタフェースを提供するクラス
リクエスト毎に日レセAPIの接続先を切り替えられるように、接続・認証情報をこのクラスのオブジェクトに保持する。 また、スレッド毎に別のオブジェクトを生成することを想定しており、 同じオブジェクトに複数のスレッドからアクセスすることはできない。
基本的には、低レベルインタフェースを使わなくても電子カルテのアプリケーションが組めるように、 OrcaApi::Service クラスを継承した高レベルインターフェースを提供する。
OrcaApi::Client#debug_output= に IO オブジェクトを設定すると、日レセAPIとのやりとりを IO に出力できる。
orca_api.debug_output = $stdout
接続・認証に関するサンプルプログラムは /example/common.rb を参照。
また、低レベルインタフェースに関するサンプルプログラムは /example/orca_api/call.rb を参照。
Instance Attribute Summary collapse
- 
  
    
      #ca_file  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
CA証明書のパス.
 - 
  
    
      #ca_path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
CA証明書を格納しているディレクトリのパス.
 - 
  
    
      #cert  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
クライアント証明書.
 - 
  
    
      #debug_output  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
デバッグに使う
IOオブジェクト. - 
  
    
      #host  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
ホスト名.
 - 
  
    
      #karte_uid  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
カルテUIDの取得 OrcaApi::Client#karte_uid= で明示的に設定しない場合は、OrcaApi::Client のインスタンス毎にユニークな値を自動生成する.
 - 
  
    
      #key  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
暗号鍵.
 - 
  
    
      #password  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
パスワード.
 - 
  
    
      #port  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
ポート番号.
 - 
  
    
      #timeout  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute timeout.
 - 
  
    
      #use_ssl  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
SSL通信をするかどうか.
 - 
  
    
      #user  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
ユーザー名.
 - 
  
    
      #verify_mode  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
サーバ証明書の検証モード.
 
高レベルインターフェース collapse
- 
  
    
      #new_acceptance_service  ⇒ AcceptanceService 
    
    
  
  
  
  
  
  
  
  
  
    
AcceptanceServiceインスタンス.
 - 
  
    
      #new_blob_service  ⇒ BlobService 
    
    
  
  
  
  
  
  
  
  
  
    
BlobServiceインスタンス.
 - 
  
    
      #new_department_service  ⇒ DepartmentService 
    
    
  
  
  
  
  
  
  
  
  
    
DepartmentServiceインスタンス.
 - 
  
    
      #new_disease_service  ⇒ DiseaseService 
    
    
  
  
  
  
  
  
  
  
  
    
DiseaseServiceインスタンス.
 - 
  
    
      #new_find_service  ⇒ FindService 
    
    
  
  
  
  
  
  
  
  
  
    
FindServiceインスタンス.
 - 
  
    
      #new_form_data_service  ⇒ FormDataService 
    
    
  
  
  
  
  
  
  
  
  
    
FormDataServiceインスタンス.
 - 
  
    
      #new_image_service  ⇒ ImageService 
    
    
  
  
  
  
  
  
  
  
  
    
ImageServiceインスタンス.
 - 
  
    
      #new_income_service  ⇒ IncomeService 
    
    
  
  
  
  
  
  
  
  
  
    
IncomeServiceインスタンス.
 - 
  
    
      #new_insurance_service  ⇒ InsuranceService 
    
    
  
  
  
  
  
  
  
  
  
    
InsuranceServiceインスタンス.
 - 
  
    
      #new_lock_service  ⇒ LockService 
    
    
  
  
  
  
  
  
  
  
  
    
LockServiceインスタンス.
 - 
  
    
      #new_medical_practice_service  ⇒ MedicalPracticeService 
    
    
  
  
  
  
  
  
  
  
  
    
MedicalPracticeServiceインスタンス.
 - 
  
    
      #new_patient_service  ⇒ PatientService 
    
    
  
  
  
  
  
  
  
  
  
    
PatientServiceインスタンス.
 - 
  
    
      #new_physician_service  ⇒ PhysicianService 
    
    
  
  
  
  
  
  
  
  
  
    
PhysicianServiceインスタンス.
 - 
  
    
      #new_print_service  ⇒ PrintService 
    
    
  
  
  
  
  
  
  
  
  
    
PrintServiceインスタンス.
 - 
  
    
      #new_receipt_data_check_service  ⇒ ReceiptDataCheckService 
    
    
  
  
  
  
  
  
  
  
  
    
ReceiptDataCheckServiceインスタンス.
 - 
  
    
      #new_receipt_data_service  ⇒ ReceiptDataService 
    
    
  
  
  
  
  
  
  
  
  
    
ReceiptDataServiceインスタンス.
 - 
  
    
      #new_receipt_service  ⇒ ReceiptService 
    
    
  
  
  
  
  
  
  
  
  
    
ReceiptServiceインスタンス.
 - 
  
    
      #new_rehabilitation_comment_service  ⇒ RehabilitationCommentService 
    
    
  
  
  
  
  
  
  
  
  
    
RehabilitationCommentServiceインスタンス.
 - 
  
    
      #new_statistics_form_service  ⇒ StatisticsFormServie 
    
    
  
  
  
  
  
  
  
  
  
    
StatisticsFormServiceインスタンス.
 - 
  
    
      #new_user_service  ⇒ UserService 
    
    
  
  
  
  
  
  
  
  
  
    
UserServiceインスタンス.
 - #reuse_session ⇒ Object
 - #reusing_session? ⇒ Boolean
 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #call(path, params: {}, body: nil, http_method: :post, format: "json", output_io: nil)  ⇒ IO, String 
    
    
  
  
  
  
  
  
  
  
  
    
任意の日レセAPIを呼び出す.
 - 
  
    
      #initialize(uri, options = {})  ⇒ Client 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Client.
 
Constructor Details
#initialize(uri, options = {}) ⇒ Client
Returns a new instance of Client
      95 96 97 98 99 100 101 102 103 104 105 106 107  | 
    
      # File 'lib/orca_api/client.rb', line 95 def initialize(uri, = {}) uri = URI.parse(uri) @host = uri.host @port = uri.port @user = uri.user || [:user] @password = uri.password || [:password] @use_ssl = uri.scheme == 'https' || [:use_ssl] if @use_ssl (.fetch(:ssl)) end @reuse_http = 0 self.timeout = [:timeout] end  | 
  
Constructor Details
#initialize(uri, options = {}) ⇒ Client
Returns a new instance of Client
      95 96 97 98 99 100 101 102 103 104 105 106 107  | 
    
      # File 'lib/orca_api/client.rb', line 95 def initialize(uri, = {}) uri = URI.parse(uri) @host = uri.host @port = uri.port @user = uri.user || [:user] @password = uri.password || [:password] @use_ssl = uri.scheme == 'https' || [:use_ssl] if @use_ssl (.fetch(:ssl)) end @reuse_http = 0 self.timeout = [:timeout] end  | 
  
Instance Attribute Details
#ca_file ⇒ Object
CA証明書のパス
      36 37 38  | 
    
      # File 'lib/orca_api/client.rb', line 36 def ca_file @ca_file end  | 
  
#ca_path ⇒ Object
CA証明書を格納しているディレクトリのパス
      37 38 39  | 
    
      # File 'lib/orca_api/client.rb', line 37 def ca_path @ca_path end  | 
  
#cert ⇒ Object
クライアント証明書
      39 40 41  | 
    
      # File 'lib/orca_api/client.rb', line 39 def cert @cert end  | 
  
#debug_output ⇒ Object
デバッグに使う IO オブジェクト
      42 43 44  | 
    
      # File 'lib/orca_api/client.rb', line 42 def debug_output @debug_output end  | 
  
#host ⇒ Object
ホスト名
      31 32 33  | 
    
      # File 'lib/orca_api/client.rb', line 31 def host @host end  | 
  
#karte_uid ⇒ String
カルテUIDの取得 OrcaApi::Client#karte_uid= で明示的に設定しない場合は、OrcaApi::Client のインスタンス毎にユニークな値を自動生成する
      113 114 115  | 
    
      # File 'lib/orca_api/client.rb', line 113 def karte_uid @karte_uid ||= SecureRandom.uuid end  | 
  
#key ⇒ Object
暗号鍵
      40 41 42  | 
    
      # File 'lib/orca_api/client.rb', line 40 def key @key end  | 
  
#password ⇒ Object
パスワード
      34 35 36  | 
    
      # File 'lib/orca_api/client.rb', line 34 def password @password end  | 
  
#port ⇒ Object
ポート番号
      32 33 34  | 
    
      # File 'lib/orca_api/client.rb', line 32 def port @port end  | 
  
#timeout ⇒ Object
Returns the value of attribute timeout.
      43 44 45  | 
    
      # File 'lib/orca_api/client.rb', line 43 def timeout @timeout end  | 
  
#use_ssl ⇒ Object
SSL通信をするかどうか
      35 36 37  | 
    
      # File 'lib/orca_api/client.rb', line 35 def use_ssl @use_ssl end  | 
  
#user ⇒ Object
ユーザー名
      33 34 35  | 
    
      # File 'lib/orca_api/client.rb', line 33 def user @user end  | 
  
#verify_mode ⇒ Object
サーバ証明書の検証モード
      38 39 40  | 
    
      # File 'lib/orca_api/client.rb', line 38 def verify_mode @verify_mode end  | 
  
Class Method Details
.underscore(name) ⇒ Object
      45 46 47 48 49 50  | 
    
      # File 'lib/orca_api/client.rb', line 45 def self.underscore(name) name. gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). downcase end  | 
  
Instance Method Details
#call(path, params: {}, body: nil, http_method: :post, format: "json", output_io: nil) ⇒ IO, String
任意の日レセAPIを呼び出す
引数paramsやbodyの内容のチェックは行わない。
結果はRubyのオブジェクト(HashやArray等)が返る。処理結果を番号で格納したApi_Resultでさえ、 値のフォーマットや意味が様々であるため、結果の内容のチェックも行わない。
      141 142 143  | 
    
      # File 'lib/orca_api/client.rb', line 141 def call(path, params: {}, body: nil, http_method: :post, format: "json", output_io: nil) do_call make_request(http_method, path, params, body, format), output_io end  | 
  
#new_acceptance_service ⇒ AcceptanceService
Returns AcceptanceServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 162
     | 
  
#new_department_service ⇒ DepartmentService
Returns DepartmentServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 153
     | 
  
#new_disease_service ⇒ DiseaseService
Returns DiseaseServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 165
     | 
  
#new_form_data_service ⇒ FormDataService
Returns FormDataServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 168
     | 
  
#new_image_service ⇒ ImageService
Returns ImageServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 177
     | 
  
#new_income_service ⇒ IncomeService
Returns IncomeServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 171
     | 
  
#new_insurance_service ⇒ InsuranceService
Returns InsuranceServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 150
     | 
  
#new_medical_practice_service ⇒ MedicalPracticeService
Returns MedicalPracticeServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 159
     | 
  
#new_patient_service ⇒ PatientService
Returns PatientServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 147
     | 
  
#new_physician_service ⇒ PhysicianService
Returns PhysicianServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 156
     | 
  
#new_print_service ⇒ PrintService
Returns PrintServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 174
     | 
  
#new_receipt_data_check_service ⇒ ReceiptDataCheckService
Returns ReceiptDataCheckServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 180
     | 
  
#new_receipt_data_service ⇒ ReceiptDataService
Returns ReceiptDataServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 183
     | 
  
#new_receipt_service ⇒ ReceiptService
Returns ReceiptServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 186
     | 
  
#new_rehabilitation_comment_service ⇒ RehabilitationCommentService
Returns RehabilitationCommentServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 195
     | 
  
#new_statistics_form_service ⇒ StatisticsFormServie
Returns StatisticsFormServiceインスタンス
| 
       | 
    
      # File 'lib/orca_api/client.rb', line 207
     | 
  
#reuse_session ⇒ Object
      246 247 248 249 250 251  | 
    
      # File 'lib/orca_api/client.rb', line 246 def reuse_session start_reuse_session yield ensure finish_reuse_session end  | 
  
#reusing_session? ⇒ Boolean
      253 254 255  | 
    
      # File 'lib/orca_api/client.rb', line 253 def reusing_session? @reuse_http.positive? end  |