Пример #1
0
        public Bed(Transfer transfer, Patient patient, Visit visit)
        {
            FromDate = transfer.FromDate;
            Pending = transfer.Pending;
            CampusId = transfer.CampusId;
            WardId = transfer.WardId;
            RoomId = transfer.RoomId;
            BedId = transfer.BedId;
            PriorCampusId = transfer.PriorCampusId;
            PriorWardId = transfer.PriorWardId;
            PriorRoomId = transfer.PriorRoomId;
            PriorBedId = transfer.PriorBedId;
            TemporaryLocation = transfer.TemporaryLocation;
            LocationStatus = transfer.LocationStatus;
            PriorLocationStatus = transfer.PriorLocationStatus;
            ConsultingDoctor = transfer.ConsultingDoctor;
            DepartmentId = transfer.DepartmentId;
            DepartmentType = transfer.DepartmentType;
            FinancialClass = transfer.FinancialClass;
            FinancialClassFromDate = transfer.FinancialClassFromDate;
            RoomAsked = transfer.RoomAsked;
            RoomAssigned = transfer.RoomAssigned;

            PatientId = patient.Id;
            PatientLastName = patient.LastName;
            PatientFirstName = patient.FirstName;
            PatientBirthDate = patient.BirthDate;
            PatientSex = patient.Sex;

            VisitId = visit.Id;
            PendingAdmission = visit.Pending;
            PatientClass = visit.PatientClass;
            AdmissionType = visit.AdmissionType;
            AdmissionDate = visit.AdmissionDate;
            DischargeDate = visit.DischargeDate;
            PendingDischarge = visit.PendingDischarge;
        }
Пример #2
0
        void RemoveBedFromWard(Transfer transfer, Ward ward, bool checkFromDate = true, bool checkLocation = true, bool removePendingDischarge = true)
        {
            if (ward == null || ward.Beds == null || !ward.Beds.Any())
                return;

            var bedsToRemove = (from b in ward.Beds
                                where b.VisitId == visit.Id &&
                                    b.PatientId == patient.Id &&
                                    (checkFromDate ? b.FromDate == transfer.FromDate : true) &&
                                    (checkLocation ?
                                        (b.CampusId == transfer.CampusId &&
                                        b.WardId == transfer.WardId &&
                                        b.RoomId == transfer.RoomId &&
                                        b.BedId == transfer.BedId) : true) &&
                                    (removePendingDischarge ? true : !b.PendingDischarge.GetValueOrDefault())
                                select b).ToList();

            foreach (var item in bedsToRemove)
            {
                if (log.IsInfoEnabled)
                    log.InfoFormat("Ward {0}: removed bed {1}-{2}-{3}-{4} fromDate '{5}' for visit {6}", ward.Id, item.CampusId, item.WardId, item.RoomId, item.BedId, item.FromDate.Maybe(d => d.Value.ToString("yyyy-MM-dd HH:mm")), item.VisitId);
                ward.Beds.Remove(item);
            }
        }
Пример #3
0
        async Task ProcessPV1(string segment)
        {
            var fields = segment.Split(fieldSep);

            var visitNumber = GetValueFromField(fields.ElementAtOrDefault(19));
            if (string.IsNullOrEmpty(visitNumber))
                return;

            visit = await httpClient.GetAsync<Visit>(string.Format(visitUri, visitNumber)).ConfigureAwait(false);
            if (visit == null)
            {
                if ((new string[] { "A01", "A04", "A05", "A14" }).Contains(eventType))
                    visit = new Visit() { Id = visitNumber };
                else
                {
                    if (log.IsWarnEnabled)
                        log.WarnFormat("No visit in DB with number {0} for HL7 with eventType {1} ", visitNumber, eventType);
                    return;
                }
            }

            visit.PatientId = patient.Id;

            transfer = new Transfer();

            visit.PatientClass = GetValueFromField(fields.ElementAtOrDefault(2));

            transfer.WardId = GetValueFromField(fields.ElementAtOrDefault(3));
            transfer.RoomId = GetValueFromField(fields.ElementAtOrDefault(3), componentIndex: 1);
            transfer.BedId = GetValueFromField(fields.ElementAtOrDefault(3), componentIndex: 2);
            transfer.CampusId = GetValueFromField(fields.ElementAtOrDefault(3), componentIndex: 3);
            transfer.LocationStatus = GetValueFromField(fields.ElementAtOrDefault(3), componentIndex: 4);

            visit.AdmissionType = GetValueFromField(fields.ElementAtOrDefault(4));
            if ((new string[] { "A04", "A05" }).Contains(eventType))
                visit.PreadmitNumber = GetValueFromField(fields.ElementAtOrDefault(5));

            transfer.PriorWardId = GetValueFromField(fields.ElementAtOrDefault(6));
            transfer.PriorRoomId = GetValueFromField(fields.ElementAtOrDefault(6), componentIndex: 1);
            transfer.PriorBedId = GetValueFromField(fields.ElementAtOrDefault(6), componentIndex: 2);
            transfer.PriorCampusId = GetValueFromField(fields.ElementAtOrDefault(6), componentIndex: 3);
            transfer.PriorLocationStatus = GetValueFromField(fields.ElementAtOrDefault(6), componentIndex: 4);

            visit.HomeDoctor = GetValueFromField(fields.ElementAtOrDefault(7));
            visit.ReferringDoctor = GetValueFromField(fields.ElementAtOrDefault(8));

            transfer.ConsultingDoctor = GetValueFromField(fields.ElementAtOrDefault(9));
            consultingDoctorLastName = GetValueFromField(fields.ElementAtOrDefault(9), componentIndex: 1);
            consultingDoctorFirstName = GetValueFromField(fields.ElementAtOrDefault(9), componentIndex: 2);

            transfer.DepartmentId = GetValueFromField(fields.ElementAtOrDefault(10));
            transfer.TemporaryLocation = GetValueFromField(fields.ElementAtOrDefault(11));

            visit.AdmittingDoctor = GetValueFromField(fields.ElementAtOrDefault(17));

            transfer.FinancialClass = GetValueFromField(fields.ElementAtOrDefault(20));
            transfer.FinancialClassFromDate = GetValueFromField(fields.ElementAtOrDefault(20), componentIndex: 1).ToNullableDatetime("yyyyMMdd", "yyyyMMddHHmm", "dd/MM/yyyy");

            visit.ChargePriceIndicator = GetValueFromField(fields.ElementAtOrDefault(21));
            visit.HomeDoctorRecievesLetter = GetValueFromField(fields.ElementAtOrDefault(22)).Maybe(x => x == "N" ? (bool?)true : null);
            if ((new string[] { "A01", "A02", "A03", "A04", "A08" }).Contains(eventType))
                visit.Internet = GetValueFromField(fields.ElementAtOrDefault(28)).Maybe(x => x == "1" ? (bool?)true : null);
            if ((new string[] { "A03", "A16" }).Contains(eventType))
            {
                visit.DischargeDisposition = GetValueFromField(fields.ElementAtOrDefault(36));
                visit.DischargeToLocation = GetValueFromField(fields.ElementAtOrDefault(37));
            }

            transfer.DepartmentType = GetValueFromField(fields.ElementAtOrDefault(39));

            visit.AdmissionDate = GetValueFromField(fields.ElementAtOrDefault(44)).ToNullableDatetime("yyyyMMdd", "yyyyMMddHHmm", "dd/MM/yyyy") ?? eventOccured;

            transfer.Pending = (new string[] { "A15", "A16" }).Contains(eventType) ? (bool?)true : null;
            transfer.FromDate = (new string[] { "A01", "A04", "A05", "A14" }).Contains(eventType) ? visit.AdmissionDate : eventOccured;
            visit.Pending = (new string[] { "A05", "A14" }).Contains(eventType) ? (bool?)true : null;

            if ((new string[] { "A03", "A16", "A08" }).Contains(eventType))
                visit.DischargeDate = GetValueFromField(fields.ElementAtOrDefault(45)).ToNullableDatetime("yyyyMMdd", "yyyyMMddHHmm", "dd/MM/yyyy");
            visit.ExternalId = GetValueFromField(fields.ElementAtOrDefault(50));
        }