Esempio n. 1
0
 public void UpdateContact(ContactViewModel updatedContact)
 {
     this.AgeUnit            = updatedContact.AgeUnit;
     this.Age                = updatedContact.Age;
     this.DateOfLastContact  = updatedContact.DateOfLastContact;
     this.FirstSaveTime      = updatedContact.FirstSaveTime;
     this.LastSourceCase     = updatedContact.LastSourceCase;
     this.District           = updatedContact.District;
     this.Gender             = updatedContact.Gender;
     this.LC1Chairman        = updatedContact.LC1Chairman;
     this.HeadOfHousehold    = updatedContact.HeadOfHousehold;
     this.HCW                = updatedContact.HCW;
     this.HCWFacility        = updatedContact.HCWFacility;
     this.Team               = updatedContact.Team;
     this.IsCase             = updatedContact.IsCase;
     this.OtherNames         = updatedContact.OtherNames;
     this.RecordId           = updatedContact.RecordId;
     this.SubCounty          = updatedContact.SubCounty;
     this.Surname            = updatedContact.Surname;
     this.ContactCDCID       = updatedContact.ContactCDCID;
     this.ContactStateID     = updatedContact.ContactStateID;
     this.PublicHealthAction = updatedContact.PublicHealthAction;
     this.UniqueKey          = updatedContact.UniqueKey;
     this.IsActive           = updatedContact.IsActive;
     this.Phone              = updatedContact.Phone;
     this.RiskLevel          = updatedContact.RiskLevel;
     this.Village            = updatedContact.Village;
     this.Country            = updatedContact.Country;
     this.Parish             = updatedContact.Parish;
     this.HCW                = updatedContact.HCW;
     this.ContactHCWPosition = updatedContact.ContactHCWPosition;
     this.HCWFacility        = updatedContact.HCWFacility;
     this.ContactHCWDistrict = updatedContact.ContactHCWDistrict;
     this.ContactHCWSC       = updatedContact.ContactHCWSC;
     this.ContactHCWVillage  = updatedContact.ContactHCWVillage;
 }
 public DailyCheckViewModel(ContactViewModel contactVM, CaseViewModel caseVM)
 {
     DailyCheck           = new DailyCheck();
     DailyCheck.CaseVM    = caseVM;
     DailyCheck.ContactVM = contactVM;
 }
Esempio n. 3
0
 public ContactViewModel(ContactViewModel newContact)
 {
     UpdateContact(newContact);
 }
Esempio n. 4
0
        //public XElement Serialize()
        //{
        //    XElement recordElement =
        //        new XElement("Record",
        //            new XAttribute("GlobalRecordId", this.RecordId.ToString()));

        //    if(this.FirstSaveTime.HasValue)
        //    {
        //        recordElement.Add(new XAttribute("FirstSaveTime", this.FirstSaveTime.Value.Ticks.ToString()));
        //    }
        //    else
        //    {
        //        recordElement.Add(new XAttribute("FirstSaveTime", String.Empty));
        //    }

        //    string age = String.Empty;
        //    if (Age.HasValue)
        //    {
        //        age = Age.Value.ToString();
        //    }

        //    object ageUnit = String.Empty;
        //    if (AgeUnit.HasValue)
        //    {
        //        ageUnit = (int)AgeUnit.Value;
        //    }

        //    recordElement.Add(
        //        new XElement("Surname", this.Surname),
        //        new XElement("OtherNames", this.OtherNames),
        //        new XElement("Age", age),
        //        new XElement("AgeUnit", ageUnit),
        //        new XElement("Gender", this.Gender),
        //        new XElement("RiskLevel", this.RiskLevel),
        //        new XElement("HeadOfHousehold", this.HeadOfHousehold),
        //        new XElement("Village", this.Village),
        //        new XElement("SubCounty", this.SubCounty),
        //        new XElement("District", this.District),
        //        new XElement("LC1Chairman", this.LC1Chairman),
        //        new XElement("Phone", this.Phone),
        //        new XElement("HCW", this.HCW),
        //        new XElement("HCWFacility", this.HCWFacility),
        //        new XElement("FinalOutcome", this.FinalOutcome)
        //        );

        //    return recordElement;
        //}
        #endregion // Methods

        #region Deprecated / old code
        ///// <summary>
        ///// Updates a contact record in the database with the corresponding in-memory dataset
        ///// </summary>
        ///// <param name="contactVM">The contact to update</param>
        //private void UpdateContactInDatabase(Contact contact)
        //{
        //    string contactBaseTableName = ContactForm.TableName;
        //    IDbDriver db = this.Database;

        //    DateTime dtNow = DateTime.Now;
        //    dtNow = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, dtNow.Minute, dtNow.Second, 0);

        //    string userID = CurrentUser;

        //    Query updateQuery = db.CreateQuery("UPDATE [" + contactBaseTableName + "] SET " +
        //        "[LastSaveLogonName] = @LastSaveLogonName, " +
        //        "[LastSaveTime] = @LastSaveTime " +
        //        "WHERE [GlobalRecordId] = @GlobalRecordId");
        //    updateQuery.Parameters.Add(new QueryParameter("@LastSaveLogonName", DbType.String, userID));
        //    updateQuery.Parameters.Add(new QueryParameter("@LastSaveTime", DbType.DateTime, dtNow));
        //    updateQuery.Parameters.Add(new QueryParameter("@GlobalRecordId", DbType.String, contact.RecordId));

        //    int rows = db.ExecuteNonQuery(updateQuery);

        //    if (rows == 0)
        //    {
        //        throw new InvalidOperationException("Warning: Could not update data for this contact.");
        //    }

        //    string queryGender = String.Empty;

        //    if (contact.Gender == Core.Enums.Gender.Male) { queryGender = "1"; }
        //    else if (contact.Gender == Core.Enums.Gender.Female) { queryGender = "2"; }

        //    string queryHCW = String.Empty;

        //    if (contact.HCW == Properties.Resources.Yes) { queryHCW = "1"; }
        //    else if (contact.HCW == Properties.Resources.No) { queryHCW = "2"; }

        //    updateQuery = db.CreateQuery("UPDATE [" + ContactForm.Pages[0].TableName + "] SET " +
        //        "[ContactSurname] = @Surname, " +
        //        "[ContactOtherNames] = @OtherNames, " +
        //        "[ContactGender] = @Gender, " +
        //        "[ContactAge] = @Age, " +
        //        "[ContactAgeUnit] = @AgeUnit, " +
        //        "[ContactHeadHouse] = @HeadHouse, " +
        //        "[ContactVillage] = @VillageRes, " +
        //        "[ContactDistrict] = @DistrictRes, " +
        //        "[ContactSC] = @SCRes, " +
        //        "[LC1] = @LC1, " +
        //        "[ContactPhone] = @PhoneNumber, " +
        //        "[ContactHCW] = @HCW, " +
        //        "[ContactHCWFacility] = @HCWFacility, " +
        //        "[RiskLevel] = @RiskLevel, " +
        //        "[FinalOutcome] = @FinalOutcome " +

        //        "WHERE [GlobalRecordId] = @GlobalRecordId");

        //    updateQuery.Parameters.Add(new QueryParameter("@Surname", DbType.String, contact.Surname));
        //    updateQuery.Parameters.Add(new QueryParameter("@OtherNames", DbType.String, contact.OtherNames));
        //    updateQuery.Parameters.Add(new QueryParameter("@Gender", DbType.String, queryGender));
        //    if (contact.AgeYears.HasValue)
        //    {
        //        updateQuery.Parameters.Add(new QueryParameter("@Age", DbType.Double, contact.AgeYears));
        //    }
        //    else
        //    {
        //        updateQuery.Parameters.Add(new QueryParameter("@Age", DbType.Double, DBNull.Value));
        //    }

        //    if (contact.AgeUnit.HasValue)
        //    {
        //        updateQuery.Parameters.Add(new QueryParameter("@AgeUnit", DbType.String, contact.AgeUnit));
        //    }
        //    else
        //    {
        //        updateQuery.Parameters.Add(new QueryParameter("@AgeUnit", DbType.String, String.Empty));
        //    }

        //    updateQuery.Parameters.Add(new QueryParameter("@ContactHeadHouse", DbType.String, contact.HeadOfHousehold));
        //    updateQuery.Parameters.Add(new QueryParameter("@VillageRes", DbType.String, contact.Village));
        //    updateQuery.Parameters.Add(new QueryParameter("@DistrictRes", DbType.String, contact.District));
        //    updateQuery.Parameters.Add(new QueryParameter("@SCRes", DbType.String, contact.SubCounty));
        //    updateQuery.Parameters.Add(new QueryParameter("@LC1", DbType.String, contact.LC1Chairman));
        //    updateQuery.Parameters.Add(new QueryParameter("@PhoneNumber", DbType.String, contact.Phone));
        //    updateQuery.Parameters.Add(new QueryParameter("@ContactHCW", DbType.String, queryHCW));
        //    updateQuery.Parameters.Add(new QueryParameter("@ContactHCWFacility", DbType.String, contact.HCWFacility));
        //    updateQuery.Parameters.Add(new QueryParameter("@ContactRiskLevel", DbType.String, contact.RiskLevel));
        //    updateQuery.Parameters.Add(new QueryParameter("@ContactFinalOutcome", DbType.String, contact.FinalOutcome));
        //    updateQuery.Parameters.Add(new QueryParameter("@GlobalRecordId", DbType.String, contact.RecordId));

        //    db.ExecuteNonQuery(updateQuery);
        //}

        ///// <summary>
        ///// Inserts a new contact record in the database with the corresponding in-memory dataset
        ///// </summary>
        ///// <param name="contactVM">The contact to add</param>
        //private void InsertContactInDatabase(Contact contact)
        //{
        //    string contactFormTableName = ContactForm.TableName;

        //    DateTime dtNow = DateTime.Now;
        //    dtNow = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, dtNow.Minute, dtNow.Second, 0);

        //    string userID = CurrentUser;

        //    contact.FirstSaveTime = dtNow;

        //    Query insertQuery = Database.CreateQuery("INSERT INTO [" + ContactForm.TableName + "] (GlobalRecordId, RECSTATUS, FirstSaveLogonName, LastSaveLogonName, FirstSaveTime, LastSaveTime) VALUES (" +
        //        "@GlobalRecordId, @RECSTATUS, @FirstSaveLogonName, @LastSaveLogonName, @FirstSaveTime, @LastSaveTime)");
        //    insertQuery.Parameters.Add(new QueryParameter("@GlobalRecordId", DbType.String, contact.RecordId));
        //    insertQuery.Parameters.Add(new QueryParameter("@RECSTATUS", DbType.Byte, 1));
        //    insertQuery.Parameters.Add(new QueryParameter("@FirstSaveLogonName", DbType.String, userID));
        //    insertQuery.Parameters.Add(new QueryParameter("@LastSaveLogonName", DbType.String, userID));
        //    insertQuery.Parameters.Add(new QueryParameter("@FirstSaveTime", DbType.DateTime, dtNow));
        //    insertQuery.Parameters.Add(new QueryParameter("@LastSaveTime", DbType.DateTime, dtNow));
        //    Database.ExecuteNonQuery(insertQuery);

        //    string queryGender = String.Empty;

        //    if (contact.Gender == Core.Enums.Gender.Male) { queryGender = "1"; }
        //    else if (contact.Gender == Core.Enums.Gender.Female) { queryGender = "2"; }

        //    string queryHCW = String.Empty;

        //    if (contact.HCW == Properties.Resources.Yes) { queryHCW = "1"; }
        //    else if (contact.HCW == Properties.Resources.No) { queryHCW = "2"; }

        //    foreach (Epi.Page page in ContactForm.Pages)
        //    {
        //        // contact form has only one page, so we can get away with this code for the time being.
        //        insertQuery = Database.CreateQuery("INSERT INTO [" + page.TableName + "] (GlobalRecordId, ContactSurname, ContactOtherNames, " +
        //            "ContactGender, ContactAge, ContactAgeUnit, ContactHeadHouse, ContactVillage, ContactDistrict, ContactSC, LC1, " +
        //            "ContactPhone, ContactHCW, ContactHCWFacility, RiskLevel, FinalOutcome) VALUES (" +
        //        "@GlobalRecordId, @ContactSurname, @ContactOtherNames, @ContactGender, @ContactAge, @ContactAgeUnit, @ContactHeadHouse, @ContactVillage, @ContactDistrict, " +
        //        "@ContactSC, @LC1, @ContactPhone, @ContactHCW, @ContactHCWFacility, @ContactRiskLevel, @ContactFinalOutcome)");
        //        insertQuery.Parameters.Add(new QueryParameter("@GlobalRecordId", DbType.String, contact.RecordId));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactSurname", DbType.String, contact.Surname));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactOtherNames", DbType.String, contact.OtherNames));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactGender", DbType.String, queryGender));
        //        if (contact.AgeYears.HasValue)
        //        {
        //            insertQuery.Parameters.Add(new QueryParameter("@ContactAge", DbType.String, contact.AgeYears));
        //        }
        //        else
        //        {
        //            insertQuery.Parameters.Add(new QueryParameter("@ContactAge", DbType.String, DBNull.Value));
        //        }
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactAgeUnit", DbType.String, contact.AgeUnit));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactHeadHouse", DbType.String, contact.HeadOfHousehold));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactVillage", DbType.String, contact.Village));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactDistrict", DbType.String, contact.District));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactSC", DbType.String, contact.SubCounty));
        //        insertQuery.Parameters.Add(new QueryParameter("@LC1", DbType.String, contact.LC1Chairman));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactPhone", DbType.String, contact.Phone));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactHCW", DbType.String, queryHCW));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactHCWFacility", DbType.String, contact.HCWFacility));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactRiskLevel", DbType.String, contact.RiskLevel));
        //        insertQuery.Parameters.Add(new QueryParameter("@ContactFinalOutcome", DbType.String, contact.FinalOutcome));
        //        Database.ExecuteNonQuery(insertQuery);
        //    }
        //}
        #endregion // Deprecated / old code

        #region Commands
        void UpdateExecute(ContactViewModel updatedContact)
        {
            UpdateContact(updatedContact);
        }
Esempio n. 5
0
 public FollowUpVisitViewModel(int day, DateTime date, ContactViewModel contactVM)
 {
     this.FollowUpVisit = new FollowUpVisit(day, date);
     _contactVM         = contactVM;
 }
Esempio n. 6
0
 public FollowUpWindowViewModel(DateTime lastContactDate, ContactViewModel contactVM, CaseViewModel caseVM)
 {
     this.FollowUpWindow = new FollowUpWindow(lastContactDate, contactVM, caseVM);
 }
 public ContactConversionInfo(ContactViewModel contactVM, ContactFinalOutcome finalOutcome)
 {
     this.ContactVM    = contactVM;
     this.FinalOutcome = finalOutcome;
 }