diff --git a/pom.xml b/pom.xml
index e2c0fae..3cb6af9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
gov.cms.madie
madie-java-models
- 0.6.68-SNAPSHOT
+ 0.6.69-SNAPSHOT
madie-java-models
Java based models for MADiE microservices
diff --git a/src/main/java/gov/cms/madie/models/common/ModelType.java b/src/main/java/gov/cms/madie/models/common/ModelType.java
index 452cb59..79e8175 100644
--- a/src/main/java/gov/cms/madie/models/common/ModelType.java
+++ b/src/main/java/gov/cms/madie/models/common/ModelType.java
@@ -4,6 +4,8 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
@Getter
public enum ModelType {
@@ -14,6 +16,7 @@ public enum ModelType {
private String value;
private String shortValue;
private static final Map MODEL_TYPE_BY_VALUE = new HashMap<>();
+ private static final Pattern VERSION_PATTERN = Pattern.compile("v(\\d+(\\.\\d+)*)");
static {
for (ModelType mt : values()) {
@@ -33,6 +36,11 @@ public enum ModelType {
this.shortValue = shortValue;
}
+ public String getVersionNumber() {
+ Matcher matcher = VERSION_PATTERN.matcher(this.value);
+ return matcher.find() ? matcher.group(1) : null;
+ }
+
@Override
public String toString() {
return this.getValue();
diff --git a/src/test/java/gov/cms/madie/models/common/ModelTypeTest.java b/src/test/java/gov/cms/madie/models/common/ModelTypeTest.java
new file mode 100644
index 0000000..39cc72e
--- /dev/null
+++ b/src/test/java/gov/cms/madie/models/common/ModelTypeTest.java
@@ -0,0 +1,15 @@
+package gov.cms.madie.models.common;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ModelTypeTest {
+ @Test
+ void testGetModelVersionNumber() {
+ assertThat(ModelType.QDM_5_6.getVersionNumber(), is(equalTo("5.6")));
+ assertThat(ModelType.QI_CORE.getVersionNumber(), is(equalTo("4.1.1")));
+ assertThat(ModelType.QI_CORE_6_0_0.getVersionNumber(), is(equalTo("6.0.0")));
+ }
+}