Exemplo n.º 1
0
		public void UpdateFacility(FacilityDetail detail, Facility facility, IPersistenceContext context)
		{
			facility.Code = detail.Code;
			facility.Name = detail.Name;
			facility.Description = detail.Description;
			facility.InformationAuthority = EnumUtils.GetEnumValue<InformationAuthorityEnum>(detail.InformationAuthority, context);
			facility.Deactivated = detail.Deactivated;
		}
Exemplo n.º 2
0
		public FacilityDetail CreateFacilityDetail(Facility facility)
		{
			return new FacilityDetail(
				facility.GetRef(),
				facility.Code,
				facility.Name,
				facility.Description,
				EnumUtils.GetEnumValueInfo(facility.InformationAuthority),
				facility.Deactivated);
		}
Exemplo n.º 3
0
		public AddFacilityResponse AddFacility(AddFacilityRequest request)
		{
			var facility = new Facility();
			var assembler = new FacilityAssembler();
			assembler.UpdateFacility(request.FacilityDetail, facility, this.PersistenceContext);

			PersistenceContext.Lock(facility, DirtyState.New);

			CheckMultipleInformationAuthoritiesUsed();

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

			return new AddFacilityResponse(assembler.CreateFacilitySummary(facility));
		}
Exemplo n.º 4
0
        /// <summary>
        /// Import external practitioner from CSV format.
        /// </summary>
        /// <param name="rows">
        /// Each string in the list must contain 4 CSV fields, as follows:
        ///     0 - Facility ID
        ///     1 - Facility Name
        ///     2 - Information Authority ID
        ///     3 - Information Authoirty Name
        /// </param>
        /// <param name="context"></param>
        public override void Import(List<string> rows, IUpdateContext context)
        {
            _enumBroker = context.GetBroker<IEnumBroker>();
            _authorities = new List<InformationAuthorityEnum>(_enumBroker.Load<InformationAuthorityEnum>(true));

            List<Facility> facilities = new List<Facility>();

            foreach (string line in rows)
            {
                // expect 4 fields in the row
                string[] fields = ParseCsv(line, 4);

                string facilityId = fields[0];
                string facilityName = fields[1];
				string facilityDescription = fields[2];
				string informationAuthorityId = fields[3];
                string informationAuthorityName = fields[4];

                // first check if we have it in memory
                Facility facility = CollectionUtils.SelectFirst(facilities,
                    delegate(Facility f) { return f.Code == facilityId && f.Name == facilityName; });

                // if not, check the database
                if (facility == null)
                {
                    FacilitySearchCriteria where = new FacilitySearchCriteria();
                    where.Code.EqualTo(facilityId);
                    where.Name.EqualTo(facilityName);

                    IFacilityBroker broker = context.GetBroker<IFacilityBroker>();
                    facility = CollectionUtils.FirstElement(broker.Find(where));

                    // if not, create a new instance
                    if (facility == null)
                    {
						facility = new Facility(facilityId, facilityName, facilityDescription, GetAuthority(informationAuthorityId, informationAuthorityName));
                        context.Lock(facility, DirtyState.New);
                    }

                    facilities.Add(facility);
                }
            }
        }
Exemplo n.º 5
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;
		}
Exemplo n.º 6
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.");
		}
Exemplo n.º 7
0
 /// <summary>
 /// Gets the profile corresponding to the specified facility, or null if no such profile exists.
 /// </summary>
 /// <param name="facility"></param>
 /// <returns></returns>
 public virtual PatientProfile GetProfile(Facility facility)
 {
     return(CollectionUtils.SelectFirst(_profiles,
                                        profile => Equals(profile.Mrn.AssigningAuthority, facility.InformationAuthority)));
 }
Exemplo n.º 8
0
		/// <summary>
		/// Gets the profile corresponding to the specified facility, or null if no such profile exists.
		/// </summary>
		/// <param name="facility"></param>
		/// <returns></returns>
		public virtual PatientProfile GetProfile(Facility facility)
		{
			return CollectionUtils.SelectFirst(_profiles,
				profile => Equals(profile.Mrn.AssigningAuthority, facility.InformationAuthority));
		}