コード例 #1
0
        public long CountByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria)
        {
            var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria);

            query.Selects.Add(new HqlSelect("count(*)"));
            return(ExecuteHqlUnique <long>(query));
        }
コード例 #2
0
        /// <summary>
        /// All pertinent data other than the Profiles gets copied from otherPatient to thisPatient
        /// </summary>
        /// <param name="thisPatient"></param>
        /// <param name="otherPatient"></param>
        /// <param name="context"></param>
        static private void ReconnectRelatedPatientInformation(Patient thisPatient, Patient otherPatient, IPersistenceContext context)
        {
            foreach (PatientNote note in otherPatient.Notes)
            {
                thisPatient.AddNote(note);
            }

            OrderSearchCriteria orderCriteria = new OrderSearchCriteria();

            orderCriteria.Patient.EqualTo(otherPatient);
            IList <Order> otherOrders = context.GetBroker <IOrderBroker>().Find(orderCriteria);

            foreach (Order order in otherOrders)
            {
                order.Patient = thisPatient;
            }

            VisitSearchCriteria visitCriteria = new VisitSearchCriteria();

            visitCriteria.Patient.EqualTo(otherPatient);
            IList <Visit> otherVisits = context.GetBroker <IVisitBroker>().Find(visitCriteria);

            foreach (Visit visit in otherVisits)
            {
                visit.Patient = thisPatient;
            }

            // TODO: delete the otherPatient
        }
コード例 #3
0
        public IList <Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria, SearchResultPage page)
        {
            var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria);

            query.Page = page;
            return(ExecuteHql <Visit>(query));
        }
コード例 #4
0
        /// <summary>
        /// Applies this filter to the specified criteria object.
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="wqc"></param>
        public void Apply(VisitSearchCriteria criteria, IWorklistQueryContext wqc)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            criteria.CurrentLocation.In(this.Values);
        }
コード例 #5
0
ファイル: VisitBroker.cs プロジェクト: m-berkani/ClearCanvas
		private static HqlProjectionQuery GetBaseVisitPractitionerQuery(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria)
		{
			var hqlFrom = new HqlFrom(typeof(Visit).Name, "v");
			hqlFrom.Joins.Add(new HqlJoin("v.Practitioners", "vp"));

			var query = new HqlProjectionQuery(hqlFrom);
			query.Conditions.AddRange(HqlCondition.FromSearchCriteria("vp", practitionerSearchCriteria));
			query.Conditions.AddRange(HqlCondition.FromSearchCriteria("v", visitSearchCriteria));
			return query;
		}
コード例 #6
0
        private static IList <Visit> GetVisitBatch(ExternalPractitioner practitioner, Action <VisitSearchCriteria> priorityFilter, int batchSize, IPersistenceContext context)
        {
            var visitsWhere = new VisitSearchCriteria();

            priorityFilter(visitsWhere);

            var practitionersWhere = new VisitPractitionerSearchCriteria();

            practitionersWhere.Practitioner.EqualTo(practitioner);
            return(context.GetBroker <IVisitBroker>().FindByVisitPractitioner(new VisitSearchCriteria(), practitionersWhere, new SearchResultPage(0, batchSize)));
        }
コード例 #7
0
        private static HqlProjectionQuery GetBaseVisitPractitionerQuery(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria)
        {
            var hqlFrom = new HqlFrom(typeof(Visit).Name, "v");

            hqlFrom.Joins.Add(new HqlJoin("v.Practitioners", "vp"));

            var query = new HqlProjectionQuery(hqlFrom);

            query.Conditions.AddRange(HqlCondition.FromSearchCriteria("vp", practitionerSearchCriteria));
            query.Conditions.AddRange(HqlCondition.FromSearchCriteria("v", visitSearchCriteria));
            return(query);
        }
コード例 #8
0
ファイル: Operation.cs プロジェクト: nhannd/Xian
			/// <summary>
			/// Reconciles the specified patient to this patient
			/// </summary>
			/// <param name="thisPatient"></param>
			/// <param name="otherPatient"></param>
			/// <param name="workflow"></param>
			private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow)
			{
				if (PatientIdentifierConflictsFound(thisPatient, otherPatient))
					throw new PatientReconciliationException("assigning authority conflict - cannot reconcile");

				// copy the collection to iterate
				var otherProfiles = new List<PatientProfile>(otherPatient.Profiles);
				foreach (var profile in otherProfiles)
				{
					thisPatient.AddProfile(profile);
				}

				// copy the collection to iterate
				var otherNotes = new List<PatientNote>(otherPatient.Notes);
				foreach (var note in otherNotes)
				{
					thisPatient.AddNote(note);
				}

				// copy the collection to iterate
				var otherAttachments = new List<PatientAttachment>(otherPatient.Attachments);
				foreach (var attachment in otherAttachments)
				{
					otherPatient.Attachments.Remove(attachment);
					thisPatient.Attachments.Add(attachment);
				}

				// copy the collection to iterate
				var otherAllergies = new List<Allergy>(otherPatient.Allergies);
				foreach (var allergy in otherAllergies)
				{
					otherPatient.Allergies.Remove(allergy);
					thisPatient.Allergies.Add(allergy);
				}

				var visitCriteria = new VisitSearchCriteria();
				visitCriteria.Patient.EqualTo(otherPatient);
				var otherVisits = workflow.GetBroker<IVisitBroker>().Find(visitCriteria);
				foreach (var visit in otherVisits)
				{
					visit.Patient = thisPatient;
				}

				var orderCriteria = new OrderSearchCriteria();
				orderCriteria.Patient.EqualTo(otherPatient);
				var otherOrders = workflow.GetBroker<IOrderBroker>().Find(orderCriteria);
				foreach (var order in otherOrders)
				{
					order.Patient = thisPatient;
				}
			}
コード例 #9
0
 private void ValidateVisitsExist(Order order)
 {
     try
     {
         var visitSearchCriteria = new VisitSearchCriteria();
         visitSearchCriteria.Patient.EqualTo(order.Patient);
         visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority);
         this.PersistenceContext.GetBroker <IVisitBroker>().FindOne(visitSearchCriteria);
     }
     catch (EntityNotFoundException)
     {
         throw new RequestValidationException(
                   string.Format(SR.InvalidRequest_CannotEnterOrderWithoutVisits,
                                 order.OrderingFacility.InformationAuthority.Value));
     }
 }
コード例 #10
0
 private void ValidateVisitsExist(Order order)
 {
     try
     {
         var visitSearchCriteria = new VisitSearchCriteria();
         visitSearchCriteria.Patient.EqualTo(order.Patient);
         visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority);
         this.PersistenceContext.GetBroker <IVisitBroker>().FindOne(visitSearchCriteria);
     }
     catch (EntityNotFoundException)
     {
         throw new RequestValidationException(
                   string.Format("The order cannot be entered because the patient does not have any visits at {0}.",
                                 order.OrderingFacility.InformationAuthority.Value));
     }
 }
コード例 #11
0
        protected Visit GetVisit(PatientProfile patientProfile, Order order)
        {
            //if order originated from this authority, then just use visit in order
            if (_authority == order.OrderingFacility.InformationAuthority.Code)
            {
                return(order.Visit);
            }

            //otherwise, find appropriate visit
            var criteria = new VisitSearchCriteria();

            criteria.Patient.EqualTo(order.Patient);
            criteria.AdmitTime.SortDesc(0);
            criteria.VisitNumber.AssigningAuthority.EqualTo(patientProfile.Mrn.AssigningAuthority);
            criteria.Status.In(new[] { VisitStatus.AA, VisitStatus.PD, VisitStatus.PA });
            return(PersistenceScope.CurrentContext.GetBroker <IVisitBroker>().FindOne(criteria));
        }
コード例 #12
0
		public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request)
		{
			Platform.CheckForNullReference(request, "request");
			Platform.CheckMemberIsSet(request.PatientRef, "PatientRef");

			var patient = this.PersistenceContext.GetBroker<IPatientBroker>().Load(request.PatientRef, EntityLoadFlags.Proxy);

			var criteria = new VisitSearchCriteria();
			criteria.Patient.EqualTo(patient);
			criteria.AdmitTime.SortDesc(0);

			var assembler = new VisitAssembler();
			return new ListVisitsForPatientResponse(
				CollectionUtils.Map<Visit, VisitSummary, List<VisitSummary>>(
					this.PersistenceContext.GetBroker<IVisitBroker>().Find(criteria),
					v => assembler.CreateVisitSummary(v, this.PersistenceContext)));
		}
コード例 #13
0
ファイル: VisitAdminService.cs プロジェクト: nhannd/Xian
        public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request)
        {
            Patient patient = PersistenceContext.Load<Patient>(request.PatientRef);

            VisitSearchCriteria criteria = new VisitSearchCriteria();
            criteria.Patient.EqualTo(patient);

            IList<Visit> visits = PersistenceContext.GetBroker<IVisitBroker>().Find(criteria);

            VisitAssembler assembler = new VisitAssembler();
            ListVisitsForPatientResponse response = new ListVisitsForPatientResponse();
            response.Visits = new List<VisitSummary>();
            foreach (Visit v in visits)
            {
                response.Visits.Add(assembler.CreateVisitSummary(v, PersistenceContext));
            }

            return response;
        }
コード例 #14
0
        public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.PatientRef, "PatientRef");

            var patient = this.PersistenceContext.GetBroker <IPatientBroker>().Load(request.PatientRef, EntityLoadFlags.Proxy);

            var criteria = new VisitSearchCriteria();

            criteria.Patient.EqualTo(patient);
            criteria.AdmitTime.SortDesc(0);

            var assembler = new VisitAssembler();

            return(new ListVisitsForPatientResponse(
                       CollectionUtils.Map <Visit, VisitSummary, List <VisitSummary> >(
                           this.PersistenceContext.GetBroker <IVisitBroker>().Find(criteria),
                           v => assembler.CreateVisitSummary(v, this.PersistenceContext))));
        }
コード例 #15
0
        public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request)
        {
            Patient patient = PersistenceContext.Load <Patient>(request.PatientRef);

            VisitSearchCriteria criteria = new VisitSearchCriteria();

            criteria.Patient.EqualTo(patient);

            IList <Visit> visits = PersistenceContext.GetBroker <IVisitBroker>().Find(criteria);

            VisitAssembler assembler = new VisitAssembler();
            ListVisitsForPatientResponse response = new ListVisitsForPatientResponse();

            response.Visits = new List <VisitSummary>();
            foreach (Visit v in visits)
            {
                response.Visits.Add(assembler.CreateVisitSummary(v, PersistenceContext));
            }

            return(response);
        }
コード例 #16
0
        public Visit GetVisit(string visitNumber, string assigningAuthority, bool createIfNotExist,
                              out bool doneCreatedVisit)
        {
            doneCreatedVisit = false;
            Platform.CheckForEmptyString(visitNumber, "visitNumber");
            Platform.CheckForEmptyString(assigningAuthority, "assigningAuthority");
            var infoAuth =
                _persistenceContext.GetBroker <IEnumBroker>().TryFind <InformationAuthorityEnum>(assigningAuthority);
            Visit visit    = null;
            var   criteria = new VisitSearchCriteria();

            criteria.VisitNumber.Id.EqualTo(visitNumber);
            criteria.VisitNumber.AssigningAuthority.EqualTo(infoAuth);
            try
            {
                visit = _persistenceContext.GetBroker <IVisitBroker>().FindOne(criteria);
                _visits.Add(new LockableEntity <Visit>(visit, DirtyState.Dirty));
                //todo check that visit.Patient matches patient in _patients
            }
            catch (EntityNotFoundException)
            {
                if (createIfNotExist)
                {
                    visit = new Visit();
                    _visits.Add(new LockableEntity <Visit>(visit, DirtyState.New));
                    visit.VisitNumber.Id = visitNumber;
                    visit.VisitNumber.AssigningAuthority = infoAuth;
                    // facility will be handled by location handler, and yet we can't leave facility null.
                    //so, we simply pick any old facility for now
                    visit.Facility =
                        _persistenceContext.GetBroker <IFacilityBroker>().FindOne(new FacilitySearchCriteria());
                    doneCreatedVisit = true;
                }
            }
            return(visit);
        }
コード例 #17
0
        private ListVisitsResponse ListVisits(ListVisitsRequest request)
        {
            // hide visits if "visit workflow" is disabled
            var workflowConfig = new WorkflowConfigurationReader();

            if (!workflowConfig.EnableVisitWorkflow)
            {
                return(null);
            }

            var browsePatientDataAssembler = new BrowsePatientDataAssembler();

            var patient = this.PersistenceContext.Load <Patient>(request.PatientRef, EntityLoadFlags.Proxy);

            var where = new VisitSearchCriteria();
            where.Patient.EqualTo(patient);

            var visits = this.PersistenceContext.GetBroker <IVisitBroker>().Find(where);

            return(new ListVisitsResponse(
                       CollectionUtils.Map <Visit, VisitListItem>(
                           visits,
                           v => browsePatientDataAssembler.CreateVisitListItem(v, this.PersistenceContext))));
        }
コード例 #18
0
ファイル: Utility.cs プロジェクト: m-berkani/ClearCanvas
		/// <summary>
		/// All pertinent data other than the Profiles gets copied from otherPatient to thisPatient
		/// </summary>
		/// <param name="thisPatient"></param>
		/// <param name="otherPatient"></param>
		/// <param name="context"></param>
		static private void ReconnectRelatedPatientInformation(Patient thisPatient, Patient otherPatient, IPersistenceContext context)
		{
			foreach (PatientNote note in otherPatient.Notes)
			{
				thisPatient.AddNote(note);
			}

			OrderSearchCriteria orderCriteria = new OrderSearchCriteria();
			orderCriteria.Patient.EqualTo(otherPatient);
			IList<Order> otherOrders = context.GetBroker<IOrderBroker>().Find(orderCriteria);
			foreach (Order order in otherOrders)
			{
				order.Patient = thisPatient;
			}

			VisitSearchCriteria visitCriteria = new VisitSearchCriteria();
			visitCriteria.Patient.EqualTo(otherPatient);
			IList<Visit> otherVisits = context.GetBroker<IVisitBroker>().Find(visitCriteria);
			foreach (Visit visit in otherVisits)
			{
				visit.Patient = thisPatient;
			}

			// TODO: delete the otherPatient
		}
コード例 #19
0
		private void ValidateVisitsExist(Order order)
		{
			try
			{
				var visitSearchCriteria = new VisitSearchCriteria();
				visitSearchCriteria.Patient.EqualTo(order.Patient);
				visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority);
				this.PersistenceContext.GetBroker<IVisitBroker>().FindOne(visitSearchCriteria);
			}
			catch (EntityNotFoundException)
			{
				throw new RequestValidationException(
					string.Format(SR.InvalidRequest_CannotEnterOrderWithoutVisits,
					order.OrderingFacility.InformationAuthority.Value));
			}
		}
コード例 #20
0
		private void ValidateVisitsExist(Order order)
		{
			try
			{
				var visitSearchCriteria = new VisitSearchCriteria();
				visitSearchCriteria.Patient.EqualTo(order.Patient);
				visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority);
				this.PersistenceContext.GetBroker<IVisitBroker>().FindOne(visitSearchCriteria);
			}
			catch (EntityNotFoundException)
			{
				throw new RequestValidationException(
					string.Format("The order cannot be entered because the patient does not have any visits at {0}.",
					order.OrderingFacility.InformationAuthority.Value));
			}
		}
コード例 #21
0
		private ListVisitsResponse ListVisits(ListVisitsRequest request)
		{
			// hide visits if "visit workflow" is disabled
			var workflowConfig = new WorkflowConfigurationReader();
			if(!workflowConfig.EnableVisitWorkflow)
				return null;

			var browsePatientDataAssembler = new BrowsePatientDataAssembler();

			var patient = this.PersistenceContext.Load<Patient>(request.PatientRef, EntityLoadFlags.Proxy);

			var where = new VisitSearchCriteria();
			where.Patient.EqualTo(patient);

			var visits = this.PersistenceContext.GetBroker<IVisitBroker>().Find(where);
			return new ListVisitsResponse(
				CollectionUtils.Map<Visit, VisitListItem>(
					visits,
					v => browsePatientDataAssembler.CreateVisitListItem(v, this.PersistenceContext)));
		}
コード例 #22
0
ファイル: Operation.cs プロジェクト: hksonngan/Xian
            /// <summary>
            /// Reconciles the specified patient to this patient
            /// </summary>
            /// <param name="thisPatient"></param>
            /// <param name="otherPatient"></param>
            /// <param name="workflow"></param>
            private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow)
            {
                if (PatientIdentifierConflictsFound(thisPatient, otherPatient))
                {
                    throw new PatientReconciliationException("assigning authority conflict - cannot reconcile");
                }

                // copy the collection to iterate
                var otherProfiles = new List <PatientProfile>(otherPatient.Profiles);

                foreach (var profile in otherProfiles)
                {
                    thisPatient.AddProfile(profile);
                }

                // copy the collection to iterate
                var otherNotes = new List <PatientNote>(otherPatient.Notes);

                foreach (var note in otherNotes)
                {
                    thisPatient.AddNote(note);
                }

                // copy the collection to iterate
                var otherAttachments = new List <PatientAttachment>(otherPatient.Attachments);

                foreach (var attachment in otherAttachments)
                {
                    otherPatient.Attachments.Remove(attachment);
                    thisPatient.Attachments.Add(attachment);
                }

                // copy the collection to iterate
                var otherAllergies = new List <Allergy>(otherPatient.Allergies);

                foreach (var allergy in otherAllergies)
                {
                    otherPatient.Allergies.Remove(allergy);
                    thisPatient.Allergies.Add(allergy);
                }

                var visitCriteria = new VisitSearchCriteria();

                visitCriteria.Patient.EqualTo(otherPatient);
                var otherVisits = workflow.GetBroker <IVisitBroker>().Find(visitCriteria);

                foreach (var visit in otherVisits)
                {
                    visit.Patient = thisPatient;
                }

                var orderCriteria = new OrderSearchCriteria();

                orderCriteria.Patient.EqualTo(otherPatient);
                var otherOrders = workflow.GetBroker <IOrderBroker>().Find(orderCriteria);

                foreach (var order in otherOrders)
                {
                    order.Patient = thisPatient;
                }
            }
コード例 #23
0
ファイル: MigrationPriority.cs プロジェクト: hksonngan/Xian
 public static void All(VisitSearchCriteria visitsWhere)
 {
     // no filters
 }
コード例 #24
0
 public IList <Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria)
 {
     return(FindByVisitPractitioner(visitSearchCriteria, practitionerSearchCriteria, new SearchResultPage()));
 }
コード例 #25
0
ファイル: VisitBroker.cs プロジェクト: m-berkani/ClearCanvas
		public IList<Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria)
		{
			return FindByVisitPractitioner(visitSearchCriteria, practitionerSearchCriteria, new SearchResultPage());
		}
コード例 #26
0
ファイル: MigrationPriority.cs プロジェクト: nhannd/Xian
		public static void All(VisitSearchCriteria visitsWhere)
		{
			// no filters
		}
コード例 #27
0
ファイル: VisitBroker.cs プロジェクト: m-berkani/ClearCanvas
		public IList<Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria, SearchResultPage page)
		{
			var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria);
			query.Page = page;
			return ExecuteHql<Visit>(query);
		}
コード例 #28
0
ファイル: VisitBroker.cs プロジェクト: m-berkani/ClearCanvas
		public long CountByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria)
		{
			var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria);
			query.Selects.Add(new HqlSelect("count(*)"));
			return ExecuteHqlUnique<long>(query);
		}