생활사건에서 업데이트 구동

이 절에서는 생활사건 스크립트에서 제출된 데이터를 처리하기 위해 개발해야 하는 아티팩트에 대해 설명합니다. 이 절에서는 다음에 대해 설명합니다.

업데이트를 위해 데이터 허브가 작동하는 방식

시민 데이터 허브는 데이터 허브 컨텍스트를 읽기용뿐 아니라 업데이트용으로도 인식하고 있습니다. 일반적으로 생활사건은 동일한 생활사건과 연관된 읽기 및 업데이트에 동일한 데이터 허브 컨텍스트 이름을 사용하므로 "CitizenBoughtCar" 컨텍스트는 "CitizenBoughtCar" 생활사건 스크립트를 사전에 입력하는 아티팩트 세트 외에도 "CitizenBoughtCar" 생활사건 스크립트를 완료할 때 시민의 데이터에 대한 업데이트를 처리하는 아티팩트 세트에 대해서도 설명합니다.

지정된 시민 데이터 허브 컨텍스트의 업데이트 조작을 수행하면 서로 다른 여러 개별 엔티티를 단일 트랜잭션으로 업데이트할 수 있습니다. 스크립트 제출 후 데이터 허브에 제공된 아티팩트는 다음과 같습니다.

데이터 저장소 루트 엔티티는 생활사건 IEG 스크립트를 통해 업데이트된 데이터 저장소의 루트입니다. 차이 명령은 IEG 스크립트를 실행하기 전에 이 스크립트에 전달된 데이터 저장소와 이 저장소의 차이점을 설명하는 엔티티입니다. 즉, 생활사건 스크립트를 실행한 결과로 데이터가 변경되는 방식에 대해 설명합니다. 이러한 차이는 다음 세 가지 기본 유형으로 구분됩니다.

이 세 유형 중 작성과 업데이트가 가장 일반적입니다. 사용자가 생활 사건 스크립트의 항목을 제거할 수 있도록 하는 방법은 일반적으로 좋지 않습니다. 표준 생활사건은 여러 작성으로 이루어진다는 특징이 있는 반면에 왕복 생활사건은 작성과 업데이트가 혼합되어 있습니다. 차이 명령은 생활사건이 제출된 다음 Life Event Broker가 자동으로 생성합니다.

데이터 허브 업데이트 조작이 보류 중인 케이스에 대한 증거 엔티티를 자동으로 업데이트하게 하려면 데이터 허브 업데이트 변환을 지정해야 합니다. 비증거 엔티티를 업데이트해야 하는 경우 업데이트 프로세서를 개발해야 합니다. 이러한 업데이트 프로세서를 개발하려면 Java 코드를 작성해야 합니다.

업데이트를 위해 변환 작성

읽기 변환 등의 업데이트 변환은 간단한 XSLT 구문을 사용하여 지정합니다. 업데이트 변환을 쓰려면 작성자가 입력 XML과 출력 증거 XML 형식을 모두 이해해야 합니다. 다음 예제는 "CitizenHavingABaby" 생활사건과 관련하여 빌드됩니다. 이 생활사건을 사용하여 출산 예정임을 보고할 수 있습니다. 태아의 수(예: 2인 경우 쌍둥이 예상)를 입력할 수 있습니다. 출산 예정일도 입력하고 태아의 아버지를 지명할 수 있습니다. 아버지는 기존 케이스 참여자이거나 완전히 다른 사람일 수 있습니다. 후자의 경우 이름, 주소, 주민등록번호 등을 입력해야 합니다. 이 생활사건은 "왕복" 생활사건이 아니므로 기존 증거의 업데이트가 아니라 새 증거의 작성과 관련됩니다. 업데이트 변환에 입력된 사항은 데이터 저장소 차이 명령의 XML 기반 설명입니다. "CitizenHavingABaby"의 샘플 차이 명령 XML은 아래 설명되어 있습니다.

<update>
  <diff diffType="NONE" entityType="Application">
    <diff diffType="NONE" entityType="Person" identifier="102">
      <diff diffType="CREATE" entityType="Pregnancy">
        <attribute name="numChildren">1</attribute>
        <attribute name="dueDate">20110528</attribute>
        <attribute name="curamDataStoreUniqueID">385</attribute>
      </diff>
    </diff>
    <diff diffType="UPDATE" entityType="Person" identifier="101">
      <attribute name="isFatherToUnbornChild">true</attribute>
      <attribute name="curamDataStoreUniqueID">399</attribute>
    </diff>
  </diff>
</update>

차이 명령 XML은 데이터 저장소 XML과 노드별로 대응합니다. 각 diff 노드는 IEG 스크립트를 실행하여 해당 데이터 저장소 엔티티를 수정하는 방식에 대해 설명합니다. curamDataStoreUniqueID 속성은 변경된 데이터 저장소 엔티티를 식별합니다. diffType 속성은 변경 유형(예: CREATE, UPDATE, NONE 또는 REMOVE)을 식별합니다. 나열된 속성은 변경되었거나 각 데이터 저장소 엔티티에 추가된 속성입니다. 위의 예제에서는 사용자가 Linda Smith(관련 역할 ID 102)에게 한 명의 태아가 있으며 2011년 5월 28일이 출산일인 임신 사실을 등록했습니다. 아버지는 James Smith(관련 역할 ID 101)로 나열되어 있습니다. 차이 명령 XML에 대한 자세한 정보는 차이 명령 XML 스키마 절의 스키마를 참조하십시오. XML을 업데이트할 때 사용하는 몇 가지 추가 속성과 요소가 아래 설명되어 있습니다.

그림 1. 업데이트 포함 증거 XML
<?xml version="1.0" encoding="UTF-8"?>
  <client-data>
    <client localID="102">
      <evidence>
        <entity type="ET10074" action="CREATE" localID="">
          <attribute name="numChildren">1</attribute>
          <attribute name="dueDate">20110528</attribute>
          <entity-data entity-data-type="role">
            <attribute type="LG"/>
            <attribute roleParticipantID="102"/>
            <attribute 
              entityRoleIDFieldName="caseParticipantRoleID"/>
          </entity-data>
          <entity-data entity-data-type="role">
            <attribute type="FAT"/>
              <attribute roleParticipantID="101"/>
              <attribute participantType="RL7"/>
              <attribute
                entityRoleIDFieldName="fahCaseParticipantRoleID"/>
            </entity-data>
          <entity type="ET10125" action="CREATE">
            <attribute name="comments"> Unborn child 1</attribute>
            <entity-data entity-data-type="role">
              <attribute type="UNB"/>
              <attribute roleParticipantID="102"/>
              <attribute 
                entityRoleIDFieldName="caseParticipantRoleID"/>
            </entity-data>
          </entity>
        </entity>
      </evidence>
    </client>
  </client-data>

기본 증거에 수행할 조치(예: 증거 작성 또는 기존 증거 업데이트)에 대해 설명하는 action 속성이 사용된 방식을 참고하십시오. 다음 절은 <entity-data> 요소의 의미에 대해 설명합니다. 위의 차이 XML을 위의 증거 XML로 변환하는 데 사용하는 XSLT의 예제는 아래 설명되어 있습니다.

<?xml version="1.0" encoding="UTF-8"?>
<!-- 이 스크립트는 XMLApplicationBuilder가 빌드한 결과에서 -->
<!-- 모든 자원 관련 엔티티를 뽑아 복사합니다. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:x="http://www.curamsoftware.com/
      schemas/DifferenceCommand"
    xmlns:fn="http://www.w3.org/2006/xpath-functions"
    version="2.0">
    <xsl:output indent="yes"/>   
    <xsl:strip-space elements="*"/>
    <xsl:template match="update">
        <xsl:for-each select="./diff[@entityType='Application']">
            <xsl:element name="client-data">
                <xsl:apply-templates/>
            </xsl:element>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="diff[@entityType='Person']">
        <xsl:element name="client">
            <xsl:attribute name="localID">
                <xsl:value-of select="./@identifier"/>
            </xsl:attribute>
            <xsl:element name="evidence">
                <xsl:apply-templates/>
            </xsl:element>
        </xsl:element>
    </xsl:template>
    <xsl:template match="diff[@entityType='Pregnancy']">
        <xsl:element name="entity">
            <xsl:attribute name="type">ET10074</xsl:attribute>
            <xsl:attribute name="action">
                <xsl:value-of select="./@diffType"/>
            </xsl:attribute>
            <xsl:attribute name="localID">
                <xsl:value-of select="./@identifier"/>
            </xsl:attribute>
            <xsl:for-each select="./attribute">
                <xsl:copy-of select="."/>
            </xsl:for-each>
            <xsl:element name="entity-data">
                <xsl:attribute name="entity-data-type">
                  role
                </xsl:attribute>
                <xsl:element name="attribute">		  
                    <xsl:attribute name="type">LG</xsl:attribute>
                </xsl:element>
                <xsl:element name="attribute">
                    <xsl:attribute name="roleParticipantID">		  
                        <xsl:value-of select="../@identifier"/>
                    </xsl:attribute>
                </xsl:element>
                <xsl:element name="attribute">
                    <xsl:attribute name="entityRoleIDFieldName">
                      caseParticipantRoleID
                    </xsl:attribute>
                </xsl:element>
            </xsl:element>
            <xsl:element name="entity-data">
                <xsl:attribute name="entity-data-type">
                  role
                </xsl:attribute>
                <xsl:element name="attribute">		  
                    <xsl:attribute name="type">FAT</xsl:attribute>
                </xsl:element>
                <xsl:for-each select=
                "../../diff[@entityType='Person']/attribute[
                  @name='isFatherToUnbornChild' 
                  and ./text()='true']">                 
                    <!-- 가족 구성원이 아버지인 경우 -->
                    <!-- 참여자 ID 복사 -->
                    <xsl:element name="attribute">
                      <xsl:attribute name="roleParticipantID">
                          <xsl:value-of select="
                            ../@identifier"/>
                        </xsl:attribute>
                    </xsl:element>
                </xsl:for-each>
                <!-- 부재 부모의 세부사항 복사 -->
                <xsl:call-template name="absentFather"/>
                <xsl:element name="attribute">
                    <xsl:attribute name="entityRoleIDFieldName">
                      fahCaseParticipantRoleID
                    </xsl:attribute>
                </xsl:element>
            </xsl:element>
            <xsl:variable name="numBabies">
                <xsl:value-of select="attribute[
                  @name='numChildren'
                  ]/text()"/>
            </xsl:variable>
            <xsl:call-template name="unbornChildren">
                <xsl:with-param name="count" select="$numBabies"/>
            </xsl:call-template>
        </xsl:element>
    </xsl:template>
    
    <xsl:template name="unbornChildren">
        <xsl:param name="count" select="1"/>
        <xsl:if test="$count > 0">
            <xsl:element name="entity">
                <xsl:attribute name="type">ET10125</xsl:attribute>
                <xsl:attribute name="action">
                    <xsl:value-of select="./@diffType"/>
                </xsl:attribute>
                <xsl:element name="attribute">
                    <xsl:attribute name="name">
                      comments
                    </xsl:attribute>
                    Unborn child <xsl:value-of select="$count"/>
                </xsl:element>
                <xsl:element name="entity-data">
                    <xsl:attribute name="entity-data-type">
                      role
                    </xsl:attribute>
                    <xsl:element name="attribute">		  
                        <xsl:attribute name="type">
                          UNB
                        </xsl:attribute>
                    </xsl:element>
                    <xsl:element name="attribute">
                        <xsl:attribute name=
                           "roleParticipantID">		  
                            <xsl:value-of select="
                              ../@identifier"/>
                        </xsl:attribute>
                    </xsl:element>
                    <xsl:element name="attribute">
                        <xsl:attribute name=
                          "entityRoleIDFieldName">
                          caseParticipantRoleID
                        </xsl:attribute>
                    </xsl:element>
                </xsl:element>
            </xsl:element>
            <xsl:call-template name="unbornChildren">
                <xsl:with-param name="count" select="$count - 1"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    
    <xsl:template name="absentFather">    
        <xsl:element name="attribute">
            <xsl:attribute name="participantType">
                <xsl:text>RL7</xsl:text>
            </xsl:attribute>
        </xsl:element>                  
        
        <xsl:if  test="attribute[@name='fahFirstName']">
            <xsl:element name="attribute">
                <xsl:attribute name="firstName">
                    <xsl:value-of select="attribute[
                      @name='fahFirstName'
                    ]/text()"/>
                </xsl:attribute>
            </xsl:element>                            
        </xsl:if>

        <!-- 기타 개인 세부사항(주민등록번호, 생년월일) -->
        <!-- 맵핑 -->
   
        <xsl:if  test="diff[@entityType='ResidentialAddress']">
            <xsl:if  test="diff[
              @entityType='ResidentialAddress']/attribute[
              @name='street1']">
                <xsl:element name="attribute">
                    <xsl:attribute name="street1">
                        <xsl:value-of select=
                        "diff[
                        @entityType='ResidentialAddress']
                          /attribute[
                        @name='street1']/text()"/>
                    </xsl:attribute>
                </xsl:element>         
            </xsl:if>
            <!-- 거주지 주소의 기타 부분 맵핑 -->
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="*">
        <!-- 아무 작업도 수행하지 않음 -->
    </xsl:template>
</xsl:stylesheet>

새 케이스 참여자를 작성하는 변환 작성

증거에 익숙한 독자는 증거 엔티티가 제3자를 참조하는 경우가 많다는 사실을 알게 됩니다. 예를 들어, 임신 증거는 케이스 참여자 역할을 통해 아버지를 참조합니다. 연관된 아버지는 개인이나 가망성이 높은 사람일 수 있습니다. 기타 증거 유형(예: 학생)은 대리인 케이스 참여자 역할로 입력된 학교를 참조할 수 있습니다.

증거 XML 스키마는 시민 데이터 허브에 특수 처리 지시시항을 제공하는 데 사용할 수 있는 <entity-data>라는 일반 요소를 제공합니다. 처리 유형은 지정된 <entity-data-type>에 따라 다릅니다. Cúram은 entity-data-type 역할에 대해 특수 프로세서를 제공합니다. 이 역할 엔티티 데이터 프로세서를 사용하여 새 케이스 참여자 역할을 작성하거나 기존 케이스 참여자의 기존 케이스 참여자 역할을 참조할 수 있습니다. 이전 절에 나열된 증거 XML 결과를 참조할 때 type으로 표시된 속성을 사용하여 케이스 참여자 역할 유형(예: 아버지의 경우 FAT, 태아의 경우 UNB)을 나타냅니다. 여기에 제공된 값은 CaseParticipantRoleType 코드 테이블의 코드 테이블 값이어야 합니다. roleParticipantID는 시스템에 있는 기존 참여자의 ConcernRoleID를 나타냅니다. 이 ID가 제공되면 시스템이 새 케이스 참여자를 작성하지 않고 이 ID의 케이스 참여자를 재사용합니다. entityRoleIDFieldName은 해당 증거 엔티티의 필드 이름입니다. 예를 들어, 임신 증거 엔티티의 경우 이 필드의 이름은 fahCaseParticipantRoleID입니다. 새 참여자를 작성해야 하는 경우 역할 엔티티 데이터 프로세서가 다음 필드를 지원합니다.

비증거 엔티티 업데이트

이전 절에서는 여러 통합 케이스에서 자동으로 업데이트를 증거 항목에 맵핑하도록 생활사건을 구성하는 방법에 대해 설명했습니다. 경우에 따라 생활사건이 비증거 엔티티(예: 거주지 주소, 직장 또는 기타 고객에 따라 다른 비증거 엔티티)를 업데이트해야 합니다. 일반적으로 이러한 엔티티는 여러 케이스에서 공유합니다. 일반적으로 이러한 엔티티는 증거 엔티티와 동일하게 제어된 생활 주기를 따르지 않습니다. 증거는 다음과 같은 여러 장점이 있습니다.

비증거 엔티티는 이러한 장점과 보호 장치가 없습니다. 특히 변경사항이 여러 케이스에 동시에 적용되는 경우, 분석가가 생활사건을 기반으로 비증거 엔티티를 업데이트하도록 결정할 때 신중을 기해야 합니다. 비증거 엔티티를 업데이트할 수 있지만 언제나 코드를 사용자 정의해야 합니다. 이러한 기능을 디자인할 때, 시스템에 변경사항을 적용하기 전에 한 명 이상의 기관 직원이 수동으로 변경사항을 승인하도록 하는 보호 장치를 포함하도록 적극 권장합니다.