/
ParticipantMaker.cs
132 lines (117 loc) · 4.54 KB
/
ParticipantMaker.cs
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
using System.Collections.Generic;
using Hl7.Fhir.Model;
namespace EPSFHIR
{
class ParticipantMaker
{
private Practitioner practitioner = null;
private PractitionerRole role = null;
private Organization organisation = null;
public Practitioner Practitioner => practitioner;
public PractitionerRole Role => role;
public Organization Organisation => organisation;
public ParticipantMaker()
{
}
public void Make(int b, List<string> rx)
{
practitioner = new Practitioner();
role = new PractitionerRole();
organisation = new Organization();
DoPractitioner(b, rx);
DoOrg(b, rx);
DoRole(b, rx);
}
private void DoPractitioner(int b, List<string> rx)
{
practitioner.Id = FhirHelper.MakeId();
HumanName h = new HumanName
{
Text = rx[b + EMUData.PERSONNAME]
};
List<HumanName> ah = new List<HumanName>
{
h
};
practitioner.Name = ah;
practitioner.Identifier.Add(FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/sds-user-id", rx[b + EMUData.SDSUSERID]));
}
private void DoOrg(int b, List<string> rx)
{
organisation.Id = FhirHelper.MakeId();
organisation.Identifier.Add(FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/ods-organization-code",rx[b + EMUData.SDSORGANISATIONID]));
ContactPoint cp = new ContactPoint
{
System = ContactPoint.ContactPointSystem.Phone,
Use = ContactPoint.ContactPointUse.Work,
Value = rx[b + EMUData.ORGANISATIONTELECOM]
};
organisation.Telecom.Add(cp);
CodeableConcept cc = new CodeableConcept();
cc.Coding.Add(FhirHelper.MakeCoding("https://fhir.nhs.uk/R4/CodeSystem/organisation-type", rx[b + EMUData.ORGANISATIONTYPE], null));
organisation.Type.Add(cc);
organisation.Name = rx[b + EMUData.ORGANISATIONNAME];
organisation.Address.Add(MakeAddress(b, rx));
Identifier pct = FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/ods-organization-code", rx[b + EMUData.PCTORGANISATIONSDSID]);
ResourceReference pctref = new ResourceReference
{
Identifier = pct
};
organisation.PartOf = pctref;
}
private Address MakeAddress(int b, List<string> rx)
{
Address a = new Address();
AddIfValue(a, rx[b + EMUData.ORGANISATIONADDRESSLINE1]);
AddIfValue(a, rx[b + EMUData.ORGANISATIONADDRESSLINE2]);
AddIfValue(a, rx[b + EMUData.ORGANISATIONADDRESSLINE3]);
AddIfValue(a, rx[b + EMUData.ORGANISATIONADDRESSLINE4]);
AddIfValue(a, rx[b + EMUData.ORGANISATIONADDRESSLINE5]);
a.PostalCode = rx[b + EMUData.ORGANISATIONPOSTCODE];
return a;
}
private void AddIfValue(Address a, string s)
{
if (s.Trim().Length > 0)
a.LineElement.Add(new FhirString(s));
}
private void DoRole(int b, List<string> rx)
{
role.Id = FhirHelper.MakeId();
role.Identifier.Add(FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/sds-role-profile-id", rx[b + EMUData.ROLEPROFILE]));
role.Practitioner = FhirHelper.MakeInternalReference(practitioner);
role.Organization = FhirHelper.MakeInternalReference(organisation);
ContactPoint cp = new ContactPoint
{
System = ContactPoint.ContactPointSystem.Phone,
Use = ContactPoint.ContactPointUse.Work,
Value = rx[b + EMUData.ORGANISATIONTELECOM]
};
role.Telecom.Add(cp);
}
public bool Has(Practitioner p)
{
if (practitioner == null)
return false;
if (p == null)
return false;
return practitioner.IsExactly(p);
}
public bool Has(PractitionerRole r)
{
if (role == null)
return false;
if (r == null)
return false;
return role.IsExactly(r);
}
public bool Has(Organization o)
{
if (organisation == null)
return false;
if (o == null)
return false;
return organisation.IsExactly(o);
}
}
}