private StructureDefinition resolveProfile(StructureDefinition profile, String pr) { if (pr.startsWith("#")) { for (Resource r : profile.getContained()) { if (r.getId().equals(pr.substring(1)) && r instanceof StructureDefinition) return (StructureDefinition) r; } return null; } else { long t = System.nanoTime(); StructureDefinition fr = context.fetchResource(StructureDefinition.class, pr); sdTime = sdTime + (System.nanoTime() - t); return fr; } }
private static void copy(FhirContext theCtx, IGenericClient theTarget, String theResType, List<IBaseResource> theQueued, Set<String> theSent, Bundle theReceived) { for (Bundle.BundleEntryComponent nextEntry : theReceived.getEntry()) { Resource nextResource = nextEntry.getResource(); nextResource.setId(theResType + "/" + "CR-" + nextResource.getIdElement().getIdPart()); boolean haveUnsentReference = false; for (ResourceReferenceInfo nextRefInfo : theCtx.newTerser().getAllResourceReferences(nextResource)) { IIdType nextRef = nextRefInfo.getResourceReference().getReferenceElement(); if (nextRef.hasIdPart()) { String newRef = nextRef.getResourceType() + "/" + "CR-" + nextRef.getIdPart(); ourLog.info("Changing reference {} to {}", nextRef.getValue(), newRef); nextRefInfo.getResourceReference().setReference(newRef); if (!theSent.contains(newRef)) { haveUnsentReference = true; } } } if (haveUnsentReference) { ourLog.info("Queueing {} for delivery after", nextResource.getId()); theQueued.add(nextResource); continue; } IIdType newId = theTarget .update() .resource(nextResource) .execute() .getId(); ourLog.info("Copied resource {} and got ID {}", nextResource.getId(), newId); theSent.add(nextResource.getIdElement().toUnqualifiedVersionless().getValue()); } }
private ValueSet resolveBindingReference(DomainResource ctxt, Type reference, String uri) { if (reference instanceof UriType) { long t = System.nanoTime(); ValueSet fr = context.fetchResource(ValueSet.class, ((UriType) reference).getValue().toString()); txTime = txTime + (System.nanoTime() - t); return fr; } else if (reference instanceof Reference) { String s = ((Reference) reference).getReference(); if (s.startsWith("#")) { for (Resource c : ctxt.getContained()) { if (c.getId().equals(s.substring(1)) && (c instanceof ValueSet)) return (ValueSet) c; } return null; } else { long t = System.nanoTime(); String ref = ((Reference) reference).getReference(); if (!Utilities.isAbsoluteUrl(ref)) ref = resolve(uri, ref); ValueSet fr = context.fetchResource(ValueSet.class, ref); txTime = txTime + (System.nanoTime() - t); return fr; } } else return null; }
private Questionnaire getQuestionnaire(QuestionnaireResponse theAnswers, Reference theQuestionnaireRef) { Questionnaire retVal; String value = theQuestionnaireRef.getReferenceElement().getValue(); if (theQuestionnaireRef.getReferenceElement().isLocal()) { retVal = (Questionnaire) theQuestionnaireRef.getResource(); if (retVal == null) { for (Resource next : theAnswers.getContained()) { if (value.equals(next.getId())) { retVal = (Questionnaire) next; } } } } else { retVal = myWorkerCtx.fetchResource(Questionnaire.class, value); } return retVal; }
nextEntry.getRequest().setMethod(HTTPVerb.PUT); if (next.getIdElement().isAbsolute()) { nextEntry.getRequest().setUrl(next.getId()); } else { String resourceType = myContext.getResourceDefinition(next).getName();
private ValueSet getValueSet(QuestionnaireResponse theResponse, Reference theQuestionnaireRef) { ValueSet retVal; if (theQuestionnaireRef.getReferenceElement().isLocal()) { retVal = (ValueSet) theQuestionnaireRef.getResource(); if (retVal == null) { for (Resource next : theResponse.getContained()) { if (theQuestionnaireRef.getReferenceElement().getValue().equals(next.getId())) { retVal = (ValueSet) next; } } } } else { retVal = myWorkerCtx.fetchResource(ValueSet.class, theQuestionnaireRef.getReferenceElement().getValue()); } return retVal; }
@Override public String getIdBase() { return getId(); }
public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.instance.model.Resource tgt) throws FHIRException { tgt.setId(src.getId()); if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); }
private static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { if (src.hasId()) tgt.setId(src.getId()); if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); }
private StructureDefinition resolveProfile(StructureDefinition profile, String pr) { if (pr.startsWith("#")) { for (Resource r : profile.getContained()) { if (r.getId().equals(pr.substring(1)) && r instanceof StructureDefinition) return (StructureDefinition) r; } return null; } else { long t = System.nanoTime(); StructureDefinition fr = context.fetchResource(StructureDefinition.class, pr); sdTime = sdTime + (System.nanoTime() - t); return fr; } }
public StructureDefinition getProfile(StructureDefinition source, String url) { StructureDefinition profile = null; String code = null; if (url.startsWith("#")) { profile = source; code = url.substring(1); } else if (context != null) { String[] parts = url.split("\\#"); profile = context.fetchResource(StructureDefinition.class, parts[0]); code = parts.length == 1 ? null : parts[1]; } if (profile == null) return null; if (code == null) return profile; for (Resource r : profile.getContained()) { if (r instanceof StructureDefinition && r.getId().equals(code)) return (StructureDefinition) r; } return null; }
private ValueSet resolveBindingReference(DomainResource ctxt, Type reference, String uri) { if (reference instanceof UriType) { long t = System.nanoTime(); ValueSet fr = context.fetchResource(ValueSet.class, ((UriType) reference).getValue().toString()); txTime = txTime + (System.nanoTime() - t); return fr; } else if (reference instanceof Reference) { String s = ((Reference) reference).getReference(); if (s.startsWith("#")) { for (Resource c : ctxt.getContained()) { if (c.getId().equals(s.substring(1)) && (c instanceof ValueSet)) return (ValueSet) c; } return null; } else { long t = System.nanoTime(); String ref = ((Reference) reference).getReference(); if (!Utilities.isAbsoluteUrl(ref)) ref = resolve(uri, ref); ValueSet fr = context.fetchResource(ValueSet.class, ref); txTime = txTime + (System.nanoTime() - t); return fr; } } else return null; }
private Questionnaire getQuestionnaire(QuestionnaireResponse theAnswers, Reference theQuestionnaireRef) { Questionnaire retVal; String value = theQuestionnaireRef.getReferenceElement().getValue(); if (theQuestionnaireRef.getReferenceElement().isLocal()) { retVal = (Questionnaire) theQuestionnaireRef.getResource(); if (retVal == null) { for (Resource next : theAnswers.getContained()) { if (value.equals(next.getId())) { retVal = (Questionnaire) next; } } } } else { retVal = myWorkerCtx.fetchResource(Questionnaire.class, value); } return retVal; }
private ValueSet getValueSet(QuestionnaireResponse theResponse, Reference theQuestionnaireRef) { ValueSet retVal; if (theQuestionnaireRef.getReferenceElement().isLocal()) { retVal = (ValueSet) theQuestionnaireRef.getResource(); if (retVal == null) { for (Resource next : theResponse.getContained()) { if (theQuestionnaireRef.getReferenceElement().getValue().equals(next.getId())) { retVal = (ValueSet) next; } } } } else { retVal = myWorkerCtx.fetchResource(ValueSet.class, theQuestionnaireRef.getReferenceElement().getValue()); } return retVal; }
public static void main(String[] theArgs) { FhirContext ctx = FhirContext.forDstu3(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3"); // Build a search and execute it Bundle response = client.search() .forResource(Patient.class) .where(Patient.NAME.matches().value("Test")) .and(Patient.BIRTHDATE.before().day("2014-01-01")) .count(100) .returnBundle(Bundle.class) .execute(); // How many resources did we find? System.out.println("Responses: " + response.getTotal()); // Print the ID of the first one System.out.println("First response ID: " + response.getEntry().get(0).getResource().getId()); } }
public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.instance.model.Resource tgt) throws FHIRException { tgt.setId(src.getId()); if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); }
private static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { if (src.hasId()) tgt.setId(src.getId()); if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); }
b = getParam(vars, tgt.getParameter().get(0)); if (b instanceof Resource) return new UriType("urn:uuid:"+((Resource) b).getId()); else throw new FHIRException("Rule \""+ruleId+"\": Transform engine cannot point at an element of type "+b.fhirType());