How POST object type of Parameters (using c#, Hl7.Fhir.DSTU2.0.50.0)

512 views
Skip to first unread message

a.g.na...@gmail.com

unread,
Mar 14, 2019, 4:46:58 AM3/14/19
to Cerner FHIR Developers
Hi.

I need POST object type of Parameters.
My attemp do this:

                Parameters.ParametersParameterComponent componentMedication = new Parameters.ParametersParameterComponent();
                componentMedication.Name = "medicationprescription";
                componentMedication.Resource = medication;
                parameters.Parameter.Add(componentMedication);

                Parameters.ParametersParameterComponent componentDigitalSignature = new Parameters.ParametersParameterComponent();
                componentDigitalSignature.Name = "DigitalSignature";

                string baseJSONPath = AppDomain.CurrentDomain.BaseDirectory + "JSONTests\\";
                string tmpString = string.Empty;
                using (StreamReader inputFileJSON = new StreamReader(Path.Combine(baseJSONPath, "Test.json.p7s")))
                {
                    tmpString = inputFileJSON.ReadToEnd();
                }
                componentDigitalSignature.Value = new Base64Binary(Encoding.UTF8.GetBytes(tmpString));
                parameters.Parameter.Add(componentDigitalSignature);

                parameters = fhirConnection.client.Create<Parameters>(parameters);

If I call this code, I have some exceptions.

I generate JSON file and send it to servce, they run it and tell me, all ok.

                string parametersJSON = Hl7.Fhir.Serialization.FhirSerializer.SerializeToJson(parameters, false, null);
                using (StreamWriter outputFileJSON = new StreamWriter(Path.Combine(baseJSONPath, "TestParameters.json"), false, Encoding.UTF8))
                {
                    outputFileJSON.Write(parametersJSON);
                }

If i need creates all other types - no problem. For example:

                    // create new Patient object
                    Hl7.Fhir.Model.Patient newPat = new Hl7.Fhir.Model.Patient();

                    newPat.Identifier = new List<Identifier>(1);
                    newPat.Identifier.Add(new Identifier("http://uiip.bas-net.by/hl7/fhir/patient-medication-card", parameters[5]));

                    newPat.Active = true;

                    // create a human name list item and add it to the new patient
                    List<string> famName = new List<string>();
                    famName.Add(parameters[0]);
                    List<string> givName = new List<string>();
                    givName.Add(parameters[1]);
                    givName.Add(parameters[2]);
                    HumanName hn = new HumanName { Family = famName, Given = givName };
                    hn.Use = HumanName.NameUse.Usual;
                    newPat.Name = new List<HumanName>();
                    newPat.Name.Add(hn);
                                       
                    // add DOB and gender
                    newPat.BirthDate = parameters[3];
                    switch (parameters[4])
                    {
                        case "Male":
                            newPat.Gender = AdministrativeGender.Male;
                            break;
                        case "Female":
                            newPat.Gender = AdministrativeGender.Female;
                            break;
                        default:
                            newPat.Gender = AdministrativeGender.Unknown;
                            break;
                    }

                    OrganizationV2 organizationV2 = new OrganizationV2(_fhirConnection);
                    Organization organization = (Organization)organizationV2.Read(Properties.Settings.Default.ProductOrganizationId);
                    newPat.ManagingOrganization = new ResourceReference();
                    newPat.ManagingOrganization.Reference = "Organization/" + organization.Id;

                    newPat = _fhirConnection.client.Create(newPat);

May be use fhirConnection.client.Transaction, or Bundle. For example - my patients search using bundle:

        public List<Patient> SearchByIdentifier<Patient>(string identifier) where Patient : DomainResource
        {
            List<Patient> searchList = new List<Patient>();
            try
            {
                var query = new string[] { "identifier=http://uiip.bas-net.by/hl7/fhir/patient-medication-card|" + identifier };
                var bundle = _fhirConnection.client.Search("Patient", query);

                foreach (BundleEntryComponent entry in bundle.Entry)
                    searchList.Add((Patient)entry.Resource);
            }
            catch (Exception exception)
            {
                Exception_DXItem item = new Exception_DXItem("Пациент - поиск по номеру карты.", exception);
                item.ShowDialog();
            }
            return searchList;
        }

Can anybody help me?

Michele Mottini

unread,
Mar 14, 2019, 10:01:07 AM3/14/19
to Cerner FHIR Developers
This group is for question about the Cerner FHIR implementation - it appears that you are trying to connect to a different server?

  - Michele
  CareEvolution Inc

Reply all
Reply to author
Forward
0 new messages