use of org.hl7.fhir.r5.model in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7PatientFHIRConversionTest method patientNameTest.
@Test
void patientNameTest() {
String patientHasMiddleName = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + // PID 5 fields (name) are extracted and tested
"PID|1||PA123456^^^MYEMR^MR||JONES^GEORGE^Q^III^MR^^B||||||||||||||||||||\r";
Patient patientObjUsualName = PatientUtils.createPatientFromHl7Segment(ftv, patientHasMiddleName);
java.util.List<org.hl7.fhir.r4.model.HumanName> name = patientObjUsualName.getName();
List<StringType> givenName = name.get(0).getGiven();
List<StringType> suffixes = name.get(0).getSuffix();
assertThat(suffixes).hasSize(1);
List<StringType> prefixes = name.get(0).getPrefix();
assertThat(prefixes).hasSize(1);
String fullName = name.get(0).getText();
assertThat(prefixes.get(0).toString()).hasToString("MR");
assertThat(givenName.get(0).toString()).hasToString("GEORGE");
assertThat(givenName.get(1).toString()).hasToString("Q");
assertThat(suffixes.get(0).toString()).hasToString("III");
assertThat(fullName).isEqualTo("MR GEORGE Q JONES III");
}
use of org.hl7.fhir.r5.model in project VERDICT by ge-high-assurance.
the class VerdictSynthesis method performSynthesisMaxSmt.
/**
* Perform synthesis using Z3 MaxSMT.
*
* @param tree
* @param targetDal
* @param factory
* @return
* @deprecated use the multi-requirement approach instead
*/
@Deprecated
public static Optional<Pair<Set<ComponentDefense>, Double>> performSynthesisMaxSmt(DTree tree, int targetDal, DLeaf.Factory factory) {
Context context = new Context();
Optimize optimizer = context.mkOptimize();
Collection<ComponentDefense> pairs = factory.allComponentDefensePairs();
int costLcd = normalizeCosts(pairs);
for (ComponentDefense pair : pairs) {
if (pair.dalToNormCost(targetDal) > 0) {
// this id ("cover") doesn't matter but we have to specify something
optimizer.AssertSoft(context.mkNot(pair.toZ3(context)), pair.dalToNormCost(targetDal), "cover");
}
}
optimizer.Assert(tree.toZ3(context));
if (optimizer.Check().equals(Status.SATISFIABLE)) {
Set<ComponentDefense> output = new LinkedHashSet<>();
int totalNormalizedCost = 0;
Model model = optimizer.getModel();
for (ComponentDefense pair : pairs) {
Expr expr = model.eval(pair.toZ3(context), true);
switch(expr.getBoolValue()) {
case Z3_L_TRUE:
output.add(pair);
totalNormalizedCost += pair.dalToNormCost(targetDal);
break;
case Z3_L_FALSE:
break;
case Z3_L_UNDEF:
default:
throw new RuntimeException("Synthesis: Undefined variable in output model: " + pair.toString());
}
}
return Optional.of(new Pair<>(output, ((double) totalNormalizedCost) / costLcd));
} else {
System.err.println("Synthesis: SMT not satisfiable, perhaps there are unmitigatable attacks");
return Optional.empty();
}
}
use of org.hl7.fhir.r5.model in project VERDICT by ge-high-assurance.
the class VerdictSynthesis method addExtraImplDefenses.
/**
* Returns a new results instance with any extraneous defenses from the provided list added to
* the results items liset as removals.
*
* @param results the input results to use as a baseline
* @param implCompDefPairs the set of all implemented component-defense pairs
* @param costModel the cost model
* @return a new results instance with the extraneous defenses included
*/
public static ResultsInstance addExtraImplDefenses(ResultsInstance results, Map<com.ge.verdict.attackdefensecollector.Pair<String, String>, Integer> implCompDefPairs, CostModel costModel) {
List<ResultsInstance.Item> items = new ArrayList<>(results.items);
Fraction inputCost = results.inputCost;
Fraction outputCost = results.outputCost;
// find all of the pairs already in the defense tree
Set<com.ge.verdict.attackdefensecollector.Pair<String, String>> accountedCompDefPairs = results.items.stream().map(item -> new com.ge.verdict.attackdefensecollector.Pair<>(item.component, item.defenseProperty)).collect(Collectors.toSet());
for (Map.Entry<com.ge.verdict.attackdefensecollector.Pair<String, String>, Integer> entry : implCompDefPairs.entrySet()) {
// only add if not already accounted for
if (!accountedCompDefPairs.contains(entry.getKey())) {
String comp = entry.getKey().left;
String defProp = entry.getKey().right;
int implDal = entry.getValue();
// compute cost of the implemented pair
Fraction pairInputCost = costModel.cost(defProp, comp, implDal);
Fraction pairOutputCost = costModel.cost(defProp, comp, 0);
// the item will be a removal, so from implDal -> 0 DAL
items.add(new ResultsInstance.Item(comp, defProp, implDal, 0, pairInputCost, pairOutputCost));
inputCost = inputCost.add(pairInputCost);
// this may seem silly, but in theory we can have a non-zero cost for DAL 0
outputCost = outputCost.add(pairOutputCost);
}
}
return new ResultsInstance(results.partialSolution, results.meritAssignment, results.inputSat, inputCost, outputCost, items);
}
use of org.hl7.fhir.r5.model in project modello by codehaus-plexus.
the class PackageVersionVerifier method testModelAddMailingList.
public void testModelAddMailingList() {
Model model = new Model();
model.addMailingList(createMailingList(0));
model.addMailingList(createMailingList(1));
model.addMailingList(createMailingList(2));
List actual = model.getMailingLists();
Assert.assertEquals("/model/mailinglists.size", 3, actual.size());
for (int i = 0; i < 3; i++) {
assertMailingList(createMailingList(i), (MailingList) actual.get(i));
}
}
use of org.hl7.fhir.r5.model in project cqf-ruler by DBCG.
the class CompositionSectionComponentBuilder method initializeDstu2_1.
@Override
protected void initializeDstu2_1(T theResource) {
super.initializeDstu2_1(theResource);
org.hl7.fhir.dstu2016may.model.Composition.SectionComponent section = (org.hl7.fhir.dstu2016may.model.Composition.SectionComponent) theResource;
section.setTitle(myTitle).setId(getId());
getEntries().forEach(entry -> section.addEntry(new Reference(entry)));
if (myText != null) {
Narrative narrative = new Narrative();
narrative.setStatusAsString(myText.getStatus());
narrative.setDivAsString(myText.getText());
section.setText(narrative);
}
// no focus
}
Aggregations