Esempio n. 1
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="reason"></param>
		/// <param name="cancelledBy"></param>
		public OrderCancelInfo(OrderCancelReasonEnum reason, Staff cancelledBy)
		{
			CustomInitialize();

			_reason = reason;
			_cancelledBy = cancelledBy;
		}
Esempio n. 2
0
		public StaffDetail CreateStaffDetail(Staff staff, IPersistenceContext context)
		{
			PersonNameAssembler assembler = new PersonNameAssembler();
			StaffGroupAssembler groupAssembler = new StaffGroupAssembler();
			EmailAddressAssembler emailAssembler = new EmailAddressAssembler();
			TelephoneNumberAssembler telephoneAssembler = new TelephoneNumberAssembler();
			AddressAssembler addressAssembler = new AddressAssembler();

			return new StaffDetail(
				staff.GetRef(),
				staff.Id,
				EnumUtils.GetEnumValueInfo(staff.Type),
				assembler.CreatePersonNameDetail(staff.Name),
				EnumUtils.GetEnumValueInfo(staff.Sex, context),
				staff.Title,
				staff.LicenseNumber,
				staff.BillingNumber,
				CollectionUtils.Map<TelephoneNumber, TelephoneDetail>(
					staff.TelephoneNumbers,
					delegate(TelephoneNumber tn) { return telephoneAssembler.CreateTelephoneDetail(tn, context); }),
				CollectionUtils.Map<Address, AddressDetail>(
					staff.Addresses,
					delegate(Address a) { return addressAssembler.CreateAddressDetail(a, context); }),
				CollectionUtils.Map<EmailAddress, EmailAddressDetail>(
					staff.EmailAddresses,
					delegate(EmailAddress ea) { return emailAssembler.CreateEmailAddressDetail(ea, context); }),
				CollectionUtils.Map<StaffGroup, StaffGroupSummary>(
					staff.Groups,
					delegate(StaffGroup group) { return groupAssembler.CreateSummary(group); }),
				ExtendedPropertyUtils.Copy(staff.ExtendedProperties),
				staff.Deactivated,
				staff.UserName);
		}
Esempio n. 3
0
		public void UpdateCannedText(CannedText cannedText, CannedTextDetail detail, Staff owner, IPersistenceContext context)
		{
			cannedText.Name = detail.Name;
			cannedText.Category = detail.Category;
			cannedText.Staff = detail.IsPersonal ? owner : null;
			cannedText.StaffGroup = detail.IsGroup ? context.Load<StaffGroup>(detail.StaffGroup.StaffGroupRef, EntityLoadFlags.Proxy) : null;
			cannedText.Text = detail.Text;
		}
Esempio n. 4
0
        /// <summary>
        /// Marks this posting as being acknowledged.
        /// </summary>
        /// <param name="acknowledgedBy"></param>
        protected virtual internal void Acknowledge(Staff acknowledgedBy)
        {
            if(_isAcknowledged)
                throw new WorkflowException("Already acknowledged.");

            _acknowledgedBy = new NoteAcknowledgement(acknowledgedBy, Platform.Time);
            _isAcknowledged = true;
        }
Esempio n. 5
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="reason"></param>
		/// <param name="cancelledBy"></param>
		/// <param name="comment"></param>
		public OrderCancelInfo(OrderCancelReasonEnum reason, Staff cancelledBy, string comment)
		{
			CustomInitialize();

			_reason = reason;
			_cancelledBy = cancelledBy;
			_comment = comment;
		}
Esempio n. 6
0
        public PatientNote CreateNote(PatientNoteDetail detail, Staff author, IPersistenceContext context)
        {
            PatientNoteCategory category = context.Load<PatientNoteCategory>(detail.Category.NoteCategoryRef, EntityLoadFlags.Proxy);
            PatientNote note = new PatientNote(author, category, detail.Comment);
            note.ValidRange.Until = detail.ValidRangeUntil;

            return note;
        }
Esempio n. 7
0
        /// <summary>
        /// Constructor for creating a new patient note.
        /// </summary>
        /// <param name="author"></param>
        /// <param name="category"></param>
        /// <param name="comment"></param>
        public PatientNote(Staff author, PatientNoteCategory category, string comment)
        {
            _author = author;
            _category = category;
            _comment = comment;

            // valid from now indefinitely
            _creationTime = Platform.Time;
            _validRange = new DateTimeRange(_creationTime, null);
        }
Esempio n. 8
0
		public StaffSummary CreateStaffSummary(Staff staff, IPersistenceContext context)
		{
			if (staff == null)
				return null;

			return new StaffSummary(staff.GetRef(), staff.Id,
				EnumUtils.GetEnumValueInfo(staff.Type),
				new PersonNameAssembler().CreatePersonNameDetail(staff.Name),
				staff.Deactivated);
		}
Esempio n. 9
0
        /// <summary>
        /// Constructor for creating a new note with recipients.
        /// </summary>
        /// <param name="category"></param>
        /// <param name="author"></param>
        /// <param name="onBehalfOf"></param>
        /// <param name="body"></param>
        /// <param name="urgent"></param>
        public Note(string category, Staff author, StaffGroup onBehalfOf, string body, bool urgent)
        {
            _category = category;
            _author = author;
        	_onBehalfOfGroup = onBehalfOf;
            _body = body;
        	_urgent = urgent;
            _postings = new HashedSet<NotePosting>();

            _creationTime = Platform.Time;
        }
Esempio n. 10
0
		public override ProcedureStep Reassign(Staff performer)
		{
			var reassign = base.Reassign(performer).Downcast<VerificationStep>();

			// When reassigning a verification step to another staff, we should reassign the supervisor as well
			// so the report part will be reviewed by the appropriate staff radiologist
			if (reassign.ReportPart != null && reassign.ReportPart.Supervisor != null)
				reassign.ReportPart.Supervisor = performer;

			return reassign;
		}
Esempio n. 11
0
		public void UpdateOrderFromRequisition(Order order, OrderRequisition requisition, Staff currentStaff, IPersistenceContext context)
		{
			// only certain properties of an order may be updated from a requisition
			// Patient cannot not be updated
			// DiagnosticService cannot be updated
			// OrderingFacility cannot be updated

			// do not update the individual procedures, as this is done separately - see UpdateProcedureFromRequisition

			// Some properties cannot be updated if the procedure is terminated
			if (!order.IsTerminated)
			{
				order.Visit = context.Load<Visit>(requisition.Visit.VisitRef, EntityLoadFlags.Proxy);

				order.SchedulingRequestTime = requisition.SchedulingRequestTime;
				order.OrderingPractitioner = context.Load<ExternalPractitioner>(
					requisition.OrderingPractitioner.PractitionerRef, EntityLoadFlags.Proxy);
				order.ReasonForStudy = requisition.ReasonForStudy;
				order.Priority = EnumUtils.GetEnumValue<OrderPriority>(requisition.Priority);

				// wipe out and reset the result recipients
				order.ResultRecipients.Clear();

				CollectionUtils.Map<ResultRecipientDetail, ResultRecipient>(
					requisition.ResultRecipients,
					s => new ResultRecipient(
							context.Load<ExternalPractitionerContactPoint>(s.ContactPoint.ContactPointRef, EntityLoadFlags.Proxy),
							EnumUtils.GetEnumValue<ResultCommunicationMode>(s.PreferredCommunicationMode))).ForEach(r => order.ResultRecipients.Add(r));
			}

			// synchronize Order.Attachments from order requisition
			var attachmentAssembler = new OrderAttachmentAssembler();
			attachmentAssembler.Synchronize(order.Attachments, requisition.Attachments, currentStaff, context);

			// synchronize Order.Notes from order requisition
			var noteAssembler = new OrderNoteAssembler();
			noteAssembler.SynchronizeOrderNotes(order, requisition.Notes, currentStaff, context);

			if (requisition.ExtendedProperties != null)
			{
				ExtendedPropertyUtils.Update(order.ExtendedProperties, requisition.ExtendedProperties);
			}
		}
Esempio n. 12
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;
		}
Esempio n. 13
0
		public void Synchronize(Patient patient, ICollection<PatientNoteDetail> sourceList, Staff newNoteAuthor, IPersistenceContext context)
        {
			foreach (PatientNoteDetail noteDetail in sourceList)
			{
				if(noteDetail.PatientNoteRef == null)
				{
					patient.AddNote(CreateNote(noteDetail, newNoteAuthor, context));
				}
				else
				{
					PatientNote note = CollectionUtils.SelectFirst(patient.Notes,
						delegate(PatientNote n) { return n.GetRef().Equals(noteDetail.PatientNoteRef, true); });

					if(note != null)
					{
						UpdateNote(note, noteDetail);
					}
				}
			}
        }
Esempio n. 14
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="note"></param>
		/// <param name="order"></param>
		/// <param name="patient"></param>
		/// <param name="patientProfile"></param>
		/// <param name="noteAuthor"></param>
		/// <param name="recipients"></param>
		/// <param name="diagnosticServiceName"></param>
		/// <param name="isAcknowledged"></param>
		public OrderNoteboxItem(Note note, Order order, Patient patient, PatientProfile patientProfile,
			Staff noteAuthor, IList recipients,
			string diagnosticServiceName, bool isAcknowledged)
		{
			_noteRef = note.GetRef();
			_orderRef = order.GetRef();
			_patientRef = patient.GetRef();
			_patientProfileRef = patientProfile.GetRef();
			_mrn = patientProfile.Mrn;
			_patientName = patientProfile.Name;
			_dateOfBirth = patientProfile.DateOfBirth;
			_accessionNumber = order.AccessionNumber;
			_diagnosticServiceName = diagnosticServiceName;
			_category = note.Category;
			_urgent = note.Urgent;
			_postTime = note.PostTime;
			_author = noteAuthor;
			_onBehalfOfGroup = note.OnBehalfOfGroup;
			_isAcknowledged = isAcknowledged;
			_recipients = recipients;
		}
        public ProcedureStepPerformer(Staff staff)
        {
            Platform.CheckForNullReference(staff, "staff");

            _staff = staff;
        }
Esempio n. 16
0
		public void UpdateProcedureFromRequisition(Procedure procedure, ProcedureRequisition requisition, Staff currentUserStaff, IPersistenceContext context)
		{
			// check if the procedure was cancelled
			if (requisition.Cancelled)
			{
				if (procedure.Status == ProcedureStatus.SC)
				{
					// if RP is still scheduled, cancel it
					procedure.Cancel();
				}
				else if (procedure.Status == ProcedureStatus.IP)
				{
					// if RP in-progress, discontinue it
					procedure.Discontinue();
				}

				// early exit - nothing else to update
				return;
			}

			// The following properties are appropriate only for procedures in SC status.
			if (!IsProcedureModifiable(procedure))
				return;

			procedure.Schedule(requisition.ScheduledTime, requisition.ScheduledDuration);
			procedure.SchedulingCode = EnumUtils.GetEnumValue<SchedulingCodeEnum>(requisition.SchedulingCode, context);

			procedure.PerformingFacility = context.Load<Facility>(requisition.PerformingFacility.FacilityRef, EntityLoadFlags.Proxy);
			procedure.PerformingDepartment = requisition.PerformingDepartment == null ? null
				: context.Load<Department>(requisition.PerformingDepartment.DepartmentRef, EntityLoadFlags.Proxy);

			// if the requisition explicitly specifies a modality, assign that modality to all MPS
			// (we ignore the fact that the procedure plan can theoretically contain modality procedures steps spanning multiple 
			// DICOM modalities, since in the small clinic use-case, each procedure type generally only has a single MPS)
			if (requisition.Modality != null)
			{
				foreach (var mps in procedure.ModalityProcedureSteps)
				{
					mps.Modality = context.Load<Modality>(requisition.Modality.ModalityRef, EntityLoadFlags.Proxy);
				}
			}

			procedure.Laterality = EnumUtils.GetEnumValue<Laterality>(requisition.Laterality);
			procedure.Portable = requisition.PortableModality;

			if (requisition.CheckedIn && procedure.IsPreCheckIn)
			{
				procedure.CheckIn(currentUserStaff, null);
			}
			else if (!requisition.CheckedIn && procedure.IsCheckedIn)
			{
				procedure.RevertCheckIn();
			}
		}
Esempio n. 17
0
 public PerformedProcedureStep(Staff performingStaff, DateTime? startTime)
     : base(new ProcedureStepPerformer(performingStaff), startTime)
 {
 }
Esempio n. 18
0
		public void UpdateStaff(StaffDetail detail, Staff staff, bool updateElectiveGroups, bool updateNonElectiveGroups, IPersistenceContext context)
		{
			PersonNameAssembler assembler = new PersonNameAssembler();
			EmailAddressAssembler emailAssembler = new EmailAddressAssembler();
			TelephoneNumberAssembler telephoneAssembler = new TelephoneNumberAssembler();
			AddressAssembler addressAssembler = new AddressAssembler();

			staff.Id = detail.StaffId;
			staff.Type = EnumUtils.GetEnumValue<StaffTypeEnum>(detail.StaffType, context);
			assembler.UpdatePersonName(detail.Name, staff.Name);
			staff.Sex = EnumUtils.GetEnumValue<Sex>(detail.Sex);
			staff.Title = detail.Title;
			staff.LicenseNumber = detail.LicenseNumber;
			staff.BillingNumber = detail.BillingNumber;
			staff.Deactivated = detail.Deactivated;
			staff.UserName = detail.UserName;

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

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

			staff.EmailAddresses.Clear();
			if (detail.EmailAddresses != null)
			{
				foreach (EmailAddressDetail emailAddressDetail in detail.EmailAddresses)
				{
					staff.EmailAddresses.Add(emailAssembler.CreateEmailAddress(emailAddressDetail));
				}
			}

			ExtendedPropertyUtils.Update(staff.ExtendedProperties, detail.ExtendedProperties);

			if (updateElectiveGroups)
			{
				// update elective groups
				UpdateStaffGroups(detail, staff,
					delegate(StaffGroupSummary summary) { return summary.IsElective; },
					delegate(StaffGroup group) { return group.Elective; },
					context);
			}

			if (updateNonElectiveGroups)
			{
				// update non-elective groups
				UpdateStaffGroups(detail, staff,
					delegate(StaffGroupSummary summary) { return !summary.IsElective; },
					delegate(StaffGroup group) { return !group.Elective; },
					context);
			}
		}
Esempio n. 19
0
		/// <summary>
		/// Throws an exception if the current user does not have access to edit specified staff.
		/// </summary>
		/// <param name="staff"></param>
		private void CheckWriteAccess(Staff staff)
		{
			// users with Admin.Data.Staff token can access any staff
			if (Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.Staff))
				return;

			// users can update their own staff profile with the Update token
			if (staff.UserName == this.CurrentUser && Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.StaffProfile.Update))
				return;

			throw new System.Security.SecurityException(SR.ExceptionUserNotAuthorized);
		}
Esempio n. 20
0
		/// <summary>
		/// Throws an exception if the current user does not have access to edit specified staff.
		/// </summary>
		/// <param name="staff"></param>
		private void CheckReadAccess(Staff staff)
		{
			// users with Admin.Data.Staff token can access any staff
			if (Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.Staff))
				return;

			// users can access their own staff profile
			if (staff.UserName == this.CurrentUser)
				return;

			throw new System.Security.SecurityException(SR.ExceptionUserNotAuthorized);
		}
Esempio n. 21
0
		public AddStaffResponse AddStaff(AddStaffRequest request)
		{
			Platform.CheckForNullReference(request, "request");
			Platform.CheckMemberIsSet(request.StaffDetail, "StaffDetail");

			// if trying to associate with a user account, check the account is free
			if(!string.IsNullOrEmpty(request.StaffDetail.UserName))
			{
				ValidateUserNameFree(request.StaffDetail.UserName);
			}

			// create new staff
			var staff = new Staff();

			// set properties from request
			var assembler = new StaffAssembler();

			var groupsEditable = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.StaffGroup);
			assembler.UpdateStaff(request.StaffDetail,
				staff,
				groupsEditable,
				groupsEditable,
				PersistenceContext);

			PersistenceContext.Lock(staff, DirtyState.New);

			// ensure the new staff is assigned an OID before using it in the return value
			PersistenceContext.SynchState();

			return new AddStaffResponse(assembler.CreateStaffSummary(staff, PersistenceContext));
		}
Esempio n. 22
0
		public CannedText CreateCannedText(CannedTextDetail detail, Staff owner, IPersistenceContext context)
		{
			CannedText newCannedText = new CannedText();
			UpdateCannedText(newCannedText, detail, owner, context);
			return newCannedText;
		}
    	public ModalityPerformedProcedureStep(Staff performingStaff, DateTime? startTime)
			: base(performingStaff, startTime)
    	{
			_dicomSeries = new HashedSet<ClearCanvas.Healthcare.DicomSeries>();
		}
Esempio n. 24
0
		private static void UpdateStaffGroups(StaffDetail detail, Staff staff, Predicate<StaffGroupSummary> p1, Predicate<StaffGroup> p2,
			IPersistenceContext context)
		{
			// create a helper to sync staff group membership
			CollectionSynchronizeHelper<StaffGroup, StaffGroupSummary> helper =
				new CollectionSynchronizeHelper<StaffGroup, StaffGroupSummary>(
					delegate(StaffGroup group, StaffGroupSummary summary)
					{
						return group.GetRef().Equals(summary.StaffGroupRef, true);
					},
					delegate(StaffGroupSummary groupSummary, ICollection<StaffGroup> groups)
					{
						StaffGroup group = context.Load<StaffGroup>(groupSummary.StaffGroupRef, EntityLoadFlags.Proxy);
						group.AddMember(staff);
					},
					delegate
					{
						// do nothing
					},
					delegate(StaffGroup group, ICollection<StaffGroup> groups)
					{
						group.RemoveMember(staff);
					}
				);

			helper.Synchronize(
				CollectionUtils.Select(staff.Groups, p2),
				CollectionUtils.Select(detail.Groups, p1));
		}
Esempio n. 25
0
 /// <summary>
 /// Add a member to this staff group.
 /// </summary>
 /// <param name="member"></param>
 public virtual void AddMember(Staff member)
 {
     _members.Add(member);
     member.Groups.Add(this);
 }
Esempio n. 26
0
 /// <summary>
 /// Remove a member from this staff group.
 /// </summary>
 /// <param name="member"></param>
 public virtual void RemoveMember(Staff member)
 {
     _members.Remove(member);
     member.Groups.Remove(this);
 }
 public bool CanEdit(Staff staff)
 {
     return this.State == ActivityStatus.IP && this.PerformingStaff == staff;
 }
Esempio n. 28
0
 public PerformedProcedureStep(Staff performingStaff)
     : base(new ProcedureStepPerformer(performingStaff))
 {
 }
Esempio n. 29
0
		/// <summary>
		/// Saves the report, and validates that a supervisor is present if the current user does not have 'unsupervised reporting' permissions.
		/// </summary>
		/// <param name="reportPartExtendedProperties"></param>
		/// <param name="step"></param>
		/// <param name="supervisor"></param>
		/// <param name="supervisorValidationRequired"></param>
		private void SaveReportHelper(Dictionary<string, string> reportPartExtendedProperties, ReportingProcedureStep step, Staff supervisor, bool supervisorValidationRequired)
		{
			if (supervisorValidationRequired
				&& Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.Report.SubmitForReview)
				&& Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Workflow.Report.OmitSupervisor) == false
				&& supervisor == null)
			{
				throw new SupervisorValidationException();
			}

			var saveReportOp = new Operations.SaveReport();
			saveReportOp.Execute(step, reportPartExtendedProperties, supervisor);
		}
		private static void SaveReportHelper(TranscriptionStep step, Dictionary<string, string> reportPartExtendedProperties, Staff supervisor)
		{
			var op = new TranscriptionOperations.SaveTranscription();
			op.Execute(step, reportPartExtendedProperties, supervisor);
		}
 public ReportingPerformedProcedureStep(Staff performingStaff)
     :base(performingStaff)
 {
 }
Esempio n. 32
0
		/// <summary>
		/// Check in the procedure, optionally specifying a check-in time.  If not specified,
		/// the current time is assumed.
		/// </summary>
		public virtual void CheckIn(Staff checkInStaff, DateTime? checkInTime)
		{
			_procedureCheckIn.CheckIn(checkInTime);

			// start the registration step, if not started
			var regStep = GetProcedureStep(ps => ps.Is<RegistrationProcedureStep>());
			if (regStep != null && regStep.State == ActivityStatus.SC)
				regStep.Start(checkInStaff, checkInTime);
		}
 public ReportingPerformedProcedureStep(Staff performingStaff)
     : base(performingStaff)
 {
 }