diff --git a/onfhir-core/src/main/scala/io/onfhir/db/MongoDBInitializer.scala b/onfhir-core/src/main/scala/io/onfhir/db/MongoDBInitializer.scala index 994d51c..4085ea9 100644 --- a/onfhir-core/src/main/scala/io/onfhir/db/MongoDBInitializer.scala +++ b/onfhir-core/src/main/scala/io/onfhir/db/MongoDBInitializer.scala @@ -16,6 +16,7 @@ import org.slf4j.{Logger, LoggerFactory} import scala.concurrent.duration._ import scala.concurrent.{Await, ExecutionContextExecutor, Future} import scala.language.postfixOps +import scala.util.Try /** * Created by tuncay on 11/15/2016. @@ -128,9 +129,9 @@ class MongoDBInitializer(resourceManager: ResourceManager) extends BaseDBInitial //If it is conformance if(resources.length ==1 && FHIRUtil.extractValueOption[String](resources.head, FHIR_COMMON_FIELDS.ID).contains(SERVER_CONFORMANCE_STATEMENT_ID)) { Map(SERVER_CONFORMANCE_STATEMENT_ID -> ( - FHIRUtil + Try(FHIRUtil .extractValueOptionByPath[String](resources.head, s"${FHIR_COMMON_FIELDS.META}.${FHIR_COMMON_FIELDS.VERSION_ID}") - .map(_.toLong).getOrElse(1L), + .map(_.toLong)).toOption.flatten.getOrElse(1L), resources.head )) } else { @@ -141,9 +142,9 @@ class MongoDBInitializer(resourceManager: ResourceManager) extends BaseDBInitial val rid = url.split('/').last rid -> ( - FHIRUtil + Try(FHIRUtil .extractValueOptionByPath[String](resource, s"${FHIR_COMMON_FIELDS.META}.${FHIR_COMMON_FIELDS.VERSION_ID}") - .map(_.toLong).getOrElse(1L), + .map(_.toLong)).toOption.flatten.getOrElse(1L), FHIRUtil.setId(resource, rid) ) } diff --git a/onfhir-validation/src/main/scala/io/onfhir/validation/FhirContentValidator.scala b/onfhir-validation/src/main/scala/io/onfhir/validation/FhirContentValidator.scala index fd8c0c6..92ed405 100644 --- a/onfhir-validation/src/main/scala/io/onfhir/validation/FhirContentValidator.scala +++ b/onfhir-validation/src/main/scala/io/onfhir/validation/FhirContentValidator.scala @@ -1467,7 +1467,7 @@ object FhirContentValidator { private val TIME_REGEX: Regex = """\A([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?$""".r private val OID_REGEX: Regex = """\Aurn:oid:[0-2](\.[1-9]\d*)+$""".r private val UUID_REGEX: Regex = """\Aurn:uuid:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$""".r - private val VERSION_REGEX: Regex = """\A[0-9]+(\.[0-9]+)*$""".r +// private val VERSION_REGEX: Regex = """\A[0-9]+(\.[0-9]+)*$""".r /** * Construction of the class @@ -1505,7 +1505,7 @@ object FhirContentValidator { case FHIR_DATA_TYPES.CANONICAL => value.extract[String].split('|') match { case Array(url) => Try(new URI(url)).isSuccess case Array(url, version) => - Try(new URI(url)).isSuccess && VERSION_REGEX.findFirstMatchIn(version).isDefined + Try(new URI(url)).isSuccess case _ => false } case FHIR_DATA_TYPES.BOOLEAN => value.isInstanceOf[JBool]