public PatientProfile LoadPatientProfile(EntityRef profileRef)
        {
            IPatientProfileBroker profileBroker = this.CurrentContext.GetBroker <IPatientProfileBroker>();
            PatientProfile        patient       = profileBroker.Load(profileRef);

            return(patient);
        }
        public PatientProfile LoadPatientProfileDetails(EntityRef profileRef)
        {
            IPatientProfileBroker broker  = this.CurrentContext.GetBroker <IPatientProfileBroker>();
            PatientProfile        patient = broker.Load(profileRef);

            // load all relevant collections
            broker.LoadAddressesForPatientProfile(patient);
            broker.LoadTelephoneNumbersForPatientProfile(patient);

            return(patient);
        }
        public IList <PatientProfileMatch> FindReconciliationMatches(PatientProfile targetProfile, IPersistenceContext context)
        {
            /* User needs to resort to manual linking of patient records from multiple HIS when automatic MPI fails.
             *
             * Allow user to to select 2 or more patient records from different hospitals and merge into an MPI.
             *
             * Display High-Probability match/search results from muliple HIS of patients with various Mrns when
             * field: healthcard # is matched/identical.
             *
             * Display Moderate-Probability match/search results from multiple HIS of patients with various Mrns when fields: surname,
             * given name, DOB, gender are matched/identical.
             *
             */
            IPatientProfileBroker broker = context.GetBroker <IPatientProfileBroker>();

            IList <PatientProfileMatch> matches = new List <PatientProfileMatch>();

            IList <PatientProfileMatch> highMatches = new List <PatientProfileMatch>();

            if (targetProfile.Healthcard != null && !string.IsNullOrEmpty(targetProfile.Healthcard.Id))
            {
                PatientProfileSearchCriteria high = new PatientProfileSearchCriteria();
                high.Healthcard.Id.EqualTo(targetProfile.Healthcard.Id);

                highMatches = PatientProfileMatch.CreateList(targetProfile, broker.Find(high), PatientProfileMatch.ScoreValue.High);
            }

            PatientProfileSearchCriteria moderateViaName = new PatientProfileSearchCriteria();

            if (targetProfile.Name.FamilyName != null && !string.IsNullOrEmpty(targetProfile.Name.FamilyName))
            {
                moderateViaName.Name.FamilyName.EqualTo(targetProfile.Name.FamilyName);
            }

            if (targetProfile.Name.GivenName != null && !string.IsNullOrEmpty(targetProfile.Name.GivenName))
            {
                moderateViaName.Name.GivenName.EqualTo(targetProfile.Name.GivenName);
            }

            if (targetProfile.DateOfBirth != null)
            {
                moderateViaName.DateOfBirth.EqualTo(targetProfile.DateOfBirth);
            }

            moderateViaName.Sex.EqualTo(targetProfile.Sex);

            IList <PatientProfileMatch> moderateMatchesViaName = PatientProfileMatch.CreateList(targetProfile, broker.Find(moderateViaName), PatientProfileMatch.ScoreValue.Moderate);

            matches = PatientProfileMatch.Combine(highMatches, moderateMatchesViaName);

            RemoveConflicts(targetProfile.Patient, matches);

            return(matches);
        }
        public IList <PatientProfile> ListPatientProfiles(PatientProfileSearchCriteria criteria)
        {
            IPatientProfileBroker profileBroker = this.CurrentContext.GetBroker <IPatientProfileBroker>();

            return(profileBroker.Find(criteria));
        }
 public PatientProfileTextQueryHelper(IPersistenceContext context)
 {
     _context   = context;
     _broker    = _context.GetBroker <IPatientProfileBroker>();
     _assembler = new PatientProfileAssembler();
 }