コード例 #1
0
        public void getCMMatchesTest()
        {
            DbMethods.getInstance().clearTables();
            int p1ID = 0;
            DbMethods.getInstance().InsertPatient();

            DateTime now = DateTime.Now;

            DbMethods.getInstance().InsertVisit(p1ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p1ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p1ID, 1, 2, now);

            Patient p = new Patient(p1ID);
            p.Visits = DbMethods.getInstance().getPatientVisits(p1ID);

            ACV acv1 = new ACV(new List<Visit>(){
                p.Visits[0],
                p.Visits[1]
            });

            ACV acv2 = new ACV(new List<Visit>()
            {
                p.Visits[0],
                new Visit(1, 1, 3, now)
            });

            List<ACV> matches = p.GetCMMatches(acv1);
            Assert.True(matches.Count == 1);

            matches = p.GetCMMatches(acv2);
            Assert.True(matches.Count == 0);
        }
コード例 #2
0
        public void isSafeTest()
        {
            int p1ID = 0;
            int p2ID = 1;
            int p3ID = 2;
            Patient p = new Patient(p1ID);
            DateTime now = DateTime.Now;

            DbMethods.getInstance().clearTables();

            DbMethods.getInstance().InsertPatient();
            DbMethods.getInstance().InsertPatient();
            DbMethods.getInstance().InsertPatient();

            DbMethods.getInstance().InsertVisit(p1ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p1ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p1ID, 1, 2, now);

            DbMethods.getInstance().InsertVisit(p2ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p2ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p2ID, 1, 3, now);

            DbMethods.getInstance().InsertVisit(p3ID, 1, 1, now);
            DbMethods.getInstance().InsertVisit(p3ID, 1, 2, now);
            DbMethods.getInstance().InsertVisit(p3ID, 1, 3, now);

            p.Visits = DbMethods.getInstance().getPatientVisits(p.ID);

            List<Patient> patients = DbMethods.getInstance().getPatientsWVisits();

            bool isSafe = p.IsSafe(patients, 2, 1);

            Assert.True(isSafe);

            isSafe = p.IsSafe(patients, 2, 2);

            Assert.False(isSafe);

            isSafe = p.IsSafe(patients, 3, 1);

            Assert.False(isSafe);

            isSafe = p.IsSafe(patients, 1, 1);

            Assert.True(isSafe);

            isSafe = p.IsSafe(patients, 1, 2);

            Assert.False(isSafe);
        }
コード例 #3
0
        public void findACVTest()
        {
            DateTime now = DateTime.Now;
            this._patientACV = new List<ACV>();
            int ACVSize = 3;

            DbMethods.getInstance().clearTables();
            DbMethods.getInstance().InsertPatient();
            DbMethods.getInstance().InsertVisit(0, 1, 1, now);
            DbMethods.getInstance().InsertVisit(0, 1, 2, now);
            DbMethods.getInstance().InsertVisit(0, 1, 3, now);
            DbMethods.getInstance().InsertVisit(0, 1, 4, now.AddDays(1));

            Patient p1 = new Patient(0);

            p1.FindACVs(ACVSize, PatientACVFound);

            Assert.True(this._patientACV.Count == (Util.getFactorial(p1.Visits.Count)/(Util.getFactorial(ACVSize)*Util.getFactorial(p1.Visits.Count-ACVSize))));
        }
コード例 #4
0
 public void Delete(Model.Patient patient)
 {
     // TODO: implement
 }
コード例 #5
0
 public void Save(Model.Patient newPatient)
 {
     // TODO: implement
 }
コード例 #6
0
ファイル: UI.cs プロジェクト: patpaquette/Cheo-visits
 private void listPatients_SelectedIndexChanged(object sender, EventArgs e)
 {
     this._selectedPatient = (Patient)this.listPatients.SelectedValue;
     this.updatePatientVisits();
 }
コード例 #7
0
 public void Update(Model.Patient patient)
 {
     // TODO: implement
 }
コード例 #8
0
        public static Hl7.Fhir.Model.Patient MapModel(Model.Patient patient)
        {
            if (patient == null)
            {
                throw new ArgumentNullException("patient");
            }

            var resource = new Hl7.Fhir.Model.Patient();

            resource.Id = patient.PatientId.ToString("D");

            resource.Active   = patient.Active;
            resource.Deceased = new FhirBoolean(patient.Deceased);

            resource.Name = new List <HumanName>();
            var name = new HumanName()
            {
                Family = new[] { patient.LastName },
                Given  = new[] { patient.FirstName },
                Use    = HumanName.NameUse.Official
            };

            resource.Name.Add(name);

            resource.BirthDate = patient.Birthday.ToString("s");

            switch (patient.Gender)
            {
            case GenderCode.Female:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "F", "Female");
                break;

            case GenderCode.Male:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "M", "Male");
                break;

            case GenderCode.Undetermined:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "U", "Undetermined");
                break;

            default:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/NullFlavor", "UNK", "Unknown");
                break;
            }

            resource.Telecom = new List <Contact>
            {
                new Contact()
                {
                    Value  = patient.Phone,
                    System = Contact.ContactSystem.Phone,
                    Use    = Contact.ContactUse.Home
                },
                new Contact()
                {
                    Value  = patient.Mobile,
                    System = Contact.ContactSystem.Phone,
                    Use    = Contact.ContactUse.Mobile
                },
                new Contact()
                {
                    Value  = patient.EMail,
                    System = Contact.ContactSystem.Email,
                    Use    = Contact.ContactUse.Home
                },
            };

            resource.Address = new List <Address>
            {
                new Address()
                {
                    Country = patient.Country,
                    City    = patient.City,
                    Zip     = patient.Zip,
                    Line    = new[]
                    {
                        patient.AddressLine1,
                        patient.AddressLine2
                    }
                }
            };

            // Make use of extensions ...
            //
            resource.Extension = new List <Extension>(1);
            resource.Extension.Add(new Extension(new Uri("http://www.englishclub.com/vocabulary/world-countries-nationality.htm"),
                                                 new FhirString(patient.Nationality)
                                                 ));

            return(resource);
        }
コード例 #9
0
        public static Model.Patient MapResource(Resource resource)
        {
            var source = resource as Hl7.Fhir.Model.Patient;

            if (source == null)
            {
                throw new ArgumentException("Resource in not a HL7 FHIR Patient resouce");
            }

            var patient = new Model.Patient();

            patient.Active = source.Active ?? true;
            var deceased = source.Deceased as FhirBoolean;

            if (deceased != null)
            {
                patient.Deceased = deceased.Value ?? false;
            }

            patient.FirstName = source.Name[0].Given.FirstOrDefault();
            patient.LastName  = source.Name[0].Family.FirstOrDefault();

            var phone = source.Telecom.FirstOrDefault(t => t.System == Contact.ContactSystem.Phone && t.Use == Contact.ContactUse.Home);

            if (phone != null)
            {
                patient.Phone = phone.Value;
            }

            var mobile = source.Telecom.FirstOrDefault(t => t.System == Contact.ContactSystem.Phone && t.Use == Contact.ContactUse.Mobile);

            if (mobile != null)
            {
                patient.Mobile = mobile.Value;
            }

            var email = source.Telecom.FirstOrDefault(t => t.System == Contact.ContactSystem.Email && t.Use == Contact.ContactUse.Home);

            if (email != null)
            {
                patient.EMail = email.Value;
            }

            var gender = source.Gender.Coding[0].Code.ToUpper();

            switch (gender)
            {
            case "U":
                patient.Gender = GenderCode.Unknown;
                break;

            case "F":
                patient.Gender = GenderCode.Female;
                break;

            case "M":
                patient.Gender = GenderCode.Male;
                break;

            case "UNK":
                patient.Gender = GenderCode.Undetermined;
                break;

            default:
                patient.Gender = GenderCode.Unknown;
                break;
            }

            // Example for extension "nationality"
            //
            var firstOrDefault = source.Extension.FirstOrDefault(x => x.Url.AbsolutePath == "http://www.englishclub.com/vocabulary/world-countries-nationality.htm");

            if (firstOrDefault != null)
            {
                var element     = firstOrDefault.Value;
                var nationality = (FhirString)firstOrDefault.Value;
                patient.Nationality = nationality.Value;
            }

            var birthday = source.BirthDate;

            patient.Birthday = DateTime.Parse(birthday);

            return(patient);
        }
コード例 #10
0
ファイル: Controller.cs プロジェクト: patpaquette/Cheo-visits
        //return list of ACV for a specified patient using the tree based algorithm
        public List<ACV> retrievePatientACV_clientBased(int patientID, int n)
        {
            List<Visit> visits = DbMethods.getInstance().getPatientVisits(patientID);
            Patient p = new Patient(patientID);

            List<ACV> acvs = new List<ACV>();
            p.FindACVs(n, new ACVFoundEventHandler(
                (Patient sender, ACVFoundArgs args) =>
                    {
                        acvs.Add(args.ACV);
                    }
            ));

            return acvs;
        }
コード例 #11
0
ファイル: Controller.cs プロジェクト: patpaquette/Cheo-visits
        //generate data for iteration 1
        public void createIteration1PatientsAndVisits(int numberOfPatients)
        {
            Random random = new Random();
            List<Patient> patients = new List<Patient>();
            List<Patient> globallySimilarPatients = new List<Patient>();
            List<Patient> globallyNonSimilarPatients = new List<Patient>();
            List<PatientMatchNode> patientMatchNodes = new List<PatientMatchNode>();
            float globallySimilarPatientsThreshold = 0.1f;
            float globallyNonSimilarPatientsThreshold = 0.1f;
            int requiredNumberOfGloballySimilarPatients = (int)((globallySimilarPatientsThreshold * numberOfPatients) + 0.5f);
            int requiredNumberOfGloballyNonSimilarPatients = (int)((globallyNonSimilarPatientsThreshold * numberOfPatients) + 0.5f);
            int currentNumberOfGloballySimilarPatients = 0;
            int currentNumberOfGloballyNonSimilarPatients = 0;
            DateTime maxRangeStart = new DateTime(2011, 01, 01);
            DateTime maxRangeEnd = new DateTime(2011, 12, 31);
            DateTime rangeStart = Util.getRandomDate(maxRangeStart, maxRangeEnd.AddMonths(-1));
            DateTime rangeEnd = rangeStart.AddDays(15);

            int randRationalMin = 1;
            int randRationalMax = 5;

            DbMethods.getInstance().clearTables();

            for (int i = 0; i < numberOfPatients; i++)
            {
                int patientID = i;
                DbMethods.getInstance().InsertPatient();
                Patient patient = new Patient(patientID);
                PatientMatchNode patientNode = new PatientMatchNode(patient);

                int numberOfVisits = random.Next(10, 20);
                bool restart = true;

                do
                {
                    patient.ClearVisits();

                    //generate directed visits
                    for (int j = 0; j < numberOfVisits; j++)
                    {
                        Visit v = new Visit(-1, random.Next(1, 100), random.Next(randRationalMin, randRationalMax), Util.getRandomDate(rangeStart, rangeEnd));
                        if (!patient.HasVisit(v))
                        {
                            patient.AddVisit(v);
                        }
                        else
                        {
                            j--;
                        }
                    }

                    if (requiredNumberOfGloballySimilarPatients > 0)
                    {
                        //SIMILAR PATIENTS

                        foreach (PatientMatchNode n in patientMatchNodes)
                        {
                            if (n.Patient.HasSimilarVisits(patient, 0.5f))
                            {
                                n.addMatch(patient);
                                restart = false;
                            }
                        }

                        List<PatientMatchNode> nodesToRemove = new List<PatientMatchNode>();
                        foreach (PatientMatchNode n in patientMatchNodes)
                        {
                            if (n.getMatchesNumber() >= 4)
                            {
                                requiredNumberOfGloballySimilarPatients--;
                                globallySimilarPatients.Add(n.Patient);
                                nodesToRemove.Add(n);
                            }
                        }

                        foreach (PatientMatchNode n in nodesToRemove)
                        {
                            patientMatchNodes.Remove(n);
                        }

                        nodesToRemove.Clear();

                        if(patientMatchNodes.Count < requiredNumberOfGloballySimilarPatients)
                        {
                            patientMatchNodes.Add(patientNode);
                            restart = false;
                        }

                    }
                    else if (requiredNumberOfGloballyNonSimilarPatients > 0)
                    {
                        //NON-SIMILAR PATIENTS
                        rangeStart = maxRangeStart;
                        rangeEnd = maxRangeEnd;

                        bool hasSimilar = false;
                        foreach (Patient p in patients)
                        {
                            if (!patient.HasNoSimilarVisits(p))
                            {
                                hasSimilar = true;
                            }
                        }

                        if (!hasSimilar)
                        {
                            restart = false;
                            requiredNumberOfGloballyNonSimilarPatients--;
                            globallyNonSimilarPatients.Add(patient);

                        }
                    }
                    else
                    {
                        bool hasSimilar = false;

                        foreach (Patient p in globallyNonSimilarPatients)
                        {
                            if (!patient.HasNoSimilarVisits(p))
                            {
                                hasSimilar = true;
                            }
                        }

                        if (!hasSimilar)
                        {
                            restart = false;
                        }
                    }

                }
                while(restart);

                //adding the visits
                foreach (Visit v in patient.Visits)
                {
                    DbMethods.getInstance().InsertVisit(patientID, v.ProfessionalID, v.RationalID, v.Date);
                }

                patients.Add(patient);
            }
        }
コード例 #12
0
 private void PatientACVFound(Patient sender, ACVFoundArgs args)
 {
     ACV acv = args.ACV;
     this._patientACV.Add(acv);
 }
コード例 #13
0
        private void RenderCMMatches(ACV cm)
        {
            int patientID = this.AskForPatientID();
            Patient p = new Patient(patientID);

            List<ACV> matches = p.GetCMMatches(cm);
            int matchCounter = 1;

            foreach (ACV acv in matches)
            {
                Console.WriteLine("Match : " + matchCounter++);
                Console.WriteLine(acv.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Combination to match : ");
            Console.WriteLine(cm.ToString());
            Console.WriteLine("Number of matches : " + matches.Count);
            Console.WriteLine();
        }
コード例 #14
0
        public void similarHistoryTest()
        {
            Patient p1 = new Patient(1);
            Patient p2 = new Patient(2);
            Patient p3 = new Patient(3);
            DateTime now = DateTime.Now;

            p1.AddVisit(new Visit(1, 1, 1, now));
            p1.AddVisit(new Visit(2, 1, 2, now));
            p1.AddVisit(new Visit(3, 1, 3, now));
            p1.AddVisit(new Visit(4, 1, 3, now.AddDays(1)));

            p2.AddVisit(new Visit(5, 1, 1, now));
            p2.AddVisit(new Visit(6, 1, 2, now));

            p3.AddVisit(new Visit(7, 1, 3, now));
            p3.AddVisit(new Visit(8, 1, 3, now.AddDays(2)));

            bool result = p1.HasSimilarVisits(p2, 0.5f);
            Assert.True(result == true);

            result = p1.HasSimilarVisits(p3, 0.5f);
            Assert.True(result == false);

            result = p1.HasSimilarVisits(p3, 0.25f);
            Assert.True(result == true);

            result = p1.HasSimilarVisits(p2, 0.75f);
            Assert.True(result == false);
        }
コード例 #15
0
        public void matchACVTest()
        {
            this._patientACV = new List<ACV>();
            DateTime now = DateTime.Now;

            DbMethods.getInstance().clearTables();
            DbMethods.getInstance().InsertPatient();
            DbMethods.getInstance().InsertVisit(0, 1, 1, now);
            DbMethods.getInstance().InsertVisit(0, 1, 2, now);
            DbMethods.getInstance().InsertVisit(0, 1, 3, now);

            DbMethods.getInstance().InsertPatient();
            DbMethods.getInstance().InsertVisit(1, 1, 1, now);
            DbMethods.getInstance().InsertVisit(1, 1, 2, now);
            DbMethods.getInstance().InsertVisit(1, 1, 3, now);

            Patient p1 = new Patient(0);
            Patient p2 = new Patient(1);

            p2.FindACVs(2, PatientACVFound);

            foreach (ACV v in this._patientACV)
            {
                Assert.True(p1.MatchesACV(v));
            }
        }
コード例 #16
0
 partial void DeletePatient(Patient instance);
コード例 #17
0
 partial void UpdatePatient(Patient instance);
コード例 #18
0
 partial void InsertPatient(Patient instance);
コード例 #19
0
        private void RenderCMMatches(int patientID)
        {
            int cmSize = 0;
            ACV CM = new ACV(new List<Visit>());
            Patient p = new Patient(patientID);

            do
            {
                Console.WriteLine("Choose the size of the CM : ");
                cmSize = int.Parse(Console.ReadLine());
            } while (cmSize <= 0);

            for (int i = 0; i < cmSize; i++)
            {
                int year;
                int month;
                int day;
                int rational;

                do
                {
                    Console.WriteLine("CM no : " + (i + 1));
                    Console.WriteLine("Month : ");
                    month = int.Parse(Console.ReadLine());
                } while (month <= 0);

                do
                {
                    Console.WriteLine("Day : ");
                    day = int.Parse(Console.ReadLine());
                } while (day <= 0);

                do
                {
                    Console.WriteLine("Year : ");
                    year = int.Parse(Console.ReadLine());
                } while (year <= 0);

                do
                {
                    Console.WriteLine("Rational : ");
                    Console.WriteLine("1. New");
                    Console.WriteLine("2. Checkup");
                    Console.WriteLine("3. Follow-up");
                    Console.WriteLine("4. Referral");
                    Console.WriteLine("5. Emergency");
                    rational = int.Parse(Console.ReadLine());
                } while (rational < 1 && rational > 5);

                CM.Add(new Visit(-1, -1, rational, new DateTime(year, month, day)));
            }

            //this._controller.matchCM(patientID, CM, false);
            List<ACV> matches = p.GetCMMatches(CM);
            int matchCounter = 1;

            foreach (ACV acv in matches)
            {
                Console.WriteLine();
                Console.WriteLine("Match : " + matchCounter++);
                Console.WriteLine(acv.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Combination to match : ");
            Console.WriteLine(CM.ToString());
            Console.WriteLine("Number of matches : " + matches.Count);
            Console.WriteLine();
        }
コード例 #20
0
ファイル: Patient.cs プロジェクト: qq5013/Medical
 public static Patient ParsePatient(DataRowCollection dataRow,int index)
 {
     try{
         Patient patient = new Patient();
         patient.D_ID = Convert.ToInt16(dataRow[index]["d_id"].ToString());
         patient.Gender = dataRow[index]["gender"].ToString();
         patient.Old = Convert.ToInt16(dataRow[index]["old"]);
         patient.P_name = dataRow[index]["p_name"].ToString();
         patient.Pid = Convert.ToInt16(dataRow[index]["pid"]);
         patient.Tel = dataRow[index]["tel"].ToString();
         return patient;
     }catch(Exception exp){
         return null;
     }
 }