Fix an issue in the JPA server if a resource has been previously saved containing vocabulary that is no longer valid. This only really happened if you were using a non-final version of FHIR (e.g. using DSTU3 before it was finalized) but if you were in this situation, upgrading HAPI could cause you to have old codes that no longer exist in your database. This fix prevents these from blocking you from accesing those resources.
This commit is contained in:
parent
e53d747f2b
commit
ef772547c3
|
@ -102,8 +102,7 @@ import ca.uhn.fhir.model.primitive.InstantDt;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.parser.*;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||
import ca.uhn.fhir.rest.method.QualifiedParamList;
|
||||
|
@ -1222,6 +1221,8 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
|
||||
IParser parser = theEntity.getEncoding().newParser(getContext(theEntity.getFhirVersion()));
|
||||
parser.setParserErrorHandler(new LenientErrorHandler(false).setErrorOnInvalidValue(false));
|
||||
|
||||
R retVal;
|
||||
try {
|
||||
retVal = parser.parseResource(resourceType, resourceText);
|
||||
|
|
|
@ -288,6 +288,13 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandWithOpEquals() {
|
||||
ValueSet result = myValueSetDao.expandByIdentifier("http://hl7.org/fhir/ValueSet/doc-typecodes", "");
|
||||
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExpandWithCodesAndDisplayFilterPartialOnFilter() {
|
||||
CodeSystem codeSystem = createExternalCsDogs();
|
||||
|
|
|
@ -49,12 +49,14 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.*;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.*;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.entity.TagTypeEnum;
|
||||
import ca.uhn.fhir.jpa.entity.*;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
|
@ -245,6 +247,37 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we handle content that was previously saved containing vocabulary that
|
||||
* is no longer valid
|
||||
*/
|
||||
@Test
|
||||
public void testResourceInDatabaseContainsInvalidVocabulary() {
|
||||
final Patient p = new Patient();
|
||||
p.setGender(AdministrativeGender.MALE);
|
||||
final IIdType id = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
||||
|
||||
TransactionTemplate tx = new TransactionTemplate(myTxManager);
|
||||
tx.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
|
||||
tx.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
String newContent = myFhirCtx.newJsonParser().encodeResourceToString(p);
|
||||
newContent = newContent.replace("male", "foo");
|
||||
table.setResource(newContent.getBytes(Charsets.UTF_8));
|
||||
table.setEncoding(ResourceEncodingEnum.JSON);
|
||||
myResourceTableDao.save(table);
|
||||
}
|
||||
});
|
||||
|
||||
Patient read = myPatientDao.read(id);
|
||||
String string = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(read);
|
||||
ourLog.info(string);
|
||||
assertThat(string, containsString("value=\"foo\""));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChoiceParamDateEquals() {
|
||||
Encounter enc = new Encounter();
|
||||
|
|
|
@ -67,6 +67,14 @@
|
|||
starting a context up on Android. Thanks to GitHub issue @Jaypeg85 for
|
||||
the pull request!
|
||||
</action>
|
||||
<action type="fix">
|
||||
Fix an issue in the JPA server if a resource has been previously
|
||||
saved containing vocabulary that is no longer valid. This only really
|
||||
happened if you were using a non-final version of FHIR (e.g. using DSTU3
|
||||
before it was finalized) but if you were in this situation, upgrading HAPI
|
||||
could cause you to have old codes that no longer exist in your database. This
|
||||
fix prevents these from blocking you from accesing those resources.
|
||||
</action>
|
||||
</release>
|
||||
<release version="2.4" date="2017-04-19">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue