FHIR STU3 ListResource.ListEntryComponent.getItemTarget()函数无法识别引用的资源

时间:2017-05-17 09:52:26

标签: hl7-fhir hapi-fhir

我将我的代码转换为FHIR STU3,并且我试图通过调用ListEntryComponent上的getItemTarget()来获取List.entry [x] .item.reference引用的组织资源,但它尽管资源存在,但始终返回NULL(请参阅if (organizations.get(i).getItemTarget()))。什么可能是错的?

以下是我使用的代码的一部分:

if (entries0.get(e).getReference().equals("List/g1")) {

        //get the organizations list
        var organizations =  entries0.get(e).getResource().getEntry();

        for (var i = 0; i < organizations.size(); i++) {

            var orgReference = organizations.get(i).getItem();              

            if (orgReference.hasReference()) {

                //if the reference resolves, Organization.type must be present
                if (organizations.get(i).getItemTarget() && 
                    organizations.get(i).getItemTarget().getResourceType() == fhirPackageStruct.ResourceType.Organization) {

                    list1OrgTypeSystem = organizations.get(i).getItemTarget().getTypeFirstRep().getCodingFirstRep().getSystem().equals("http://spms.min-saude.pt/pds/codings/nn_organization_types");
                    throwIfTrue(!list1OrgTypeSystem,'Composition.section[0].entry['+e+'].entry['+i+'].item ' + orgReference.getReference(), "INVALID Organization.type.system. Expected: http://spms.min-saude.pt/pds/codings/nn_organization_types");
                }
                else {
                    throw 'srcTransf validateNNDocumentProfile: não foi encontrado o recurso referenciado por ' + orgReference.getReference() + ' da lista de instituições de seguimento da grávida.';
                }

                orgReference = orgReference.getReference().toLowerCase();
            }               

            if (orgReference.equals("organization/hospital")) {

                section0HospMotive = organizations.get(i).getItemTarget().getExtension().isEmpty();
                throwIfTrue(section0HospMotive,'Composition.section[0].entry['+e+'].entry['+i+'].item (Organization/Hospital)', "MISSING FOLLOWUP MOTIVE EXTENSION");
            }
        }   
}
你能帮帮我吗?谢谢!!

1 个答案:

答案 0 :(得分:1)

getFOOTarget()方法有点令人困惑,它们实际上并未被使用,可能会被删除。

您需要将getItemTarget()替换为getItem().getResource()