Class: Quincy::PCnet
- Inherits:
-
Object
- Object
- Quincy::PCnet
- Defined in:
- lib/quincy.rb
Overview
Interface to Frey Quincy PCNet (www.frey.de/q_pcnet.htm).
Extracts patient information by reading the folder containing the PATDATXX-subdirectories.
Usage:
# find the patient with the number 98
patient = Quincy::PCnet.new("/example/QUINCY").find(98)
Instance Attribute Summary collapse
-
#quincy_path ⇒ Object
readonly
Returns the value of attribute quincy_path.
Instance Method Summary collapse
- #find(nr) ⇒ Object
-
#initialize(path = nil) ⇒ PCnet
constructor
A new instance of PCnet.
-
#path_for(nr) ⇒ Object
returns the PATDAT-file for a given patient nr.
Constructor Details
#initialize(path = nil) ⇒ PCnet
Returns a new instance of PCnet.
34 35 36 37 38 39 40 |
# File 'lib/quincy.rb', line 34 def initialize(path = nil) path ||= ENV["QUINCY"] @@blocksize = 1024 raise ArgumentError, "Quincy Path not set (use '-q' or ENV['QUINCY'])" unless path @quincy_path = Pathname.new(path) end |
Instance Attribute Details
#quincy_path ⇒ Object (readonly)
Returns the value of attribute quincy_path.
32 33 34 |
# File 'lib/quincy.rb', line 32 def quincy_path @quincy_path end |
Instance Method Details
#find(nr) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/quincy.rb', line 54 def find(nr) filename = Pathname.new(path_for(nr)) return nil unless File.exists?(filename) filename.open { |f| while (record = f.read(@@blocksize,"rb")) patient = read_record(record) return patient if patient and patient.nr == nr end } end |
#path_for(nr) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/quincy.rb', line 47 def path_for(nr) dat_nr = nr % 0xa00 dir_nr = dat_nr / 0x80 patdat_path = @quincy_path + "PATDAT#{"%02d" % dir_nr}" + "#{"%04d"% dat_nr}.DAT" patdat_path.to_str end |