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.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 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?