use of org.hl7.fhir.dstu3.model.Account in project org.hl7.fhir.core by hapifhir.
the class TurtleTests method test_account_example.
@Test
public void test_account_example() throws FileNotFoundException, IOException, Exception {
System.out.println("account-example.ttl");
new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\account-example.ttl"));
}
use of org.hl7.fhir.dstu3.model.Account in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeEncounter.
protected void composeEncounter(Complex parent, String parentType, String name, Encounter element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Encounter", name, element, index);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Encounter", "identifier", element.getIdentifier().get(i), i);
if (element.hasStatusElement())
composeEnum(t, "Encounter", "status", element.getStatusElement(), -1);
for (int i = 0; i < element.getStatusHistory().size(); i++) composeEncounterStatusHistoryComponent(t, "Encounter", "statusHistory", element.getStatusHistory().get(i), i);
if (element.hasClass_())
composeCoding(t, "Encounter", "class", element.getClass_(), -1);
for (int i = 0; i < element.getClassHistory().size(); i++) composeEncounterClassHistoryComponent(t, "Encounter", "classHistory", element.getClassHistory().get(i), i);
for (int i = 0; i < element.getType().size(); i++) composeCodeableConcept(t, "Encounter", "type", element.getType().get(i), i);
if (element.hasPriority())
composeCodeableConcept(t, "Encounter", "priority", element.getPriority(), -1);
if (element.hasSubject())
composeReference(t, "Encounter", "subject", element.getSubject(), -1);
for (int i = 0; i < element.getEpisodeOfCare().size(); i++) composeReference(t, "Encounter", "episodeOfCare", element.getEpisodeOfCare().get(i), i);
for (int i = 0; i < element.getIncomingReferral().size(); i++) composeReference(t, "Encounter", "incomingReferral", element.getIncomingReferral().get(i), i);
for (int i = 0; i < element.getParticipant().size(); i++) composeEncounterEncounterParticipantComponent(t, "Encounter", "participant", element.getParticipant().get(i), i);
if (element.hasAppointment())
composeReference(t, "Encounter", "appointment", element.getAppointment(), -1);
if (element.hasPeriod())
composePeriod(t, "Encounter", "period", element.getPeriod(), -1);
if (element.hasLength())
composeDuration(t, "Encounter", "length", element.getLength(), -1);
for (int i = 0; i < element.getReason().size(); i++) composeCodeableConcept(t, "Encounter", "reason", element.getReason().get(i), i);
for (int i = 0; i < element.getDiagnosis().size(); i++) composeEncounterDiagnosisComponent(t, "Encounter", "diagnosis", element.getDiagnosis().get(i), i);
for (int i = 0; i < element.getAccount().size(); i++) composeReference(t, "Encounter", "account", element.getAccount().get(i), i);
if (element.hasHospitalization())
composeEncounterEncounterHospitalizationComponent(t, "Encounter", "hospitalization", element.getHospitalization(), -1);
for (int i = 0; i < element.getLocation().size(); i++) composeEncounterEncounterLocationComponent(t, "Encounter", "location", element.getLocation().get(i), i);
if (element.hasServiceProvider())
composeReference(t, "Encounter", "serviceProvider", element.getServiceProvider(), -1);
if (element.hasPartOf())
composeReference(t, "Encounter", "partOf", element.getPartOf(), -1);
}
use of org.hl7.fhir.dstu3.model.Account in project org.hl7.fhir.core by hapifhir.
the class Tester method main.
public static void main(String[] args) throws Exception {
IWorkerContext context = SimpleWorkerContext.fromPack(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", "validation-min.xml.zip"));
int t = 0;
int ok = 0;
for (String f : new File("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
if (f.endsWith(".xml") && !f.endsWith(".canonical.xml") && !f.contains("profile") && !f.contains("questionnaire") && new File("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl")).exists()) {
// if (f.equals("account-questionnaire.xml")) {
System.out.print("convert " + f);
// Manager.convert(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
// new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
// String src = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")));
// String tgt = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".json")));
Element e = Manager.parse(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + f), FhirFormat.XML);
Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl")), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML, OutputStyle.PRETTY, null);
String src = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl"));
String tgt = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl"));
t++;
if (src.equals(tgt)) {
System.out.println(".. ok");
ok++;
} else
System.out.println(".. fail");
}
// }
}
System.out.println("done - " + Integer.toString(t) + " files, " + Integer.toString(ok) + " ok");
}
use of org.hl7.fhir.dstu3.model.Account in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeEncounter.
protected void composeEncounter(Complex parent, String parentType, String name, Encounter element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Encounter", name, element, index);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Encounter", "identifier", element.getIdentifier().get(i), i);
if (element.hasStatusElement())
composeEnum(t, "Encounter", "status", element.getStatusElement(), -1);
for (int i = 0; i < element.getStatusHistory().size(); i++) composeEncounterStatusHistoryComponent(t, "Encounter", "statusHistory", element.getStatusHistory().get(i), i);
if (element.hasClass_())
composeCoding(t, "Encounter", "class", element.getClass_(), -1);
for (int i = 0; i < element.getClassHistory().size(); i++) composeEncounterClassHistoryComponent(t, "Encounter", "classHistory", element.getClassHistory().get(i), i);
for (int i = 0; i < element.getType().size(); i++) composeCodeableConcept(t, "Encounter", "type", element.getType().get(i), i);
if (element.hasServiceType())
composeCodeableConcept(t, "Encounter", "serviceType", element.getServiceType(), -1);
if (element.hasPriority())
composeCodeableConcept(t, "Encounter", "priority", element.getPriority(), -1);
if (element.hasSubject())
composeReference(t, "Encounter", "subject", element.getSubject(), -1);
for (int i = 0; i < element.getEpisodeOfCare().size(); i++) composeReference(t, "Encounter", "episodeOfCare", element.getEpisodeOfCare().get(i), i);
for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "Encounter", "basedOn", element.getBasedOn().get(i), i);
for (int i = 0; i < element.getParticipant().size(); i++) composeEncounterEncounterParticipantComponent(t, "Encounter", "participant", element.getParticipant().get(i), i);
for (int i = 0; i < element.getAppointment().size(); i++) composeReference(t, "Encounter", "appointment", element.getAppointment().get(i), i);
if (element.hasPeriod())
composePeriod(t, "Encounter", "period", element.getPeriod(), -1);
if (element.hasLength())
composeDuration(t, "Encounter", "length", element.getLength(), -1);
for (int i = 0; i < element.getReasonCode().size(); i++) composeCodeableConcept(t, "Encounter", "reasonCode", element.getReasonCode().get(i), i);
for (int i = 0; i < element.getReasonReference().size(); i++) composeReference(t, "Encounter", "reasonReference", element.getReasonReference().get(i), i);
for (int i = 0; i < element.getDiagnosis().size(); i++) composeEncounterDiagnosisComponent(t, "Encounter", "diagnosis", element.getDiagnosis().get(i), i);
for (int i = 0; i < element.getAccount().size(); i++) composeReference(t, "Encounter", "account", element.getAccount().get(i), i);
if (element.hasHospitalization())
composeEncounterEncounterHospitalizationComponent(t, "Encounter", "hospitalization", element.getHospitalization(), -1);
for (int i = 0; i < element.getLocation().size(); i++) composeEncounterEncounterLocationComponent(t, "Encounter", "location", element.getLocation().get(i), i);
if (element.hasServiceProvider())
composeReference(t, "Encounter", "serviceProvider", element.getServiceProvider(), -1);
if (element.hasPartOf())
composeReference(t, "Encounter", "partOf", element.getPartOf(), -1);
}
use of org.hl7.fhir.dstu3.model.Account in project org.hl7.fhir.core by hapifhir.
the class GraphQLEngine method filter.
private List<Base> filter(Resource context, Property prop, String fieldName, List<Argument> arguments, List<Base> values, boolean extensionMode) throws FHIRException, EGraphQLException {
List<Base> result = new ArrayList<Base>();
if (values.size() > 0) {
int count = Integer.MAX_VALUE;
int offset = 0;
StringBuilder fp = new StringBuilder();
for (Argument arg : arguments) {
List<Value> vl = resolveValues(arg);
if ((vl.size() != 1))
throw new EGraphQLException("Incorrect number of arguments");
if (values.get(0).isPrimitive())
throw new EGraphQLException("Attempt to use a filter (" + arg.getName() + ") on a primtive type (" + prop.getTypeCode() + ")");
if ((arg.getName().equals("fhirpath")))
fp.append(" and " + vl.get(0).toString());
else if ((arg.getName().equals("_count")))
count = Integer.valueOf(vl.get(0).toString());
else if ((arg.getName().equals("_offset")))
offset = Integer.valueOf(vl.get(0).toString());
else {
Property p = values.get(0).getNamedProperty(arg.getName());
if (p == null)
throw new EGraphQLException("Attempt to use an unknown filter (" + arg.getName() + ") on a type (" + prop.getTypeCode() + ")");
fp.append(" and " + arg.getName() + " = '" + vl.get(0).toString() + "'");
}
}
// Account for situations where the GraphQL expression selected e.g.
// effectiveDateTime but the field contains effectivePeriod
String propName = prop.getName();
List<Base> newValues = new ArrayList<>(values.size());
for (Base value : values) {
if (propName.endsWith("[x]")) {
String propNameShortened = propName.substring(0, propName.length() - 3);
if (fieldName.startsWith(propNameShortened) && fieldName.length() > propNameShortened.length()) {
if (!value.fhirType().equalsIgnoreCase(fieldName.substring(propNameShortened.length()))) {
continue;
}
}
}
newValues.add(value);
}
int i = 0;
int t = 0;
if (fp.length() == 0)
for (Base v : newValues) {
if ((i >= offset) && passesExtensionMode(v, extensionMode)) {
result.add(v);
t++;
if (t >= count)
break;
}
i++;
}
else {
ExpressionNode node = fpe.parse(fp.substring(5));
for (Base v : newValues) {
if ((i >= offset) && passesExtensionMode(v, extensionMode) && fpe.evaluateToBoolean(null, context, v, node)) {
result.add(v);
t++;
if (t >= count)
break;
}
i++;
}
}
}
return result;
}
Aggregations