OHSUCMP / ecp-sds-hardfork

eCare Plan Supplemental Data Store (hard-forked from hapi-fhir-jpaserver-starter v6.4.0)
Apache License 2.0
0 stars 4 forks source link

error PUTting a foreign Patient resource due to referenced Practitioner resource not existing first #5

Open mattStorer opened 1 year ago

mattStorer commented 1 year ago

trying to PUT a foreign Patient resource, I got it to get through the interceptors, but the PUT still fails due to a referenced Practitioner resource:

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "HAPI-1094: Resource Practitioner/eYqt1o5Ia40Eyx.wYDJdvUA3 not found, specified in path: Patient.generalPractitioner"
        }
    ]
}

this is the Patient resource whose PUT generated the error above:

{
    "resourceType": "Patient",
    "id": "eFTHaVbQzCEwOEE97maN2MC2jJi-r8nnkhRh.umMUlz03",
    "extension": [
        {
            "extension": [
                {
                    "valueCoding": {
                        "system": "urn:oid:2.16.840.1.113883.6.238",
                        "code": "1002-5",
                        "display": "American Indian or Alaska Native"
                    },
                    "url": "ombCategory"
                },
                {
                    "valueString": "American Indian/Alaska Native",
                    "url": "text"
                }
            ],
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"
        },
        {
            "extension": [
                {
                    "valueString": "Unknown",
                    "url": "text"
                }
            ],
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"
        },
        {
            "valueCodeableConcept": {
                "coding": [
                    {
                        "system": "urn:oid:1.2.840.114350.1.13.135.3.7.10.698084.130.657370.909258",
                        "code": "female",
                        "display": "female"
                    }
                ]
            },
            "url": "http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"
        },
        {
            "valueCodeableConcept": {
                "coding": [
                    {
                        "system": "http://hl7.org/fhir/gender-identity",
                        "code": "female",
                        "display": "female"
                    }
                ]
            },
            "url": "http://hl7.org/fhir/StructureDefinition/patient-genderIdentity"
        },
        {
            "valueCode": "F",
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"
        }
    ],
    "identifier": [
        {
            "use": "usual",
            "type": {
                "text": "CEID"
            },
            "system": "urn:oid:1.2.840.114350.1.13.135.3.7.3.688884.100",
            "value": "O123CMS1P4X6DJV"
        },
        {
            "use": "usual",
            "type": {
                "text": "EPI"
            },
            "system": "urn:oid:1.2.840.114350.1.13.135.2.7.5.737384.0",
            "value": "E3764677"
        },
        {
            "use": "usual",
            "type": {
                "text": "EXTERNAL"
            },
            "system": "urn:oid:1.2.840.114350.1.13.135.3.7.2.698084",
            "value": "Z4444395"
        },
        {
            "use": "usual",
            "type": {
                "text": "FHIR"
            },
            "system": "http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id",
            "value": "TDw5Hf-X5yLps-OKfCUNxadDxocQq8tKGQlu6FB5FWhMB"
        },
        {
            "use": "usual",
            "type": {
                "text": "FHIR STU3"
            },
            "system": "http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id",
            "value": "eFTHaVbQzCEwOEE97maN2MC2jJi-r8nnkhRh.umMUlz03"
        },
        {
            "use": "usual",
            "type": {
                "text": "INTERNAL"
            },
            "system": "urn:oid:1.2.840.114350.1.13.135.3.7.2.698084",
            "value": "  Z4444395"
        },
        {
            "use": "usual",
            "type": {
                "text": "MYCHARTLOGIN"
            },
            "system": "urn:oid:1.2.840.114350.1.13.135.3.7.3.878082.110",
            "value": "ROSEFHIR"
        },
        {
            "use": "usual",
            "type": {
                "text": "PA0"
            },
            "system": "urn:oid:2.16.840.1.113883.3.2076.2.100",
            "value": "03102837"
        },
        {
            "use": "usual",
            "type": {
                "text": "WPRINTERNAL"
            },
            "system": "urn:oid:1.2.840.114350.1.13.135.3.7.2.878082",
            "value": "1356699"
        },
        {
            "use": "usual",
            "system": "https://open.epic.com/FHIR/StructureDefinition/PayerMemberId",
            "value": "26500002"
        },
        {
            "use": "usual",
            "system": "https://open.epic.com/FHIR/StructureDefinition/PayerMemberId",
            "value": "220046021"
        },
        {
            "use": "usual",
            "system": "https://open.epic.com/FHIR/StructureDefinition/PayerMemberId",
            "value": "LEG10015632"
        }
    ],
    "active": true,
    "name": [
        {
            "use": "old",
            "text": "FHIR,ROSIE ONE",
            "family": "Fhir",
            "given": [
                "Rosie",
                "One"
            ]
        },
        {
            "use": "old",
            "text": "FHIR,ROSIE",
            "family": "Fhir",
            "given": [
                "Rosie"
            ]
        },
        {
            "use": "official",
            "text": "Rose Pink Fhir",
            "family": "Fhir",
            "given": [
                "Rose",
                "Pink"
            ]
        },
        {
            "use": "usual",
            "text": "Rosie Pink Fhir",
            "family": "Fhir",
            "given": [
                "Rosie",
                "Pink"
            ]
        }
    ],
    "telecom": [
        {
            "system": "phone",
            "value": "503-555-1234",
            "use": "home"
        },
        {
            "system": "phone",
            "value": "503-555-1234",
            "use": "mobile"
        }
    ],
    "gender": "female",
    "birthDate": "1975-01-23",
    "deceasedBoolean": false,
    "address": [
        {
            "use": "old",
            "line": [
                "4321 NO WAY"
            ],
            "city": "PORTLAND",
            "district": "MULTNOMAH",
            "state": "OR",
            "postalCode": "97201",
            "country": "US"
        },
        {
            "use": "home",
            "line": [
                "4321 NO WAY"
            ],
            "city": "PORTLAND",
            "district": "MULTNOMAH",
            "state": "OR",
            "postalCode": "97201",
            "country": "US"
        }
    ],
    "maritalStatus": {
        "text": "Married"
    },
    "contact": [
        {
            "relationship": [
                {
                    "coding": [
                        {
                            "system": "urn:oid:1.2.840.114350.1.13.135.3.7.4.827665.1000",
                            "code": "16",
                            "display": "Spouse"
                        }
                    ],
                    "text": "Spouse"
                }
            ],
            "name": {
                "use": "usual",
                "text": "Walker FHIR"
            },
            "telecom": [
                {
                    "system": "phone",
                    "value": "503-555-4912",
                    "use": "mobile"
                }
            ]
        },
        {
            "relationship": [
                {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v2-0131",
                            "code": "E",
                            "display": "Employer"
                        }
                    ]
                }
            ],
            "organization": {
                "display": "Lam Research"
            }
        }
    ],
    "communication": [
        {
            "language": {
                "coding": [
                    {
                        "system": "urn:ietf:bcp:47",
                        "code": "en",
                        "display": "English"
                    }
                ],
                "text": "English"
            },
            "preferred": true
        }
    ],
    "generalPractitioner": [
        {
            "reference": "Practitioner/eYqt1o5Ia40Eyx.wYDJdvUA3",
            "type": "Practitioner",
            "display": "Christopher P Terndrup, MD"
        }
    ],
    "managingOrganization": {
        "reference": "Organization/eOJWft-Ij4QZs2h6ZeYdnuA3",
        "display": "Oregon Health & Science Univ"
    }
}

Note that it's likely that if we first PUT the referenced Practitioner, that we'll get another similar error for the referenced Organization.

This raises an issue about resource dependencies, and means we will need to be very, very intentional about the order in which we try to recreate a patient record in the SDS. It may be the case that certain resources are referenced that we can't read due to scoping issues. Or there could potentially be something ugly like a cyclical dependency, where A references B and B references A, which would necessitate having both resources and writing them both at the same time in a Bundle using the contained construct.

This could get very complicated.