LinuxForHealth / hl7v2-fhir-converter

Converts HL7 v2 Messages to FHIR Resources
Apache License 2.0
85 stars 34 forks source link

Bundle.type must be either 'batch' or 'transaction'. #64

Open sueschm opened 3 years ago

sueschm commented 3 years ago

Bundle type is collection, it needs to be changed it to transaction/batch ** These types take a request field on each entry, which indicates that, for example, it should be PUT into Patient/2342

JSON file that was generated

{ "resourceType": "Bundle", "id": "711e839f-f1d1-4e9d-807c-4bfedfeec08e", "meta": { "lastUpdated": "2021-03-17T20:08:12.174+00:00" }, "type": "collection", "entry": [ { "fullUrl": "urn:uuid:Patient/863d3aea-54d8-4349-8e02-cf43bb45d47e", "resource": { "resourceType": "Patient", "id": "863d3aea-54d8-4349-8e02-cf43bb45d47e", "identifier": [ { "value": "KL_000945", "assigner": { "reference": "Organization/MRN" } } ], "name": [ { "family": "PatientAccuracy000945", "given": [ "Adam" ] } ], "gender": "male", "birthDate": "1967-03-11" } }, { "fullUrl": "urn:uuid:Organization/MRN", "resource": { "resourceType": "Organization", "id": "MRN", "name": "Assigning Authority" } }, { "fullUrl": "urn:uuid:DiagnosticReport/81e388d7-f4f4-46fa-94d0-ef1cc1857006", "resource": { "resourceType": "DiagnosticReport", "id": "81e388d7-f4f4-46fa-94d0-ef1cc1857006", "identifier": [ { "value": "CD_000945" } ], "status": "final", "code": { "coding": [ { "code": "2244", "display": "General Order" } ], "text": "General Order" }, "subject": { "reference": "Patient/863d3aea-54d8-4349-8e02-cf43bb45d47e" }, "effectiveDateTime": "2017-08-25T01:05:00+08:00", "resultsInterpreter": [ { "reference": "Practitioner/05103a18-1e53-463e-ab20-4ca1cec6a41e" } ] } }, { "fullUrl": "urn:uuid:Practitioner/05103a18-1e53-463e-ab20-4ca1cec6a41e", "resource": { "resourceType": "Practitioner", "id": "05103a18-1e53-463e-ab20-4ca1cec6a41e", "identifier": [ { "value": "770600" } ], "name": [ { "text": "1234 A", "prefix": [ "1234" ], "suffix": [ "A" ] } ] } } ] }

ssnowski commented 3 years ago

To elaborate, "must be either batch or transaction" is an error that will come back from a fhir server (in our case, the IBM fhir server)

As of 1.0.5, there is a flag to change the bundle type that can be used to set it to a batch or transaction to allow it to be taken, but the resulting fhir created is not compliant: it does not have a request in each entry (specification as per https://www.hl7.org/fhir/bundle.html#invs constraint bdl-3). This can be reproduced with:

ConverterOptions converterOptions = new ConverterOptions.Builder().withBundleType(Bundle.BundleType.BATCH).withValidateResource().build();
new HL7ToFHIRConverter().convert(
    "MSH|^~\\&|AccMgr|1|||20050110045504||ADT^A01|599102|P|2.3||| \n" +
    "EVN|A01|20050110045502||||| \n" +
    "PID|1||10006579^^^1^MRN^1||DUCK^DONALD^D||19241010|M||1|111 DUCK ST^^FOWL^CA^999990000^^M|1|8885551212|8885551212|1|2||40007716^^^AccMgr^VN^1|123121234|||||||||||NO \n" +
    "PV1|1|I|PREOP^101^1^1^^^S|3|||37^DISNEY^WALT^^^^^^AccMgr^^^^CI|||01||||1|||37^DISNEY^WALT^^^^^^AccMgr^^^^CI|2|40007716^^^AccMgr^VN|4|||||||||||||||||||1||G|||20050110045253|||||"
    , converterOptions);

Which results in error java.lang.IllegalArgumentException: Validation issues encountered. Bundle bdl-3: entry.request mandatory for batch/transaction/history, otherwise prohibited [entry.all(request.exists() = ((%resource.type = 'batch') or (%resource.type = 'transaction') or (%resource.type = 'history')))] ERROR