/// <summary>
        /// Synchronizes the service.
        /// </summary>
        /// <param name="encounter">The encounter.</param>
        /// <param name="procedure">The procedure.</param>
        /// <param name="diagnosis">The diagnosis.</param>
        /// <returns>A service.</returns>
        public Service SynchronizeService(Encounter encounter, Procedure procedure, CodedConcept diagnosis)
        {
            Check.IsNotNull(encounter, "Encounter is required.");
            Check.IsNotNull(procedure, "Procedure is required.");
            Check.IsNotNull(diagnosis, "Diagnosis is required.");

            var medicalProcedure = _medicalProcedureTranslator.Translate ( procedure );

            var service = _serviceRepository.GetByTrackingNumber ( procedure.Key );

            var primaryIndicator = ( procedure.ProcedureType != ProcedureType.Activity );

            if (service == null)
            {
                service = _serviceFactory.CreateService ( encounter, diagnosis, medicalProcedure, primaryIndicator, procedure.Key );
            }
            else
            {
                if (encounter.Key != service.Encounter.Key)
                {
                    service.ReviseEncounter(encounter);
                }

                if (diagnosis != service.Diagnosis)
                {
                    service.ReviseDiagnosis(diagnosis);
                }

                if (medicalProcedure != service.MedicalProcedure)
                {
                    service.ReviseMedicalProcedure(medicalProcedure);
                }

                if (procedure.Key != service.TrackingNumber)
                {
                    service.ReviseTrackingNumber(procedure.Key);
                }

                if (primaryIndicator != service.PrimaryIndicator)
                {
                    service.RevisePrimaryIndicator(primaryIndicator);
                }

                if (procedure.BillingUnitCount != service.BillingUnitCount)
                {
                    service.ReviseBillingUnitCount(procedure.BillingUnitCount);
                }
            }

            //TODO: move them to ctor
            var currency = _lookupValueRepository.GetLookupByWellKnownName<Currency>(WellKnownNames.CommonModule.Currency.USDollars);
            service.ReviseChargeAmount(new Money(currency, 1));

            var c = new UnitCount ( 1 );
            service.ReviseBillingUnitCount ( c );
            return service;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Translates the specified procedure.
        /// </summary>
        /// <param name="procedure">The procedure.</param>
        /// <returns>
        /// A MedicalProcedure instance.
        /// </returns>
        public MedicalProcedure Translate(Procedure procedure)
        {
            if (procedure == null)
            {
                return null;
            }

            var medicalProcedure = new MedicalProcedure (
                procedure.ProcedureCode,
                procedure.FirstModifierCode,
                procedure.SecondModifierCode,
                procedure.ThirdModifierCode,
                procedure.FourthModifierCode );

            return medicalProcedure;
        }