Example #1
0
        public XDSResponse PatientRegistryRecordRevised(XmlDocument xmlDocRequest)
        {
            XDSResponse xdsResponse    = null;
            XmlDocument xmlDocResponse = null;
            PatientIdentityFeedRecord patientIdentityFeedRecord = null;
            string eventOutcomeIndicator = "0";
            string resultCode            = "CA";
            int    patientID             = 0;

            xdsResponse = new XDSResponse();
            xdsResponse.AtnaParameters = new StringDictionary();

            patientIdentityFeedRecord = GetPatient(xmlDocRequest);

            if (patientIdentityFeedRecord != null)
            {
                if (IsPatientUIDExists(patientIdentityFeedRecord.PatientUID, out patientID))
                {
                    resultCode            = "CA";
                    eventOutcomeIndicator = "0";
                }
                else
                {
                    resultCode            = "CE";
                    eventOutcomeIndicator = "8";
                }
            }

            xmlDocResponse = ConstructPatientAcknowledgementMessage(xmlDocRequest, resultCode, "PATIENT-REVISED-ACK");
            xdsResponse.XDSResponseDocument = xmlDocResponse;

            xdsResponse.AtnaParameters.Add("$EventIdentification.EventOutcomeIndicator$", eventOutcomeIndicator);

            return(xdsResponse);
        }
Example #2
0
        Message IDocumentRegistry.PatientRegistryRecordAdded(System.ServiceModel.Channels.Message input)
        {
            Message     msgResult      = null;
            XmlDocument xmlDocRequest  = null;
            XmlDocument xmlDocResponse = null;
            XDSResponse xdsResponse    = null;
            PatientIdentityFeedLogic  patientFeedLogic          = null;
            PatientIdentityFeedRecord patientIdentityFeedRecord = null;
            RegistryLogic             objRegistryLogic          = null;
            string eventOutcomeIndicator = "0";
            string sourceUserID          = string.Empty;
            string destinationUserID     = string.Empty;

            try
            {
                //ATNA Event - Active Participant Source UserID
                sourceUserID = GetSourceUserID();

                //ATNA Event - Active Participant Destination UserID
                destinationUserID = GetDestinationUserID();

                xmlDocRequest = new XmlDocument();
                xmlDocRequest.Load(input.GetReaderAtBodyContents());

                objRegistryLogic = new RegistryLogic();
                patientFeedLogic = new PatientIdentityFeedLogic();
                xdsResponse      = patientFeedLogic.PatientRegistryRecordAdded(xmlDocRequest);

                xmlDocResponse        = xdsResponse.XDSResponseDocument;
                eventOutcomeIndicator = xdsResponse.AtnaParameters["$EventIdentification.EventOutcomeIndicator$"];

                //ATNA
                patientIdentityFeedRecord = patientFeedLogic.GetPatient(xmlDocRequest);
            }
            catch (Exception)
            {
                //Log Error
                objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, DateTime.Now);

                //ATNA Event Failure Indicator
                eventOutcomeIndicator = "8";
            }

            //Log ATNA Event
            if (patientIdentityFeedRecord != null)
            {
                patientFeedLogic.ProcessPatientRecordAddATNAEvent(patientIdentityFeedRecord.PatientUID, sourceUserID, destinationUserID, eventOutcomeIndicator);
            }

            //Create Soap Message
            msgResult = Message.CreateMessage(input.Headers.MessageVersion, GlobalValues.CONST_ACTION_PatientIdentityFeedResponse, new XmlNodeReader(xmlDocResponse));


            return(msgResult);
        }
Example #3
0
        public XDSResponse PatientRegistryRecordAdded(XmlDocument xmlDocPatientRecordAddedRequest)
        {
            int         patientID             = 0;
            string      resultCode            = "CA";
            string      eventOutcomeIndicator = "0";
            XDSResponse xdsResponse           = null;
            XmlDocument xmlDocResponse        = null;
            PatientIdentityFeedRecord     patientIdentityFeedRecord = null;
            PatientIdentityFeedDataAccess patientDataAccess         = new PatientIdentityFeedDataAccess();

            try
            {
                xdsResponse = new XDSResponse();
                xdsResponse.AtnaParameters = new StringDictionary();

                //Parse Xml & get Patient UID
                patientIdentityFeedRecord = GetPatient(xmlDocPatientRecordAddedRequest);

                //Insert/Feed Patient UID in the DB
                //First validates whether the patient uid already exists in the DB
                if (IsPatientUIDExists(patientIdentityFeedRecord.PatientUID, out patientID))
                {
                    patientIdentityFeedRecord.ResultCode = PatientIdentityFeedResultCode.PATIENT_ALREADY_EXISTS;
                    resultCode = "CE";
                }
                else
                {
                    patientIdentityFeedRecord = patientDataAccess.PatientRegistryRecordAdded(patientIdentityFeedRecord);
                }
            }
            catch (Exception ex)
            {
                patientIdentityFeedRecord.ResultCode = PatientIdentityFeedResultCode.FAILURE;
                resultCode            = "CE";
                eventOutcomeIndicator = "8";
            }

            //Generate Response Message
            //xmlDocResponse = ConstructPatientRegistryRecordAddedResponse(patientIdentityFeedRecord);
            if (patientIdentityFeedRecord.ResultCode != PatientIdentityFeedResultCode.SUCCESS)
            {
                resultCode            = "CE";
                eventOutcomeIndicator = "8";
            }

            xmlDocResponse = ConstructPatientAcknowledgementMessage(xmlDocPatientRecordAddedRequest, resultCode, "PATIENT-ADD-ACK");

            xdsResponse.XDSResponseDocument = xmlDocResponse;
            xdsResponse.AtnaParameters.Add("$EventIdentification.EventOutcomeIndicator$", eventOutcomeIndicator);

            return(xdsResponse);
        }
Example #4
0
        private PatientDuplicateEntry GetPatientDuplicateEntry(XmlDocument xmlDocRequest)
        {
            XmlElement  root = null;
            XmlNodeList nodeListOldPatient = null;
            XmlNode     nodeNewPatient     = null;
            PatientIdentityFeedRecord oldPatientFeedRecord  = null;
            PatientDuplicateEntry     patientDuplicateEntry = new PatientDuplicateEntry();

            root = xmlDocRequest.DocumentElement;

            //New Patient UID
            nodeNewPatient = root.SelectSingleNode(".//*[local-name()='controlActProcess']/*[local-name()='subject']/*[local-name()='registrationEvent']/*[local-name()='subject1']/*[local-name()='patient']/*[local-name()=\"id\"]");

            if (nodeNewPatient == null)
            {
                throw new Exception("Node registrationEvent does not exists in the request xml.");
            }

            //New Patient
            patientDuplicateEntry.NewPatient           = new PatientIdentityFeedRecord();
            patientDuplicateEntry.NewPatient.Root      = nodeNewPatient.Attributes["root"].Value;
            patientDuplicateEntry.NewPatient.Extension = nodeNewPatient.Attributes["extension"].Value;

            //Old Patient UIDs
            //Commented below line of code during Europe Connect-a-thon
            //Bug Fixed: Sample xml used during development was incorrect, the new xpath expression gets the patient id
            //nodeListOldPatient = root.SelectNodes(".//*[local-name()=\"replacementOf\"]/*[local-name()=\"priorRegistration\"]/*[local-name()=\"subject2\"]/*[local-name()=\"priorRegisteredRole\"]/*[local-name()=\"id\"]");
            nodeListOldPatient = root.SelectNodes(".//*[local-name()=\"replacementOf\"]/*[local-name()=\"priorRegistration\"]/*[local-name()=\"id\"]");

            if (nodeListOldPatient == null)
            {
                throw new Exception("Node replacementOf or one it's child nodes does not exists in the request xml.");
            }

            //Old Patients
            patientDuplicateEntry.OldPatientList = new List <PatientIdentityFeedRecord>();

            for (int oldPatientCount = 0; oldPatientCount < nodeListOldPatient.Count; oldPatientCount++)
            {
                oldPatientFeedRecord           = new PatientIdentityFeedRecord();
                oldPatientFeedRecord.Root      = nodeListOldPatient[oldPatientCount].Attributes["root"].Value;
                oldPatientFeedRecord.Extension = nodeListOldPatient[oldPatientCount].Attributes["extension"].Value;

                patientDuplicateEntry.OldPatientList.Add(oldPatientFeedRecord);
            }


            return(patientDuplicateEntry);
        }
Example #5
0
        public PatientIdentityFeedRecord GetPatient(XmlDocument xmlDocPatientRecordAddedRequest)
        {
            PatientIdentityFeedRecord patientIdentityFeedRecord = null;
            XmlElement root          = null;
            XmlNode    patientIdNode = null;


            root          = xmlDocPatientRecordAddedRequest.DocumentElement;
            patientIdNode = root.SelectSingleNode(".//*[local-name()='controlActProcess']/*[local-name()='subject']/*[local-name()='registrationEvent']/*[local-name()='subject1']/*[local-name()='patient']/*[local-name()=\"id\"]");

            if (patientIdNode == null)
            {
                throw new Exception("Element 'id' is missing in the request xml.");
            }

            if (patientIdNode != null)
            {
                patientIdentityFeedRecord           = new PatientIdentityFeedRecord();
                patientIdentityFeedRecord.Root      = patientIdNode.Attributes["root"].Value;
                patientIdentityFeedRecord.Extension = patientIdNode.Attributes["extension"].Value;
            }

            return(patientIdentityFeedRecord);
        }
        public PatientIdentityFeedRecord PatientRegistryRecordAdded(PatientIdentityFeedRecord patientIdentityFeedRecord)
        {
            int numberOfRowsAffected = 0;

            Database  dbIHEDB   = DatabaseFactory.CreateDatabase(CONST_CONNECTIONSTRING_NAME);
            DbCommand dbCommand = dbIHEDB.GetStoredProcCommand("usp_patient_insert");

            dbIHEDB.AddInParameter(dbCommand, "patientUID", DbType.String, patientIdentityFeedRecord.PatientUID);
            dbIHEDB.AddOutParameter(dbCommand, "patientID", DbType.Int32, int.MaxValue);

            numberOfRowsAffected = dbIHEDB.ExecuteNonQuery(dbCommand);

            if (numberOfRowsAffected == 0)
            {
                patientIdentityFeedRecord.ResultCode = PatientIdentityFeedResultCode.FAILURE;
            }
            else
            {
                patientIdentityFeedRecord.PatientID  = (Int32)dbIHEDB.GetParameterValue(dbCommand, "patientID");
                patientIdentityFeedRecord.ResultCode = PatientIdentityFeedResultCode.SUCCESS;
            }

            return(patientIdentityFeedRecord);
        }
Example #7
0
        public void ProcessPatientDuplicatesResolvedATNAEvent(PatientDuplicateEntry patientDuplicateEntry, string sourceUserID, string destinationUserID, string eventOutcomeIndicator)
        {
            try
            {
                //Log ATNA - Repository Event
                ATNALogic atnaLogic = new ATNALogic();
                AuditMessageConfiguration auditMsgConfig  = null;
                PatientIdentityFeedRecord patientNotFound = null;

                if (patientDuplicateEntry != null)
                {
                    patientNotFound = patientDuplicateEntry.OldPatientList.Find(
                        delegate(PatientIdentityFeedRecord patFeedRecord)
                    {
                        if (patFeedRecord.ResultCode == PatientIdentityFeedResultCode.PATIENT_NOT_FOUND)
                        {
                            return(true);
                        }

                        return(false);
                    }
                        );

                    if (patientNotFound != null)
                    {
                        eventOutcomeIndicator = "8";
                    }
                }

                //Patient Add/Update ATNA Event
                auditMsgConfig = atnaLogic.GetAuditMessageConfigurationDetails("REGISTRY-PATIENT-RECORD-DUPLICATES-RESOLVED-UPDATE-ITI-44");

                if (auditMsgConfig != null)
                {
                    auditMsgConfig = ATNALogic.SetParameterValue(auditMsgConfig, "$XDSPatientID$", patientDuplicateEntry.NewPatient.PatientUID);

                    //$ActiveParticipant.UserID.Source$
                    auditMsgConfig = ATNALogic.SetParameterValue(auditMsgConfig, "$ActiveParticipant.UserID.Source$", sourceUserID);

                    //$ActiveParticipant.UserID.Destination$
                    auditMsgConfig = ATNALogic.SetParameterValue(auditMsgConfig, "$ActiveParticipant.UserID.Destination$", destinationUserID);

                    //New Patient Add Event
                    atnaLogic.ProcessEvent(auditMsgConfig, ATNAEvent.XDSREGISTRY_TYPE, eventOutcomeIndicator, ATNAEvent.UDP_TAG_APPNAME_REGISTRY);
                }

                //Patient Delete ATNA Event
                auditMsgConfig = atnaLogic.GetAuditMessageConfigurationDetails("REGISTRY-PATIENT-RECORD-DUPLICATES-RESOLVED-DELETE-ITI-44");

                if ((auditMsgConfig != null) && (patientNotFound == null))
                {
                    //ATNA Log for all the deleted patient uids
                    for (int oldPatientCount = 0; oldPatientCount < patientDuplicateEntry.OldPatientList.Count; oldPatientCount++)
                    {
                        auditMsgConfig = ATNALogic.SetParameterValue(auditMsgConfig, "$XDSPatientID$", patientDuplicateEntry.OldPatientList[oldPatientCount].PatientUID);

                        //$ActiveParticipant.UserID.Destination$
                        auditMsgConfig = ATNALogic.SetParameterValue(auditMsgConfig, "$ActiveParticipant.UserID.Destination$", ATNAEvent.XDSREGISTRY_SERVICE_ADDRESS);

                        //Old Patient Delete Event
                        atnaLogic.ProcessEvent(auditMsgConfig, ATNAEvent.XDSREGISTRY_TYPE, "0", ATNAEvent.UDP_TAG_APPNAME_REGISTRY);
                    }
                }
            }
            catch
            {
                //Oops...ATNA event failed...probably UDP failure....can't afford to stop XDSRepository service sorry :(
            }
        }