Ejemplo n.º 1
0
		public VisitSummary CreateVisitSummary(Visit visit, IPersistenceContext context)
		{
			var patientProfileAssembler = new PatientProfileAssembler();
			var summary = new VisitSummary
				{
					VisitRef = visit.GetRef(),
					Patient = patientProfileAssembler.CreatePatientProfileSummary(visit.PatientProfile, context),
					VisitNumber = CreateVisitNumberDetail(visit.VisitNumber),
					AdmissionType = EnumUtils.GetEnumValueInfo(visit.AdmissionType),
					PatientClass = EnumUtils.GetEnumValueInfo(visit.PatientClass),
					PatientType = EnumUtils.GetEnumValueInfo(visit.PatientType),
					Status = EnumUtils.GetEnumValueInfo(visit.Status, context),
					AdmitTime = visit.AdmitTime,
					DischargeTime = visit.DischargeTime
				};

			var facilityAssembler = new FacilityAssembler();
			summary.Facility = visit.Facility == null ? null : facilityAssembler.CreateFacilitySummary(visit.Facility);

			var locationAssembler = new LocationAssembler();
			summary.CurrentLocation = visit.CurrentLocation == null ? null : locationAssembler.CreateLocationSummary(visit.CurrentLocation);
			summary.CurrentRoom = visit.CurrentRoom;
			summary.CurrentBed = visit.CurrentBed;

			return summary;
		}
Ejemplo n.º 2
0
		public VisitListItem CreateVisitListItem(Visit visit, IPersistenceContext context)
		{
			var data = new VisitListItem();

			UpdateListItem(data, visit, context);

			return data;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// The specified visit and its associated orders get moved from otherPatient to thisPatient
		/// </summary>
		/// <param name="thisPatient"></param>
		/// <param name="otherPatient"></param>
		/// <param name="visit"></param>
		/// <param name="context"></param>
		static public void MoveVisit(Patient thisPatient, Patient otherPatient, Visit visit, IPersistenceContext context)
		{
			var orderCriteria = new OrderSearchCriteria();
			orderCriteria.Visit.EqualTo(visit);
			var visitOrders = context.GetBroker<IOrderBroker>().Find(orderCriteria);
			foreach (var order in visitOrders)
			{
				order.Patient = thisPatient;
			}

			visit.Patient = thisPatient;
		}
Ejemplo n.º 4
0
		private static void UpdateListItem(VisitListItem data, Visit visit, IPersistenceContext context)
		{
			var facilityAssembler = new FacilityAssembler();

			data.VisitRef = visit.GetRef();
			data.VisitNumber = new CompositeIdentifierDetail(visit.VisitNumber.Id, EnumUtils.GetEnumValueInfo(visit.VisitNumber.AssigningAuthority));
			data.PatientClass = EnumUtils.GetEnumValueInfo(visit.PatientClass);
			data.PatientType = EnumUtils.GetEnumValueInfo(visit.PatientType);
			data.AdmissionType = EnumUtils.GetEnumValueInfo(visit.AdmissionType);
			data.VisitStatus = EnumUtils.GetEnumValueInfo(visit.Status, context);
			data.AdmitTime = visit.AdmitTime;
			data.DischargeTime = visit.DischargeTime;
			data.VisitFacility = facilityAssembler.CreateFacilitySummary(visit.Facility);
			data.PreadmitNumber = visit.PreadmitNumber;
		}
Ejemplo n.º 5
0
		public VisitDetail CreateVisitDetail(Visit visit, IPersistenceContext context)
		{
			var patientProfileAssembler = new PatientProfileAssembler();
			var detail = new VisitDetail
				{
					VisitRef = visit.GetRef(),
					Patient = patientProfileAssembler.CreatePatientProfileSummary(visit.PatientProfile, context),
					VisitNumber = CreateVisitNumberDetail(visit.VisitNumber),
					AdmissionType = EnumUtils.GetEnumValueInfo(visit.AdmissionType),
					PatientClass = EnumUtils.GetEnumValueInfo(visit.PatientClass),
					PatientType = EnumUtils.GetEnumValueInfo(visit.PatientType),
					Status = EnumUtils.GetEnumValueInfo(visit.Status, context),
					AdmitTime = visit.AdmitTime,
					DischargeTime = visit.DischargeTime,
					DischargeDisposition = visit.DischargeDisposition,
					Facility = new FacilityAssembler().CreateFacilitySummary(visit.Facility),
					CurrentLocation = visit.CurrentLocation == null ? null : new LocationAssembler().CreateLocationSummary(visit.CurrentLocation),
					CurrentRoom = visit.CurrentRoom,
					CurrentBed = visit.CurrentBed,
					Locations = new List<VisitLocationDetail>(),
					PreadmitNumber = visit.PreadmitNumber,
					VipIndicator = visit.VipIndicator,
					ExtendedProperties = ExtendedPropertyUtils.Copy(visit.ExtendedProperties)
				};

			foreach (var vl in visit.Locations)
			{
				detail.Locations.Add(CreateVisitLocationDetail(vl, context));
			}

			detail.Practitioners = new List<VisitPractitionerDetail>();
			foreach (var vp in visit.Practitioners)
			{
				detail.Practitioners.Add(CreateVisitPractitionerDetail(vp, context));
			}

			detail.AmbulatoryStatuses = new List<EnumValueInfo>();
			foreach (var ambulatoryStatus in visit.AmbulatoryStatuses)
			{
				detail.AmbulatoryStatuses.Add(EnumUtils.GetEnumValueInfo(ambulatoryStatus));
			}

			return detail;
		}
 /// <summary>
 /// Constructor that does not specify an explicit list of procedures.
 /// </summary>
 /// <param name="enteredTime"></param>
 /// <param name="enteredBy"></param>
 /// <param name="enteredComment"></param>
 /// <param name="accessionNumber"></param>
 /// <param name="patient"></param>
 /// <param name="visit"></param>
 /// <param name="diagnosticService"></param>
 /// <param name="reasonForStudy"></param>
 /// <param name="priority"></param>
 /// <param name="orderingFacility"></param>
 /// <param name="performingFacility"></param>
 /// <param name="schedulingRequestTime"></param>
 /// <param name="orderingPractitioner"></param>
 /// <param name="resultRecipients"></param>
 public OrderCreationArgs(DateTime enteredTime, Staff enteredBy, string enteredComment, string accessionNumber,
                          Patient patient, Visit visit, DiagnosticService diagnosticService, string reasonForStudy, OrderPriority priority,
                          Facility orderingFacility, Facility performingFacility, DateTime?schedulingRequestTime, ExternalPractitioner orderingPractitioner,
                          IList <ResultRecipient> resultRecipients)
 {
     EnteredTime           = enteredTime;
     EnteredBy             = enteredBy;
     EnteredComment        = enteredComment;
     AccessionNumber       = accessionNumber;
     Patient               = patient;
     Visit                 = visit;
     DiagnosticService     = diagnosticService;
     ReasonForStudy        = reasonForStudy;
     Priority              = priority;
     OrderingFacility      = orderingFacility;
     PerformingFacility    = performingFacility;
     SchedulingRequestTime = schedulingRequestTime;
     OrderingPractitioner  = orderingPractitioner;
     ResultRecipients      = resultRecipients;
 }
Ejemplo n.º 7
0
		/// <summary>
		/// Constructor that does not specify an explicit list of procedures.
		/// </summary>
		/// <param name="enteredTime"></param>
		/// <param name="enteredBy"></param>
		/// <param name="enteredComment"></param>
		/// <param name="accessionNumber"></param>
		/// <param name="patient"></param>
		/// <param name="visit"></param>
		/// <param name="diagnosticService"></param>
		/// <param name="reasonForStudy"></param>
		/// <param name="priority"></param>
		/// <param name="orderingFacility"></param>
		/// <param name="performingFacility"></param>
		/// <param name="schedulingRequestTime"></param>
		/// <param name="orderingPractitioner"></param>
		/// <param name="resultRecipients"></param>
		public OrderCreationArgs(DateTime enteredTime, Staff enteredBy, string enteredComment, string accessionNumber,
			Patient patient, Visit visit, DiagnosticService diagnosticService, string reasonForStudy, OrderPriority priority,
			Facility orderingFacility, Facility performingFacility, DateTime? schedulingRequestTime, ExternalPractitioner orderingPractitioner,
			IList<ResultRecipient> resultRecipients)
		{
			EnteredTime = enteredTime;
			EnteredBy = enteredBy;
			EnteredComment = enteredComment;
			AccessionNumber = accessionNumber;
			Patient = patient;
			Visit = visit;
			DiagnosticService = diagnosticService;
			ReasonForStudy = reasonForStudy;
			Priority = priority;
			OrderingFacility = orderingFacility;
			PerformingFacility = performingFacility;
			SchedulingRequestTime = schedulingRequestTime;
			OrderingPractitioner = orderingPractitioner;
			ResultRecipients = resultRecipients;
		}
Ejemplo n.º 8
0
Archivo: Visit.cs Proyecto: nhannd/Xian
		public virtual void CopyFrom(Visit v)
		{
			this.VisitNumber.Id = v.VisitNumber.Id;
			this.VisitNumber.AssigningAuthority = v.VisitNumber.AssigningAuthority;
			this.Status = v.Status;
			this.AdmitTime = v.AdmitTime;
			this.PatientClass = v.PatientClass;
			this.PatientType = v.PatientType;
			this.AdmissionType = v.AdmissionType;
			this.Facility = v.Facility;
			this.DischargeTime = v.DischargeTime;
			this.DischargeDisposition = v.DischargeDisposition;
			this.VipIndicator = v.VipIndicator;
			//this.AmbulatoryStatus = v.AmbulatoryStatus;
			this.PreadmitNumber = v.PreadmitNumber;

			foreach (AmbulatoryStatusEnum a in v.AmbulatoryStatuses)
			{
				this.AmbulatoryStatuses.Add(a);
			}

			foreach (VisitPractitioner vp in v.Practitioners)
			{
				VisitPractitioner practitioner = new VisitPractitioner();
				practitioner.CopyFrom(vp);
				this.Practitioners.Add(practitioner);
			}

			foreach (VisitLocation vl in v.Locations)
			{
				VisitLocation location = new VisitLocation();
				location.CopyFrom(vl);
				this.Locations.Add(location);
			}

			ExtendedPropertyUtils.Update(this.ExtendedProperties, v.ExtendedProperties);
		}
Ejemplo n.º 9
0
        public virtual void CopyFrom(Visit v)
        {
            this.VisitNumber.Id = v.VisitNumber.Id;
            this.VisitNumber.AssigningAuthority = v.VisitNumber.AssigningAuthority;
            this.Status               = v.Status;
            this.AdmitTime            = v.AdmitTime;
            this.PatientClass         = v.PatientClass;
            this.PatientType          = v.PatientType;
            this.AdmissionType        = v.AdmissionType;
            this.Facility             = v.Facility;
            this.DischargeTime        = v.DischargeTime;
            this.DischargeDisposition = v.DischargeDisposition;
            this.VipIndicator         = v.VipIndicator;
            //this.AmbulatoryStatus = v.AmbulatoryStatus;
            this.PreadmitNumber = v.PreadmitNumber;

            foreach (AmbulatoryStatusEnum a in v.AmbulatoryStatuses)
            {
                this.AmbulatoryStatuses.Add(a);
            }

            foreach (VisitPractitioner vp in v.Practitioners)
            {
                VisitPractitioner practitioner = new VisitPractitioner();
                practitioner.CopyFrom(vp);
                this.Practitioners.Add(practitioner);
            }

            foreach (VisitLocation vl in v.Locations)
            {
                VisitLocation location = new VisitLocation();
                location.CopyFrom(vl);
                this.Locations.Add(location);
            }

            ExtendedPropertyUtils.Update(this.ExtendedProperties, v.ExtendedProperties);
        }
Ejemplo n.º 10
0
		public void UpdateVisit(Visit visit, VisitDetail detail, IPersistenceContext context)
		{
			visit.Patient = context.Load<Patient>(detail.Patient.PatientRef, EntityLoadFlags.Proxy);
			visit.VisitNumber.Id = detail.VisitNumber.Id;
			visit.VisitNumber.AssigningAuthority = EnumUtils.GetEnumValue<InformationAuthorityEnum>(detail.VisitNumber.AssigningAuthority, context);

			visit.AdmissionType = EnumUtils.GetEnumValue<AdmissionTypeEnum>(detail.AdmissionType, context);
			visit.PatientClass = EnumUtils.GetEnumValue<PatientClassEnum>(detail.PatientClass, context);
			visit.PatientType = EnumUtils.GetEnumValue<PatientTypeEnum>(detail.PatientType, context);
			visit.Status = EnumUtils.GetEnumValue<VisitStatus>(detail.Status);

			visit.AdmitTime = detail.AdmitTime;
			visit.DischargeTime = detail.DischargeTime;
			visit.DischargeDisposition = detail.DischargeDisposition;
			visit.VipIndicator = detail.VipIndicator;

			visit.Facility = detail.Facility == null ? null :
				context.Load<Facility>(detail.Facility.FacilityRef, EntityLoadFlags.Proxy);
			visit.CurrentLocation = detail.CurrentLocation == null ? null :
				context.Load<Location>(detail.CurrentLocation.LocationRef, EntityLoadFlags.Proxy);
			visit.CurrentRoom = detail.CurrentRoom;
			visit.CurrentBed = detail.CurrentBed;

			visit.Locations.Clear();
			foreach (var vlDetail in detail.Locations)
			{
				visit.Locations.Add(new VisitLocation(
					context.Load<Location>(vlDetail.Location.LocationRef, EntityLoadFlags.Proxy),
					vlDetail.Room,
					vlDetail.Bed,
					EnumUtils.GetEnumValue<VisitLocationRole>(vlDetail.Role),
					vlDetail.StartTime,
					vlDetail.EndTime));
			}

			visit.Practitioners.Clear();
			foreach (var vpDetail in detail.Practitioners)
			{
				visit.Practitioners.Add(new VisitPractitioner(
					context.Load<ExternalPractitioner>(vpDetail.Practitioner.PractitionerRef, EntityLoadFlags.Proxy),
					EnumUtils.GetEnumValue<VisitPractitionerRole>(vpDetail.Role),
					vpDetail.StartTime,
					vpDetail.EndTime));
			}

			visit.AmbulatoryStatuses.Clear();
			foreach (var ambulatoryStatus in detail.AmbulatoryStatuses)
			{
				visit.AmbulatoryStatuses.Add(EnumUtils.GetEnumValue<AmbulatoryStatusEnum>(ambulatoryStatus, context));
			}

			ExtendedPropertyUtils.Update(visit.ExtendedProperties, detail.ExtendedProperties);
		}
Ejemplo n.º 11
0
		public AddVisitResponse AddVisit(AddVisitRequest request)
        {
            Visit visit = new Visit();

            VisitAssembler assembler = new VisitAssembler();
            assembler.UpdateVisit(visit, request.VisitDetail, PersistenceContext);

            PersistenceContext.Lock(visit, DirtyState.New);
            PersistenceContext.SynchState();

            return new AddVisitResponse(assembler.CreateVisitSummary(visit, PersistenceContext));
        }
Ejemplo n.º 12
0
		/// <summary>
		/// Finds the visit specified in the requisition, or if no visit is specified, auto-generates a visit.
		/// </summary>
		/// <param name="requisition"></param>
		/// <param name="patient"></param>
		/// <param name="orderingFacility"></param>
		/// <returns></returns>
		private Visit FindOrCreateVisit(OrderRequisition requisition, Patient patient, Facility orderingFacility, string accessionNumber)
		{
			if (requisition.Visit != null && requisition.Visit.VisitRef != null)
			{
				return this.PersistenceContext.Load<Visit>(requisition.Visit.VisitRef, EntityLoadFlags.Proxy);
			}

			// if Visit Workflow is disabled, then we must auto-generate a "dummy" visit in order to keep the system happy
			// the user will never see this dummy visit
			if (!new WorkflowConfigurationReader().EnableVisitWorkflow)
			{
				var patientClasses = PersistenceContext.GetBroker<IEnumBroker>().Load<PatientClassEnum>(false);

				// create a visit using the minimum possible amount of information
				var visit = new Visit
								{
									Patient = patient,
									VisitNumber = new VisitNumber(accessionNumber, orderingFacility.InformationAuthority),
									Status = VisitStatus.AA,
									AdmitTime = Platform.Time,
									Facility = orderingFacility,
									PatientClass = CollectionUtils.FirstElement(patientClasses)
								};

				this.PersistenceContext.Lock(visit, DirtyState.New);
				return visit;
			}

			throw new RequestValidationException("A visit is required.");
		}