public ConsultationSchedulerSagaId(string value)
        {
            //TODO:Use compiled regex instead of string.Replace(..)
            var id = value.Replace($"{MetaKey}-", "");

            this.PatientId = new PatientId(id);
        }
Beispiel #2
0
        private InstanceStorageInfo(DicomCStoreRequest request, string storageRootFullPath, string calledAeTitle, uint associationId, IFileSystem fileSystem)
        {
            Guard.Against.Null(request, nameof(request));
            Guard.Against.NullOrWhiteSpace(storageRootFullPath, nameof(storageRootFullPath));
            Guard.Against.NullOrWhiteSpace(calledAeTitle, nameof(calledAeTitle));
            Guard.Against.Null(fileSystem, nameof(fileSystem));

            _fileSystem = fileSystem;

            AeStoragePath = storageRootFullPath;
            CalledAeTitle = calledAeTitle;

            var temp        = string.Empty;
            var missingTags = new List <DicomTag>();

            if (!request.Dataset.TryGetSingleValue(DicomTag.PatientID, out temp))
            {
                missingTags.Add(DicomTag.PatientID);
            }
            else
            {
                PatientId = temp;
            }

            if (!request.Dataset.TryGetSingleValue(DicomTag.StudyInstanceUID, out temp))
            {
                missingTags.Add(DicomTag.StudyInstanceUID);
            }
            else
            {
                StudyInstanceUid = temp;
            }
            if (!request.Dataset.TryGetSingleValue(DicomTag.SeriesInstanceUID, out temp))
            {
                missingTags.Add(DicomTag.SeriesInstanceUID);
            }
            else
            {
                SeriesInstanceUid = temp;
            }

            if (missingTags.Count != 0)
            {
                throw new MissingRequiredTagException(missingTags.ToArray());
            }

            SopClassUid    = request.SOPClassUID.UID;
            SopInstanceUid = request.SOPInstanceUID.UID;

            AeStoragePath      = fileSystem.Path.Combine(AeStoragePath, associationId.ToString());
            AeStoragePath      = fileSystem.Path.GetDicomStoragePath(AeStoragePath);
            PatientStoragePath = fileSystem.Path.Combine(AeStoragePath, PatientId.RemoveInvalidPathChars());

            StudyStoragePath  = fileSystem.Path.Combine(PatientStoragePath, StudyInstanceUid.RemoveInvalidPathChars());
            SeriesStoragePath = fileSystem.Path.Combine(StudyStoragePath, SeriesInstanceUid.RemoveInvalidPathChars());

            fileSystem.Directory.CreateDirectoryIfNotExists(SeriesStoragePath);

            InstanceStorageFullPath = fileSystem.Path.Combine(SeriesStoragePath, SopInstanceUid.RemoveInvalidPathChars()) + ".dcm";
        }
        public static async Task <int> CallPatientInfoService()
        {
            var service = new PatientDataIntegrationServiceClient();

            var header = new MessageHeader()
            {
                MessageID           = "101",
                TransactionID       = "101",
                SenderID            = "101",
                SenderApplication   = "Debug",
                ReceiverID          = "101",
                ReceiverApplication = "Effica",
                CharacterSet        = "UTF-16"
            };

            var common = new LisCommon()
            {
                ContractKey   = ContractKey,
                UserId        = UserId,
                CallingSystem = CallingSystem,
                CallingUserId = UserId
            };

            var patient = new PatientId()
            {
                Identifier = "010101-0101"
            };

            PatientDataServiceReference.Patient[] patients = new Patient[1];

            service.GetPatientData(ref header, common, patient, out patients);

            return(0);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         return((PatientId.GetHashCode() * 397) ^ SequenceNumber);
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string Createdate = "";
            string ID         = "";

            if (btnSave.Text == "Save")
            {
                if (validate() == false)
                {
                    return;
                }
                IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
                DataTable        theDT          = PatientTransferMgr.GetSatelliteID(PatientId.ToString());
                string           FromLocationID = theDT.Rows[0]["LocationID"].ToString();
                int retVal = PatientTransferMgr.SaveUpdate(ID, PatientId.ToString(), FromLocationID, ddSatellite.SelectedValue, txtTransferDate.Text, Convert.ToInt32(Session["AppUserId"]), Createdate, 0);
                ViewState["Save"] = "";
                SaveUpdateMsg();
            }


            else if (btnSave.Text == "Update")
            {
                if (validateEdit() == false)
                {
                    return;
                }
                IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
                int Transfer = (int)PatientTransferMgr.SaveUpdate(TransferId, PatientId.ToString(), ViewState["FromID"].ToString(), ddSatelliteEdit.SelectedValue, TxtTransDateEdit.Text, Convert.ToInt32(Session["AppUserId"]), Createdate, 1);
                SaveUpdateMsg();
            }
            GrdTransfer.Columns.Clear();
            BindGrid();
        }
Beispiel #6
0
        public static async Task <int> CallDiagnosisService()
        {
            var service = new DiagnosisServiceClient();

            var header = new MessageHeader()
            {
                MessageID           = "101",
                TransactionID       = "101",
                SenderID            = "101",
                SenderApplication   = "Debug",
                ReceiverID          = "101",
                ReceiverApplication = "Effica",
                CharacterSet        = "UTF-16"
            };

            var common = new LisCommon()
            {
                ContractKey   = ContractKey,
                UserId        = UserId,
                CallingSystem = CallingSystem,
                CallingUserId = UserId
            };

            // Initialize Request
            var req = new DiagnosisReq()
            {
                Organisation = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "317"
                },
                Area = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "kotih"
                },
                EffectiveTime = new EffectiveTime()
                {
                    StartDateTime = DateTime.Now.AddDays(-365.0), EndDateTime = DateTime.Now
                },
                PatientId = new PatientId()
                {
                    Identifier = "121221-A020"
                }
            };

            // Structure for return data
            var patientId = new PatientId();
            var diagnoses = new Diagnose[100];

            try
            {
                service.GetPatientDiagnoses(ref header, common, req, out patientId, out diagnoses);
            }
            catch (Exception e)
            {
                Debug.Write(e.Message);
            }

            return(0);
        }
Beispiel #7
0
 public Appointment(AppointmentId appointmentId, DoctorId doctorId, PatientId patientId, DateTime appointmentAt, AppointmentDuration appointmentDuration)
 {
     AppointmentId       = appointmentId;
     DoctorId            = doctorId;
     PatientId           = patientId;
     AppointmentAt       = appointmentAt;
     AppointmentDuration = appointmentDuration;
 }
Beispiel #8
0
 public Visit(DoctorId doctorId, DateTime date, PatientId patientId = null)
 {
     _state = new VisitState {
         Doctor = doctorId ?? throw new ArgumentNullException(nameof(doctorId)),
                        Date    = date,
                        Patient = patientId
     };
 }
Beispiel #9
0
 //TODO:Validate arguments
 public CreateConsultationCommand(ConsultationId aggregateId, PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime registrationDate, DateTime consultationDate) : base(aggregateId)
 {
     PatientId        = patientId;
     DoctorId         = doctorId;
     TreatmentRoomId  = treatmentRoomId;
     RegistrationDate = registrationDate;
     ConsultationDate = consultationDate;
 }
Beispiel #10
0
 public ConsultationSchedulingIsCompletedEvent(PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime patientRegistrationDate, DateTime consultationDate)
 {
     PatientId               = patientId;
     DoctorId                = doctorId;
     TreatmentRoomId         = treatmentRoomId;
     PatientRegistrationDate = patientRegistrationDate;
     ConsultationDate        = consultationDate;
 }
Beispiel #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (PatientId != null ? PatientId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PlansAndPlanSumsInScope != null ? PlansAndPlanSumsInScope.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ActivePlan != null ? ActivePlan.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #12
0
 public ConsultationIsCreatedEvent(ConsultationId consultationId, PatientId patientId, DoctorId doctorId, TreatmentRoomId treatmentRoomId, DateTime registrationDate, DateTime consultationDate)
 {
     ConsultationId   = consultationId;
     PatientId        = patientId;
     DoctorId         = doctorId;
     TreatmentRoomId  = treatmentRoomId;
     RegistrationDate = registrationDate;
     ConsultationDate = consultationDate;
     Timestamp        = DateTime.UtcNow;
 }
Beispiel #13
0
        public override string ToString()
        {
            var str = "";

            str = str + "\n PatientId: " + PatientId.ToString();
            str = str + "\n StartDate: " + StartDate.ToString();
            str = str + "\n EndDate: " + EndDate.ToString();

            return(str);
        }
Beispiel #14
0
        /// <summary>
        /// Open the observation form and let the user enter data.
        /// Sets the observe form to the patient of the activity not the global patient.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get parameter values
            bool markReviewed = MarkReviewed.Expression != null?MarkReviewed.Get(context) : false;

            Guid obdGuid = ObdGuid.Get(context);

            var parms = new UddWidgetParams
            {
                MarkReviewed       = markReviewed,
                UddDataParams      = { PatId1 = PatientId.Get(context) },
                TabViewObdGuid     = obdGuid,
                Mode               = UddWidgetMode.Insert,
                IsFlowsheetDisplay = true
            };

            var view = ObsDef.GetEntityByObdGuid(obdGuid, PM);

            var securityEnum = SecurityUtility.ByteArrayToEnum(view.Security_Mask);

            bool returnResult = ReturnResult.Get(context);

            if (!returnResult)
            {
                // open an instance of the UDD with a distinct instanceid from the standard UDD indstance id
                var host = new UddWidgetModalHost(parms, securityEnum, null, Strings.FlowsheetFormActivity_UddInstanceId);

                // Defect 6398 - Clicking OK in error window cause Mosaiq crashed when trigger IQ script (create assessment by QCL task)
                // if user doesn't have modify rights in Assessment/Labs/Vital signs
                // Defect 7055: Replace IsHandleCreated with !IsDisposed because the window's handle is never created at this point
                if (!host.IsDisposed)
                {
                    var modalDialog = ModalDialog.Get(context);
                    if (modalDialog)
                    {
                        host.ShowDialog();
                    }
                    else
                    {
                        host.Show();
                        host.ForceToFront();
                    }
                }
                return;
            }

            DialogResult res = UddWidgetModalHost.ShowModal(parms, securityEnum, Strings.FlowsheetFormActivity_UddInstanceId);

            if (res == System.Windows.Forms.DialogResult.OK)
            {
                ObrId.Set(context, parms.UddDataParams.ObrId);
            }
            //Record output parameters
            DialogResult.Set(context, res);
        }
        private void BindTransferDetail()
        {
            txtLocationName.Text     = Session["AppLocation"].ToString();
            txtLocationName.ReadOnly = true;

            /*Binding Satellite ID*/
            BindFunctions BindManager = new BindFunctions();
            IQCareUtils   theUtils    = new IQCareUtils();
            DataTable     theDT       = new DataTable();

            DataSet          theDS = new DataSet();
            IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");

            if (btnSave.Text == "Save")
            {
                tredit.Visible       = false;
                theDS                = PatientTransferMgr.GetSatelliteLocation(PatientId.ToString(), TransferId, 0, Session["SystemId"].ToString());
                txtLocationName.Text = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
                DataView theDV = new DataView(theDS.Tables[1]);
                if (theDV.Table != null)
                {
                    theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                    BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
                    theDV.Dispose();
                    theDT.Clear();
                }
            }


            if (btnSave.Text == "Update")
            {
                tredit.Visible = true;
                theDS          = PatientTransferMgr.GetSatelliteLocation(PatientId.ToString(), TransferId, 1, Session["SystemId"].ToString());

                txtLocationNameEdit.Text    = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
                txtLocationNameEdit.Enabled = false;
                txtFromSatellite.Text       = theDS.Tables[2].Rows[0]["TransferfromSatellite"].ToString();
                txtFromSatellite.Enabled    = false;
                ViewState["FromID"]         = theDS.Tables[2].Rows[0]["TransferredfromID"].ToString();
                //ddSatelliteEdit.Enabled = false;
                TxtTransDateEdit.Text     = string.Format("{0:dd-MMM-yyyy}", Convert.ToDateTime(theDS.Tables[2].Rows[0]["TransferredDate"]));
                ViewState["TransferDate"] = TxtTransDateEdit.Text;
                DataView theDV = new DataView(theDS.Tables[1]);
                //theDV.RowFilter = "DeleteFlag=0";
                if (theDV.Table != null)
                {
                    theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                    BindManager.BindCombo(ddSatelliteEdit, theDT, "Name", "ID");
                    theDV.Dispose();
                    theDT.Clear();
                }
                ddSatelliteEdit.SelectedValue = theDS.Tables[2].Rows[0][3].ToString();
            }
        }
Beispiel #16
0
        public string CopyTo(string targetRoot)
        {
            Guard.Against.NullOrWhiteSpace(targetRoot, nameof(targetRoot));

            var targetPath = _fileSystem.Path.Combine(targetRoot, PatientId.RemoveInvalidPathChars(), StudyInstanceUid.RemoveInvalidPathChars(), SeriesInstanceUid.RemoveInvalidPathChars());

            _fileSystem.Directory.CreateDirectoryIfNotExists(targetPath);
            targetPath = _fileSystem.Path.Combine(targetPath, SopInstanceUid.RemoveInvalidPathChars()) + ".dcm";
            _fileSystem.File.Copy(InstanceStorageFullPath, targetPath, true);
            return(targetPath);
        }
 //fill patient  with MUST-only credentials
 public void PatientExecute()
 {
     PatientCreateBusiness();
     PatientName.SendKeys("1");
     SaveButton.ClickOn();
     //    softAssert.VerifyElementIsPresent(PatientValidation);
     PatientName.EnterClearText(PatientUseName);
     PatientLastame.EnterClearText(Constant.patientLastname);
     PatientId.SendKeys(RandomNumber.smallNumber());
     PatientIDType.ClickOn();
     PatientIDType.SendKeys(Keys.ArrowDown);
 }
        public async Task <Patient> GetByIdAsync(PatientId patientId, CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var patientTable = await context.PatientTables.SingleOrDefaultAsync(x => x.PatientId == patientId.Value, cancellation);

            if (patientTable == null)
            {
                return(null);
            }

            return(new Patient(new PatientId(patientTable.PatientId), patientTable.Name));
        }
Beispiel #19
0
        public void ReserveVisit(PatientId patientId)
        {
            if (_state.Patient == null)
            {
                _state.Patient = patientId;
            }

            if (_state.Patient == patientId)
            {
                return;
            }

            throw new Exception("Alredy taken");
        }
Beispiel #20
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 40, Configuration.FieldSeparator),
                       Id,
                       SetIdPid.HasValue ? SetIdPid.Value.ToString(culture) : null,
                       PatientId?.ToDelimitedString(),
                       PatientIdentifierList != null ? string.Join(Configuration.FieldRepeatSeparator, PatientIdentifierList.Select(x => x.ToDelimitedString())) : null,
                       AlternatePatientIdPid != null ? string.Join(Configuration.FieldRepeatSeparator, AlternatePatientIdPid.Select(x => x.ToDelimitedString())) : null,
                       PatientName != null ? string.Join(Configuration.FieldRepeatSeparator, PatientName.Select(x => x.ToDelimitedString())) : null,
                       MothersMaidenName != null ? string.Join(Configuration.FieldRepeatSeparator, MothersMaidenName.Select(x => x.ToDelimitedString())) : null,
                       DateTimeOfBirth.HasValue ? DateTimeOfBirth.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       AdministrativeSex,
                       PatientAlias != null ? string.Join(Configuration.FieldRepeatSeparator, PatientAlias.Select(x => x.ToDelimitedString())) : null,
                       Race != null ? string.Join(Configuration.FieldRepeatSeparator, Race.Select(x => x.ToDelimitedString())) : null,
                       PatientAddress != null ? string.Join(Configuration.FieldRepeatSeparator, PatientAddress.Select(x => x.ToDelimitedString())) : null,
                       CountyCode,
                       PhoneNumberHome != null ? string.Join(Configuration.FieldRepeatSeparator, PhoneNumberHome.Select(x => x.ToDelimitedString())) : null,
                       PhoneNumberBusiness != null ? string.Join(Configuration.FieldRepeatSeparator, PhoneNumberBusiness.Select(x => x.ToDelimitedString())) : null,
                       PrimaryLanguage?.ToDelimitedString(),
                       MaritalStatus?.ToDelimitedString(),
                       Religion?.ToDelimitedString(),
                       PatientAccountNumber?.ToDelimitedString(),
                       SsnNumberPatient,
                       DriversLicenseNumberPatient?.ToDelimitedString(),
                       MothersIdentifier != null ? string.Join(Configuration.FieldRepeatSeparator, MothersIdentifier.Select(x => x.ToDelimitedString())) : null,
                       EthnicGroup != null ? string.Join(Configuration.FieldRepeatSeparator, EthnicGroup.Select(x => x.ToDelimitedString())) : null,
                       BirthPlace,
                       MultipleBirthIndicator,
                       BirthOrder.HasValue ? BirthOrder.Value.ToString(Consts.NumericFormat, culture) : null,
                       Citizenship != null ? string.Join(Configuration.FieldRepeatSeparator, Citizenship.Select(x => x.ToDelimitedString())) : null,
                       VeteransMilitaryStatus?.ToDelimitedString(),
                       Nationality?.ToDelimitedString(),
                       PatientDeathDateAndTime.HasValue ? PatientDeathDateAndTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       PatientDeathIndicator,
                       IdentityUnknownIndicator,
                       IdentityReliabilityCode != null ? string.Join(Configuration.FieldRepeatSeparator, IdentityReliabilityCode) : null,
                       LastUpdateDateTime.HasValue ? LastUpdateDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       LastUpdateFacility?.ToDelimitedString(),
                       TaxonomicClassificationCode?.ToDelimitedString(),
                       BreedCode?.ToDelimitedString(),
                       Strain,
                       ProductionClassCode?.ToDelimitedString(),
                       TribalCitizenship != null ? string.Join(Configuration.FieldRepeatSeparator, TribalCitizenship.Select(x => x.ToDelimitedString())) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Beispiel #21
0
        /// <summary>
        /// Returns true if WaitingListEntry instances are equal
        /// </summary>
        /// <param name="other">Instance of WaitingListEntry to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(WaitingListEntry other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     PatientId == other.PatientId ||
                     PatientId != null &&
                     PatientId.Equals(other.PatientId)
                 ) &&
                 (
                     Since == other.Since ||
                     Since != null &&
                     Since.Equals(other.Since)
                 ) &&
                 (
                     Estimated == other.Estimated ||
                     Estimated != null &&
                     Estimated.Equals(other.Estimated)
                 ) &&
                 (
                     EstimatedDurationMinutes == other.EstimatedDurationMinutes ||
                     EstimatedDurationMinutes != null &&
                     EstimatedDurationMinutes.Equals(other.EstimatedDurationMinutes)
                 ) &&
                 (
                     Condition == other.Condition ||
                     Condition != null &&
                     Condition.Equals(other.Condition)
                 ));
        }
        static void Main(string[] args)
        {
            var visitId = VisitId.New();
            var agg     = new Visit(DoctorId.New(), DateTime.Now);

            var rep    = new VisitRepository();
            var exists = rep.Get(new VisitId(Guid.Parse("b1e81cb1-0683-473a-94b6-666d9c1babe8")));

            rep.Save(agg, visitId);

            var vis = rep.Get(visitId);

            vis.ReserveVisit(PatientId.New());
            rep.Save(vis, visitId);
            Console.WriteLine("Hello World!");
        }
        public async Task HandleAsync(ScheduleAppointmentCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var unitOfWork = await _unitOfWorkFactory.CreateAsync())
            {
                // Convert from external representations to domain representations
                var appointmentId       = new AppointmentId(command.AppointmentId);
                var doctorId            = new DoctorId(command.DoctorId);
                var patientId           = new PatientId(command.PatientId);
                var appointmentDuration = new AppointmentDuration(command.AppointmentDurationInMinutes);

                // Invoke domain logic
                await _scheduleAppointmentService.ScheduleAsync(appointmentId, doctorId, patientId, command.AppointmentAt,
                                                                appointmentDuration, cancellationToken);

                await unitOfWork.CommitAsync();
            }
        }
Beispiel #24
0
    public void BookSlot(SlotId slotId, PatientId patientId)
    {
        IsCancelledOrArchived();
        IsNotScheduled();

        var slotStatus = _slots.GetStatus(slotId);

        switch (slotStatus)
        {
        case SlotStatus.Available:
            Raise(new SlotBooked(Id, slotId.Value, patientId.Value));
            break;

        case SlotStatus.Booked:
            throw new SlotAlreadyBookedException();

        case SlotStatus.NotScheduled:
            throw new SlotNotScheduledException();
        }
    }
Beispiel #25
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (PatientId != null)
         {
             hashCode = hashCode * 59 + PatientId.GetHashCode();
         }
         if (Since != null)
         {
             hashCode = hashCode * 59 + Since.GetHashCode();
         }
         if (Estimated != null)
         {
             hashCode = hashCode * 59 + Estimated.GetHashCode();
         }
         if (EstimatedDurationMinutes != null)
         {
             hashCode = hashCode * 59 + EstimatedDurationMinutes.GetHashCode();
         }
         if (Condition != null)
         {
             hashCode = hashCode * 59 + Condition.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #26
0
        private IList <RestoreQueue> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <RestoreQueue>());
            }

            if (SearchKeys != null)
            {
                IList <RestoreQueue> archiveQueueList = new List <RestoreQueue>();
                foreach (ServerEntityKey key in SearchKeys)
                {
                    archiveQueueList.Add(RestoreQueue.Load(key));
                }

                resultCount = archiveQueueList.Count;

                return(archiveQueueList);
            }

            WebQueryRestoreQueueParameters parameters = new WebQueryRestoreQueueParameters();

            parameters.StartIndex  = startRowIndex;
            parameters.MaxRowCount = maximumRows;
            if (Partition != null)
            {
                parameters.ServerPartitionKey = Partition.Key;
            }

            if (!string.IsNullOrEmpty(PatientId))
            {
                string key = PatientId.Replace("*", "%");
                key = key.Replace("?", "_");
                parameters.PatientId = key;
            }
            if (!string.IsNullOrEmpty(PatientName))
            {
                string key = PatientName.Replace("*", "%");
                key = key.Replace("?", "_");
                parameters.PatientsName = key;
            }

            if (String.IsNullOrEmpty(ScheduledDate))
            {
                parameters.ScheduledTime = null;
            }
            else
            {
                parameters.ScheduledTime = DateTime.ParseExact(ScheduledDate, DateFormats, null);
            }

            if (StatusEnum != null)
            {
                parameters.RestoreQueueStatusEnum = StatusEnum;
            }


            List <string>   groupOIDs = new List <string>();
            CustomPrincipal user      = Thread.CurrentPrincipal as CustomPrincipal;

            if (user != null)
            {
                if (!user.IsInRole(MatrixPACS.Enterprise.Common.AuthorityTokens.DataAccess.AllStudies))
                {
                    foreach (var oid in user.Credentials.DataAccessAuthorityGroups)
                    {
                        groupOIDs.Add(oid.ToString());
                    }

                    parameters.CheckDataAccess         = true;
                    parameters.UserAuthorityGroupGUIDs = StringUtilities.Combine(groupOIDs, ",");
                }
            }

            IList <RestoreQueue> list = _searchController.FindRestoreQueue(parameters);

            resultCount = parameters.ResultCount;

            return(list);
        }
        public async Task ScheduleAsync(AppointmentId appointmentId, DoctorId doctorId, PatientId patientId, DateTime requestedAppointmentAt, AppointmentDuration requestedAppointmentDuration,
                                        CancellationToken cancellationToken = default)
        {
            if (requestedAppointmentAt < _systemClockService.UtcNow.DateTime)
            {
                throw new DomainValidationException("The appointment could not be scheduled because it occurs in the past.");
            }

            var doctor = await _doctorRepository.GetByIdAsync(doctorId, cancellationToken);

            if (doctor == null)
            {
                throw new EntityNotFoundException("The requested doctor was not found.");
            }

            var patient = await _patientRepository.GetByIdAsync(patientId, cancellationToken);

            if (patient == null)
            {
                throw new EntityNotFoundException("The requested patient was not found.");
            }

            // Does the requested appointment occur during the doctor's availability?

            var doctorAvailabilities = await _doctorAvailabilityRepository.GetAllForDoctorAsync(doctorId, cancellationToken);

            var doctorIsAvailable = doctorAvailabilities.Any(a =>
                                                             a.DayOfWeek == requestedAppointmentAt.DayOfWeek &&                            // Occurs on an available day of the week
                                                             a.StartsAt <= requestedAppointmentAt.TimeOfDay && // After that day of the week's start time
                                                             a.EndsAt >= requestedAppointmentAt.TimeOfDay + requestedAppointmentDuration); // And ends before that day of the week's end time

            if (!doctorIsAvailable)
            {
                throw new DomainValidationException("The appointment could not be scheduled because it is outside of the doctor's availability.");
            }

            // Determine if there are any scheduling conflicts.
            // Algorithm description: Two time periods overlap if each one starts before the other one ends.

            var doctorAppointments = await _appointmentRepository.GetAllUpcomingForDoctorAsync(doctorId, cancellationToken);

            var doctorHasConflictingAppointment = doctorAppointments.Any(existingAppointment =>
                                                                         requestedAppointmentAt < existingAppointment.AppointmentAt.Add(existingAppointment.AppointmentDuration) &&
                                                                         existingAppointment.AppointmentAt < requestedAppointmentAt.Add(requestedAppointmentDuration));

            if (doctorHasConflictingAppointment)
            {
                throw new DomainValidationException("The appointment could not be scheduled because the doctor has a conflicting appointment.");
            }

            var patientAppointments = await _appointmentRepository.GetAllUpcomingForPatientAsync(patientId, cancellationToken);

            var patientHasConflictingAppointment = patientAppointments.Any(existingAppointment =>
                                                                           requestedAppointmentAt < existingAppointment.AppointmentAt.Add(existingAppointment.AppointmentDuration) &&
                                                                           existingAppointment.AppointmentAt < requestedAppointmentAt.Add(requestedAppointmentDuration));

            if (patientHasConflictingAppointment)
            {
                throw new DomainValidationException("The appointment could not be scheduled because the patient has a conflicting appointment.");
            }

            var appointment = new Appointment(appointmentId, doctorId, patientId, requestedAppointmentAt, requestedAppointmentDuration);

            await _appointmentRepository.CreateAsync(appointment, cancellationToken);
        }
Beispiel #28
0
        private IList <WorkQueue> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <WorkQueue>());
            }

            if (SearchKeys != null)
            {
                IList <WorkQueue> workQueueList = new List <WorkQueue>();
                foreach (ServerEntityKey key in SearchKeys)
                {
                    workQueueList.Add(WorkQueue.Load(key));
                }

                resultCount = workQueueList.Count;

                return(workQueueList);
            }

            WebWorkQueueQueryParameters parameters = new WebWorkQueueQueryParameters
            {
                StartIndex  = startRowIndex,
                MaxRowCount = maximumRows
            };

            if (Partition != null)
            {
                parameters.ServerPartitionKey = Partition.Key;
            }

            if (!string.IsNullOrEmpty(PatientsName))
            {
                string key = PatientsName.Replace("*", "%");
                key = key.Replace("?", "_");
                parameters.PatientsName = key;
            }
            if (!string.IsNullOrEmpty(PatientId))
            {
                string key = PatientId.Replace("*", "%");
                key = key.Replace("?", "_");
                parameters.PatientID = key;
            }
            if (!string.IsNullOrEmpty(ProcessingServer))
            {
                string key = ProcessingServer.Replace("*", "%");
                key = key.Replace("?", "_");
                parameters.ProcessorID = key;
            }

            if (String.IsNullOrEmpty(ScheduledDate))
            {
                parameters.ScheduledTime = null;
            }
            else
            {
                parameters.ScheduledTime = DateTime.ParseExact(ScheduledDate, DateFormats, null);
            }

            if (TypeEnums != null && TypeEnums.Length > 0)
            {
                string types = "(";
                if (TypeEnums.Length == 1)
                {
                    types += TypeEnums[0].Enum;
                }
                else
                {
                    string separator = "";
                    foreach (WorkQueueTypeEnum typeEnum in TypeEnums)
                    {
                        types    += separator + typeEnum.Enum;
                        separator = ",";
                    }
                }

                parameters.Type = types + ")";
            }

            if (StatusEnums != null && StatusEnums.Length > 0)
            {
                string statuses = "(";
                if (StatusEnums.Length == 1)
                {
                    statuses += StatusEnums[0].Enum;
                }
                else
                {
                    string separator = "";
                    foreach (WorkQueueStatusEnum statusEnum in StatusEnums)
                    {
                        statuses += separator + statusEnum.Enum;
                        separator = ",";
                    }
                }

                parameters.Status = statuses + ")";
            }

            if (PriorityEnum != null)
            {
                parameters.Priority = PriorityEnum;
            }

            List <string>   groupOIDs = new List <string>();
            CustomPrincipal user      = Thread.CurrentPrincipal as CustomPrincipal;

            if (user != null)
            {
                if (!user.IsInRole(ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllStudies))
                {
                    foreach (var oid in user.Credentials.DataAccessAuthorityGroups)
                    {
                        groupOIDs.Add(oid.ToString());
                    }

                    parameters.CheckDataAccess         = true;
                    parameters.UserAuthorityGroupGUIDs = StringUtilities.Combine(groupOIDs, ",");
                }
            }

            IList <WorkQueue> list = _searchController.FindWorkQueue(parameters);

            resultCount = parameters.ResultCount;

            return(list);
        }
        protected override void OnAppearing()
        {
            //Note that the Random Class plays a role in making new animations random every time the ui is loaded

            base.OnAppearing();

            Random randomInit;

            #region Animation Init values
            AgeTileGrid.Scale            = 0;
            BloodTypeGrid.Scale          = 0;
            BloodPressureGrid.Scale      = 0;
            GenderGrid.Scale             = 0;
            ChronicDiseaseGrid.Scale     = 0;
            MedicalFileGrid.Scale        = 0;
            MedicationGrid.Scale         = 0;
            AllergiesGrid.Scale          = 0;
            AddFileButtonGrid.Opacity    = 0;
            DoctorNoteGrid.Opacity       = 0;
            PrescriptionFillGrid.Opacity = 0;
            PageLoadAnimation.Opacity    = 0;
            PatientId.Opacity            = 0;
            #endregion

            PageLoadAnimation.FadeTo(1, 800, Easing.CubicInOut);

            randomInit = new Random();
            PatientId.FadeTo(1, (uint)randomInit.Next(1000, 2000), Easing.Linear);

            #region Tile Animations
            randomInit = new Random();
            AgeTileGrid.ScaleTo(1, (uint)randomInit.Next(1000, 2000), Easing.SinOut);

            randomInit = new Random();
            BloodPressureGrid.ScaleTo(1, (uint)randomInit.Next(1000, 2000), Easing.SinInOut);

            randomInit = new Random();
            BloodTypeGrid.ScaleTo(1, (uint)randomInit.Next(1000, 2000), Easing.SinOut);

            randomInit = new Random();
            GenderGrid.ScaleTo(1, (uint)randomInit.Next(1000, 2000), Easing.SinInOut);

            randomInit = new Random();
            ChronicDiseaseGrid.ScaleTo(1, (uint)randomInit.Next(1000, 2000), Easing.SinInOut);

            randomInit = new Random();
            MedicalFileGrid.ScaleTo(1, (uint)randomInit.Next(1000, 2000), Easing.SinInOut);

            randomInit = new Random();
            MedicationGrid.ScaleTo(1, (uint)randomInit.Next(1, 1000), Easing.SinInOut);

            randomInit = new Random();
            AllergiesGrid.ScaleTo(1, (uint)randomInit.Next(1, 1000), Easing.SinInOut);
            #endregion

            #region Button Animations
            randomInit = new Random();


            randomInit = new Random();
            AddFileButtonGrid.FadeTo(1, (uint)randomInit.Next(1000, 2000), Easing.Linear);

            randomInit = new Random();
            DoctorNoteGrid.FadeTo(1, (uint)randomInit.Next(1000, 2000), Easing.Linear);

            randomInit = new Random();
            PrescriptionFillGrid.FadeTo(1, (uint)randomInit.Next(1000, 2000), Easing.Linear);
            #endregion
        }
Beispiel #30
0
        public async Task <IReadOnlyList <Appointment> > GetAllUpcomingForPatientAsync(PatientId patientId,
                                                                                       CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var now = _systemClockService.UtcNow;

            return(await context.AppointmentTables
                   .Where(x => x.AppointmentAt >= now)
                   .Where(x => x.PatientId == patientId.Value)
                   .Select(x => new Appointment(new AppointmentId(x.AppointmentId), new DoctorId(x.DoctorId), new PatientId(x.PatientId),
                                                x.AppointmentAt, new AppointmentDuration(x.Duration)))
                   .ToListAsync(cancellation));
        }