UNPKG

@dvsa/smc-encounter-schema

Version:

Schemas required for Encounter submission as well as custom validators ## Developing ### Pre-requisites

1 lines 2.3 kB
'use strict';var classValidator=require('class-validator');var y=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var n=(t,e)=>y(t,"name",{value:e,configurable:true});var i=(t,e,E,r)=>{for(var o=r>1?void 0:r?A(e,E):e,p=t.length-1,u;p>=0;p--)(u=t[p])&&(o=(r?u(e,E,o):u(o))||o);return r&&o&&y(e,E,o),o};var m=class t{static{n(this,"CurrentEncounterLevel");}static instance;level;officerType;requestType;constructor(){this.level=1,this.officerType="ANY",this.requestType="C";}static getInstance(){return t.instance||(t.instance=new t),t.instance}getEncounterType(){return this.level}setEncounterType(e){this.level=e;}getExaminerOfficerType(){return this.officerType}setExaminerOfficerType(e){this.officerType=e;}getRequestType(){return this.requestType}setRequestType(e){this.requestType=e;}isDeletedEncounter(){return this.requestType==="D"}};var l=class{validate(e,E){let r=E.constraints[0],o=m.getInstance(),p=o.getEncounterType(),u=o.getExaminerOfficerType();return r.level===0||r.exceptions?.includes(p)||r.level!==void 0&&r.level>p||r.roles?.length&&!r.roles.includes(u)&&!r.roles.includes("ANY")?true:e==null?false:typeof e=="string"?r.allowEmpty?true:e.trim().length>0:Array.isArray(e)?e.length===0?false:e.every((O,C)=>O==null?false:Object.entries(O).every(([x,f])=>typeof f=="string"?f.trim().length>0:f!=null)):true}};n(l,"MandatoryFieldConstraint"),l=i([classValidator.ValidatorConstraint({name:"MandatoryField",async:false})],l);function s(t,e){return (E,r)=>{classValidator.registerDecorator({name:"MandatoryField",target:E.constructor,propertyName:r,constraints:[t],options:e,validator:l});}}n(s,"MandatoryField");var a=class{static{n(this,"CommonDeletion");}description;deletionMarker};i([s({level:4},{groups:["createEncounter"]})],a.prototype,"description",2),i([s({level:4},{groups:["createEncounter"]})],a.prototype,"deletionMarker",2);var c=class extends a{static{n(this,"CommonCode");}code;name};i([s({level:4},{groups:["createEncounter"]})],c.prototype,"code",2),i([s({level:4},{groups:["createEncounter"]})],c.prototype,"name",2);var d=class extends c{static{n(this,"TextType");}withinEncounter;sortSequence};i([s({level:4},{groups:["createEncounter"]})],d.prototype,"withinEncounter",2),i([classValidator.IsOptional()],d.prototype,"sortSequence",2);exports.TextType=d;