FHIR Chat · sample code · Vital Signs

Stream: Vital Signs

Topic: sample code


view this post on Zulip Eric Mays (May 14 2020 at 16:56):

public List<Observation> getObservations(String id, String start, String end, String system, String code)
        throws Exception {
    IQuery<IBaseBundle> query = client.search() //
            .forResource(Observation.class) //
            .where(Observation.CODE.exactly().systemAndCode(system, code)) //
            .and(Observation.SUBJECT.hasId(id));
    if (start != null) {
        Date date = Date.from(LocalDate.parse(start).atStartOfDay().minusDays(2).toInstant(ZoneOffset.UTC));
        query = query.and(Observation.DATE.afterOrEquals().day(date));
    }
    if (end != null) {
        Date date = Date.from(LocalDate.parse(end).atStartOfDay().plusDays(2).toInstant(ZoneOffset.UTC));
        query = query.and(Observation.DATE.beforeOrEquals().day(date));
    }
    Bundle results = query.returnBundle(Bundle.class).execute();
    // Log the results
    // logger.info(ContextUtil.getContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(results));
    ArrayList<Observation> ret = new ArrayList<>();
    ret.addAll(getEntries(results));
    while (results.getLink(Bundle.LINK_NEXT) != null) {
        results = client.loadPage().next(results).execute();
        ret.addAll(getEntries(results));
    }
    ArrayList<Observation> fret = new ArrayList<>();
    for (Observation obs : ret) {
        DateTimeType eff = obs.getEffectiveDateTimeType();
        if ((start == null || eff.after(parseDate(start, eff, false)))
                && (end == null || eff.before(parseDate(end, eff, true)))) {
            fret.add(obs);
        }
    }
    return fret;
}

view this post on Zulip Eric Mays (May 14 2020 at 16:57):

public List<Observation> getBloodPressures(Patient patient) throws Exception {
    return getBloodPressures(patient.getId());
}

public List<Observation> getBloodPressures(String id) throws Exception {
    return getBloodPressures(id, null, null);
}

public List<Observation> getBloodPressures(Patient patient, String start, String end) throws Exception {
    return getBloodPressures(patient.getId(), start, end);
}

public List<Observation> getBloodPressures(String id, String start, String end) throws Exception {
    return getObservations(id, start, end, LoincCode.system, LoincCode.Bp.getCode());
}

view this post on Zulip Eric Mays (May 14 2020 at 16:58):

public List<Observation> getAverageBloodPressures(Patient patient) throws Exception {
    return getAverageBloodPressures(patient.getId());
}

public List<Observation> getAverageBloodPressures(String id) throws Exception {
    return getAverageBloodPressures(id, null, null);
}

public List<Observation> getAverageBloodPressures(Patient patient, String start, String end) throws Exception {
    return getAverageBloodPressures(patient.getId(), start, end);
}

public List<Observation> getAverageBloodPressures(String id, String start, String end) throws Exception {
    return getObservations(id, start, end, SnomedConcept.system, "" + SnomedConcept.AverageBp.getSctid());
}

view this post on Zulip Eric Mays (May 14 2020 at 17:01):

// 723232008 |Average blood pressure (observable entity)|
AverageBp(723232008, "Average blood pressure (observable entity)"),
// 314440001 |Average systolic blood pressure (observable entity)|
AverageSbp(314440001, "Average systolic blood pressure (observable entity)"),
// 314453003 |Average diastolic blood pressure (observable entity)|
AverageDbp(314453003, "Average diastolic blood pressure (observable entity)"),
// 364075005 |Heart rate (observable entity)|

view this post on Zulip Claude Nanjo (May 14 2020 at 17:20):

Hi Eric, it looks like we cannot support two FHIR servers at a time, at least for the setup we have for the connectathon so we will have to import the data. Is the last data set you provided to me the latest or do you want to send me an updated set? I will then import it into our FHIR server. This will simulate the pull from the aggregator for now.

view this post on Zulip Eric Mays (May 14 2020 at 17:32):

The data I sent should be close enough, but here's the latest
ATC-med-2-cimi-avgs.json ATC-med-2-cimi.json

view this post on Zulip Claude Nanjo (May 14 2020 at 17:34):

Out of the pair, which one should I use in determining whether the patient's blood pressure is in control? I assume the clinically valid average?

view this post on Zulip Eric Mays (May 14 2020 at 17:38):

Yes, use IHM_AVERAGE_IHM_BP_7. For this data I think they are all clinically valid.

view this post on Zulip Claude Nanjo (May 14 2020 at 17:38):

Perfect. Thank you.

view this post on Zulip Claude Nanjo (May 14 2020 at 18:07):

I noticed the algorithm in in the notes. It works for me but when I was generating data to test out the use case, I had it in the algorithm extension:
{
"resourceType": "Observation",
"extension": [
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/BodyPositionExt",
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "33586001",
"display": "Sitting position (finding)"
}
]
}
},
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/MeasurementDeviceExt",
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "720738005",
"display": "Blood pressure cuff, adult size large (physical object)"
}
]
}
},
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/MeasurementSettingExt",
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "264362003",
"display": "Home (environment)"
}
]
}
},
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/AlgorithmForBloodPressureAverageExt",
"extension": [
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/AlgorithmTypeExt",
"valueCodeableConcept": {
"text": "IHM_AVERAGE_IHM_BP_7"
}
},
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/TimeWindowExt",
"valueQuantity": {
"value": 10,
"unit": "d"
}
},
{
"url": "http://hl7.org/fhir/hspc/StructureDefinition/SetSizeExt",
"valueInteger": 30
}
]
}
],
"status": "final",
"code": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "723232008",
"display": "Average blood pressure (observable entity)"
}
],
"text": "Average Home Blood Pressure Panel"
},
"subject": {
"reference": "Patient/X1000003"
},
"effectiveDateTime": "2020-05-13T20:34:03-07:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "17137000",
"display": "Structure of brachial artery (body structure)"
}
]
},
"method": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "17146006",
"display": "Arterial pressure monitoring, non-invasive method (regime/therapy)"
}
]
},
"component": [
{
"code": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "314453003",
"display": "Average diastolic blood pressure (observable entity)"
}
],
"text": "Diastolic blood pressure"
},
"valueQuantity": {
"value": 96,
"unit": "mmHg"
}
},
{
"code": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "314440001",
"display": "Average systolic blood pressure (observable entity)"
}
],
"text": "Systolic blood pressure"
},
"valueQuantity": {
"value": 148,
"unit": "mmHg"
}
}
]
}

view this post on Zulip Eric Mays (May 14 2020 at 18:31):

OK, if you could work with the note that would be great. There are some issues with the completeness of the algorithm extension and the use of codeable concept.


Last updated: Apr 12 2022 at 19:14 UTC