Merge pull request #762 from hapifhir/gg-202203-vs-system
Gg 202203 vs system
This commit is contained in:
commit
a73b501469
|
@ -6169,9 +6169,9 @@ The primary difference between a medication statement and a medication administr
|
|||
return _4_1_0;
|
||||
if ("4.2.0".equals(codeString))
|
||||
return _4_2_0;
|
||||
if ("4.3.0-snapshot1".equals(codeString))
|
||||
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return _4_3_0SNAPSHOT1;
|
||||
if ("4.3.0-cibuild".equals(codeString))
|
||||
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return _4_3_0CIBUILD;
|
||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
|
@ -6434,9 +6434,9 @@ public String toCode(int len) {
|
|||
return FHIRVersion._4_1_0;
|
||||
if ("4.2.0".equals(codeString))
|
||||
return FHIRVersion._4_2_0;
|
||||
if ("4.3.0-snapshot1".equals(codeString))
|
||||
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return FHIRVersion._4_3_0SNAPSHOT1;
|
||||
if ("4.3.0-cibuild".equals(codeString))
|
||||
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return FHIRVersion._4_3_0CIBUILD;
|
||||
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
|
@ -6498,9 +6498,9 @@ public String toCode(int len) {
|
|||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
||||
if ("4.2.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_2_0);
|
||||
if ("4.3.0-snapshot1".equals(codeString))
|
||||
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0SNAPSHOT1);
|
||||
if ("4.3.0-cibuild".equals(codeString))
|
||||
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0CIBUILD);
|
||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
|
|
|
@ -3741,8 +3741,8 @@ public class Enumerations {
|
|||
*/
|
||||
MEDICATIONREQUEST,
|
||||
/**
|
||||
* A record of a medication that is being consumed by a patient. A MedicationUsage may indicate that the patient may be taking the medication now or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from sources such as the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains.
|
||||
|
||||
* A record of a medication that is being consumed by a patient. A MedicationUsage may indicate that the patient may be taking the medication now or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from sources such as the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains.
|
||||
|
||||
The primary difference between a medicationusage and a medicationadministration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medicationusage is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the Medication Usage information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information.
|
||||
*/
|
||||
MEDICATIONUSAGE,
|
||||
|
@ -7243,71 +7243,71 @@ public String toCode(int len) {
|
|||
String codeString = ((PrimitiveType) code).asStringValue();
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("0.01".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_01);
|
||||
if ("0.05".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_05);
|
||||
if ("0.06".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_06);
|
||||
if ("0.11".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_11);
|
||||
if ("0.0.80".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_0_80);
|
||||
if ("0.0.81".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_0_81);
|
||||
if ("0.0.82".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_0_82);
|
||||
if ("0.4.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_4_0);
|
||||
if ("0.5.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_5_0);
|
||||
if ("1.0.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_0_0);
|
||||
if ("1.0.1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_0_1);
|
||||
if ("1.0.2".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_0_2);
|
||||
if ("1.1.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_1_0);
|
||||
if ("1.4.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_4_0);
|
||||
if ("1.6.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_6_0);
|
||||
if ("1.8.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_8_0);
|
||||
if ("3.0.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_0_0);
|
||||
if ("3.0.1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_0_1);
|
||||
if ("3.0.2".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_0_2);
|
||||
if ("3.3.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_3_0);
|
||||
if ("3.5.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_5_0);
|
||||
if ("4.0.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_0);
|
||||
if ("4.0.1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1);
|
||||
if ("4.1.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
||||
if ("4.2.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_2_0);
|
||||
if ("4.3.0-snapshot1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0SNAPSHOT1);
|
||||
if ("4.3.0-cibuild".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0CIBUILD);
|
||||
if ("4.4.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_4_0);
|
||||
if ("4.5.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_5_0);
|
||||
if ("4.6.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_6_0);
|
||||
if ("5.0.0-snapshot1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._5_0_0SNAPSHOT1);
|
||||
if ("5.0.0-cibuild".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._5_0_0CIBUILD);
|
||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
if ("0.01".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_01);
|
||||
if ("0.05".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_05);
|
||||
if ("0.06".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_06);
|
||||
if ("0.11".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_11);
|
||||
if ("0.0.80".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_0_80);
|
||||
if ("0.0.81".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_0_81);
|
||||
if ("0.0.82".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_0_82);
|
||||
if ("0.4.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_4_0);
|
||||
if ("0.5.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._0_5_0);
|
||||
if ("1.0.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_0_0);
|
||||
if ("1.0.1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_0_1);
|
||||
if ("1.0.2".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_0_2);
|
||||
if ("1.1.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_1_0);
|
||||
if ("1.4.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_4_0);
|
||||
if ("1.6.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_6_0);
|
||||
if ("1.8.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._1_8_0);
|
||||
if ("3.0.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_0_0);
|
||||
if ("3.0.1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_0_1);
|
||||
if ("3.0.2".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_0_2);
|
||||
if ("3.3.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_3_0);
|
||||
if ("3.5.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._3_5_0);
|
||||
if ("4.0.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_0);
|
||||
if ("4.0.1".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1);
|
||||
if ("4.1.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
||||
if ("4.2.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_2_0);
|
||||
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0SNAPSHOT1);
|
||||
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0CIBUILD);
|
||||
if ("4.4.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_4_0);
|
||||
if ("4.5.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_5_0);
|
||||
if ("4.6.0".equals(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_6_0);
|
||||
if ("5.0.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._5_0_0SNAPSHOT1);
|
||||
if ("5.0.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._5_0_0CIBUILD);
|
||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
public String toCode(FHIRVersion code) {
|
||||
if (code == FHIRVersion._0_01)
|
||||
|
@ -9870,8 +9870,8 @@ public String toCode(int len) {
|
|||
*/
|
||||
MEDICATIONREQUEST,
|
||||
/**
|
||||
* A record of a medication that is being consumed by a patient. A MedicationUsage may indicate that the patient may be taking the medication now or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from sources such as the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains.
|
||||
|
||||
* A record of a medication that is being consumed by a patient. A MedicationUsage may indicate that the patient may be taking the medication now or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from sources such as the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains.
|
||||
|
||||
The primary difference between a medicationusage and a medicationadministration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medicationusage is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the Medication Usage information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information.
|
||||
*/
|
||||
MEDICATIONUSAGE,
|
||||
|
|
|
@ -33,8 +33,10 @@ package org.hl7.fhir.r5.terminologies;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.NoTerminologyServiceException;
|
||||
|
@ -544,71 +546,92 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
|||
|
||||
|
||||
private String systemForCodeInValueSet(String code) {
|
||||
String sys = null;
|
||||
Set<String> sys = new HashSet<>();
|
||||
if (!scanForCodeInValueSet(code, sys)) {
|
||||
return null;
|
||||
}
|
||||
if (sys.size() != 1) {
|
||||
return null;
|
||||
} else {
|
||||
return sys.iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean scanForCodeInValueSet(String code, Set<String> sys) {
|
||||
if (valueset.hasCompose()) {
|
||||
if (valueset.getCompose().hasExclude()) {
|
||||
return null;
|
||||
}
|
||||
// not sure what to do with the
|
||||
// if (valueset.getCompose().hasExclude()) {
|
||||
// return false;
|
||||
// }
|
||||
for (ConceptSetComponent vsi : valueset.getCompose().getInclude()) {
|
||||
if (vsi.hasValueSet()) {
|
||||
return null;
|
||||
}
|
||||
if (!vsi.hasSystem()) {
|
||||
return null;
|
||||
}
|
||||
if (vsi.hasFilter()) {
|
||||
return null;
|
||||
}
|
||||
CodeSystem cs = resolveCodeSystem(vsi.getSystem());
|
||||
if (cs == null) {
|
||||
return null;
|
||||
}
|
||||
if (vsi.hasConcept()) {
|
||||
for (ConceptReferenceComponent cc : vsi.getConcept()) {
|
||||
boolean match = cs.getCaseSensitive() ? cc.getCode().equals(code) : cc.getCode().equalsIgnoreCase(code);
|
||||
if (match) {
|
||||
if (sys == null) {
|
||||
sys = vsi.getSystem();
|
||||
} else if (!sys.equals(vsi.getSystem())) {
|
||||
return null;
|
||||
}
|
||||
for (CanonicalType u : vsi.getValueSet()) {
|
||||
if (!checkForCodeInValueSet(code, u.getValue(), sys)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code);
|
||||
if (cc != null) {
|
||||
if (sys == null) {
|
||||
sys = vsi.getSystem();
|
||||
} else if (!sys.equals(vsi.getSystem())) {
|
||||
return null;
|
||||
} else if (!vsi.hasSystem()) {
|
||||
return false;
|
||||
}
|
||||
if (vsi.hasSystem()) {
|
||||
if (vsi.hasFilter()) {
|
||||
return false;
|
||||
}
|
||||
CodeSystem cs = resolveCodeSystem(vsi.getSystem());
|
||||
if (cs != null) {
|
||||
|
||||
if (vsi.hasConcept()) {
|
||||
for (ConceptReferenceComponent cc : vsi.getConcept()) {
|
||||
boolean match = cs.getCaseSensitive() ? cc.getCode().equals(code) : cc.getCode().equalsIgnoreCase(code);
|
||||
if (match) {
|
||||
sys.add(vsi.getSystem());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code);
|
||||
if (cc != null) {
|
||||
sys.add(vsi.getSystem());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (vsi.hasConcept()) {
|
||||
for (ConceptReferenceComponent cc : vsi.getConcept()) {
|
||||
boolean match = cc.getCode().equals(code);
|
||||
if (match) {
|
||||
sys.add(vsi.getSystem());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (valueset.hasExpansion()) {
|
||||
// Retrieve a list of all systems associated with this code in the expansion
|
||||
List<String> systems = new ArrayList<String>();
|
||||
checkSystems(valueset.getExpansion().getContains(), code, systems);
|
||||
if (systems.size()==1)
|
||||
sys = systems.get(0);
|
||||
if (!checkSystems(valueset.getExpansion().getContains(), code, sys)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return sys;
|
||||
private boolean checkForCodeInValueSet(String code, String uri, Set<String> sys) {
|
||||
ValueSetCheckerSimple vs = getVs(uri);
|
||||
return vs.scanForCodeInValueSet(code, sys);
|
||||
}
|
||||
|
||||
/*
|
||||
* Recursively go through all codes in the expansion and for any coding that matches the specified code, add the system for that coding
|
||||
* to the passed list.
|
||||
*/
|
||||
private void checkSystems(List<ValueSetExpansionContainsComponent> contains, String code, List<String> systems) {
|
||||
private boolean checkSystems(List<ValueSetExpansionContainsComponent> contains, String code, Set<String> systems) {
|
||||
for (ValueSetExpansionContainsComponent c: contains) {
|
||||
if (c.getCode().equals(code)) {
|
||||
if (!systems.contains(c.getSystem()))
|
||||
systems.add(c.getSystem());
|
||||
systems.add(c.getSystem());
|
||||
}
|
||||
if (c.hasContains())
|
||||
checkSystems(c.getContains(), code, systems);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue