Message IDocumentRepository.ProvideAndRegisterDocumentSet(Message msgRequest) { Message msgResponse = null; XmlDocument xmlDocRequest = null; XmlDocument xmlDocResponse = null; XmlNode nodeRegistryError = null; string errorCode = null; RepositoryLogic repositoryLogic = null; StringDictionary stringDictionary = null; string eventOutcomeIndicator = "0"; string submissionSetUniqueID = string.Empty; string sourceUserID = string.Empty; string destinationUserID = string.Empty; try { repositoryLogic = new RepositoryLogic(); objDocumentRepositoryLog = new DocumentRepositoryLog(); objDocumentRepositoryLog.StartTime = DateTime.Now; objDocumentRepositoryLog.RequesterIdentity = Environment.UserName; //ATNA Event Source & Destination UserID sourceUserID = GetSourceUserID(); destinationUserID = GetDestinationUserID(); //Request XmlDocument xmlDocRequest = new XmlDocument(); xmlDocRequest.Load(msgRequest.GetReaderAtBodyContents()); //Process Message will Construct Response for Register Transaction Set-B //Recieves a message from Provide and register document set B(With no errors from Repositrory) xmlDocResponse = ProcessProvideAndRegisterDocumentSet(xmlDocRequest, msgRequest.Headers.MessageVersion, out stringDictionary); //ATNA Event eventOutcomeIndicator = stringDictionary["$EventIdentification.EventOutcomeIndicator$"]; } catch (ServerTooBusyException serverTooBusyException) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSRepositoryTooBusyException, GlobalValues.CONST_ERROR_CODE_XDSRepositoryTooBusyException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); nodeRegistryError = xmlDocResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); errorCode = nodeRegistryError.Attributes["errorCode"].Value; if (errorCode != null) { repositoryLogic.LogRolledBackData(objDocumentRepositoryLog, errorCode); } //ATNA EVENT LOG eventOutcomeIndicator = "8"; } catch (TimeoutException timeoutException) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_TimeOut, GlobalValues.CONST_ERROR_CODE_TimeOut, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); nodeRegistryError = xmlDocResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); errorCode = nodeRegistryError.Attributes["errorCode"].Value; if (errorCode != null) { repositoryLogic.LogRolledBackData(objDocumentRepositoryLog, errorCode); } //ATNA EVENT LOG eventOutcomeIndicator = "8"; } catch (System.ServiceModel.Security.SecurityAccessDeniedException AuthorizationException) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSAuthorizationException, GlobalValues.CONST_ERROR_CODE_XDSAuthorizationException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); nodeRegistryError = xmlDocResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); errorCode = nodeRegistryError.Attributes["errorCode"].Value; if (errorCode != null) { repositoryLogic.LogRolledBackData(objDocumentRepositoryLog, errorCode); } //ATNA EVENT LOG eventOutcomeIndicator = "8"; } catch (OutOfMemoryException RepositoryOutOfResources) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSRepositoryOutOfResources, GlobalValues.CONST_ERROR_CODE_XDSRepositoryOutOfResources, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); nodeRegistryError = xmlDocResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); errorCode = nodeRegistryError.Attributes["errorCode"].Value; if (errorCode != null) { repositoryLogic.LogRolledBackData(objDocumentRepositoryLog, errorCode); } //ATNA EVENT LOG eventOutcomeIndicator = "8"; } catch (Exception ex) { if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentMetadata) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "XDSDocumentEntry document exists in metadata with no corresponding metatdata", GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentMetadata, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentAttachment) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "XDSDocumentEntry exists in metadata with no corresponding attached document", GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentAttachment, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSInvalidRequest) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "XDSInvalidRequest - DcoumentId is not unique.", GlobalValues.CONST_ERROR_CODE_XDSInvalidRequest, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "Error occurred in Parsing the Metadata.", GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSRegistryNotAvailable) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "Repository was unable to access the Registry.", GlobalValues.CONST_ERROR_CODE_XDSRegistryNotAvailable, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSRepositoryError, GlobalValues.CONST_ERROR_CODE_XDSRepositoryError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } nodeRegistryError = xmlDocResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); errorCode = nodeRegistryError.Attributes["errorCode"].Value; if (errorCode != null) { repositoryLogic.LogRolledBackData(objDocumentRepositoryLog, errorCode); } //ATNA EVENT LOG eventOutcomeIndicator = "8"; } //ATNA EVENT LOG submissionSetUniqueID = stringDictionary["$SubmissionSet.UniqueID$"]; //REPOSITORY-RDS-EXPORT-ITI-42 repositoryLogic.ProcessRegisterDocumentSetATNAEvent(submissionSetUniqueID, sourceUserID, destinationUserID, eventOutcomeIndicator); //REPOSITORY-P-AND-R-IMPORT-ITI-41 repositoryLogic.ProcessProvideAndRegisterATNAEvent(submissionSetUniqueID, sourceUserID, destinationUserID, eventOutcomeIndicator); msgResponse = Message.CreateMessage(msgRequest.Headers.MessageVersion, GlobalValues.CONST_ACTION_ProvideAndRegisterDocumentSet_bResponse, new XmlNodeReader(xmlDocResponse)); return(msgResponse); }
Message IDocumentRegistry.RegisterDocumentSet(Message input) { XDSResponse xdsResponse = null; Message msgResponse = null; XmlDocument xmlDocRequest = null;; XmlDocument xmlDocResponse = null; XmlNode nodeRegistryError = null; RegistryLogic objRegistryLogic = null; DateTime dtStart = DateTime.Now; string eventOutcomeIndicator = "0"; string submissionSetUniqueID = string.Empty; 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(); //Request XmlDocument xmlDocRequest = new XmlDocument(); xmlDocRequest.Load(input.GetReaderAtBodyContents()); // objRegistryLogic = new RegistryLogic(); xdsResponse = objRegistryLogic.RegisterDocumentSet(xmlDocRequest); xmlDocResponse = xdsResponse.XDSResponseDocument; //Failure nodeRegistryError = xmlDocResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); if (nodeRegistryError != null) { eventOutcomeIndicator = "8"; objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, dtStart); } ////Failure //if ((xdsResponse.XDSErrorList != null) && (xdsResponse.XDSErrorList.Count > 0)) //{ // eventOutcomeIndicator = "8"; //} //if ((xdsResponse.XDSErrorList == null) || (xdsResponse.XDSErrorList.Count == 0)) //{ //} //else //{ // xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "Internal Registry Error", "RegistryInternalError", GlobalValues.CONST_SEVERITY_TYPE_ERROR, "Registry"); // objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, dtStart); // //ATNA Event Outcome Indicator // eventOutcomeIndicator = "8"; //} } catch (System.ServiceModel.ServerTooBusyException serverTooBusyException) { xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, serverTooBusyException.Message, GlobalValues.CONST_REGISTRYERROR_CODE_XDSRegistryTooBusyException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, dtStart); //ATNA Event Outcome Indicator eventOutcomeIndicator = "8"; } catch (TimeoutException timeoutException) { xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, timeoutException.Message, GlobalValues.CONST_ERROR_CODE_TimeOut, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, dtStart); //ATNA Event Outcome Indicator eventOutcomeIndicator = "8"; } catch (System.ServiceModel.Security.SecurityAccessDeniedException AuthorizationException) { xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, AuthorizationException.Message, GlobalValues.CONST_ERROR_CODE_XDSAuthorizationException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, dtStart); //ATNA Event Outcome Indicator eventOutcomeIndicator = "8"; } catch (Exception) { //ATNA Event Outcome Indicator eventOutcomeIndicator = "8"; xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_REGISTRYERROR_CODE_XDSRegistryError, GlobalValues.CONST_REGISTRYERROR_CODE_XDSRegistryError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, dtStart); } //------------------------------------------------------------------------------------ //ATNA Event if (xdsResponse.AtnaParameters.ContainsKey("$SubmissionSet.UniqueID$")) { submissionSetUniqueID = xdsResponse.AtnaParameters["$SubmissionSet.UniqueID$"]; } objRegistryLogic.ProcessRegisterDocumentSetATNAEvent(submissionSetUniqueID, sourceUserID, destinationUserID, eventOutcomeIndicator); //------------------------------------------------------------------------------------ msgResponse = Message.CreateMessage(input.Headers.MessageVersion, GlobalValues.CONST_ACTION_RegisterDocumentSetResponse, new XmlNodeReader(xmlDocResponse)); return(msgResponse); }
Message IReceiveDocumentSet.ReceiveDocumentSet(Message msgRequest) { Message msgResponse = null; XmlDocument xmlDocRequest = null; XmlDocument xmlDocResponse = null; XDSHelper xdsHelper = null; StringDictionary stringDictionary = null; ILogger logger = Log.For(this); try { xdsHelper = new XDSHelper(); //Request XmlDocument xmlDocRequest = new XmlDocument(); xmlDocRequest.Load(msgRequest.GetReaderAtBodyContents()); //Process Message will Construct Response for Register Transaction Set-B //Recieves a message from Provide and register document set B(With no errors from Repository) // changes for PnR - register document set async xmlDocResponse = ProcessReceiveDocumentSet(xmlDocRequest, msgRequest.Headers.MessageId, msgRequest.Headers.MessageVersion, out stringDictionary); } catch (ServerTooBusyException serverTooBusyException) { logger.Error("Server Too Busy", serverTooBusyException); //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSRepositoryTooBusyException, GlobalValues.CONST_ERROR_CODE_XDSRepositoryTooBusyException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } catch (TimeoutException timeoutException) { logger.Error("Timeout processing document submission", timeoutException); //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_TimeOut, GlobalValues.CONST_ERROR_CODE_TimeOut, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } catch (System.ServiceModel.Security.SecurityAccessDeniedException AuthorizationException) { logger.Error("Access denied", AuthorizationException); //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSAuthorizationException, GlobalValues.CONST_ERROR_CODE_XDSAuthorizationException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } catch (OutOfMemoryException RepositoryOutOfResources) { logger.Error("Out of resources", RepositoryOutOfResources); //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSRepositoryOutOfResources, GlobalValues.CONST_ERROR_CODE_XDSRepositoryOutOfResources, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } catch (Exception ex) { if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentMetadata) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "XDSDocumentEntry document exists in metadata with no corresponding metatdata", GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentMetadata, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentAttachment) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "XDSDocumentEntry exists in metadata with no corresponding attached document", GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentAttachment, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSInvalidRequest) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "XDSInvalidRequest - DcoumentId is not unique.", GlobalValues.CONST_ERROR_CODE_XDSInvalidRequest, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "Error occurred in Parsing the Metadata.", GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else if (ex.Message == GlobalValues.CONST_ERROR_CODE_XDSRegistryNotAvailable) { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "Repository was unable to access the Registry.", GlobalValues.CONST_ERROR_CODE_XDSRegistryNotAvailable, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } else { //Construct Error Response xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, GlobalValues.CONST_ERROR_CODE_XDSRepositoryError, GlobalValues.CONST_ERROR_CODE_XDSRepositoryError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); } } try { msgResponse = Message.CreateMessage(msgRequest.Headers.MessageVersion, GlobalValues.CONST_ACTION_ProvideAndRegisterDocumentSet_bResponse, new XmlNodeReader(xmlDocResponse)); return(msgResponse); } catch (Exception ex) { logger.Error("Unexpected error", ex); throw ex; } }
Message IDocumentRegistry.RegistryStoredQuery(System.ServiceModel.Channels.Message input) { Message msgResult = null; XmlDocument xmlDocRequest = null; XmlDocument xmlDocResponse = new XmlDocument(); XmlElement rootElement = xmlDocResponse.DocumentElement; RegistryStoredQueryLogic objStoredQueryLogic = null; RegistryLogic objRegistryLogic = null; StringDictionary atnaParameterValues = null; string eventOutcomeIndicator = "0"; string sourceUserID = string.Empty; string destinationUserID = string.Empty; string xdsPatientID = string.Empty; string adHocQueryElementXml = string.Empty; try { objRegistryLogic = new RegistryLogic(); objStoredQueryLogic = new RegistryStoredQueryLogic(); //ATNA Event - Active Participant Source UserID sourceUserID = GetSourceUserID(); //ATNA Event - Active Participant Destination UserID destinationUserID = GetDestinationUserID(); xmlDocRequest = new XmlDocument(); xmlDocRequest.Load(input.GetReaderAtBodyContents()); xmlDocResponse = objStoredQueryLogic.RegistryStoredQuery(xmlDocRequest, out atnaParameterValues); //ATNA eventOutcomeIndicator = atnaParameterValues["$EventIdentification.EventOutcomeIndicator$"]; xdsPatientID = atnaParameterValues["$XDSPatient$"]; adHocQueryElementXml = atnaParameterValues["$AdhocQuery$"]; } catch (System.ServiceModel.ServerTooBusyException serverTooBusyException) { objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, DateTime.Now); xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, serverTooBusyException.Message, GlobalValues.CONST_REGISTRYERROR_CODE_XDSRegistryTooBusyException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); //ATNA Event Failure Indicator eventOutcomeIndicator = "8"; } catch (TimeoutException timeoutException) { objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, DateTime.Now); xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, timeoutException.Message, GlobalValues.CONST_ERROR_CODE_TimeOut, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); //ATNA Event Failure Indicator eventOutcomeIndicator = "8"; } catch (System.ServiceModel.Security.SecurityAccessDeniedException AuthorizationException) { objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, DateTime.Now); xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, AuthorizationException.Message, GlobalValues.CONST_ERROR_CODE_XDSAuthorizationException, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); //ATNA Event Failure Indicator eventOutcomeIndicator = "8"; } catch (Exception ex) { //Log Error Message objRegistryLogic.CreateRegistryLogEntry(xmlDocRequest.InnerXml, GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, DateTime.Now); //Generate Error Message xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, ex.Message, GlobalValues.CONST_REGISTRYERROR_CODE_XDSRegistryError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); //ATNA Event Failure Indicator eventOutcomeIndicator = "8"; } //Record ATNA Event objStoredQueryLogic.ProcessRegistryStoredQueryATNAEvent(sourceUserID, destinationUserID, xdsPatientID, adHocQueryElementXml, eventOutcomeIndicator); //Create Soap Message msgResult = Message.CreateMessage(input.Headers.MessageVersion, GlobalValues.CONST_ACTION_RegistryStoredQueryResponse, new XmlNodeReader(xmlDocResponse)); return(msgResult); }
// Process the document set that was received private XmlDocument ProcessReceiveDocumentSet(XmlDocument xmlDocRequest, System.Xml.UniqueId messageID, MessageVersion msgVersion, out StringDictionary atnaParameterValues) { XmlDocument xmlDocResponse = null; Message registryMessage = null; XmlDocument xmlDocRegistryResponse = null; XDSHelper xdsHelper = null; XmlElement eltProvideAndRegDocSet = null; XmlNodeList nodeListExtrinsicObject = null; XmlNodeList nodeListDocument = null; XmlNode nodeSubmissionSet = null; XmlNode nodeExternalIdentifier = null; List <Document> docList = null; StringBuilder sbMetaData = null; string xpathExternalIdentifierDocument = @".//*[local-name()='ExtrinsicObject'][@id='$id$']/*[local-name()='ExternalIdentifier'][@identificationScheme='$identificationScheme$']"; string xpath = null; string entryUUID = null; string uniqueID = null; string eventOutcomeIndicator = "0"; atnaParameterValues = new StringDictionary(); try { xdsHelper = new XDSHelper(); xpathExternalIdentifierDocument = xpathExternalIdentifierDocument.Replace("$identificationScheme$", GlobalValues.XDSDocumentEntry_uniqueIdUUID); // get the root document element of the XML Document which is metadata plus MTOM encoded documents eltProvideAndRegDocSet = xmlDocRequest.DocumentElement; // get the list of nodes from the root document element that are ExtrinsicObject nodes nodeListExtrinsicObject = eltProvideAndRegDocSet.SelectNodes(".//*[local-name()='ExtrinsicObject']"); // get the list of nodes from the root doc element that are Document nodes nodeListDocument = eltProvideAndRegDocSet.SelectNodes(".//*[local-name()='Document']"); // get the Submission Set node from the document element nodeSubmissionSet = eltProvideAndRegDocSet.SelectSingleNode("//*[local-name()='SubmitObjectsRequest']/*[local-name()=\"RegistryObjectList\"]/*[local-name()='RegistryPackage']/*[local-name()='ExternalIdentifier'][@identificationScheme='urn:uuid:96fdda7c-d067-4183-912e-bf5ee74998a8']/@value"); //Proceed further only if any ExtrinsicObject Exists(with attachments) if (nodeListExtrinsicObject == null) { throw new Exception(); } // check each ExtrinsicObject node document Id and match with attached documents to see if anything is missing if (xdsHelper.IsMissingDocumentAttachment(eltProvideAndRegDocSet)) { throw new Exception(GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentAttachment); } //if (repositoryLogic.IsMissingDocumentMetadata(nodeListExtrinsicObject, eltProvideAndRegDocSet)) if (xdsHelper.IsMissingDocumentMetadata(eltProvideAndRegDocSet)) { throw new Exception(GlobalValues.CONST_ERROR_CODE_XDSMissingDocumentMetadata); } // does each document have a unique id? if (xdsHelper.IsDuplicateUniqueID(eltProvideAndRegDocSet)) { throw new Exception(GlobalValues.CONST_ERROR_CODE_XDSRepositoryDuplicateUniqueIdInMessage); } // if we have metadata for each document and actual documents (this seems redundant with the earlier checks - refactor?) if (nodeListExtrinsicObject.Count > 0 && eltProvideAndRegDocSet.SelectNodes(@"//*[local-name()='Document']").Count > 0) { //No document OR Metadata is Missing // DocumentEntry object should be replaced by the new Document/Message object we want to use to carry this info // lstDocumentEntry = new List<DocumentEntry>(); sbMetaData = new StringBuilder(); int loopCount = 0; foreach (XmlNode node in nodeListExtrinsicObject) { // DocumentEntry objDocumentEntry = new DocumentEntry(); if (node.Attributes["mimeType"].Value == string.Empty) { throw new Exception(GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError); } // objDocumentEntry.MimeType = node.Attributes["mimeType"].Value; entryUUID = node.Attributes["id"].Value; xpath = xpathExternalIdentifierDocument.Replace("$id$", node.Attributes["id"].Value); nodeExternalIdentifier = eltProvideAndRegDocSet.SelectSingleNode(xpath); uniqueID = nodeExternalIdentifier.Attributes["value"].Value; if (string.IsNullOrEmpty(uniqueID)) { throw new Exception(GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError); } // objDocumentEntry.EntryUUID = entryUUID; // objDocumentEntry.UniqueID = uniqueID; // objDocumentEntry.Hash = xdsHelper.GetHashCode(xmlDocRequest, entryUUID); // objDocumentEntry.Content = xdsHelper.GetDocumentContentStream(xmlDocRequest, entryUUID); // objDocumentEntry.Size = (int)objDocumentEntry.Content.Length; // CP-ITI-419 string docHash = string.Empty; XmlNode docHashNode = eltProvideAndRegDocSet.SelectNodes("//*[local-name()='SubmitObjectsRequest']/*[local-name()=\"RegistryObjectList\"]/*[local-name()='ExtrinsicObject']/*[local-name()='Slot'][@name='hash']")[loopCount]; if (docHashNode != null) { docHash = docHashNode.InnerText.Trim(); } string docSize = string.Empty; XmlNode docSizeNode = eltProvideAndRegDocSet.SelectNodes("//*[local-name()='SubmitObjectsRequest']/*[local-name()=\"RegistryObjectList\"]/*[local-name()='ExtrinsicObject']/*[local-name()='Slot'][@name='size']")[loopCount]; if (docSizeNode != null) { docSize = docSizeNode.InnerText.Trim(); } // if ((!string.IsNullOrEmpty(docHash) && (docHash.ToLower() != objDocumentEntry.Hash.ToLower())) // || (!string.IsNullOrEmpty(docSize) && (Convert.ToInt32(docSize) != objDocumentEntry.Size))) { xmlDocResponse = CommonUtility.ConstructRegistryErrorResponse(GlobalValues.CONST_RESPONSE_STATUS_TYPE_FAILURE, string.Empty, "Size/hash of document not matching Metadata.", GlobalValues.CONST_ERROR_CODE_XDSRepositoryMetadataError, GlobalValues.CONST_SEVERITY_TYPE_ERROR, string.Empty); eventOutcomeIndicator = "8"; atnaParameterValues.Add("$EventIdentification.EventOutcomeIndicator$", eventOutcomeIndicator); return(xmlDocResponse); } // CP-ITI-419 // lstDocumentEntry.Add(objDocumentEntry); } } else { xmlDocRegistryResponse = new XmlDocument(); xmlDocRegistryResponse.Load(registryMessage.GetReaderAtBodyContents()); XmlNode errorList = xmlDocRegistryResponse.SelectSingleNode(@"//*[local-name()='RegistryError']"); string errorCode = null; if (errorList != null) { errorCode = errorList.Attributes["errorCode"].Value; } //Assign Registry Response to Repository Response xmlDocResponse = xmlDocRegistryResponse; } } catch { throw; } try { return(xmlDocResponse); } catch (Exception ex) { throw ex; } }