简体   繁体   中英

Search a FHIR server for a specific resource id

I am using Hapi FHIR DSTU2 HL7Org. In my application, I need to create a MedicationOrder and provide the possibility of updating/ deleting erroneous entries. I have the id, patientId, etc of the created MedicationOrder, but writing a code with where clause is pretty problematic. In all the examples I have seen, entries like

where(Patient.FAMILY.matches().value("duck") 

presents, but I get SP_PATIENT, SP_STATUS, etc.

FhirContext ctx = FhirContext.forDstu2Hl7Org();
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
Bundle bundle = client.search().forResource(MedicationOrder.class).where(MedicationOrder.SP_PATIENT.equals("patientId")).returnBundle(Bundle.class).encodedXml().prettyPrint().execute();

The above code does not compile saying "The method where(ICriterion) in the type IQuery is not applicable for the arguments (boolean)". I could not manage to create any IQuery object.

Can someone please instruct me how to proceed?

This is a bit of a weird one- the DSTU2 HL7Org structures were created at a point where we hadn't yet brought all of the model features over from HAPI's structures into the HL7Org ones. Those "non-SP" criterion constants are one of the things we hadn't copied over.

The good news is that you can still use the ones from the DSTU2 or DSTU3 structures if you want, even if you are using the DSTU2-Hl7Org structures. You could do this with something like:

FhirContext ctx = FhirContext.forDstu2Hl7Org();
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
Bundle bundle = client.search().forResource(MedicationOrder.class).where(ca.uhn.fhir.model.dstu2.resource.MedicationOrder.PATIENT.matches().value("duck")).returnBundle(Bundle.class).encodedXml().prettyPrint().execute();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM