use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class R3TEchnicalCorrectionProcessor method extractToPackageMaster.
private void extractToPackageMaster(List<Resource> list, String root) throws IOException, FHIRFormatError {
System.out.println("Updating Packages Master");
String corePath = Utilities.path(root, "hl7.fhir.r3.core", "package");
String examplesPath = Utilities.path(root, "hl7.fhir.r3.examples", "package");
String elementsPath = Utilities.path(root, "hl7.fhir.r3.elements", "package");
int coreTotal = new File(corePath).list().length - 1;
int examplesTotal = new File(examplesPath).list().length - 1;
int elementsTotal = new File(elementsPath).list().length - 1;
int coreCount = 0;
int examplesCount = 0;
int elementsCount = 0;
for (Resource r : list) {
String n = r.fhirType() + "-" + r.getId() + ".json";
FileOutputStream dst = null;
if (n.startsWith("DataElement-")) {
elementsCount++;
dst = new FileOutputStream(Utilities.path(elementsPath, n));
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(dst, r);
} else {
dst = new FileOutputStream(Utilities.path(examplesPath, n));
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(dst, r);
examplesCount++;
if (isCoreResource(r.fhirType())) {
coreCount++;
DomainResource dr = (DomainResource) r;
dr.setText(null);
new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(corePath, n)), r);
}
}
}
System.out.println(" Core @ " + corePath + ": Replaced " + coreCount + " of " + coreTotal);
System.out.println(" Examples @ " + examplesPath + ": Replaced " + examplesCount + " of " + examplesTotal);
System.out.println(" Elements @ " + elementsPath + ": Replaced " + elementsCount + " of " + elementsTotal);
}
use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class GraphQLEngineTests method lookup.
@Override
public ReferenceResolution lookup(Object appInfo, IBaseResource context, IBaseReference reference) throws FHIRException {
try {
if (reference.getReferenceElement().isLocal()) {
if (!(context instanceof DomainResource))
return null;
for (Resource r : ((DomainResource) context).getContained()) {
if (('#' + r.getId()).equals(reference.getReferenceElement().getValue())) {
return new ReferenceResolution(context, r);
}
}
} else {
String[] parts = reference.getReferenceElement().getValue().split("/");
String filename = TestingUtilities.resourceNameToFile(parts[0].toLowerCase() + '-' + parts[1].toLowerCase() + ".xml");
if (new File(filename).exists())
return new ReferenceResolution(null, new XmlParser().parse(new FileInputStream(filename)));
}
return null;
} catch (Exception e) {
throw new FHIRException(e);
}
}
use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class NarrativeGeneratorTests method process.
private void process(String path) throws FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
XmlParser p = new XmlParser();
DomainResource r = (DomainResource) p.parse(new FileInputStream(path));
gen.generate(r, null);
FileOutputStream s = new FileOutputStream(TestingUtilities.resourceNameToFile("gen", "gen.xml"));
new XmlParser().compose(s, r, true);
s.close();
}
use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class XmlParserBase method parseDomainResourceContained.
protected DomainResource parseDomainResourceContained(XmlPullParser xpp) throws IOException, FHIRFormatError, XmlPullParserException {
next(xpp);
int eventType = nextNoWhitespace(xpp);
if (eventType == XmlPullParser.START_TAG) {
DomainResource dr = (DomainResource) parseResource(xpp);
nextNoWhitespace(xpp);
next(xpp);
return dr;
} else {
unknownContent(xpp);
return null;
}
}
use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class DomainResource method copyValues.
public void copyValues(DomainResource dst) {
super.copyValues(dst);
dst.text = text == null ? null : text.copy();
if (contained != null) {
dst.contained = new ArrayList<Resource>();
for (Resource i : contained) dst.contained.add(i.copy());
}
;
if (extension != null) {
dst.extension = new ArrayList<Extension>();
for (Extension i : extension) dst.extension.add(i.copy());
}
;
if (modifierExtension != null) {
dst.modifierExtension = new ArrayList<Extension>();
for (Extension i : modifierExtension) dst.modifierExtension.add(i.copy());
}
;
}
Aggregations