Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help to define repetition of data elements within a segment in an edifact? #105

Closed
KasturiR opened this issue Jul 3, 2018 · 6 comments

Comments

@KasturiR
Copy link

KasturiR commented Jul 3, 2018

I am not sure how to add definition in case of repetitive data elements inside a segment.
below is an example of DRU segment where the 4th data element is repeated and the repetition delimiter is asterisk *.

DRU+D:SPRINTEC 28 DAY
TABLET:00555901658:ND+:28:87:AC:C48542++LD:20100615:102*ZDS:28:804+1’

I want to parse the values into DOQ class.

 public List<DateOrQuantity> DOQ

Below is the definition of DOQ class type

 [EdiElement]
 [EdiPath("DRU/3")]
 public class DateOrQuanitity
 {
     [EdiValue("X(35)", Path = "DRU/3/1")]
     public string DateOrQuantity { get; set; }

     [EdiValue("X(100)", Path = "DRU/3/2")]
     public string FormatQualifier { get; set; }
 }

Is there a recommended way of accomplishing this
or any way to define Repetition Separator?

@cleftheris
Copy link
Contributor

@KasturiR hi and thanks for you interest in Edi.Net.

Is your list above a property?

@KasturiR
Copy link
Author

KasturiR commented Jul 3, 2018

yes, List DOQ is a property.

@cleftheris
Copy link
Contributor

cleftheris commented Jul 3, 2018

I don't see how a segment class could contain an element list. Keep in mind this is a model first approach.
You could map the same Element position to different properties though using the EdiConditionAttribute to discriminate between them.

Am I missing something?

@KasturiR
Copy link
Author

KasturiR commented Jul 4, 2018

Hi @cleftheris
let me define my doubt more clearly,

I have a DRU segment in the message, below is the example

DRU+D:SPRINTEC 28 DAY TABLET:00555901658:ND+:28:87:AC:C48542++LD:20100615:102*ZDS:20100715:102*38:20100715:102+1’

Inside DRU segment the 4th element(or group of components) is being repeated, so the elements are of same type(have the same path, definition) and are separated by an asterisk as a separator, unlike the other elements of segments which are separated by + and can be of different types.

+LD:20100615:102*ZDS:20100715:102*38:20100715:102+ this is the element no 4 and 3 elements are present inside, which are the repetition of the same type separated by *.

I have defined a class to parse the content of DRU segment and another list of class DateOrQuanitity to deserialize the more than one elements of the same type separated by *. So inside the segment class, I have defined a list of class DateOrQuantity.

I am not sure how to define Repetition Separator, I assume once I can define this separator, I can parse the element repetition as a list of objects of class
DateOrQuanitity. Since now it is not able to recognize the * symbol.

Below is the class definition for DRU segment

    [EdiSegment]
    [EdiPath("DRU")]
    public class DrugDetails
    {
        [EdiValue("X(1)", Path = "DRU/0/0")]
        public string ItemDescriptionIdentification { get; set; }

        [EdiValue("X(35)", Path = "DRU/0/1")]
        public string DrugName { get; set; }

        [EdiValue("X(35)", Path = "DRU/0/2")]
        public string DrugNumber { get; set; }

        [EdiValue("X(3)", Path = "DRU/0/3")]
        public string CodeListResponsibility { get; set; }

        [EdiValue("X(35)", Path = "DRU/0/9")]
        public string FullDrugNumber { get; set; }

        [EdiValue("X(35)", Path = "DRU/0/10")]
        public string DrugStrength { get; set; }

        [EdiValue("X(35)", Path = "DRU/0/11")]
        public string DrugForm { get; set; }

        [EdiValue("X(3)", Path = "DRU/1/0")]
        public string QuantityQualifier { get; set; }

        [EdiValue("X(35)", Path = "DRU/1/1")]
        public string Quantity { get; set; }

        [EdiValue("X(3)", Path = "DRU/1/2")]
        public string CodeListQualifier { get; set; }

        [EdiValue("X(3)", Path = "DRU/1/3")]
        public string UnitSourceCode { get; set; }

        [EdiValue("X(15)", Path = "DRU/1/4")]
        public string PotencyUnitCode { get; set; }

        [EdiValue("X(70)", Path = "DRU/2/1")]
        public string SIGInstructions1 { get; set; }

        public List<DateOrQuanitity> DateTimePeriod { get; set; }

        [EdiValue("X(3)", Path = "DRU/5/0")]
        public string RefillQualifier { get; set; }

        [EdiValue("X(35)", Path = "DRU/5/1")]
        public string RefillQuantity { get; set; }
		
  }

And this the class to define the element which is being repeated

	
     [EdiElement]
     [EdiPath("DRU/3")]
     public class DateOrQuanitity
     {
        [EdiValue("X(35)", Path = "DRU/3/1")]
        public string DateOrQuantity { get; set; }

        [EdiValue("X(100)", Path = "DRU/3/2")]
        public string FormatQualifier { get; set; }
     }

please let me know if i am not clear enough.

@cleftheris
Copy link
Contributor

Hi again,

someone recently brought to my attention a case in EDIFact transmissions of the COM (CommunicationContact segment) that there is an element defined once in the spec and is marked with a repeat counter. So I took a quick look here.

I did not know that, so my reply above is not accurate at all.

This is not supported at the moment but I believe that I can make something work is an upcoming release.

Thanks for poining this out

@cleftheris
Copy link
Contributor

As of v1.9.4 this is fully supported using wildcard paths like so. In this version the following will work fine both serializing and deserializing.

    [EdiSegment]
    [EdiPath("DRU")]
    public class DrugDetails
    {

          [EdiPath("DRU/*")]
          public List<DateOrQuantity> DOQ
    }

     [EdiElement]
     public class DateOrQuanitity
     {
        [EdiValue("X(35)", Path = "*/*/1")]
        public string DateOrQuantity { get; set; }

        [EdiValue("X(100)", Path = "*/*/2")]
        public string FormatQualifier { get; set; }
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants