Class: XDS::Metadata

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/xds/metadata.rb

Constant Summary collapse

EXTERNAL_ID_SCHEMES =
{:patient_id=> {:scheme=>'urn:uuid:58a6f841-87b3-4a3e-92fd-a8ffeff98427',
            :value=>'XDSDocumentEntry.patientId'},
:unique_id=>{:scheme=>'urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab',
             :value=>'XDSDocumentEntry.uniqueId'}
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#create_classification, #create_external_identifier, #create_extrinsic_object, #create_localized_string, #create_name, #create_slot, #get_external_identifier_value, #get_slot_value, #get_slot_values, #with_classification

Instance Attribute Details

#authorObject

Returns the value of attribute author.



11
12
13
# File 'lib/xds/metadata.rb', line 11

def author
  @author
end

#availability_statusObject

Returns the value of attribute availability_status.



12
13
14
# File 'lib/xds/metadata.rb', line 12

def availability_status
  @availability_status
end

#class_codeObject

Returns the value of attribute class_code.



13
14
15
# File 'lib/xds/metadata.rb', line 13

def class_code
  @class_code
end

#confidentiality_codeObject

Returns the value of attribute confidentiality_code.



14
15
16
# File 'lib/xds/metadata.rb', line 14

def confidentiality_code
  @confidentiality_code
end

#creation_timeObject

Returns the value of attribute creation_time.



15
16
17
# File 'lib/xds/metadata.rb', line 15

def creation_time
  @creation_time
end

#format_codeObject

Returns the value of attribute format_code.



16
17
18
# File 'lib/xds/metadata.rb', line 16

def format_code
  @format_code
end

#healthcare_facility_type_codeObject

Returns the value of attribute healthcare_facility_type_code.



17
18
19
# File 'lib/xds/metadata.rb', line 17

def healthcare_facility_type_code
  @healthcare_facility_type_code
end

#idObject

Returns the value of attribute id.



30
31
32
# File 'lib/xds/metadata.rb', line 30

def id
  @id
end

#language_codeObject

Returns the value of attribute language_code.



18
19
20
# File 'lib/xds/metadata.rb', line 18

def language_code
  @language_code
end

#mime_typeObject

Returns the value of attribute mime_type.



19
20
21
# File 'lib/xds/metadata.rb', line 19

def mime_type
  @mime_type
end

#patient_idObject

Returns the value of attribute patient_id.



20
21
22
# File 'lib/xds/metadata.rb', line 20

def patient_id
  @patient_id
end

#practice_setting_codeObject

Returns the value of attribute practice_setting_code.



21
22
23
# File 'lib/xds/metadata.rb', line 21

def practice_setting_code
  @practice_setting_code
end

#repository_unique_idObject

Returns the value of attribute repository_unique_id.



33
34
35
# File 'lib/xds/metadata.rb', line 33

def repository_unique_id
  @repository_unique_id
end

#service_start_timeObject

Returns the value of attribute service_start_time.



22
23
24
# File 'lib/xds/metadata.rb', line 22

def service_start_time
  @service_start_time
end

#service_stop_timeObject

Returns the value of attribute service_stop_time.



22
23
24
# File 'lib/xds/metadata.rb', line 22

def service_stop_time
  @service_stop_time
end

#sizeObject

Returns the value of attribute size.



23
24
25
# File 'lib/xds/metadata.rb', line 23

def size
  @size
end

#source_idObject

Returns the value of attribute source_id.



32
33
34
# File 'lib/xds/metadata.rb', line 32

def source_id
  @source_id
end

#source_patient_idObject

Returns the value of attribute source_patient_id.



24
25
26
# File 'lib/xds/metadata.rb', line 24

def source_patient_id
  @source_patient_id
end

#source_patient_infoObject

Returns the value of attribute source_patient_info.



25
26
27
# File 'lib/xds/metadata.rb', line 25

def source_patient_info
  @source_patient_info
end

#ss_unique_idObject

Returns the value of attribute ss_unique_id.



31
32
33
# File 'lib/xds/metadata.rb', line 31

def ss_unique_id
  @ss_unique_id
end

#type_codeObject

Returns the value of attribute type_code.



26
27
28
# File 'lib/xds/metadata.rb', line 26

def type_code
  @type_code
end

#unique_idObject

Returns the value of attribute unique_id.



27
28
29
# File 'lib/xds/metadata.rb', line 27

def unique_id
  @unique_id
end

#uriObject

Returns the value of attribute uri.



28
29
30
# File 'lib/xds/metadata.rb', line 28

def uri
  @uri
end

#version_infoObject

Returns the value of attribute version_info.



29
30
31
# File 'lib/xds/metadata.rb', line 29

def version_info
  @version_info
end

Instance Method Details

#external_identifier(builder, name) ⇒ Object



170
171
172
173
174
175
176
177
# File 'lib/xds/metadata.rb', line 170

def external_identifier(builder,name)
  ei_params = EXTERNAL_ID_SCHEMES[name]
  if ei_params
    create_external_identifier(builder,"urn:uid:#{UUID.new.generate}",@id,ei_params[:scheme],self.send(name))  do |build|
      create_name(builder,ei_params[:value])
    end
  end
end

#from_hash(hash, affinity_domain_config) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/xds/metadata.rb', line 143

def from_hash(hash, affinity_domain_config)
  if hash['author']
    @author = Author.new(hash['author']['institution'], hash['author']['person'], hash['author']['role'], hash['author']['specialty'])
  end
  @availibility_status = hash['availibility_status']
  @class_code = affinity_domain_config.coded_attribute(:class_code, hash['class_code'])
  @confidentiality_code = affinity_domain_config.coded_attribute(:confidentiality_code, hash['confidentiality_code'])
  @creation_time = hash['creation_time']
  @format_code = affinity_domain_config.coded_attribute(:format_code, hash['format_code'])
  @healthcare_facility_type_code = affinity_domain_config.coded_attribute(:healthcare_facility_type_code, hash['healthcare_facility_type_code'])
  @language_code = affinity_domain_config.coded_attribute(:language_code, hash['language_code'])
  @mime_type = hash['mime_type']
  @patient_id = hash['patient_id']
  @practice_setting_code = affinity_domain_config.coded_attribute(:practice_setting_code, hash['practice_setting_code'])
  @service_start_time = hash['service_start_time']
  @service_stop_time = hash['service_stop_time']
  @source_pateint_id = hash['source_pateint_id']
  @source_patient_info = SourcePatientInfo.new(hash['source_patient_info']) if hash['source_patient_info']
  @type_code = affinity_domain_config.coded_attribute(:type_code, hash['type_code'])
  @unique_id = hash['unique_id']
  @uri = hash['uri']
  @version_info = hash['version_info']
  @ss_unique_id = hash['ss_unique_id']
  @source_id = hash['source_id']
  @repository_unique_id = hash['repository_unique_id']
end

#load_from_extrinsic_object(eo_node) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/xds/metadata.rb', line 100

def load_from_extrinsic_object(eo_node)
  @author = Author.new
  @author.from_extrinsic_object(eo_node)
  @availability_status = CodedAttribute.new(:availability_status)
  @availability_status.from_extrinsic_object(eo_node)
  @class_code = CodedAttribute.new(:class_code)
  @class_code.from_extrinsic_object(eo_node)
  @confidentiality_code = CodedAttribute.new(:confidentiality_code)
  @confidentiality_code.from_extrinsic_object(eo_node)
  
  
  @creation_time = get_slot_value(eo_node, 'creationTime')

  @format_code = CodedAttribute.new(:format_code)
  @format_code.from_extrinsic_object(eo_node)
  @healthcare_facility_type_code = CodedAttribute.new(:healthcare_facility_type_code)
  @healthcare_facility_type_code.from_extrinsic_object(eo_node)
  @language_code = CodedAttribute.new(:language_code)
  @language_code.from_extrinsic_object(eo_node)
  
  @mime_type = eo_node.attributes['mimeType']
  
  @patient_id = get_external_identifier_value(eo_node, EXTERNAL_ID_SCHEMES[:patient_id][:scheme])
  
  @practice_setting_code = CodedAttribute.new(:practice_setting_code)
  @practice_setting_code.from_extrinsic_object(eo_node)
  

  @service_start_time = get_slot_value(eo_node, 'serviceStartTime')
  @service_stop_time = get_slot_value(eo_node, 'serviceStopTime')

  @source_patient_info = SourcePatientInfo.new
  @source_patient_info.from_extrinsic_object(eo_node)
  
  @size = get_slot_value(eo_node, 'size')
  @source_pateint_id = get_slot_value(eo_node, 'sourcePatientId')
  @type_code = CodedAttribute.new(:type_code)
  @type_code.from_extrinsic_object(eo_node)
  @unique_id = get_external_identifier_value(eo_node, EXTERNAL_ID_SCHEMES[:unique_id][:scheme])
  @uri = get_slot_value(eo_node, 'URI')
  @repository_unique_id = get_slot_value(eo_node,"repositoryUniqueId")
end

#to_soap(builder) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/xds/metadata.rb', line 36

def to_soap(builder)
  @id="urn:uid:#{UUID.new.generate}" unless @id

  builder.RegistryObjectList("xmlns"=>"urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0") do 
     create_extrinsic_object(builder,@id,@mime_type,"urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1") do
      
      create_slot(builder,'languageCode', @language_code) if @language_code
      create_slot(builder,'creationTime', @creation_time) if @creation_time
      create_slot(builder,'serviceStartTime', @service_start_time) if @service_start_time     
      create_slot(builder,'serviceStopTime', @service_stop_time)  if @service_stop_time

      create_slot(builder,'sourcePatientId', @source_patient_id) if @source_patient_id
      @source_patient_info.try(:to_soap, builder)
      
      @version_info.to_soap(builder) if @version_info
      @author.try(:to_soap, builder, @id)       
      @class_code.try(:to_soap, builder, @id) 
      @confidentiality_code.try(:to_soap, builder, @id)     
      @format_code.try(:to_soap, builder, @id) 
      @healthcare_facility_type_code.try(:to_soap, builder, @id)         
      
      @practice_setting_code.try(:to_soap, builder, @id)
      
      @type_code.try(:to_soap, builder, @id)

      external_identifier(builder,:patient_id)
      external_identifier(builder,:unique_id)
    end
   
    builder.RegistryPackage(:id=>"ss01",:objectType=>"urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage") do
      create_slot(builder,"submissionTime",Time.now.strftime('%Y%m%d'))
 
      create_classification(builder,"urn:uuid:aa543740-bdda-424e-8c96-df4873be8500","ss01","Initial evaluation","cl01") do
        create_slot(builder,"codingScheme","Connect-a-thon contentTypeCodes")
        create_name(builder,"Initial evaluation")
      end
          
      create_external_identifier(builder,"ss_ei_01","ss01","urn:uuid:96fdda7c-d067-4183-912e-bf5ee74998a8",ss_unique_id)  do |build|
        create_name(builder,"XDSSubmissionSet.uniqueId")
      end
      
      create_external_identifier(builder,"ss_ei_02","ss01","urn:uuid:554ac39e-e3fe-47fe-b233-965d2a147832",source_id)  do |build|
        create_name(builder,"XDSSubmissionSet.sourceId")
      end
      
      create_external_identifier(builder,"ss_ei_03","ss01","urn:uuid:58a6f841-87b3-4a3e-92fd-a8ffeff98427",@source_patient_info.source_patient_identifier)  do |build|
        create_name(builder,"XDSDocumentEntry.patientId")
      end
      
      create_external_identifier(builder,"ss_ei_04","ss01","urn:uuid:6b5aea1a-874d-4603-a4bc-96a0a7b38446",@source_patient_info.source_patient_identifier)  do |build|
        create_name(builder,"XDSSubmissionSet.patientId")
      end
      
      
    end
    builder.Classification(:id=>"ss01_class_id",:classificationScheme=>"urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd",:classificationNode=>"urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd",:classifiedObject=>"ss01")
    
    
   builder.Association(:id=>"ass_01",:associationType=>"urn:oasis:names:tc:ebxml-regrep:AssociationType:HasMember",:sourceObject=>"ss01",:targetObject=>@id) do
        create_slot(builder,"SubmissionSetStatus","Original")
    end
  end
end