-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DocumentReference 30_40 converter produces NPE on valid DocumentReference.status element #1799
Comments
This may be limited to The general case appears to be converting an unpopulated element of type |
@dotasek I think we've discussed this before - it does need a sweeping fix for this, to check if the enum .getValue() is null before doing the switch. Is my memory correct? |
@grahamegrieve I think what was done before was this: https://github.com/hapifhir/org.hl7.fhir.core/pull/1697/files, which is also involved null handling, but not what this fix is asking for. I'll look into it. |
@grahamegrieve a structural search of this shows that these specific switches ( Some are covered with this kind of null check, which I believe is the correct approach: if (src.getValue() == null) {
tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL);
} else {
switch (src.getValue()) {
//...
}
} I will not be manually sorting through each of the 2,369 instances so I'm going to try to refine those results. On my first look, most of the missing null checks are in the resource conversions (e.g. |
For clarity, I believe the correct pattern for the fix would be the following, demonstrated on DocumentReference30_40.convertReferredDocumentStatus:
If that's correct, I can work on applying it, once I sort out how to find all the unchecked switches. |
yes we're sure not manually reviewing >2000 references. Whatever we do is going to be done by code but setting it to .NULL feels like a problem to me. It's not .NULL in the source, it's null, and we should set it to that value. It's supposed to be the same thing, but .NULL is not consistently handled - I've fixed bugs to do with that before, and I'm not even sure I should have defined them now |
Hm. So what do we do with all the existing conversions that convert to |
@tadgh @jamesagnew: Grahame's response regarding the correct conversion behaviour came in Zulip:
Intuitively I think the places where it does something like this are incorrect: if (src.getValue() == null) {
tgt.setValue(some.hl7.model.Enumeration.NULL);
} else {
switch (src.getValue()) {
//..
}
} I think the correct way to be performing this is the use an actual if (src.getValue() == null) {
tgt.setValue(null);
} else {
switch (src.getValue()) {
//..
}
} This change will touch a lot of code, but I'm not sure if the impact will just be a few gently breaking tests that will just need an expected field removed or something worse. |
theDocumentReference.docStatus = null
theDocumentReference.getDocStatusElement().addExtension(someExtension)
VersionConvertorFactory_30_40.convertResource(theDocumentReference);
The text was updated successfully, but these errors were encountered: