示例#1
0
    public void LoadInfoXML(string filename)
    {
        Serializer<PatientInfo> serializer = new Serializer<PatientInfo>();
        Info = serializer.Load(filename);
        Info.Debug();
		
		// setup the info.startingDateTime
		
		Info.startingDateTime = DateTime.Now;
		if (Info.startingTime != ""){
			// look for TraumaBrain and set the starting time there
			Brain tb = FindObjectOfType(typeof(Brain)) as Brain;
			if (tb != null){
				tb.SetStartTime(Info.startingTime);	
			}
			
			// make one for us, maybe we don't really need our own...
			string[] ss = Info.startingTime.Split (':')	;
			if (ss.Length == 2){
				int hours = 0;
				int mins = 0;
				int.TryParse(ss[0],out hours);
				int.TryParse(ss[1],out mins);
				TimeSpan ts = new TimeSpan(hours, mins, 0);
				Info.startingDateTime = Info.startingDateTime.Date + ts;
			}
		}

        // initialize initial patient vitals
        Vitals = new PatientVitals();
        Vitals.Set(Info.initialVitalState, 0.0f);
        VitalsMgr.GetInstance().SetCurrent(Vitals);
        // start behavior, null is nothing
        VitalsBehaviorManager.GetInstance().AddBehavior(Info.initialVitalsBehavior);
		VitalsBehaviorManager.GetInstance().StateChange += VitalsBehaviorChange;

		// lets create and load up the PatientRecords structure with this data
		if (PatientRecords == null){
			PatientRecords = new List<PatientRecord>();
		}
		Record = new PatientRecord();
		Record.Name = "filename"; //we currently only ever have one
		Record.Info = Info;
		Record.XRayRecords = new List<ScanRecord>();
		Record.FastRecords = new List<ScanRecord>();
		Record.CTRecords = new List<ScanRecord>();


		// load up the list of records
		Serializer<ScanRecord> scanSerializer = new Serializer<ScanRecord>();
		foreach (string recordPath in Info.scanRecords){
		//	string pathname = "XML/Patient/Records"+recordPath.Replace (".xml","");
			ScanRecord record = scanSerializer.Load(recordPath);
			LoadScanRecord( record );
		}
		
		// set XRAY images // deprecate these !!!  use the Record.XrayRecords, get by name.
		ChestXRAY = Info.chestXRAY;
		PelvicXRAY = Info.pelvicXRAY;

		gcs_eyes = Info.gcsEyes;
		gcs_verbal = Info.gcsVerbal;
		gcs_motor = Info.gcsMotor;
		gcs_total = Info.gcsTotal;
/*
		
		ScanRecord chestXrayRecord = new ScanRecord();
		chestXrayRecord.Name = "chest";
		chestXrayRecord.Region = "Chest";
		chestXrayRecord.Filename = Info.chestXRAY;
		Record.XRayRecords.Add (chestXrayRecord);

//		CreateStringXML( Info.fast);

		ScanRecord pelvicXrayRecord = new ScanRecord();
		pelvicXrayRecord.Name = "pelvis";
		pelvicXrayRecord.Region = "Pelvis";
		pelvicXrayRecord.Filename = Info.pelvicXRAY;	
		Record.XRayRecords.Add (pelvicXrayRecord);
		
		// make assumption about the order of fast filenames
		// perihepatic, perisplenic, pelvis, pericardium, chest
		ScanRecord perihepaticFastRecord = new ScanRecord();
		perihepaticFastRecord.Name = "perihepatic";
		perihepaticFastRecord.Region = "Perihepatic";
		perihepaticFastRecord.Filename = Info.fast[0];
		perihepaticFastRecord.Thumbnail = Info.fastThumbnail[0];
		Record.FastRecords.Add(perihepaticFastRecord);
		ScanRecord perisplenicFastRecord = new ScanRecord();
		perisplenicFastRecord.Name = "perisplenic";
		perisplenicFastRecord.Region = "Perisplenic";
		perisplenicFastRecord.Filename = Info.fast[1];
		perisplenicFastRecord.Thumbnail = Info.fastThumbnail[1];
		Record.FastRecords.Add(perisplenicFastRecord);
		ScanRecord pelvisFastRecord = new ScanRecord();
		pelvisFastRecord.Name = "pelvis";
		pelvisFastRecord.Region = "Pelvis";
		pelvisFastRecord.Filename = Info.fast[2];
		pelvisFastRecord.Thumbnail = Info.fastThumbnail[2];
		Record.FastRecords.Add(pelvisFastRecord);
		ScanRecord pericardiumFastRecord = new ScanRecord();
		pericardiumFastRecord.Name = "pericardium";
		pericardiumFastRecord.Region = "Pericardium";
		pericardiumFastRecord.Filename = Info.fast[3];
		pericardiumFastRecord.Thumbnail = Info.fastThumbnail[3];
		Record.FastRecords.Add(pericardiumFastRecord);
		if (Info.fast.Count > 4){
			ScanRecord chestFastRecord = new ScanRecord();
			chestFastRecord.Name = "chest";
			chestFastRecord.Region = "Chest";
			chestFastRecord.Filename = Info.fast[4];
			chestFastRecord.Thumbnail = Info.fastThumbnail[4];
			Record.FastRecords.Add(chestFastRecord);
		}
		// load CT results
		// make assumption about the order of fast filenames
		// brain, cspine, chest, abdomen, tlspine
		ScanRecord brainCTRecord = new ScanRecord();
		brainCTRecord.Name = "brain";
		brainCTRecord.Region = "Brain";
		brainCTRecord.Filename = Info.CT[0];
		brainCTRecord.Thumbnail = Info.CTThumbnail[0];
		Record.CTRecords.Add(brainCTRecord);
		ScanRecord cspineCTRecord = new ScanRecord();
		cspineCTRecord.Name = "cspine";
		cspineCTRecord.Region = "C-Spine";
		cspineCTRecord.Filename = Info.CT[1];
		cspineCTRecord.Thumbnail = Info.CTThumbnail[1];
		Record.CTRecords.Add(cspineCTRecord);
		ScanRecord chestCTRecord = new ScanRecord();
		chestCTRecord.Name = "chest";
		chestCTRecord.Region = "Chest";
		chestCTRecord.Filename = Info.CT[2];
		chestCTRecord.Thumbnail = Info.CTThumbnail[2];
		Record.CTRecords.Add(chestCTRecord);
		ScanRecord abdomenCTRecord = new ScanRecord();
		abdomenCTRecord.Name = "abdomen";
		abdomenCTRecord.Region = "Abdomen";
		abdomenCTRecord.Filename = Info.CT[3];
		abdomenCTRecord.Thumbnail = Info.CTThumbnail[3];
		Record.CTRecords.Add(abdomenCTRecord);
		ScanRecord tlspineCTRecord = new ScanRecord();
		tlspineCTRecord.Name = "tlspine";
		tlspineCTRecord.Region = "TL-Spine";
		tlspineCTRecord.Filename = Info.CT[4];
		tlspineCTRecord.Thumbnail = Info.CTThumbnail[4];
		Record.CTRecords.Add(tlspineCTRecord);
*/
		PatientRecords.Add(Record);
		// now these can be accessed with Patient.GetPatientRecord().GetXRay("name") etc



        // set initial state and seektimes
        // load decisions
        foreach( string decision in Info.decisions )
            DecisionMgr.GetInstance().LoadXML(decision);
    }