Module: XdsRecordUtility

Defined in:
lib/xds_record_utility.rb

Defined Under Namespace

Classes: XDSRecord

Class Method Summary (collapse)

Class Method Details

+ (Object) all_identifiers

get all identifiers in the registry



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/xds_record_utility.rb', line 37

def self.all_identifiers
   
   establish_connection
        
    xds_all_ids_query = "SELECT patId.value, patId.identificationScheme, patId.id FROM ExternalIdentifier patId"
    begin
      ActiveRecord::Base.connection_handler.retrieve_connection( self ).select_all( "#{xds_all_ids_query}\n" )
    rescue ActiveRecord::StatementInvalid
       return
    end
end

+ (Object) all_patients

instantiate all identifiers in the registry as XDSRecords



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/xds_record_utility.rb', line 15

def self.all_patients
  
  patients = []
  
  all_identifiers.each do |identifier|
   
    xds_record = XDSRecord.new
    xds_record.documents = documents(  identifier[ 'identificationscheme' ], identifier['value'] )
    xds_record.value = identifier['value']
    xds_record.id = identifier['id']
    xds_record.id_scheme = identifier[ 'identificationscheme' ]
    xds_record.patient = Patient.find_by_patient_identifier( identifier[ 'value' ] )
    
    patients << xds_record
  end
  
  patients
  
end

+ (Object) documents(id_scheme, value)

get documents/object ids associated with an identifier in the registry



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/xds_record_utility.rb', line 50

def self.documents( id_scheme, value )

  establish_connection
  
  xds_docs_query = "SELECT doc.id
              FROM ExtrinsicObject doc, ExternalIdentifier patId
              WHERE
                doc.id = patId.registryobject AND      
                patId.identificationScheme='#{id_scheme}'
              AND
                patId.value = '#{value}';" 
  begin
    ActiveRecord::Base.connection_handler.retrieve_connection( self ).select_values( "#{xds_docs_query}\n" )
  rescue ActiveRecord::StatementInvalid
    return
  end  
end