you first step is to create class objects to represent the JSON. then you need to write queries and create the objects. the sample JSON is very hierarchal and may require server queries.
there are a number of tools to convert the JSON to c# classes. here is my result (you might want to rename the class Root to something more intuitive:
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class Address
{
public string AddressLine1 { get; set; }
public string City { get; set; }
public string StateProvince { get; set; }
public string PostalCode { get; set; }
public string CountryCode { get; set; }
public string AddressLine2 { get; set; }
}
public class Body
{
public NewRx NewRx { get; set; }
}
public class CommunicationNumbers
{
public PrimaryTelephone PrimaryTelephone { get; set; }
public Fax Fax { get; set; }
}
public class DateOfBirth
{
public string Date { get; set; }
}
public class DEASchedule
{
public string Code { get; set; }
}
public class DigitalSignature
{
[JsonProperty("@Version")]
public string Version { get; set; }
public string DigitalSignatureIndicator { get; set; }
}
public class DrugCoded
{
public DrugDBCode DrugDBCode { get; set; }
public DEASchedule DEASchedule { get; set; }
}
public class DrugDBCode
{
public string Code { get; set; }
public string Qualifier { get; set; }
}
public class Fax
{
public string Number { get; set; }
}
public class From
{
[JsonProperty("@Qualifier")]
public string Qualifier { get; set; }
[JsonProperty("#text")]
public string text { get; set; }
}
public class Header
{
public To To { get; set; }
public From From { get; set; }
public string MessageID { get; set; }
public DateTime SentTime { get; set; }
public Security Security { get; set; }
public SenderSoftware SenderSoftware { get; set; }
public DigitalSignature DigitalSignature { get; set; }
}
public class HumanPatient
{
public Name Name { get; set; }
public string Gender { get; set; }
public DateOfBirth DateOfBirth { get; set; }
public Address Address { get; set; }
}
public class Identification
{
public string NCPDPID { get; set; }
public string NPI { get; set; }
}
public class MedicationPrescribed
{
public string DrugDescription { get; set; }
public DrugCoded DrugCoded { get; set; }
public Quantity Quantity { get; set; }
public WrittenDate WrittenDate { get; set; }
public string Substitutions { get; set; }
public string NumberOfRefills { get; set; }
public Sig Sig { get; set; }
}
public class Message
{
[JsonProperty("@DatatypesVersion")]
public string DatatypesVersion { get; set; }
[JsonProperty("@TransportVersion")]
public string TransportVersion { get; set; }
[JsonProperty("@TransactionDomain")]
public string TransactionDomain { get; set; }
[JsonProperty("@TransactionVersion")]
public string TransactionVersion { get; set; }
[JsonProperty("@StructuresVersion")]
public string StructuresVersion { get; set; }
[JsonProperty("@ECLVersion")]
public string ECLVersion { get; set; }
public Header Header { get; set; }
public Body Body { get; set; }
}
public class Name
{
public string LastName { get; set; }
public string FirstName { get; set; }
}
public class NewRx
{
public Patient Patient { get; set; }
public Pharmacy Pharmacy { get; set; }
public Prescriber Prescriber { get; set; }
public MedicationPrescribed MedicationPrescribed { get; set; }
}
public class NonVeterinarian
{
public Identification Identification { get; set; }
public Name Name { get; set; }
public Address Address { get; set; }
public CommunicationNumbers CommunicationNumbers { get; set; }
}
public class Password
{
[JsonProperty("@Type")]
public string Type { get; set; }
[JsonProperty("#text")]
public string text { get; set; }
}
public class Patient
{
public HumanPatient HumanPatient { get; set; }
}
public class Pharmacy
{
public Identification Identification { get; set; }
public string Specialty { get; set; }
public string BusinessName { get; set; }
public Address Address { get; set; }
public CommunicationNumbers CommunicationNumbers { get; set; }
}
public class Prescriber
{
public NonVeterinarian NonVeterinarian { get; set; }
}
public class PrimaryTelephone
{
public string Number { get; set; }
}
public class Quantity
{
public string Value { get; set; }
public string CodeListQualifier { get; set; }
public QuantityUnitOfMeasure QuantityUnitOfMeasure { get; set; }
}
public class QuantityUnitOfMeasure
{
public string Code { get; set; }
}
public class Receiver
{
public string SecondaryIdentification { get; set; }
public string TertiaryIdentification { get; set; }
}
public class Root
{
public Message Message { get; set; }
}
public class Security
{
public UsernameToken UsernameToken { get; set; }
public Sender Sender { get; set; }
public Receiver Receiver { get; set; }
}
public class Sender
{
public string SecondaryIdentification { get; set; }
public string TertiaryIdentification { get; set; }
}
public class SenderSoftware
{
public string SenderSoftwareDeveloper { get; set; }
public string SenderSoftwareProduct { get; set; }
public string SenderSoftwareVersionRelease { get; set; }
}
public class Sig
{
public string SigText { get; set; }
}
public class To
{
[JsonProperty("@Qualifier")]
public string Qualifier { get; set; }
[JsonProperty("#text")]
public string text { get; set; }
}
public class UsernameToken
{
public string Username { get; set; }
public Password Password { get; set; }
public string Nonce { get; set; }
public DateTime Created { get; set; }
}
public class WrittenDate
{
public string Date { get; set; }
}