Module: USCoreTestKit::Generator::Naming

Defined in:
lib/us_core_test_kit/generator/naming.rb

Constant Summary collapse

ALLERGY_INTOLERANCE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-allergyintolerance'
CARE_PLAN =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-careplan'
CARE_TEAM =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-careteam'
CONDITION =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition'
IMPLANTABLE_DEVICE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-implantable-device'
DIAGNOSTIC_REPORT_NOTE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-note'
DIAGNOSTIC_REPORT_LAB =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-lab'
DOCUMENT_REFERENCE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-documentreference'
ENCOUNTER =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter'
GOAL =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-goal'
IMMUNIZATION =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-immunization'
LOCATION =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-location'
MEDICATION =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-medication'
MEDICATION_REQUEST =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-medicationrequest'
SMOKING_STATUS =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-smokingstatus'
PEDIATRIC_WEIGHT_FOR_HEIGHT =
'http://hl7.org/fhir/us/core/StructureDefinition/pediatric-weight-for-height'
OBSERVATION_LAB =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab'
PEDIATRIC_BMI_FOR_AGE =
'http://hl7.org/fhir/us/core/StructureDefinition/pediatric-bmi-for-age'
PULSE_OXIMETRY =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry'
HEAD_CIRCUMFERENCE =
'http://hl7.org/fhir/us/core/StructureDefinition/head-occipital-frontal-circumference-percentile'
ORGANIZATION =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization'
PATIENT =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient'
PRACTITIONER =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner'
PRACTITIONER_ROLE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole'
PROCEDURE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-procedure'
PROVENANCE =
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-provenance'
{
  'v3.1.1' => 'http://hl7.org/fhir/us/core/STU3.1.1',
  'v4.0.0' => 'http://hl7.org/fhir/us/core/STU4',
  'v5.0.1' => 'http://hl7.org/fhir/us/core/STU5.0.1',
  'v6.1.0' => 'http://hl7.org/fhir/us/core/STU6.1',
  'v7.0.0' => 'http://hl7.org/fhir/us/core/STU7'
}.freeze

Class Method Summary collapse

Class Method Details



66
67
68
# File 'lib/us_core_test_kit/generator/naming.rb', line 66

def ig_link(version)
  IG_LINKS[version]
end

.resource_has_multiple_profiles?(resource) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/us_core_test_kit/generator/naming.rb', line 44

def resource_has_multiple_profiles?(resource)
  resources_with_multiple_profiles.include? resource
end

.resources_with_multiple_profilesObject



40
41
42
# File 'lib/us_core_test_kit/generator/naming.rb', line 40

def resources_with_multiple_profiles
  ['Condition', 'DiagnosticReport', 'Observation']
end

.snake_case_for_profile(group_metadata) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/us_core_test_kit/generator/naming.rb', line 48

def snake_case_for_profile()
  resource = .resource
  return resource.underscore unless resource_has_multiple_profiles?(resource)

  if .profile_url == HEAD_CIRCUMFERENCE
    return .reformatted_version == 'v311' ? 'head_circumference' : 'head_circumference_percentile'
  end

  .name
    .delete_prefix('us_core_')
    .gsub('diagnosticreport', 'diagnostic_report')
    .underscore
end

.upper_camel_case_for_profile(group_metadata) ⇒ Object



62
63
64
# File 'lib/us_core_test_kit/generator/naming.rb', line 62

def upper_camel_case_for_profile()
  snake_case_for_profile().camelize
end