Пример #1
0
        /// <summary>
        /// creates a submission set containing a document.
        /// The metadata consists of
        ///   (O) Description
        ///   Slots
        ///     (R2)authorInstitution
        ///     (O) authorPerson
        ///     (R2)authorRole
        ///     (R2)authorSpecialty
        ///     (R) submissionTime
        ///   ExternalIdentifiers
        ///     (R) patientId
        ///     (R) sourceId
        ///     (R) uniqueId
        ///   Classifications
        ///     (R) contentTypeCode
        /// </summary>
        /// <param name="sor">SubmitObjectsRequest corresponding to the new document submission</param>
        public static void AddSubmissionSet(SubmitObjectsRequest sor, DocumentPackage package, string submissionSetId)
        {
            string[] eiScheme = new string[3];
            string[] eiValue = new string[3];
            string[] eiName = new string[3];
            string[] eiId = new string[3];
            string[] eiRegistryObject = new string[3];
            eiScheme[0] = GlobalValues.XDSSubmissionSet_patientIdUUID;
            eiScheme[1] = GlobalValues.XDSSubmissionSet_sourceIdUUID;
            eiScheme[2] = GlobalValues.XDSSubmissionSet_uniqueIdUUID;
            eiValue[0] = package.PatientId.ToCx();  //patID  //TODO change these OIDS
            eiValue[1] = package.SourceId; // "1.3.6.1.4.1.21367.2005.3.11";
            eiValue[2] = package.UniqueId; // "1.3.6.1.4.1.21367.2005.3.11.14"

            eiName[0] = "XDSSubmissionSet.patientId";
            eiName[1] = "XDSSubmissionSet.sourceId";
            eiName[2] = "XDSSubmissionSet.uniqueId";

            eiId[0] = "eiId101";
            eiId[1] = "eiId102";
            eiId[2] = "eiId103";

            eiRegistryObject[0] = submissionSetId;
            eiRegistryObject[1] = submissionSetId;
            eiRegistryObject[2] = submissionSetId;

            SlotType[] slots = new SlotType[2];
            string[] values = new string[1];
            values[0] = Extensions.ToHL7Date(DateTime.Now);
            //HL7Time(XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc));
            slots[0] = new SlotType(SlotNameType.submissionTime, values);

            values = new string[package.IntendedRecipients.Count];
            for (int i = 0; i < package.IntendedRecipients.Count; i++)
            {
                values[i] = package.IntendedRecipients[i].ToXONXCNXTN();
            }
            slots[0] = new SlotType(SlotNameType.intendedRecipient, values);

            // Create Classification for authorPerson and authorInstitution:
            // <rim:Classification id="cl08" classificationScheme="urn:uuid:a7058bb9-b4e4-4307-ba5b-e3f0ab85e12d" classifiedObject="SubmissionSet01">
            //    <rim:Slot name="authorPerson">
            //        <rim:ValueList>
            //            <rim:Value>Sherry Dopplemeyer</rim:Value>
            //        </rim:ValueList>
            //    </rim:Slot>
            //    <rim:Slot name="authorInstitution">
            //        <rim:ValueList>
            //            <rim:Value>Cleveland Clinic</rim:Value>
            //            <rim:Value>Berea Community</rim:Value>
            //        </rim:ValueList>
            //    </rim:Slot>
            // </rim:Classification>

            ClassificationType[] classifications = new ClassificationType[2];
            SlotType[] cSlots = new SlotType[3];
            values = new string[package.Author.Institutions.Count];
            for (int i = 0; i < package.Author.Institutions.Count; i++)
            {
                values[i] = package.Author.Institutions[i].ToXON();
            }
            cSlots[0] = new SlotType(SlotNameType.authorInstitution, values);

            values = new string[1];
            values[0] = package.Author.Person.ToXCN();
            cSlots[1] = new SlotType(SlotNameType.authorPerson, values);

            values = new string[1];
            values[0] = package.Author.TelecomAddress.ToXTN();
            cSlots[2] = new SlotType(SlotNameType.authorTelecom, values);

            classifications[0] = new ClassificationType(GlobalValues.XDSSubmissionSet_authorDescriptionUUID,
                submissionSetId, null, null, "cl01", null, cSlots);

            cSlots = new SlotType[1];
            values = new string[1];
            values[0] = package.ContentTypeCode.Scheme;
            cSlots[0] = new SlotType(SlotNameType.codingScheme, values);
            classifications[1] = new ClassificationType(GlobalValues.XDSSubmissionSet_contentTypeCodeUUID,
                submissionSetId, null, package.ContentTypeCode.Code, "cl02",
                package.ContentTypeCode.Label, cSlots);

            sor.RegistryObjectList.RegistryPackages.Add(
                new RegistryPackageType(submissionSetId, "Submission Set",
                eiScheme, eiValue, eiId, eiRegistryObject, eiName, slots, classifications, RegistryEntryStatus.Submitted));
        }
		/// <summary>
		/// Builds the serializable Document Set Submission Request.
		/// </summary>
		/// <returns>Nothing</returns>
		public void BuildMetaData(string submissionSetId, DocumentPackage package)
		{
            // Add the set of document to the list of documents in this set.
            _documents = new List<Document>(package.Documents.Count);
            foreach (DocumentMetadata doc in package.Documents)
            {

                // Add each document to the list of documents in this set.
                _documents.Add(new Document(XD_PANDR_DEFAULT_DOCUMENTID + (package.Documents.IndexOf(doc) + 1), doc.DocumentBytes));
            }

			_submitObjectsRequest = new SubmitObjectsRequest();
			//Add ExtrinsicObject for each document
            foreach (DocumentMetadata doc in package.Documents)
            {
                _submitObjectsRequest.RegistryObjectList.ExtrinsicObjects.Add(StaticHelpers.CreateDocumentEntry(doc, XD_PANDR_DEFAULT_DOCUMENTID + (package.Documents.IndexOf(doc) + 1)));
            }


			//Add SubmissionSet Registry Package
			StaticHelpers.AddSubmissionSet(_submitObjectsRequest, package, submissionSetId);
			_submitObjectsRequest.RegistryObjectList.Classifications.Add(
				new ClassificationType(null, XD_PANDR_DEFAULT_SUBMISSIONSETID,
				GlobalValues.XDSSubmissionSetUUID, null, "class01", null, null));

            SlotType[] slots = null;
            string[] slotVals = null;
			// Associate Documens and Submission Set
            foreach (Document doc in _documents)
            {
                slots = new SlotType[1];
                slotVals = new string[1];
                slotVals[0] = "Original";
                slots[0] = new SlotType(SlotNameType.SubmissionSetStatus, slotVals);

                _submitObjectsRequest.RegistryObjectList.Associations.Add(new AssociationType(AssociationKind.HasMember,
                XD_PANDR_DEFAULT_SUBMISSIONSETID, doc.Id , "assoc" + doc.Id , slots));

            }
			/*

			try
			{
				XmlSerializer ser = new XmlSerializer(typeof(SubmitObjectsRequest));
				MemoryStream ms = new MemoryStream();
				ser.Serialize(ms, _submitObjectsRequest);
				ms.Position = 0;
				StreamReader requestReader = new StreamReader(ms);
				string requestString = requestReader.ReadToEnd();
				ms.Close();

				// This removes <?xml version="1.0"?> from the top of the requestString
				if (requestString.StartsWith("<?")) requestString = requestString.Substring(requestString.IndexOf("?>") + 2).Trim();

				this.XmlMessage.LoadXml(requestString);
			}
			catch (Exception ex)
			{
				Console.WriteLine("Exception caught while serializing XML: " + ex.Message);
			}
             */
		}