-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDeathRecord_submissionProperties.cs
More file actions
7347 lines (7097 loc) · 355 KB
/
DeathRecord_submissionProperties.cs
File metadata and controls
7347 lines (7097 loc) · 355 KB
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
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Linq;
using System.Collections.Generic;
using Hl7.Fhir.Model;
// DeathRecord_submissionProperties.cs
// These fields are used primarily for submitting death records to NCHS. Some are also used in response messages from NCHS to EDRS corresponding to TRX and MRE content.
namespace VRDR
{
/// <summary>Class <c>DeathRecord</c> models a FHIR Vital Records Death Reporting (VRDR) Death
/// Record. This class was designed to help consume and produce death records that follow the
/// HL7 FHIR Vital Records Death Reporting Implementation Guide, as described at:
/// http://hl7.org/fhir/us/vrdr and https://github.com/hl7/vrdr.
/// </summary>
public partial class DeathRecord
{
/////////////////////////////////////////////////////////////////////////////////
//
// Record Properties: Death Certification
//
/////////////////////////////////////////////////////////////////////////////////
/// <summary>Death Record Identifier, Death Certificate Number.</summary>
/// <value>a record identification string.</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.Identifier = "42";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Death Certificate Number: {ExampleDeathRecord.Identifier}");</para>
/// </example>
[Property("Identifier", Property.Types.String, "Death Certification", "Death Certificate Number.", true, IGURL.DeathCertificate, true, 3)]
[FHIRPath("Bundle", "identifier")]
public string Identifier
{
get
{
if (Bundle?.Identifier?.Extension != null)
{
Extension ext = Bundle.Identifier.Extension.Find(ex => ex.Url == ExtensionURL.CertificateNumber);
if (ext?.Value != null)
{
return Convert.ToString(ext.Value);
}
}
return null;
}
set
{
Bundle.Identifier.Extension.RemoveAll(ex => ex.Url == ExtensionURL.CertificateNumber);
if (!String.IsNullOrWhiteSpace(value))
{
Extension ext = new Extension(ExtensionURL.CertificateNumber, new FhirString(value));
Bundle.Identifier.Extension.Add(ext);
UpdateDeathRecordIdentifier();
}
}
}
/// <summary>Update the bundle identifier from the component fields.</summary>
private void UpdateDeathRecordIdentifier()
{
uint certificateNumber = 0;
if (Identifier != null)
{
UInt32.TryParse(Identifier, out certificateNumber);
}
uint deathYear = 0;
if (this.DeathYear != null)
{
deathYear = (uint)this.DeathYear;
}
String jurisdictionId = this.DeathLocationJurisdiction;
if (jurisdictionId == null || jurisdictionId.Trim().Length < 2)
{
jurisdictionId = "XX";
}
else
{
jurisdictionId = jurisdictionId.Trim().Substring(0, 2).ToUpper();
}
this.DeathRecordIdentifier = $"{deathYear.ToString("D4")}{jurisdictionId}{certificateNumber.ToString("D6")}";
}
/// <summary>Death Record Bundle Identifier, NCHS identifier.</summary>
/// <value>a record bundle identification string, e.g., 2022MA000100, derived from year of death, jurisdiction of death, and certificate number</value>
/// <example>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"NCHS identifier: {ExampleDeathRecord.DeathRecordIdentifier}");</para>
/// </example>
[Property("Death Record Identifier", Property.Types.String, "Death Certification", "Death Record identifier.", true, IGURL.DeathCertificate, true, 4)]
[FHIRPath("Bundle", "identifier")]
public string DeathRecordIdentifier
{
get
{
if (Bundle != null && Bundle.Identifier != null)
{
return Bundle.Identifier.Value;
}
return null;
}
// The setter is private because the value is derived so should never be set directly
private set
{
if (String.IsNullOrWhiteSpace(value))
{
return;
}
if (Bundle.Identifier == null)
{
Bundle.Identifier = new Identifier();
}
Bundle.Identifier.Value = value;
Bundle.Identifier.System = "http://nchs.cdc.gov/vrdr_id";
}
}
/// <summary>State Local Identifier1.</summary>
/// <para>"value" the string representation of the local identifier</para>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.StateLocalIdentifier1 = "MA";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"State local identifier: {ExampleDeathRecord.StateLocalIdentifier1}");</para>
/// </example>
[Property("State Local Identifier1", Property.Types.String, "Death Certification", "State Local Identifier.", true, ProfileURL.DeathCertificate, true, 5)]
[FHIRPath("Bundle", "identifier")]
public string StateLocalIdentifier1
{
get
{
if (Bundle?.Identifier?.Extension != null)
{
Extension ext = Bundle.Identifier.Extension.Find(ex => ex.Url == ExtensionURL.AuxiliaryStateIdentifier1);
if (ext?.Value != null)
{
return Convert.ToString(ext.Value);
}
}
return null;
}
set
{
Bundle.Identifier.Extension.RemoveAll(ex => ex.Url == ExtensionURL.AuxiliaryStateIdentifier1);
if (!String.IsNullOrWhiteSpace(value))
{
Extension ext = new Extension(ExtensionURL.AuxiliaryStateIdentifier1, new FhirString(value));
Bundle.Identifier.Extension.Add(ext);
}
}
}
/// <summary>State Local Identifier2.</summary>
/// <para>"value" the string representation of the local identifier</para>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.StateLocalIdentifier2 = "YC";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"State local identifier: {ExampleDeathRecord.StateLocalIdentifier1}");</para>
/// </example>
[Property("State Local Identifier2", Property.Types.String, "Death Certification", "State Local Identifier.", true, ProfileURL.DeathCertificate, true, 5)]
[FHIRPath("Bundle", "identifier")]
public string StateLocalIdentifier2
{
get
{
if (Bundle?.Identifier?.Extension != null)
{
Extension ext = Bundle.Identifier.Extension.Find(ex => ex.Url == ExtensionURL.AuxiliaryStateIdentifier2);
if (ext?.Value != null)
{
return Convert.ToString(ext.Value);
}
}
return null;
}
set
{
Bundle.Identifier.Extension.RemoveAll(ex => ex.Url == ExtensionURL.AuxiliaryStateIdentifier2);
if (!String.IsNullOrWhiteSpace(value))
{
Extension ext = new Extension(ExtensionURL.AuxiliaryStateIdentifier2, new FhirString(value));
Bundle.Identifier.Extension.Add(ext);
}
}
}
/// <summary>Certified time.</summary>
/// <value>time when the record was certified.</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.CertifiedTime = "2019-01-29T16:48:06-05:00";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Certified at: {ExampleDeathRecord.CertifiedTime}");</para>
/// </example>
[Property("Certified Time", Property.Types.StringDateTime, "Death Certification", "Certified time (i.e. certifier date signed).", true, IGURL.DeathCertification, false, 12)]
[FHIRPath("Bundle.entry.resource.where($this is Procedure).where(code.coding.code='308646001')", "")]
public string CertifiedTime
{
get
{
if (DeathCertification != null && DeathCertification.Performed != null)
{
return Convert.ToString(DeathCertification.Performed);
}
else if (Composition != null && Composition.Attester != null && Composition.Attester.FirstOrDefault() != null && Composition.Attester.First().Time != null)
{
return Composition.Attester.First().Time;
}
return null;
}
set
{
if (String.IsNullOrWhiteSpace(value))
{
return;
}
if (DeathCertification == null)
{
CreateDeathCertification();
}
Composition.Attester.First().Time = value;
DeathCertification.Performed = new FhirDateTime(value);
}
}
/// <summary>Filing Format.</summary>
/// <value>Source flag: paper/electronic.
/// <para>"code" - the code</para>
/// <para>"system" - the code system this code belongs to</para>
/// <para>"display" - a human readable meaning of the code</para>
/// </value> /// <example>
/// <para>// Setter:</para>
/// <para>Dictionary<string, string> format = new Dictionary<string, string>();</para>
/// <para>format.Add("code", ValueSets.FilingFormat.electronic);</para>
/// <para>format.Add("system", CodeSystems.FilingFormat);</para>
/// <para>format.Add("display", "Electronic");</para>
/// <para>ExampleDeathRecord.FilingFormat = format;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Filed method: {ExampleDeathRecord.FilingFormat}");</para>
/// </example>
[Property("Filing Format", Property.Types.Dictionary, "Death Certification", "Filing format.", true, IGURL.DeathCertificate, true, 13)]
[PropertyParam("code", "The code used to describe this concept.")]
[PropertyParam("system", "The relevant code system.")]
[PropertyParam("display", "The human readable version of this code.")]
[FHIRPath("Bundle.entry.resource.where($this is Composition).extension.where(url='http://hl7.org/fhir/us/vrdr/StructureDefinition/FilingFormat')", "")]
public Dictionary<string, string> FilingFormat
{
get
{
if (Composition != null)
{
Extension filingFormat = Composition.Extension.Find(ext => ext.Url == ExtensionURL.FilingFormat);
if (filingFormat != null && filingFormat.Value != null && filingFormat.Value as CodeableConcept != null)
{
return CodeableConceptToDict((CodeableConcept)filingFormat.Value);
}
}
return EmptyCodeableDict();
}
set
{
// TODO: Handle case where Composition == null (either create it or throw exception)
Composition.Extension.RemoveAll(ext => ext.Url == ExtensionURL.FilingFormat);
Extension filingFormat = new Extension();
filingFormat.Url = ExtensionURL.FilingFormat;
filingFormat.Value = DictToCodeableConcept(value);
Composition.Extension.Add(filingFormat);
}
}
/// <summary>Filing Format Helper.</summary>
/// <value>filing format.
/// <para>"code" - the code</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.FilingFormatHelper = ValueSets.FilingFormat.Electronic;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Filing Format: {ExampleDeathRecord.FilingFormatHelper}");</para>
/// </example>
[Property("Filing Format Helper", Property.Types.String, "Death Certification", "Filing Format.", false, IGURL.DeathCertificate, true, 13)]
[PropertyParam("code", "The code used to describe this concept.")]
[FHIRPath("Bundle.entry.resource.where($this is Composition).extension.where(url='http://hl7.org/fhir/us/vrdr/StructureDefinition/FilingFormat')", "")]
public string FilingFormatHelper
{
get
{
if (FilingFormat.ContainsKey("code") && !String.IsNullOrWhiteSpace(FilingFormat["code"]))
{
return FilingFormat["code"];
}
return null;
}
set
{
if (!String.IsNullOrWhiteSpace(value))
{
SetCodeValue("FilingFormat", value, VRDR.ValueSets.FilingFormat.Codes);
}
}
}
/// <summary>Registered time.</summary>
/// <value>time when the record was registered.</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.RegisteredTime = "2019-01-29T16:48:06-05:00";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Registered at: {ExampleDeathRecord.RegisteredTime}");</para>
/// </example>
[Property("Registered Date/Time", Property.Types.StringDateTime, "Death Certification", "Date/Time of record registration.", true, IGURL.DeathCertificate, true, 13)]
[FHIRPath("Bundle.entry.resource.where($this is Composition)", "date")]
public string RegisteredTime
{
get
{
if (Composition != null)
{
return Composition.Date;
}
return null;
}
set
{
if (!String.IsNullOrWhiteSpace(value))
{
Composition.Date = value;
}
}
}
/// <summary>State Specific Data.</summary>
/// <value>Possible use for future filler unless two neighboring states wish to use for some specific information that they both collect. This would be a non-standard field</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.StateSpecific = "Data";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"State Specific Data: {ExampleDeathRecord.StateSpecific}");</para>
/// </example>
[Property("State Specific Data", Property.Types.String, "Death Certification", "State Specific Content.", true, IGURL.DeathCertificate, true, 13)]
[FHIRPath("Bundle.entry.resource.where($this is Composition).extension.where(url='http://hl7.org/fhir/us/vrdr/StructureDefinition/StateSpecificField')", "date")]
public string StateSpecific
{
get
{
if (Composition != null)
{
Extension stateSpecificData = Composition.Extension.Where(ext => ext.Url == ExtensionURL.StateSpecificField).FirstOrDefault();
if (stateSpecificData != null && stateSpecificData.Value as FhirString != null)
{
return stateSpecificData.Value.ToString();
}
}
return null;
}
set
{
// TODO: Handle case where Composition == null (either create it or throw exception)
Composition.Extension.RemoveAll(ext => ext.Url == ExtensionURL.StateSpecificField);
if (String.IsNullOrWhiteSpace(value))
{
return;
}
Extension stateSpecificData = new Extension();
stateSpecificData.Url = ExtensionURL.StateSpecificField;
stateSpecificData.Value = new FhirString(value);
Composition.Extension.Add(stateSpecificData);
}
}
/// <summary>Replace Status.</summary>
/// <value>Replacement Record – suggested codes.</value>
/// <example>
/// <para>// Setter:</para>
/// <para>Dictionary<string, string> replace = new Dictionary<string, string>();</para>
/// <para>replace.Add("code", "original");</para>
/// <para>replace.Add("system", CodeSystems.ReplaceStatus);</para>
/// <para>replace.Add("display", "original");</para>
/// <para>ExampleDeathRecord.ReplaceStatus = replace;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Filed method: {ExampleDeathRecord.ReplaceStatus}");</para>
/// </example>
[Property("Replace Status", Property.Types.Dictionary, "Death Certification", "Replace status.", true, IGURL.DeathCertificate, true, 13)]
[PropertyParam("code", "The code used to describe this concept.")]
[PropertyParam("system", "The relevant code system.")]
[PropertyParam("display", "The human readable version of this code.")]
[FHIRPath("Bundle.Entry.Resource is MessageHeader", "")]
// [FHIRPath("Bundle.entry.resource.where($this is Composition).extension.where(url='http://hl7.org/fhir/us/vrdr/StructureDefinition/ReplaceStatus')", "")]
public Dictionary<string, string> ReplaceStatus
{
get
{
Dictionary<string, string> ReplaceStatusDict = new Dictionary<string, string>();
var MessageHeaderEntry = Bundle.Entry.FirstOrDefault(entry => entry.Resource is MessageHeader);
if (MessageHeaderEntry != null)
{
int ReplaceStatusFlagCode = DestinationFound(MessageHeaderEntry);
if(ReplaceStatusFlagCode==0)//Original submission
{
//This is an original submission message
ReplaceStatusDict.Add("code", "original");
ReplaceStatusDict.Add("system", CodeSystems.ReplaceStatus);
ReplaceStatusDict.Add("display", "original record");
//ReplaceStatus.Add(DictToCodeableConcept(ReplaceStatusDict));
CodeableConcept codeableConcept = DictToCodeableConcept(ReplaceStatusDict);
codeableConcept.Coding.Add(new Coding(CodeSystems.ReplaceStatus, ReplaceStatusDict.Values.First()));
return CodeableConceptToDict((CodeableConcept)codeableConcept);
}
else if (ReplaceStatusFlagCode==1) //updated submission
{
//This is an Updated submission message
ReplaceStatusDict.Add("code", "updated");
ReplaceStatusDict.Add("system", CodeSystems.ReplaceStatus);
ReplaceStatusDict.Add("display", "Updated record");
//ReplaceStatus.Add(DictToCodeableConcept(ReplaceStatusDict));
CodeableConcept codeableConcept = DictToCodeableConcept(ReplaceStatusDict);
codeableConcept.Coding.Add(new Coding(CodeSystems.ReplaceStatus, ReplaceStatusDict.Values.First()));
return CodeableConceptToDict((CodeableConcept)codeableConcept);
}
else if (ReplaceStatusFlagCode==2) //updated submission
{
//This is an Updated submission message
ReplaceStatusDict.Add("code", "updated_notforNCHS");
ReplaceStatusDict.Add("system", CodeSystems.ReplaceStatus);
ReplaceStatusDict.Add("display", "Updated record not for NCHS");
//ReplaceStatus.Add(DictToCodeableConcept(ReplaceStatusDict));
CodeableConcept codeableConcept = DictToCodeableConcept(ReplaceStatusDict);
codeableConcept.Coding.Add(new Coding(CodeSystems.ReplaceStatus, ReplaceStatusDict.Values.First()));
return CodeableConceptToDict((CodeableConcept)codeableConcept);
}
else
{
return EmptyCodeableDict();
}
}
return EmptyCodeableDict();
}
set
{
// TODO: Handle case where Composition == null (either create it or throw exception)
//This field is deprecated according to the IG Version 2.2.0
//Composition.Extension.RemoveAll(ext => ext.Url == ExtensionURL.ReplaceStatus);
//Extension replaceStatus = new Extension();
//replaceStatus.Url = ExtensionURL.ReplaceStatus;
//replaceStatus.Value = DictToCodeableConcept(value);
//Composition.Extension.Add(replaceStatus);
}
}
/// <summary>Replace Status Helper.</summary>
/// <value>replace status.
/// <para>"code" - the code</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.ReplaceStatusHelper = ValueSets.ReplaceStatus.Original_Record;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"ReplaceStatus: {ExampleDeathRecord.ReplaceStatusHelper}");</para>
/// </example>
[Property("Replace Status Helper", Property.Types.String, "Death Certification", "Replace Status.", false, IGURL.DeathCertificate, true, 4)]
[PropertyParam("code", "The code used to describe this concept.")]
[FHIRPath("Bundle.Entry.Resource is MessageHeader", "")]
// [FHIRPath("Bundle.entry.resource.where($this is Composition).extension.where(url='http://hl7.org/fhir/us/vrdr/StructureDefinition/ReplaceStatus')", "")]
public string ReplaceStatusHelper
{
get
{
var MessageHeaderEntry = Bundle.Entry.FirstOrDefault(entry => entry.Resource is MessageHeader);
if (MessageHeaderEntry != null && ReplaceStatus != null)
{
if (ReplaceStatus.ContainsKey("code") && !String.IsNullOrWhiteSpace(ReplaceStatus["code"]))
{
return ReplaceStatus["code"];
}
}
return null;
}
set
{
//This is no longer available in the death record according to the IG Version 2.2.0
//if (!String.IsNullOrWhiteSpace(value))
//{
//SetCodeValue("ReplaceStatus", value, VRDR.ValueSets.ReplaceStatus.Codes);
//}
}
}
/// <summary>Certification Role.</summary>
/// <value>the role/qualification of the person who certified the death. A Dictionary representing a code, containing the following key/value pairs:
/// <para>"code" - the code</para>
/// <para>"system" - the code system this code belongs to</para>
/// <para>"display" - a human readable meaning of the code</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>Dictionary<string, string> role = new Dictionary<string, string>();</para>
/// <para>role.Add("code", "76899008");</para>
/// <para>role.Add("system", CodeSystems.SCT);</para>
/// <para>role.Add("display", "Infectious diseases physician");</para>
/// <para>ExampleDeathRecord.CertificationRole = role;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Certification Role: {ExampleDeathRecord.CertificationRole['display']}");</para>
/// </example>
[Property("Certification Role", Property.Types.Dictionary, "Death Certification", "Certification Role.", true, IGURL.DeathCertification, true, 4)]
[PropertyParam("code", "The code used to describe this concept.")]
[PropertyParam("system", "The relevant code system.")]
[PropertyParam("display", "The human readable version of this code.")]
[FHIRPath("Bundle.entry.resource.where($this is Procedure).where(code.coding.code='308646001')", "performer")]
public Dictionary<string, string> CertificationRole
{
get
{
if (DeathCertification == null)
{
return EmptyCodeableDict();
}
Hl7.Fhir.Model.Procedure.PerformerComponent performer = DeathCertification.Performer.FirstOrDefault();
if (performer != null && performer.Function != null)
{
return CodeableConceptToDict(performer.Function);
}
return EmptyCodeableDict();
}
set
{
if (DeathCertification == null)
{
CreateDeathCertification();
}
Hl7.Fhir.Model.Procedure.PerformerComponent performer = new Hl7.Fhir.Model.Procedure.PerformerComponent();
performer.Function = DictToCodeableConcept(value);
performer.Actor = new ResourceReference("urn:uuid:" + Certifier.Id);
DeathCertification.Performer.Clear();
DeathCertification.Performer.Add(performer);
}
}
/// <summary>Certification Role Helper.</summary>
/// <value>the role/qualification of the person who certified the death.
/// <para>"code" - the code</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.CertificationRoleHelper = ValueSets.CertificationRole.InfectiousDiseasesPhysician;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Certification Role: {ExampleDeathRecord.CertificationRoleHelper}");</para>
/// </example>
[Property("Certification Role Helper", Property.Types.String, "Death Certification", "Certification Role.", false, IGURL.DeathCertification, true, 4)]
[PropertyParam("code", "The code used to describe this concept.")]
[FHIRPath("Bundle.entry.resource.where($this is Procedure).where(code.coding.code='308646001')", "performer")]
public string CertificationRoleHelper
{
get
{
if (CertificationRole.ContainsKey("code"))
{
string code = CertificationRole["code"];
if (code == "OTH")
{
if (CertificationRole.ContainsKey("text") && !String.IsNullOrWhiteSpace(CertificationRole["text"]))
{
return (CertificationRole["text"]);
}
return ("Other");
}
else if (!String.IsNullOrWhiteSpace(code))
{
return code;
}
}
return null;
}
set
{
if (String.IsNullOrWhiteSpace(value))
{
// do nothing
return;
}
if (!VRDR.Mappings.CertifierTypes.FHIRToIJE.ContainsKey(value))
{ //other
CertificationRole = CodeableConceptToDict(new CodeableConcept(CodeSystems.NullFlavor_HL7_V3, "OTH", "Other", value));
}
else
{ // normal path
SetCodeValue("CertificationRole", value, VRDR.ValueSets.CertifierTypes.Codes);
}
}
}
/// <summary>Manner of Death Type.</summary>
/// <value>the manner of death type. A Dictionary representing a code, containing the following key/value pairs:
/// <para>"code" - the code</para>
/// <para>"system" - the code system this code belongs to</para>
/// <para>"display" - a human readable meaning of the code</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>Dictionary<string, string> manner = new Dictionary<string, string>();</para>
/// <para>manner.Add("code", "7878000");</para>
/// <para>manner.Add("system", "");</para>
/// <para>manner.Add("display", "Accidental death");</para>
/// <para>ExampleDeathRecord.MannerOfDeathType = manner;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Manner Of Death Type: {ExampleDeathRecord.MannerOfDeathType['display']}");</para>
/// </example>
[Property("Manner Of Death Type", Property.Types.Dictionary, "Death Certification", "Manner of Death Type.", true, IGURL.MannerOfDeath, true, 49)]
[PropertyParam("code", "The code used to describe this concept.")]
[PropertyParam("system", "The relevant code system.")]
[PropertyParam("display", "The human readable version of this code.")]
[FHIRPath("Bundle.entry.resource.where($this is Observation).where(code.coding.code='69449-7')", "")]
public Dictionary<string, string> MannerOfDeathType
{
get
{
if (MannerOfDeath != null && MannerOfDeath.Value != null && MannerOfDeath.Value as CodeableConcept != null)
{
return CodeableConceptToDict((CodeableConcept)MannerOfDeath.Value);
}
return EmptyCodeableDict();
}
set
{
if (IsDictEmptyOrDefault(value) && MannerOfDeath == null)
{
return;
}
if (MannerOfDeath == null)
{
MannerOfDeath = new Observation();
MannerOfDeath.Id = Guid.NewGuid().ToString();
MannerOfDeath.Meta = new Meta();
string[] mannerofdeath_profile = { ProfileURL.MannerOfDeath };
MannerOfDeath.Meta.Profile = mannerofdeath_profile;
MannerOfDeath.Status = ObservationStatus.Final;
MannerOfDeath.Code = new CodeableConcept(CodeSystems.LOINC, "69449-7", "Manner of death", null);
MannerOfDeath.Subject = new ResourceReference("urn:uuid:" + Decedent.Id);
MannerOfDeath.Performer.Add(new ResourceReference("urn:uuid:" + Certifier.Id));
MannerOfDeath.Value = DictToCodeableConcept(value);
AddReferenceToComposition(MannerOfDeath.Id, "DeathCertification");
Bundle.AddResourceEntry(MannerOfDeath, "urn:uuid:" + MannerOfDeath.Id);
}
else
{
MannerOfDeath.Value = DictToCodeableConcept(value);
}
}
}
/// <summary>Manner of Death Type Helper</summary>
/// <value>the manner of death type
/// <para>"code" - the code</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.MannerOfDeathTypeHelper = MannerOfDeath.Natural;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Manner Of Death Type: {ExampleDeathRecord.MannerOfDeathTypeHelper}");</para>
/// </example>
[Property("Manner Of Death Type Helper", Property.Types.String, "Death Certification", "Manner of Death Type.", false, IGURL.MannerOfDeath, true, 49)]
[PropertyParam("code", "The code used to describe this concept.")]
[FHIRPath("Bundle.entry.resource.where($this is Observation).where(code.coding.code='69449-7')", "")]
public string MannerOfDeathTypeHelper
{
get
{
if (MannerOfDeathType.ContainsKey("code") && !String.IsNullOrWhiteSpace(MannerOfDeathType["code"]))
{
return MannerOfDeathType["code"];
}
return null;
}
set
{
if (!String.IsNullOrWhiteSpace(value))
{
SetCodeValue("MannerOfDeathType", value, VRDR.ValueSets.MannerOfDeath.Codes);
}
}
}
/// <summary>Given name(s) of certifier.</summary>
/// <value>the certifier's name (first, middle, etc.)</value>
/// <example>
/// <para>// Setter:</para>
/// <para>string[] names = { "Doctor", "Middle" };</para>
/// <para>ExampleDeathRecord.CertifierGivenNames = names;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Certifier Given Name(s): {string.Join(", ", ExampleDeathRecord.CertifierGivenNames)}");</para>
/// </example>
[Property("Certifier Given Names", Property.Types.StringArr, "Death Certification", "Given name(s) of certifier.", true, IGURL.Certifier, true, 5)]
[FHIRPath("Bundle.entry.resource.where($this is Practitioner).where(meta.profile='http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-certifier')", "name")]
public string[] CertifierGivenNames
{
get
{
if (Certifier != null && Certifier.Name.Count() > 0)
{
return Certifier.Name.First().Given.ToArray();
}
return new string[0];
}
set
{
if (Certifier == null)
{
CreateCertifier();
}
updateGivenHumanName(value, Certifier.Name);
}
}
/// <summary>Family name of certifier.</summary>
/// <value>the certifier's family name (i.e. last name)</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.CertifierFamilyName = "Last";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Certifier's Last Name: {ExampleDeathRecord.CertifierFamilyName}");</para>
/// </example>
[Property("Certifier Family Name", Property.Types.String, "Death Certification", "Family name of certifier.", true, IGURL.Certifier, true, 6)]
[FHIRPath("Bundle.entry.resource.where($this is Practitioner).where(meta.profile='http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-certifier')", "name")]
public string CertifierFamilyName
{
get
{
if (Certifier != null && Certifier.Name.Count() > 0)
{
return Certifier.Name.First().Family;
}
return null;
}
set
{
if (Certifier == null)
{
CreateCertifier();
}
HumanName name = Certifier.Name.FirstOrDefault();
if (name != null && !String.IsNullOrEmpty(value))
{
name.Family = value;
}
else if (!String.IsNullOrEmpty(value))
{
name = new HumanName();
name.Use = HumanName.NameUse.Official;
name.Family = value;
Certifier.Name.Add(name);
}
}
}
/// <summary>Certifier's Suffix.</summary>
/// <value>the certifier's suffix</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.CertifierSuffix = "Jr.";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Certifier Suffix: {ExampleDeathRecord.CertifierSuffix}");</para>
/// </example>
[Property("Certifier Suffix", Property.Types.String, "Death Certification", "Certifier's Suffix.", true, IGURL.Certifier, true, 7)]
[FHIRPath("Bundle.entry.resource.where($this is Practitioner).where(meta.profile='http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-certifier')", "name")]
public string CertifierSuffix
{
get
{
if (Certifier != null && Certifier.Name.Count() > 0 && Certifier.Name.First().Suffix.Count() > 0)
{
return Certifier.Name.First().Suffix.First();
}
return null;
}
set
{
if (Certifier == null)
{
CreateCertifier();
}
HumanName name = Certifier.Name.FirstOrDefault();
if (name != null && !String.IsNullOrEmpty(value))
{
string[] suffix = { value };
name.Suffix = suffix;
}
else if (!String.IsNullOrEmpty(value))
{
name = new HumanName();
name.Use = HumanName.NameUse.Official;
string[] suffix = { value };
name.Suffix = suffix;
Certifier.Name.Add(name);
}
}
}
/// <summary>Certifier's Address.</summary>
/// <value>the certifier's address. A Dictionary representing an address, containing the following key/value pairs:
/// <para>"addressLine1" - address, line one</para>
/// <para>"addressLine2" - address, line two</para>
/// <para>"addressCity" - address, city</para>
/// <para>"addressCounty" - address, county</para>
/// <para>"addressState" - address, state</para>
/// <para>"addressZip" - address, zip</para>
/// <para>"addressCountry" - address, country</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>Dictionary<string, string> address = new Dictionary<string, string>();</para>
/// <para>address.Add("addressLine1", "123 Test Street");</para>
/// <para>address.Add("addressLine2", "Unit 3");</para>
/// <para>address.Add("addressCity", "Boston");</para>
/// <para>address.Add("addressCounty", "Suffolk");</para>
/// <para>address.Add("addressState", "MA");</para>
/// <para>address.Add("addressZip", "12345");</para>
/// <para>address.Add("addressCountry", "US");</para>
/// <para>ExampleDeathRecord.CertifierAddress = address;</para>
/// <para>// Getter:</para>
/// <para>foreach(var pair in ExampleDeathRecord.CertifierAddress)</para>
/// <para>{</para>
/// <para> Console.WriteLine($"\tCertifierAddress key: {pair.Key}: value: {pair.Value}");</para>
/// <para>};</para>
/// </example>
[Property("Certifier Address", Property.Types.Dictionary, "Death Certification", "Certifier's Address.", true, IGURL.Certifier, true, 8)]
[PropertyParam("addressLine1", "address, line one")]
[PropertyParam("addressLine2", "address, line two")]
[PropertyParam("addressCity", "address, city")]
[PropertyParam("addressCounty", "address, county")]
[PropertyParam("addressState", "address, state")]
[PropertyParam("addressStnum", "address, stnum")]
[PropertyParam("addressPredir", "address, predir")]
[PropertyParam("addressPostdir", "address, postdir")]
[PropertyParam("addressStname", "address, stname")]
[PropertyParam("addressStrdesig", "address, strdesig")]
[PropertyParam("addressUnitnum", "address, unitnum")]
[PropertyParam("addressZip", "address, zip")]
[PropertyParam("addressCountry", "address, country")]
[FHIRPath("Bundle.entry.resource.where($this is Practitioner).where(meta.profile='http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-certifier')", "address")]
public Dictionary<string, string> CertifierAddress
{
get
{
if (Certifier == null)
{
return (new Dictionary<string, string>());
}
return AddressToDict(Certifier.Address.FirstOrDefault());
}
set
{
if (Certifier == null)
{
CreateCertifier();
}
Certifier.Address.Clear();
Certifier.Address.Add(DictToAddress(value));
}
}
/// <summary>Certifier Identifier ** not mapped to IJE **.</summary>
/// <value>the certifier identification. A Dictionary representing a system (e.g. NPI) and a value, containing the following key/value pairs:
/// <para>"system" - the identifier system, e.g. US NPI</para>
/// <para>"value" - the idetifier value, e.g. US NPI number</para>
/// </value>
/// <example>
/// <para>// Setter:</para>
/// <para>Dictionary<string, string> identifier = new Dictionary<string, string>();</para>
/// <para>identifier.Add("system", "http://hl7.org/fhir/sid/us-npi");</para>
/// <para>identifier.Add("value", "1234567890");</para>
/// <para>ExampleDeathRecord.CertifierIdentifier = identifier;</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"\tCertifier Identifier: {ExampleDeathRecord.CertifierIdentifier['value']}");</para>
/// </example>
[Property("Certifier Identifier", Property.Types.Dictionary, "Death Certification", "Certifier Identifier.", true, IGURL.Certifier, false, 10)]
[PropertyParam("system", "The identifier system.")]
[PropertyParam("value", "The identifier value.")]
[FHIRPath("Bundle.entry.resource.where($this is Practitioner).where(meta.profile='http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-certifier')", "identifier")]
public Dictionary<string, string> CertifierIdentifier
{
get
{
if (Certifier == null || Certifier.Identifier.FirstOrDefault() == null)
{
return new Dictionary<string, string>();
}
Identifier identifier = Certifier.Identifier.FirstOrDefault();
var result = new Dictionary<string, string>();
result["system"] = identifier.System;
result["value"] = identifier.Value;
return result;
}
set
{
if (Certifier == null)
{
CreateCertifier();
}
if (Certifier.Identifier.Count > 0)
{
Certifier.Identifier.Clear();
}
if (value.ContainsKey("system") && value.ContainsKey("value"))
{
Identifier identifier = new Identifier();
identifier.System = value["system"];
identifier.Value = value["value"];
Certifier.Identifier.Add(identifier);
}
}
}
// /// <summary>Certifier License Number. ** NOT MAPPED TO IJE ** </summary>
// /// <value>A string containing the certifier license number.</value>
// /// <example>
// /// <para>// Setter:</para>
// /// <para>ExampleDeathRecord.CertifierQualification = qualification;</para>
// /// <para>// Getter:</para>
// /// <para>Console.WriteLine($"\tCertifier Qualification: {ExampleDeathRecord.CertifierQualification['display']}");</para>
// /// </example>
// [Property("Certifier License Number", Property.Types.String, "Death Certification", "Certifier License Number.", true, "http://build.fhir.org/ig/HL7/vrdr/StructureDefinition-VRDR-Certifier.html", false, 11)]
// [FHIRPath("Bundle.entry.resource.where($this is Practitioner).where(meta.profile='http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-certifier')", "qualification")]
// public string CertifierLicenseNumber
// {
// get
// {
// Practitioner.QualificationComponent qualification = Certifier.Qualification.FirstOrDefault();
// if (qualification != null && qualification.Identifier.FirstOrDefault() != null)
// {
// if (!String.IsNullOrWhiteSpace(qualification.Identifier.First().Value))
// {
// return qualification.Identifier.First().Value;
// }
// return null;
// }
// return null;
// }
// set
// {
// if (Certifier.Qualification.FirstOrDefault() == null)
// {
// Practitioner.QualificationComponent qualification = new Practitioner.QualificationComponent();
// Identifier identifier = new Identifier();
// identifier.Value = value;
// qualification.Identifier.Add(identifier);
// Certifier.Qualification.Add(qualification);
// }
// else
// {
// Certifier.Qualification.First().Identifier.Clear();
// Identifier identifier = new Identifier();
// identifier.Value = value;
// Certifier.Qualification.First().Identifier.Add(identifier);
// }
// }
// }
/// <summary>Significant conditions that contributed to death but did not result in the underlying cause.
/// Corresponds to part 2 of item 32 of the U.S. Standard Certificate of Death.</summary>
/// <value>A string containing the significant conditions that contributed to death but did not result in
/// the underlying cause captured by a CauseOfDeathCondition.</value>
/// <example>
/// <para>// Setter:</para>
/// <para>ExampleDeathRecord.ContributingConditions = "Example Contributing Condition";</para>
/// <para>// Getter:</para>
/// <para>Console.WriteLine($"Cause: {ExampleDeathRecord.ContributingConditions}");</para>
/// </example>
[Property("Contributing Conditions", Property.Types.String, "Death Certification", "Significant conditions that contributed to death but did not result in the underlying cause.", true, IGURL.CauseOfDeathPart2, true, 100)]
[FHIRPath("Bundle.entry.resource.where($this is Observation).where(code.coding.code='69441-4')", "")]
public string ContributingConditions
{
get
{
if (ConditionContributingToDeath != null && ConditionContributingToDeath.Value != null)
{
return (CodeableConceptToDict((CodeableConcept)ConditionContributingToDeath.Value))["text"];
}
return null;
}
set
{
if (String.IsNullOrWhiteSpace(value))
{
return;
}
if (ConditionContributingToDeath != null)
{
ConditionContributingToDeath.Value = new CodeableConcept(null, null, null, value);
}
else
{
ConditionContributingToDeath = new Observation();