Exemplo n.º 1
0
 internal SubjectSurvey( Int16 surveyYear, SurveySource source )
 {
     SurveyYear = surveyYear;
     SurveySource = source;
 }
Exemplo n.º 2
0
        private void AddRow( Int32 subjectTag, SurveySource surveySource, Int16 surveyYear, DateTime? surveyDate, float? ageSelfReport, float? calculatedAge )
        {
            lock ( _ds.tblSurveyTime ) {
                LinksDataSet.tblSurveyTimeRow drNew = _ds.tblSurveyTime.NewtblSurveyTimeRow();
                drNew.SubjectTag = subjectTag;
                drNew.SurveySource = (byte)surveySource;
                drNew.SurveyYear = surveyYear;

                if ( surveyDate.HasValue ) drNew.SurveyDate = surveyDate.Value;
                else drNew.SetSurveyDateNull();

                if ( ageSelfReport.HasValue ) drNew.AgeSelfReportYears = ageSelfReport.Value;
                else drNew.SetAgeSelfReportYearsNull();

                if ( calculatedAge.HasValue ) drNew.AgeCalculateYears = calculatedAge.Value;
                else drNew.SetAgeCalculateYearsNull();

                _ds.tblSurveyTime.AddtblSurveyTimeRow(drNew);
            }
        }
Exemplo n.º 3
0
        private static DateTime? DetermineSurveyDate( SurveySource source, Int16 surveyYear, LinksDataSet.tblSubjectRow drSubject, LinksDataSet.tblResponseDataTable dtResponseForSubject )
        {
            Int32 maxRecords = 1;
            Int32? monthReported = Retrieve.ResponseNullPossible(surveyYear, Item.InterviewDateMonth, source, drSubject.SubjectTag, maxRecords, dtResponseForSubject);
            if ( !monthReported.HasValue || monthReported < 0 ) return null;

            Int32? dayReported = Retrieve.ResponseNullPossible(surveyYear, Item.InterviewDateDay, source, drSubject.SubjectTag, maxRecords, dtResponseForSubject);
            if ( !dayReported.HasValue || dayReported < 0 ) dayReported = Constants.DefaultDayOfMonth;
            //Trace.Fail("There shouldn't be any interview date that missing a day, but not a month.");

            Int32? yearReported = Retrieve.ResponseNullPossible(surveyYear, Item.InterviewDateYear, source, drSubject.SubjectTag, maxRecords, dtResponseForSubject);
            if ( yearReported < 0 || !yearReported.HasValue ) yearReported = surveyYear;
            else if ( 0 < yearReported && yearReported < 1900 ) yearReported = 1900 + yearReported;//The 1993 Gen1 Survey reports it like '93', instead of '1993'.

            dayReported = Math.Min(28, dayReported.Value);
            DateTime interviewDate = new DateTime(yearReported.Value, monthReported.Value, dayReported.Value);
            return interviewDate;
        }
Exemplo n.º 4
0
 private static float? DetermineAgeSelfReport( SurveySource source, Int32 subjectTag, LinksDataSet.tblResponseDataTable dtResponse, Int16 surveyYear )
 {
     float? ageSelfReportYears;
     switch ( source ) {
         case SurveySource.Gen2C:
             ageSelfReportYears = AgeSelfReportMonths(subjectTag, surveyYear, dtResponse);
             break;
         case SurveySource.Gen1:
         case SurveySource.Gen2YA:
             ageSelfReportYears = AgeSelfReportYears(subjectTag, surveyYear, dtResponse);
             break;
         default: throw new ArgumentOutOfRangeException("source", source, "The SurveySource value was not recognized.");
     }
     if ( ageSelfReportYears.HasValue && ageSelfReportYears.Value < 0 ) throw new InvalidOperationException(string.Format("The self-reported age for SubjectTag {0} is {1}.", subjectTag, ageSelfReportYears.Value));
     return ageSelfReportYears;
 }
 private static YesNo DetermineBiodadInHH( SurveySource source, Int16 surveyYear, Int32 subjectTag, LinksDataSet.tblResponseDataTable dtExtended )
 {
     Item item;
     switch ( source ) {
         case SurveySource.Gen2C: item = Item.Gen2CFatherLivingInHH; break;
         //case SurveySource.Gen2YA: item = Item.Gen2CFathedrLivingInHH;
         default: throw new ArgumentOutOfRangeException("source", source, "Only (nonmissing) Gen2 sources are allowed.");
     }
     Int32? response = Retrieve.ResponseNullPossible(surveyYear, item, subjectTag, dtExtended);
     if ( !response.HasValue )
         return YesNo.ValidSkipOrNoInterviewOrNotInSurvey;
     EnumResponsesGen2.FatherOfGen2LiveInHH codedResponse = (EnumResponsesGen2.FatherOfGen2LiveInHH)response.Value;
     switch ( codedResponse ) {
         case EnumResponsesGen2.FatherOfGen2LiveInHH.InvalidSkip: return YesNo.Refusal;
         case EnumResponsesGen2.FatherOfGen2LiveInHH.DoNotKnow: return YesNo.DoNotKnow;
         case EnumResponsesGen2.FatherOfGen2LiveInHH.Refusal: return YesNo.Refusal;
         case EnumResponsesGen2.FatherOfGen2LiveInHH.No: return YesNo.No;
         case EnumResponsesGen2.FatherOfGen2LiveInHH.Yes: return YesNo.Yes;
         default: throw new InvalidOperationException("The response " + codedResponse + " was not recognized.");
     }
 }
Exemplo n.º 6
0
 internal static Int32? ResponseNullPossible( Int16 surveyYear, Item itemID, SurveySource surveySource, Int32 subjectTag, Int32 maxRows, LinksDataSet.tblResponseDataTable dt )
 {
     if ( dt == null ) throw new ArgumentNullException("dt");
     string select = string.Format("{0}={1} AND {2}={3} AND {4}={5} AND {6}={7}",
         subjectTag, dt.SubjectTagColumn.ColumnName,
         (Int16)itemID, dt.ItemColumn.ColumnName,
         surveyYear, dt.SurveyYearColumn.ColumnName,
         (byte)surveySource, dt.SurveySourceColumn.ColumnName);
     LinksDataSet.tblResponseRow[] drsRaw = (LinksDataSet.tblResponseRow[])dt.Select(select);
     Trace.Assert(drsRaw.Length <= maxRows, "At most, " + maxRows + " row(s) should be returned.");
     if ( drsRaw.Length == 0 )
         return null;
     else
         return drsRaw[0].Value;
 }