juan_gandhi: (VP)
[personal profile] juan_gandhi
(scala below)

Before



  def buildItem(eob:EOB)(props: Props): Result[EOB_item] = {
    implicit val empty: String = "" // weird
    for (sDate            <- props valueOf DateOfServicePerItem;
         date             <- DateFormat("MM/dd/yyyy").parseCurrent(sDate);
         description      <- props valueOf ProcedureDescription;
         sBilled          <- props valueOf BilledPerItem;
         billed           <- dollars(sBilled);
         sInsPaid         <- props valueOf PaidByPlanPerItem;
         insPaid          <- dollars(sInsPaid);
         sDeductible      <- props valueOf Deductible;
         deductible       <- dollars(sDeductible);
         sCoinsurance     <- props valueOf Coinsurance;
         deductible       <- dollars(sDeductible);
         sCopay           <- props valueOf CopayPerItem;
         copay            <- dollars(sDeductible);
         sAllowed         <- props valueOf Allowed;
         allowed          <- dollars(sDeductible);
         x <- Good(true)) yield new EOB_item() {//...


after


    val ex = new DataExtractor(props, DateFormat("MM/dd/yyyy").parseCurrent)
    implicit def extractor(name: String) = ex(name)

    for (date        <- DateOfServicePerItem asRecentDate;
         description <- ProcedureDescription requireText;
         billed      <- BilledPerItem $$$;
         insPaid     <- PaidByPlanPerItem $$$;
         deductible  <- Deductible $$$;
         coinsurance <- Coinsurance $$$;
         copay       <- CopayPerItem $$$;
         allowed     <- Allowed $$$;
         x <- Good(true)) yield new EOB_item() {



where



  class DataExtractor(props:Props, string2date: String=>Result[Date]) {
    def apply(name:String) = new {
      def requireText: Result[String] = props valueOf name
      def text:String = requireText getOrElse ""
      def $$$: Result[BigDecimalField] = requireText flatMap dollars
      def asRecentDate = requireText flatMap string2date
    }
  }


Date: 2014-03-02 12:37 am (UTC)
From: [identity profile] http://users.livejournal.com/_xacid_/
хочу сделать чтото подобное но пока не собрал в кучку мысли

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

May 2025

S M T W T F S
    1 2 3
456 7 8 9 10
11 121314151617
181920 21 222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 25th, 2025 10:48 am
Powered by Dreamwidth Studios