Beispiel #1
0
        private void SetObservations()
        {
            var o = new Observation
            {
                Id = 1,
                StartObservationDate = DateTime.Parse("12.03.2014"),
                EndObservationDate   = DateTime.Parse("12.03.2015"),
                PatientId            = 2,
                DiagnosisId          = 3,
                DoctorId             = 2
            };

            Observations.Add(o);

            o = new Observation
            {
                Id = 2,
                StartObservationDate = DateTime.Parse("22.09.2016"),
                EndObservationDate   = DateTime.Parse("12.10.2016"),
                PatientId            = 1,
                DiagnosisId          = 1,
                DoctorId             = 3
            };
            Observations.Add(o);

            o = new Observation
            {
                Id = 4,
                StartObservationDate = DateTime.Parse("01.01.2017"),
                EndObservationDate   = DateTime.Parse("13.01.2017"),
                PatientId            = 1,
                DiagnosisId          = 1,
                DoctorId             = 1
            };
            Observations.Add(o);

            o = new Observation
            {
                Id = 5,
                StartObservationDate = DateTime.Parse("25.09.2018"),
                EndObservationDate   = DateTime.Parse("07.10.2018"),
                PatientId            = 1,
                DiagnosisId          = 3,
                DoctorId             = 2
            };
            Observations.Add(o);

            o = new Observation
            {
                Id = 3,
                StartObservationDate = DateTime.Parse("10.10.2007"),
                EndObservationDate   = DateTime.Parse("12.10.2017"),
                PatientId            = 3,
                DiagnosisId          = 3,
                DoctorId             = 1
            };
            Observations.Add(o);
        }
        public override async Task InitializeAsync(object navigationData)
        {
            if (Observations == null)
            {
                Observations = new ObservableCollection <Observation>();
            }

            IEnumerable <Observation> observations = await _observationsService.GetObservationsAsync();

            Observations.Clear();
            foreach (Observation observation in observations)
            {
                Observations.Add(observation);
            }

            await base.InitializeAsync(navigationData);
        }
Beispiel #3
0
        public async void GetObservationsAsync()
        {
            if (monitoringPressure)
            {
                var retrievedObservations = await observationRepository.GetByPatientAndBloodPressure(PatientId);

                foreach (var o in retrievedObservations)
                {
                    if (Observations.Where(observation => observation.Id == o.Id).ToList().Count() == 0)
                    {
                        Observations.Add(o);
                    }
                }
            }
            if (monitoringCholesterol)
            {
                var retrievedObservations = await observationRepository.GetByPatientAndTotalCholesterol(PatientId);

                foreach (var o in retrievedObservations)
                {
                    if (Observations.Where(observation => observation.Id == o.Id).ToList().Count() == 0)
                    {
                        Observations.Add(o);
                    }
                }
            }
            if (monitoringTobacco)
            {
                var retrievedObservations = await observationRepository.GetByPatientAndTobacco(PatientId);

                foreach (var o in retrievedObservations)
                {
                    if (Observations.Where(observation => observation.Id == o.Id).ToList().Count() == 0)
                    {
                        Observations.Add(o);
                    }
                }
            }
            foreach (var o in Observations)
            {
                foreach (var observer in Observers)
                {
                    observer.OnNext(o);
                }
            }
        }
Beispiel #4
0
 public override void AddObservations()
 {
     Observations.Add(Energy, "Energy");
 }
Beispiel #5
0
 public override void AddObservations()
 {
     Observations.Add(GetComponent <TrailPointPoolable>().Energy, "Energy");
 }
Beispiel #6
0
        public override Guid WriteToCDS(OrganizationServiceProxy _serviceProxy)
        {
            Guid profileId = Guid.Empty;

            try
            {
                HealthCDM.Contact addContact = new HealthCDM.Contact();

                //Set standard atttributes (this could be done via reflection)
                // but for now this is all we are setting
                addContact.GenderCode               = new OptionSetValue(GenderCode);
                addContact.FirstName                = FirstName;
                addContact.LastName                 = LastName;
                addContact.Address1_Line1           = Address1Line1;
                addContact.Address1_City            = Address1City;
                addContact.Address1_StateOrProvince = Address1StateOrProvince;
                addContact.Address1_PostalCode      = Address1PostalCode;
                addContact.Telephone1               = Telephone1;
                addContact.MobilePhone              = MobilePhone;
                addContact.Telephone2               = Telephone2;
                addContact.Address1_Country         = Address1Country;
                addContact.EMailAddress1            = FirstName + "." + LastName + "@" + EmailAddressDomain;
                addContact.Address1_Country         = Address1Country;
                addContact.Salutation               = Salutation;
                addContact.BirthDate                = BirthDate;
                // set the primary language
                addContact.msemr_Communication1Language = new EntityReference(HealthCDM.msemr_codeableconcept.EntityLogicalName, GetCodeableConceptId(_serviceProxy, PrimaryLanguageCode, (int)HealthCDMEnums.CodeableConcept_Type.Language));

                addContact.msemr_ContactType = new OptionSetValue((int)HealthCDMEnums.Contact_Contacttype.Patient);

                // Set the Primary Practitioner, Emergency Contact & Primary Contacts
                if (!string.IsNullOrEmpty(PrimaryPractitionerId))
                {
                    addContact.msemr_GeneralPractioner = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse(PrimaryPractitionerId));
                }

                if (!string.IsNullOrEmpty(EmergencyContactId))
                {
                    addContact.msemr_Contact1             = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse(EmergencyContactId));
                    addContact.msemr_Contact1Relationship = new EntityReference(HealthCDM.msemr_codeableconcept.EntityLogicalName, GetCodeableConceptId(_serviceProxy, EmergencyContactRelationshipTypeId, (int)HealthCDMEnums.CodeableConcept_Type.PatientRelationshipType));
                }

                if (!string.IsNullOrEmpty(PrimaryContactId))
                {
                    addContact.msemr_Contact2             = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse(PrimaryContactId));
                    addContact.msemr_Contact2Relationship = new EntityReference(HealthCDM.msemr_codeableconcept.EntityLogicalName, GetCodeableConceptId(_serviceProxy, PrimaryContactRelationshipTypeId, (int)HealthCDMEnums.CodeableConcept_Type.PatientRelationshipType));
                }

                addContact.msemr_MedicalRecordNumber = PatientMedicalNumber;

                try
                {
                    profileId = _serviceProxy.Create(addContact);

                    if (profileId != Guid.Empty)
                    {
                        ContactId = profileId.ToString();

                        #region remap section due to dependencies

                        // Add alergies to patient
                        if (AllergyIntolerances.Count > 0)
                        {
                            foreach (AllergyIntolerance ai in AllergyIntolerances)
                            {
                                ai.PatientId = ContactId;
                                ai.WriteToCDS(_serviceProxy);
                            }
                        }

                        if (Devices.Count > 0)
                        {
                            foreach (Device device in Devices)
                            {
                                Location location = Locations[SampleDataCache.SelectRandomItem.Next(0, Locations.Count - 1)];

                                device.PatientId  = ContactId;
                                device.LocationId = location.LocationId;
                                device.WriteToCDS(_serviceProxy);
                            }
                        }


                        if (Appointments.Count > 0)
                        {
                            foreach (Appointment appointment in Appointments)
                            {
                                Location location = Locations[SampleDataCache.SelectRandomItem.Next(0, Locations.Count - 1)];

                                appointment.Description   = FullName + " - Appointment";
                                appointment.PatientId     = ContactId;
                                appointment.LocationId    = location.LocationId;
                                appointment.AppointmentId = appointment.WriteToCDS(_serviceProxy).ToString();
                            }
                        }

                        if (Encounters.Count > 0)
                        {
                            foreach (Encounter encounter in Encounters)
                            {
                                Appointment appointment = Appointments[SampleDataCache.SelectRandomItem.Next(0, Appointments.Count - 1)];

                                encounter.Name             = FullName + " - Patient Encounter";
                                encounter.SubjectPatientId = ContactId;
                                encounter.AppointmentEmrId = appointment.AppointmentId;
                                encounter.EncounterId      = encounter.WriteToCDS(_serviceProxy).ToString();
                            }
                        }

                        if (ReferralRequests.Count > 0)
                        {
                            foreach (ReferralRequest request in ReferralRequests)
                            {
                                Encounter   encounter   = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];
                                Appointment appointment = Appointments[SampleDataCache.SelectRandomItem.Next(0, Appointments.Count - 1)];

                                request.PatientId      = ContactId;
                                request.PractitionerId = primaryPractitionerId;
                                request.EncounterId    = encounter.EncounterId;
                                request.AppointmentId  = appointment.AppointmentId;
                                request.WriteToCDS(_serviceProxy);
                            }
                        }

                        if (NutritionOrders.Count > 0)
                        {
                            foreach (NutritionOrder no in NutritionOrders)
                            {
                                Encounter encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];

                                no.PatientId      = ContactId;
                                no.PractitionerId = PrimaryPractitionerId;
                                no.EncounterId    = encounter.EncounterId;
                                no.WriteToCDS(_serviceProxy);
                            }
                        }

                        //if (Products.Count > 0)
                        //{
                        //    // we need the Uomid/groupid first
                        //    Uom.WriteToCDS(_serviceProxy);

                        //    foreach (Medication product in Products)
                        //    {
                        //        product.UomId = uom.UomId;
                        //        product.UnitGroupId = uom.GroupId;
                        //        product.Subject = "Sample Product " + GenerateRandomNumber();
                        //        product.WriteToCDS(_serviceProxy);
                        //    }

                        //    PriceList.Products = products;
                        //    PriceList.GroupId = uom.GroupId;
                        //    PriceList.UomId = uom.UomId;

                        //    PriceList.WriteToCDS(_serviceProxy);
                        //}

                        if (MedicationRequests.Count > 0)
                        {
                            foreach (MedicationRequest request in MedicationRequests)
                            {
                                Encounter  encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];
                                Medication product   = Products[SampleDataCache.SelectRandomItem.Next(0, Products.Count - 1)];

                                request.PatientId                = ContactId;
                                request.PractitionerId           = primaryPractitionerId;
                                request.MedicationTypePreference = string.Empty; // This is the PRODUCT reference which we don't have yet
                                request.EncounterId              = encounter.EncounterId;
                                request.MedicationTypePreference = product.MedicationId;
                                request.WriteToCDS(_serviceProxy);

                                MedicationAdministration admin = new DataModel.MedicationAdministration();

                                admin.PatientId   = ContactId;
                                admin.EncounterId = encounter.EncounterId;
                                admin.Name        = FullName + " - medication  administration";
                                admin.MedicationAdministrationId = admin.WriteToCDS(_serviceProxy).ToString();

                                medicationAdminitrations.Add(admin);
                            }
                        }

                        if (EpisodesOfCare.Count > 0)
                        {
                            foreach (EpisodeOfCare request in EpisodesOfCare)
                            {
                                Encounter encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];

                                request.PatientId       = ContactId;
                                request.PractitionerId  = primaryPractitionerId;
                                request.Description     = FullName + " - Episode of Care";
                                request.EncounterId     = encounter.EncounterId;
                                request.EpisodeOfCareId = request.WriteToCDS(_serviceProxy).ToString();

                                // now we will add in the Observations
                                Device   device   = Devices[SampleDataCache.SelectRandomItem.Next(0, Devices.Count - 1)];
                                Location location = Locations[SampleDataCache.SelectRandomItem.Next(0, Locations.Count - 1)];

                                Observation observation = new Observation();

                                observation.PatientId       = ContactId;
                                observation.Description     = FullName + " - Observation";
                                observation.EpisodeOfCareId = request.EpisodeOfCareId;
                                observation.LocationId      = location.LocationId;
                                observation.DeviceId        = device.DeviceId;

                                observation.WriteToCDS(_serviceProxy);

                                Observations.Add(observation);
                            }
                        }

                        if (Careplans.Count > 0)
                        {
                            foreach (CarePlan plan in Careplans)
                            {
                                Encounter encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];

                                plan.PatientId   = ContactId;
                                plan.EncounterId = encounter.EncounterId;
                                plan.Description = FullName + " - Description";
                                plan.Title       = FullName + " - Care Plan;";
                                plan.CarePlanId  = plan.WriteToCDS(_serviceProxy).ToString();
                            }
                        }

                        if (Conditions.Count > 0)
                        {
                            foreach (Condition condition in Conditions)
                            {
                                Appointment appointment = Appointments[SampleDataCache.SelectRandomItem.Next(0, Appointments.Count - 1)];
                                CarePlan    careplan    = Careplans[SampleDataCache.SelectRandomItem.Next(0, Careplans.Count - 1)];

                                condition.PatientId      = ContactId;
                                condition.PractitionerId = PrimaryPractitionerId;
                                condition.AsserterId     = ContactId;
                                condition.AppointmentId  = appointment.AppointmentId;
                                condition.CarePlanId     = careplan.CarePlanId;
                                condition.WriteToCDS(_serviceProxy);
                            }
                        }

                        if (RiskAssessments.Count > 0)
                        {
                            foreach (RiskAssessment assessment in RiskAssessments)
                            {
                                Encounter encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];
                                Condition condition = Conditions[SampleDataCache.SelectRandomItem.Next(0, Conditions.Count - 1)];

                                assessment.PatientId      = ContactId;
                                assessment.PractitionerId = PrimaryPractitionerId;
                                assessment.ConditionId    = condition.ConditionId;
                                assessment.EncounterId    = encounter.EncounterId;
                                assessment.Name           = FullName + " - Risk Assessment";
                                assessment.WriteToCDS(_serviceProxy);
                            }
                        }

                        if (Procedures.Count > 0)
                        {
                            foreach (Procedure procedure in Procedures)
                            {
                                Encounter encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];

                                procedure.EncounterId = encounter.EncounterId;
                                procedure.PatientId   = ContactId;
                                procedure.WriteToCDS(_serviceProxy);
                            }
                        }

                        if (Careteams.Count > 0)
                        {
                            foreach (CareTeam team in Careteams)
                            {
                                team.PatientId  = ContactId;
                                team.Name       = addContact.FullName + " - Care Team;";
                                team.CareTeamId = team.WriteToCDS(_serviceProxy).ToString();

                                // for each care team we will add the participants
                                CareTeamParticipant patient       = new CareTeamParticipant();
                                CareTeamParticipant relatedperson = new CareTeamParticipant();
                                CareTeamParticipant practitioner  = new CareTeamParticipant();

                                patient.CareTeamId       = team.CareTeamId;
                                relatedperson.CareTeamId = team.CareTeamId;
                                practitioner.CareTeamId  = team.CareTeamId;

                                patient.PatientId = ContactId;

                                relatedperson.RelatedPersonId = PrimaryContactId;
                                relatedperson.PatientId       = ContactId;

                                practitioner.PractitionerId = PrimaryPractitionerId;
                                practitioner.PatientId      = ContactId;

                                patient.MemberType       = (int)HealthCDMEnums.CareTeamParticipant_Membertype.Patient;
                                relatedperson.MemberType = (int)HealthCDMEnums.CareTeamParticipant_Membertype.RelationPerson;
                                practitioner.MemberType  = (int)HealthCDMEnums.CareTeamParticipant_Membertype.Practitioner;

                                patient.WriteToCDS(_serviceProxy);
                                relatedperson.WriteToCDS(_serviceProxy);
                                practitioner.WriteToCDS(_serviceProxy);

                                CareTeamParticipants.Add(patient);
                                CareTeamParticipants.Add(relatedperson);
                                CareTeamParticipants.Add(practitioner);

                                //patient.RoleId = SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.ParticipantRole.ToString()]
                                //    .Values.ElementAt(SampleDataCache.SelectRandomItem.Next(0, SampleDataCache.CodeableConcepts[HealthCDMEnums.CodeableConcept_Type.ParticipantRole.ToString()]
                                //    .Values.Count - 1)).Key;
                            }
                        }

                        if (Specimens.Count > 0)
                        {
                            foreach (Specimen specimen in Specimens)
                            {
                                Device device = Devices[SampleDataCache.SelectRandomItem.Next(0, Devices.Count - 1)];

                                specimen.PatientId      = ContactId;
                                specimen.PractitionerId = PrimaryPractitionerId;
                                specimen.DeviceId       = device.DeviceId;
                                specimen.Name           = FullName + " - Specimen";
                                specimen.WriteToCDS(_serviceProxy);
                            }
                        }

                        if (Tasks.Count > 0)
                        {
                            foreach (PatientTask task in Tasks)
                            {
                                Encounter encounter = Encounters[SampleDataCache.SelectRandomItem.Next(0, Encounters.Count - 1)];

                                task.OwnerPatientId           = ContactId;
                                task.RequestingPatientId      = ContactId;
                                task.Subject                  = FullName + " - Task";
                                task.OwnerPractitionerId      = PrimaryPractitionerId;
                                task.RequestingPractitionerId = PrimaryPractitionerId;
                                task.EncounterId              = encounter.EncounterId;
                                task.WriteToCDS(_serviceProxy);
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        throw new Exception("Contact Id == null");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(profileId);
        }
Beispiel #7
0
 public override bool Load(ICancelProgressHandler progresshandler)
 {
     if (File.Exists(FileName))
     {
         var grid = (Owner.Grid as MFGrid);
         Observations.Clear();
         StreamReader sr   = new StreamReader(FileName);
         var          line = ReadComment(sr);
         var          strs = TypeConverterEx.Split <string>(line, 6);
         NH       = int.Parse(strs[0]);
         MOBS     = int.Parse(strs[1]);
         MAXM     = int.Parse(strs[2]);
         IUHOBSV  = int.Parse(strs[3]);
         HOBDRY   = float.Parse(strs[4]);
         Option   = strs[5];
         TOMULTH  = TypeConverterEx.Split <float>(sr.ReadLine(), 1)[0];
         Topology = new RegularGridTopology();
         int i = 0;
         while (!sr.EndOfStream)
         {
             line = sr.ReadLine();
             var vv = TypeConverterEx.SkipSplit <float>(line, 1, 8);
             strs = TypeConverterEx.Split <string>(line);
             HeadObservation obs = new HeadObservation(i)
             {
                 Layer      = (int)vv[0],
                 Row        = (int)vv[1],
                 Column     = (int)vv[2],
                 IREFSPFlag = (int)vv[3],
                 Name       = strs[0]
             };
             obs.CellID = grid.Topology.GetID(obs.Row - 1, obs.Column - 1);
             if (obs.IREFSPFlag < 0)
             {
                 line    = sr.ReadLine();
                 obs.ITT = TypeConverterEx.Split <int>(line, 1)[0];
                 int nsp = Math.Abs((int)vv[3]);
                 obs.IREFSP  = new int[nsp];
                 obs.TOFFSET = new float[nsp];
                 obs.HOBS    = new float[nsp];
                 obs.ROFF    = vv[5];
                 obs.COFF    = vv[6];
                 for (int t = 0; t < nsp; t++)
                 {
                     line           = sr.ReadLine();
                     vv             = TypeConverterEx.SkipSplit <float>(line, 1, 4);
                     obs.IREFSP[t]  = (int)vv[0];
                     obs.TOFFSET[t] = vv[1];
                     obs.HOBS[t]    = vv[2];
                 }
             }
             else
             {
                 int nsp = 1;
                 obs.IREFSP     = new int[nsp];
                 obs.TOFFSET    = new float[nsp];
                 obs.HOBS       = new float[nsp];
                 obs.IREFSP[0]  = (int)vv[3];
                 obs.TOFFSET[0] = vv[4];
                 obs.ROFF       = vv[5];
                 obs.COFF       = vv[6];
                 obs.HOBS[0]    = vv[7];
             }
             obs.Elevation = grid.GetElevationAt(obs.Row - 1, obs.Column - 1, obs.Layer - 1);
             Observations.Add(obs);
             i++;
         }
         if (Observations.Any())
         {
             Topology.ActiveCell      = new int[NH][];
             Topology.ActiveCellIDs   = new int[NH];
             Topology.RowCount        = grid.RowCount;
             Topology.ColumnCount     = grid.ColumnCount;
             Topology.ActiveCellCount = NH;
             var nsp1 = (Observations[0] as HeadObservation).IREFSP.Length;
             HOBS           = new DataCube <float>(1, nsp1, NH);
             HOBS.Variables = new string[] { "Head Observation" };
             for (int t = 0; t < nsp1; t++)
             {
                 for (int k = 0; k < NH; k++)
                 {
                     var hob = Observations[k] as HeadObservation;
                     HOBS[0, t, k]             = hob.HOBS[t];
                     Topology.ActiveCell[k]    = new int[] { hob.Row - 1, hob.Column - 1 };
                     Topology.ActiveCellIDs[k] = grid.Topology.GetID(hob.Row - 1, hob.Column - 1);
                 }
             }
             HOBS.Topology = this.Topology;
         }
         sr.Close();
         OnLoaded(progresshandler);
         return(true);
     }
     else
     {
         OnLoadFailed("Failed to load " + this.Name, progresshandler);
         return(false);
     }
 }
Beispiel #8
0
        public void AddData(IEntity data, EntityType entityType)
        {
            switch (entityType)
            {
            case EntityType.Person:
            {
                Persons.Add((Person)data);
                break;
            }

            case EntityType.Death:
            {
                Deaths.Add((Death)data);
                break;
            }

            case EntityType.PayerPlanPeriod:
            {
                PayerPlanPeriods.Add((PayerPlanPeriod)data);
                break;
            }

            case EntityType.ConditionOccurrence:
            {
                ConditionOccurrences.Add((ConditionOccurrence)data);
                break;
            }

            case EntityType.DrugExposure:
            {
                DrugExposures.Add((DrugExposure)data);
                break;
            }

            case EntityType.ProcedureOccurrence:
            {
                ProcedureOccurrences.Add((ProcedureOccurrence)data);
                break;
            }

            case EntityType.Observation:
            {
                Observations.Add((Observation)data);
                break;
            }

            case EntityType.VisitOccurrence:
            {
                VisitOccurrences.Add((VisitOccurrence)data);
                break;
            }

            case EntityType.VisitDetail:
            {
                VisitDetails.Add((VisitDetail)data);
                break;
            }

            case EntityType.Cohort:
            {
                Cohort.Add((Cohort)data);
                break;
            }

            case EntityType.Measurement:
            {
                Measurements.Add((Measurement)data);
                break;
            }

            case EntityType.DeviceExposure:
            {
                DeviceExposure.Add((DeviceExposure)data);
                break;
            }

            case EntityType.ObservationPeriod:
            {
                ObservationPeriods.Add((ObservationPeriod)data);
                break;
            }

            case EntityType.DrugEra:
            {
                DrugEra.Add((EraEntity)data);
                break;
            }

            case EntityType.ConditionEra:
            {
                ConditionEra.Add((EraEntity)data);
                break;
            }

            case EntityType.Note:
            {
                Note.Add((Note)data);
                break;
            }
            }
        }
 public Task Publish(Observation observation)
 {
     Observations.Add(observation);
     return(Task.FromResult(0));
 }
Beispiel #10
0
 /// <summary>
 /// Adds the specified <see cref="Observation"/> to this <see cref="Category"/>.
 /// Should be used only by <see cref="Observation(Category, double, SkiaSharp.SKRect)"/>.
 /// </summary>
 /// <param name="observation">The <see cref="Observation"/> to add.</param>
 internal void Add(Observation observation)
 {
     Observations.Add(observation);
 }