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 static void AddPatientGp(Patient p, System.Collections.Generic.List <string> rx)
        {
            ResourceReference r = new ResourceReference
            {
                Identifier = FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/ods-organization-code", rx[EMUData.PATIENTPRIMARYCAREPROVIDESDSID])
            };

            p.ManagingOrganization = r;
        }
        private static Identifier MakeGroupIdentifier(System.Collections.Generic.List <string> rx)
        {
            Identifier sfid = FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/prescription-short-form",
                                                        rx[EMUData.PRESCRIPTIONID]);
            Extension e = FhirHelper.MakeExtension(null, "https://fhir.nhs.uk/R4/StructureDefinition/Extension-PrescriptionId",
                                                   FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/prescription", rx[EMUData.PRESCRIPTIONCLINICALSTATEMENTID]));

            sfid.Extension.Add(e);
            return(sfid);
        }
        private static MessageHeader.MessageSourceComponent MakeSource()
        {
            MessageHeader.MessageSourceComponent s = new MessageHeader.MessageSourceComponent();
            Extension a = FhirHelper.MakeExtension("https://fhir.nhs.uk/R4/StructureDefinition/Extension-spineEndpoint",
                                                   FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/spine-ASID", asid));

            s.Extension.Add(a);
            s.Name     = ods;
            s.Endpoint = url;
            return(s);
        }
        private static ResourceReference GetNominatedPharmacyReference(System.Collections.Generic.List <string> rx)
        {
            ResourceReference r = null;
            string            n = rx[EMUData.NOMINATEDPHARMACYID].Trim();

            if (n.Length > 0)
            {
                r = new ResourceReference
                {
                    Identifier = FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/ods-organization-code", n)
                };
            }
            return(r);
        }
        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);
        }
        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 static void AddNhsNumber(Patient p, System.Collections.Generic.List <string> rx)
        {
            currentNhsNumber = rx[EMUData.PATIENTID];
            Identifier n   = FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/nhs-number", rx[EMUData.PATIENTID]);
            Extension  evs = new Extension
            {
                Url = "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus"
            };
            CodeableConcept vccvs = new CodeableConcept();

            vccvs.Coding.Add(FhirHelper.MakeCoding("https://fhir.nhs.uk/R4/CodeSystem/UKCore-NHSNumberVerificationStatus",
                                                   "01", "Number present and verified"));
            evs.Value = vccvs;
            n.Extension.Add(evs);
            p.Identifier.Add(n);
        }
        private static MedicationRequest MakeMedicationRequest(Patient p, System.Collections.Generic.List <string> rx,
                                                               System.Collections.Generic.List <string> item, ResourceReference nom, ParticipantMaker a)
        {
            MedicationRequest m = new MedicationRequest
            {
                Id = FhirHelper.MakeId()
            };

            m.Status  = MedicationRequest.medicationrequestStatus.Active;
            m.Intent  = MedicationRequest.medicationRequestIntent.Order;
            m.Subject = FhirHelper.MakeInternalReference(p);
            m.Identifier.Add(FhirHelper.MakeIdentifier("https://fhir.nhs.uk/Id/prescription-line-id", item[EMUData.LINEITEMID]));
            ResourceReference rq = FhirHelper.MakeInternalReference(a.Role);

            rq.Display        = a.Practitioner.Name[0].Text;
            m.Requester       = rq;
            m.AuthoredOn      = rx[EMUData.AUTHORPARTICIPATIONTIME];
            m.GroupIdentifier = MakeGroupIdentifier(rx);

            DoPrescriptionType(m, rx);
            DoResponsiblePractitioner(m, a);
            m.Medication          = DoMedication(item);
            m.CourseOfTherapyType = MakeCourseOfTherapyType(rx);
            if (item[EMUData.DOSAGEINTRUCTIONS].Trim().Length > 0)
            {
                Dosage di = new Dosage
                {
                    Text = item[EMUData.DOSAGEINTRUCTIONS]
                };
                m.DosageInstruction.Add(di);
                if (item[EMUData.ADDITIONALINSTRUCTIONS].Trim().Length > 0)
                {
                    di.PatientInstruction = item[EMUData.ADDITIONALINSTRUCTIONS];
                }
            }
            m.DispenseRequest = MakeDispenseRequest(nom, rx, item);
            return(m);
        }