예제 #1
0
 /// <summary>
 /// Внутренний конструктор для работы фабрики
 /// </summary>
 /// <param name="delimiters">структура с разделителями</param>
 /// <param name="messageControlID"></param>
 /// <param name="accessPassword"></param>
 /// <param name="senderID"></param>
 /// <param name="senderStreetAddress"></param>
 /// <param name="reserved0"></param>
 /// <param name="senderTelephoneNumber"></param>
 /// <param name="senderCharacteristics"></param>
 /// <param name="receiverID"></param>
 /// <param name="comment"></param>
 /// <param name="processingID"></param>
 /// <param name="versionNumber"></param>
 /// <param name="messageDateTime"></param>
 internal HeaderRecord(
     Delimiters delimiters,
     string messageControlID,
     string accessPassword,
     string senderID,
     string senderStreetAddress,
     string reserved0,
     string senderTelephoneNumber,
     string senderCharacteristics,
     string receiverID,
     string comment,
     ProcessingType?processingID,
     string versionNumber,
     DateTimeField?messageDateTime)
 {
     Delimiters            = delimiters;
     MessageControlID      = messageControlID;
     AccessPassword        = accessPassword;
     SenderID              = senderID;
     SenderStreetAddress   = senderStreetAddress;
     Reserved0             = reserved0;
     SenderTelephoneNumber = senderTelephoneNumber;
     SenderCharacteristics = senderCharacteristics;
     ReceiverID            = receiverID;
     Comment         = comment;
     ProcessingID    = processingID;
     VersionNumber   = versionNumber;
     MessageDateTime = messageDateTime;
 }
예제 #2
0
        private static DateField?ParseBirthdate(ReadOnlySpan <char> input, Delimiters delimiters)
        {
            var bdField   = input.GetField(delimiters.FieldDelimiter, 8);
            var birthdate = default(DateField?);

            if (!bdField.IsEmpty)
            {
                birthdate = DateField.Parse(bdField);
            }
            return(birthdate);
        }
예제 #3
0
        public static HeaderRecord Parse(ReadOnlySpan <char> input)
        {
            if (input.Length < 5)
            {
                throw new ArgumentException("Minimal header length is 5 chars");
            }
            var recordType = RecordType.Parse(input);

            if (recordType != RecordType.MessageHeader)
            {
                throw new ArgumentException("This is not header record");
            }

            var delimiters = Delimiters.Parse(input.Slice(1, 4));

            var messageControlID      = new string(input.GetField(delimiters.FieldDelimiter, 2));
            var accessPassword        = new string(input.GetField(delimiters.FieldDelimiter, 3));
            var senderID              = new string(input.GetField(delimiters.FieldDelimiter, 4));
            var senderStreetAddress   = new string(input.GetField(delimiters.FieldDelimiter, 5));
            var reserved0             = new string(input.GetField(delimiters.FieldDelimiter, 6));
            var senderTelephoneNumber = new string(input.GetField(delimiters.FieldDelimiter, 7));
            var senderCharacteristics = new string(input.GetField(delimiters.FieldDelimiter, 8));
            var receiverID            = new string(input.GetField(delimiters.FieldDelimiter, 9));
            var comment        = new string(input.GetField(delimiters.FieldDelimiter, 10));
            var processingType = input.GetField(delimiters.FieldDelimiter, 11);
            var processingID   = processingType.IsEmpty ? default(ProcessingType?) : ProcessingType.Parse(processingType[0]);
            var versionNumber  = new string(input.GetField(delimiters.FieldDelimiter, 12));

            var msgDateTime = default(DateTimeField?);
            var msgDTField  = input.GetField(delimiters.FieldDelimiter, 13);

            if (!msgDTField.IsEmpty)
            {
                msgDateTime = DateTimeField.Parse(msgDTField);
            }


            return(new HeaderRecord(
                       delimiters,
                       messageControlID,
                       accessPassword,
                       senderID,
                       senderStreetAddress,
                       reserved0,
                       senderTelephoneNumber,
                       senderCharacteristics,
                       receiverID,
                       comment,
                       processingID,
                       versionNumber,
                       msgDateTime));
        }
예제 #4
0
        private static PatientSex?ParseSex(ReadOnlySpan <char> input, Delimiters delimiters)
        {
            var sexfield = input.GetField(delimiters.FieldDelimiter, 9);

            if (sexfield.IsEmpty)
            {
                return(null);
            }
            return(sexfield[0] switch
            {
                'M' => PatientSex.Male,
                'm' => PatientSex.Male,
                'F' => PatientSex.Female,
                'f' => PatientSex.Female,
                'U' => PatientSex.Undefined,
                'u' => PatientSex.Undefined,
                _ => throw new ArgumentException("Unknown sex")
            });
예제 #5
0
        public static PatientRecord Parse(ReadOnlySpan <char> input, Delimiters delimiters)
        {
            if (input.Length < 3)
            {
                throw new ArgumentException("Minimal patient record length is 3 chars");
            }
            var seqNumber         = int.Parse(input.GetField(delimiters.FieldDelimiter, 2));
            var practiceID        = new string(input.GetField(delimiters.FieldDelimiter, 3));
            var labID             = new string(input.GetField(delimiters.FieldDelimiter, 4));
            var id3               = new string(input.GetField(delimiters.FieldDelimiter, 5));
            var name              = new string(input.GetField(delimiters.FieldDelimiter, 6));
            var mothersMaidenName = new string(input.GetField(delimiters.FieldDelimiter, 7));
            var birthdate         = ParseBirthdate(input, delimiters);
            var patsex            = ParseSex(input, delimiters);

            // TODO parse other fields

            return(new PatientRecord(seqNumber, practiceID, labID, id3, name, mothersMaidenName, birthdate, patsex, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null));
        }