locked
Adding Lab Test Results RRS feed

  • Question

  •  

    Hi,

     

    We are currently integrating our reference lab application with HV, and would like to insert lab results into PHRs.  My code currently looks like this:

     

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    List<LabTestResultGroup> groups = new List<LabTestResultGroup>();

    LabTestResultGroup grp = new LabTestResultGroup(new CodableValue("CBC With Differential/Platelet"));

    grp.LaboratoryName = new Organization("MB");

    grp.Status = new CodableValue("C");

    groups.Add(grp);

     

    LabTestResults ltr = new LabTestResults(groups);

    ltr.OrderedBy = new Organization("39502605");

    ltr.When = new ApproximateDateTime("2008-01-26 20:05:00.000");

     

    LabTestType test = new LabTestType();

    test.CollectionMethod = new CodableValue("MethodBig Smileraw");

    test.Description = "Monocytes";

    test.Name = "015131";

    test.Status = new CodableValue("F");

    test.When = new HealthServiceDateTime(DateTime.Parse("2008-01-26 06:56:00.000"));

     

    LabResultType result = new LabResultType();

    test.Result = result;

    result.ReferenceRange = new DoubleRange(4, 13);

    result.TextValue = "19";

    result.Unit = new CodableValue("%");

    result.Value = 19;

     

    // How to add the LabTestType to LabTestResults?

     

    PersonInfo.SelectedRecord.NewItem(ltr);

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     

    Notice the comment in my code above.  After I have a LabTestResults instance, how do I assign the list of LabTestType objects to it?  Also, how would I describe the above using XML?  

     

    Thanks in advance,

    Jad Startin 

    Wednesday, August 20, 2008 9:40 PM

Answers

  • The lab result types are a bit confusing right now, since there are two sets of types. This will get better as soon as the platform versioning work is done (coming soon), as we'll be able to get rid of the old (original) lab results types.

     

    I wrote a version of what you wrote for the current lab test results type. I coded the test to a loinc test (since that was handy). You'll want to revisit that and figure out how to handle the date/time part.

     

    Here's the code. If you want to see the XML representation, I think the easiest thing to do is to turn on request/response tracing and look at the XML in the log file.

     

    LabTestResults ltr = new LabTestResults();

    ltr.OrderedBy = new Organization("39502605");

    ltr.When = new ApproximateDateTime("2008-01-26 20:05:00.000");

    LabTestResultGroup grp = new LabTestResultGroup(new CodableValue("CBC With Differential/Platelet"));

    grp.LaboratoryName = new Organization("MB");

    grp.Status = new CodableValue("C");

    ltr.Groups.Add(grp);

    LabTestResultDetails details = new LabTestResultDetails();

    details.CollectionMethod = new CodableValue("Methodraw");

    details.ClinicalCode = new CodableValue("Monocytes", new CodedValue("11112-0", "loinc", "regenstrief", "2.22")); // code to a real vocab (loinc?) here...

    details.Name = "Monocytes";

    details.Status = new CodableValue("F");

    details.When = new ApproximateDateTime(); // needs to be set to a real value - was DateTime.Parse("2008-01-26 06:56:00.000"));

    details.Value = new LabTestResultValue();

    details.Value.Ranges.Add(new TestResultRange(new CodableValue("ReferenceRange"), new DoubleRange(4, 13)));

    details.Value.Measurement = new GeneralMeasurement();

    details.Value.Measurement.Display = "19%";

    details.Value.Measurement.Structured.Add(new StructuredMeasurement(19, new CodableValue("%", new CodedValue("pcnt", "lab-results-units"))));

    grp.Results.Add(details);

    PersonInfo.SelectedRecord.NewItem(ltr);

     

    Hope that helps.

    Wednesday, August 20, 2008 11:23 PM

All replies

  • The lab result types are a bit confusing right now, since there are two sets of types. This will get better as soon as the platform versioning work is done (coming soon), as we'll be able to get rid of the old (original) lab results types.

     

    I wrote a version of what you wrote for the current lab test results type. I coded the test to a loinc test (since that was handy). You'll want to revisit that and figure out how to handle the date/time part.

     

    Here's the code. If you want to see the XML representation, I think the easiest thing to do is to turn on request/response tracing and look at the XML in the log file.

     

    LabTestResults ltr = new LabTestResults();

    ltr.OrderedBy = new Organization("39502605");

    ltr.When = new ApproximateDateTime("2008-01-26 20:05:00.000");

    LabTestResultGroup grp = new LabTestResultGroup(new CodableValue("CBC With Differential/Platelet"));

    grp.LaboratoryName = new Organization("MB");

    grp.Status = new CodableValue("C");

    ltr.Groups.Add(grp);

    LabTestResultDetails details = new LabTestResultDetails();

    details.CollectionMethod = new CodableValue("Methodraw");

    details.ClinicalCode = new CodableValue("Monocytes", new CodedValue("11112-0", "loinc", "regenstrief", "2.22")); // code to a real vocab (loinc?) here...

    details.Name = "Monocytes";

    details.Status = new CodableValue("F");

    details.When = new ApproximateDateTime(); // needs to be set to a real value - was DateTime.Parse("2008-01-26 06:56:00.000"));

    details.Value = new LabTestResultValue();

    details.Value.Ranges.Add(new TestResultRange(new CodableValue("ReferenceRange"), new DoubleRange(4, 13)));

    details.Value.Measurement = new GeneralMeasurement();

    details.Value.Measurement.Display = "19%";

    details.Value.Measurement.Structured.Add(new StructuredMeasurement(19, new CodableValue("%", new CodedValue("pcnt", "lab-results-units"))));

    grp.Results.Add(details);

    PersonInfo.SelectedRecord.NewItem(ltr);

     

    Hope that helps.

    Wednesday, August 20, 2008 11:23 PM
  • Hi Eric,

     

    This worked great!  Thanks for your help.  For anyone interested, here is a fixed up version showing a test with 3 results:

     

    LabTestResults ltr = new LabTestResults();

    ltr.OrderedBy = new Organization("39502605");

    ltr.When = new ApproximateDateTime(new ApproximateDate(2008, 1, 26), new ApproximateTime(20, 5));

    ltr.When.Description = "2008-01-26 20:05:00.000";

     

    LabTestResultGroup grp = new LabTestResultGroup(new CodableValue("CBC With Differential/Platelet"));

    grp.LaboratoryName = new Organization("MB");

    grp.Status = new CodableValue("C");

    ltr.Groups.Add(grp);

     

    LabTestResultDetails details = new LabTestResultDetails();

    details.CollectionMethod = new CodableValue("Method-Draw");

    details.ClinicalCode = new CodableValue("015131", new CodedValue("015131", "custom-result-codes", "LCA", "12.9"));

    details.Name = "Monocytes";

    details.Status = new CodableValue("C");

    details.When = new ApproximateDateTime(new ApproximateDate(2008, 1, 26), new ApproximateTime(6, 56));

    details.When.Description = "2008-01-26 06:56:00.000";

    details.Value = new LabTestResultValue();

    details.Value.Ranges.Add(new TestResultRange(new CodableValue("ReferenceRange"), new DoubleRange(4, 13)));

    details.Value.Measurement = new GeneralMeasurement();

    details.Value.Measurement.Display = "19%";

    details.Value.Measurement.Structured.Add(new StructuredMeasurement(19, new CodableValue("%", new CodedValue("pcnt", "lab-results-units"))));

    details.Value.Flag.Add(new CodableValue("H", new CodedValue("H", "lab-result-flag")));

    grp.Results.Add(details);

     

    details = new LabTestResultDetails();

    details.CollectionMethod = new CodableValue("Method-Draw");

    details.ClinicalCode = new CodableValue("015172", new CodedValue("015172", "custom-result-codes", "LCA", "12.9"));

    details.Name = "Platelets";

    details.Status = new CodableValue("C");

    details.When = new ApproximateDateTime(new ApproximateDate(2008, 1, 26), new ApproximateTime(6, 56));

    details.When.Description = "2008-01-26 06:56:00.000";

    details.Value = new LabTestResultValue();

    details.Value.Ranges.Add(new TestResultRange(new CodableValue("ReferenceRange"), new DoubleRange(140, 415)));

    details.Value.Measurement = new GeneralMeasurement();

    details.Value.Measurement.Display = "262 x10E3/uL";

    details.Value.Measurement.Structured.Add(new StructuredMeasurement(262, new CodableValue("x10E3/uL", new CodedValue("k-per-ul", "lab-results-units"))));

    grp.Results.Add(details);

     

    details = new LabTestResultDetails();

    details.CollectionMethod = new CodableValue("Method-Draw");

    details.ClinicalCode = new CodableValue("015107", new CodedValue("015107", "custom-result-codes", "LCA", "12.9"));

    details.Name = "Neutrophils";

    details.Status = new CodableValue("C");

    details.When = new ApproximateDateTime(new ApproximateDate(2008, 1, 26), new ApproximateTime(6, 56));

    details.When.Description = "2008-01-26 06:56:00.000";

    details.Value = new LabTestResultValue();

    details.Value.Ranges.Add(new TestResultRange(new CodableValue("ReferenceRange"), new DoubleRange(40, 74)));

    details.Value.Measurement = new GeneralMeasurement();

    details.Value.Measurement.Display = "38%";

    details.Value.Measurement.Structured.Add(new StructuredMeasurement(38, new CodableValue("%", new CodedValue("pcnt", "lab-results-units"))));

    details.Value.Flag.Add(new CodableValue("L", new CodedValue("L", "lab-result-flag")));

    grp.Results.Add(details);

     

    PersonInfo.SelectedRecord.NewItem(ltr);

    PopulateLabTestsTable();

     

    Thanks,

    Jad

     

    Thursday, August 21, 2008 11:22 PM