Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Location"/> class.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="locationProfile">The location profile.</param>
        protected internal Location(Agency agency, LocationProfile locationProfile)
            : this()
        {
            Check.IsNotNull(agency, () => Agency);
            Check.IsNotNull(locationProfile, () => LocationProfile);

            _agency = agency;
            _locationProfile = locationProfile;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the staff.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="staffProfile">The staff profile.</param>
        /// <returns>
        /// A Staff
        /// </returns>
        public Staff CreateStaff( Agency agency, StaffProfile staffProfile)
        {
            var staff = new Staff(agency, staffProfile);

            AddStaffChecklistItemsAndStaffEvents(staff);

            _staffRepository.MakePersistent ( staff );

            return staff;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VisitTemplate"/> class.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="name">The name.</param>
        /// <param name="cptCode">The CPT code.</param>
        protected internal VisitTemplate( Agency agency, string name, string cptCode )
        {
            Check.IsNotNull ( agency, "Agency is required." );
            Check.IsNotNullOrWhitespace ( name, "Name is required." );
            Check.IsNotNullOrWhitespace ( cptCode, "CptCode is required." );

            _name = name;
            _cptCode = cptCode;
            _agency = agency;
            _activityTypes = new List<VisitTemplateActivityType> ();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BillingOffice"/> class.
 /// </summary>
 /// <param name="agency">The agency.</param>
 /// <param name="administratorStaff">The administrator staff.</param>
 /// <param name="electronicTransmitterIdentificationNumber">The electronic transmitter identification number.</param>
 /// <param name="profile">The profile.</param>
 protected internal BillingOffice(
     Agency agency, Staff administratorStaff, string electronicTransmitterIdentificationNumber, BillingOfficeProfile profile )
     : this()
 {
     Check.IsNotNull ( agency, () => Agency );
     Check.IsNotNull ( administratorStaff, () => AdministratorStaff );
     Check.IsNotNull ( electronicTransmitterIdentificationNumber, () => ElectronicTransmitterIdentificationNumber );
     Check.IsNotNull ( profile, () => Profile );
     Agency = agency;
     AdministratorStaff = administratorStaff;
     ElectronicTransmitterIdentificationNumber = electronicTransmitterIdentificationNumber;
     Profile = profile;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates the billing office.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="administratorStaff">The administrator staff.</param>
        /// <param name="electronicTransmitterIdentificationNumber">The electronic transmitter identification number.</param>
        /// <param name="profile">The profile.</param>
        /// <returns>The Billing Office.</returns>
        public BillingOffice CreateBillingOffice(
            Agency agency, Staff administratorStaff, string electronicTransmitterIdentificationNumber, BillingOfficeProfile profile )
        {
            Check.IsNotNull ( agency, "Agency is required." );
            Check.IsNotNull ( administratorStaff, "Administrator Staff is required." );
            Check.IsNotNull ( electronicTransmitterIdentificationNumber, "Electronic Transmitter Identification Number is required." );

            var billingOffice = new BillingOffice ( agency, administratorStaff, electronicTransmitterIdentificationNumber, profile );

            _billingOfficeRepository.MakePersistent ( billingOffice );

            return billingOffice;
        }
Ejemplo n.º 6
0
        internal Program( Agency agency, string name, DateTime startDate, ProgramCharacteristics programCharacteristics )
            : this()
        {
            Check.IsNotNull ( agency, "Agency is required." );
            Check.IsNotNullOrWhitespace ( name, "Display name is required." );
            Check.IsNotNull ( startDate, "StartDate is required." );
            Check.IsNotNull(programCharacteristics, "ProgramCharacteristics is required.");

            Agency = agency;
            _name = name;
            _startDate = startDate;
            _endDate = null;
            _programCharacteristics = programCharacteristics;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Patient"/> class.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="patientName">Name of the patient.</param>
        /// <param name="profile">The profile.</param>
        protected internal Patient(
            Agency agency,
            PersonName patientName,
            PatientProfile profile )
            : this()
        {
            Check.IsNotNull ( agency, "Agency is required." );
            Check.IsNotNull ( patientName, "Patient name is required" );
            Check.IsNotNull ( profile, "Patient profile is required" );

            Agency = agency;
            _name = patientName;

            _profile = profile;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the location.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="locationProfile">The location profile.</param>
        /// <returns>
        /// A Location.
        /// </returns>
        public Location CreateLocation(Agency agency, LocationProfile locationProfile)
        {
            Check.IsNotNull(agency, "agency is required.");
            Check.IsNotNull(locationProfile, "locationProfile is required.");

            var newLocation = new Location ( agency, locationProfile );
            Location createdLocation = null;

            DomainRuleEngine.CreateRuleEngine ( newLocation, "CreateLocationRuleSet" )
                .Execute(() =>
                {
                    _locationRepository.MakePersistent(newLocation);
                    createdLocation = newLocation;
                });

            return createdLocation;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates the patient.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="patientName">Name of the patient.</param>
        /// <param name="patientProfile">The patient profile.</param>
        /// <returns>
        /// A Patient.
        /// </returns>
        public Patient CreatePatient(Agency agency, PersonName patientName, PatientProfile patientProfile )
        {
            var newPatient = new Patient(agency, patientName, patientProfile);
            Patient createdPatient = null;

            DomainRuleEngine.CreateRuleEngine ( newPatient, "CreatePatientRuleSet" )
                .WithContext ( newPatient.Profile )
                .Execute(() =>
                    {
                        createdPatient = newPatient;

                        newPatient.UpdateUniqueIdentifier(_patientUniqueIdentifierCalculator.GenerateUniqueIdentifier(newPatient));

                        _patientRepository.MakePersistent ( newPatient );

                        DomainEvent.Raise ( new PatientCreatedEvent { Patient = newPatient } );
                });

            return createdPatient;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Determines if the values are equal.
 /// </summary>
 /// <param name="otherLocationProfile">The other location profile.</param>
 /// <param name="otherLocationProfileAgency">The other location profile agency.</param>
 /// <returns>
 /// A boolean denoting equality of the values.
 /// </returns>
 public virtual bool ValuesEqual(LocationProfile otherLocationProfile, Agency otherLocationProfileAgency)
 {
     return LocationProfile.LocationName.Name.Equals(otherLocationProfile.LocationName.Name)
            && Agency.Key == otherLocationProfileAgency.Key;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Agency"/> class.
        /// </summary>
        /// <param name="agencyProfile">
        /// The agency profile.
        /// </param>
        /// <param name="parentAgency">
        /// The parent agency.
        /// </param>
        protected internal Agency( AgencyProfile agencyProfile, Agency parentAgency )
            : this()
        {
            Check.IsNotNull ( agencyProfile, () => AgencyProfile );

            _agencyProfile = agencyProfile;
            _parentAgency = parentAgency;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Determines if the values are equal.
 /// </summary>
 /// <param name="otherLocationProfile">The other location profile.</param>
 /// <param name="otherLocationProfileAgency">The other location profile agency.</param>
 /// <returns>
 /// A boolean denoting equality of the values.
 /// </returns>
 public virtual bool ValuesEqual(LocationProfile otherLocationProfile, Agency otherLocationProfileAgency)
 {
     return(LocationProfile.LocationName.Name.Equals(otherLocationProfile.LocationName.Name) &&
            Agency.Key == otherLocationProfileAgency.Key);
 }
Ejemplo n.º 13
0
 private Location BuildLocation(Agency agency, string name)
 {
     var location = new Location(agency, new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(name)));
     Session.SaveOrUpdate(location);
     return location;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BillingOfficeCache"/> class.
 /// </summary>
 /// <param name="agency">The agency.</param>
 protected internal BillingOfficeCache( Agency agency )
 {
     Check.IsNotNull ( agency, () => Agency );
     _agency = agency;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Destroys the agency.
 /// </summary>
 /// <param name="agency">
 /// The agency.
 /// </param>
 public void DestroyAgency(Agency agency)
 {
     Check.IsNotNull(agency, "Agency is required.");
     _agencyRepository.MakeTransient(agency);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Revises the agency.
 /// </summary>
 /// <param name="agency">The agency.</param>
 public virtual void ReviseAgency( Agency agency )
 {
     Check.IsNotNull ( agency, () => Agency );
     Agency = agency;
 }
Ejemplo n.º 17
0
        private AccountType BuildAccountType( Agency agency )
        {
            Logger.Debug ( "BuildAccountType - Building Account for Agency {0}", agency.AgencyProfile.AgencyName.DisplayName );

            return new AccountType
                {
                    AccountName = _newCropAccountName,
                    ID = _newCropAccountId,
                    SiteID = _agency.Key.ToString (),
                    AccountAddress = BuildAccountAddress ( agency ),
                    AccountPrimaryFaxNumber = BuildAccountAddressPhone ( agency, AddressPhoneType.Fax ),
                    AccountPrimaryPhoneNumber = BuildAccountAddressPhone ( agency, AddressPhoneType.Fax ),
                    //TODO: Get the right Phone Number from Agency
                };
        }
Ejemplo n.º 18
0
        private void LoadEntitiesFromDomain( long patientKey, long staffKey, long agencyKey, long locationKey )
        {
            Logger.Debug ( "LoadEntitiesFromDomain - Loading Entities" );

            var patientCriteria =
                DetachedCriteria.For<Patient> ( "p" ).Add ( Restrictions.Eq ( Projections.Property ( "p.Key" ), patientKey ) );

            var staffCriteria = DetachedCriteria
                .For<Staff> ( "s" )
                .Add ( Restrictions.Eq ( Projections.Property ( "s.Key" ), staffKey ) );

            var agencyCriteria =
                DetachedCriteria.For<Agency> ( "a" ).Add ( Restrictions.Eq ( Projections.Property ( "a.Key" ), agencyKey ) );

            var locationCriteria =
                DetachedCriteria.For<Location> ( "l" ).Add ( Restrictions.Eq ( Projections.Property ( "l.Key" ), locationKey ) );

            var multiCriteria =
                _session.CreateMultiCriteria ()
                    .Add ( patientCriteria )
                    .Add ( staffCriteria )
                    .Add ( agencyCriteria )
                    .Add ( locationCriteria );

            var criteriaList = multiCriteria.List ();

            try
            {
                _patient = ( ( IList )criteriaList[0] )[0] as Patient;
            }
            catch ( ArgumentOutOfRangeException )
            {
                //// No patient with an Id of [_patientKey] was found.
                _patient = null;
            }
            _staff = ( ( IList )criteriaList[1] )[0] as Staff;
            _agency = ( ( IList )criteriaList[2] )[0] as Agency;
            _location = ( ( IList )criteriaList[3] )[0] as Location;
        }
Ejemplo n.º 19
0
        private AddressType BuildAccountAddress( Agency agency )
        {
            Logger.Debug ( "BuildAccountAddress - Building Account Address" );
            var candidate = agency.AddressesAndPhones.FirstOrDefault ();

            if ( candidate != null )
            {
                return new AddressType
                    {
                        Address1 = candidate.AgencyAddress.Address.FirstStreetAddress,
                        Address2 = candidate.AgencyAddress.Address.SecondStreetAddress,
                        City = candidate.AgencyAddress.Address.CityName,
                        Country = ( candidate.AgencyAddress.Address.Country != null )
                                      ? candidate.AgencyAddress.Address.Country.WellKnownName
                                      : "US",
                        State =
                            candidate.AgencyAddress.Address.StateProvince != null
                                ? candidate.AgencyAddress.Address.StateProvince.ShortName
                                : "MD",
                        Zip = candidate.AgencyAddress.Address.PostalCode.Code.Substring ( 0, 5 )
                    };
            }

            throw new ApplicationException (
                string.Format ( "Agency  {0} Does not contain an Address", agency.AgencyProfile.AgencyName.DisplayName ) );
        }
Ejemplo n.º 20
0
        private string BuildAccountAddressPhone( Agency agency, string identifierType )
        {
            Logger.Debug (
                "BuildAccountAddressPhone - Building Account Address Phone for agency {0}, Phone Type:{1}",
                agency.AgencyProfile.AgencyName.DisplayName,
                identifierType );

            var candidate = agency.AddressesAndPhones.FirstOrDefault ();

            if ( candidate != null )
            {
                var phoneNumber = candidate.PhoneNumbers
                    .FirstOrDefault ( phone => phone.AgencyPhoneType.WellKnownName == identifierType );

                if ( phoneNumber == null )
                {
                    throw new ApplicationException (
                        string.Format (
                            "Agency {0} must have a valid Phone Number of type {1}",
                            identifierType,
                            agency.AgencyProfile.AgencyName.DisplayName ) );
                }

                return phoneNumber.Phone.PhoneNumber;
            }

            throw new ApplicationException (
                string.Format (
                    "Agency {0} must have a valid Address",
                    agency.AgencyProfile.AgencyName.DisplayName ) );
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Revises the parent agency.
 /// </summary>
 /// <param name="parentAgency">
 /// The parent agency.
 /// </param>
 public virtual void ReviseParentAgency(Agency parentAgency)
 {
     ParentAgency = parentAgency;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Staff"/> class.
        /// </summary>
        /// <param name="agency">
        /// The agency.
        /// </param>
        /// <param name="staffProfile">
        /// The staff profile.
        /// </param>
        protected internal Staff( Agency agency, StaffProfile staffProfile )
            : this()
        {
            Check.IsNotNull ( agency, () => Agency );
            Check.IsNotNull ( staffProfile, () => StaffProfile );

            _agency = agency;
            _staffProfile = staffProfile;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Creates the child agency.
        /// </summary>
        /// <param name="agencyProfile">
        /// The agency profile.
        /// </param>
        /// <param name="parentAgency">
        /// The parent agency.
        /// </param>
        /// <returns>
        /// An Agency.
        /// </returns>
        public Agency CreateChildAgency(AgencyProfile agencyProfile, Agency parentAgency)
        {
            Check.IsNotNull(agencyProfile, "agencyProfile is required.");
            Check.IsNotNull(parentAgency, "parentAgency is required.");

            Agency agency = new AgencyBuilder().WithAgencyProfile(agencyProfile).WithPatentAgency(parentAgency);

            _agencyRepository.MakePersistent(agency);

            return agency;
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Revises the parent agency.
 /// </summary>
 /// <param name="parentAgency">
 /// The parent agency.
 /// </param>
 public virtual void ReviseParentAgency( Agency parentAgency )
 {
     ParentAgency = parentAgency;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Destroys the agency.
 /// </summary>
 /// <param name="agency">
 /// The agency.
 /// </param>
 public void DestroyAgency(Agency agency)
 {
     Check.IsNotNull(agency, "Agency is required.");
     _agencyRepository.MakeTransient(agency);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Creates the program.
 /// </summary>
 /// <param name="agency">The agency.</param>
 /// <param name="name">The name.</param>
 /// <param name="startDate">The start date.</param>
 /// <param name="programCharacteristics">The program characteristics.</param>
 /// <returns>
 /// A Program.
 /// </returns>
 public Program CreateProgram( Agency agency, string name, DateTime startDate, ProgramCharacteristics programCharacteristics )
 {
     var program = new Program ( agency, name, startDate, programCharacteristics );
     _programRepository.MakePersistent ( program );
     return program;
 }
Ejemplo n.º 27
0
        private Staff BuildStaff(Agency agency, string firstName, string lastName)
        {
            var staff = new Staff(
                agency,
                new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst(firstName).WithLast(lastName)));

            Session.SaveOrUpdate(staff);
            return staff;
        }