x12_alt 0.1.0

Data types for X12 EDI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
use std::fmt;
use serde::{de, Deserialize, ser, Serialize};
/**1336

See docs at <https://www.stedi.com/edi/x12/element/1336>*/
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum InsuranceTypeCode {
    ///12 - Medicare Secondary Working Aged Beneficiary or Spouse with Employer Group Health Plan
    MedicareSecondaryWorkingAgedBeneficiaryOrSpouseWithEmployerGroupHealthPlan,
    ///13 - Medicare Secondary End-Stage Renal Disease Beneficiary in the Mandated Coordination Period with an Employer's Group Health Plan
    MedicareSecondaryEndStageRenalDiseaseBeneficiaryInTheMandatedCoordinationPeriodWithAnEmployersGroupHealthPlan,
    ///14 - Medicare Secondary, No-fault Insurance including Auto is Primary
    Code14,
    ///15 - Medicare Secondary Worker's Compensation
    MedicareSecondaryWorkersCompensation,
    ///16 - Medicare Secondary Public Health Service (PHS)or Other Federal Agency
    Code16,
    ///17 - Dental
    Dental,
    ///18 - Vision
    Vision,
    ///19 - Prescription Drugs
    PrescriptionDrugs,
    ///41 - Medicare Secondary Black Lung
    MedicareSecondaryBlackLung,
    ///42 - Medicare Secondary Veteran's Administration
    MedicareSecondaryVeteransAdministration,
    ///43 - Medicare Secondary Disabled Beneficiary Under Age 65 with Large Group Health Plan (LGHP)
    Code43,
    ///47 - Medicare Secondary, Other Liability Insurance is Primary
    Code47,
    ///AP - Auto Insurance Policy
    AutoInsurancePolicy,
    ///C1 - Commercial
    Commercial,
    ///CO - Consolidated Omnibus Budget Reconciliation Act (COBRA)
    CodeCO,
    ///CP - Medicare Conditionally Primary
    MedicareConditionallyPrimary,
    ///D - Disability
    Disability,
    ///DB - Disability Benefits
    DisabilityBenefits,
    ///E - Medicare - Point of Service (POS)
    CodeE,
    ///EP - Exclusive Provider Organization
    ExclusiveProviderOrganization,
    ///FF - Family or Friends
    FamilyOrFriends,
    ///GP - Group Policy
    GroupPolicy,
    ///HA - Health Insurance Exchange (HIX) Silver
    CodeHA,
    ///HB - Health Insurance Exchange (HIX) Bronze
    CodeHB,
    ///HD - High Deductible Health Plan
    HighDeductibleHealthPlan,
    ///HG - Health Insurance Exchange (HIX) Gold
    CodeHG,
    ///HM - Health Maintenance Organization (HMO)
    CodeHM,
    ///HN - Health Maintenance Organization (HMO) - Medicare Risk
    CodeHN,
    ///HP - Health Insurance Exchange (HIX) Platinum
    CodeHP,
    ///HS - Special Low Income Medicare Beneficiary
    SpecialLowIncomeMedicareBeneficiary,
    ///IN - Indemnity
    Indemnity,
    ///IP - Individual Policy
    IndividualPolicy,
    ///LC - Long Term Care
    LongTermCare,
    ///LD - Long Term Policy
    LongTermPolicy,
    ///LI - Life Insurance
    LifeInsurance,
    ///LT - Litigation
    Litigation,
    ///M - Medicare Advantage Point of Service (POS) Plan that excludes Part D coverage
    CodeM,
    ///MA - Medicare Part A
    MedicarePartA,
    ///MB - Medicare Part B
    MedicarePartB,
    ///MC - Medicaid
    Medicaid,
    ///MD - Medicare Part D
    MedicarePartD,
    ///ME - Medicare Advantage Preferred Provider Organization (PPO) Plan that excludes Part D Coverage
    CodeME,
    ///MF - Medicare Advantage Private Fee for Service
    MedicareAdvantagePrivateFeeForService,
    ///MH - Medigap Part A
    MedigapPartA,
    ///MI - Medigap Part B
    MedigapPartB,
    ///MJ - Medicare Advantage Health Maintenance Organization (HMO) Plan that includes Part D Coverage
    CodeMJ,
    ///MK - Medicare Advantage Health Maintenance Organization (HMO) Risk Plan that includes Part D Coverage
    CodeMK,
    ///ML - Medicare Advantage Indemnity Plan that includes Part D Coverage
    MedicareAdvantageIndemnityPlanThatIncludesPartDCoverage,
    ///MM - Medicare Advantage Preferred Provider Organization (PPO) Plan that includes Part D Coverage
    CodeMM,
    ///MN - Medicare Advantage Indemnity Plan that excludes Part D coverage
    MedicareAdvantageIndemnityPlanThatExcludesPartDCoverage,
    ///MO - Medicare Advantage Point of Service (POS) Plan that includes Part D Coverage
    CodeMO,
    ///MP - Medicare Primary
    MedicarePrimary,
    ///MR - Medicare Advantage Health Maintenance Organization (HMO) Risk Plan that excludes Part D coverage
    CodeMR,
    ///MT - Medicare Advantage Health Maintenance Organization (HMO) Plan that excludes Part D coverage
    CodeMT,
    ///MV - Medicare Advantage
    MedicareAdvantage,
    ///OA - Open Access Point of Service Plan
    OpenAccessPointOfServicePlan,
    ///OT - Other
    Other,
    ///PE - Property Insurance - Personal
    PropertyInsurancePersonal,
    ///PL - Personal
    Personal,
    ///PP - Personal Payment (Cash - No Insurance)
    CodePP,
    ///PR - Preferred Provider Organization (PPO)
    CodePR,
    ///PS - Point of Service (POS)
    CodePS,
    ///QM - Qualified Medicare Beneficiary
    QualifiedMedicareBeneficiary,
    ///RP - Property Insurance - Real
    PropertyInsuranceReal,
    ///SP - Supplemental Policy
    SupplementalPolicy,
    ///TF - Tax Equity Fiscal Responsibility Act (TEFRA)
    CodeTF,
    ///U - Multiple Options Health Plan
    MultipleOptionsHealthPlan,
    ///WC - Workers Compensation
    WorkersCompensation,
    ///WU - Wrap Up Policy
    WrapUpPolicy,
}
impl InsuranceTypeCode {
    pub fn code(&self) -> &str {
        {
            use InsuranceTypeCode::*;
            match self {
                MedicareSecondaryWorkingAgedBeneficiaryOrSpouseWithEmployerGroupHealthPlan => {
                    "12"
                }
                MedicareSecondaryEndStageRenalDiseaseBeneficiaryInTheMandatedCoordinationPeriodWithAnEmployersGroupHealthPlan => {
                    "13"
                }
                Code14 => "14",
                MedicareSecondaryWorkersCompensation => "15",
                Code16 => "16",
                Dental => "17",
                Vision => "18",
                PrescriptionDrugs => "19",
                MedicareSecondaryBlackLung => "41",
                MedicareSecondaryVeteransAdministration => "42",
                Code43 => "43",
                Code47 => "47",
                AutoInsurancePolicy => "AP",
                Commercial => "C1",
                CodeCO => "CO",
                MedicareConditionallyPrimary => "CP",
                Disability => "D",
                DisabilityBenefits => "DB",
                CodeE => "E",
                ExclusiveProviderOrganization => "EP",
                FamilyOrFriends => "FF",
                GroupPolicy => "GP",
                CodeHA => "HA",
                CodeHB => "HB",
                HighDeductibleHealthPlan => "HD",
                CodeHG => "HG",
                CodeHM => "HM",
                CodeHN => "HN",
                CodeHP => "HP",
                SpecialLowIncomeMedicareBeneficiary => "HS",
                Indemnity => "IN",
                IndividualPolicy => "IP",
                LongTermCare => "LC",
                LongTermPolicy => "LD",
                LifeInsurance => "LI",
                Litigation => "LT",
                CodeM => "M",
                MedicarePartA => "MA",
                MedicarePartB => "MB",
                Medicaid => "MC",
                MedicarePartD => "MD",
                CodeME => "ME",
                MedicareAdvantagePrivateFeeForService => "MF",
                MedigapPartA => "MH",
                MedigapPartB => "MI",
                CodeMJ => "MJ",
                CodeMK => "MK",
                MedicareAdvantageIndemnityPlanThatIncludesPartDCoverage => "ML",
                CodeMM => "MM",
                MedicareAdvantageIndemnityPlanThatExcludesPartDCoverage => "MN",
                CodeMO => "MO",
                MedicarePrimary => "MP",
                CodeMR => "MR",
                CodeMT => "MT",
                MedicareAdvantage => "MV",
                OpenAccessPointOfServicePlan => "OA",
                Other => "OT",
                PropertyInsurancePersonal => "PE",
                Personal => "PL",
                CodePP => "PP",
                CodePR => "PR",
                CodePS => "PS",
                QualifiedMedicareBeneficiary => "QM",
                PropertyInsuranceReal => "RP",
                SupplementalPolicy => "SP",
                CodeTF => "TF",
                MultipleOptionsHealthPlan => "U",
                WorkersCompensation => "WC",
                WrapUpPolicy => "WU",
            }
        }
    }
    pub fn from_code(code: &[u8]) -> Option<InsuranceTypeCode> {
        use InsuranceTypeCode::*;
        match code {
            b"12" => {
                Some(
                    MedicareSecondaryWorkingAgedBeneficiaryOrSpouseWithEmployerGroupHealthPlan,
                )
            }
            b"13" => {
                Some(
                    MedicareSecondaryEndStageRenalDiseaseBeneficiaryInTheMandatedCoordinationPeriodWithAnEmployersGroupHealthPlan,
                )
            }
            b"14" => Some(Code14),
            b"15" => Some(MedicareSecondaryWorkersCompensation),
            b"16" => Some(Code16),
            b"17" => Some(Dental),
            b"18" => Some(Vision),
            b"19" => Some(PrescriptionDrugs),
            b"41" => Some(MedicareSecondaryBlackLung),
            b"42" => Some(MedicareSecondaryVeteransAdministration),
            b"43" => Some(Code43),
            b"47" => Some(Code47),
            b"AP" => Some(AutoInsurancePolicy),
            b"C1" => Some(Commercial),
            b"CO" => Some(CodeCO),
            b"CP" => Some(MedicareConditionallyPrimary),
            b"D" => Some(Disability),
            b"DB" => Some(DisabilityBenefits),
            b"E" => Some(CodeE),
            b"EP" => Some(ExclusiveProviderOrganization),
            b"FF" => Some(FamilyOrFriends),
            b"GP" => Some(GroupPolicy),
            b"HA" => Some(CodeHA),
            b"HB" => Some(CodeHB),
            b"HD" => Some(HighDeductibleHealthPlan),
            b"HG" => Some(CodeHG),
            b"HM" => Some(CodeHM),
            b"HN" => Some(CodeHN),
            b"HP" => Some(CodeHP),
            b"HS" => Some(SpecialLowIncomeMedicareBeneficiary),
            b"IN" => Some(Indemnity),
            b"IP" => Some(IndividualPolicy),
            b"LC" => Some(LongTermCare),
            b"LD" => Some(LongTermPolicy),
            b"LI" => Some(LifeInsurance),
            b"LT" => Some(Litigation),
            b"M" => Some(CodeM),
            b"MA" => Some(MedicarePartA),
            b"MB" => Some(MedicarePartB),
            b"MC" => Some(Medicaid),
            b"MD" => Some(MedicarePartD),
            b"ME" => Some(CodeME),
            b"MF" => Some(MedicareAdvantagePrivateFeeForService),
            b"MH" => Some(MedigapPartA),
            b"MI" => Some(MedigapPartB),
            b"MJ" => Some(CodeMJ),
            b"MK" => Some(CodeMK),
            b"ML" => Some(MedicareAdvantageIndemnityPlanThatIncludesPartDCoverage),
            b"MM" => Some(CodeMM),
            b"MN" => Some(MedicareAdvantageIndemnityPlanThatExcludesPartDCoverage),
            b"MO" => Some(CodeMO),
            b"MP" => Some(MedicarePrimary),
            b"MR" => Some(CodeMR),
            b"MT" => Some(CodeMT),
            b"MV" => Some(MedicareAdvantage),
            b"OA" => Some(OpenAccessPointOfServicePlan),
            b"OT" => Some(Other),
            b"PE" => Some(PropertyInsurancePersonal),
            b"PL" => Some(Personal),
            b"PP" => Some(CodePP),
            b"PR" => Some(CodePR),
            b"PS" => Some(CodePS),
            b"QM" => Some(QualifiedMedicareBeneficiary),
            b"RP" => Some(PropertyInsuranceReal),
            b"SP" => Some(SupplementalPolicy),
            b"TF" => Some(CodeTF),
            b"U" => Some(MultipleOptionsHealthPlan),
            b"WC" => Some(WorkersCompensation),
            b"WU" => Some(WrapUpPolicy),
            _ => None,
        }
    }
    fn description(&self) -> &str {
        use InsuranceTypeCode::*;
        match self {
            MedicareSecondaryWorkingAgedBeneficiaryOrSpouseWithEmployerGroupHealthPlan => {
                "Medicare Secondary Working Aged Beneficiary or Spouse with Employer Group Health Plan"
            }
            MedicareSecondaryEndStageRenalDiseaseBeneficiaryInTheMandatedCoordinationPeriodWithAnEmployersGroupHealthPlan => {
                "Medicare Secondary End-Stage Renal Disease Beneficiary in the Mandated Coordination Period with an Employer's Group Health Plan"
            }
            Code14 => "Medicare Secondary, No-fault Insurance including Auto is Primary",
            MedicareSecondaryWorkersCompensation => {
                "Medicare Secondary Worker's Compensation"
            }
            Code16 => {
                "Medicare Secondary Public Health Service (PHS)or Other Federal Agency"
            }
            Dental => "Dental",
            Vision => "Vision",
            PrescriptionDrugs => "Prescription Drugs",
            MedicareSecondaryBlackLung => "Medicare Secondary Black Lung",
            MedicareSecondaryVeteransAdministration => {
                "Medicare Secondary Veteran's Administration"
            }
            Code43 => {
                "Medicare Secondary Disabled Beneficiary Under Age 65 with Large Group Health Plan (LGHP)"
            }
            Code47 => "Medicare Secondary, Other Liability Insurance is Primary",
            AutoInsurancePolicy => "Auto Insurance Policy",
            Commercial => "Commercial",
            CodeCO => "Consolidated Omnibus Budget Reconciliation Act (COBRA)",
            MedicareConditionallyPrimary => "Medicare Conditionally Primary",
            Disability => "Disability",
            DisabilityBenefits => "Disability Benefits",
            CodeE => "Medicare - Point of Service (POS)",
            ExclusiveProviderOrganization => "Exclusive Provider Organization",
            FamilyOrFriends => "Family or Friends",
            GroupPolicy => "Group Policy",
            CodeHA => "Health Insurance Exchange (HIX) Silver",
            CodeHB => "Health Insurance Exchange (HIX) Bronze",
            HighDeductibleHealthPlan => "High Deductible Health Plan",
            CodeHG => "Health Insurance Exchange (HIX) Gold",
            CodeHM => "Health Maintenance Organization (HMO)",
            CodeHN => "Health Maintenance Organization (HMO) - Medicare Risk",
            CodeHP => "Health Insurance Exchange (HIX) Platinum",
            SpecialLowIncomeMedicareBeneficiary => {
                "Special Low Income Medicare Beneficiary"
            }
            Indemnity => "Indemnity",
            IndividualPolicy => "Individual Policy",
            LongTermCare => "Long Term Care",
            LongTermPolicy => "Long Term Policy",
            LifeInsurance => "Life Insurance",
            Litigation => "Litigation",
            CodeM => {
                "Medicare Advantage Point of Service (POS) Plan that excludes Part D coverage"
            }
            MedicarePartA => "Medicare Part A",
            MedicarePartB => "Medicare Part B",
            Medicaid => "Medicaid",
            MedicarePartD => "Medicare Part D",
            CodeME => {
                "Medicare Advantage Preferred Provider Organization (PPO) Plan that excludes Part D Coverage"
            }
            MedicareAdvantagePrivateFeeForService => {
                "Medicare Advantage Private Fee for Service"
            }
            MedigapPartA => "Medigap Part A",
            MedigapPartB => "Medigap Part B",
            CodeMJ => {
                "Medicare Advantage Health Maintenance Organization (HMO) Plan that includes Part D Coverage"
            }
            CodeMK => {
                "Medicare Advantage Health Maintenance Organization (HMO) Risk Plan that includes Part D Coverage"
            }
            MedicareAdvantageIndemnityPlanThatIncludesPartDCoverage => {
                "Medicare Advantage Indemnity Plan that includes Part D Coverage"
            }
            CodeMM => {
                "Medicare Advantage Preferred Provider Organization (PPO) Plan that includes Part D Coverage"
            }
            MedicareAdvantageIndemnityPlanThatExcludesPartDCoverage => {
                "Medicare Advantage Indemnity Plan that excludes Part D coverage"
            }
            CodeMO => {
                "Medicare Advantage Point of Service (POS) Plan that includes Part D Coverage"
            }
            MedicarePrimary => "Medicare Primary",
            CodeMR => {
                "Medicare Advantage Health Maintenance Organization (HMO) Risk Plan that excludes Part D coverage"
            }
            CodeMT => {
                "Medicare Advantage Health Maintenance Organization (HMO) Plan that excludes Part D coverage"
            }
            MedicareAdvantage => "Medicare Advantage",
            OpenAccessPointOfServicePlan => "Open Access Point of Service Plan",
            Other => "Other",
            PropertyInsurancePersonal => "Property Insurance - Personal",
            Personal => "Personal",
            CodePP => "Personal Payment (Cash - No Insurance)",
            CodePR => "Preferred Provider Organization (PPO)",
            CodePS => "Point of Service (POS)",
            QualifiedMedicareBeneficiary => "Qualified Medicare Beneficiary",
            PropertyInsuranceReal => "Property Insurance - Real",
            SupplementalPolicy => "Supplemental Policy",
            CodeTF => "Tax Equity Fiscal Responsibility Act (TEFRA)",
            MultipleOptionsHealthPlan => "Multiple Options Health Plan",
            WorkersCompensation => "Workers Compensation",
            WrapUpPolicy => "Wrap Up Policy",
        }
    }
    fn from_description(description: &str) -> Option<InsuranceTypeCode> {
        {
            use InsuranceTypeCode::*;
            match description {
                "Medicare Secondary Working Aged Beneficiary or Spouse with Employer Group Health Plan" => {
                    Some(
                        MedicareSecondaryWorkingAgedBeneficiaryOrSpouseWithEmployerGroupHealthPlan,
                    )
                }
                "Medicare Secondary End-Stage Renal Disease Beneficiary in the Mandated Coordination Period with an Employer's Group Health Plan" => {
                    Some(
                        MedicareSecondaryEndStageRenalDiseaseBeneficiaryInTheMandatedCoordinationPeriodWithAnEmployersGroupHealthPlan,
                    )
                }
                "Medicare Secondary, No-fault Insurance including Auto is Primary" => {
                    Some(Code14)
                }
                "Medicare Secondary Worker's Compensation" => {
                    Some(MedicareSecondaryWorkersCompensation)
                }
                "Medicare Secondary Public Health Service (PHS)or Other Federal Agency" => {
                    Some(Code16)
                }
                "Dental" => Some(Dental),
                "Vision" => Some(Vision),
                "Prescription Drugs" => Some(PrescriptionDrugs),
                "Medicare Secondary Black Lung" => Some(MedicareSecondaryBlackLung),
                "Medicare Secondary Veteran's Administration" => {
                    Some(MedicareSecondaryVeteransAdministration)
                }
                "Medicare Secondary Disabled Beneficiary Under Age 65 with Large Group Health Plan (LGHP)" => {
                    Some(Code43)
                }
                "Medicare Secondary, Other Liability Insurance is Primary" => {
                    Some(Code47)
                }
                "Auto Insurance Policy" => Some(AutoInsurancePolicy),
                "Commercial" => Some(Commercial),
                "Consolidated Omnibus Budget Reconciliation Act (COBRA)" => Some(CodeCO),
                "Medicare Conditionally Primary" => Some(MedicareConditionallyPrimary),
                "Disability" => Some(Disability),
                "Disability Benefits" => Some(DisabilityBenefits),
                "Medicare - Point of Service (POS)" => Some(CodeE),
                "Exclusive Provider Organization" => Some(ExclusiveProviderOrganization),
                "Family or Friends" => Some(FamilyOrFriends),
                "Group Policy" => Some(GroupPolicy),
                "Health Insurance Exchange (HIX) Silver" => Some(CodeHA),
                "Health Insurance Exchange (HIX) Bronze" => Some(CodeHB),
                "High Deductible Health Plan" => Some(HighDeductibleHealthPlan),
                "Health Insurance Exchange (HIX) Gold" => Some(CodeHG),
                "Health Maintenance Organization (HMO)" => Some(CodeHM),
                "Health Maintenance Organization (HMO) - Medicare Risk" => Some(CodeHN),
                "Health Insurance Exchange (HIX) Platinum" => Some(CodeHP),
                "Special Low Income Medicare Beneficiary" => {
                    Some(SpecialLowIncomeMedicareBeneficiary)
                }
                "Indemnity" => Some(Indemnity),
                "Individual Policy" => Some(IndividualPolicy),
                "Long Term Care" => Some(LongTermCare),
                "Long Term Policy" => Some(LongTermPolicy),
                "Life Insurance" => Some(LifeInsurance),
                "Litigation" => Some(Litigation),
                "Medicare Advantage Point of Service (POS) Plan that excludes Part D coverage" => {
                    Some(CodeM)
                }
                "Medicare Part A" => Some(MedicarePartA),
                "Medicare Part B" => Some(MedicarePartB),
                "Medicaid" => Some(Medicaid),
                "Medicare Part D" => Some(MedicarePartD),
                "Medicare Advantage Preferred Provider Organization (PPO) Plan that excludes Part D Coverage" => {
                    Some(CodeME)
                }
                "Medicare Advantage Private Fee for Service" => {
                    Some(MedicareAdvantagePrivateFeeForService)
                }
                "Medigap Part A" => Some(MedigapPartA),
                "Medigap Part B" => Some(MedigapPartB),
                "Medicare Advantage Health Maintenance Organization (HMO) Plan that includes Part D Coverage" => {
                    Some(CodeMJ)
                }
                "Medicare Advantage Health Maintenance Organization (HMO) Risk Plan that includes Part D Coverage" => {
                    Some(CodeMK)
                }
                "Medicare Advantage Indemnity Plan that includes Part D Coverage" => {
                    Some(MedicareAdvantageIndemnityPlanThatIncludesPartDCoverage)
                }
                "Medicare Advantage Preferred Provider Organization (PPO) Plan that includes Part D Coverage" => {
                    Some(CodeMM)
                }
                "Medicare Advantage Indemnity Plan that excludes Part D coverage" => {
                    Some(MedicareAdvantageIndemnityPlanThatExcludesPartDCoverage)
                }
                "Medicare Advantage Point of Service (POS) Plan that includes Part D Coverage" => {
                    Some(CodeMO)
                }
                "Medicare Primary" => Some(MedicarePrimary),
                "Medicare Advantage Health Maintenance Organization (HMO) Risk Plan that excludes Part D coverage" => {
                    Some(CodeMR)
                }
                "Medicare Advantage Health Maintenance Organization (HMO) Plan that excludes Part D coverage" => {
                    Some(CodeMT)
                }
                "Medicare Advantage" => Some(MedicareAdvantage),
                "Open Access Point of Service Plan" => Some(OpenAccessPointOfServicePlan),
                "Other" => Some(Other),
                "Property Insurance - Personal" => Some(PropertyInsurancePersonal),
                "Personal" => Some(Personal),
                "Personal Payment (Cash - No Insurance)" => Some(CodePP),
                "Preferred Provider Organization (PPO)" => Some(CodePR),
                "Point of Service (POS)" => Some(CodePS),
                "Qualified Medicare Beneficiary" => Some(QualifiedMedicareBeneficiary),
                "Property Insurance - Real" => Some(PropertyInsuranceReal),
                "Supplemental Policy" => Some(SupplementalPolicy),
                "Tax Equity Fiscal Responsibility Act (TEFRA)" => Some(CodeTF),
                "Multiple Options Health Plan" => Some(MultipleOptionsHealthPlan),
                "Workers Compensation" => Some(WorkersCompensation),
                "Wrap Up Policy" => Some(WrapUpPolicy),
                _ => None,
            }
        }
    }
}
impl Serialize for InsuranceTypeCode {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: ser::Serializer,
    {
        let value = if serializer.is_human_readable() {
            self.description()
        } else {
            self.code()
        };
        serializer.serialize_str(value)
    }
}
struct Visitor;
impl<'de> de::Visitor<'de> for Visitor {
    type Value = InsuranceTypeCode;
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("Insurance Type Code")
    }
    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
    where
        E: de::Error,
    {
        InsuranceTypeCode::from_description(v)
            .ok_or_else(|| E::custom(format!("Invalid Insurance Type Code: {}", v)))
    }
    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
    where
        E: de::Error,
    {
        InsuranceTypeCode::from_code(v)
            .ok_or_else(|| E::custom(
                format!(
                    "Invalid Insurance Type Code: {}", std::str::from_utf8(v).unwrap()
                ),
            ))
    }
}
impl<'de> Deserialize<'de> for InsuranceTypeCode {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: de::Deserializer<'de>,
    {
        if deserializer.is_human_readable() {
            deserializer.deserialize_str(Visitor)
        } else {
            deserializer.deserialize_bytes(Visitor)
        }
    }
}