private void LoadPatientProfile()
        {
            Async.CancelPending(this);

            if (_profileRef == null)
            {
                return;
            }

            Async.Request(this,
                          (IBrowsePatientDataService service) =>
            {
                var request = new GetDataRequest
                {
                    GetPatientProfileDetailRequest = new GetPatientProfileDetailRequest
                    {
                        PatientProfileRef = _profileRef,
                        // include notes for the notes component
                        IncludeNotes = true,
                        // include attachments for the docs component
                        IncludeAttachments = true,
                        // include patient allergies for allergies component
                        IncludeAllergies = true
                    }
                };

                return(service.GetData(request));
            },
                          response =>
            {
                _patientProfile = response.GetPatientProfileDetailResponse.PatientProfile;

                this.Host.Title = string.Format(SR.TitleBiography, PersonNameFormat.Format(_patientProfile.Name), MrnFormat.Format(_patientProfile.Mrn));
                _bannerComponent.HealthcareContext = _patientProfile;
                _documentComponent.Attachments     = _patientProfile.Attachments;
                _noteComponent.Notes        = _patientProfile.Notes;
                _allergyComponent.Allergies = _patientProfile.Allergies;

                NotifyPropertyChanged("SelectedOrder");
                NotifyAllPropertiesChanged();
            },
                          exception =>
            {
                ExceptionHandler.Report(exception, this.Host.DesktopWindow);

                _patientProfile = null;
                _bannerComponent.HealthcareContext = null;
                _documentComponent.Attachments     = new List <AttachmentSummary>();
                _noteComponent.Notes = new List <PatientNoteDetail>();

                NotifyPropertyChanged("SelectedOrder");
                NotifyAllPropertiesChanged();
            });
        }
예제 #2
0
        private void UpdateHelper(PatientProfile profile, PatientProfileDetail detail, bool updatePatient, bool updateProfile, bool updateMrn)
        {
            if (updatePatient)
            {
                var patient = profile.Patient;

                var noteAssembler = new PatientNoteAssembler();
                noteAssembler.Synchronize(patient, detail.Notes, CurrentUserStaff, PersistenceContext);

                var attachmentAssembler = new PatientAttachmentAssembler();
                attachmentAssembler.Synchronize(patient.Attachments, detail.Attachments, this.CurrentUserStaff, PersistenceContext);

                var allergyAssembler = new PatientAllergyAssembler();
                allergyAssembler.Synchronize(patient.Allergies, detail.Allergies, PersistenceContext);
            }

            if (updateProfile)
            {
                var assembler = new PatientProfileAssembler();
                assembler.UpdatePatientProfile(profile, detail, updateMrn, PersistenceContext);
            }
        }
예제 #3
0
 public AddPatientRequest(PatientProfileDetail patientDetail)
 {
     this.PatientDetail = patientDetail;
 }
 public UpdatePatientProfileRequest(EntityRef patientProfileRef, PatientProfileDetail patientDetail)
 {
     this.PatientProfileRef = patientProfileRef;
     this.PatientDetail     = patientDetail;
 }
예제 #5
0
 public UpdatePatientProfileRequest(EntityRef patientProfileRef, PatientProfileDetail patientDetail)
 {
     this.PatientProfileRef = patientProfileRef;
     this.PatientDetail = patientDetail;
 }
예제 #6
0
 public LoadPatientProfileForEditResponse(EntityRef patientRef, EntityRef patientProfileRef, PatientProfileDetail patientDetail)
 {
     this.PatientRef        = patientRef;
     this.PatientProfileRef = patientProfileRef;
     this.PatientDetail     = patientDetail;
 }
예제 #7
0
 public AddPatientRequest(PatientProfileDetail patientDetail)
 {
     this.PatientDetail = patientDetail;
 }
예제 #8
0
        // JR: this method won't compile anymore since the reconciliation service was moved to the Extended plugins... do we really need it?
        ///// <summary>
        ///// Creates a new patient with multiple profiles.
        ///// </summary>
        ///// <returns></returns>
        //public static PatientProfileSummary CreatePatient(String[] InfoAuth)
        //{
        //    var result=new List<PatientProfileSummary>();

        //    if (InfoAuth.Length==0)
        //        result.Add(CreatePatient());
        //    else
        //    {
        //        var timespan = new TimeSpan(GetRandomInteger(0,100 * 365 * 24), 0, 0);
        //        InitReferenceDataCacheOnce();
        //        var birthDate = Platform.Time - timespan;

        //        var profile = new PatientProfileDetail
        //            {
        //                Healthcard = new HealthcardDetail(
        //                    GenerateRandomIntegerString(10),
        //                    ChooseRandom(_patientEditorFormData.HealthcardAssigningAuthorityChoices),
        //                    "", null),
        //                DateOfBirth = birthDate,
        //                Sex = ChooseRandom(_patientEditorFormData.SexChoices),
        //                PrimaryLanguage = ChooseRandom(_patientEditorFormData.PrimaryLanguageChoices),
        //                Religion = ChooseRandom(_patientEditorFormData.ReligionChoices),
        //                DeathIndicator = false,
        //                TimeOfDeath = null
        //            };

        //        profile.Name = new PersonNameDetail
        //            {
        //                FamilyName = GetRandomNameFromFile(RandomUtilsSettings.Default.FamilyNameDictionary),
        //                GivenName = profile.Sex.Code == "F"
        //                    ? GetRandomNameFromFile(RandomUtilsSettings.Default.FemaleNameDictionary) + " Anonymous"
        //                    : GetRandomNameFromFile(RandomUtilsSettings.Default.MaleNameDictionary) + " Anonymous"
        //            };

        //        AddPatientResponse addResponse = null;

        //        for(var i=0; i<InfoAuth.Length; i++)
        //        {
        //            profile.Mrn = new CompositeIdentifierDetail(
        //                GenerateRandomIntegerString(10),
        //                CollectionUtils.SelectFirst(_patientEditorFormData.MrnAssigningAuthorityChoices, MAAC => MAAC.Code == InfoAuth[i]));

        //            Platform.GetService(
        //                delegate(IPatientAdminService service)
        //                {
        //                    addResponse = service.AddPatient(new AddPatientRequest(profile));
        //                });

        //            result.Add(addResponse.PatientProfile);
        //        }

        //        if (InfoAuth.Length > 1)
        //        {
        //            //reconcile patients
        //            var checkedPatients = new List<EntityRef>();
        //            foreach (var pps in result)
        //            {
        //                checkedPatients.Add(pps.PatientRef);
        //            }

        //            // reconcile
        //            Platform.GetService<IPatientReconciliationService>(
        //                service => service.ReconcilePatients(new ReconcilePatientsRequest(checkedPatients)));
        //        }
        //    }

        //    return result[0];
        //}

        /// <summary>
        /// Creates a new patient with a single profile.
        /// </summary>
        /// <returns></returns>
        public static PatientProfileSummary CreatePatient()
        {
            var timespan = new TimeSpan(GetRandomInteger(0, 100 * 365 * 24), 0, 0);

            InitReferenceDataCacheOnce();
            var birthDate = Platform.Time - timespan;

            var profile = new PatientProfileDetail
            {
                Mrn = new CompositeIdentifierDetail(
                    GenerateRandomIntegerString(10),
                    ChooseRandom(_patientEditorFormData.MrnAssigningAuthorityChoices)),
                Healthcard = new HealthcardDetail(
                    GenerateRandomIntegerString(10),
                    ChooseRandom(_patientEditorFormData.HealthcardAssigningAuthorityChoices),
                    "", null),
                DateOfBirth     = birthDate,
                Sex             = ChooseRandom(_patientEditorFormData.SexChoices),
                PrimaryLanguage = ChooseRandom(_patientEditorFormData.PrimaryLanguageChoices),
                Religion        = ChooseRandom(_patientEditorFormData.ReligionChoices),
                DeathIndicator  = false,
                TimeOfDeath     = null
            };

            // Randomly create 0-2 allergies
            for (var i = 0; i < GetRandomInteger(0, 2); i++)
            {
                var allergy = new PatientAllergyDetail(
                    ChooseRandom(_patientEditorFormData.AllergenTypeChoices),
                    string.Format("description {0}", GenerateRandomString(3)),
                    ChooseRandom(_patientEditorFormData.AllergySeverityChoices),
                    string.Format("reaction {0}", GenerateRandomString(3)),
                    ChooseRandom(_patientEditorFormData.AllergySensitivityTypeChoices),
                    Platform.Time,
                    Platform.Time,
                    new PersonNameDetail
                {
                    FamilyName = GetRandomNameFromFile(RandomUtilsSettings.Default.FamilyNameDictionary),
                    GivenName  = GetRandomNameFromFile(RandomUtilsSettings.Default.MaleNameDictionary) + " Anonymous"
                },
                    ChooseRandom(_patientEditorFormData.PersonRelationshipTypeChoices));

                profile.Allergies.Add(allergy);
            }

            profile.Name = new PersonNameDetail
            {
                FamilyName = GetRandomNameFromFile(RandomUtilsSettings.Default.FamilyNameDictionary),
                GivenName  = profile.Sex.Code == "F"
                                        ? GetRandomNameFromFile(RandomUtilsSettings.Default.FemaleNameDictionary) + " Anonymous"
                                        : GetRandomNameFromFile(RandomUtilsSettings.Default.MaleNameDictionary) + " Anonymous"
            };

            AddPatientResponse addResponse = null;

            Platform.GetService(
                delegate(IPatientAdminService service)
            {
                addResponse = service.AddPatient(new AddPatientRequest(profile));
            });

            return(addResponse.PatientProfile);
        }
예제 #9
0
        public PatientProfileDetail CreatePatientProfileDetail(PatientProfile profile,
                                                               IPersistenceContext context,
                                                               bool includeAddresses,
                                                               bool includeContactPersons,
                                                               bool includeEmailAddresses,
                                                               bool includeTelephoneNumbers,
                                                               bool includeNotes,
                                                               bool includeAttachments,
                                                               bool includeAllergies)
        {
            var healthcardAssembler = new HealthcardAssembler();
            var nameAssembler       = new PersonNameAssembler();
            var addressAssembler    = new AddressAssembler();
            var telephoneAssembler  = new TelephoneNumberAssembler();

            var detail = new PatientProfileDetail
            {
                PatientRef        = profile.Patient.GetRef(),
                PatientProfileRef = profile.GetRef(),
                Mrn                = new MrnAssembler().CreateMrnDetail(profile.Mrn),
                Healthcard         = healthcardAssembler.CreateHealthcardDetail(profile.Healthcard),
                Name               = nameAssembler.CreatePersonNameDetail(profile.Name),
                Sex                = EnumUtils.GetEnumValueInfo(profile.Sex, context),
                DateOfBirth        = profile.DateOfBirth,
                DeathIndicator     = profile.DeathIndicator,
                TimeOfDeath        = profile.TimeOfDeath,
                PrimaryLanguage    = EnumUtils.GetEnumValueInfo(profile.PrimaryLanguage),
                Religion           = EnumUtils.GetEnumValueInfo(profile.Religion),
                CurrentHomeAddress = addressAssembler.CreateAddressDetail(profile.CurrentHomeAddress, context),
                CurrentWorkAddress = addressAssembler.CreateAddressDetail(profile.CurrentWorkAddress, context),
                CurrentHomePhone   = telephoneAssembler.CreateTelephoneDetail(profile.CurrentHomePhone, context),
                CurrentWorkPhone   = telephoneAssembler.CreateTelephoneDetail(profile.CurrentWorkPhone, context),
                BillingInformation = profile.BillingInformation
            };

            if (includeTelephoneNumbers)
            {
                detail.TelephoneNumbers = new List <TelephoneDetail>();
                foreach (var t in profile.TelephoneNumbers)
                {
                    detail.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneDetail(t, context));
                }
            }

            if (includeAddresses)
            {
                detail.Addresses = new List <AddressDetail>();
                foreach (var a in profile.Addresses)
                {
                    detail.Addresses.Add(addressAssembler.CreateAddressDetail(a, context));
                }
            }

            if (includeContactPersons)
            {
                var contactPersonAssembler = new ContactPersonAssembler();
                detail.ContactPersons = new List <ContactPersonDetail>();
                foreach (var cp in profile.ContactPersons)
                {
                    detail.ContactPersons.Add(contactPersonAssembler.CreateContactPersonDetail(cp));
                }
            }

            if (includeEmailAddresses)
            {
                var emailAssembler = new EmailAddressAssembler();
                detail.EmailAddresses = new List <EmailAddressDetail>();
                foreach (var e in profile.EmailAddresses)
                {
                    detail.EmailAddresses.Add(emailAssembler.CreateEmailAddressDetail(e, context));
                }
            }

            if (includeNotes)
            {
                var noteAssembler = new PatientNoteAssembler();
                detail.Notes = new List <PatientNoteDetail>();
                foreach (var n in profile.Patient.Notes)
                {
                    detail.Notes.Add(noteAssembler.CreateNoteDetail(n, context));
                }
            }

            if (includeAttachments)
            {
                var attachmentAssembler = new PatientAttachmentAssembler();
                detail.Attachments = new List <AttachmentSummary>();
                foreach (var a in profile.Patient.Attachments)
                {
                    detail.Attachments.Add(attachmentAssembler.CreatePatientAttachmentSummary(a, context));
                }
            }

            if (includeAllergies)
            {
                var allergyAssembler = new PatientAllergyAssembler();
                detail.Allergies = new List <PatientAllergyDetail>();
                foreach (var a in profile.Patient.Allergies)
                {
                    detail.Allergies.Add(allergyAssembler.CreateAllergyDetail(a));
                }
            }

            return(detail);
        }
예제 #10
0
        public void UpdatePatientProfile(PatientProfile profile, PatientProfileDetail detail, bool updateMrn, IPersistenceContext context)
        {
            if (updateMrn)
            {
                profile.Mrn.Id = detail.Mrn.Id;
                profile.Mrn.AssigningAuthority = EnumUtils.GetEnumValue <InformationAuthorityEnum>(detail.Mrn.AssigningAuthority, context);
            }

            profile.Healthcard = new HealthcardNumber();
            new HealthcardAssembler().UpdateHealthcard(profile.Healthcard, detail.Healthcard, context);

            var nameAssembler = new PersonNameAssembler();

            nameAssembler.UpdatePersonName(detail.Name, profile.Name);

            profile.Sex            = EnumUtils.GetEnumValue <Sex>(detail.Sex);
            profile.DateOfBirth    = detail.DateOfBirth;
            profile.DeathIndicator = detail.DeathIndicator;
            profile.TimeOfDeath    = detail.TimeOfDeath;

            profile.PrimaryLanguage    = EnumUtils.GetEnumValue <SpokenLanguageEnum>(detail.PrimaryLanguage, context);
            profile.Religion           = EnumUtils.GetEnumValue <ReligionEnum>(detail.Religion, context);
            profile.BillingInformation = detail.BillingInformation;

            var telephoneAssembler = new TelephoneNumberAssembler();

            profile.TelephoneNumbers.Clear();
            if (detail.TelephoneNumbers != null)
            {
                foreach (var phoneDetail in detail.TelephoneNumbers)
                {
                    profile.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneNumber(phoneDetail));
                }
            }

            var addressAssembler = new AddressAssembler();

            profile.Addresses.Clear();
            if (detail.Addresses != null)
            {
                foreach (var addressDetail in detail.Addresses)
                {
                    profile.Addresses.Add(addressAssembler.CreateAddress(addressDetail));
                }
            }

            var emailAssembler = new EmailAddressAssembler();

            profile.EmailAddresses.Clear();
            foreach (var e in detail.EmailAddresses)
            {
                profile.EmailAddresses.Add(emailAssembler.CreateEmailAddress(e));
            }

            var contactAssembler = new ContactPersonAssembler();

            profile.ContactPersons.Clear();
            foreach (var cp in detail.ContactPersons)
            {
                profile.ContactPersons.Add(contactAssembler.CreateContactPerson(cp, context));
            }
        }
 public LoadPatientProfileForEditResponse(EntityRef patientRef, EntityRef patientProfileRef, PatientProfileDetail patientDetail)
 {
     this.PatientRef = patientRef;
     this.PatientProfileRef = patientProfileRef;
     this.PatientDetail = patientDetail;
 }
        public override void Start()
        {
            Platform.GetService <IPatientAdminService>(
                service =>
            {
                var formData = service.LoadPatientProfileEditorFormData(new LoadPatientProfileEditorFormDataRequest());
                if (_isNew)
                {
                    _profile = new PatientProfileDetail();
                    _profile.Mrn.AssigningAuthority = formData.MrnAssigningAuthorityChoices.Count > 0
                                                        ? GetWorkingFacilityInformationAuthority(formData.MrnAssigningAuthorityChoices)
                                                        : null;
                    _profile.Healthcard.AssigningAuthority = formData.HealthcardAssigningAuthorityChoices.Count > 0
                                                        ? formData.HealthcardAssigningAuthorityChoices[0]
                                                        : null;
                    _profile.Sex         = formData.SexChoices[0];
                    _profile.DateOfBirth = Platform.Time.Date;
                }
                else
                {
                    var response = service.LoadPatientProfileForEdit(new LoadPatientProfileForEditRequest(_profileRef));

                    _profileRef = response.PatientProfileRef;
                    _profile    = response.PatientDetail;

                    this.Host.Title =
                        string.Format(SR.TitlePatientComponent, PersonNameFormat.Format(_profile.Name), MrnFormat.Format(_profile.Mrn));
                }

                if (_newAttachments.Count > 0)
                {
                    _profile.Attachments.AddRange(_newAttachments);
                    this.Modified      = true;
                    this.AcceptEnabled = true;
                }

                // if the user has permission to either a) create a new patient, or b) update the patient profile, then
                // these pages should be displayed
                if (Thread.CurrentPrincipal.IsInRole(
                        ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.PatientProfile.Update) ||
                    Thread.CurrentPrincipal.IsInRole(ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.Patient.Create))
                {
                    this.Pages.Add(
                        new NavigatorPage("NodePatient",
                                          _patientEditor =
                                              new PatientProfileDetailsEditorComponent(
                                                  _isNew,
                                                  formData.MrnAutoGenerated,
                                                  formData.SexChoices,
                                                  formData.MrnAssigningAuthorityChoices,
                                                  formData.HealthcardAssigningAuthorityChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeAddresses",
                                          _addressesSummary = new AddressesSummaryComponent(formData.AddressTypeChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodePhoneNumbers",
                                          _phoneNumbersSummary = new PhoneNumbersSummaryComponent(formData.PhoneTypeChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeEmailAddresses",
                                          _emailAddressesSummary = new EmailAddressesSummaryComponent()));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeContactPersons",
                                          _contactPersonsSummary =
                                              new ContactPersonsSummaryComponent(formData.ContactPersonTypeChoices, formData.ContactPersonRelationshipChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeCulture",
                                          _additionalPatientInfoSummary =
                                              new PatientProfileAdditionalInfoEditorComponent(formData.ReligionChoices, formData.PrimaryLanguageChoices)));

                    _addressesSummary.SetModifiedOnListChange      = true;
                    _phoneNumbersSummary.SetModifiedOnListChange   = true;
                    _emailAddressesSummary.SetModifiedOnListChange = true;
                    _contactPersonsSummary.SetModifiedOnListChange = true;

                    _patientEditor.Subject                = _profile;
                    _addressesSummary.Subject             = _profile.Addresses;
                    _phoneNumbersSummary.Subject          = _profile.TelephoneNumbers;
                    _emailAddressesSummary.Subject        = _profile.EmailAddresses;
                    _contactPersonsSummary.Subject        = _profile.ContactPersons;
                    _additionalPatientInfoSummary.Subject = _profile;
                }

                // if the user has permission to either a) create a new patient, or b) update a patient, then
                // these pages should be displayed
                if (Thread.CurrentPrincipal.IsInRole(ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.Patient.Create) ||
                    Thread.CurrentPrincipal.IsInRole(ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.Patient.Update))
                {
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeNotes",
                                          _notesSummary   = new PatientNoteSummaryComponent(_profile.Notes, formData.NoteCategoryChoices)));
                    _notesSummary.SetModifiedOnListChange = true;

                    var patientDocumentsPage = new NavigatorPage("NodePatient/NodeAttachments",
                                                                 _documentSummary =
                                                                     new AttachedDocumentPreviewComponent(false, AttachmentSite.Patient));
                    this.Pages.Add(patientDocumentsPage);
                    _documentSummary.Attachments = _profile.Attachments;

                    if (_newAttachments.Count > 0)
                    {
                        this.MoveTo(this.Pages.IndexOf(patientDocumentsPage));
                        _documentSummary.SetInitialSelection(_newAttachments[0]);
                    }
                }

                this.ValidationStrategy = new AllComponentsValidationStrategy();
            });


            base.Start();
        }