public static void main(String[] args) throws Exception { FhirContext ctx = FhirContext.forDstu2(); String fileName = "src/main/resources/vs/dstu2/all-valuesets-bundle.xml"; FileReader fr = new FileReader(fileName); Bundle b = ctx.newXmlParser().parseResource(Bundle.class, fr); for (Entry nextEntry : b.getEntry()) { BaseResource nextRes = (BaseResource) nextEntry.getResource(); nextRes.setText(new NarrativeDt()); } File f = new File(fileName); OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(f, false), "UTF-8"); ctx.newXmlParser().encodeResourceToWriter(b, fw); fw.close(); ourLog.info("Fixed {} valuesets", b.getEntry().size()); }
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = newXmlParser.parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, vs); for (Entry nextEntry : bundle.getEntry()) { ca.uhn.fhir.model.dstu2.resource.ValueSet nextVs = (ca.uhn.fhir.model.dstu2.resource.ValueSet) nextEntry.getResource(); parseValueSet(nextVs);
private void filterBundle(ca.uhn.fhir.model.dstu2.resource.Bundle theBundle) { for (Iterator<Entry> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
IResource res = nextReqEntry.getResource(); IdDt nextResourceId = null; if (res != null) { String matchUrl = nextEntry.getRequest().getIfNoneExist(); if (isNotBlank(matchUrl)) { IFhirResourceDao<?> resourceDao = getDao(nextEntry.getResource().getClass()); Set<Long> val = resourceDao.processMatchUrl(matchUrl); if (val.size() > 1) {
if (subResponseEntry.getResource() == null) { subResponseEntry.setResource(nextResponseBundle.getEntry().get(0).getResource());
ValidationResult eresult = validator.validateWithResult(entry.getResource()); if (!eresult.isSuccessful()) { for (SingleValidationMessage emessage : eresult.getMessages()) { System.out.println(parser.encodeResourceToString(entry.getResource())); System.out.println("ERROR: " + emessage.getMessage()); validationErrors.add(emessage.getMessage()); if (entry.getResource() instanceof DiagnosticReport) { DiagnosticReport report = (DiagnosticReport) entry.getResource(); if (report.getPerformer().isEmpty()) { validationErrors.add("Performer is a required field on DiagnosticReport!");
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Entry next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdDt id = new IdDt(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IResource res = (IResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
private <T extends IResource> Collection<T> asCollection(Bundle results) { List<T> list = new ArrayList<>(); for (Bundle.Entry entry : results.getEntry()) { list.add((T) entry.getResource()); } return list; }
IResource res = nextReqEntry.getResource(); IdDt nextResourceId = null; if (res != null) { String matchUrl = nextEntry.getRequest().getIfNoneExist(); if (isNotBlank(matchUrl)) { IFhirResourceDao<?> resourceDao = getDao(nextEntry.getResource().getClass()); Set<Long> val = resourceDao.processMatchUrl(matchUrl); if (val.size() > 1) {
Bundle bundle = ctx.newXmlParser().parseResource(Bundle.class, new InputStreamReader(valuesetText)); for (Entry next : bundle.getEntry()) { ValueSet nextVs = (ValueSet) next.getResource(); myNameToValueSetUrl.put(nextVs.getName(), nextVs.getUrl());
int count = 1; for (Entry i : bundle.getEntry()) { ValueSet next = (ValueSet) i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless()); count = 1; for (Entry i : bundle.getEntry()) { ValueSet next = (ValueSet) i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless()); count = 1; for (Entry i : bundle.getEntry()) { ValueSet next = (ValueSet) i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless());
if (input instanceof Bundle) { for (Entry nextEntry : ((Bundle) input).getEntry()) { if (nextEntry.getResource() != null) { nextEntry.getResource().getText().getDiv().setValueAsString((String) null); nextEntry.getResource().getText().getStatus().setValueAsString((String) null);
if ("Subscription".equals(next.getResource().getResourceName()) || "DataElement".equals(next.getResource().getResourceName()) || "OperationOutcome".equals(next.getResource().getResourceName()) || "OperationDefinition".equals(next.getResource().getResourceName())) { ourLog.info("Skipping " + next.getResource().getResourceName() + " example"); iterator.remove(); } else { IdDt resourceId = new IdDt(next.getResource().getResourceName() + "/EX" + next.getResource().getId().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); next.getResource().setId(resourceId); } else { ourLog.info("Discarding resource with not explicit ID"); for (Iterator<Entry> iterator = bundle.getEntry().iterator(); iterator.hasNext(); ) { Entry next = iterator.next(); if (next.getResource().getId().getIdPart() != null) { String nextId = next.getResource().getId().getValue(); next.getRequest().setMethod(HTTPVerbEnum.PUT); next.getRequest().setUrl(nextId); List<ResourceReferenceInfo> refs = ctx.newTerser().getAllResourceReferences(next.getResource()); for (ResourceReferenceInfo nextRef : refs) {
if (subResponseEntry.getResource() == null) { subResponseEntry.setResource(nextResponseBundle.getEntry().get(0).getResource());
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Entry next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdDt id = new IdDt(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IResource res = (IResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }