none
Medications dose RRS feed

  • Question

  • Getting an "Object not set to an instance..." error.

    Trying to create a dose entry in a medication item:

    if ((medications_dose_structured_value != null && medications_dose_structured_value != string.Empty) && (medications_dose_structured_units != null && medications_dose_structured_units != string.Empty))
                            {
                                StructuredMeasurement dose_structured = new StructuredMeasurement(Convert.ToDouble(medications_dose_structured_value), new CodableValue(medications_dose_structured_units));
                                medication_push.Dose.Structured.Add(dose_structured);
                            }

    Thanks,
    Gary
    Tuesday, February 2, 2010 9:44 PM

Answers

  • Hello Gary,

    Before you assign the value to dose structured collection, you need to set the value to Dose. You will get the Object reference error when dose value is not assigned.

    Please check the sample code:

    medication.Dose = new GeneralMeasurement("some value");

    StructuredMeasurement dose_structured = new StructuredMeasurement(Convert.ToDouble(medications_dose_structured_value), new CodableValue(medications_dose_structured_units));
    medication.Dose.Structured.Add(dose_structured);


    -Mahesh
    Tuesday, February 2, 2010 11:51 PM

All replies

  • Hello Gary,

    Before you assign the value to dose structured collection, you need to set the value to Dose. You will get the Object reference error when dose value is not assigned.

    Please check the sample code:

    medication.Dose = new GeneralMeasurement("some value");

    StructuredMeasurement dose_structured = new StructuredMeasurement(Convert.ToDouble(medications_dose_structured_value), new CodableValue(medications_dose_structured_units));
    medication.Dose.Structured.Add(dose_structured);


    -Mahesh
    Tuesday, February 2, 2010 11:51 PM
  • Thanks Mahesh.
    Wednesday, February 3, 2010 2:40 AM