From 8166ef497437567c8e7aaa9b2a8d6482752c017b Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 21 Sep 2017 16:42:49 +0700 Subject: Fixed meta attribute filling of MedicalRecord when one transforms it from ApiRecord; Fixed FuzzyValue fromString method: on proviedstring it transformes the string to lower case and capitalize it --- .../xyz/driver/pdsuicommon/domain/FuzzyValue.scala | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/main/scala/xyz/driver/pdsuicommon') diff --git a/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala b/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala index 4e98f40..b0ee436 100644 --- a/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala +++ b/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala @@ -10,21 +10,34 @@ object FuzzyValue { case object No extends FuzzyValue case object Maybe extends FuzzyValue - val All: Set[FuzzyValue] = Set(Yes, No, Maybe) + private val yes = "Yes" + private val no = "No" + private val maybe = "Maybe" - def fromBoolean(x: Boolean): FuzzyValue = if (x) Yes else No + val All: Set[FuzzyValue] = { + Set(Yes, No, Maybe) + } + + def fromBoolean(x: Boolean): FuzzyValue = { + if (x) Yes else No + } + + implicit def toPhiString(x: FuzzyValue): PhiString = { + Unsafe(Utils.getClassSimpleName(x.getClass)) + } - implicit def toPhiString(x: FuzzyValue): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) val fromString: PartialFunction[String, FuzzyValue] = { - case "Yes" => Yes - case "No" => No - case "Maybe" => Maybe + case fuzzy => fuzzy.toLowerCase.capitalize match { + case `yes` => Yes + case `no` => No + case `maybe` => Maybe + } } def valueToString(x: FuzzyValue): String = x match { - case Yes => "Yes" - case No => "No" - case Maybe => "Maybe" + case Yes => `yes` + case No => `no` + case Maybe => `maybe` } } -- cgit v1.2.3