Ejemplo n.º 1
0
        /// <summary>
        /// Update an AD
        /// </summary>
        private void UpdateAD(SVC.Core.DataTypes.AddressSet addr, NHapi.Model.V231.Datatype.XAD ad)
        {
            var dec = new DeComponentUtility()
            {
                Context = this.Context
            };

            ad.AddressType.Value = dec.ReverseLookup(ComponentUtility.AD_USE_MAP, addr.Use);

            foreach (var cmp in addr.Parts)
            {
                string cmpStr = dec.ReverseLookup(ComponentUtility.AD_MAP, cmp.PartType);
                if (String.IsNullOrEmpty(cmpStr))
                {
                    continue;
                }
                int cmpNo = int.Parse(cmpStr);
                if (ad.Components[cmpNo - 1] is AbstractPrimitive)
                {
                    (ad.Components[cmpNo - 1] as AbstractPrimitive).Value = cmp.AddressValue;
                }
                else if (ad.Components[cmpNo - 1] is NHapi.Model.V25.Datatype.SAD)
                {
                    (ad.Components[cmpNo - 1] as NHapi.Model.V25.Datatype.SAD).StreetOrMailingAddress.Value = cmp.AddressValue;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update an XPN
        /// </summary>
        private void UpdateXPN(SVC.Core.DataTypes.NameSet name, NHapi.Model.V231.Datatype.XPN xpn)
        {
            var dec = new DeComponentUtility()
            {
                Context = this.Context
            };

            xpn.NameTypeCode.Value = dec.ReverseLookup(ComponentUtility.XPN_USE_MAP, name.Use);

            // IF SEAGULL!!! NOOO!!!! Hopefully nobody finds this thing
            foreach (var cmp in name.Parts)
            {
                string cmpStr = dec.ReverseLookup(ComponentUtility.XPN_MAP, cmp.Type);
                int    cmpNo  = int.Parse(cmpStr);

                if (xpn.Components[cmpNo - 1] is AbstractPrimitive)
                {
                    if (cmp.Type == NamePart.NamePartType.Given && (!String.IsNullOrEmpty((xpn.Components[cmpNo - 1] as AbstractPrimitive).Value)))// given is taken so use other segment
                    {
                        if (!String.IsNullOrEmpty(xpn.MiddleInitialOrName.Value))
                        {
                            xpn.MiddleInitialOrName.Value += " ";
                        }
                        xpn.MiddleInitialOrName.Value += cmp.Value;
                    }
                    else
                    {
                        (xpn.Components[cmpNo - 1] as AbstractPrimitive).Value = cmp.Value;
                    }
                }
                else if (xpn.Components[cmpNo - 1] is NHapi.Model.V231.Datatype.FN)
                {
                    var fn = xpn.Components[cmpNo - 1] as NHapi.Model.V231.Datatype.FN;
                    if (!String.IsNullOrEmpty(fn.FamilyName.Value))
                    {
                        fn.FamilyName.Value += "-";
                    }
                    fn.FamilyName.Value += cmp.Value;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update the PID
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="pid"></param>
        private void UpdatePID(Person subject, PID pid, ISystemConfigurationService config)
        {
            var dec = new DeComponentUtility();

            // Alternate identifiers
            if (subject.AlternateIdentifiers != null)
            {
                //subject.AlternateIdentifiers.RemoveAll(ii => !this.Target.NotificationDomain.Exists(o => o.Domain.Equals(ii.Domain)));
                List <String> alreadyAdded = new List <string>();
                foreach (var altId in subject.AlternateIdentifiers)
                {
                    String idS = String.Format("{0}^{1}", altId.Domain, altId.Identifier);
                    if (!alreadyAdded.Contains(idS))
                    {
                        var id = pid.GetPatientIdentifierList(pid.PatientIdentifierListRepetitionsUsed);
                        this.UpdateCX(altId, id, config);
                        alreadyAdded.Add(idS);
                    }
                }
            }

            // Populate Names
            pid.GetPatientName(0).FamilyName.Surname.Value = " ";
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the PID
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="pid"></param>
        private void UpdatePID(Person subject, PID pid, ISystemConfigurationService config)
        {
            var dec = new DeComponentUtility();

            // Alternate identifiers
            if (subject.AlternateIdentifiers != null)
            {
                if (!this.Target.NotificationDomain.Any(o => o.Domain == "*"))
                {
                    subject.AlternateIdentifiers.RemoveAll(ii => !this.Target.NotificationDomain.Exists(o => o.Domain.Equals(ii.Domain)));
                }
                List <String> alreadyAdded = new List <string>();
                foreach (var altId in subject.AlternateIdentifiers)
                {
                    String idS = String.Format("{0}^{1}", altId.Domain, altId.Identifier);
                    if (!alreadyAdded.Contains(idS))
                    {
                        var id = pid.GetPatientIdentifierList(pid.PatientIdentifierListRepetitionsUsed);
                        this.UpdateCX(altId, id, config);
                        alreadyAdded.Add(idS);
                    }
                }
            }


            // Populate Names
            if (subject.Names != null)
            {
                foreach (var name in subject.Names)
                {
                    var xpn = pid.GetPatientName(pid.PatientNameRepetitionsUsed);
                    this.UpdateXPN(name, xpn);
                }
            }

            // Birth time
            if (subject.BirthTime != null)
            {
                MARC.Everest.DataTypes.TS ts = new Everest.DataTypes.TS(subject.BirthTime.Value, dec.ReverseLookup(ComponentUtility.TS_PREC_MAP, subject.BirthTime.Precision));
                pid.DateTimeOfBirth.TimeOfAnEvent.Value = MARC.Everest.Connectors.Util.ToWireFormat(ts);
            }

            // Admin Sex
            if (subject.GenderCode != null)
            {
                pid.Sex.Value = subject.GenderCode;
            }

            // Address
            if (subject.Addresses != null)
            {
                foreach (var addr in subject.Addresses)
                {
                    var ad = pid.GetPatientAddress(pid.PatientAddressRepetitionsUsed);
                    this.UpdateAD(addr, ad);
                }
            }

            // Death
            if (subject.DeceasedTime != null)
            {
                pid.PatientDeathIndicator.Value = "Y";
                MARC.Everest.DataTypes.TS ts = new Everest.DataTypes.TS(subject.DeceasedTime.Value, dec.ReverseLookup(ComponentUtility.TS_PREC_MAP, subject.DeceasedTime.Precision));
                pid.PatientDeathDateAndTime.TimeOfAnEvent.Value = MARC.Everest.Connectors.Util.ToWireFormat(ts);
            }

            // MB Order
            if (subject.BirthOrder.HasValue)
            {
                pid.MultipleBirthIndicator.Value = "Y";
                pid.BirthOrder.Value             = subject.BirthOrder.ToString();
            }

            // Citizenship
            if (subject.Citizenship != null)
            {
                foreach (var cit in subject.Citizenship)
                {
                    if (cit.Status == SVC.Core.ComponentModel.Components.StatusType.Active)
                    {
                        var c = pid.GetCitizenship(pid.CitizenshipRepetitionsUsed);
                        this.UpdateCE(new CodeValue(cit.CountryCode, config.OidRegistrar.GetOid("ISO3166-1").Oid), c);
                    }
                }
            }

            // Language
            if (subject.Language != null)
            {
                foreach (var lang in subject.Language)
                {
                    if (lang.Type == LanguageType.Fluency)
                    {
                        this.UpdateCE(new CodeValue(lang.Language, config.OidRegistrar.GetOid("ISO639-1").Oid), pid.PrimaryLanguage);
                        break;
                    }
                }
            }

            // Mothers name
            var relations = subject.FindAllComponents(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.RepresentitiveOf);

            foreach (var r in relations)
            {
                if (r is MARC.HI.EHRS.SVC.Core.ComponentModel.Components.PersonalRelationship)
                {
                    var psn = r as MARC.HI.EHRS.SVC.Core.ComponentModel.Components.PersonalRelationship;
                    if (psn.RelationshipKind != "MTH")
                    {
                        continue;
                    }

                    if (psn.AlternateIdentifiers != null)
                    {
                        foreach (var altid in psn.AlternateIdentifiers)
                        {
                            var id = pid.GetMotherSIdentifier(pid.MotherSIdentifierRepetitionsUsed);
                            UpdateCX(altid, id, config);
                        }
                    }
                    if (psn.LegalName != null)
                    {
                        UpdateXPN(psn.LegalName, pid.GetMotherSMaidenName(0));
                    }
                    break;
                }
            }

            // Telecom addresses
            //if(subject.TelecomAddresses != null)
            //    foreach (var tel in subject.TelecomAddresses)
            //        if (tel.Use == "HP" && tel.Value.StartsWith("tel"))
            //            MessageUtil.XTNFromTel((MARC.Everest.DataTypes.TEL)tel.Value, pid.GetPhoneNumberHome(pid.PhoneNumberHomeRepetitionsUsed));
            //        else if (tel.Use == "HP")
            //            pid.GetPhoneNumberHome(pid.PhoneNumberHomeRepetitionsUsed).EmailAddress.Value = tel.Value;
            //        else if (tel.Use == "WP" && tel.Value.StartsWith("tel"))
            //            MessageUtil.XTNFromTel((MARC.Everest.DataTypes.TEL)tel.Value, pid.GetPhoneNumberBusiness(pid.PhoneNumberBusinessRepetitionsUsed));
            //        else if (tel.Use == "WP")
            //            pid.GetPhoneNumberBusiness(pid.PhoneNumberBusinessRepetitionsUsed).EmailAddress.Value = tel.Value;
        }