public RParentChild( LinksDataSet dsLinks, LinksDataSet.tblRelatedStructureRow drLeft ) { //ImportDataSet dsImport, , LinksDataSet.tblRelatedStructureRow drRight if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( drLeft == null ) throw new ArgumentNullException("drLeft"); if ( dsLinks.tblSubject.Count == 0 ) throw new InvalidOperationException("tblSubject must NOT be empty before assigning R values from it."); _dsLinks = dsLinks; _drLeft = drLeft; _idRelatedLeft = _drLeft.ID; _drBare1 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S1); _drBare2 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S2); Trace.Assert(_drBare1.Generation != _drBare2.Generation, "The generation should not be the same for a parent-child relationship."); _multipleBirth = MultipleBirth.No; _isMZ = Tristate.No; //For IAssignPass1 _rImplicitPass1 = RCoefficients.ParentChild; _rImplicit2004 = RCoefficients.ParentChild; _rExplicitOldestSibVersion = null; _rExplicitYoungestSibVersion = null; _rExplicitPass1 = RCoefficients.ParentChild; _rPass1 = RCoefficients.ParentChild; //For IAssignPass2 _rImplicit = RCoefficients.ParentChild; _rImplicitSubject = RCoefficients.ParentChild; _rImplicitMother = RCoefficients.ParentChild; _rExplicit = RCoefficients.ParentChild; _rFull = RCoefficients.ParentChild; _rPeek = RCoefficients.ParentChild; }
public RGen2Cousins( LinksDataSet dsLinks, LinksDataSet.tblRelatedStructureRow drLeft ) { //ImportDataSet dsImport, , LinksDataSet.tblRelatedStructureRow drRight if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( drLeft == null ) throw new ArgumentNullException("drLeft"); if ( dsLinks.tblSubject.Count == 0 ) throw new InvalidOperationException("tblSubject must NOT be empty before assigning R values from it."); _dsLinks = dsLinks; _idRelatedLeft = drLeft.ID; _drBare1 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S1); _drBare2 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S2); Trace.Assert(_drBare1.Generation == (byte)Generation.Gen2, "The generation should be Gen2."); Trace.Assert(_drBare2.Generation == (byte)Generation.Gen2, "The generation should be Gen2."); _multipleBirth = MultipleBirth.No; _isMZ = Tristate.No; LinksDataSet.tblRelatedValuesRow drValuesOfGen1Housemates = Gen1HousematesValues(_drBare1.SubjectTag, _drBare2.SubjectTag);//RelatedValues.Retrieve(_dsLinks, _path, //For IAssignPass1 if ( drValuesOfGen1Housemates.IsRImplicitPass1Null() ) _rImplicitPass1 = null; else _rImplicitPass1 = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RImplicitPass1); if ( drValuesOfGen1Housemates.IsRImplicit2004Null() ) _rImplicit2004 = null; else _rImplicit2004 = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RImplicit2004); _rExplicitOldestSibVersion = null; _rExplicitYoungestSibVersion = null; if ( drValuesOfGen1Housemates.IsRExplicitPass1Null() ) _rExplicitPass1 = null; else _rExplicitPass1 = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RExplicitPass1); if ( drValuesOfGen1Housemates.IsRPass1Null() ) _rPass1 = null; else _rPass1 = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RPass1); ; //For IAssignPass2 if ( drValuesOfGen1Housemates.IsRImplicitNull() ) _rImplicit = null; else _rImplicit = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RImplicit); if ( drValuesOfGen1Housemates.IsRImplicitSubjectNull() ) _rImplicitSubject = null; else _rImplicitSubject = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RImplicitSubject); if ( drValuesOfGen1Housemates.IsRImplicitMotherNull() ) _rImplicitMother = null; else _rImplicitMother = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RImplicitMother); if ( drValuesOfGen1Housemates.IsRExplicitNull() ) _rExplicit = null; else _rExplicit = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RExplicit); if ( drValuesOfGen1Housemates.IsRNull() ) _r= null; else _r= (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.R); if ( drValuesOfGen1Housemates.IsRFullNull() ) _rFull = null; else _rFull = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RFull); if ( drValuesOfGen1Housemates.IsRPeekNull() ) _rPeek = null; else _rPeek = (float)(RCoefficients.ParentChild * RCoefficients.ParentChild * drValuesOfGen1Housemates.RPeek); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Patient; if (dest != null) { base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (Name != null) { dest.Name = new List <Hl7.Fhir.Model.HumanName>(Name.DeepCopy()); } if (Telecom != null) { dest.Telecom = new List <Hl7.Fhir.Model.Contact>(Telecom.DeepCopy()); } if (Gender != null) { dest.Gender = (Hl7.Fhir.Model.CodeableConcept)Gender.DeepCopy(); } if (BirthDateElement != null) { dest.BirthDateElement = (Hl7.Fhir.Model.FhirDateTime)BirthDateElement.DeepCopy(); } if (Deceased != null) { dest.Deceased = (Hl7.Fhir.Model.Element)Deceased.DeepCopy(); } if (Address != null) { dest.Address = new List <Hl7.Fhir.Model.Address>(Address.DeepCopy()); } if (MaritalStatus != null) { dest.MaritalStatus = (Hl7.Fhir.Model.CodeableConcept)MaritalStatus.DeepCopy(); } if (MultipleBirth != null) { dest.MultipleBirth = (Hl7.Fhir.Model.Element)MultipleBirth.DeepCopy(); } if (Photo != null) { dest.Photo = new List <Hl7.Fhir.Model.Attachment>(Photo.DeepCopy()); } if (Contact != null) { dest.Contact = new List <Hl7.Fhir.Model.Patient.ContactComponent>(Contact.DeepCopy()); } if (Animal != null) { dest.Animal = (Hl7.Fhir.Model.Patient.AnimalComponent)Animal.DeepCopy(); } if (Communication != null) { dest.Communication = new List <Hl7.Fhir.Model.CodeableConcept>(Communication.DeepCopy()); } if (CareProvider != null) { dest.CareProvider = new List <Hl7.Fhir.Model.ResourceReference>(CareProvider.DeepCopy()); } if (ManagingOrganization != null) { dest.ManagingOrganization = (Hl7.Fhir.Model.ResourceReference)ManagingOrganization.DeepCopy(); } if (Link != null) { dest.Link = new List <Hl7.Fhir.Model.Patient.PatientLinkComponent>(Link.DeepCopy()); } if (ActiveElement != null) { dest.ActiveElement = (Hl7.Fhir.Model.FhirBoolean)ActiveElement.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
private float? _rPass1 = float.NaN; // float.NaN; #endregion Fields #region Constructors public RGen1Pass1( ImportDataSet dsImport, LinksDataSet dsLinks, LinksDataSet.tblRelatedStructureRow drLeft, LinksDataSet.tblRelatedStructureRow drRight ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( drLeft == null ) throw new ArgumentNullException("drLeft"); if ( drRight == null ) throw new ArgumentNullException("drRight"); if ( dsImport.tblLinks2004Gen1.Count == 0 ) throw new InvalidOperationException("tblLinks2004Gen1 must NOT be empty before assigning R values from it."); if ( dsLinks.tblMzManual.Count == 0 ) throw new InvalidOperationException("tblMzManual must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubject.Count == 0 ) throw new InvalidOperationException("tblSubject must NOT be empty before assigning R values from it."); if ( dsLinks.tblRosterGen1.Count == 0 ) throw new InvalidOperationException("tblRosterGen1 must NOT be empty before assigning R values from it."); if ( dsLinks.tblMarkerGen1.Count == 0 ) throw new InvalidOperationException("tblMarkerGen2 must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubjectDetails.Count == 0 ) throw new InvalidOperationException("tblSubjectDetails must NOT be empty before assigning R values from it."); _dsImport = dsImport; _dsLinks = dsLinks; _drLeft = drLeft; _drRight = drRight; _idRelatedLeft = _drLeft.ID; _idRelatedRight = _drRight.ID; _drSubjectDetails1 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S1); _drSubjectDetails2 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S2); _extendedID = _drLeft.tblSubjectRowByFK_tblRelatedStructure_tblSubject_Subject1.ExtendedID; //LinksDataSet.tblRosterGen1Row drRoster = _dsLinks.tblRosterGen1.FindByRelatedID(drLeft.ID); //Tristate rosterShareBiomom = (Tristate)drRoster.ShareBiomom; //Tristate rosterShareBiodad = (Tristate)drRoster.ShareBiodad; //if ( drRoster.IsRNull() ) _rRoster = null; //else _rRoster = (float)drRoster.R; if ( _drSubjectDetails1.BirthOrderInNls <= _drSubjectDetails2.BirthOrderInNls ) {//This is the way it usually is. Remember that twins were assigned tied birth orders _idRelatedOlderAboutYounger = _idRelatedLeft; _idRelatedYoungerAboutOlder = _idRelatedRight; } else if ( _drSubjectDetails1.BirthOrderInNls > _drSubjectDetails2.BirthOrderInNls ) { _idRelatedOlderAboutYounger = _idRelatedRight; _idRelatedYoungerAboutOlder = _idRelatedLeft; } _dtMarkersGen1 = MarkerGen1.PairRelevantMarkerRows(_idRelatedLeft, _idRelatedRight, _dsLinks, _extendedID); LinksDataSet.tblMzManualRow drMz = Retrieve.MzManualRecord(_drLeft.SubjectTag_S1, _drLeft.SubjectTag_S2, _dsLinks); if ( drMz == null ) { _multipleBirth = MultipleBirth.No; _isMZ = Tristate.No; _isRelatedInMzManual = Tristate.DoNotKnow; } else { _multipleBirth = (MultipleBirth)drMz.MultipleBirthIfSameSex; _isMZ = (Tristate)drMz.IsMz; if ( drMz.IsRelatedNull() ) _isRelatedInMzManual = Tristate.DoNotKnow; else if ( drMz.Related ) _isRelatedInMzManual = Tristate.Yes; else _isRelatedInMzManual = Tristate.No; } MarkerEvidence explicitBiomomFromOlder = ReduceShareBioparentToOne(MarkerType.ShareBiomom, ItemYears.Gen1ShareBioparent.Length, _idRelatedOlderAboutYounger); MarkerEvidence explicitBiodadFromOlder = ReduceShareBioparentToOne(MarkerType.ShareBiodad, ItemYears.Gen1ShareBioparent.Length, _idRelatedOlderAboutYounger); MarkerEvidence explicitBiomomFromYounger = ReduceShareBioparentToOne(MarkerType.ShareBiomom, ItemYears.Gen1ShareBioparent.Length, _idRelatedYoungerAboutOlder); MarkerEvidence explicitBiodadFromYounger = ReduceShareBioparentToOne(MarkerType.ShareBiodad, ItemYears.Gen1ShareBioparent.Length, _idRelatedYoungerAboutOlder); MarkerEvidence biomomInHH1979 = MarkerGen1.RetrieveParentMarkerMultiYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiomomInHH, 1979, Bioparent.Mom, _dtMarkersGen1); MarkerEvidence biodadInHH1979 = MarkerGen1.RetrieveParentMarkerMultiYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiodadInHH, 1979, Bioparent.Dad, _dtMarkersGen1); MarkerEvidence biomomDeathAge = MarkerGen1.RetrieveParentMarkerSingleYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiomomDeathAge, Bioparent.Mom, _dtMarkersGen1); MarkerEvidence biodadDeathAge = MarkerGen1.RetrieveParentMarkerSingleYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiodadDeathAge, Bioparent.Dad, _dtMarkersGen1); _explicitShareBiomomPass1 = CommonFunctions.TranslateEvidenceToTristate(explicitBiomomFromOlder, explicitBiomomFromYounger); _explicitShareBiodadPass1 = CommonFunctions.TranslateEvidenceToTristate(explicitBiodadFromOlder, explicitBiodadFromYounger); _implicitShareBiomomPass1 = ImplicitShareBioparent(inHH1979: biomomInHH1979, deathAge: biomomDeathAge); _implicitShareBiodadPass1 = ImplicitShareBioparent(inHH1979: biodadInHH1979, deathAge: biodadDeathAge); _shareBiomomPass1 = CommonFunctions.TakePriority(_explicitShareBiomomPass1, _implicitShareBiomomPass1); _shareBiodadPass1 = CommonFunctions.TakePriority(_explicitShareBiodadPass1, _implicitShareBiodadPass1); _rExplicitOldestSibVersion = CalculateRExplicitSingleSibVersion(explicitBiomomFromOlder, explicitBiodadFromOlder); _rExplicitYoungestSibVersion = CalculateRExplicitSingleSibVersion(explicitBiomomFromYounger, explicitBiodadFromYounger); _rExplicitPass1 = CommonFunctions.TranslateToR(shareBiomom: _explicitShareBiomomPass1, shareBiodad: _explicitShareBiodadPass1, mustDecide: false); _rImplicitPass1 = CommonFunctions.TranslateToR(shareBiomom: _implicitShareBiomomPass1, shareBiodad: _implicitShareBiodadPass1, mustDecide: false); _rImplicit2004 = RetrieveRImplicit2004(); _rPass1 = CalculateRFull(shareBiomom: _shareBiomomPass1, shareBiodad: _shareBiodadPass1, multiple: _multipleBirth, isMZ: _isMZ, isRelatedInMZManual: _isRelatedInMzManual, idRelated: _idRelatedLeft, dtRoster: _dsLinks.tblRosterGen1); }
public static float? CalculateRFull( Tristate shareBiomom, Tristate shareBiodad, MultipleBirth multiple, Tristate isMZ, Tristate isRelatedInMZManual, Int32 idRelated, LinksDataSet.tblRosterGen1DataTable dtRoster ) { float? rRoster = CalculateRRoster(idRelated, dtRoster); if ( isMZ == BaseAssembly.Tristate.Yes ) { return RCoefficients.MzTrue; } else if ( isRelatedInMZManual == Tristate.No ) { return RCoefficients.NotRelated; //Of the 21 Gen1 subjects in tblMZManual with Related=0, 17 ended up with R=0 (as of 11/9/2012). 1 was assigned R=.5; 3 were assigned R=NULL (which I want to override now here, looking at the DOB differences). } else if ( isMZ == BaseAssembly.Tristate.DoNotKnow && isRelatedInMZManual == Tristate.Yes ) { Trace.Assert(multiple == MultipleBirth.Twin || multiple == MultipleBirth.Trip || multiple == MultipleBirth.TwinOrTrip, "To be assigned full sib, they've got to be assigned to be a twin/trip."); return RCoefficients.MzAmbiguous; } else if ( multiple == MultipleBirth.Twin || multiple == MultipleBirth.Trip || multiple == MultipleBirth.TwinOrTrip ) { return RCoefficients.SiblingFull; } else if ( rRoster.HasValue ) { return rRoster; } else { //The implicits & explicits were already combined to get the values of shareBiomom & shareBiodad. return CommonFunctions.TranslateToR(shareBiomom: shareBiomom, shareBiodad: shareBiodad, mustDecide: false); } }
public RGen2Pass1( ImportDataSet dsImport, LinksDataSet dsLinks, LinksDataSet.tblRelatedStructureRow drLeft, LinksDataSet.tblRelatedStructureRow drRight ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( drLeft == null ) throw new ArgumentNullException("drLeft"); if ( drRight == null ) throw new ArgumentNullException("drRight"); if ( dsImport.tblLinks2004Gen2.Count == 0 ) throw new InvalidOperationException("tblLinks2004Gen2 must NOT be empty before assigning R values from it."); if ( dsLinks.tblMzManual.Count == 0 ) throw new InvalidOperationException("tblMzManual must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubject.Count == 0 ) throw new InvalidOperationException("tblSubject must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubjectDetails.Count == 0 ) throw new InvalidOperationException("tblSubjectDetails must NOT be empty before assigning R values from it."); if ( dsLinks.tblMarkerGen2.Count == 0 ) throw new InvalidOperationException("tblMarkerGen2 must NOT be empty before assigning R values from it."); _dsImport = dsImport; _dsLinks = dsLinks; _drLeft = drLeft; _drRight = drRight; _idRelatedLeft = _drLeft.ID; _idRelatedRight = _drRight.ID; _drBare1 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S1); _drBare2 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S2); _drSubjectDetails1 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S1); _drSubjectDetails2 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S2); _extendedID = _drLeft.tblSubjectRowByFK_tblRelatedStructure_tblSubject_Subject1.ExtendedID; if ( _drSubjectDetails1.BirthOrderInNls <= _drSubjectDetails2.BirthOrderInNls ) {//This is the way it usually is. Recall twins were assigned tied birth orders _idRelatedOlderAboutYounger = _idRelatedLeft; _idRelatedYoungerAboutOlder = _idRelatedRight; } else if ( _drSubjectDetails1.BirthOrderInNls > _drSubjectDetails2.BirthOrderInNls ) { _idRelatedOlderAboutYounger = _idRelatedRight; _idRelatedYoungerAboutOlder = _idRelatedLeft; } _dtMarkersGen2 = MarkerGen2.PairRelevantMarkerRows(_idRelatedLeft, _idRelatedRight, _dsLinks, _extendedID); LinksDataSet.tblMzManualRow drMzManual = Retrieve.MzManualRecord(_drBare1, _drBare2, _dsLinks); if ( drMzManual == null ) { _multipleBirth = MultipleBirth.No; _isMZ = Tristate.No; } else { _multipleBirth = (MultipleBirth)drMzManual.MultipleBirthIfSameSex; _isMZ = (Tristate)drMzManual.IsMz; } MarkerEvidence babyDaddyDeathDate = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyDeathDate, _dtMarkersGen2); MarkerEvidence babyDaddyAlive = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyAlive, _dtMarkersGen2); MarkerEvidence babyDaddyInHH = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyInHH, _dtMarkersGen2); MarkerEvidence babyDaddyLeftHHDate = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyLeftHHDate, _dtMarkersGen2); MarkerEvidence babyDaddyDistanceFromHH = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyDistanceFromHH, _dtMarkersGen2); MarkerEvidence babyDaddyAsthma = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyAsthma, _dtMarkersGen2); _rImplicitPass1 = CalculateRImplicitPass1(babyDaddyDeathDate, babyDaddyAlive, babyDaddyInHH, babyDaddyLeftHHDate, babyDaddyDistanceFromHH, babyDaddyAsthma); //_rImplicit not set; _rImplicit2004 = RetrieveRImplicit2004(); _rExplicitOldestSibVersion = CalculateRExplicitOldestSibVersion(); _rExplicitYoungestSibVersion = CalculateRExplicitYoungestSibVersion(); _rExplicitPass1 = CalculateRExplicitPass1(_isMZ, _multipleBirth); //_rExplicit not set; _rPass1 = CalculateRPass1(); //_r not set; //_rPeek not set; }
private float? CalculateRExplicitPass1( Tristate isMZ, MultipleBirth multipleBirth ) { float? rExplicitPreTwin = null; if ( !RExplicitOldestSibVersion.HasValue && !RExplicitYoungestSibVersion.HasValue ) rExplicitPreTwin = null; else if ( !RExplicitOldestSibVersion.HasValue ) rExplicitPreTwin = RExplicitYoungestSibVersion.Value; else if ( !RExplicitYoungestSibVersion.HasValue ) rExplicitPreTwin = RExplicitOldestSibVersion.Value; else if ( RExplicitOldestSibVersion.Value == RExplicitYoungestSibVersion.Value ) rExplicitPreTwin = RExplicitOldestSibVersion.Value; else if ( RExplicitOldestSibVersion.Value == RCoefficients.SiblingAmbiguous ) rExplicitPreTwin = RExplicitYoungestSibVersion.Value; else if ( RExplicitYoungestSibVersion.Value == RCoefficients.SiblingAmbiguous ) rExplicitPreTwin = RExplicitOldestSibVersion.Value; else if ( RExplicitOldestSibVersion.Value == RCoefficients.SiblingFull && RExplicitYoungestSibVersion.Value == RCoefficients.SiblingHalf ) rExplicitPreTwin = RCoefficients.SiblingAmbiguous; else if ( RExplicitYoungestSibVersion.Value == RCoefficients.SiblingFull && RExplicitOldestSibVersion.Value == RCoefficients.SiblingHalf ) rExplicitPreTwin = RCoefficients.SiblingAmbiguous; else throw new InvalidOperationException("All condition should have been caught."); return ExplicitAgreementWithTwins(isMZ, multipleBirth, rExplicitPreTwin); //return rExplicitPreTwin; }
internal static float? ExplicitAgreementWithTwins( Tristate isMz, MultipleBirth multipleBirth, float? newRExplicit ) { if ( !newRExplicit.HasValue ) return null; else if ( isMz == Tristate.Yes ) { Trace.Assert(newRExplicit >= RCoefficients.SiblingFull, "If the pair has been identified as MZ, their RExplicit should be >= .5."); return RCoefficients.MzTrue; } else if ( isMz == Tristate.DoNotKnow ) { Trace.Assert(newRExplicit >= RCoefficients.SiblingAmbiguous, "If the pair has been identified as an ambiguous MZ, their RExplicit should be >= .5."); return RCoefficients.MzAmbiguous; } else if ( multipleBirth == MultipleBirth.Trip || multipleBirth == MultipleBirth.Twin || multipleBirth == MultipleBirth.TwinOrTrip ) { Trace.Assert(newRExplicit >= RCoefficients.SiblingFull, "If the pair has been identified as Twin/Trip, their RExplicit should be >= .5."); return newRExplicit; } else { return newRExplicit; } }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Identifier != null) { Identifier.ForEach(elem => result.AddRange(elem.Validate())); } if (Name != null) { Name.ForEach(elem => result.AddRange(elem.Validate())); } if (Telecom != null) { Telecom.ForEach(elem => result.AddRange(elem.Validate())); } if (Gender != null) { result.AddRange(Gender.Validate()); } if (BirthDateElement != null) { result.AddRange(BirthDateElement.Validate()); } if (Deceased != null) { result.AddRange(Deceased.Validate()); } if (Address != null) { Address.ForEach(elem => result.AddRange(elem.Validate())); } if (MaritalStatus != null) { result.AddRange(MaritalStatus.Validate()); } if (MultipleBirth != null) { result.AddRange(MultipleBirth.Validate()); } if (Photo != null) { Photo.ForEach(elem => result.AddRange(elem.Validate())); } if (Contact != null) { Contact.ForEach(elem => result.AddRange(elem.Validate())); } if (Animal != null) { result.AddRange(Animal.Validate()); } if (Communication != null) { Communication.ForEach(elem => result.AddRange(elem.Validate())); } if (Provider != null) { result.AddRange(Provider.Validate()); } if (Link != null) { Link.ForEach(elem => result.AddRange(elem.Validate())); } if (ActiveElement != null) { result.AddRange(ActiveElement.Validate()); } return(result); }
public Patient CreateFHIRPatientProfile() { Patient pt; try { /* * * _patientFHIRProfile.NoIDHubPassword = password; * _patientFHIRProfile.NoIDHubName = patientHub; * _patientFHIRProfile.GenderChangeFlag = genderChangeFlag; * */ pt = new Patient(); BiometricsCaptured = GetBiometricsCaptured(); // Add message status New, Return or Update Meta meta = new Meta(); meta.Extension.Add(FHIRUtilities.MessageTypeExtension(NoIDStatus, NoIDType, CheckinDateTime)); meta.Extension.Add(FHIRUtilities.ClinicLocationExtension(ClinicArea, DevicePhysicalLocation)); if (FingerPrintMinutiasList.Count > 0) { meta.Extension.Add(FHIRUtilities.CaptureSummaryExtension(BiometricsCaptured, FingerPrintMinutiasList[0].DeviceName, FingerPrintMinutiasList[0].OriginalDpi, FingerPrintMinutiasList[0].OriginalHeight, FingerPrintMinutiasList[0].OriginalWidth) ); } meta.Extension.Add(FHIRUtilities.NoIDHubInfo(NoIDHubName, NoIDHubPassword)); if (GenderChangeFlag.ToLower().Contains("yes") == true || MultipleBirth.ToLower().Contains("no") == false) { meta.Extension.Add(FHIRUtilities.GenderAndTwinInfo(GenderChangeFlag, MultipleBirth)); } pt.Meta = meta; //TODO: Move fingerprint minutias to Identifier.Extension Identifier idSession = new Identifier(); idSession.System = ServerName + "/fhir/SessionID"; if (SessionID == null || SessionID.Length == 0) { NewSession(); } idSession.Value = SessionID; pt.Identifier.Add(idSession); if (BiometricExceptionMissingReason.Length > 0) { if (SecretQuestion1.Length > 0 && SecretAnswer1.Length > 0 && SecretQuestion2.Length > 0 && SecretAnswer2.Length > 0) { Identifier idBiometricException = new Identifier(); idBiometricException.System = ServerName + "/fhir/BiometricException"; idBiometricException.Value = "Biometric Exception Pathway"; Extension extBiometricException; extBiometricException = FHIRUtilities.BiometricException( BiometricExceptionMissingReason, SecretQuestion1, SecretAnswer1, SecretQuestion2, SecretAnswer2 ); idBiometricException.Extension.Add(extBiometricException); pt.Identifier.Add(idBiometricException); } { //throw an error back to the page. } } ResourceReference managingOrganization = new ResourceReference(OrganizationName, DomainName); pt.ManagingOrganization = managingOrganization; // Add patient demographics pt.Language = Language; pt.BirthDate = BirthDate; if (Gender.ToLower() == "f") { pt.Gender = AdministrativeGender.Female; } else if (Gender.ToLower() == "m") { pt.Gender = AdministrativeGender.Male; } else { pt.Gender = AdministrativeGender.Unknown; } if (!(MultipleBirth == null) && MultipleBirth.Length > 0) { if (MultipleBirth.ToLower().Substring(0, 2) == "no") { pt.MultipleBirth = new FhirString("No"); } else if (MultipleBirth.ToLower() == "yes") { pt.MultipleBirth = new FhirString("Yes"); } } // Add patient name HumanName ptName = new HumanName(); ptName.Given = new string[] { FirstName, MiddleName }; ptName.Family = LastName; pt.Name = new List <HumanName> { ptName }; if (StreetAddress.Length > 0 || City.Length > 0 || State.Length > 0 || PostalCode.Length > 0) { Address address = new Address(); // Add patient address address.Line = new string[] { StreetAddress, StreetAddress2 }; address.City = City; address.State = State; address.Country = Country; address.PostalCode = PostalCode; pt.Address.Add(address); } // Add patient contact information (phone numbers and email) // TODO: make sure email and phone are valid. // Validate phone with UI. Patient.ContactComponent contact = new Patient.ContactComponent(); bool addContact = false; if ((EmailAddress != null) && EmailAddress.Length > 0) { ContactPoint emailAddress = new ContactPoint(ContactPoint.ContactPointSystem.Email, ContactPoint.ContactPointUse.Home, EmailAddress); contact.Telecom.Add(emailAddress); addContact = true; } if ((PhoneHome != null) && PhoneHome.Length > 0) { ContactPoint phoneHome = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Home, PhoneHome); contact.Telecom.Add(phoneHome); addContact = true; } if ((PhoneCell != null) && PhoneCell.Length > 0) { ContactPoint phoneCell = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Mobile, PhoneCell); contact.Telecom.Add(phoneCell); addContact = true; } if ((PhoneWork != null) && PhoneWork.Length > 0) { ContactPoint phoneWork = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Work, PhoneWork); contact.Telecom.Add(phoneWork); addContact = true; } if (addContact) { pt.Contact.Add(contact); } //TODO: Change location of minutias in Patient FHIR profile from attached Photo.Extension to Identity.Extension foreach (FingerPrintMinutias minutias in FingerPrintMinutiasList) { Attachment attach = new Attachment(); Media fingerprintMedia = FingerPrintFHIRMedia(minutias, minutias.DeviceName, minutias.OriginalDpi, minutias.OriginalHeight, minutias.OriginalWidth); byte[] mediaBytes = FhirSerializer.SerializeToJsonBytes(fingerprintMedia, summary: SummaryType.Data); attach.Data = mediaBytes; pt.Photo.Add(attach); } } catch (Exception ex) { BaseException = new Exception("Error in PatientProfile::CreateFHIRProfile(). Failed to create a new FHIR profile: " + ex.Message); return(null); } return(pt); }