@@ -79,15 +79,21 @@ class <?php echo $coreFile; ?> implements <?php echo $resourceTypeInterface; ?>,
7979 private const _FHIR_VALIDATION_RULES = [];
8080
8181 protected string $_name;
82+ protected string $_versionName;
83+ protected string $_semanticVersion;
8284
8385 private array $_valueXMLLocations = [];
8486
8587 public function __construct(string $name,
8688 array $fields = [],
8789 array $validationRuleMap = [],
88- array $fhirComments = [])
90+ array $fhirComments = [],
91+ string $versionName = 'mock',
92+ string $semanticVersion = 'v0.0.0')
8993 {
9094 $this->_name = $name;
95+ $this->_versionName = $versionName;
96+ $this->_semanticVersion = $semanticVersion;
9197 $this->_setFHIRComments($fhirComments);
9298 foreach($validationRuleMap as $field => $rules) {
9399 $this->_setFieldValidationRules($field, $rules);
@@ -100,6 +106,26 @@ public function _getFHIRTypeName(): string
100106 return $this->_name;
101107 }
102108
109+ public function _getFHIRVersionName(): string
110+ {
111+ return $this->_versionName;
112+ }
113+
114+ public function _getFHIRSemanticVersion(): string
115+ {
116+ return $this->_semanticVersion;
117+ }
118+
119+ public function _getFHIRShortVersion(): string
120+ {
121+ $v = ltrim($this->_semanticVersion, 'v');
122+ return match (substr_count($v, '.')) {
123+ 1 => $v,
124+ 2 => substr($v, 0, strrpos($v, '.')),
125+ default => implode('.', array_chunk(explode('.', $v), 2)[0])
126+ };
127+ }
128+
103129 public static function xmlUnserialize(\SimpleXMLElement|string $element,
104130 null|<?php echo $ unserializeConfig ; ?> $config = null,
105131 null|<?php echo $ resourceTypeInterface ; ?> $type = null): <?php echo $ resourceTypeInterface ; ?>
0 commit comments